@farm.js/core 0.1.71 → 0.1.73

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 (256) hide show
  1. package/dist/{agent-mcp-handler-VIT4GOSR.mjs → agent-mcp-handler-RK7LDYEL.mjs} +5 -5
  2. package/dist/{agent-mcp-handler-KE4J3W7S.cjs → agent-mcp-handler-VBCA3WZ6.cjs} +6 -6
  3. package/dist/{agent-mcp.d-BzNw6JI8.d.ts → agent-mcp.d-D_gHjCAE.d.ts} +2 -2
  4. package/dist/{agent-mcp.d-CgFen3EH.d.mts → agent-mcp.d-PvEf-1mi.d.mts} +2 -2
  5. package/dist/agent-runtime.d.mts +4 -4
  6. package/dist/agent-runtime.d.ts +4 -4
  7. package/dist/{analyzer-VK3BAOFI.mjs → analyzer-MFYCJT75.mjs} +2 -2
  8. package/dist/analyzer-V5ZMRIIY.cjs +16 -0
  9. package/dist/api/node.d.mts +6 -6
  10. package/dist/api/node.d.ts +6 -6
  11. package/dist/api/route-manager.cjs +7 -6
  12. package/dist/api/route-manager.d.mts +8 -8
  13. package/dist/api/route-manager.d.ts +8 -8
  14. package/dist/api/route-manager.mjs +6 -5
  15. package/dist/api/runtime.d.mts +5 -5
  16. package/dist/api/runtime.d.ts +5 -5
  17. package/dist/api.cjs +8 -7
  18. package/dist/api.d.mts +9 -9
  19. package/dist/api.d.ts +9 -9
  20. package/dist/api.mjs +7 -6
  21. package/dist/{app-manifest.d-DY4JfJxi.d.ts → app-manifest.d-BpVTg43i.d.ts} +1 -1
  22. package/dist/{app-manifest.d-DpDK_B1k.d.mts → app-manifest.d-CN7cEWHX.d.mts} +1 -1
  23. package/dist/app-markdown.cjs +4 -4
  24. package/dist/app-markdown.d.mts +5 -5
  25. package/dist/app-markdown.d.ts +5 -5
  26. package/dist/app-markdown.mjs +3 -3
  27. package/dist/{app.d-D-5UNrFd.d.mts → app.d-BFWzAdTe.d.mts} +54 -6
  28. package/dist/{app.d-BeK6bb1c.d.ts → app.d-DO4PTCWm.d.ts} +54 -6
  29. package/dist/{chunk-7A3URI2F.mjs → chunk-2EVESLP3.mjs} +8 -1
  30. package/dist/{chunk-IYDJNCR7.mjs → chunk-462MUII7.mjs} +10 -5
  31. package/dist/{chunk-MWUDEYBI.mjs → chunk-4CTCSKAF.mjs} +1 -1
  32. package/dist/{chunk-SXMWVP2L.cjs → chunk-4YHGQDTT.cjs} +12 -12
  33. package/dist/{chunk-YCNHUIPR.cjs → chunk-4Z3YLMSW.cjs} +10 -10
  34. package/dist/{chunk-K66JILV3.cjs → chunk-5LOARKDP.cjs} +2 -2
  35. package/dist/{chunk-O32QPFVV.cjs → chunk-5PDMBWAF.cjs} +5 -5
  36. package/dist/{chunk-IGXS54GC.mjs → chunk-6O6PAZZR.mjs} +1 -1
  37. package/dist/{chunk-LXEJNWF5.mjs → chunk-73K53YPP.mjs} +2 -2
  38. package/dist/{chunk-2CQC5CMD.mjs → chunk-7GMBETHM.mjs} +1 -1
  39. package/dist/{chunk-W2T6NDNP.mjs → chunk-B67CW2LM.mjs} +2 -2
  40. package/dist/{chunk-CSQPMV3Q.cjs → chunk-CLEWORVY.cjs} +6 -6
  41. package/dist/{chunk-KPJYBSHL.mjs → chunk-CPMME66W.mjs} +149 -22
  42. package/dist/{chunk-BBPDJGCU.cjs → chunk-CYOTNHDF.cjs} +2 -2
  43. package/dist/{chunk-4OD2LXF2.mjs → chunk-CYRIIVD4.mjs} +26 -15
  44. package/dist/{chunk-DPIGYXSV.mjs → chunk-FRO4BB2T.mjs} +1 -1
  45. package/dist/{chunk-Y2SZVIVH.cjs → chunk-GPICBTDV.cjs} +8 -1
  46. package/dist/{chunk-N3XO5AL5.cjs → chunk-GPO3LJDJ.cjs} +2 -2
  47. package/dist/{chunk-MITIAOUQ.mjs → chunk-GZOKWJIW.mjs} +4 -4
  48. package/dist/{chunk-NAXKOTPP.cjs → chunk-HFUOLILA.cjs} +21 -21
  49. package/dist/{chunk-C2JOS77Z.cjs → chunk-HGB4PM2C.cjs} +178 -51
  50. package/dist/{chunk-2IFT2CSA.cjs → chunk-HTXKSREF.cjs} +515 -151
  51. package/dist/{chunk-Z3GPAFIA.mjs → chunk-HY6IVQ54.mjs} +1 -1
  52. package/dist/{chunk-X7LGLF33.mjs → chunk-IBVN7SW5.mjs} +480 -116
  53. package/dist/{chunk-DPYBVVL3.cjs → chunk-ILQ5DKYF.cjs} +2 -2
  54. package/dist/{chunk-V25GSH43.mjs → chunk-IXZSBO76.mjs} +1 -1
  55. package/dist/{chunk-RJUCNO7R.mjs → chunk-JMOCMXTQ.mjs} +1 -1
  56. package/dist/{chunk-UISZLYKY.cjs → chunk-KDOZORJD.cjs} +52 -41
  57. package/dist/{chunk-PLXD2MJV.cjs → chunk-KTDG4THT.cjs} +2 -2
  58. package/dist/{chunk-L6E4SHUB.cjs → chunk-LGR7565L.cjs} +6 -6
  59. package/dist/chunk-LRPPXKCX.mjs +58 -0
  60. package/dist/{chunk-GUU3IZSM.mjs → chunk-MJEKMT6B.mjs} +324 -148
  61. package/dist/chunk-NDOE76QC.cjs +58 -0
  62. package/dist/{chunk-2AM26UGI.cjs → chunk-NLBK37HI.cjs} +5 -4
  63. package/dist/{chunk-REP6HWJN.mjs → chunk-OBYM5S5G.mjs} +2 -2
  64. package/dist/{chunk-ZUVAGMQ5.cjs → chunk-ODBM54RT.cjs} +7 -7
  65. package/dist/{chunk-J5ASGNKF.mjs → chunk-OIP62QEL.mjs} +1 -1
  66. package/dist/{chunk-KEB7AGS6.cjs → chunk-OXNZUCHN.cjs} +16 -11
  67. package/dist/{chunk-2MR4MABG.cjs → chunk-PXAHSCR6.cjs} +58 -8
  68. package/dist/{chunk-7BUE2GM6.mjs → chunk-QGCSUC5O.mjs} +174 -81
  69. package/dist/{chunk-VXB5CMNC.cjs → chunk-QKEZLYON.cjs} +2 -2
  70. package/dist/{chunk-UQUOSNRN.mjs → chunk-REK6HZSU.mjs} +470 -267
  71. package/dist/{chunk-E77IA5IF.mjs → chunk-RLFGKJQ6.mjs} +1 -1
  72. package/dist/{chunk-3BQ7QHUH.cjs → chunk-ROCF6UQD.cjs} +17 -8
  73. package/dist/{chunk-KQAB5LML.mjs → chunk-SUQACHER.mjs} +2 -2
  74. package/dist/{chunk-NA77GEIU.mjs → chunk-SVQX5HYW.mjs} +53 -3
  75. package/dist/{chunk-KWST2O22.cjs → chunk-TAU3OF5B.cjs} +611 -435
  76. package/dist/{chunk-ZPUAOKHV.cjs → chunk-TDCP3Z4T.cjs} +3 -3
  77. package/dist/{chunk-3AUINHFG.mjs → chunk-TNYC3TYP.mjs} +3 -2
  78. package/dist/{chunk-TP4RAV7Y.cjs → chunk-TU6VAH4V.cjs} +8 -8
  79. package/dist/{chunk-MEJCP2LX.cjs → chunk-UVQRMUAR.cjs} +1 -1
  80. package/dist/{chunk-JMFTKNBA.mjs → chunk-UVZMSRHF.mjs} +2 -2
  81. package/dist/{chunk-MU5V7XHL.mjs → chunk-VJSXPN3W.mjs} +3 -0
  82. package/dist/{chunk-DU4VHHPJ.mjs → chunk-VO55MMBX.mjs} +1 -1
  83. package/dist/{chunk-GF22VGMS.cjs → chunk-VPETSSWN.cjs} +2 -2
  84. package/dist/{chunk-LDVJIBGN.mjs → chunk-VT25ERQK.mjs} +1 -1
  85. package/dist/{chunk-AYVGD3PK.mjs → chunk-XI3OXOMK.mjs} +1 -1
  86. package/dist/{chunk-7OHJWFLB.cjs → chunk-XUSJVHHD.cjs} +466 -373
  87. package/dist/{chunk-FILXOEWD.cjs → chunk-YXIQYWOK.cjs} +2 -2
  88. package/dist/{chunk-JVA4PIYN.cjs → chunk-YZK64PZT.cjs} +635 -432
  89. package/dist/{chunk-THG2TVDH.mjs → chunk-YZLEOMMA.mjs} +3 -3
  90. package/dist/{chunk-QUFENL7Q.mjs → chunk-Z3IN6GEX.mjs} +16 -7
  91. package/dist/{chunk-Q5HMVGR5.cjs → chunk-ZFEJ2SF2.cjs} +13 -13
  92. package/dist/{chunk-LNVGXUL3.cjs → chunk-ZMSVKVI3.cjs} +3 -0
  93. package/dist/{client-component.d-DwpH251K.d.mts → client-component.d-C71rMuHF.d.mts} +2 -2
  94. package/dist/{client-component.d-fYupugbZ.d.ts → client-component.d-sF-Znk0j.d.ts} +2 -2
  95. package/dist/{client-plugins.d-k3bOT5gz.d.mts → client-plugins.d-B-Gd9mWR.d.mts} +5 -4
  96. package/dist/{client-plugins.d-BxqFfHpM.d.ts → client-plugins.d-MFibjgBg.d.ts} +5 -4
  97. package/dist/client-plugins.d.mts +4 -4
  98. package/dist/client-plugins.d.ts +4 -4
  99. package/dist/client.cjs +1 -1
  100. package/dist/client.d.mts +9 -9
  101. package/dist/client.d.ts +9 -9
  102. package/dist/client.mjs +1 -1
  103. package/dist/config.d.mts +4 -4
  104. package/dist/config.d.ts +4 -4
  105. package/dist/desktop.d.mts +5 -5
  106. package/dist/desktop.d.ts +5 -5
  107. package/dist/{devtools-O5625KCK.cjs → devtools-6K4QXFRL.cjs} +7 -7
  108. package/dist/{devtools-6MXPFPNJ.mjs → devtools-TDIJ6HVC.mjs} +6 -6
  109. package/dist/docs.cjs +10 -10
  110. package/dist/docs.d.mts +5 -5
  111. package/dist/docs.d.ts +5 -5
  112. package/dist/docs.mjs +9 -9
  113. package/dist/environment/vite.cjs +3 -3
  114. package/dist/environment/vite.mjs +2 -2
  115. package/dist/{headers.d-sNT7ZQiU.d.mts → headers.d-BUxGJTsj.d.mts} +2 -2
  116. package/dist/{headers.d-DalIGbVO.d.ts → headers.d-uQ6BR59u.d.ts} +2 -2
  117. package/dist/i18n/client.cjs +3 -2
  118. package/dist/i18n/client.d.mts +2 -2
  119. package/dist/i18n/client.d.ts +2 -2
  120. package/dist/i18n/client.mjs +2 -1
  121. package/dist/i18n/index.cjs +3 -2
  122. package/dist/i18n/index.d.mts +3 -3
  123. package/dist/i18n/index.d.ts +3 -3
  124. package/dist/i18n/index.mjs +2 -1
  125. package/dist/i18n/server.cjs +6 -5
  126. package/dist/i18n/server.d.mts +5 -5
  127. package/dist/i18n/server.d.ts +5 -5
  128. package/dist/i18n/server.mjs +5 -4
  129. package/dist/index.cjs +32 -30
  130. package/dist/{index.d-BcA-secm.d.ts → index.d-BCGfxCXY.d.ts} +1 -1
  131. package/dist/{index.d-DDHHAv7j.d.mts → index.d-CuWOJ-un.d.mts} +1 -1
  132. package/dist/index.d.mts +24 -24
  133. package/dist/index.d.ts +24 -24
  134. package/dist/index.mjs +31 -29
  135. package/dist/integrations/orm.d.mts +4 -4
  136. package/dist/integrations/orm.d.ts +4 -4
  137. package/dist/integrations.d.mts +4 -4
  138. package/dist/integrations.d.ts +4 -4
  139. package/dist/internal/app-markdown-runtime.cjs +3 -3
  140. package/dist/internal/app-markdown-runtime.d.mts +5 -5
  141. package/dist/internal/app-markdown-runtime.d.ts +5 -5
  142. package/dist/internal/app-markdown-runtime.mjs +2 -2
  143. package/dist/internal/build-runtime.cjs +29 -29
  144. package/dist/internal/build-runtime.d.mts +6 -6
  145. package/dist/internal/build-runtime.d.ts +6 -6
  146. package/dist/internal/build-runtime.mjs +28 -28
  147. package/dist/internal/cli-runtime.cjs +12 -12
  148. package/dist/internal/cli-runtime.mjs +11 -11
  149. package/dist/internal/client-error-overlay.cjs +4 -4
  150. package/dist/internal/client-error-overlay.mjs +1 -1
  151. package/dist/internal/client-runtime.cjs +2 -2
  152. package/dist/internal/client-runtime.d.mts +7 -7
  153. package/dist/internal/client-runtime.d.ts +7 -7
  154. package/dist/internal/client-runtime.mjs +3 -3
  155. package/dist/internal/compression-runtime.d.mts +4 -4
  156. package/dist/internal/compression-runtime.d.ts +4 -4
  157. package/dist/internal/config-runtime.cjs +8 -8
  158. package/dist/internal/config-runtime.d.mts +7 -7
  159. package/dist/internal/config-runtime.d.ts +7 -7
  160. package/dist/internal/config-runtime.mjs +7 -7
  161. package/dist/internal/infra-analytics-runtime.cjs +10 -10
  162. package/dist/internal/infra-analytics-runtime.mjs +8 -8
  163. package/dist/internal/native-server-fns.cjs +4 -4
  164. package/dist/internal/native-server-fns.mjs +3 -3
  165. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  166. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  167. package/dist/internal/production-runtime.cjs +19 -19
  168. package/dist/internal/production-runtime.d.mts +37 -25
  169. package/dist/internal/production-runtime.d.ts +37 -25
  170. package/dist/internal/production-runtime.mjs +18 -18
  171. package/dist/internal/vercel-edge-middleware.d.mts +2 -2
  172. package/dist/internal/vercel-edge-middleware.d.ts +2 -2
  173. package/dist/markdown.cjs +2 -2
  174. package/dist/markdown.d.mts +4 -4
  175. package/dist/markdown.d.ts +4 -4
  176. package/dist/markdown.mjs +1 -1
  177. package/dist/middleware.cjs +3 -3
  178. package/dist/middleware.d.mts +5 -5
  179. package/dist/middleware.d.ts +5 -5
  180. package/dist/middleware.mjs +2 -2
  181. package/dist/mobile.d.mts +3 -3
  182. package/dist/mobile.d.ts +3 -3
  183. package/dist/{mount.d-C1PONsEe.d.mts → mount.d-BIYmcGGg.d.mts} +1 -1
  184. package/dist/{mount.d-D3JOux2V.d.ts → mount.d-q8k0cJV0.d.ts} +1 -1
  185. package/dist/{native-tree-L2IIEBXH.mjs → native-tree-OYGKP2NZ.mjs} +2 -2
  186. package/dist/{native-tree-GF4BH33L.cjs → native-tree-R6CQMDTI.cjs} +3 -3
  187. package/dist/{navigation-delegate.d-CQQPbdkE.d.ts → navigation-delegate.d-Btfs6Uoa.d.ts} +1 -1
  188. package/dist/{navigation-delegate.d-CJQQHboA.d.mts → navigation-delegate.d-CYBUupsv.d.mts} +1 -1
  189. package/dist/navigation.d.mts +7 -7
  190. package/dist/navigation.d.ts +7 -7
  191. package/dist/{observability.d-B2363jB6.d.mts → observability.d-DdJRiaIX.d.mts} +27 -3
  192. package/dist/{observability.d-B2363jB6.d.ts → observability.d-DdJRiaIX.d.ts} +27 -3
  193. package/dist/observability.d.mts +1 -1
  194. package/dist/observability.d.ts +1 -1
  195. package/dist/plugin.cjs +21 -21
  196. package/dist/plugin.d.mts +7 -7
  197. package/dist/plugin.d.ts +7 -7
  198. package/dist/plugin.mjs +20 -20
  199. package/dist/{production-runtime.d-B0IeWWyO.d.mts → production-runtime.d-Bcu37SCo.d.mts} +1 -1
  200. package/dist/{production-runtime.d-q3aHIv5Y.d.ts → production-runtime.d-qPj3XRET.d.ts} +1 -1
  201. package/dist/{render-plan.d-DHuJMJRP.d.ts → render-plan.d-0FHusf1D.d.ts} +1 -1
  202. package/dist/{render-plan.d-CiUj0rq5.d.mts → render-plan.d-BlyxqKMu.d.mts} +1 -1
  203. package/dist/renderer-client.cjs +3 -2
  204. package/dist/renderer-client.d.mts +7 -7
  205. package/dist/renderer-client.d.ts +7 -7
  206. package/dist/renderer-client.mjs +2 -1
  207. package/dist/{request.d-DRUbOmYD.d.ts → request.d-CPdVjssg.d.ts} +1 -1
  208. package/dist/{request.d-D-F7o7tb.d.mts → request.d-CX-gks1l.d.mts} +1 -1
  209. package/dist/request.d.mts +5 -5
  210. package/dist/request.d.ts +5 -5
  211. package/dist/{resolver.d-9iKC79CU.d.mts → resolver.d-DJgzbdsp.d.mts} +1 -1
  212. package/dist/{resolver.d-CY6mEa_F.d.ts → resolver.d-yaHcGCCG.d.ts} +1 -1
  213. package/dist/{route-rendering.d-6smgwT2t.d.mts → route-rendering.d-CcvZ_4N2.d.mts} +1 -1
  214. package/dist/{route-rendering.d-KwqM_mlK.d.ts → route-rendering.d-DcOoSNoG.d.ts} +1 -1
  215. package/dist/{router.d-BYmDeDlp.d.mts → router.d-C8RHma4A.d.mts} +1 -1
  216. package/dist/{router.d-B6sesMRD.d.ts → router.d-D2QnK8cM.d.ts} +1 -1
  217. package/dist/{routes.d-D3aJw1H5.d.mts → routes.d-CCccJRrp.d.mts} +1 -1
  218. package/dist/{routes.d-K-Qg79AA.d.ts → routes.d-b7khoRoU.d.ts} +1 -1
  219. package/dist/routes.d.mts +4 -4
  220. package/dist/routes.d.ts +4 -4
  221. package/dist/{routing.d-DwSUVZbF.d.mts → routing.d-BhPgtN_S.d.ts} +2 -1
  222. package/dist/{routing.d-BxOZ2YWc.d.ts → routing.d-D67HQmnv.d.mts} +2 -1
  223. package/dist/{rsc-pipeline-R2GOKIMU.mjs → rsc-pipeline-LC2FBZAR.mjs} +7 -7
  224. package/dist/{rsc-pipeline-P4PCWDO2.cjs → rsc-pipeline-NTAM65NT.cjs} +8 -8
  225. package/dist/{runtime-DP5DYGW5.mjs → runtime-MWAC7NWR.mjs} +7 -7
  226. package/dist/{runtime-WA2Q4SLG.cjs → runtime-U4PAMTVH.cjs} +9 -9
  227. package/dist/{runtime.d-CbdMI0Oy.d.ts → runtime.d-1l_1bLrL.d.ts} +1 -1
  228. package/dist/{runtime.d-BFSJf-ww.d.mts → runtime.d-BQUHHq8M.d.mts} +1 -1
  229. package/dist/{runtime.d-nUz0HAL4.d.mts → runtime.d-CTAXWZby.d.mts} +2 -2
  230. package/dist/{runtime.d-B_uPfMjA.d.ts → runtime.d-PUA5qBnd.d.ts} +2 -2
  231. package/dist/server-plugins.d.mts +6 -6
  232. package/dist/server-plugins.d.ts +6 -6
  233. package/dist/server.cjs +43 -41
  234. package/dist/server.d.mts +15 -15
  235. package/dist/server.d.ts +15 -15
  236. package/dist/server.mjs +26 -24
  237. package/dist/{spa-router.d-mC1D5cTN.d.ts → spa-router.d-BJtXNeqo.d.ts} +3 -3
  238. package/dist/{spa-router.d-D4EDwR20.d.mts → spa-router.d-BzPdi48R.d.mts} +3 -3
  239. package/dist/testing.cjs +6 -5
  240. package/dist/testing.d.mts +4 -4
  241. package/dist/testing.d.ts +4 -4
  242. package/dist/testing.mjs +6 -5
  243. package/dist/{types.d-wVRlLtBf.d.ts → types.d-euATAbE4.d.mts} +4 -0
  244. package/dist/{types.d-wVRlLtBf.d.mts → types.d-euATAbE4.d.ts} +4 -0
  245. package/dist/{utils.d-DxMzteqE.d.mts → utils.d-B4ZW-6z6.d.mts} +1 -1
  246. package/dist/{utils.d-A2X3a6z_.d.ts → utils.d-DquC6qxy.d.ts} +1 -1
  247. package/dist/version.cjs +2 -2
  248. package/dist/version.mjs +1 -1
  249. package/dist/vite.cjs +23 -21
  250. package/dist/vite.d.mts +18 -9
  251. package/dist/vite.d.ts +18 -9
  252. package/dist/vite.mjs +22 -20
  253. package/package.json +1 -1
  254. package/dist/analyzer-LPIVRSTJ.cjs +0 -16
  255. package/dist/chunk-V3UOEWCB.cjs +0 -46
  256. package/dist/chunk-VE3FWJBO.mjs +0 -46
