@farm.js/core 0.1.37 → 0.1.39

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 (250) hide show
  1. package/dist/{agent-mcp-BC0bAGVF.d.mts → agent-mcp-BhneNPb4.d.mts} +1 -1
  2. package/dist/{agent-mcp-jyDHbQKe.d.ts → agent-mcp-HcTYQmNX.d.ts} +1 -1
  3. package/dist/{agent-mcp-handler-SJAHFSPI.cjs → agent-mcp-handler-MRGP3WJ3.cjs} +5 -5
  4. package/dist/{agent-mcp-handler-LPJ2CADR.mjs → agent-mcp-handler-OLRMZONF.mjs} +4 -4
  5. package/dist/agent-runtime.cjs +3 -3
  6. package/dist/agent-runtime.d.mts +1 -1
  7. package/dist/agent-runtime.d.ts +1 -1
  8. package/dist/agent-runtime.mjs +2 -2
  9. package/dist/api/client.cjs +3 -3
  10. package/dist/api/client.mjs +2 -2
  11. package/dist/api/route-manager.cjs +5 -5
  12. package/dist/api/route-manager.d.mts +3 -3
  13. package/dist/api/route-manager.d.ts +3 -3
  14. package/dist/api/route-manager.mjs +4 -4
  15. package/dist/api/runtime.cjs +4 -4
  16. package/dist/api/runtime.d.mts +2 -2
  17. package/dist/api/runtime.d.ts +2 -2
  18. package/dist/api/runtime.mjs +3 -3
  19. package/dist/api.cjs +7 -7
  20. package/dist/api.d.mts +3 -3
  21. package/dist/api.d.ts +3 -3
  22. package/dist/api.mjs +6 -6
  23. package/dist/{app-CKO3iN1c.d.ts → app-CMkoghtp.d.ts} +21 -3
  24. package/dist/{app-Cbkj9ufe.d.mts → app-DVzmmbNO.d.mts} +21 -3
  25. package/dist/app-markdown.cjs +4 -4
  26. package/dist/app-markdown.d.mts +2 -2
  27. package/dist/app-markdown.d.ts +2 -2
  28. package/dist/app-markdown.mjs +3 -3
  29. package/dist/chunk-2ZYGC6SS.cjs +576 -0
  30. package/dist/{chunk-75X755YZ.cjs → chunk-34UCJRQO.cjs} +2 -2
  31. package/dist/{chunk-CVH2BXPY.cjs → chunk-3LOLJTFV.cjs} +6 -6
  32. package/dist/{chunk-4GPOC4LN.cjs → chunk-472NCAZ7.cjs} +3 -3
  33. package/dist/{chunk-O6WAEAX3.mjs → chunk-5BWWFHR2.mjs} +70 -15
  34. package/dist/{chunk-6LGFV2CQ.cjs → chunk-5OKBARDN.cjs} +2 -2
  35. package/dist/{chunk-3IP27TCG.cjs → chunk-5PWXMJOH.cjs} +19 -19
  36. package/dist/{chunk-WT4TGLXT.cjs → chunk-5ULKUBIA.cjs} +6 -6
  37. package/dist/{chunk-WRPHYQVY.mjs → chunk-677THUVP.mjs} +1 -1
  38. package/dist/chunk-6BK3K2GB.mjs +318 -0
  39. package/dist/{chunk-HEVMCTSR.mjs → chunk-6HB6V3R7.mjs} +1 -1
  40. package/dist/{chunk-NICDYKBS.cjs → chunk-6XWDE2P2.cjs} +22 -4
  41. package/dist/{chunk-CXEN47J3.mjs → chunk-73WX6PRY.mjs} +25 -0
  42. package/dist/{chunk-EXG5LD6B.mjs → chunk-75HN5IZ3.mjs} +21 -9
  43. package/dist/{chunk-7O5M4UKW.cjs → chunk-A657YSP4.cjs} +2 -2
  44. package/dist/{chunk-LBDP3YT3.mjs → chunk-ARC7I3O2.mjs} +1 -1
  45. package/dist/{chunk-Q5FYSK45.cjs → chunk-AS2VPMEE.cjs} +640 -521
  46. package/dist/{chunk-Z5BEWYVO.mjs → chunk-ATSDUUFK.mjs} +27 -1
  47. package/dist/{chunk-EMMQ64QW.cjs → chunk-B5J2YVG7.cjs} +16 -16
  48. package/dist/{chunk-FWE7LEQC.cjs → chunk-BD3D7EZV.cjs} +4 -4
  49. package/dist/{chunk-Z7LA7MHQ.mjs → chunk-BFJTHYTN.mjs} +1 -1
  50. package/dist/{chunk-UJZLSXUB.cjs → chunk-BWIQR4DH.cjs} +30 -4
  51. package/dist/{chunk-W2YDNK66.cjs → chunk-BXDJXFQG.cjs} +4 -4
  52. package/dist/{chunk-MCIZVNOQ.mjs → chunk-BZHXGVMA.mjs} +1 -1
  53. package/dist/{chunk-7DWNJI73.cjs → chunk-CIOT4HGT.cjs} +37 -19
  54. package/dist/{chunk-KDTBF3UU.mjs → chunk-CNNOLE4O.mjs} +1 -1
  55. package/dist/{chunk-TDNWPAVR.mjs → chunk-CUM5NYL5.mjs} +1 -1
  56. package/dist/{chunk-HITLGIAO.cjs → chunk-CY2ZQ5C6.cjs} +7 -6
  57. package/dist/{chunk-KPFKMDM7.mjs → chunk-EGCTIS5F.mjs} +2 -2
  58. package/dist/{chunk-VR4GD5I3.cjs → chunk-EIPC3FDA.cjs} +12 -4
  59. package/dist/{chunk-B5PFZLKV.cjs → chunk-EKN7NSZO.cjs} +25 -8
  60. package/dist/{chunk-6SJ2KJTA.mjs → chunk-EPYU2EBL.mjs} +1 -1
  61. package/dist/{chunk-LBGILORX.mjs → chunk-GKBWWRBG.mjs} +101 -10
  62. package/dist/{chunk-PTZ2TVNE.cjs → chunk-H5CLOUZS.cjs} +5 -5
  63. package/dist/{chunk-DTSROJ5J.mjs → chunk-HD5CF3OE.mjs} +1 -1
  64. package/dist/{chunk-3A4KGQYI.cjs → chunk-HRETEZ2Z.cjs} +27 -15
  65. package/dist/{chunk-ATWHHSY2.cjs → chunk-HRSAQ23K.cjs} +7 -7
  66. package/dist/{chunk-IAIYV4RZ.mjs → chunk-HXRYZWTA.mjs} +1 -1
  67. package/dist/{chunk-4P6ULFMD.mjs → chunk-HYTZYOW2.mjs} +222 -103
  68. package/dist/{chunk-HMRSWN47.mjs → chunk-INL3THCU.mjs} +1 -1
  69. package/dist/{chunk-FBOJ55OM.mjs → chunk-IVLZZZEI.mjs} +1 -1
  70. package/dist/{chunk-ENLZ4R3Y.mjs → chunk-J7K2NZD6.mjs} +7 -6
  71. package/dist/{chunk-PMQHMWZU.cjs → chunk-JCYYXBAJ.cjs} +3 -3
  72. package/dist/{chunk-K3SAEIM3.mjs → chunk-KTSUBU2E.mjs} +2 -2
  73. package/dist/{chunk-LPFV45AY.cjs → chunk-LMPAPBUA.cjs} +19 -19
  74. package/dist/{chunk-EK4QAEFZ.cjs → chunk-LZESP4IR.cjs} +25 -0
  75. package/dist/{chunk-TW4GYDBJ.mjs → chunk-MLY2RP5R.mjs} +10 -2
  76. package/dist/{chunk-BHY547NB.cjs → chunk-NBBEQLOK.cjs} +9 -9
  77. package/dist/{chunk-WQ7T2263.mjs → chunk-OAHTRMIC.mjs} +3 -3
  78. package/dist/{chunk-HZFM2LWQ.mjs → chunk-P3PLW4FR.mjs} +34 -2
  79. package/dist/{chunk-UH6QN5NL.mjs → chunk-P664ZVTV.mjs} +2 -2
  80. package/dist/{chunk-TE2G5ION.cjs → chunk-PGZDEPTM.cjs} +88 -33
  81. package/dist/{chunk-3KGDJLJK.mjs → chunk-POSPE3IO.mjs} +19 -1
  82. package/dist/{chunk-FGRYBX5X.mjs → chunk-PVZE2JGJ.mjs} +2 -2
  83. package/dist/{chunk-TPLJVC7E.mjs → chunk-QFW2IH5E.mjs} +23 -6
  84. package/dist/{chunk-5BXGGEC7.cjs → chunk-QG775BRV.cjs} +17 -17
  85. package/dist/{chunk-S3VWVTVA.mjs → chunk-QRKIMN7T.mjs} +13 -1
  86. package/dist/chunk-QTXBII4Z.cjs +632 -0
  87. package/dist/{chunk-NQ6QFZWD.cjs → chunk-QUCXCDE2.cjs} +1 -1
  88. package/dist/{chunk-NFMDCAOS.mjs → chunk-QYMZOOC5.mjs} +3 -3
  89. package/dist/{chunk-CI6E3UOH.cjs → chunk-RG4A6LB2.cjs} +7 -7
  90. package/dist/{chunk-LOFKRKO7.cjs → chunk-RVXFINNS.cjs} +113 -22
  91. package/dist/{chunk-7SQ5SGYZ.cjs → chunk-RW63BOV7.cjs} +2 -2
  92. package/dist/{chunk-U6MPZ35Q.cjs → chunk-RWFLWR5J.cjs} +8 -8
  93. package/dist/{chunk-EUV4YR3V.cjs → chunk-SGBJ247Q.cjs} +18 -2
  94. package/dist/{chunk-J3ANCZKA.mjs → chunk-SKVTP5PR.mjs} +1 -1
  95. package/dist/{chunk-YCKO6FRS.mjs → chunk-SOP2EAA6.mjs} +1 -1
  96. package/dist/{chunk-ND2CWPOD.mjs → chunk-TS4JHGUJ.mjs} +1 -1
  97. package/dist/chunk-U6QLDL3G.mjs +576 -0
  98. package/dist/{chunk-OW67PDDS.cjs → chunk-ULASELLA.cjs} +13 -1
  99. package/dist/{chunk-4GWRFP22.cjs → chunk-UPJLHLJU.cjs} +35 -3
  100. package/dist/{chunk-WWIKMBRN.mjs → chunk-VNGH5MLF.mjs} +17 -1
  101. package/dist/{chunk-NNSAQX3U.mjs → chunk-VT4WFRHA.mjs} +1 -1
  102. package/dist/{chunk-JPNFPAZ4.mjs → chunk-VWBHM3F6.mjs} +2 -2
  103. package/dist/{chunk-ADOAUDQ6.cjs → chunk-VXEEATVD.cjs} +2 -2
  104. package/dist/{chunk-RRMVL6CJ.mjs → chunk-W36M2BQ4.mjs} +1 -1
  105. package/dist/{chunk-4WQ6PGSJ.cjs → chunk-WEW2JVA4.cjs} +4 -4
  106. package/dist/{chunk-4E5WBPEG.mjs → chunk-WFRT7JPX.mjs} +8 -533
  107. package/dist/{chunk-VXAWRDK7.mjs → chunk-WLL43JMO.mjs} +1 -1
  108. package/dist/chunk-WW46B6HA.cjs +318 -0
  109. package/dist/{chunk-D3C5LBQY.cjs → chunk-WXJLNP33.cjs} +2 -2
  110. package/dist/{chunk-NDILNQ4L.cjs → chunk-XKG2BLFN.cjs} +2 -2
  111. package/dist/{chunk-6TJITR2B.cjs → chunk-YFYUYWL7.cjs} +870 -751
  112. package/dist/{chunk-XOPOIFTJ.mjs → chunk-YKZRDB5Z.mjs} +25 -7
  113. package/dist/{chunk-K4I4O5TS.mjs → chunk-ZUPXLIGB.mjs} +790 -671
  114. package/dist/{chunk-G2TEB74S.cjs → chunk-ZXH4TS3F.cjs} +2 -2
  115. package/dist/{client-plugins-CV4eJ9De.d.mts → client-plugins-CsCuCLBz.d.mts} +58 -7
  116. package/dist/{client-plugins-C8DjftDF.d.ts → client-plugins-D0ke-Hc8.d.ts} +58 -7
  117. package/dist/client-plugins.d.mts +1 -1
  118. package/dist/client-plugins.d.ts +1 -1
  119. package/dist/client.cjs +7 -7
  120. package/dist/client.d.mts +5 -5
  121. package/dist/client.d.ts +5 -5
  122. package/dist/client.mjs +6 -6
  123. package/dist/config.d.mts +1 -1
  124. package/dist/config.d.ts +1 -1
  125. package/dist/{devtools-KVOY2TCZ.mjs → devtools-5AFIPVUJ.mjs} +8 -6
  126. package/dist/{devtools-JXFQNWSH.cjs → devtools-LW4QQ5J3.cjs} +9 -7
  127. package/dist/docs.cjs +12 -10
  128. package/dist/docs.d.mts +20 -2
  129. package/dist/docs.d.ts +20 -2
  130. package/dist/docs.mjs +11 -9
  131. package/dist/headers.cjs +6 -4
  132. package/dist/headers.d.mts +11 -1
  133. package/dist/headers.d.ts +11 -1
  134. package/dist/headers.mjs +5 -3
  135. package/dist/index.cjs +55 -42
  136. package/dist/index.d.mts +15 -15
  137. package/dist/index.d.ts +15 -15
  138. package/dist/index.mjs +55 -42
  139. package/dist/integrations.cjs +5 -3
  140. package/dist/integrations.d.mts +1 -1
  141. package/dist/integrations.d.ts +1 -1
  142. package/dist/integrations.mjs +4 -2
  143. package/dist/internal/app-markdown-runtime.cjs +3 -3
  144. package/dist/internal/app-markdown-runtime.d.mts +2 -2
  145. package/dist/internal/app-markdown-runtime.d.ts +2 -2
  146. package/dist/internal/app-markdown-runtime.mjs +2 -2
  147. package/dist/internal/build-runtime.cjs +30 -29
  148. package/dist/internal/build-runtime.d.mts +3 -3
  149. package/dist/internal/build-runtime.d.ts +3 -3
  150. package/dist/internal/build-runtime.mjs +29 -28
  151. package/dist/internal/cli-runtime.cjs +11 -9
  152. package/dist/internal/cli-runtime.mjs +10 -8
  153. package/dist/internal/client-error-overlay.cjs +4 -4
  154. package/dist/internal/client-error-overlay.mjs +1 -1
  155. package/dist/internal/compression-runtime.d.mts +1 -1
  156. package/dist/internal/compression-runtime.d.ts +1 -1
  157. package/dist/internal/config-runtime.cjs +9 -7
  158. package/dist/internal/config-runtime.d.mts +2 -2
  159. package/dist/internal/config-runtime.d.ts +2 -2
  160. package/dist/internal/config-runtime.mjs +8 -6
  161. package/dist/internal/docs-precompiled-runtime.cjs +19 -13
  162. package/dist/internal/docs-precompiled-runtime.d.mts +5 -0
  163. package/dist/internal/docs-precompiled-runtime.d.ts +5 -0
  164. package/dist/internal/docs-precompiled-runtime.mjs +14 -8
  165. package/dist/internal/infra-analytics-runtime.cjs +5 -5
  166. package/dist/internal/infra-analytics-runtime.mjs +3 -3
  167. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  168. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  169. package/dist/internal/production-node-env.cjs +6 -2
  170. package/dist/internal/production-node-env.d.mts +10 -1
  171. package/dist/internal/production-node-env.d.ts +10 -1
  172. package/dist/internal/production-node-env.mjs +5 -1
  173. package/dist/internal/production-runtime.cjs +38 -16
  174. package/dist/internal/production-runtime.d.mts +51 -11
  175. package/dist/internal/production-runtime.d.ts +51 -11
  176. package/dist/internal/production-runtime.mjs +40 -18
  177. package/dist/markdown.cjs +8 -2
  178. package/dist/markdown.d.mts +1 -1
  179. package/dist/markdown.d.ts +1 -1
  180. package/dist/markdown.mjs +7 -1
  181. package/dist/middleware.cjs +10 -8
  182. package/dist/middleware.d.mts +24 -4
  183. package/dist/middleware.d.ts +24 -4
  184. package/dist/middleware.mjs +10 -8
  185. package/dist/navigation.cjs +6 -6
  186. package/dist/navigation.d.mts +4 -4
  187. package/dist/navigation.d.ts +4 -4
  188. package/dist/navigation.mjs +5 -5
  189. package/dist/plugin.cjs +23 -22
  190. package/dist/plugin.d.mts +1 -1
  191. package/dist/plugin.d.ts +1 -1
  192. package/dist/plugin.mjs +22 -21
  193. package/dist/{production-runtime-C2kkrPVZ.d.ts → production-runtime-BaI3WHnV.d.ts} +1 -1
  194. package/dist/{production-runtime-Du_FHb2-.d.mts → production-runtime-DfRP0cV0.d.mts} +1 -1
  195. package/dist/query/client.cjs +8 -8
  196. package/dist/query/client.mjs +3 -3
  197. package/dist/{render-plan-BnnPTpus.d.ts → render-plan-CfIdJKAf.d.ts} +1 -1
  198. package/dist/{render-plan-Cgx7v8tJ.d.mts → render-plan-Dg8RBYFa.d.mts} +1 -1
  199. package/dist/renderer-client.cjs +5 -5
  200. package/dist/renderer-client.d.mts +3 -3
  201. package/dist/renderer-client.d.ts +3 -3
  202. package/dist/renderer-client.mjs +2 -2
  203. package/dist/renderer.d.mts +13 -4
  204. package/dist/renderer.d.ts +13 -4
  205. package/dist/{request-BNWr7r5e.d.ts → request-CEbHIIl4.d.ts} +4 -2
  206. package/dist/{request-sKayKcop.d.mts → request-DfE02G_A.d.mts} +4 -2
  207. package/dist/request.cjs +3 -3
  208. package/dist/request.d.mts +2 -2
  209. package/dist/request.d.ts +2 -2
  210. package/dist/request.mjs +2 -2
  211. package/dist/{route-rendering-DWFp3Yq4.d.mts → route-rendering-BHyOfXjD.d.mts} +1 -1
  212. package/dist/{route-rendering-Bx4Auw6Q.d.ts → route-rendering-C4oHbv6C.d.ts} +1 -1
  213. package/dist/{router-BK6K42Ij.d.mts → router-DwhA61SB.d.mts} +1 -1
  214. package/dist/{router-DnW_2tQi.d.ts → router-uRN_29Em.d.ts} +1 -1
  215. package/dist/routes.d.mts +1 -1
  216. package/dist/routes.d.ts +1 -1
  217. package/dist/{runtime-DJDaCMd_.d.mts → runtime-BEdHhN4C.d.mts} +1 -1
  218. package/dist/{runtime-CA3Ei5k_.d.ts → runtime-COk03hmx.d.ts} +1 -1
  219. package/dist/server-fn.cjs +3 -3
  220. package/dist/server-fn.mjs +2 -2
  221. package/dist/server-plugins.cjs +5 -5
  222. package/dist/server-plugins.d.mts +2 -2
  223. package/dist/server-plugins.d.ts +2 -2
  224. package/dist/server-plugins.mjs +4 -4
  225. package/dist/server-query.cjs +4 -4
  226. package/dist/server-query.mjs +3 -3
  227. package/dist/server.cjs +49 -48
  228. package/dist/server.d.mts +7 -7
  229. package/dist/server.d.ts +7 -7
  230. package/dist/server.mjs +27 -26
  231. package/dist/{spa-router-Mwbd7g2L.d.ts → spa-router-DrVOBVGg.d.ts} +2 -2
  232. package/dist/{spa-router-D6fUA4Rn.d.mts → spa-router-w4aFOuyn.d.mts} +2 -2
  233. package/dist/testing.cjs +5 -5
  234. package/dist/testing.d.mts +1 -1
  235. package/dist/testing.d.ts +1 -1
  236. package/dist/testing.mjs +4 -4
  237. package/dist/theme/server.cjs +4 -4
  238. package/dist/theme/server.mjs +3 -3
  239. package/dist/{utils-p9Hs-jCc.d.mts → utils-BtYehqeU.d.mts} +1 -1
  240. package/dist/{utils-BwVcAfUR.d.ts → utils-Dhuqwmd2.d.ts} +1 -1
  241. package/dist/version.cjs +2 -2
  242. package/dist/version.mjs +1 -1
  243. package/dist/vite.cjs +23 -22
  244. package/dist/vite.d.mts +1 -1
  245. package/dist/vite.d.ts +1 -1
  246. package/dist/vite.mjs +22 -21
  247. package/package.json +1 -1
  248. package/dist/chunk-655RLQQL.mjs +0 -43
  249. package/dist/chunk-MRMI32SN.cjs +0 -1157
  250. package/dist/chunk-MT763TDW.cjs +0 -43
