@farm.js/core 0.2.0-beta.1 → 0.2.0-beta.2

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 (244) hide show
  1. package/dist/{agent-mcp-handler-IUL6OPC3.cjs → agent-mcp-handler-EXOG55M4.cjs} +5 -5
  2. package/dist/{agent-mcp-handler-GDY5CPPW.mjs → agent-mcp-handler-VX4NDDHR.mjs} +4 -4
  3. package/dist/{agent-mcp.d-BdM0pIrD.d.ts → agent-mcp.d-DBaonhLg.d.ts} +1 -1
  4. package/dist/{agent-mcp.d-CMGqpUbk.d.mts → agent-mcp.d-DhCEzIfu.d.mts} +1 -1
  5. package/dist/agent-runtime.cjs +2 -2
  6. package/dist/agent-runtime.d.mts +1 -1
  7. package/dist/agent-runtime.d.ts +1 -1
  8. package/dist/agent-runtime.mjs +1 -1
  9. package/dist/analyzer-OWIHFO5M.cjs +17 -0
  10. package/dist/{analyzer-RYSF2BM3.mjs → analyzer-T2U345WL.mjs} +2 -2
  11. package/dist/api/node.d.mts +3 -3
  12. package/dist/api/node.d.ts +3 -3
  13. package/dist/api/route-manager.d.mts +3 -3
  14. package/dist/api/route-manager.d.ts +3 -3
  15. package/dist/api/runtime.d.mts +2 -2
  16. package/dist/api/runtime.d.ts +2 -2
  17. package/dist/api.d.mts +4 -4
  18. package/dist/api.d.ts +4 -4
  19. package/dist/{app-manifest.d-COhjPgHn.d.ts → app-manifest.d-nLVFFd7N.d.ts} +1 -1
  20. package/dist/{app-manifest.d-BeDB2OVm.d.mts → app-manifest.d-uE0JGZKN.d.mts} +1 -1
  21. package/dist/app-markdown.cjs +6 -4
  22. package/dist/app-markdown.d.mts +3 -3
  23. package/dist/app-markdown.d.ts +3 -3
  24. package/dist/app-markdown.mjs +7 -5
  25. package/dist/{app.d-CoY-zsJt.d.ts → app.d-CwVkAUEU.d.ts} +13 -7
  26. package/dist/{app.d-DE5KNbmf.d.mts → app.d-DGGcNXV7.d.mts} +13 -7
  27. package/dist/{chunk-AG27TI6Q.mjs → chunk-23NBOP43.mjs} +3 -0
  28. package/dist/{chunk-OOOUYA6L.mjs → chunk-26ZTI2ZO.mjs} +4 -4
  29. package/dist/{chunk-CPMK7EFR.mjs → chunk-4Q263EQI.mjs} +2 -2
  30. package/dist/{chunk-2NOHVIJ3.cjs → chunk-5LJF4KUZ.cjs} +17 -4
  31. package/dist/{chunk-5AL2GXAU.mjs → chunk-7MMDEIVC.mjs} +1 -1
  32. package/dist/{chunk-QBXS4TNG.mjs → chunk-BL54BTVJ.mjs} +1 -1
  33. package/dist/{chunk-VZWAXQME.mjs → chunk-BW563VZZ.mjs} +34 -2
  34. package/dist/{chunk-ZPQY7O64.cjs → chunk-CBB7I6HW.cjs} +3 -3
  35. package/dist/{chunk-KMGHXIDA.cjs → chunk-CHOOBTDD.cjs} +2 -2
  36. package/dist/{chunk-ISSFWEPY.mjs → chunk-COK4IXOO.mjs} +35 -18
  37. package/dist/{chunk-YU2MNIIY.mjs → chunk-CRF5MOLO.mjs} +17 -4
  38. package/dist/{chunk-NQ3Y6E2T.mjs → chunk-CV4MOEMO.mjs} +2 -2
  39. package/dist/{chunk-OLKYHTLN.cjs → chunk-DA432P2F.cjs} +5 -5
  40. package/dist/{chunk-B3HQTGXS.cjs → chunk-DVAZ53X6.cjs} +6 -1
  41. package/dist/{chunk-XRSNW4IU.mjs → chunk-E72GG355.mjs} +5 -0
  42. package/dist/{chunk-FJGA3XWL.cjs → chunk-EA5HVG45.cjs} +2 -2
  43. package/dist/{chunk-NG2EZ6QS.cjs → chunk-EODGIFI7.cjs} +4 -2
  44. package/dist/{chunk-Y3DO7BIJ.cjs → chunk-EUZFBHPP.cjs} +3 -0
  45. package/dist/{chunk-KRU3XPOW.cjs → chunk-EXPVSFAG.cjs} +14 -11
  46. package/dist/{chunk-EACD6ND7.cjs → chunk-EZUTDTFM.cjs} +7 -7
  47. package/dist/{chunk-KCJBIWBM.mjs → chunk-GVORDLLV.mjs} +1 -1
  48. package/dist/{chunk-XGL42MQ7.mjs → chunk-HIDZM23B.mjs} +1 -1
  49. package/dist/{chunk-23BZ7ZH6.mjs → chunk-HNB5JHBO.mjs} +5 -2
  50. package/dist/{chunk-DZC2XGK4.mjs → chunk-HVGINJTO.mjs} +81 -28
  51. package/dist/{chunk-EBKYRP2P.mjs → chunk-I5KPOXUE.mjs} +1 -1
  52. package/dist/{chunk-HR5GU4UU.cjs → chunk-ILQSRLKK.cjs} +4 -4
  53. package/dist/{chunk-L4B7PB3H.cjs → chunk-J2EKGR6E.cjs} +1025 -480
  54. package/dist/{chunk-26WP75W5.cjs → chunk-JDT733EW.cjs} +41 -27
  55. package/dist/{chunk-W53Z4WDI.cjs → chunk-JH4CDG4G.cjs} +8 -8
  56. package/dist/{chunk-KQ6TYQU7.cjs → chunk-KDQKTX3Q.cjs} +4 -4
  57. package/dist/{chunk-PEQJ4UUT.mjs → chunk-LP6DIYGA.mjs} +2 -2
  58. package/dist/{chunk-Z7ZRBCAB.mjs → chunk-LQ3FISSD.mjs} +58 -37
  59. package/dist/{chunk-KBIM7PFQ.cjs → chunk-M4YXD6MD.cjs} +272 -219
  60. package/dist/{chunk-6ETHVRFO.cjs → chunk-MWAWMFG3.cjs} +407 -386
  61. package/dist/{chunk-ECVSRE4Y.mjs → chunk-N2BRIN7I.mjs} +1 -1
  62. package/dist/{chunk-MO4UTDQ6.mjs → chunk-NNNMFSXG.mjs} +1 -1
  63. package/dist/{chunk-V3Y3R3JJ.cjs → chunk-NOSLIDSG.cjs} +1 -1
  64. package/dist/{chunk-ICOJ2BC6.mjs → chunk-NWF2FTFV.mjs} +24 -10
  65. package/dist/{chunk-M3JYBZO2.cjs → chunk-OLIWLN4I.cjs} +2 -2
  66. package/dist/{chunk-YPAOC3FO.mjs → chunk-P2TGLGRR.mjs} +4 -4
  67. package/dist/{chunk-THGSPDFD.cjs → chunk-PAKB6JHX.cjs} +7 -7
  68. package/dist/{chunk-NVXU5BEG.mjs → chunk-Q637AXGZ.mjs} +172 -47
  69. package/dist/{chunk-ZZGQD3LL.mjs → chunk-QO24II6C.mjs} +4 -2
  70. package/dist/{chunk-HENPVGZC.cjs → chunk-RBSGFS5X.cjs} +66 -34
  71. package/dist/{chunk-IJPRCQHW.cjs → chunk-RGMUS3HO.cjs} +10 -10
  72. package/dist/{chunk-OIPPISQ6.cjs → chunk-RTAWQXME.cjs} +273 -148
  73. package/dist/{chunk-DMSXZNQR.cjs → chunk-RZI6436F.cjs} +2 -2
  74. package/dist/{chunk-HZY63K5C.mjs → chunk-S6MGFULY.mjs} +2 -2
  75. package/dist/{chunk-5GFTMTX3.cjs → chunk-SAUGKNCF.cjs} +2 -2
  76. package/dist/{chunk-6BMAGVDI.cjs → chunk-SCE7VWPN.cjs} +12 -12
  77. package/dist/{chunk-PKV3JGMS.mjs → chunk-SSFAPTRD.mjs} +1 -1
  78. package/dist/{chunk-ND65INFS.cjs → chunk-SWPLGPYF.cjs} +7 -7
  79. package/dist/{chunk-WP77JDKI.cjs → chunk-UCJCU2IL.cjs} +14 -14
  80. package/dist/{chunk-WX752VMN.mjs → chunk-UCRNNDNS.mjs} +1 -1
  81. package/dist/{chunk-27ESPHQA.cjs → chunk-UGWKNZ4U.cjs} +44 -27
  82. package/dist/{chunk-FLKG2PYH.cjs → chunk-UOMSGJHK.cjs} +11 -11
  83. package/dist/{chunk-2U2GRXP5.mjs → chunk-UWDFH3ZV.mjs} +1 -1
  84. package/dist/{chunk-AMMFRXFW.mjs → chunk-V5FEFFHV.mjs} +1 -1
  85. package/dist/{chunk-HR4N2K4V.mjs → chunk-WABOJXAA.mjs} +2 -2
  86. package/dist/{chunk-LTXKRIST.mjs → chunk-WANLI3ZC.mjs} +2 -2
  87. package/dist/{chunk-HQEYZSF3.cjs → chunk-WPURVYXT.cjs} +2 -2
  88. package/dist/{chunk-TE7AX6HB.mjs → chunk-WV63R4GE.mjs} +1 -1
  89. package/dist/{chunk-CIQCJ72N.mjs → chunk-XOLYZZDX.mjs} +693 -148
  90. package/dist/{chunk-4ZVKDHS6.cjs → chunk-YSRZSKQB.cjs} +4 -4
  91. package/dist/{cli-runtime.d-jqZ7YCsm.d.ts → cli-runtime.d-Dbl-gIoz.d.ts} +5 -5
  92. package/dist/{cli-runtime.d-qL44rqYO.d.mts → cli-runtime.d-oUiNuspW.d.mts} +5 -5
  93. package/dist/{client-component.d-BDD5aiUb.d.ts → client-component.d-CT4q7tmy.d.ts} +1 -1
  94. package/dist/{client-component.d-B2L2LyAr.d.mts → client-component.d-DaUqOhZT.d.mts} +1 -1
  95. package/dist/{client-plugins.d-Crct3m_r.d.ts → client-plugins.d-24qhjX8c.d.ts} +30 -4
  96. package/dist/{client-plugins.d-Dzc3vOw_.d.mts → client-plugins.d-BfGTqbAH.d.mts} +30 -4
  97. package/dist/client-plugins.d.mts +1 -1
  98. package/dist/client-plugins.d.ts +1 -1
  99. package/dist/client.cjs +4 -4
  100. package/dist/client.d.mts +7 -7
  101. package/dist/client.d.ts +7 -7
  102. package/dist/client.mjs +3 -3
  103. package/dist/config.d.mts +1 -1
  104. package/dist/config.d.ts +1 -1
  105. package/dist/desktop.d.mts +2 -2
  106. package/dist/desktop.d.ts +2 -2
  107. package/dist/{devtools-JTJA2KIZ.cjs → devtools-5WDQQDTA.cjs} +6 -6
  108. package/dist/{devtools-5DBTT2DI.mjs → devtools-DPYIYHTI.mjs} +5 -5
  109. package/dist/docs.cjs +8 -8
  110. package/dist/docs.d.mts +3 -3
  111. package/dist/docs.d.ts +3 -3
  112. package/dist/docs.mjs +7 -7
  113. package/dist/environment/vite.cjs +3 -3
  114. package/dist/environment/vite.mjs +2 -2
  115. package/dist/{handler.d-B1S1ZBqS.d.mts → handler.d-GfNuz57p.d.mts} +1 -1
  116. package/dist/{handler.d-ZweCBJD4.d.ts → handler.d-Oca5kNSz.d.ts} +1 -1
  117. package/dist/{headers.d-C-yGl_f6.d.mts → headers.d-C_lsQIWA.d.mts} +1 -1
  118. package/dist/{headers.d-BgBdQN8x.d.ts → headers.d-b8gHJDvu.d.ts} +1 -1
  119. package/dist/index.cjs +33 -29
  120. package/dist/{index.d-13h3oDu7.d.mts → index.d-BLtjh1aS.d.mts} +1 -1
  121. package/dist/{index.d-CtoniAXT.d.ts → index.d-Ckv6kHFm.d.ts} +1 -1
  122. package/dist/index.d.mts +23 -23
  123. package/dist/index.d.ts +23 -23
  124. package/dist/index.mjs +34 -30
  125. package/dist/integrations/orm.d.mts +1 -1
  126. package/dist/integrations/orm.d.ts +1 -1
  127. package/dist/integrations.cjs +4 -2
  128. package/dist/integrations.d.mts +1 -1
  129. package/dist/integrations.d.ts +1 -1
  130. package/dist/integrations.mjs +3 -1
  131. package/dist/internal/app-markdown-runtime.cjs +5 -3
  132. package/dist/internal/app-markdown-runtime.d.mts +10 -5
  133. package/dist/internal/app-markdown-runtime.d.ts +10 -5
  134. package/dist/internal/app-markdown-runtime.mjs +6 -4
  135. package/dist/internal/build-runtime.cjs +26 -26
  136. package/dist/internal/build-runtime.d.mts +4 -4
  137. package/dist/internal/build-runtime.d.ts +4 -4
  138. package/dist/internal/build-runtime.mjs +25 -25
  139. package/dist/internal/cli-runtime.cjs +10 -10
  140. package/dist/internal/cli-runtime.d.mts +7 -7
  141. package/dist/internal/cli-runtime.d.ts +7 -7
  142. package/dist/internal/cli-runtime.mjs +9 -9
  143. package/dist/internal/client-error-overlay.cjs +4 -4
  144. package/dist/internal/client-error-overlay.mjs +1 -1
  145. package/dist/internal/client-runtime.d.mts +5 -5
  146. package/dist/internal/client-runtime.d.ts +5 -5
  147. package/dist/internal/compression-runtime.d.mts +1 -1
  148. package/dist/internal/compression-runtime.d.ts +1 -1
  149. package/dist/internal/config-runtime.cjs +7 -7
  150. package/dist/internal/config-runtime.d.mts +3 -3
  151. package/dist/internal/config-runtime.d.ts +3 -3
  152. package/dist/internal/config-runtime.mjs +6 -6
  153. package/dist/internal/infra-analytics-runtime.cjs +9 -9
  154. package/dist/internal/infra-analytics-runtime.mjs +7 -7
  155. package/dist/internal/metadata-image-runtime.d.mts +2 -2
  156. package/dist/internal/metadata-image-runtime.d.ts +2 -2
  157. package/dist/internal/native-server-fns.cjs +4 -4
  158. package/dist/internal/native-server-fns.mjs +3 -3
  159. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  160. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  161. package/dist/internal/production-node-env.cjs +2 -2
  162. package/dist/internal/production-node-env.mjs +1 -1
  163. package/dist/internal/production-runtime.cjs +12 -12
  164. package/dist/internal/production-runtime.d.mts +10 -10
  165. package/dist/internal/production-runtime.d.ts +10 -10
  166. package/dist/internal/production-runtime.mjs +11 -11
  167. package/dist/internal/spa-router.cjs +3 -3
  168. package/dist/internal/spa-router.d.mts +3 -3
  169. package/dist/internal/spa-router.d.ts +3 -3
  170. package/dist/internal/spa-router.mjs +2 -2
  171. package/dist/internal/start-manifest.d.mts +1 -1
  172. package/dist/internal/start-manifest.d.ts +1 -1
  173. package/dist/markdown.cjs +2 -2
  174. package/dist/markdown.d.mts +1 -1
  175. package/dist/markdown.d.ts +1 -1
  176. package/dist/markdown.mjs +1 -1
  177. package/dist/middleware.d.mts +1 -1
  178. package/dist/middleware.d.ts +1 -1
  179. package/dist/{mount.d-_6Un9wdK.d.mts → mount.d-BCS8mD4E.d.mts} +1 -1
  180. package/dist/{mount.d-DyKlRR6z.d.ts → mount.d-DEX8eref.d.ts} +1 -1
  181. package/dist/{native-tree-5TENEQ7Y.cjs → native-tree-52CUAP3N.cjs} +3 -3
  182. package/dist/{native-tree-LNO7K6JR.mjs → native-tree-AO7PQ7FR.mjs} +2 -2
  183. package/dist/{navigation-delegate.d-BbW1_pf_.d.ts → navigation-delegate.d-Cgi28e5Q.d.ts} +1 -1
  184. package/dist/{navigation-delegate.d-B9GjWbov.d.mts → navigation-delegate.d-F83ugsZW.d.mts} +1 -1
  185. package/dist/navigation.cjs +5 -5
  186. package/dist/navigation.d.mts +4 -4
  187. package/dist/navigation.d.ts +4 -4
  188. package/dist/navigation.mjs +4 -4
  189. package/dist/plugin.cjs +19 -19
  190. package/dist/plugin.d.mts +5 -5
  191. package/dist/plugin.d.ts +5 -5
  192. package/dist/plugin.mjs +18 -18
  193. package/dist/query/client.cjs +7 -7
  194. package/dist/query/client.mjs +2 -2
  195. package/dist/{render-plan.d-DaM1NPnm.d.mts → render-plan.d-BkVY4aFb.d.mts} +1 -1
  196. package/dist/{render-plan.d-D0FV9lDT.d.ts → render-plan.d-DCF2GZdD.d.ts} +1 -1
  197. package/dist/renderer-client.cjs +5 -5
  198. package/dist/renderer-client.d.mts +5 -5
  199. package/dist/renderer-client.d.ts +5 -5
  200. package/dist/renderer-client.mjs +2 -2
  201. package/dist/renderer.d.mts +22 -11
  202. package/dist/renderer.d.ts +22 -11
  203. package/dist/{request.d-CrXC7voZ.d.ts → request.d-C5o-4dU2.d.ts} +1 -1
  204. package/dist/{request.d-DVSLilGx.d.mts → request.d-DMPB53-i.d.mts} +1 -1
  205. package/dist/request.d.mts +2 -2
  206. package/dist/request.d.ts +2 -2
  207. package/dist/{route-rendering.d-CWi3UYtR.d.mts → route-rendering.d-DDvArvik.d.mts} +1 -1
  208. package/dist/{route-rendering.d-OfbM_rj8.d.ts → route-rendering.d-DfP6zRP7.d.ts} +1 -1
  209. package/dist/{router.d-YKVirmj4.d.mts → router.d-1Skf2XCO.d.mts} +1 -1
  210. package/dist/{router.d-Bm9FNSu3.d.ts → router.d-s40h7aoS.d.ts} +1 -1
  211. package/dist/routes.d.mts +3 -3
  212. package/dist/routes.d.ts +3 -3
  213. package/dist/{rsc-pipeline-W5DSWDHD.mjs → rsc-pipeline-O2YMVHUF.mjs} +7 -7
  214. package/dist/{rsc-pipeline-LGXJGGMW.cjs → rsc-pipeline-SFQSMVI7.cjs} +8 -8
  215. package/dist/{runtime-UOZKSM5S.mjs → runtime-K2X3IZAF.mjs} +6 -6
  216. package/dist/{runtime-YV4X5FAK.cjs → runtime-WOTVFYQY.cjs} +8 -8
  217. package/dist/{runtime.d-BVj6apd0.d.mts → runtime.d-Bykc5Qfg.d.mts} +1 -1
  218. package/dist/{runtime.d-D7QYVJGO.d.ts → runtime.d-k-9kFUsM.d.ts} +1 -1
  219. package/dist/{server-components-status.d-BDVcxi0z.d.mts → server-components-status.d-D-HixBe0.d.mts} +1 -1
  220. package/dist/{server-components-status.d-CfKDpmCH.d.ts → server-components-status.d-DLNd1C5j.d.ts} +1 -1
  221. package/dist/server-plugins.d.mts +3 -3
  222. package/dist/server-plugins.d.ts +3 -3
  223. package/dist/server.cjs +41 -41
  224. package/dist/server.d.mts +11 -11
  225. package/dist/server.d.ts +11 -11
  226. package/dist/server.mjs +20 -20
  227. package/dist/{spa-router.d-DGmropfK.d.mts → spa-router.d-DIlXwm00.d.mts} +2 -2
  228. package/dist/{spa-router.d-nE1jHNGt.d.ts → spa-router.d-Dl-EJeJT.d.ts} +2 -2
  229. package/dist/{ssg.d-DS-gXUbf.d.mts → ssg.d-D2ZV0bhs.d.mts} +2 -2
  230. package/dist/{ssg.d-jXlUAKzg.d.ts → ssg.d-bE-ylg0e.d.ts} +2 -2
  231. package/dist/{store-core.d-B5cwOd8g.d.ts → store-core.d-BmdnMopD.d.ts} +2 -2
  232. package/dist/{store-core.d-C-gATBwd.d.mts → store-core.d-DPsCYzV7.d.mts} +2 -2
  233. package/dist/testing.d.mts +1 -1
  234. package/dist/testing.d.ts +1 -1
  235. package/dist/{utils.d-BODwBtkz.d.ts → utils.d-BFZQcBZV.d.ts} +1 -1
  236. package/dist/{utils.d-Cmj-fzds.d.mts → utils.d-nM3OHKq5.d.mts} +1 -1
  237. package/dist/version.cjs +2 -2
  238. package/dist/version.mjs +1 -1
  239. package/dist/vite.cjs +19 -19
  240. package/dist/vite.d.mts +6 -6
  241. package/dist/vite.d.ts +6 -6
  242. package/dist/vite.mjs +18 -18
  243. package/package.json +1 -1
  244. package/dist/analyzer-IIWSUXSQ.cjs +0 -17
