@farm.js/core 0.1.39 → 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 (362) hide show
  1. package/dist/{agent-mcp-BhneNPb4.d.mts → agent-mcp-DRlXq3lM.d.ts} +1 -1
  2. package/dist/{agent-mcp-HcTYQmNX.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-CMkoghtp.d.ts → app-CDJHPqZn.d.ts} +11 -4
  28. package/dist/{app-DVzmmbNO.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-QYMZOOC5.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-YFYUYWL7.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-RW63BOV7.cjs → chunk-7FHZ3E6D.cjs} +2 -2
  61. package/dist/chunk-7GNWGLWB.mjs +14 -0
  62. package/dist/{chunk-34UCJRQO.cjs → chunk-7RNAKBWF.cjs} +2 -2
  63. package/dist/{chunk-MSSFIQGM.mjs → chunk-7VAJSSPG.mjs} +41 -10
  64. package/dist/{chunk-PVZE2JGJ.mjs → chunk-ACLPN56I.mjs} +43 -25
  65. package/dist/{chunk-JCYYXBAJ.cjs → chunk-AGR7F3LA.cjs} +3 -3
  66. package/dist/{chunk-UPJLHLJU.cjs → chunk-ALPWLT27.cjs} +4 -4
  67. package/dist/{chunk-ATSDUUFK.mjs → chunk-AX7S67YV.mjs} +33 -40
  68. package/dist/{chunk-CUM5NYL5.mjs → chunk-AXB5P7BK.mjs} +1 -1
  69. package/dist/{chunk-2ZYGC6SS.cjs → chunk-B6IMBBOS.cjs} +3 -3
  70. package/dist/{chunk-472NCAZ7.cjs → chunk-B77AUCBV.cjs} +3 -3
  71. package/dist/{chunk-H5CLOUZS.cjs → chunk-BMOBTMDR.cjs} +5 -5
  72. package/dist/{chunk-CQMVIOYP.mjs → chunk-BPGO2IEP.mjs} +7 -7
  73. package/dist/{chunk-E2ROOWQC.cjs → chunk-BPOTSHDO.cjs} +24 -87
  74. package/dist/chunk-BRYPZIMB.mjs +6 -0
  75. package/dist/{chunk-WFRT7JPX.mjs → chunk-BYQVROIP.mjs} +2 -2
  76. package/dist/{chunk-HALDNTIV.mjs → chunk-BYR3RQPB.mjs} +10 -73
  77. package/dist/{chunk-IWZKTWHZ.cjs → chunk-CA62IQY3.cjs} +7 -2
  78. package/dist/chunk-CALY6QG6.mjs +963 -0
  79. package/dist/{chunk-WC5UV2HQ.cjs → chunk-CBXBGM72.cjs} +2 -2
  80. package/dist/{chunk-WW46B6HA.cjs → chunk-CGR525MJ.cjs} +84 -45
  81. package/dist/{chunk-6V4TDWEC.cjs → chunk-CGVPXIRN.cjs} +18 -1
  82. package/dist/{chunk-677THUVP.mjs → chunk-CKFK3Z2V.mjs} +1 -1
  83. package/dist/chunk-CZS6OACQ.mjs +63 -0
  84. package/dist/{chunk-SGBJ247Q.cjs → chunk-D4ROBNTK.cjs} +2 -2
  85. package/dist/{chunk-WEW2JVA4.cjs → chunk-D5IHNDHI.cjs} +6 -6
  86. package/dist/{chunk-ULASELLA.cjs → chunk-DATEWH3W.cjs} +13 -1
  87. package/dist/{chunk-QUCXCDE2.cjs → chunk-DKU6NXRK.cjs} +1 -1
  88. package/dist/{chunk-NBBEQLOK.cjs → chunk-E55H6UKH.cjs} +9 -9
  89. package/dist/{chunk-AS2VPMEE.cjs → chunk-EGCT3AHF.cjs} +1440 -8172
  90. package/dist/{chunk-SDOTRX3V.cjs → chunk-EORXKFLR.cjs} +7 -7
  91. package/dist/{chunk-HD5CF3OE.mjs → chunk-ETPEZLS3.mjs} +2 -2
  92. package/dist/{chunk-RVXFINNS.cjs → chunk-EW4MEVLE.cjs} +30 -30
  93. package/dist/{chunk-HYTZYOW2.mjs → chunk-FCOLU5P6.mjs} +1172 -7904
  94. package/dist/chunk-FGH3ZXTP.mjs +1063 -0
  95. package/dist/{chunk-HRETEZ2Z.cjs → chunk-FLZ4H25A.cjs} +37 -35
  96. package/dist/chunk-FVPXT2JR.cjs +63 -0
  97. package/dist/{chunk-D2ULAULS.cjs → chunk-FXFKIJDA.cjs} +9 -7
  98. package/dist/chunk-GC3EM6H4.mjs +80 -0
  99. package/dist/chunk-GKQL726H.cjs +6096 -0
  100. package/dist/{chunk-5PWXMJOH.cjs → chunk-GNVEJUT5.cjs} +36 -36
  101. package/dist/{chunk-E3UK5IIB.cjs → chunk-GS3WR5HX.cjs} +5 -3
  102. package/dist/{chunk-QFW2IH5E.mjs → chunk-GZTUT75U.mjs} +5 -2
  103. package/dist/chunk-H3EGVQE5.mjs +22 -0
  104. package/dist/{chunk-LMPAPBUA.cjs → chunk-H44XGLFU.cjs} +36 -68
  105. package/dist/{chunk-SOP2EAA6.mjs → chunk-H56MQYEG.mjs} +1 -1
  106. package/dist/chunk-HANGSYMB.mjs +67 -0
  107. package/dist/{chunk-5BWWFHR2.mjs → chunk-HBEBV7OZ.mjs} +3 -3
  108. package/dist/{chunk-RSOJ7DRT.mjs → chunk-HCSVR4YZ.mjs} +1 -58
  109. package/dist/{chunk-P3PLW4FR.mjs → chunk-HKFBMHCD.mjs} +4 -4
  110. package/dist/{chunk-MLY2RP5R.mjs → chunk-I63UCMXW.mjs} +6 -2
  111. package/dist/{chunk-TO4GJ56K.cjs → chunk-I64GEPOB.cjs} +58 -18
  112. package/dist/{chunk-VNGH5MLF.mjs → chunk-I6UVKUYK.mjs} +1 -1
  113. package/dist/{chunk-EPYU2EBL.mjs → chunk-IF4NU2NG.mjs} +1 -1
  114. package/dist/{chunk-IVLZZZEI.mjs → chunk-IM7DY3ED.mjs} +1 -1
  115. package/dist/{chunk-YKZRDB5Z.mjs → chunk-IMQO6ZUU.mjs} +2 -2
  116. package/dist/{chunk-F5QO4FNE.mjs → chunk-INQ64HTJ.mjs} +43 -11
  117. package/dist/{chunk-BXDJXFQG.cjs → chunk-IRYK4Z5M.cjs} +4 -4
  118. package/dist/{chunk-UWPLULNK.mjs → chunk-JGHCKIRI.mjs} +84 -24
  119. package/dist/{chunk-BFJTHYTN.mjs → chunk-JIYYX7WU.mjs} +10 -8
  120. package/dist/{chunk-6MVFL3R5.cjs → chunk-JR4QCLJY.cjs} +1 -58
  121. package/dist/{chunk-Q2KB32T4.mjs → chunk-JXB6DVCO.mjs} +5 -5
  122. package/dist/{chunk-CGBDNNSM.cjs → chunk-KEXK442I.cjs} +44 -12
  123. package/dist/{chunk-5D2JIPLH.cjs → chunk-KK22JPQM.cjs} +10 -10
  124. package/dist/{chunk-EA5K5BKU.mjs → chunk-KNHBTJP6.mjs} +18 -1
  125. package/dist/{chunk-MVL2RAJW.mjs → chunk-KYN5ODF6.mjs} +1 -1
  126. package/dist/{chunk-B5J2YVG7.cjs → chunk-LDPKAYVS.cjs} +2 -2
  127. package/dist/chunk-LFHCG2DU.mjs +43 -0
  128. package/dist/{chunk-FZ6YYU2W.mjs → chunk-MGMF4VP7.mjs} +38 -1
  129. package/dist/{chunk-KTSUBU2E.mjs → chunk-MNUSIXGS.mjs} +2 -2
  130. package/dist/{chunk-MYIZXDZA.mjs → chunk-MOSYH4CY.mjs} +1 -1
  131. package/dist/{chunk-4ZFL5GFN.cjs → chunk-OILHPMFX.cjs} +86 -26
  132. package/dist/{chunk-AJQTP4OO.mjs → chunk-OJ7JP7RJ.mjs} +1 -1
  133. package/dist/{chunk-VWBHM3F6.mjs → chunk-OLQ73ZO5.mjs} +1 -1
  134. package/dist/{chunk-5OKBARDN.cjs → chunk-OZN4XL6L.cjs} +10 -10
  135. package/dist/{chunk-T5OJPTVN.cjs → chunk-P4TYB4SF.cjs} +2 -2
  136. package/dist/chunk-P7XDC7UJ.mjs +92 -0
  137. package/dist/{chunk-5ULKUBIA.cjs → chunk-PGW7HZE2.cjs} +6 -6
  138. package/dist/{chunk-SHLXACIO.cjs → chunk-PJ42JESY.cjs} +1 -9
  139. package/dist/{chunk-U6QLDL3G.mjs → chunk-PNCM5MFD.mjs} +1 -1
  140. package/dist/{chunk-OAHTRMIC.mjs → chunk-PYQ3ZG4Z.mjs} +11 -11
  141. package/dist/{chunk-KMTGADN3.mjs → chunk-QCVIRVHE.mjs} +1 -9
  142. package/dist/{chunk-RWFLWR5J.cjs → chunk-QJM7A4CR.cjs} +17 -15
  143. package/dist/{chunk-BWIQR4DH.cjs → chunk-RHGK2JEN.cjs} +56 -63
  144. package/dist/{chunk-QV4VE2OW.mjs → chunk-S6ENKNNG.mjs} +5 -3
  145. package/dist/{chunk-HRSAQ23K.cjs → chunk-SHFXCE5A.cjs} +4 -4
  146. package/dist/{chunk-EKN7NSZO.cjs → chunk-SZLNU3GJ.cjs} +8 -5
  147. package/dist/{chunk-WLL43JMO.mjs → chunk-T36UJS3X.mjs} +7 -5
  148. package/dist/{chunk-CNNOLE4O.mjs → chunk-T4II4MMW.mjs} +1 -1
  149. package/dist/{chunk-GKBWWRBG.mjs → chunk-T6DLMX5V.mjs} +11 -11
  150. package/dist/{chunk-CIOT4HGT.cjs → chunk-TAKG7ZCD.cjs} +14 -14
  151. package/dist/{chunk-SKVTP5PR.mjs → chunk-TFX4RTH2.mjs} +1 -62
  152. package/dist/chunk-TI7UANHI.cjs +77 -0
  153. package/dist/{chunk-6BK3K2GB.mjs → chunk-UIDWEU7M.mjs} +83 -44
  154. package/dist/{chunk-EGCTIS5F.mjs → chunk-UM3ZV5EP.mjs} +1 -1
  155. package/dist/{chunk-YWN746US.cjs → chunk-UMQAK3KP.cjs} +85 -54
  156. package/dist/chunk-UNJZGVPU.cjs +6 -0
  157. package/dist/{chunk-XKG2BLFN.cjs → chunk-UXMIFB44.cjs} +18 -35
  158. package/dist/{chunk-DMEPTZTI.mjs → chunk-VBN3UAPQ.mjs} +47 -7
  159. package/dist/chunk-VDRM36QB.cjs +963 -0
  160. package/dist/{chunk-RG4A6LB2.cjs → chunk-VNPXKF3G.cjs} +7 -7
  161. package/dist/chunk-VQDBNVOO.cjs +14 -0
  162. package/dist/chunk-VQGKD7RV.mjs +25 -0
  163. package/dist/{chunk-6HB6V3R7.mjs → chunk-WCWV25PG.mjs} +10 -27
  164. package/dist/{chunk-ZMSZZXOR.mjs → chunk-WDMIW6Q6.mjs} +0 -19
  165. package/dist/{chunk-4WVJLURN.mjs → chunk-WMHG64DA.mjs} +1 -1
  166. package/dist/{chunk-A657YSP4.cjs → chunk-WSOBCAYO.cjs} +37 -35
  167. package/dist/{chunk-ARC7I3O2.mjs → chunk-WW374SGU.mjs} +1 -1
  168. package/dist/{chunk-J63ZH5OQ.cjs → chunk-X3GMHKO3.cjs} +2 -2
  169. package/dist/{chunk-VT4WFRHA.mjs → chunk-XJAEZCT6.mjs} +1 -1
  170. package/dist/{chunk-ZUPXLIGB.mjs → chunk-XKIUHXHW.mjs} +618 -343
  171. package/dist/{chunk-6XWDE2P2.cjs → chunk-XVIEGKTT.cjs} +30 -5
  172. package/dist/{chunk-QG775BRV.cjs → chunk-Y2GNNXGV.cjs} +72 -54
  173. package/dist/{chunk-75HN5IZ3.mjs → chunk-Y4QVEU67.mjs} +21 -19
  174. package/dist/chunk-Y5RG6B7S.mjs +77 -0
  175. package/dist/{chunk-QRKIMN7T.mjs → chunk-Y6LRPO2K.mjs} +13 -1
  176. package/dist/{chunk-BZHXGVMA.mjs → chunk-YJBWB6GF.mjs} +5 -3
  177. package/dist/{chunk-WXJLNP33.cjs → chunk-YR2P74F7.cjs} +9 -7
  178. package/dist/chunk-YZAKIXRL.cjs +67 -0
  179. package/dist/chunk-ZKVJYQPO.mjs +6095 -0
  180. package/dist/{chunk-POSPE3IO.mjs → chunk-ZOABCQGT.mjs} +27 -2
  181. package/dist/chunk-ZQRCSUSB.cjs +25 -0
  182. package/dist/{chunk-ZMMBIVQM.mjs → chunk-ZZGQD7A4.mjs} +16 -86
  183. package/dist/{client-plugins-CsCuCLBz.d.mts → client-plugins-B_5QbNrp.d.mts} +2544 -2664
  184. package/dist/{client-plugins-D0ke-Hc8.d.ts → client-plugins-DgSfIWIF.d.ts} +2544 -2664
  185. package/dist/client-plugins.d.mts +5 -7
  186. package/dist/client-plugins.d.ts +5 -7
  187. package/dist/client.cjs +5 -5
  188. package/dist/client.d.mts +11 -12
  189. package/dist/client.d.ts +11 -12
  190. package/dist/client.mjs +4 -4
  191. package/dist/config.d.mts +5 -7
  192. package/dist/config.d.ts +5 -7
  193. package/dist/{devtools-LW4QQ5J3.cjs → devtools-ANJ7JAPQ.cjs} +21 -18
  194. package/dist/{devtools-5AFIPVUJ.mjs → devtools-VEQQDVHE.mjs} +20 -17
  195. package/dist/docs.cjs +23 -20
  196. package/dist/docs.d.mts +6 -8
  197. package/dist/docs.d.ts +6 -8
  198. package/dist/docs.mjs +22 -19
  199. package/dist/{endpoint-CA-TNX60.d.ts → endpoint-BOE0IAaG.d.ts} +6 -3
  200. package/dist/{endpoint-CCHFqyTE.d.mts → endpoint-DGZRZHux.d.mts} +6 -3
  201. package/dist/environment/vite.cjs +6 -2
  202. package/dist/environment/vite.d.mts +11 -2
  203. package/dist/environment/vite.d.ts +11 -2
  204. package/dist/environment/vite.mjs +5 -1
  205. package/dist/headers.cjs +4 -4
  206. package/dist/headers.mjs +3 -3
  207. package/dist/image/server.cjs +7 -3
  208. package/dist/image/server.d.mts +9 -1
  209. package/dist/image/server.d.ts +9 -1
  210. package/dist/image/server.mjs +6 -2
  211. package/dist/image/sharp.cjs +12 -10
  212. package/dist/image/sharp.mjs +4 -2
  213. package/dist/index.cjs +87 -67
  214. package/dist/index.d.mts +27 -24
  215. package/dist/index.d.ts +27 -24
  216. package/dist/index.mjs +100 -80
  217. package/dist/{integration-api-BPJo5oXb.d.ts → integration-api-BuPHMeKz.d.ts} +2 -2
  218. package/dist/{integration-api-0y4FXJpC.d.mts → integration-api-DWyMmvrR.d.mts} +2 -2
  219. package/dist/integration-orm-P2II2EBK.cjs +14 -0
  220. package/dist/{integration-orm-KV5B3BGZ.mjs → integration-orm-RBKCIQYZ.mjs} +4 -3
  221. package/dist/integrations.cjs +7 -5
  222. package/dist/integrations.d.mts +7 -9
  223. package/dist/integrations.d.ts +7 -9
  224. package/dist/integrations.mjs +6 -4
  225. package/dist/internal/app-markdown-runtime.cjs +6 -5
  226. package/dist/internal/app-markdown-runtime.d.mts +6 -8
  227. package/dist/internal/app-markdown-runtime.d.ts +6 -8
  228. package/dist/internal/app-markdown-runtime.mjs +5 -4
  229. package/dist/internal/build-runtime.cjs +56 -55
  230. package/dist/internal/build-runtime.d.mts +7 -9
  231. package/dist/internal/build-runtime.d.ts +7 -9
  232. package/dist/internal/build-runtime.mjs +55 -54
  233. package/dist/internal/cli-runtime.cjs +36 -30
  234. package/dist/internal/cli-runtime.mjs +36 -30
  235. package/dist/internal/client-error-overlay.cjs +4 -4
  236. package/dist/internal/client-error-overlay.mjs +1 -1
  237. package/dist/internal/compression-runtime.d.mts +5 -7
  238. package/dist/internal/compression-runtime.d.ts +5 -7
  239. package/dist/internal/config-runtime.cjs +21 -18
  240. package/dist/internal/config-runtime.d.mts +6 -8
  241. package/dist/internal/config-runtime.d.ts +6 -8
  242. package/dist/internal/config-runtime.mjs +20 -17
  243. package/dist/internal/docs-precompiled-runtime.cjs +3 -3
  244. package/dist/internal/docs-precompiled-runtime.mjs +2 -2
  245. package/dist/internal/infra-analytics-runtime.cjs +7 -7
  246. package/dist/internal/infra-analytics-runtime.mjs +5 -5
  247. package/dist/internal/metadata-image-runtime.cjs +4 -3
  248. package/dist/internal/metadata-image-runtime.mjs +3 -2
  249. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  250. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  251. package/dist/internal/production-node-env.cjs +2 -2
  252. package/dist/internal/production-node-env.mjs +1 -1
  253. package/dist/internal/production-runtime.cjs +44 -27
  254. package/dist/internal/production-runtime.d.mts +25 -14
  255. package/dist/internal/production-runtime.d.ts +25 -14
  256. package/dist/internal/production-runtime.mjs +47 -30
  257. package/dist/layers-CM5i6T7z.d.mts +55 -0
  258. package/dist/layers-CM5i6T7z.d.ts +55 -0
  259. package/dist/markdown.cjs +4 -4
  260. package/dist/markdown.d.mts +5 -7
  261. package/dist/markdown.d.ts +5 -7
  262. package/dist/markdown.mjs +3 -3
  263. package/dist/middleware.cjs +16 -10
  264. package/dist/middleware.d.mts +7 -9
  265. package/dist/middleware.d.ts +7 -9
  266. package/dist/middleware.mjs +19 -13
  267. package/dist/navigation.cjs +4 -4
  268. package/dist/navigation.d.mts +8 -9
  269. package/dist/navigation.d.ts +8 -9
  270. package/dist/navigation.mjs +3 -3
  271. package/dist/{nitro-MPZJGPXK.mjs → nitro-NFG2LBRC.mjs} +3 -2
  272. package/dist/{nitro-7F65EZZS.cjs → nitro-S2QABUFA.cjs} +4 -3
  273. package/dist/observability.cjs +2 -2
  274. package/dist/observability.mjs +1 -1
  275. package/dist/plugin-DBBZ4JI2.cjs +32 -0
  276. package/dist/plugin-SYMK7PQ2.mjs +32 -0
  277. package/dist/plugin.cjs +55 -42
  278. package/dist/plugin.d.mts +23 -7
  279. package/dist/plugin.d.ts +23 -7
  280. package/dist/plugin.mjs +56 -43
  281. package/dist/{production-runtime-BaI3WHnV.d.ts → production-runtime-DfknD3g_.d.ts} +17 -3
  282. package/dist/{production-runtime-DfRP0cV0.d.mts → production-runtime-j_WCfuwB.d.mts} +17 -3
  283. package/dist/programmatic-routes-client-DcoxEaLe.d.mts +55 -0
  284. package/dist/programmatic-routes-client-DcoxEaLe.d.ts +55 -0
  285. package/dist/query/client.cjs +2 -2
  286. package/dist/query/client.mjs +1 -1
  287. package/dist/{render-plan-CfIdJKAf.d.ts → render-plan-CFIhcYYS.d.ts} +1 -1
  288. package/dist/{render-plan-Dg8RBYFa.d.mts → render-plan-ChUtsymc.d.mts} +1 -1
  289. package/dist/renderer-client.d.mts +7 -8
  290. package/dist/renderer-client.d.ts +7 -8
  291. package/dist/{request-DfE02G_A.d.mts → request-F4HRwzSd.d.mts} +1 -1
  292. package/dist/{request-CEbHIIl4.d.ts → request-RJvelT8L.d.ts} +1 -1
  293. package/dist/request.cjs +3 -3
  294. package/dist/request.d.mts +6 -8
  295. package/dist/request.d.ts +6 -8
  296. package/dist/request.mjs +2 -2
  297. package/dist/{route-rendering-C4oHbv6C.d.ts → route-rendering-3a4fbNyC.d.mts} +1 -1
  298. package/dist/{route-rendering-BHyOfXjD.d.mts → route-rendering-D4coJ-kw.d.ts} +1 -1
  299. package/dist/{router-DwhA61SB.d.mts → router-DqIssGRO.d.mts} +1 -1
  300. package/dist/{router-uRN_29Em.d.ts → router-WLEW3Te1.d.ts} +1 -1
  301. package/dist/routes.cjs +6 -5
  302. package/dist/routes.d.mts +5 -7
  303. package/dist/routes.d.ts +5 -7
  304. package/dist/routes.mjs +5 -4
  305. package/dist/{runtime-COk03hmx.d.ts → runtime-BrNdLOq9.d.ts} +3 -3
  306. package/dist/{runtime-BEdHhN4C.d.mts → runtime-CmE_j-js.d.mts} +3 -3
  307. package/dist/{schema-dev-notice-Y7MQEFGN.cjs → schema-dev-notice-5JPE67AI.cjs} +6 -4
  308. package/dist/{schema-dev-notice-O67CPXJ6.mjs → schema-dev-notice-WLPZ6WKU.mjs} +4 -2
  309. package/dist/server-action-security.cjs +4 -3
  310. package/dist/server-action-security.mjs +3 -2
  311. package/dist/server-client-bridge-DKWDl5NB.d.mts +7 -0
  312. package/dist/server-client-bridge-DKWDl5NB.d.ts +7 -0
  313. package/dist/server-fn-client.d.mts +3 -3
  314. package/dist/server-fn-client.d.ts +3 -3
  315. package/dist/server-fn.cjs +8 -7
  316. package/dist/server-fn.d.mts +1 -1
  317. package/dist/server-fn.d.ts +1 -1
  318. package/dist/server-fn.mjs +7 -6
  319. package/dist/server-plugins.cjs +5 -5
  320. package/dist/server-plugins.d.mts +6 -8
  321. package/dist/server-plugins.d.ts +6 -8
  322. package/dist/server-plugins.mjs +4 -4
  323. package/dist/server-query-client.d.mts +1 -1
  324. package/dist/server-query-client.d.ts +1 -1
  325. package/dist/server-query.cjs +9 -8
  326. package/dist/server-query.d.mts +1 -1
  327. package/dist/server-query.d.ts +1 -1
  328. package/dist/server-query.mjs +8 -7
  329. package/dist/server.cjs +96 -72
  330. package/dist/server.d.mts +16 -12
  331. package/dist/server.d.ts +16 -12
  332. package/dist/server.mjs +81 -57
  333. package/dist/{spa-router-w4aFOuyn.d.mts → spa-router-C41zjnFl.d.mts} +2 -2
  334. package/dist/{spa-router-DrVOBVGg.d.ts → spa-router-D_0VXqPC.d.ts} +2 -2
  335. package/dist/storage.cjs +6 -2
  336. package/dist/storage.d.mts +9 -1
  337. package/dist/storage.d.ts +9 -1
  338. package/dist/storage.mjs +5 -1
  339. package/dist/testing.cjs +20 -18
  340. package/dist/testing.d.mts +6 -8
  341. package/dist/testing.d.ts +6 -8
  342. package/dist/testing.mjs +16 -14
  343. package/dist/theme/server.cjs +4 -4
  344. package/dist/theme/server.mjs +3 -3
  345. package/dist/{utils-Dhuqwmd2.d.ts → utils-BKWSe3S7.d.mts} +1 -1
  346. package/dist/{utils-BtYehqeU.d.mts → utils-YYcWsOJp.d.ts} +1 -1
  347. package/dist/version.cjs +2 -2
  348. package/dist/version.mjs +1 -1
  349. package/dist/vite.cjs +57 -44
  350. package/dist/vite.d.mts +92 -10
  351. package/dist/vite.d.ts +92 -10
  352. package/dist/vite.mjs +58 -45
  353. package/dist/{workflows-jZ4BcdoZ.d.ts → workflows-IWP1ddBm.d.mts} +5 -2
  354. package/dist/{workflows-jZ4BcdoZ.d.mts → workflows-IWP1ddBm.d.ts} +5 -2
  355. package/dist/workflows.cjs +4 -3
  356. package/dist/workflows.d.mts +1 -1
  357. package/dist/workflows.d.ts +1 -1
  358. package/dist/workflows.mjs +3 -2
  359. package/package.json +2 -1
  360. package/dist/chunk-3SDFA7UF.cjs +0 -701
  361. package/dist/chunk-E5GNDG5F.mjs +0 -701
  362. package/dist/integration-orm-55F7CII5.cjs +0 -13