@@ -28,6 +28,8 @@ import {
28
28
  createLateRedirectRecovery,
29
29
  createRouteDirectoryPattern,
30
30
  extractFarmFullDocument,
31
+ farmPathGuardCoversEndpoint,
32
+ farmPathGuardCoversPage,
31
33
  formatRouteSegment,
32
34
  getDefaultErrorStatusText,
33
35
  getRouteDirectoryDepth,
@@ -42,7 +44,7 @@ import {
42
44
  resolveFarmAppManifestInput,
43
45
  routeBoundaryCoversDirectory,
44
46
  stripRouteGroups
45
- } from "./chunk-LBGILORX.mjs";
47
+ } from "./chunk-GKBWWRBG.mjs";
46
48
  import {
47
49
  FARM_DEFAULT_MCP_PATH,
48
50
  collectFarmDefaultMCPPages,
@@ -50,7 +52,7 @@ import {
50
52
  farmConfigMountsMCP,
51
53
  isFarmDefaultMCPPathname,
52
54
  resolveFarmDefaultMCPServer
53
- } from "./chunk-UH6QN5NL.mjs";
55
+ } from "./chunk-P664ZVTV.mjs";
54
56
  import {
55
57
  isFarmPreviewDeploymentEnvironment
56
58
  } from "./chunk-BOYNDCZL.mjs";