@@ -26,7 +26,7 @@ import {
26
26
  import {
27
27
  collectFarmNativeServerFns,
28
28
  findFarmNativeScreenFiles
29
- } from "./chunk-2CQC5CMD.mjs";
29
+ } from "./chunk-7GMBETHM.mjs";
30
30
  import {
31
31
  generateNativeMCPPluginSource
32
32
  } from "./chunk-KQH2COEJ.mjs";
@@ -41,7 +41,7 @@ import {
41
41
  hasFarmDocsRuntimeAdapter,
42
42
  listFarmDocsAdapterPages,
43
43
  listFarmDocsPagePaths
44
- } from "./chunk-4OD2LXF2.mjs";
44
+ } from "./chunk-CYRIIVD4.mjs";
45
45
  import {
46
46
  FARM_DOCS_LAST_MODIFIED_MANIFEST,
47
47
  createFarmDocsHandler,
@@ -54,7 +54,7 @@ import {
54
54
  loadFarmDocsPage,
55
55
  resolveFarmDocsContentDir,
56
56
  toFarmDocsMarkdownPage
57
- } from "./chunk-LXEJNWF5.mjs";
57
+ } from "./chunk-73K53YPP.mjs";
58
58
  import {
59
59
  generateFarmDocsSearchClientRuntime,
60
60
  isFarmDocsSearchEnabled,
@@ -65,16 +65,16 @@ import {
65
65
  } from "./chunk-OAEDVXVE.mjs";
66
66
  import {
67
67
  FARM_PRERENDER_ENV
68
- } from "./chunk-QUFENL7Q.mjs";
68
+ } from "./chunk-Z3IN6GEX.mjs";
69
69
  import {
70
70
  loadFarmDocsEngine
71
- } from "./chunk-VE3FWJBO.mjs";
71
+ } from "./chunk-LRPPXKCX.mjs";
72
72
  import {
73
73
  getDefaultDeployOutputDir,
74
74
  getDeployTargetForPreset,
75
75
  hasCustomFarmRouteContext,
76
76
  resolveDeployOutputPath
77
- } from "./chunk-IYDJNCR7.mjs";
77
+ } from "./chunk-462MUII7.mjs";
78
78
  import {
79
79
  resolveFarmInstrumentationFile
80
80
  } from "./chunk-57QAQU4F.mjs";
