@farm.js/core 0.1.38 → 0.1.40

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 (368) hide show
  1. package/dist/{agent-mcp-BwKlpnc7.d.mts → agent-mcp-DRlXq3lM.d.ts} +1 -1
  2. package/dist/{agent-mcp-De1imoMS.d.ts → agent-mcp-XNF4JqHw.d.mts} +1 -1
  3. package/dist/{agent-mcp-handler-OLRMZONF.mjs → agent-mcp-handler-HVV5LNXF.mjs} +6 -6
  4. package/dist/{agent-mcp-handler-MRGP3WJ3.cjs → agent-mcp-handler-YKG7KVCY.cjs} +7 -7
  5. package/dist/agent-runtime.cjs +10 -6
  6. package/dist/agent-runtime.d.mts +5 -7
  7. package/dist/agent-runtime.d.ts +5 -7
  8. package/dist/agent-runtime.mjs +9 -5
  9. package/dist/api/client.cjs +3 -3
  10. package/dist/api/client.d.mts +3 -3
  11. package/dist/api/client.d.ts +3 -3
  12. package/dist/api/client.mjs +2 -2
  13. package/dist/api/route-manager.cjs +15 -13
  14. package/dist/api/route-manager.d.mts +7 -9
  15. package/dist/api/route-manager.d.ts +7 -9
  16. package/dist/api/route-manager.mjs +14 -12
  17. package/dist/api/runtime.cjs +12 -10
  18. package/dist/api/runtime.d.mts +6 -8
  19. package/dist/api/runtime.d.ts +6 -8
  20. package/dist/api/runtime.mjs +11 -9
  21. package/dist/{api-client-CyFtZFJ4.d.ts → api-client-BJv9mTbO.d.ts} +2 -2
  22. package/dist/{api-client-BjMmY8OD.d.mts → api-client-Dk9QOLwr.d.mts} +2 -2
  23. package/dist/api.cjs +17 -15
  24. package/dist/api.d.mts +9 -11
  25. package/dist/api.d.ts +9 -11
  26. package/dist/api.mjs +16 -14
  27. package/dist/{app-kT_QXTdx.d.ts → app-CDJHPqZn.d.ts} +11 -4
  28. package/dist/{app-CFZt-srr.d.mts → app-CWjCklhF.d.mts} +11 -4
  29. package/dist/app-markdown.cjs +7 -6
  30. package/dist/app-markdown.d.mts +6 -8
  31. package/dist/app-markdown.d.ts +6 -8
  32. package/dist/app-markdown.mjs +6 -5
  33. package/dist/cache.cjs +6 -3
  34. package/dist/cache.d.mts +23 -2
  35. package/dist/cache.d.ts +23 -2
  36. package/dist/cache.mjs +5 -2
  37. package/dist/{chunk-3UEVPCGW.mjs → chunk-2DMWQWNJ.mjs} +6 -1
  38. package/dist/{chunk-ZXH4TS3F.cjs → chunk-2JG2LJDI.cjs} +3 -64
  39. package/dist/{chunk-QTXBII4Z.cjs → chunk-3TB5QGUW.cjs} +5 -5
  40. package/dist/chunk-45QJHGZM.cjs +1063 -0
  41. package/dist/{chunk-JCKYH4LG.mjs → chunk-45UZKX2J.mjs} +12 -44
  42. package/dist/{chunk-FUCSUGDM.cjs → chunk-4A3YUB4D.cjs} +3 -3
  43. package/dist/{chunk-FUZEBRP3.mjs → chunk-4GP3XZ4Z.mjs} +5 -3
  44. package/dist/chunk-4TLUFAIP.cjs +92 -0
  45. package/dist/chunk-4U5XZDLG.cjs +80 -0
  46. package/dist/{chunk-VXEEATVD.cjs → chunk-4XO5GSD6.cjs} +2 -2
  47. package/dist/{chunk-P664ZVTV.mjs → chunk-4ZZNPK25.mjs} +2 -2
  48. package/dist/{chunk-TGFQVLLF.cjs → chunk-54QWHSNR.cjs} +697 -422
  49. package/dist/{chunk-W36M2BQ4.mjs → chunk-5E65AL7P.mjs} +3 -3
  50. package/dist/{chunk-3LOLJTFV.cjs → chunk-5JEC43MQ.cjs} +11 -11
  51. package/dist/{chunk-INL3THCU.mjs → chunk-5LL6TKII.mjs} +1 -1
  52. package/dist/{chunk-KIIMAWOJ.cjs → chunk-5NAVKJCZ.cjs} +35 -105
  53. package/dist/{chunk-PGZDEPTM.cjs → chunk-5XS5NCVM.cjs} +10 -10
  54. package/dist/{chunk-HXRYZWTA.mjs → chunk-62DY5GKS.mjs} +3 -3
  55. package/dist/{chunk-LSKZMJMP.cjs → chunk-64SBBZDU.cjs} +38 -1
  56. package/dist/chunk-6BWKJ6QS.cjs +43 -0
  57. package/dist/{chunk-JSROZYYO.cjs → chunk-6D24SDKO.cjs} +1 -20
  58. package/dist/{chunk-EIPC3FDA.cjs → chunk-6ILGLCXF.cjs} +9 -5
  59. package/dist/chunk-6QOLZITB.cjs +22 -0
  60. package/dist/{chunk-CXEN47J3.mjs → chunk-73WX6PRY.mjs} +25 -0
  61. package/dist/{chunk-RW63BOV7.cjs → chunk-7FHZ3E6D.cjs} +2 -2
  62. package/dist/chunk-7GNWGLWB.mjs +14 -0
  63. package/dist/{chunk-34UCJRQO.cjs → chunk-7RNAKBWF.cjs} +2 -2
  64. package/dist/{chunk-MSSFIQGM.mjs → chunk-7VAJSSPG.mjs} +41 -10
  65. package/dist/{chunk-KHKLMNI5.mjs → chunk-ACLPN56I.mjs} +43 -25
  66. package/dist/{chunk-JCYYXBAJ.cjs → chunk-AGR7F3LA.cjs} +3 -3
  67. package/dist/{chunk-4GWRFP22.cjs → chunk-ALPWLT27.cjs} +35 -3
  68. package/dist/{chunk-IBUQWVYA.mjs → chunk-AX7S67YV.mjs} +43 -40
  69. package/dist/{chunk-CUM5NYL5.mjs → chunk-AXB5P7BK.mjs} +1 -1
  70. package/dist/{chunk-2ZYGC6SS.cjs → chunk-B6IMBBOS.cjs} +3 -3
  71. package/dist/{chunk-472NCAZ7.cjs → chunk-B77AUCBV.cjs} +3 -3
  72. package/dist/{chunk-FWE7LEQC.cjs → chunk-BD3D7EZV.cjs} +4 -4
  73. package/dist/{chunk-H5CLOUZS.cjs → chunk-BMOBTMDR.cjs} +5 -5
  74. package/dist/{chunk-CQMVIOYP.mjs → chunk-BPGO2IEP.mjs} +7 -7
  75. package/dist/{chunk-E2ROOWQC.cjs → chunk-BPOTSHDO.cjs} +24 -87
  76. package/dist/chunk-BRYPZIMB.mjs +6 -0
  77. package/dist/{chunk-WFRT7JPX.mjs → chunk-BYQVROIP.mjs} +2 -2
  78. package/dist/{chunk-HALDNTIV.mjs → chunk-BYR3RQPB.mjs} +10 -73
  79. package/dist/{chunk-IWZKTWHZ.cjs → chunk-CA62IQY3.cjs} +7 -2
  80. package/dist/chunk-CALY6QG6.mjs +963 -0
  81. package/dist/{chunk-WC5UV2HQ.cjs → chunk-CBXBGM72.cjs} +2 -2
  82. package/dist/{chunk-WW46B6HA.cjs → chunk-CGR525MJ.cjs} +84 -45
  83. package/dist/{chunk-6V4TDWEC.cjs → chunk-CGVPXIRN.cjs} +18 -1
  84. package/dist/{chunk-TYMMBFN2.mjs → chunk-CKFK3Z2V.mjs} +1 -1
  85. package/dist/chunk-CZS6OACQ.mjs +63 -0
  86. package/dist/{chunk-SGBJ247Q.cjs → chunk-D4ROBNTK.cjs} +2 -2
  87. package/dist/{chunk-WEW2JVA4.cjs → chunk-D5IHNDHI.cjs} +6 -6
  88. package/dist/{chunk-ULASELLA.cjs → chunk-DATEWH3W.cjs} +13 -1
  89. package/dist/{chunk-KKSTAEMY.cjs → chunk-DKU6NXRK.cjs} +1 -1
  90. package/dist/{chunk-NBBEQLOK.cjs → chunk-E55H6UKH.cjs} +9 -9
  91. package/dist/{chunk-YR2VBEMO.cjs → chunk-EGCT3AHF.cjs} +1455 -8187
  92. package/dist/{chunk-SDOTRX3V.cjs → chunk-EORXKFLR.cjs} +7 -7
  93. package/dist/{chunk-HD5CF3OE.mjs → chunk-ETPEZLS3.mjs} +2 -2
  94. package/dist/{chunk-2DD4JMQC.cjs → chunk-EW4MEVLE.cjs} +30 -30
  95. package/dist/{chunk-TUBTR2OP.mjs → chunk-FCOLU5P6.mjs} +1173 -7905
  96. package/dist/chunk-FGH3ZXTP.mjs +1063 -0
  97. package/dist/{chunk-Q3NXS4MU.cjs → chunk-FLZ4H25A.cjs} +44 -32
  98. package/dist/chunk-FVPXT2JR.cjs +63 -0
  99. package/dist/{chunk-D2ULAULS.cjs → chunk-FXFKIJDA.cjs} +9 -7
  100. package/dist/chunk-GC3EM6H4.mjs +80 -0
  101. package/dist/chunk-GKQL726H.cjs +6096 -0
  102. package/dist/{chunk-5PWXMJOH.cjs → chunk-GNVEJUT5.cjs} +36 -36
  103. package/dist/{chunk-E3UK5IIB.cjs → chunk-GS3WR5HX.cjs} +5 -3
  104. package/dist/{chunk-QFW2IH5E.mjs → chunk-GZTUT75U.mjs} +5 -2
  105. package/dist/chunk-H3EGVQE5.mjs +22 -0
  106. package/dist/{chunk-KCQBAKIY.cjs → chunk-H44XGLFU.cjs} +36 -68
  107. package/dist/{chunk-LI2F57NI.mjs → chunk-H56MQYEG.mjs} +1 -1
  108. package/dist/chunk-HANGSYMB.mjs +67 -0
  109. package/dist/{chunk-5BWWFHR2.mjs → chunk-HBEBV7OZ.mjs} +3 -3
  110. package/dist/{chunk-RSOJ7DRT.mjs → chunk-HCSVR4YZ.mjs} +1 -58
  111. package/dist/{chunk-HZFM2LWQ.mjs → chunk-HKFBMHCD.mjs} +34 -2
  112. package/dist/{chunk-MLY2RP5R.mjs → chunk-I63UCMXW.mjs} +6 -2
  113. package/dist/{chunk-TO4GJ56K.cjs → chunk-I64GEPOB.cjs} +58 -18
  114. package/dist/{chunk-VNGH5MLF.mjs → chunk-I6UVKUYK.mjs} +1 -1
  115. package/dist/{chunk-EPYU2EBL.mjs → chunk-IF4NU2NG.mjs} +1 -1
  116. package/dist/{chunk-IVLZZZEI.mjs → chunk-IM7DY3ED.mjs} +1 -1
  117. package/dist/{chunk-A3EAIURZ.mjs → chunk-IMQO6ZUU.mjs} +2 -2
  118. package/dist/{chunk-F5QO4FNE.mjs → chunk-INQ64HTJ.mjs} +43 -11
  119. package/dist/{chunk-XKVVMZP5.cjs → chunk-IRYK4Z5M.cjs} +4 -4
  120. package/dist/{chunk-UWPLULNK.mjs → chunk-JGHCKIRI.mjs} +84 -24
  121. package/dist/{chunk-7FPTZLKH.mjs → chunk-JIYYX7WU.mjs} +10 -8
  122. package/dist/{chunk-6MVFL3R5.cjs → chunk-JR4QCLJY.cjs} +1 -58
  123. package/dist/{chunk-Q2KB32T4.mjs → chunk-JXB6DVCO.mjs} +5 -5
  124. package/dist/{chunk-CGBDNNSM.cjs → chunk-KEXK442I.cjs} +44 -12
  125. package/dist/{chunk-5D2JIPLH.cjs → chunk-KK22JPQM.cjs} +10 -10
  126. package/dist/{chunk-EA5K5BKU.mjs → chunk-KNHBTJP6.mjs} +18 -1
  127. package/dist/{chunk-MVL2RAJW.mjs → chunk-KYN5ODF6.mjs} +1 -1
  128. package/dist/{chunk-TYJALEHQ.cjs → chunk-LDPKAYVS.cjs} +16 -16
  129. package/dist/chunk-LFHCG2DU.mjs +43 -0
  130. package/dist/{chunk-EK4QAEFZ.cjs → chunk-LZESP4IR.cjs} +25 -0
  131. package/dist/{chunk-FZ6YYU2W.mjs → chunk-MGMF4VP7.mjs} +38 -1
  132. package/dist/{chunk-EKF7KDFD.mjs → chunk-MNUSIXGS.mjs} +2 -2
  133. package/dist/{chunk-MYIZXDZA.mjs → chunk-MOSYH4CY.mjs} +1 -1
  134. package/dist/{chunk-4ZFL5GFN.cjs → chunk-OILHPMFX.cjs} +86 -26
  135. package/dist/{chunk-AJQTP4OO.mjs → chunk-OJ7JP7RJ.mjs} +1 -1
  136. package/dist/{chunk-7PEP3BUT.mjs → chunk-OLQ73ZO5.mjs} +2 -2
  137. package/dist/{chunk-5OKBARDN.cjs → chunk-OZN4XL6L.cjs} +10 -10
  138. package/dist/{chunk-T5OJPTVN.cjs → chunk-P4TYB4SF.cjs} +2 -2
  139. package/dist/chunk-P7XDC7UJ.mjs +92 -0
  140. package/dist/{chunk-4E5QXOCL.cjs → chunk-PGW7HZE2.cjs} +6 -6
  141. package/dist/{chunk-SHLXACIO.cjs → chunk-PJ42JESY.cjs} +1 -9
  142. package/dist/{chunk-U6QLDL3G.mjs → chunk-PNCM5MFD.mjs} +1 -1
  143. package/dist/{chunk-OAHTRMIC.mjs → chunk-PYQ3ZG4Z.mjs} +11 -11
  144. package/dist/{chunk-KMTGADN3.mjs → chunk-QCVIRVHE.mjs} +1 -9
  145. package/dist/{chunk-RWFLWR5J.cjs → chunk-QJM7A4CR.cjs} +17 -15
  146. package/dist/{chunk-VU6AAZVY.cjs → chunk-RHGK2JEN.cjs} +65 -62
  147. package/dist/{chunk-QV4VE2OW.mjs → chunk-S6ENKNNG.mjs} +5 -3
  148. package/dist/{chunk-EMO6K4YY.cjs → chunk-SHFXCE5A.cjs} +7 -7
  149. package/dist/{chunk-EKN7NSZO.cjs → chunk-SZLNU3GJ.cjs} +8 -5
  150. package/dist/{chunk-WLL43JMO.mjs → chunk-T36UJS3X.mjs} +7 -5
  151. package/dist/{chunk-CNNOLE4O.mjs → chunk-T4II4MMW.mjs} +1 -1
  152. package/dist/{chunk-B6G5CKMC.mjs → chunk-T6DLMX5V.mjs} +11 -11
  153. package/dist/{chunk-4IE345DM.cjs → chunk-TAKG7ZCD.cjs} +14 -14
  154. package/dist/{chunk-SKVTP5PR.mjs → chunk-TFX4RTH2.mjs} +1 -62
  155. package/dist/chunk-TI7UANHI.cjs +77 -0
  156. package/dist/{chunk-ND2CWPOD.mjs → chunk-TS4JHGUJ.mjs} +1 -1
  157. package/dist/{chunk-6BK3K2GB.mjs → chunk-UIDWEU7M.mjs} +83 -44
  158. package/dist/{chunk-DRLKAXDM.mjs → chunk-UM3ZV5EP.mjs} +2 -2
  159. package/dist/{chunk-YWN746US.cjs → chunk-UMQAK3KP.cjs} +85 -54
  160. package/dist/chunk-UNJZGVPU.cjs +6 -0
  161. package/dist/{chunk-XKG2BLFN.cjs → chunk-UXMIFB44.cjs} +18 -35
  162. package/dist/{chunk-DMEPTZTI.mjs → chunk-VBN3UAPQ.mjs} +47 -7
  163. package/dist/chunk-VDRM36QB.cjs +963 -0
  164. package/dist/{chunk-RG4A6LB2.cjs → chunk-VNPXKF3G.cjs} +7 -7
  165. package/dist/chunk-VQDBNVOO.cjs +14 -0
  166. package/dist/chunk-VQGKD7RV.mjs +25 -0
  167. package/dist/{chunk-6HB6V3R7.mjs → chunk-WCWV25PG.mjs} +10 -27
  168. package/dist/{chunk-ZMSZZXOR.mjs → chunk-WDMIW6Q6.mjs} +0 -19
  169. package/dist/{chunk-4WVJLURN.mjs → chunk-WMHG64DA.mjs} +1 -1
  170. package/dist/{chunk-L4DD7ODZ.cjs → chunk-WSOBCAYO.cjs} +37 -35
  171. package/dist/{chunk-ARC7I3O2.mjs → chunk-WW374SGU.mjs} +1 -1
  172. package/dist/{chunk-J63ZH5OQ.cjs → chunk-X3GMHKO3.cjs} +2 -2
  173. package/dist/{chunk-VT4WFRHA.mjs → chunk-XJAEZCT6.mjs} +1 -1
  174. package/dist/{chunk-OCIEZME4.mjs → chunk-XKIUHXHW.mjs} +618 -343
  175. package/dist/{chunk-6XWDE2P2.cjs → chunk-XVIEGKTT.cjs} +30 -5
  176. package/dist/{chunk-N32CC42M.cjs → chunk-Y2GNNXGV.cjs} +72 -54
  177. package/dist/{chunk-ZJD2PN6Z.mjs → chunk-Y4QVEU67.mjs} +30 -18
  178. package/dist/chunk-Y5RG6B7S.mjs +77 -0
  179. package/dist/{chunk-QRKIMN7T.mjs → chunk-Y6LRPO2K.mjs} +13 -1
  180. package/dist/{chunk-BZHXGVMA.mjs → chunk-YJBWB6GF.mjs} +5 -3
  181. package/dist/{chunk-WXJLNP33.cjs → chunk-YR2P74F7.cjs} +9 -7
  182. package/dist/chunk-YZAKIXRL.cjs +67 -0
  183. package/dist/chunk-ZKVJYQPO.mjs +6095 -0
  184. package/dist/{chunk-POSPE3IO.mjs → chunk-ZOABCQGT.mjs} +27 -2
  185. package/dist/chunk-ZQRCSUSB.cjs +25 -0
  186. package/dist/{chunk-ZMMBIVQM.mjs → chunk-ZZGQD7A4.mjs} +16 -86
  187. package/dist/{client-plugins-DUrIYX9B.d.mts → client-plugins-B_5QbNrp.d.mts} +2551 -2653
  188. package/dist/{client-plugins-BvlNhGEB.d.ts → client-plugins-DgSfIWIF.d.ts} +2551 -2653
  189. package/dist/client-plugins.d.mts +5 -7
  190. package/dist/client-plugins.d.ts +5 -7
  191. package/dist/client.cjs +7 -7
  192. package/dist/client.d.mts +11 -12
  193. package/dist/client.d.ts +11 -12
  194. package/dist/client.mjs +6 -6
  195. package/dist/config.d.mts +5 -7
  196. package/dist/config.d.ts +5 -7
  197. package/dist/{devtools-VQWJANJV.cjs → devtools-ANJ7JAPQ.cjs} +21 -18
  198. package/dist/{devtools-JYJNOLPQ.mjs → devtools-VEQQDVHE.mjs} +20 -17
  199. package/dist/docs.cjs +23 -20
  200. package/dist/docs.d.mts +6 -8
  201. package/dist/docs.d.ts +6 -8
  202. package/dist/docs.mjs +22 -19
  203. package/dist/{endpoint-CA-TNX60.d.ts → endpoint-BOE0IAaG.d.ts} +6 -3
  204. package/dist/{endpoint-CCHFqyTE.d.mts → endpoint-DGZRZHux.d.mts} +6 -3
  205. package/dist/environment/vite.cjs +6 -2
  206. package/dist/environment/vite.d.mts +11 -2
  207. package/dist/environment/vite.d.ts +11 -2
  208. package/dist/environment/vite.mjs +5 -1
  209. package/dist/headers.cjs +4 -4
  210. package/dist/headers.mjs +3 -3
  211. package/dist/image/server.cjs +7 -3
  212. package/dist/image/server.d.mts +9 -1
  213. package/dist/image/server.d.ts +9 -1
  214. package/dist/image/server.mjs +6 -2
  215. package/dist/image/sharp.cjs +12 -10
  216. package/dist/image/sharp.mjs +4 -2
  217. package/dist/index.cjs +89 -69
  218. package/dist/index.d.mts +27 -24
  219. package/dist/index.d.ts +27 -24
  220. package/dist/index.mjs +102 -82
  221. package/dist/{integration-api-BPJo5oXb.d.ts → integration-api-BuPHMeKz.d.ts} +2 -2
  222. package/dist/{integration-api-0y4FXJpC.d.mts → integration-api-DWyMmvrR.d.mts} +2 -2
  223. package/dist/integration-orm-P2II2EBK.cjs +14 -0
  224. package/dist/{integration-orm-KV5B3BGZ.mjs → integration-orm-RBKCIQYZ.mjs} +4 -3
  225. package/dist/integrations.cjs +7 -5
  226. package/dist/integrations.d.mts +7 -9
  227. package/dist/integrations.d.ts +7 -9
  228. package/dist/integrations.mjs +6 -4
  229. package/dist/internal/app-markdown-runtime.cjs +6 -5
  230. package/dist/internal/app-markdown-runtime.d.mts +6 -8
  231. package/dist/internal/app-markdown-runtime.d.ts +6 -8
  232. package/dist/internal/app-markdown-runtime.mjs +5 -4
  233. package/dist/internal/build-runtime.cjs +57 -56
  234. package/dist/internal/build-runtime.d.mts +7 -9
  235. package/dist/internal/build-runtime.d.ts +7 -9
  236. package/dist/internal/build-runtime.mjs +56 -55
  237. package/dist/internal/cli-runtime.cjs +36 -30
  238. package/dist/internal/cli-runtime.mjs +36 -30
  239. package/dist/internal/client-error-overlay.cjs +4 -4
  240. package/dist/internal/client-error-overlay.mjs +1 -1
  241. package/dist/internal/compression-runtime.d.mts +5 -7
  242. package/dist/internal/compression-runtime.d.ts +5 -7
  243. package/dist/internal/config-runtime.cjs +21 -18
  244. package/dist/internal/config-runtime.d.mts +6 -8
  245. package/dist/internal/config-runtime.d.ts +6 -8
  246. package/dist/internal/config-runtime.mjs +20 -17
  247. package/dist/internal/docs-precompiled-runtime.cjs +3 -3
  248. package/dist/internal/docs-precompiled-runtime.mjs +2 -2
  249. package/dist/internal/infra-analytics-runtime.cjs +7 -7
  250. package/dist/internal/infra-analytics-runtime.mjs +5 -5
  251. package/dist/internal/metadata-image-runtime.cjs +4 -3
  252. package/dist/internal/metadata-image-runtime.mjs +3 -2
  253. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  254. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  255. package/dist/internal/production-node-env.cjs +2 -2
  256. package/dist/internal/production-node-env.mjs +1 -1
  257. package/dist/internal/production-runtime.cjs +47 -28
  258. package/dist/internal/production-runtime.d.mts +25 -14
  259. package/dist/internal/production-runtime.d.ts +25 -14
  260. package/dist/internal/production-runtime.mjs +50 -31
  261. package/dist/layers-CM5i6T7z.d.mts +55 -0
  262. package/dist/layers-CM5i6T7z.d.ts +55 -0
  263. package/dist/markdown.cjs +4 -4
  264. package/dist/markdown.d.mts +5 -7
  265. package/dist/markdown.d.ts +5 -7
  266. package/dist/markdown.mjs +3 -3
  267. package/dist/middleware.cjs +16 -10
  268. package/dist/middleware.d.mts +7 -9
  269. package/dist/middleware.d.ts +7 -9
  270. package/dist/middleware.mjs +19 -13
  271. package/dist/navigation.cjs +6 -6
  272. package/dist/navigation.d.mts +8 -9
  273. package/dist/navigation.d.ts +8 -9
  274. package/dist/navigation.mjs +5 -5
  275. package/dist/{nitro-MPZJGPXK.mjs → nitro-NFG2LBRC.mjs} +3 -2
  276. package/dist/{nitro-7F65EZZS.cjs → nitro-S2QABUFA.cjs} +4 -3
  277. package/dist/observability.cjs +2 -2
  278. package/dist/observability.mjs +1 -1
  279. package/dist/plugin-DBBZ4JI2.cjs +32 -0
  280. package/dist/plugin-SYMK7PQ2.mjs +32 -0
  281. package/dist/plugin.cjs +56 -43
  282. package/dist/plugin.d.mts +23 -7
  283. package/dist/plugin.d.ts +23 -7
  284. package/dist/plugin.mjs +57 -44
  285. package/dist/{production-runtime-D2aMyzjr.d.ts → production-runtime-DfknD3g_.d.ts} +17 -3
  286. package/dist/{production-runtime-BQ4_WLwQ.d.mts → production-runtime-j_WCfuwB.d.mts} +17 -3
  287. package/dist/programmatic-routes-client-DcoxEaLe.d.mts +55 -0
  288. package/dist/programmatic-routes-client-DcoxEaLe.d.ts +55 -0
  289. package/dist/query/client.cjs +8 -8
  290. package/dist/query/client.mjs +3 -3
  291. package/dist/{render-plan-25p4hrj4.d.ts → render-plan-CFIhcYYS.d.ts} +1 -1
  292. package/dist/{render-plan-DtkXMN8D.d.mts → render-plan-ChUtsymc.d.mts} +1 -1
  293. package/dist/renderer-client.cjs +5 -5
  294. package/dist/renderer-client.d.mts +7 -8
  295. package/dist/renderer-client.d.ts +7 -8
  296. package/dist/renderer-client.mjs +2 -2
  297. package/dist/{request-DgCkIdcn.d.mts → request-F4HRwzSd.d.mts} +1 -1
  298. package/dist/{request-jF4jwx8f.d.ts → request-RJvelT8L.d.ts} +1 -1
  299. package/dist/request.cjs +3 -3
  300. package/dist/request.d.mts +6 -8
  301. package/dist/request.d.ts +6 -8
  302. package/dist/request.mjs +2 -2
  303. package/dist/{route-rendering-Bji6S6a_.d.ts → route-rendering-3a4fbNyC.d.mts} +1 -1
  304. package/dist/{route-rendering-CSBF78Ya.d.mts → route-rendering-D4coJ-kw.d.ts} +1 -1
  305. package/dist/{router-B09Ui3Qm.d.mts → router-DqIssGRO.d.mts} +1 -1
  306. package/dist/{router-CPB9cXtG.d.ts → router-WLEW3Te1.d.ts} +1 -1
  307. package/dist/routes.cjs +6 -5
  308. package/dist/routes.d.mts +5 -7
  309. package/dist/routes.d.ts +5 -7
  310. package/dist/routes.mjs +5 -4
  311. package/dist/{runtime-EDMwLdjv.d.ts → runtime-BrNdLOq9.d.ts} +3 -3
  312. package/dist/{runtime-CM6E6yuI.d.mts → runtime-CmE_j-js.d.mts} +3 -3
  313. package/dist/{schema-dev-notice-Y7MQEFGN.cjs → schema-dev-notice-5JPE67AI.cjs} +6 -4
  314. package/dist/{schema-dev-notice-O67CPXJ6.mjs → schema-dev-notice-WLPZ6WKU.mjs} +4 -2
  315. package/dist/server-action-security.cjs +4 -3
  316. package/dist/server-action-security.mjs +3 -2
  317. package/dist/server-client-bridge-DKWDl5NB.d.mts +7 -0
  318. package/dist/server-client-bridge-DKWDl5NB.d.ts +7 -0
  319. package/dist/server-fn-client.d.mts +3 -3
  320. package/dist/server-fn-client.d.ts +3 -3
  321. package/dist/server-fn.cjs +8 -7
  322. package/dist/server-fn.d.mts +1 -1
  323. package/dist/server-fn.d.ts +1 -1
  324. package/dist/server-fn.mjs +7 -6
  325. package/dist/server-plugins.cjs +5 -5
  326. package/dist/server-plugins.d.mts +6 -8
  327. package/dist/server-plugins.d.ts +6 -8
  328. package/dist/server-plugins.mjs +4 -4
  329. package/dist/server-query-client.d.mts +1 -1
  330. package/dist/server-query-client.d.ts +1 -1
  331. package/dist/server-query.cjs +9 -8
  332. package/dist/server-query.d.mts +1 -1
  333. package/dist/server-query.d.ts +1 -1
  334. package/dist/server-query.mjs +8 -7
  335. package/dist/server.cjs +97 -73
  336. package/dist/server.d.mts +16 -12
  337. package/dist/server.d.ts +16 -12
  338. package/dist/server.mjs +82 -58
  339. package/dist/{spa-router-Cgimzfbi.d.mts → spa-router-C41zjnFl.d.mts} +2 -2
  340. package/dist/{spa-router-B_N8XgVu.d.ts → spa-router-D_0VXqPC.d.ts} +2 -2
  341. package/dist/storage.cjs +6 -2
  342. package/dist/storage.d.mts +9 -1
  343. package/dist/storage.d.ts +9 -1
  344. package/dist/storage.mjs +5 -1
  345. package/dist/testing.cjs +20 -18
  346. package/dist/testing.d.mts +6 -8
  347. package/dist/testing.d.ts +6 -8
  348. package/dist/testing.mjs +16 -14
  349. package/dist/theme/server.cjs +4 -4
  350. package/dist/theme/server.mjs +3 -3
  351. package/dist/{utils-DZciYXYl.d.mts → utils-BKWSe3S7.d.mts} +1 -1
  352. package/dist/{utils-BNxAKAuT.d.ts → utils-YYcWsOJp.d.ts} +1 -1
  353. package/dist/version.cjs +2 -2
  354. package/dist/version.mjs +1 -1
  355. package/dist/vite.cjs +58 -45
  356. package/dist/vite.d.mts +92 -10
  357. package/dist/vite.d.ts +92 -10
  358. package/dist/vite.mjs +59 -46
  359. package/dist/{workflows-jZ4BcdoZ.d.ts → workflows-IWP1ddBm.d.mts} +5 -2
  360. package/dist/{workflows-jZ4BcdoZ.d.mts → workflows-IWP1ddBm.d.ts} +5 -2
  361. package/dist/workflows.cjs +4 -3
  362. package/dist/workflows.d.mts +1 -1
  363. package/dist/workflows.d.ts +1 -1
  364. package/dist/workflows.mjs +3 -2
  365. package/package.json +2 -1
  366. package/dist/chunk-3SDFA7UF.cjs +0 -701
  367. package/dist/chunk-E5GNDG5F.mjs +0 -701
  368. package/dist/integration-orm-55F7CII5.cjs +0 -13