@@ -73,12 +75,12 @@ import {
73
75
  import {
74
76
  _setDefaultFarmThemeConfig,
75
77
  getTheme
76
- } from "./chunk-TDNWPAVR.mjs";
78
+ } from "./chunk-CUM5NYL5.mjs";
77
79
  import {
78
80
  generateFarmDocsAdapterClientRuntime,
79
81
  getFarmDocsAdapterConfigModule,
80
82
  isSecretDocsConfigKey
81
- } from "./chunk-ENLZ4R3Y.mjs";
83
+ } from "./chunk-J7K2NZD6.mjs";
82
84
  import {
83
85
  resolveFarmDocsFontAssets,
84
86
  toFarmDocsPublicFontAssets
@@ -119,24 +121,27 @@ import {
119
121
  } from "./chunk-DAATZTKJ.mjs";
120
122
  import {
121
123
  FARM_PREVIEW_ROBOTS_TAG,
122
- addFarmCspNonceToScriptTags,
123
124
  createFarmAgentRobots,
124
- createFarmCspNonce,
125
- createFarmCspNonceRewriter,
126
125
  createFarmDefaultSitemap,
127
- getFarmSecurityHeader,
128
126
  resolveFarmAgentCrawlers,
129
127
  resolveFarmAgentSitemap,
130
- resolveFarmPerformanceConfig,
131
- resolveFarmSecurityConfig
132
- } from "./chunk-4E5WBPEG.mjs";
128
+ resolveFarmPerformanceConfig
129
+ } from "./chunk-WFRT7JPX.mjs";
133
130
  import {
134
131
  collectFarmLlmsTxtPages,
135
132
  createFarmDefaultLlmsTxt,
136
133
  createFarmLlmsMarkdownReader,
137
134
  renderFarmLlmsFullTxt,
138
135
  resolveFarmLlmsTxtConfig
139
- } from "./chunk-DTSROJ5J.mjs";
136
+ } from "./chunk-HD5CF3OE.mjs";
137
+ import {
138
+ createFarmCspNonce,
139
+ createFarmCspNonceRewriter,
140
+ filterFarmCspNonces,
141
+ getFarmSecurityHeader,
142
+ resolveFarmSecurityConfig,
143
+ stampFarmCspNonce
144
+ } from "./chunk-U6QLDL3G.mjs";
140
145
  import {
141
146
  getPublicFarmImageConfig,
142
147
  resolveFarmImageConfig
@@ -154,18 +159,20 @@ import {
154
159
  import {
155
160
  createFarmMarkdownRouteModuleFromFile,
156
161
  loadFarmMdxComponents
157
- } from "./chunk-FBOJ55OM.mjs";
162
+ } from "./chunk-IVLZZZEI.mjs";
158
163
  import {
159
164
  createFarmMarkdownSourceResponse,
160
165
  isFarmMarkdownPageFile,
161
166
  normalizeFarmMarkdownRoutePath
162
- } from "./chunk-TPLJVC7E.mjs";
167
+ } from "./chunk-QFW2IH5E.mjs";
163
168
  import {
164
169
  resolveFarmMdxComponentsModulePath,
165
170
  resolveMdxConfig
166
171
  } from "./chunk-FA2W42OV.mjs";