@@ -110,7 +110,7 @@ import {
110
110
  resolveFarmImageServerRuntime,
111
111
  resolveFarmNotFoundComponentPath,
112
112
  resolveFarmRouteRootStrategy
113
- } from "./chunk-GUU3IZSM.mjs";
113
+ } from "./chunk-MJEKMT6B.mjs";
114
114
  import {
115
115
  generateFarmClientPluginEntryCode,
116
116
  hasFarmServerRuntimePlugins,
@@ -123,7 +123,7 @@ import {
123
123
  generateFarmTypeArtifacts,
124
124
  readRouteRenderingDirectiveFromFile,
125
125
  resolveRouteRenderingConfigFromFile
126
- } from "./chunk-W2T6NDNP.mjs";
126
+ } from "./chunk-B67CW2LM.mjs";
127
127
  import {
128
128
  HOISTED_HEAD_ELEMENT,
129
129
  appMiddlewareMayHandlePath,
@@ -136,7 +136,7 @@ import {
136
136
  layoutsCanCoverSamePage,
137
137
  routeBoundaryCoversDirectory,
138
138
  stripRouteGroups
139
- } from "./chunk-NA77GEIU.mjs";
139
+ } from "./chunk-SVQX5HYW.mjs";
140
140
  import {
141
141
  FARM_NATIVE_TREE_CONTENT_TYPE
142
142
  } from "./chunk-LLZSYFOM.mjs";
@@ -150,15 +150,15 @@ import {
150
150
  listFarmBuiltInRoutePaths,
151
151
  resolveFarmApiCatalogInput,
152
152
  resolveFarmAppManifestInput
153
- } from "./chunk-MITIAOUQ.mjs";
153
+ } from "./chunk-GZOKWJIW.mjs";
154
154
  import {
155
155
  FARM_DEFAULT_MCP_PATH,
156
156
  createFarmDefaultMCPServer,
157
157
  farmConfigMountsMCP
158
- } from "./chunk-JMFTKNBA.mjs";
158
+ } from "./chunk-UVZMSRHF.mjs";
159
159
  import {
160
160
  isFarmPreviewDeploymentEnvironment
161
- } from "./chunk-V25GSH43.mjs";
161
+ } from "./chunk-IXZSBO76.mjs";
162
162
  import {
163
163
  FARM_NATIVE_SERVER_FN_PLUGIN
164
164
  } from "./chunk-L4RTTTVE.mjs";
@@ -175,8 +175,9 @@ import {
175
175
  resolvePackageClientBoundaryCacheFile,
176
176
  usePackageClientBoundaryCacheFile,
177
177
  usesFarmServerTree,
178
+ withFarmSourceSnapshot,
178
179
  withPackageClientBoundaryCache
179
- } from "./chunk-X7LGLF33.mjs";
180
+ } from "./chunk-IBVN7SW5.mjs";
180
181
  import {
181
182
  generateFarmDocsAdapterClientRuntime,
182
183
  getFarmDocsAdapterConfigModule
@@ -223,14 +224,14 @@ import {
223
224
  } from "./chunk-N33DLJBC.mjs";
224
225
  import {
225
226
  isFarmMarkdownPageFile
226
- } from "./chunk-J5ASGNKF.mjs";
227
+ } from "./chunk-OIP62QEL.mjs";
227
228
  import {
228
229
  resolveFarmMdxComponentsModulePath,
229
230
  resolveMdxConfig
230
231
  } from "./chunk-UIJOLBUL.mjs";
231
232
  import {
232
233
  getFarmMarkdownAlternatePath
233
- } from "./chunk-KPJYBSHL.mjs";
234
+ } from "./chunk-CPMME66W.mjs";
234
235
  import {
235
236
  withPlainDiagnostics
236
237
  } from "./chunk-MGKWYPE3.mjs";
@@ -255,10 +256,10 @@ import {
255
256
  } from "./chunk-MMK4MZUN.mjs";
256
257
  import {
257
258
  APIRouteManager
258
- } from "./chunk-E77IA5IF.mjs";
259
+ } from "./chunk-RLFGKJQ6.mjs";
259
260
  import {
260
261
  readFarmI18nCatalogs
261
- } from "./chunk-DU4VHHPJ.mjs";
262
+ } from "./chunk-VO55MMBX.mjs";
262
263
  import {
263
264
  VERCEL_OG_INSTALL_HINT
264
265
  } from "./chunk-NR63PD3P.mjs";
@@ -283,14 +284,14 @@ import {
283
284
  } from "./chunk-2I6PUKWJ.mjs";
284
285
  import {
285
286
  FARM_VERSION
286
- } from "./chunk-RJUCNO7R.mjs";
287
- import {
288
- normalizeFarmTrailingSlashPathname
289
- } from "./chunk-4O26BPUY.mjs";
287
+ } from "./chunk-JMOCMXTQ.mjs";
290
288
  import {
291
289
  getFarmPresetRuntime,
292
290
  resolveCloudflareProcessEnvFlags
293
291
  } from "./chunk-IWJONXPF.mjs";
292
+ import {
293
+ normalizeFarmTrailingSlashPathname
294
+ } from "./chunk-4O26BPUY.mjs";
294
295
  import {
295
296
  _runWithFarmCspNonce
296
297
  } from "./chunk-5OFNUETM.mjs";
@@ -300,7 +301,9 @@ import {
300
301
  stripFarmBasePath
301
302
  } from "./chunk-SF3JB56B.mjs";
302
303
  import {
303
- compareRoutePatternSpecificity
304
+ compareRoutePatternSpecificity,
305
+ compareRouteSpecificity,
306
+ getRoutePatternSpecificity
304
307
  } from "./chunk-AYP2YFVN.mjs";
305
308
 
306
309
  // src/build/index.ts