@@ -1,701 +0,0 @@
1
- import {
2
- __name
3
- } from "./chunk-LPEX4YW6.mjs";
4
-
5
- // src/programmatic-routes-client.ts
6
- import { builtinModules } from "module";
7
- var ROUTE_IMPORT_SOURCES = /* @__PURE__ */ new Set(["@farm.js/core", "@farm.js/core/routes"]);
8
- var ROUTE_FACTORY_NAMES = {
9
- createRoute: "page",
10
- page: "page",
11
- layout: "layout",
12
- api: "api"
13
- };
14
- var SERVER_ONLY_KEYS = {
15
- page: /* @__PURE__ */ new Set(["guard", "data", "staticPaths", "generateMetadata"]),
16
- layout: /* @__PURE__ */ new Set(["generateMetadata"]),
17
- api: /* @__PURE__ */ new Set(["GET", "HEAD", "QUERY", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"])
18
- };
19
- var MODULE_EXTENSION_RE = /\.[cm]?[jt]sx?$/;
20
- var NODE_BUILTINS = new Set(builtinModules);
21
- function transformProgrammaticRoutesForClient(options) {
22
- if (!isTransformableModule(options.id) || !options.code.includes("@farm.js/core")) return null;
23
- const ast = options.parse(options.code);
24
- const bindings = findRouteFactoryBindings(ast);
25
- if (!bindings) return null;
26
- const calls = findRouteFactoryCalls(ast, bindings);
27
- if (calls.length === 0 && !bindings.definesRoutes) return null;
28
- const replacements = calls.flatMap((call) => {
29
- const replacement = stripRouteOptions(options.code, call.kind, call.options);
30
- return replacement ? [replacement] : [];
31
- });
32
- let code = applyReplacements(options.code, withoutNested(replacements));
33
- if (replacements.length > 0) {
34
- code = applyReplacements(code, removeUnusedTopLevel(code, options.parse(code)));
35
- }
36
- const builtin = findNodeBuiltinImport(options.parse(code));
37
- if (builtin) {
38
- throw new Error(
39
- `[Farm.js] ${options.id} defines programmatic routes and is loaded in the browser to hydrate them, but it still imports the server-only module "${builtin}" after Farm removed the server route hooks (guard, data, staticPaths, generateMetadata, and API handlers). Use it only inside those hooks, or move it into a module that only they import.`
40
- );
41
- }
42
- return { code, definesRoutes: true };
43
- }
44
- __name(transformProgrammaticRoutesForClient, "transformProgrammaticRoutesForClient");
45
- function findClientNodeBuiltinChain(entry, getImportedIds) {
46
- const parents = /* @__PURE__ */ new Map([[entry, null]]);
47
- const queue = [entry];
48
- while (queue.length > 0) {
49
- const id = queue.shift();
50
- for (const imported of getImportedIds(id) ?? []) {
51
- if (isNodeBuiltinId(imported)) {
52
- const chain = [imported];
53
- for (let cursor = id; cursor; cursor = parents.get(cursor) ?? null) {
54
- chain.unshift(cursor);
55
- }
56
- return chain;
57
- }
58
- if (parents.has(imported) || !isApplicationModuleId(imported)) continue;
59
- parents.set(imported, id);
60
- queue.push(imported);
61
- }
62
- }
63
- return null;
64
- }
65
- __name(findClientNodeBuiltinChain, "findClientNodeBuiltinChain");
66
- function isTransformableModule(id) {
67
- if (id.startsWith("\0") || id.includes("/node_modules/") || id.includes("\\node_modules\\")) {
68
- return false;
69
- }
70
- return MODULE_EXTENSION_RE.test(id.split("?", 1)[0]);
71
- }
72
- __name(isTransformableModule, "isTransformableModule");
73
- function isApplicationModuleId(id) {
74
- return !id.startsWith("\0") && isTransformableModule(id);
75
- }
76
- __name(isApplicationModuleId, "isApplicationModuleId");
77
- function isNodeBuiltinId(id) {
78
- const external = id.indexOf("__vite-browser-external:");
79
- const bare = external === 0 || external === 1 ? id.slice(external + 24) : id;
80
- return bare.startsWith("node:") || NODE_BUILTINS.has(bare);
81
- }
82
- __name(isNodeBuiltinId, "isNodeBuiltinId");
83
- function findRouteFactoryBindings(ast) {
84
- const factories = /* @__PURE__ */ new Map();
85
- const namespaces = /* @__PURE__ */ new Set();
86
- const defineRoutesNames = /* @__PURE__ */ new Set();
87
- let definesRoutes = false;
88
- for (const statement of asNodes(ast.body)) {
89
- if (statement.type !== "ImportDeclaration" || statement.importKind === "type") continue;
90
- const source = isAstNode(statement.source) ? statement.source.value : void 0;
91
- if (typeof source !== "string" || !ROUTE_IMPORT_SOURCES.has(source)) continue;
92
- for (const specifier of asNodes(statement.specifiers)) {
93
- const local = isAstNode(specifier.local) ? specifier.local.name : void 0;
94
- if (typeof local !== "string") continue;
95
- if (specifier.type === "ImportNamespaceSpecifier") {
96
- namespaces.add(local);
97
- } else if (specifier.type === "ImportSpecifier" && isAstNode(specifier.imported)) {
98
- const imported = String(specifier.imported.name ?? specifier.imported.value);
99
- if (imported === "defineRoutes") defineRoutesNames.add(local);
100
- const kind = ROUTE_FACTORY_NAMES[imported];
101
- if (kind) factories.set(local, kind);
102
- }
103
- }
104
- }
105
- if (factories.size === 0 && namespaces.size === 0 && defineRoutesNames.size === 0) return null;
106
- walk(ast, (node) => {
107
- if (node.type !== "CallExpression" || !isAstNode(node.callee)) return;
108
- const callee = node.callee;
109
- const isDefineRoutes = callee.type === "Identifier" && defineRoutesNames.has(String(callee.name)) || callee.type === "MemberExpression" && callee.computed !== true && isAstNode(callee.object) && namespaces.has(String(callee.object.name)) && isAstNode(callee.property) && callee.property.name === "defineRoutes";
110
- if (!isDefineRoutes) return;
111
- definesRoutes = true;
112
- const callback = asNodes(node.arguments)[0];
113
- if (!callback || !isFunctionNode(callback)) return;
114
- const builder = asNodes(callback.params)[0];
115
- if (!builder) return;
116
- if (builder.type === "Identifier") {
117
- namespaces.add(String(builder.name));
118
- } else if (builder.type === "ObjectPattern") {
119
- for (const property of asNodes(builder.properties)) {
120
- if (property.type !== "Property" || property.computed === true) continue;
121
- const key = readPropertyName(property.key);
122
- const value = isAstNode(property.value) ? property.value : void 0;
123
- const kind = key ? ROUTE_FACTORY_NAMES[key] : void 0;
124
- if (kind && key !== "createRoute" && value?.type === "Identifier") {
125
- factories.set(String(value.name), kind);
126
- }
127
- }
128
- }
129
- });
130
- return { factories, namespaces, definesRoutes };
131
- }
132
- __name(findRouteFactoryBindings, "findRouteFactoryBindings");
133
- function findRouteFactoryCalls(ast, bindings) {
134
- const calls = [];
135
- walk(ast, (node) => {
136
- if (node.type !== "CallExpression" || !isAstNode(node.callee)) return;
137
- const callee = node.callee;
138
- let kind;
139
- if (callee.type === "Identifier") {
140
- kind = bindings.factories.get(String(callee.name));
141
- } else if (callee.type === "MemberExpression" && callee.computed !== true && isAstNode(callee.object) && callee.object.type === "Identifier" && bindings.namespaces.has(String(callee.object.name)) && isAstNode(callee.property)) {
142
- kind = ROUTE_FACTORY_NAMES[String(callee.property.name)];
143
- }
144
- const options = asNodes(node.arguments)[1];
145
- if (kind && options?.type === "ObjectExpression") calls.push({ kind, options });
146
- });
147
- return calls;
148
- }
149
- __name(findRouteFactoryCalls, "findRouteFactoryCalls");
150
- function stripRouteOptions(code, kind, options) {
151
- const serverOnlyKeys = SERVER_ONLY_KEYS[kind];
152
- const kept = [];
153
- const removed = [];
154
- for (const property of asNodes(options.properties)) {
155
- const key = property.type === "Property" && property.computed !== true ? readPropertyName(property.key) : void 0;
156
- if (key && serverOnlyKeys.has(kind === "api" ? key.toUpperCase() : key)) {
157
- removed.push(key);
158
- } else {
159
- kept.push(code.slice(property.start, property.end));
160
- }
161
- }
162
- if (removed.length === 0) return null;
163
- const propHooks = removed.filter((key) => key === "guard" || key === "data");
164
- if (kind === "page" && propHooks.length > 0) {
165
- kept.push(`__farmServerHooks: ${JSON.stringify(propHooks)}`);
166
- }
167
- return { start: options.start, end: options.end, code: `{ ${kept.join(", ")} }` };
168
- }
169
- __name(stripRouteOptions, "stripRouteOptions");
170
- function removeUnusedTopLevel(code, ast) {
171
- const statements = asNodes(ast.body).map((node) => {
172
- if (node.type === "ImportDeclaration") {
173
- const declared = asNodes(node.specifiers).flatMap(
174
- (specifier) => isAstNode(specifier.local) ? [String(specifier.local.name)] : []
175
- );
176
- return { node, declared, references: /* @__PURE__ */ new Set(), root: declared.length === 0 };
177
- }
178
- if (node.type === "VariableDeclaration") {
179
- const declared = asNodes(node.declarations).flatMap((item) => patternNames(item.id));
180
- const references2 = /* @__PURE__ */ new Set();
181
- for (const item of asNodes(node.declarations)) collectReferences(item.init, references2);
182
- return { node, declared, references: references2, root: false };
183
- }
184
- if ((node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") && isAstNode(node.id)) {
185
- const references2 = /* @__PURE__ */ new Set();
186
- collectReferences({ ...node, id: null }, references2);
187
- return { node, declared: [String(node.id.name)], references: references2, root: false };
188
- }
189
- const references = /* @__PURE__ */ new Set();
190
- collectReferences(node, references);
191
- return { node, declared: [], references, root: true };
192
- });
193
- const declaredBy = /* @__PURE__ */ new Map();
194
- for (const statement of statements) {
195
- for (const name of statement.declared) declaredBy.set(name, statement);
196
- }
197
- const live = /* @__PURE__ */ new Set();
198
- const queue = statements.filter((statement) => statement.root).flatMap((s) => [...s.references]);
199
- while (queue.length > 0) {
200
- const name = queue.pop();
201
- if (live.has(name)) continue;
202
- live.add(name);
203
- const statement = declaredBy.get(name);
204
- if (statement) queue.push(...statement.references);
205
- }
206
- const replacements = [];
207
- for (const statement of statements) {
208
- if (statement.root || statement.declared.some((name) => live.has(name))) {
209
- if (statement.node.type === "ImportDeclaration") {
210
- const rewritten = rewriteImport(code, statement.node, live);
211
- if (rewritten) replacements.push(rewritten);
212
- }
213
- continue;
214
- }
215
- replacements.push({ start: statement.node.start, end: statement.node.end, code: "" });
216
- }
217
- return replacements;
218
- }
219
- __name(removeUnusedTopLevel, "removeUnusedTopLevel");
220
- function rewriteImport(code, node, live) {
221
- const specifiers = asNodes(node.specifiers);
222
- const kept = specifiers.filter(
223
- (specifier) => isAstNode(specifier.local) && live.has(String(specifier.local.name))
224
- );
225
- if (kept.length === specifiers.length) return null;
226
- const defaults = kept.filter((specifier) => specifier.type !== "ImportSpecifier");
227
- const named = kept.filter((specifier) => specifier.type === "ImportSpecifier");
228
- const clauses = defaults.map((specifier) => code.slice(specifier.start, specifier.end));
229
- if (named.length > 0) {
230
- clauses.push(`{ ${named.map((item) => code.slice(item.start, item.end)).join(", ")} }`);
231
- }
232
- const source = code.slice(node.source.start, node.source.end);
233
- return { start: node.start, end: node.end, code: `import ${clauses.join(", ")} from ${source};` };
234
- }
235
- __name(rewriteImport, "rewriteImport");
236
- function findNodeBuiltinImport(ast) {
237
- let found = null;
238
- walk(ast, (node) => {
239
- if (found) return;
240
- if (node.type !== "ImportDeclaration" && node.type !== "ImportExpression" && node.type !== "ExportAllDeclaration" && node.type !== "ExportNamedDeclaration") {
241
- return;
242
- }
243
- const source = isAstNode(node.source) ? node.source.value : void 0;
244
- if (typeof source === "string" && isNodeBuiltinId(source)) found = source;
245
- });
246
- return found;
247
- }
248
- __name(findNodeBuiltinImport, "findNodeBuiltinImport");
249
- function collectReferences(node, names) {
250
- if (Array.isArray(node)) {
251
- for (const item of node) collectReferences(item, names);
252
- return;
253
- }
254
- if (!isAstNode(node)) return;
255
- if (node.type === "Identifier") {
256
- names.add(String(node.name));
257
- return;
258
- }
259
- for (const [key, value] of Object.entries(node)) {
260
- if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
261
- if (key === "key" && node.computed !== true && (node.type === "Property" || node.type === "MethodDefinition" || node.type === "PropertyDefinition")) {
262
- continue;
263
- }
264
- if (key === "property" && node.type === "MemberExpression" && node.computed !== true) continue;
265
- if (key === "label") continue;
266
- collectReferences(value, names);
267
- }
268
- }
269
- __name(collectReferences, "collectReferences");
270
- function patternNames(pattern) {
271
- if (!isAstNode(pattern)) return [];
272
- if (pattern.type === "Identifier") return [String(pattern.name)];
273
- if (pattern.type === "ObjectPattern") {
274
- return asNodes(pattern.properties).flatMap(
275
- (property) => patternNames(property.type === "RestElement" ? property.argument : property.value)
276
- );
277
- }
278
- if (pattern.type === "ArrayPattern") return asNodes(pattern.elements).flatMap(patternNames);
279
- if (pattern.type === "AssignmentPattern") return patternNames(pattern.left);
280
- if (pattern.type === "RestElement") return patternNames(pattern.argument);
281
- return [];
282
- }
283
- __name(patternNames, "patternNames");
284
- function withoutNested(replacements) {
285
- return replacements.filter(
286
- (replacement) => !replacements.some(
287
- (other) => other !== replacement && other.start <= replacement.start && other.end >= replacement.end
288
- )
289
- );
290
- }
291
- __name(withoutNested, "withoutNested");
292
- function applyReplacements(code, replacements) {
293
- let output = code;
294
- for (const replacement of [...replacements].sort((left, right) => right.start - left.start)) {
295
- output = output.slice(0, replacement.start) + replacement.code + output.slice(replacement.end);
296
- }
297
- return output;
298
- }
299
- __name(applyReplacements, "applyReplacements");
300
- function readPropertyName(node) {
301
- if (!isAstNode(node)) return void 0;
302
- if (node.type === "Identifier") return String(node.name);
303
- if (node.type === "Literal" && typeof node.value === "string") return node.value;
304
- return void 0;
305
- }
306
- __name(readPropertyName, "readPropertyName");
307
- function isFunctionNode(node) {
308
- return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression";
309
- }
310
- __name(isFunctionNode, "isFunctionNode");
311
- function walk(node, visit) {
312
- visit(node);
313
- for (const [key, value] of Object.entries(node)) {
314
- if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
315
- if (isAstNode(value)) walk(value, visit);
316
- else if (Array.isArray(value)) {
317
- for (const item of value) if (isAstNode(item)) walk(item, visit);
318
- }
319
- }
320
- }
321
- __name(walk, "walk");
322
- function asNodes(value) {
323
- return Array.isArray(value) ? value.filter(isAstNode) : [];
324
- }
325
- __name(asNodes, "asNodes");
326
- function isAstNode(value) {
327
- return !!value && typeof value === "object" && typeof value.type === "string" && typeof value.start === "number";
328
- }
329
- __name(isAstNode, "isAstNode");
330
-
331
- // src/environment-vite.ts
332
- var ENVIRONMENT_IMPORTS = /* @__PURE__ */ new Set([
333
- "@farm.js/core",
334
- "@farm.js/core/environment",
335
- "@farm.js/core/server"
336
- ]);
337
- var ENVIRONMENT_FUNCTIONS = /* @__PURE__ */ new Set([
338
- "createServerOnlyFn",
339
- "createClientOnlyFn",
340
- "createIsomorphicFn"
341
- ]);
342
- var MODULE_EXTENSION_RE2 = /\.[cm]?[jt]sx?$/;
343
- function transformEnvironmentFunctions(options) {
344
- if (!isTransformableModule2(options.id) || !containsEnvironmentFunction(options.code)) {
345
- return null;
346
- }
347
- let output = options.code;
348
- let transformed = false;
349
- for (let pass = 0; pass < 20; pass++) {
350
- const ast = options.parse(output);
351
- const bindings = findEnvironmentFunctionBindings(ast);
352
- if (bindings.named.size === 0 && bindings.namespaces.size === 0) break;
353
- const calls = findEnvironmentCalls(ast, bindings);
354
- if (calls.length === 0) break;
355
- const innermostCalls = calls.filter(
356
- (call) => !calls.some(
357
- (candidate) => candidate !== call && candidate.node.start > call.node.start && candidate.node.end < call.node.end
358
- )
359
- );
360
- const replacements = innermostCalls.map(
361
- (call) => createReplacement(output, options.id, options.environment, call)
362
- );
363
- output = applyReplacements2(output, replacements);
364
- transformed = true;
365
- }
366
- if (!transformed) return null;
367
- const remainingAst = options.parse(output);
368
- const remainingBindings = findEnvironmentFunctionBindings(remainingAst);
369
- if (findEnvironmentCalls(remainingAst, remainingBindings).length > 0) {
370
- throw transformError(options.id, "environment functions are nested too deeply");
371
- }
372
- return { code: output };
373
- }
374
- __name(transformEnvironmentFunctions, "transformEnvironmentFunctions");
375
- function farmEnvironmentFunctionsPlugin() {
376
- const clientRouteModules = /* @__PURE__ */ new Set();
377
- return {
378
- name: "farm:environment-functions",
379
- enforce: "post",
380
- transform(code, id, transformOptions) {
381
- const environment = resolveBuildEnvironment(
382
- this,
383
- transformOptions?.ssr
384
- );
385
- const parse = /* @__PURE__ */ __name((source) => this.parse(source), "parse");
386
- const result = transformEnvironmentFunctions({ code, id, environment, parse });
387
- if (environment !== "client") {
388
- return result ? { code: result.code, map: null } : null;
389
- }
390
- let routes;
391
- try {
392
- routes = transformProgrammaticRoutesForClient({ code: result?.code ?? code, id, parse });
393
- } catch (error) {
394
- this.error(error instanceof Error ? error.message : String(error));
395
- }
396
- if (routes) clientRouteModules.add(id);
397
- const output = routes?.code ?? result?.code;
398
- return output !== void 0 ? { code: output, map: null } : null;
399
- },
400
- generateBundle() {
401
- const context = this;
402
- if (resolveBuildEnvironment(context, false) !== "client") return;
403
- for (const id of clientRouteModules) {
404
- const chain = findClientNodeBuiltinChain(id, (moduleId) => {
405
- const info = this.getModuleInfo(moduleId);
406
- return info?.importedIds;
407
- });
408
- if (chain) {
409
- this.error(
410
- `[Farm.js] The browser bundle reaches the server-only module "${chain.at(-1)}" through the programmatic routes in ${id}: ${chain.join(" -> ")}. Import it only from guard, data, staticPaths, generateMetadata, or API handlers, which Farm keeps out of the browser.`
411
- );
412
- }
413
- }
414
- }
415
- };
416
- }
417
- __name(farmEnvironmentFunctionsPlugin, "farmEnvironmentFunctionsPlugin");
418
- function resolveBuildEnvironment(context, ssr) {
419
- if (context.environment?.name === "client") return "client";
420
- if (context.environment?.name === "rsc" || context.environment?.name === "ssr") {
421
- return "server";
422
- }
423
- return ssr ? "server" : "client";
424
- }
425
- __name(resolveBuildEnvironment, "resolveBuildEnvironment");
426
- function findEnvironmentFunctionBindings(ast) {
427
- const named = /* @__PURE__ */ new Map();
428
- const namespaces = /* @__PURE__ */ new Set();
429
- const body = Array.isArray(ast.body) ? ast.body : [];
430
- for (const statement of body) {
431
- if (!isAstNode2(statement) || statement.type !== "ImportDeclaration") continue;
432
- const source = isAstNode2(statement.source) ? statement.source.value : void 0;
433
- if (typeof source !== "string" || !ENVIRONMENT_IMPORTS.has(source)) continue;
434
- const specifiers = Array.isArray(statement.specifiers) ? statement.specifiers : [];
435
- for (const specifier of specifiers) {
436
- if (!isAstNode2(specifier) || !isAstNode2(specifier.local)) continue;
437
- const localName = specifier.local.name;
438
- if (typeof localName !== "string") continue;
439
- if (specifier.type === "ImportNamespaceSpecifier") {
440
- namespaces.add(localName);
441
- continue;
442
- }
443
- if (specifier.type !== "ImportSpecifier" || !isAstNode2(specifier.imported)) continue;
444
- const importedName = specifier.imported.name ?? specifier.imported.value;
445
- if (isEnvironmentFunctionKind(importedName)) {
446
- named.set(localName, importedName);
447
- }
448
- }
449
- }
450
- return { named, namespaces };
451
- }
452
- __name(findEnvironmentFunctionBindings, "findEnvironmentFunctionBindings");
453
- function findEnvironmentCalls(ast, bindings) {
454
- const calls = [];
455
- walkAst(ast, (node, ancestors) => {
456
- if (node.type !== "CallExpression" || !isAstNode2(node.callee)) return;
457
- if (node.callee.type === "Identifier" && typeof node.callee.name === "string") {
458
- const kind = bindings.named.get(node.callee.name);
459
- if (kind && !isNameShadowed(node.callee.name, ancestors)) calls.push({ node, kind });
460
- return;
461
- }
462
- if (node.callee.type !== "MemberExpression" || node.callee.computed === true || !isAstNode2(node.callee.object) || !isAstNode2(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)) {
463
- return;
464
- }
465
- calls.push({ node, kind: node.callee.property.name });
466
- });
467
- return calls;
468
- }
469
- __name(findEnvironmentCalls, "findEnvironmentCalls");
470
- function createReplacement(code, id, environment, call) {
471
- const args = Array.isArray(call.node.arguments) ? call.node.arguments : [];
472
- if (args.length !== 1 || !isAstNode2(args[0]) || args[0].type === "SpreadElement") {
473
- throw transformError(id, `${call.kind}() requires exactly one static argument`);
474
- }
475
- let replacement;
476
- if (call.kind === "createIsomorphicFn") {
477
- replacement = selectIsomorphicImplementation(code, id, environment, args[0]);
478
- } else {
479
- const expected = call.kind === "createServerOnlyFn" ? "server" : "client";
480
- replacement = environment === expected ? readNode(code, args[0]) : `(0, ${readNode(code, call.node.callee)})(undefined, ${JSON.stringify(environment)})`;
481
- }
482
- return {
483
- start: call.node.start,
484
- end: call.node.end,
485
- code: `(${replacement})`
486
- };
487
- }
488
- __name(createReplacement, "createReplacement");
489
- function selectIsomorphicImplementation(code, id, environment, optionsNode) {
490
- if (optionsNode.type !== "ObjectExpression") {
491
- throw transformError(id, "createIsomorphicFn() requires an inline options object");
492
- }
493
- const properties = Array.isArray(optionsNode.properties) ? optionsNode.properties : [];
494
- if (properties.some((property) => isAstNode2(property) && property.type === "SpreadElement")) {
495
- throw transformError(id, "createIsomorphicFn() does not support spread properties");
496
- }
497
- let selectedProperty;
498
- for (const property of properties) {
499
- if (!isAstNode2(property) || property.type !== "Property" || property.computed === true) {
500
- continue;
501
- }
502
- const key = readPropertyName2(property.key);
503
- if (key === environment) selectedProperty = property;
504
- }
505
- if (!selectedProperty || !isAstNode2(selectedProperty.value)) {
506
- throw transformError(id, `createIsomorphicFn() requires a ${environment} implementation`);
507
- }
508
- if (selectedProperty.kind !== void 0 && selectedProperty.kind !== "init") {
509
- throw transformError(id, "createIsomorphicFn() does not support getters or setters");
510
- }
511
- return selectedProperty.method === true ? renderObjectMethod(code, id, selectedProperty.value) : readNode(code, selectedProperty.value);
512
- }
513
- __name(selectIsomorphicImplementation, "selectIsomorphicImplementation");
514
- function renderObjectMethod(code, id, functionNode) {
515
- if (!isAstNode2(functionNode.body) || !Array.isArray(functionNode.params)) {
516
- throw transformError(id, "createIsomorphicFn() received an unsupported method");
517
- }
518
- const params = functionNode.params.map((param) => {
519
- if (!isAstNode2(param)) {
520
- throw transformError(id, "createIsomorphicFn() received an unsupported parameter");
521
- }
522
- return readNode(code, param);
523
- });
524
- const asyncPrefix = functionNode.async === true ? "async " : "";
525
- const generatorMarker = functionNode.generator === true ? "*" : "";
526
- return `${asyncPrefix}function${generatorMarker}(${params.join(", ")}) ${readNode(code, functionNode.body)}`;
527
- }
528
- __name(renderObjectMethod, "renderObjectMethod");
529
- function applyReplacements2(code, replacements) {
530
- let output = code;
531
- for (const replacement of replacements.sort((left, right) => right.start - left.start)) {
532
- output = output.slice(0, replacement.start) + replacement.code + output.slice(replacement.end);
533
- }
534
- return output;
535
- }
536
- __name(applyReplacements2, "applyReplacements");
537
- function walkAst(node, visit, ancestors = []) {
538
- visit(node, ancestors);
539
- const childAncestors = [...ancestors, node];
540
- for (const [key, value] of Object.entries(node)) {
541
- if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
542
- if (isAstNode2(value)) {
543
- walkAst(value, visit, childAncestors);
544
- } else if (Array.isArray(value)) {
545
- for (const item of value) {
546
- if (isAstNode2(item)) walkAst(item, visit, childAncestors);
547
- }
548
- }
549
- }
550
- }
551
- __name(walkAst, "walkAst");
552
- function isNameShadowed(name, ancestors) {
553
- for (const [index, ancestor] of ancestors.entries()) {
554
- if (isFunctionNode2(ancestor)) {
555
- const params = Array.isArray(ancestor.params) ? ancestor.params : [];
556
- if (params.some((param) => patternContainsName(param, name))) return true;
557
- if (patternContainsName(ancestor.id, name)) return true;
558
- if (isAstNode2(ancestor.body) && ancestors.slice(index + 1).includes(ancestor.body) && functionBodyDeclaresVarName(ancestor.body, name)) {
559
- return true;
560
- }
561
- }
562
- if (ancestor.type === "CatchClause" && patternContainsName(ancestor.param, name)) {
563
- return true;
564
- }
565
- if ((ancestor.type === "BlockStatement" || ancestor.type === "StaticBlock") && blockDeclaresName(ancestor, name)) {
566
- return true;
567
- }
568
- if (loopDeclaresName(ancestor, name)) return true;
569
- if (ancestor.type === "SwitchStatement" && ancestors.slice(index + 1).some((candidate) => candidate.type === "SwitchCase") && switchDeclaresName(ancestor, name)) {
570
- return true;
571
- }
572
- if (ancestor.type === "ClassExpression" && patternContainsName(ancestor.id, name) && ancestors.slice(index + 1).some((candidate) => candidate.type === "ClassBody")) {
573
- return true;
574
- }
575
- }
576
- return false;
577
- }
578
- __name(isNameShadowed, "isNameShadowed");
579
- function functionBodyDeclaresVarName(body, name) {
580
- if (body.type === "VariableDeclaration" && body.kind === "var") {
581
- const declarations = Array.isArray(body.declarations) ? body.declarations : [];
582
- if (declarations.some(
583
- (declaration) => isAstNode2(declaration) && patternContainsName(declaration.id, name)
584
- )) {
585
- return true;
586
- }
587
- }
588
- for (const [key, value] of Object.entries(body)) {
589
- if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
590
- if (isAstNode2(value)) {
591
- if (isNestedVarScope(value)) continue;
592
- if (functionBodyDeclaresVarName(value, name)) return true;
593
- } else if (Array.isArray(value)) {
594
- for (const item of value) {
595
- if (!isAstNode2(item) || isNestedVarScope(item)) continue;
596
- if (functionBodyDeclaresVarName(item, name)) return true;
597
- }
598
- }
599
- }
600
- return false;
601
- }
602
- __name(functionBodyDeclaresVarName, "functionBodyDeclaresVarName");
603
- function isNestedVarScope(node) {
604
- return isFunctionNode2(node) || node.type === "ClassDeclaration" || node.type === "ClassExpression";
605
- }
606
- __name(isNestedVarScope, "isNestedVarScope");
607
- function loopDeclaresName(node, name) {
608
- const declaration = node.type === "ForStatement" ? node.init : node.type === "ForInStatement" || node.type === "ForOfStatement" ? node.left : void 0;
609
- if (!isAstNode2(declaration) || declaration.type !== "VariableDeclaration") return false;
610
- const declarations = Array.isArray(declaration.declarations) ? declaration.declarations : [];
611
- return declarations.some((item) => isAstNode2(item) && patternContainsName(item.id, name));
612
- }
613
- __name(loopDeclaresName, "loopDeclaresName");
614
- function switchDeclaresName(node, name) {
615
- const cases = Array.isArray(node.cases) ? node.cases : [];
616
- return cases.some((switchCase) => {
617
- if (!isAstNode2(switchCase) || !Array.isArray(switchCase.consequent)) return false;
618
- return switchCase.consequent.some((statement) => {
619
- if (!isAstNode2(statement)) return false;
620
- if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && patternContainsName(statement.id, name)) {
621
- return true;
622
- }
623
- if (statement.type !== "VariableDeclaration" || statement.kind === "var") return false;
624
- const declarations = Array.isArray(statement.declarations) ? statement.declarations : [];
625
- return declarations.some(
626
- (declaration) => isAstNode2(declaration) && patternContainsName(declaration.id, name)
627
- );
628
- });
629
- });
630
- }
631
- __name(switchDeclaresName, "switchDeclaresName");
632
- function blockDeclaresName(block, name) {
633
- const statements = Array.isArray(block.body) ? block.body : [];
634
- for (const statement of statements) {
635
- if (!isAstNode2(statement)) continue;
636
- if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && patternContainsName(statement.id, name)) {
637
- return true;
638
- }
639
- if (statement.type !== "VariableDeclaration" || !Array.isArray(statement.declarations)) {
640
- continue;
641
- }
642
- if (statement.declarations.some(
643
- (declaration) => isAstNode2(declaration) && patternContainsName(declaration.id, name)
644
- )) {
645
- return true;
646
- }
647
- }
648
- return false;
649
- }
650
- __name(blockDeclaresName, "blockDeclaresName");
651
- function patternContainsName(value, name) {
652
- if (!isAstNode2(value)) return false;
653
- if (value.type === "Identifier") return value.name === name;
654
- if (value.type === "RestElement") return patternContainsName(value.argument, name);
655
- if (value.type === "AssignmentPattern") return patternContainsName(value.left, name);
656
- if (value.type === "Property") return patternContainsName(value.value, name);
657
- const elements = Array.isArray(value.elements) ? value.elements : Array.isArray(value.properties) ? value.properties : [];
658
- return elements.some((element) => patternContainsName(element, name));
659
- }
660
- __name(patternContainsName, "patternContainsName");
661
- function isFunctionNode2(node) {
662
- return node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
663
- }
664
- __name(isFunctionNode2, "isFunctionNode");
665
- function readPropertyName2(value) {
666
- if (!isAstNode2(value)) return void 0;
667
- if (value.type === "Identifier" && typeof value.name === "string") return value.name;
668
- if (value.type === "Literal" && typeof value.value === "string") return value.value;
669
- return void 0;
670
- }
671
- __name(readPropertyName2, "readPropertyName");
672
- function readNode(code, node) {
673
- return code.slice(node.start, node.end);
674
- }
675
- __name(readNode, "readNode");
676
- function isAstNode2(value) {
677
- return !!value && typeof value === "object" && typeof value.type === "string" && typeof value.start === "number" && typeof value.end === "number";
678
- }
679
- __name(isAstNode2, "isAstNode");
680
- function isEnvironmentFunctionKind(value) {
681
- return typeof value === "string" && ENVIRONMENT_FUNCTIONS.has(value);
682
- }
683
- __name(isEnvironmentFunctionKind, "isEnvironmentFunctionKind");
684
- function containsEnvironmentFunction(code) {
685
- return Array.from(ENVIRONMENT_FUNCTIONS).some((name) => code.includes(name));
686
- }
687
- __name(containsEnvironmentFunction, "containsEnvironmentFunction");
688
- function isTransformableModule2(id) {
689
- const cleanId = id.split("?", 1)[0];
690
- return MODULE_EXTENSION_RE2.test(cleanId) && !/\.d\.[cm]?ts$/.test(cleanId);
691
- }
692
- __name(isTransformableModule2, "isTransformableModule");
693
- function transformError(id, message) {
694
- return new Error(`[Farm environment functions] ${message} in ${id.split("?", 1)[0]}`);
695
- }
696
- __name(transformError, "transformError");
697
-
698
- export {
699
- transformEnvironmentFunctions,
700
- farmEnvironmentFunctionsPlugin
701
- };