167
172
  import {
168
173
  FARM_MARKDOWN_CONTENT_TYPE,
174
+ FARM_MARKDOWN_PAGE_CHECK_HEADER,
175
+ _isFarmMarkdownPageCheck,
169
176
  createFarmMarkdownErrorBody,
170
177
  createMarkdownMirrorResponse,
171
178
  farmRequestWantsMarkdown,
@@ -173,7 +180,7 @@ import {
173
180
  getFarmMarkdownMirrorPath,
174
181
  resolveMarkdownConfig,
175
182
  resolveMarkdownMirrorTarget
176
- } from "./chunk-WWIKMBRN.mjs";
183
+ } from "./chunk-VNGH5MLF.mjs";
177
184
  import {
178
185
  resolveWorkflowsConfig
179
186
  } from "./chunk-Q2KB32T4.mjs";
@@ -196,10 +203,10 @@ import {
196
203
  getRegisteredIntegrationAPIManifest,
197
204
  isFarmIntegrationProviderComponentReference,
198
205
  matchIntegrationRoute
199
- } from "./chunk-Z5BEWYVO.mjs";
206
+ } from "./chunk-ATSDUUFK.mjs";
200
207
  import {
201
208
  MiddlewareManager
202
- } from "./chunk-NFMDCAOS.mjs";
209
+ } from "./chunk-QYMZOOC5.mjs";
203
210
  import {
204
211
  createRouteSlotContainerId,
205
212
  parseRouteSlotFile
@@ -209,7 +216,7 @@ import {
209
216
  _clearCurrentMiddlewareData,
210
217
  _runWithMiddlewareContext,
211
218
  _runWithMiddlewareData
212
- } from "./chunk-J3ANCZKA.mjs";
219
+ } from "./chunk-SKVTP5PR.mjs";
213
220
  import {
214
221
  createFarmDevServerDispatch
215
222
  } from "./chunk-SGBZPZUW.mjs";
@@ -221,7 +228,7 @@ import {
221
228
  } from "./chunk-IOEH4VWN.mjs";
222
229
  import {
223
230
  APIRouteManager
224
- } from "./chunk-VXAWRDK7.mjs";
231
+ } from "./chunk-WLL43JMO.mjs";
225
232
  import {
226
233
  findProgrammaticRouteFiles,
227
234
  loadProgrammaticRouteManifests
@@ -240,7 +247,7 @@ import {
240
247
  } from "./chunk-YOZYCI6Z.mjs";
241
248
  import {
242
249
  isFarmAPIPathname
243
- } from "./chunk-HEVMCTSR.mjs";
250
+ } from "./chunk-6HB6V3R7.mjs";
244
251
  import {
245
252
  registerFarmMCPServer
246
253
  } from "./chunk-ZLAT2CWY.mjs";
@@ -325,7 +332,7 @@ import {
325
332
  } from "./chunk-BTHHUD7Q.mjs";
326
333
  import {
327
334
  FARM_VERSION
328
- } from "./chunk-YCKO6FRS.mjs";
335
+ } from "./chunk-SOP2EAA6.mjs";
329
336
  import {
330
337
  resolveFarmTrailingSlashRedirect,
331
338
  setFarmTrailingSlashPreference
@@ -346,7 +353,7 @@ import {
346
353
  renderMetadataHead,
347
354
  renderViewportHead,
348
355
  resolveFarmNotFoundMetadata
349
- } from "./chunk-CXEN47J3.mjs";
356
+ } from "./chunk-73WX6PRY.mjs";
350
357
  import {
351
358
  FARM_DEPLOYMENT_ID_HEADER,
352
359
  createFarmDeploymentCookie,
@@ -363,7 +370,7 @@ import {
363
370
  } from "./chunk-CNOQY6Z7.mjs";
364
371
  import {
365
372
  FARM_CONFIG_REWRITES_PLUGIN_NAME
366
- } from "./chunk-HMRSWN47.mjs";
373
+ } from "./chunk-INL3THCU.mjs";
367
374
  import {
368
375
  appendFarmRedirectQuery
369
376
  } from "./chunk-BRYHOB4X.mjs";