@@ -1041,14 +1044,40 @@ function buildFarmVercelRoutes(options) {
1041
1044
  function escapeRegExp2(value) {
1042
1045
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1043
1046
  }
1047
+ var FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH = 4096;
1048
+ function groupFarmVercelRouteAlternatives(items, alternative) {
1049
+ const groups = [];
1050
+ let current = null;
1051
+ const frame = 6;
1052
+ for (const item of items) {
1053
+ const part = alternative(item);
1054
+ if (part.length + frame > FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH) {
1055
+ throw new Error(
1056
+ `Farm cannot route ${JSON.stringify(part.slice(0, 80))}\u2026 on Vercel: its pattern is longer than Vercel's ${FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH}-character limit for a route. Shorten the page's path.`
1057
+ );
1058
+ }
1059
+ if (current && current.length + 1 + part.length > FARM_VERCEL_ROUTE_SOURCE_MAX_LENGTH) {
1060
+ groups.push({ src: `^(?:${current.parts.join("|")})$`, items: current.items });
1061
+ current = null;
1062
+ }
1063
+ if (!current) current = { parts: [], items: [], length: frame - 1 };
1064
+ current.parts.push(part);
1065
+ current.items.push(item);
1066
+ current.length += 1 + part.length;
1067
+ }
1068
+ if (current) groups.push({ src: `^(?:${current.parts.join("|")})$`, items: current.items });
1069
+ return groups;
1070
+ }
1044
1071
  function createFarmVercelCanonicalSlashRoutes(publicPaths) {
1045
1072
  const otherSpellings = [
1046
1073
  ...new Set(
1047
1074
  publicPaths.filter((pathname) => pathname !== "/").map((pathname) => pathname.endsWith("/") ? pathname.replace(/\/+$/, "") : `${pathname}/`).filter((pathname) => pathname !== "")
1048
1075
  )
1049
1076
  ];
1050
- if (otherSpellings.length === 0) return [];
1051
- return [{ src: `^(?:${otherSpellings.map(escapeRegExp2).join("|")})$`, dest: "/__nitro" }];
1077
+ return groupFarmVercelRouteAlternatives(otherSpellings, escapeRegExp2).map((group) => ({
1078
+ src: group.src,
1079
+ dest: "/__nitro"
1080
+ }));
1052
1081
  }
1053
1082
 
1054
1083
  // src/nitro/ssr-public-assets.ts
@@ -1459,18 +1488,17 @@ function toFarmVercelEdgeGuardedUrls(pathnames, basePath) {
1459
1488
  ...new Set(pathnames.flatMap((pathname) => [pathname, applyFarmBasePath(pathname, basePath)]))
1460
1489
  ];
1461
1490
  }