@@ -0,0 +1,963 @@
1
+ import {
2
+ getFarmSourceRoots
3
+ } from "./chunk-BUGNQIHC.mjs";
4
+ import {
5
+ PROGRAMMATIC_ROUTE_FILE_NAMES,
6
+ getProgrammaticRouteDefinitionSource,
7
+ parseProgrammaticRouteModuleId
8
+ } from "./chunk-KNHBTJP6.mjs";
9
+ import {
10
+ __name
11
+ } from "./chunk-LPEX4YW6.mjs";
12
+
13
+ // src/environment-vite.ts
14
+ import { realpathSync } from "fs";
15
+ import path from "path";
16
+
17
+ // src/programmatic-routes-client.ts
18
+ import { builtinModules } from "module";
19
+ import { fileURLToPath } from "url";
20
+ var SERVER_PROPS_KEYS = ["params", "search", "guard", "data"];
21
+ function programmaticClientRouteKey(routesFile, kind, routePath) {
22
+ return `${toPosixPath(routesFile)}\0${kind}\0${routePath}`;
23
+ }
24
+ __name(programmaticClientRouteKey, "programmaticClientRouteKey");
25
+ function resolveProgrammaticClientRoutes(options) {
26
+ const routesFile = toPosixPath(options.routesFile);
27
+ const modules = collectGraph(options.graph, routesFile);
28
+ const routeSourceFiles = /* @__PURE__ */ new Set([routesFile]);
29
+ const exportsByValue = /* @__PURE__ */ new Map();
30
+ const modulesByFile = /* @__PURE__ */ new Map();
31
+ const definitions = options.routes.filter(isProgrammaticRouteDefinition);
32
+ for (const module of modules.values()) {
33
+ if (module.file) {
34
+ modulesByFile.set(module.file, [...modulesByFile.get(module.file) ?? [], module]);
35
+ }
36
+ for (const [exportName, value] of module.exports) {
37
+ if (!isReferenceValue(value)) continue;
38
+ if (!module.routeSource && holdsRouteDefinition(value, definitions)) {
39
+ module.routeSource = true;
40
+ }
41
+ const owners = exportsByValue.get(value) ?? [];
42
+ owners.push({ module, exportName });
43
+ exportsByValue.set(value, owners);
44
+ }
45
+ }
46
+ let untraced = false;
47
+ const definedIn = /* @__PURE__ */ new Map();
48
+ for (const route of definitions) {
49
+ const source = getProgrammaticRouteDefinitionSource(route);
50
+ const callers = (source?.stacks ?? []).map((stack) => findRouteCallers(stack, modulesByFile));
51
+ for (const caller of callers.flat()) caller.routeSource = true;
52
+ definedIn.set(route, callers.flat());
53
+ if (!source || source.raw || (callers[0] ?? []).length === 0) untraced = true;
54
+ }
55
+ for (const module of modules.values()) {
56
+ if (module.routeSource && module.file) routeSourceFiles.add(module.file);
57
+ }
58
+ const reaches = createReachability(modules);
59
+ const closure = createClosure(modules);
60
+ const routeCode = /* @__PURE__ */ new Map();
61
+ const definesRoutes = /* @__PURE__ */ __name((module) => {
62
+ if (!routeCode.has(module)) routeCode.set(module, mayDefineRoutes(module.code));
63
+ return routeCode.get(module);
64
+ }, "definesRoutes");
65
+ const refusal = /* @__PURE__ */ new Map();
66
+ const refuse = /* @__PURE__ */ __name((module) => {
67
+ if (refusal.has(module)) return refusal.get(module);
68
+ let reason = null;
69
+ for (const reached of closure(module)) {
70
+ if (reached.routeSource) {
71
+ reason = reached === module ? `${module.file}, which defines routes` : `${module.file}, which imports ${reached.file ?? reached.id}, which defines routes`;
72
+ break;
73
+ }
74
+ if (untraced && !reached.external && definesRoutes(reached)) {
75
+ reason = `${module.file}, and a route defined as an object literal outside every export can't be traced to its module, so Farm can't tell that ${reached === module ? "it" : reached.file ?? reached.id} defines no routes (build such routes with page(), layout(), or api(), or export them)`;
76
+ break;
77
+ }
78
+ }
79
+ refusal.set(module, reason);
80
+ return reason;
81
+ }, "refuse");
82
+ const locate = /* @__PURE__ */ __name((route, value, label) => {
83
+ if (!isReferenceValue(value)) return `its ${label} is not a component`;
84
+ const owners = exportsByValue.get(value) ?? [];
85
+ const local = owners.filter(({ module }) => module.file && !module.external);
86
+ const eligible = local.filter(({ module }) => !refuse(module));
87
+ if (eligible.length === 0) {
88
+ const refused = local.find(({ module }) => refuse(module));
89
+ if (refused) return `its ${label} is exported by ${refuse(refused.module)}`;
90
+ if (owners.some(({ module }) => module.external)) {
91
+ return `its ${label} comes from a package; re-export it from a module in your app`;
92
+ }
93
+ return `its ${label} is not exported by any module the routes file imports`;
94
+ }
95
+ let defining = eligible.filter(
96
+ (candidate) => !eligible.some(
97
+ (other) => other.module !== candidate.module && reaches(candidate.module, other.module)
98
+ )
99
+ );
100
+ if (defining.length === 0) defining = eligible;
101
+ if (new Set(defining.map(({ module }) => module)).size > 1) {
102
+ const importers = [...modulesByFile.get(routesFile) ?? [], ...definedIn.get(route) ?? []];
103
+ const imported = defining.filter(
104
+ (candidate) => importers.some((importer) => importsBinding(importer, candidate))
105
+ );
106
+ if (imported.length > 0) defining = imported;
107
+ const depth = Math.min(...defining.map(({ module }) => module.depth));
108
+ defining = defining.filter(({ module }) => module.depth === depth);
109
+ const files = [...new Set(defining.map(({ module }) => module.file))];
110
+ if (files.length > 1) {
111
+ return `its ${label} is exported by several modules (${files.join(", ")}) and Farm can't tell which one the routes file uses`;
112
+ }
113
+ }
114
+ const chosen = defining.sort(compareOwners)[0];
115
+ return { file: chosen.module.file, exportName: chosen.exportName };
116
+ }, "locate");
117
+ const routes = /* @__PURE__ */ new Map();
118
+ for (const route of definitions) {
119
+ if (route.kind !== "page" && route.kind !== "layout" || typeof route.path !== "string") {
120
+ continue;
121
+ }
122
+ const routePath = options.normalizeRoutePath(route.path);
123
+ const clientRoute = {
124
+ kind: route.kind,
125
+ path: routePath,
126
+ routesFile
127
+ };
128
+ const problems = [];
129
+ const component = locate(route, route.component, "component");
130
+ if (typeof component === "string") problems.push(component);
131
+ else clientRoute.component = component;
132
+ if (route.kind === "page") {
133
+ if (route.pending) {
134
+ const pending = locate(route, route.pending, "pending component");
135
+ if (typeof pending === "string") problems.push(pending);
136
+ else clientRoute.pending = pending;
137
+ }
138
+ const serverProps = SERVER_PROPS_KEYS.filter((key) => Boolean(route[key]));
139
+ if (serverProps.length > 0) clientRoute.serverProps = serverProps;
140
+ }
141
+ if (problems.length > 0) clientRoute.problem = problems.join("; ");
142
+ routes.set(programmaticClientRouteKey(routesFile, route.kind, routePath), clientRoute);
143
+ }
144
+ return { routes, routeSourceFiles };
145
+ }
146
+ __name(resolveProgrammaticClientRoutes, "resolveProgrammaticClientRoutes");
147
+ function createEvaluatedRouteGraph(server) {
148
+ const evaluated = server.environments?.ssr?.runner?.evaluatedModules;
149
+ if (!evaluated) return void 0;
150
+ const toGraphModule = /* @__PURE__ */ __name((node) => ({
151
+ id: node.id,
152
+ file: node.file || void 0,
153
+ url: node.url,
154
+ imports: node.imports,
155
+ exports: node.exports,
156
+ external: Boolean(node.meta && "externalize" in node.meta),
157
+ code: node.meta && typeof node.meta.code === "string" ? node.meta.code : void 0
158
+ }), "toGraphModule");
159
+ return {
160
+ getModuleById: /* @__PURE__ */ __name((id) => {
161
+ const node = evaluated.getModuleById(id);
162
+ return node ? toGraphModule(node) : void 0;
163
+ }, "getModuleById"),
164
+ getModulesByFile: /* @__PURE__ */ __name((file) => [...evaluated.fileToModulesMap.get(file) ?? []].map(toGraphModule), "getModulesByFile")
165
+ };
166
+ }
167
+ __name(createEvaluatedRouteGraph, "createEvaluatedRouteGraph");
168
+ function mergeProgrammaticClientRoutes(entries) {
169
+ const routes = /* @__PURE__ */ new Map();
170
+ const routeSourceFiles = /* @__PURE__ */ new Set();
171
+ for (const entry of entries) {
172
+ for (const [key, route] of entry.routes) routes.set(key, route);
173
+ for (const file of entry.routeSourceFiles) routeSourceFiles.add(file);
174
+ }
175
+ return { routes, routeSourceFiles };
176
+ }
177
+ __name(mergeProgrammaticClientRoutes, "mergeProgrammaticClientRoutes");
178
+ function generateProgrammaticClientRouteModule(options) {
179
+ const label = `Programmatic ${options.kind} route "${options.routePath}" in ${options.routesFile}`;
180
+ if (options.kind === "api") {
181
+ throw new Error(
182
+ `[Farm.js] ${label} is server-only, but the browser bundle imports it. API routes never reach the browser; call them over HTTP instead.`
183
+ );
184
+ }
185
+ const route = options.route;
186
+ if (!route) {
187
+ throw new Error(
188
+ `[Farm.js] ${label} renders in the browser, but Farm did not find it when it evaluated the routes file on the server, so it can't tell which module holds its component.`
189
+ );
190
+ }
191
+ if (route.problem || !route.component) {
192
+ throw new Error(
193
+ `[Farm.js] ${label} renders in the browser, but ${route.problem ?? "its component has no module"}. The browser never loads the routes file, so move the component to its own module and import it into the routes file (for example \`import { AdminPage } from "./features/admin/page"\`).`
194
+ );
195
+ }
196
+ const component = importExport(route.component, "__farmComponent", options.toImportSpecifier);
197
+ if (route.kind === "layout") {
198
+ return `${component}
199
+ export default __farmComponent;
200
+ `;
201
+ }
202
+ const pending = route.pending ? importExport(route.pending, "__farmPending", options.toImportSpecifier) : "";
203
+ if (!route.pending && !route.serverProps) {
204
+ return `${component}
205
+ export default __farmComponent;
206
+ `;
207
+ }
208
+ const definition = [
209
+ `kind: "page"`,
210
+ `path: ${JSON.stringify(route.path)}`,
211
+ "component: __farmComponent",
212
+ ...route.pending ? ["pending: __farmPending"] : [],
213
+ // Read by createRouteModuleFromProgrammaticPage: the page renders only from props the
214
+ // server resolved for this document.
215
+ ...route.serverProps ? [`__farmServerHooks: ${JSON.stringify(route.serverProps)}`] : []
216
+ ];
217
+ return `
218
+ import * as __farmRendererRuntime from ${JSON.stringify(options.rendererServer)};
219
+ import { createRouteModuleFromProgrammaticPage as __farmCreatePageRouteModule } from "@farm.js/core/routes";
220
+ ${component}
221
+ ${pending}
222
+
223
+ const __farmRouteModule = __farmCreatePageRouteModule(
224
+ { ${definition.join(", ")} },
225
+ {
226
+ createElement: __farmRendererRuntime.createElement,
227
+ Suspense: __farmRendererRuntime.Suspense,
228
+ // Optional hook: only renderers that need it export markFunctionComponent.
229
+ markFunctionComponent: Reflect.get(__farmRendererRuntime, "markFunctionComponent"),
230
+ },
231
+ );
232
+
233
+ export const __farmRouteSchemas = __farmRouteModule.__farmRouteSchemas;
234
+ export const __farmRouteParsesProps = __farmRouteModule.__farmRouteParsesProps;
235
+ export const __farmResolveRouteProps = __farmRouteModule.__farmResolveRouteProps;
236
+ export default __farmRouteModule.default;
237
+ `.trimStart();
238
+ }
239
+ __name(generateProgrammaticClientRouteModule, "generateProgrammaticClientRouteModule");
240
+ function findClientNodeBuiltinChain(entry, getImportedIds) {
241
+ const parents = /* @__PURE__ */ new Map([[entry, null]]);
242
+ const queue = [entry];
243
+ while (queue.length > 0) {
244
+ const id = queue.shift();
245
+ for (const imported of getImportedIds(id) ?? []) {
246
+ if (isNodeBuiltinId(imported)) {
247
+ const chain = [imported];
248
+ for (let cursor = id; cursor; cursor = parents.get(cursor) ?? null) {
249
+ chain.unshift(cursor);
250
+ }
251
+ return chain;
252
+ }
253
+ if (parents.has(imported) || !isApplicationModuleId(imported)) continue;
254
+ parents.set(imported, id);
255
+ queue.push(imported);
256
+ }
257
+ }
258
+ return null;
259
+ }
260
+ __name(findClientNodeBuiltinChain, "findClientNodeBuiltinChain");
261
+ var NODE_BUILTINS = new Set(builtinModules);
262
+ var MODULE_EXTENSION_RE = /\.[cm]?[jt]sx?$/;
263
+ function isApplicationModuleId(id) {
264
+ if (id.startsWith("\0") || id.includes("/node_modules/") || id.includes("\\node_modules\\")) {
265
+ return false;
266
+ }
267
+ return MODULE_EXTENSION_RE.test(id.split("?", 1)[0]);
268
+ }
269
+ __name(isApplicationModuleId, "isApplicationModuleId");
270
+ function isNodeBuiltinId(id) {
271
+ const external = id.indexOf("__vite-browser-external:");
272
+ const bare = external === 0 || external === 1 ? id.slice(external + 24) : id;
273
+ return bare.startsWith("node:") || NODE_BUILTINS.has(bare);
274
+ }
275
+ __name(isNodeBuiltinId, "isNodeBuiltinId");
276
+ function isProgrammaticRouteActionProxy(code) {
277
+ return Boolean(code?.includes("__farmRouteActionTarget: true"));
278
+ }
279
+ __name(isProgrammaticRouteActionProxy, "isProgrammaticRouteActionProxy");
280
+ function collectGraph(graph, routesFile) {
281
+ const modules = /* @__PURE__ */ new Map();
282
+ const queue = [...graph.getModulesByFile(routesFile)].map((node) => ({ node, depth: 0 }));
283
+ while (queue.length > 0) {
284
+ const { node, depth } = queue.shift();
285
+ if (modules.has(node.id)) continue;
286
+ const file = node.file ? toModuleFile(node.file) : void 0;
287
+ const entry = {
288
+ id: node.id,
289
+ file,
290
+ url: node.url,
291
+ code: node.code,
292
+ external: node.external === true,
293
+ imports: [...node.imports],
294
+ exports: readExports(node.exports),
295
+ routeSource: file === routesFile,
296
+ order: modules.size,
297
+ depth
298
+ };
299
+ modules.set(node.id, entry);
300
+ if (entry.external) continue;
301
+ for (const id of entry.imports) {
302
+ const imported = graph.getModuleById(id);
303
+ if (imported && !modules.has(imported.id)) queue.push({ node: imported, depth: depth + 1 });
304
+ }
305
+ }
306
+ return modules;
307
+ }
308
+ __name(collectGraph, "collectGraph");
309
+ function createReachability(modules) {
310
+ const cache = /* @__PURE__ */ new Map();
311
+ const reachable = /* @__PURE__ */ __name((start) => {
312
+ const cached = cache.get(start.id);
313
+ if (cached) return cached;
314
+ const seen = /* @__PURE__ */ new Set();
315
+ const stack = [...start.imports];
316
+ while (stack.length > 0) {
317
+ const id = stack.pop();
318
+ if (seen.has(id)) continue;
319
+ seen.add(id);
320
+ const module = modules.get(id);
321
+ if (module && !module.external) stack.push(...module.imports);
322
+ }
323
+ cache.set(start.id, seen);
324
+ return seen;
325
+ }, "reachable");
326
+ return (from, to) => reachable(from).has(to.id);
327
+ }
328
+ __name(createReachability, "createReachability");
329
+ function createClosure(modules) {
330
+ return /* @__PURE__ */ __name(function* closure(start) {
331
+ const seen = /* @__PURE__ */ new Set([start.id]);
332
+ const queue = [start];
333
+ while (queue.length > 0) {
334
+ const module = queue.shift();
335
+ yield module;
336
+ if (module.external) continue;
337
+ for (const id of module.imports) {
338
+ const imported = modules.get(id);
339
+ if (!imported || seen.has(id)) continue;
340
+ seen.add(id);
341
+ queue.push(imported);
342
+ }
343
+ }
344
+ }, "closure");
345
+ }
346
+ __name(createClosure, "createClosure");
347
+ var WALK_DEPTH = 10;
348
+ var WALK_BUDGET = 2e4;
349
+ function holdsRouteDefinition(value, definitions) {
350
+ const seen = /* @__PURE__ */ new Set();
351
+ const queue = [{ value, depth: 0 }];
352
+ while (queue.length > 0 && seen.size < WALK_BUDGET) {
353
+ const { value: current, depth } = queue.shift();
354
+ if (!isReferenceValue(current) || seen.has(current)) continue;
355
+ seen.add(current);
356
+ if (isRouteManifest(current) || isDefinitionObject(current, definitions)) return true;
357
+ if (depth >= WALK_DEPTH || ArrayBuffer.isView(current) || current instanceof Promise) continue;
358
+ const next = /* @__PURE__ */ __name((child) => {
359
+ if (isReferenceValue(child)) queue.push({ value: child, depth: depth + 1 });
360
+ }, "next");
361
+ try {
362
+ if (Array.isArray(current)) current.forEach(next);
363
+ else if (current instanceof Map) {
364
+ for (const [key, child] of current) {
365
+ next(key);
366
+ next(child);
367
+ }
368
+ } else if (current instanceof Set) current.forEach(next);
369
+ else {
370
+ for (const key of Object.keys(current)) {
371
+ const descriptor = Object.getOwnPropertyDescriptor(current, key);
372
+ if (descriptor && "value" in descriptor) next(descriptor.value);
373
+ }
374
+ }
375
+ } catch {
376
+ }
377
+ }
378
+ return false;
379
+ }
380
+ __name(holdsRouteDefinition, "holdsRouteDefinition");
381
+ function isRouteManifest(value) {
382
+ return value.__farmRoutes === true && Array.isArray(value.routes);
383
+ }
384
+ __name(isRouteManifest, "isRouteManifest");
385
+ function isDefinitionObject(value, definitions) {
386
+ if (!isProgrammaticRouteDefinition(value)) return false;
387
+ const route = value;
388
+ const where = route.kind === "redirect" ? route.source : route.path;
389
+ if (typeof where !== "string") return false;
390
+ const values = Object.values(route);
391
+ const own = /* @__PURE__ */ __name((child) => typeof child === "function" || isReferenceValue(child) && Object.values(child).some((nested) => typeof nested === "function"), "own");
392
+ if (values.some(own)) return true;
393
+ return definitions.some(
394
+ (definition) => definition.kind === route.kind && Object.entries(definition).every(
395
+ ([key, child]) => !isReferenceValue(child) || route[key] === child
396
+ ) && definition[route.kind === "redirect" ? "source" : "path"] === where
397
+ );
398
+ }
399
+ __name(isDefinitionObject, "isDefinitionObject");
400
+ function findRouteCallers(stack, modulesByFile) {
401
+ const files = stack.split("\n").slice(1).map(stackFrameFile).filter((file) => Boolean(file));
402
+ const own = files[0];
403
+ const callers = [];
404
+ for (const file of files) {
405
+ if (file === own) continue;
406
+ const modules = modulesByFile.get(file);
407
+ if (!modules) continue;
408
+ callers.push(...modules);
409
+ if (modules.some((module) => !module.external)) break;
410
+ }
411
+ return callers;
412
+ }
413
+ __name(findRouteCallers, "findRouteCallers");
414
+ function stackFrameFile(frame) {
415
+ const line = frame.trim();
416
+ if (!line.startsWith("at ")) return void 0;
417
+ const location = line.endsWith(")") ? line.slice(line.lastIndexOf("(") + 1, -1) : line.slice(3).replace(/^async /, "");
418
+ const file = location.replace(/:\d+(?::\d+)?$/, "");
419
+ if (!file || file === location || file.startsWith("node:") || file.includes("<anonymous>")) {
420
+ return void 0;
421
+ }
422
+ return toModuleFile(file);
423
+ }
424
+ __name(stackFrameFile, "stackFrameFile");
425
+ function importsBinding(importer, candidate) {
426
+ if (!importer.code || !importer.imports.includes(candidate.module.id)) return false;
427
+ const specifiers = new Set([candidate.module.url, candidate.module.id].filter(Boolean));
428
+ for (const match of importer.code.matchAll(SSR_IMPORT_RE)) {
429
+ if (!specifiers.has(readJsonString(match[1]))) continue;
430
+ if (match[2] === void 0) return true;
431
+ const names = readJsonArray(`[${match[2]}]`);
432
+ if (!names || names.includes(candidate.exportName)) return true;
433
+ }
434
+ return false;
435
+ }
436
+ __name(importsBinding, "importsBinding");
437
+ var SSR_IMPORT_RE = /__vite_ssr_import__\(("(?:[^"\\]|\\.)*")(?:\s*,\s*\{\s*"importedNames"\s*:\s*\[([^\]]*)\])?/g;
438
+ var ROUTE_KINDS = /* @__PURE__ */ new Set(["page", "layout", "api", "redirect"]);
439
+ var ROUTE_FACTORIES = /* @__PURE__ */ new Set([
440
+ "page",
441
+ "layout",
442
+ "api",
443
+ "redirect",
444
+ "createRoute",
445
+ "routesBuilder",
446
+ "defineRoutes"
447
+ ]);
448
+ function mayDefineRoutes(code) {
449
+ if (code === void 0) return true;
450
+ for (const match of code.matchAll(KIND_KEY_RE)) {
451
+ const value = code.slice(match.index + match[0].length);
452
+ const quote = value[0];
453
+ if (quote !== '"' && quote !== "'" && quote !== "`") return true;
454
+ const end = value.indexOf(quote, 1);
455
+ if (end < 0 || ROUTE_KINDS.has(value.slice(1, end))) return true;
456
+ }
457
+ if (KIND_SHORTHAND_RE.test(code) || KIND_ASSIGNMENT_RE.test(code)) return true;
458
+ for (const match of code.matchAll(SSR_IMPORT_RE)) {
459
+ if (!FARM_CORE_RE.test(readJsonString(match[1]) ?? "")) continue;
460
+ if (match[2] === void 0) return true;
461
+ const names = readJsonArray(`[${match[2]}]`);
462
+ if (!names || names.some((name) => ROUTE_FACTORIES.has(String(name)))) return true;
463
+ }
464
+ return false;
465
+ }
466
+ __name(mayDefineRoutes, "mayDefineRoutes");
467
+ var KIND_KEY_RE = /(?<![\w$.])["']?kind["']?\s*:\s*/g;
468
+ var KIND_SHORTHAND_RE = /[{,]\s*kind\s*[,}]/;
469
+ var KIND_ASSIGNMENT_RE = /(?:\.kind|\[\s*["'`]kind["'`]\s*\])\s*=(?!=)/;
470
+ var FARM_CORE_RE = /^@farm\.js\/core(?:\/routes)?$/;
471
+ function readJsonString(text) {
472
+ try {
473
+ const value = JSON.parse(text);
474
+ return typeof value === "string" ? value : void 0;
475
+ } catch {
476
+ return void 0;
477
+ }
478
+ }
479
+ __name(readJsonString, "readJsonString");
480
+ function readJsonArray(text) {
481
+ try {
482
+ const value = JSON.parse(text);
483
+ return Array.isArray(value) ? value : void 0;
484
+ } catch {
485
+ return void 0;
486
+ }
487
+ }
488
+ __name(readJsonArray, "readJsonArray");
489
+ function readExports(namespace) {
490
+ if (!namespace || typeof namespace !== "object" && typeof namespace !== "function") return [];
491
+ const entries = [];
492
+ let keys;
493
+ try {
494
+ keys = Object.keys(namespace);
495
+ } catch {
496
+ return [];
497
+ }
498
+ for (const key of keys) {
499
+ try {
500
+ entries.push([key, namespace[key]]);
501
+ } catch {
502
+ }
503
+ }
504
+ return entries;
505
+ }
506
+ __name(readExports, "readExports");
507
+ function isReferenceValue(value) {
508
+ return typeof value === "function" || typeof value === "object" && value !== null;
509
+ }
510
+ __name(isReferenceValue, "isReferenceValue");
511
+ function isProgrammaticRouteDefinition(value) {
512
+ if (!value || typeof value !== "object") return false;
513
+ const kind = value.kind;
514
+ return kind === "page" || kind === "layout" || kind === "api" || kind === "redirect";
515
+ }
516
+ __name(isProgrammaticRouteDefinition, "isProgrammaticRouteDefinition");
517
+ function compareOwners(left, right) {
518
+ if (left.module !== right.module) return right.module.order - left.module.order;
519
+ if (left.exportName === "default") return -1;
520
+ if (right.exportName === "default") return 1;
521
+ return left.exportName < right.exportName ? -1 : left.exportName > right.exportName ? 1 : 0;
522
+ }
523
+ __name(compareOwners, "compareOwners");
524
+ var IDENTIFIER_RE = /^[A-Za-z_$][\w$]*$/;
525
+ function importExport(value, local, toImportSpecifier) {
526
+ const source = JSON.stringify(toImportSpecifier(value.file));
527
+ if (value.exportName === "default") return `import ${local} from ${source};`;
528
+ const imported = IDENTIFIER_RE.test(value.exportName) ? value.exportName : JSON.stringify(value.exportName);
529
+ return `import { ${imported} as ${local} } from ${source};`;
530
+ }
531
+ __name(importExport, "importExport");
532
+ function toPosixPath(filePath) {
533
+ return filePath.replace(/\\/g, "/");
534
+ }
535
+ __name(toPosixPath, "toPosixPath");
536
+ function toModuleFile(file) {
537
+ if (file.startsWith("file://")) {
538
+ try {
539
+ return toPosixPath(fileURLToPath(file));
540
+ } catch {
541
+ return toPosixPath(file);
542
+ }
543
+ }
544
+ return toPosixPath(file.split("?", 1)[0]);
545
+ }
546
+ __name(toModuleFile, "toModuleFile");
547
+
548
+ // src/environment-vite.ts
549
+ var ENVIRONMENT_IMPORTS = /* @__PURE__ */ new Set([
550
+ "@farm.js/core",
551
+ "@farm.js/core/environment",
552
+ "@farm.js/core/server"
553
+ ]);
554
+ var ENVIRONMENT_FUNCTIONS = /* @__PURE__ */ new Set([
555
+ "createServerOnlyFn",
556
+ "createClientOnlyFn",
557
+ "createIsomorphicFn"
558
+ ]);
559
+ var MODULE_EXTENSION_RE2 = /\.[cm]?[jt]sx?$/;
560
+ function transformEnvironmentFunctions(options) {
561
+ if (!isTransformableModule(options.id) || !containsEnvironmentFunction(options.code)) {
562
+ return null;
563
+ }
564
+ let output = options.code;
565
+ let transformed = false;
566
+ for (let pass = 0; pass < 20; pass++) {
567
+ const ast = options.parse(output);
568
+ const bindings = findEnvironmentFunctionBindings(ast);
569
+ if (bindings.named.size === 0 && bindings.namespaces.size === 0) break;
570
+ const calls = findEnvironmentCalls(ast, bindings);
571
+ if (calls.length === 0) break;
572
+ const innermostCalls = calls.filter(
573
+ (call) => !calls.some(
574
+ (candidate) => candidate !== call && candidate.node.start > call.node.start && candidate.node.end < call.node.end
575
+ )
576
+ );
577
+ const replacements = innermostCalls.map(
578
+ (call) => createReplacement(output, options.id, options.environment, call)
579
+ );
580
+ output = applyReplacements(output, replacements);
581
+ transformed = true;
582
+ }
583
+ if (!transformed) return null;
584
+ const remainingAst = options.parse(output);
585
+ const remainingBindings = findEnvironmentFunctionBindings(remainingAst);
586
+ if (findEnvironmentCalls(remainingAst, remainingBindings).length > 0) {
587
+ throw transformError(options.id, "environment functions are nested too deeply");
588
+ }
589
+ return { code: output };
590
+ }
591
+ __name(transformEnvironmentFunctions, "transformEnvironmentFunctions");
592
+ function farmEnvironmentFunctionsPlugin(options = {}) {
593
+ let routesFiles = /* @__PURE__ */ new Set();
594
+ let farmApi;
595
+ let isBuild = false;
596
+ let sources;
597
+ const routeSourceFiles = /* @__PURE__ */ __name(() => {
598
+ const clientRoutes = farmApi?.getProgrammaticClientRoutes();
599
+ if (sources?.for !== clientRoutes || !sources) {
600
+ sources = {
601
+ for: clientRoutes,
602
+ files: /* @__PURE__ */ new Set([
603
+ ...routesFiles,
604
+ ...[...clientRoutes?.routeSourceFiles ?? []].map(resolvedFile)
605
+ ])
606
+ };
607
+ }
608
+ return sources.files;
609
+ }, "routeSourceFiles");
610
+ const routeSourceError = /* @__PURE__ */ __name((file, importers = []) => `[Farm.js] ${file} defines programmatic routes, but the browser bundle imports it` + (importers.length > 0 ? ` (from ${importers.join(", ")})` : "") + ". Routes files and the modules that define routes carry server-only guards, data hooks, and API handlers, so they never reach the browser. Import the component, server function, or helper from its own module instead.", "routeSourceError");
611
+ return {
612
+ name: "farm:environment-functions",
613
+ enforce: "post",
614
+ configResolved(config) {
615
+ isBuild = config.command === "build";
616
+ farmApi = config.plugins.find((plugin) => plugin.name === "farm")?.api;
617
+ sources = void 0;
618
+ routesFiles = new Set(
619
+ getFarmSourceRoots({ ...options, root: options.root ?? config.root }).flatMap(
620
+ (source) => PROGRAMMATIC_ROUTE_FILE_NAMES.map(
621
+ (name) => resolvedFile(path.resolve(source.root, source.srcDir, name))
622
+ )
623
+ )
624
+ );
625
+ },
626
+ transform(code, id, transformOptions) {
627
+ const environment = resolveBuildEnvironment(
628
+ this,
629
+ transformOptions?.ssr
630
+ );
631
+ const parse = /* @__PURE__ */ __name((source) => this.parse(source), "parse");
632
+ const result = transformEnvironmentFunctions({ code, id, environment, parse });
633
+ if (environment === "client" && !isBuild && !parseProgrammaticRouteModuleId(id) && routeSourceFiles().has(moduleFile(id)) && !isProgrammaticRouteActionProxy(code)) {
634
+ this.error(routeSourceError(moduleFile(id)));
635
+ }
636
+ return result ? { code: result.code, map: null } : null;
637
+ },
638
+ generateBundle() {
639
+ const context = this;
640
+ if (resolveBuildEnvironment(context, false) !== "client") return;
641
+ const forbidden = routeSourceFiles();
642
+ for (const id of this.getModuleIds()) {
643
+ if (parseProgrammaticRouteModuleId(id)) {
644
+ const chain = findClientNodeBuiltinChain(id, (moduleId) => {
645
+ return this.getModuleInfo(moduleId)?.importedIds;
646
+ });
647
+ if (chain) {
648
+ this.error(
649
+ `[Farm.js] The browser bundle reaches the server-only module "${chain.at(-1)}" through the programmatic route module ${moduleFile(id)}: ${chain.map(moduleFile).join(" -> ")}. Keep server-only imports in the routes file or in modules only its guard, data, and API handlers use.`
650
+ );
651
+ }
652
+ continue;
653
+ }
654
+ if (!forbidden.has(moduleFile(id))) continue;
655
+ const info = this.getModuleInfo(id);
656
+ if (isProgrammaticRouteActionProxy(info?.code)) continue;
657
+ this.error(routeSourceError(moduleFile(id), info?.importers.map(moduleFile)));
658
+ }
659
+ }
660
+ };
661
+ }
662
+ __name(farmEnvironmentFunctionsPlugin, "farmEnvironmentFunctionsPlugin");
663
+ function moduleFile(id) {
664
+ return id.split("?", 1)[0].replace(/\\/g, "/");
665
+ }
666
+ __name(moduleFile, "moduleFile");
667
+ function resolvedFile(filePath) {
668
+ try {
669
+ return moduleFile(realpathSync(filePath));
670
+ } catch {
671
+ return moduleFile(filePath);
672
+ }
673
+ }
674
+ __name(resolvedFile, "resolvedFile");
675
+ function resolveBuildEnvironment(context, ssr) {
676
+ if (context.environment?.name === "client") return "client";
677
+ if (context.environment?.name === "rsc" || context.environment?.name === "ssr") {
678
+ return "server";
679
+ }
680
+ return ssr ? "server" : "client";
681
+ }
682
+ __name(resolveBuildEnvironment, "resolveBuildEnvironment");
683
+ function findEnvironmentFunctionBindings(ast) {
684
+ const named = /* @__PURE__ */ new Map();
685
+ const namespaces = /* @__PURE__ */ new Set();
686
+ const body = Array.isArray(ast.body) ? ast.body : [];
687
+ for (const statement of body) {
688
+ if (!isAstNode(statement) || statement.type !== "ImportDeclaration") continue;
689
+ const source = isAstNode(statement.source) ? statement.source.value : void 0;
690
+ if (typeof source !== "string" || !ENVIRONMENT_IMPORTS.has(source)) continue;
691
+ const specifiers = Array.isArray(statement.specifiers) ? statement.specifiers : [];
692
+ for (const specifier of specifiers) {
693
+ if (!isAstNode(specifier) || !isAstNode(specifier.local)) continue;
694
+ const localName = specifier.local.name;
695
+ if (typeof localName !== "string") continue;
696
+ if (specifier.type === "ImportNamespaceSpecifier") {
697
+ namespaces.add(localName);
698
+ continue;
699
+ }
700
+ if (specifier.type !== "ImportSpecifier" || !isAstNode(specifier.imported)) continue;
701
+ const importedName = specifier.imported.name ?? specifier.imported.value;
702
+ if (isEnvironmentFunctionKind(importedName)) {
703
+ named.set(localName, importedName);
704
+ }
705
+ }
706
+ }
707
+ return { named, namespaces };
708
+ }
709
+ __name(findEnvironmentFunctionBindings, "findEnvironmentFunctionBindings");
710
+ function findEnvironmentCalls(ast, bindings) {
711
+ const calls = [];
712
+ walkAst(ast, (node, ancestors) => {
713
+ if (node.type !== "CallExpression" || !isAstNode(node.callee)) return;
714
+ if (node.callee.type === "Identifier" && typeof node.callee.name === "string") {
715
+ const kind = bindings.named.get(node.callee.name);
716
+ if (kind && !isNameShadowed(node.callee.name, ancestors)) calls.push({ node, kind });
717
+ return;
718
+ }
719
+ if (node.callee.type !== "MemberExpression" || node.callee.computed === true || !isAstNode(node.callee.object) || !isAstNode(node.callee.property) || node.callee.object.type !== "Identifier" || node.callee.property.type !== "Identifier" || typeof node.callee.object.name !== "string" || typeof node.callee.property.name !== "string" || !bindings.namespaces.has(node.callee.object.name) || isNameShadowed(node.callee.object.name, ancestors) || !isEnvironmentFunctionKind(node.callee.property.name)) {
720
+ return;
721
+ }
722
+ calls.push({ node, kind: node.callee.property.name });
723
+ });
724
+ return calls;
725
+ }
726
+ __name(findEnvironmentCalls, "findEnvironmentCalls");
727
+ function createReplacement(code, id, environment, call) {
728
+ const args = Array.isArray(call.node.arguments) ? call.node.arguments : [];
729
+ if (args.length !== 1 || !isAstNode(args[0]) || args[0].type === "SpreadElement") {
730
+ throw transformError(id, `${call.kind}() requires exactly one static argument`);
731
+ }
732
+ let replacement;
733
+ if (call.kind === "createIsomorphicFn") {
734
+ replacement = selectIsomorphicImplementation(code, id, environment, args[0]);
735
+ } else {
736
+ const expected = call.kind === "createServerOnlyFn" ? "server" : "client";
737
+ replacement = environment === expected ? readNode(code, args[0]) : `(0, ${readNode(code, call.node.callee)})(undefined, ${JSON.stringify(environment)})`;
738
+ }
739
+ return {
740
+ start: call.node.start,
741
+ end: call.node.end,
742
+ code: `(${replacement})`
743
+ };
744
+ }
745
+ __name(createReplacement, "createReplacement");
746
+ function selectIsomorphicImplementation(code, id, environment, optionsNode) {
747
+ if (optionsNode.type !== "ObjectExpression") {
748
+ throw transformError(id, "createIsomorphicFn() requires an inline options object");
749
+ }
750
+ const properties = Array.isArray(optionsNode.properties) ? optionsNode.properties : [];
751
+ if (properties.some((property) => isAstNode(property) && property.type === "SpreadElement")) {
752
+ throw transformError(id, "createIsomorphicFn() does not support spread properties");
753
+ }
754
+ let selectedProperty;
755
+ for (const property of properties) {
756
+ if (!isAstNode(property) || property.type !== "Property" || property.computed === true) {
757
+ continue;
758
+ }
759
+ const key = readPropertyName(property.key);
760
+ if (key === environment) selectedProperty = property;
761
+ }
762
+ if (!selectedProperty || !isAstNode(selectedProperty.value)) {
763
+ throw transformError(id, `createIsomorphicFn() requires a ${environment} implementation`);
764
+ }
765
+ if (selectedProperty.kind !== void 0 && selectedProperty.kind !== "init") {
766
+ throw transformError(id, "createIsomorphicFn() does not support getters or setters");
767
+ }
768
+ return selectedProperty.method === true ? renderObjectMethod(code, id, selectedProperty.value) : readNode(code, selectedProperty.value);
769
+ }
770
+ __name(selectIsomorphicImplementation, "selectIsomorphicImplementation");
771
+ function renderObjectMethod(code, id, functionNode) {
772
+ if (!isAstNode(functionNode.body) || !Array.isArray(functionNode.params)) {
773
+ throw transformError(id, "createIsomorphicFn() received an unsupported method");
774
+ }
775
+ const params = functionNode.params.map((param) => {
776
+ if (!isAstNode(param)) {
777
+ throw transformError(id, "createIsomorphicFn() received an unsupported parameter");
778
+ }
779
+ return readNode(code, param);
780
+ });
781
+ const asyncPrefix = functionNode.async === true ? "async " : "";
782
+ const generatorMarker = functionNode.generator === true ? "*" : "";
783
+ return `${asyncPrefix}function${generatorMarker}(${params.join(", ")}) ${readNode(code, functionNode.body)}`;
784
+ }
785
+ __name(renderObjectMethod, "renderObjectMethod");
786
+ function applyReplacements(code, replacements) {
787
+ let output = code;
788
+ for (const replacement of replacements.sort((left, right) => right.start - left.start)) {
789
+ output = output.slice(0, replacement.start) + replacement.code + output.slice(replacement.end);
790
+ }
791
+ return output;
792
+ }
793
+ __name(applyReplacements, "applyReplacements");
794
+ function walkAst(node, visit, ancestors = []) {
795
+ visit(node, ancestors);
796
+ const childAncestors = [...ancestors, node];
797
+ for (const [key, value] of Object.entries(node)) {
798
+ if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
799
+ if (isAstNode(value)) {
800
+ walkAst(value, visit, childAncestors);
801
+ } else if (Array.isArray(value)) {
802
+ for (const item of value) {
803
+ if (isAstNode(item)) walkAst(item, visit, childAncestors);
804
+ }
805
+ }
806
+ }
807
+ }
808
+ __name(walkAst, "walkAst");
809
+ function isNameShadowed(name, ancestors) {
810
+ for (const [index, ancestor] of ancestors.entries()) {
811
+ if (isFunctionNode(ancestor)) {
812
+ const params = Array.isArray(ancestor.params) ? ancestor.params : [];
813
+ if (params.some((param) => patternContainsName(param, name))) return true;
814
+ if (patternContainsName(ancestor.id, name)) return true;
815
+ if (isAstNode(ancestor.body) && ancestors.slice(index + 1).includes(ancestor.body) && functionBodyDeclaresVarName(ancestor.body, name)) {
816
+ return true;
817
+ }
818
+ }
819
+ if (ancestor.type === "CatchClause" && patternContainsName(ancestor.param, name)) {
820
+ return true;
821
+ }
822
+ if ((ancestor.type === "BlockStatement" || ancestor.type === "StaticBlock") && blockDeclaresName(ancestor, name)) {
823
+ return true;
824
+ }
825
+ if (loopDeclaresName(ancestor, name)) return true;
826
+ if (ancestor.type === "SwitchStatement" && ancestors.slice(index + 1).some((candidate) => candidate.type === "SwitchCase") && switchDeclaresName(ancestor, name)) {
827
+ return true;
828
+ }
829
+ if (ancestor.type === "ClassExpression" && patternContainsName(ancestor.id, name) && ancestors.slice(index + 1).some((candidate) => candidate.type === "ClassBody")) {
830
+ return true;
831
+ }
832
+ }
833
+ return false;
834
+ }
835
+ __name(isNameShadowed, "isNameShadowed");
836
+ function functionBodyDeclaresVarName(body, name) {
837
+ if (body.type === "VariableDeclaration" && body.kind === "var") {
838
+ const declarations = Array.isArray(body.declarations) ? body.declarations : [];
839
+ if (declarations.some(
840
+ (declaration) => isAstNode(declaration) && patternContainsName(declaration.id, name)
841
+ )) {
842
+ return true;
843
+ }
844
+ }
845
+ for (const [key, value] of Object.entries(body)) {
846
+ if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
847
+ if (isAstNode(value)) {
848
+ if (isNestedVarScope(value)) continue;
849
+ if (functionBodyDeclaresVarName(value, name)) return true;
850
+ } else if (Array.isArray(value)) {
851
+ for (const item of value) {
852
+ if (!isAstNode(item) || isNestedVarScope(item)) continue;
853
+ if (functionBodyDeclaresVarName(item, name)) return true;
854
+ }
855
+ }
856
+ }
857
+ return false;
858
+ }
859
+ __name(functionBodyDeclaresVarName, "functionBodyDeclaresVarName");
860
+ function isNestedVarScope(node) {
861
+ return isFunctionNode(node) || node.type === "ClassDeclaration" || node.type === "ClassExpression";
862
+ }
863
+ __name(isNestedVarScope, "isNestedVarScope");
864
+ function loopDeclaresName(node, name) {
865
+ const declaration = node.type === "ForStatement" ? node.init : node.type === "ForInStatement" || node.type === "ForOfStatement" ? node.left : void 0;
866
+ if (!isAstNode(declaration) || declaration.type !== "VariableDeclaration") return false;
867
+ const declarations = Array.isArray(declaration.declarations) ? declaration.declarations : [];
868
+ return declarations.some((item) => isAstNode(item) && patternContainsName(item.id, name));
869
+ }
870
+ __name(loopDeclaresName, "loopDeclaresName");
871
+ function switchDeclaresName(node, name) {
872
+ const cases = Array.isArray(node.cases) ? node.cases : [];
873
+ return cases.some((switchCase) => {
874
+ if (!isAstNode(switchCase) || !Array.isArray(switchCase.consequent)) return false;
875
+ return switchCase.consequent.some((statement) => {
876
+ if (!isAstNode(statement)) return false;
877
+ if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && patternContainsName(statement.id, name)) {
878
+ return true;
879
+ }
880
+ if (statement.type !== "VariableDeclaration" || statement.kind === "var") return false;
881
+ const declarations = Array.isArray(statement.declarations) ? statement.declarations : [];
882
+ return declarations.some(
883
+ (declaration) => isAstNode(declaration) && patternContainsName(declaration.id, name)
884
+ );
885
+ });
886
+ });
887
+ }
888
+ __name(switchDeclaresName, "switchDeclaresName");
889
+ function blockDeclaresName(block, name) {
890
+ const statements = Array.isArray(block.body) ? block.body : [];
891
+ for (const statement of statements) {
892
+ if (!isAstNode(statement)) continue;
893
+ if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && patternContainsName(statement.id, name)) {
894
+ return true;
895
+ }
896
+ if (statement.type !== "VariableDeclaration" || !Array.isArray(statement.declarations)) {
897
+ continue;
898
+ }
899
+ if (statement.declarations.some(
900
+ (declaration) => isAstNode(declaration) && patternContainsName(declaration.id, name)
901
+ )) {
902
+ return true;
903
+ }
904
+ }
905
+ return false;
906
+ }
907
+ __name(blockDeclaresName, "blockDeclaresName");
908
+ function patternContainsName(value, name) {
909
+ if (!isAstNode(value)) return false;
910
+ if (value.type === "Identifier") return value.name === name;
911
+ if (value.type === "RestElement") return patternContainsName(value.argument, name);
912
+ if (value.type === "AssignmentPattern") return patternContainsName(value.left, name);
913
+ if (value.type === "Property") return patternContainsName(value.value, name);
914
+ const elements = Array.isArray(value.elements) ? value.elements : Array.isArray(value.properties) ? value.properties : [];
915
+ return elements.some((element) => patternContainsName(element, name));
916
+ }
917
+ __name(patternContainsName, "patternContainsName");
918
+ function isFunctionNode(node) {
919
+ return node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
920
+ }
921
+ __name(isFunctionNode, "isFunctionNode");
922
+ function readPropertyName(value) {
923
+ if (!isAstNode(value)) return void 0;
924
+ if (value.type === "Identifier" && typeof value.name === "string") return value.name;
925
+ if (value.type === "Literal" && typeof value.value === "string") return value.value;
926
+ return void 0;
927
+ }
928
+ __name(readPropertyName, "readPropertyName");
929
+ function readNode(code, node) {
930
+ return code.slice(node.start, node.end);
931
+ }
932
+ __name(readNode, "readNode");
933
+ function isAstNode(value) {
934
+ return !!value && typeof value === "object" && typeof value.type === "string" && typeof value.start === "number" && typeof value.end === "number";
935
+ }
936
+ __name(isAstNode, "isAstNode");
937
+ function isEnvironmentFunctionKind(value) {
938
+ return typeof value === "string" && ENVIRONMENT_FUNCTIONS.has(value);
939
+ }
940
+ __name(isEnvironmentFunctionKind, "isEnvironmentFunctionKind");
941
+ function containsEnvironmentFunction(code) {
942
+ return Array.from(ENVIRONMENT_FUNCTIONS).some((name) => code.includes(name));
943
+ }
944
+ __name(containsEnvironmentFunction, "containsEnvironmentFunction");
945
+ function isTransformableModule(id) {
946
+ const cleanId = id.split("?", 1)[0];
947
+ return MODULE_EXTENSION_RE2.test(cleanId) && !/\.d\.[cm]?ts$/.test(cleanId);
948
+ }
949
+ __name(isTransformableModule, "isTransformableModule");
950
+ function transformError(id, message) {
951
+ return new Error(`[Farm environment functions] ${message} in ${id.split("?", 1)[0]}`);
952
+ }
953
+ __name(transformError, "transformError");
954
+
955
+ export {
956
+ programmaticClientRouteKey,
957
+ resolveProgrammaticClientRoutes,
958
+ createEvaluatedRouteGraph,
959
+ mergeProgrammaticClientRoutes,
960
+ generateProgrammaticClientRouteModule,
961
+ transformEnvironmentFunctions,
962
+ farmEnvironmentFunctionsPlugin
963
+ };