@farm.js/core 0.1.70 → 0.1.72

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 (242) hide show
  1. package/dist/{agent-mcp-handler-6T2Z7TB6.cjs → agent-mcp-handler-KE4J3W7S.cjs} +4 -4
  2. package/dist/{agent-mcp-handler-CPU354QQ.mjs → agent-mcp-handler-VIT4GOSR.mjs} +3 -3
  3. package/dist/{agent-mcp.d-DulgFLBt.d.ts → agent-mcp.d-BO3rZXEM.d.ts} +15 -5
  4. package/dist/{agent-mcp.d-TAs1ES2F.d.mts → agent-mcp.d-Cwff7lcA.d.mts} +15 -5
  5. package/dist/agent-runtime.d.mts +3 -3
  6. package/dist/agent-runtime.d.ts +3 -3
  7. package/dist/{analyzer-QGRBLETM.mjs → analyzer-5Q75LTIL.mjs} +2 -2
  8. package/dist/analyzer-UJG4MIZW.cjs +16 -0
  9. package/dist/api/node.d.mts +5 -5
  10. package/dist/api/node.d.ts +5 -5
  11. package/dist/api/route-manager.cjs +7 -6
  12. package/dist/api/route-manager.d.mts +7 -7
  13. package/dist/api/route-manager.d.ts +7 -7
  14. package/dist/api/route-manager.mjs +6 -5
  15. package/dist/api/runtime.d.mts +4 -4
  16. package/dist/api/runtime.d.ts +4 -4
  17. package/dist/api.cjs +8 -7
  18. package/dist/api.d.mts +8 -8
  19. package/dist/api.d.ts +8 -8
  20. package/dist/api.mjs +7 -6
  21. package/dist/{app-manifest.d-C-nf3Vmm.d.ts → app-manifest.d-DwjGkYlP.d.ts} +1 -1
  22. package/dist/{app-manifest.d-6zXb90o6.d.mts → app-manifest.d-USD_IbFd.d.mts} +1 -1
  23. package/dist/app-markdown.cjs +5 -3
  24. package/dist/app-markdown.d.mts +5 -5
  25. package/dist/app-markdown.d.ts +5 -5
  26. package/dist/app-markdown.mjs +4 -2
  27. package/dist/{app.d-C2xeMIYT.d.ts → app.d-DAmF2MAk.d.ts} +52 -8
  28. package/dist/{app.d-DF0aundc.d.mts → app.d-fW06_h8h.d.mts} +52 -8
  29. package/dist/{chunk-7A3URI2F.mjs → chunk-2EVESLP3.mjs} +8 -1
  30. package/dist/{chunk-JRF2SKCD.mjs → chunk-3JN5M3T5.mjs} +259 -61
  31. package/dist/{chunk-XYVPTTUT.cjs → chunk-3WG7GJQL.cjs} +11 -6
  32. package/dist/{chunk-K66JILV3.cjs → chunk-5LOARKDP.cjs} +2 -2
  33. package/dist/{chunk-I7NUT24Z.cjs → chunk-5R4Q5FN7.cjs} +2 -2
  34. package/dist/{chunk-BPUVDCGG.cjs → chunk-5X6OHJEE.cjs} +15 -3
  35. package/dist/{chunk-RMOU3PR4.mjs → chunk-5XFKWHZD.mjs} +293 -66
  36. package/dist/{chunk-A2TH5MKE.mjs → chunk-645ENY7W.mjs} +3 -3
  37. package/dist/{chunk-NYF7A4UW.mjs → chunk-77VNYVVX.mjs} +1 -1
  38. package/dist/{chunk-32SYRIQ7.cjs → chunk-7QCJDYZQ.cjs} +3 -3
  39. package/dist/{chunk-QZHTDVH4.mjs → chunk-AUAMXI6N.mjs} +1 -1
  40. package/dist/{chunk-5R3JQPWD.mjs → chunk-AYVGD3PK.mjs} +1 -1
  41. package/dist/{chunk-IEN2EFE5.cjs → chunk-BE7AQXJB.cjs} +346 -148
  42. package/dist/{chunk-CCHJWJGP.mjs → chunk-BSXKZPFE.mjs} +204 -98
  43. package/dist/{chunk-2MR4MABG.cjs → chunk-C5AM2XDN.cjs} +54 -4
  44. package/dist/{chunk-M6U6E4F7.cjs → chunk-CBLRSZQL.cjs} +557 -330
  45. package/dist/{chunk-BBPDJGCU.cjs → chunk-CYOTNHDF.cjs} +2 -2
  46. package/dist/{chunk-5IJRJWJS.mjs → chunk-DGNMXL2O.mjs} +11 -1
  47. package/dist/{chunk-3EXCZJEN.mjs → chunk-DS7JGFW5.mjs} +13 -1
  48. package/dist/{chunk-EDZU7YRK.mjs → chunk-E2V7RRFL.mjs} +2 -2
  49. package/dist/{chunk-K7JMTAFH.cjs → chunk-E3LE6EZH.cjs} +20 -10
  50. package/dist/{chunk-DIHBWZDZ.cjs → chunk-ET6WW3FY.cjs} +636 -355
  51. package/dist/{chunk-65FPDDT4.cjs → chunk-EXN4DTVF.cjs} +2 -2
  52. package/dist/{chunk-K4UGCUXX.cjs → chunk-FSSONJRV.cjs} +7 -7
  53. package/dist/{chunk-Y2SZVIVH.cjs → chunk-GPICBTDV.cjs} +8 -1
  54. package/dist/{chunk-FJ5YCERM.cjs → chunk-HLMUWKAP.cjs} +466 -359
  55. package/dist/{chunk-A7HCBHMC.cjs → chunk-IWCYRDRQ.cjs} +3 -3
  56. package/dist/{chunk-R7254L3R.mjs → chunk-J5ASGNKF.mjs} +23 -0
  57. package/dist/{chunk-75E5FDX2.mjs → chunk-JMFTKNBA.mjs} +10 -10
  58. package/dist/{chunk-TLSSIYAL.mjs → chunk-KQAB5LML.mjs} +10 -3
  59. package/dist/{chunk-NSZY3EWG.cjs → chunk-L6E4SHUB.cjs} +31 -8
  60. package/dist/{chunk-OCNV4CI2.cjs → chunk-MQ4DYVFS.cjs} +26 -0
  61. package/dist/{chunk-4AC4PXZO.cjs → chunk-N3XO5AL5.cjs} +2 -2
  62. package/dist/{chunk-2AM26UGI.cjs → chunk-NLBK37HI.cjs} +5 -4
  63. package/dist/{chunk-R2ZHU37O.mjs → chunk-NLRAQXAA.mjs} +26 -0
  64. package/dist/{chunk-NA77GEIU.mjs → chunk-NV26EGMC.mjs} +51 -1
  65. package/dist/{chunk-LECZ5DPZ.cjs → chunk-OSEQL34Q.cjs} +2 -2
  66. package/dist/{chunk-3WS5AZ3R.mjs → chunk-OSMUE5ST.mjs} +8 -3
  67. package/dist/{chunk-JFPKARWM.cjs → chunk-PMU4U2W2.cjs} +1 -0
  68. package/dist/{chunk-KPMLDT3B.mjs → chunk-QUYAGU65.mjs} +581 -300
  69. package/dist/{chunk-N62IYXYD.mjs → chunk-RFWWXEIF.mjs} +1 -1
  70. package/dist/{chunk-E77IA5IF.mjs → chunk-RLFGKJQ6.mjs} +1 -1
  71. package/dist/{chunk-3AUINHFG.mjs → chunk-TNYC3TYP.mjs} +3 -2
  72. package/dist/{chunk-VG6HYT5K.cjs → chunk-TP4RAV7Y.cjs} +9 -9
  73. package/dist/{chunk-JFVT5ZZV.mjs → chunk-VAWDGGW3.mjs} +1 -1
  74. package/dist/{chunk-MU5V7XHL.mjs → chunk-VJSXPN3W.mjs} +3 -0
  75. package/dist/{chunk-DU4VHHPJ.mjs → chunk-VO55MMBX.mjs} +1 -1
  76. package/dist/{chunk-LDVJIBGN.mjs → chunk-VT25ERQK.mjs} +1 -1
  77. package/dist/{chunk-HAXFV2CD.mjs → chunk-WIJF3PBM.mjs} +1 -1
  78. package/dist/{chunk-QEWWKYDL.cjs → chunk-YCNHUIPR.cjs} +17 -10
  79. package/dist/{chunk-FILXOEWD.cjs → chunk-YXIQYWOK.cjs} +2 -2
  80. package/dist/{chunk-THG2TVDH.mjs → chunk-YZLEOMMA.mjs} +3 -3
  81. package/dist/{chunk-PJQ5W356.mjs → chunk-Z5ZZAGIH.mjs} +1 -0
  82. package/dist/{chunk-MZLJFNMH.cjs → chunk-ZDZUFD67.cjs} +1 -1
  83. package/dist/{chunk-Q5HMVGR5.cjs → chunk-ZFEJ2SF2.cjs} +13 -13
  84. package/dist/{chunk-LNVGXUL3.cjs → chunk-ZMSVKVI3.cjs} +3 -0
  85. package/dist/{client-component.d-DNbC4oWI.d.ts → client-component.d-9J7CkTWW.d.ts} +2 -2
  86. package/dist/{client-component.d-Bk5qKJM-.d.mts → client-component.d-ciHeCxr-.d.mts} +2 -2
  87. package/dist/{client-plugins.d-DwUqh4gp.d.ts → client-plugins.d-CUOhfapO.d.ts} +12 -8
  88. package/dist/{client-plugins.d-Pi9nG0W0.d.mts → client-plugins.d-JnRz5a1o.d.mts} +12 -8
  89. package/dist/client-plugins.d.mts +3 -3
  90. package/dist/client-plugins.d.ts +3 -3
  91. package/dist/client.cjs +1 -1
  92. package/dist/client.d.mts +8 -8
  93. package/dist/client.d.ts +8 -8
  94. package/dist/client.mjs +1 -1
  95. package/dist/config.d.mts +3 -3
  96. package/dist/config.d.ts +3 -3
  97. package/dist/desktop.d.mts +4 -4
  98. package/dist/desktop.d.ts +4 -4
  99. package/dist/{devtools-CB43AHEP.mjs → devtools-7JPQMSTQ.mjs} +4 -4
  100. package/dist/{devtools-L5DUNDF3.cjs → devtools-IZFUYWPG.cjs} +5 -5
  101. package/dist/docs.cjs +6 -6
  102. package/dist/docs.d.mts +4 -4
  103. package/dist/docs.d.ts +4 -4
  104. package/dist/docs.mjs +5 -5
  105. package/dist/environment/vite.cjs +3 -3
  106. package/dist/environment/vite.mjs +2 -2
  107. package/dist/{headers.d-CE6OWB-n.d.ts → headers.d-CqpTL_fZ.d.ts} +2 -2
  108. package/dist/{headers.d-DED1hHh4.d.mts → headers.d-rbbTKGaN.d.mts} +2 -2
  109. package/dist/i18n/client.cjs +3 -2
  110. package/dist/i18n/client.d.mts +2 -2
  111. package/dist/i18n/client.d.ts +2 -2
  112. package/dist/i18n/client.mjs +2 -1
  113. package/dist/i18n/index.cjs +3 -2
  114. package/dist/i18n/index.d.mts +3 -3
  115. package/dist/i18n/index.d.ts +3 -3
  116. package/dist/i18n/index.mjs +2 -1
  117. package/dist/i18n/server.cjs +6 -5
  118. package/dist/i18n/server.d.mts +5 -5
  119. package/dist/i18n/server.d.ts +5 -5
  120. package/dist/i18n/server.mjs +5 -4
  121. package/dist/index.cjs +29 -27
  122. package/dist/{index.d-c9UwIqDy.d.ts → index.d-CMKvzHLW.d.ts} +1 -1
  123. package/dist/{index.d-CbvOjJcp.d.mts → index.d-D_B2D9Il.d.mts} +1 -1
  124. package/dist/index.d.mts +24 -24
  125. package/dist/index.d.ts +24 -24
  126. package/dist/index.mjs +28 -26
  127. package/dist/integrations/orm.d.mts +3 -3
  128. package/dist/integrations/orm.d.ts +3 -3
  129. package/dist/integrations.d.mts +3 -3
  130. package/dist/integrations.d.ts +3 -3
  131. package/dist/internal/app-markdown-runtime.cjs +4 -2
  132. package/dist/internal/app-markdown-runtime.d.mts +13 -5
  133. package/dist/internal/app-markdown-runtime.d.ts +13 -5
  134. package/dist/internal/app-markdown-runtime.mjs +3 -1
  135. package/dist/internal/build-runtime.cjs +26 -26
  136. package/dist/internal/build-runtime.d.mts +5 -5
  137. package/dist/internal/build-runtime.d.ts +5 -5
  138. package/dist/internal/build-runtime.mjs +25 -25
  139. package/dist/internal/cli-runtime.cjs +9 -7
  140. package/dist/internal/cli-runtime.mjs +8 -6
  141. package/dist/internal/client-error-overlay.cjs +4 -4
  142. package/dist/internal/client-error-overlay.mjs +1 -1
  143. package/dist/internal/client-runtime.cjs +2 -2
  144. package/dist/internal/client-runtime.d.mts +6 -6
  145. package/dist/internal/client-runtime.d.ts +6 -6
  146. package/dist/internal/client-runtime.mjs +3 -3
  147. package/dist/internal/compression-runtime.d.mts +3 -3
  148. package/dist/internal/compression-runtime.d.ts +3 -3
  149. package/dist/internal/config-runtime.cjs +6 -6
  150. package/dist/internal/config-runtime.d.mts +6 -6
  151. package/dist/internal/config-runtime.d.ts +6 -6
  152. package/dist/internal/config-runtime.mjs +5 -5
  153. package/dist/internal/infra-analytics-runtime.cjs +8 -8
  154. package/dist/internal/infra-analytics-runtime.mjs +6 -6
  155. package/dist/internal/native-server-fns.cjs +4 -4
  156. package/dist/internal/native-server-fns.mjs +3 -3
  157. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  158. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  159. package/dist/internal/production-runtime.cjs +15 -15
  160. package/dist/internal/production-runtime.d.mts +41 -24
  161. package/dist/internal/production-runtime.d.ts +41 -24
  162. package/dist/internal/production-runtime.mjs +14 -14
  163. package/dist/internal/vercel-edge-middleware.d.mts +2 -2
  164. package/dist/internal/vercel-edge-middleware.d.ts +2 -2
  165. package/dist/markdown.d.mts +3 -3
  166. package/dist/markdown.d.ts +3 -3
  167. package/dist/middleware.cjs +3 -3
  168. package/dist/middleware.d.mts +4 -4
  169. package/dist/middleware.d.ts +4 -4
  170. package/dist/middleware.mjs +2 -2
  171. package/dist/mobile.d.mts +3 -3
  172. package/dist/mobile.d.ts +3 -3
  173. package/dist/{mount.d-DngLY7NL.d.ts → mount.d-B0XMxDRh.d.ts} +1 -1
  174. package/dist/{mount.d-BvWxf8ZE.d.mts → mount.d-ImEO7q8a.d.mts} +1 -1
  175. package/dist/{navigation-delegate.d-CMyl1h2l.d.mts → navigation-delegate.d-83Q7ksf7.d.mts} +1 -1
  176. package/dist/{navigation-delegate.d-zZogiDfa.d.ts → navigation-delegate.d-RRx1CSlb.d.ts} +1 -1
  177. package/dist/navigation.d.mts +6 -6
  178. package/dist/navigation.d.ts +6 -6
  179. package/dist/{nitro-Y3LGITW3.cjs → nitro-2LMOMIST.cjs} +2 -2
  180. package/dist/{nitro-NSTXT7LB.mjs → nitro-72TFIGGO.mjs} +1 -1
  181. package/dist/{plugin-F2O4BFTK.cjs → plugin-5PIQQVRP.cjs} +2 -2
  182. package/dist/{plugin-VEBRN7A3.mjs → plugin-QZT747YW.mjs} +1 -1
  183. package/dist/plugin.cjs +20 -20
  184. package/dist/plugin.d.mts +6 -6
  185. package/dist/plugin.d.ts +6 -6
  186. package/dist/plugin.mjs +19 -19
  187. package/dist/{production-runtime.d-B0IeWWyO.d.mts → production-runtime.d-Bcu37SCo.d.mts} +1 -1
  188. package/dist/{production-runtime.d-q3aHIv5Y.d.ts → production-runtime.d-qPj3XRET.d.ts} +1 -1
  189. package/dist/{render-plan.d-DQj2bzd2.d.ts → render-plan.d-Ds2sXJ5m.d.ts} +1 -1
  190. package/dist/{render-plan.d-Di1znBDW.d.mts → render-plan.d-wP8nTeRV.d.mts} +1 -1
  191. package/dist/renderer-client.cjs +3 -2
  192. package/dist/renderer-client.d.mts +6 -6
  193. package/dist/renderer-client.d.ts +6 -6
  194. package/dist/renderer-client.mjs +2 -1
  195. package/dist/{request.d-CJWzfDYJ.d.mts → request.d-F3h7K37m.d.mts} +1 -1
  196. package/dist/{request.d-C5vyoYeL.d.ts → request.d-zpSn6pu_.d.ts} +1 -1
  197. package/dist/request.d.mts +4 -4
  198. package/dist/request.d.ts +4 -4
  199. package/dist/{resolver.d-9iKC79CU.d.mts → resolver.d-DJgzbdsp.d.mts} +1 -1
  200. package/dist/{resolver.d-CY6mEa_F.d.ts → resolver.d-yaHcGCCG.d.ts} +1 -1
  201. package/dist/{route-rendering.d-DhsY5M2I.d.ts → route-rendering.d-BL0_AdKj.d.ts} +1 -1
  202. package/dist/{route-rendering.d-C-et2TZ1.d.mts → route-rendering.d-Mw0ZKG2e.d.mts} +1 -1
  203. package/dist/{router.d-CJB-Ntni.d.ts → router.d-BwXigemZ.d.ts} +1 -1
  204. package/dist/{router.d-BMDS5s5X.d.mts → router.d-NGVsU11T.d.mts} +1 -1
  205. package/dist/{routes.d-D3aJw1H5.d.mts → routes.d-CCccJRrp.d.mts} +1 -1
  206. package/dist/{routes.d-K-Qg79AA.d.ts → routes.d-b7khoRoU.d.ts} +1 -1
  207. package/dist/routes.d.mts +3 -3
  208. package/dist/routes.d.ts +3 -3
  209. package/dist/{routing.d-BxOZ2YWc.d.ts → routing.d-BhPgtN_S.d.ts} +2 -1
  210. package/dist/{routing.d-DwSUVZbF.d.mts → routing.d-D67HQmnv.d.mts} +2 -1
  211. package/dist/{rsc-pipeline-NJKLZ3YE.cjs → rsc-pipeline-BNXYMG4G.cjs} +6 -6
  212. package/dist/{rsc-pipeline-AXQJCCHI.mjs → rsc-pipeline-DHYZLWSF.mjs} +5 -5
  213. package/dist/{runtime-DMW6DDOI.cjs → runtime-IWOT6ZVC.cjs} +7 -7
  214. package/dist/{runtime-JXNEKOSE.mjs → runtime-XPYKUNL3.mjs} +5 -5
  215. package/dist/{runtime.d-BonodRI9.d.mts → runtime.d-BA3MzhXz.d.mts} +1 -1
  216. package/dist/{runtime.d-nUz0HAL4.d.mts → runtime.d-CTAXWZby.d.mts} +2 -2
  217. package/dist/{runtime.d-uw4123iI.d.ts → runtime.d-OBIZWpx1.d.ts} +1 -1
  218. package/dist/{runtime.d-B_uPfMjA.d.ts → runtime.d-PUA5qBnd.d.ts} +2 -2
  219. package/dist/server-plugins.d.mts +5 -5
  220. package/dist/server-plugins.d.ts +5 -5
  221. package/dist/server.cjs +40 -40
  222. package/dist/server.d.mts +14 -14
  223. package/dist/server.d.ts +14 -14
  224. package/dist/server.mjs +22 -22
  225. package/dist/{spa-router.d-rha3M95y.d.mts → spa-router.d-BG2XzE5p.d.mts} +3 -3
  226. package/dist/{spa-router.d-l0d9pPZj.d.ts → spa-router.d-DrYT944-.d.ts} +3 -3
  227. package/dist/testing.cjs +6 -5
  228. package/dist/testing.d.mts +3 -3
  229. package/dist/testing.d.ts +3 -3
  230. package/dist/testing.mjs +6 -5
  231. package/dist/{types.d-wVRlLtBf.d.mts → types.d-euATAbE4.d.mts} +4 -0
  232. package/dist/{types.d-wVRlLtBf.d.ts → types.d-euATAbE4.d.ts} +4 -0
  233. package/dist/{utils.d-BzuTobEc.d.mts → utils.d-C1k9BJeD.d.mts} +1 -1
  234. package/dist/{utils.d-BK-PTOF8.d.ts → utils.d-DcF4wxey.d.ts} +1 -1
  235. package/dist/version.cjs +2 -2
  236. package/dist/version.mjs +1 -1
  237. package/dist/vite.cjs +20 -20
  238. package/dist/vite.d.mts +9 -7
  239. package/dist/vite.d.ts +9 -7
  240. package/dist/vite.mjs +19 -19
  241. package/package.json +2 -2
  242. package/dist/analyzer-GUIRJWZH.cjs +0 -16
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
3
 