@@ -22,7 +22,7 @@ import {
22
22
  createFarmNodeServerEntry,
23
23
  createReactProductionModePlugin,
24
24
  withProductionNodeEnv
25
- } from "./chunk-ZZGQD3LL.mjs";
25
+ } from "./chunk-QO24II6C.mjs";
26
26
  import {
27
27
  generateNativeMCPPluginSource
28
28
  } from "./chunk-KQH2COEJ.mjs";
@@ -32,15 +32,16 @@ import {
32
32
  import {
33
33
  collectFarmNativeServerFns,
34
34
  findFarmNativeScreenFiles
35
- } from "./chunk-2U2GRXP5.mjs";
35
+ } from "./chunk-UWDFH3ZV.mjs";
36
36
  import {
37
37
  assertFarmDocsAdapterServesNoGuardedPages,
38
38
  compileFarmDocsAdapterEdgeManifest,
39
39
  createFarmDocsAPIHandler,
40
40
  farmDocsAdapterServesGuardedPages,
41
41
  listFarmDocsAdapterPages,
42
+ listFarmDocsAdapterRoutes,
42
43
  listFarmDocsPagePaths
43
- } from "./chunk-VZWAXQME.mjs";
44
+ } from "./chunk-BW563VZZ.mjs";
44
45
  import {
45
46
  FARM_DOCS_LAST_MODIFIED_MANIFEST,
46
47
  createFarmDocsHandler,
@@ -53,7 +54,7 @@ import {
53
54
  loadFarmDocsPage,
54
55
  resolveFarmDocsContentDir,
55
56
  toFarmDocsMarkdownPage
56
- } from "./chunk-KCJBIWBM.mjs";
57
+ } from "./chunk-GVORDLLV.mjs";
57
58
  import {
58
59
  generateFarmDocsSearchClientRuntime,
59
60
  isFarmDocsSearchEnabled,
@@ -70,7 +71,7 @@ import {
70
71
  getDeployTargetForPreset,
71
72
  hasCustomFarmRouteContext,
72
73
  resolveDeployOutputPath
73
- } from "./chunk-OOOUYA6L.mjs";
74
+ } from "./chunk-26ZTI2ZO.mjs";
74
75
  import {
75
76
  resolveFarmInstrumentationFile
76
77
  } from "./chunk-QRNYSISP.mjs";
@@ -116,14 +117,14 @@ import {
116
117
  resolveFarmNotFoundComponentPath,
117
118
  resolveFarmRouteRootStrategy,
118
119
  toBakedMarkdownSourcePath
119
- } from "./chunk-DZC2XGK4.mjs";
120
+ } from "./chunk-HVGINJTO.mjs";
120
121
  import {
121
122
  TAILWIND_CSS_BROWSER_TARGET,
122
123
  generateFarmClientPluginEntryCode,
123
124
  hasFarmServerRuntimePlugins,
124
125
  includesTailwindVitePlugin,
125
126
  loadTailwindVitePlugin
126
- } from "./chunk-MO4UTDQ6.mjs";
127
+ } from "./chunk-NNNMFSXG.mjs";
127
128
  import {
128
129
  PluginManager
129
130
  } from "./chunk-IVP5Q4BX.mjs";
@@ -132,11 +133,11 @@ import {
132
133
  readRouteRenderingDirectiveFromFile,
133
134
  resolveRouteRenderingConfig,
134
135
  resolveRouteRenderingConfigFromFile
135
- } from "./chunk-23BZ7ZH6.mjs";
136
+ } from "./chunk-HNB5JHBO.mjs";
136
137
  import {
137
138
  FARM_PRERENDER_ENV,
138
139
  _farmWebMCPReportsEnabled
139
- } from "./chunk-ISSFWEPY.mjs";
140
+ } from "./chunk-COK4IXOO.mjs";
140
141
  import {
141
142
  HOISTED_HEAD_ELEMENT,
142
143
  appMiddlewareMayHandlePath,
@@ -149,12 +150,13 @@ import {
149
150
  layoutsCanCoverSamePage,
150
151
  routeBoundaryCoversDirectory,
151
152
  stripRouteGroups
152
- } from "./chunk-PEQJ4UUT.mjs";
153
+ } from "./chunk-LP6DIYGA.mjs";
153
154
  import {
154
155
  FARM_NATIVE_TREE_CONTENT_TYPE
155
156
  } from "./chunk-LLZSYFOM.mjs";