@@ -375,13 +382,15 @@ import {
375
382
  import {
376
383
  _getRequestReadCount,
377
384
  _runWithCurrentRequest,
385
+ _runWithFarmCspNonce,
378
386
  createWebRequestFromFarmRequest,
379
387
  getCurrentRequestOrNull,
380
388
  resolveFarmRequestURL
381
- } from "./chunk-3KGDJLJK.mjs";
389
+ } from "./chunk-POSPE3IO.mjs";
382
390
  import {
391
+ _resolveCurrentCspNonce,
383
392
  _resolveCurrentRequest
384
- } from "./chunk-S3VWVTVA.mjs";
393
+ } from "./chunk-QRKIMN7T.mjs";
385
394
  import {
386
395
  localizeFarmHref,
387
396
  localizeFarmPathname,
@@ -4707,6 +4716,11 @@ function createPreHydrationClickQueueScript() {
4707
4716
  return `<script>(function(){if(window.__FARM_PREHYDRATION_CLICK_QUEUE__)return;var queue=[];window.__FARM_PREHYDRATION_CLICK_QUEUE__=queue;window.__FARM_HYDRATED__=false;document.documentElement.dataset.farmHydrated="false";function isModified(event){return !!(event.metaKey||event.altKey||event.ctrlKey||event.shiftKey)}function inHydrated(node){return !!(node&&node.closest&&node.closest('[data-farm-island-hydrated="true"]'))}function closestQueuedTarget(target){while(target&&target!==document.documentElement){if(target.matches&&target.matches(${selector}))return target;target=target.parentElement}return null}function announce(target,kind){document.dispatchEvent(new CustomEvent("farm:island-interaction",{detail:{target:target,kind:kind||null}}))}function hold(event,target,kind){if(!queue.some(function(item){return item.target===target})){queue.push({target:target,kind:kind,createdAt:Date.now()});announce(target,kind)}event.preventDefault();event.stopImmediatePropagation()}document.addEventListener("click",function(event){if(window.__FARM_HYDRATED__)return;if(event.defaultPrevented||event.button!==0||isModified(event))return;var target=closestQueuedTarget(event.target);if(!target||target.closest&&target.closest("a[href]")||inHydrated(target))return;hold(event,target,"click")},true);document.addEventListener("submit",function(event){if(window.__FARM_HYDRATED__)return;if(event.defaultPrevented)return;var form=event.target;if(!form||form.nodeName!=="FORM"||inHydrated(form))return;hold(event,form,"submit")},true);function observe(event){if(window.__FARM_HYDRATED__)return;var target=event.target;if(!(target&&target.closest)||inHydrated(target))return;announce(target,null)}document.addEventListener("pointerdown",observe,true);document.addEventListener("focusin",observe,true);})();</script>`;
4708
4717
  }
4709
4718
  __name(createPreHydrationClickQueueScript, "createPreHydrationClickQueueScript");
4719
+ function rendererRenderOptions() {
4720
+ const nonce = _resolveCurrentCspNonce();
4721
+ return nonce ? { nonce } : void 0;
4722
+ }
4723
+ __name(rendererRenderOptions, "rendererRenderOptions");
4710
4724
  function createDocumentFooter(options) {
4711
4725
  return `</div>
4712
4726
  ${options.suspenseRevealFallback}
@@ -4960,22 +4974,27 @@ var _ServerRenderer = class _ServerRenderer {
4960
4974
  }
4961
4975
  return this.rendererRuntime.wrapClientGraph(element);
4962
4976
  }
4963
- async renderElementToCompleteHTML(element) {
4977
+ async renderElementToCompleteHTML(element, options = {}) {
4964
4978
  const streaming = getFarmRendererStreamingCapabilitiesForRuntime(this.config.renderer, "node");
4965
4979
  const renderToPipeableStream = streaming.node ? this.rendererRuntime.renderToPipeableStream : void 0;
4966
4980
  if (renderToPipeableStream) {
4967
4981
  return await new Promise((resolve6, reject) => {
4968
4982
  const chunks = [];
4969
4983
  let started = false;
4984
+ let lateNavigation;
4970
4985
  const writable = new Writable({
4971
4986
  write(chunk, _encoding, callback) {
4972
4987
  chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
4973
4988
  callback();
4974
4989
  }
4975
4990
  });
4976
- writable.once("finish", () => resolve6(Buffer.concat(chunks).toString("utf8")));
4991
+ writable.once(
4992
+ "finish",
4993
+ () => lateNavigation === void 0 ? resolve6(Buffer.concat(chunks).toString("utf8")) : reject(lateNavigation)
4994
+ );
4977
4995
  writable.once("error", reject);
4978
4996
  const stream = renderToPipeableStream(element, {
4997
+ nonce: _resolveCurrentCspNonce(),
4979
4998
  onShellReady() {
4980
4999
  started = true;
4981
5000
  stream.pipe(writable);
@@ -4985,26 +5004,35 @@ var _ServerRenderer = class _ServerRenderer {
4985
5004
  },
4986
5005
  onError(error) {
4987
5006
  if (!started) reject(error);
5007
+ else if (options.rejectLateNavigation && lateNavigation === void 0 && (isFarmRedirectError(error) || isFarmNotFoundError(error))) {
5008
+ lateNavigation = error;
5009
+ }
4988
5010
  }
4989
5011
  });
4990
5012
  });
4991
5013
  }
4992
5014
  if (streaming.web && this.rendererRuntime.renderToReadableStream) {
4993
- const stream = await this.rendererRuntime.renderToReadableStream(element);
5015
+ const stream = await this.rendererRuntime.renderToReadableStream(
5016
+ element,
5017
+ rendererRenderOptions()
5018
+ );
4994
5019
  return await readFarmRendererWebStream(stream);
4995
5020
  }
4996
- return await this.rendererRuntime.renderToString(element);
5021
+ return await this.rendererRuntime.renderToString(element, rendererRenderOptions());
4997
5022
  }
4998
5023
  /**
4999
5024
  * Buffered render carrying document-head markup for renderers that emit it
5000
5025
  * during render (e.g. <svelte:head>). Other renderers return an empty head.
5001
5026
  */
5002
- async renderElementToDocumentParts(element) {
5027
+ async renderElementToDocumentParts(element, options = {}) {
5003
5028
  if (this.rendererRuntime.renderToStringWithHead) {
5004
- const rendered = await this.rendererRuntime.renderToStringWithHead(element);
5029
+ const rendered = await this.rendererRuntime.renderToStringWithHead(
5030
+ element,
5031
+ rendererRenderOptions()
5032
+ );
5005
5033
  return { html: rendered.html, head: rendered.head || "" };
5006
5034
  }
5007
- return { html: await this.renderElementToCompleteHTML(element), head: "" };
5035
+ return { html: await this.renderElementToCompleteHTML(element, options), head: "" };
5008
5036
  }
5009
5037
  /**
5010
5038
  * Render the route tree used by client navigation without producing a second
@@ -5373,7 +5401,10 @@ var _ServerRenderer = class _ServerRenderer {
5373
5401
  return;
5374
5402
  }
5375
5403
  }
5376
- return this.runWithRequestContext(request2, () => this.renderPageInContext(req, res));
5404
+ return _runWithFarmCspNonce(
5405
+ cspNonce,
5406
+ () => this.runWithRequestContext(request2, () => this.renderPageInContext(req, res))
5407
+ );
5377
5408
  }
5378
5409
  async renderPageInContext(req, res) {
5379
5410
  const renderStartTime = Date.now();
@@ -6283,7 +6314,7 @@ var _ServerRenderer = class _ServerRenderer {
6283
6314
  trustProxy: this.config.server?.trustProxy
6284
6315
  });
6285
6316
  const sources = await Promise.all(
6286
- [...this.routeManager.getRoutes()].filter(([pattern]) => !pattern.includes("[")).map(async ([pattern, route]) => {
6317
+ this.getAgentListedRoutes().map(async ([pattern, route]) => {
6287
6318
  const [module, stat] = await Promise.all([
6288
6319
  this.routeManager.loadRouteModule(route.modulePath).catch((error) => {
6289
6320
  logger.warn(`Could not read metadata for ${pattern} in sitemap.xml: ${error}`);
@@ -6321,6 +6352,21 @@ var _ServerRenderer = class _ServerRenderer {
6321
6352
  setAPIRouteLookup(exists) {
6322
6353
  this.apiRouteExists = exists;
6323
6354
  }
6355
+ /** The dev server's file middleware, so public page listings can leave guarded pages out. */
6356
+ setMiddlewareRouteLookup(routes) {
6357
+ this.middlewareRoutes = routes;
6358
+ }
6359
+ /**
6360
+ * The static pages sitemap.xml, llms.txt and the default MCP server may list: not one a
6361
+ * path-specific guard (non-root middleware.ts, a config or integration middleware
6362
+ * matcher) covers, as the production build decides.
6363
+ */
6364
+ getAgentListedRoutes() {
6365
+ const guards = { config: this.config, middlewareRoutes: this.middlewareRoutes?.() ?? [] };
6366
+ return [...this.routeManager.getRoutes()].filter(
6367
+ ([pattern]) => !pattern.includes("[") && !farmPathGuardCoversPage(guards, pattern)
6368
+ );
6369
+ }
6324
6370
  /**
6325
6371
  * The default read-only MCP server (`agent.mcp`), or undefined when the app has an MCP
6326
6372
  * server of its own: a route that answers /mcp, an API route at /api/mcp, `@farm.js/mcp`,
@@ -6340,14 +6386,14 @@ var _ServerRenderer = class _ServerRenderer {
6340
6386
  const server = this.getDefaultMCPServer();
6341
6387
  const request2 = getCurrentRequestOrNull() ?? createWebRequestFromFarmRequest(req, { trustProxy: this.config.server?.trustProxy });
6342
6388
  try {
6343
- const { handleFarmDefaultMCPRequest } = await import("./agent-mcp-handler-LPJ2CADR.mjs");
6389
+ const { handleFarmDefaultMCPRequest } = await import("./agent-mcp-handler-OLRMZONF.mjs");
6344
6390
  const origin = new URL(request2.url).origin;
6345
6391
  const response = await handleFarmDefaultMCPRequest(request2, {
6346
6392
  server,
6347
6393
  basePath: this.config.basePath,
6348
6394
  listPages: /* @__PURE__ */ __name(async () => {
6349
6395
  const sources = await Promise.all(
6350
- [...this.routeManager.getRoutes()].filter(([pattern]) => !pattern.includes("[")).map(async ([pattern, route]) => ({
6396
+ this.getAgentListedRoutes().map(async ([pattern, route]) => ({
6351
6397
  pattern,
6352
6398
  // The page itself surfaces a load error. Without its module a guard cannot
6353
6399
  // be ruled out, so the page is left out.
@@ -6383,14 +6429,12 @@ var _ServerRenderer = class _ServerRenderer {
6383
6429
  async createLlmsTxtContext(request2, options = {}) {
6384
6430
  const config = resolveFarmLlmsTxtConfig(this.config.agent?.llmsTxt);
6385
6431
  const origin = new URL(request2.url).origin;
6386
- const staticRoutes = [...this.routeManager.getRoutes()].filter(
6387
- ([pattern]) => !pattern.includes("[")
6388
- );
6389
6432
  const sources = await Promise.all(
6390
- staticRoutes.map(async ([pattern, route]) => {
6433
+ this.getAgentListedRoutes().map(async ([pattern, route]) => {
6391
6434
  try {
6392
- const metadata = (await this.routeManager.loadRouteModule(route.modulePath)).metadata;
6393
- return { pattern, metadata };
6435
+ const module = await this.routeManager.loadRouteModule(route.modulePath);
6436
+ if (module.__farmRouteGuard) return null;
6437
+ return { pattern, metadata: module.metadata };
6394
6438
  } catch (error) {
6395
6439
  logger.warn(`Could not read metadata for ${pattern} in llms.txt: ${error}`);
6396
6440
  return { pattern };
@@ -6399,13 +6443,16 @@ var _ServerRenderer = class _ServerRenderer {
6399
6443
  );
6400
6444
  const rootLayout = this.routeManager.getLayouts().get("/");
6401
6445
  const rootMetadata = rootLayout ? (await this.routeManager.loadLayoutModule(rootLayout.modulePath)).metadata : void 0;
6402
- const pages = collectFarmLlmsTxtPages(sources, {
6403
- origin,
6404
- basePath: this.config.basePath,
6405
- markdown: resolveMarkdownConfig(this.config.md),
6406
- include: config.include,
6407
- exclude: config.exclude
6408
- });
6446
+ const pages = collectFarmLlmsTxtPages(
6447
+ sources.filter((source) => source !== null),
6448
+ {
6449
+ origin,
6450
+ basePath: this.config.basePath,
6451
+ markdown: resolveMarkdownConfig(this.config.md),
6452
+ include: config.include,
6453
+ exclude: config.exclude
6454
+ }
6455
+ );
6409
6456
  return {
6410
6457
  pages,
6411
6458
  defaults: createFarmDefaultLlmsTxt({
@@ -6567,7 +6614,7 @@ var _ServerRenderer = class _ServerRenderer {
6567
6614
  options.middlewareMap,
6568
6615
  () => _runWithMiddlewareContext(
6569
6616
  options.middlewareContext,
6570
- () => this.rendererRuntime.renderToString(wrapped)
6617
+ () => this.rendererRuntime.renderToString(wrapped, rendererRenderOptions())
6571
6618
  )
6572
6619
  );
6573
6620
  res.statusCode = options.statusCode;
@@ -6657,7 +6704,8 @@ var _ServerRenderer = class _ServerRenderer {
6657
6704
  const pagePath = req.__FARM_PAGE_PATH__;
6658
6705
  const relativePath = pagePath ? toViteModuleId(pagePath, this.config.root) : "/src/app/page.tsx";
6659
6706
  const deploymentId = this.getDeploymentId();
6660
- const bootstrapScript = `<script data-farm-refresh-state>
6707
+ const farmScripts = /* @__PURE__ */ __name((markup) => this.stampFarmScripts(req, markup), "farmScripts");
6708
+ const bootstrapScript = farmScripts(`<script data-farm-refresh-state>
6661
6709
  window.__FARM_PROPS__ = ${serializeInlineValue(deferredProps.data.page)};
6662
6710
  window.__FARM_ROUTE_SLOTS__ = ${serializeInlineValue(deferredProps.data.slots)};
6663
6711
  window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue(deploymentId)};
@@ -6676,10 +6724,23 @@ window.__FARM_LOADING_MODULE__ = ${JSON.stringify(req.__FARM_LOADING_MODULE_PATH
6676
6724
  window.__FARM_MANIFEST__ = ${JSON.stringify(clientManifest)};
6677
6725
  window.__FARM_INTEGRATION_API_MANIFEST__ = ${JSON.stringify(getRegisteredIntegrationAPIManifest())};
6678
6726
  window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getFarmI18nClientSnapshot()) : "null"};
6679
- </script>`;
6680
- const deferredScript = createDeferredHydrationScript(deferredProps.records);
6681
- const rendererHydrationScript = this.rendererRuntime.generateHydrationScript?.() || "";
6682
- const { html: content, head: rendererHead } = await this.renderElementToDocumentParts(element);
6727
+ </script>`);
6728
+ const deferredScript = farmScripts(createDeferredHydrationScript(deferredProps.records));
6729
+ const rendererHydrationScript = farmScripts(
6730
+ this.rendererRuntime.generateHydrationScript?.() || ""
6731
+ );
6732
+ const viteClientScript = farmScripts(`<script type="module" src="/@vite/client"></script>`);
6733
+ const farmClientScript = farmScripts(
6734
+ `<script type="module" src="/@farm/client.js"></script>`
6735
+ );
6736
+ const { html: content, head: rendererHead } = await this.renderElementToDocumentParts(
6737
+ element,
6738
+ {
6739
+ rejectLateNavigation: _isFarmMarkdownPageCheck(
6740
+ req.headers?.[FARM_MARKDOWN_PAGE_CHECK_HEADER]
6741
+ )
6742
+ }
6743
+ );
6683
6744
  const {
6684
6745
  title,
6685
6746
  tags: metaTags,
@@ -6703,6 +6764,7 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6703
6764
  this.config.basePath,
6704
6765
  getTheme()
6705
6766
  );
6767
+ themeDocument.head = farmScripts(themeDocument.head);
6706
6768
  const fullDocument = extractFarmFullDocument(content);
6707
6769
  let html;
6708
6770
  if (fullDocument) {
@@ -6727,11 +6789,11 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6727
6789
  renderFarmFontDevHead(this.config.root || process.cwd()),
6728
6790
  this.devGlobalStylesheetLink(),
6729
6791
  ...this.collectDevStyleLinks(),
6730
- `<script type="module" src="/@vite/client"></script>`,
6792
+ viteClientScript,
6731
6793
  rendererHydrationScript,
6732
6794
  bootstrapScript
6733
6795
  ].filter(Boolean).join("\n "),
6734
- bodyFooter: [deferredScript, `<script type="module" src="/@farm/client.js"></script>`].filter(Boolean).join("\n ")
6796
+ bodyFooter: [deferredScript, farmClientScript].filter(Boolean).join("\n ")
6735
6797
  });
6736
6798
  } else {
6737
6799
  html = `<!DOCTYPE html>
@@ -6747,14 +6809,14 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6747
6809
  ${renderFarmFontDevHead(this.config.root || process.cwd())}
6748
6810
  ${this.devGlobalStylesheetLink()}${this.collectDevStyleLinks().map((l) => `
6749
6811
  ${l}`).join("")}
6750
- <script type="module" src="/@vite/client"></script>
6812
+ ${viteClientScript}
6751
6813
  ${rendererHydrationScript}
6752
6814
  ${bootstrapScript}
6753
6815
  </head>
6754
6816
  <body class="">
6755
6817
  <div id="root">${content}</div>
6756
6818
  ${deferredScript}
6757
- <script type="module" src="/@farm/client.js"></script>
6819
+ ${farmClientScript}
6758
6820
  </body>
6759
6821
  </html>`;
6760
6822
  }
@@ -6815,7 +6877,7 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6815
6877
  async renderWithSSR(element, req, res, clearMiddlewareData, options = {}) {
6816
6878
  const renderToPipeableStream = this.rendererRuntime.renderToPipeableStream;
6817
6879
  const fullDocumentRouteKey = options.observabilityRoute || req.__FARM_ROUTE__ || req.url || "/";
6818
- if (!renderToPipeableStream || fullDocumentRoutes.has(fullDocumentRouteKey) || await this.rootLayoutRendersDocument()) {
6880
+ if (!renderToPipeableStream || _isFarmMarkdownPageCheck(req.headers?.[FARM_MARKDOWN_PAGE_CHECK_HEADER]) || fullDocumentRoutes.has(fullDocumentRouteKey) || await this.rootLayoutRendersDocument()) {
6819
6881
  return this.renderBufferedSSR(element, req, res, clearMiddlewareData, options);
6820
6882
  }
6821
6883
  return new Promise((resolve6, reject) => {
@@ -6946,7 +7008,8 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6946
7008
  const devStyleLinks = this.collectDevStyleLinks();
6947
7009
  const globalStylesheetLink = this.devGlobalStylesheetLink(true);
6948
7010
  const cspNonce = this.getCspNonce(req);
6949
- const secureDocumentHTML = /* @__PURE__ */ __name((html) => cspNonce ? addFarmCspNonceToScriptTags(html, cspNonce) : html, "secureDocumentHTML");
7011
+ const stampDocumentHTML = /* @__PURE__ */ __name((html) => stampFarmCspNonce(html, cspNonce || ""), "stampDocumentHTML");
7012
+ const filterDocumentHTML = /* @__PURE__ */ __name((html) => cspNonce ? filterFarmCspNonces(html, cspNonce) : html, "filterDocumentHTML");
6950
7013
  const createLateNavigationRecovery = /* @__PURE__ */ __name((navigationError) => this.createLateNavigationRecoveryHTML(req, navigationError), "createLateNavigationRecovery");
6951
7014
  const { pipe, abort } = renderToPipeableStream(streamRoot, {
6952
7015
  nonce: cspNonce,
@@ -6987,7 +7050,7 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6987
7050
  </head>
6988
7051
  <body class="">
6989
7052
  <div id="root">`;
6990
- const securedShell = secureDocumentHTML(shell);
7053
+ const securedShell = stampDocumentHTML(shell);
6991
7054
  htmlParts.push(securedShell);
6992
7055
  staticShellParts?.push(securedShell);
6993
7056
  let firstChunk = true;
@@ -7045,7 +7108,7 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
7045
7108
  lateNavigationError = null;
7046
7109
  createLateNavigationRecovery(navigationError).then(
7047
7110
  (recovery) => {
7048
- const secured = secureDocumentHTML(recovery);
7111
+ const secured = filterDocumentHTML(recovery);
7049
7112
  htmlParts.push(secured);
7050
7113
  res.write(secured);
7051
7114
  finishStream(callback);
@@ -7067,7 +7130,7 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
7067
7130
  if (tail) res.write(tail);
7068
7131
  }
7069
7132
  const suspenseRevealFallback = `<script>(function(){function moveFragment(srcId,placeholderId){var src=document.getElementById(srcId),ph=document.getElementById(placeholderId);if(!src||!ph||!ph.parentNode)return false;while(src.firstChild)ph.parentNode.insertBefore(src.firstChild,ph);ph.parentNode.removeChild(ph);if(src.parentNode)src.parentNode.removeChild(src);return true}function revealBoundary(boundaryId,sectionId){var boundary=document.getElementById(boundaryId),section=document.getElementById(sectionId);if(!boundary||!section||!boundary.parentNode)return false;var start=boundary.previousSibling;if(!start||start.nodeType!==8)return false;var parent=boundary.parentNode;var node=boundary;var depth=0;while(node){if(node.nodeType===8){var data=node.data;if(data==="/$"||data==="/&"){if(depth===0)break;depth--;}else if(data==="$"||data==="$?"||data==="$~"||data==="$!"||data==="&"){depth++;}}var next=node.nextSibling;parent.removeChild(node);node=next;}while(section.firstChild)parent.insertBefore(section.firstChild,node);if(section.parentNode)section.parentNode.removeChild(section);start.data="$";return true}var tries=0;var timer=setInterval(function(){var changed=false;document.querySelectorAll('div[id^="S:"]').forEach(function(section){var suffix=section.id.slice(2);changed=moveFragment('S:'+suffix,'P:'+suffix)||changed;});document.querySelectorAll('template[id^="B:"]').forEach(function(boundary){var suffix=boundary.id.slice(2);changed=revealBoundary('B:'+suffix,'S:'+suffix)||changed;});tries++;if(tries>80||(!document.querySelector('template[id^="B:"]')&&!document.querySelector('template[id^="P:"]'))){clearInterval(timer);}},50);})();</script>`;
7070
- const footer = secureDocumentHTML(
7133
+ const footer = stampDocumentHTML(
7071
7134
  createDocumentFooter({
7072
7135
  suspenseRevealFallback,
7073
7136
  deferredHydrationScript: createDeferredHydrationScript(deferredProps.records)
@@ -7196,7 +7259,10 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
7196
7259
  */
7197
7260
  async createLateNavigationRecoveryHTML(req, error) {
7198
7261
  if (isFarmRedirectError(error)) {
7199
- return createLateRedirectRecovery(this.localizeRedirectUrl(getFarmRedirectError(error).url));
7262
+ return createLateRedirectRecovery(
7263
+ this.localizeRedirectUrl(getFarmRedirectError(error).url),
7264
+ this.getCspNonce(req) || ""
7265
+ );
7200
7266
  }
7201
7267
  const pathname = resolveFarmRequestURL(req, {
7202
7268
  trustProxy: this.config.server?.trustProxy
@@ -7208,13 +7274,14 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
7208
7274
  content = await this.rendererRuntime.renderToString(
7209
7275
  await this.wrapWithIntegrationProviders(
7210
7276
  this.rendererRuntime.createElement(NotFoundComponent, { pathname })
7211
- )
7277
+ ),
7278
+ rendererRenderOptions()
7212
7279
  );
7213
7280
  } catch (error2) {
7214
7281
  logger.warn(`not-found page could not render outside its layout, using Farm's: ${error2}`);
7215
7282
  }
7216
7283
  }
7217
- return createLateNotFoundRecovery(content);
7284
+ return createLateNotFoundRecovery(content, this.getCspNonce(req) || "");
7218
7285
  }
7219
7286
  async render404(req, res) {
7220
7287
  res.statusCode = 404;
@@ -7257,7 +7324,10 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
7257
7324
  });
7258
7325
  }
7259
7326
  element = await this.wrapWithIntegrationProviders(element);
7260
- const content = await this.rendererRuntime.renderToString(element);
7327
+ const content = await this.rendererRuntime.renderToString(
7328
+ element,
7329
+ rendererRenderOptions()
7330
+ );
7261
7331
  const { head: head2, metadata: metadata2 } = await this.notFoundMetadataHead(layoutModule, notFoundModule);
7262
7332
  const html2 = this.createFullHTML(content, false, pathname, head2, { req, metadata: metadata2 });
7263
7333
  res.setHeader("Content-Type", "text/html; charset=utf-8");
@@ -7290,20 +7360,23 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
7290
7360
  });
7291
7361
  const diagnostics = isDev ? createDefaultErrorDiagnostics(error, this.config.root || process.cwd()) : void 0;
7292
7362
  const statusText = getDefaultErrorStatusText(statusCode);
7293
- const content = createDefaultErrorMarkup({
7294
- statusCode,
7295
- statusText,
7296
- requestPath: requestUrl.pathname,
7297
- method: req.method || "GET",
7298
- message: diagnostics?.message,
7299
- errorName: diagnostics?.name,
7300
- stack: diagnostics?.stack,
7301
- sourceFrame: diagnostics?.sourceFrame,
7302
- development: isDev,
7303
- farmVersion: FARM_VERSION,
7304
- nodeVersion: process.version,
7305
- mode: isDev ? "development" : "production"
7306
- });
7363
+ const content = this.stampFarmScripts(
7364
+ req,
7365
+ createDefaultErrorMarkup({
7366
+ statusCode,
7367
+ statusText,
7368
+ requestPath: requestUrl.pathname,
7369
+ method: req.method || "GET",
7370
+ message: diagnostics?.message,
7371
+ errorName: diagnostics?.name,
7372
+ stack: diagnostics?.stack,
7373
+ sourceFrame: diagnostics?.sourceFrame,
7374
+ development: isDev,
7375
+ farmVersion: FARM_VERSION,
7376
+ nodeVersion: process.version,
7377
+ mode: isDev ? "development" : "production"
7378
+ })
7379
+ );
7307
7380
  const html = this.createFullHTML(
7308
7381
  content,
7309
7382
  false,
@@ -7331,12 +7404,14 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
7331
7404
  }
7332
7405
  createFullHTML(content, isClientComponent = false, requestPath = "/", metadataHead, alternates = {}) {
7333
7406
  const i18nSnapshot = getFarmI18nClientSnapshot();
7334
- const clientScript = isClientComponent ? ` <script type="module" src="/@farm/client.js"></script>` : "";
7335
- const integrationManifestScript = `<script>
7407
+ const farmScripts = /* @__PURE__ */ __name((html) => this.stampFarmScripts(alternates.req, html), "farmScripts");
7408
+ const clientScript = isClientComponent ? ` ${farmScripts(`<script type="module" src="/@farm/client.js"></script>`)}` : "";
7409
+ const viteClientScript = farmScripts(`<script type="module" src="/@vite/client"></script>`);
7410
+ const integrationManifestScript = farmScripts(`<script>
7336
7411
  window.__FARM_DEPLOYMENT_ID__ = ${serializeInlineValue(this.getDeploymentId())};
7337
7412
  window.__FARM_INTEGRATION_API_MANIFEST__ = ${JSON.stringify(getRegisteredIntegrationAPIManifest())};
7338
7413
  ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue(i18nSnapshot)};` : ""}
7339
- </script>`;
7414
+ </script>`);
7340
7415
  const alternateLinks = i18nSnapshot ? renderI18nAlternateLinks(
7341
7416
  requestPath,
7342
7417
  i18nSnapshot,
@@ -7348,7 +7423,10 @@ ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue(i18nSnapshot)};`
7348
7423
  this.config.basePath,
7349
7424
  getTheme()
7350
7425
  );
7351
- const rendererHydrationScript = this.rendererRuntime.generateHydrationScript?.() || "";
7426
+ themeDocument.head = farmScripts(themeDocument.head);
7427
+ const rendererHydrationScript = farmScripts(
7428
+ this.rendererRuntime.generateHydrationScript?.() || ""
7429
+ );
7352
7430
  const viewportTags = renderViewportHead(alternates.metadata?.viewport);
7353
7431
  const fullDocument = extractFarmFullDocument(content);
7354
7432
  if (fullDocument) {
@@ -7370,7 +7448,7 @@ ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue(i18nSnapshot)};`
7370
7448
  fontHead,
7371
7449
  this.devGlobalStylesheetLink(true),
7372
7450
  ...this.collectDevStyleLinks(),
7373
- `<script type="module" src="/@vite/client"></script>`,
7451
+ viteClientScript,
7374
7452
  rendererHydrationScript,
7375
7453
  integrationManifestScript
7376
7454
  ].filter(Boolean).join("\n "),
@@ -7389,7 +7467,7 @@ ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue(i18nSnapshot)};`
7389
7467
  ${fontHead}
7390
7468
  ${this.devGlobalStylesheetLink(true)}${this.collectDevStyleLinks().map((l) => `
7391
7469
  ${l}`).join("")}
7392
- <script type="module" src="/@vite/client"></script>
7470
+ ${viteClientScript}
7393
7471
  ${rendererHydrationScript}
7394
7472
  ${integrationManifestScript}
7395
7473
  </head>
@@ -7403,9 +7481,18 @@ ${clientScript}
7403
7481
  const value = req.__FARM_CSP_NONCE__;
7404
7482
  return typeof value === "string" ? value : void 0;
7405
7483
  }
7484
+ /** Stamp the response nonce on markup Farm generates (never on rendered app output). */
7485
+ stampFarmScripts(req, html) {
7486
+ return stampFarmCspNonce(html, req && this.getCspNonce(req) || "");
7487
+ }
7488
+ /**
7489
+ * The last pass over a document that holds rendered app output: scripts
7490
+ * keep the response nonce only when Farm or the app (through getCspNonce())
7491
+ * gave it to them.
7492
+ */
7406
7493
  secureDocumentHTML(req, html) {
7407
7494
  const nonce = this.getCspNonce(req);
7408
- return nonce ? addFarmCspNonceToScriptTags(html, nonce) : html;
7495
+ return nonce ? filterFarmCspNonces(html, nonce) : html;
7409
7496
  }
7410
7497
  applyDeploymentHeaders(req, res) {
7411
7498
  const deploymentId = this.getDeploymentId();
@@ -9349,19 +9436,23 @@ function unwrapFarmDocumentElement(node) {
9349
9436
  });
9350
9437
  }