4
- var _chunk65FPDDT4cjs = require('./chunk-65FPDDT4.cjs');
4
+ var _chunkEXN4DTVFcjs = require('./chunk-EXN4DTVF.cjs');
5
5
 
6
6
 
7
7
  var _chunkPIUTGRDIcjs = require('./chunk-PIUTGRDI.cjs');
@@ -64,7 +64,7 @@ function findFarmNativeScreenFiles(appDirs) {
64
64
  }
65
65
  function collectFarmNativeServerFns(options) {
66
66
  const { root, srcDir } = options;
67
- const aliases = _chunk65FPDDT4cjs.readAliases.call(void 0, root, srcDir);
67
+ const aliases = _chunkEXN4DTVFcjs.readAliases.call(void 0, root, srcDir);
68
68
  const seen = /* @__PURE__ */ new Set();
69
69
  const found = /* @__PURE__ */ new Map();
70
70
  const queue = [...options.entries];
@@ -98,7 +98,7 @@ function collectFarmNativeServerFns(options) {
98
98
  }
99
99
  }
100
100
  for (const candidate of _nullishCoalesce(candidates, () => ( []))) {
101
- const resolved = _chunk65FPDDT4cjs.resolveFile.call(void 0, candidate);
101
+ const resolved = _chunkEXN4DTVFcjs.resolveFile.call(void 0, candidate);
102
102
  if (resolved && SCRIPT.test(resolved) && !resolved.includes(`${_path2.default.sep}node_modules${_path2.default.sep}`)) {
103
103
  queue.push(resolved);
104
104
  break;
@@ -75,6 +75,27 @@ async function evaluateMdxSource(source, filePath) {
75
75
  remarkPlugins: [remarkGfm]
76
76
  });
77
77
  }