156
157
  import {
157
- farmPluginMayAffectRuntimePath
158
+ farmPluginMayAffectRuntimePath,
159
+ normalizeFarmPluginRuntimeEndpointPath
158
160
  } from "./chunk-UUMKLGUU.mjs";
159
161
  import {
160
162
  FARM_API_CATALOG_PATH,
@@ -163,15 +165,15 @@ import {
163
165
  listFarmBuiltInRoutePaths,
164
166
  resolveFarmApiCatalogInput,
165
167
  resolveFarmAppManifestInput
166
- } from "./chunk-YPAOC3FO.mjs";
168
+ } from "./chunk-P2TGLGRR.mjs";
167
169
  import {
168
170
  FARM_DEFAULT_MCP_PATH,
169
171
  createFarmDefaultMCPServer,
170
172
  farmConfigMountsMCP
171
- } from "./chunk-HR4N2K4V.mjs";
173
+ } from "./chunk-WABOJXAA.mjs";
172
174
  import {
173
175
  isFarmPreviewDeploymentEnvironment
174
- } from "./chunk-PKV3JGMS.mjs";
176
+ } from "./chunk-SSFAPTRD.mjs";
175
177
  import {
176
178
  FARM_NATIVE_SERVER_FN_PLUGIN
177
179
  } from "./chunk-L4RTTTVE.mjs";
@@ -192,7 +194,7 @@ import {
192
194
  withFarmSourceSnapshot,
193
195
  withFarmSourceSnapshotOf,
194
196
  withPackageClientBoundaryCache
195
- } from "./chunk-NVXU5BEG.mjs";
197
+ } from "./chunk-Q637AXGZ.mjs";
196
198
  import {
197
199
  generateFarmDocsAdapterClientRuntime,
198
200
  getFarmDocsAdapterConfigModule
@@ -249,14 +251,14 @@ import {
249
251
  isFarmMarkdownPageFile,
250
252
  parseMarkdownFrontmatter,
251
253
  readFarmMarkdownRouteConfig
252
- } from "./chunk-ICOJ2BC6.mjs";
254
+ } from "./chunk-NWF2FTFV.mjs";
253
255
  import {
254
256
  resolveFarmMdxComponentsModulePath,
255
257
  resolveMdxConfig
256
258
  } from "./chunk-UIJOLBUL.mjs";
257
259
  import {
258
260
  getFarmMarkdownAlternatePath
259
- } from "./chunk-YU2MNIIY.mjs";
261
+ } from "./chunk-CRF5MOLO.mjs";
260
262
  import {
261
263
  withPlainDiagnostics
262
264
  } from "./chunk-AYDVUCXD.mjs";
@@ -266,10 +268,12 @@ import {
266
268
  } from "./chunk-LTOT5KVJ.mjs";
267
269
  import {
268
270
  getFarmIntegrationPluginServerRuntime,
269
- getIntegrationProviders
270
- } from "./chunk-XRSNW4IU.mjs";
271
+ getIntegrationProviders,
272
+ providerSupportsIslands
273
+ } from "./chunk-E72GG355.mjs";
271
274
  import {
272
- FARM_INTEGRATION_API_BASE_PATH_KEY
275
+ FARM_INTEGRATION_API_BASE_PATH_KEY,
276
+ isFarmIntegration
273
277
  } from "./chunk-CZOXZ6WQ.mjs";