9351
9438
 
9439
+ function farmLayoutBoundaryElement(pattern, content) {
9440
+ return React.createElement(
9441
+ "div",
9442
+ {
9443
+ "data-farm-layout-boundary": "true",
9444
+ "data-farm-layout-pattern": pattern,
9445
+ style: { display: "contents" },
9446
+ },
9447
+ content,
9448
+ );
9449
+ }
9450
+
9352
9451
  function FarmLayoutBoundary(props) {
9353
9452
  const Component = props.component;
9354
9453
  const layoutProps = { children: props.children, params: props.params };
9355
9454
  const boundary = function (content) {
9356
- return React.createElement(
9357
- "div",
9358
- {
9359
- "data-farm-layout-boundary": "true",
9360
- "data-farm-layout-pattern": props.pattern,
9361
- style: { display: "contents" },
9362
- },
9363
- content,
9364
- );
9455
+ return farmLayoutBoundaryElement(props.pattern, content);
9365
9456
  };
9366
9457
  const isPlainFunction =
9367
9458
  typeof Component === "function" &&
@@ -9377,6 +9468,12 @@ function FarmLayoutBoundary(props) {
9377
9468
  }
9378
9469
 
9379
9470
  function createFarmLayoutElement(Component, pattern, children, params) {
9471
+ if (typeof React.markFunctionComponent === "function") {
9472
+ return farmLayoutBoundaryElement(
9473
+ pattern,
9474
+ React.createElement(Component, { children: children, params: params }),
9475
+ );
9476
+ }
9380
9477
  return React.createElement(
9381
9478
  FarmLayoutBoundary,
9382
9479
  { key: farmLayoutComponentKey(Component), component: Component, pattern: pattern, params: params },
@@ -10164,7 +10261,7 @@ function loadFarmWorkflowsDevRuntime() {
10164
10261
  }
10165
10262
  __name(loadFarmWorkflowsDevRuntime, "loadFarmWorkflowsDevRuntime");
10166
10263
  function loadFarmDevtoolsSnapshotRuntime() {
10167
- return import("./devtools-KVOY2TCZ.mjs");
10264
+ return import("./devtools-5AFIPVUJ.mjs");
10168
10265
  }
10169
10266
  __name(loadFarmDevtoolsSnapshotRuntime, "loadFarmDevtoolsSnapshotRuntime");
10170
10267
  function loadFarmDevtoolsUIRuntime() {
@@ -11128,6 +11225,9 @@ function farmPlugin(options = {}, initialPluginManager) {
11128
11225
  apiServerBasePath
11129
11226
  );
11130
11227
  await middlewareManager.discover();
11228
+ farmApp.getServerRenderer().setMiddlewareRouteLookup(
11229
+ () => middlewareManager.getMiddlewares().filter((entry) => entry.source !== "config")
11230
+ );
11131
11231
  if (pm) {
11132
11232
  for (const middleware of middlewareManager.getMiddlewares()) {
11133
11233
  await pm.runHookParallel("middlewareDiscovered", {
@@ -11169,6 +11269,13 @@ function farmPlugin(options = {}, initialPluginManager) {
11169
11269
  return resolveFarmLayoutFonts(layoutModules);
11170
11270
  }, "resolveDocsLayoutFonts");
11171
11271
  releaseDocsMCPServers();
11272
+ const isFarmDocsPathGuarded = /* @__PURE__ */ __name((href) => farmPathGuardCoversPage(
11273
+ {
11274
+ config: farmConfig,
11275
+ middlewareRoutes: middlewareManager.getMiddlewares().filter((entry) => entry.source !== "config")
11276
+ },
11277
+ href
11278
+ ), "isFarmDocsPathGuarded");
11172
11279
  const farmDocsHandler = farmDocsDevRuntime ? farmDocsDevRuntime.hasFarmDocsRuntimeAdapter(farmConfig.docs) ? await farmDocsDevRuntime.createFarmDocsAdapterHandler(farmConfig.docs, {
11173
11280
  root: farmConfig.root,
11174
11281
  srcDir: farmConfig.srcDir,
@@ -11196,7 +11303,8 @@ function farmPlugin(options = {}, initialPluginManager) {
11196
11303
  docsMCPServerDisposers.delete(dispose);
11197
11304
  dispose();
11198
11305
  };
11199
- }, "registerMCPServer")
11306
+ }, "registerMCPServer"),
11307
+ isPathGuarded: isFarmDocsPathGuarded
11200
11308
  }) : farmDocsDevRuntime.createFarmDocsHandler(farmConfig.docs, {
11201
11309
  root: farmConfig.root,
11202
11310
  srcDir: farmConfig.srcDir,
@@ -11207,7 +11315,8 @@ function farmPlugin(options = {}, initialPluginManager) {
11207
11315
  globalStylesheetHref: resolveDevGlobalStylesheetHref(
11208
11316
  farmConfig.root,
11209
11317
  farmConfig.srcDir
11210
- )
11318
+ ),
11319
+ isPathGuarded: isFarmDocsPathGuarded
11211
11320
  }) : null;
11212
11321
  const wrapFarmDocsResponseWithLayouts = /* @__PURE__ */ __name(async (request2, response) => {
11213
11322
  if (request2.method === "HEAD" || response.headers.has("x-farm-docs-adapter") || !response.headers.get("content-type")?.toLowerCase().includes("text/html")) {
@@ -11315,7 +11424,8 @@ window.__FARM_MANIFEST__ = ${inlineValue({
11315
11424
  rootDir: farmConfig.root,
11316
11425
  srcDir: farmConfig.srcDir,
11317
11426
  docs: farmConfig.docs,
11318
- diagnostics: true
11427
+ diagnostics: true,
11428
+ isPathGuarded: isFarmDocsPathGuarded
11319
11429
  }) : null;
11320
11430
  const farmDocsFontAssets = new Map(
11321
11431
  farmDocsFontAssetList.map(({ url, sourcePath }) => [url, sourcePath])
@@ -11509,7 +11619,16 @@ window.__FARM_MANIFEST__ = ${inlineValue({
11509
11619
  // Read again on each request; unchanged files come from a cache.
11510
11620
  webmcpTools: farmConfig.plugins?.some(({ name }) => name === "farm:webmcp") ? collectFarmWebMCPTools(farmConfig.root ?? process.cwd(), farmConfig.srcDir) : []
11511
11621
  }),
11512
- defaultMCP: /* @__PURE__ */ __name(() => farmApp.getServerRenderer().getDefaultMCPServer(), "defaultMCP")
11622
+ defaultMCP: /* @__PURE__ */ __name(() => farmApp.getServerRenderer().getDefaultMCPServer(), "defaultMCP"),
11623
+ // A guard written for an MCP server's path keeps its tools out of the public view.
11624
+ guardCoversPath: /* @__PURE__ */ __name((path22) => farmPathGuardCoversEndpoint(
11625
+ {
11626
+ config: farmConfig,
11627
+ middlewareRoutes: middlewareManager.getMiddlewares().filter((entry) => entry.source !== "config")
11628
+ },
11629
+ path22,
11630
+ apiServerBasePath
11631
+ ), "guardCoversPath")
11513
11632
  }
11514
11633
  );
11515
11634
  await sendWebResponse(res, manifest);