@farm.js/core 0.1.73 → 0.1.74

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 (362) hide show
  1. package/dist/{agent-mcp-handler-RK7LDYEL.mjs → agent-mcp-handler-HX4F4VKN.mjs} +4 -4
  2. package/dist/{agent-mcp-handler-VBCA3WZ6.cjs → agent-mcp-handler-NRIL4JBC.cjs} +5 -5
  3. package/dist/{agent-mcp.d-PvEf-1mi.d.mts → agent-mcp.d-BEhDfdWc.d.mts} +1 -1
  4. package/dist/{agent-mcp.d-D_gHjCAE.d.ts → agent-mcp.d-CX8_oOT_.d.ts} +1 -1
  5. package/dist/agent-runtime.cjs +4 -4
  6. package/dist/agent-runtime.d.mts +4 -4
  7. package/dist/agent-runtime.d.ts +4 -4
  8. package/dist/agent-runtime.mjs +3 -3
  9. package/dist/{analyzer-MFYCJT75.mjs → analyzer-2K35LIQZ.mjs} +2 -2
  10. package/dist/analyzer-6EOYURMV.cjs +16 -0
  11. package/dist/api/client.d.mts +3 -3
  12. package/dist/api/client.d.ts +3 -3
  13. package/dist/api/client.native.d.mts +4 -4
  14. package/dist/api/client.native.d.ts +4 -4
  15. package/dist/api/node.cjs +9 -8
  16. package/dist/api/node.d.mts +6 -6
  17. package/dist/api/node.d.ts +6 -6
  18. package/dist/api/node.mjs +8 -7
  19. package/dist/api/route-manager.cjs +11 -9
  20. package/dist/api/route-manager.d.mts +9 -7
  21. package/dist/api/route-manager.d.ts +9 -7
  22. package/dist/api/route-manager.mjs +10 -8
  23. package/dist/api/runtime.cjs +8 -7
  24. package/dist/api/runtime.d.mts +5 -5
  25. package/dist/api/runtime.d.ts +5 -5
  26. package/dist/api/runtime.mjs +7 -6
  27. package/dist/{api-client.d-Bp35zMqR.d.mts → api-client.d-CyVmI4Di.d.mts} +2 -2
  28. package/dist/{api-client.d-CFI_xL0V.d.ts → api-client.d-DrTM7BdH.d.ts} +2 -2
  29. package/dist/api.cjs +13 -11
  30. package/dist/api.d.mts +9 -9
  31. package/dist/api.d.ts +9 -9
  32. package/dist/api.mjs +12 -10
  33. package/dist/{app-manifest.d-CN7cEWHX.d.mts → app-manifest.d-BcXt2yCx.d.mts} +10 -1
  34. package/dist/{app-manifest.d-BpVTg43i.d.ts → app-manifest.d-CVEx1CFB.d.ts} +10 -1
  35. package/dist/app-markdown.cjs +8 -4
  36. package/dist/app-markdown.d.mts +6 -6
  37. package/dist/app-markdown.d.ts +6 -6
  38. package/dist/app-markdown.mjs +7 -3
  39. package/dist/{app.d-DO4PTCWm.d.ts → app.d-B6i8CSrx.d.ts} +30 -4
  40. package/dist/{app.d-BFWzAdTe.d.mts → app.d-DowzSmT5.d.mts} +30 -4
  41. package/dist/cache.cjs +2 -2
  42. package/dist/cache.d.mts +8 -0
  43. package/dist/cache.d.ts +8 -0
  44. package/dist/cache.mjs +1 -1
  45. package/dist/chunk-2DOI6HLJ.cjs +284 -0
  46. package/dist/chunk-2GQBBOFH.mjs +76 -0
  47. package/dist/{chunk-5LOARKDP.cjs → chunk-2TZ3F6TN.cjs} +29 -17
  48. package/dist/{chunk-TDCP3Z4T.cjs → chunk-35GBGSQZ.cjs} +3 -3
  49. package/dist/{chunk-VPETSSWN.cjs → chunk-3BUJIPKE.cjs} +2 -2
  50. package/dist/{chunk-Y5LEPEVH.mjs → chunk-3ODLJRA6.mjs} +1 -1
  51. package/dist/{chunk-DMAP4RND.cjs → chunk-3OMLZLDE.cjs} +54 -16
  52. package/dist/{chunk-VNBDN5W2.cjs → chunk-47ZDUDN5.cjs} +64 -27
  53. package/dist/{chunk-2W4GNXGX.cjs → chunk-4AB62NMW.cjs} +2 -2
  54. package/dist/{chunk-HDPT6OYE.cjs → chunk-4M5ESTJ2.cjs} +10 -2
  55. package/dist/{chunk-TAU3OF5B.cjs → chunk-56HHUSR5.cjs} +420 -337
  56. package/dist/chunk-5XD2ULJG.mjs +114 -0
  57. package/dist/{chunk-JX5VOLAV.cjs → chunk-65OS2TOT.cjs} +4 -4
  58. package/dist/{chunk-7GMBETHM.mjs → chunk-6JEXH7N6.mjs} +1 -1
  59. package/dist/{chunk-TY5KCYDE.mjs → chunk-72NTEYCX.mjs} +10 -3
  60. package/dist/{chunk-KDOZORJD.cjs → chunk-737MIVX3.cjs} +22 -22
  61. package/dist/{chunk-ROCF6UQD.cjs → chunk-77SVUQM5.cjs} +74 -17
  62. package/dist/{chunk-CKQAQFF6.mjs → chunk-7RKHXF4P.mjs} +2 -2
  63. package/dist/{chunk-GJEC5S4V.mjs → chunk-7VCLTNED.mjs} +1 -1
  64. package/dist/{chunk-CLEWORVY.cjs → chunk-ACAEFEOH.cjs} +38 -41
  65. package/dist/{chunk-OBYM5S5G.mjs → chunk-AL6E63FZ.mjs} +2 -2
  66. package/dist/{chunk-DQ2DI3Y7.mjs → chunk-AO5IRA2N.mjs} +2 -2
  67. package/dist/{chunk-CYRIIVD4.mjs → chunk-AU5UPNOD.mjs} +2 -2
  68. package/dist/{chunk-Z3IN6GEX.mjs → chunk-B3XY6FMC.mjs} +69 -12
  69. package/dist/{chunk-U7VH3Q5E.cjs → chunk-B5WZP3T3.cjs} +15 -2
  70. package/dist/{chunk-IBVN7SW5.mjs → chunk-BFOMCSZ2.mjs} +292 -120
  71. package/dist/{chunk-I4KPA2C6.mjs → chunk-BIX46FTI.mjs} +1 -1
  72. package/dist/{chunk-YZLEOMMA.mjs → chunk-BNXV3PRM.mjs} +4 -4
  73. package/dist/{chunk-3GNVIYPO.cjs → chunk-BSJMWCWM.cjs} +7 -7
  74. package/dist/{chunk-WVQNXXNE.cjs → chunk-BWFBTTJ5.cjs} +2 -2
  75. package/dist/{chunk-FEFCISOX.cjs → chunk-CEVXKJKF.cjs} +2 -2
  76. package/dist/{chunk-B67CW2LM.mjs → chunk-CF77L6RL.mjs} +33 -36
  77. package/dist/{chunk-OB45EAQL.mjs → chunk-CXQZQK6R.mjs} +3 -2
  78. package/dist/{chunk-255J7K4X.mjs → chunk-D2IAYGYA.mjs} +1 -1
  79. package/dist/{chunk-ILQ5DKYF.cjs → chunk-D4TYE6MY.cjs} +2 -2
  80. package/dist/{chunk-4YHGQDTT.cjs → chunk-DM2YGTRH.cjs} +24 -17
  81. package/dist/{chunk-ICFPTHXM.mjs → chunk-DRBXYJZ6.mjs} +7 -3
  82. package/dist/{chunk-E3HDJCWF.mjs → chunk-DRHHTHA3.mjs} +1 -1
  83. package/dist/{chunk-YXIQYWOK.cjs → chunk-DTBRSRTR.cjs} +23 -5
  84. package/dist/{chunk-JZQS3ZOI.mjs → chunk-E4T7WJJN.mjs} +10 -2
  85. package/dist/{chunk-YAEN3L2F.cjs → chunk-EF5AP4CV.cjs} +21 -2
  86. package/dist/{chunk-SPP3EZTJ.cjs → chunk-EHJOSIXM.cjs} +137 -67
  87. package/dist/{chunk-JZBU7V4D.mjs → chunk-ELJQWUAR.mjs} +125 -55
  88. package/dist/{chunk-DMXMIE2C.cjs → chunk-ENYBDM4U.cjs} +2 -2
  89. package/dist/{chunk-ZFEJ2SF2.cjs → chunk-EWIEJQP6.cjs} +28 -28
  90. package/dist/{chunk-ODBM54RT.cjs → chunk-F244KE2D.cjs} +7 -7
  91. package/dist/{chunk-WW3LRNQV.mjs → chunk-FCBUNILW.mjs} +1 -1
  92. package/dist/{chunk-GZOKWJIW.mjs → chunk-FEQ72ZHD.mjs} +16 -9
  93. package/dist/{chunk-ME7RVELR.mjs → chunk-FGXSWRWA.mjs} +20 -1
  94. package/dist/{chunk-2AFW7673.cjs → chunk-FNWL5DMG.cjs} +4 -3
  95. package/dist/{chunk-XUSJVHHD.cjs → chunk-FYV6DTAG.cjs} +738 -485
  96. package/dist/{chunk-7PPLTD3P.cjs → chunk-G7S6XG6X.cjs} +6 -6
  97. package/dist/{chunk-AQIO3RNL.mjs → chunk-GK2GBIXD.mjs} +3 -3
  98. package/dist/{chunk-IHTDLCDJ.cjs → chunk-GRHSQYD4.cjs} +17 -4
  99. package/dist/{chunk-W44X6IC2.cjs → chunk-HBLYSWIJ.cjs} +13 -9
  100. package/dist/chunk-HK4VJI27.cjs +76 -0
  101. package/dist/{chunk-EGIY4A7V.cjs → chunk-HKZVC5GP.cjs} +2 -2
  102. package/dist/{chunk-EYPSKXO4.mjs → chunk-HRQV5Q3J.mjs} +1 -1
  103. package/dist/{chunk-S7MWSFFP.cjs → chunk-IBEHVSU4.cjs} +2 -2
  104. package/dist/{chunk-JMOCMXTQ.mjs → chunk-IG4IQMIW.mjs} +1 -1
  105. package/dist/{chunk-GPO3LJDJ.cjs → chunk-IJFNXP3D.cjs} +2 -2
  106. package/dist/{chunk-FRO4BB2T.mjs → chunk-IP2R2TAE.mjs} +1 -1
  107. package/dist/{chunk-FETMUBIA.mjs → chunk-IZ5WOTQP.mjs} +1 -1
  108. package/dist/{chunk-CSLHNBPS.cjs → chunk-J42QN7OC.cjs} +6 -6
  109. package/dist/{chunk-NDDRTFN4.mjs → chunk-J7EUGGTY.mjs} +2 -2
  110. package/dist/{chunk-MJEKMT6B.mjs → chunk-JI6N4W2I.mjs} +125 -42
  111. package/dist/{chunk-GJ7QVFAG.mjs → chunk-JOECBGY7.mjs} +1 -1
  112. package/dist/{chunk-CL52PD6D.cjs → chunk-JSUVQ5HG.cjs} +8 -8
  113. package/dist/{chunk-DZHTNSQ5.cjs → chunk-JWHRVBCZ.cjs} +14 -14
  114. package/dist/{chunk-462MUII7.mjs → chunk-JZ43UD6S.mjs} +7 -7
  115. package/dist/{chunk-RLEALQEN.mjs → chunk-KIRIFO6T.mjs} +43 -5
  116. package/dist/{chunk-XGTFLG73.cjs → chunk-KMYOKQPP.cjs} +18 -11
  117. package/dist/{chunk-WX63N6C5.mjs → chunk-KNEYWPZV.mjs} +64 -27
  118. package/dist/{chunk-XI3OXOMK.mjs → chunk-KUMKBBYP.mjs} +1 -1
  119. package/dist/{chunk-VT25ERQK.mjs → chunk-KWUZJZ23.mjs} +21 -3
  120. package/dist/{chunk-SVQX5HYW.mjs → chunk-LHFGTR7F.mjs} +2 -2
  121. package/dist/{chunk-4P5634G6.cjs → chunk-LIQJYEQP.cjs} +14 -9
  122. package/dist/chunk-LXTYJ2HW.mjs +139 -0
  123. package/dist/{chunk-5PDMBWAF.cjs → chunk-MKQ27TGW.cjs} +5 -5
  124. package/dist/{chunk-SUQACHER.mjs → chunk-MQ5HA7H2.mjs} +2 -2
  125. package/dist/{chunk-HY6IVQ54.mjs → chunk-MUITBU5Z.mjs} +1 -1
  126. package/dist/{chunk-QKEZLYON.cjs → chunk-NET6PBUH.cjs} +2 -2
  127. package/dist/{chunk-YBY34UHB.mjs → chunk-NKETXVKP.mjs} +15 -2
  128. package/dist/chunk-NRWEY2CM.mjs +25 -0
  129. package/dist/chunk-NU5XLYRN.cjs +139 -0
  130. package/dist/{chunk-HTXKSREF.cjs → chunk-NXGQIXR7.cjs} +345 -173
  131. package/dist/{chunk-PXAHSCR6.cjs → chunk-O2A6HE76.cjs} +4 -4
  132. package/dist/{chunk-OAEDVXVE.mjs → chunk-O6K4G7YA.mjs} +5 -2
  133. package/dist/{chunk-73K53YPP.mjs → chunk-OSKIG4OP.mjs} +1 -1
  134. package/dist/{chunk-OXNZUCHN.cjs → chunk-P3EZKU6L.cjs} +18 -18
  135. package/dist/{chunk-HGB4PM2C.cjs → chunk-PG6ZIHKE.cjs} +102 -30
  136. package/dist/{chunk-YZK64PZT.cjs → chunk-Q3MVNRAO.cjs} +1071 -650
  137. package/dist/{chunk-AZ6IW6SF.mjs → chunk-Q4G52OSW.mjs} +1 -1
  138. package/dist/{chunk-TPYAYFMF.cjs → chunk-QL3YZTGZ.cjs} +2 -2
  139. package/dist/{chunk-UVZMSRHF.mjs → chunk-R4BWNP73.mjs} +2 -2
  140. package/dist/{chunk-OIP62QEL.mjs → chunk-R6Q6VSGU.mjs} +24 -9
  141. package/dist/{chunk-B6RBJJ5G.mjs → chunk-RBRIKT6B.mjs} +15 -2
  142. package/dist/{chunk-C6CUUBY5.cjs → chunk-RHI67C2V.cjs} +5 -5
  143. package/dist/chunk-RK3YYUX6.cjs +114 -0
  144. package/dist/{chunk-Y2LU4LE5.mjs → chunk-ROPMQNCG.mjs} +2 -2
  145. package/dist/{chunk-QIXEU2WV.cjs → chunk-RQ4UZJPR.cjs} +3 -3
  146. package/dist/{chunk-UVQRMUAR.cjs → chunk-RSL3YFJG.cjs} +1 -1
  147. package/dist/{chunk-JWY66PID.cjs → chunk-S3D6SL2V.cjs} +9 -6
  148. package/dist/{chunk-4HGLJOXZ.cjs → chunk-TPDKFRQX.cjs} +11 -11
  149. package/dist/{chunk-6O6PAZZR.mjs → chunk-UHAARKF3.mjs} +2 -2
  150. package/dist/{chunk-QSTRBKHZ.mjs → chunk-UJWRXBVP.mjs} +2 -2
  151. package/dist/{chunk-KTDG4THT.cjs → chunk-V6T3UJAH.cjs} +7 -7
  152. package/dist/{chunk-IXZSBO76.mjs → chunk-VFPFXMTF.mjs} +1 -1
  153. package/dist/{chunk-CPMME66W.mjs → chunk-VKLV7GF4.mjs} +72 -0
  154. package/dist/{chunk-TU6VAH4V.cjs → chunk-VKRMO3EZ.cjs} +8 -8
  155. package/dist/chunk-VWIW47FW.cjs +25 -0
  156. package/dist/{chunk-LGR7565L.cjs → chunk-VZKCGHWC.cjs} +39 -24
  157. package/dist/{chunk-JWLRBDDC.cjs → chunk-WH3PBJS7.cjs} +2 -2
  158. package/dist/{chunk-QGCSUC5O.mjs → chunk-WS4SLJW5.mjs} +403 -150
  159. package/dist/{chunk-5OFNUETM.mjs → chunk-WTTJ2YS2.mjs} +9 -1
  160. package/dist/{chunk-RLFGKJQ6.mjs → chunk-X2KNHD4B.mjs} +14 -2
  161. package/dist/{chunk-5CFHQ7HM.mjs → chunk-XXKMAHYE.mjs} +1 -1
  162. package/dist/{chunk-MBCRWU3P.cjs → chunk-XZPI44Q7.cjs} +4 -4
  163. package/dist/{chunk-ACGBXN3U.cjs → chunk-Y4FEQBKY.cjs} +17 -9
  164. package/dist/{chunk-4CTCSKAF.mjs → chunk-YH33PZ3K.mjs} +1 -1
  165. package/dist/chunk-YQWRBBAA.mjs +284 -0
  166. package/dist/{chunk-REK6HZSU.mjs → chunk-YWDRWG4L.mjs} +962 -541
  167. package/dist/{chunk-E46NXBNJ.mjs → chunk-ZD7JUTBY.mjs} +11 -6
  168. package/dist/{chunk-JDO346NV.mjs → chunk-ZLRWO5GK.mjs} +1 -1
  169. package/dist/{chunk-HFUOLILA.cjs → chunk-ZRCGPSUM.cjs} +4 -4
  170. package/dist/{chunk-4Z3YLMSW.cjs → chunk-ZZGANFQH.cjs} +10 -10
  171. package/dist/client/lifecycle.d.mts +1 -1
  172. package/dist/client/lifecycle.d.ts +1 -1
  173. package/dist/{client-component.d-sF-Znk0j.d.ts → client-component.d-DYOwmq0c.d.ts} +80 -3
  174. package/dist/{client-component.d-C71rMuHF.d.mts → client-component.d-edV76QvU.d.mts} +80 -3
  175. package/dist/{client-plugins.d-MFibjgBg.d.ts → client-plugins.d-BmJYW2FY.d.ts} +19 -6
  176. package/dist/{client-plugins.d-B-Gd9mWR.d.mts → client-plugins.d-DwvqqGsU.d.mts} +19 -6
  177. package/dist/client-plugins.d.mts +4 -4
  178. package/dist/client-plugins.d.ts +4 -4
  179. package/dist/client.cjs +6 -5
  180. package/dist/client.d.mts +11 -11
  181. package/dist/client.d.ts +11 -11
  182. package/dist/client.mjs +5 -4
  183. package/dist/config.d.mts +4 -4
  184. package/dist/config.d.ts +4 -4
  185. package/dist/cron.cjs +6 -2
  186. package/dist/cron.d.mts +11 -2
  187. package/dist/cron.d.ts +11 -2
  188. package/dist/cron.mjs +7 -3
  189. package/dist/desktop.d.mts +5 -5
  190. package/dist/desktop.d.ts +5 -5
  191. package/dist/{devtools-TDIJ6HVC.mjs → devtools-WPX62NG2.mjs} +10 -9
  192. package/dist/{devtools-6K4QXFRL.cjs → devtools-YMDS7PUA.cjs} +12 -11
  193. package/dist/docs.cjs +13 -12
  194. package/dist/docs.d.mts +5 -5
  195. package/dist/docs.d.ts +5 -5
  196. package/dist/docs.mjs +12 -11
  197. package/dist/{endpoint.d-BkMSCRf6.d.mts → endpoint.d-BXbBpKoh.d.mts} +42 -1
  198. package/dist/{endpoint.d-BgHn0lhl.d.ts → endpoint.d-Dx_1k6Du.d.ts} +42 -1
  199. package/dist/environment/vite.cjs +3 -3
  200. package/dist/environment/vite.mjs +2 -2
  201. package/dist/headers.cjs +3 -3
  202. package/dist/{headers.d-uQ6BR59u.d.ts → headers.d-BIbQyAxJ.d.ts} +1 -1
  203. package/dist/{headers.d-BUxGJTsj.d.mts → headers.d-BtNxFc2s.d.mts} +1 -1
  204. package/dist/headers.mjs +2 -2
  205. package/dist/index.cjs +70 -59
  206. package/dist/{index.d-BCGfxCXY.d.ts → index.d-CQ_wUzOV.d.ts} +1 -1
  207. package/dist/{index.d-CuWOJ-un.d.mts → index.d-CQdDRXd1.d.mts} +1 -1
  208. package/dist/index.d.mts +62 -28
  209. package/dist/index.d.ts +62 -28
  210. package/dist/index.mjs +66 -55
  211. package/dist/integrations/orm.d.mts +4 -4
  212. package/dist/integrations/orm.d.ts +4 -4
  213. package/dist/integrations.cjs +4 -4
  214. package/dist/integrations.d.mts +4 -4
  215. package/dist/integrations.d.ts +4 -4
  216. package/dist/integrations.mjs +3 -3
  217. package/dist/internal/app-markdown-runtime.cjs +7 -3
  218. package/dist/internal/app-markdown-runtime.d.mts +17 -6
  219. package/dist/internal/app-markdown-runtime.d.ts +17 -6
  220. package/dist/internal/app-markdown-runtime.mjs +6 -2
  221. package/dist/internal/build-runtime.cjs +41 -39
  222. package/dist/internal/build-runtime.d.mts +6 -6
  223. package/dist/internal/build-runtime.d.ts +6 -6
  224. package/dist/internal/build-runtime.mjs +40 -38
  225. package/dist/internal/cli-runtime.cjs +20 -19
  226. package/dist/internal/cli-runtime.mjs +19 -18
  227. package/dist/internal/client-error-overlay.cjs +6 -6
  228. package/dist/internal/client-error-overlay.mjs +2 -2
  229. package/dist/internal/client-runtime.cjs +6 -2
  230. package/dist/internal/client-runtime.d.mts +21 -9
  231. package/dist/internal/client-runtime.d.ts +21 -9
  232. package/dist/internal/client-runtime.mjs +5 -1
  233. package/dist/internal/compression-runtime.d.mts +4 -4
  234. package/dist/internal/compression-runtime.d.ts +4 -4
  235. package/dist/internal/config-runtime.cjs +12 -11
  236. package/dist/internal/config-runtime.d.mts +6 -6
  237. package/dist/internal/config-runtime.d.ts +6 -6
  238. package/dist/internal/config-runtime.mjs +11 -10
  239. package/dist/internal/form-actions.cjs +5 -4
  240. package/dist/internal/form-actions.d.mts +2 -2
  241. package/dist/internal/form-actions.d.ts +2 -2
  242. package/dist/internal/form-actions.mjs +4 -3
  243. package/dist/internal/infra-analytics-runtime.cjs +10 -10
  244. package/dist/internal/infra-analytics-runtime.mjs +8 -8
  245. package/dist/internal/native-server-fns.cjs +4 -4
  246. package/dist/internal/native-server-fns.mjs +3 -3
  247. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  248. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  249. package/dist/internal/production-runtime.cjs +32 -22
  250. package/dist/internal/production-runtime.d.mts +64 -13
  251. package/dist/internal/production-runtime.d.ts +64 -13
  252. package/dist/internal/production-runtime.mjs +31 -21
  253. package/dist/internal/react-cache.cjs +3 -3
  254. package/dist/internal/react-cache.mjs +1 -1
  255. package/dist/internal/vercel-edge-middleware.cjs +4 -4
  256. package/dist/internal/vercel-edge-middleware.mjs +3 -3
  257. package/dist/{lifecycle.d-keQs5Swc.d.mts → lifecycle.d-OtGWAvJT.d.mts} +4 -0
  258. package/dist/{lifecycle.d-keQs5Swc.d.ts → lifecycle.d-OtGWAvJT.d.ts} +4 -0
  259. package/dist/{manager-JIA66YJ2.mjs → manager-RHB2P35B.mjs} +4 -1
  260. package/dist/{manager-JOHU6BQI.cjs → manager-S77ZARTC.cjs} +5 -2
  261. package/dist/markdown.cjs +2 -2
  262. package/dist/markdown.d.mts +4 -4
  263. package/dist/markdown.d.ts +4 -4
  264. package/dist/markdown.mjs +1 -1
  265. package/dist/middleware.cjs +6 -6
  266. package/dist/middleware.d.mts +4 -4
  267. package/dist/middleware.d.ts +4 -4
  268. package/dist/middleware.mjs +5 -5
  269. package/dist/{mount.d-BIYmcGGg.d.mts → mount.d-6bhpBQQB.d.mts} +1 -1
  270. package/dist/{mount.d-q8k0cJV0.d.ts → mount.d-C-u7rFkM.d.ts} +1 -1
  271. package/dist/{native-server-fn-handler-EP5AFJYE.mjs → native-server-fn-handler-I66X4E5S.mjs} +6 -5
  272. package/dist/{native-server-fn-handler-QRTXGZA4.cjs → native-server-fn-handler-W4FSD76W.cjs} +7 -6
  273. package/dist/{native-tree-OYGKP2NZ.mjs → native-tree-3X23BT3N.mjs} +2 -2
  274. package/dist/{native-tree-R6CQMDTI.cjs → native-tree-TAPKR7QJ.cjs} +3 -3
  275. package/dist/{navigation-delegate.d-CYBUupsv.d.mts → navigation-delegate.d-nx6gtsY4.d.mts} +1 -1
  276. package/dist/{navigation-delegate.d-Btfs6Uoa.d.ts → navigation-delegate.d-xsG4T1x-.d.ts} +1 -1
  277. package/dist/navigation.cjs +4 -4
  278. package/dist/navigation.d.mts +7 -7
  279. package/dist/navigation.d.ts +7 -7
  280. package/dist/navigation.mjs +3 -3
  281. package/dist/{nitro-2LMOMIST.cjs → nitro-SSFTPZMW.cjs} +4 -4
  282. package/dist/{nitro-72TFIGGO.mjs → nitro-XTQ2HKDL.mjs} +1 -1
  283. package/dist/plugin.cjs +36 -33
  284. package/dist/plugin.d.mts +7 -7
  285. package/dist/plugin.d.ts +7 -7
  286. package/dist/plugin.mjs +35 -32
  287. package/dist/query/client.cjs +5 -5
  288. package/dist/query/client.mjs +1 -1
  289. package/dist/{render-plan.d-BlyxqKMu.d.mts → render-plan.d-B5y3h97B.d.mts} +1 -1
  290. package/dist/{render-plan.d-0FHusf1D.d.ts → render-plan.d-gW0fwKz2.d.ts} +1 -1
  291. package/dist/renderer-client.cjs +4 -4
  292. package/dist/renderer-client.d.mts +7 -7
  293. package/dist/renderer-client.d.ts +7 -7
  294. package/dist/renderer-client.mjs +1 -1
  295. package/dist/request.cjs +2 -2
  296. package/dist/{request.d-CX-gks1l.d.mts → request.d-B0ugAadD.d.ts} +9 -2
  297. package/dist/{request.d-CPdVjssg.d.ts → request.d-DLq33nYo.d.mts} +9 -2
  298. package/dist/request.d.mts +5 -5
  299. package/dist/request.d.ts +5 -5
  300. package/dist/request.mjs +1 -1
  301. package/dist/{route-rendering.d-CcvZ_4N2.d.mts → route-rendering.d-DSeIV7yV.d.mts} +1 -1
  302. package/dist/{route-rendering.d-DcOoSNoG.d.ts → route-rendering.d-ytaqDQD6.d.ts} +1 -1
  303. package/dist/{route.d-DrXkpvcg.d.mts → route.d-Cd4Fi6BA.d.ts} +3 -1
  304. package/dist/{route.d-hs-_cyHn.d.ts → route.d-ShmtqqVQ.d.mts} +3 -1
  305. package/dist/{router.d-D2QnK8cM.d.ts → router.d-BaEAEGPg.d.ts} +1 -1
  306. package/dist/{router.d-C8RHma4A.d.mts → router.d-Chd5cpe3.d.mts} +1 -1
  307. package/dist/routes.cjs +5 -3
  308. package/dist/routes.d.mts +4 -4
  309. package/dist/routes.d.ts +4 -4
  310. package/dist/routes.mjs +4 -2
  311. package/dist/{rsc-pipeline-LC2FBZAR.mjs → rsc-pipeline-DPMYONEV.mjs} +12 -11
  312. package/dist/{rsc-pipeline-NTAM65NT.cjs → rsc-pipeline-XIUUMMG5.cjs} +13 -12
  313. package/dist/{runtime-U4PAMTVH.cjs → runtime-WD77S3C5.cjs} +25 -25
  314. package/dist/{runtime-MWAC7NWR.mjs → runtime-XIUJZTZ3.mjs} +16 -16
  315. package/dist/{runtime.d-BQUHHq8M.d.mts → runtime.d-DpCs0eAO.d.mts} +3 -3
  316. package/dist/{runtime.d-1l_1bLrL.d.ts → runtime.d-h2USyQsz.d.ts} +3 -3
  317. package/dist/server-action-security.cjs +5 -3
  318. package/dist/server-action-security.d.mts +11 -3
  319. package/dist/server-action-security.d.ts +11 -3
  320. package/dist/server-action-security.mjs +4 -2
  321. package/dist/server-fn-client.d.mts +3 -3
  322. package/dist/server-fn-client.d.ts +3 -3
  323. package/dist/server-fn.cjs +6 -5
  324. package/dist/server-fn.d.mts +1 -1
  325. package/dist/server-fn.d.ts +1 -1
  326. package/dist/server-fn.mjs +5 -4
  327. package/dist/server-plugins.cjs +4 -4
  328. package/dist/server-plugins.d.mts +53 -9
  329. package/dist/server-plugins.d.ts +53 -9
  330. package/dist/server-plugins.mjs +3 -3
  331. package/dist/server-query-client.d.mts +1 -1
  332. package/dist/server-query-client.d.ts +1 -1
  333. package/dist/server-query.cjs +7 -6
  334. package/dist/server-query.d.mts +1 -1
  335. package/dist/server-query.d.ts +1 -1
  336. package/dist/server-query.mjs +6 -5
  337. package/dist/server.cjs +62 -67
  338. package/dist/server.d.mts +14 -14
  339. package/dist/server.d.ts +14 -14
  340. package/dist/server.mjs +41 -46
  341. package/dist/{spa-router.d-BzPdi48R.d.mts → spa-router.d-DCQVtEaE.d.mts} +11 -5
  342. package/dist/{spa-router.d-BJtXNeqo.d.ts → spa-router.d-DpdJHs1q.d.ts} +11 -5
  343. package/dist/testing.cjs +16 -14
  344. package/dist/testing.d.mts +4 -4
  345. package/dist/testing.d.ts +4 -4
  346. package/dist/testing.mjs +12 -10
  347. package/dist/theme/server.cjs +3 -3
  348. package/dist/theme/server.mjs +2 -2
  349. package/dist/{utils.d-B4ZW-6z6.d.mts → utils.d-DKDZtAY5.d.mts} +1 -1
  350. package/dist/{utils.d-DquC6qxy.d.ts → utils.d-DmicwMvS.d.ts} +1 -1
  351. package/dist/version.cjs +2 -2
  352. package/dist/version.mjs +1 -1
  353. package/dist/vite.cjs +36 -33
  354. package/dist/vite.d.mts +13 -8
  355. package/dist/vite.d.ts +13 -8
  356. package/dist/vite.mjs +35 -32
  357. package/package.json +1 -1
  358. package/dist/analyzer-V5ZMRIIY.cjs +0 -16
  359. package/dist/chunk-6I4BFRE7.cjs +0 -51
  360. package/dist/chunk-EIVGPQN5.mjs +0 -51
  361. /package/dist/{chunk-QEJWNXRI.cjs → chunk-EMRYJG4U.cjs} +0 -0
  362. /package/dist/{chunk-TXE4SAMV.mjs → chunk-H2ZJ35NW.mjs} +0 -0
@@ -26,7 +26,7 @@ var _chunkNG2EZ6QScjs = require('./chunk-NG2EZ6QS.cjs');
26
26
 
27
27
 
28
28
 
29
- var _chunkTDCP3Z4Tcjs = require('./chunk-TDCP3Z4T.cjs');
29
+ var _chunk35GBGSQZcjs = require('./chunk-35GBGSQZ.cjs');
30
30
 
31
31
 
32
32
  var _chunkVM57CK74cjs = require('./chunk-VM57CK74.cjs');
@@ -41,7 +41,7 @@ var _chunk4BS3HSY7cjs = require('./chunk-4BS3HSY7.cjs');
41
41
 
42
42
 
43
43
 
44
- var _chunkKDOZORJDcjs = require('./chunk-KDOZORJD.cjs');
44
+ var _chunk737MIVX3cjs = require('./chunk-737MIVX3.cjs');
45
45
 
46
46
 
47
47
 
@@ -54,7 +54,7 @@ var _chunkKDOZORJDcjs = require('./chunk-KDOZORJD.cjs');
54
54
 
55
55
 
56
56
 
57
- var _chunkHFUOLILAcjs = require('./chunk-HFUOLILA.cjs');
57
+ var _chunkZRCGPSUMcjs = require('./chunk-ZRCGPSUM.cjs');
58
58
 
59
59
 
60
60
 
@@ -62,10 +62,10 @@ var _chunkHFUOLILAcjs = require('./chunk-HFUOLILA.cjs');
62
62
  var _chunkDZZHTMWMcjs = require('./chunk-DZZHTMWM.cjs');
63
63
 
64
64
 
65
- var _chunkJWY66PIDcjs = require('./chunk-JWY66PID.cjs');
65
+ var _chunkS3D6SL2Vcjs = require('./chunk-S3D6SL2V.cjs');
66
66
 
67
67
 
68
- var _chunkROCF6UQDcjs = require('./chunk-ROCF6UQD.cjs');
68
+ var _chunk77SVUQM5cjs = require('./chunk-77SVUQM5.cjs');
69
69
 
70
70
 
71
71
  var _chunkNDOE76QCcjs = require('./chunk-NDOE76QC.cjs');
@@ -74,7 +74,7 @@ var _chunkNDOE76QCcjs = require('./chunk-NDOE76QC.cjs');
74
74
 
75
75
 
76
76
 
77
- var _chunkOXNZUCHNcjs = require('./chunk-OXNZUCHN.cjs');
77
+ var _chunkP3EZKU6Lcjs = require('./chunk-P3EZKU6L.cjs');
78
78
 
79
79
 
80
80
  var _chunk3GNHJ3RNcjs = require('./chunk-3GNHJ3RN.cjs');
@@ -110,12 +110,12 @@ var _chunkOCS3PSYRcjs = require('./chunk-OCS3PSYR.cjs');
110
110
 
111
111
 
112
112
 
113
- var _chunkTAU3OF5Bcjs = require('./chunk-TAU3OF5B.cjs');
113
+ var _chunk56HHUSR5cjs = require('./chunk-56HHUSR5.cjs');
114
114
 
115
115
 
116
116
 
117
117
 
118
- var _chunkDMXMIE2Ccjs = require('./chunk-DMXMIE2C.cjs');
118
+ var _chunkENYBDM4Ucjs = require('./chunk-ENYBDM4U.cjs');
119
119
 
120
120
 
121
121
  var _chunkPMU4U2W2cjs = require('./chunk-PMU4U2W2.cjs');
@@ -123,8 +123,8 @@ var _chunkPMU4U2W2cjs = require('./chunk-PMU4U2W2.cjs');
123
123
 
124
124
 
125
125
 
126
- var _chunkCLEWORVYcjs = require('./chunk-CLEWORVY.cjs');
127
126
 
127
+ var _chunkACAEFEOHcjs = require('./chunk-ACAEFEOH.cjs');
128
128
 
129
129
 
130
130
 
@@ -136,7 +136,8 @@ var _chunkCLEWORVYcjs = require('./chunk-CLEWORVY.cjs');
136
136
 
137
137
 
138
138
 
139
- var _chunkPXAHSCR6cjs = require('./chunk-PXAHSCR6.cjs');
139
+
140
+ var _chunkO2A6HE76cjs = require('./chunk-O2A6HE76.cjs');
140
141
 
141
142
 
142
143
  var _chunk3HLQTOVUcjs = require('./chunk-3HLQTOVU.cjs');
@@ -150,15 +151,15 @@ var _chunk47JV57DAcjs = require('./chunk-47JV57DA.cjs');
150
151
 
151
152
 
152
153
 
153
- var _chunk4YHGQDTTcjs = require('./chunk-4YHGQDTT.cjs');
154
+ var _chunkDM2YGTRHcjs = require('./chunk-DM2YGTRH.cjs');
154
155
 
155
156
 
156
157
 
157
158
 
158
- var _chunkTU6VAH4Vcjs = require('./chunk-TU6VAH4V.cjs');
159
+ var _chunkVKRMO3EZcjs = require('./chunk-VKRMO3EZ.cjs');
159
160
 
160
161
 
161
- var _chunkILQ5DKYFcjs = require('./chunk-ILQ5DKYF.cjs');
162
+ var _chunkD4TYE6MYcjs = require('./chunk-D4TYE6MY.cjs');
162
163
 
163
164
 
164
165
  var _chunk4EBC7EMWcjs = require('./chunk-4EBC7EMW.cjs');
@@ -177,7 +178,9 @@ var _chunk4EBC7EMWcjs = require('./chunk-4EBC7EMW.cjs');
177
178
 
178
179
 
179
180
 
180
- var _chunkHTXKSREFcjs = require('./chunk-HTXKSREF.cjs');
181
+
182
+
183
+ var _chunkNXGQIXR7cjs = require('./chunk-NXGQIXR7.cjs');
181
184
 
182
185
 
183
186
 
@@ -215,23 +218,27 @@ var _chunk67MZTLTFcjs = require('./chunk-67MZTLTF.cjs');
215
218
 
216
219
 
217
220
 
218
- var _chunkYAEN3L2Fcjs = require('./chunk-YAEN3L2F.cjs');
219
221
 
222
+ var _chunkEF5AP4CVcjs = require('./chunk-EF5AP4CV.cjs');
220
223
 
221
- var _chunk4P5634G6cjs = require('./chunk-4P5634G6.cjs');
224
+
225
+ var _chunkLIQJYEQPcjs = require('./chunk-LIQJYEQP.cjs');
222
226
 
223
227
 
224
228
  var _chunk3EIPOTZVcjs = require('./chunk-3EIPOTZV.cjs');
225
229
 
226
230
 
227
- var _chunkLGR7565Lcjs = require('./chunk-LGR7565L.cjs');
231
+
232
+
233
+
234
+ var _chunkVZKCGHWCcjs = require('./chunk-VZKCGHWC.cjs');
228
235
 
229
236
 
230
237
 
231
238
  var _chunk2HW5LWAHcjs = require('./chunk-2HW5LWAH.cjs');
232
239
 
233
240
 
234
- var _chunkHGB4PM2Ccjs = require('./chunk-HGB4PM2C.cjs');
241
+ var _chunkPG6ZIHKEcjs = require('./chunk-PG6ZIHKE.cjs');
235
242
 
236
243
 
237
244
  var _chunkASYOWPSRcjs = require('./chunk-ASYOWPSR.cjs');
@@ -242,7 +249,7 @@ var _chunkFSODPZRTcjs = require('./chunk-FSODPZRT.cjs');
242
249
 
243
250
 
244
251
 
245
- var _chunkJX5VOLAVcjs = require('./chunk-JX5VOLAV.cjs');
252
+ var _chunk65OS2TOTcjs = require('./chunk-65OS2TOT.cjs');
246
253
 
247
254
 
248
255
  var _chunkZOYKJBP5cjs = require('./chunk-ZOYKJBP5.cjs');
@@ -256,7 +263,7 @@ var _chunkJMYXO572cjs = require('./chunk-JMYXO572.cjs');
256
263
  var _chunkMHLNWRCJcjs = require('./chunk-MHLNWRCJ.cjs');
257
264
 
258
265
 
259
- var _chunk5LOARKDPcjs = require('./chunk-5LOARKDP.cjs');
266
+ var _chunk2TZ3F6TNcjs = require('./chunk-2TZ3F6TN.cjs');
260
267
 
261
268
 
262
269
  var _chunkCYOTNHDFcjs = require('./chunk-CYOTNHDF.cjs');
@@ -284,7 +291,7 @@ var _chunkQMNWKQL4cjs = require('./chunk-QMNWKQL4.cjs');
284
291
  var _chunk2OF5RPVUcjs = require('./chunk-2OF5RPVU.cjs');
285
292
 
286
293
 
287
- var _chunkUVQRMUARcjs = require('./chunk-UVQRMUAR.cjs');
294
+ var _chunkRSL3YFJGcjs = require('./chunk-RSL3YFJG.cjs');
288
295
 
289
296
 
290
297
 
@@ -294,7 +301,7 @@ var _chunkNLBHLPEOcjs = require('./chunk-NLBHLPEO.cjs');
294
301
  var _chunkDVJM55D2cjs = require('./chunk-DVJM55D2.cjs');
295
302
 
296
303
 
297
- var _chunkHDPT6OYEcjs = require('./chunk-HDPT6OYE.cjs');
304
+ var _chunk4M5ESTJ2cjs = require('./chunk-4M5ESTJ2.cjs');
298
305
 
299
306
 
300
307
 
@@ -322,17 +329,17 @@ var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
322
329
  var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
323
330
  var FARM_CLIENT_BOOT_SRC_PLACEHOLDER = "/__farm_client_boot_src__";
324
331
  async function hashAndCopy(sourcePath, destinationDir, hashedName) {
325
- const fs4 = await import("fs/promises");
332
+ const fs5 = await import("fs/promises");
326
333
  try {
327
- const bytes = await fs4.readFile(sourcePath);
334
+ const bytes = await fs5.readFile(sourcePath);
328
335
  if (bytes.length === 0) return null;
329
336
  const { createHash } = await import("crypto");
330
337
  const hash = createHash("sha256").update(bytes).digest("hex").slice(0, 8);
331
338
  const name = hashedName(hash);
332
- await fs4.mkdir(destinationDir, { recursive: true });
333
- await fs4.writeFile(_path2.default.join(destinationDir, name), bytes);
339
+ await fs5.mkdir(destinationDir, { recursive: true });
340
+ await fs5.writeFile(_path2.default.join(destinationDir, name), bytes);
334
341
  return name;
335
- } catch (e) {
342
+ } catch (e2) {
336
343
  return null;
337
344
  }
338
345
  }
@@ -345,31 +352,31 @@ async function resolveHashedClientCssHref(clientOutputDir) {
345
352
  return name ? `/assets/${name}` : "/farm-client.css";
346
353
  }
347
354
  async function findFingerprintedClientEntry(clientOutputDir) {
348
- const fs4 = await import("fs/promises");
355
+ const fs5 = await import("fs/promises");
349
356
  try {
350
- const entries = await fs4.readdir(clientOutputDir);
357
+ const entries = await fs5.readdir(clientOutputDir);
351
358
  return _nullishCoalesce(entries.find((name) => /^farm-client-h[0-9a-f]+\.js$/.test(name)), () => ( null));
352
- } catch (e2) {
359
+ } catch (e3) {
353
360
  return null;
354
361
  }
355
362
  }
356
363
  async function resolveClientBootSrc(clientOutputDir) {
357
- const fs4 = await import("fs/promises");
364
+ const fs5 = await import("fs/promises");
358
365
  try {
359
- const entries = await fs4.readdir(clientOutputDir);
366
+ const entries = await fs5.readdir(clientOutputDir);
360
367
  const name = entries.find((entry) => /^farm-client-boot-h[0-9a-f]+\.js$/.test(entry));
361
368
  return name ? `/${name}` : null;
362
- } catch (e3) {
369
+ } catch (e4) {
363
370
  return null;
364
371
  }
365
372
  }
366
373
  async function resolveHashedClientJsSrc(clientOutputDir) {
367
374
  const entryName = await findFingerprintedClientEntry(clientOutputDir);
368
375
  if (!entryName) return "/farm-client.js";
369
- const fs4 = await import("fs/promises");
376
+ const fs5 = await import("fs/promises");
370
377
  const shim = `export * from "./${entryName}";
371
378
  `;
372
- await fs4.writeFile(_path2.default.join(clientOutputDir, "farm-client.js"), shim);
379
+ await fs5.writeFile(_path2.default.join(clientOutputDir, "farm-client.js"), shim);
373
380
  return `/${entryName}`;
374
381
  }
375
382
 
@@ -377,6 +384,7 @@ async function resolveHashedClientJsSrc(clientOutputDir) {
377
384
  var _os = require('os'); var _os2 = _interopRequireDefault(_os);
378
385
 
379
386
 
387
+ var _esmodulelexer = require('es-module-lexer');
380
388
  var _url = require('url');
381
389
  var _module = require('module');
382
390
  var _util = require('util');
@@ -423,14 +431,14 @@ function getDocsTitle(docs) {
423
431
  return typeof docs.config.nav === "object" && docs.config.nav && "title" in docs.config.nav ? String(docs.config.nav.title || "Documentation") : "Documentation";
424
432
  }
425
433
  function loadPages(contentDir, docs) {
426
- return _chunkHFUOLILAcjs.discoverFarmDocsPages.call(void 0, contentDir, docs).map((page) => _chunkHFUOLILAcjs.loadFarmDocsPage.call(void 0, contentDir, docs, page.slug)).filter((page) => Boolean(page)).sort((a, b) => a.href.localeCompare(b.href));
434
+ return _chunkZRCGPSUMcjs.discoverFarmDocsPages.call(void 0, contentDir, docs).map((page) => _chunkZRCGPSUMcjs.loadFarmDocsPage.call(void 0, contentDir, docs, page.slug)).filter((page) => Boolean(page)).sort((a, b) => a.href.localeCompare(b.href));
427
435
  }
428
436
  function findSocialImagePath(html, basePath) {
429
437
  const match = /<meta\s+property=["']og:image["']\s+content=["']([^"']+)["']/i.exec(html) || /<meta\s+content=["']([^"']+)["']\s+property=["']og:image["']/i.exec(html);
430
438
  if (!_optionalChain([match, 'optionalAccess', _2 => _2[1]])) return null;
431
439
  try {
432
440
  return _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, new URL(match[1], FARM_DOCS_COMPILED_ORIGIN).pathname, basePath);
433
- } catch (e4) {
441
+ } catch (e5) {
434
442
  return null;
435
443
  }
436
444
  }
@@ -441,7 +449,7 @@ async function addHandlerRoute(routes, pathname, handler, absolutePaths) {
441
449
  return response;
442
450
  }
443
451
  async function compileFarmDocsManifest(docs, options) {
444
- const contentDir = _chunkHFUOLILAcjs.resolveFarmDocsContentDir.call(void 0, docs, options);
452
+ const contentDir = _chunkZRCGPSUMcjs.resolveFarmDocsContentDir.call(void 0, docs, options);
445
453
  const pages = loadPages(contentDir, docs);
446
454
  const basePath = _chunkD22BUQKWcjs.normalizeFarmBasePath.call(void 0, options.basePath);
447
455
  const absolutePaths = [
@@ -449,7 +457,7 @@ async function compileFarmDocsManifest(docs, options) {
449
457
  _path2.default.resolve(contentDir),
450
458
  docs.configPath || ""
451
459
  ];
452
- const handler = _chunkHFUOLILAcjs.createFarmDocsHandler.call(void 0, docs, {
460
+ const handler = _chunkZRCGPSUMcjs.createFarmDocsHandler.call(void 0, docs, {
453
461
  root: options.root,
454
462
  srcDir: options.srcDir,
455
463
  clientEntry: options.clientEntry,
@@ -459,7 +467,7 @@ async function compileFarmDocsManifest(docs, options) {
459
467
  isPathGuarded: options.isPathGuarded,
460
468
  basePath
461
469
  });
462
- const apiHandler = _chunkKDOZORJDcjs.createFarmDocsAPIHandler.call(void 0, {
470
+ const apiHandler = _chunk737MIVX3cjs.createFarmDocsAPIHandler.call(void 0, {
463
471
  rootDir: options.root,
464
472
  srcDir: options.srcDir,
465
473
  docs,
@@ -471,7 +479,7 @@ async function compileFarmDocsManifest(docs, options) {
471
479
  const apiMarkdown = {};
472
480
  for (const page of pages) {
473
481
  const htmlResponse = await addHandlerRoute(routes, page.href, handler, absolutePaths);
474
- const markdownPath = _chunkHFUOLILAcjs.getFarmDocsMarkdownPath.call(void 0, page.href);
482
+ const markdownPath = _chunkZRCGPSUMcjs.getFarmDocsMarkdownPath.call(void 0, page.href);
475
483
  await addHandlerRoute(routes, markdownPath, handler, absolutePaths);
476
484
  if (htmlResponse) {
477
485
  const socialImagePath = findSocialImagePath(await htmlResponse.text(), basePath);
@@ -556,7 +564,7 @@ async function compileFarmDocsManifest(docs, options) {
556
564
  post: await compileResponse(postResponse, absolutePaths),
557
565
  search: {
558
566
  pages: publicPages.map((page) => ({
559
- ..._chunkHFUOLILAcjs.toFarmDocsMarkdownPage.call(void 0, page, basePath),
567
+ ..._chunkZRCGPSUMcjs.toFarmDocsMarkdownPage.call(void 0, page, basePath),
560
568
  sourcePath: `farm-docs:${page.slug || "index"}`
561
569
  })),
562
570
  search: _nullishCoalesce(searchConfig, () => ( true)),
@@ -634,12 +642,51 @@ async function readFarmClientModulePreloads(buildDir) {
634
642
  return JSON.parse(
635
643
  await _promises2.default.readFile(_path2.default.join(buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE), "utf8")
636
644
  );
637
- } catch (e5) {
645
+ } catch (e6) {
638
646
  return null;
639
647
  }
640
648
  }
641
649
  function encodeFarmClientModulePreloads(manifest) {
642
- return JSON.stringify(JSON.stringify(manifest)).slice(1, -1).replace(/'/g, "\\u0027").replace(/`/g, "\\u0060").replace(/\$/g, "\\u0024").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
650
+ return encodeFarmBuildJSONPlaceholder(manifest);
651
+ }
652
+ function encodeFarmBuildJSONPlaceholder(value) {
653
+ return JSON.stringify(JSON.stringify(value)).slice(1, -1).replace(/'/g, "\\u0027").replace(/`/g, "\\u0060").replace(/\$/g, "\\u0024").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
654
+ }
655
+
656
+ // src/nitro/client-route-table.ts
657
+
658
+
659
+ var FARM_CLIENT_ROUTE_TABLE_MODULE = "farm-client-routes";
660
+ var FARM_CLIENT_ROUTE_TABLE_FILE = "client-route-table.json";
661
+ var FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER = "__farm_client_route_table__";
662
+ function createFarmClientRouteTable(clientPages) {
663
+ let loaders = 0;
664
+ return clientPages.map((page) => ({
665
+ pattern: page.pattern,
666
+ ...page.directory ? { directory: page.directory } : {},
667
+ pageShouldHydrate: page.pageShouldHydrate,
668
+ ...page.docs ? { docs: true } : {},
669
+ ...page.hasIsolatedClientBoundaries ? { hasIsolatedClientBoundaries: true } : {},
670
+ islandStrategy: page.islandStrategy,
671
+ ...page.pageShouldHydrate ? { loader: loaders++ } : {}
672
+ }));
673
+ }
674
+ function generateFarmClientRouteTableModule(table) {
675
+ return `export default JSON.parse(${JSON.stringify(JSON.stringify(table))});
676
+ `;
677
+ }
678
+ async function writeFarmClientRouteTable(buildDir, table) {
679
+ await _promises2.default.mkdir(buildDir, { recursive: true });
680
+ await _promises2.default.writeFile(_path2.default.join(buildDir, FARM_CLIENT_ROUTE_TABLE_FILE), JSON.stringify(table));
681
+ }
682
+ async function readFarmClientRouteTable(buildDir) {
683
+ try {
684
+ return JSON.parse(
685
+ await _promises2.default.readFile(_path2.default.join(buildDir, FARM_CLIENT_ROUTE_TABLE_FILE), "utf8")
686
+ );
687
+ } catch (e7) {
688
+ return null;
689
+ }
643
690
  }
644
691
 
645
692
  // src/docs/module-preloads.ts
@@ -721,7 +768,7 @@ async function readFarmDocsModulePreloads(buildDir) {
721
768
  return JSON.parse(
722
769
  await _promises2.default.readFile(_path2.default.join(buildDir, FARM_DOCS_MODULE_PRELOADS_FILE), "utf8")
723
770
  );
724
- } catch (e6) {
771
+ } catch (e8) {
725
772
  return null;
726
773
  }
727
774
  }
@@ -737,7 +784,7 @@ async function createFarmRouteRuntimeManifest(options) {
737
784
  const routes = [];
738
785
  for (const [pattern, entry] of options.routeManager.getRoutes()) {
739
786
  const routeModule = await options.routeManager.loadRouteModule(entry.modulePath);
740
- const rendering = await _chunkCLEWORVYcjs.resolveRouteRenderingConfigFromFile.call(void 0, routeModule, entry.modulePath);
787
+ const rendering = await _chunkACAEFEOHcjs.resolveRouteRenderingConfigFromFile.call(void 0, routeModule, entry.modulePath);
741
788
  const runtimeConfig = await options.routeManager.resolveRouteRuntimeConfig(pattern);
742
789
  routes.push({
743
790
  kind: "page",
@@ -802,10 +849,10 @@ async function createFarmRouteRuntimeManifest(options) {
802
849
  };
803
850
  }
804
851
  async function writeFarmRouteRuntimeManifest(directory, manifest) {
805
- const fs4 = await import("fs/promises");
852
+ const fs5 = await import("fs/promises");
806
853
  const manifestPath = _path2.default.join(directory, FARM_ROUTE_RUNTIME_MANIFEST);
807
- await fs4.mkdir(directory, { recursive: true });
808
- await fs4.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
854
+ await fs5.mkdir(directory, { recursive: true });
855
+ await fs5.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
809
856
  `);
810
857
  return manifestPath;
811
858
  }
@@ -847,7 +894,7 @@ function normalizeManifestSource(root, modulePath) {
847
894
 
848
895
  // src/nitro/vercel-route-runtime.ts
849
896
 
850
- async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs4, basePath = "/") {
897
+ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs5, basePath = "/") {
851
898
  const dynamicRoutes = manifest.routes.filter(
852
899
  (route) => route.rendering === "dynamic" && route.runtime !== "edge"
853
900
  );
@@ -878,8 +925,8 @@ async function createFarmVercelRouteRuntimeFunctions(outputDir, manifest, fs4, b
878
925
  groupIndex += 1;
879
926
  const functionName = `__farm_runtime_${groupIndex}`;
880
927
  const functionDir = _path2.default.join(functionsDir, `${functionName}.func`);
881
- await fs4.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
882
- await configureVercelFunction(functionDir, group.config, fs4);
928
+ await fs5.cp(baseFunctionDir, functionDir, { recursive: true, force: true });
929
+ await configureVercelFunction(functionDir, group.config, fs5);
883
930
  destinations.set(key, `/${functionName}`);
884
931
  }
885
932
  const routes = [];
@@ -916,15 +963,15 @@ function farmRoutePatternToVercelSource(pattern, basePath = "/") {
916
963
  if (!normalizedBasePath) return source || "/";
917
964
  return source === "/" ? normalizedBasePath : `${normalizedBasePath}${source}`;
918
965
  }
919
- async function configureVercelFunction(functionDir, config, fs4) {
966
+ async function configureVercelFunction(functionDir, config, fs5) {
920
967
  const configPath = _path2.default.join(functionDir, ".vc-config.json");
921
- const current = JSON.parse(await fs4.readFile(configPath, "utf8"));
968
+ const current = JSON.parse(await fs5.readFile(configPath, "utf8"));
922
969
  const next = {
923
970
  ...current,
924
971
  ..._optionalChain([config, 'access', _12 => _12.regions, 'optionalAccess', _13 => _13.length]) ? { regions: config.regions } : {},
925
972
  ...config.maxDuration ? { maxDuration: config.maxDuration } : {}
926
973
  };
927
- await fs4.writeFile(configPath, `${JSON.stringify(next, null, 2)}
974
+ await fs5.writeFile(configPath, `${JSON.stringify(next, null, 2)}
928
975
  `);
929
976
  }
930
977
  function hasVercelFunctionControls(route) {
@@ -1007,8 +1054,8 @@ function planFarmImmutableAssets(options) {
1007
1054
  return plan;
1008
1055
  }
1009
1056
  async function listFarmClientOutputFiles(dir) {
1010
- const fs4 = await import("fs/promises");
1011
- const entries = await fs4.readdir(dir, { recursive: true, withFileTypes: true }).catch(() => []);
1057
+ const fs5 = await import("fs/promises");
1058
+ const entries = await fs5.readdir(dir, { recursive: true, withFileTypes: true }).catch(() => []);
1012
1059
  return entries.filter((entry) => entry.isFile()).map((entry) => {
1013
1060
  const relative = _path2.default.relative(dir, _path2.default.join(entry.parentPath, entry.name));
1014
1061
  return `/${relative.split(_path2.default.sep).join("/")}`;
@@ -1091,7 +1138,7 @@ function resolveBundleFileName(chunkFileName, relativeUrl) {
1091
1138
  let relativePath = relativeUrl.replace(/[?#].*$/, "");
1092
1139
  try {
1093
1140
  relativePath = decodeURI(relativePath);
1094
- } catch (e7) {
1141
+ } catch (e9) {
1095
1142
  }
1096
1143
  const fileName = _path2.default.posix.normalize(
1097
1144
  _path2.default.posix.join(_path2.default.posix.dirname(chunkFileName), relativePath)
@@ -1338,7 +1385,7 @@ function stripPlatformConfigSource(code, parse) {
1338
1385
  function realPath(file) {
1339
1386
  try {
1340
1387
  return _fs.realpathSync.call(void 0, file);
1341
- } catch (e8) {
1388
+ } catch (e10) {
1342
1389
  return _path2.default.resolve(file);
1343
1390
  }
1344
1391
  }
@@ -1350,7 +1397,7 @@ function farmStripPlatformConfigPlugin(configFiles) {
1350
1397
  // removed block used (`readFileSync` for a version, say).
1351
1398
  enforce: "pre",
1352
1399
  transform: {
1353
- filter: { id: _chunkTAU3OF5Bcjs.fileNamePattern.call(void 0, configFiles) },
1400
+ filter: { id: _chunk56HHUSR5cjs.fileNamePattern.call(void 0, configFiles) },
1354
1401
  async handler(code, id) {
1355
1402
  const file = id.split("?", 1)[0];
1356
1403
  if (!files.has(_path2.default.resolve(file)) && !files.has(realPath(file))) return null;
@@ -1364,6 +1411,59 @@ function farmStripPlatformConfigPlugin(configFiles) {
1364
1411
  };
1365
1412
  }
1366
1413
 
1414
+ // src/build/markdown-precompile.ts
1415
+
1416
+
1417
+
1418
+ var _worker_threads = require('worker_threads');
1419
+ var WORKER_SOURCE = `
1420
+ const { parentPort, workerData } = require("node:worker_threads");
1421
+ import(workerData.runtime).then(async ({ compileFarmMarkdownPage }) => {
1422
+ const pages = [];
1423
+ for (const body of workerData.bodies) {
1424
+ try {
1425
+ pages.push([body, await compileFarmMarkdownPage(body)]);
1426
+ } catch {}
1427
+ }
1428
+ parentPort.postMessage(pages);
1429
+ });
1430
+ `;
1431
+ function precompileFarmMarkdownPages(bodies, coreRoot) {
1432
+ const runtime = coreRoot ? _path2.default.join(coreRoot, "dist", "internal", "app-markdown-runtime.mjs") : null;
1433
+ if (bodies.length === 0 || !runtime || !_fs.existsSync.call(void 0, runtime)) {
1434
+ return { pages: Promise.resolve(/* @__PURE__ */ new Map()), dispose() {
1435
+ } };
1436
+ }
1437
+ let worker;
1438
+ const pages = new Promise((resolve) => {
1439
+ const done = (entries = []) => {
1440
+ worker = void 0;
1441
+ resolve(new Map(entries));
1442
+ };
1443
+ try {
1444
+ worker = new (0, _worker_threads.Worker)(WORKER_SOURCE, {
1445
+ eval: true,
1446
+ workerData: { runtime: _url.pathToFileURL.call(void 0, runtime).href, bodies: [...new Set(bodies)] }
1447
+ });
1448
+ } catch (e11) {
1449
+ done();
1450
+ return;
1451
+ }
1452
+ worker.once("message", (entries) => {
1453
+ void _optionalChain([worker, 'optionalAccess', _29 => _29.terminate, 'call', _30 => _30()]);
1454
+ done(entries);
1455
+ });
1456
+ worker.once("error", () => done());
1457
+ worker.once("exit", () => done());
1458
+ });
1459
+ return {
1460
+ pages,
1461
+ dispose() {
1462
+ void _optionalChain([worker, 'optionalAccess', _31 => _31.terminate, 'call', _32 => _32()]);
1463
+ }
1464
+ };
1465
+ }
1466
+
1367
1467
  // src/nitro/client-sourcemaps.ts
1368
1468
 
1369
1469
 
@@ -1402,7 +1502,7 @@ function literalMatcher(node) {
1402
1502
  if (node.type === "Literal" && node.regex)
1403
1503
  return new RegExp(node.regex.pattern, node.regex.flags);
1404
1504
  if (node.type === "TemplateLiteral" && node.expressions.length === 0) {
1405
- return _nullishCoalesce(_optionalChain([node, 'access', _29 => _29.quasis, 'access', _30 => _30[0], 'optionalAccess', _31 => _31.value, 'optionalAccess', _32 => _32.cooked]), () => ( void 0));
1505
+ return _nullishCoalesce(_optionalChain([node, 'access', _33 => _33.quasis, 'access', _34 => _34[0], 'optionalAccess', _35 => _35.value, 'optionalAccess', _36 => _36.cooked]), () => ( void 0));
1406
1506
  }
1407
1507
  return void 0;
1408
1508
  }
@@ -1426,7 +1526,7 @@ function readStaticMiddlewareConfig(program) {
1426
1526
  let found = null;
1427
1527
  for (const statement of program.body) {
1428
1528
  if (statement.type === "ExportNamedDeclaration" && !statement.declaration) {
1429
- if (statement.specifiers.some((specifier) => _optionalChain([specifier, 'access', _33 => _33.exported, 'optionalAccess', _34 => _34.name]) === "config")) {
1529
+ if (statement.specifiers.some((specifier) => _optionalChain([specifier, 'access', _37 => _37.exported, 'optionalAccess', _38 => _38.name]) === "config")) {
1430
1530
  return "unknown";
1431
1531
  }
1432
1532
  continue;
@@ -1434,14 +1534,14 @@ function readStaticMiddlewareConfig(program) {
1434
1534
  const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : null;
1435
1535
  if (!declaration || declaration.type !== "VariableDeclaration") continue;
1436
1536
  for (const declarator of declaration.declarations) {
1437
- if (_optionalChain([declarator, 'access', _35 => _35.id, 'optionalAccess', _36 => _36.type]) !== "Identifier" || declarator.id.name !== "config") continue;
1537
+ if (_optionalChain([declarator, 'access', _39 => _39.id, 'optionalAccess', _40 => _40.type]) !== "Identifier" || declarator.id.name !== "config") continue;
1438
1538
  if (declaration.kind !== "const" || !declarator.init) return "unknown";
1439
1539
  const init = unwrap(declarator.init);
1440
1540
  if (init.type !== "ObjectExpression") return "unknown";
1441
1541
  const config = {};
1442
1542
  for (const property of init.properties) {
1443
1543
  if (property.type !== "Property" || property.computed) return "unknown";
1444
- const key = _nullishCoalesce(_optionalChain([property, 'access', _37 => _37.key, 'optionalAccess', _38 => _38.name]), () => ( _optionalChain([property, 'access', _39 => _39.key, 'optionalAccess', _40 => _40.value])));
1544
+ const key = _nullishCoalesce(_optionalChain([property, 'access', _41 => _41.key, 'optionalAccess', _42 => _42.name]), () => ( _optionalChain([property, 'access', _43 => _43.key, 'optionalAccess', _44 => _44.value])));
1445
1545
  if (key === "runtime") {
1446
1546
  const runtime = literalMatcher(unwrap(property.value));
1447
1547
  if (runtime === "edge" || runtime === "nodejs") config.runtime = runtime;
@@ -1462,9 +1562,9 @@ async function readMiddlewareFileConfig(filePath) {
1462
1562
  try {
1463
1563
  const [{ readFile }, vite] = await Promise.all([import("fs/promises"), import("vite")]);
1464
1564
  const parsed = vite.parseSync(filePath, await readFile(filePath, "utf8"));
1465
- if (_optionalChain([parsed, 'access', _41 => _41.errors, 'optionalAccess', _42 => _42.length])) return "unknown";
1565
+ if (_optionalChain([parsed, 'access', _45 => _45.errors, 'optionalAccess', _46 => _46.length])) return "unknown";
1466
1566
  return readStaticMiddlewareConfig(parsed.program);
1467
- } catch (e9) {
1567
+ } catch (e12) {
1468
1568
  return "unknown";
1469
1569
  }
1470
1570
  }
@@ -1481,7 +1581,7 @@ function farmTargetRunsEdgeMiddleware(preset) {
1481
1581
  return preset === "vercel";
1482
1582
  }
1483
1583
  function isFarmEdgeMiddlewareRoute(route) {
1484
- return typeof route.config === "object" && _optionalChain([route, 'access', _43 => _43.config, 'optionalAccess', _44 => _44.runtime]) === "edge";
1584
+ return typeof route.config === "object" && _optionalChain([route, 'access', _47 => _47.config, 'optionalAccess', _48 => _48.runtime]) === "edge";
1485
1585
  }
1486
1586
  function escapeRegExp3(value) {
1487
1587
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -1518,18 +1618,18 @@ export default createFarmVercelEdgeMiddleware({
1518
1618
  ${modules.join("\n")}
1519
1619
  ],
1520
1620
  i18n: ${JSON.stringify(config.i18n)},
1521
- server: ${JSON.stringify({ trustProxy: _optionalChain([config, 'access', _45 => _45.server, 'optionalAccess', _46 => _46.trustProxy]) === true })},
1621
+ server: ${JSON.stringify({ trustProxy: _optionalChain([config, 'access', _49 => _49.server, 'optionalAccess', _50 => _50.trustProxy]) === true })},
1522
1622
  apiBasePath: ${JSON.stringify(_chunk2OF5RPVUcjs.resolveFarmAPIServerBasePath.call(void 0, config.api))},
1523
1623
  notFoundPath: ${JSON.stringify(_chunkD22BUQKWcjs.applyFarmBasePath.call(void 0, FARM_VERCEL_EDGE_NOT_FOUND_PATH, config.basePath))},
1524
1624
  pages: ${JSON.stringify(toFarmVercelEdgeGuardedUrls(guardedPages, config.basePath))},
1525
1625
  });
1526
1626
  `;
1527
1627
  }
1528
- async function resolveFarmCoreDir(root, fs4) {
1628
+ async function resolveFarmCoreDir(root, fs5) {
1529
1629
  const runtimeEntry = _module.createRequire.call(void 0, _path2.default.join(root, "package.json")).resolve(
1530
1630
  "@farm.js/core/internal/vercel-edge-middleware"
1531
1631
  );
1532
- return fs4.realpath(_path2.default.resolve(_path2.default.dirname(runtimeEntry), "..", ".."));
1632
+ return fs5.realpath(_path2.default.resolve(_path2.default.dirname(runtimeEntry), "..", ".."));
1533
1633
  }
1534
1634
  function edgeNodeModulesPlugin(coreDir, unsupported) {
1535
1635
  const streamStub = "\0farm-edge-node-stream";
@@ -1553,20 +1653,20 @@ function edgeNodeModulesPlugin(coreDir, unsupported) {
1553
1653
  };
1554
1654
  }
1555
1655
  async function writeFarmVercelEdgeMiddlewareFunction(options) {
1556
- const { root, outputDir, buildDir, config, routes, guardedPages, fs: fs4 } = options;
1656
+ const { root, outputDir, buildDir, config, routes, guardedPages, fs: fs5 } = options;
1557
1657
  const functionDir = _path2.default.join(
1558
1658
  outputDir,
1559
1659
  "functions",
1560
1660
  `${FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION}.func`
1561
1661
  );
1562
1662
  const entryPath = _path2.default.join(buildDir, "vercel-edge-middleware-entry.mjs");
1563
- await fs4.mkdir(_path2.default.dirname(entryPath), { recursive: true });
1564
- await fs4.writeFile(
1663
+ await fs5.mkdir(_path2.default.dirname(entryPath), { recursive: true });
1664
+ await fs5.writeFile(
1565
1665
  entryPath,
1566
1666
  generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages)
1567
1667
  );
1568
1668
  const unsupported = /* @__PURE__ */ new Set();
1569
- const coreDir = await resolveFarmCoreDir(root, fs4);
1669
+ const coreDir = await resolveFarmCoreDir(root, fs5);
1570
1670
  const { rolldown } = await import("rolldown");
1571
1671
  let code;
1572
1672
  try {
@@ -1577,7 +1677,7 @@ async function writeFarmVercelEdgeMiddlewareFunction(options) {
1577
1677
  logLevel: "silent",
1578
1678
  plugins: [edgeNodeModulesPlugin(coreDir, unsupported)],
1579
1679
  resolve: {
1580
- alias: _chunkTAU3OF5Bcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
1680
+ alias: _chunk56HHUSR5cjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
1581
1681
  conditionNames: ["edge-light", "worker", "browser", "import", "module", "default"]
1582
1682
  },
1583
1683
  transform: {
@@ -1598,7 +1698,7 @@ async function writeFarmVercelEdgeMiddlewareFunction(options) {
1598
1698
  } catch (error) {
1599
1699
  throw _chunkASYOWPSRcjs.withPlainDiagnostics.call(void 0, error);
1600
1700
  } finally {
1601
- await fs4.rm(entryPath, { force: true });
1701
+ await fs5.rm(entryPath, { force: true });
1602
1702
  }
1603
1703
  if (unsupported.size > 0) {
1604
1704
  throw new Error(
@@ -1607,10 +1707,10 @@ async function writeFarmVercelEdgeMiddlewareFunction(options) {
1607
1707
  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.`
1608
1708
  );
1609
1709
  }
1610
- await fs4.rm(functionDir, { recursive: true, force: true });
1611
- await fs4.mkdir(functionDir, { recursive: true });
1612
- await fs4.writeFile(_path2.default.join(functionDir, "index.js"), code);
1613
- await fs4.writeFile(
1710
+ await fs5.rm(functionDir, { recursive: true, force: true });
1711
+ await fs5.mkdir(functionDir, { recursive: true });
1712
+ await fs5.writeFile(_path2.default.join(functionDir, "index.js"), code);
1713
+ await fs5.writeFile(
1614
1714
  _path2.default.join(functionDir, ".vc-config.json"),
1615
1715
  `${JSON.stringify({ runtime: "edge", entrypoint: "index.js" }, null, 2)}
1616
1716
  `
@@ -1629,15 +1729,15 @@ Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(",
1629
1729
  // src/nitro/universal-build.ts
1630
1730
  var FARM_NATIVE_STYLESHEETS_PLACEHOLDER = "__FARM_NATIVE_STYLESHEETS__";
1631
1731
  async function readFarmNativeStylesheets(clientOutputDir, clientCssHref) {
1632
- const fs4 = await import("fs/promises");
1732
+ const fs5 = await import("fs/promises");
1633
1733
  try {
1634
1734
  return {
1635
- [clientCssHref]: await fs4.readFile(
1735
+ [clientCssHref]: await fs5.readFile(
1636
1736
  _path2.default.join(clientOutputDir, clientCssHref.slice(1)),
1637
1737
  "utf8"
1638
1738
  )
1639
1739
  };
1640
- } catch (e10) {
1740
+ } catch (e13) {
1641
1741
  return {};
1642
1742
  }
1643
1743
  }
@@ -1656,7 +1756,7 @@ function findFarmCoreRoot(from) {
1656
1756
  if (_fs.existsSync.call(void 0, manifest)) {
1657
1757
  try {
1658
1758
  if (JSON.parse(_fs.readFileSync.call(void 0, manifest, "utf8")).name === "@farm.js/core") return dir;
1659
- } catch (e11) {
1759
+ } catch (e14) {
1660
1760
  }
1661
1761
  }
1662
1762
  dir = _path2.default.dirname(dir);
@@ -1674,7 +1774,7 @@ function findInstalledPackageDir(name, from) {
1674
1774
  if (_fs.existsSync.call(void 0, _path2.default.join(candidate, "package.json"))) {
1675
1775
  try {
1676
1776
  return _fs.realpathSync.call(void 0, candidate);
1677
- } catch (e12) {
1777
+ } catch (e15) {
1678
1778
  return null;
1679
1779
  }
1680
1780
  }
@@ -1690,7 +1790,7 @@ function collectFarmDependencyDirs(root) {
1690
1790
  let manifest;
1691
1791
  try {
1692
1792
  manifest = JSON.parse(_fs.readFileSync.call(void 0, _path2.default.join(dir, "package.json"), "utf8"));
1693
- } catch (e13) {
1793
+ } catch (e16) {
1694
1794
  return;
1695
1795
  }
1696
1796
  for (const field of ["dependencies", "optionalDependencies", "peerDependencies"]) {
@@ -1706,7 +1806,7 @@ function collectFarmDependencyDirs(root) {
1706
1806
  if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
1707
1807
  }
1708
1808
  }
1709
- } catch (e14) {
1809
+ } catch (e17) {
1710
1810
  }
1711
1811
  for (let next = queue.pop(); next; next = queue.pop()) {
1712
1812
  const dir = findInstalledPackageDir(next.name, next.from);
@@ -1791,19 +1891,32 @@ function resolveNitroInternalRuntimeAliases(root) {
1791
1891
  )
1792
1892
  };
1793
1893
  }
1894
+ function createPrerenderMarkdownPagesPlugin(pages) {
1895
+ return {
1896
+ name: "farm-prerender-markdown-pages",
1897
+ async banner(chunk) {
1898
+ if (!chunk.isEntry) return "";
1899
+ const compiled = await pages;
1900
+ if (compiled.size === 0) return "";
1901
+ return `globalThis[Symbol.for(${JSON.stringify(
1902
+ _chunkVZKCGHWCcjs.FARM_MARKDOWN_PRECOMPILED_PAGES.description
1903
+ )})] = new Map(${JSON.stringify([...compiled])});`;
1904
+ }
1905
+ };
1906
+ }
1794
1907
  function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveNitroPackageEntry) {
1795
1908
  let nitroEntry;
1796
1909
  return {
1797
1910
  name: "farm-prerender-runtime-resolver",
1798
1911
  async resolveId(id, _importer, options) {
1799
- if (_optionalChain([options, 'access', _47 => _47.custom, 'optionalAccess', _48 => _48.farmPrerenderRuntimeResolve])) return null;
1912
+ if (_optionalChain([options, 'access', _51 => _51.custom, 'optionalAccess', _52 => _52.farmPrerenderRuntimeResolve])) return null;
1800
1913
  if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || _path2.default.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
1801
1914
  return null;
1802
1915
  }
1803
1916
  if (nitroEntry === void 0) {
1804
1917
  try {
1805
1918
  nitroEntry = resolveNitroEntry(root);
1806
- } catch (e15) {
1919
+ } catch (e18) {
1807
1920
  nitroEntry = null;
1808
1921
  }
1809
1922
  }
@@ -1824,7 +1937,7 @@ function createFarmStorageModuleRegistration(config) {
1824
1937
  let runtimeRequire = projectRequire;
1825
1938
  try {
1826
1939
  runtimeRequire = _module.createRequire.call(void 0, projectRequire.resolve("@farm.js/core"));
1827
- } catch (e16) {
1940
+ } catch (e19) {
1828
1941
  }
1829
1942
  const loaders = [];
1830
1943
  for (const specifier of modules) {
@@ -1833,7 +1946,7 @@ function createFarmStorageModuleRegistration(config) {
1833
1946
  try {
1834
1947
  resolved = require2.resolve(specifier);
1835
1948
  break;
1836
- } catch (e17) {
1949
+ } catch (e20) {
1837
1950
  }
1838
1951
  }
1839
1952
  if (resolved) {
@@ -1851,7 +1964,7 @@ function resolveNitroPackageEntry(root) {
1851
1964
  let runtimeRequire = projectRequire;
1852
1965
  try {
1853
1966
  runtimeRequire = _module.createRequire.call(void 0, projectRequire.resolve("@farm.js/core"));
1854
- } catch (e18) {
1967
+ } catch (e21) {
1855
1968
  }
1856
1969
  return runtimeRequire.resolve("nitro");
1857
1970
  }
@@ -1905,7 +2018,7 @@ async function canUseRolldownBuilder() {
1905
2018
  try {
1906
2019
  await import("rolldown");
1907
2020
  return true;
1908
- } catch (e19) {
2021
+ } catch (e22) {
1909
2022
  return false;
1910
2023
  }
1911
2024
  }
@@ -1919,7 +2032,7 @@ function hasReactDomEdgeServerBuild(root) {
1919
2032
  try {
1920
2033
  _module.createRequire.call(void 0, _path2.default.join(root, "package.json")).resolve("react-dom/server.edge");
1921
2034
  return true;
1922
- } catch (e20) {
2035
+ } catch (e23) {
1923
2036
  return false;
1924
2037
  }
1925
2038
  }
@@ -1954,7 +2067,7 @@ function isFarmCoreModule(file) {
1954
2067
  if (_fs.existsSync.call(void 0, manifest)) {
1955
2068
  try {
1956
2069
  return JSON.parse(_fs.readFileSync.call(void 0, manifest, "utf8")).name === "@farm.js/core";
1957
- } catch (e21) {
2070
+ } catch (e24) {
1958
2071
  return false;
1959
2072
  }
1960
2073
  }
@@ -1966,7 +2079,7 @@ function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
1966
2079
  return {
1967
2080
  name: "farm-omitted-metadata-image-runtime",
1968
2081
  resolveId: {
1969
- filter: { id: _chunkTAU3OF5Bcjs.exactIdPattern.call(void 0, ["@vercel/og"]) },
2082
+ filter: { id: _chunk56HHUSR5cjs.exactIdPattern.call(void 0, ["@vercel/og"]) },
1970
2083
  handler(source, importer) {
1971
2084
  if (source !== "@vercel/og") return null;
1972
2085
  const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(_path2.default.basename(importer.split("?", 1)[0]));
@@ -1975,7 +2088,7 @@ function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
1975
2088
  }
1976
2089
  },
1977
2090
  load: {
1978
- filter: { id: _chunkTAU3OF5Bcjs.exactIdPattern.call(void 0, [FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID]) },
2091
+ filter: { id: _chunk56HHUSR5cjs.exactIdPattern.call(void 0, [FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID]) },
1979
2092
  handler(id) {
1980
2093
  if (id !== FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID) return null;
1981
2094
  return `
@@ -2003,8 +2116,8 @@ function readVercelOgManifest(file) {
2003
2116
  }
2004
2117
  function resolveVercelOgConditionEntry(resolvedId, condition) {
2005
2118
  const vercelOg = readVercelOgManifest(resolvedId);
2006
- const entry = _optionalChain([vercelOg, 'optionalAccess', _49 => _49.manifest, 'access', _50 => _50.exports, 'optionalAccess', _51 => _51["."], 'optionalAccess', _52 => _52[condition]]);
2007
- const file = typeof entry === "string" ? entry : _optionalChain([entry, 'optionalAccess', _53 => _53.default]);
2119
+ const entry = _optionalChain([vercelOg, 'optionalAccess', _53 => _53.manifest, 'access', _54 => _54.exports, 'optionalAccess', _55 => _55["."], 'optionalAccess', _56 => _56[condition]]);
2120
+ const file = typeof entry === "string" ? entry : _optionalChain([entry, 'optionalAccess', _57 => _57.default]);
2008
2121
  return vercelOg && typeof file === "string" ? _path2.default.join(vercelOg.dir, file) : null;
2009
2122
  }
2010
2123
  function createEdgeMetadataImageRuntimePlugin({
@@ -2020,7 +2133,7 @@ function createEdgeMetadataImageRuntimePlugin({
2020
2133
  const edgeEntry = resolveVercelOgConditionEntry(resolved.id, condition);
2021
2134
  return edgeEntry ? { ...resolved, id: edgeEntry } : resolved;
2022
2135
  }
2023
- if (wasm !== "module" || !source.endsWith(".wasm?module") || !_optionalChain([importer, 'optionalAccess', _54 => _54.replace, 'call', _55 => _55(/\\/g, "/"), 'access', _56 => _56.includes, 'call', _57 => _57("/@vercel/og/")])) {
2136
+ if (wasm !== "module" || !source.endsWith(".wasm?module") || !_optionalChain([importer, 'optionalAccess', _58 => _58.replace, 'call', _59 => _59(/\\/g, "/"), 'access', _60 => _60.includes, 'call', _61 => _61("/@vercel/og/")])) {
2024
2137
  return null;
2025
2138
  }
2026
2139
  const resolvedPath = _path2.default.resolve(_path2.default.dirname(importer.split("?", 1)[0]), source);
@@ -2042,7 +2155,7 @@ function createVercelOgFontInlinePlugin(runtime = "Cloudflare Workers") {
2042
2155
  return `Promise.resolve({ arrayBuffer: () => Uint8Array.from(atob(${JSON.stringify(encoded)}), (character) => character.charCodeAt(0)).buffer })`;
2043
2156
  });
2044
2157
  if (inlined !== code) return { code: inlined, map: null };
2045
- const version = _nullishCoalesce(_optionalChain([readVercelOgManifest, 'call', _58 => _58(file), 'optionalAccess', _59 => _59.manifest, 'access', _60 => _60.version]), () => ( "(unknown version)"));
2158
+ const version = _nullishCoalesce(_optionalChain([readVercelOgManifest, 'call', _62 => _62(file), 'optionalAccess', _63 => _63.manifest, 'access', _64 => _64.version]), () => ( "(unknown version)"));
2046
2159
  this.error(
2047
2160
  `@vercel/og ${version} cannot be bundled for ${runtime}: ${file} does not load its default font with fetch(new URL("./<font>.ttf", import.meta.url)), the pattern Farm inlines because an edge function cannot fetch it. Install a @vercel/og version whose edge build does, such as 1.0.1.`
2048
2161
  );
@@ -2053,7 +2166,7 @@ function createMetadataImageWasmPlugin() {
2053
2166
  return {
2054
2167
  name: "farm-metadata-image-wasm",
2055
2168
  resolveId(source, importer) {
2056
- if (!source.endsWith(".wasm?module") || !_optionalChain([importer, 'optionalAccess', _61 => _61.replace, 'call', _62 => _62(/\\/g, "/"), 'access', _63 => _63.includes, 'call', _64 => _64("/@vercel/og/")])) {
2169
+ if (!source.endsWith(".wasm?module") || !_optionalChain([importer, 'optionalAccess', _65 => _65.replace, 'call', _66 => _66(/\\/g, "/"), 'access', _67 => _67.includes, 'call', _68 => _68("/@vercel/og/")])) {
2057
2170
  return null;
2058
2171
  }
2059
2172
  const requestPath = source.slice(0, -"?module".length);
@@ -2129,9 +2242,9 @@ function hasFarmRuntimeConfigModule(config, configModulePath) {
2129
2242
  return Boolean(configModulePath || (config.layers || []).some((layer) => layer.configFile));
2130
2243
  }
2131
2244
  function nameCodeSplittingGroups(bundlerConfig) {
2132
- const outputs = _optionalChain([bundlerConfig, 'optionalAccess', _65 => _65.output]);
2245
+ const outputs = _optionalChain([bundlerConfig, 'optionalAccess', _69 => _69.output]);
2133
2246
  for (const output of Array.isArray(outputs) ? outputs : [outputs]) {
2134
- const groups = _optionalChain([output, 'optionalAccess', _66 => _66.codeSplitting, 'optionalAccess', _67 => _67.groups]);
2247
+ const groups = _optionalChain([output, 'optionalAccess', _70 => _70.codeSplitting, 'optionalAccess', _71 => _71.groups]);
2135
2248
  if (!Array.isArray(groups)) continue;
2136
2249
  groups.forEach((group, index) => {
2137
2250
  if (group && typeof group.name === "function" && !group.debugName) {
@@ -2155,41 +2268,46 @@ async function minifyFarmServerChunk(code, fileName, options) {
2155
2268
  }
2156
2269
  return restoreLiteralModuleSpecifiers(result.code, fileName, rolldownUtils);
2157
2270
  }
2271
+ var moduleLexerReady = false;
2272
+ function lexDynamicImportArguments(code) {
2273
+ if (!moduleLexerReady) {
2274
+ _esmodulelexer.initSync.call(void 0, );
2275
+ moduleLexerReady = true;
2276
+ }
2277
+ try {
2278
+ return _esmodulelexer.parse.call(void 0, code)[0].filter((entry) => entry.d > -1).map((entry) => ({ start: entry.s, end: entry.e }));
2279
+ } catch (e25) {
2280
+ return null;
2281
+ }
2282
+ }
2158
2283
  function restoreLiteralModuleSpecifiers(code, fileName, { parseSync, Visitor }) {
2159
2284
  const hasImportTemplate = code.includes("import(`");
2160
2285
  const hasRequireTemplate = code.includes("require(`");
2161
2286
  if (!hasImportTemplate && !hasRequireTemplate) return code;
2162
- const parsed = parseSync(fileName, code, { lang: "js", sourceType: "module" });
2163
- if (parsed.errors.length > 0) {
2164
- throw new Error(`Failed to minify ${fileName}: ${parsed.errors[0].message}`);
2165
- }
2166
2287
  const replacements = [];
2167
2288
  let needsAst = hasRequireTemplate && /(?<![\w$])require\(`/.test(code);
2168
- if (!needsAst) {
2169
- const seenStarts = /* @__PURE__ */ new Set();
2170
- for (const { moduleRequest } of parsed.module.dynamicImports) {
2171
- if (seenStarts.has(moduleRequest.start)) continue;
2172
- seenStarts.add(moduleRequest.start);
2173
- const source = code.slice(moduleRequest.start, moduleRequest.end);
2174
- if (!source.startsWith("`")) continue;
2175
- const value = source.slice(1, -1);
2176
- if (source.length < 2 || !source.endsWith("`") || /[\\\r\n`]|\$\{/.test(value)) {
2177
- needsAst = true;
2178
- break;
2179
- }
2180
- replacements.push({
2181
- start: moduleRequest.start,
2182
- end: moduleRequest.end,
2183
- text: toAsciiStringLiteral(value)
2184
- });
2185
- }
2289
+ const dynamicImports = needsAst ? null : lexDynamicImportArguments(code);
2290
+ if (!dynamicImports) needsAst = true;
2291
+ for (const { start, end } of _nullishCoalesce(dynamicImports, () => ( []))) {
2292
+ const source = code.slice(start, end);
2293
+ if (!source.startsWith("`")) continue;
2294
+ const value = source.slice(1, -1);
2295
+ if (source.length < 2 || !source.endsWith("`") || /[\\\r\n`]|\$\{/.test(value)) {
2296
+ needsAst = true;
2297
+ break;
2298
+ }
2299
+ replacements.push({ start, end, text: toAsciiStringLiteral(value) });
2186
2300
  }
2187
2301
  if (needsAst) {
2188
2302
  replacements.length = 0;
2303
+ const parsed = parseSync(fileName, code, { lang: "js", sourceType: "module" });
2304
+ if (parsed.errors.length > 0) {
2305
+ throw new Error(`Failed to minify ${fileName}: ${parsed.errors[0].message}`);
2306
+ }
2189
2307
  const restore = (node) => {
2190
- if (_optionalChain([node, 'optionalAccess', _68 => _68.type]) !== "TemplateLiteral") return;
2308
+ if (_optionalChain([node, 'optionalAccess', _72 => _72.type]) !== "TemplateLiteral") return;
2191
2309
  const template = node;
2192
- const value = _optionalChain([template, 'access', _69 => _69.quasis, 'access', _70 => _70[0], 'optionalAccess', _71 => _71.value, 'access', _72 => _72.cooked]);
2310
+ const value = _optionalChain([template, 'access', _73 => _73.quasis, 'access', _74 => _74[0], 'optionalAccess', _75 => _75.value, 'access', _76 => _76.cooked]);
2193
2311
  if (template.expressions.length > 0 || typeof value !== "string") return;
2194
2312
  replacements.push({
2195
2313
  start: template.start,
@@ -2267,13 +2385,13 @@ function hasProjectPostcssConfig(root) {
2267
2385
  try {
2268
2386
  projectRequire.resolve(`./${file}`);
2269
2387
  return true;
2270
- } catch (e22) {
2388
+ } catch (e26) {
2271
2389
  return false;
2272
2390
  }
2273
2391
  });
2274
2392
  }
2275
2393
  async function findFarmConfigPath(root) {
2276
- const fs4 = await import("fs/promises");
2394
+ const fs5 = await import("fs/promises");
2277
2395
  const candidates = [
2278
2396
  "farm.config.ts",
2279
2397
  "farm.config.mts",
@@ -2287,9 +2405,9 @@ async function findFarmConfigPath(root) {
2287
2405
  for (const candidate of candidates) {
2288
2406
  const resolvedPath = _path2.default.join(root, candidate);
2289
2407
  try {
2290
- await fs4.access(resolvedPath);
2408
+ await fs5.access(resolvedPath);
2291
2409
  return resolvedPath;
2292
- } catch (e23) {
2410
+ } catch (e27) {
2293
2411
  }
2294
2412
  }
2295
2413
  return null;
@@ -2299,20 +2417,20 @@ function hasFarmPluginRoutes(config) {
2299
2417
  }
2300
2418
  function farmServerRuntimePluginsMayHandlePath(config, pathname) {
2301
2419
  return (config.plugins || []).some(
2302
- (plugin) => _chunkJX5VOLAVcjs.getFarmIntegrationPluginServerRuntime.call(void 0, plugin) !== false && // Mobile session tokens change only bearer requests and cookie-clearing responses, which a
2420
+ (plugin) => _chunk65OS2TOTcjs.getFarmIntegrationPluginServerRuntime.call(void 0, plugin) !== false && // Mobile session tokens change only bearer requests and cookie-clearing responses, which a
2303
2421
  // prerendered file never answers or sends; its endpoints live under /__farm/.
2304
2422
  plugin.name !== _chunk4BS3HSY7cjs.FARM_MOBILE_SESSION_PLUGIN && _chunk47JV57DAcjs.farmPluginMayAffectRuntimePath.call(void 0, plugin, pathname)
2305
2423
  );
2306
2424
  }
2307
2425
  async function discoverMiddlewareRoutes(appDir) {
2308
- const fs4 = await import("fs/promises");
2426
+ const fs5 = await import("fs/promises");
2309
2427
  const appDirs = Array.isArray(appDir) ? [...appDir] : [appDir];
2310
2428
  const routes = /* @__PURE__ */ new Map();
2311
2429
  async function walk(dir, routePath, directory, discovered) {
2312
2430
  let entries;
2313
2431
  try {
2314
- entries = await fs4.readdir(dir, { withFileTypes: true });
2315
- } catch (e24) {
2432
+ entries = await fs5.readdir(dir, { withFileTypes: true });
2433
+ } catch (e28) {
2316
2434
  return;
2317
2435
  }
2318
2436
  const middlewareFile = entries.find(
@@ -2347,7 +2465,7 @@ async function discoverMiddlewareRoutes(appDir) {
2347
2465
  return Array.from(routes.values()).sort(_chunkMHLNWRCJcjs.compareMiddlewareRouteLocations).map(({ path: routePath, filePath }) => ({ path: routePath, filePath }));
2348
2466
  }
2349
2467
  function assertFarmDocsRuntimeSupported(config, preset) {
2350
- if (!_optionalChain([config, 'access', _73 => _73.docs, 'optionalAccess', _74 => _74.enabled]) || !_optionalChain([config, 'access', _75 => _75.docs, 'access', _76 => _76.adapter, 'optionalAccess', _77 => _77.server]) || _chunkNLBHLPEOcjs.getFarmPresetRuntime.call(void 0, preset) !== "edge" || Boolean(config.docs.adapter.edgeCompiler)) {
2468
+ if (!_optionalChain([config, 'access', _77 => _77.docs, 'optionalAccess', _78 => _78.enabled]) || !_optionalChain([config, 'access', _79 => _79.docs, 'access', _80 => _80.adapter, 'optionalAccess', _81 => _81.server]) || _chunkNLBHLPEOcjs.getFarmPresetRuntime.call(void 0, preset) !== "edge" || Boolean(config.docs.adapter.edgeCompiler)) {
2351
2469
  return;
2352
2470
  }
2353
2471
  throw new Error(
@@ -2368,6 +2486,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2368
2486
  _chunkQMNWKQL4cjs.logger.info(`\u{1F69C} Building Farm.js application (universal) with preset: ${preset}...`);
2369
2487
  const rendererBuild = options.rendererBuildLifetime ? void 0 : new AbortController();
2370
2488
  const rendererBuildLifetime = _nullishCoalesce(options.rendererBuildLifetime, () => ( rendererBuild.signal));
2489
+ let markdownPrecompile;
2371
2490
  try {
2372
2491
  const routeRuntimeManifestPromise = options.routeRuntimeManifest ? Promise.resolve(options.routeRuntimeManifest) : createFarmRouteRuntimeManifest({
2373
2492
  config,
@@ -2378,7 +2497,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2378
2497
  const routeRuntimeManifestResultPromise = Promise.allSettled([routeRuntimeManifestPromise]);
2379
2498
  const pageRoutes = [];
2380
2499
  for (const [pattern, entry] of routeManager.getRoutes()) {
2381
- const markdownSourcePath = entry.markdownSourcePath || (_chunkLGR7565Lcjs.isFarmMarkdownPageFile.call(void 0, entry.modulePath) ? entry.modulePath : void 0);
2500
+ const markdownSourcePath = entry.markdownSourcePath || (_chunkVZKCGHWCcjs.isFarmMarkdownPageFile.call(void 0, entry.modulePath) ? entry.modulePath : void 0);
2382
2501
  pageRoutes.push({
2383
2502
  pattern,
2384
2503
  ...entry.directory ? { directory: entry.directory } : {},
@@ -2389,6 +2508,10 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2389
2508
  } : {}
2390
2509
  });
2391
2510
  }
2511
+ markdownPrecompile = precompileFarmMarkdownPages(
2512
+ collectFarmPrerenderedMarkdownBodies(pageRoutes),
2513
+ farmCoreRoot
2514
+ );
2392
2515
  const routeSlots = Array.from(
2393
2516
  routeManager.getRouteSlots().values(),
2394
2517
  (entry) => ({
@@ -2403,12 +2526,12 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2403
2526
  })
2404
2527
  );
2405
2528
  _chunkQMNWKQL4cjs.logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
2406
- const fs4 = await import("fs/promises");
2529
+ const fs5 = await import("fs/promises");
2407
2530
  const layoutRoutes = [];
2408
2531
  const appDir = _path2.default.join(root, srcDir, "app");
2409
2532
  async function findLayoutsForClient(dir, routePrefix = "/") {
2410
2533
  try {
2411
- const entries = await fs4.readdir(dir, { withFileTypes: true });
2534
+ const entries = await fs5.readdir(dir, { withFileTypes: true });
2412
2535
  for (const entry of entries) {
2413
2536
  if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
2414
2537
  layoutRoutes.push({
@@ -2420,7 +2543,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2420
2543
  await findLayoutsForClient(_path2.default.join(dir, entry.name), childPrefix);
2421
2544
  }
2422
2545
  }
2423
- } catch (e25) {
2546
+ } catch (e29) {
2424
2547
  }
2425
2548
  }
2426
2549
  await findLayoutsForClient(appDir);
@@ -2440,7 +2563,8 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2440
2563
  ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2441
2564
  );
2442
2565
  }
2443
- const hydrationPlanCache = /* @__PURE__ */ new Map();
2566
+ const hydrationPlanCache = routeManager.getRouteModuleHydrationPlans();
2567
+ const sourceSnapshot = routeManager.takeBuildSourceSnapshot();
2444
2568
  const clientOutputDir = _path2.default.join(root, distDir, "client");
2445
2569
  const [productionViteResult] = await productionViteResultPromise;
2446
2570
  if (productionViteResult.status === "rejected") {
@@ -2453,8 +2577,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2453
2577
  const rendererDisabled = _chunk67MZTLTFcjs.isFarmRendererDisabled.call(void 0, config.renderer);
2454
2578
  const buildClientBundle = async () => {
2455
2579
  if (rendererDisabled) {
2456
- await fs4.rm(clientOutputDir, { recursive: true, force: true });
2457
- await fs4.mkdir(clientOutputDir, { recursive: true });
2580
+ await fs5.rm(clientOutputDir, { recursive: true, force: true });
2581
+ await fs5.mkdir(clientOutputDir, { recursive: true });
2458
2582
  return;
2459
2583
  }
2460
2584
  return buildClient(
@@ -2470,7 +2594,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2470
2594
  hydrationPlanCache,
2471
2595
  rendererBuildLifetime,
2472
2596
  routeManager.getProgrammaticClientRoutes(),
2473
- mobileClient
2597
+ mobileClient,
2598
+ sourceSnapshot
2474
2599
  );
2475
2600
  };
2476
2601
  const buildSSRBundle = () => buildSSRInMemory(
@@ -2486,7 +2611,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2486
2611
  routeSlots,
2487
2612
  isolatedClientBoundaryModules,
2488
2613
  hydrationPlanCache,
2489
- rendererBuildLifetime
2614
+ rendererBuildLifetime,
2615
+ sourceSnapshot
2490
2616
  );
2491
2617
  let clientBuildResult;
2492
2618
  let ssrBuildResult;
@@ -2527,7 +2653,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2527
2653
  hydrationPlanCache,
2528
2654
  rendererBuildLifetime,
2529
2655
  routeManager.getProgrammaticClientRoutes(),
2530
- mobileClient
2656
+ mobileClient,
2657
+ sourceSnapshot
2531
2658
  );
2532
2659
  } catch (retryError) {
2533
2660
  if (!(retryError instanceof IncompleteClientBuildOutputError)) throw retryError;
@@ -2536,6 +2663,7 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2536
2663
  );
2537
2664
  }
2538
2665
  }
2666
+ _optionalChain([sourceSnapshot, 'optionalAccess', _82 => _82.clear, 'call', _83 => _83()]);
2539
2667
  const ssrResult = ssrBuildResult.value;
2540
2668
  const routeRuntimeManifest = routeRuntimeManifestResult.value;
2541
2669
  const runtimeValidation = validateFarmRouteRuntimeDeployment(routeRuntimeManifest, preset);
@@ -2563,7 +2691,8 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2563
2691
  routeRuntimeManifest,
2564
2692
  configuredHeaderRoutes,
2565
2693
  nitroBuilderResultPromise,
2566
- lifecyclePluginManager
2694
+ lifecyclePluginManager,
2695
+ _optionalChain([markdownPrecompile, 'optionalAccess', _84 => _84.pages])
2567
2696
  );
2568
2697
  const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
2569
2698
  _path2.default.join(root, distDir),
@@ -2584,8 +2713,22 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2584
2713
  _chunkQMNWKQL4cjs.logger.error(`\u274C Build failed: ${error}`);
2585
2714
  throw error;
2586
2715
  } finally {
2587
- _optionalChain([rendererBuild, 'optionalAccess', _78 => _78.abort, 'call', _79 => _79()]);
2716
+ _optionalChain([rendererBuild, 'optionalAccess', _85 => _85.abort, 'call', _86 => _86()]);
2717
+ _optionalChain([markdownPrecompile, 'optionalAccess', _87 => _87.dispose, 'call', _88 => _88()]);
2718
+ }
2719
+ }
2720
+ function collectFarmPrerenderedMarkdownBodies(pageRoutes) {
2721
+ const bodies = [];
2722
+ for (const route of pageRoutes) {
2723
+ if (route.source === void 0 || !_chunkVZKCGHWCcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath)) continue;
2724
+ const { body } = _chunkVZKCGHWCcjs.parseMarkdownFrontmatter.call(void 0, route.source);
2725
+ const rendering = _chunkACAEFEOHcjs.resolveRouteRenderingConfig.call(void 0,
2726
+ _chunkVZKCGHWCcjs.readFarmMarkdownRouteConfig.call(void 0, body),
2727
+ route.source
2728
+ );
2729
+ if (rendering.ssg && rendering.revalidate === void 0) bodies.push(body);
2588
2730
  }
2731
+ return bodies;
2589
2732
  }
2590
2733
  function shouldBuildFarmMobileClient(config) {
2591
2734
  return Boolean(config.mobileClient) && !config.desktop;
@@ -2594,7 +2737,7 @@ function varyFarmNitroCacheRules(rules, headerNames) {
2594
2737
  if (headerNames.length === 0) return rules;
2595
2738
  return Object.fromEntries(
2596
2739
  Object.entries(rules).map(([source, rule]) => {
2597
- const cached = _optionalChain([rule, 'optionalAccess', _80 => _80.swr]) !== void 0 && rule.swr !== false || _optionalChain([rule, 'optionalAccess', _81 => _81.cache]) !== void 0 && rule.cache !== false;
2740
+ const cached = _optionalChain([rule, 'optionalAccess', _89 => _89.swr]) !== void 0 && rule.swr !== false || _optionalChain([rule, 'optionalAccess', _90 => _90.cache]) !== void 0 && rule.cache !== false;
2598
2741
  if (!cached || rule.cache === false) return [source, rule];
2599
2742
  const cache = rule.cache && typeof rule.cache === "object" ? rule.cache : {};
2600
2743
  const varies = [
@@ -2605,7 +2748,7 @@ function varyFarmNitroCacheRules(rules, headerNames) {
2605
2748
  );
2606
2749
  }
2607
2750
  async function writeSSRAssetsToClient(bundle, outputDir) {
2608
- const fs4 = await import("fs/promises");
2751
+ const fs5 = await import("fs/promises");
2609
2752
  const serverOnlyAssets = collectServerOnlySSRAssets(bundle);
2610
2753
  for (const [fileName, output] of Object.entries(bundle)) {
2611
2754
  if (output.type !== "asset" || serverOnlyAssets.has(fileName)) continue;
@@ -2614,40 +2757,40 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
2614
2757
  continue;
2615
2758
  }
2616
2759
  const filePath = _path2.default.join(outputDir, fileName);
2617
- await fs4.mkdir(_path2.default.dirname(filePath), { recursive: true });
2618
- await fs4.writeFile(filePath, output.source);
2760
+ await fs5.mkdir(_path2.default.dirname(filePath), { recursive: true });
2761
+ await fs5.writeFile(filePath, output.source);
2619
2762
  }
2620
2763
  }
2621
2764
  async function copyFarmDocsFontAssetsToClient(root, outputDir) {
2622
- const fs4 = await import("fs/promises");
2765
+ const fs5 = await import("fs/promises");
2623
2766
  await Promise.all(
2624
2767
  _chunkERMUL73Lcjs.resolveFarmDocsFontAssets.call(void 0, root).map(async ({ sourcePath, url }) => {
2625
2768
  const targetPath = _path2.default.join(outputDir, url.replace(/^\/+/, ""));
2626
- await fs4.mkdir(_path2.default.dirname(targetPath), { recursive: true });
2627
- await fs4.copyFile(sourcePath, targetPath);
2769
+ await fs5.mkdir(_path2.default.dirname(targetPath), { recursive: true });
2770
+ await fs5.copyFile(sourcePath, targetPath);
2628
2771
  })
2629
2772
  );
2630
2773
  }
2631
2774
  async function mergeBuiltFontCss(outputDir, fontCssSource) {
2632
- const fs4 = await import("fs/promises");
2775
+ const fs5 = await import("fs/promises");
2633
2776
  const fontCssPath = _path2.default.join(outputDir, "farm-fonts.css");
2634
2777
  let fontCss = fontCssSource;
2635
2778
  if (fontCss === void 0) {
2636
2779
  try {
2637
- fontCss = await fs4.readFile(fontCssPath);
2638
- } catch (e26) {
2780
+ fontCss = await fs5.readFile(fontCssPath);
2781
+ } catch (e30) {
2639
2782
  return;
2640
2783
  }
2641
2784
  }
2642
2785
  const clientCssPath = _path2.default.join(outputDir, "farm-client.css");
2643
2786
  let clientCss = "";
2644
2787
  try {
2645
- clientCss = await fs4.readFile(clientCssPath, "utf8");
2646
- } catch (e27) {
2788
+ clientCss = await fs5.readFile(clientCssPath, "utf8");
2789
+ } catch (e31) {
2647
2790
  }
2648
2791
  const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
2649
- await fs4.writeFile(fontCssPath, normalizedFontCss);
2650
- await fs4.writeFile(clientCssPath, _chunkTAU3OF5Bcjs.mergeFarmFontCss.call(void 0, clientCss, normalizedFontCss));
2792
+ await fs5.writeFile(fontCssPath, normalizedFontCss);
2793
+ await fs5.writeFile(clientCssPath, _chunk56HHUSR5cjs.mergeFarmFontCss.call(void 0, clientCss, normalizedFontCss));
2651
2794
  }
2652
2795
  function importsFarmClientBlockedPackage(id, packageName) {
2653
2796
  return id === packageName || id.startsWith(`${packageName}/`);
@@ -2663,14 +2806,14 @@ var IncompleteClientBuildOutputError = class extends Error {
2663
2806
  }
2664
2807
  };
2665
2808
  async function validateClientBuildOutput(root, srcDir, outputDir) {
2666
- const fs4 = await import("fs/promises");
2809
+ const fs5 = await import("fs/promises");
2667
2810
  const fingerprinted = await findFingerprintedClientEntry(outputDir);
2668
2811
  const clientEntryPath = _path2.default.join(outputDir, _nullishCoalesce(fingerprinted, () => ( "farm-client.js")));
2669
2812
  let clientEntrySize = 0;
2670
2813
  try {
2671
- const clientEntry = await fs4.stat(clientEntryPath);
2814
+ const clientEntry = await fs5.stat(clientEntryPath);
2672
2815
  if (clientEntry.isFile()) clientEntrySize = clientEntry.size;
2673
- } catch (e28) {
2816
+ } catch (e32) {
2674
2817
  }
2675
2818
  if (clientEntrySize === 0) {
2676
2819
  throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
@@ -2679,12 +2822,12 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
2679
2822
  const globalsCssPath = _path2.default.join(root, srcDir, "app", "globals.css");
2680
2823
  let expectsCss = false;
2681
2824
  try {
2682
- const globalsCss = await fs4.readFile(globalsCssPath, "utf8");
2825
+ const globalsCss = await fs5.readFile(globalsCssPath, "utf8");
2683
2826
  expectsCss = globalsCss.replace(/\/\*[\s\S]*?\*\//g, "").trim().length > 0;
2684
- } catch (e29) {
2827
+ } catch (e33) {
2685
2828
  }
2686
2829
  try {
2687
- const clientCss = await fs4.stat(clientCssPath);
2830
+ const clientCss = await fs5.stat(clientCssPath);
2688
2831
  if (expectsCss && (!clientCss.isFile() || clientCss.size === 0)) {
2689
2832
  throw new IncompleteClientBuildOutputError("farm-client.css is empty");
2690
2833
  }
@@ -2693,24 +2836,24 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
2693
2836
  if (expectsCss) {
2694
2837
  throw new IncompleteClientBuildOutputError("farm-client.css is missing");
2695
2838
  }
2696
- await fs4.writeFile(clientCssPath, "");
2839
+ await fs5.writeFile(clientCssPath, "");
2697
2840
  }
2698
2841
  }
2699
2842
  function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
2700
- const key = `${_path2.default.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${options.serverOwners === true}\0${options.serverTreeLayouts === true}\0${_path2.default.resolve(modulePath)}`;
2843
+ const key = _chunkNXGQIXR7cjs.getClientModuleHydrationPlanKey.call(void 0, modulePath, root, mode, options);
2701
2844
  let plan = cache.get(key);
2702
2845
  if (!plan) {
2703
- plan = _chunkHTXKSREFcjs.getClientModuleHydrationPlan.call(void 0, modulePath, root, mode, options);
2846
+ plan = _chunkNXGQIXR7cjs.getClientModuleHydrationPlan.call(void 0, modulePath, root, mode, options);
2704
2847
  cache.set(key, plan);
2705
2848
  }
2706
2849
  return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
2707
2850
  }
2708
- async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false) {
2851
+ async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false, sourceSnapshot) {
2709
2852
  if (!mobile) await _chunkE5UN4OWXcjs.removeFarmMobileClientManifest.call(void 0, _path2.default.dirname(outputDir));
2710
2853
  const viteBuild = productionVite.build;
2711
2854
  const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.cjs");
2712
2855
  const { PluginManager: PluginManager2 } = await import("./plugin-5PIQQVRP.cjs");
2713
- const fs4 = await import("fs/promises");
2856
+ const fs5 = await import("fs/promises");
2714
2857
  const pluginManager = new PluginManager2({
2715
2858
  config,
2716
2859
  isDev: false,
@@ -2718,52 +2861,53 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2718
2861
  });
2719
2862
  pluginManager.addPlugins(config.plugins || []);
2720
2863
  const clientPages = [];
2721
- const integrationProviders = _chunkJX5VOLAVcjs.getIntegrationProviders.call(void 0, config.integrations).filter(
2864
+ const integrationProviders = _chunk65OS2TOTcjs.getIntegrationProviders.call(void 0, config.integrations).filter(
2722
2865
  (provider) => provider.component || provider.type === "clerk"
2723
2866
  );
2724
2867
  const unsupportedIntegrationProvider = integrationProviders.find(
2725
2868
  (provider) => provider.supportsIsolatedHydration !== true
2726
2869
  );
2727
- if (_optionalChain([config, 'access', _82 => _82.experimental, 'optionalAccess', _83 => _83.isolatedClientHydration]) === "enabled" && _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _84 => _84.experimental, 'optionalAccess', _85 => _85.serverComponents])) !== "rsc" && unsupportedIntegrationProvider) {
2870
+ if (_optionalChain([config, 'access', _91 => _91.experimental, 'optionalAccess', _92 => _92.isolatedClientHydration]) === "enabled" && _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _93 => _93.experimental, 'optionalAccess', _94 => _94.serverComponents])) !== "rsc" && unsupportedIntegrationProvider) {
2728
2871
  _chunkQMNWKQL4cjs.logger.warn(
2729
2872
  `[Farm.js] isolated hydration kept route-wide because integration provider "${unsupportedIntegrationProvider.name}" does not declare supportsIsolatedHydration: true.`
2730
2873
  );
2731
2874
  }
2732
- const isolatedMode = _chunkHTXKSREFcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
2733
- _optionalChain([config, 'access', _86 => _86.experimental, 'optionalAccess', _87 => _87.isolatedClientHydration]),
2875
+ const isolatedMode = _chunkNXGQIXR7cjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
2876
+ _optionalChain([config, 'access', _95 => _95.experimental, 'optionalAccess', _96 => _96.isolatedClientHydration]),
2734
2877
  {
2735
- serverComponents: _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _88 => _88.experimental, 'optionalAccess', _89 => _89.serverComponents])) === "rsc",
2878
+ serverComponents: _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _97 => _97.experimental, 'optionalAccess', _98 => _98.serverComponents])) === "rsc",
2736
2879
  hasUnsupportedIntegrationProvider: Boolean(unsupportedIntegrationProvider)
2737
2880
  }
2738
2881
  );
2739
- const planOptions = _chunkHTXKSREFcjs.getFarmClientHydrationPlanOptions.call(void 0,
2882
+ const planOptions = _chunkNXGQIXR7cjs.getFarmClientHydrationPlanOptions.call(void 0,
2740
2883
  config.renderer,
2741
2884
  Boolean(unsupportedIntegrationProvider)
2742
2885
  );
2743
2886
  const pagePlanOptions = {
2744
2887
  ...planOptions,
2745
- serverOwners: _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _90 => _90.experimental, 'optionalAccess', _91 => _91.serverComponents])) === "islands"
2888
+ serverOwners: _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _99 => _99.experimental, 'optionalAccess', _100 => _100.serverComponents])) === "islands"
2746
2889
  };
2747
2890
  const layoutPlanOptions = {
2748
2891
  ...planOptions,
2749
2892
  serverTreeLayouts: pagePlanOptions.serverOwners
2750
2893
  };
2751
- const layoutAppliesToRoute = _chunkPXAHSCR6cjs.routeBoundaryCoversDirectory;
2894
+ const layoutAppliesToRoute = _chunkO2A6HE76cjs.routeBoundaryCoversDirectory;
2752
2895
  const routeDirectory = (route) => _nullishCoalesce(route.directory, () => ( route.pattern));
2753
- const islandsMode = _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _92 => _92.experimental, 'optionalAccess', _93 => _93.serverComponents])) === "islands";
2896
+ const islandsMode = _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _101 => _101.experimental, 'optionalAccess', _102 => _102.serverComponents])) === "islands";
2754
2897
  const adapterOwnsDocsRuntime = Boolean(
2755
- _chunk67MZTLTFcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access', _94 => _94.docs, 'optionalAccess', _95 => _95.enabled]) && _optionalChain([config, 'access', _96 => _96.docs, 'access', _97 => _97.adapter, 'optionalAccess', _98 => _98.server]) && config.docs.adapter.react
2898
+ _chunk67MZTLTFcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access', _103 => _103.docs, 'optionalAccess', _104 => _104.enabled]) && _optionalChain([config, 'access', _105 => _105.docs, 'access', _106 => _106.adapter, 'optionalAccess', _107 => _107.server]) && config.docs.adapter.react
2756
2899
  );
2757
- const docsEntries = _optionalChain([config, 'access', _99 => _99.docs, 'optionalAccess', _100 => _100.enabled]) ? _chunkHFUOLILAcjs.getFarmDocsRoots.call(void 0, config.docs).map(
2900
+ const docsEntries = _optionalChain([config, 'access', _108 => _108.docs, 'optionalAccess', _109 => _109.enabled]) ? _chunkZRCGPSUMcjs.getFarmDocsRoots.call(void 0, config.docs).map(
2758
2901
  (docsRoot) => `/${docsRoot.entry || "docs"}`.replace(/\/+/g, "/").replace(/\/$/, "") || "/"
2759
2902
  ) : [];
2760
2903
  const adapterDocsEntry = _nullishCoalesce(docsEntries[0], () => ( null));
2761
2904
  const isAdapterDocsRoute = (routePattern) => adapterOwnsDocsRuntime && docsEntries.some(
2762
2905
  (docsEntry) => docsEntry === "/" || routePattern === docsEntry || routePattern.startsWith(`${docsEntry}/`)
2763
2906
  );
2764
- const syntheticDocsEntry = _optionalChain([config, 'access', _101 => _101.docs, 'optionalAccess', _102 => _102.enabled]) && !adapterOwnsDocsRuntime ? adapterDocsEntry : null;
2907
+ const syntheticDocsEntry = _optionalChain([config, 'access', _110 => _110.docs, 'optionalAccess', _111 => _111.enabled]) && !adapterOwnsDocsRuntime ? adapterDocsEntry : null;
2765
2908
  const syntheticDocsPatterns = syntheticDocsEntry ? syntheticDocsEntry === "/" ? ["/", "/[...slug]"] : [syntheticDocsEntry, `${syntheticDocsEntry}/[...slug]`] : [];
2766
- const { clientLayouts, clientRouteSlots } = _chunkHTXKSREFcjs.withFarmSourceSnapshot.call(void 0, () => {
2909
+ const plan = (operation) => sourceSnapshot ? _chunkNXGQIXR7cjs.withFarmSourceSnapshotOf.call(void 0, sourceSnapshot, operation) : _chunkNXGQIXR7cjs.withFarmSourceSnapshot.call(void 0, operation);
2910
+ const { clientLayouts, clientRouteSlots } = plan(() => {
2767
2911
  const clientLayouts2 = layoutRoutes.map((layout) => {
2768
2912
  try {
2769
2913
  const metadata = getCachedClientModuleHydrationPlan(
@@ -2809,7 +2953,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2809
2953
  };
2810
2954
  }
2811
2955
  });
2812
- const markdownPagePlan = _chunkHTXKSREFcjs.createMarkdownPageHydrationPlanner.call(void 0,
2956
+ const markdownPagePlan = _chunkNXGQIXR7cjs.createMarkdownPageHydrationPlanner.call(void 0,
2813
2957
  _chunk2HW5LWAHcjs.resolveFarmMdxComponentsModulePath.call(void 0, _chunk2HW5LWAHcjs.resolveMdxConfig.call(void 0, config.mdx), root),
2814
2958
  root,
2815
2959
  isolatedMode,
@@ -2817,7 +2961,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2817
2961
  );
2818
2962
  const routePlans = pageRoutes.map((route) => ({
2819
2963
  route,
2820
- metadata: _chunkLGR7565Lcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
2964
+ metadata: _chunkVZKCGHWCcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
2821
2965
  route.modulePath,
2822
2966
  root,
2823
2967
  isolatedMode,
@@ -2825,7 +2969,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2825
2969
  pagePlanOptions
2826
2970
  )
2827
2971
  }));
2828
- _chunkHTXKSREFcjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
2972
+ _chunkNXGQIXR7cjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
2829
2973
  clientLayouts2.map((layout) => ({
2830
2974
  pattern: layout.pattern,
2831
2975
  depth: layout.pattern.split("/").filter(Boolean).length,
@@ -2834,7 +2978,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2834
2978
  [
2835
2979
  ...routePlans.map(({ route, metadata }) => ({
2836
2980
  pattern: routeDirectory(route),
2837
- depth: _chunkPXAHSCR6cjs.getRouteDirectoryDepth.call(void 0, routeDirectory(route)),
2981
+ depth: _chunkO2A6HE76cjs.getRouteDirectoryDepth.call(void 0, routeDirectory(route)),
2838
2982
  metadata
2839
2983
  })),
2840
2984
  ...syntheticDocsPatterns.map((pattern) => ({
@@ -2859,7 +3003,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2859
3003
  const matchesBuiltRoute = pageRoutes.some((route) => layoutAppliesToRoute(layout.pattern, routeDirectory(route))) || docsEntries.some((docsEntry) => layoutAppliesToRoute(layout.pattern, docsEntry));
2860
3004
  if (matchesBuiltRoute && layout.suppressedAsyncHydration) {
2861
3005
  _chunkQMNWKQL4cjs.logger.warn(
2862
- `\u26A0\uFE0F ${_chunkHTXKSREFcjs.describeSuppressedAsyncHydration.call(void 0, layout.pattern, layout.fallbackReason)}`
3006
+ `\u26A0\uFE0F ${_chunkNXGQIXR7cjs.describeSuppressedAsyncHydration.call(void 0, layout.pattern, layout.fallbackReason)}`
2863
3007
  );
2864
3008
  }
2865
3009
  }
@@ -2877,14 +3021,14 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2877
3021
  }
2878
3022
  }
2879
3023
  const serverSlotPlans = islandsMode ? routeSlots.flatMap((slot) => {
2880
- const plan = getCachedClientModuleHydrationPlan(
3024
+ const plan2 = getCachedClientModuleHydrationPlan(
2881
3025
  slot.modulePath,
2882
3026
  root,
2883
3027
  isolatedMode,
2884
3028
  hydrationPlanCache,
2885
3029
  { ...pagePlanOptions, serverOwners: true }
2886
3030
  );
2887
- return plan.isClientComponent ? [] : [{ slot, plan }];
3031
+ return plan2.isClientComponent ? [] : [{ slot, plan: plan2 }];
2888
3032
  }) : [];
2889
3033
  for (const { route, metadata } of routePlans) {
2890
3034
  if (isAdapterDocsRoute(route.pattern)) continue;
@@ -2894,15 +3038,15 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2894
3038
  );
2895
3039
  if (metadata.suppressedAsyncHydration) {
2896
3040
  _chunkQMNWKQL4cjs.logger.warn(
2897
- `\u26A0\uFE0F ${_chunkHTXKSREFcjs.describeSuppressedAsyncHydration.call(void 0, route.pattern, metadata.fallbackReason)}`
3041
+ `\u26A0\uFE0F ${_chunkNXGQIXR7cjs.describeSuppressedAsyncHydration.call(void 0, route.pattern, metadata.fallbackReason)}`
2898
3042
  );
2899
3043
  }
2900
3044
  const slotBoundaries = serverSlotPlans.filter(
2901
3045
  ({ slot }) => layoutAppliesToRoute(_nullishCoalesce(slot.ownerDirectory, () => ( slot.ownerPattern)), routeDirectory(route))
2902
- ).flatMap(({ plan }) => plan.isolatedBoundaries);
3046
+ ).flatMap(({ plan: plan2 }) => plan2.isolatedBoundaries);
2903
3047
  if (metadata.shouldHydrate || metadata.hasIsolatedClientBoundaries || applicableClientLayouts.length > 0 || slotBoundaries.length > 0) {
2904
3048
  const relativePath = route.modulePath.replace(root, "").replace(/^\//, "");
2905
- const islandStrategy = _chunkTAU3OF5Bcjs.resolveFarmRouteRootStrategy.call(void 0,
3049
+ const islandStrategy = _chunk56HHUSR5cjs.resolveFarmRouteRootStrategy.call(void 0,
2906
3050
  route,
2907
3051
  metadata,
2908
3052
  clientLayouts2,
@@ -2921,7 +3065,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2921
3065
  ...applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries || layout.serverTreeLayout).flatMap((layout) => layout.isolatedBoundaries)
2922
3066
  ],
2923
3067
  // The server renders a server tree only below a hydrating layout.
2924
- ..._chunkHTXKSREFcjs.usesFarmServerTree.call(void 0, metadata) && applicableClientLayouts.some((layout) => layout.shouldHydrate) ? { serverTree: true } : {}
3068
+ ..._chunkNXGQIXR7cjs.usesFarmServerTree.call(void 0, metadata) && applicableClientLayouts.some((layout) => layout.shouldHydrate) ? { serverTree: true } : {}
2925
3069
  });
2926
3070
  _chunkQMNWKQL4cjs.logger.info(`\u{1F4F1} Found hydratable route: ${route.pattern} -> ${route.modulePath}`);
2927
3071
  }
@@ -2958,7 +3102,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2958
3102
  }
2959
3103
  const clientRouteSlots2 = routeSlots.filter((slot) => {
2960
3104
  try {
2961
- const metadata = _chunkHTXKSREFcjs.getClientModuleMetadata.call(void 0, slot.modulePath, root);
3105
+ const metadata = _chunkNXGQIXR7cjs.getClientModuleMetadata.call(void 0, slot.modulePath, root);
2962
3106
  return metadata.shouldHydrate && (!islandsMode || metadata.isClientComponent);
2963
3107
  } catch (error) {
2964
3108
  _chunkQMNWKQL4cjs.logger.warn(`\u26A0\uFE0F Could not inspect route slot ${slot.modulePath}: ${error}`);
@@ -2970,10 +3114,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2970
3114
  _chunkQMNWKQL4cjs.logger.info(
2971
3115
  `\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
2972
3116
  );
3117
+ const clientRouteTable = createFarmClientRouteTable(clientPages);
3118
+ await writeFarmClientRouteTable(_path2.default.dirname(outputDir), clientRouteTable);
2973
3119
  const buildTarget = async (platform) => {
2974
3120
  const clientEntryRoot = _path2.default.join(root, ".farm", "tmp");
2975
- await fs4.mkdir(clientEntryRoot, { recursive: true });
2976
- const clientEntryDir = await fs4.mkdtemp(_path2.default.join(clientEntryRoot, "client-entry-"));
3121
+ await fs5.mkdir(clientEntryRoot, { recursive: true });
3122
+ const clientEntryDir = await fs5.mkdtemp(_path2.default.join(clientEntryRoot, "client-entry-"));
2977
3123
  const clientEntryPath = _path2.default.join(clientEntryDir, "farm-client-entry.tsx");
2978
3124
  const clientHydrationCode = generateClientHydrationEntry(
2979
3125
  clientPages,
@@ -2983,20 +3129,20 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2983
3129
  srcDir,
2984
3130
  adapterOwnsDocsRuntime ? false : _chunkDZZHTMWMcjs.isFarmDocsSearchEnabled.call(void 0, config.docs),
2985
3131
  adapterOwnsDocsRuntime ? void 0 : _chunkDZZHTMWMcjs.resolveFarmDocsSearchClientModule.call(void 0, root),
2986
- _optionalChain([config, 'access', _103 => _103.docs, 'optionalAccess', _104 => _104.enabled]) ? _chunkHFUOLILAcjs.getFarmDocsRoots.call(void 0, config.docs).map((docsRoot) => docsRoot.entry) : void 0,
2987
- adapterOwnsDocsRuntime ? _optionalChain([config, 'access', _105 => _105.docs, 'access', _106 => _106.adapter, 'optionalAccess', _107 => _107.react]) : void 0,
3132
+ _optionalChain([config, 'access', _112 => _112.docs, 'optionalAccess', _113 => _113.enabled]) ? _chunkZRCGPSUMcjs.getFarmDocsRoots.call(void 0, config.docs).map((docsRoot) => docsRoot.entry) : void 0,
3133
+ adapterOwnsDocsRuntime ? _optionalChain([config, 'access', _114 => _114.docs, 'access', _115 => _115.adapter, 'optionalAccess', _116 => _116.react]) : void 0,
2988
3134
  config.i18n,
2989
3135
  config.plugins,
2990
3136
  config.renderer,
2991
3137
  config.publicRuntimeConfig,
2992
3138
  config.trailingSlash,
2993
- _chunkJX5VOLAVcjs.getIntegrationProviders.call(void 0, config.integrations),
3139
+ _chunk65OS2TOTcjs.getIntegrationProviders.call(void 0, config.integrations),
2994
3140
  config.basePath,
2995
- _chunkTAU3OF5Bcjs.generateClientCachePersistenceCode.call(void 0, _chunkTAU3OF5Bcjs.resolveFarmClientCacheAdapterEntry.call(void 0, root, config.cache)),
3141
+ _chunk56HHUSR5cjs.generateClientCachePersistenceCode.call(void 0, _chunk56HHUSR5cjs.resolveFarmClientCacheAdapterEntry.call(void 0, root, config.cache)),
2996
3142
  adapterOwnsDocsRuntime ? _chunkSM2SYWARcjs.getFarmDocsAdapterConfigModule.call(void 0, config.docs) : void 0,
2997
- _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _108 => _108.experimental, 'optionalAccess', _109 => _109.serverComponents])) === "islands",
3143
+ _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _117 => _117.experimental, 'optionalAccess', _118 => _118.serverComponents])) === "islands",
2998
3144
  platform,
2999
- islandsMode ? _chunkHTXKSREFcjs.collectFarmServerStylesheets.call(void 0,
3145
+ islandsMode ? _chunkNXGQIXR7cjs.collectFarmServerStylesheets.call(void 0,
3000
3146
  [
3001
3147
  ...layoutRoutes.map((layout) => layout.modulePath),
3002
3148
  ...pageRoutes.filter((route) => !isAdapterDocsRoute(route.pattern)).map((route) => route.modulePath)
@@ -3006,14 +3152,18 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3006
3152
  );
3007
3153
  const entryName = platform === "mobile" ? _chunkE5UN4OWXcjs.FARM_MOBILE_CLIENT_ENTRY_NAME : "farm-client";
3008
3154
  const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientRouter(clientHydrationCode) : { entry: clientHydrationCode, router: void 0 };
3009
- await fs4.writeFile(clientEntryPath, clientEntry.entry);
3155
+ await fs5.writeFile(clientEntryPath, clientEntry.entry);
3156
+ await fs5.writeFile(
3157
+ _path2.default.join(clientEntryDir, `${FARM_CLIENT_ROUTE_TABLE_MODULE}.tsx`),
3158
+ generateFarmClientRouteTableModule(clientRouteTable)
3159
+ );
3010
3160
  if (clientEntry.router !== void 0) {
3011
- await fs4.writeFile(_path2.default.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
3161
+ await fs5.writeFile(_path2.default.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
3012
3162
  }
3013
3163
  const clientInput = { [entryName]: clientEntryPath };
3014
- if (platform === "web" && _chunkTAU3OF5Bcjs.canBootFarmIslandsClient.call(void 0, config)) {
3164
+ if (platform === "web" && _chunk56HHUSR5cjs.canBootFarmIslandsClient.call(void 0, config)) {
3015
3165
  const clientBootPath = _path2.default.join(clientEntryDir, "farm-client-boot.tsx");
3016
- await fs4.writeFile(
3166
+ await fs5.writeFile(
3017
3167
  clientBootPath,
3018
3168
  'import { startFarmIslandsBoot } from "@farm.js/core/internal/islands-boot";\nstartFarmIslandsBoot();\n'
3019
3169
  );
@@ -3030,9 +3180,9 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3030
3180
  _chunkQMNWKQL4cjs.logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
3031
3181
  } else {
3032
3182
  const postcssConfigPath = _path2.default.join(clientEntryDir, "postcss.config.cjs");
3033
- await fs4.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
3183
+ await fs5.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
3034
3184
  postcssSearchPath = clientEntryDir;
3035
- tailwindVitePlugin = await _chunkDMXMIE2Ccjs.loadTailwindVitePlugin.call(void 0, {
3185
+ tailwindVitePlugin = await _chunkENYBDM4Ucjs.loadTailwindVitePlugin.call(void 0, {
3036
3186
  builder: productionVite.builder,
3037
3187
  announce: true
3038
3188
  });
@@ -3054,7 +3204,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3054
3204
  outDir: outputDir,
3055
3205
  emptyOutDir: platform === "web",
3056
3206
  // Never public: see resolveFarmClientSourcemap.
3057
- sourcemap: resolveFarmClientSourcemap(_optionalChain([config, 'access', _110 => _110.vite, 'optionalAccess', _111 => _111.build, 'optionalAccess', _112 => _112.sourcemap])),
3207
+ sourcemap: resolveFarmClientSourcemap(_optionalChain([config, 'access', _119 => _119.vite, 'optionalAccess', _120 => _120.build, 'optionalAccess', _121 => _121.sourcemap])),
3058
3208
  assetsInlineLimit: 0,
3059
3209
  cssCodeSplit: false,
3060
3210
  // Bundle all CSS into one file
@@ -3066,7 +3216,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3066
3216
  hashCharacters: "hex",
3067
3217
  // Use predictable name for CSS so we can reference it in SSR HTML
3068
3218
  assetFileNames: (assetInfo) => {
3069
- if (_optionalChain([assetInfo, 'access', _113 => _113.name, 'optionalAccess', _114 => _114.endsWith, 'call', _115 => _115(".css")])) {
3219
+ if (_optionalChain([assetInfo, 'access', _122 => _122.name, 'optionalAccess', _123 => _123.endsWith, 'call', _124 => _124(".css")])) {
3070
3220
  return `${entryName}.css`;
3071
3221
  }
3072
3222
  return "assets/[name]-h[hash][extname]";
@@ -3083,7 +3233,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3083
3233
  }
3084
3234
  },
3085
3235
  plugins: [
3086
- _chunkTAU3OF5Bcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
3236
+ _chunk56HHUSR5cjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
3087
3237
  createFarmPrivateClientSourcemapsPlugin({
3088
3238
  outDir: _path2.default.join(
3089
3239
  _path2.default.dirname(outputDir),
@@ -3115,7 +3265,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3115
3265
  ...rendererVitePlugins,
3116
3266
  ...config.vite.plugins || [],
3117
3267
  farmServerOnlyEntriesPlugin({ platform }),
3118
- _chunkTAU3OF5Bcjs.farmDocsClientConfigPlugin.call(void 0,
3268
+ _chunk56HHUSR5cjs.farmDocsClientConfigPlugin.call(void 0,
3119
3269
  adapterOwnsDocsRuntime ? _chunkSM2SYWARcjs.getFarmDocsAdapterConfigModule.call(void 0, config.docs) : void 0
3120
3270
  ),
3121
3271
  // Plugin to redirect @farm.js/core imports to client-only exports
@@ -3148,7 +3298,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3148
3298
  },
3149
3299
  load: {
3150
3300
  filter: {
3151
- id: _chunkTAU3OF5Bcjs.exactIdPattern.call(void 0, [
3301
+ id: _chunk56HHUSR5cjs.exactIdPattern.call(void 0, [
3152
3302
  "\0empty-module",
3153
3303
  "\0empty-api-route",
3154
3304
  "\0farm-i18n-client-bridge",
@@ -3183,10 +3333,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3183
3333
  },
3184
3334
  farmIslandContainersPlugin(config),
3185
3335
  farmPlugin(
3186
- { ...config, isolatedClientBoundaryModules, programmaticClientRoutes },
3336
+ { ...config, isolatedClientBoundaryModules, programmaticClientRoutes, sourceSnapshot },
3187
3337
  pluginManager
3188
3338
  ),
3189
- _chunkHTXKSREFcjs.farmEnvironmentFunctionsPlugin.call(void 0, config)
3339
+ _chunkNXGQIXR7cjs.farmEnvironmentFunctionsPlugin.call(void 0, config)
3190
3340
  ],
3191
3341
  mode: "production",
3192
3342
  css: postcssSearchPath ? {
@@ -3194,7 +3344,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3194
3344
  } : void 0,
3195
3345
  // Ensure React is bundled for client
3196
3346
  resolve: {
3197
- alias: _chunkTAU3OF5Bcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
3347
+ alias: _chunk56HHUSR5cjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
3198
3348
  dedupe: [...config.renderer.dedupe || []]
3199
3349
  },
3200
3350
  // Optimize dependencies - exclude server-side code from client bundle
@@ -3208,10 +3358,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3208
3358
  }
3209
3359
  };
3210
3360
  await viteBuild(
3211
- _chunkTAU3OF5Bcjs.mergeFarmProductionViteConfig.call(void 0, clientViteConfig, config.vite, { clientOutput: true })
3361
+ _chunk56HHUSR5cjs.mergeFarmProductionViteConfig.call(void 0, clientViteConfig, config.vite, { clientOutput: true })
3212
3362
  );
3213
3363
  if (platform === "mobile") {
3214
- await fs4.rm(_path2.default.join(outputDir, `${entryName}.css`), { force: true });
3364
+ await fs5.rm(_path2.default.join(outputDir, `${entryName}.css`), { force: true });
3215
3365
  if (!await _chunkE5UN4OWXcjs.hasFarmMobileClientEntry.call(void 0, _path2.default.dirname(outputDir), outputDir)) {
3216
3366
  throw new IncompleteClientBuildOutputError(
3217
3367
  `${_chunkE5UN4OWXcjs.FARM_MOBILE_CLIENT_ENTRY_NAME}.js is missing or empty`
@@ -3223,8 +3373,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3223
3373
  }
3224
3374
  } finally {
3225
3375
  try {
3226
- await fs4.rm(clientEntryDir, { recursive: true, force: true });
3227
- } catch (e30) {
3376
+ await fs5.rm(clientEntryDir, { recursive: true, force: true });
3377
+ } catch (e34) {
3228
3378
  }
3229
3379
  }
3230
3380
  };
@@ -3244,6 +3394,7 @@ function generateUniversalRouterStateRuntime(streamNavigations = false) {
3244
3394
  return `
3245
3395
  const FARM_PAGE_STATE_KEY = "__farmPageState";
3246
3396
  const FARM_HISTORY_INDEX_KEY = "__farmHistoryIndex";
3397
+ const FARM_HISTORY_KEY = "__farmHistoryKey";
3247
3398
  const IDLE_NAVIGATION_STATE = {
3248
3399
  state: "idle",
3249
3400
  pending: false,
@@ -3263,8 +3414,8 @@ function createNavigationLocation(url) {
3263
3414
  };
3264
3415
  }
3265
3416
 
3266
- function scrollElementStorageKey(pathname, key) {
3267
- return "farm-scroll-" + pathname + ":" + key;
3417
+ function scrollElementStorageKey(scrollKey, key) {
3418
+ return "farm-scroll-" + scrollKey + ":" + key;
3268
3419
  }
3269
3420
 
3270
3421
  function createHistoryState(path, pageState, currentState) {
@@ -3309,7 +3460,7 @@ async function fetchFarmNavigationDocument(url, headers, recover = true, signal)
3309
3460
  return response;
3310
3461
  }
3311
3462
 
3312
- ${streamNavigations ? _chunkTAU3OF5Bcjs.FARM_NAVIGATION_STREAM_READER_SOURCE : ""}
3463
+ ${streamNavigations ? _chunk56HHUSR5cjs.FARM_NAVIGATION_STREAM_READER_SOURCE : ""}
3313
3464
 
3314
3465
  function clearFarmPrefetchCacheOnDeploymentMismatch(router, error) {
3315
3466
  if (error?.name === "FarmDeploymentMismatchError") {
@@ -3323,12 +3474,140 @@ function readHistoryIndex(state) {
3323
3474
  return Number.isSafeInteger(value) ? value : null;
3324
3475
  }
3325
3476
 
3477
+ function readHistoryKey(state) {
3478
+ if (!state || typeof state !== "object") return null;
3479
+ const value = state[FARM_HISTORY_KEY];
3480
+ return typeof value === "string" && value.length > 0 && value.length <= 64 ? value : null;
3481
+ }
3482
+
3483
+ // The time keeps keys unique across the reloads and documents that share a tab's sessionStorage.
3484
+ function createHistoryKey() {
3485
+ return Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 10);
3486
+ }
3487
+
3488
+ // Scroll positions are saved per history entry, so the same URL twice in history keeps two
3489
+ // positions. An entry Farm did not write has no key and falls back to its path.
3490
+ function historyScrollKey(state, path) {
3491
+ return readHistoryKey(state) || path;
3492
+ }
3493
+
3326
3494
  /*farm-router-end*/
3327
3495
  function hasAbsoluteNavigationHref(href) {
3328
3496
  return /^[a-zA-Z][a-zA-Z\\d+.-]*:/.test(href) || href.startsWith("//");
3329
3497
  }
3330
3498
  `.trim();
3331
3499
  }
3500
+ function generateFarmClientRouteTableRuntime(options) {
3501
+ const prefetch = `const farmPrefetchWhileRouteTableLoads = ${!options.streamNavigations};`;
3502
+ if (!options.table) {
3503
+ return `${prefetch}
3504
+ const clientRoutes = [];
3505
+ const clientRouteMatcher = createFarmRouter([]);
3506
+ const clientPageRouteMatcher = clientRouteMatcher;
3507
+ function loadFarmClientRouteTable() { return null; }
3508
+ function prefetchFarmClientRouteTable() {}
3509
+ const farmClientRoutesBoot = null;`;
3510
+ }
3511
+ return `${prefetch}
3512
+ let clientRoutes = [];
3513
+ let clientRouteMatcher = createFarmRouter([]);
3514
+ let clientPageRouteMatcher = clientRouteMatcher;
3515
+ let farmClientRouteTableLoad = null;
3516
+ let farmClientRouteTableLoaded = false;
3517
+
3518
+ function setFarmClientRoutes(routes) {
3519
+ clientRoutes = routes.map(function(route) {
3520
+ const load = typeof route.loader === "number" ? farmClientRouteLoaders[route.loader] : undefined;
3521
+ return { ...route, navigation: "html-fragment", load: load || null };
3522
+ });
3523
+ clientRouteMatcher = createFarmRouter(clientRoutes.map(function(route) {
3524
+ return { path: route.pattern, meta: route };
3525
+ }));
3526
+ clientPageRouteMatcher = ${options.docs ? `createFarmRouter(clientRoutes.filter(function(route) {
3527
+ return !route.docs;
3528
+ }).map(function(route) {
3529
+ return { path: route.pattern, meta: route };
3530
+ }))` : "clientRouteMatcher"};
3531
+ }
3532
+
3533
+ // Null once the whole table is in place, else a promise that settles when it is.
3534
+ function loadFarmClientRouteTable() {
3535
+ if (farmClientRouteTableLoaded) return null;
3536
+ return farmClientRouteTableLoad || (farmClientRouteTableLoad = import("./${FARM_CLIENT_ROUTE_TABLE_MODULE}").then(function(module) {
3537
+ setFarmClientRoutes(module.default);
3538
+ farmClientRouteTableLoaded = true;
3539
+ }, function(error) {
3540
+ farmClientRouteTableLoad = null;
3541
+ throw error;
3542
+ }));
3543
+ }
3544
+
3545
+ // A navigation to come (a prefetch, the lazy router) warms the table; that navigation handles a failure.
3546
+ function prefetchFarmClientRouteTable() {
3547
+ const table = loadFarmClientRouteTable();
3548
+ if (table) table.catch(function() {});
3549
+ }
3550
+
3551
+ const farmClientRoutesBoot = (function() {
3552
+ const boot = window.__FARM_CLIENT_ROUTES__;
3553
+ if (boot && Array.isArray(boot.routes) && boot.path === getFarmRoutePathname(window.location.pathname)) {
3554
+ setFarmClientRoutes(boot.routes);
3555
+ return null;
3556
+ }
3557
+ return loadFarmClientRouteTable().catch(function(error) {
3558
+ console.warn("[Farm.js] Could not load the client route table; the page was left as the server rendered it.", error);
3559
+ });
3560
+ })();
3561
+
3562
+ // A plain <a> has no prefetch, unlike Link: a pointer or focus reaching one warms the table its
3563
+ // navigation will read.
3564
+ const FARM_ROUTE_TABLE_INTENT_EVENTS = ["pointerover", "pointerdown", "focusin", "touchstart"];
3565
+ function warmFarmClientRouteTable(event) {
3566
+ const target = event.target;
3567
+ if (!target || !target.closest || !target.closest("a[href]")) return;
3568
+ for (const type of FARM_ROUTE_TABLE_INTENT_EVENTS) {
3569
+ document.removeEventListener(type, warmFarmClientRouteTable, true);
3570
+ }
3571
+ prefetchFarmClientRouteTable();
3572
+ }
3573
+ for (const type of FARM_ROUTE_TABLE_INTENT_EVENTS) {
3574
+ document.addEventListener(type, warmFarmClientRouteTable, { capture: true, passive: true });
3575
+ }`;
3576
+ }
3577
+ function generateFarmClientBootRoutesServerSource(tableSource) {
3578
+ return `// The client route table (client-route-table.ts), filled in from the client build. The client
3579
+ // loads it on its first navigation; a document names the entries its page boots with, found
3580
+ // with the client's own matcher, so its page hydrates without the table.
3581
+ const farmClientRouteTable = (() => {
3582
+ try {
3583
+ const table = JSON.parse(${tableSource});
3584
+ if (!Array.isArray(table) || table.length === 0) return null;
3585
+ const toRoute = function(route) { return { path: route.pattern, meta: route }; };
3586
+ const routes = createFarmRouter(table.map(toRoute));
3587
+ return {
3588
+ routes: routes,
3589
+ pages: table.some(function(route) { return route.docs; })
3590
+ ? createFarmRouter(table.filter(function(route) { return !route.docs; }).map(toRoute))
3591
+ : routes,
3592
+ };
3593
+ } catch {
3594
+ return null;
3595
+ }
3596
+ })();
3597
+
3598
+ // The entries the client's matchRoute and getFarmPageDirectory read for this route path.
3599
+ function getFarmClientBootRoutes(routePathname) {
3600
+ if (!farmClientRouteTable || typeof routePathname !== "string") return undefined;
3601
+ const routes = [];
3602
+ const matched = farmClientRouteTable.routes.match(routePathname);
3603
+ if (matched) {
3604
+ routes.push(matched.route.meta);
3605
+ const page = matched.route.meta.docs ? farmClientRouteTable.pages.match(routePathname) : null;
3606
+ if (page) routes.push(page.route.meta);
3607
+ }
3608
+ return { path: routePathname, routes: routes };
3609
+ }`;
3610
+ }
3332
3611
  function generateClientPageDirectorySource() {
3333
3612
  return `function getFarmPageDirectory(pathname) {
3334
3613
  const path = getFarmRoutePathname(pathname);
@@ -3655,7 +3934,8 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
3655
3934
 
3656
3935
  initializeHistory: function() {
3657
3936
  const existingIndex = readHistoryIndex(window.history.state);
3658
- if (existingIndex != null) {
3937
+ const existingKey = readHistoryKey(window.history.state);
3938
+ if (existingIndex != null && existingKey != null) {
3659
3939
  this.currentHistoryIndex = existingIndex;
3660
3940
  this.currentHistoryState = window.history.state;
3661
3941
  return;
@@ -3665,14 +3945,15 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
3665
3945
  ...(window.history.state && typeof window.history.state === "object"
3666
3946
  ? window.history.state
3667
3947
  : {}),
3668
- [FARM_HISTORY_INDEX_KEY]: 0,
3948
+ [FARM_HISTORY_INDEX_KEY]: existingIndex != null ? existingIndex : 0,
3949
+ [FARM_HISTORY_KEY]: existingKey || createHistoryKey(),
3669
3950
  };
3670
3951
  window.history.replaceState(initialState, "", window.location.href);
3671
- this.currentHistoryIndex = 0;
3952
+ this.currentHistoryIndex = initialState[FARM_HISTORY_INDEX_KEY];
3672
3953
  this.currentHistoryState = initialState;
3673
3954
  } catch {
3674
- this.currentHistoryIndex = null;
3675
- this.currentHistoryState = null;
3955
+ this.currentHistoryIndex = existingIndex;
3956
+ this.currentHistoryState = existingIndex != null ? window.history.state : null;
3676
3957
  }
3677
3958
  },
3678
3959
 
@@ -3965,6 +4246,9 @@ ${streamNavigations ? ` if (streamShell && response.body) {
3965
4246
  ? this.currentHistoryIndex
3966
4247
  : this.currentHistoryIndex + 1;
3967
4248
  if (nextIndex != null) nextState[FARM_HISTORY_INDEX_KEY] = nextIndex;
4249
+ // A push is a new entry; createHistoryState copied the current entry's key into it.
4250
+ nextState[FARM_HISTORY_KEY] =
4251
+ (action === "replace" && readHistoryKey(nextState)) || createHistoryKey();
3968
4252
  if (action === "replace") window.history.replaceState(nextState, "", url);
3969
4253
  else window.history.pushState(nextState, "", url);
3970
4254
  this.currentHistoryIndex = nextIndex;
@@ -3980,43 +4264,54 @@ ${streamNavigations ? ` if (streamShell && response.body) {
3980
4264
 
3981
4265
  registerScrollElement: function(key, element) {
3982
4266
  this.scrollElements.set(key, element);
3983
- this.restoreScrollElement(window.location.pathname + window.location.search, key, element);
4267
+ this.restoreScrollElement(
4268
+ historyScrollKey(this.currentHistoryState, window.location.pathname + window.location.search),
4269
+ key,
4270
+ element,
4271
+ );
3984
4272
  return () => {
3985
4273
  if (this.scrollElements.get(key) === element) this.scrollElements.delete(key);
3986
4274
  };
3987
4275
  },
3988
4276
 
3989
- saveScrollPosition: function(pathname) {
4277
+ // Without a key, saves the entry on screen (the unload handler, which may run on a stand-in).
4278
+ saveScrollPosition: function(scrollKey) {
4279
+ if (scrollKey === undefined) {
4280
+ scrollKey = historyScrollKey(
4281
+ this.currentHistoryState,
4282
+ window.location.pathname + window.location.search,
4283
+ );
4284
+ }
3990
4285
  try {
3991
4286
  sessionStorage.setItem(
3992
- "farm-scroll-" + pathname,
4287
+ "farm-scroll-" + scrollKey,
3993
4288
  JSON.stringify({ x: window.scrollX, y: window.scrollY }),
3994
4289
  );
3995
4290
  for (const [key, element] of this.scrollElements) {
3996
4291
  sessionStorage.setItem(
3997
- scrollElementStorageKey(pathname, key),
4292
+ scrollElementStorageKey(scrollKey, key),
3998
4293
  JSON.stringify({ x: element.scrollLeft, y: element.scrollTop }),
3999
4294
  );
4000
4295
  }
4001
4296
  } catch {}
4002
4297
  },
4003
4298
 
4004
- restoreScrollPosition: function(pathname) {
4299
+ restoreScrollPosition: function(scrollKey) {
4005
4300
  try {
4006
- const saved = sessionStorage.getItem("farm-scroll-" + pathname);
4301
+ const saved = sessionStorage.getItem("farm-scroll-" + scrollKey);
4007
4302
  if (saved) {
4008
4303
  const position = JSON.parse(saved);
4009
4304
  setTimeout(() => window.scrollTo(position.x, position.y), 0);
4010
4305
  }
4011
4306
  for (const [key, element] of this.scrollElements) {
4012
- this.restoreScrollElement(pathname, key, element);
4307
+ this.restoreScrollElement(scrollKey, key, element);
4013
4308
  }
4014
4309
  } catch {}
4015
4310
  },
4016
4311
 
4017
- restoreScrollElement: function(pathname, key, element) {
4312
+ restoreScrollElement: function(scrollKey, key, element) {
4018
4313
  try {
4019
- const saved = sessionStorage.getItem(scrollElementStorageKey(pathname, key));
4314
+ const saved = sessionStorage.getItem(scrollElementStorageKey(scrollKey, key));
4020
4315
  if (!saved) return;
4021
4316
  const position = JSON.parse(saved);
4022
4317
  setTimeout(() => {
@@ -4043,6 +4338,8 @@ const farmRouterReady = [];
4043
4338
  const farmRouterObserved = new Set();
4044
4339
 
4045
4340
  function loadFarmRouter() {
4341
+ // The router's first navigation needs the route table: fetch both at once.
4342
+ if (!farmRouterLoading) prefetchFarmClientRouteTable();
4046
4343
  return farmRouterLoading || (farmRouterLoading = import("./farm-client-router").then(function(module) {
4047
4344
  farmLoadedRouter = module.spaRouter;
4048
4345
  // The router module installs itself as the global; this object stays it, so a reference taken
@@ -4171,7 +4468,7 @@ function readFarmEntryImports(source) {
4171
4468
  for (const match of source.matchAll(/^import\s+([^"';]+?)\s+from\s+(["'][^"']+["'])/gm)) {
4172
4469
  const from = match[2];
4173
4470
  const named = /\{([^}]*)\}/.exec(match[1]);
4174
- for (const specifier of _nullishCoalesce(_optionalChain([named, 'optionalAccess', _116 => _116[1], 'optionalAccess', _117 => _117.split, 'call', _118 => _118(",")]), () => ( []))) {
4471
+ for (const specifier of _nullishCoalesce(_optionalChain([named, 'optionalAccess', _125 => _125[1], 'optionalAccess', _126 => _126.split, 'call', _127 => _127(",")]), () => ( []))) {
4175
4472
  const [imported, local] = specifier.trim().split(/\s+as\s+/);
4176
4473
  if (imported)
4177
4474
  bindings.push({ local: _nullishCoalesce(local, () => ( imported)), clause: `{ ${specifier.trim()} }`, from });
@@ -4266,7 +4563,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
4266
4563
  direction: {}
4267
4564
  }, plugins = [], renderer = _chunk67MZTLTFcjs.REACT_RENDERER, publicRuntimeConfig = void 0, trailingSlash = false, integrationProviders = [], basePath = "/", clientCachePersistence = { imports: "", init: "" }, docsConfigModule, islandValues = false, platform, serverStylesheets = []) {
4268
4565
  const toImportPath = (targetPath) => targetPath.replace(/\\/g, "/");
4269
- const clientPluginEntry = _chunkDMXMIE2Ccjs.generateFarmClientPluginEntryCode.call(void 0,
4566
+ const clientPluginEntry = _chunkENYBDM4Ucjs.generateFarmClientPluginEntryCode.call(void 0,
4270
4567
  plugins,
4271
4568
  root,
4272
4569
  srcDir,
@@ -4278,7 +4575,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
4278
4575
  import { createRoot, hydrateRoot } from "react-dom/client";` : appSetupPath ? `import React, { createRoot, hydrateRoot, configureApp as __farmConfigureApp } from ${JSON.stringify(renderer.client)};
4279
4576
  import __farmAppSetup from ${JSON.stringify(_chunkQMNWKQL4cjs.toPosixPath.call(void 0, appSetupPath))};
4280
4577
  __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot } from ${JSON.stringify(renderer.client)};`;
4281
- const providerClientCode = _chunkTAU3OF5Bcjs.generateFarmIntegrationProviderClientCode.call(void 0,
4578
+ const providerClientCode = _chunk56HHUSR5cjs.generateFarmIntegrationProviderClientCode.call(void 0,
4282
4579
  integrationProviders,
4283
4580
  root,
4284
4581
  _nullishCoalesce(renderer.componentExtensions, () => ( []))
@@ -4301,18 +4598,18 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
4301
4598
  const layoutImportStatements = [];
4302
4599
  const layoutRegistrations = [];
4303
4600
  const hydratingLayoutPatterns = layoutRoutes.filter((layout) => layout.shouldHydrate).map((layout) => layout.pattern);
4304
- const treeLayoutPatterns = islandValues ? _chunkPXAHSCR6cjs.getFarmServerTreeLayoutPatterns.call(void 0, layoutRoutes) : /* @__PURE__ */ new Set();
4601
+ const treeLayoutPatterns = islandValues ? _chunkO2A6HE76cjs.getFarmServerTreeLayoutPatterns.call(void 0, layoutRoutes) : /* @__PURE__ */ new Set();
4305
4602
  layoutRoutes.forEach((layout, index) => {
4306
4603
  const relativePath = toImportPath(layout.modulePath);
4307
4604
  const treeLayout = treeLayoutPatterns.has(layout.pattern);
4308
4605
  const rendersOnClient = treeLayout || !layout.hasIsolatedClientBoundaries && hydratingLayoutPatterns.some(
4309
- (pattern) => _chunkPXAHSCR6cjs.layoutsCanCoverSamePage.call(void 0, layout.pattern, pattern)
4606
+ (pattern) => _chunkO2A6HE76cjs.layoutsCanCoverSamePage.call(void 0, layout.pattern, pattern)
4310
4607
  );
4311
4608
  if (rendersOnClient && !treeLayout) {
4312
4609
  layoutImportStatements.push(`import Layout${index} from "${relativePath}";`);
4313
4610
  }
4314
- const groupScope = _chunkPXAHSCR6cjs.getRouteGroupScope.call(void 0, layout.pattern);
4315
- const groupFields = groupScope ? `, urlPattern: ${JSON.stringify(_chunkPXAHSCR6cjs.stripRouteGroups.call(void 0, layout.pattern))}, groupScope: ${JSON.stringify(groupScope)}` : "";
4611
+ const groupScope = _chunkO2A6HE76cjs.getRouteGroupScope.call(void 0, layout.pattern);
4612
+ const groupFields = groupScope ? `, urlPattern: ${JSON.stringify(_chunkO2A6HE76cjs.stripRouteGroups.call(void 0, layout.pattern))}, groupScope: ${JSON.stringify(groupScope)}` : "";
4316
4613
  layoutRegistrations.push(
4317
4614
  ` { pattern: ${JSON.stringify(layout.pattern)}${groupFields}, Component: ${rendersOnClient ? treeLayout ? `getFarmTreeLayoutComponent(${JSON.stringify(layout.pattern)})` : `Layout${index}` : "null"}, shouldHydrate: ${JSON.stringify(layout.shouldHydrate)}, islandStrategy: ${JSON.stringify(layout.islandStrategy)}${treeLayout ? ", serverTree: true" : ""} }`
4318
4615
  );
@@ -4382,7 +4679,7 @@ function isFarmDocsPath() {
4382
4679
  // Farm.js Client Runtime (no client components)
4383
4680
  ${cssImport}
4384
4681
  ${layoutImports}
4385
- import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
4682
+ import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, installFarmLinkPrefetch, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
4386
4683
  import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
4387
4684
  ${clientPluginEntry.imports}
4388
4685
  ${clientCachePersistence.imports}
@@ -4399,7 +4696,7 @@ mountFarmDocsSearch();
4399
4696
 
4400
4697
  ${generateUniversalRouterStateRuntime()}
4401
4698
 
4402
- ${_chunkTAU3OF5Bcjs.FARM_NAVIGATION_SCRIPT_SOURCE}
4699
+ ${_chunk56HHUSR5cjs.FARM_NAVIGATION_SCRIPT_SOURCE}
4403
4700
 
4404
4701
  // SPA Router for server-rendered pages (HTML swap)
4405
4702
  const spaRouter = {
@@ -4458,13 +4755,14 @@ ${generateUniversalRouterStateProperties()}
4458
4755
  this.cancelActiveNavigation();
4459
4756
  return;
4460
4757
  }
4758
+ // The entry still on screen: on Back/Forward the URL and history.state already name the destination.
4759
+ const fromScrollKey = historyScrollKey(this.currentHistoryState, from);
4461
4760
  if (action === "pop") {
4462
4761
  this.currentHistoryIndex = readHistoryIndex(options.popState);
4463
4762
  this.currentHistoryState = options.popState;
4464
4763
  }
4465
4764
 
4466
- // Save under the page still on screen: on Back/Forward the URL already names the destination.
4467
- this.saveScrollPosition(from);
4765
+ this.saveScrollPosition(fromScrollKey);
4468
4766
  const navigation = this.startNavigation(from, url, action);
4469
4767
  let clientNavigation;
4470
4768
  try {
@@ -4495,7 +4793,7 @@ ${generateUniversalRouterStateProperties()}
4495
4793
  if (url.hash) getHashTargetElement(url.hash)?.scrollIntoView();
4496
4794
  else window.scrollTo(0, 0);
4497
4795
  } else {
4498
- this.restoreScrollPosition(to);
4796
+ this.restoreScrollPosition(historyScrollKey(this.currentHistoryState, to));
4499
4797
  }
4500
4798
  });
4501
4799
  if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
@@ -4634,7 +4932,7 @@ window.addEventListener("beforeunload", function(event) {
4634
4932
  event.preventDefault();
4635
4933
  event.returnValue = "";
4636
4934
  }
4637
- spaRouter.saveScrollPosition(window.location.pathname + window.location.search);
4935
+ spaRouter.saveScrollPosition();
4638
4936
  });
4639
4937
 
4640
4938
  // Handle popstate (back/forward)
@@ -4662,10 +4960,13 @@ document.addEventListener("click", function(e) {
4662
4960
  e.preventDefault();
4663
4961
  spaRouter.navigate(href);
4664
4962
  });
4963
+
4964
+ // Link anchors on a page that does not hydrate prefetch through the router as Link would.
4965
+ installFarmLinkPrefetch();
4665
4966
  `.trim();
4666
4967
  }
4667
4968
  const imports = [];
4668
- const routeEntries = [];
4969
+ const routeLoaders = [];
4669
4970
  const routeSlotEntries = [];
4670
4971
  const isolatedBoundaryModules = /* @__PURE__ */ new Map();
4671
4972
  clientPages.forEach((page) => {
@@ -4675,16 +4976,11 @@ document.addEventListener("click", function(e) {
4675
4976
  toImportPath(boundary.modulePath)
4676
4977
  );
4677
4978
  }
4678
- const load = page.pageShouldHydrate ? `() => import(${JSON.stringify(toImportPath(page.modulePath))}).then((module) => module.default)` : "null";
4679
- routeEntries.push(` {
4680
- pattern: ${JSON.stringify(page.pattern)},${page.directory ? `
4681
- directory: ${JSON.stringify(page.directory)},` : ""}
4682
- pageShouldHydrate: ${JSON.stringify(page.pageShouldHydrate)},${page.docs ? "\n docs: true," : ""}
4683
- ${page.hasIsolatedClientBoundaries ? "hasIsolatedClientBoundaries: true," : ""}
4684
- islandStrategy: ${JSON.stringify(page.islandStrategy)},
4685
- navigation: "html-fragment",
4686
- load: ${load},
4687
- }`);
4979
+ if (page.pageShouldHydrate) {
4980
+ routeLoaders.push(
4981
+ ` () => import(${JSON.stringify(toImportPath(page.modulePath))}).then((module) => module.default),`
4982
+ );
4983
+ }
4688
4984
  });
4689
4985
  const isolatedHydrationEnabled = isolatedBoundaryModules.size > 0;
4690
4986
  const serverTreeEnabled = isolatedHydrationEnabled && clientPages.some((page) => page.serverTree);
@@ -4755,7 +5051,7 @@ ${layoutImports}
4755
5051
  ${rendererClientImports}
4756
5052
  ${isolatedHydrationImport}
4757
5053
  ${providerClientCode.imports}
4758
- import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
5054
+ import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, installChunkErrorRecovery, installFarmLinkPrefetch, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
4759
5055
  import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
4760
5056
  import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";
4761
5057
  ${clientPluginEntry.imports}
@@ -4774,18 +5070,15 @@ setFarmTrailingSlashPreference(${JSON.stringify(trailingSlash)});
4774
5070
  installChunkErrorRecovery();
4775
5071
  ${clientCachePersistence.init}
4776
5072
 
4777
- // Client component routes
4778
- const clientRoutes = [
4779
- ${routeEntries.join(",\n")}
5073
+ // The page modules that hydrate, by their route's \`loader\` index
5074
+ const farmClientRouteLoaders = [
5075
+ ${routeLoaders.join("\n")}
4780
5076
  ];
4781
- const clientRouteMatcher = createFarmRouter(clientRoutes.map(function(route) {
4782
- return { path: route.pattern, meta: route };
4783
- }));
4784
- ${clientPages.some((page) => page.docs) ? `const clientPageRouteMatcher = createFarmRouter(clientRoutes.filter(function(route) {
4785
- return !route.docs;
4786
- }).map(function(route) {
4787
- return { path: route.pattern, meta: route };
4788
- }));` : "const clientPageRouteMatcher = clientRouteMatcher;"}
5077
+ ${generateFarmClientRouteTableRuntime({
5078
+ table: clientPages.length > 0,
5079
+ docs: clientPages.some((page) => page.docs),
5080
+ streamNavigations: islandValues
5081
+ })}
4789
5082
  ${generateClientPageDirectorySource()}
4790
5083
 
4791
5084
  ${isolatedHydrationRuntime}
@@ -4837,7 +5130,7 @@ function hasHydratableLayout(pathname) {
4837
5130
  });
4838
5131
  }
4839
5132
 
4840
- ${_chunkTAU3OF5Bcjs.FARM_LAYOUT_ELEMENT_CLIENT_SOURCE}
5133
+ ${_chunk56HHUSR5cjs.FARM_LAYOUT_ELEMENT_CLIENT_SOURCE}
4841
5134
  // Wrap a page element with applicable layouts
4842
5135
  function wrapWithLayouts(pageElement, pathname, params) {
4843
5136
  const layouts = getApplicableLayouts(pathname);
@@ -4872,7 +5165,7 @@ function createLayoutPageBoundary(route, pageElement, serverHtml) {
4872
5165
  return React.createElement("div", props, pageElement);
4873
5166
  }
4874
5167
  let farmLastRouteState = null;
4875
- ${hasServerTreeLayouts && islandValues && isolatedHydrationEnabled ? `${_chunkTAU3OF5Bcjs.FARM_SERVER_TREE_LAYOUT_CLIENT_SOURCE}
5168
+ ${hasServerTreeLayouts && islandValues && isolatedHydrationEnabled ? `${_chunk56HHUSR5cjs.FARM_SERVER_TREE_LAYOUT_CLIENT_SOURCE}
4876
5169
  function farmTreeLayoutsOf(pathname) {
4877
5170
  return getApplicableLayouts(pathname).filter(function(layout) {
4878
5171
  return layout.serverTree === true;
@@ -5274,6 +5567,8 @@ async function hydrate() {
5274
5567
  window.__FARM_PPR_HYDRATING__ = true;
5275
5568
  await farmClientRuntime.start();
5276
5569
 
5570
+ // The route table, when the document named no entries for this URL.
5571
+ await farmClientRoutesBoot;
5277
5572
  const pathname = window.location.pathname;
5278
5573
  const matched = matchRoute(pathname);
5279
5574
  ${islandValues ? `if (
@@ -5436,7 +5731,7 @@ function fitsSegmentResponse(currentRoot, nextRoot) {
5436
5731
  return true;
5437
5732
  }` : ""}
5438
5733
 
5439
- ${_chunkTAU3OF5Bcjs.FARM_NAVIGATION_SCRIPT_SOURCE}
5734
+ ${_chunk56HHUSR5cjs.FARM_NAVIGATION_SCRIPT_SOURCE}
5440
5735
 
5441
5736
  function activateNavigationScripts(root) {
5442
5737
  for (const script of Array.from(root?.querySelectorAll?.("script") || [])) {
@@ -5539,7 +5834,7 @@ function getLayoutShell(root, patterns, index) {
5539
5834
  return shell.innerHTML;
5540
5835
  }
5541
5836
 
5542
- ${islandValues ? _chunkTAU3OF5Bcjs.FARM_REFRESH_FIELDS_SOURCE : ""}function replaceSharedLayoutBoundary(currentRoot, nextRoot, refresh = false) {
5837
+ ${islandValues ? _chunk56HHUSR5cjs.FARM_REFRESH_FIELDS_SOURCE : ""}function replaceSharedLayoutBoundary(currentRoot, nextRoot, refresh = false) {
5543
5838
  // A refresh keeps the islands still on the page: the ones in streamed Suspense content too.
5544
5839
  if (refresh) revealFarmStreamedContent(nextRoot);
5545
5840
  const currentPatterns = getLayoutPatterns(currentRoot);
@@ -5650,6 +5945,21 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
5650
5945
  return;
5651
5946
  }
5652
5947
 
5948
+ // The first navigation that matches a route waits for the client route table; a prefetch
5949
+ // usually loaded it already (generateFarmClientRouteTableRuntime). Without it (a deployment
5950
+ // that removed it, a network error), a document navigation is the safe fallback.
5951
+ const routeTable = loadFarmClientRouteTable();
5952
+ if (routeTable) {
5953
+ if (farmPrefetchWhileRouteTableLoads && !options.refresh) this.prefetch(url.href);
5954
+ try {
5955
+ await routeTable;
5956
+ } catch (error) {
5957
+ console.warn("[Farm.js] Could not load the client route table; navigating to " + href + " in full.", error);
5958
+ if (action === "push") window.location.assign(url.href);
5959
+ else window.location.replace(url.href);
5960
+ return;
5961
+ }
5962
+ }
5653
5963
  const pathname = url.pathname;
5654
5964
  const matched = matchRoute(pathname);
5655
5965
  const from = this.currentPath;
@@ -5666,6 +5976,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
5666
5976
  this.cancelActiveNavigation();
5667
5977
  return;
5668
5978
  }
5979
+ // The entry still on screen: on Back/Forward the URL and history.state already name the destination.
5980
+ const fromScrollKey = historyScrollKey(this.currentHistoryState, from);
5669
5981
  if (action === "pop") {
5670
5982
  this.currentHistoryIndex = readHistoryIndex(options.popState);
5671
5983
  this.currentHistoryState = options.popState;
@@ -5674,8 +5986,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
5674
5986
  // A route transition invalidates any trigger waiting on the previous DOM boundary.
5675
5987
  cancelPendingPageHydration();
5676
5988
  this.stopNavigationStream();
5677
- // Save under the page still on screen: on Back/Forward the URL already names the destination.
5678
- this.saveScrollPosition(from);
5989
+ this.saveScrollPosition(fromScrollKey);
5679
5990
  const navigation = this.startNavigation(from, url, action);
5680
5991
  // A refresh keeps the islands still on the page (islands mode).
5681
5992
  navigation.refresh = options.refresh === true;
@@ -5844,7 +6155,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
5844
6155
  if (url.hash) getHashTargetElement(url.hash)?.scrollIntoView();
5845
6156
  else window.scrollTo(0, 0);
5846
6157
  } else {
5847
- this.restoreScrollPosition(to);
6158
+ this.restoreScrollPosition(historyScrollKey(this.currentHistoryState, to));
5848
6159
  }
5849
6160
  await farmClientRuntime.resolveNavigation(clientNavigation);
5850
6161
  if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
@@ -6025,6 +6336,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6025
6336
  const url = new URL(href, window.location.href);
6026
6337
  if (isFarmExternalNavigationURL(url, window.location.origin)) return;
6027
6338
  if (isFarmDocsPath(url.pathname)) return;
6339
+ prefetchFarmClientRouteTable();
6028
6340
 
6029
6341
  // A prefetch warms an ordinary future navigation, which reads the bare
6030
6342
  // URL key. Carrying the intercept identity here both missed every real
@@ -6076,6 +6388,9 @@ void farmClientRuntime.start();
6076
6388
  /*farm-router-start*/
6077
6389
  spaRouter.initializeHistory();
6078
6390
  window.__FARM_SPA_ROUTER__ = spaRouter;
6391
+ // Link anchors on a page that does not hydrate prefetch through the router as Link would. In
6392
+ // islands mode this runs once the router loads, so a page still loads it only when it needs it.
6393
+ installFarmLinkPrefetch();
6079
6394
  /*farm-router-end*/
6080
6395
 
6081
6396
  window.addEventListener("beforeunload", function(event) {
@@ -6083,7 +6398,7 @@ window.addEventListener("beforeunload", function(event) {
6083
6398
  event.preventDefault();
6084
6399
  event.returnValue = "";
6085
6400
  }
6086
- spaRouter.saveScrollPosition(window.location.pathname + window.location.search);
6401
+ spaRouter.saveScrollPosition();
6087
6402
  });
6088
6403
 
6089
6404
  // Handle popstate (back/forward)
@@ -6119,11 +6434,11 @@ if (isFarmDocsSearchPage()) {
6119
6434
  void hydrate();
6120
6435
  `.trim();
6121
6436
  }
6122
- async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
6437
+ async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime, sourceSnapshot) {
6123
6438
  const viteBuild = productionVite.build;
6124
6439
  const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.cjs");
6125
6440
  const { PluginManager: PluginManager2 } = await import("./plugin-5PIQQVRP.cjs");
6126
- const fs4 = await import("fs/promises");
6441
+ const fs5 = await import("fs/promises");
6127
6442
  const pluginManager = new PluginManager2({
6128
6443
  config,
6129
6444
  isDev: false,
@@ -6138,12 +6453,12 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6138
6453
  buildLifetime: rendererBuildLifetime
6139
6454
  });
6140
6455
  if (!hasScopedPostcssConfig) {
6141
- postcssConfigDir = await fs4.mkdtemp(_path2.default.join(_os2.default.tmpdir(), "farm-postcss-"));
6142
- await fs4.writeFile(
6456
+ postcssConfigDir = await fs5.mkdtemp(_path2.default.join(_os2.default.tmpdir(), "farm-postcss-"));
6457
+ await fs5.writeFile(
6143
6458
  _path2.default.join(postcssConfigDir, "postcss.config.cjs"),
6144
6459
  "module.exports = { plugins: [] };\n"
6145
6460
  );
6146
- tailwindVitePlugin = await _chunkDMXMIE2Ccjs.loadTailwindVitePlugin.call(void 0, {
6461
+ tailwindVitePlugin = await _chunkENYBDM4Ucjs.loadTailwindVitePlugin.call(void 0, {
6147
6462
  builder: productionVite.builder,
6148
6463
  label: "for SSR"
6149
6464
  });
@@ -6165,7 +6480,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6165
6480
  fileName: entry.fileName,
6166
6481
  sourceType: "static",
6167
6482
  staticInfo: entry.staticInfo,
6168
- data: (await fs4.readFile(entry.modulePath)).toString("base64")
6483
+ data: (await fs5.readFile(entry.modulePath)).toString("base64")
6169
6484
  });
6170
6485
  continue;
6171
6486
  }
@@ -6225,10 +6540,11 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6225
6540
  const appDirs = _chunkMTBDJ326cjs.getFarmAppDirectories.call(void 0, config);
6226
6541
  let openAPIReference = null;
6227
6542
  if (config.openapi.enabled && config.openapi.route) {
6228
- const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-JOHU6BQI.cjs");
6543
+ const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-S77ZARTC.cjs");
6229
6544
  const openAPIManager = new OpenAPIManager(appDirs, config.openapi, {
6230
6545
  mode: "production",
6231
6546
  apiBaseURL: config.api.baseURL,
6547
+ routes: () => apiRouteManager.getRoutes().values(),
6232
6548
  loadModule: (filePath) => apiRouteManager.loadModule(filePath)
6233
6549
  });
6234
6550
  const spec = await openAPIManager.generateSpec();
@@ -6249,7 +6565,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6249
6565
  }))
6250
6566
  );
6251
6567
  const instrumentationPath = _chunk3GNHJ3RNcjs.resolveFarmInstrumentationFile.call(void 0, root, config.srcDir || "src");
6252
- const notFoundPath = _chunkTAU3OF5Bcjs.resolveFarmNotFoundComponentPath.call(void 0, config, appDirs);
6568
+ const notFoundPath = _chunk56HHUSR5cjs.resolveFarmNotFoundComponentPath.call(void 0, config, appDirs);
6253
6569
  if (notFoundPath) _chunkQMNWKQL4cjs.logger.info(`\u{1F4CB} Found custom 404 page: ${notFoundPath}`);
6254
6570
  layoutRoutes.sort((a, b) => {
6255
6571
  const depthA = a.pattern.split("/").filter(Boolean).length;
@@ -6266,14 +6582,14 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6266
6582
  const hasServerRuntimeIntegrations = configuredIntegrationValues.some(
6267
6583
  (integration) => typeof integration === "object" && integration !== null && (!("serverRuntime" in integration) || integration.serverRuntime !== false)
6268
6584
  );
6269
- const hasIntegrationProviders = _chunkJX5VOLAVcjs.getIntegrationProviders.call(void 0, config.integrations).some(
6585
+ const hasIntegrationProviders = _chunk65OS2TOTcjs.getIntegrationProviders.call(void 0, config.integrations).some(
6270
6586
  (provider) => provider.component || provider.type === "clerk"
6271
6587
  );
6272
6588
  const hasObservabilityHandler = !!config.observability && typeof config.observability === "object" && "onEvent" in config.observability;
6273
- const hasMdxComponentConfig = Boolean(_optionalChain([config, 'access', _119 => _119.mdx, 'optionalAccess', _120 => _120.components]));
6274
- const hasMiddlewareConfig = _chunkPXAHSCR6cjs.hasFarmMiddlewareConfig.call(void 0, config.middleware);
6275
- const hasRouteContextConfig = _chunkOXNZUCHNcjs.hasCustomFarmRouteContext.call(void 0, config);
6276
- const hasServerRuntimePlugins = _chunkDMXMIE2Ccjs.hasFarmServerRuntimePlugins.call(void 0, config.plugins);
6589
+ const hasMdxComponentConfig = Boolean(_optionalChain([config, 'access', _128 => _128.mdx, 'optionalAccess', _129 => _129.components]));
6590
+ const hasMiddlewareConfig = _chunkO2A6HE76cjs.hasFarmMiddlewareConfig.call(void 0, config.middleware);
6591
+ const hasRouteContextConfig = _chunkP3EZKU6Lcjs.hasCustomFarmRouteContext.call(void 0, config);
6592
+ const hasServerRuntimePlugins = _chunkENYBDM4Ucjs.hasFarmServerRuntimePlugins.call(void 0, config.plugins);
6277
6593
  const hasPluginRoutes = hasFarmPluginRoutes(config);
6278
6594
  const hasServerCacheConfig = hasFarmServerCacheConfig(config.cache);
6279
6595
  const configModulePath = hasServerRuntimeIntegrations || hasObservabilityHandler || hasMdxComponentConfig || hasMiddlewareConfig || hasRouteContextConfig || hasServerRuntimePlugins || hasPluginRoutes || hasServerCacheConfig || hasFarmServerStorageConfig(config.storage) || hasIntegrationProviders ? await findFarmConfigPath(root) : null;
@@ -6282,9 +6598,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6282
6598
  const hasConfiguredRuntimePlugins = Boolean(
6283
6599
  hasRuntimeConfigModule && (config.plugins || []).length > 0
6284
6600
  );
6285
- if (_chunkKDOZORJDcjs.hasFarmDocsRuntimeAdapter.call(void 0, config.docs)) {
6601
+ if (_chunk737MIVX3cjs.hasFarmDocsRuntimeAdapter.call(void 0, config.docs)) {
6286
6602
  const adapterGuardedPaths = new Set(getFarmDocsGuardedPaths(config, middlewareRoutes));
6287
- _chunkKDOZORJDcjs.assertFarmDocsAdapterServesNoGuardedPages.call(void 0,
6603
+ _chunk737MIVX3cjs.assertFarmDocsAdapterServesNoGuardedPages.call(void 0,
6288
6604
  config.docs,
6289
6605
  { root, srcDir: config.srcDir },
6290
6606
  (pathname) => adapterGuardedPaths.has(pathname),
@@ -6292,9 +6608,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6292
6608
  );
6293
6609
  }
6294
6610
  const farmDocsCspNonceMarker = _chunk6JHZPB52cjs.createFarmCspNonce.call(void 0, config.security);
6295
- const farmDocsPrecompiledManifest = _optionalChain([config, 'access', _121 => _121.docs, 'optionalAccess', _122 => _122.enabled]) && _chunkNLBHLPEOcjs.getFarmPresetRuntime.call(void 0, preset) === "edge" ? await _chunkHDPT6OYEcjs._runWithFarmCspNonce.call(void 0,
6611
+ const farmDocsPrecompiledManifest = _optionalChain([config, 'access', _130 => _130.docs, 'optionalAccess', _131 => _131.enabled]) && _chunkNLBHLPEOcjs.getFarmPresetRuntime.call(void 0, preset) === "edge" ? await _chunk4M5ESTJ2cjs._runWithFarmCspNonce.call(void 0,
6296
6612
  farmDocsCspNonceMarker,
6297
- async () => _optionalChain([config, 'access', _123 => _123.docs, 'access', _124 => _124.adapter, 'optionalAccess', _125 => _125.server]) ? await _chunkKDOZORJDcjs.compileFarmDocsAdapterEdgeManifest.call(void 0, config.docs, {
6613
+ async () => _optionalChain([config, 'access', _132 => _132.docs, 'access', _133 => _133.adapter, 'optionalAccess', _134 => _134.server]) ? await _chunk737MIVX3cjs.compileFarmDocsAdapterEdgeManifest.call(void 0, config.docs, {
6298
6614
  root,
6299
6615
  srcDir: config.srcDir,
6300
6616
  clientEntry: FARM_CLIENT_JS_SRC_PLACEHOLDER,
@@ -6408,7 +6724,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6408
6724
  // Adapters can render provider scripts by serializing function source.
6409
6725
  // keepNames injects helper calls into those functions; after Nitro
6410
6726
  // minifies the server chunk the helper is no longer in script scope.
6411
- keepNames: !(_optionalChain([config, 'access', _126 => _126.docs, 'optionalAccess', _127 => _127.enabled]) && _optionalChain([config, 'access', _128 => _128.docs, 'access', _129 => _129.adapter, 'optionalAccess', _130 => _130.server])),
6727
+ keepNames: !(_optionalChain([config, 'access', _135 => _135.docs, 'optionalAccess', _136 => _136.enabled]) && _optionalChain([config, 'access', _137 => _137.docs, 'access', _138 => _138.adapter, 'optionalAccess', _139 => _139.server])),
6412
6728
  jsxDev: false
6413
6729
  },
6414
6730
  // SSR configuration to externalize problematic modules
@@ -6458,10 +6774,10 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6458
6774
  define: {
6459
6775
  __FARM_API_BASE_URL__: JSON.stringify(config.api.baseURL),
6460
6776
  __FARM_ENV__: JSON.stringify(_chunk3EIPOTZVcjs.createBundledEnv.call(void 0, config.env)),
6461
- __FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _131 => _131.env, 'optionalAccess', _132 => _132.public]) || {})
6777
+ __FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _140 => _140.env, 'optionalAccess', _141 => _141.public]) || {})
6462
6778
  },
6463
6779
  plugins: [
6464
- _chunkTAU3OF5Bcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
6780
+ _chunk56HHUSR5cjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
6465
6781
  ...tailwindVitePlugin ? [tailwindVitePlugin] : [],
6466
6782
  ...rendererVitePlugins,
6467
6783
  ...config.vite.plugins || [],
@@ -6484,8 +6800,15 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6484
6800
  { ..._chunkNG2EZ6QScjs.createReactProductionModePlugin.call(void 0, ), enforce: "pre" },
6485
6801
  farmServerOnlyEntriesPlugin(),
6486
6802
  farmIslandContainersPlugin(config),
6487
- farmPlugin({ ...config, isolatedClientBoundaryModules }, pluginManager),
6488
- _chunkHTXKSREFcjs.farmEnvironmentFunctionsPlugin.call(void 0, config),
6803
+ farmPlugin(
6804
+ {
6805
+ ...config,
6806
+ isolatedClientBoundaryModules,
6807
+ sourceSnapshot
6808
+ },
6809
+ pluginManager
6810
+ ),
6811
+ _chunkNXGQIXR7cjs.farmEnvironmentFunctionsPlugin.call(void 0, config),
6489
6812
  ...hasRuntimeConfigModule ? [
6490
6813
  farmStripPlatformConfigPlugin(
6491
6814
  [
@@ -6497,7 +6820,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6497
6820
  {
6498
6821
  name: "farm-virtual-ssr-entry",
6499
6822
  resolveId: {
6500
- filter: { id: _chunkTAU3OF5Bcjs.exactIdPattern.call(void 0, [virtualEntryId, "\0virtual:farm-ssr-entry"]) },
6823
+ filter: { id: _chunk56HHUSR5cjs.exactIdPattern.call(void 0, [virtualEntryId, "\0virtual:farm-ssr-entry"]) },
6501
6824
  handler(id) {
6502
6825
  if (id === virtualEntryId || id === "\0virtual:farm-ssr-entry") {
6503
6826
  return virtualEntryId;
@@ -6506,7 +6829,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6506
6829
  }
6507
6830
  },
6508
6831
  load: {
6509
- filter: { id: _chunkTAU3OF5Bcjs.exactIdPattern.call(void 0, [virtualEntryId]) },
6832
+ filter: { id: _chunk56HHUSR5cjs.exactIdPattern.call(void 0, [virtualEntryId]) },
6510
6833
  handler(id) {
6511
6834
  if (id === virtualEntryId) {
6512
6835
  return virtualEntryCode;
@@ -6538,7 +6861,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6538
6861
  resolve: {
6539
6862
  alias: [
6540
6863
  ...shouldAliasReactServerToWebBuild(config.renderer, preset) ? [createFarmReactWebServerAlias(hasReactDomEdgeServerBuild(root))] : [],
6541
- ...Object.entries(_chunkTAU3OF5Bcjs.createFarmSourceAlias.call(void 0, root, config.srcDir)).map(
6864
+ ...Object.entries(_chunk56HHUSR5cjs.createFarmSourceAlias.call(void 0, root, config.srcDir)).map(
6542
6865
  ([find, replacement]) => ({ find, replacement })
6543
6866
  )
6544
6867
  ],
@@ -6546,12 +6869,12 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6546
6869
  dedupe: [...config.renderer.dedupe || []]
6547
6870
  }
6548
6871
  };
6549
- await viteBuild(_chunkTAU3OF5Bcjs.mergeFarmProductionViteConfig.call(void 0, serverViteConfig, config.vite));
6872
+ await viteBuild(_chunk56HHUSR5cjs.mergeFarmProductionViteConfig.call(void 0, serverViteConfig, config.vite));
6550
6873
  } finally {
6551
6874
  if (postcssConfigDir) {
6552
6875
  try {
6553
- await fs4.rm(postcssConfigDir, { recursive: true, force: true });
6554
- } catch (e31) {
6876
+ await fs5.rm(postcssConfigDir, { recursive: true, force: true });
6877
+ } catch (e35) {
6555
6878
  }
6556
6879
  }
6557
6880
  }
@@ -6564,7 +6887,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6564
6887
  function readFarmAppPackageIdentity(root) {
6565
6888
  try {
6566
6889
  return JSON.parse(_fs.readFileSync.call(void 0, _path2.default.join(root, "package.json"), "utf8"));
6567
- } catch (e32) {
6890
+ } catch (e36) {
6568
6891
  return {};
6569
6892
  }
6570
6893
  }
@@ -6576,32 +6899,32 @@ function readFarmPageLastModified(pageRoutes) {
6576
6899
  lastModified[route.pattern] = _fs.statSync.call(void 0,
6577
6900
  _nullishCoalesce(route.markdownSourcePath, () => ( route.modulePath))
6578
6901
  ).mtime.toISOString();
6579
- } catch (e33) {
6902
+ } catch (e37) {
6580
6903
  }
6581
6904
  }
6582
6905
  return lastModified;
6583
6906
  }
6584
6907
  function getFarmDocsGuardedPaths(config, middlewareRoutes) {
6585
- if (!_optionalChain([config, 'access', _133 => _133.docs, 'optionalAccess', _134 => _134.enabled])) return [];
6908
+ if (!_optionalChain([config, 'access', _142 => _142.docs, 'optionalAccess', _143 => _143.enabled])) return [];
6586
6909
  const options = { root: config.root, srcDir: config.srcDir };
6587
6910
  const guards = {
6588
6911
  config: { middleware: config.middleware, integrations: config.integrations },
6589
6912
  middlewareRoutes
6590
6913
  };
6591
- return _chunkHFUOLILAcjs.getFarmDocsRoots.call(void 0, config.docs).flatMap(
6592
- (docsRoot) => _chunkHFUOLILAcjs.discoverFarmDocsPages.call(void 0, _chunkHFUOLILAcjs.resolveFarmDocsContentDir.call(void 0, docsRoot, options), docsRoot)
6593
- ).flatMap((page) => [page.href, _chunkHFUOLILAcjs.getFarmDocsMarkdownPath.call(void 0, page.href)]).filter((pathname) => _chunkPXAHSCR6cjs.farmPathGuardCoversPage.call(void 0, guards, pathname));
6914
+ return _chunkZRCGPSUMcjs.getFarmDocsRoots.call(void 0, config.docs).flatMap(
6915
+ (docsRoot) => _chunkZRCGPSUMcjs.discoverFarmDocsPages.call(void 0, _chunkZRCGPSUMcjs.resolveFarmDocsContentDir.call(void 0, docsRoot, options), docsRoot)
6916
+ ).flatMap((page) => [page.href, _chunkZRCGPSUMcjs.getFarmDocsMarkdownPath.call(void 0, page.href)]).filter((pathname) => _chunkO2A6HE76cjs.farmPathGuardCoversPage.call(void 0, guards, pathname));
6594
6917
  }
6595
6918
  function getFarmAppOwnedDocsEnginePaths(agent, applicationMetadataRoutes) {
6596
- const llmsTxt = _optionalChain([agent, 'optionalAccess', _135 => _135.llmsTxt]);
6919
+ const llmsTxt = _optionalChain([agent, 'optionalAccess', _144 => _144.llmsTxt]);
6597
6920
  const ownedByFile = (kind) => applicationMetadataRoutes.some(
6598
6921
  (metadata) => metadata.kind === kind && metadata.pattern === "/"
6599
6922
  );
6600
6923
  return [
6601
- ..._optionalChain([llmsTxt, 'optionalAccess', _136 => _136.enabled]) || ownedByFile("llms") ? ["/llms.txt"] : [],
6602
- ..._optionalChain([llmsTxt, 'optionalAccess', _137 => _137.enabled]) && llmsTxt.full || ownedByFile("llms-full") ? ["/llms-full.txt"] : [],
6603
- ..._optionalChain([agent, 'optionalAccess', _138 => _138.sitemap, 'optionalAccess', _139 => _139.enabled]) || ownedByFile("sitemap") ? ["/sitemap.xml"] : [],
6604
- ..._optionalChain([agent, 'optionalAccess', _140 => _140.crawlers, 'optionalAccess', _141 => _141.enabled]) || ownedByFile("robots") ? ["/robots.txt"] : []
6924
+ ..._optionalChain([llmsTxt, 'optionalAccess', _145 => _145.enabled]) || ownedByFile("llms") ? ["/llms.txt"] : [],
6925
+ ..._optionalChain([llmsTxt, 'optionalAccess', _146 => _146.enabled]) && llmsTxt.full || ownedByFile("llms-full") ? ["/llms-full.txt"] : [],
6926
+ ..._optionalChain([agent, 'optionalAccess', _147 => _147.sitemap, 'optionalAccess', _148 => _148.enabled]) || ownedByFile("sitemap") ? ["/sitemap.xml"] : [],
6927
+ ..._optionalChain([agent, 'optionalAccess', _149 => _149.crawlers, 'optionalAccess', _150 => _150.enabled]) || ownedByFile("robots") ? ["/robots.txt"] : []
6605
6928
  ];
6606
6929
  }
6607
6930
  function generateFarmDocsAdapterHandlerArguments(docs, docsConfigModulePath) {
@@ -6612,7 +6935,7 @@ function generateFarmDocsAdapterHandlerArguments(docs, docsConfigModulePath) {
6612
6935
  docsPath: ${root}.entry,
6613
6936
  contentDir: ${root}.contentDir || ${root}.config?.contentDir,
6614
6937
  }`;
6615
- if (_optionalChain([docs, 'optionalAccess', _142 => _142.roots, 'optionalAccess', _143 => _143.length])) {
6938
+ if (_optionalChain([docs, 'optionalAccess', _151 => _151.roots, 'optionalAccess', _152 => _152.length])) {
6616
6939
  return {
6617
6940
  factory: "createFarmDocsAdapterMultiRuntimeHandler",
6618
6941
  config: `[farmDocsResolvedConfig, ...farmDocsResolvedConfig.roots].map((farmDocsRoot) => (${runtimeConfig("farmDocsRoot")}))`
@@ -6625,7 +6948,7 @@ function generateFarmDocsAdapterHandlerArguments(docs, docsConfigModulePath) {
6625
6948
  }
6626
6949
  function generateFarmDocsRuntimeConfigExpression(docs, precompiled = false) {
6627
6950
  if (!docs.enabled) return "null";
6628
- const serializableDocs = _optionalChain([docs, 'access', _144 => _144.roots, 'optionalAccess', _145 => _145.length]) ? {
6951
+ const serializableDocs = _optionalChain([docs, 'access', _153 => _153.roots, 'optionalAccess', _154 => _154.length]) ? {
6629
6952
  ...docs,
6630
6953
  // React elements and functions do not survive JSON; see runtimeConfig below.
6631
6954
  roots: docs.roots.map((docsRoot) => ({ ...docsRoot, runtimeConfig: void 0 }))
@@ -6659,7 +6982,7 @@ function generateFarmDocsRuntimeConfigExpression(docs, precompiled = false) {
6659
6982
  },
6660
6983
  }
6661
6984
  : ${JSON.stringify({ ...serializableDocs, runtimeConfig: void 0 })}`;
6662
- if (!_optionalChain([docs, 'access', _146 => _146.roots, 'optionalAccess', _147 => _147.length])) return expression;
6985
+ if (!_optionalChain([docs, 'access', _155 => _155.roots, 'optionalAccess', _156 => _156.length])) return expression;
6663
6986
  return `((farmDocs) => ({
6664
6987
  ...farmDocs,
6665
6988
  roots: farmDocs.roots.map((farmDocsRoot, index) => {
@@ -6676,7 +6999,7 @@ function toVirtualEntryImportSpecifier(modulePath) {
6676
6999
  return JSON.stringify(modulePath.replace(/\\/g, "/"));
6677
7000
  }
6678
7001
  function generateNativeAuthIntegrationSource(auth) {
6679
- if (_optionalChain([auth, 'optionalAccess', _148 => _148.enabled]) !== true) {
7002
+ if (_optionalChain([auth, 'optionalAccess', _157 => _157.enabled]) !== true) {
6680
7003
  return { importSource: "", registerSource: "" };
6681
7004
  }
6682
7005
  return {
@@ -6986,26 +7309,26 @@ ReactDOMServer.configureApp(__farmAppSetup);`;
6986
7309
  }
6987
7310
  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 = []) {
6988
7311
  const farmRendererDisabled = _chunk67MZTLTFcjs.isFarmRendererDisabled.call(void 0, config.renderer);
6989
- const farmIslandsMode = _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _149 => _149.experimental, 'optionalAccess', _150 => _150.serverComponents])) === "islands";
6990
- const farmClientBoot = _chunkTAU3OF5Bcjs.canBootFarmIslandsClient.call(void 0, config);
7312
+ const farmIslandsMode = _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _158 => _158.experimental, 'optionalAccess', _159 => _159.serverComponents])) === "islands";
7313
+ const farmClientBoot = _chunk56HHUSR5cjs.canBootFarmIslandsClient.call(void 0, config);
6991
7314
  const farmMobileClient = shouldBuildFarmMobileClient(config);
6992
7315
  const farmMobileShells = farmMobileClient && config.mobileShells ? config.mobileShells : null;
6993
7316
  const hasCompressionRuntime = config.compress && _chunkOCS3PSYRcjs.resolveFarmInstrumentationRuntime.call(void 0, preset) === "nodejs";
6994
- const servesAgentRobotsTxt = Boolean(_optionalChain([config, 'access', _151 => _151.agent, 'optionalAccess', _152 => _152.crawlers, 'optionalAccess', _153 => _153.enabled])) && !applicationMetadataRoutes.some(
7317
+ const servesAgentRobotsTxt = Boolean(_optionalChain([config, 'access', _160 => _160.agent, 'optionalAccess', _161 => _161.crawlers, 'optionalAccess', _162 => _162.enabled])) && !applicationMetadataRoutes.some(
6995
7318
  (metadata) => metadata.kind === "robots" && metadata.pattern === "/"
6996
7319
  );
6997
- const servesAgentSitemap = Boolean(_optionalChain([config, 'access', _154 => _154.agent, 'optionalAccess', _155 => _155.sitemap, 'optionalAccess', _156 => _156.enabled])) && !applicationMetadataRoutes.some(
7320
+ const servesAgentSitemap = Boolean(_optionalChain([config, 'access', _163 => _163.agent, 'optionalAccess', _164 => _164.sitemap, 'optionalAccess', _165 => _165.enabled])) && !applicationMetadataRoutes.some(
6998
7321
  (metadata) => metadata.kind === "sitemap" && metadata.pattern === "/"
6999
7322
  );
7000
- const servesDefaultMCP = _optionalChain([config, 'access', _157 => _157.agent, 'optionalAccess', _158 => _158.mcp]) === true && !_chunkTU6VAH4Vcjs.farmConfigMountsMCP.call(void 0, config) && !apiRoutes.some((route) => route.path === "/api/mcp");
7001
- const servesAiCatalog = _optionalChain([config, 'access', _159 => _159.agent, 'optionalAccess', _160 => _160.aiCatalog]) !== false;
7323
+ const servesDefaultMCP = _optionalChain([config, 'access', _166 => _166.agent, 'optionalAccess', _167 => _167.mcp]) === true && !_chunkVKRMO3EZcjs.farmConfigMountsMCP.call(void 0, config) && !apiRoutes.some((route) => route.path === "/api/mcp");
7324
+ const servesAiCatalog = _optionalChain([config, 'access', _168 => _168.agent, 'optionalAccess', _169 => _169.aiCatalog]) !== false;
7002
7325
  const hasPluginRuntime = hasRuntimeIntegrationConfig || hasServerRuntimePlugins;
7003
7326
  const hasInfraAnalyticsRuntime = config.analytics !== false && _chunkOCS3PSYRcjs.resolveFarmInstrumentationRuntime.call(void 0, preset) === "nodejs";
7004
7327
  const hasPrecompiledDocs = Boolean(farmDocsPrecompiledManifest);
7005
7328
  const adapterOwnsDocsRuntime = Boolean(
7006
- _chunk67MZTLTFcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access', _161 => _161.docs, 'optionalAccess', _162 => _162.enabled]) && _optionalChain([config, 'access', _163 => _163.docs, 'access', _164 => _164.adapter, 'optionalAccess', _165 => _165.server]) && config.docs.adapter.react
7329
+ _chunk67MZTLTFcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access', _170 => _170.docs, 'optionalAccess', _171 => _171.enabled]) && _optionalChain([config, 'access', _172 => _172.docs, 'access', _173 => _173.adapter, 'optionalAccess', _174 => _174.server]) && config.docs.adapter.react
7007
7330
  );
7008
- if (_optionalChain([config, 'access', _166 => _166.docs, 'optionalAccess', _167 => _167.enabled]) && _optionalChain([config, 'access', _168 => _168.docs, 'access', _169 => _169.roots, 'optionalAccess', _170 => _170.length]) && !adapterOwnsDocsRuntime) {
7331
+ if (_optionalChain([config, 'access', _175 => _175.docs, 'optionalAccess', _176 => _176.enabled]) && _optionalChain([config, 'access', _177 => _177.docs, 'access', _178 => _178.roots, 'optionalAccess', _179 => _179.length]) && !adapterOwnsDocsRuntime) {
7009
7332
  throw new Error(
7010
7333
  "Several docs roots need the docs adapter, which serves the React renderer only; Farm's built-in docs renderer serves a single docs root."
7011
7334
  );
@@ -7055,9 +7378,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7055
7378
  (image) => image.sourceType === "module"
7056
7379
  );
7057
7380
  const edgeMiddlewareFilePaths = farmTargetRunsEdgeMiddleware(preset) ? middlewareRoutes.filter(isFarmEdgeMiddlewareRoute).map((route) => route.filePath) : [];
7058
- const hasMiddlewareRuntime = middlewareRoutes.length > 0 || _chunkPXAHSCR6cjs.hasFarmMiddlewareConfig.call(void 0, config.middleware);
7059
- const farmDocsFontAssets = _optionalChain([config, 'access', _171 => _171.docs, 'optionalAccess', _172 => _172.enabled]) ? _chunkERMUL73Lcjs.toFarmDocsPublicFontAssets.call(void 0, _chunkERMUL73Lcjs.resolveFarmDocsFontAssets.call(void 0, config.root)) : [];
7060
- const integrationProviders = _chunkJX5VOLAVcjs.getIntegrationProviders.call(void 0, config.integrations);
7381
+ const hasMiddlewareRuntime = middlewareRoutes.length > 0 || _chunkO2A6HE76cjs.hasFarmMiddlewareConfig.call(void 0, config.middleware);
7382
+ const farmDocsFontAssets = _optionalChain([config, 'access', _180 => _180.docs, 'optionalAccess', _181 => _181.enabled]) ? _chunkERMUL73Lcjs.toFarmDocsPublicFontAssets.call(void 0, _chunkERMUL73Lcjs.resolveFarmDocsFontAssets.call(void 0, config.root)) : [];
7383
+ const integrationProviders = _chunk65OS2TOTcjs.getIntegrationProviders.call(void 0, config.integrations);
7061
7384
  const renderedIntegrationProviders = integrationProviders.filter(
7062
7385
  (provider) => provider.component || provider.type === "clerk"
7063
7386
  );
@@ -7066,16 +7389,16 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7066
7389
  `Integration provider components are not supported by the "${config.renderer.name}" renderer.`
7067
7390
  );
7068
7391
  }
7069
- const providerServerModules = _chunkTAU3OF5Bcjs.generateFarmIntegrationProviderServerModules.call(void 0,
7392
+ const providerServerModules = _chunk56HHUSR5cjs.generateFarmIntegrationProviderServerModules.call(void 0,
7070
7393
  renderedIntegrationProviders,
7071
7394
  config.root,
7072
7395
  _nullishCoalesce(config.renderer.componentExtensions, () => ( []))
7073
7396
  );
7074
7397
  const resolvedIntegrationProviderFallback = Object.fromEntries(
7075
7398
  Object.entries(config.integrations).flatMap(([name, integration]) => {
7076
- const configuredProviders = _optionalChain([integration, 'optionalAccess', _173 => _173.providers]);
7399
+ const configuredProviders = _optionalChain([integration, 'optionalAccess', _182 => _182.providers]);
7077
7400
  const providers = Array.isArray(configuredProviders) ? configuredProviders : [];
7078
- if (providers.some((provider) => typeof _optionalChain([provider, 'optionalAccess', _174 => _174.component]) === "function")) {
7401
+ if (providers.some((provider) => typeof _optionalChain([provider, 'optionalAccess', _183 => _183.component]) === "function")) {
7079
7402
  throw new Error(
7080
7403
  `Integration provider components in production must use an importable component reference, for example component: { module: "@/components/provider" }.`
7081
7404
  );
@@ -7086,22 +7409,22 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7086
7409
  const unsupportedIntegrationProvider = renderedIntegrationProviders.find(
7087
7410
  (provider) => provider.supportsIsolatedHydration !== true
7088
7411
  );
7089
- const isolatedHydrationMode = _chunkHTXKSREFcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
7090
- _optionalChain([config, 'access', _175 => _175.experimental, 'optionalAccess', _176 => _176.isolatedClientHydration]),
7412
+ const isolatedHydrationMode = _chunkNXGQIXR7cjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
7413
+ _optionalChain([config, 'access', _184 => _184.experimental, 'optionalAccess', _185 => _185.isolatedClientHydration]),
7091
7414
  {
7092
- serverComponents: _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _177 => _177.experimental, 'optionalAccess', _178 => _178.serverComponents])) === "rsc",
7415
+ serverComponents: _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _186 => _186.experimental, 'optionalAccess', _187 => _187.serverComponents])) === "rsc",
7093
7416
  hasUnsupportedIntegrationProvider: Boolean(unsupportedIntegrationProvider)
7094
7417
  }
7095
7418
  );
7096
- const hydrationPlanOptions = _chunkHTXKSREFcjs.getFarmClientHydrationPlanOptions.call(void 0,
7419
+ const hydrationPlanOptions = _chunkNXGQIXR7cjs.getFarmClientHydrationPlanOptions.call(void 0,
7097
7420
  config.renderer,
7098
7421
  Boolean(unsupportedIntegrationProvider)
7099
7422
  );
7100
7423
  const pageHydrationPlanOptions = {
7101
7424
  ...hydrationPlanOptions,
7102
- serverOwners: _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _179 => _179.experimental, 'optionalAccess', _180 => _180.serverComponents])) === "islands"
7425
+ serverOwners: _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _188 => _188.experimental, 'optionalAccess', _189 => _189.serverComponents])) === "islands"
7103
7426
  };
7104
- const { layoutHydrationPlans, pageHydrationPlans } = _chunkHTXKSREFcjs.withFarmSourceSnapshot.call(void 0, () => {
7427
+ const { layoutHydrationPlans, pageHydrationPlans } = _chunkNXGQIXR7cjs.withFarmSourceSnapshot.call(void 0, () => {
7105
7428
  const layoutHydrationPlans2 = layoutRoutes.map((layout) => ({
7106
7429
  ...layout,
7107
7430
  hydration: getCachedClientModuleHydrationPlan(
@@ -7112,7 +7435,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7112
7435
  { ...hydrationPlanOptions, serverTreeLayouts: pageHydrationPlanOptions.serverOwners }
7113
7436
  )
7114
7437
  }));
7115
- const markdownPagePlan = _chunkHTXKSREFcjs.createMarkdownPageHydrationPlanner.call(void 0,
7438
+ const markdownPagePlan = _chunkNXGQIXR7cjs.createMarkdownPageHydrationPlanner.call(void 0,
7116
7439
  _chunk2HW5LWAHcjs.resolveFarmMdxComponentsModulePath.call(void 0, _chunk2HW5LWAHcjs.resolveMdxConfig.call(void 0, config.mdx), config.root),
7117
7440
  config.root,
7118
7441
  isolatedHydrationMode,
@@ -7121,7 +7444,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7121
7444
  const pageHydrationPlans2 = new Map(
7122
7445
  pageRoutes.map((route) => [
7123
7446
  route.modulePath,
7124
- _chunkLGR7565Lcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
7447
+ _chunkVZKCGHWCcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
7125
7448
  route.modulePath,
7126
7449
  config.root,
7127
7450
  isolatedHydrationMode,
@@ -7132,7 +7455,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7132
7455
  );
7133
7456
  return { layoutHydrationPlans: layoutHydrationPlans2, pageHydrationPlans: pageHydrationPlans2 };
7134
7457
  });
7135
- _chunkHTXKSREFcjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
7458
+ _chunkNXGQIXR7cjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
7136
7459
  layoutHydrationPlans.map((layout) => ({
7137
7460
  pattern: layout.pattern,
7138
7461
  depth: layout.pattern.split("/").filter(Boolean).length,
@@ -7141,10 +7464,10 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7141
7464
  pageRoutes.map((route) => ({
7142
7465
  // Compared by directory so a grouped layout applies only inside its group.
7143
7466
  pattern: _nullishCoalesce(route.directory, () => ( route.pattern)),
7144
- depth: _chunkPXAHSCR6cjs.getRouteDirectoryDepth.call(void 0, _nullishCoalesce(route.directory, () => ( route.pattern))),
7467
+ depth: _chunkO2A6HE76cjs.getRouteDirectoryDepth.call(void 0, _nullishCoalesce(route.directory, () => ( route.pattern))),
7145
7468
  metadata: pageHydrationPlans.get(route.modulePath)
7146
7469
  })),
7147
- _chunkPXAHSCR6cjs.routeBoundaryCoversDirectory,
7470
+ _chunkO2A6HE76cjs.routeBoundaryCoversDirectory,
7148
7471
  { serverOwners: pageHydrationPlanOptions.serverOwners }
7149
7472
  );
7150
7473
  const providerServerImports = [
@@ -7162,7 +7485,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7162
7485
  apiRegistrations.push(`
7163
7486
  {
7164
7487
  path: ${JSON.stringify(route.path)},
7165
- methods: ${JSON.stringify(route.methods.filter((method) => !_optionalChain([route, 'access', _181 => _181.pluginMethods, 'optionalAccess', _182 => _182.includes, 'call', _183 => _183(method)])))},
7488
+ methods: ${JSON.stringify(route.methods.filter((method) => !_optionalChain([route, 'access', _190 => _190.pluginMethods, 'optionalAccess', _191 => _191.includes, 'call', _192 => _192(method)])))},
7166
7489
  endpoints: ${varName},
7167
7490
  }`);
7168
7491
  });
@@ -7175,9 +7498,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7175
7498
  }).map(({ route }) => route);
7176
7499
  orderedPageRoutes.forEach((route, index) => {
7177
7500
  const varName = `pageRoute${index}`;
7178
- if (_chunkLGR7565Lcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath)) {
7179
- const renderingDirective2 = _chunkCLEWORVYcjs.readRouteRenderingDirectiveFromFile.call(void 0, route.modulePath);
7180
- const markdownServerTree = pageHydrationPlanOptions.serverOwners && _chunkHTXKSREFcjs.usesFarmServerTree.call(void 0, pageHydrationPlans.get(route.modulePath));
7501
+ if (_chunkVZKCGHWCcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath)) {
7502
+ const renderingDirective2 = _chunkACAEFEOHcjs.readRouteRenderingDirectiveFromFile.call(void 0, route.modulePath);
7503
+ const markdownServerTree = pageHydrationPlanOptions.serverOwners && _chunkNXGQIXR7cjs.usesFarmServerTree.call(void 0, pageHydrationPlans.get(route.modulePath));
7181
7504
  pageRegistrations.push(`
7182
7505
  {
7183
7506
  pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
@@ -7202,7 +7525,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7202
7525
  `import * as ${varName} from ${toVirtualEntryImportSpecifier(route.modulePath)};`
7203
7526
  );
7204
7527
  const clientMetadata = pageHydrationPlans.get(route.modulePath);
7205
- const renderingDirective = _chunkCLEWORVYcjs.readRouteRenderingDirectiveFromFile.call(void 0, route.modulePath);
7528
+ const renderingDirective = _chunkACAEFEOHcjs.readRouteRenderingDirectiveFromFile.call(void 0, route.modulePath);
7206
7529
  pageRegistrations.push(`
7207
7530
  {
7208
7531
  pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
@@ -7210,8 +7533,8 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7210
7533
  module: ${varName},
7211
7534
  shouldHydrate: ${JSON.stringify(clientMetadata.shouldHydrate)},${clientMetadata.shouldHydrate ? `
7212
7535
  clientModule: ${JSON.stringify(_chunkQMNWKQL4cjs.toViteModuleId.call(void 0, route.modulePath, config.root))},` : ""}
7213
- islandStrategy: ${JSON.stringify(clientMetadata.islandStrategy)},${_chunkHTXKSREFcjs.usesFarmServerTree.call(void 0, clientMetadata) ? "\n serverTree: true," : ""}${(() => {
7214
- const rootStrategy = _chunkTAU3OF5Bcjs.resolveFarmRouteRootStrategy.call(void 0,
7536
+ islandStrategy: ${JSON.stringify(clientMetadata.islandStrategy)},${_chunkNXGQIXR7cjs.usesFarmServerTree.call(void 0, clientMetadata) ? "\n serverTree: true," : ""}${(() => {
7537
+ const rootStrategy = _chunk56HHUSR5cjs.resolveFarmRouteRootStrategy.call(void 0,
7215
7538
  route,
7216
7539
  clientMetadata,
7217
7540
  layoutHydrationPlans.map((layout) => ({ ...layout, ...layout.hydration })),
@@ -7230,7 +7553,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7230
7553
  });
7231
7554
  const layoutImports = [];
7232
7555
  const layoutRegistrations = [];
7233
- const treeLayoutPatterns = farmIslandsMode ? _chunkPXAHSCR6cjs.getFarmServerTreeLayoutPatterns.call(void 0,
7556
+ const treeLayoutPatterns = farmIslandsMode ? _chunkO2A6HE76cjs.getFarmServerTreeLayoutPatterns.call(void 0,
7234
7557
  layoutHydrationPlans.map((layout) => ({
7235
7558
  pattern: layout.pattern,
7236
7559
  shouldHydrate: layout.hydration.shouldHydrate,
@@ -7274,7 +7597,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7274
7597
  containerId: ${JSON.stringify(slot.containerId)},
7275
7598
  interception: ${JSON.stringify(slot.interception)},
7276
7599
  fallback: ${JSON.stringify(slot.fallback)},
7277
- hydrates: ${!farmIslandsMode || _chunkHTXKSREFcjs.getClientModuleMetadata.call(void 0, slot.modulePath, config.root).isClientComponent},
7600
+ hydrates: ${!farmIslandsMode || _chunkNXGQIXR7cjs.getClientModuleMetadata.call(void 0, slot.modulePath, config.root).isClientComponent},
7278
7601
  module: ${varName},
7279
7602
  }`);
7280
7603
  });
@@ -7285,12 +7608,12 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7285
7608
  errorImports.push(
7286
7609
  `import * as ${varName} from ${toVirtualEntryImportSpecifier(errorRoute.modulePath)};`
7287
7610
  );
7288
- const groupScope = _chunkPXAHSCR6cjs.getRouteGroupScope.call(void 0, errorRoute.pattern);
7611
+ const groupScope = _chunkO2A6HE76cjs.getRouteGroupScope.call(void 0, errorRoute.pattern);
7289
7612
  errorRegistrations.push(`
7290
7613
  {
7291
- pattern: ${JSON.stringify(_chunkPXAHSCR6cjs.stripRouteGroups.call(void 0, errorRoute.pattern))},${groupScope ? `
7614
+ pattern: ${JSON.stringify(_chunkO2A6HE76cjs.stripRouteGroups.call(void 0, errorRoute.pattern))},${groupScope ? `
7292
7615
  groupScope: ${JSON.stringify(groupScope)},
7293
- directoryDepth: ${_chunkPXAHSCR6cjs.getRouteDirectoryDepth.call(void 0, errorRoute.pattern)},` : ""}
7616
+ directoryDepth: ${_chunkO2A6HE76cjs.getRouteDirectoryDepth.call(void 0, errorRoute.pattern)},` : ""}
7294
7617
  module: ${varName},
7295
7618
  }`);
7296
7619
  });
@@ -7302,12 +7625,12 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7302
7625
  loadingImports.push(
7303
7626
  `import * as ${varName} from ${toVirtualEntryImportSpecifier(loadingRoute.modulePath)};`
7304
7627
  );
7305
- const groupScope = _chunkPXAHSCR6cjs.getRouteGroupScope.call(void 0, loadingRoute.pattern);
7628
+ const groupScope = _chunkO2A6HE76cjs.getRouteGroupScope.call(void 0, loadingRoute.pattern);
7306
7629
  loadingRegistrations.push(`
7307
7630
  {
7308
- pattern: ${JSON.stringify(_chunkPXAHSCR6cjs.stripRouteGroups.call(void 0, loadingRoute.pattern))},${groupScope ? `
7631
+ pattern: ${JSON.stringify(_chunkO2A6HE76cjs.stripRouteGroups.call(void 0, loadingRoute.pattern))},${groupScope ? `
7309
7632
  groupScope: ${JSON.stringify(groupScope)},
7310
- directoryDepth: ${_chunkPXAHSCR6cjs.getRouteDirectoryDepth.call(void 0, loadingRoute.pattern)},` : ""}
7633
+ directoryDepth: ${_chunkO2A6HE76cjs.getRouteDirectoryDepth.call(void 0, loadingRoute.pattern)},` : ""}
7311
7634
  module: ${varName},
7312
7635
  }`);
7313
7636
  });
@@ -7413,6 +7736,9 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7413
7736
  listFarmMCPLlmsTxtLinks,
7414
7737
  readFarmLlmsMarkdownFrom,
7415
7738
  registerFarmMCPServer,
7739
+ _listFarmRegisteredMCPServerTools,
7740
+ _observeFarmRegisteredMCPResponse,
7741
+ _readFarmRegisteredMCPCalls,
7416
7742
  renderFarmLlmsFullTxt,
7417
7743
  resolveFarmAgentOrigin,
7418
7744
  createFarmLlmsFullRenderer,
@@ -7454,6 +7780,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7454
7780
  resolveFarmInstrumentationRuntime,
7455
7781
  resolveFarmPreviewDeployment,
7456
7782
  resolveFarmWebRequestOrigin,
7783
+ _withFarmTrustedProxyOrigin,
7457
7784
  fetchFarmExternalRewrite,
7458
7785
  runWithFarmRequestSpan,
7459
7786
  createFarmSearchParams,
@@ -7470,7 +7797,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7470
7797
  createFarmDeploymentMismatchResponse,
7471
7798
  FARM_DEPLOYMENT_ID_HEADER,
7472
7799
  getFarmDeploymentMismatch,
7473
- withoutFarmDeploymentCookie,${config.mobileClient ? "\n createFarmNativeTreeResponse," : ""}${config.trailingSlash && (_optionalChain([config, 'access', _184 => _184.md, 'optionalAccess', _185 => _185.enabled]) || hasMarkdownPages) ? "\n toFarmTrailingSlashPageRequest," : ""}${hasInfraAnalyticsRuntime ? "\n resolveFarmDocsEngineRouteLabel,\n resolveFarmDocsRouteLabel,\n resolveFarmMarkdownRouteLabel,\n resolveFarmMCPRouteLabel,\n setFarmRouteLabel," : ""}${hasFarmServerStorageConfig(config.storage) ? "\n _registerFarmStorageModules,\n disposeFarmStorage,\n initFarmStorage," : ""}
7800
+ withoutFarmDeploymentCookie,${config.mobileClient ? "\n createFarmNativeTreeResponse," : ""}${config.trailingSlash && (_optionalChain([config, 'access', _193 => _193.md, 'optionalAccess', _194 => _194.enabled]) || hasMarkdownPages) ? "\n toFarmTrailingSlashPageRequest," : ""}${hasInfraAnalyticsRuntime ? "\n resolveFarmDocsEngineRouteLabel,\n resolveFarmDocsRouteLabel,\n resolveFarmMarkdownRouteLabel,\n resolveFarmMCPRouteLabel,\n setFarmRouteLabel," : ""}${hasFarmServerStorageConfig(config.storage) ? "\n _registerFarmStorageModules,\n disposeFarmStorage,\n initFarmStorage," : ""}
7474
7801
  } from "@farm.js/core/internal/production-runtime";${farmMobileClient ? `
7475
7802
  import { _applyFarmMobileShellClient } from "@farm.js/core/internal/production-runtime";
7476
7803
  // The mobile client documents load when a mobile shell asks for them (RFC 0004, 7.2), filled in
@@ -7527,7 +7854,7 @@ function resolveFarmMobileShellRender(request, route, routePathname) {
7527
7854
  import { getFarmFormState as farmFormState, getSharedLayoutPrefixLength, handleFarmFormActionRequest, ignoreFarmHeldValues, installFarmIslandValues, parseFarmLayoutChainHeader, renderFarmFormStateScript as farmFormStateScript } from "@farm.js/core/internal/production-runtime";
7528
7855
  import { installFarmIslandsServer } from "@farm.js/core/internal/islands-server";
7529
7856
  installFarmIslandsServer();
7530
- const farmFormActionsConfig = ${JSON.stringify(_chunk4P5634G6cjs.resolveServerActionsConfig.call(void 0, config.serverActions))};
7857
+ const farmFormActionsConfig = ${JSON.stringify(_chunkLIQJYEQPcjs.resolveServerActionsConfig.call(void 0, config.serverActions))};
7531
7858
  installFarmIslandValues();
7532
7859
  ${islandsActionKeyCode()}
7533
7860
  ${FARM_SEGMENT_NAVIGATION_SERVER_RUNTIME}` : `
@@ -7539,25 +7866,25 @@ function farmFormStateScript() { return ""; }`}`;
7539
7866
  const infraAnalyticsImport = hasInfraAnalyticsRuntime ? `import { ${hasPluginRuntime ? "createFarmInfraAnalyticsPlugin" : "createFarmInfraAnalyticsRecorder"} } from "@farm.js/core/internal/infra-analytics-runtime";` : "";
7540
7867
  const compressionRuntimeImport = hasCompressionRuntime ? `import { compressFarmResponse${hasPluginRuntime ? ", createCompressionPlugin" : ""} } from "@farm.js/core/internal/compression-runtime";` : "";
7541
7868
  const i18nServerImport = config.i18n.enabled ? `import { _runWithFarmI18nRequest, _setDefaultFarmI18nRuntime, createFarmI18nRuntime, getFarmI18nClientSnapshot } from "@farm.js/core/i18n/server";` : "";
7542
- const docsHandlerImport = _optionalChain([config, 'access', _186 => _186.docs, 'optionalAccess', _187 => _187.enabled]) ? hasPrecompiledDocs ? `import { createFarmDocsPrecompiledRuntime } from "@farm.js/core/internal/docs-precompiled-runtime";
7869
+ const docsHandlerImport = _optionalChain([config, 'access', _195 => _195.docs, 'optionalAccess', _196 => _196.enabled]) ? hasPrecompiledDocs ? `import { createFarmDocsPrecompiledRuntime } from "@farm.js/core/internal/docs-precompiled-runtime";
7543
7870
  const isFarmDocsAPIRequest = (requestOrPathname) => {
7544
7871
  const pathname = typeof requestOrPathname === "string"
7545
7872
  ? requestOrPathname
7546
7873
  : new URL(requestOrPathname.url).pathname;
7547
- const apiPath = ${JSON.stringify(_optionalChain([farmDocsPrecompiledManifest, 'optionalAccess', _188 => _188.apiPath]) || "/api/docs")};
7874
+ const apiPath = ${JSON.stringify(_optionalChain([farmDocsPrecompiledManifest, 'optionalAccess', _197 => _197.apiPath]) || "/api/docs")};
7548
7875
  return pathname === apiPath || pathname.startsWith(apiPath + "/");
7549
7876
  };` : adapterOwnsDocsRuntime ? `import { ${docsConfigModulePath ? "getFarmDocsConfigModuleRoot, " : ""}isFarmDocsAPIRequest } from "@farm.js/core/docs";
7550
- import { ${_optionalChain([config, 'access', _189 => _189.docs, 'access', _190 => _190.roots, 'optionalAccess', _191 => _191.length]) ? "createFarmDocsMultiRuntimeHandler as createFarmDocsAdapterMultiRuntimeHandler" : "createFarmDocsRuntimeHandler as createFarmDocsAdapterRuntimeHandler"} } from ${JSON.stringify(config.docs.adapter.server)};
7877
+ import { ${_optionalChain([config, 'access', _198 => _198.docs, 'access', _199 => _199.roots, 'optionalAccess', _200 => _200.length]) ? "createFarmDocsMultiRuntimeHandler as createFarmDocsAdapterMultiRuntimeHandler" : "createFarmDocsRuntimeHandler as createFarmDocsAdapterRuntimeHandler"} } from ${JSON.stringify(config.docs.adapter.server)};
7551
7878
  import * as FarmDocsAdapterReact from ${JSON.stringify(config.docs.adapter.react)};${docsConfigModulePath ? `
7552
7879
  import * as farmDocsConfigModule from ${toVirtualEntryImportSpecifier(docsConfigModulePath)};` : ""}` : `import { createFarmDocsAPIHandler, createFarmDocsHandler, isFarmDocsAPIRequest } from "@farm.js/core/docs";` : "";
7553
- const docsFontImport = _optionalChain([config, 'access', _192 => _192.docs, 'optionalAccess', _193 => _193.enabled]) && !hasPrecompiledDocs ? `import { resolveFarmLayoutFonts } from "@farm.js/core/font";` : "";
7554
- const docsRuntimeImport = _optionalChain([config, 'access', _194 => _194.docs, 'optionalAccess', _195 => _195.enabled]) && !hasPrecompiledDocs ? `import { existsSync as farmDocsExistsSync } from "node:fs";
7880
+ const docsFontImport = _optionalChain([config, 'access', _201 => _201.docs, 'optionalAccess', _202 => _202.enabled]) && !hasPrecompiledDocs ? `import { resolveFarmLayoutFonts } from "@farm.js/core/font";` : "";
7881
+ const docsRuntimeImport = _optionalChain([config, 'access', _203 => _203.docs, 'optionalAccess', _204 => _204.enabled]) && !hasPrecompiledDocs ? `import { existsSync as farmDocsExistsSync } from "node:fs";
7555
7882
  import { dirname as farmDocsDirname, join as farmDocsJoin } from "node:path";
7556
7883
  import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
7557
- const markdownHandlerImport = _optionalChain([config, 'access', _196 => _196.md, 'optionalAccess', _197 => _197.enabled]) ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
7884
+ const markdownHandlerImport = _optionalChain([config, 'access', _205 => _205.md, 'optionalAccess', _206 => _206.enabled]) ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
7558
7885
  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;";
7559
7886
  const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
7560
- const mdxComponentsPath = typeof _optionalChain([config, 'access', _198 => _198.mdx, 'optionalAccess', _199 => _199.components]) === "string" ? _path2.default.isAbsolute(config.mdx.components) ? config.mdx.components : _path2.default.join(config.root, config.mdx.components) : null;
7887
+ const mdxComponentsPath = typeof _optionalChain([config, 'access', _207 => _207.mdx, 'optionalAccess', _208 => _208.components]) === "string" ? _path2.default.isAbsolute(config.mdx.components) ? config.mdx.components : _path2.default.join(config.root, config.mdx.components) : null;
7561
7888
  const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
7562
7889
  const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
7563
7890
  const layerConfigImports = layerConfigPaths.map(
@@ -7577,14 +7904,14 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
7577
7904
  const nativeAuth = generateNativeAuthIntegrationSource(config.auth);
7578
7905
  const nativeMCP = _chunkVM57CK74cjs.generateNativeMCPPluginSource.call(void 0, config.mcp);
7579
7906
  const mobileSession = (config.plugins || []).some(
7580
- (plugin) => _optionalChain([plugin, 'optionalAccess', _200 => _200.name]) === _chunk4BS3HSY7cjs.FARM_MOBILE_SESSION_PLUGIN
7907
+ (plugin) => _optionalChain([plugin, 'optionalAccess', _209 => _209.name]) === _chunk4BS3HSY7cjs.FARM_MOBILE_SESSION_PLUGIN
7581
7908
  );
7582
7909
  const nativeServerFns = (config.plugins || []).some(
7583
- (plugin) => _optionalChain([plugin, 'optionalAccess', _201 => _201.name]) === _chunk4EBC7EMWcjs.FARM_NATIVE_SERVER_FN_PLUGIN
7584
- ) ? _chunkTDCP3Z4Tcjs.collectFarmNativeServerFns.call(void 0, {
7910
+ (plugin) => _optionalChain([plugin, 'optionalAccess', _210 => _210.name]) === _chunk4EBC7EMWcjs.FARM_NATIVE_SERVER_FN_PLUGIN
7911
+ ) ? _chunk35GBGSQZcjs.collectFarmNativeServerFns.call(void 0, {
7585
7912
  root: config.root,
7586
7913
  srcDir: config.srcDir,
7587
- entries: _chunkTDCP3Z4Tcjs.findFarmNativeScreenFiles.call(void 0, _chunkMTBDJ326cjs.getFarmAppDirectories.call(void 0, config))
7914
+ entries: _chunk35GBGSQZcjs.findFarmNativeScreenFiles.call(void 0, _chunkMTBDJ326cjs.getFarmAppDirectories.call(void 0, config))
7588
7915
  }) : void 0;
7589
7916
  const integrationImports = `
7590
7917
  ${configModulePath ? `import * as FarmUserConfigModule from ${toVirtualEntryImportSpecifier(configModulePath)};` : ""}
@@ -7599,7 +7926,7 @@ ${nativeServerFns ? `const __farmNativeServerFnRegistry = Object.assign(Object.c
7599
7926
  ${nativeServerFns.flatMap((module, index) => module.exports.map((entry) => ` ${JSON.stringify(entry.id)}: __farmNativeServerFns${index}[${JSON.stringify(entry.name)}],`)).join("\n")}
7600
7927
  });` : ""}
7601
7928
  `;
7602
- const imageRuntime = _chunkTAU3OF5Bcjs.resolveFarmImageServerRuntime.call(void 0, config.images, preset);
7929
+ const imageRuntime = _chunk56HHUSR5cjs.resolveFarmImageServerRuntime.call(void 0, config.images, preset);
7603
7930
  const imageRuntimeImport = imageRuntime === "none" ? "" : `import { _withFarmImageSourceClientAddress, createCloudflareImageTransformer, createFarmImageHandler } from "@farm.js/core/image/server";`;
7604
7931
  const imageNodeRuntimeImport = imageRuntime === "node" ? `import { createNodeImageFetcher, createNodeImageUrlValidator, createSharpImageTransformer } from "@farm.js/core/image/sharp";` : "";
7605
7932
  const apiHandlerCode = apiRoutes.length > 0 ? `
@@ -7728,7 +8055,7 @@ ${instrumentationImport}
7728
8055
  ${imageRuntimeImport}
7729
8056
  ${imageNodeRuntimeImport}
7730
8057
  import { farmFontPreloadHeader } from "virtual:farm-font-runtime";
7731
- import { isFarmRouteActive } from "@farm.js/core/router";
8058
+ import { createFarmRouter, isFarmRouteActive } from "@farm.js/core/router";
7732
8059
  ${rendererServerImports}
7733
8060
 
7734
8061
  ${routeClientGraphServerRuntime}
@@ -7779,9 +8106,9 @@ const farmUserConfig = ${configModulePath ? "(FarmUserConfigModule.default || Fa
7779
8106
  const farmRuntimeConfigs = [${[...layerConfigValues, "farmUserConfig"].join(", ")}].filter(Boolean);
7780
8107
  const farmResolvedRuntimeConfig = Object.assign({}, ...farmRuntimeConfigs);
7781
8108
 
7782
- function FarmDefault404Page() {
8109
+ function renderFarmDefault404Page() {
7783
8110
  return React.createElement(React.Fragment, null,
7784
- React.createElement("style", null, ${JSON.stringify(_chunkTAU3OF5Bcjs.DEFAULT_NOT_FOUND_STYLES)}),
8111
+ React.createElement("style", null, ${JSON.stringify(_chunk56HHUSR5cjs.DEFAULT_NOT_FOUND_STYLES)}),
7785
8112
  React.createElement("main", {
7786
8113
  className: "farm-default-not-found",
7787
8114
  "aria-labelledby": "farm-default-not-found-title",
@@ -7805,6 +8132,12 @@ function FarmDefault404Page() {
7805
8132
  );
7806
8133
  }
7807
8134
 
8135
+ // Renderers that compile their own components (Vue, Svelte) render a plain function as a
8136
+ // component only once it is marked; unmarked, Vue printed this page as "[object Object]".
8137
+ const FarmDefault404Page = typeof React.markFunctionComponent === "function"
8138
+ ? React.markFunctionComponent(renderFarmDefault404Page)
8139
+ : renderFarmDefault404Page;
8140
+
7808
8141
  /** The app's not-found page, or Farm's, without layouts. */
7809
8142
  function createFarmNotFoundElement(pathname) {
7810
8143
  const NotFoundPage = hasCustomNotFound && CustomNotFoundComponent ? CustomNotFoundComponent : FarmDefault404Page;
@@ -7918,24 +8251,24 @@ const farmImageHandler = ${imageRuntime === "none" ? "null" : imageRuntime === "
7918
8251
  validateRemoteUrl: createNodeImageUrlValidator(${JSON.stringify(config.images)}),
7919
8252
  onError(error) { console.error("[Farm Image]", error); },
7920
8253
  })`};
7921
- const farmMarkdownConfig = ${JSON.stringify(config.md)};${_optionalChain([config, 'access', _202 => _202.md, 'optionalAccess', _203 => _203.enabled]) || hasMarkdownPages ? config.trailingSlash ? `
8254
+ const farmMarkdownConfig = ${JSON.stringify(config.md)};${_optionalChain([config, 'access', _211 => _211.md, 'optionalAccess', _212 => _212.enabled]) || hasMarkdownPages ? config.trailingSlash ? `
7922
8255
  // A Markdown mirror, and a page.md source's page check, read the page at the URL it answers at
7923
8256
  // ('/about/'), so the trailing-slash 308 never answers in its place.
7924
8257
  const toFarmMarkdownPageRequest = (request) => toFarmTrailingSlashPageRequest(request, true);` : `
7925
8258
  const toFarmMarkdownPageRequest = (request) => request;` : ""}
7926
- const farmLlmsTxtConfig = ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _204 => _204.agent, 'optionalAccess', _205 => _205.llmsTxt]), () => ( { enabled: false, include: [], exclude: [] })))};
7927
- ${_optionalChain([config, 'access', _206 => _206.agent, 'optionalAccess', _207 => _207.llmsTxt, 'optionalAccess', _208 => _208.enabled]) ? "const farmLlmsFullRenderer = createFarmLlmsFullRenderer({ revalidate: farmLlmsTxtConfig.revalidate });\n" : ""}${servesAgentRobotsTxt ? `const farmAgentCrawlers = ${JSON.stringify(config.agent.crawlers)};` : ""}
8259
+ const farmLlmsTxtConfig = ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _213 => _213.agent, 'optionalAccess', _214 => _214.llmsTxt]), () => ( { enabled: false, include: [], exclude: [] })))};
8260
+ ${_optionalChain([config, 'access', _215 => _215.agent, 'optionalAccess', _216 => _216.llmsTxt, 'optionalAccess', _217 => _217.enabled]) ? "const farmLlmsFullRenderer = createFarmLlmsFullRenderer({ revalidate: farmLlmsTxtConfig.revalidate });\n" : ""}${servesAgentRobotsTxt ? `const farmAgentCrawlers = ${JSON.stringify(config.agent.crawlers)};` : ""}
7928
8261
  const farmMdxConfig = ${JSON.stringify({
7929
8262
  ...config.mdx,
7930
- components: typeof _optionalChain([config, 'access', _209 => _209.mdx, 'optionalAccess', _210 => _210.components]) === "string" ? config.mdx.components : void 0
8263
+ components: typeof _optionalChain([config, 'access', _218 => _218.mdx, 'optionalAccess', _219 => _219.components]) === "string" ? config.mdx.components : void 0
7931
8264
  })};
7932
8265
  const configuredFarmMdxComponents = farmUserConfig?.mdx?.components;
7933
- ${_optionalChain([config, 'access', _211 => _211.agent, 'optionalAccess', _212 => _212.noindexPreviews]) ? `// agent.noindexPreviews: the runtime environment decides, falling back to the
8266
+ ${_optionalChain([config, 'access', _220 => _220.agent, 'optionalAccess', _221 => _221.noindexPreviews]) ? `// agent.noindexPreviews: the runtime environment decides, falling back to the
7934
8267
  // environment this was built in, since Netlify exposes its deploy context only
7935
8268
  // to the build.
7936
8269
  const farmNoindexPreview = resolveFarmPreviewDeployment(
7937
8270
  globalThis.process?.env,
7938
- ${JSON.stringify(_chunkILQ5DKYFcjs.isFarmPreviewDeploymentEnvironment.call(void 0, process.env))},
8271
+ ${JSON.stringify(_chunkD4TYE6MYcjs.isFarmPreviewDeploymentEnvironment.call(void 0, process.env))},
7939
8272
  );` : ""}
7940
8273
  const farmMdxComponents = ${mdxComponentsPath ? `(FarmMdxComponentsModule.components || Reflect.get(FarmMdxComponentsModule, "default") || {})` : `(configuredFarmMdxComponents && typeof configuredFarmMdxComponents === "object" ? configuredFarmMdxComponents : {})`};
7941
8274
  const farmObservabilityConfig = farmUserConfig?.observability ?? ${JSON.stringify(
@@ -7981,7 +8314,7 @@ export const farmProductionLifecycle = createFarmProductionLifecycle({
7981
8314
  });
7982
8315
  const farmI18nRuntime = ${config.i18n.enabled ? `createFarmI18nRuntime(farmI18nConfig, ${JSON.stringify(i18nCatalogs)})` : "null"};
7983
8316
  ${config.i18n.enabled ? "_setDefaultFarmI18nRuntime(farmI18nRuntime);" : ""}
7984
- const farmDocsBundledContentDir = ${_optionalChain([config, 'access', _213 => _213.docs, 'optionalAccess', _214 => _214.enabled]) && !hasPrecompiledDocs ? `(() => {
8317
+ const farmDocsBundledContentDir = ${_optionalChain([config, 'access', _222 => _222.docs, 'optionalAccess', _223 => _223.enabled]) && !hasPrecompiledDocs ? `(() => {
7985
8318
  try {
7986
8319
  const currentDir = farmDocsDirname(farmDocsFileURLToPath(import.meta.url));
7987
8320
  const candidates = [
@@ -7993,7 +8326,7 @@ const farmDocsBundledContentDir = ${_optionalChain([config, 'access', _213 => _2
7993
8326
  } catch {
7994
8327
  return null;
7995
8328
  }
7996
- })()` : "null"};${_optionalChain([config, 'access', _215 => _215.docs, 'optionalAccess', _216 => _216.enabled]) && !hasPrecompiledDocs && _optionalChain([config, 'access', _217 => _217.docs, 'access', _218 => _218.roots, 'optionalAccess', _219 => _219.length]) ? `
8329
+ })()` : "null"};${_optionalChain([config, 'access', _224 => _224.docs, 'optionalAccess', _225 => _225.enabled]) && !hasPrecompiledDocs && _optionalChain([config, 'access', _226 => _226.docs, 'access', _227 => _227.roots, 'optionalAccess', _228 => _228.length]) ? `
7997
8330
  const farmDocsBundledRootsDir = (() => {
7998
8331
  try {
7999
8332
  const currentDir = farmDocsDirname(farmDocsFileURLToPath(import.meta.url));
@@ -8045,7 +8378,7 @@ const farmDocsModulePreloadPaths = farmDocsModulePreloads
8045
8378
  ),
8046
8379
  }
8047
8380
  : undefined;
8048
- const farmDocsHandler = ${_optionalChain([config, 'access', _220 => _220.docs, 'optionalAccess', _221 => _221.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `${adapterHandler.factory}(${adapterHandler.config}, {
8381
+ const farmDocsHandler = ${_optionalChain([config, 'access', _229 => _229.docs, 'optionalAccess', _230 => _230.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `${adapterHandler.factory}(${adapterHandler.config}, {
8049
8382
  rootDir: farmDocsRuntimeRoot,
8050
8383
  // A production build's content cannot change, so the adapter reads its
8051
8384
  // navigation once instead of scanning the content directory per request.
@@ -8066,7 +8399,7 @@ const farmDocsHandler = ${_optionalChain([config, 'access', _220 => _220.docs, '
8066
8399
  registerMCPServer: registerFarmMCPServer,
8067
8400
  // A page built with this keeps its HTML string, so the preload budget and the response
8068
8401
  // writer use it instead of reading and re-encoding the body. Older adapters ignore it.
8069
- createHtmlResponse: farmOwnedHtmlResponse,${_chunkKDOZORJDcjs.farmDocsAdapterServesGuardedPages.call(void 0, config.docs) ? `
8402
+ createHtmlResponse: farmOwnedHtmlResponse,${_chunk737MIVX3cjs.farmDocsAdapterServesGuardedPages.call(void 0, config.docs) ? `
8070
8403
  // The adapter keeps pages a path guard covers off search, llms.txt, the sitemap and MCP. It
8071
8404
  // asks about any path its own content lists, so the guards decide here, not a page list.
8072
8405
  isPathGuarded: (pathname) =>
@@ -8092,11 +8425,11 @@ const farmDocsHandler = ${_optionalChain([config, 'access', _220 => _220.docs, '
8092
8425
  isPathGuarded: isFarmDocsPathGuarded,
8093
8426
  basePath: ${JSON.stringify(config.basePath)},
8094
8427
  })` : "null"};
8095
- const farmDocsAPIHandler = ${_optionalChain([config, 'access', _222 => _222.docs, 'optionalAccess', _223 => _223.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig, isPathGuarded: isFarmDocsPathGuarded, basePath: ${JSON.stringify(config.basePath)} })` : "null"};
8428
+ const farmDocsAPIHandler = ${_optionalChain([config, 'access', _231 => _231.docs, 'optionalAccess', _232 => _232.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig, isPathGuarded: isFarmDocsPathGuarded, basePath: ${JSON.stringify(config.basePath)} })` : "null"};
8096
8429
 
8097
8430
  // API routes bundled at build time
8098
8431
  const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
8099
- ]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path15, methods }) => ({ path: path15, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
8432
+ ]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path17, methods }) => ({ path: path17, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
8100
8433
  // A plugin calling an app endpoint (an MCP tool, say) goes through the whole
8101
8434
  // pipeline, so the endpoint's middleware and integration guards run for it.
8102
8435
  function dispatchFarmPluginAPIRequest(request) {
@@ -8124,12 +8457,12 @@ const farmDeploymentCookiePath = ${JSON.stringify(config.basePath || "/")};
8124
8457
  // runtime request.
8125
8458
  const farmRuntimeErrorSlot = Symbol("farm.runtime.error.slot");
8126
8459
  const farmOpenAPIReference = ${JSON.stringify(openAPIReference)};
8127
- ${_optionalChain([config, 'access', _224 => _224.agent, 'optionalAccess', _225 => _225.apiCatalog]) ? `const farmApiCatalogInput = ${JSON.stringify(_chunk4YHGQDTTcjs.resolveFarmApiCatalogInput.call(void 0, config))};
8128
- ` : ""}${_optionalChain([config, 'access', _226 => _226.agent, 'optionalAccess', _227 => _227.manifest]) !== false ? `const farmAppManifestInput = ${JSON.stringify(
8129
- _chunk4YHGQDTTcjs.resolveFarmAppManifestInput.call(void 0, config, {
8460
+ ${_optionalChain([config, 'access', _233 => _233.agent, 'optionalAccess', _234 => _234.apiCatalog]) ? `const farmApiCatalogInput = ${JSON.stringify(_chunkDM2YGTRHcjs.resolveFarmApiCatalogInput.call(void 0, config))};
8461
+ ` : ""}${_optionalChain([config, 'access', _235 => _235.agent, 'optionalAccess', _236 => _236.manifest]) !== false ? `const farmAppManifestInput = ${JSON.stringify(
8462
+ _chunkDM2YGTRHcjs.resolveFarmAppManifestInput.call(void 0, config, {
8130
8463
  build: config.deploymentId,
8131
- packages: _chunkTAU3OF5Bcjs.resolveFarmAppPackages.call(void 0, config.root),
8132
- webmcpTools: config.plugins.some(({ name }) => name === "farm:webmcp") ? _chunkTAU3OF5Bcjs.collectFarmWebMCPTools.call(void 0, config.root, config.srcDir) : []
8464
+ packages: _chunk56HHUSR5cjs.resolveFarmAppPackages.call(void 0, config.root),
8465
+ webmcpTools: config.plugins.some(({ name }) => name === "farm:webmcp") ? _chunk56HHUSR5cjs.collectFarmWebMCPTools.call(void 0, config.root, config.srcDir) : []
8133
8466
  })
8134
8467
  )};
8135
8468
  ${servesDefaultMCP ? "farmAppManifestInput.defaultMCP = getFarmDefaultMCPServer;\n" : ""}// A guard written for an MCP server's path keeps its tools out of the public view.
@@ -8142,7 +8475,17 @@ farmAppManifestInput.guardCoversPath = (path) =>
8142
8475
  path,
8143
8476
  farmLocalAPIBasePath,
8144
8477
  );
8145
- ` : ""}
8478
+ ${_optionalChain([config, 'access', _237 => _237.docs, 'optionalAccess', _238 => _238.enabled]) ? `// A docs runtime's MCP server lists its tools when asked over MCP, in process. A build
8479
+ // can't change them, so they are read once.
8480
+ if (farmDocsHandler) {
8481
+ farmAppManifestInput.registeredMCP = (request) =>
8482
+ _listFarmRegisteredMCPServerTools(farmDocsHandler, request, {
8483
+ basePath: ${JSON.stringify(config.basePath)},
8484
+ guardCoversPath: farmAppManifestInput.guardCoversPath,
8485
+ cache: true,
8486
+ });
8487
+ }
8488
+ ` : ""}` : ""}
8146
8489
  function isFarmLocalAPIPathname(pathname) {
8147
8490
  return farmLocalAPIBasePath !== "/" &&
8148
8491
  (pathname === farmLocalAPIBasePath ||
@@ -8226,7 +8569,7 @@ function serializeFarmInlineValue(value) {
8226
8569
  .replace(/\\u2029/g, "\\\\u2029");
8227
8570
  }
8228
8571
 
8229
- function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, pageProps) {
8572
+ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, pageProps, routePathname) {
8230
8573
  const integrationManifest = ${hasRuntimeIntegrationConfig ? "getRegisteredIntegrationAPIManifest()" : "{}"};
8231
8574
  const serializedRouteSlots = serializeFarmInlineValue(selectedRouteSlots || []);
8232
8575
  const serializedPageProps = serializeFarmInlineValue(pageProps || {});
@@ -8235,6 +8578,13 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
8235
8578
  serializeFarmInlineValue(integrationManifest) +
8236
8579
  ';window.__FARM_ROUTE_SLOTS__=' + serializedRouteSlots +
8237
8580
  ';window.__FARM_DEPLOYMENT_ID__=' + serializeFarmInlineValue(farmDeploymentId) + ';';
8581
+ // The client boots at the canonical path when the script below moves it there.
8582
+ const bootRoutes = getFarmClientBootRoutes(
8583
+ typeof canonicalPath === "string" && canonicalPath.startsWith("/")
8584
+ ? getFarmRoutePathname(canonicalPath.split(/[?#]/)[0])
8585
+ : routePathname
8586
+ );
8587
+ if (bootRoutes) source += 'window.__FARM_CLIENT_ROUTES__=' + serializeFarmInlineValue(bootRoutes) + ';';
8238
8588
  if (typeof canonicalPath === "string" && canonicalPath.startsWith("/")) {
8239
8589
  const serializedPath = serializeFarmInlineValue(canonicalPath);
8240
8590
  source += 'if(location.pathname+location.search!==' + serializedPath + '){' +
@@ -8325,9 +8675,12 @@ async function farmKeptLayoutsRender(ReactDOMServer, layouts, keptCount, params)
8325
8675
  if (Layout) element = React.createElement(Layout, { children: element, params });
8326
8676
  }
8327
8677
  try {
8678
+ // The markup is thrown away, so client components render as plain components, as in a root
8679
+ // that hydrates whole: their props are not encoded for a browser that never receives them.
8680
+ // Server components, guards included, run as usual.
8328
8681
  const rendered = await renderFarmElement(
8329
8682
  ReactDOMServer,
8330
- wrapWithFarmIntegrationProviders(element),
8683
+ wrapWithFarmIntegrationProviders(wrapFarmRouteClientGraph(element)),
8331
8684
  );
8332
8685
  if (rendered.stream) {
8333
8686
  const reader = rendered.stream.getReader();
@@ -8882,7 +9235,7 @@ function peelFarmDocumentPrefix(markup) {
8882
9235
  let inner = markup.replace(/^\\s+/, "");
8883
9236
  let hoisted = "";
8884
9237
  const wrapper = /^<div\\b[^>]*style=["']display\\s*:\\s*contents;?\\s*["'][^>]*>/i;
8885
- const hoistable = /${_chunkPXAHSCR6cjs.HOISTED_HEAD_ELEMENT.source}/i;
9238
+ const hoistable = /${_chunkO2A6HE76cjs.HOISTED_HEAD_ELEMENT.source}/i;
8886
9239
  let match;
8887
9240
  while ((match = wrapper.exec(inner) || hoistable.exec(inner))) {
8888
9241
  if (!/^<div/i.test(match[0])) hoisted += match[0];
@@ -8911,7 +9264,7 @@ function opensFarmFullDocument(markup) {
8911
9264
  // them: its own head takes them. Matches the dev renderer's takeFarmHoistedHead.
8912
9265
  function takeFarmHoistedHead(markup) {
8913
9266
  if (opensFarmFullDocument(markup)) return { head: "", body: markup };
8914
- const hoistable = /${_chunkPXAHSCR6cjs.HOISTED_HEAD_ELEMENT.source}/i;
9267
+ const hoistable = /${_chunkO2A6HE76cjs.HOISTED_HEAD_ELEMENT.source}/i;
8915
9268
  let head = "";
8916
9269
  let body = markup;
8917
9270
  let match;
@@ -9047,6 +9400,9 @@ function createFarmErrorDocument(html, title) {
9047
9400
  ' ' + renderFarmClientEntryScript() + '\\n</body>';
9048
9401
  },
9049
9402
  );
9403
+ // The charset and viewport a layout's own document leaves out, as on a page and the
9404
+ // not-found page: without the viewport the error page lays out at desktop width on phones.
9405
+ fullHtml = ensureFarmDocumentMeta(fullHtml, renderViewportHead(undefined));
9050
9406
  return fullHtml.trim().startsWith("<!DOCTYPE")
9051
9407
  ? fullHtml
9052
9408
  : "<!DOCTYPE html>\\n" + fullHtml;
@@ -9061,6 +9417,8 @@ const farmClientModulePreloads = (() => {
9061
9417
  return null;
9062
9418
  }
9063
9419
  })();
9420
+ ${generateFarmClientBootRoutesServerSource(`"${FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER}"`)}
9421
+
9064
9422
  const farmClientEntryPreloadTags = farmClientModulePreloads
9065
9423
  ? farmClientModulePreloads.entry.map(renderFarmClientModulePreload).join("")
9066
9424
  : "";
@@ -9435,7 +9793,7 @@ function createFarmAgentRobotsResponse(request) {
9435
9793
  // its nearest layout's.
9436
9794
  const farmAgentGuardedPages = new Set(${JSON.stringify(
9437
9795
  pageRoutes.map((route) => route.pattern).filter(
9438
- (pattern) => !pattern.includes("[") && _chunkPXAHSCR6cjs.farmPathGuardCoversPage.call(void 0,
9796
+ (pattern) => !pattern.includes("[") && _chunkO2A6HE76cjs.farmPathGuardCoversPage.call(void 0,
9439
9797
  {
9440
9798
  config: { middleware: config.middleware, integrations: config.integrations },
9441
9799
  middlewareRoutes
@@ -9490,12 +9848,12 @@ ${servesDefaultMCP ? `// agent.mcp: the default read-only MCP server at /mcp, as
9490
9848
  // aside for a page route that answers /mcp and for any MCP server published or
9491
9849
  // registered at runtime, such as the docs engine's.
9492
9850
  const farmDefaultMCPServer = ${JSON.stringify(
9493
- _chunkTU6VAH4Vcjs.createFarmDefaultMCPServer.call(void 0, readFarmAppPackageIdentity(config.root), _chunkUVQRMUARcjs.FARM_VERSION)
9851
+ _chunkVKRMO3EZcjs.createFarmDefaultMCPServer.call(void 0, readFarmAppPackageIdentity(config.root), _chunkRSL3YFJGcjs.FARM_VERSION)
9494
9852
  )};
9495
9853
  let farmDefaultMCPRouteFree;
9496
9854
  function getFarmDefaultMCPServer() {
9497
9855
  if (farmDefaultMCPRouteFree === undefined) {
9498
- farmDefaultMCPRouteFree = !matchPageRoute(${JSON.stringify(_chunkTU6VAH4Vcjs.FARM_DEFAULT_MCP_PATH)});
9856
+ farmDefaultMCPRouteFree = !matchPageRoute(${JSON.stringify(_chunkVKRMO3EZcjs.FARM_DEFAULT_MCP_PATH)});
9499
9857
  }
9500
9858
  return farmDefaultMCPRouteFree ? resolveFarmDefaultMCPServer(farmDefaultMCPServer) : undefined;
9501
9859
  }
@@ -9684,7 +10042,7 @@ ${edgeMiddlewareFilePaths.length > 0 ? `
9684
10042
  // middleware guards is never prerendered. Read once: Nitro's prerender worker sets the variable.
9685
10043
  const farmEdgeMiddlewareFiles = new Set(${JSON.stringify(edgeMiddlewareFilePaths)});
9686
10044
  const farmPrerendering =
9687
- typeof process !== "undefined" && process.env?.${_chunkROCF6UQDcjs.FARM_PRERENDER_ENV} === "1";
10045
+ typeof process !== "undefined" && process.env?.${_chunk77SVUQM5cjs.FARM_PRERENDER_ENV} === "1";
9688
10046
  ` : ""}
9689
10047
  const farmMiddlewareRunner = ${hasMiddlewareRuntime ? `createProductionMiddlewareRunner({
9690
10048
  config: farmMiddlewareConfig,
@@ -9828,7 +10186,7 @@ function hasLocalRequestRoute(request, routePathname) {
9828
10186
  if (${imageRuntime === "none" ? "false" : `pathname === ${JSON.stringify(config.images.path)}`}) {
9829
10187
  return true;
9830
10188
  }
9831
- ${_optionalChain([config, 'access', _228 => _228.docs, 'optionalAccess', _229 => _229.enabled]) ? `const docsPath = normalizeRuntimePath(farmDocsResolvedConfig?.entry || "/docs");
10189
+ ${_optionalChain([config, 'access', _239 => _239.docs, 'optionalAccess', _240 => _240.enabled]) ? `const docsPath = normalizeRuntimePath(farmDocsResolvedConfig?.entry || "/docs");
9832
10190
  // The docs answer below the basePath; their API stays at /api/docs, as API routes do.
9833
10191
  const docsRoutePathname = stripFarmBasePath(pathname);
9834
10192
  if (
@@ -9856,7 +10214,7 @@ function getFarmPluginRequestOptions(request) {
9856
10214
  route: { ...route, pattern: normalizeRuntimePath(farmOpenAPIReference.route) },
9857
10215
  };
9858
10216
  }
9859
- const isDocsAPIRequest = ${_optionalChain([config, 'access', _230 => _230.docs, 'optionalAccess', _231 => _231.enabled]) ? "isFarmDocsAPIRequest(pathname)" : "false"};
10217
+ const isDocsAPIRequest = ${_optionalChain([config, 'access', _241 => _241.docs, 'optionalAccess', _242 => _242.enabled]) ? "isFarmDocsAPIRequest(pathname)" : "false"};
9860
10218
  const integrationMatch = ${hasServerRuntimeIntegrations ? `matchIntegrationRoute(serverRuntimeIntegrations, {
9861
10219
  pathname,
9862
10220
  method: request.method,
@@ -9940,7 +10298,7 @@ ${hasInfraAnalyticsRuntime ? `
9940
10298
  // endpoints, Markdown mirrors, and docs pages have no app route pattern, so they are
9941
10299
  // labeled here; route.pattern keeps meaning the matched app route for plugins.
9942
10300
  const farmBuiltInRoutePaths = new Set(${JSON.stringify(
9943
- _chunk4YHGQDTTcjs.listFarmBuiltInRoutePaths.call(void 0, {
10301
+ _chunkDM2YGTRHcjs.listFarmBuiltInRoutePaths.call(void 0, {
9944
10302
  agent: {
9945
10303
  ...config.agent,
9946
10304
  aiCatalog: servesAiCatalog,
@@ -9951,9 +10309,9 @@ const farmBuiltInRoutePaths = new Set(${JSON.stringify(
9951
10309
  openapi: openAPIReference
9952
10310
  })
9953
10311
  )});
9954
- ${_optionalChain([config, 'access', _232 => _232.docs, 'optionalAccess', _233 => _233.enabled]) ? `const farmDocsRouteLabelInput = {
10312
+ ${_optionalChain([config, 'access', _243 => _243.docs, 'optionalAccess', _244 => _244.enabled]) ? `const farmDocsRouteLabelInput = {
9955
10313
  path: normalizeRuntimePath(farmDocsResolvedConfig?.entry || "/docs"),
9956
- apiPath: ${JSON.stringify(_optionalChain([farmDocsPrecompiledManifest, 'optionalAccess', _234 => _234.apiPath]) || "/api/docs")},${_optionalChain([config, 'access', _235 => _235.docs, 'access', _236 => _236.roots, 'optionalAccess', _237 => _237.length]) ? "\n roots: farmDocsResolvedConfig.roots.map((farmDocsRoot) => farmDocsRoot.entry)," : ""}${farmDocsAnalyticsPages.length ? `
10314
+ apiPath: ${JSON.stringify(_optionalChain([farmDocsPrecompiledManifest, 'optionalAccess', _245 => _245.apiPath]) || "/api/docs")},${_optionalChain([config, 'access', _246 => _246.docs, 'access', _247 => _247.roots, 'optionalAccess', _248 => _248.length]) ? "\n roots: farmDocsResolvedConfig.roots.map((farmDocsRoot) => farmDocsRoot.entry)," : ""}${farmDocsAnalyticsPages.length ? `
9957
10315
  pages: new Set(${JSON.stringify(farmDocsAnalyticsPages)}),` : ""}
9958
10316
  };
9959
10317
  ` : ""}// The request's route payload, for a handler that learns what answered while it handles.
@@ -9969,11 +10327,11 @@ function labelFarmRequestOptions(options) {
9969
10327
  setFarmRouteLabel(options.route, mcpLabel);
9970
10328
  return options;
9971
10329
  }
9972
- ${_optionalChain([config, 'access', _238 => _238.docs, 'optionalAccess', _239 => _239.enabled]) ? `if (options.kind === "docs") {
10330
+ ${_optionalChain([config, 'access', _249 => _249.docs, 'optionalAccess', _250 => _250.enabled]) ? `if (options.kind === "docs") {
9973
10331
  setFarmRouteLabel(options.route, resolveFarmDocsRouteLabel(routePathname, farmDocsRouteLabelInput));
9974
10332
  return options;
9975
10333
  }` : ""}
9976
- ${_optionalChain([config, 'access', _240 => _240.md, 'optionalAccess', _241 => _241.enabled]) || hasMarkdownPages ? `const markdownLabel = resolveFarmMarkdownRouteLabel(
10334
+ ${_optionalChain([config, 'access', _251 => _251.md, 'optionalAccess', _252 => _252.enabled]) || hasMarkdownPages ? `const markdownLabel = resolveFarmMarkdownRouteLabel(
9977
10335
  routePathname,
9978
10336
  (page) => matchPageRoute(page)?.route.pattern,
9979
10337
  );
@@ -10008,7 +10366,7 @@ function getApplicableLayouts(pathname, directory) {
10008
10366
  return applicable;
10009
10367
  }
10010
10368
 
10011
- ${_optionalChain([config, 'access', _242 => _242.docs, 'optionalAccess', _243 => _243.enabled]) ? `async function wrapFarmDocsResponseWithLayouts(request, response) {
10369
+ ${_optionalChain([config, 'access', _253 => _253.docs, 'optionalAccess', _254 => _254.enabled]) ? `async function wrapFarmDocsResponseWithLayouts(request, response) {
10012
10370
  if (request.method === "HEAD") return response;
10013
10371
  if (response.headers.get("x-farm-docs-adapter")) return response;
10014
10372
 
@@ -10093,7 +10451,7 @@ ${_optionalChain([config, 'access', _242 => _242.docs, 'optionalAccess', _243 =>
10093
10451
  : html.replace(/<[/]head>/i, clientStylesheet + "</head>");
10094
10452
  }
10095
10453
  if (!html.includes('id="__farm_route_slots_data__"')) {
10096
- html = html.replace(/<[/]body>/i, function() { return renderFarmClientBootstrapScript() + "\\n</body>"; });
10454
+ html = html.replace(/<[/]body>/i, function() { return renderFarmClientBootstrapScript(undefined, undefined, undefined, pathname) + "\\n</body>"; });
10097
10455
  }
10098
10456
  if (!html.includes('src="/__farm_client_js_src__"')) {
10099
10457
  html = html.replace(
@@ -10116,7 +10474,7 @@ ${_optionalChain([config, 'access', _242 => _242.docs, 'optionalAccess', _243 =>
10116
10474
 
10117
10475
  // Shells keep their own LRU so query-string variants never evict app cache entries.
10118
10476
  const pprShellCache = getFarmDataCache().pprShellCache;
10119
- const experimentalPPREnabled = ${JSON.stringify(_optionalChain([config, 'access', _244 => _244.experimental, 'optionalAccess', _245 => _245.ppr]) === true)};
10477
+ const experimentalPPREnabled = ${JSON.stringify(_optionalChain([config, 'access', _255 => _255.experimental, 'optionalAccess', _256 => _256.ppr]) === true)};
10120
10478
 
10121
10479
  function resolveRouteRenderingView(route) {
10122
10480
  // The same merge development uses: baked directive config under the
@@ -10244,7 +10602,7 @@ async function handleFarmRequest(request, adapterContext) {
10244
10602
  },
10245
10603
  { redirect: !isFarmLocalAPIPathname(requestUrl.pathname) }
10246
10604
  )` : "handleFarmRequestInContext(request, null, false, Date.now(), adapterContext, requestUrl)"};
10247
- ${_optionalChain([config, 'access', _246 => _246.md, 'optionalAccess', _247 => _247.enabled]) ? `const pathname = getFarmRoutePathname(requestUrl.pathname);
10605
+ ${_optionalChain([config, 'access', _257 => _257.md, 'optionalAccess', _258 => _258.enabled]) ? `const pathname = getFarmRoutePathname(requestUrl.pathname);
10248
10606
  if (matchPageRoute(pathname)) {
10249
10607
  // The Link header advertises the public .md URL, like the head alternate.
10250
10608
  return applyMarkdownNegotiationHeaders(response, {
@@ -10461,7 +10819,7 @@ ${hasServerRuntimeIntegrations ? `
10461
10819
  return renderFarmErrorJSONResponse();` : `
10462
10820
  if (isFarmLocalAPIPathname(pathname)) return renderFarmErrorJSONResponse();
10463
10821
  // No page was selected, so only the root error boundary and layouts apply.
10464
- const errorResponse = await renderFarmErrorResponse(middlewareResult.error, "/", {}, null);${_optionalChain([config, 'access', _248 => _248.md, 'optionalAccess', _249 => _249.enabled]) ? `
10822
+ const errorResponse = await renderFarmErrorResponse(middlewareResult.error, "/", {}, null);${_optionalChain([config, 'access', _259 => _259.md, 'optionalAccess', _260 => _260.enabled]) ? `
10465
10823
  // An agent asking for Markdown reads the error document as Markdown, as it
10466
10824
  // does when a page throws. The helper answers null when Markdown is off.
10467
10825
  const markdownErrorResponse = await createMarkdownMirrorResponse({
@@ -10503,7 +10861,7 @@ ${hasServerRuntimeIntegrations ? `
10503
10861
  }
10504
10862
  ` : ""}
10505
10863
 
10506
- ${_optionalChain([config, 'access', _250 => _250.docs, 'optionalAccess', _251 => _251.enabled]) ? `
10864
+ ${_optionalChain([config, 'access', _261 => _261.docs, 'optionalAccess', _262 => _262.enabled]) ? `
10507
10865
  // Docs responses are served after app middleware so route guards and
10508
10866
  // middleware headers apply to the docs engine like any other page content.
10509
10867
  // An app's own llms.txt, llms-full.txt, sitemap.xml, and robots.txt take
@@ -10512,7 +10870,13 @@ ${hasServerRuntimeIntegrations ? `
10512
10870
  const owned = getFarmAppOwnedDocsEnginePaths(config.agent, applicationMetadataRoutes);
10513
10871
  return owned.length ? ` && !${JSON.stringify(owned)}.includes(normalizeRuntimePath(routePathname))` : "";
10514
10872
  })()}) {
10515
- const docsResponse = await farmDocsHandler(cloneFarmRequestWithContext(request));
10873
+ const farmDocsRequest = cloneFarmRequestWithContext(request);
10874
+ // Tool calls to a docs runtime's MCP server emit mcp.tool.complete, as @farm.js/mcp's do.
10875
+ const farmRegisteredMCPCalls = await _readFarmRegisteredMCPCalls(
10876
+ farmDocsRequest,
10877
+ ${JSON.stringify(config.basePath)},
10878
+ );
10879
+ const docsResponse = await farmDocsHandler(farmDocsRequest);
10516
10880
  if (docsResponse) {${hasInfraAnalyticsRuntime ? `
10517
10881
  const farmAnalyticsRoute = adapterContext?.[farmRouteLabelSlot];
10518
10882
  if (farmAnalyticsRoute) {
@@ -10523,7 +10887,19 @@ ${hasServerRuntimeIntegrations ? `
10523
10887
  }` : ""}
10524
10888
  if (!docsResponse.headers.get("content-type")?.toLowerCase().includes("text/html")) {
10525
10889
  return applyProductionMiddlewareHeaders(
10526
- withFarmDocsRequestCache(docsResponse, request, farmLocaleResolution, middlewareData, middlewareContext),
10890
+ withFarmDocsRequestCache(
10891
+ _observeFarmRegisteredMCPResponse(
10892
+ docsResponse,
10893
+ farmRegisteredMCPCalls,
10894
+ typeof adapterContext?.waitUntil === "function"
10895
+ ? adapterContext.waitUntil.bind(adapterContext)
10896
+ : undefined,
10897
+ ),
10898
+ request,
10899
+ farmLocaleResolution,
10900
+ middlewareData,
10901
+ middlewareContext,
10902
+ ),
10527
10903
  middlewareHeaders,
10528
10904
  );
10529
10905
  }
@@ -10601,7 +10977,7 @@ ${hasServerRuntimeIntegrations ? `
10601
10977
  }
10602
10978
  ` : ""}
10603
10979
 
10604
- ${_optionalChain([config, 'access', _252 => _252.md, 'optionalAccess', _253 => _253.enabled]) ? `
10980
+ ${_optionalChain([config, 'access', _263 => _263.md, 'optionalAccess', _264 => _264.enabled]) ? `
10605
10981
  if (farmMarkdownConfig?.enabled) {
10606
10982
  const markdownResponse = await createMarkdownMirrorResponse({
10607
10983
  // The mirror helper only reads metadata and creates its own GET request.
@@ -10705,11 +11081,11 @@ ${hasServerRuntimeIntegrations ? `
10705
11081
  return applyProductionMiddlewareHeaders(applicationMetadataResponse, middlewareHeaders);
10706
11082
  }
10707
11083
  ` : ""}
10708
- ${_optionalChain([config, 'access', _254 => _254.agent, 'optionalAccess', _255 => _255.manifest]) !== false ? `
11084
+ ${_optionalChain([config, 'access', _265 => _265.agent, 'optionalAccess', _266 => _266.manifest]) !== false ? `
10709
11085
  // agent.manifest: /.well-known/farmjs.json (and 0.1.34's /.well-known/farmjs), the app's
10710
11086
  // public manifest, the same document for every request.
10711
11087
  if (
10712
- [${JSON.stringify(_chunk4YHGQDTTcjs.FARM_APP_MANIFEST_PATH)}, ${JSON.stringify(_chunk4YHGQDTTcjs.FARM_APP_MANIFEST_LEGACY_PATH)}].includes(
11088
+ [${JSON.stringify(_chunkDM2YGTRHcjs.FARM_APP_MANIFEST_PATH)}, ${JSON.stringify(_chunkDM2YGTRHcjs.FARM_APP_MANIFEST_LEGACY_PATH)}].includes(
10713
11089
  normalizeRuntimePath(routePathname),
10714
11090
  )
10715
11091
  ) {
@@ -10719,9 +11095,9 @@ ${hasServerRuntimeIntegrations ? `
10719
11095
  );
10720
11096
  }
10721
11097
  ` : ""}
10722
- ${_optionalChain([config, 'access', _256 => _256.agent, 'optionalAccess', _257 => _257.apiCatalog]) ? `
11098
+ ${_optionalChain([config, 'access', _267 => _267.agent, 'optionalAccess', _268 => _268.apiCatalog]) ? `
10723
11099
  // agent.apiCatalog: list the OpenAPI and MCP surfaces at the RFC 9727 path.
10724
- if (normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunk4YHGQDTTcjs.FARM_API_CATALOG_PATH)}) {
11100
+ if (normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunkDM2YGTRHcjs.FARM_API_CATALOG_PATH)}) {
10725
11101
  return applyProductionMiddlewareHeaders(
10726
11102
  createFarmApiCatalogResponse(request.method, farmApiCatalogInput, request),
10727
11103
  middlewareHeaders,
@@ -10746,11 +11122,11 @@ ${hasServerRuntimeIntegrations ? `
10746
11122
  );
10747
11123
  }
10748
11124
  ` : ""}
10749
- ${_optionalChain([config, 'access', _258 => _258.agent, 'optionalAccess', _259 => _259.llmsTxt, 'optionalAccess', _260 => _260.enabled]) ? `
11125
+ ${_optionalChain([config, 'access', _269 => _269.agent, 'optionalAccess', _270 => _270.llmsTxt, 'optionalAccess', _271 => _271.enabled]) ? `
10750
11126
  // agent.llmsTxt with no llms.ts or llms-full.ts: serve the generated files.
10751
11127
  const farmGeneratedLlmsKind = normalizeRuntimePath(routePathname) === "/llms.txt"
10752
11128
  ? "llms"
10753
- : ${_optionalChain([config, 'access', _261 => _261.agent, 'optionalAccess', _262 => _262.llmsTxt, 'optionalAccess', _263 => _263.full]) ? `normalizeRuntimePath(routePathname) === "/llms-full.txt" ? "llms-full" : ` : ""}null;
11129
+ : ${_optionalChain([config, 'access', _272 => _272.agent, 'optionalAccess', _273 => _273.llmsTxt, 'optionalAccess', _274 => _274.full]) ? `normalizeRuntimePath(routePathname) === "/llms-full.txt" ? "llms-full" : ` : ""}null;
10754
11130
  if (farmGeneratedLlmsKind) {
10755
11131
  const llmsContext = createFarmLlmsTxtContext(request, farmGeneratedLlmsKind === "llms-full");
10756
11132
  // Renders are shared per origin the request reached, which is where pages are read.
@@ -10786,7 +11162,7 @@ ${hasServerRuntimeIntegrations ? `
10786
11162
  }
10787
11163
  ` : ""}
10788
11164
 
10789
- ${_optionalChain([config, 'access', _264 => _264.docs, 'optionalAccess', _265 => _265.enabled]) ? `if (farmDocsAPIHandler && isFarmDocsAPIRequest(pathname)) {
11165
+ ${_optionalChain([config, 'access', _275 => _275.docs, 'optionalAccess', _276 => _276.enabled]) ? `if (farmDocsAPIHandler && isFarmDocsAPIRequest(pathname)) {
10790
11166
  const docsAPIResponse = await farmDocsAPIHandler(cloneFarmRequestWithContext(request));
10791
11167
  if (docsAPIResponse) {
10792
11168
  return applyProductionMiddlewareHeaders(
@@ -10819,7 +11195,9 @@ ${hasServerRuntimeIntegrations ? `
10819
11195
  if (matchedRoute && request.method === "POST") {
10820
11196
  const actionResponse = await _runWithMiddlewareData(middlewareData || {}, () =>
10821
11197
  _runWithMiddlewareContext(middlewareContext || {}, () =>
10822
- handleFarmFormActionRequest(request, farmFormActionsConfig, farmRequestedUrl)
11198
+ handleFarmFormActionRequest(request, farmFormActionsConfig, farmRequestedUrl, {
11199
+ trustProxy: farmServerConfig.trustProxy === true,
11200
+ })
10823
11201
  )
10824
11202
  );
10825
11203
  if (actionResponse) return applyProductionMiddlewareHeaders(actionResponse, middlewareHeaders);
@@ -11392,7 +11770,7 @@ ${hasServerRuntimeIntegrations ? `
11392
11770
  );
11393
11771
  }
11394
11772
  }
11395
- ${_optionalChain([config, 'access', _266 => _266.md, 'optionalAccess', _267 => _267.enabled]) ? `
11773
+ ${_optionalChain([config, 'access', _277 => _277.md, 'optionalAccess', _278 => _278.enabled]) ? `
11396
11774
  // Advertise the Markdown mirror in the head as well as the Link header,
11397
11775
  // using the public path the .md request will be resolved against.
11398
11776
  mergedMetadata = addMetadataMarkdownAlternate(
@@ -11411,7 +11789,7 @@ ${hasServerRuntimeIntegrations ? `
11411
11789
  emitFarmEvent({ type: "cache.bypass", route: pathname, reason: "request-read" });
11412
11790
  }
11413
11791
 
11414
- const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _268 => _268.agent, 'optionalAccess', _269 => _269.jsonLd]), () => ( false)))} });
11792
+ const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _279 => _279.agent, 'optionalAccess', _280 => _280.jsonLd]), () => ( false)))} });
11415
11793
  const title = renderedMetadata.title;
11416
11794
  const metaTags = renderedMetadata.tags;
11417
11795
  const hasFavicon = renderedMetadata.hasFavicon;
@@ -11553,7 +11931,8 @@ ${hasServerRuntimeIntegrations ? `
11553
11931
  return ' ' + renderFarmClientBootstrapScript(
11554
11932
  pageProps.__farmCanonicalPath,
11555
11933
  farmDeferredData.data.slots,
11556
- farmDeferredData.data.page
11934
+ farmDeferredData.data.page,
11935
+ routePathname
11557
11936
  ) + '\\n' +
11558
11937
  ' ' + renderFarmClientEntryScript(early) + '\\n';
11559
11938
  };
@@ -11710,7 +12089,8 @@ ${hasServerRuntimeIntegrations ? `
11710
12089
  () => ' ' + renderFarmClientBootstrapScript(
11711
12090
  pageProps.__farmCanonicalPath,
11712
12091
  farmDeferredData.data.slots,
11713
- farmDeferredData.data.page
12092
+ farmDeferredData.data.page,
12093
+ routePathname
11714
12094
  ) + renderFarmDeferredDataScript(farmDeferredData.records) + '\\n' +
11715
12095
  ' ' + farmEntryScript + '\\n</body>',
11716
12096
  );
@@ -11728,7 +12108,7 @@ ${hasServerRuntimeIntegrations ? `
11728
12108
  </head>
11729
12109
  <body>
11730
12110
  <div id="root">\${html}</div>
11731
- \${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, farmDeferredData.data.slots, farmDeferredData.data.page)}\${renderFarmDeferredDataScript(farmDeferredData.records)}
12111
+ \${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, farmDeferredData.data.slots, farmDeferredData.data.page, routePathname)}\${renderFarmDeferredDataScript(farmDeferredData.records)}
11732
12112
  \${farmEntryScript}
11733
12113
  </body>
11734
12114
  </html>\`;
@@ -11843,7 +12223,7 @@ ${hasServerRuntimeIntegrations ? `
11843
12223
  ${servesDefaultMCP ? `
11844
12224
  // agent.mcp: no app route answered /mcp, so the default read-only server may.
11845
12225
  if (
11846
- normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunkTU6VAH4Vcjs.FARM_DEFAULT_MCP_PATH)} &&
12226
+ normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunkVKRMO3EZcjs.FARM_DEFAULT_MCP_PATH)} &&
11847
12227
  getFarmDefaultMCPServer()
11848
12228
  ) {
11849
12229
  return applyProductionMiddlewareHeaders(
@@ -12065,7 +12445,7 @@ ${farmRendererDisabled ? `
12065
12445
  .replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
12066
12446
  .replace(
12067
12447
  /<\\/body>/i,
12068
- () => ' ' + renderFarmClientBootstrapScript() + '\\n' +
12448
+ () => ' ' + renderFarmClientBootstrapScript(undefined, undefined, undefined, routePathname) + '\\n' +
12069
12449
  ' ' + renderFarmClientEntryScript() + '\\n</body>',
12070
12450
  );
12071
12451
  fullHtml = ensureFarmDocumentMeta(fullHtml, notFoundMetadata.viewport);
@@ -12085,7 +12465,7 @@ ${farmRendererDisabled ? `
12085
12465
  </head>
12086
12466
  <body>
12087
12467
  <div id="root">\${html}</div>
12088
- \${renderFarmClientBootstrapScript()}
12468
+ \${renderFarmClientBootstrapScript(undefined, undefined, undefined, routePathname)}
12089
12469
  \${renderFarmClientEntryScript()}
12090
12470
  </body>
12091
12471
  </html>\`;
@@ -12213,16 +12593,19 @@ function createFarmRuntimeHookErrorResponse(request, error) {
12213
12593
  export async function fetch(request, context) {${imageRuntime === "none" ? "" : `
12214
12594
  // The image optimizer's fetch of a local source is not a loopback visitor.
12215
12595
  context = _withFarmImageSourceClientAddress(request, context);`}
12216
- ${_optionalChain([config, 'access', _270 => _270.agent, 'optionalAccess', _271 => _271.noindexPreviews]) ? "const response = await" : "return"} _runWithAPIRequestRuntime({
12596
+ ${_optionalChain([config, 'access', _281 => _281.agent, 'optionalAccess', _282 => _282.noindexPreviews]) ? "const response = await" : "return"} _runWithAPIRequestRuntime({
12217
12597
  basePath: farmLocalAPIBasePath,
12218
12598
  dispatch: async (localRequest) =>
12219
12599
  (await handleAPIRequest(localRequest)) ?? Response.json({ error: "Not Found" }, { status: 404 }),
12220
- }, () => handleFarmFetch(request, context));${_optionalChain([config, 'access', _272 => _272.agent, 'optionalAccess', _273 => _273.noindexPreviews]) ? `
12600
+ }, () => handleFarmFetch(request, context));${_optionalChain([config, 'access', _283 => _283.agent, 'optionalAccess', _284 => _284.noindexPreviews]) ? `
12221
12601
  // Keep every response of a preview deployment out of search indexes.
12222
12602
  return farmNoindexPreview ? applyFarmPreviewRobotsTag(response) : response;` : ""}
12223
12603
  }
12224
12604
 
12225
- async function handleFarmFetch(request, context) {
12605
+ async function handleFarmFetch(request, context) {${config.server.trustProxy ? `
12606
+ // server.trustProxy: middleware, pages, and API routes read the URL the visitor requested,
12607
+ // at the origin the trusted proxy forwards, as in development.
12608
+ request = _withFarmTrustedProxyOrigin(request);` : ""}
12226
12609
  const healthResponse = await farmProductionLifecycle.handleHealthRequest(request);
12227
12610
  if (healthResponse) return healthResponse;
12228
12611
 
@@ -12424,11 +12807,11 @@ function getManifestPageEntry(manifest, pathname) {
12424
12807
  })).sort((left, right) => _chunkYTVSWXEZcjs.compareRouteSpecificity.call(void 0, left.specificity, right.specificity)).map(({ entry, matches }) => ({ entry, matches }));
12425
12808
  manifestPageMatchers.set(manifest.routes, pages);
12426
12809
  }
12427
- return _optionalChain([pages, 'access', _274 => _274.find, 'call', _275 => _275((page) => page.matches(pathname)), 'optionalAccess', _276 => _276.entry]);
12810
+ return _optionalChain([pages, 'access', _285 => _285.find, 'call', _286 => _286((page) => page.matches(pathname)), 'optionalAccess', _287 => _287.entry]);
12428
12811
  }
12429
12812
  function withFarmEdgeGuardedPrerenderHeaders(headers, edgeGuarded) {
12430
12813
  if (!edgeGuarded) return headers;
12431
- const cacheHeaders = /* @__PURE__ */ new Set(["cache-control", ..._chunkJWY66PIDcjs.CDN_CACHE_CONTROL_HEADERS]);
12814
+ const cacheHeaders = /* @__PURE__ */ new Set(["cache-control", ..._chunkS3D6SL2Vcjs.CDN_CACHE_CONTROL_HEADERS]);
12432
12815
  return {
12433
12816
  ...Object.fromEntries(
12434
12817
  Object.entries(headers).filter(([name]) => !cacheHeaders.has(name.toLowerCase()))
@@ -12440,7 +12823,7 @@ function prerenderWouldChangePageUrl(pathname) {
12440
12823
  if (/%(?:23|25|2F|3F)/i.test(pathname)) return true;
12441
12824
  try {
12442
12825
  return decodeURI(pathname) !== pathname;
12443
- } catch (e34) {
12826
+ } catch (e38) {
12444
12827
  return true;
12445
12828
  }
12446
12829
  }
@@ -12461,13 +12844,13 @@ function getPhysicalPrerenderBypassReason(options) {
12461
12844
  if (rewriteSources.some((source) => middlewarePatternMatches(source, pathname))) {
12462
12845
  return "rewrite";
12463
12846
  }
12464
- if (_chunkPXAHSCR6cjs.appMiddlewareMayHandlePath.call(void 0, middlewareRoutes, pathname)) return "app middleware";
12465
- if (_chunkPXAHSCR6cjs.configMiddlewareMayHandlePath.call(void 0, config.middleware, pathname)) return "configured middleware";
12466
- if (_chunkOXNZUCHNcjs.hasCustomFarmRouteContext.call(void 0, config)) return "request context";
12847
+ if (_chunkO2A6HE76cjs.appMiddlewareMayHandlePath.call(void 0, middlewareRoutes, pathname)) return "app middleware";
12848
+ if (_chunkO2A6HE76cjs.configMiddlewareMayHandlePath.call(void 0, config.middleware, pathname)) return "configured middleware";
12849
+ if (_chunkP3EZKU6Lcjs.hasCustomFarmRouteContext.call(void 0, config)) return "request context";
12467
12850
  if (farmServerRuntimePluginsMayHandlePath(config, pathname)) return "server runtime plugin";
12468
12851
  const manifestEntry = getManifestPageEntry(routeRuntimeManifest, pathname);
12469
- if (_optionalChain([manifestEntry, 'optionalAccess', _277 => _277.rendering]) === "dynamic") return "dynamic runtime manifest";
12470
- if (manifestEntry && (manifestEntry.runtime !== "auto" || Boolean(_optionalChain([manifestEntry, 'access', _278 => _278.regions, 'optionalAccess', _279 => _279.length])) || manifestEntry.maxDuration !== void 0)) {
12852
+ if (_optionalChain([manifestEntry, 'optionalAccess', _288 => _288.rendering]) === "dynamic") return "dynamic runtime manifest";
12853
+ if (manifestEntry && (manifestEntry.runtime !== "auto" || Boolean(_optionalChain([manifestEntry, 'access', _289 => _289.regions, 'optionalAccess', _290 => _290.length])) || manifestEntry.maxDuration !== void 0)) {
12471
12854
  return "route runtime controls";
12472
12855
  }
12473
12856
  const routeRule = getEffectiveRouteRule(config, pathname);
@@ -12480,15 +12863,15 @@ function getPhysicalPrerenderBypassReason(options) {
12480
12863
  return void 0;
12481
12864
  }
12482
12865
  async function getFarmDocsPrerenderPages(config, root, preset) {
12483
- if (!_optionalChain([config, 'access', _280 => _280.docs, 'optionalAccess', _281 => _281.enabled]) || !config.docs.prerender) return [];
12866
+ if (!_optionalChain([config, 'access', _291 => _291.docs, 'optionalAccess', _292 => _292.enabled]) || !config.docs.prerender) return [];
12484
12867
  if (_chunkNLBHLPEOcjs.getFarmPresetRuntime.call(void 0, preset) === "edge") {
12485
12868
  _chunkQMNWKQL4cjs.logger.info(
12486
12869
  `\u21AA Keeping docs pages in the edge docs snapshot: docs.prerender writes static files on Node and serverless targets, not "${preset}".`
12487
12870
  );
12488
12871
  return [];
12489
12872
  }
12490
- if (!_chunkKDOZORJDcjs.hasFarmDocsRuntimeAdapter.call(void 0, config.docs)) {
12491
- const { pages: pages2, originDependent } = _chunkHFUOLILAcjs.listFarmDocsBuiltInPrerenderPages.call(void 0, config.docs, {
12873
+ if (!_chunk737MIVX3cjs.hasFarmDocsRuntimeAdapter.call(void 0, config.docs)) {
12874
+ const { pages: pages2, originDependent } = _chunkZRCGPSUMcjs.listFarmDocsBuiltInPrerenderPages.call(void 0, config.docs, {
12492
12875
  root,
12493
12876
  srcDir: config.srcDir
12494
12877
  });
@@ -12505,7 +12888,7 @@ async function getFarmDocsPrerenderPages(config, root, preset) {
12505
12888
  );
12506
12889
  return [];
12507
12890
  }
12508
- const pages = await _chunkKDOZORJDcjs.listFarmDocsAdapterPages.call(void 0, config.docs, { root, srcDir: config.srcDir });
12891
+ const pages = await _chunk737MIVX3cjs.listFarmDocsAdapterPages.call(void 0, config.docs, { root, srcDir: config.srcDir });
12509
12892
  if (!pages) {
12510
12893
  _chunkQMNWKQL4cjs.logger.warn(
12511
12894
  `The docs adapter ${JSON.stringify(config.docs.adapter.id)} does not list its pages for prerendering; upgrade it to prerender docs pages. They render on request until then.`
@@ -12515,14 +12898,14 @@ async function getFarmDocsPrerenderPages(config, root, preset) {
12515
12898
  return pages;
12516
12899
  }
12517
12900
  async function listFarmDocsAnalyticsPages(config, root, preset) {
12518
- if (!_optionalChain([config, 'access', _282 => _282.docs, 'optionalAccess', _283 => _283.enabled]) || config.analytics === false || _chunkOCS3PSYRcjs.resolveFarmInstrumentationRuntime.call(void 0, preset) !== "nodejs") {
12901
+ if (!_optionalChain([config, 'access', _293 => _293.docs, 'optionalAccess', _294 => _294.enabled]) || config.analytics === false || _chunkOCS3PSYRcjs.resolveFarmInstrumentationRuntime.call(void 0, preset) !== "nodejs") {
12519
12902
  return [];
12520
12903
  }
12521
12904
  try {
12522
- return await _chunkKDOZORJDcjs.listFarmDocsPagePaths.call(void 0, config.docs, {
12905
+ return await _chunk737MIVX3cjs.listFarmDocsPagePaths.call(void 0, config.docs, {
12523
12906
  root,
12524
12907
  srcDir: config.srcDir,
12525
- adapter: _chunk67MZTLTFcjs.isReactRenderer.call(void 0, config.renderer) && _chunkKDOZORJDcjs.hasFarmDocsRuntimeAdapter.call(void 0, config.docs)
12908
+ adapter: _chunk67MZTLTFcjs.isReactRenderer.call(void 0, config.renderer) && _chunk737MIVX3cjs.hasFarmDocsRuntimeAdapter.call(void 0, config.docs)
12526
12909
  });
12527
12910
  } catch (error) {
12528
12911
  _chunkQMNWKQL4cjs.logger.warn(
@@ -12533,14 +12916,14 @@ async function listFarmDocsAnalyticsPages(config, root, preset) {
12533
12916
  }
12534
12917
  function hasFarmNitroCacheRouteRule(routeRules) {
12535
12918
  return Object.values(routeRules || {}).some((rule) => {
12536
- const swr = _optionalChain([rule, 'optionalAccess', _284 => _284.swr]);
12537
- const cache = _optionalChain([rule, 'optionalAccess', _285 => _285.cache]);
12538
- const headers = _optionalChain([rule, 'optionalAccess', _286 => _286.headers]);
12919
+ const swr = _optionalChain([rule, 'optionalAccess', _295 => _295.swr]);
12920
+ const cache = _optionalChain([rule, 'optionalAccess', _296 => _296.cache]);
12921
+ const headers = _optionalChain([rule, 'optionalAccess', _297 => _297.headers]);
12539
12922
  return swr !== void 0 && swr !== false || cache !== void 0 && cache !== false || !!headers && typeof headers === "object" && Object.keys(headers).length > 0;
12540
12923
  });
12541
12924
  }
12542
- async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager) {
12543
- const [fs4, nitroBuilderResult] = await Promise.all([
12925
+ async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager, markdownPrecompiledPages) {
12926
+ const [fs5, nitroBuilderResult] = await Promise.all([
12544
12927
  import("fs/promises"),
12545
12928
  nitroBuilderResultPromise
12546
12929
  ]);
@@ -12548,10 +12931,10 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12548
12931
  const nitroBuilder = nitroBuilderResult.value;
12549
12932
  const isVercel = preset === "vercel";
12550
12933
  const isCloudflareWorker = preset === "cloudflare-module";
12551
- const outputDir = _chunkOXNZUCHNcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
12934
+ const outputDir = _chunkP3EZKU6Lcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
12552
12935
  const runtimeServerOutputDir = isVercel ? _path2.default.join(outputDir, "functions", "__nitro.func") : _path2.default.join(outputDir, "server");
12553
12936
  const ssrOutputDir = _path2.default.join(root, distDir, "ssr");
12554
- const imageRuntime = _chunkTAU3OF5Bcjs.resolveFarmImageServerRuntime.call(void 0, config.images, preset);
12937
+ const imageRuntime = _chunk56HHUSR5cjs.resolveFarmImageServerRuntime.call(void 0, config.images, preset);
12555
12938
  const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
12556
12939
  (image) => image.sourceType === "module"
12557
12940
  );
@@ -12577,7 +12960,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12577
12960
  const configuredResponseRoutesPromise = Promise.all([config.redirects(), config.rewrites()]);
12578
12961
  const docsPrerenderPagesPromise = getFarmDocsPrerenderPages(config, root, preset);
12579
12962
  const farmWorkflows = await _chunkFSODPZRTcjs.prepareFarmWorkflowsForNitro.call(void 0, config);
12580
- const farmCron = await _chunkYAEN3L2Fcjs.prepareFarmCronForNitro.call(void 0, config);
12963
+ const farmCron = await _chunkEF5AP4CVcjs.prepareFarmCronForNitro.call(void 0, config);
12581
12964
  const [
12582
12965
  { ssg: ssgPages },
12583
12966
  middlewareRoutes,
@@ -12607,7 +12990,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12607
12990
  const edgeGuardedPrerenderRoutes = [];
12608
12991
  const addPrerenderRoute = (pathname) => {
12609
12992
  prerenderRoutes.push(pathname);
12610
- if (_chunkPXAHSCR6cjs.appMiddlewareMayHandlePath.call(void 0, edgeMiddlewareRoutes, pathname)) {
12993
+ if (_chunkO2A6HE76cjs.appMiddlewareMayHandlePath.call(void 0, edgeMiddlewareRoutes, pathname)) {
12611
12994
  edgeGuardedPrerenderRoutes.push(pathname);
12612
12995
  }
12613
12996
  };
@@ -12666,18 +13049,31 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12666
13049
  "Cloudflare Pages does not install Cron Triggers. Use the cloudflare-module preset or an external scheduler with .farm/cron-manifest.json."
12667
13050
  );
12668
13051
  }
12669
- const scheduledTasks = _chunkYAEN3L2Fcjs.mergeScheduledTasks.call(void 0, farmWorkflows.scheduledTasks, farmCron.scheduledTasks);
12670
- const cloudflareCronConfig = farmCron.provider === "host" ? _chunkYAEN3L2Fcjs.createFarmCronCloudflareConfig.call(void 0, farmCron.jobs) : void 0;
12671
- const [clientCssHref, clientJsSrc, clientBootSrc, docsModulePreloads, clientModulePreloads] = await Promise.all([
13052
+ const portableScheduledTasks = _chunkEF5AP4CVcjs.mergeScheduledTasks.call(void 0,
13053
+ farmWorkflows.scheduledTasks,
13054
+ farmCron.scheduledTasks
13055
+ );
13056
+ const scheduledTasks = preset.startsWith("cloudflare") ? _chunkEF5AP4CVcjs.toFarmCronCloudflareScheduledTasks.call(void 0, portableScheduledTasks) : portableScheduledTasks;
13057
+ const cloudflareCronConfig = farmCron.provider === "host" ? _chunkEF5AP4CVcjs.createFarmCronCloudflareConfig.call(void 0, farmCron.jobs) : void 0;
13058
+ const [
13059
+ clientCssHref,
13060
+ clientJsSrc,
13061
+ clientBootSrc,
13062
+ docsModulePreloads,
13063
+ clientModulePreloads,
13064
+ clientRouteTable
13065
+ ] = await Promise.all([
12672
13066
  resolveHashedClientCssHref(clientOutputDir),
12673
13067
  resolveHashedClientJsSrc(clientOutputDir),
12674
13068
  resolveClientBootSrc(clientOutputDir),
12675
13069
  readFarmDocsModulePreloads(_path2.default.join(root, distDir)),
12676
- readFarmClientModulePreloads(_path2.default.join(root, distDir))
13070
+ readFarmClientModulePreloads(_path2.default.join(root, distDir)),
13071
+ readFarmClientRouteTable(_path2.default.join(root, distDir))
12677
13072
  ]);
12678
13073
  let nativeStylesheets;
12679
13074
  const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
12680
13075
  const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
13076
+ const encodedClientRouteTable = encodeFarmBuildJSONPlaceholder(clientRouteTable);
12681
13077
  const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? _chunkE5UN4OWXcjs.encodeFarmMobileShellClient.call(void 0,
12682
13078
  await _chunkE5UN4OWXcjs.finalizeFarmMobileClient.call(void 0, {
12683
13079
  buildDir: _path2.default.join(root, distDir),
@@ -12685,7 +13081,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12685
13081
  webEntry: clientJsSrc,
12686
13082
  webBoot: clientBootSrc,
12687
13083
  stylesheet: clientCssHref,
12688
- webFiles: _nullishCoalesce(_optionalChain([clientModulePreloads, 'optionalAccess', _287 => _287.files]), () => ( []))
13084
+ webFiles: _nullishCoalesce(_optionalChain([clientModulePreloads, 'optionalAccess', _298 => _298.files]), () => ( []))
12689
13085
  })
12690
13086
  ) : null;
12691
13087
  for (const output of Object.values(ssrBundle)) {
@@ -12699,6 +13095,9 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12699
13095
  if (output.code.includes(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER)) {
12700
13096
  output.code = output.code.split(FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER).join(encodedClientModulePreloads);
12701
13097
  }
13098
+ if (output.code.includes(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER)) {
13099
+ output.code = output.code.split(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER).join(encodedClientRouteTable);
13100
+ }
12702
13101
  if (output.code.includes(FARM_CLIENT_CSS_HREF_PLACEHOLDER)) {
12703
13102
  output.code = output.code.split(FARM_CLIENT_CSS_HREF_PLACEHOLDER).join(clientCssHref);
12704
13103
  }
@@ -12716,12 +13115,12 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12716
13115
  output.code = output.code.split(JSON.stringify(FARM_NATIVE_STYLESHEETS_PLACEHOLDER)).join(JSON.stringify(JSON.stringify(nativeStylesheets)));
12717
13116
  }
12718
13117
  }
12719
- await fs4.mkdir(ssrOutputDir, { recursive: true });
13118
+ await fs5.mkdir(ssrOutputDir, { recursive: true });
12720
13119
  await Promise.all(
12721
13120
  Object.entries(ssrBundle).map(async ([fileName, output]) => {
12722
13121
  const filePath = _path2.default.join(ssrOutputDir, fileName);
12723
- await fs4.mkdir(_path2.default.dirname(filePath), { recursive: true });
12724
- await fs4.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
13122
+ await fs5.mkdir(_path2.default.dirname(filePath), { recursive: true });
13123
+ await fs5.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
12725
13124
  })
12726
13125
  );
12727
13126
  const nitroEntryPath = _path2.default.join(ssrOutputDir, "nitro-entry.mjs");
@@ -12930,7 +13329,7 @@ function toFarmNodeResponse(request, response) {
12930
13329
  })
12931
13330
  }` : ""}
12932
13331
  `.trim();
12933
- await fs4.writeFile(nitroEntryPath, nitroEntryCode);
13332
+ await fs5.writeFile(nitroEntryPath, nitroEntryCode);
12934
13333
  const desktopServerEntry = config.desktop ? {
12935
13334
  basePath: config.basePath === "/" ? "" : config.basePath || "",
12936
13335
  guardModule: "@farm.js/core/internal/desktop-guard"
@@ -12941,18 +13340,18 @@ function toFarmNodeResponse(request, response) {
12941
13340
  `[Farm] A desktop build runs its server in the shell, so it needs the "bun" or "node-server" preset, not "${preset}".`
12942
13341
  );
12943
13342
  }
12944
- await fs4.writeFile(
13343
+ await fs5.writeFile(
12945
13344
  _path2.default.join(ssrOutputDir, _chunkNG2EZ6QScjs.FARM_DESKTOP_ENV_MODULE_FILE),
12946
13345
  _chunkNG2EZ6QScjs.FARM_DESKTOP_ENV_MODULE_SOURCE
12947
13346
  );
12948
13347
  }
12949
13348
  const farmNodeServerEntryPath = preset === "node-server" ? _path2.default.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
12950
13349
  if (farmNodeServerEntryPath && nodeAdapterModule) {
12951
- await fs4.writeFile(
13350
+ await fs5.writeFile(
12952
13351
  _path2.default.join(ssrOutputDir, _chunkNG2EZ6QScjs.FARM_NODE_ENV_MODULE_FILE),
12953
13352
  _chunkNG2EZ6QScjs.FARM_NODE_ENV_MODULE_SOURCE
12954
13353
  );
12955
- await fs4.writeFile(
13354
+ await fs5.writeFile(
12956
13355
  farmNodeServerEntryPath,
12957
13356
  _chunkNG2EZ6QScjs.createFarmNodeServerEntry.call(void 0, {
12958
13357
  nitroEntryFile: _path2.default.basename(nitroEntryPath),
@@ -12965,7 +13364,7 @@ function toFarmNodeResponse(request, response) {
12965
13364
  }
12966
13365
  const farmBunServerEntryPath = preset === "bun" ? _path2.default.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
12967
13366
  if (farmBunServerEntryPath) {
12968
- await fs4.writeFile(
13367
+ await fs5.writeFile(
12969
13368
  farmBunServerEntryPath,
12970
13369
  _chunkNG2EZ6QScjs.createFarmBunServerEntry.call(void 0, {
12971
13370
  nitroEntryFile: _path2.default.basename(nitroEntryPath),
@@ -12978,7 +13377,7 @@ function toFarmNodeResponse(request, response) {
12978
13377
  }
12979
13378
  const farmNetlifyEntryPath = preset === "netlify" ? _path2.default.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
12980
13379
  if (farmNetlifyEntryPath) {
12981
- await fs4.writeFile(
13380
+ await fs5.writeFile(
12982
13381
  farmNetlifyEntryPath,
12983
13382
  createFarmNetlifyEntry({
12984
13383
  nitroNetlifyEntry: resolveNitroNetlifyEntry(resolveNitroPackageEntry(root))
@@ -12987,7 +13386,7 @@ function toFarmNodeResponse(request, response) {
12987
13386
  }
12988
13387
  const farmCloudflareEnvPath = preset === "cloudflare-pages" ? _path2.default.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
12989
13388
  if (farmCloudflareEnvPath) {
12990
- await fs4.writeFile(
13389
+ await fs5.writeFile(
12991
13390
  farmCloudflareEnvPath,
12992
13391
  `export default function farmCloudflareEnv(event) {
12993
13392
  const env = event.req.runtime?.cloudflare?.env
@@ -13005,7 +13404,7 @@ function toFarmNodeResponse(request, response) {
13005
13404
  varyFarmNitroCacheRules(_chunkMQ4DYVFScjs.routeRulesToNitroRouteRules.call(void 0, config.routeRules), [
13006
13405
  ...config.md.enabled ? ["accept"] : [],
13007
13406
  ...shouldBuildFarmMobileClient(config) ? ["x-farm-shell"] : [],
13008
- ..._chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _288 => _288.experimental, 'optionalAccess', _289 => _289.serverComponents])) === "islands" ? ["f-layouts"] : []
13407
+ ..._chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _299 => _299.experimental, 'optionalAccess', _300 => _300.serverComponents])) === "islands" ? ["f-layouts"] : []
13009
13408
  ]),
13010
13409
  config.basePath,
13011
13410
  _chunk2OF5RPVUcjs.resolveFarmAPIServerBasePath.call(void 0, config.api)
@@ -13083,7 +13482,12 @@ function toFarmNodeResponse(request, response) {
13083
13482
  // answered independently, as by the production server, so keeping several
13084
13483
  // in flight overlaps the worker's rendering with this thread's per-route work.
13085
13484
  concurrency: Math.min(_os2.default.availableParallelism(), 8),
13086
- routes: prerenderRoutes.map(toPrerenderPublicPath)
13485
+ routes: prerenderRoutes.map(toPrerenderPublicPath),
13486
+ // Cloudflare's asset server answers a directory index (about/index.html) at the
13487
+ // trailing-slash URL and redirects the other spelling to it, so a page is written as
13488
+ // about.html unless trailingSlash asks for the slash, as Nitro's Netlify and Vercel
13489
+ // presets already write it.
13490
+ ...preset.startsWith("cloudflare") ? { autoSubfolderIndex: config.trailingSlash === true } : {}
13087
13491
  }
13088
13492
  } : {},
13089
13493
  experimental: {
@@ -13161,23 +13565,23 @@ function toFarmNodeResponse(request, response) {
13161
13565
  snapshotSSRRebundleOptions(nitroConfig)
13162
13566
  );
13163
13567
  const requestedBuilder = _nullishCoalesce(nitroConfig.builder, () => ( process.env.NITRO_BUILDER));
13164
- const nitroBuildIsFarms = (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && _optionalChain([nitroConfig, 'access', _290 => _290.rollupConfig, 'optionalAccess', _291 => _291.external]) === nitroRollupExternal && !hasRollupPlugins(_optionalChain([nitroConfig, 'access', _292 => _292.rollupConfig, 'optionalAccess', _293 => _293.plugins])) && customRollupKeys.length === 0 && Boolean(
13165
- _optionalChain([nitroConfig, 'access', _294 => _294.handlers, 'optionalAccess', _295 => _295.some, 'call', _296 => _296(
13166
- (handler) => _path2.default.resolve(_optionalChain([handler, 'optionalAccess', _297 => _297.handler]) || "") === nitroEntryPath
13568
+ const nitroBuildIsFarms = (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && _optionalChain([nitroConfig, 'access', _301 => _301.rollupConfig, 'optionalAccess', _302 => _302.external]) === nitroRollupExternal && !hasRollupPlugins(_optionalChain([nitroConfig, 'access', _303 => _303.rollupConfig, 'optionalAccess', _304 => _304.plugins])) && customRollupKeys.length === 0 && Boolean(
13569
+ _optionalChain([nitroConfig, 'access', _305 => _305.handlers, 'optionalAccess', _306 => _306.some, 'call', _307 => _307(
13570
+ (handler) => _path2.default.resolve(_optionalChain([handler, 'optionalAccess', _308 => _308.handler]) || "") === nitroEntryPath
13167
13571
  )])
13168
13572
  );
13169
- const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms && _path2.default.resolve(_optionalChain([nitroConfig, 'access', _298 => _298.output, 'optionalAccess', _299 => _299.serverDir]) || "") === _path2.default.resolve(expectedServerDir);
13573
+ const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms && _path2.default.resolve(_optionalChain([nitroConfig, 'access', _309 => _309.output, 'optionalAccess', _310 => _310.serverDir]) || "") === _path2.default.resolve(expectedServerDir);
13170
13574
  const prerenderReusesPrebuiltSSR = prerenderRoutes.length > 0 && ssrExternalsArePackaged && nitroBuildIsFarms;
13171
13575
  const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
13172
13576
  if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
13173
13577
  const useRolldownBuilder = canReusePrebuiltSSR && (_nullishCoalesce(nitroConfig.builder, () => ( process.env.NITRO_BUILDER))) === "rolldown";
13174
13578
  const shouldMinify = nitroConfig.minify !== false;
13175
- const keepServerNames = !(_optionalChain([config, 'access', _300 => _300.docs, 'optionalAccess', _301 => _301.enabled]) && _optionalChain([config, 'access', _302 => _302.docs, 'access', _303 => _303.adapter, 'optionalAccess', _304 => _304.server]));
13579
+ const keepServerNames = !(_optionalChain([config, 'access', _311 => _311.docs, 'optionalAccess', _312 => _312.enabled]) && _optionalChain([config, 'access', _313 => _313.docs, 'access', _314 => _314.adapter, 'optionalAccess', _315 => _315.server]));
13176
13580
  const useFarmServerMinifier = shouldMinify && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig;
13177
13581
  const serverChunkMinifier = useFarmServerMinifier ? createServerChunkMinifyPlugin({ keepNames: keepServerNames, target: "esnext" }) : null;
13178
13582
  const ssrRollupPlugin = canReusePrebuiltSSR ? prebuiltSSRPlugin : createServerReadSSRAssetsPlugin(ssrBundle, ssrOutputDir);
13179
13583
  if (ssrRollupPlugin) {
13180
- const configuredRollupPlugins = _optionalChain([nitroConfig, 'access', _305 => _305.rollupConfig, 'optionalAccess', _306 => _306.plugins]);
13584
+ const configuredRollupPlugins = _optionalChain([nitroConfig, 'access', _316 => _316.rollupConfig, 'optionalAccess', _317 => _317.plugins]);
13181
13585
  nitroConfig.rollupConfig = {
13182
13586
  ...nitroConfig.rollupConfig,
13183
13587
  plugins: [
@@ -13194,7 +13598,7 @@ function toFarmNodeResponse(request, response) {
13194
13598
  Array.from(routes, (route, index) => {
13195
13599
  try {
13196
13600
  return [decodeURI(route), index];
13197
- } catch (e35) {
13601
+ } catch (e39) {
13198
13602
  return [route, index];
13199
13603
  }
13200
13604
  })
@@ -13204,10 +13608,25 @@ function toFarmNodeResponse(request, response) {
13204
13608
  const orderOf = (route) => _nullishCoalesce(prerenderOrder.get(route), () => ( Number.MAX_SAFE_INTEGER));
13205
13609
  prerenderedRoutes.sort((a, b) => orderOf(a.route) - orderOf(b.route));
13206
13610
  });
13207
- if (_optionalChain([config, 'access', _307 => _307.md, 'optionalAccess', _308 => _308.enabled])) {
13611
+ const prerenderPagePaths = new Set(prerenderRoutes.map(toPrerenderPublicPath));
13612
+ let skippedNonHtmlPrerenderRoute = false;
13613
+ nitroInstance.hooks.hook("prerender:generate", (route) => {
13614
+ if (route.error || !prerenderPagePaths.has(route.route)) return;
13615
+ if (_optionalChain([route, 'access', _318 => _318.contentType, 'optionalAccess', _319 => _319.toLowerCase, 'call', _320 => _320(), 'access', _321 => _321.includes, 'call', _322 => _322("html")])) return;
13616
+ route.skip = true;
13617
+ skippedNonHtmlPrerenderRoute = true;
13618
+ const configuredRule = configuredNitroRouteRules[route.route];
13619
+ if (configuredRule) nitroInstance.options.routeRules[route.route] = configuredRule;
13620
+ else delete nitroInstance.options.routeRules[route.route];
13621
+ _chunkQMNWKQL4cjs.logger.info(`\u21AA Keeping SSG route ${route.route} server-handled (it does not render HTML)`);
13622
+ });
13623
+ nitroInstance.hooks.hook("prerender:done", () => {
13624
+ if (skippedNonHtmlPrerenderRoute) nitroInstance.routing.sync();
13625
+ });
13626
+ if (_optionalChain([config, 'access', _323 => _323.md, 'optionalAccess', _324 => _324.enabled])) {
13208
13627
  nitroInstance.hooks.hook("prerender:generate", (route) => {
13209
- if (!route.contents || !_optionalChain([route, 'access', _309 => _309.contentType, 'optionalAccess', _310 => _310.toLowerCase, 'call', _311 => _311(), 'access', _312 => _312.includes, 'call', _313 => _313("html")])) return;
13210
- const alternatePath = _chunkHGB4PM2Ccjs.getFarmMarkdownAlternatePath.call(void 0, config.md, route.route, {
13628
+ if (!route.contents || !_optionalChain([route, 'access', _325 => _325.contentType, 'optionalAccess', _326 => _326.toLowerCase, 'call', _327 => _327(), 'access', _328 => _328.includes, 'call', _329 => _329("html")])) return;
13629
+ const alternatePath = _chunkPG6ZIHKEcjs.getFarmMarkdownAlternatePath.call(void 0, config.md, route.route, {
13211
13630
  routePathname: (pathname) => routeManager.toRoutePathname(pathname)
13212
13631
  });
13213
13632
  if (!alternatePath) return;
@@ -13229,7 +13648,7 @@ function toFarmNodeResponse(request, response) {
13229
13648
  }
13230
13649
  if (config.security.csp && config.security.csp.nonce) {
13231
13650
  nitroInstance.hooks.hook("prerender:generate", async (route) => {
13232
- if (!route.contents || !_optionalChain([route, 'access', _314 => _314.contentType, 'optionalAccess', _315 => _315.toLowerCase, 'call', _316 => _316(), 'access', _317 => _317.includes, 'call', _318 => _318("html")])) return;
13651
+ if (!route.contents || !_optionalChain([route, 'access', _330 => _330.contentType, 'optionalAccess', _331 => _331.toLowerCase, 'call', _332 => _332(), 'access', _333 => _333.includes, 'call', _334 => _334("html")])) return;
13233
13652
  const staticCsp = await _chunk6JHZPB52cjs.applyFarmCspHashesToHtml.call(void 0, route.contents, config.security);
13234
13653
  if (!staticCsp) return;
13235
13654
  route.contents = staticCsp.html;
@@ -13256,7 +13675,8 @@ function toFarmNodeResponse(request, response) {
13256
13675
  const configuredPlugins = rollupConfig.plugins;
13257
13676
  rollupConfig.plugins = [
13258
13677
  ...Array.isArray(configuredPlugins) ? configuredPlugins : configuredPlugins ? [configuredPlugins] : [],
13259
- createPrerenderRuntimeResolverPlugin(config.root)
13678
+ createPrerenderRuntimeResolverPlugin(config.root),
13679
+ ...markdownPrecompiledPages ? [createPrerenderMarkdownPagesPlugin(markdownPrecompiledPages)] : []
13260
13680
  ];
13261
13681
  });
13262
13682
  });
@@ -13264,7 +13684,7 @@ function toFarmNodeResponse(request, response) {
13264
13684
  await nitroBuilder.copyPublicAssets(nitroInstance);
13265
13685
  if (prerenderReusesPrebuiltSSR && !canReusePrebuiltSSR) {
13266
13686
  nitroInstance.hooks.hook("prerender:config", (prerendererConfig) => {
13267
- const configuredPlugins = _optionalChain([prerendererConfig, 'access', _319 => _319.rollupConfig, 'optionalAccess', _320 => _320.plugins]);
13687
+ const configuredPlugins = _optionalChain([prerendererConfig, 'access', _335 => _335.rollupConfig, 'optionalAccess', _336 => _336.plugins]);
13268
13688
  const plugins = Array.isArray(configuredPlugins) ? configuredPlugins : configuredPlugins ? [configuredPlugins] : [];
13269
13689
  prerendererConfig.rollupConfig = {
13270
13690
  ...prerendererConfig.rollupConfig,
@@ -13294,9 +13714,9 @@ function toFarmNodeResponse(request, response) {
13294
13714
  ssrBundle,
13295
13715
  _path2.default.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
13296
13716
  null,
13297
- fs4
13717
+ fs5
13298
13718
  );
13299
- await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs4);
13719
+ await registerPrebuiltSSRPackageImport(prerenderServerDir, ssrEntryFile, fs5);
13300
13720
  });
13301
13721
  });
13302
13722
  }
@@ -13321,16 +13741,16 @@ function toFarmNodeResponse(request, response) {
13321
13741
  }
13322
13742
  if (prerenderRoutes.length > 0) {
13323
13743
  _chunkQMNWKQL4cjs.logger.info(`\u{1F4C4} Pre-rendering ${prerenderRoutes.length} SSG page(s)`);
13324
- const previousPrerender = process.env[_chunkROCF6UQDcjs.FARM_PRERENDER_ENV];
13325
- process.env[_chunkROCF6UQDcjs.FARM_PRERENDER_ENV] = "1";
13744
+ const previousPrerender = process.env[_chunk77SVUQM5cjs.FARM_PRERENDER_ENV];
13745
+ process.env[_chunk77SVUQM5cjs.FARM_PRERENDER_ENV] = "1";
13326
13746
  try {
13327
13747
  await nitroBuilder.prerender(nitroInstance);
13328
13748
  } finally {
13329
- if (previousPrerender === void 0) delete process.env[_chunkROCF6UQDcjs.FARM_PRERENDER_ENV];
13330
- else process.env[_chunkROCF6UQDcjs.FARM_PRERENDER_ENV] = previousPrerender;
13749
+ if (previousPrerender === void 0) delete process.env[_chunk77SVUQM5cjs.FARM_PRERENDER_ENV];
13750
+ else process.env[_chunk77SVUQM5cjs.FARM_PRERENDER_ENV] = previousPrerender;
13331
13751
  }
13332
13752
  }
13333
- const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir, fs4, preset) : Promise.resolve(null);
13753
+ const sharpRuntimeStagePromise = imageRuntime === "node" ? stageSharpRuntime(config, root, distDir, fs5, preset) : Promise.resolve(null);
13334
13754
  const prebuiltSSRFilesPromise = canReusePrebuiltSSR ? prepareSSRBundleFiles(
13335
13755
  ssrBundle,
13336
13756
  shouldMinify ? { keepNames: keepServerNames, target: "node18" } : null
@@ -13343,7 +13763,7 @@ function toFarmNodeResponse(request, response) {
13343
13763
  await nitroInstance.close();
13344
13764
  if (nitroBuildResult.status === "rejected") {
13345
13765
  if (sharpRuntimeStageResult.status === "fulfilled" && sharpRuntimeStageResult.value) {
13346
- await fs4.rm(sharpRuntimeStageResult.value.stageDir, {
13766
+ await fs5.rm(sharpRuntimeStageResult.value.stageDir, {
13347
13767
  recursive: true,
13348
13768
  force: true
13349
13769
  });
@@ -13356,20 +13776,20 @@ function toFarmNodeResponse(request, response) {
13356
13776
  if (prebuiltSSRFilesResult.status === "rejected") {
13357
13777
  throw prebuiltSSRFilesResult.reason;
13358
13778
  }
13359
- const stagedSharpRuntime = await _asyncNullishCoalesce(sharpRuntimeStageResult.value, async () => ( (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir, fs4, preset) : null)));
13779
+ const stagedSharpRuntime = await _asyncNullishCoalesce(sharpRuntimeStageResult.value, async () => ( (imageRuntime === "node" ? await stageSharpRuntime(config, root, distDir, fs5, preset) : null)));
13360
13780
  const runtimeCopyPromise = (async () => {
13361
13781
  if (stagedSharpRuntime) {
13362
- await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir, fs4);
13782
+ await installStagedSharpRuntime(stagedSharpRuntime, runtimeServerOutputDir, fs5);
13363
13783
  }
13364
13784
  if (useExternalMetadataImageRuntime) {
13365
- await copyMetadataImageRuntime(root, runtimeServerOutputDir, fs4);
13785
+ await copyMetadataImageRuntime(root, runtimeServerOutputDir, fs5);
13366
13786
  }
13367
13787
  })();
13368
13788
  const copyResults = await Promise.allSettled([
13369
13789
  prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
13370
13790
  prebuiltSSRFilesResult.value,
13371
13791
  _path2.default.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
13372
- fs4
13792
+ fs5
13373
13793
  ) : Promise.resolve(),
13374
13794
  runtimeCopyPromise
13375
13795
  ]);
@@ -13378,17 +13798,17 @@ function toFarmNodeResponse(request, response) {
13378
13798
  );
13379
13799
  if (failedCopy) throw failedCopy.reason;
13380
13800
  if (canReusePrebuiltSSR) {
13381
- await registerPrebuiltSSRPackageImport(_path2.default.join(outputDir, "server"), ssrEntryFile, fs4);
13801
+ await registerPrebuiltSSRPackageImport(_path2.default.join(outputDir, "server"), ssrEntryFile, fs5);
13382
13802
  _chunkQMNWKQL4cjs.logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
13383
13803
  }
13384
13804
  if (useRolldownBuilder) {
13385
13805
  _chunkQMNWKQL4cjs.logger.info("\u26A1 Built the Node adapter with Rolldown");
13386
13806
  }
13387
13807
  if (preset === "node-server" && !desktopServerEntry) {
13388
- await installFarmCompileCacheLauncher(_path2.default.join(outputDir, "server"), fs4);
13808
+ await installFarmCompileCacheLauncher(_path2.default.join(outputDir, "server"), fs5);
13389
13809
  }
13390
13810
  if (preset.startsWith("cloudflare")) {
13391
- await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir, fs4);
13811
+ await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir, fs5);
13392
13812
  }
13393
13813
  if (pluginManager) {
13394
13814
  await pluginManager.runHookParallel("afterNitroBuild", {
@@ -13402,7 +13822,7 @@ function toFarmNodeResponse(request, response) {
13402
13822
  await postProcessVercelOutput(
13403
13823
  root,
13404
13824
  outputDir,
13405
- fs4,
13825
+ fs5,
13406
13826
  config,
13407
13827
  farmWorkflows,
13408
13828
  routeRuntimeManifest,
@@ -13430,11 +13850,11 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
13430
13850
  } : {}
13431
13851
  };
13432
13852
  }
13433
- async function populateCloudflareProcessEnv(serverDir, fs4) {
13853
+ async function populateCloudflareProcessEnv(serverDir, fs5) {
13434
13854
  const wranglerPath = _path2.default.join(serverDir, "wrangler.json");
13435
13855
  let source;
13436
13856
  try {
13437
- source = await fs4.readFile(wranglerPath, "utf8");
13857
+ source = await fs5.readFile(wranglerPath, "utf8");
13438
13858
  } catch (error) {
13439
13859
  if (error.code === "ENOENT") return;
13440
13860
  throw error;
@@ -13442,7 +13862,7 @@ async function populateCloudflareProcessEnv(serverDir, fs4) {
13442
13862
  const wrangler = JSON.parse(source);
13443
13863
  const flags = _chunkNLBHLPEOcjs.resolveCloudflareProcessEnvFlags.call(void 0, wrangler);
13444
13864
  if (!flags) return;
13445
- await fs4.writeFile(
13865
+ await fs5.writeFile(
13446
13866
  wranglerPath,
13447
13867
  JSON.stringify({ ...wrangler, compatibility_flags: flags }, null, 2)
13448
13868
  );
@@ -13455,36 +13875,36 @@ function prepareSSRBundleFiles(ssrBundle, minifyOptions) {
13455
13875
  }))
13456
13876
  );
13457
13877
  }
13458
- async function writeSSRBundleFiles(files, targetDir, fs4) {
13459
- await fs4.rm(targetDir, { recursive: true, force: true });
13878
+ async function writeSSRBundleFiles(files, targetDir, fs5) {
13879
+ await fs5.rm(targetDir, { recursive: true, force: true });
13460
13880
  await Promise.all(
13461
13881
  files.map(async ({ fileName, contents }) => {
13462
13882
  const targetPath = _path2.default.join(targetDir, fileName);
13463
- await fs4.mkdir(_path2.default.dirname(targetPath), { recursive: true });
13464
- await fs4.writeFile(targetPath, contents);
13883
+ await fs5.mkdir(_path2.default.dirname(targetPath), { recursive: true });
13884
+ await fs5.writeFile(targetPath, contents);
13465
13885
  })
13466
13886
  );
13467
13887
  }
13468
- async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs4) {
13469
- await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs4);
13888
+ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs5) {
13889
+ await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs5);
13470
13890
  }
13471
- async function installFarmCompileCacheLauncher(serverDir, fs4) {
13891
+ async function installFarmCompileCacheLauncher(serverDir, fs5) {
13472
13892
  const entryPath = _path2.default.join(serverDir, "index.mjs");
13473
13893
  const serverPath = _path2.default.join(serverDir, _chunkNG2EZ6QScjs.FARM_SERVER_MODULE_FILE);
13474
- const entry = await fs4.readFile(entryPath, "utf8").catch((error) => {
13894
+ const entry = await fs5.readFile(entryPath, "utf8").catch((error) => {
13475
13895
  if (error.code === "ENOENT") return null;
13476
13896
  throw error;
13477
13897
  });
13478
13898
  if (entry === null) return false;
13479
13899
  if (entry.includes(`./${_chunkNG2EZ6QScjs.FARM_SERVER_MODULE_FILE}`)) return false;
13480
- await fs4.rename(entryPath, serverPath);
13481
- await fs4.writeFile(entryPath, _chunkNG2EZ6QScjs.createFarmCompileCacheLauncher.call(void 0, _chunkNG2EZ6QScjs.FARM_SERVER_MODULE_FILE));
13482
- await fs4.rm(_path2.default.join(serverDir, _chunkNG2EZ6QScjs.FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
13900
+ await fs5.rename(entryPath, serverPath);
13901
+ await fs5.writeFile(entryPath, _chunkNG2EZ6QScjs.createFarmCompileCacheLauncher.call(void 0, _chunkNG2EZ6QScjs.FARM_SERVER_MODULE_FILE));
13902
+ await fs5.rm(_path2.default.join(serverDir, _chunkNG2EZ6QScjs.FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
13483
13903
  return true;
13484
13904
  }
13485
- async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs4) {
13905
+ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs5) {
13486
13906
  const packagePath = _path2.default.join(serverDir, "package.json");
13487
- const packageJSON = await fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
13907
+ const packageJSON = await fs5.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
13488
13908
  if (error.code === "ENOENT") return { type: "module" };
13489
13909
  throw error;
13490
13910
  });
@@ -13494,56 +13914,56 @@ async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs4) {
13494
13914
  ...existingImports,
13495
13915
  [FARM_SSR_PACKAGE_IMPORT]: `./${outputEntry}`
13496
13916
  };
13497
- await fs4.mkdir(serverDir, { recursive: true });
13498
- await fs4.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
13917
+ await fs5.mkdir(serverDir, { recursive: true });
13918
+ await fs5.writeFile(packagePath, `${JSON.stringify(packageJSON, null, 2)}
13499
13919
  `);
13500
13920
  }
13501
- async function moveVercelOutputPath(src, dest, fs4) {
13921
+ async function moveVercelOutputPath(src, dest, fs5) {
13502
13922
  try {
13503
- await fs4.rename(src, dest);
13923
+ await fs5.rename(src, dest);
13504
13924
  return;
13505
13925
  } catch (error) {
13506
- const code = _optionalChain([error, 'optionalAccess', _321 => _321.code]);
13926
+ const code = _optionalChain([error, 'optionalAccess', _337 => _337.code]);
13507
13927
  if (code !== "EPERM" && code !== "EACCES" && code !== "EXDEV" && code !== "ENOTEMPTY") {
13508
13928
  throw error;
13509
13929
  }
13510
13930
  }
13511
- await fs4.cp(src, dest, { recursive: true, force: true });
13512
- await fs4.rm(src, { recursive: true, force: true });
13931
+ await fs5.cp(src, dest, { recursive: true, force: true });
13932
+ await fs5.rm(src, { recursive: true, force: true });
13513
13933
  }
13514
- async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages) {
13934
+ async function postProcessVercelOutput(root, outputDir, fs5, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages) {
13515
13935
  const serverDir = _path2.default.join(outputDir, "server");
13516
13936
  const functionsDir = _path2.default.join(outputDir, "functions");
13517
13937
  const nitroFuncDir = _path2.default.join(functionsDir, "__nitro.func");
13518
13938
  const staticDir = _path2.default.join(outputDir, "static");
13519
13939
  const publicDir = _path2.default.join(outputDir, "public");
13520
- await fs4.mkdir(nitroFuncDir, { recursive: true });
13521
- const serverContents = await fs4.readdir(serverDir).catch((error) => {
13940
+ await fs5.mkdir(nitroFuncDir, { recursive: true });
13941
+ const serverContents = await fs5.readdir(serverDir).catch((error) => {
13522
13942
  if (error.code === "ENOENT") return [];
13523
13943
  throw error;
13524
13944
  });
13525
13945
  for (const file of serverContents) {
13526
- await moveVercelOutputPath(_path2.default.join(serverDir, file), _path2.default.join(nitroFuncDir, file), fs4);
13946
+ await moveVercelOutputPath(_path2.default.join(serverDir, file), _path2.default.join(nitroFuncDir, file), fs5);
13527
13947
  }
13528
- if (serverContents.length > 0) await fs4.rm(serverDir, { recursive: true, force: true });
13948
+ if (serverContents.length > 0) await fs5.rm(serverDir, { recursive: true, force: true });
13529
13949
  try {
13530
- await moveVercelOutputPath(publicDir, staticDir, fs4);
13950
+ await moveVercelOutputPath(publicDir, staticDir, fs5);
13531
13951
  } catch (error) {
13532
- if (_optionalChain([error, 'optionalAccess', _322 => _322.code]) !== "ENOENT") throw error;
13952
+ if (_optionalChain([error, 'optionalAccess', _338 => _338.code]) !== "ENOENT") throw error;
13533
13953
  }
13534
- await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4);
13535
- await copyPrismaClientForVercel(root, nitroFuncDir, fs4);
13954
+ await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5);
13955
+ await copyPrismaClientForVercel(root, nitroFuncDir, fs5);
13536
13956
  const configPath = _path2.default.join(outputDir, "config.json");
13537
- const configContent = await fs4.readFile(configPath, "utf-8");
13957
+ const configContent = await fs5.readFile(configPath, "utf-8");
13538
13958
  const vercelConfig = JSON.parse(configContent);
13539
13959
  const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
13540
13960
  outputDir,
13541
13961
  routeRuntimeManifest,
13542
- fs4,
13962
+ fs5,
13543
13963
  config.basePath
13544
13964
  );
13545
13965
  const edgeMiddlewareRoutes = edgeMiddleware.middlewareRoutes.filter(
13546
- (route) => edgeMiddleware.guardedPages.some((pathname) => _chunkPXAHSCR6cjs.appMiddlewareMayHandlePath.call(void 0, [route], pathname))
13966
+ (route) => edgeMiddleware.guardedPages.some((pathname) => _chunkO2A6HE76cjs.appMiddlewareMayHandlePath.call(void 0, [route], pathname))
13547
13967
  );
13548
13968
  if (edgeMiddlewareRoutes.length > 0) {
13549
13969
  await writeFarmVercelEdgeMiddlewareFunction({
@@ -13553,7 +13973,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
13553
13973
  config,
13554
13974
  routes: edgeMiddlewareRoutes,
13555
13975
  guardedPages: edgeMiddleware.guardedPages,
13556
- fs: fs4
13976
+ fs: fs5
13557
13977
  });
13558
13978
  }
13559
13979
  vercelConfig.routes = buildFarmVercelRoutes({
@@ -13566,19 +13986,19 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
13566
13986
  vercelConfig,
13567
13987
  farmWorkflows.workflows
13568
13988
  );
13569
- const vercelConfigWithCrons = _chunkYAEN3L2Fcjs.applyFarmCronVercelCrons.call(void 0, vercelConfigWithWorkflowCrons, cronJobs);
13570
- await fs4.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
13989
+ const vercelConfigWithCrons = _chunkEF5AP4CVcjs.applyFarmCronVercelCrons.call(void 0, vercelConfigWithWorkflowCrons, cronJobs);
13990
+ await fs5.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
13571
13991
  _chunkQMNWKQL4cjs.logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
13572
13992
  }
13573
- async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
13574
- if (!_optionalChain([config, 'access', _323 => _323.docs, 'optionalAccess', _324 => _324.enabled])) return;
13575
- const [mainRoot, ...extraRoots] = _chunkHFUOLILAcjs.getFarmDocsRoots.call(void 0, config.docs);
13993
+ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5) {
13994
+ if (!_optionalChain([config, 'access', _339 => _339.docs, 'optionalAccess', _340 => _340.enabled])) return;
13995
+ const [mainRoot, ...extraRoots] = _chunkZRCGPSUMcjs.getFarmDocsRoots.call(void 0, config.docs);
13576
13996
  await copyFarmDocsRootContent(
13577
13997
  mainRoot,
13578
13998
  root,
13579
13999
  config.srcDir,
13580
14000
  _path2.default.join(nitroFuncDir, "farm-docs-content"),
13581
- fs4
14001
+ fs5
13582
14002
  );
13583
14003
  for (const [index, docsRoot] of extraRoots.entries()) {
13584
14004
  await copyFarmDocsRootContent(
@@ -13586,31 +14006,31 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
13586
14006
  root,
13587
14007
  config.srcDir,
13588
14008
  _path2.default.join(nitroFuncDir, "farm-docs-roots", String(index)),
13589
- fs4
14009
+ fs5
13590
14010
  );
13591
14011
  }
13592
14012
  }
13593
- async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs4) {
14013
+ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs5) {
13594
14014
  const docsContentDir = resolveBuildDocsContentDir(docs, root, srcDir);
13595
14015
  if (!docsContentDir) return;
13596
- const lastModifiedManifest = _chunkHFUOLILAcjs.createFarmDocsLastModifiedManifest.call(void 0, docsContentDir, {
14016
+ const lastModifiedManifest = _chunkZRCGPSUMcjs.createFarmDocsLastModifiedManifest.call(void 0, docsContentDir, {
13597
14017
  fallback: "now"
13598
14018
  });
13599
- const undatedPages = _nullishCoalesce(_optionalChain([lastModifiedManifest, 'access', _325 => _325.unknown, 'optionalAccess', _326 => _326.length]), () => ( 0));
14019
+ const undatedPages = _nullishCoalesce(_optionalChain([lastModifiedManifest, 'access', _341 => _341.unknown, 'optionalAccess', _342 => _342.length]), () => ( 0));
13600
14020
  if (undatedPages > 0) {
13601
14021
  _chunkQMNWKQL4cjs.logger.warn(
13602
14022
  `${undatedPages} docs page(s) were last changed before this shallow clone's Git history, so they show no "Last updated" date. Build from a full clone (git fetch --unshallow) or set lastModified in the page's frontmatter.`
13603
14023
  );
13604
14024
  }
13605
- await fs4.rm(bundledContentDir, { recursive: true, force: true });
13606
- await fs4.mkdir(_path2.default.dirname(bundledContentDir), { recursive: true });
13607
- await fs4.cp(docsContentDir, bundledContentDir, {
14025
+ await fs5.rm(bundledContentDir, { recursive: true, force: true });
14026
+ await fs5.mkdir(_path2.default.dirname(bundledContentDir), { recursive: true });
14027
+ await fs5.cp(docsContentDir, bundledContentDir, {
13608
14028
  recursive: true,
13609
14029
  force: true,
13610
14030
  dereference: true
13611
14031
  });
13612
- await fs4.writeFile(
13613
- _path2.default.join(bundledContentDir, _chunkHFUOLILAcjs.FARM_DOCS_LAST_MODIFIED_MANIFEST),
14032
+ await fs5.writeFile(
14033
+ _path2.default.join(bundledContentDir, _chunkZRCGPSUMcjs.FARM_DOCS_LAST_MODIFIED_MANIFEST),
13614
14034
  `${JSON.stringify(lastModifiedManifest, null, 2)}
13615
14035
  `
13616
14036
  );
@@ -13629,21 +14049,21 @@ function platformFieldAllows(field, value) {
13629
14049
  const allowed = entries.filter((entry) => !entry.startsWith("!"));
13630
14050
  return allowed.length === 0 || allowed.includes(value);
13631
14051
  }
13632
- async function stageSharpRuntime(config, root, distDir, fs4, preset) {
14052
+ async function stageSharpRuntime(config, root, distDir, fs5, preset) {
13633
14053
  const functionPlatform = resolveServerFunctionPlatform(preset);
13634
14054
  const projectRequire = _module.createRequire.call(void 0, _path2.default.join(root, "package.json"));
13635
14055
  let sharpRequire = projectRequire;
13636
14056
  if (!resolvePackageJson(projectRequire, "sharp")) {
13637
14057
  try {
13638
14058
  sharpRequire = _module.createRequire.call(void 0, projectRequire.resolve("@farm.js/core"));
13639
- } catch (e36) {
14059
+ } catch (e40) {
13640
14060
  }
13641
14061
  }
13642
14062
  const copiedPackages = /* @__PURE__ */ new Map();
13643
14063
  const packageCopies = /* @__PURE__ */ new Map();
13644
14064
  const stageRoot = _path2.default.join(root, distDir, "tmp");
13645
- await fs4.mkdir(stageRoot, { recursive: true });
13646
- const stageDir = await fs4.mkdtemp(_path2.default.join(stageRoot, "sharp-runtime-"));
14065
+ await fs5.mkdir(stageRoot, { recursive: true });
14066
+ const stageDir = await fs5.mkdtemp(_path2.default.join(stageRoot, "sharp-runtime-"));
13647
14067
  const targetNodeModules = _path2.default.join(stageDir, "node_modules");
13648
14068
  function copyPackage(packageName, parentRequire) {
13649
14069
  const activeCopy = packageCopies.get(packageName);
@@ -13655,19 +14075,19 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
13655
14075
  async function copyPackageOnce(packageName, parentRequire) {
13656
14076
  const packageJsonPath = resolvePackageJson(parentRequire, packageName);
13657
14077
  if (!packageJsonPath) return;
13658
- const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
14078
+ const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf8"));
13659
14079
  if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
13660
14080
  const packageDir = _path2.default.dirname(packageJsonPath);
13661
14081
  const targetDir = _path2.default.join(targetNodeModules, ...packageName.split("/"));
13662
14082
  copiedPackages.set(packageName, String(packageJson.version || "*"));
13663
- await fs4.mkdir(_path2.default.dirname(targetDir), { recursive: true });
14083
+ await fs5.mkdir(_path2.default.dirname(targetDir), { recursive: true });
13664
14084
  const packageRequire = _module.createRequire.call(void 0, packageJsonPath);
13665
14085
  const dependencies = {
13666
14086
  ...packageJson.dependencies,
13667
14087
  ...packageJson.optionalDependencies
13668
14088
  };
13669
14089
  await settleAllOrThrow([
13670
- fs4.cp(packageDir, targetDir, {
14090
+ fs5.cp(packageDir, targetDir, {
13671
14091
  recursive: true,
13672
14092
  force: true,
13673
14093
  dereference: true,
@@ -13681,10 +14101,10 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
13681
14101
  try {
13682
14102
  await copyPackage("sharp", sharpRequire);
13683
14103
  if (!copiedPackages.has("sharp")) {
13684
- throw new Error(`Farm image optimization requires sharp. ${_chunkTAU3OF5Bcjs.SHARP_INSTALL_HINT}`);
14104
+ throw new Error(`Farm image optimization requires sharp. ${_chunk56HHUSR5cjs.SHARP_INSTALL_HINT}`);
13685
14105
  }
13686
14106
  } catch (error) {
13687
- await fs4.rm(stageDir, { recursive: true, force: true });
14107
+ await fs5.rm(stageDir, { recursive: true, force: true });
13688
14108
  throw error;
13689
14109
  }
13690
14110
  return {
@@ -13694,19 +14114,19 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
13694
14114
  )
13695
14115
  };
13696
14116
  }
13697
- async function installStagedSharpRuntime(staged, nitroFuncDir, fs4) {
14117
+ async function installStagedSharpRuntime(staged, nitroFuncDir, fs5) {
13698
14118
  const stagedNodeModules = _path2.default.join(staged.stageDir, "node_modules");
13699
14119
  const targetNodeModules = _path2.default.join(nitroFuncDir, "node_modules");
13700
14120
  try {
13701
- await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs4);
13702
- const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs4);
14121
+ await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs5);
14122
+ const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs5);
13703
14123
  functionPackage.dependencies = {
13704
14124
  ...functionPackage.dependencies,
13705
14125
  ...staged.dependencies
13706
14126
  };
13707
- await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs4);
14127
+ await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
13708
14128
  } finally {
13709
- await fs4.rm(staged.stageDir, { recursive: true, force: true });
14129
+ await fs5.rm(staged.stageDir, { recursive: true, force: true });
13710
14130
  }
13711
14131
  _chunkQMNWKQL4cjs.logger.info(
13712
14132
  `\u{1F5BC}\uFE0F Bundled Sharp image runtime (${Object.keys(staged.dependencies).length} packages)`
@@ -13719,15 +14139,15 @@ async function settleAllOrThrow(operations) {
13719
14139
  );
13720
14140
  if (failure) throw failure.reason;
13721
14141
  }
13722
- async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
13723
- await fs4.mkdir(targetDir, { recursive: true });
13724
- const entries = await fs4.readdir(sourceDir, { withFileTypes: true });
14142
+ async function mergeStagedDirectory(sourceDir, targetDir, fs5) {
14143
+ await fs5.mkdir(targetDir, { recursive: true });
14144
+ const entries = await fs5.readdir(sourceDir, { withFileTypes: true });
13725
14145
  await settleAllOrThrow(
13726
14146
  entries.map(async (entry) => {
13727
14147
  const sourcePath = _path2.default.join(sourceDir, entry.name);
13728
14148
  const targetPath = _path2.default.join(targetDir, entry.name);
13729
14149
  try {
13730
- await fs4.rename(sourcePath, targetPath);
14150
+ await fs5.rename(sourcePath, targetPath);
13731
14151
  return;
13732
14152
  } catch (error) {
13733
14153
  const code = error.code;
@@ -13736,16 +14156,16 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
13736
14156
  }
13737
14157
  }
13738
14158
  if (entry.isDirectory()) {
13739
- await mergeStagedDirectory(sourcePath, targetPath, fs4);
13740
- await fs4.rm(sourcePath, { recursive: true, force: true });
14159
+ await mergeStagedDirectory(sourcePath, targetPath, fs5);
14160
+ await fs5.rm(sourcePath, { recursive: true, force: true });
13741
14161
  return;
13742
14162
  }
13743
- await fs4.cp(sourcePath, targetPath, {
14163
+ await fs5.cp(sourcePath, targetPath, {
13744
14164
  force: true,
13745
14165
  dereference: true,
13746
14166
  mode: _fs.constants.COPYFILE_FICLONE
13747
14167
  });
13748
- await fs4.rm(sourcePath, { force: true });
14168
+ await fs5.rm(sourcePath, { force: true });
13749
14169
  })
13750
14170
  );
13751
14171
  }
@@ -13763,41 +14183,41 @@ function resolveMetadataImageRuntimePackageJson(root) {
13763
14183
  if (packageJsonPath) return packageJsonPath;
13764
14184
  try {
13765
14185
  return resolvePackageJson(_module.createRequire.call(void 0, projectRequire.resolve("@farm.js/core")), "@vercel/og");
13766
- } catch (e37) {
14186
+ } catch (e41) {
13767
14187
  return null;
13768
14188
  }
13769
14189
  }
13770
- async function copyMetadataImageRuntime(root, nitroFuncDir, fs4) {
14190
+ async function copyMetadataImageRuntime(root, nitroFuncDir, fs5) {
13771
14191
  const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
13772
14192
  if (!packageJsonPath) return;
13773
- const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
14193
+ const packageJson = JSON.parse(await fs5.readFile(packageJsonPath, "utf8"));
13774
14194
  const packageDir = _path2.default.dirname(packageJsonPath);
13775
14195
  const targetDir = _path2.default.join(nitroFuncDir, "node_modules", "@vercel", "og");
13776
- await fs4.mkdir(_path2.default.dirname(targetDir), { recursive: true });
13777
- await fs4.cp(packageDir, targetDir, {
14196
+ await fs5.mkdir(_path2.default.dirname(targetDir), { recursive: true });
14197
+ await fs5.cp(packageDir, targetDir, {
13778
14198
  recursive: true,
13779
14199
  force: true,
13780
14200
  dereference: true,
13781
14201
  mode: _fs.constants.COPYFILE_FICLONE
13782
14202
  });
13783
- const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs4);
14203
+ const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs5);
13784
14204
  functionPackage.dependencies = {
13785
14205
  ...functionPackage.dependencies,
13786
14206
  "@vercel/og": String(packageJson.version || "0.11.1")
13787
14207
  };
13788
- await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs4);
14208
+ await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
13789
14209
  _chunkQMNWKQL4cjs.logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
13790
14210
  }
13791
- async function readNitroOutputPackage(outputDir, fs4) {
14211
+ async function readNitroOutputPackage(outputDir, fs5) {
13792
14212
  const packagePath = _path2.default.join(outputDir, "package.json");
13793
- return fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
14213
+ return fs5.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
13794
14214
  if (error.code === "ENOENT") return {};
13795
14215
  throw error;
13796
14216
  });
13797
14217
  }
13798
- async function writeNitroOutputPackage(outputDir, packageJson, fs4) {
13799
- await fs4.mkdir(outputDir, { recursive: true });
13800
- await fs4.writeFile(
14218
+ async function writeNitroOutputPackage(outputDir, packageJson, fs5) {
14219
+ await fs5.mkdir(outputDir, { recursive: true });
14220
+ await fs5.writeFile(
13801
14221
  _path2.default.join(outputDir, "package.json"),
13802
14222
  `${JSON.stringify(packageJson, null, 2)}
13803
14223
  `
@@ -13810,7 +14230,7 @@ function resolvePackageJson(parentRequire, packageName) {
13810
14230
  const resolved = parentRequire.resolve(request);
13811
14231
  if (resolved.endsWith(".json")) return resolved;
13812
14232
  _nullishCoalesce(metadataModule, () => ( (metadataModule = resolved)));
13813
- } catch (e38) {
14233
+ } catch (e42) {
13814
14234
  }
13815
14235
  }
13816
14236
  try {
@@ -13821,63 +14241,63 @@ function resolvePackageJson(parentRequire, packageName) {
13821
14241
  try {
13822
14242
  const manifest = JSON.parse(_fs.readFileSync.call(void 0, candidate, "utf8"));
13823
14243
  if (manifest.name === packageName) return candidate;
13824
- } catch (e39) {
14244
+ } catch (e43) {
13825
14245
  }
13826
14246
  }
13827
14247
  if (_path2.default.basename(directory) === "node_modules") break;
13828
14248
  directory = _path2.default.dirname(directory);
13829
14249
  }
13830
- } catch (e40) {
14250
+ } catch (e44) {
13831
14251
  }
13832
14252
  return null;
13833
14253
  }
13834
- async function resolveProjectInstalledPackageDir(root, packageName, fs4) {
14254
+ async function resolveProjectInstalledPackageDir(root, packageName, fs5) {
13835
14255
  let directory = _path2.default.resolve(root);
13836
14256
  while (true) {
13837
14257
  const candidate = _path2.default.join(directory, "node_modules", ...packageName.split("/"));
13838
14258
  try {
13839
- const packageDir = await fs4.realpath(candidate);
13840
- if ((await fs4.stat(_path2.default.join(packageDir, "package.json"))).isFile()) return packageDir;
13841
- } catch (e41) {
14259
+ const packageDir = await fs5.realpath(candidate);
14260
+ if ((await fs5.stat(_path2.default.join(packageDir, "package.json"))).isFile()) return packageDir;
14261
+ } catch (e45) {
13842
14262
  }
13843
14263
  const parent = _path2.default.dirname(directory);
13844
14264
  if (parent === directory) return null;
13845
14265
  directory = parent;
13846
14266
  }
13847
14267
  }
13848
- async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
13849
- const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client", fs4);
14268
+ async function copyPrismaClientForVercel(root, nitroFuncDir, fs5) {
14269
+ const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client", fs5);
13850
14270
  if (!prismaClientDir) return;
13851
14271
  const generatedClientDir = _path2.default.join(prismaClientDir, "..", "..", ".prisma", "client");
13852
14272
  try {
13853
- await fs4.access(generatedClientDir);
13854
- } catch (e42) {
14273
+ await fs5.access(generatedClientDir);
14274
+ } catch (e46) {
13855
14275
  return;
13856
14276
  }
13857
14277
  const targetNodeModules = _path2.default.join(nitroFuncDir, "node_modules");
13858
14278
  const targetPrismaScopeDir = _path2.default.join(targetNodeModules, "@prisma");
13859
14279
  const targetGeneratedDir = _path2.default.join(targetNodeModules, ".prisma", "client");
13860
14280
  const targetClientDir = _path2.default.join(targetPrismaScopeDir, "client");
13861
- await fs4.mkdir(targetPrismaScopeDir, { recursive: true });
13862
- await fs4.cp(prismaClientDir, targetClientDir, {
14281
+ await fs5.mkdir(targetPrismaScopeDir, { recursive: true });
14282
+ await fs5.cp(prismaClientDir, targetClientDir, {
13863
14283
  recursive: true,
13864
14284
  force: true
13865
14285
  });
13866
- await fs4.cp(generatedClientDir, targetGeneratedDir, {
14286
+ await fs5.cp(generatedClientDir, targetGeneratedDir, {
13867
14287
  recursive: true,
13868
14288
  force: true
13869
14289
  });
13870
14290
  const clientPackagePath = _path2.default.join(prismaClientDir, "package.json");
13871
14291
  const [functionPackage, clientPackageContent] = await Promise.all([
13872
- readNitroOutputPackage(nitroFuncDir, fs4),
13873
- fs4.readFile(clientPackagePath, "utf-8")
14292
+ readNitroOutputPackage(nitroFuncDir, fs5),
14293
+ fs5.readFile(clientPackagePath, "utf-8")
13874
14294
  ]);
13875
14295
  const clientPackage = JSON.parse(clientPackageContent);
13876
14296
  functionPackage.dependencies = {
13877
14297
  ...functionPackage.dependencies,
13878
14298
  "@prisma/client": clientPackage.version
13879
14299
  };
13880
- await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs4);
14300
+ await writeNitroOutputPackage(nitroFuncDir, functionPackage, fs5);
13881
14301
  }
13882
14302
  function islandsActionKeyCode() {
13883
14303
  const key = _crypto.randomBytes.call(void 0, 32).toString("base64url");
@@ -13911,7 +14331,7 @@ async function createFarmProjectModuleSsrEnvironment() {
13911
14331
  // src/build/index.ts
13912
14332
  async function build(config, options = {}) {
13913
14333
  return _chunkNG2EZ6QScjs.withProductionNodeEnv.call(void 0,
13914
- () => _chunkHTXKSREFcjs.withPackageClientBoundaryCache.call(void 0, () => buildWithProductionNodeEnv(config, options))
14334
+ () => _chunkNXGQIXR7cjs.withPackageClientBoundaryCache.call(void 0, () => buildWithProductionNodeEnv(config, options))
13915
14335
  );
13916
14336
  }
13917
14337
  function createBuildTargetBaseline(config) {
@@ -13922,7 +14342,7 @@ function createBuildTargetBaseline(config) {
13922
14342
  preset,
13923
14343
  distDir,
13924
14344
  outputDir,
13925
- outputWasDerived: outputDir === _chunkOXNZUCHNcjs.getDefaultDeployOutputDir.call(void 0, config.deploy.target, preset, distDir)
14345
+ outputWasDerived: outputDir === _chunkP3EZKU6Lcjs.getDefaultDeployOutputDir.call(void 0, config.deploy.target, preset, distDir)
13926
14346
  };
13927
14347
  }
13928
14348
  function resolveBuildTargets(config, options, baseline) {
@@ -13931,8 +14351,8 @@ function resolveBuildTargets(config, options, baseline) {
13931
14351
  const distDir = config.distDir || ".farm";
13932
14352
  const outputWasReplaced = config.deploy.outputDir !== baseline.outputDir;
13933
14353
  const shouldRefreshDerivedOutput = baseline.outputWasDerived && !outputWasReplaced && (preset !== baseline.preset || distDir !== baseline.distDir);
13934
- const deployTarget = preset === config.deploy.preset ? config.deploy.target : _chunkOXNZUCHNcjs.getDeployTargetForPreset.call(void 0, preset);
13935
- const outputDir = shouldRefreshDerivedOutput ? _chunkOXNZUCHNcjs.getDefaultDeployOutputDir.call(void 0, deployTarget, preset, distDir) : config.deploy.outputDir;
14354
+ const deployTarget = preset === config.deploy.preset ? config.deploy.target : _chunkP3EZKU6Lcjs.getDeployTargetForPreset.call(void 0, preset);
14355
+ const outputDir = shouldRefreshDerivedOutput ? _chunkP3EZKU6Lcjs.getDefaultDeployOutputDir.call(void 0, deployTarget, preset, distDir) : config.deploy.outputDir;
13936
14356
  return {
13937
14357
  root,
13938
14358
  preset,
@@ -13940,7 +14360,7 @@ function resolveBuildTargets(config, options, baseline) {
13940
14360
  distDir,
13941
14361
  deployTarget,
13942
14362
  outputDir,
13943
- deployOutputDir: _chunkOXNZUCHNcjs.resolveDeployOutputPath.call(void 0, root, outputDir)
14363
+ deployOutputDir: _chunkP3EZKU6Lcjs.resolveDeployOutputPath.call(void 0, root, outputDir)
13944
14364
  };
13945
14365
  }
13946
14366
  async function buildWithProductionNodeEnv(inputConfig, options) {
@@ -13977,15 +14397,15 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
13977
14397
  };
13978
14398
  config = {
13979
14399
  ...config,
13980
- images: _chunkTAU3OF5Bcjs.resolveFarmImageProviderForRuntime.call(void 0, config.images, {
14400
+ images: _chunk56HHUSR5cjs.resolveFarmImageProviderForRuntime.call(void 0, config.images, {
13981
14401
  root: targets.root,
13982
14402
  preset: targets.preset
13983
14403
  })
13984
14404
  };
13985
- if (_optionalChain([config, 'access', _327 => _327.docs, 'optionalAccess', _328 => _328.enabled])) await _chunkNDOE76QCcjs.loadFarmDocsEngine.call(void 0, );
14405
+ if (_optionalChain([config, 'access', _343 => _343.docs, 'optionalAccess', _344 => _344.enabled])) await _chunkNDOE76QCcjs.loadFarmDocsEngine.call(void 0, );
13986
14406
  pluginManager.updateContext({ config });
13987
14407
  const { root, preset, srcDir, distDir, deployOutputDir } = targets;
13988
- _chunkHTXKSREFcjs.usePackageClientBoundaryCacheFile.call(void 0, _chunkHTXKSREFcjs.resolvePackageClientBoundaryCacheFile.call(void 0, root, distDir));
14408
+ _chunkNXGQIXR7cjs.usePackageClientBoundaryCacheFile.call(void 0, _chunkNXGQIXR7cjs.resolvePackageClientBoundaryCacheFile.call(void 0, root, distDir));
13989
14409
  _chunkQMNWKQL4cjs.logger.info(`\u{1F69C} Building Farm.js application with preset: ${preset}...`);
13990
14410
  await pluginManager.setupPlugins();
13991
14411
  await pluginManager.runHookParallel("beforeBundle", {
@@ -13997,8 +14417,8 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
13997
14417
  });
13998
14418
  _chunkQMNWKQL4cjs.logger.info("\u{1F50D} Discovering routes and API endpoints...");
13999
14419
  const productionViteResult = productionViteResultPromise ? (await productionViteResultPromise)[0] : void 0;
14000
- if (_optionalChain([productionViteResult, 'optionalAccess', _329 => _329.status]) === "rejected") throw productionViteResult.reason;
14001
- const productionVite = _optionalChain([productionViteResult, 'optionalAccess', _330 => _330.value]);
14420
+ if (_optionalChain([productionViteResult, 'optionalAccess', _345 => _345.status]) === "rejected") throw productionViteResult.reason;
14421
+ const productionVite = _optionalChain([productionViteResult, 'optionalAccess', _346 => _346.value]);
14002
14422
  const createViteServer = productionVite ? productionVite.createServer : (await import("vite")).createServer;
14003
14423
  projectModuleServer = await createProjectModuleServer(
14004
14424
  createViteServer,
@@ -14006,18 +14426,19 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
14006
14426
  root,
14007
14427
  rendererBuild.signal
14008
14428
  );
14009
- const farmApp = _chunkTAU3OF5Bcjs.createFarmApp.call(void 0, config, projectModuleServer);
14429
+ const farmApp = _chunk56HHUSR5cjs.createFarmApp.call(void 0, config, projectModuleServer);
14430
+ if (options.universal !== false) farmApp.getRouteManager().keepBuildSourceSnapshot();
14010
14431
  await farmApp.initialize();
14011
14432
  const routeManager = farmApp.getRouteManager();
14012
14433
  const serverRenderer = farmApp.getServerRenderer();
14013
- const typeArtifacts = _chunkCLEWORVYcjs.generateFarmTypeArtifacts.call(void 0, {
14434
+ const typeArtifacts = _chunkACAEFEOHcjs.generateFarmTypeArtifacts.call(void 0, {
14014
14435
  root,
14015
14436
  srcDir,
14016
14437
  layers: config.layers,
14017
14438
  plugins: config.plugins,
14018
14439
  extraRoutes: [
14019
- ..._optionalChain([config, 'access', _331 => _331.openapi, 'optionalAccess', _332 => _332.enabled]) && config.openapi.route ? [config.openapi.route] : [],
14020
- ..._chunkHFUOLILAcjs.getFarmDocsRouteTypeEntries.call(void 0, config.docs)
14440
+ ..._optionalChain([config, 'access', _347 => _347.openapi, 'optionalAccess', _348 => _348.enabled]) && config.openapi.route ? [config.openapi.route] : [],
14441
+ ..._chunkZRCGPSUMcjs.getFarmDocsRouteTypeEntries.call(void 0, config.docs)
14021
14442
  ],
14022
14443
  suppressLintOnLink: config.suppressLintOnLink,
14023
14444
  componentExtensions: config.renderer.componentExtensions,
@@ -14026,7 +14447,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
14026
14447
  const message = error instanceof Error ? error.message : String(error);
14027
14448
  _chunkQMNWKQL4cjs.logger.warn(`Route type generation failed (farm.d.ts may be stale): ${message}`);
14028
14449
  });
14029
- const apiRouteManager = new (0, _chunk5LOARKDPcjs.APIRouteManager)(
14450
+ const apiRouteManager = new (0, _chunk2TZ3F6TNcjs.APIRouteManager)(
14030
14451
  _chunkMTBDJ326cjs.getFarmAppDirectories.call(void 0, config),
14031
14452
  projectModuleServer,
14032
14453
  {
@@ -14101,7 +14522,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
14101
14522
  throw error;
14102
14523
  } finally {
14103
14524
  try {
14104
- await _optionalChain([projectModuleServer, 'optionalAccess', _333 => _333.close, 'call', _334 => _334()]);
14525
+ await _optionalChain([projectModuleServer, 'optionalAccess', _349 => _349.close, 'call', _350 => _350()]);
14105
14526
  } finally {
14106
14527
  rendererBuild.abort();
14107
14528
  }
@@ -14113,7 +14534,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
14113
14534
  ssr: true,
14114
14535
  buildLifetime
14115
14536
  });
14116
- const viteConfig = _chunkTAU3OF5Bcjs.mergeFarmViteConfig.call(void 0,
14537
+ const viteConfig = _chunk56HHUSR5cjs.mergeFarmViteConfig.call(void 0,
14117
14538
  {
14118
14539
  root,
14119
14540
  appType: "custom",
@@ -14125,12 +14546,12 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
14125
14546
  },
14126
14547
  plugins: [
14127
14548
  ...rendererVitePlugins,
14128
- _chunkTAU3OF5Bcjs.farmFontImportsPlugin.call(void 0, {
14549
+ _chunk56HHUSR5cjs.farmFontImportsPlugin.call(void 0, {
14129
14550
  root,
14130
14551
  basePath: config.basePath,
14131
14552
  publicDir: config.publicDir
14132
14553
  }),
14133
- _chunkHTXKSREFcjs.farmEnvironmentFunctionsPlugin.call(void 0, ),
14554
+ _chunkNXGQIXR7cjs.farmEnvironmentFunctionsPlugin.call(void 0, ),
14134
14555
  // Route modules load here at build time (rendering config, prerendering): `server-only`
14135
14556
  // resolves as it does in the server build. Module-entry packages load pre-bundled, as in
14136
14557
  // `farm dev`: unbundled, lucide-react alone is ~1,750 modules through the module runner,
@@ -14142,7 +14563,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
14142
14563
  hmr: false
14143
14564
  },
14144
14565
  resolve: {
14145
- alias: _chunkTAU3OF5Bcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
14566
+ alias: _chunk56HHUSR5cjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
14146
14567
  dedupe: [...config.renderer.dedupe || []]
14147
14568
  },
14148
14569
  optimizeDeps: {
@@ -14181,10 +14602,10 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
14181
14602
  noDiscovery: true
14182
14603
  },
14183
14604
  // An app or plugin that brings its own SSR environment keeps it.
14184
- environments: _optionalChain([viteConfig, 'access', _335 => _335.environments, 'optionalAccess', _336 => _336.ssr, 'optionalAccess', _337 => _337.dev, 'optionalAccess', _338 => _338.createEnvironment]) ? viteConfig.environments : {
14605
+ environments: _optionalChain([viteConfig, 'access', _351 => _351.environments, 'optionalAccess', _352 => _352.ssr, 'optionalAccess', _353 => _353.dev, 'optionalAccess', _354 => _354.createEnvironment]) ? viteConfig.environments : {
14185
14606
  ...viteConfig.environments,
14186
14607
  ssr: {
14187
- ..._optionalChain([viteConfig, 'access', _339 => _339.environments, 'optionalAccess', _340 => _340.ssr]),
14608
+ ..._optionalChain([viteConfig, 'access', _355 => _355.environments, 'optionalAccess', _356 => _356.ssr]),
14188
14609
  ...await createFarmProjectModuleSsrEnvironment()
14189
14610
  }
14190
14611
  }
@@ -14218,7 +14639,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
14218
14639
  farmServerOnlyEntriesPlugin(),
14219
14640
  farmIslandContainersPlugin(config),
14220
14641
  farmPlugin(config, pluginManager),
14221
- _chunkHTXKSREFcjs.farmEnvironmentFunctionsPlugin.call(void 0, config)
14642
+ _chunkNXGQIXR7cjs.farmEnvironmentFunctionsPlugin.call(void 0, config)
14222
14643
  ],
14223
14644
  mode: "production"
14224
14645
  });
@@ -14246,13 +14667,13 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
14246
14667
  define: {
14247
14668
  __FARM_API_BASE_URL__: JSON.stringify(config.api.baseURL),
14248
14669
  __FARM_ENV__: JSON.stringify(_chunk3EIPOTZVcjs.createBundledEnv.call(void 0, config.env)),
14249
- __FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _341 => _341.env, 'optionalAccess', _342 => _342.public]) || {})
14670
+ __FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _357 => _357.env, 'optionalAccess', _358 => _358.public]) || {})
14250
14671
  },
14251
14672
  plugins: [
14252
14673
  farmI18nClientBridgePlugin(),
14253
14674
  farmIslandContainersPlugin(config),
14254
14675
  farmPlugin(config, pluginManager),
14255
- _chunkHTXKSREFcjs.farmEnvironmentFunctionsPlugin.call(void 0, config)
14676
+ _chunkNXGQIXR7cjs.farmEnvironmentFunctionsPlugin.call(void 0, config)
14256
14677
  ],
14257
14678
  mode: "production"
14258
14679
  });
@@ -14267,7 +14688,7 @@ function resolveLegacyPageEntry(config, root, srcDir) {
14267
14688
  }
14268
14689
  async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
14269
14690
  const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
14270
- import("./nitro-2LMOMIST.cjs"),
14691
+ import("./nitro-SSFTPZMW.cjs"),
14271
14692
  import("nitro/builder")
14272
14693
  ]);
14273
14694
  let nitroConfig = await createNitroConfig(
@@ -14280,7 +14701,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
14280
14701
  if (pluginManager) {
14281
14702
  nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
14282
14703
  }
14283
- const outputDir = _chunkOXNZUCHNcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
14704
+ const outputDir = _chunkP3EZKU6Lcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
14284
14705
  const serverOutputDir = _path2.default.join(outputDir, "server");
14285
14706
  const publicOutputDir = _path2.default.join(outputDir, "public");
14286
14707
  const { mkdir, cp } = await import("fs/promises");
@@ -14294,10 +14715,10 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
14294
14715
  const manifestPath = _path2.default.join(publicOutputDir, "farm-client-manifest.json");
14295
14716
  const assetsDir = _path2.default.join(publicOutputDir, "assets");
14296
14717
  const manifestExists = await import("fs/promises").then(
14297
- (fs4) => fs4.access(manifestPath).then(() => true).catch(() => false)
14718
+ (fs5) => fs5.access(manifestPath).then(() => true).catch(() => false)
14298
14719
  );
14299
14720
  const assetsExist = await import("fs/promises").then(
14300
- (fs4) => fs4.access(assetsDir).then(() => true).catch(() => false)
14721
+ (fs5) => fs5.access(assetsDir).then(() => true).catch(() => false)
14301
14722
  );
14302
14723
  if (manifestExists && assetsExist) {
14303
14724
  _chunkQMNWKQL4cjs.logger.info("\u2705 Verified client assets are present");
@@ -14339,7 +14760,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
14339
14760
  const { readFile } = await import("fs/promises");
14340
14761
  const manifestContent = await readFile(clientManifestPath, "utf-8");
14341
14762
  farmRegistry.clientManifest = JSON.parse(manifestContent);
14342
- } catch (e43) {
14763
+ } catch (e47) {
14343
14764
  farmRegistry.clientManifest = {};
14344
14765
  }
14345
14766
  } catch (error) {
@@ -14351,7 +14772,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
14351
14772
  root,
14352
14773
  preset,
14353
14774
  distDir,
14354
- outputDir: _chunkOXNZUCHNcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir)
14775
+ outputDir: _chunkP3EZKU6Lcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir)
14355
14776
  });
14356
14777
  }
14357
14778
  }