274
278
  import {
275
279
  _collectFarmStorageModules
@@ -283,7 +287,8 @@ import {
283
287
  APIRouteManager
284
288
  } from "./chunk-SPKZCFPH.mjs";
285
289
  import {
286
- hasPolyroutePlugin
290
+ hasPolyroutePlugin,
291
+ isPolyrouteRouteFileName
287
292
  } from "./chunk-GTHBWZUK.mjs";
288
293
  import {
289
294
  readFarmI18nCatalogs
@@ -312,10 +317,10 @@ import {
312
317
  } from "./chunk-2I6PUKWJ.mjs";
313
318
  import {
314
319
  FARM_VERSION
315
- } from "./chunk-EBKYRP2P.mjs";
320
+ } from "./chunk-I5KPOXUE.mjs";
316
321
  import {
317
322
  FARM_VIDEO_PLAYER_PATH
318
- } from "./chunk-AG27TI6Q.mjs";
323
+ } from "./chunk-23NBOP43.mjs";
319
324
  import {
320
325
  getFarmPresetRuntime,
321
326
  resolveCloudflareProcessEnvFlags
@@ -468,7 +473,8 @@ function parseRange(header, size) {
468
473
  }
469
474
  `;
470
475
  function createNitroStaticRangePlugin(nitroPackageEntry, canonicalPages = []) {
471
- const redirects = canonicalPages.filter((url) => url !== "/" && !url.startsWith("//")).map((url) => [url.endsWith("/") ? url.slice(0, -1) : url + "/", url]);
476
+ const pages = [...new Set(canonicalPages.filter((url) => !url.startsWith("//")))];
477
+ const redirects = pages.filter((url) => url !== "/").map((url) => [url.endsWith("/") ? url.slice(0, -1) : url + "/", url]);
472
478
  const original = "?farm-static-handler";
473
479
  const handlerFile = path.join(path.dirname(nitroPackageEntry), "internal", "static.mjs");
474
480
  const handlerIds = /* @__PURE__ */ new Set([toPosix(handlerFile)]);
@@ -487,13 +493,19 @@ function createNitroStaticRangePlugin(nitroPackageEntry, canonicalPages = []) {
487
493
  handler(id) {
488
494
  const file = id.split("?", 1)[0];
489
495
  if (!handlerIds.has(toPosix(file))) return null;
490
- if (redirects.length && !id.endsWith(original)) {
496
+ if (pages.length && !id.endsWith(original)) {
491
497
  return `import serve from ${JSON.stringify(toPosix(file) + original)};
492
498
  const redirects = new Map(${JSON.stringify(redirects)});
499
+ const pages = new Set(${JSON.stringify(pages)});
500
+ const MARKDOWN_ACCEPT = /text\\/(?:markdown|plain)/i;
493
501
  export default function(event) {
494
502
  const url = new URL(event.req.url);
495
503
  const target = redirects.get(url.pathname);
496
504
  if (target !== undefined) return new Response(null, { status: 308, headers: { Location: target + url.search } });
505
+ if (pages.has(url.pathname)) {
506
+ if (MARKDOWN_ACCEPT.test(event.req.headers.get("accept") || "")) return;
507
+ event.res.headers.append("Vary", "Accept");
508
+ }
497
509
  return serve(event);
498
510
  }`;
499
511
  }
@@ -775,6 +787,7 @@ import fs from "fs/promises";
775
787
  import path4 from "path";
776
788
  var FARM_CLIENT_MODULE_PRELOADS_PLACEHOLDER = "__farm_client_module_preloads__";
777
789
  var FARM_CLIENT_MODULE_PRELOADS_FILE = "client-module-preloads.json";
790
+ var ROLLDOWN_RUNTIME_MODULE = "\0rolldown/runtime.js";
778
791
  function collectFarmClientModulePreloads(bundle, options) {
779
792
  const chunks = Object.values(bundle).filter(
780
793
  (output) => output.type === "chunk"
@@ -804,18 +817,38 @@ function collectFarmClientModulePreloads(bundle, options) {
804
817
  };
805
818
  const entryFiles = staticImports(entry, /* @__PURE__ */ new Set([entry.fileName]), []);
806
819
  const entryLoaded = /* @__PURE__ */ new Set([entry.fileName, ...entryFiles]);
820
+ const entryModule = entry.facadeModuleId;
821
+ const stubEntry = entry.moduleIds?.length === 0 && Boolean(entryModule);
822
+ const entryCodeFiles = entryFiles.filter((fileName) => {
823
+ const ids = byFile.get(fileName)?.moduleIds;
824
+ if (!ids) return false;
825
+ if (ids.length === 1 && ids[0] === ROLLDOWN_RUNTIME_MODULE) return true;
826
+ return stubEntry && ids.some((id) => id === entryModule || id === ROLLDOWN_RUNTIME_MODULE);
827
+ });
807
828
  const modules = {};
829
+ const addModule = (id, chunk) => {
830
+ const moduleId = id.split("?")[0];
831
+ if (!path4.isAbsolute(moduleId)) return;
832
+ const key = toViteModuleId(moduleId, options.root);
833
+ if (modules[key]) return;
834
+ const loaded = /* @__PURE__ */ new Set([...entryLoaded, chunk.fileName]);
835
+ modules[key] = [chunk.fileName, ...staticImports(chunk, loaded, [])].map(index);
836
+ };
808
837
  for (const chunk of chunks) {
809
838
  if (!chunk.isDynamicEntry || !chunk.facadeModuleId || entryLoaded.has(chunk.fileName)) {
810
839
  continue;
811
840
  }
812
- const moduleId = chunk.facadeModuleId.split("?")[0];
813
- if (!path4.isAbsolute(moduleId)) continue;
814
- const loaded = /* @__PURE__ */ new Set([...entryLoaded, chunk.fileName]);
815
- modules[toViteModuleId(moduleId, options.root)] = [
816
- chunk.fileName,
817
- ...staticImports(chunk, loaded, [])
818
- ].map(index);
841
+ addModule(chunk.facadeModuleId, chunk);
842
+ }
843
+ if (options.isDynamicallyImported) {
844
+ const dynamicTargets = new Set(chunks.flatMap((chunk) => chunk.dynamicImports ?? []));
845
+ for (const chunk of chunks) {
846
+ if (chunk.facadeModuleId || !dynamicTargets.has(chunk.fileName)) continue;
847
+ if (entryLoaded.has(chunk.fileName)) continue;
848
+ for (const id of chunk.moduleIds ?? []) {
849
+ if (options.isDynamicallyImported(id)) addModule(id, chunk);
850
+ }
851
+ }
819
852
  }
820
853
  const dynamicFiles = (moduleIds, before = []) => {
821
854
  const into = [];
@@ -840,6 +873,7 @@ function collectFarmClientModulePreloads(bundle, options) {
840
873
  return {
841
874
  files,
842
875
  entry: entryFiles.map(index),
876
+ ...entryCodeFiles.length > 0 ? { entryCode: entryCodeFiles.map(index) } : {},
843
877
  router: dynamicFiles(options.routerModules).map(index),
844
878
  ...rendererFiles.length > 0 ? { renderer: rendererFiles.map(index) } : {},
845
879
  ...rootFiles.length > 0 ? { root: rootFiles.map(index) } : {},
@@ -872,7 +906,8 @@ function createFarmClientModulePreloadPlugin(options) {
872
906
  ...options,
873
907
  rendererModules,
874
908
  actionModules,
875
- serverTreeModules
909
+ serverTreeModules,
910
+ isDynamicallyImported: (id) => (this.getModuleInfo(id)?.dynamicImporters.length ?? 0) > 0
876
911
  })
877
912
  )
878
913
  );
@@ -895,72 +930,6 @@ function encodeFarmBuildJSONPlaceholder(value) {
895
930
  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");
896
931
  }
897
932
 
898
- // src/nitro/islands-react-chunk.ts
899
- var REACT_MODULE = /[\\/]node_modules[\\/](?:react|react-dom|scheduler)[\\/]/;
900
- var REACT_DOM_MODULE = /[\\/]node_modules[\\/]react-dom[\\/]/;
901
- var FARM_EAGER_COMPILE_HINT = "//# allFunctionsCalledOnLoad";
902
- function createFarmIslandsReactOutput() {
903
- let entryImportsReact;
904
- return {
905
- codeSplitting: {
906
- groups: [
907
- {
908
- debugName: "react",
909
- name(moduleId, context) {
910
- if (!REACT_MODULE.test(moduleId)) return null;
911
- entryImportsReact ?? (entryImportsReact = reactLoadsWithAnEntry(moduleId, context));
912
- return entryImportsReact ? null : "react";
913
- }
914
- }
915
- ]
916
- },
917
- // After minification, so the hint stays the chunk's first line; its source map accounts for it.
918
- // Rolldown adds a line after any string, an empty one too, so other chunks get none.
919
- postBanner: ((chunk) => entryImportsReact === false && chunk.moduleIds.some((id) => REACT_DOM_MODULE.test(id)) ? FARM_EAGER_COMPILE_HINT : void 0)
920
- };
921
- }
922
- function reactLoadsWithAnEntry(moduleId, context) {
923
- const react = /* @__PURE__ */ new Set();
924
- const pending = [moduleId];
925
- for (let id = pending.pop(); id !== void 0; id = pending.pop()) {
926
- if (react.has(id) || !REACT_MODULE.test(id)) continue;
927
- react.add(id);
928
- const info = context.getModuleInfo(id);
929
- if (info) pending.push(...info.importedIds, ...info.importers);
930
- }
931
- const seen = /* @__PURE__ */ new Set();
932
- pending.push(...react);
933
- for (let id = pending.pop(); id !== void 0; id = pending.pop()) {
934
- if (seen.has(id)) continue;
935
- seen.add(id);
936
- const info = context.getModuleInfo(id);
937
- if (!info) continue;
938
- if (info.isEntry) return true;
939
- pending.push(...info.importers);
940
- }
941
- return false;
942
- }
943
- var CHUNKING_OPTIONS = [
944
- "manualChunks",
945
- "advancedChunks",
946
- "codeSplitting",
947
- "inlineDynamicImports"
948
- ];
949
- function createFarmIslandsReactChunkPlugin() {
950
- return {
951
- name: "farm-islands-react-chunk",
952
- enforce: "post",
953
- outputOptions: {
954
- order: "post",
955
- handler(options) {
956
- if (CHUNKING_OPTIONS.some((key) => options[key] !== void 0)) return null;
957
- const { codeSplitting, postBanner } = createFarmIslandsReactOutput();
958
- return { ...options, codeSplitting, postBanner: options.postBanner ?? postBanner };
959
- }
960
- }
961
- };
962
- }
963
-
964
933
  // src/nitro/client-route-table.ts
965
934
  import fs2 from "fs/promises";
966
935
  import path5 from "path";
@@ -1418,21 +1387,31 @@ function createFarmVercelImmutableAssetRoute() {
1418
1387
  };
1419
1388
  }
1420
1389
  function buildFarmVercelRoutes(options) {
1421
- const { presetRoutes, runtimeRoutes, middlewareRoutes = [], canonicalSlashRoutes = [] } = options;
1390
+ const {
1391
+ presetRoutes,
1392
+ runtimeRoutes,
1393
+ middlewareRoutes = [],
1394
+ canonicalSlashRoutes = [],
1395
+ markdownRoutes = [],
1396
+ notFoundRoutes
1397
+ } = options;
1422
1398
  const filesystemIndex = presetRoutes.findIndex((route) => route.handle === "filesystem");
1423
1399
  const sourceRoutes = filesystemIndex >= 0 ? presetRoutes.slice(0, filesystemIndex) : [];
1424
1400
  const preservedSourceRoutes = sourceRoutes.filter((route) => route.continue !== true);
1425
1401
  return [
1402
+ ...markdownRoutes,
1426
1403
  ...middlewareRoutes,
1427
1404
  ...preservedSourceRoutes,
1428
1405
  ...canonicalSlashRoutes,
1429
1406
  createFarmVercelImmutableAssetRoute(),
1430
1407
  { handle: "filesystem" },
1431
1408
  ...runtimeRoutes,
1432
- {
1433
- src: "/(.*)",
1434
- dest: "/__nitro"
1435
- }
1409
+ ...notFoundRoutes ?? [
1410
+ {
1411
+ src: "/(.*)",
1412
+ dest: "/__nitro"
1413
+ }
1414
+ ]
1436
1415
  ];
1437
1416
  }
1438
1417
  function escapeRegExp2(value) {
@@ -1473,6 +1452,91 @@ function createFarmVercelCanonicalSlashRoutes(publicPaths) {
1473
1452
  dest: "/__nitro"
1474
1453
  }));
1475
1454
  }
1455
+ var FARM_VERCEL_MARKDOWN_ACCEPT_PATTERN = ".*text/(?:markdown|plain).*";
1456
+ function createFarmVercelMarkdownRoutes(publicPaths) {
1457
+ return groupFarmVercelRouteAlternatives([...new Set(publicPaths)], escapeRegExp2).map((group) => ({
1458
+ src: group.src,
1459
+ has: [{ type: "header", key: "accept", value: FARM_VERCEL_MARKDOWN_ACCEPT_PATTERN }],
1460
+ dest: "/__nitro"
1461
+ }));
1462
+ }
1463
+
1464
+ // src/nitro/vercel-not-found.ts
1465
+ var FARM_STATIC_NOT_FOUND_PATH = "/404.html";
1466
+ var FARM_STATIC_NOT_FOUND_REFUSAL_TYPE = "application/x-farm-static-not-found-refusal";
1467
+ function createFarmVercelStaticNotFoundRoutes(input) {
1468
+ const basePath = normalizeBasePath2(input.basePath);
1469
+ const alternatives = /* @__PURE__ */ new Set();
1470
+ for (const base of /* @__PURE__ */ new Set(["", basePath])) {
1471
+ for (const pattern of input.routePatterns) {
1472
+ alternatives.add(withOptionalTrailingSlash(farmRoutePatternToVercelSource(pattern, base)));
1473
+ }
1474
+ for (const pattern of input.prefixPatterns) {
1475
+ const source = farmRoutePatternToVercelSource(pattern, base);
1476
+ alternatives.add(source === "/" ? "/.*" : `${source}(?:/.*)?`);
1477
+ }
1478
+ for (const pathname of input.paths) {
1479
+ alternatives.add(withOptionalTrailingSlash(escapeRegExp3(withBasePath(pathname, base))));
1480
+ }
1481
+ for (const source of input.matcherSources) {
1482
+ const alternative = getFarmMatcherSourceAlternative(source);
1483
+ if (alternative === null) {
1484
+ throw new Error(
1485
+ `Farm cannot serve a static 404 page: ${JSON.stringify(source)} can match any path.`
1486
+ );
1487
+ }
1488
+ alternatives.add(`${escapeRegExp3(base)}${alternative}`);
1489
+ }
1490
+ alternatives.add(`${escapeRegExp3(base)}/.*\\.md`);
1491
+ }
1492
+ return [
1493
+ ...groupFarmVercelRouteAlternatives([...alternatives], (source) => source).map((group) => ({
1494
+ src: group.src,
1495
+ dest: "/__nitro"
1496
+ })),
1497
+ {
1498
+ src: "/.*",
1499
+ has: [{ type: "header", key: "accept", value: FARM_VERCEL_MARKDOWN_ACCEPT_PATTERN }],
1500
+ dest: "/__nitro"
1501
+ },
1502
+ { src: "/.*", dest: withBasePath(FARM_STATIC_NOT_FOUND_PATH, basePath), status: 404 }
1503
+ ];
1504
+ }
1505
+ function getFarmMatcherSourceAlternative(source) {
1506
+ const normalized = source.startsWith("/") ? source : `/${source}`;
1507
+ const special = normalized.search(/[:*?()[\]{}+\\|^$]/);
1508
+ const literal = special === -1 ? normalized : normalized.slice(0, special);
1509
+ const prefix = literal.replace(/\/+$/, "");
1510
+ if (special === -1) return prefix ? `${escapeRegExp3(prefix)}(?:/.*)?` : "/?";
1511
+ if (literal.endsWith("/")) return prefix ? `${escapeRegExp3(prefix)}(?:/.*)?` : null;
1512
+ return `${escapeRegExp3(literal)}.*`;
1513
+ }
1514
+ function getFarmStaticNotFoundHandlerSources(handlers, farmHandlers) {
1515
+ const sources = [];
1516
+ for (const handler of handlers) {
1517
+ if (farmHandlers.has(handler.handler)) continue;
1518
+ if (!handler.route || getFarmMatcherSourceAlternative(handler.route) === null) return null;
1519
+ sources.push(handler.route);
1520
+ }
1521
+ return sources;
1522
+ }
1523
+ function withOptionalTrailingSlash(source) {
1524
+ return source === "/" || source.endsWith("/") ? source : `${source}/?`;
1525
+ }
1526
+ function withBasePath(pathname, basePath) {
1527
+ const normalized = pathname.startsWith("/") ? pathname : `/${pathname}`;
1528
+ if (!basePath) return normalized;
1529
+ return normalized === "/" ? basePath : `${basePath}${normalized}`;
1530
+ }
1531
+ function normalizeBasePath2(value) {
1532
+ const trimmed = value?.trim() ?? "";
1533
+ if (!trimmed || trimmed === "/") return "";
1534
+ const withSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
1535
+ return withSlash.replace(/\/+$/g, "");
1536
+ }
1537
+ function escapeRegExp3(value) {
1538
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1539
+ }
1476
1540
 
1477
1541
  // src/nitro/ssr-public-assets.ts
1478
1542
  import path10 from "path";
@@ -1879,6 +1943,95 @@ async function writeFarmClientBrotliAssets(clientOutputDir) {
1879
1943
  await Promise.all(Array.from({ length: availableParallelism() }, next));
1880
1944
  }
1881
1945
 
1946
+ // src/nitro/islands-react-chunk.ts
1947
+ var REACT_MODULE = /[\\/]node_modules[\\/](?:react|react-dom|scheduler)[\\/]/;
1948
+ var REACT_DOM_MODULE = /[\\/]node_modules[\\/]react-dom[\\/]/;
1949
+ var FARM_EAGER_COMPILE_HINT = "//# allFunctionsCalledOnLoad";
1950
+ function createFarmIslandsReactOutput() {
1951
+ let entryImportsReact;
1952
+ return {
1953
+ codeSplitting: {
1954
+ groups: [
1955
+ {
1956
+ debugName: "react",
1957
+ name(moduleId, context) {
1958
+ if (!REACT_MODULE.test(moduleId)) return null;
1959
+ entryImportsReact ?? (entryImportsReact = reactLoadsWithAnEntry(moduleId, context));
1960
+ return entryImportsReact ? null : "react";
1961
+ }
1962
+ }
1963
+ ]
1964
+ },
1965
+ // After minification, so the hint stays the chunk's first line; its source map accounts for it.
1966
+ // Rolldown adds a line after any string, an empty one too, so other chunks get none.
1967
+ postBanner: ((chunk) => entryImportsReact === false && chunk.moduleIds.some((id) => REACT_DOM_MODULE.test(id)) ? FARM_EAGER_COMPILE_HINT : void 0)
1968
+ };
1969
+ }
1970
+ function reactLoadsWithAnEntry(moduleId, context) {
1971
+ const react = /* @__PURE__ */ new Set();
1972
+ const pending = [moduleId];
1973
+ for (let id = pending.pop(); id !== void 0; id = pending.pop()) {
1974
+ if (react.has(id) || !REACT_MODULE.test(id)) continue;
1975
+ react.add(id);
1976
+ const info = context.getModuleInfo(id);
1977
+ if (info) pending.push(...info.importedIds, ...info.importers);
1978
+ }
1979
+ const seen = /* @__PURE__ */ new Set();
1980
+ pending.push(...react);
1981
+ for (let id = pending.pop(); id !== void 0; id = pending.pop()) {
1982
+ if (seen.has(id)) continue;
1983
+ seen.add(id);
1984
+ const info = context.getModuleInfo(id);
1985
+ if (!info) continue;
1986
+ if (info.isEntry) return true;
1987
+ pending.push(...info.importers);
1988
+ }
1989
+ return false;
1990
+ }
1991
+
1992
+ // src/nitro/client-chunks.ts
1993
+ var FARM_CLIENT_INLINE_CHUNK_BYTES = 32 * 1024;
1994
+ var STYLE_MODULE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss|sss)(?:\?|$)/;
1995
+ var CHUNKING_OPTIONS = [
1996
+ "manualChunks",
1997
+ "advancedChunks",
1998
+ "codeSplitting",
1999
+ "inlineDynamicImports"
2000
+ ];
2001
+ function canInlineCommonChunks(options) {
2002
+ const format = options.format ?? "es";
2003
+ return (format === "es" || format === "esm" || format === "module") && options.strictExecutionOrder !== false && !options.preserveModules;
2004
+ }
2005
+ function createFarmClientChunksPlugin(options) {
2006
+ return {
2007
+ name: "farm-client-chunks",
2008
+ enforce: "post",
2009
+ outputOptions: {
2010
+ order: "post",
2011
+ handler(output) {
2012
+ if (CHUNKING_OPTIONS.some((key) => output[key] !== void 0)) return null;
2013
+ const inline = options.inlineCommonChunks && canInlineCommonChunks(output);
2014
+ const islands = options.islandsReact ? createFarmIslandsReactOutput() : void 0;
2015
+ if (!inline && !islands) return null;
2016
+ const codeSplitting = {
2017
+ ...islands?.codeSplitting,
2018
+ ...inline ? {
2019
+ experimentalInlineCommonChunks: {
2020
+ maxSize: FARM_CLIENT_INLINE_CHUNK_BYTES,
2021
+ exclude: STYLE_MODULE
2022
+ }
2023
+ } : {}
2024
+ };
2025
+ return {
2026
+ ...output,
2027
+ codeSplitting,
2028
+ ...islands ? { postBanner: output.postBanner ?? islands.postBanner } : {}
2029
+ };
2030
+ }
2031
+ }
2032
+ };
2033
+ }
2034
+
1882
2035
  // src/middleware/static-config.ts
1883
2036
  function literalMatcher(node) {
1884
2037
  if (!node) return void 0;
@@ -1967,7 +2120,7 @@ function farmTargetRunsEdgeMiddleware(preset) {
1967
2120
  function isFarmEdgeMiddlewareRoute(route) {
1968
2121
  return typeof route.config === "object" && route.config?.runtime === "edge";
1969
2122
  }
1970
- function escapeRegExp3(value) {
2123
+ function escapeRegExp4(value) {
1971
2124
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1972
2125
  }
1973
2126
  function toFarmVercelEdgeGuardedUrls(pathnames, basePath) {
@@ -1979,7 +2132,7 @@ function createFarmVercelEdgeMiddlewareRoutes(pathnames, basePath = "/") {
1979
2132
  const publicPaths = toFarmVercelEdgeGuardedUrls(pathnames, basePath);
1980
2133
  return groupFarmVercelRouteAlternatives(publicPaths, (pathname) => {
1981
2134
  const trimmed = pathname.replace(/\/+$/, "");
1982
- return trimmed ? `${escapeRegExp3(trimmed)}(?:/|/index\\.html|\\.html)?` : "/(?:index\\.html)?";
2135
+ return trimmed ? `${escapeRegExp4(trimmed)}(?:/|/index\\.html|\\.html)?` : "/(?:index\\.html)?";
1983
2136
  }).map((group) => ({
1984
2137
  src: group.src,
1985
2138
  middlewarePath: FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION,
@@ -2750,6 +2903,13 @@ function resolveBuildDocsContentDir(docs, root, srcDir) {
2750
2903
  const rootDocsDir = path17.join(root, entryDir);
2751
2904
  return existsSync3(rootDocsDir) ? rootDocsDir : null;
2752
2905
  }
2906
+ function getFarmDocsBundledRootPaths(docs, root, srcDir) {
2907
+ return getFarmDocsRoots(docs).slice(1).map((docsRoot) => {
2908
+ const contentDir = resolveBuildDocsContentDir(docsRoot, root, srcDir);
2909
+ const relativePath = contentDir ? path17.relative(root, contentDir) : "";
2910
+ return relativePath === ".." || relativePath.startsWith(`..${path17.sep}`) || path17.isAbsolute(relativePath) ? "" : relativePath.split(path17.sep).join("/");
2911
+ });
2912
+ }
2753
2913
  function hasProjectPostcssConfig(root) {
2754
2914
  const candidates = [
2755
2915
  "postcss.config.js",
@@ -3250,11 +3410,11 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3250
3410
  (provider) => provider.component || provider.type === "clerk"
3251
3411
  );
3252
3412
  const unsupportedIntegrationProvider = integrationProviders.find(
3253
- (provider) => provider.supportsIsolatedHydration !== true
3413
+ (provider) => !providerSupportsIslands(provider)
3254
3414
  );
3255
3415
  if (config.experimental?.isolatedClientHydration === "enabled" && resolveFarmServerComponentsMode(config.experimental?.serverComponents) !== "rsc" && unsupportedIntegrationProvider) {
3256
3416
  logger.warn(
3257
- `[Farm.js] isolated hydration kept route-wide because integration provider "${unsupportedIntegrationProvider.name}" does not declare supportsIsolatedHydration: true.`
3417
+ `[Farm.js] Client components hydrate with their route, not as islands, because integration provider "${unsupportedIntegrationProvider.name}" doesn't declare \`islands: true\`.`
3258
3418
  );