1462
- function createFarmVercelEdgeMiddlewareRoute(pathnames, basePath = "/") {
1491
+ function createFarmVercelEdgeMiddlewareRoutes(pathnames, basePath = "/") {
1463
1492
  const publicPaths = toFarmVercelEdgeGuardedUrls(pathnames, basePath);
1464
- const alternatives = publicPaths.map((pathname) => {
1493
+ return groupFarmVercelRouteAlternatives(publicPaths, (pathname) => {
1465
1494
  const trimmed = pathname.replace(/\/+$/, "");
1466
1495
  return trimmed ? `${escapeRegExp3(trimmed)}(?:/|/index\\.html|\\.html)?` : "/(?:index\\.html)?";
1467
- });
1468
- return {
1469
- src: `^(?:${alternatives.join("|")})$`,
1496
+ }).map((group) => ({
1497
+ src: group.src,
1470
1498
  middlewarePath: FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION,
1471
- middlewareRawSrc: publicPaths,
1499
+ middlewareRawSrc: group.items,
1472
1500
  continue: true
1473
- };
1501
+ }));
1474
1502
  }
1475
1503
  function generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages) {
1476
1504
  const imports = routes.map(
@@ -2677,7 +2705,7 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
2677
2705
  async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false) {
2678
2706
  if (!mobile) await removeFarmMobileClientManifest(path13.dirname(outputDir));
2679
2707
  const viteBuild = productionVite.build;
2680
- const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
2708
+ const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
2681
2709
  const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
2682
2710
  const fs4 = await import("fs/promises");
2683
2711
  const pluginManager = new PluginManager2({
@@ -2717,51 +2745,6 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2717
2745
  ...planOptions,
2718
2746
  serverTreeLayouts: pagePlanOptions.serverOwners
2719
2747
  };
2720
- const clientLayouts = layoutRoutes.map((layout) => {
2721
- try {
2722
- const metadata = getCachedClientModuleHydrationPlan(
2723
- layout.modulePath,
2724
- root,
2725
- isolatedMode,
2726
- hydrationPlanCache,
2727
- layoutPlanOptions
2728
- );
2729
- return {
2730
- ...layout,
2731
- shouldHydrate: metadata.shouldHydrate,
2732
- islandStrategy: metadata.islandStrategy,
2733
- legacyShouldHydrate: metadata.legacyShouldHydrate,
2734
- legacyIslandStrategy: metadata.legacyIslandStrategy,
2735
- mode: metadata.mode,
2736
- estimatedIsolatedRootCount: metadata.estimatedIsolatedRootCount,
2737
- hasIsolatedClientBoundaries: metadata.hasIsolatedClientBoundaries,
2738
- isolatedHydrationEligible: metadata.isolatedHydrationEligible,
2739
- isolatedBoundaries: metadata.isolatedBoundaries,
2740
- asyncOwnerIslands: metadata.asyncOwnerIslands,
2741
- suppressedAsyncHydration: metadata.suppressedAsyncHydration,
2742
- fallbackReason: metadata.fallbackReason,
2743
- serverTreeLayout: metadata.serverTreeLayout
2744
- };
2745
- } catch (error) {
2746
- logger.warn(`\u26A0\uFE0F Could not inspect layout file ${layout.modulePath}: ${error}`);
2747
- return {
2748
- ...layout,
2749
- shouldHydrate: false,
2750
- islandStrategy: null,
2751
- legacyShouldHydrate: false,
2752
- legacyIslandStrategy: null,
2753
- mode: isolatedMode,
2754
- estimatedIsolatedRootCount: 0,
2755
- hasIsolatedClientBoundaries: false,
2756
- isolatedHydrationEligible: false,
2757
- isolatedBoundaries: [],
2758
- asyncOwnerIslands: void 0,
2759
- suppressedAsyncHydration: void 0,
2760
- fallbackReason: void 0,
2761
- serverTreeLayout: void 0
2762
- };
2763
- }
2764
- });
2765
2748
  const layoutAppliesToRoute = routeBoundaryCoversDirectory;
2766
2749
  const routeDirectory = (route) => route.directory ?? route.pattern;
2767
2750
  const islandsMode = resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands";
@@ -2777,159 +2760,209 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2777
2760
  );
2778
2761
  const syntheticDocsEntry = config.docs?.enabled && !adapterOwnsDocsRuntime ? adapterDocsEntry : null;
2779
2762
  const syntheticDocsPatterns = syntheticDocsEntry ? syntheticDocsEntry === "/" ? ["/", "/[...slug]"] : [syntheticDocsEntry, `${syntheticDocsEntry}/[...slug]`] : [];
2780
- const markdownPagePlan = createMarkdownPageHydrationPlanner(
2781
- resolveFarmMdxComponentsModulePath(resolveMdxConfig(config.mdx), root),
2782
- root,
2783
- isolatedMode,
2784
- { ...planOptions, packageReferences: pagePlanOptions.serverOwners }
2785
- );
2786
- const routePlans = pageRoutes.map((route) => ({
2787
- route,
2788
- metadata: isFarmMarkdownPageFile(route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
2789
- route.modulePath,
2790
- root,
2791
- isolatedMode,
2792
- hydrationPlanCache,
2793
- pagePlanOptions
2794
- )
2795
- }));
2796
- enforceFarmIsolatedHydrationRouteBudget(
2797
- clientLayouts.map((layout) => ({
2798
- pattern: layout.pattern,
2799
- depth: layout.pattern.split("/").filter(Boolean).length,
2800
- metadata: layout
2801
- })),
2802
- [
2803
- ...routePlans.map(({ route, metadata }) => ({
2804
- pattern: routeDirectory(route),
2805
- depth: getRouteDirectoryDepth(routeDirectory(route)),
2806
- metadata
2807
- })),
2808
- ...syntheticDocsPatterns.map((pattern) => ({
2809
- pattern,
2810
- depth: pattern.split("/").filter(Boolean).length,
2811
- metadata: {
2812
- mode: isolatedMode,
2763
+ const { clientLayouts, clientRouteSlots } = withFarmSourceSnapshot(() => {
2764
+ const clientLayouts2 = layoutRoutes.map((layout) => {
2765
+ try {
2766
+ const metadata = getCachedClientModuleHydrationPlan(
2767
+ layout.modulePath,
2768
+ root,
2769
+ isolatedMode,
2770
+ hydrationPlanCache,
2771
+ layoutPlanOptions
2772
+ );
2773
+ return {
2774
+ ...layout,
2775
+ shouldHydrate: metadata.shouldHydrate,
2776
+ islandStrategy: metadata.islandStrategy,
2777
+ legacyShouldHydrate: metadata.legacyShouldHydrate,
2778
+ legacyIslandStrategy: metadata.legacyIslandStrategy,
2779
+ mode: metadata.mode,
2780
+ estimatedIsolatedRootCount: metadata.estimatedIsolatedRootCount,
2781
+ hasIsolatedClientBoundaries: metadata.hasIsolatedClientBoundaries,
2782
+ isolatedHydrationEligible: metadata.isolatedHydrationEligible,
2783
+ isolatedBoundaries: metadata.isolatedBoundaries,
2784
+ asyncOwnerIslands: metadata.asyncOwnerIslands,
2785
+ suppressedAsyncHydration: metadata.suppressedAsyncHydration,
2786
+ fallbackReason: metadata.fallbackReason,
2787
+ serverTreeLayout: metadata.serverTreeLayout
2788
+ };
2789
+ } catch (error) {
2790
+ logger.warn(`\u26A0\uFE0F Could not inspect layout file ${layout.modulePath}: ${error}`);
2791
+ return {
2792
+ ...layout,
2813
2793
  shouldHydrate: false,
2814
2794
  islandStrategy: null,
2815
2795
  legacyShouldHydrate: false,
2816
2796
  legacyIslandStrategy: null,
2797
+ mode: isolatedMode,
2817
2798
  estimatedIsolatedRootCount: 0,
2818
2799
  hasIsolatedClientBoundaries: false,
2819
- isolatedBoundaries: []
2820
- }
2821
- }))
2822
- ],
2823
- layoutAppliesToRoute,
2824
- { serverOwners: islandsMode }
2825
- );
2826
- for (const layout of clientLayouts) {
2827
- const matchesBuiltRoute = pageRoutes.some((route) => layoutAppliesToRoute(layout.pattern, routeDirectory(route))) || docsEntries.some((docsEntry) => layoutAppliesToRoute(layout.pattern, docsEntry));
2828
- if (matchesBuiltRoute && layout.suppressedAsyncHydration) {
2829
- logger.warn(`\u26A0\uFE0F ${describeSuppressedAsyncHydration(layout.pattern, layout.fallbackReason)}`);
2830
- }
2831
- }
2832
- if (isolatedMode === "analyze") {
2833
- for (const { entry, metadata } of [
2834
- ...clientLayouts.map((layout) => ({ entry: layout, metadata: layout })),
2835
- ...routePlans.map(({ route, metadata: metadata2 }) => ({ entry: route, metadata: metadata2 }))
2836
- ]) {
2837
- if (!("isolatedHydrationEligible" in metadata) || !metadata.isolatedHydrationEligible) {
2838
- continue;
2800
+ isolatedHydrationEligible: false,
2801
+ isolatedBoundaries: [],
2802
+ asyncOwnerIslands: void 0,
2803
+ suppressedAsyncHydration: void 0,
2804
+ fallbackReason: void 0,
2805
+ serverTreeLayout: void 0
2806
+ };
2839
2807
  }
2840
- logger.info(
2841
- `\u{1F4CA} Isolated hydration analysis: ${entry.modulePath} can exclude its server owner and hydrate ${metadata.isolatedBoundaries.length} client ${metadata.isolatedBoundaries.length === 1 ? "boundary" : "boundaries"}.`
2842
- );
2843
- }
2844
- }
2845
- const serverSlotPlans = islandsMode ? routeSlots.flatMap((slot) => {
2846
- const plan = getCachedClientModuleHydrationPlan(
2847
- slot.modulePath,
2808
+ });
2809
+ const markdownPagePlan = createMarkdownPageHydrationPlanner(
2810
+ resolveFarmMdxComponentsModulePath(resolveMdxConfig(config.mdx), root),
2848
2811
  root,
2849
2812
  isolatedMode,
2850
- hydrationPlanCache,
2851
- { ...pagePlanOptions, serverOwners: true }
2813
+ { ...planOptions, packageReferences: pagePlanOptions.serverOwners }
2852
2814
  );
2853
- return plan.isClientComponent ? [] : [{ slot, plan }];
2854
- }) : [];
2855
- for (const { route, metadata } of routePlans) {
2856
- if (isAdapterDocsRoute(route.pattern)) continue;
2857
- try {
2858
- const applicableClientLayouts = clientLayouts.filter(
2859
- (layout) => (layout.shouldHydrate || layout.hasIsolatedClientBoundaries) && layoutAppliesToRoute(layout.pattern, routeDirectory(route))
2860
- );
2861
- if (metadata.suppressedAsyncHydration) {
2815
+ const routePlans = pageRoutes.map((route) => ({
2816
+ route,
2817
+ metadata: isFarmMarkdownPageFile(route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
2818
+ route.modulePath,
2819
+ root,
2820
+ isolatedMode,
2821
+ hydrationPlanCache,
2822
+ pagePlanOptions
2823
+ )
2824
+ }));
2825
+ enforceFarmIsolatedHydrationRouteBudget(
2826
+ clientLayouts2.map((layout) => ({
2827
+ pattern: layout.pattern,
2828
+ depth: layout.pattern.split("/").filter(Boolean).length,
2829
+ metadata: layout
2830
+ })),
2831
+ [
2832
+ ...routePlans.map(({ route, metadata }) => ({
2833
+ pattern: routeDirectory(route),
2834
+ depth: getRouteDirectoryDepth(routeDirectory(route)),
2835
+ metadata
2836
+ })),
2837
+ ...syntheticDocsPatterns.map((pattern) => ({
2838
+ pattern,
2839
+ depth: pattern.split("/").filter(Boolean).length,
2840
+ metadata: {
2841
+ mode: isolatedMode,
2842
+ shouldHydrate: false,
2843
+ islandStrategy: null,
2844
+ legacyShouldHydrate: false,
2845
+ legacyIslandStrategy: null,
2846
+ estimatedIsolatedRootCount: 0,
2847
+ hasIsolatedClientBoundaries: false,
2848
+ isolatedBoundaries: []
2849
+ }
2850
+ }))
2851
+ ],
2852
+ layoutAppliesToRoute,
2853
+ { serverOwners: islandsMode }
2854
+ );
2855
+ for (const layout of clientLayouts2) {
2856
+ const matchesBuiltRoute = pageRoutes.some((route) => layoutAppliesToRoute(layout.pattern, routeDirectory(route))) || docsEntries.some((docsEntry) => layoutAppliesToRoute(layout.pattern, docsEntry));
2857
+ if (matchesBuiltRoute && layout.suppressedAsyncHydration) {
2862
2858
  logger.warn(
2863
- `\u26A0\uFE0F ${describeSuppressedAsyncHydration(route.pattern, metadata.fallbackReason)}`
2859
+ `\u26A0\uFE0F ${describeSuppressedAsyncHydration(layout.pattern, layout.fallbackReason)}`
2864
2860
  );
2865
2861
  }
2866
- const slotBoundaries = serverSlotPlans.filter(
2867
- ({ slot }) => layoutAppliesToRoute(slot.ownerDirectory ?? slot.ownerPattern, routeDirectory(route))
2868
- ).flatMap(({ plan }) => plan.isolatedBoundaries);
2869
- if (metadata.shouldHydrate || metadata.hasIsolatedClientBoundaries || applicableClientLayouts.length > 0 || slotBoundaries.length > 0) {
2870
- const relativePath = route.modulePath.replace(root, "").replace(/^\//, "");
2871
- const islandStrategy = resolveFarmRouteRootStrategy(
2872
- route,
2873
- metadata,
2874
- clientLayouts,
2875
- root,
2876
- islandsMode
2862
+ }
2863
+ if (isolatedMode === "analyze") {
2864
+ for (const { entry, metadata } of [
2865
+ ...clientLayouts2.map((layout) => ({ entry: layout, metadata: layout })),
2866
+ ...routePlans.map(({ route, metadata: metadata2 }) => ({ entry: route, metadata: metadata2 }))
2867
+ ]) {
2868
+ if (!("isolatedHydrationEligible" in metadata) || !metadata.isolatedHydrationEligible) {
2869
+ continue;
2870
+ }
2871
+ logger.info(
2872
+ `\u{1F4CA} Isolated hydration analysis: ${entry.modulePath} can exclude its server owner and hydrate ${metadata.isolatedBoundaries.length} client ${metadata.isolatedBoundaries.length === 1 ? "boundary" : "boundaries"}.`
2877
2873
  );
2878
- clientPages.push({
2879
- ...route,
2880
- relativePath,
2881
- pageShouldHydrate: metadata.shouldHydrate,
2882
- islandStrategy,
2883
- hasIsolatedClientBoundaries: metadata.hasIsolatedClientBoundaries || applicableClientLayouts.some((layout) => layout.hasIsolatedClientBoundaries) || slotBoundaries.length > 0,
2884
- isolatedBoundaries: [
2885
- ...metadata.hasIsolatedClientBoundaries ? metadata.isolatedBoundaries : [],
2886
- ...slotBoundaries,
2887
- ...applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries || layout.serverTreeLayout).flatMap((layout) => layout.isolatedBoundaries)
2888
- ],
2889
- // The server renders a server tree only below a hydrating layout.
2890
- ...usesFarmServerTree(metadata) && applicableClientLayouts.some((layout) => layout.shouldHydrate) ? { serverTree: true } : {}
2891
- });
2892
- logger.info(`\u{1F4F1} Found hydratable route: ${route.pattern} -> ${route.modulePath}`);
2893
2874
  }
2894
- } catch (error) {
2895
- logger.warn(`\u26A0\uFE0F Could not inspect route file ${route.modulePath}: ${error}`);
2896
2875
  }
2897
- }
2898
- if (syntheticDocsEntry) {
2899
- const docsEntry = syntheticDocsEntry;
2900
- const applicableClientLayouts = clientLayouts.filter(
2901
- (layout) => (layout.shouldHydrate || layout.hasIsolatedClientBoundaries) && layoutAppliesToRoute(layout.pattern, docsEntry)
2902
- );
2903
- if (applicableClientLayouts.length > 0) {
2904
- const hydrationStrategies = applicableClientLayouts.flatMap(
2905
- (layout) => layout.islandStrategy ? [layout.islandStrategy] : []
2876
+ const serverSlotPlans = islandsMode ? routeSlots.flatMap((slot) => {
2877
+ const plan = getCachedClientModuleHydrationPlan(
2878
+ slot.modulePath,
2879
+ root,
2880
+ isolatedMode,
2881
+ hydrationPlanCache,
2882
+ { ...pagePlanOptions, serverOwners: true }
2906
2883
  );
2907
- const islandStrategy = hydrationStrategies.every(
2908
- (strategy) => strategy === hydrationStrategies[0]
2909
- ) ? hydrationStrategies[0] ?? "load" : "load";
2910
- const docsClientRoutes = syntheticDocsPatterns.map((pattern) => ({
2911
- pattern,
2912
- docs: true,
2913
- modulePath: "",
2914
- relativePath: "",
2915
- pageShouldHydrate: false,
2916
- islandStrategy,
2917
- hasIsolatedClientBoundaries: applicableClientLayouts.some(
2918
- (layout) => layout.hasIsolatedClientBoundaries
2919
- ),
2920
- isolatedBoundaries: applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries || layout.serverTreeLayout).flatMap((layout) => layout.isolatedBoundaries)
2921
- }));
2922
- clientPages.unshift(...docsClientRoutes);
2884
+ return plan.isClientComponent ? [] : [{ slot, plan }];
2885
+ }) : [];
2886
+ for (const { route, metadata } of routePlans) {
2887
+ if (isAdapterDocsRoute(route.pattern)) continue;
2888
+ try {
2889
+ const applicableClientLayouts = clientLayouts2.filter(
2890
+ (layout) => (layout.shouldHydrate || layout.hasIsolatedClientBoundaries) && layoutAppliesToRoute(layout.pattern, routeDirectory(route))
2891
+ );
2892
+ if (metadata.suppressedAsyncHydration) {
2893
+ logger.warn(
2894
+ `\u26A0\uFE0F ${describeSuppressedAsyncHydration(route.pattern, metadata.fallbackReason)}`
2895
+ );
2896
+ }
2897
+ const slotBoundaries = serverSlotPlans.filter(
2898
+ ({ slot }) => layoutAppliesToRoute(slot.ownerDirectory ?? slot.ownerPattern, routeDirectory(route))
2899
+ ).flatMap(({ plan }) => plan.isolatedBoundaries);
2900
+ if (metadata.shouldHydrate || metadata.hasIsolatedClientBoundaries || applicableClientLayouts.length > 0 || slotBoundaries.length > 0) {
2901
+ const relativePath = route.modulePath.replace(root, "").replace(/^\//, "");
2902
+ const islandStrategy = resolveFarmRouteRootStrategy(
2903
+ route,
2904
+ metadata,
2905
+ clientLayouts2,
2906
+ root,
2907
+ islandsMode
2908
+ );
2909
+ clientPages.push({
2910
+ ...route,
2911
+ relativePath,
2912
+ pageShouldHydrate: metadata.shouldHydrate,
2913
+ islandStrategy,
2914
+ hasIsolatedClientBoundaries: metadata.hasIsolatedClientBoundaries || applicableClientLayouts.some((layout) => layout.hasIsolatedClientBoundaries) || slotBoundaries.length > 0,
2915
+ isolatedBoundaries: [
2916
+ ...metadata.hasIsolatedClientBoundaries ? metadata.isolatedBoundaries : [],
2917
+ ...slotBoundaries,
2918
+ ...applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries || layout.serverTreeLayout).flatMap((layout) => layout.isolatedBoundaries)
2919
+ ],
2920
+ // The server renders a server tree only below a hydrating layout.
2921
+ ...usesFarmServerTree(metadata) && applicableClientLayouts.some((layout) => layout.shouldHydrate) ? { serverTree: true } : {}
2922
+ });
2923
+ logger.info(`\u{1F4F1} Found hydratable route: ${route.pattern} -> ${route.modulePath}`);
2924
+ }
2925
+ } catch (error) {
2926
+ logger.warn(`\u26A0\uFE0F Could not inspect route file ${route.modulePath}: ${error}`);
2927
+ }
2923
2928
  }
2924
- }
2925
- const clientRouteSlots = routeSlots.filter((slot) => {
2926
- try {
2927
- const metadata = getClientModuleMetadata(slot.modulePath, root);
2928
- return metadata.shouldHydrate && (!islandsMode || metadata.isClientComponent);
2929
- } catch (error) {
2930
- logger.warn(`\u26A0\uFE0F Could not inspect route slot ${slot.modulePath}: ${error}`);
2931
- return false;
2929
+ if (syntheticDocsEntry) {
2930
+ const docsEntry = syntheticDocsEntry;
2931
+ const applicableClientLayouts = clientLayouts2.filter(
2932
+ (layout) => (layout.shouldHydrate || layout.hasIsolatedClientBoundaries) && layoutAppliesToRoute(layout.pattern, docsEntry)
2933
+ );
2934
+ if (applicableClientLayouts.length > 0) {
2935
+ const hydrationStrategies = applicableClientLayouts.flatMap(
2936
+ (layout) => layout.islandStrategy ? [layout.islandStrategy] : []
2937
+ );
2938
+ const islandStrategy = hydrationStrategies.every(
2939
+ (strategy) => strategy === hydrationStrategies[0]
2940
+ ) ? hydrationStrategies[0] ?? "load" : "load";
2941
+ const docsClientRoutes = syntheticDocsPatterns.map((pattern) => ({
2942
+ pattern,
2943
+ docs: true,
2944
+ modulePath: "",
2945
+ relativePath: "",
2946
+ pageShouldHydrate: false,
2947
+ islandStrategy,
2948
+ hasIsolatedClientBoundaries: applicableClientLayouts.some(
2949
+ (layout) => layout.hasIsolatedClientBoundaries
2950
+ ),
2951
+ isolatedBoundaries: applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries || layout.serverTreeLayout).flatMap((layout) => layout.isolatedBoundaries)
2952
+ }));
2953
+ clientPages.unshift(...docsClientRoutes);
2954
+ }
2932
2955
  }
2956
+ const clientRouteSlots2 = routeSlots.filter((slot) => {
2957
+ try {
2958
+ const metadata = getClientModuleMetadata(slot.modulePath, root);
2959
+ return metadata.shouldHydrate && (!islandsMode || metadata.isClientComponent);
2960
+ } catch (error) {
2961
+ logger.warn(`\u26A0\uFE0F Could not inspect route slot ${slot.modulePath}: ${error}`);
2962
+ return false;
2963
+ }
2964
+ });
2965
+ return { clientLayouts: clientLayouts2, clientRouteSlots: clientRouteSlots2 };
2933
2966
  });
2934
2967
  logger.info(
2935
2968
  `\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
@@ -3145,6 +3178,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3145
3178
  }
3146
3179
  }
3147
3180
  },
3181
+ farmIslandContainersPlugin(config),
3148
3182
  farmPlugin(
3149
3183
  { ...config, isolatedClientBoundaryModules, programmaticClientRoutes },
3150
3184
  pluginManager
@@ -4426,7 +4460,8 @@ ${generateUniversalRouterStateProperties()}
4426
4460
  this.currentHistoryState = options.popState;
4427
4461
  }
4428
4462
 
4429
- this.saveScrollPosition(window.location.pathname + window.location.search);
4463
+ // Save under the page still on screen: on Back/Forward the URL already names the destination.
4464
+ this.saveScrollPosition(from);
4430
4465
  const navigation = this.startNavigation(from, url, action);
4431
4466
  let clientNavigation;
4432
4467
  try {
@@ -5636,7 +5671,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
5636
5671
  // A route transition invalidates any trigger waiting on the previous DOM boundary.
5637
5672
  cancelPendingPageHydration();
5638
5673
  this.stopNavigationStream();
5639
- this.saveScrollPosition(window.location.pathname + window.location.search);
5674
+ // Save under the page still on screen: on Back/Forward the URL already names the destination.
5675
+ this.saveScrollPosition(from);
5640
5676
  const navigation = this.startNavigation(from, url, action);
5641
5677
  // A refresh keeps the islands still on the page (islands mode).
5642
5678
  navigation.refresh = options.refresh === true;
@@ -6082,7 +6118,7 @@ void hydrate();
6082
6118
  }
6083
6119
  async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
6084
6120
  const viteBuild = productionVite.build;
6085
- const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
6121
+ const { farmIslandContainersPlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
6086
6122
  const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
6087
6123
  const fs4 = await import("fs/promises");
6088
6124
  const pluginManager = new PluginManager2({
@@ -6203,13 +6239,12 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6203
6239
  specRoute: config.openapi.specRoute || null
6204
6240
  };
6205
6241
  }
6206
- const discoveredMiddlewareRoutes = await discoverMiddlewareRoutes(appDirs);
6207
- const middlewareRoutes = farmTargetRunsEdgeMiddleware(preset) ? await Promise.all(
6208
- discoveredMiddlewareRoutes.map(async (route) => ({
6242
+ const middlewareRoutes = await Promise.all(
6243
+ (await discoverMiddlewareRoutes(appDirs)).map(async (route) => ({
6209
6244
  ...route,
6210
6245
  config: await readMiddlewareFileConfig(route.filePath)
6211
6246
  }))
6212
- ) : discoveredMiddlewareRoutes;
6247
+ );
6213
6248
  const instrumentationPath = resolveFarmInstrumentationFile(root, config.srcDir || "src");
6214
6249
  const notFoundPath = resolveFarmNotFoundComponentPath(config, appDirs);
6215
6250
  if (notFoundPath) logger.info(`\u{1F4CB} Found custom 404 page: ${notFoundPath}`);
@@ -6445,6 +6480,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6445
6480
  ] : [],
6446
6481
  { ...createReactProductionModePlugin(), enforce: "pre" },
6447
6482
  farmServerOnlyEntriesPlugin(),
6483
+ farmIslandContainersPlugin(config),
6448
6484
  farmPlugin({ ...config, isolatedClientBoundaryModules }, pluginManager),
6449
6485
  farmEnvironmentFunctionsPlugin(config),
6450
6486
  ...hasRuntimeConfigModule ? [
@@ -7062,34 +7098,37 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7062
7098
  ...hydrationPlanOptions,
7063
7099
  serverOwners: resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands"
7064
7100
  };
7065
- const layoutHydrationPlans = layoutRoutes.map((layout) => ({
7066
- ...layout,
7067
- hydration: getCachedClientModuleHydrationPlan(
7068
- layout.modulePath,
7069
- config.root,
7070
- isolatedHydrationMode,
7071
- hydrationPlanCache,
7072
- { ...hydrationPlanOptions, serverTreeLayouts: pageHydrationPlanOptions.serverOwners }
7073
- )
7074
- }));
7075
- const markdownPagePlan = createMarkdownPageHydrationPlanner(
7076
- resolveFarmMdxComponentsModulePath(resolveMdxConfig(config.mdx), config.root),
7077
- config.root,
7078
- isolatedHydrationMode,
7079
- { ...hydrationPlanOptions, packageReferences: pageHydrationPlanOptions.serverOwners }
7080
- );
7081
- const pageHydrationPlans = new Map(
7082
- pageRoutes.map((route) => [
7083
- route.modulePath,
7084
- isFarmMarkdownPageFile(route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
7085
- route.modulePath,
7101
+ const { layoutHydrationPlans, pageHydrationPlans } = withFarmSourceSnapshot(() => {
7102
+ const layoutHydrationPlans2 = layoutRoutes.map((layout) => ({
7103
+ ...layout,
7104
+ hydration: getCachedClientModuleHydrationPlan(
7105
+ layout.modulePath,
7086
7106
  config.root,
7087
7107
  isolatedHydrationMode,
7088
7108
  hydrationPlanCache,
7089
- pageHydrationPlanOptions
7109
+ { ...hydrationPlanOptions, serverTreeLayouts: pageHydrationPlanOptions.serverOwners }
7090
7110
  )
7091
- ])
7092
- );
7111
+ }));
7112
+ const markdownPagePlan = createMarkdownPageHydrationPlanner(
7113
+ resolveFarmMdxComponentsModulePath(resolveMdxConfig(config.mdx), config.root),
7114
+ config.root,
7115
+ isolatedHydrationMode,
7116
+ { ...hydrationPlanOptions, packageReferences: pageHydrationPlanOptions.serverOwners }
7117
+ );
7118
+ const pageHydrationPlans2 = new Map(
7119
+ pageRoutes.map((route) => [
7120
+ route.modulePath,
7121
+ isFarmMarkdownPageFile(route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
7122
+ route.modulePath,
7123
+ config.root,
7124
+ isolatedHydrationMode,
7125
+ hydrationPlanCache,
7126
+ pageHydrationPlanOptions
7127
+ )
7128
+ ])
7129
+ );
7130
+ return { layoutHydrationPlans: layoutHydrationPlans2, pageHydrationPlans: pageHydrationPlans2 };
7131
+ });
7093
7132
  enforceFarmIsolatedHydrationRouteBudget(
7094
7133
  layoutHydrationPlans.map((layout) => ({
7095
7134
  pattern: layout.pattern,
@@ -7135,11 +7174,12 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7135
7174
  const varName = `pageRoute${index}`;
7136
7175
  if (isFarmMarkdownPageFile(route.modulePath)) {
7137
7176
  const renderingDirective2 = readRouteRenderingDirectiveFromFile(route.modulePath);
7177
+ const markdownServerTree = pageHydrationPlanOptions.serverOwners && usesFarmServerTree(pageHydrationPlans.get(route.modulePath));
7138
7178
  pageRegistrations.push(`
7139
7179
  {
7140
7180
  pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
7141
7181
  directory: ${JSON.stringify(route.directory)},` : ""}${renderingDirective2 ? `
7142
- rendering: ${JSON.stringify(renderingDirective2)},` : ""}
7182
+ rendering: ${JSON.stringify(renderingDirective2)},` : ""}${markdownServerTree ? "\n serverTree: true," : ""}
7143
7183
  module: createFarmMarkdownRouteModule({
7144
7184
  source: ${JSON.stringify(route.source ?? "")},
7145
7185
  filePath: ${JSON.stringify(toBakedMarkdownSourcePath(config.root, route.modulePath))},
@@ -8590,12 +8630,98 @@ async function renderFarmElement(ReactDOMServer, element, routeKey, flushToken =
8590
8630
  return { html, head: "", shellHtml: html, streamErrors };
8591
8631
  }
8592
8632
 
8593
- async function renderFarmElementToString(ReactDOMServer, element) {
8594
- const rendered = await renderFarmElement(ReactDOMServer, element);
8595
- if (rendered.html !== undefined) return rendered.html;
8596
- const html = await new Response(rendered.stream).text();
8597
- if (rendered.streamErrors.length > 0) throw rendered.streamErrors[0];
8598
- return html;
8633
+ // The not-found and error documents go out whole, with their status, so they never stream.
8634
+ // renderToString renders a tree that does not suspend in one synchronous pass, but throws "A
8635
+ // component suspended while responding to synchronous input" when a lazy component or a use()
8636
+ // read suspends outside a Suspense boundary, and leaves a boundary that suspends inside one to
8637
+ // the client (<!--$!-->). Such a document renders with the streaming renderer instead, which
8638
+ // sends nothing until every boundary is done, so the output is the resolved markup without
8639
+ // fallbacks or reveal scripts. A document that suspended once keeps that renderer for the rest
8640
+ // of this server process, as a page route that suspends keeps streaming. As for pages, a
8641
+ // response with a CSP nonce or a posted form state renders with the stream, which takes them.
8642
+ // Renderers other than React wait for their own async content in renderToString.
8643
+ const farmSuspendingDocuments = new Set();
8644
+
8645
+ async function renderFarmCompleteDocument(ReactDOMServer, element, documentKey) {
8646
+ if (!farmReactSyncRender || !canRenderFarmElementWhenAllReady(ReactDOMServer)) {
8647
+ return await ReactDOMServer.renderToString(element, getFarmRendererRenderOptions());
8648
+ }
8649
+ if (!farmSuspendingDocuments.has(documentKey) &&
8650
+ !_resolveCurrentCspNonce() &&
8651
+ farmFormState() === undefined) {
8652
+ let html;
8653
+ try {
8654
+ html = ReactDOMServer.renderToString(element, getFarmRendererRenderOptions());
8655
+ } catch {
8656
+ // A real render error fails the streaming render the same way.
8657
+ }
8658
+ if (typeof html === "string" && !html.includes("<!--$!-->")) return html;
8659
+ farmSuspendingDocuments.add(documentKey);
8660
+ }
8661
+ return await renderFarmElementWhenAllReady(ReactDOMServer, element);
8662
+ }
8663
+
8664
+ function canRenderFarmElementWhenAllReady(ReactDOMServer) {
8665
+ return (farmRendererStreamingCapabilities.web &&
8666
+ typeof ReactDOMServer.renderToReadableStream === "function") ||
8667
+ (farmRendererStreamingCapabilities.node &&
8668
+ typeof ReactDOMServer.renderToPipeableStream === "function");
8669
+ }
8670
+
8671
+ async function renderFarmElementWhenAllReady(ReactDOMServer, element) {
8672
+ const onError = function(error) {
8673
+ // After the shell, a failed boundary is rendered by the client, as on a page.
8674
+ if (isFarmRedirectError(error) || isFarmNotFoundError(error)) return;
8675
+ console.error("[Farm SSR stream]", error);
8676
+ };
8677
+ // Completed boundaries larger than this would stream behind their fallback: keep them inline.
8678
+ const progressiveChunkSize = Number.MAX_SAFE_INTEGER;
8679
+ if (farmRendererStreamingCapabilities.web &&
8680
+ typeof ReactDOMServer.renderToReadableStream === "function") {
8681
+ const stream = await ReactDOMServer.renderToReadableStream(element, {
8682
+ nonce: _resolveCurrentCspNonce(),
8683
+ formState: farmFormState(),
8684
+ progressiveChunkSize,
8685
+ onError,
8686
+ });
8687
+ await stream.allReady;
8688
+ return await new Response(stream).text();
8689
+ }
8690
+ return await new Promise(function(resolve, reject) {
8691
+ const chunks = [];
8692
+ const decoder = new TextDecoder();
8693
+ const destination = {
8694
+ write(chunk) {
8695
+ chunks.push(typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true }));
8696
+ return true;
8697
+ },
8698
+ flush() {},
8699
+ end() {
8700
+ chunks.push(decoder.decode());
8701
+ resolve(chunks.join(""));
8702
+ },
8703
+ on() {
8704
+ return destination;
8705
+ },
8706
+ destroy(error) {
8707
+ reject(error || new Error("React server render stream was destroyed"));
8708
+ },
8709
+ };
8710
+ const pipeableStream = ReactDOMServer.renderToPipeableStream(element, {
8711
+ nonce: _resolveCurrentCspNonce(),
8712
+ formState: farmFormState(),
8713
+ progressiveChunkSize,
8714
+ onAllReady() {
8715
+ try {
8716
+ pipeableStream.pipe(destination);
8717
+ } catch (error) {
8718
+ reject(error);
8719
+ }
8720
+ },
8721
+ onShellError: reject,
8722
+ onError,
8723
+ });
8724
+ });
8599
8725
  }
8600
8726
 
8601
8727
  // Most pages render without suspending. React's renderToString renders them in
@@ -8777,6 +8903,50 @@ function opensFarmFullDocument(markup) {
8777
8903
  return /^<!doctype/i.test(inner) || /^<html[\\s>]/i.test(inner);
8778
8904
  }
8779
8905
 
8906
+ // The head elements a component renders (<meta>, <title>, preloads), which React writes ahead of
8907
+ // a render whose root is not <html>, split off for the document's head. A full document keeps
8908
+ // them: its own head takes them. Matches the dev renderer's takeFarmHoistedHead.
8909
+ function takeFarmHoistedHead(markup) {
8910
+ if (opensFarmFullDocument(markup)) return { head: "", body: markup };
8911
+ const hoistable = /${HOISTED_HEAD_ELEMENT.source}/i;
8912
+ let head = "";
8913
+ let body = markup;
8914
+ let match;
8915
+ while ((match = hoistable.exec(body.replace(/^\\s+/, "")))) {
8916
+ head += match[0];
8917
+ body = body.replace(/^\\s+/, "").slice(match[0].length);
8918
+ }
8919
+ return { head: head, body: body };
8920
+ }
8921
+
8922
+ // A rendered page with the head elements React wrote first moved to its head field, for Farm's shell to
8923
+ // put in the document's head. A streamed page's first chunk is its shellHtml: those bytes are
8924
+ // dropped from the stream.
8925
+ function takeFarmRenderedHead(rendered) {
8926
+ if (rendered.head) return rendered;
8927
+ if (rendered.html !== undefined) {
8928
+ const split = takeFarmHoistedHead(rendered.html);
8929
+ if (!split.head) return rendered;
8930
+ return Object.assign({}, rendered, { html: split.body, shellHtml: split.body, head: split.head });
8931
+ }
8932
+ const shell = rendered.shellHtml || "";
8933
+ const split = takeFarmHoistedHead(shell);
8934
+ if (!split.head) return rendered;
8935
+ let left = new TextEncoder().encode(shell.slice(0, shell.length - split.body.length)).byteLength;
8936
+ const stream = rendered.stream.pipeThrough(new TransformStream({
8937
+ transform(chunk, controller) {
8938
+ if (left > 0) {
8939
+ const dropped = Math.min(left, chunk.byteLength);
8940
+ left -= dropped;
8941
+ chunk = chunk.subarray(dropped);
8942
+ if (chunk.byteLength === 0) return;
8943
+ }
8944
+ controller.enqueue(chunk);
8945
+ },
8946
+ }));
8947
+ return Object.assign({}, rendered, { stream: stream, shellHtml: split.body, head: split.head });
8948
+ }
8949
+
8780
8950
  function extractFarmFullDocument(markup) {
8781
8951
  if (!opensFarmFullDocument(markup)) return null;
8782
8952
  const hoisted = peelFarmDocumentPrefix(markup).hoisted;
@@ -11152,9 +11322,10 @@ ${hasServerRuntimeIntegrations ? `
11152
11322
  wrappedElement = wrapWithFarmIntegrationProviders(wrappedElement);
11153
11323
  return renderFarmElement(ReactDOMServer, wrappedElement, route.pattern, farmFlushToken);
11154
11324
  };
11155
- const renderedPage = ${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
11325
+ // The head elements a component rendered go to the document's head (takeFarmRenderedHead).
11326
+ const renderedPage = takeFarmRenderedHead(${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
11156
11327
  _runWithMiddlewareContext(middlewareContext, renderPageElement)
11157
- )` : "await renderPageElement()"};
11328
+ )` : "await renderPageElement()"});
11158
11329
 
11159
11330
  // A completed document is not a reusable PPR shell: it already contains
11160
11331
  // the request's resolved Suspense content. Until the production runtime
@@ -11394,7 +11565,8 @@ ${hasServerRuntimeIntegrations ? `
11394
11565
  ' <meta charset="utf-8">\\n' +
11395
11566
  ' ' + viewportTags + '\\n' +
11396
11567
  (hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
11397
- ' <title>' + title + '</title>' + metaTags + '\\n' +
11568
+ (suppressDefaultTitle ? '' : ' <title>' + title + '</title>') + metaTags +
11569
+ (rendererHead ? '\\n ' + rendererHead : '') + '\\n' +
11398
11570
  ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
11399
11571
  ' <link rel="modulepreload" href="/__farm_client_js_src__">' + renderFarmClientModulePreloads(null, route.clientModule) + '\\n' +
11400
11572
  renderFarmRendererHydrationScript() + '\\n' +
@@ -11421,9 +11593,10 @@ ${hasServerRuntimeIntegrations ? `
11421
11593
  }
11422
11594
  try {
11423
11595
  return createLateNotFoundRecovery(
11424
- await ReactDOMServer.renderToString(
11596
+ await renderFarmCompleteDocument(
11597
+ ReactDOMServer,
11425
11598
  wrapWithFarmIntegrationProviders(createFarmNotFoundElement(pathname)),
11426
- getFarmRendererRenderOptions()
11599
+ "not-found-recovery"
11427
11600
  )
11428
11601
  );
11429
11602
  } catch (error) {
@@ -11581,7 +11754,9 @@ ${hasServerRuntimeIntegrations ? `
11581
11754
  pprCacheKey,
11582
11755
  { html: fullHtml },
11583
11756
  {
11584
- paths: [pathname],
11757
+ // revalidatePath() takes the route path ("/pricing"), as the docs show, while the
11758
+ // shell answers the public one ("/console/fr/pricing"): either clears it.
11759
+ paths: [...new Set([pathname, getFarmRoutePathname(pathname)])],
11585
11760
  tags: ["ppr"],
11586
11761
  revalidate: pprConfig.revalidate ?? false,
11587
11762
  }
@@ -11712,7 +11887,12 @@ ${servesDefaultMCP ? `
11712
11887
  errorElement = wrapWithFarmIntegrationProviders(errorElement);
11713
11888
 
11714
11889
  const renderErrorElement = () =>
11715
- renderFarmElementToString(ReactDOMServer, errorElement);
11890
+ renderFarmCompleteDocument(
11891
+ ReactDOMServer,
11892
+ // Islands mode: the error document writes its islands' values, as a page does.
11893
+ typeof farmIslandsRender === "function" ? farmIslandsRender(errorElement) : errorElement,
11894
+ "error:" + errorBoundaryMatch.route.pattern
11895
+ );
11716
11896
  const errorHtml = ${hasMiddlewareRuntime ? `await _runWithMiddlewareData(middlewareData, () =>
11717
11897
  _runWithMiddlewareContext(middlewareContext, renderErrorElement)
11718
11898
  )` : "await renderErrorElement()"};
@@ -11853,7 +12033,7 @@ ${farmRendererDisabled ? `
11853
12033
  }
11854
12034
  notFoundElement = wrapWithFarmIntegrationProviders(notFoundElement);
11855
12035
 
11856
- const html = await ReactDOMServer.renderToString(notFoundElement, getFarmRendererRenderOptions());
12036
+ const html = await renderFarmCompleteDocument(ReactDOMServer, notFoundElement, "not-found");
11857
12037
  // The layouts' and the not-found page's metadata, as the development renderer uses it.
11858
12038
  const notFoundMetadata = renderMetadataHead(
11859
12039
  await resolveFarmNotFoundMetadata(
@@ -12187,17 +12367,22 @@ function escapeRoutePattern(value) {
12187
12367
  return value.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
12188
12368
  }
12189
12369
  function middlewarePatternMatches(pattern, pathname) {
12370
+ return createMiddlewarePatternMatcher(pattern)(pathname);
12371
+ }
12372
+ function createMiddlewarePatternMatcher(pattern) {
12190
12373
  if (pattern instanceof RegExp) {
12191
- pattern.lastIndex = 0;
12192
- return pattern.test(pathname);
12374
+ return (pathname) => {
12375
+ pattern.lastIndex = 0;
12376
+ return pattern.test(pathname);
12377
+ };
12193
12378
  }
12194
- if (pattern === "*" || pattern === "/(.*)") return true;
12379
+ if (pattern === "*" || pattern === "/(.*)") return () => true;
12195
12380
  if (pattern.endsWith("(.*)")) {
12196
12381
  const prefix = pattern.slice(0, -4);
12197
- return pathname === prefix || pathname.startsWith(`${prefix}/`);
12382
+ return (pathname) => pathname === prefix || pathname.startsWith(`${prefix}/`);
12198
12383
  }
12199
12384
  const segments = pattern.split("/").filter(Boolean);
12200
- if (segments.length === 0) return pathname === "/";
12385
+ if (segments.length === 0) return (pathname) => pathname === "/";
12201
12386
  const expression = segments.map((segment) => {
12202
12387
  if (segment === "**") return "(?:/.*)?";
12203
12388
  if (segment === "*") return "/[^/]+";
@@ -12209,7 +12394,8 @@ function middlewarePatternMatches(pattern, pathname) {
12209
12394
  if (segment.startsWith(":") || /^\[.+\]$/.test(segment)) return "/[^/]+";
12210
12395
  return `/${escapeRoutePattern(segment).replace(/\\\*/g, "[^/]*")}`;
12211
12396
  }).join("");
12212
- return new RegExp(`^${expression}/?$`).test(pathname);
12397
+ const regex = new RegExp(`^${expression}/?$`);
12398
+ return (pathname) => regex.test(pathname);
12213
12399
  }
12214
12400
  function routePatternSpecificity(pattern) {
12215
12401
  return pattern.split("/").filter(Boolean).reduce((score, segment) => {
@@ -12224,8 +12410,18 @@ function routePatternSpecificity(pattern) {
12224
12410
  function getEffectiveRouteRule(config, pathname) {
12225
12411
  return Object.entries(config.routeRules).filter(([pattern]) => middlewarePatternMatches(pattern, pathname)).sort(([left], [right]) => routePatternSpecificity(left) - routePatternSpecificity(right)).reduce((resolved, [, rule]) => Object.assign(resolved, rule), {});
12226
12412
  }
12413
+ var manifestPageMatchers = /* @__PURE__ */ new WeakMap();
12227
12414
  function getManifestPageEntry(manifest, pathname) {
12228
- return manifest.routes.filter((entry) => entry.kind === "page" && middlewarePatternMatches(entry.pattern, pathname)).sort((left, right) => compareRoutePatternSpecificity(left.pattern, right.pattern))[0];
12415
+ let pages = manifestPageMatchers.get(manifest.routes);
12416
+ if (!pages) {
12417
+ pages = manifest.routes.filter((entry) => entry.kind === "page").map((entry) => ({
12418
+ entry,
12419
+ matches: createMiddlewarePatternMatcher(entry.pattern),
12420
+ specificity: getRoutePatternSpecificity(entry.pattern)
12421
+ })).sort((left, right) => compareRouteSpecificity(left.specificity, right.specificity)).map(({ entry, matches }) => ({ entry, matches }));
12422
+ manifestPageMatchers.set(manifest.routes, pages);
12423
+ }
12424
+ return pages.find((page) => page.matches(pathname))?.entry;
12229
12425
  }
12230
12426
  function withFarmEdgeGuardedPrerenderHeaders(headers, edgeGuarded) {
12231
12427
  if (!edgeGuarded) return headers;
@@ -13360,7 +13556,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
13360
13556
  vercelConfig.routes = buildFarmVercelRoutes({
13361
13557
  presetRoutes: Array.isArray(vercelConfig.routes) ? vercelConfig.routes : [],
13362
13558
  runtimeRoutes,
13363
- middlewareRoutes: edgeMiddlewareRoutes.length > 0 ? [createFarmVercelEdgeMiddlewareRoute(edgeMiddleware.guardedPages, config.basePath)] : [],
13559
+ middlewareRoutes: edgeMiddlewareRoutes.length > 0 ? createFarmVercelEdgeMiddlewareRoutes(edgeMiddleware.guardedPages, config.basePath) : [],
13364
13560
  canonicalSlashRoutes: createFarmVercelCanonicalSlashRoutes(prerenderedPages)
13365
13561
  });
13366
13562
  const vercelConfigWithWorkflowCrons = applyFarmWorkflowVercelCrons(
@@ -13992,7 +14188,12 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
13992
14188
  });
13993
14189
  }
13994
14190
  async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
13995
- const { farmI18nClientBridgePlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
14191
+ const {
14192
+ farmI18nClientBridgePlugin,
14193
+ farmIslandContainersPlugin,
14194
+ farmPlugin,
14195
+ farmServerOnlyEntriesPlugin
14196
+ } = await import("./vite.mjs");
13996
14197
  const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
13997
14198
  const pluginManager = new PluginManager2({
13998
14199
  config,
@@ -14012,6 +14213,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
14012
14213
  plugins: [
14013
14214
  farmI18nClientBridgePlugin(),
14014
14215
  farmServerOnlyEntriesPlugin(),
14216
+ farmIslandContainersPlugin(config),
14015
14217
  farmPlugin(config, pluginManager),
14016
14218
  farmEnvironmentFunctionsPlugin(config)
14017
14219
  ],
@@ -14019,7 +14221,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
14019
14221
  });
14020
14222
  }
14021
14223
  async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
14022
- const { farmI18nClientBridgePlugin, farmPlugin } = await import("./vite.mjs");
14224
+ const { farmI18nClientBridgePlugin, farmIslandContainersPlugin, farmPlugin } = await import("./vite.mjs");
14023
14225
  const { PluginManager: PluginManager2 } = await import("./plugin-QZT747YW.mjs");
14024
14226
  const pluginManager = new PluginManager2({
14025
14227
  config,
@@ -14045,6 +14247,7 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
14045
14247
  },
14046
14248
  plugins: [
14047
14249
  farmI18nClientBridgePlugin(),
14250
+ farmIslandContainersPlugin(config),
14048
14251
  farmPlugin(config, pluginManager),
14049
14252
  farmEnvironmentFunctionsPlugin(config)
14050
14253
  ],