78
+ var MARKDOWN_ROUTE_CONFIG_EXPORT = /^export\s+const\s+(dynamic|revalidate|ssg)\s*=\s*("[^"\\]*"|'[^'\\]*'|\d+(?:\.\d+)?|true|false)\s*;?\s*$/;
79
+ function readFarmMarkdownRouteConfig(body) {
80
+ const config = {};
81
+ let fence;
82
+ for (const line of body.split(/\r?\n/)) {
83
+ const marker = line.match(/^ {0,3}(`{3,}|~{3,})/)?.[1];
84
+ if (fence) {
85
+ if (marker && marker[0] === fence[0] && marker.length >= fence.length) fence = void 0;
86
+ continue;
87
+ }
88
+ if (marker) {
89
+ fence = marker;
90
+ continue;
91
+ }
92
+ const match = line.match(MARKDOWN_ROUTE_CONFIG_EXPORT);
93
+ if (!match) continue;
94
+ const literal = match[2];
95
+ config[match[1]] = literal === "true" ? true : literal === "false" ? false : /^\d/.test(literal) ? Number(literal) : literal.slice(1, -1);
96
+ }
97
+ return config;
98
+ }
78
99
  function createFarmMarkdownRouteModule(input) {
79
100
  const { body } = parseMarkdownFrontmatter(input.source);
80
101
  const className = input.config?.className || "farm-markdown";
@@ -110,6 +131,7 @@ function createFarmMarkdownRouteModule(input) {
110
131
  );
111
132
  }
112
133
  return {
134
+ ...readFarmMarkdownRouteConfig(body),
113
135
  default: FarmMarkdownPage,
114
136
  metadata: createMarkdownMetadata(input.source, input.filePath),
115
137
  source: input.source
@@ -287,6 +309,7 @@ export {
287
309
  parseMarkdownFrontmatter,
288
310
  titleFromMarkdown,
289
311
  createMarkdownMetadata,
312
+ readFarmMarkdownRouteConfig,
290
313
  createFarmMarkdownRouteModule,
291
314
  isFarmMarkdownPublicSourceResponse,
292
315
  FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS,
@@ -1,5 +1,7 @@
1
1
  import {
2
- collectFarmLlmsTxtPages
2
+ collectFarmLlmsTxtPages,
3
+ getFarmAgentPagePublicPath,
4
+ resolveFarmAgentOrigin
3
5
  } from "./chunk-Z3GPAFIA.mjs";
4
6
  import {
5
7
  getFarmMarkdownMirrorPath,
@@ -13,10 +15,6 @@ import {
13
15
  normalizeFarmTrailingSlashPathname
14
16
  } from "./chunk-4O26BPUY.mjs";
15
17
  import {
16
- localizeFarmPathname
17
- } from "./chunk-7S7AAK2D.mjs";
18
- import {
19
- applyFarmBasePath,
20
18
  stripFarmBasePath
21
19
  } from "./chunk-SF3JB56B.mjs";
22
20
 
@@ -114,8 +112,7 @@ function collectFarmDefaultMCPPages(sources, options) {
114
112
  if (!isFarmMarkdownMirrorExposed(options.markdown, source.pattern)) continue;
115
113
  readable.push({ pattern: source.pattern, metadata: module?.metadata });
116
114
  }
117
- const i18n = resolveFarmDefaultMCPI18n(options.i18n, options.basePath);
118
- const toPublicPath = (pathname) => i18n ? localizeFarmPathname(pathname, i18n.defaultLocale, i18n) : applyFarmBasePath(pathname, options.basePath);
115
+ const base = resolveFarmAgentOrigin(options.metadataBase, options.origin);
119
116
  return collectFarmLlmsTxtPages(readable, {
120
117
  origin: options.origin,
121
118
  basePath: options.basePath,
@@ -124,13 +121,16 @@ function collectFarmDefaultMCPPages(sources, options) {
124
121
  path: page.path,
125
122
  title: page.title,
126
123
  // As the sitemap lists it: '/base' without trailingSlash ('/base/' redirects there).
127
- url: `${options.origin}${normalizeFarmTrailingSlashPathname(
128
- toPublicPath(page.path),
124
+ url: `${base}${normalizeFarmTrailingSlashPathname(
125
+ getFarmAgentPagePublicPath(page.path, options),
129
126
  options.trailingSlash === true
130
127
  )}`,
131
128
  ...page.description ? { description: page.description } : {},
132
129
  // A mirror keeps its .md URL whatever trailingSlash says, as llms.txt links it.
133
- markdownUrl: `${options.origin}${toPublicPath(getFarmMarkdownMirrorPath(page.path))}`
130
+ markdownUrl: `${options.origin}${getFarmAgentPagePublicPath(
131
+ getFarmMarkdownMirrorPath(page.path),
132
+ options
133
+ )}`
134
134
  }));
135
135
  }
136
136
  function resolveFarmDefaultMCPI18n(i18n, basePath) {
@@ -3,7 +3,10 @@ import {
3
3
  FARM_DEFAULT_MCP_PROTOCOL_VERSIONS,
4
4
  FARM_DEFAULT_MCP_TOOLS,
5
5
  resolveFarmDefaultMCPI18n
6
- } from "./chunk-75E5FDX2.mjs";
6
+ } from "./chunk-JMFTKNBA.mjs";
7
+ import {
8
+ resolveFarmAgentOrigin
9
+ } from "./chunk-Z3GPAFIA.mjs";
7
10
  import {
8
11
  resolveFarmLocalePath
9
12
  } from "./chunk-7S7AAK2D.mjs";
@@ -154,6 +157,7 @@ async function callTool(params, request, context) {
154
157
  const pagePath = toPagePath(
155
158
  path,
156
159
  request.url,
160
+ context.metadataBase,
157
161
  context.basePath,
158
162
  resolveFarmDefaultMCPI18n(context.i18n, context.basePath)
159
163
  );
@@ -203,14 +207,17 @@ function searchPages(pages, query, limit) {
203
207
  (left, right) => right.score - left.score || left.page.path.localeCompare(right.page.path)
204
208
  ).slice(0, limit).map(({ page }) => page);
205
209
  }
206
- function toPagePath(input, requestUrl, basePath, i18n) {
210
+ function toPagePath(input, requestUrl, metadataBase, basePath, i18n) {
207
211
  let url;
208
212
  try {
209
213
  url = new URL(input.trim(), requestUrl);
210
214
  } catch {
211
215
  return null;
212
216
  }
213
- if (url.origin !== new URL(requestUrl).origin) return null;
217
+ const requestOrigin = new URL(requestUrl).origin;
218
+ if (url.origin !== requestOrigin && url.origin !== resolveFarmAgentOrigin(metadataBase, requestOrigin)) {
219
+ return null;
220
+ }
214
221
  let path = url.pathname;
215
222
  try {
216
223
  path = decodeURI(path);
@@ -75,9 +75,30 @@ async function evaluateMdxSource(source, filePath) {
75
75
  remarkPlugins: [remarkGfm]
76
76
  });
77
77
  }
78
+ var MARKDOWN_ROUTE_CONFIG_EXPORT = /^export\s+const\s+(dynamic|revalidate|ssg)\s*=\s*("[^"\\]*"|'[^'\\]*'|\d+(?:\.\d+)?|true|false)\s*;?\s*$/;
79
+ function readFarmMarkdownRouteConfig(body) {
80
+ const config = {};
81
+ let fence;
82
+ for (const line of body.split(/\r?\n/)) {
83
+ const marker = _optionalChain([line, 'access', _6 => _6.match, 'call', _7 => _7(/^ {0,3}(`{3,}|~{3,})/), 'optionalAccess', _8 => _8[1]]);
84
+ if (fence) {
85
+ if (marker && marker[0] === fence[0] && marker.length >= fence.length) fence = void 0;
86
+ continue;
87
+ }
88
+ if (marker) {
89
+ fence = marker;
90
+ continue;
91
+ }
92
+ const match = line.match(MARKDOWN_ROUTE_CONFIG_EXPORT);
93
+ if (!match) continue;
94
+ const literal = match[2];
95
+ config[match[1]] = literal === "true" ? true : literal === "false" ? false : /^\d/.test(literal) ? Number(literal) : literal.slice(1, -1);
96
+ }
97
+ return config;
98
+ }
78
99
  function createFarmMarkdownRouteModule(input) {
79
100
  const { body } = parseMarkdownFrontmatter(input.source);
80
- const className = _optionalChain([input, 'access', _6 => _6.config, 'optionalAccess', _7 => _7.className]) || "farm-markdown";
101
+ const className = _optionalChain([input, 'access', _9 => _9.config, 'optionalAccess', _10 => _10.className]) || "farm-markdown";
81
102
  let evaluatedPromise;
82
103
  let componentsPromise;
83
104
  const loadContent = async () => {
@@ -104,12 +125,13 @@ function createFarmMarkdownRouteModule(input) {
104
125
  ...props,
105
126
  components: {
106
127
  ...components,
107
- ..._optionalChain([props, 'optionalAccess', _8 => _8.components])
128
+ ..._optionalChain([props, 'optionalAccess', _11 => _11.components])
108
129
  }
109
130
  })
110
131
  );
111
132
  }
112
133
  return {
134
+ ...readFarmMarkdownRouteConfig(body),
113
135
  default: FarmMarkdownPage,
114
136
  metadata: createMarkdownMetadata(input.source, input.filePath),
115
137
  source: input.source
@@ -183,8 +205,8 @@ async function anonymousVisitorOpensPage(options, url, targetPathname) {
183
205
  signal: options.request.signal
184
206
  })
185
207
  );
186
- if (response.status < 200 || response.status >= 300 || !_optionalChain([response, 'access', _9 => _9.headers, 'access', _10 => _10.get, 'call', _11 => _11("content-type"), 'optionalAccess', _12 => _12.toLowerCase, 'call', _13 => _13(), 'access', _14 => _14.includes, 'call', _15 => _15("text/html")])) {
187
- void _optionalChain([response, 'access', _16 => _16.body, 'optionalAccess', _17 => _17.cancel, 'call', _18 => _18(), 'access', _19 => _19.catch, 'call', _20 => _20(() => {
208
+ if (response.status < 200 || response.status >= 300 || !_optionalChain([response, 'access', _12 => _12.headers, 'access', _13 => _13.get, 'call', _14 => _14("content-type"), 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16(), 'access', _17 => _17.includes, 'call', _18 => _18("text/html")])) {
209
+ void _optionalChain([response, 'access', _19 => _19.body, 'optionalAccess', _20 => _20.cancel, 'call', _21 => _21(), 'access', _22 => _22.catch, 'call', _23 => _23(() => {
188
210
  })]);
189
211
  return false;
190
212
  }
@@ -201,7 +223,7 @@ async function createFarmMarkdownSourceResponse(options) {
201
223
  if (options.request.method !== "GET" && options.request.method !== "HEAD") {
202
224
  return null;
203
225
  }
204
- if (_optionalChain([options, 'access', _21 => _21.config, 'optionalAccess', _22 => _22.markdownRoutes]) === false) {
226
+ if (_optionalChain([options, 'access', _24 => _24.config, 'optionalAccess', _25 => _25.markdownRoutes]) === false) {
205
227
  return null;
206
228
  }
207
229
  const url = new URL(options.request.url);
@@ -244,7 +266,7 @@ async function createFarmMarkdownSourceResponse(options) {
244
266
  publicSourceResponses.add(response);
245
267
  return response;
246
268
  }
247
- await _optionalChain([publicResponse, 'access', _23 => _23.body, 'optionalAccess', _24 => _24.cancel, 'call', _25 => _25()]);
269
+ await _optionalChain([publicResponse, 'access', _26 => _26.body, 'optionalAccess', _27 => _27.cancel, 'call', _28 => _28()]);
248
270
  if (!hasMarkdownExtension) return null;
249
271
  return new Response(`No public Markdown version of ${targetPathname}.
250
272
  `, {
@@ -262,7 +284,7 @@ async function createFarmMarkdownSourceResponse(options) {
262
284
  "Content-Type": "text/markdown; charset=utf-8",
263
285
  "Content-Location": _chunkC2JOS77Zcjs._getFarmMarkdownPath.call(void 0,
264
286
  targetPathname,
265
- _optionalChain([options, 'access', _26 => _26.routePathname, 'optionalCall', _27 => _27(targetPathname)])
287
+ _optionalChain([options, 'access', _29 => _29.routePathname, 'optionalCall', _30 => _30(targetPathname)])
266
288
  ),
267
289
  "Cache-Control": "public, s-maxage=60, stale-while-revalidate=300",
268
290
  "X-Farm-Markdown-Route": targetPathname,
@@ -291,4 +313,5 @@ async function createFarmMarkdownSourceResponse(options) {
291
313
 
292
314
 
293
315
 
294
- exports.isFarmMarkdownPageFile = isFarmMarkdownPageFile; exports.normalizeFarmMarkdownRoutePath = normalizeFarmMarkdownRoutePath; exports.parseMarkdownFrontmatter = parseMarkdownFrontmatter; exports.titleFromMarkdown = titleFromMarkdown; exports.createMarkdownMetadata = createMarkdownMetadata; exports.createFarmMarkdownRouteModule = createFarmMarkdownRouteModule; exports.isFarmMarkdownPublicSourceResponse = isFarmMarkdownPublicSourceResponse; exports.FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS = FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS; exports.createFarmMarkdownSourceResponse = createFarmMarkdownSourceResponse;
316
+
317
+ exports.isFarmMarkdownPageFile = isFarmMarkdownPageFile; exports.normalizeFarmMarkdownRoutePath = normalizeFarmMarkdownRoutePath; exports.parseMarkdownFrontmatter = parseMarkdownFrontmatter; exports.titleFromMarkdown = titleFromMarkdown; exports.createMarkdownMetadata = createMarkdownMetadata; exports.readFarmMarkdownRouteConfig = readFarmMarkdownRouteConfig; exports.createFarmMarkdownRouteModule = createFarmMarkdownRouteModule; exports.isFarmMarkdownPublicSourceResponse = isFarmMarkdownPublicSourceResponse; exports.FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS = FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS; exports.createFarmMarkdownSourceResponse = createFarmMarkdownSourceResponse;
@@ -23,6 +23,7 @@ function normalizeRouteRules(routeRules) {
23
23
  if (!rule) continue;
24
24
  const normalizedSource = normalizeRuleSource(source);
25
25
  _chunkPWKAX5MScjs.validateConfigRouteSource.call(void 0, normalizedSource, `Route rule "${source}" source`);
26
+ assertSingleCatchAll(normalizedSource);
26
27
  const existingSource = normalizedSources.get(normalizedSource);
27
28
  if (existingSource !== void 0) {
28
29
  throw new Error(
@@ -150,6 +151,31 @@ function normalizeList(value) {
150
151
  if (!value || typeof value === "string") return value;
151
152
  return value.join(", ");
152
153
  }
154
+ function assertSingleCatchAll(source) {
155
+ let catchAlls = 0;
156
+ for (const segment of source.split("/")) {
157
+ if (/^:[A-Za-z_]\w*[*+]$/.test(segment)) {
158
+ catchAlls += 1;
159
+ continue;
160
+ }
161
+ const withoutDoubleStars = segment.replace(/\*\*/g, () => {
162
+ catchAlls += 1;
163
+ return "";
164
+ });
165
+ catchAlls += withoutDoubleStars.split("*").length - 1;
166
+ }
167
+ if (catchAlls <= 1) return;
168
+ const segments = source.split("/");
169
+ let last = segments.length - 1;
170
+ while (last > 0 && !segments[last].includes("*")) last -= 1;
171
+ let names = 0;
172
+ const suggestion = segments.map(
173
+ (segment, index) => segment === "*" && index !== last ? `:segment${++names === 1 ? "" : names}` : segment
174
+ ).join("/");
175
+ throw new Error(
176
+ `Route rule "${source}" has more than one catch-all. A route rule may use one "*", "**", ":name*" or ":name+", and "*" matches any number of segments, as "**" does. Match one segment with a named parameter instead` + (suggestion !== source ? `: "${suggestion}".` : `, as in "/:locale/docs/**".`)
177
+ );
178
+ }
153
179
  function normalizeRuleSource(source) {
154
180
  const trimmed = source.trim();
155
181
  if (!trimmed) {
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkNSZY3EWGcjs = require('./chunk-NSZY3EWG.cjs');
3
+ var _chunkL6E4SHUBcjs = require('./chunk-L6E4SHUB.cjs');
4
4
 
5
5
  // src/app-markdown.ts
6
6
  var _promises = require('fs/promises');
@@ -8,7 +8,7 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
8
8
  var _url = require('url');
9
9
  async function createFarmMarkdownRouteModuleFromFile(filePath, options = {}) {
10
10
  const source = await _promises.readFile.call(void 0, filePath, "utf8");
11
- return _chunkNSZY3EWGcjs.createFarmMarkdownRouteModule.call(void 0, {
11
+ return _chunkL6E4SHUBcjs.createFarmMarkdownRouteModule.call(void 0, {
12
12
  source,
13
13
  filePath,
14
14
  components: options.components,
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkBBPDJGCUcjs = require('./chunk-BBPDJGCU.cjs');
3
+ var _chunkCYOTNHDFcjs = require('./chunk-CYOTNHDF.cjs');
4
4
 
5
5
 
6
- var _chunkY2SZVIVHcjs = require('./chunk-Y2SZVIVH.cjs');
6
+ var _chunkGPICBTDVcjs = require('./chunk-GPICBTDV.cjs');
7
7
 
8
8
 
9
9
  var _chunkAOKXITZ6cjs = require('./chunk-AOKXITZ6.cjs');
@@ -25,7 +25,7 @@ var FarmI18nRuntime = class {
25
25
  }
26
26
  async initialize() {
27
27
  if (!this.config.enabled) return;
28
- const bundle = await _chunkBBPDJGCUcjs.readFarmI18nCatalogs.call(void 0, this.config);
28
+ const bundle = await _chunkCYOTNHDFcjs.readFarmI18nCatalogs.call(void 0, this.config);
29
29
  this.replaceCatalogs(bundle.catalogs);
30
30
  }
31
31
  async reload() {
@@ -42,7 +42,7 @@ var FarmI18nRuntime = class {
42
42
  );
43
43
  }
44
44
  resolveRequest(request, options = {}) {
45
- return _chunkY2SZVIVHcjs.resolveFarmLocaleRequest.call(void 0, request, this.config, options);
45
+ return _chunkGPICBTDVcjs.resolveFarmLocaleRequest.call(void 0, request, this.config, options);
46
46
  }
47
47
  translate(locale, key, values) {
48
48
  const result = this.formatMessage(locale, key, values);
@@ -69,6 +69,7 @@ var FarmI18nRuntime = class {
69
69
  defaultLocale: this.config.defaultLocale,
70
70
  routing: this.config.routing,
71
71
  basePath: this.config.basePath,
72
+ trailingSlash: this.config.trailingSlash,
72
73
  cookie: this.config.cookie,
73
74
  direction: _chunkOWQV6MLMcjs.getFarmLocaleDirection.call(void 0, resolution.locale, this.config.direction),
74
75
  messages: {
@@ -23,6 +23,7 @@ function normalizeRouteRules(routeRules) {
23
23
  if (!rule) continue;
24
24
  const normalizedSource = normalizeRuleSource(source);
25
25
  validateConfigRouteSource(normalizedSource, `Route rule "${source}" source`);
26
+ assertSingleCatchAll(normalizedSource);
26
27
  const existingSource = normalizedSources.get(normalizedSource);
27
28
  if (existingSource !== void 0) {
28
29
  throw new Error(
@@ -150,6 +151,31 @@ function normalizeList(value) {
150
151
  if (!value || typeof value === "string") return value;
151
152
  return value.join(", ");
152
153
  }
154
+ function assertSingleCatchAll(source) {
155
+ let catchAlls = 0;
156
+ for (const segment of source.split("/")) {
157
+ if (/^:[A-Za-z_]\w*[*+]$/.test(segment)) {
158
+ catchAlls += 1;
159
+ continue;
160
+ }
161
+ const withoutDoubleStars = segment.replace(/\*\*/g, () => {
162
+ catchAlls += 1;
163
+ return "";
164
+ });
165
+ catchAlls += withoutDoubleStars.split("*").length - 1;
166
+ }
167
+ if (catchAlls <= 1) return;
168
+ const segments = source.split("/");
169
+ let last = segments.length - 1;
170
+ while (last > 0 && !segments[last].includes("*")) last -= 1;
171
+ let names = 0;
172
+ const suggestion = segments.map(
173
+ (segment, index) => segment === "*" && index !== last ? `:segment${++names === 1 ? "" : names}` : segment
174
+ ).join("/");
175
+ throw new Error(
176
+ `Route rule "${source}" has more than one catch-all. A route rule may use one "*", "**", ":name*" or ":name+", and "*" matches any number of segments, as "**" does. Match one segment with a named parameter instead` + (suggestion !== source ? `: "${suggestion}".` : `, as in "/:locale/docs/**".`)
177
+ );
178
+ }
153
179
  function normalizeRuleSource(source) {
154
180
  const trimmed = source.trim();
155
181
  if (!trimmed) {
@@ -33,6 +33,9 @@ import {
33
33
  parseRoutePattern,
34
34
  splitNormalizedPathname
35
35
  } from "./chunk-MFQGU5CC.mjs";
36
+ import {
37
+ normalizeFarmTrailingSlashPathname
38
+ } from "./chunk-4O26BPUY.mjs";
36
39
  import {
37
40
  localizeFarmPathname
38
41
  } from "./chunk-7S7AAK2D.mjs";
@@ -237,6 +240,32 @@ function classifyFarmDocumentPrefix(markup) {
237
240
  if (/^<!doctype/i.test(inner) || /^<html[\s>]/i.test(inner)) return "document";
238
241
  return inner === "" ? "pending" : "fragment";
239
242
  }
243
+ function takeFarmHoistedHead(markup, complete) {
244
+ const kind = classifyFarmDocumentPrefix(markup);
245
+ if (kind === "document") return { head: "", body: markup };
246
+ if (kind === "pending" && !complete) return null;
247
+ let head = "";
248
+ let body = markup;
249
+ let match;
250
+ while (match = HOISTED_HEAD_ELEMENT.exec(body.replace(/^\s+/, ""))) {
251
+ head += match[0];
252
+ body = body.replace(/^\s+/, "").slice(match[0].length);
253
+ }
254
+ if (!complete && endsInsideHoistable(body)) return null;
255
+ return { head, body };
256
+ }
257
+ function endsInsideHoistable(body) {
258
+ const open = /^\s*<(meta|link|base|title|script|style)\b/i.exec(body);
259
+ if (!open) return false;
260
+ const tag = open[1].toLowerCase();
261
+ if (!body.includes(">")) return true;
262
+ return (tag === "title" || tag === "script" || tag === "style") && !new RegExp(`</${tag}>`, "i").test(body);
263
+ }
264
+ function appendFarmHead(document, head) {
265
+ if (!head) return document;
266
+ return document.replace(/<\/head>/i, () => `${head}
267
+ </head>`);
268
+ }
240
269
  function ensureFarmDocumentHead(markup) {
241
270
  if (/<head[\s>]/i.test(markup)) return markup;
242
271
  return markup.replace(/<html([^>]*)>/i, (_match, attributes) => {
@@ -423,10 +452,21 @@ function pathSpecificConfigMiddlewareCovers(config, pathname) {
423
452
  return matchesCompiledMiddlewareConfig(pathname, compiled, {}).matched;
424
453
  });
425
454
  }
455
+ function middlewareRouteConfig(route) {
456
+ if (route.config !== void 0) return route.config === "unknown" ? void 0 : route.config;
457
+ return route.module?.config;
458
+ }
426
459
  function farmPathGuardCoversPage(options, pathname) {
427
460
  return appMiddlewareMayHandlePath(
428
461
  options.middlewareRoutes.filter((route) => route.path !== "/"),
429
462
  pathname
463
+ ) || // The root file runs for every path unless its own matcher narrows it, which is how a
464
+ // Next.js-style `middleware.ts` guards `/dashboard/:path*`.
465
+ options.middlewareRoutes.some(
466
+ (route) => route.path === "/" && pathSpecificConfigMiddlewareCovers(
467
+ middlewareRouteConfig(route),
468
+ pathname
469
+ )
430
470
  ) || pathSpecificConfigMiddlewareCovers(options.config.middleware, pathname) || integrationMiddlewareMayHandlePath(options.config.integrations, pathname, CATCH_ALL_PROBE);
431
471
  }
432
472
  function farmPathGuardCoversEndpoint(options, path, apiServerBasePath) {
@@ -440,7 +480,15 @@ function renderFarmLocaleAlternateLinks(pathname, config, options = {}) {
440
480
  if (config.routing === "none") return "";
441
481
  const base = resolveAlternateBase(options);
442
482
  const link = (hreflang, locale) => `<link rel="alternate" hreflang="${escapeHtmlAttribute(hreflang)}" href="${escapeHtmlAttribute(
443
- resolveAlternateHref(localizeFarmPathname(pathname, locale, config), base)
483
+ resolveAlternateHref(
484
+ // Each alternate is the page's canonical URL in that locale, so it carries the app's
485
+ // trailingSlash: an alternate the server redirects reads as an error to search engines.
486
+ normalizeFarmTrailingSlashPathname(
487
+ localizeFarmPathname(pathname, locale, config),
488
+ config.trailingSlash === true
489
+ ),
490
+ base
491
+ )
444
492
  )}">`;
445
493
  const links = config.locales.map((locale) => link(locale, locale));
446
494
  links.push(link("x-default", config.defaultLocale));
@@ -856,6 +904,8 @@ export {
856
904
  HOISTED_HEAD_ELEMENT,
857
905
  extractFarmFullDocument,
858
906
  classifyFarmDocumentPrefix,
907
+ takeFarmHoistedHead,
908
+ appendFarmHead,
859
909
  removeFarmDocumentTitles,
860
910
  ensureFarmDocumentMeta,
861
911
  composeFarmFullDocument,
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkMZLJFNMHcjs = require('./chunk-MZLJFNMH.cjs');
3
+ var _chunkZDZUFD67cjs = require('./chunk-ZDZUFD67.cjs');
4
4
 
5
5
  // src/deployment-environment.ts
6
6
  function isFarmProductionDeploymentEnvironment(env = process.env) {
@@ -90,7 +90,7 @@ function createFarmProductionSiteReporter(options) {
90
90
  schemaVersion: FARM_PRODUCTION_SITE_TELEMETRY_SCHEMA_VERSION,
91
91
  eventType: FARM_PRODUCTION_SITE_ATTESTATION_EVENT_TYPE,
92
92
  packageName: FARM_PRODUCTION_SITE_TELEMETRY_PACKAGE_NAME,
93
- packageVersion: sanitizeDetail(_chunkMZLJFNMHcjs.FARM_VERSION, "unknown"),
93
+ packageVersion: sanitizeDetail(_chunkZDZUFD67cjs.FARM_VERSION, "unknown"),
94
94
  renderer: sanitizeDetail(options.renderer, "custom"),
95
95
  deployTarget: sanitizeDetail(options.deployTarget, "custom")
96
96
  };
@@ -7,7 +7,7 @@ import {
7
7
  normalizeRouteRules,
8
8
  routeRulesToHeaders,
9
9
  routeRulesToRedirects
10
- } from "./chunk-R2ZHU37O.mjs";
10
+ } from "./chunk-NLRAQXAA.mjs";
11
11
  import {
12
12
  assertPluginDependencies
13
13
  } from "./chunk-XR2ZIBQK.mjs";
@@ -82,7 +82,7 @@ import {
82
82
  } from "./chunk-EDPENAVO.mjs";
83
83
  import {
84
84
  resolveFarmI18nConfig
85
- } from "./chunk-MU5V7XHL.mjs";
85
+ } from "./chunk-VJSXPN3W.mjs";
86
86
  import {
87
87
  logger
88
88
  } from "./chunk-JSDV2NUN.mjs";
@@ -1208,7 +1208,12 @@ async function resolveConfig(userConfig, mode) {
1208
1208
  performance: resolveFarmPerformanceConfig(userConfig.performance),
1209
1209
  theme: resolveFarmThemeConfig(userConfig.theme, basePath),
1210
1210
  publicDir: userConfig.publicDir || "public",
1211
- i18n: resolveFarmI18nConfig(userConfig.i18n, { root, mode, basePath }),
1211
+ i18n: resolveFarmI18nConfig(userConfig.i18n, {
1212
+ root,
1213
+ mode,
1214
+ basePath,
1215
+ trailingSlash: userConfig.trailingSlash ?? false
1216
+ }),
1212
1217
  openapi,
1213
1218
  middleware: validateMiddlewareConfig(userConfig.middleware) || {},
1214
1219
  notFound: userConfig.notFound || {},
@@ -688,6 +688,7 @@ var PluginManager = class {
688
688
  * Runs only `runtime.before` for a request Farm re-routed internally, such as
689
689
  * a configured rewrite, so guards also see the destination URL. The session
690
690
  * opened for `source` keeps its context; context and after hooks don't rerun.
691
+ * `options` describe the destination; the session keeps the source's route.
691
692
  */
692
693
  async runRuntimeBeforeForRewrite(source, request, options = {}) {
693
694
  if (!this.hasRuntimeHook("before")) return request;