3259
3419
  }
3260
3420
  const isolatedMode = resolveFarmIsolatedClientHydrationMode(
@@ -3691,8 +3851,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3691
3851
  ...tailwindVitePlugin ? [tailwindVitePlugin] : [],
3692
3852
  ...rendererVitePlugins,
3693
3853
  ...config.vite.plugins || [],
3694
- // React in one chunk, unless the app's config or one of its plugins splits chunks.
3695
- ...islandsMode && isReactRenderer(config.renderer) ? [createFarmIslandsReactChunkPlugin()] : [],
3854
+ // Small shared chunks copied into their readers, and React in one chunk in islands mode,
3855
+ // unless the app's config or one of its plugins splits chunks.
3856
+ createFarmClientChunksPlugin({
3857
+ inlineCommonChunks: platform === "web",
3858
+ islandsReact: islandsMode && isReactRenderer(config.renderer)
3859
+ }),
3696
3860
  farmServerOnlyEntriesPlugin({ platform, distDir: config.distDir || ".farm" }),
3697
3861
  farmNavigationPlugin(config.renderer),
3698
3862
  farmDocsClientConfigPlugin(
@@ -7866,7 +8030,10 @@ function generateFarmDocsAdapterHandlerArguments(docs, docsConfigModulePath) {
7866
8030
  if (docs?.roots?.length) {
7867
8031
  return {
7868
8032
  factory: "createFarmDocsAdapterMultiRuntimeHandler",
7869
- config: `[farmDocsResolvedConfig, ...farmDocsResolvedConfig.roots].map((farmDocsRoot) => (${runtimeConfig("farmDocsRoot")}))`
8033
+ config: `[farmDocsResolvedConfig, ...farmDocsResolvedConfig.roots].map((farmDocsRoot) => ({
8034
+ ...${runtimeConfig("farmDocsRoot")},
8035
+ rootDir: farmDocsRoot.rootDir || farmDocsRuntimeRoot,
8036
+ }))`
7870
8037
  };
7871
8038
  }
7872
8039
  return {
@@ -7874,7 +8041,7 @@ function generateFarmDocsAdapterHandlerArguments(docs, docsConfigModulePath) {
7874
8041
  config: runtimeConfig("farmDocsResolvedConfig")
7875
8042
  };
7876
8043
  }
7877
- function generateFarmDocsRuntimeConfigExpression(docs, precompiled = false) {
8044
+ function generateFarmDocsRuntimeConfigExpression(docs, precompiled = false, bundledRootPaths = []) {
7878
8045
  if (!docs.enabled) return "null";
7879
8046
  const serializableDocs = docs.roots?.length ? {
7880
8047
  ...docs,
@@ -7911,17 +8078,18 @@ function generateFarmDocsRuntimeConfigExpression(docs, precompiled = false) {
7911
8078
  }
7912
8079
  : ${JSON.stringify({ ...serializableDocs, runtimeConfig: void 0 })}`;
7913
8080
  if (!docs.roots?.length) return expression;
7914
- return `((farmDocs) => ({
8081
+ return `((farmDocs, farmDocsBundledRootPaths) => ({
7915
8082
  ...farmDocs,
7916
8083
  roots: farmDocs.roots.map((farmDocsRoot, index) => {
7917
- const contentDir = farmDocsBundledRootsDir
8084
+ const rootDir = farmDocsBundledRootsDir
7918
8085
  ? farmDocsJoin(farmDocsBundledRootsDir, String(index))
7919
8086
  : null;
8087
+ const contentDir = rootDir && farmDocsJoin(rootDir, farmDocsBundledRootPaths[index] || "");
7920
8088
  return contentDir && farmDocsExistsSync(contentDir)
7921
- ? { ...farmDocsRoot, contentDir, config: { ...farmDocsRoot.config, contentDir } }
8089
+ ? { ...farmDocsRoot, rootDir, contentDir, config: { ...farmDocsRoot.config, contentDir } }
7922
8090
  : farmDocsRoot;
7923
8091
  }),
7924
- }))(${expression})`;
8092
+ }))(${expression}, ${JSON.stringify(bundledRootPaths)})`;
7925
8093
  }
7926
8094
  function toVirtualEntryImportSpecifier(modulePath) {
7927
8095
  return JSON.stringify(modulePath.replace(/\\/g, "/"));
@@ -8242,6 +8410,7 @@ ReactDOMServer.configureApp(__farmAppSetup);`;
8242
8410
  }
8243
8411
  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 = []) {
8244
8412
  const farmRendererDisabled = isFarmRendererDisabled(config.renderer);
8413
+ const farmStaticNotFoundBuild = preset === "vercel" && config.experimental?.staticNotFound === true && !farmRendererDisabled;
8245
8414
  const searchPreserveRoutes = pageRoutes.flatMap(
8246
8415
  (route) => route.searchPreserve ? [route.searchPreserve] : []
8247
8416
  );
@@ -8366,7 +8535,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
8366
8535
  })
8367
8536
  );
8368
8537
  const unsupportedIntegrationProvider = renderedIntegrationProviders.find(
8369
- (provider) => provider.supportsIsolatedHydration !== true
8538
+ (provider) => !providerSupportsIslands(provider)
8370
8539
  );
8371
8540
  const isolatedHydrationMode = resolveFarmIsolatedClientHydrationMode(
8372
8541
  config.experimental?.isolatedClientHydration,
@@ -8435,12 +8604,16 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
8435
8604
  ].filter(Boolean).join("\n");
8436
8605
  const apiImports = [];
8437
8606
  const apiRegistrations = [];
8607
+ const nativeAPIRoutes = [];
8438
8608
  apiRoutes.forEach((route, index) => {
8439
8609
  if (!route.filePath) return;
8440
8610
  const varName = `apiRoute${index}`;
8441
8611
  apiImports.push(
8442
8612
  `import * as ${varName} from ${toVirtualEntryImportSpecifier(route.filePath)};`
8443
8613
  );
8614
+ if (isPolyrouteRouteFileName(path17.basename(route.filePath))) {
8615
+ nativeAPIRoutes.push(`[${JSON.stringify(route.path)}, ${varName}]`);
8616
+ }
8444
8617
  apiRegistrations.push(`
8445
8618
  {
8446
8619
  path: ${JSON.stringify(route.path)},
@@ -9112,7 +9285,24 @@ const FarmDefault404Page = typeof React.markFunctionComponent === "function"
9112
9285
  function createFarmNotFoundElement(pathname) {
9113
9286
  const NotFoundPage = hasCustomNotFound && CustomNotFoundComponent ? CustomNotFoundComponent : FarmDefault404Page;
9114
9287
  return React.createElement(NotFoundPage, { pathname: pathname });
9288
+ }${farmStaticNotFoundBuild ? `
9289
+
9290
+ // The build's own request for the not-found page it writes for Vercel. Nitro's prerender worker
9291
+ // sets the variable, so no visitor's request is mistaken for it.
9292
+ function isFarmStaticNotFoundPrerender(pathname) {
9293
+ return (
9294
+ typeof process !== "undefined" &&
9295
+ process.env?.${FARM_PRERENDER_ENV} === "1" &&
9296
+ pathname === ${JSON.stringify(applyFarmBasePath(FARM_STATIC_NOT_FOUND_PATH, config.basePath))}
9297
+ );
9115
9298
  }
9299
+
9300
+ function createFarmStaticNotFoundRefusal(reason) {
9301
+ return new Response(reason, {
9302
+ status: 404,
9303
+ headers: { "Content-Type": ${JSON.stringify(FARM_STATIC_NOT_FOUND_REFUSAL_TYPE)} },
9304
+ });
9305
+ }` : ""}
9116
9306
  ${nativeMCP.registerSource}
9117
9307
  // Config middleware from layers is appended in layer order ahead of the
9118
9308
  // project's, the same merge development applies (mergeFarmLayerConfig).
@@ -9323,7 +9513,11 @@ const farmDocsBundledRootsDir = (() => {
9323
9513
  return null;
9324
9514
  }
9325
9515
  })();` : ""}
9326
- const farmDocsResolvedConfig = ${generateFarmDocsRuntimeConfigExpression(config.docs, hasPrecompiledDocs)};
9516
+ const farmDocsResolvedConfig = ${generateFarmDocsRuntimeConfigExpression(
9517
+ config.docs,
9518
+ hasPrecompiledDocs,
9519
+ config.docs?.enabled && config.docs.roots?.length ? getFarmDocsBundledRootPaths(config.docs, config.root, config.srcDir) : []
9520
+ )};
9327
9521
  const farmDocsRuntimeRoot = ${hasPrecompiledDocs ? '"."' : `farmDocsBundledContentDir || ${JSON.stringify(config.root)}`};
9328
9522
  // Docs pages a path-specific guard covers, decided at build time. The docs API and the
9329
9523
  // root llms/sitemap files answer anyone, so they leave these pages out.
@@ -9363,8 +9557,8 @@ const farmDocsModulePreloadPaths = farmDocsModulePreloads
9363
9557
  : undefined;
9364
9558
  ${adapterOwnsDocsRuntime && !hasPrecompiledDocs ? `// The renderer contract's server exports, for a docs UI that builds its pages with them.
9365
9559
  const farmDocsAppRenderer = ${isReactRenderer(config.renderer) ? '{ name: "react", createElement: React.createElement, Fragment: React.Fragment, renderToString: ReactDOMServer.renderToString }' : "__farmRendererServer"};
9366
- ` : ""}const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `${adapterHandler.factory}(${adapterHandler.config}, {
9367
- rootDir: farmDocsRuntimeRoot,
9560
+ ` : ""}const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `${adapterHandler.factory}(${adapterHandler.config}, {${config.docs.roots?.length ? "" : `
9561
+ rootDir: farmDocsRuntimeRoot,`}
9368
9562
  // A production build's content cannot change, so the adapter reads its
9369
9563
  // navigation once instead of scanning the content directory per request.
9370
9564
  immutableContent: true,
@@ -9415,6 +9609,22 @@ const farmDocsAppRenderer = ${isReactRenderer(config.renderer) ? '{ name: "react
9415
9609
  })` : "null"};
9416
9610
  const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig, isPathGuarded: isFarmDocsPathGuarded, basePath: ${JSON.stringify(config.basePath)} })` : "null"};
9417
9611
 
9612
+ // A long-running server calls this before it listens, so a Polyroute route's first request
9613
+ // doesn't wait for its WebAssembly to compile and its instance to start. Polyroute releases
9614
+ // without \`prepare()\` skip it. Polyroute doesn't keep a failed start, so a route that
9615
+ // fails here tries again on its first request, as it did before this step existed.
9616
+ export async function farmPrepareNativeRoutes() {${nativeAPIRoutes.length > 0 ? `
9617
+ await Promise.all(
9618
+ [${nativeAPIRoutes.join(", ")}].map(async ([routePath, routeModule]) => {
9619
+ try {
9620
+ await routeModule.default?.prepare?.();
9621
+ } catch (error) {
9622
+ console.error(\`[Farm] Couldn't prepare route \${routePath} before listening; its first request will try again:\`, error);
9623
+ }
9624
+ }),
9625
+ );
9626
+ ` : ""}}
9627
+
9418
9628
  // API routes bundled at build time
9419
9629
  const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
9420
9630
  ]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path19, methods }) => ({ path: path19, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
@@ -10468,10 +10678,14 @@ const FARM_ACTION_REFERENCE_PATTERN = /"\\$":"a"|name="\\$F_REF_/;
10468
10678
  // A server tree in a document's markup: the payload a page or layout root rebuilds from.
10469
10679
  const FARM_SERVER_TREE_PATTERN = /<script type="f\\/tree"/;
10470
10680
 
10681
+ // What the entry runs before its own code (Rolldown's runtime, and the chunk holding the entry's
10682
+ // code when the entry chunk is a stub) loads at the entry script's priority. The other preloads
10683
+ // are low, so they don't hold back the first paint's CSS and fonts.
10471
10684
  function renderFarmClientModulePreload(index) {
10685
+ const entryCode = farmClientModulePreloads.entryCode;
10472
10686
  return '\\n <link rel="modulepreload" href="/' +
10473
10687
  escapeFarmHtmlAttribute(farmClientModulePreloads.files[index]) +
10474
- '" fetchpriority="low">';
10688
+ (entryCode && entryCode.includes(index) ? '">' : '" fetchpriority="low">');
10475
10689
  }
10476
10690
 
10477
10691
  // The manifest indexes of the modules a document's hydrating page and its markup
@@ -12024,6 +12238,10 @@ ${hasServerRuntimeIntegrations ? `
12024
12238
  // In place for a page the adapter built with createHtmlResponse, so its HTML string stays.
12025
12239
  const bufferedDocsResponse = farmPreloadHeadersResponse(wrappedDocsResponse, (headers) => {
12026
12240
  headers.set("x-farm-preload-buffered", "1");
12241
+ // The docs engine answers this URL with Markdown for an Accept that asks for it, so a
12242
+ // shared cache keys the page on Accept. An adapter's page does not always say so, and
12243
+ // only a page that is also an app route gets it from Markdown negotiation.
12244
+ appendFarmVary(headers, "Accept");
12027
12245
  });
12028
12246
  return applyProductionMiddlewareHeaders(bufferedDocsResponse, middlewareHeaders);
12029
12247
  }
@@ -13586,7 +13804,8 @@ ${farmRendererDisabled ? `
13586
13804
  ), middlewareHeaders);
13587
13805
  }
13588
13806
 
13589
- try {
13807
+ try {${farmStaticNotFoundBuild ? `
13808
+ const farmNotFoundRequestReads = _getRequestReadCount() + _getRequestCookieReadCount();` : ""}
13590
13809
  // Wrap 404 page with root layout if available
13591
13810
  let notFoundElement = createFarmNotFoundElement(pathname);
13592
13811
  // No page matched, so a layout inside a route group cannot apply.
@@ -13610,8 +13829,16 @@ ${farmRendererDisabled ? `
13610
13829
  hasCustomNotFound ? CustomNotFoundModule : null,
13611
13830
  ),
13612
13831
  { pathname },
13613
- );
13614
-
13832
+ );${farmStaticNotFoundBuild ? `
13833
+ // experimental.staticNotFound: Vercel serves this render to every missing URL. A render that
13834
+ // read cookies or headers, here or through an auth helper, belongs to one visitor.
13835
+ if (
13836
+ isFarmStaticNotFoundPrerender(pathname) &&
13837
+ _getRequestReadCount() + _getRequestCookieReadCount() !== farmNotFoundRequestReads
13838
+ ) {
13839
+ return createFarmStaticNotFoundRefusal("the not-found page reads cookies or headers");
13840
+ }` : ""}
13841
+
13615
13842
  // Check if layout provides full HTML document
13616
13843
  const fullDocument = extractFarmFullDocument(html);
13617
13844
  const hasFullDocument = fullDocument !== null;
@@ -13680,7 +13907,11 @@ ${farmRendererDisabled ? `
13680
13907
  }
13681
13908
  }), middlewareHeaders), fullHtml);
13682
13909
  } catch (error) {
13683
- console.error("404 render error:", error);
13910
+ console.error("404 render error:", error);${farmStaticNotFoundBuild ? `
13911
+ // The fallback names this request's path, which a file served at every URL can't.
13912
+ if (isFarmStaticNotFoundPrerender(pathname)) {
13913
+ return createFarmStaticNotFoundRefusal("the not-found page failed to render");
13914
+ }` : ""}
13684
13915
  const fallbackDocument = applyFarmThemeDocument(
13685
13916
  \`<!DOCTYPE html><html><head><title>404</title></head><body><h1>404 - Page Not Found</h1><p>The page \${pathname} doesn't exist.</p><a href="\${escapeFarmHtmlAttribute(applyFarmBasePath("/", farmResolvedRuntimeConfig.basePath))}">Go Home</a></body></html>\`,
13686
13917
  farmThemeConfig,
@@ -14048,6 +14279,178 @@ function getPhysicalPrerenderBypassReason(options) {
14048
14279
  }
14049
14280
  return void 0;
14050
14281
  }
14282
+ function normalizeStaticNotFoundPath(pathname) {
14283
+ const normalized = pathname.startsWith("/") ? pathname : `/${pathname}`;
14284
+ return normalized.replace(/\/+$/, "") || "/";
14285
+ }
14286
+ var FARM_STATIC_NOT_FOUND_PROBE = "/__farm-static-not-found-probe__/0";
14287
+ async function resolveFarmStaticNotFoundPlan(options) {
14288
+ const { config, routeManager } = options;
14289
+ if (config.experimental?.staticNotFound !== true) return null;
14290
+ if (options.preset !== "vercel") {
14291
+ return { reason: `it applies to the vercel target, not "${options.preset}"` };
14292
+ }
14293
+ if (isFarmRendererDisabled(config.renderer)) {
14294
+ return { reason: "the app sets `renderer: false`, so a missing URL gets a JSON 404" };
14295
+ }
14296
+ if (config.i18n.enabled) return { reason: "i18n may redirect any path to a locale" };
14297
+ const routePatterns = /* @__PURE__ */ new Set();
14298
+ const prefixPatterns = /* @__PURE__ */ new Set([
14299
+ "/api",
14300
+ resolveFarmAPIServerBasePath(config.api),
14301
+ "/_farm",
14302
+ "/__farm",
14303
+ "/.well-known",
14304
+ "/mcp"
14305
+ ]);
14306
+ const paths = /* @__PURE__ */ new Set([
14307
+ "/robots.txt",
14308
+ "/sitemap.xml",
14309
+ "/llms.txt",
14310
+ "/llms-full.txt",
14311
+ config.images.path
14312
+ ]);
14313
+ const matcherSources = /* @__PURE__ */ new Set();
14314
+ const addMatcherSource = (source, owner) => {
14315
+ if (getFarmMatcherSourceAlternative(source) === null) {
14316
+ return `${owner} \`${source}\` may match any path`;
14317
+ }
14318
+ matcherSources.add(source);
14319
+ return null;
14320
+ };
14321
+ const addMatchers = (matcher, owner) => {
14322
+ const matchers = matcher === void 0 ? [] : Array.isArray(matcher) ? matcher : [matcher];
14323
+ if (matchers.length === 0) return `${owner} has no \`matcher\`, so it runs for every path`;
14324
+ for (const entry of matchers) {
14325
+ if (typeof entry !== "string") {
14326
+ return `${owner} has a function or regular-expression \`matcher\``;
14327
+ }
14328
+ const refusal = addMatcherSource(entry, `${owner}'s matcher`);
14329
+ if (refusal) return refusal;
14330
+ }
14331
+ return null;
14332
+ };
14333
+ for (const entry of options.routeRuntimeManifest.routes) {
14334
+ if (entry.kind !== "page" && entry.kind !== "metadata") continue;
14335
+ if (/^\/\[\[?\.\.\./.test(entry.pattern)) {
14336
+ return { reason: `the page \`${entry.pattern}\` answers every path` };
14337
+ }
14338
+ routePatterns.add(entry.pattern);
14339
+ }
14340
+ for (const image of routeManager.getMetadataImages().values()) {
14341
+ routePatterns.add(`${image.pattern === "/" ? "" : image.pattern}/${image.fileName}`);
14342
+ }
14343
+ for (const plugin of config.plugins || []) {
14344
+ if (getFarmIntegrationPluginServerRuntime(plugin) === false) continue;
14345
+ if (plugin.name === FARM_MOBILE_SESSION_PLUGIN) continue;
14346
+ if (farmPluginMayAffectRuntimePath(plugin, FARM_STATIC_NOT_FOUND_PROBE)) {
14347
+ return { reason: `the server plugin "${plugin.name}" may answer any path` };
14348
+ }
14349
+ for (const endpoint of plugin.runtime?.endpoints ?? []) {
14350
+ paths.add(
14351
+ normalizeFarmPluginRuntimeEndpointPath(
14352
+ endpoint.path,
14353
+ `Farm plugin "${plugin.name}" runtime endpoint`
14354
+ )
14355
+ );
14356
+ }
14357
+ }
14358
+ if (hasFarmMiddlewareConfig(config.middleware)) {
14359
+ const entries = Array.isArray(config.middleware) ? config.middleware : [config.middleware];
14360
+ for (const entry of entries) {
14361
+ const refusal = addMatchers(entry.matcher, "middleware in the config");
14362
+ if (refusal) return { reason: refusal };
14363
+ }
14364
+ }
14365
+ for (const route of options.middlewareRoutes) {
14366
+ if (normalizeStaticNotFoundPath(route.path) !== "/") {
14367
+ prefixPatterns.add(route.path);
14368
+ continue;
14369
+ }
14370
+ const fileConfig = route.config ?? await readMiddlewareFileConfig(route.filePath);
14371
+ if (!fileConfig || fileConfig === "unknown") {
14372
+ return {
14373
+ reason: "middleware.ts at the app root has no literal `config.matcher`, so it runs for every path"
14374
+ };
14375
+ }
14376
+ const refusal = addMatchers(fileConfig.matcher, "middleware.ts at the app root");
14377
+ if (refusal) return { reason: refusal };
14378
+ }
14379
+ for (const [key, integration] of Object.entries(config.integrations || {})) {
14380
+ if (!isFarmIntegration(integration)) continue;
14381
+ for (const entry of integration.middleware ?? []) {
14382
+ const refusal = addMatchers(entry.matcher, `the "${key}" integration's middleware`);
14383
+ if (refusal) return { reason: refusal };
14384
+ }
14385
+ for (const route of integration.routes ?? []) {
14386
+ const refusal = addMatcherSource(route.path, `the "${key}" integration's route`);
14387
+ if (refusal) return { reason: refusal };
14388
+ }
14389
+ }
14390
+ for (const source of options.redirectSources) {
14391
+ const refusal = addMatcherSource(source, "the redirect source");
14392
+ if (refusal) return { reason: refusal };
14393
+ }
14394
+ for (const source of options.rewriteSources) {
14395
+ const refusal = addMatcherSource(source, "the rewrite source");
14396
+ if (refusal) return { reason: refusal };
14397
+ }
14398
+ if (config.docs?.enabled) {
14399
+ for (const docsRoot of getFarmDocsRoots(config.docs)) {
14400
+ const entry = normalizeStaticNotFoundPath(docsRoot.entry);
14401
+ if (entry === "/") return { reason: "the docs entry is `/`, so docs answer every path" };
14402
+ prefixPatterns.add(entry);
14403
+ }
14404
+ if (hasFarmDocsRuntimeAdapter(config.docs)) {
14405
+ const adapterRoutes = await listFarmDocsAdapterRoutes(config.docs, {
14406
+ root: options.root,
14407
+ srcDir: config.srcDir
14408
+ });
14409
+ if (!adapterRoutes) {
14410
+ return {
14411
+ reason: `the docs adapter ${JSON.stringify(config.docs.adapter.id)} does not list the paths it answers; upgrade it`
14412
+ };
14413
+ }
14414
+ for (const pathname of adapterRoutes.paths) paths.add(pathname);
14415
+ for (const prefix of adapterRoutes.prefixes) {
14416
+ if (normalizeStaticNotFoundPath(prefix) === "/") {
14417
+ return {
14418
+ reason: `the docs adapter ${JSON.stringify(config.docs.adapter.id)} answers every path`
14419
+ };
14420
+ }
14421
+ prefixPatterns.add(prefix);
14422
+ }
14423
+ }
14424
+ }
14425
+ if (config.server.health.enabled) {
14426
+ paths.add(config.server.health.livenessPath);
14427
+ paths.add(config.server.health.readinessPath);
14428
+ }
14429
+ if (config.openapi.enabled) {
14430
+ if (config.openapi.route) paths.add(config.openapi.route);
14431
+ if (config.openapi.specRoute) paths.add(config.openapi.specRoute);
14432
+ }
14433
+ if (config.workflows.route) prefixPatterns.add(config.workflows.route);
14434
+ const notFoundPath = resolveFarmNotFoundComponentPath(
14435
+ config,
14436
+ getFarmAppDirectories(config),
14437
+ routeManager.getRendererNotFoundPath()
14438
+ );
14439
+ if (notFoundPath && /\bpathname\b/.test(readFileSync2(notFoundPath, "utf8"))) {
14440
+ return {
14441
+ reason: `the not-found page (${path17.relative(options.root, notFoundPath)}) reads \`pathname\`, which a file served at every URL cannot give each one`
14442
+ };
14443
+ }
14444
+ return {
14445
+ input: {
14446
+ basePath: config.basePath,
14447
+ routePatterns: [...routePatterns],
14448
+ prefixPatterns: [...prefixPatterns],
14449
+ paths: [...paths],
14450
+ matcherSources: [...matcherSources]
14451
+ }
14452
+ };
14453
+ }
14051
14454
  async function getFarmDocsPrerenderPages(config, root, preset) {
14052
14455
  if (!config.docs?.enabled || !config.docs.prerender) return [];
14053
14456
  if (getFarmPresetRuntime(preset) === "edge") {
@@ -14102,6 +14505,15 @@ function hasFarmNitroCacheRouteRule(routeRules) {
14102
14505
  return swr !== void 0 && swr !== false || cache !== void 0 && cache !== false || !!headers && typeof headers === "object" && Object.keys(headers).length > 0;
14103
14506
  });
14104
14507
  }
14508
+ function getFarmRouteRuleHeaderNames(routeRules) {
14509
+ const names = /* @__PURE__ */ new Set();
14510
+ for (const rule of Object.values(routeRules || {})) {
14511
+ const headers = rule?.headers;
14512
+ if (!headers || typeof headers !== "object") continue;
14513
+ for (const name of Object.keys(headers)) names.add(name.toLowerCase());
14514
+ }
14515
+ return [...names].sort();
14516
+ }
14105
14517
  async function buildNitroUniversal(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, ssrBundle, ssrEntryFile, clientOutputDir, routeRuntimeManifest, configuredHeaderRoutes, nitroBuilderResultPromise, pluginManager, markdownPrecompiledPages) {
14106
14518
  const [fs5, nitroBuilderResult] = await Promise.all([
14107
14519
  import("fs/promises"),
@@ -14214,6 +14626,22 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
14214
14626
  for (const skipped of skippedPrerenderRoutes) {
14215
14627
  logger.info(`\u21AA Keeping SSG route ${skipped.pathname} server-handled (${skipped.reason})`);
14216
14628
  }
14629
+ const staticNotFoundPlan = await resolveFarmStaticNotFoundPlan({
14630
+ config,
14631
+ root,
14632
+ preset,
14633
+ routeManager,
14634
+ routeRuntimeManifest,
14635
+ middlewareRoutes,
14636
+ redirectSources,
14637
+ rewriteSources
14638
+ });
14639
+ if (staticNotFoundPlan && "reason" in staticNotFoundPlan) {
14640
+ logger.info(
14641
+ `\u21AA Keeping missing URLs server-handled: experimental.staticNotFound is off because ${staticNotFoundPlan.reason}`
14642
+ );
14643
+ }
14644
+ const staticNotFoundPrerenderPath = staticNotFoundPlan && "input" in staticNotFoundPlan ? applyFarmBasePath(FARM_STATIC_NOT_FOUND_PATH, config.basePath) : null;
14217
14645
  if (farmWorkflows.workflows.length > 0) {
14218
14646
  logger.info(`\u23F1\uFE0F Found ${farmWorkflows.workflows.length} Farm workflow task(s)`);
14219
14647
  }
@@ -14312,17 +14740,19 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
14312
14740
  const nitroEntryPath = path17.join(ssrOutputDir, "nitro-entry.mjs");
14313
14741
  const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
14314
14742
  const hasNitroCacheRouteRules = hasFarmNitroCacheRouteRule(config.routeRules);
14743
+ const hasPrerenderedPages = prerenderRoutes.length > 0;
14744
+ const usesNitroResponseHook = hasNitroCacheRouteRules || hasPrerenderedPages;
14315
14745
  const nitroEntryCode = `
14316
14746
  // Farm.js Nitro Entry
14317
14747
  // This file adapts Farm's Web fetch handler to Nitro's event handler contract.
14318
14748
 
14319
14749
  import { useNitroHooks } from '#nitro/runtime/app'
14320
- import handler, { farmProductionLifecycle, createFarmNodeRequestAbortSignal${nodeAdapterModule ? ", getFarmOwnedBufferedHtml, useFarmNodePageResponse" : ""} } from './${ssrEntryFile}'${nodeAdapterModule ? `
14750
+ import handler, { farmPrepareNativeRoutes, farmProductionLifecycle, createFarmNodeRequestAbortSignal${nodeAdapterModule ? ", getFarmOwnedBufferedHtml, useFarmNodePageResponse" : ""} } from './${ssrEntryFile}'${nodeAdapterModule ? `
14321
14751
  import { FastResponse } from ${JSON.stringify(nodeAdapterModule)}
14322
14752
 
14323
14753
  useFarmNodePageResponse(FastResponse)` : ""}
14324
14754
 
14325
- export { farmProductionLifecycle }
14755
+ export { farmPrepareNativeRoutes, farmProductionLifecycle }
14326
14756
 
14327
14757
  let farmCloseHookRegistered = false
14328
14758
  function registerFarmCloseHook() {
@@ -14332,12 +14762,50 @@ function registerFarmCloseHook() {
14332
14762
  farmProductionLifecycle.close('production-server-closed')
14333
14763
  )
14334
14764
  }
14335
- ${hasNitroCacheRouteRules ? `
14765
+ ${usesNitroResponseHook ? `
14766
+ const FARM_PRIVATE_CACHE_DIRECTIVE = /(?:^|,)\\s*(?:private|no-store)\\s*(?:[,=]|$)/i
14767
+ ` : ""}${hasPrerenderedPages ? `
14768
+ // A prerendered page's route rule holds its static file's headers, and H3 sets them on
14769
+ // whatever the server answers at that URL after Farm answered: a Markdown request by
14770
+ // Accept, or the URL's other trailing-slash spelling. Farm's answer keeps its own headers,
14771
+ // so a CDN caches its Markdown as it does for a page that renders on request. Headers an
14772
+ // app's routeRules set still apply, and so does the file's private policy.
14773
+ const FARM_ROUTE_RULE_HEADERS = new Set(${JSON.stringify(getFarmRouteRuleHeaderNames(config.routeRules))})
14774
+ const farmPrerenderedPageHeadersKey = Symbol.for('farm.prerenderedPageHeaders')
14775
+ let farmPrerenderedPageHookRegistered = false
14776
+ function keepFarmPrerenderedPageHeaders(event, response) {
14777
+ const ruleHeaders = event.context?.routeRules?.headers
14778
+ if (!ruleHeaders || !event.context) return
14779
+ const own = []
14780
+ for (const name of Object.keys(ruleHeaders)) {
14781
+ const key = name.toLowerCase()
14782
+ if (FARM_ROUTE_RULE_HEADERS.has(key)) continue
14783
+ if (key === 'cache-control' && FARM_PRIVATE_CACHE_DIRECTIVE.test(String(ruleHeaders[name]))) continue
14784
+ own.push([key, response.headers.get(key)])
14785
+ }
14786
+ if (own.length === 0) return
14787
+ if (!farmPrerenderedPageHookRegistered) {
14788
+ farmPrerenderedPageHookRegistered = true
14789
+ useNitroHooks().hook('response', (response, responseEvent) => {
14790
+ const headers = responseEvent.context?.[farmPrerenderedPageHeadersKey]
14791
+ if (!headers) return
14792
+ try {
14793
+ for (const [key, value] of headers) {
14794
+ if (value === null) response.headers.delete(key)
14795
+ else if (response.headers.get(key) !== value) response.headers.set(key, value)
14796
+ }
14797
+ } catch {
14798
+ // Immutable headers belong to a response Nitro passed through untouched.
14799
+ }
14800
+ })
14801
+ }
14802
+ event.context[farmPrerenderedPageHeadersKey] = own
14803
+ }
14804
+ ` : ""}${hasNitroCacheRouteRules ? `
14336
14805
  // A swr route rule caches through Nitro, which writes its own public Cache-Control on
14337
14806
  // the event after Farm answered, and a headers route rule sets its headers there too. H3
14338
14807
  // lets those replace the response's. A response middleware let through keeps Farm's
14339
14808
  // private policy and no CDN cache header, so no CDN serves it to others.
14340
- const FARM_PRIVATE_CACHE_DIRECTIVE = /(?:^|,)\\s*(?:private|no-store)\\s*(?:[,=]|$)/i
14341
14809
  const FARM_CDN_CACHE_CONTROL_HEADERS = [
14342
14810
  'cdn-cache-control',
14343
14811
  'vercel-cdn-cache-control',
@@ -14484,7 +14952,8 @@ ${hasNitroCacheRouteRules ? " let farmGuardedResponse = false\n" : ""} const r
14484
14952
  if (farmVary) {
14485
14953
  const nitroHeaders = event.res.headers
14486
14954
  if (nitroHeaders.has('Vary')) mergeVaryHeaders(nitroHeaders, farmVary)
14487
- }${hasNitroCacheRouteRules ? `
14955
+ }${hasPrerenderedPages ? `
14956
+ if (event.context?.routeRules?.prerender) keepFarmPrerenderedPageHeaders(event, response)` : ""}${hasNitroCacheRouteRules ? `
14488
14957
  const farmCacheControl = response.headers.get('cache-control')
14489
14958
  if (
14490
14959
  // A guarded response, or any response Farm kept private under a swr or cache rule: the
@@ -14638,8 +15107,8 @@ function toFarmNodeResponse(request, response) {
14638
15107
  ...farmNodeServerEntryPath ? { entry: farmNodeServerEntryPath } : {},
14639
15108
  ...farmBunServerEntryPath ? { entry: farmBunServerEntryPath } : {},
14640
15109
  ...farmNetlifyEntryPath ? { entry: farmNetlifyEntryPath } : {},
14641
- // The response hook that keeps a private Cache-Control under a swr or headers rule (nitro-entry).
14642
- ...hasNitroCacheRouteRules ? { features: { runtimeHooks: true } } : {},
15110
+ // The response hooks that keep Farm's headers under a route rule's (nitro-entry).
15111
+ ...usesNitroResponseHook ? { features: { runtimeHooks: true } } : {},
14643
15112
  rootDir: root,
14644
15113
  // Farm registers every handler, task, and plugin explicitly. Scanning the
14645
15114
  // project root would bundle an app's own `middleware/`, `api/`, `routes/`,
@@ -14664,7 +15133,7 @@ function toFarmNodeResponse(request, response) {
14664
15133
  // print sizes after the build. A self-hosted server is never shipped compressed,
14665
15134
  // so list plain sizes; zipped serverless and edge bundles keep the gzip column.
14666
15135
  ...preset === "node-server" || preset === "bun" ? { logging: { compressedSizes: false } } : {},
14667
- ...prerenderRoutes.length > 0 ? {
15136
+ ...prerenderRoutes.length > 0 || staticNotFoundPrerenderPath ? {
14668
15137
  prerender: {
14669
15138
  crawlLinks: false,
14670
15139
  failOnError: true,
@@ -14672,7 +15141,10 @@ function toFarmNodeResponse(request, response) {
14672
15141
  // answered independently, as by the production server, so keeping several
14673
15142
  // in flight overlaps the worker's rendering with this thread's per-route work.
14674
15143
  concurrency: Math.min(os.availableParallelism(), 8),
14675
- routes: prerenderRoutes.map(toPrerenderPublicPath),
15144
+ routes: [
15145
+ ...prerenderRoutes.map(toPrerenderPublicPath),
15146
+ ...staticNotFoundPrerenderPath ? [staticNotFoundPrerenderPath] : []
15147
+ ],
14676
15148
  // Cloudflare's asset server answers a directory index (about/index.html) at the
14677
15149
  // trailing-slash URL and redirects the other spelling to it, so a page is written as
14678
15150
  // about.html unless trailingSlash asks for the slash, as Nitro's Netlify and Vercel
@@ -14717,7 +15189,8 @@ function toFarmNodeResponse(request, response) {
14717
15189
  ...configuredNitroRouteRules,
14718
15190
  // Exact user rules must retain their runtime settings without replacing
14719
15191
  // the headers and prerender marker generated for a safe physical page.
14720
- ...prerenderNitroRouteRules
15192
+ ...prerenderNitroRouteRules,
15193
+ ...staticNotFoundPrerenderPath ? { [staticNotFoundPrerenderPath]: { prerender: true } } : {}
14721
15194
  },
14722
15195
  rollupConfig: {
14723
15196
  external: nitroRollupExternal,
@@ -14761,7 +15234,7 @@ function toFarmNodeResponse(request, response) {
14761
15234
  )
14762
15235
  );
14763
15236
  const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms && path17.resolve(nitroConfig.output?.serverDir || "") === path17.resolve(expectedServerDir);
14764
- const prerenderReusesPrebuiltSSR = prerenderRoutes.length > 0 && ssrExternalsArePackaged && nitroBuildIsFarms;
15237
+ const prerenderReusesPrebuiltSSR = (prerenderRoutes.length > 0 || staticNotFoundPrerenderPath !== null) && ssrExternalsArePackaged && nitroBuildIsFarms;
14765
15238
  const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
14766
15239
  if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
14767
15240
  const useRolldownBuilder = canReusePrebuiltSSR && (nitroConfig.builder ?? process.env.NITRO_BUILDER) === "rolldown";
@@ -14861,6 +15334,22 @@ function toFarmNodeResponse(request, response) {
14861
15334
  nitroInstance.routing.sync();
14862
15335
  });
14863
15336
  }
15337
+ let staticNotFoundWritten = false;
15338
+ let staticNotFoundRefusal = null;
15339
+ if (staticNotFoundPrerenderPath) {
15340
+ nitroInstance.hooks.hook("prerender:generate", (route) => {
15341
+ if (route.route !== staticNotFoundPrerenderPath) return;
15342
+ const status = route.error?.status ?? 200;
15343
+ const contentType = route.contentType?.toLowerCase() ?? "";
15344
+ route.error = void 0;
15345
+ if (status === 404 && contentType.includes("text/html")) {
15346
+ staticNotFoundWritten = true;
15347
+ return;
15348
+ }
15349
+ route.skip = true;
15350
+ staticNotFoundRefusal = contentType.includes(FARM_STATIC_NOT_FOUND_REFUSAL_TYPE) ? route.contents || "the not-found page can't be served as a file" : `the build's request for the not-found page answered ${status} instead of 404`;
15351
+ });
15352
+ }
14864
15353
  if (farmNodeServerEntryPath || farmBunServerEntryPath || farmNetlifyEntryPath) {
14865
15354
  nitroInstance.hooks.hook("prerender:config", (prerendererConfig) => {
14866
15355
  delete prerendererConfig.entry;
@@ -14917,6 +15406,15 @@ function toFarmNodeResponse(request, response) {
14917
15406
  });
14918
15407
  });
14919
15408
  }
15409
+ if (isVercel && docsPrerenderPages.some((pathname) => prerenderRoutes.includes(pathname))) {
15410
+ nitroInstance.hooks.hook("prerender:init", (prerenderer) => {
15411
+ prerenderer.hooks.hook("compiled", async () => {
15412
+ await copyFarmDocsContentForVercel(config, root, prerenderer.options.output.serverDir, fs5, {
15413
+ log: false
15414
+ });
15415
+ });
15416
+ });
15417
+ }
14920
15418
  nitroInstance.hooks.hook("rollup:before", (_nitro, rollupConfig) => {
14921
15419
  nameCodeSplittingGroups(rollupConfig);
14922
15420
  });
@@ -14936,8 +15434,10 @@ function toFarmNodeResponse(request, response) {
14936
15434
  }
14937
15435
  });
14938
15436
  }
14939
- if (prerenderRoutes.length > 0) {
14940
- logger.info(`\u{1F4C4} Pre-rendering ${prerenderRoutes.length} SSG page(s)`);
15437
+ if (prerenderRoutes.length > 0 || staticNotFoundPrerenderPath) {
15438
+ if (prerenderRoutes.length > 0) {
15439
+ logger.info(`\u{1F4C4} Pre-rendering ${prerenderRoutes.length} SSG page(s)`);
15440
+ }
14941
15441
  const previousPrerender = process.env[FARM_PRERENDER_ENV];
14942
15442
  process.env[FARM_PRERENDER_ENV] = "1";
14943
15443
  try {
@@ -15015,6 +15515,41 @@ function toFarmNodeResponse(request, response) {
15015
15515
  outputDir
15016
15516
  });
15017
15517
  }
15518
+ let staticNotFoundRoutes;
15519
+ if (staticNotFoundPlan && "input" in staticNotFoundPlan && staticNotFoundPrerenderPath) {
15520
+ const toHandlerKey = (handler) => toPosixPath(path17.resolve(root, handler));
15521
+ const handlerSources = getFarmStaticNotFoundHandlerSources(
15522
+ nitroInstance.options.handlers.map((handler) => ({
15523
+ route: handler.route,
15524
+ handler: toHandlerKey(handler.handler)
15525
+ })),
15526
+ new Set(
15527
+ [nitroEntryPath, farmWorkflows.handlerPath].filter((handler) => Boolean(handler)).map(toHandlerKey)
15528
+ )
15529
+ );
15530
+ if (!handlerSources) {
15531
+ staticNotFoundRefusal = "a Nitro handler that a plugin or module adds may answer any path";
15532
+ } else if (staticNotFoundWritten) {
15533
+ staticNotFoundRoutes = createFarmVercelStaticNotFoundRoutes({
15534
+ ...staticNotFoundPlan.input,
15535
+ matcherSources: [...staticNotFoundPlan.input.matcherSources, ...handlerSources]
15536
+ });
15537
+ const fileHeaders = nitroInstance.options.routeRules[staticNotFoundPrerenderPath]?.headers;
15538
+ const cspHeaders = Object.fromEntries(
15539
+ Object.entries(fileHeaders || {}).filter(
15540
+ ([name]) => name.toLowerCase().startsWith("content-security-policy")
15541
+ )
15542
+ );
15543
+ const notFoundRoute = staticNotFoundRoutes[staticNotFoundRoutes.length - 1];
15544
+ if (notFoundRoute && Object.keys(cspHeaders).length > 0) notFoundRoute.headers = cspHeaders;
15545
+ logger.info("\u{1F4C4} Serving the not-found page as a file to missing URLs");
15546
+ }
15547
+ if (!staticNotFoundRoutes) {
15548
+ logger.info(
15549
+ `\u21AA Keeping missing URLs server-handled: experimental.staticNotFound is off because ${staticNotFoundRefusal ?? "the build did not write the not-found page"}`
15550
+ );
15551
+ }
15552
+ }
15018
15553
  if (isVercel) {
15019
15554
  await postProcessVercelOutput(
15020
15555
  root,
@@ -15029,7 +15564,8 @@ function toFarmNodeResponse(request, response) {
15029
15564
  middlewareRoutes: edgeMiddlewareRoutes,
15030
15565
  guardedPages: edgeGuardedPrerenderRoutes
15031
15566
  },
15032
- prerenderRoutes.map(toPrerenderPublicPath)
15567
+ prerenderRoutes.map(toPrerenderPublicPath),
15568
+ staticNotFoundRoutes
15033
15569
  );
15034
15570
  }
15035
15571
  logger.success(`\u2705 Nitro build completed with preset: ${preset}`);
@@ -15129,7 +15665,7 @@ async function moveVercelOutputPath(src, dest, fs5) {
15129
15665
  await fs5.cp(src, dest, { recursive: true, force: true });
15130
15666
  await fs5.rm(src, { recursive: true, force: true });
15131
15667
  }
15132
- async function postProcessVercelOutput(root, outputDir, fs5, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages) {
15668
+ async function postProcessVercelOutput(root, outputDir, fs5, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages, notFoundRoutes) {
15133
15669
  const serverDir = path17.join(outputDir, "server");
15134
15670
  const functionsDir = path17.join(outputDir, "functions");
15135
15671
  const nitroFuncDir = path17.join(functionsDir, "__nitro.func");
@@ -15178,7 +15714,9 @@ async function postProcessVercelOutput(root, outputDir, fs5, config, farmWorkflo
15178
15714
  presetRoutes: Array.isArray(vercelConfig.routes) ? vercelConfig.routes : [],
15179
15715
  runtimeRoutes,
15180
15716
  middlewareRoutes: edgeMiddlewareRoutes.length > 0 ? createFarmVercelEdgeMiddlewareRoutes(edgeMiddleware.guardedPages, config.basePath) : [],
15181
- canonicalSlashRoutes: createFarmVercelCanonicalSlashRoutes(prerenderedPages)
15717
+ canonicalSlashRoutes: createFarmVercelCanonicalSlashRoutes(prerenderedPages),
15718
+ markdownRoutes: createFarmVercelMarkdownRoutes(prerenderedPages),
15719
+ notFoundRoutes
15182
15720
  });
15183
15721
  const vercelConfigWithWorkflowCrons = applyFarmWorkflowVercelCrons(
15184
15722
  vercelConfig,
@@ -15188,7 +15726,7 @@ async function postProcessVercelOutput(root, outputDir, fs5, config, farmWorkflo
15188
15726
  await fs5.writeFile(configPath, JSON.stringify(vercelConfigWithCrons, null, 2));
15189
15727
  logger.info("\u2705 Post-processed Vercel output for Build Output API v3");
15190
15728
  }
15191
- async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5) {
15729
+ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5, options = {}) {
15192
15730
  if (!config.docs?.enabled) return;
15193
15731
  const [mainRoot, ...extraRoots] = getFarmDocsRoots(config.docs);
15194
15732
  await copyFarmDocsRootContent(
@@ -15196,26 +15734,31 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs5) {
15196
15734
  root,
15197
15735
  config.srcDir,
15198
15736
  path17.join(nitroFuncDir, "farm-docs-content"),
15199
- fs5
15737
+ fs5,
15738
+ options
15200
15739
  );
15740
+ const bundledRootPaths = getFarmDocsBundledRootPaths(config.docs, root, config.srcDir);
15201
15741
  for (const [index, docsRoot] of extraRoots.entries()) {
15742
+ const bundledRootDir = path17.join(nitroFuncDir, "farm-docs-roots", String(index));
15743
+ await fs5.rm(bundledRootDir, { recursive: true, force: true });
15202
15744
  await copyFarmDocsRootContent(
15203
15745
  docsRoot,
15204
15746
  root,
15205
15747
  config.srcDir,
15206
- path17.join(nitroFuncDir, "farm-docs-roots", String(index)),
15207
- fs5
15748
+ path17.join(bundledRootDir, ...bundledRootPaths[index].split("/")),
15749
+ fs5,
15750
+ options
15208
15751
  );
15209
15752
  }
15210
15753
  }
15211
- async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs5) {
15754
+ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs5, { log = true } = {}) {
15212
15755
  const docsContentDir = resolveBuildDocsContentDir(docs, root, srcDir);
15213
15756
  if (!docsContentDir) return;
15214
15757
  const lastModifiedManifest = createFarmDocsLastModifiedManifest(docsContentDir, {
15215
15758
  fallback: "now"
15216
15759
  });
15217
15760
  const undatedPages = lastModifiedManifest.unknown?.length ?? 0;
15218
- if (undatedPages > 0) {
15761
+ if (log && undatedPages > 0) {
15219
15762
  logger.warn(
15220
15763
  `${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.`
15221
15764
  );
@@ -15232,7 +15775,9 @@ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs
15232
15775
  `${JSON.stringify(lastModifiedManifest, null, 2)}
15233
15776
  `
15234
15777
  );
15235
- logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path17.relative(root, docsContentDir)}`);
15778
+ if (log) {
15779
+ logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path17.relative(root, docsContentDir)}`);
15780
+ }
15236
15781
  }
15237
15782
  function resolveServerFunctionPlatform(preset) {
15238
15783
  return preset === "vercel" || preset === "netlify" ? { os: "linux", cpu: "x64", libc: "glibc" } : null;