@farm.js/core 0.1.66 → 0.1.68

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 (494) hide show
  1. package/dist/{agent-mcp-handler-QLFDDTYN.mjs → agent-mcp-handler-AZ7QW4UP.mjs} +5 -5
  2. package/dist/{agent-mcp-handler-OXT73ZBY.cjs → agent-mcp-handler-FER4MQDF.cjs} +6 -6
  3. package/dist/{agent-mcp.d-QD2WZ9BS.d.ts → agent-mcp.d-Uh5xr7aX.d.ts} +1 -1
  4. package/dist/{agent-mcp.d-CO_ABmNK.d.mts → agent-mcp.d-wkVPK1GA.d.mts} +1 -1
  5. package/dist/agent-runtime.cjs +6 -5
  6. package/dist/agent-runtime.d.mts +10 -8
  7. package/dist/agent-runtime.d.ts +10 -8
  8. package/dist/agent-runtime.mjs +5 -4
  9. package/dist/{analyzer-4UFP4HVP.mjs → analyzer-CQDU7E3Y.mjs} +2 -2
  10. package/dist/analyzer-PPAHM4AW.cjs +16 -0
  11. package/dist/api/client.cjs +12 -2
  12. package/dist/api/client.d.mts +4 -4
  13. package/dist/api/client.d.ts +4 -4
  14. package/dist/api/client.mjs +12 -2
  15. package/dist/api/client.native.cjs +12 -2
  16. package/dist/api/client.native.d.mts +5 -5
  17. package/dist/api/client.native.d.ts +5 -5
  18. package/dist/api/client.native.mjs +12 -2
  19. package/dist/api/node.cjs +223 -0
  20. package/dist/api/node.d.mts +61 -0
  21. package/dist/api/node.d.ts +61 -0
  22. package/dist/api/node.mjs +223 -0
  23. package/dist/api/route-manager.cjs +11 -11
  24. package/dist/api/route-manager.d.mts +14 -11
  25. package/dist/api/route-manager.d.ts +14 -11
  26. package/dist/api/route-manager.mjs +10 -10
  27. package/dist/api/runtime.cjs +11 -7
  28. package/dist/api/runtime.d.mts +11 -9
  29. package/dist/api/runtime.d.ts +11 -9
  30. package/dist/api/runtime.mjs +10 -6
  31. package/dist/{api-client.d-BNLXNCXJ.d.mts → api-client.d-Bp35zMqR.d.mts} +1 -1
  32. package/dist/{api-client.d-ddQBNGtu.d.ts → api-client.d-CFI_xL0V.d.ts} +1 -1
  33. package/dist/api.cjs +17 -13
  34. package/dist/api.d.mts +15 -12
  35. package/dist/api.d.ts +15 -12
  36. package/dist/api.mjs +16 -12
  37. package/dist/{app-manifest.d-DDmNkYQQ.d.ts → app-manifest.d-BT5i2F-o.d.ts} +1 -1
  38. package/dist/{app-manifest.d-BpKxiU_E.d.mts → app-manifest.d-Dd4q5CFx.d.mts} +1 -1
  39. package/dist/app-markdown.cjs +5 -5
  40. package/dist/app-markdown.d.mts +15 -15
  41. package/dist/app-markdown.d.ts +15 -15
  42. package/dist/app-markdown.mjs +4 -4
  43. package/dist/{app.d-x68Cwr0_.d.ts → app.d-BVOpL_f2.d.ts} +52 -11
  44. package/dist/{app.d-kuoVWhWM.d.mts → app.d-BhiDXex_.d.mts} +52 -11
  45. package/dist/{chunk-RY4ABNPE.cjs → chunk-225APHKC.cjs} +3 -3
  46. package/dist/{chunk-JGAE5XPL.cjs → chunk-23VJEGKC.cjs} +4 -2
  47. package/dist/{chunk-5C7XMKQ4.cjs → chunk-2AFW7673.cjs} +6 -1
  48. package/dist/{chunk-SYW346ZN.cjs → chunk-2LHZD3OP.cjs} +1 -21
  49. package/dist/{chunk-ZZI56IUY.mjs → chunk-2ZOYOYEE.mjs} +13 -13
  50. package/dist/{chunk-7XGWBPQQ.cjs → chunk-3EEINK7G.cjs} +24 -10
  51. package/dist/{chunk-BRWIVOV4.cjs → chunk-3GNHJ3RN.cjs} +10 -8
  52. package/dist/{chunk-HCGWDRZO.mjs → chunk-3Y52TWYU.mjs} +18 -7
  53. package/dist/{chunk-CBOEJ5Z4.cjs → chunk-437QZIC2.cjs} +133 -46
  54. package/dist/{chunk-O6L3YYPM.cjs → chunk-4E57QHPW.cjs} +8 -16
  55. package/dist/{chunk-WKPBIT5Q.cjs → chunk-4HGLJOXZ.cjs} +6 -6
  56. package/dist/{chunk-CJNAUEVC.mjs → chunk-4QENVMG7.mjs} +1 -1
  57. package/dist/{chunk-EMNKZGF4.mjs → chunk-4UAQB5LB.mjs} +556 -462
  58. package/dist/{chunk-BQWBHWEW.mjs → chunk-4ZXKYCYK.mjs} +1 -1
  59. package/dist/{chunk-N35YPV4N.mjs → chunk-57QAQU4F.mjs} +9 -7
  60. package/dist/{chunk-ZEXE4TGY.mjs → chunk-5FBZJJGA.mjs} +247 -110
  61. package/dist/{chunk-4OSOLDPL.cjs → chunk-5JKDFRTK.cjs} +2 -2
  62. package/dist/{chunk-OLIGNTWU.cjs → chunk-5NFQ6AZI.cjs} +7 -7
  63. package/dist/{chunk-6HRAK7I5.mjs → chunk-5OFNUETM.mjs} +8 -2
  64. package/dist/{chunk-RD623KW4.cjs → chunk-67MZTLTF.cjs} +21 -3
  65. package/dist/chunk-6I4BFRE7.cjs +51 -0
  66. package/dist/{chunk-UBMHQVWN.mjs → chunk-6OFOIMNS.mjs} +1 -1
  67. package/dist/{chunk-K5EW7GUU.mjs → chunk-7BIW7VCW.mjs} +13 -5
  68. package/dist/{chunk-CHYTADNK.cjs → chunk-7LK5CTUM.cjs} +70 -53
  69. package/dist/{chunk-HPP2II4Z.mjs → chunk-7PJARAQQ.mjs} +1 -1
  70. package/dist/{chunk-LEJDW34D.cjs → chunk-7PPLTD3P.cjs} +3 -3
  71. package/dist/{chunk-BYRZ5VTH.mjs → chunk-A3T445WK.mjs} +47 -34
  72. package/dist/{chunk-TGULJSHD.mjs → chunk-AJNBTOVQ.mjs} +20 -9
  73. package/dist/{chunk-FBEBSAVI.cjs → chunk-AKIQ54FK.cjs} +82 -63
  74. package/dist/{chunk-2NGZFOKG.mjs → chunk-AOIUYHPH.mjs} +2 -2
  75. package/dist/{chunk-NKRZLQUK.mjs → chunk-AQIO3RNL.mjs} +1 -1
  76. package/dist/chunk-AQIRXBBY.cjs +26 -0
  77. package/dist/{chunk-DQJ2CIH7.cjs → chunk-ASYOWPSR.cjs} +2 -1
  78. package/dist/chunk-AZ6IW6SF.mjs +28 -0
  79. package/dist/{chunk-QMDU6QHN.mjs → chunk-B6RBJJ5G.mjs} +1 -1
  80. package/dist/{chunk-I32V5CZL.cjs → chunk-BDYM2TN3.cjs} +28 -17
  81. package/dist/{chunk-JLDNXURZ.cjs → chunk-BZWTBELF.cjs} +32 -32
  82. package/dist/{chunk-ITV4QQL2.cjs → chunk-C6CUUBY5.cjs} +14 -3
  83. package/dist/{chunk-QGJ4FI2G.mjs → chunk-C6HGUTXB.mjs} +113 -29
  84. package/dist/{chunk-YN6BHOYY.cjs → chunk-CL52PD6D.cjs} +10 -3
  85. package/dist/{chunk-VQJHT2ND.mjs → chunk-CRVSYDHV.mjs} +2 -2
  86. package/dist/{chunk-XURDCXNH.cjs → chunk-CSLHNBPS.cjs} +6 -6
  87. package/dist/{chunk-XQSYOVCW.cjs → chunk-DBYNZIIQ.cjs} +13 -5
  88. package/dist/{chunk-AZUUKA66.mjs → chunk-DIXFKAPM.mjs} +1251 -389
  89. package/dist/{chunk-QTD6EMN2.mjs → chunk-DQ2DI3Y7.mjs} +11 -4
  90. package/dist/{chunk-NHQM2Q4I.cjs → chunk-DWLNLU55.cjs} +2 -2
  91. package/dist/chunk-DXZ57EPE.mjs +375 -0
  92. package/dist/{chunk-SA7MLSP4.mjs → chunk-E3HDJCWF.mjs} +3 -3
  93. package/dist/{chunk-52Y3C3HG.mjs → chunk-E7VF3LQ5.mjs} +3 -2
  94. package/dist/{chunk-752XUZIM.cjs → chunk-EGIY4A7V.cjs} +6 -6
  95. package/dist/chunk-EIVGPQN5.mjs +51 -0
  96. package/dist/{chunk-KPAJWD3N.mjs → chunk-EYPSKXO4.mjs} +1 -1
  97. package/dist/{chunk-E4UDLFWR.cjs → chunk-F36LS2C7.cjs} +796 -702
  98. package/dist/{chunk-MPIGW42F.mjs → chunk-F6CMGWAL.mjs} +1 -1
  99. package/dist/{chunk-GL7N5UHF.cjs → chunk-FJMC24KG.cjs} +21 -10
  100. package/dist/{chunk-QISW423S.cjs → chunk-FPBOAG6N.cjs} +2 -2
  101. package/dist/{chunk-3CCAICF7.cjs → chunk-FSODPZRT.cjs} +5 -5
  102. package/dist/{chunk-2C5L5RPM.cjs → chunk-FT6KJHS3.cjs} +71 -38
  103. package/dist/{chunk-WMTBBQHY.cjs → chunk-FVYBEMOD.cjs} +288 -151
  104. package/dist/{chunk-BM2LH2JM.mjs → chunk-G7NBPP7H.mjs} +14 -13
  105. package/dist/{chunk-ES2LD2YD.mjs → chunk-GCRT6GJG.mjs} +18 -0
  106. package/dist/{chunk-5OJVKXFV.cjs → chunk-GDM3ZD2O.cjs} +10 -8
  107. package/dist/{chunk-25T5VXOE.mjs → chunk-GFPS7MNE.mjs} +106 -19
  108. package/dist/{chunk-EMDGXYUD.mjs → chunk-GJ7QVFAG.mjs} +16 -7
  109. package/dist/{chunk-TGSEVBPO.mjs → chunk-GJEC5S4V.mjs} +11 -0
  110. package/dist/{chunk-HNAISJFD.cjs → chunk-HDPT6OYE.cjs} +9 -3
  111. package/dist/{chunk-RVGSVQWT.mjs → chunk-HEJM46HQ.mjs} +21 -7
  112. package/dist/chunk-HHLEYA4B.cjs +17 -0
  113. package/dist/{chunk-ZNH6NR3H.cjs → chunk-HJZZSBVK.cjs} +2 -2
  114. package/dist/{chunk-E552H232.cjs → chunk-I7J5RLGO.cjs} +16 -2
  115. package/dist/chunk-ICFPTHXM.mjs +97 -0
  116. package/dist/{chunk-K7OZAVOI.mjs → chunk-IFR74W6S.mjs} +46 -13
  117. package/dist/{chunk-MPJEIHW2.cjs → chunk-IGDYL2IA.cjs} +2 -2
  118. package/dist/{chunk-5A77OEIG.cjs → chunk-IHTDLCDJ.cjs} +5 -5
  119. package/dist/{chunk-OYZXVBZP.cjs → chunk-IUKBPBM7.cjs} +2 -1
  120. package/dist/chunk-J6TZRYCO.cjs +22 -0
  121. package/dist/{chunk-E4RDMG3K.mjs → chunk-JL2YW5KX.mjs} +5 -4
  122. package/dist/chunk-JSOCDYER.cjs +375 -0
  123. package/dist/{chunk-UPYIFH2H.cjs → chunk-JWLRBDDC.cjs} +2 -2
  124. package/dist/{chunk-OLGQZRW6.mjs → chunk-JZBU7V4D.mjs} +37 -17
  125. package/dist/{chunk-ONG4RDW3.mjs → chunk-JZGL2PIH.mjs} +13 -3
  126. package/dist/chunk-K63OWRY2.mjs +22 -0
  127. package/dist/{chunk-TUPKMMXT.mjs → chunk-K6HIIWUB.mjs} +1 -1
  128. package/dist/{chunk-MESQF2JC.mjs → chunk-K6SXMVXO.mjs} +2 -2
  129. package/dist/{chunk-L2JG337G.cjs → chunk-K6VFYFOY.cjs} +33 -31
  130. package/dist/{chunk-TKK5QHKZ.mjs → chunk-KDO6T6OB.mjs} +3 -3
  131. package/dist/{chunk-EZ34EHQP.mjs → chunk-KI3MU7B5.mjs} +1 -1
  132. package/dist/{chunk-GHNW564E.mjs → chunk-KSZK34HU.mjs} +30 -10
  133. package/dist/{chunk-IT6WRNGB.cjs → chunk-KWCZKJYU.cjs} +1541 -679
  134. package/dist/{chunk-DVKH2RVN.cjs → chunk-LDEXTX4I.cjs} +70 -57
  135. package/dist/{chunk-ECKQFEX2.mjs → chunk-LENKRGBV.mjs} +8 -6
  136. package/dist/{chunk-XBSKPLHF.cjs → chunk-LR4KP3I7.cjs} +2 -2
  137. package/dist/{chunk-HEPJIKKQ.cjs → chunk-MCSRMEQV.cjs} +2 -2
  138. package/dist/{chunk-DQF3QLOH.mjs → chunk-ME7RVELR.mjs} +3 -2
  139. package/dist/{chunk-VFXE6NWR.mjs → chunk-MGKWYPE3.mjs} +2 -1
  140. package/dist/{chunk-TZVUF5JJ.mjs → chunk-MGZVDX4R.mjs} +5 -5
  141. package/dist/{chunk-MGKW5XZE.cjs → chunk-MMDKYJ5V.cjs} +7 -7
  142. package/dist/{chunk-SK7QSNWE.mjs → chunk-MNJDNTGO.mjs} +1 -1
  143. package/dist/{chunk-5Y2P454O.cjs → chunk-MTBDJ326.cjs} +6 -5
  144. package/dist/{chunk-FIR62CR3.mjs → chunk-MV7NWU23.mjs} +1 -1
  145. package/dist/{chunk-7ONGIFYX.cjs → chunk-MZ4CRSY7.cjs} +481 -171
  146. package/dist/{chunk-O4F3JUST.mjs → chunk-NDDRTFN4.mjs} +4 -0
  147. package/dist/{chunk-4IHMHFQB.cjs → chunk-NG2EZ6QS.cjs} +28 -1
  148. package/dist/{chunk-XBSLKXBL.mjs → chunk-NT4W4H52.mjs} +52 -35
  149. package/dist/{chunk-UAQD67HM.mjs → chunk-NVOMQLI2.mjs} +16 -2
  150. package/dist/{chunk-R62SF5R4.mjs → chunk-OB45EAQL.mjs} +6 -1
  151. package/dist/{chunk-V56632LA.cjs → chunk-OCNV4CI2.cjs} +39 -6
  152. package/dist/{chunk-SYXPWJ7N.cjs → chunk-OFBLGH6V.cjs} +17 -18
  153. package/dist/{chunk-VQ4NWOWO.mjs → chunk-OGVTUGMU.mjs} +5 -13
  154. package/dist/{chunk-3UZVPO72.mjs → chunk-OIOPQ25L.mjs} +6 -7
  155. package/dist/{chunk-2XGBJSDV.cjs → chunk-OO7DYIJD.cjs} +73 -24
  156. package/dist/{chunk-27FPUFWR.mjs → chunk-P2NBQ5JI.mjs} +1 -1
  157. package/dist/{chunk-HZPKJRYA.cjs → chunk-PDFFYZAT.cjs} +2 -2
  158. package/dist/{chunk-GSVJ3IIF.cjs → chunk-PHCJJJZV.cjs} +2 -2
  159. package/dist/{chunk-EVMXPJCB.mjs → chunk-PKMUQ7LM.mjs} +2 -1
  160. package/dist/{chunk-OAJOQU5J.mjs → chunk-PLJKJJ2H.mjs} +82 -63
  161. package/dist/{chunk-72KCTHLV.cjs → chunk-PRL7FXG4.cjs} +113 -29
  162. package/dist/{chunk-6XQSPIN6.cjs → chunk-PWKAX5MS.cjs} +13 -3
  163. package/dist/{chunk-4ZJ5C7UJ.cjs → chunk-QIXEU2WV.cjs} +19 -10
  164. package/dist/{chunk-FJWN7RV4.cjs → chunk-QO43L7Z4.cjs} +38 -8
  165. package/dist/{chunk-X4K7TYN6.cjs → chunk-QOGIZKSO.cjs} +26 -25
  166. package/dist/{chunk-CNNBFGL5.cjs → chunk-QSUYB3RH.cjs} +14 -14
  167. package/dist/chunk-QYNZ3CTI.mjs +17 -0
  168. package/dist/{chunk-X3XUZWRB.mjs → chunk-R2ZHU37O.mjs} +36 -3
  169. package/dist/{chunk-ZIHWAN55.cjs → chunk-RE5E2G5S.cjs} +1 -1
  170. package/dist/{chunk-O75GQVUK.mjs → chunk-RLH5AH2M.mjs} +1 -1
  171. package/dist/chunk-RWR7SMD7.cjs +50 -0
  172. package/dist/{chunk-7PTISZSQ.cjs → chunk-S7MWSFFP.cjs} +4 -0
  173. package/dist/chunk-SD6JGJOM.mjs +50 -0
  174. package/dist/{chunk-7H4SVNC4.cjs → chunk-SPP3EZTJ.cjs} +46 -26
  175. package/dist/{chunk-BIF5MLTH.cjs → chunk-SQ6IWJ3H.cjs} +1 -1
  176. package/dist/{chunk-WVYRLP5E.mjs → chunk-T5XFZQCL.mjs} +1 -1
  177. package/dist/{chunk-WAY6LOQH.mjs → chunk-TEJ67GD2.mjs} +1 -1
  178. package/dist/{chunk-OP7LHY4Y.cjs → chunk-TNK2TVRS.cjs} +2005 -800
  179. package/dist/{chunk-IFTGERT3.mjs → chunk-TTXIITYA.mjs} +49 -0
  180. package/dist/{chunk-ZFWYCVKS.mjs → chunk-TY5KCYDE.mjs} +22 -4
  181. package/dist/{chunk-WYAXRIYP.cjs → chunk-UKZ6AWKZ.cjs} +10 -9
  182. package/dist/{chunk-UJ3R2AH2.cjs → chunk-UPOYKX4S.cjs} +5 -5
  183. package/dist/{chunk-VBCQ5WOI.cjs → chunk-URN7VFO7.cjs} +105 -16
  184. package/dist/{chunk-2DLGV2ZG.mjs → chunk-UTUS6JUH.mjs} +1 -21
  185. package/dist/{chunk-435QJNC2.mjs → chunk-VFNAK6A5.mjs} +4 -4
  186. package/dist/{chunk-WFWFECDW.mjs → chunk-VRGY3X2I.mjs} +100 -11
  187. package/dist/{chunk-LQNW3ABP.cjs → chunk-VX2HZGC7.cjs} +14 -14
  188. package/dist/chunk-W44X6IC2.cjs +97 -0
  189. package/dist/{chunk-A2MN5PQJ.mjs → chunk-WMLSZAKN.mjs} +9 -9
  190. package/dist/{chunk-672ISQIG.mjs → chunk-WPB67LE5.mjs} +379 -69
  191. package/dist/{chunk-3EEET2Q5.cjs → chunk-WUTFJOV7.cjs} +32 -12
  192. package/dist/chunk-WVQNXXNE.cjs +28 -0
  193. package/dist/{chunk-Y5TOT5F6.cjs → chunk-X3MHKLCO.cjs} +5 -5
  194. package/dist/{chunk-W2ZXMMHA.mjs → chunk-XCAQTCGK.mjs} +1 -1
  195. package/dist/{chunk-Z7P2BTZ3.cjs → chunk-XGTFLG73.cjs} +30 -12
  196. package/dist/{chunk-XCXHQBMM.mjs → chunk-Y2LU4LE5.mjs} +1 -1
  197. package/dist/{chunk-5J45H65F.mjs → chunk-Y5LEPEVH.mjs} +1 -1
  198. package/dist/{chunk-D4MRNBVF.cjs → chunk-Y6KHPJDB.cjs} +2 -2
  199. package/dist/{chunk-BT4SEFLC.cjs → chunk-YAEN3L2F.cjs} +3 -2
  200. package/dist/chunk-YFTGIHNC.mjs +26 -0
  201. package/dist/{chunk-KL7SHLQB.mjs → chunk-YGJ5P3TJ.mjs} +31 -1
  202. package/dist/{chunk-752IHQTD.cjs → chunk-YTNBCXCW.cjs} +12 -12
  203. package/dist/{chunk-RFKTJTWZ.mjs → chunk-YVPX5PI5.mjs} +3 -1
  204. package/dist/{chunk-4TVPYN32.cjs → chunk-Z3PW3DIR.cjs} +7 -7
  205. package/dist/{chunk-OB7VKCUZ.mjs → chunk-Z6SOXHAD.mjs} +1851 -646
  206. package/dist/{chunk-72KABRWN.mjs → chunk-ZJGFAW5U.mjs} +5 -3
  207. package/dist/{chunk-TNBJ4LZG.mjs → chunk-ZPKJPM7K.mjs} +4 -4
  208. package/dist/{chunk-5FE5YT2N.mjs → chunk-ZZGQD3LL.mjs} +28 -1
  209. package/dist/client/lifecycle.cjs +2 -2
  210. package/dist/client/lifecycle.d.mts +1 -1
  211. package/dist/client/lifecycle.d.ts +1 -1
  212. package/dist/client/lifecycle.mjs +1 -1
  213. package/dist/{client-component.d-D74pqdea.d.mts → client-component.d-BvQOxSqh.d.mts} +2 -2
  214. package/dist/{client-component.d-D8VcypQA.d.ts → client-component.d-DNVSLEPi.d.ts} +2 -2
  215. package/dist/client-plugins.cjs +2 -2
  216. package/dist/{client-plugins.d-D4-6hNx7.d.mts → client-plugins.d-CE1lVK2R.d.mts} +116 -373
  217. package/dist/{client-plugins.d-CXElzotB.d.ts → client-plugins.d-CNDqcAuf.d.ts} +116 -373
  218. package/dist/client-plugins.d.mts +10 -8
  219. package/dist/client-plugins.d.ts +10 -8
  220. package/dist/client-plugins.mjs +1 -1
  221. package/dist/client.cjs +11 -9
  222. package/dist/client.d.mts +17 -15
  223. package/dist/client.d.ts +17 -15
  224. package/dist/client.mjs +10 -8
  225. package/dist/{config.d-qt-mE8O5.d.mts → config.d-BKIhJtmr.d.mts} +7 -2
  226. package/dist/{config.d-qt-mE8O5.d.ts → config.d-BKIhJtmr.d.ts} +7 -2
  227. package/dist/config.d.mts +10 -8
  228. package/dist/config.d.ts +10 -8
  229. package/dist/cron.cjs +2 -2
  230. package/dist/cron.mjs +1 -1
  231. package/dist/deferred.cjs +2 -2
  232. package/dist/deferred.mjs +1 -1
  233. package/dist/deployment.cjs +4 -2
  234. package/dist/deployment.d.mts +15 -1
  235. package/dist/deployment.d.ts +15 -1
  236. package/dist/deployment.mjs +3 -1
  237. package/dist/desktop.d.mts +11 -9
  238. package/dist/desktop.d.ts +11 -9
  239. package/dist/{devtools-NZUVNUP3.mjs → devtools-2A2GPC7B.mjs} +33 -29
  240. package/dist/{devtools-N2JQCMXB.cjs → devtools-R27T3BRY.cjs} +38 -34
  241. package/dist/docs.cjs +28 -27
  242. package/dist/docs.d.mts +24 -10
  243. package/dist/docs.d.ts +24 -10
  244. package/dist/docs.mjs +27 -26
  245. package/dist/env-types.cjs +3 -3
  246. package/dist/env-types.mjs +2 -2
  247. package/dist/environment/vite.cjs +7 -7
  248. package/dist/environment/vite.d.mts +1 -1
  249. package/dist/environment/vite.d.ts +1 -1
  250. package/dist/environment/vite.mjs +6 -6
  251. package/dist/{generate-route-types.d-BL2pq6xC.d.ts → generate-route-types.d-B76M5R11.d.ts} +1 -1
  252. package/dist/{generate-route-types.d-BoVDU8qX.d.mts → generate-route-types.d-CaGMIaNI.d.mts} +1 -1
  253. package/dist/headers.cjs +3 -3
  254. package/dist/headers.mjs +2 -2
  255. package/dist/image/server.d.mts +1 -1
  256. package/dist/image/server.d.ts +1 -1
  257. package/dist/image/sharp.d.mts +1 -1
  258. package/dist/image/sharp.d.ts +1 -1
  259. package/dist/{image-config.d-CeDgNyX4.d.mts → image-config.d-ByhQ0TT7.d.mts} +3 -1
  260. package/dist/{image-config.d-CeDgNyX4.d.ts → image-config.d-ByhQ0TT7.d.ts} +3 -1
  261. package/dist/image.cjs +6 -6
  262. package/dist/image.d.mts +1 -1
  263. package/dist/image.d.ts +1 -1
  264. package/dist/image.mjs +1 -1
  265. package/dist/index.cjs +148 -128
  266. package/dist/{index.d-SSgYDv4D.d.mts → index.d-Bt3kl19W.d.mts} +1 -1
  267. package/dist/{index.d-A_x10zGS.d.ts → index.d-Cx_-DaKV.d.ts} +1 -1
  268. package/dist/index.d.mts +39 -87
  269. package/dist/index.d.ts +39 -87
  270. package/dist/index.mjs +224 -204
  271. package/dist/instrumentation.cjs +3 -3
  272. package/dist/instrumentation.mjs +2 -2
  273. package/dist/{integration-orm-52GPGTHO.cjs → integrations/orm.cjs} +5 -5
  274. package/dist/integrations/orm.d.mts +35 -0
  275. package/dist/integrations/orm.d.ts +35 -0
  276. package/dist/{integration-orm-CO23MSFE.mjs → integrations/orm.mjs} +5 -5
  277. package/dist/integrations.cjs +6 -5
  278. package/dist/integrations.d.mts +10 -8
  279. package/dist/integrations.d.ts +10 -8
  280. package/dist/integrations.mjs +5 -4
  281. package/dist/internal/app-markdown-runtime.cjs +4 -4
  282. package/dist/internal/app-markdown-runtime.d.mts +27 -11
  283. package/dist/internal/app-markdown-runtime.d.ts +27 -11
  284. package/dist/internal/app-markdown-runtime.mjs +3 -3
  285. package/dist/internal/build-runtime.cjs +76 -71
  286. package/dist/internal/build-runtime.d.mts +12 -10
  287. package/dist/internal/build-runtime.d.ts +12 -10
  288. package/dist/internal/build-runtime.mjs +75 -70
  289. package/dist/internal/cli-runtime.cjs +47 -46
  290. package/dist/internal/cli-runtime.mjs +46 -45
  291. package/dist/internal/client-error-overlay.cjs +6 -6
  292. package/dist/internal/client-error-overlay.mjs +2 -2
  293. package/dist/internal/client-runtime.cjs +85 -36
  294. package/dist/internal/client-runtime.d.mts +44 -13
  295. package/dist/internal/client-runtime.d.ts +44 -13
  296. package/dist/internal/client-runtime.mjs +79 -30
  297. package/dist/internal/compression-runtime.d.mts +10 -8
  298. package/dist/internal/compression-runtime.d.ts +10 -8
  299. package/dist/internal/config-runtime.cjs +27 -26
  300. package/dist/internal/config-runtime.d.mts +14 -12
  301. package/dist/internal/config-runtime.d.ts +14 -12
  302. package/dist/internal/config-runtime.mjs +26 -25
  303. package/dist/internal/docs-precompiled-runtime.cjs +16 -5
  304. package/dist/internal/docs-precompiled-runtime.d.mts +7 -0
  305. package/dist/internal/docs-precompiled-runtime.d.ts +7 -0
  306. package/dist/internal/docs-precompiled-runtime.mjs +15 -4
  307. package/dist/internal/form-actions.cjs +7 -2
  308. package/dist/internal/form-actions.d.mts +10 -3
  309. package/dist/internal/form-actions.d.ts +10 -3
  310. package/dist/internal/form-actions.mjs +8 -3
  311. package/dist/internal/infra-analytics-runtime.cjs +11 -11
  312. package/dist/internal/infra-analytics-runtime.mjs +9 -9
  313. package/dist/internal/islands-boot.cjs +6 -1
  314. package/dist/internal/islands-boot.mjs +6 -1
  315. package/dist/internal/islands-runtime.cjs +33 -4
  316. package/dist/internal/islands-runtime.d.mts +1 -1
  317. package/dist/internal/islands-runtime.d.ts +1 -1
  318. package/dist/internal/islands-runtime.mjs +31 -2
  319. package/dist/internal/native-server-fns.cjs +5 -5
  320. package/dist/internal/native-server-fns.mjs +4 -4
  321. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  322. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  323. package/dist/internal/production-node-env.cjs +4 -2
  324. package/dist/internal/production-node-env.d.mts +22 -1
  325. package/dist/internal/production-node-env.d.ts +22 -1
  326. package/dist/internal/production-node-env.mjs +3 -1
  327. package/dist/internal/production-runtime.cjs +57 -39
  328. package/dist/internal/production-runtime.d.mts +27 -21
  329. package/dist/internal/production-runtime.d.ts +27 -21
  330. package/dist/internal/production-runtime.mjs +72 -54
  331. package/dist/internal/react-cache.cjs +3 -3
  332. package/dist/internal/react-cache.mjs +1 -1
  333. package/dist/internal/server-tree.cjs +2 -2
  334. package/dist/internal/server-tree.d.mts +0 -5
  335. package/dist/internal/server-tree.d.ts +0 -5
  336. package/dist/internal/server-tree.mjs +1 -1
  337. package/dist/internal/vercel-edge-middleware.cjs +87 -0
  338. package/dist/internal/vercel-edge-middleware.d.mts +39 -0
  339. package/dist/internal/vercel-edge-middleware.d.ts +39 -0
  340. package/dist/internal/vercel-edge-middleware.mjs +87 -0
  341. package/dist/layers-7P4RLKVX.cjs +20 -0
  342. package/dist/{layers-T55SA47E.mjs → layers-XQ7VFMWO.mjs} +4 -2
  343. package/dist/{layers.d-CcS42OGR.d.mts → layers.d-CH0bC4QL.d.mts} +2 -1
  344. package/dist/{layers.d-CcS42OGR.d.ts → layers.d-CH0bC4QL.d.ts} +2 -1
  345. package/dist/{lifecycle.d-C2aLBOwu.d.ts → lifecycle.d-keQs5Swc.d.mts} +7 -1
  346. package/dist/{lifecycle.d-C2aLBOwu.d.mts → lifecycle.d-keQs5Swc.d.ts} +7 -1
  347. package/dist/{manager-H5ZM3HAM.mjs → manager-JIA66YJ2.mjs} +4 -3
  348. package/dist/manager-JOHU6BQI.cjs +15 -0
  349. package/dist/markdown.cjs +7 -3
  350. package/dist/markdown.d.mts +10 -8
  351. package/dist/markdown.d.ts +10 -8
  352. package/dist/markdown.mjs +6 -2
  353. package/dist/middleware.cjs +11 -11
  354. package/dist/middleware.d.mts +13 -10
  355. package/dist/middleware.d.ts +13 -10
  356. package/dist/middleware.mjs +13 -13
  357. package/dist/mobile.d.mts +6 -6
  358. package/dist/mobile.d.ts +6 -6
  359. package/dist/mount.d-Bki4pOaJ.d.mts +38 -0
  360. package/dist/mount.d-DjR5aerM.d.ts +38 -0
  361. package/dist/{native-server-fn-handler-GLRHAYWV.mjs → native-server-fn-handler-EP5AFJYE.mjs} +5 -5
  362. package/dist/{native-server-fn-handler-J5MYRXN6.cjs → native-server-fn-handler-QRTXGZA4.cjs} +6 -6
  363. package/dist/{native-tree-7LPH57Z4.cjs → native-tree-W2SSJB3Y.cjs} +4 -4
  364. package/dist/{native-tree-VV6WN3GX.mjs → native-tree-Y5YQANW7.mjs} +3 -3
  365. package/dist/{navigation-delegate.d-GghbHJuK.d.ts → navigation-delegate.d-CtghaSP3.d.ts} +1 -1
  366. package/dist/{navigation-delegate.d-DQVYKoaZ.d.mts → navigation-delegate.d-VDkziXTK.d.mts} +1 -1
  367. package/dist/navigation.cjs +8 -7
  368. package/dist/navigation.d.mts +13 -11
  369. package/dist/navigation.d.ts +13 -11
  370. package/dist/navigation.mjs +7 -6
  371. package/dist/{nitro-DD4QCA66.mjs → nitro-NSTXT7LB.mjs} +11 -11
  372. package/dist/{nitro-VRDX2H4M.cjs → nitro-Y3LGITW3.cjs} +13 -13
  373. package/dist/node-module-bundle-LIZ2KMVW.cjs +13 -0
  374. package/dist/node-module-bundle-VR6NV6AI.mjs +13 -0
  375. package/dist/{plugin-53SY5YBS.mjs → plugin-SAS22JL7.mjs} +4 -3
  376. package/dist/{plugin-HZIBL3DW.cjs → plugin-WIU4GDD4.cjs} +5 -4
  377. package/dist/plugin.cjs +65 -63
  378. package/dist/plugin.d.mts +12 -10
  379. package/dist/plugin.d.ts +12 -10
  380. package/dist/plugin.mjs +64 -62
  381. package/dist/{production-runtime.d-Bzns3NW9.d.ts → production-runtime.d-BMyyLGBB.d.ts} +3 -57
  382. package/dist/{production-runtime.d-DiFa5vHW.d.mts → production-runtime.d-DMZY3OgV.d.mts} +3 -57
  383. package/dist/query/client.cjs +9 -7
  384. package/dist/query/client.mjs +5 -3
  385. package/dist/{render-plan.d-CcF0MeCf.d.mts → render-plan.d-BSwV8PE4.d.mts} +1 -1
  386. package/dist/{render-plan.d-CL_Ikfg_.d.ts → render-plan.d-i9sI4tc9.d.ts} +1 -1
  387. package/dist/renderer/none/server.cjs +35 -0
  388. package/dist/renderer/none/server.d.mts +21 -0
  389. package/dist/renderer/none/server.d.ts +21 -0
  390. package/dist/renderer/none/server.mjs +35 -0
  391. package/dist/renderer/react/server.cjs +3 -3
  392. package/dist/renderer/react/server.mjs +3 -3
  393. package/dist/renderer-client.cjs +8 -6
  394. package/dist/renderer-client.d.mts +13 -11
  395. package/dist/renderer-client.d.ts +13 -11
  396. package/dist/renderer-client.mjs +5 -3
  397. package/dist/renderer.cjs +6 -2
  398. package/dist/renderer.d.mts +25 -2
  399. package/dist/renderer.d.ts +25 -2
  400. package/dist/renderer.mjs +5 -1
  401. package/dist/request.cjs +2 -2
  402. package/dist/{request.d-DarDOCk9.d.mts → request.d-C24FNQ_7.d.mts} +1 -1
  403. package/dist/{request.d-B1RnTLri.d.ts → request.d-Dgln8tuI.d.ts} +1 -1
  404. package/dist/request.d.mts +11 -9
  405. package/dist/request.d.ts +11 -9
  406. package/dist/request.mjs +1 -1
  407. package/dist/{route-rendering.d-BTUYCIj4.d.ts → route-rendering.d-CUylZKJA.d.ts} +1 -1
  408. package/dist/{route-rendering.d-D_2Ual0-.d.mts → route-rendering.d-Ds0BfwQi.d.mts} +1 -1
  409. package/dist/{route.d-BaVH3V0w.d.mts → route.d-DrXkpvcg.d.mts} +1 -1
  410. package/dist/{route.d-DBTEqifW.d.ts → route.d-hs-_cyHn.d.ts} +1 -1
  411. package/dist/{router.d-CMANF6da.d.ts → router.d-B56rMOFm.d.ts} +1 -1
  412. package/dist/{router.d-Cuv1jntg.d.mts → router.d-CFPcbqzc.d.mts} +1 -1
  413. package/dist/routes.cjs +3 -3
  414. package/dist/{routes.d-B6yFe6jm.d.ts → routes.d-9GFFNioh.d.ts} +2 -2
  415. package/dist/{routes.d-c2HKfrfL.d.mts → routes.d-CrEy0lJS.d.mts} +2 -2
  416. package/dist/routes.d.mts +10 -8
  417. package/dist/routes.d.ts +10 -8
  418. package/dist/routes.mjs +2 -2
  419. package/dist/{rsc-pipeline-Z7QBZOIJ.cjs → rsc-pipeline-3T7V6OUT.cjs} +30 -28
  420. package/dist/{rsc-pipeline-7PNVJSTR.mjs → rsc-pipeline-GA4AQWZI.mjs} +29 -27
  421. package/dist/{runtime-FKFCUHSK.cjs → runtime-REUTNTI5.cjs} +72 -46
  422. package/dist/{runtime-QQHX4BP3.mjs → runtime-ZYCKKY7L.mjs} +60 -34
  423. package/dist/{runtime.d-wvh4ngU0.d.mts → runtime.d-DLRO-ExG.d.mts} +11 -3
  424. package/dist/{runtime.d-C3RQUj6_.d.ts → runtime.d-H7k9hOQE.d.ts} +11 -3
  425. package/dist/{schema-dev-notice-JMXEQWIQ.mjs → schema-dev-notice-C2JINRZI.mjs} +3 -2
  426. package/dist/{schema-dev-notice-PLBFDTOF.cjs → schema-dev-notice-X7GG7QVB.cjs} +5 -4
  427. package/dist/schema.cjs +6 -2
  428. package/dist/schema.d-Dny9pnrm.d.mts +298 -0
  429. package/dist/schema.d-Dny9pnrm.d.ts +298 -0
  430. package/dist/schema.d.mts +1 -115
  431. package/dist/schema.d.ts +1 -115
  432. package/dist/schema.mjs +5 -1
  433. package/dist/server-fn-client.d.mts +2 -2
  434. package/dist/server-fn-client.d.ts +2 -2
  435. package/dist/server-fn.cjs +5 -5
  436. package/dist/server-fn.mjs +4 -4
  437. package/dist/server-http.d-rAe7lAQc.d.mts +70 -0
  438. package/dist/server-http.d-rAe7lAQc.d.ts +70 -0
  439. package/dist/server-plugins.cjs +7 -7
  440. package/dist/server-plugins.d.mts +20 -12
  441. package/dist/server-plugins.d.ts +20 -12
  442. package/dist/server-plugins.mjs +8 -8
  443. package/dist/server-query.cjs +6 -6
  444. package/dist/server-query.mjs +5 -5
  445. package/dist/server.cjs +168 -126
  446. package/dist/server.d-C5FFrZAo.d.ts +57 -0
  447. package/dist/server.d-DgC8xew5.d.mts +57 -0
  448. package/dist/server.d.mts +24 -16
  449. package/dist/server.d.ts +24 -16
  450. package/dist/server.mjs +144 -102
  451. package/dist/{spa-router.d-m8H_Kl_B.d.ts → spa-router.d-Dr7oanhl.d.ts} +15 -5
  452. package/dist/{spa-router.d-WU_qS5gJ.d.mts → spa-router.d-g4CzhEH1.d.mts} +15 -5
  453. package/dist/testing.cjs +17 -17
  454. package/dist/testing.d.mts +10 -8
  455. package/dist/testing.d.ts +10 -8
  456. package/dist/testing.mjs +13 -13
  457. package/dist/theme/server.cjs +3 -3
  458. package/dist/theme/server.mjs +2 -2
  459. package/dist/types.d-xCIhyjOq.d.mts +233 -0
  460. package/dist/types.d-xCIhyjOq.d.ts +233 -0
  461. package/dist/{utils.d-C9dQD5Zg.d.ts → utils.d-BxxyDEb8.d.ts} +1 -1
  462. package/dist/{utils.d-W9IiEqmW.d.mts → utils.d-HIla3pD_.d.mts} +1 -1
  463. package/dist/version.cjs +2 -2
  464. package/dist/version.mjs +1 -1
  465. package/dist/vite.cjs +65 -63
  466. package/dist/vite.d.mts +36 -14
  467. package/dist/vite.d.ts +36 -14
  468. package/dist/vite.mjs +64 -62
  469. package/dist/workflows.cjs +4 -4
  470. package/dist/workflows.d.mts +121 -1
  471. package/dist/workflows.d.ts +121 -1
  472. package/dist/workflows.mjs +3 -3
  473. package/package.json +37 -2
  474. package/dist/analyzer-H7SIX6BJ.cjs +0 -16
  475. package/dist/chunk-5YPBFMBN.cjs +0 -19
  476. package/dist/chunk-CLFEQGET.cjs +0 -60
  477. package/dist/chunk-MK5E44WP.mjs +0 -60
  478. package/dist/chunk-OM7WILES.mjs +0 -100
  479. package/dist/chunk-Q5B4LNON.mjs +0 -19
  480. package/dist/chunk-QPJ4MZTO.mjs +0 -60
  481. package/dist/chunk-R53QDV6T.cjs +0 -100
  482. package/dist/chunk-UYTAP4FQ.cjs +0 -60
  483. package/dist/layers-DMRXRL7F.cjs +0 -18
  484. package/dist/manager-2LUKNX2N.cjs +0 -14
  485. package/dist/node-module-bundle-7JHPPF6B.mjs +0 -11
  486. package/dist/node-module-bundle-YJGYBOGK.cjs +0 -11
  487. package/dist/workflows.d-CRMzQZ3k.d.mts +0 -188
  488. package/dist/workflows.d-CRMzQZ3k.d.ts +0 -188
  489. /package/dist/{chunk-QGOZLGVP.mjs → chunk-I6FIAWNT.mjs} +0 -0
  490. /package/dist/{chunk-XPIPMWY3.cjs → chunk-K5NI5YQR.cjs} +0 -0
  491. /package/dist/{chunk-NWUHS6GV.cjs → chunk-QEJWNXRI.cjs} +0 -0
  492. /package/dist/{chunk-FSXSQQTV.mjs → chunk-TXE4SAMV.mjs} +0 -0
  493. /package/dist/{chunk-ZXK2EYQW.cjs → chunk-UUQNJDGH.cjs} +0 -0
  494. /package/dist/{chunk-46P5KNTE.mjs → chunk-VZBAW44S.mjs} +0 -0
@@ -4,13 +4,13 @@ var _chunk7KJJ4SBScjs = require('./chunk-7KJJ4SBS.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunkZIHWAN55cjs = require('./chunk-ZIHWAN55.cjs');
7
+ var _chunkRE5E2G5Scjs = require('./chunk-RE5E2G5S.cjs');
8
8
 
9
9
 
10
- var _chunk5Y2P454Ocjs = require('./chunk-5Y2P454O.cjs');
10
+ var _chunkMTBDJ326cjs = require('./chunk-MTBDJ326.cjs');
11
11
 
12
12
 
13
- var _chunkRD623KW4cjs = require('./chunk-RD623KW4.cjs');
13
+ var _chunk67MZTLTFcjs = require('./chunk-67MZTLTF.cjs');
14
14
 
15
15
 
16
16
 
@@ -21,7 +21,7 @@ var _chunkE7QOEV5Zcjs = require('./chunk-E7QOEV5Z.cjs');
21
21
  var _chunkQMNWKQL4cjs = require('./chunk-QMNWKQL4.cjs');
22
22
 
23
23
 
24
- var _chunkBIF5MLTHcjs = require('./chunk-BIF5MLTH.cjs');
24
+ var _chunkSQ6IWJ3Hcjs = require('./chunk-SQ6IWJ3H.cjs');
25
25
 
26
26
  // src/environment-vite.ts
27
27
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
@@ -192,14 +192,18 @@ function resolveSource(file, source) {
192
192
  if (source.startsWith(".")) return resolveRelative(file, source);
193
193
  return resolveFarmPackageDefaultEntry(file, source);
194
194
  }
195
- function traceFarmExport(file, name, depth = 0) {
195
+ function traceExport(file, name, depth) {
196
196
  if (depth > 8) return void 0;
197
197
  const program = readModule(file);
198
198
  if (!program) return void 0;
199
- if (isClientModule(program)) return "client";
199
+ const client = isClientModule(program);
200
+ const here = (kind) => ({ kind, file });
201
+ if (client && !(_nullishCoalesce(program.body, () => ( []))).some((node) => (_nullishCoalesce(node.type, () => ( ""))).startsWith("Export"))) {
202
+ return here("client");
203
+ }
200
204
  const follow = (source, imported) => {
201
205
  const target = resolveSource(file, source);
202
- return target ? traceFarmExport(target, imported, depth + 1) : void 0;
206
+ return target ? traceExport(target, imported, depth + 1) : void 0;
203
207
  };
204
208
  const imports = /* @__PURE__ */ new Map();
205
209
  for (const node of _nullishCoalesce(program.body, () => ( []))) {
@@ -212,38 +216,44 @@ function traceFarmExport(file, name, depth = 0) {
212
216
  }
213
217
  const local = (localName) => {
214
218
  const binding = imports.get(localName);
215
- return binding ? follow(binding.source, binding.imported) : "server";
219
+ return binding ? follow(binding.source, binding.imported) : here("server");
216
220
  };
221
+ const own = (traced) => client ? here("client") : traced();
217
222
  const stars = [];
218
223
  for (const node of _nullishCoalesce(program.body, () => ( []))) {
219
224
  if (node.type === "ExportNamedDeclaration" && node.source) {
220
225
  for (const specifier of _nullishCoalesce(node.specifiers, () => ( []))) {
221
226
  if (exportedName(specifier.exported) !== name) continue;
222
- return follow(node.source.value, _nullishCoalesce(exportedName(specifier.local), () => ( name)));
227
+ return own(() => follow(node.source.value, _nullishCoalesce(exportedName(specifier.local), () => ( name))));
223
228
  }
224
229
  } else if (node.type === "ExportAllDeclaration" && node.source && !node.exported) {
225
230
  stars.push(node.source.value);
226
231
  } else if (node.type === "ExportNamedDeclaration" && !node.source) {
227
232
  for (const specifier of _nullishCoalesce(node.specifiers, () => ( []))) {
228
233
  if (exportedName(specifier.exported) === name) {
229
- return local(_nullishCoalesce(exportedName(specifier.local), () => ( name)));
234
+ return own(() => local(_nullishCoalesce(exportedName(specifier.local), () => ( name))));
230
235
  }
231
236
  }
232
237
  const declared = [
233
238
  ..._optionalChain([node, 'access', _5 => _5.declaration, 'optionalAccess', _6 => _6.id]) ? [node.declaration.id.name] : [],
234
239
  ...(_nullishCoalesce(_optionalChain([node, 'access', _7 => _7.declaration, 'optionalAccess', _8 => _8.declarations]), () => ( []))).map((declarator) => _optionalChain([declarator, 'access', _9 => _9.id, 'optionalAccess', _10 => _10.name]))
235
240
  ];
236
- if (declared.includes(name)) return "server";
241
+ if (declared.includes(name)) return here(client ? "client" : "server");
237
242
  } else if (node.type === "ExportDefaultDeclaration" && name === "default") {
238
- return _optionalChain([node, 'access', _11 => _11.declaration, 'optionalAccess', _12 => _12.type]) === "Identifier" ? local(node.declaration.name) : "server";
243
+ return own(
244
+ () => _optionalChain([node, 'access', _11 => _11.declaration, 'optionalAccess', _12 => _12.type]) === "Identifier" ? local(node.declaration.name) : here("server")
245
+ );
239
246
  }
240
247
  }
241
248
  for (const source of stars) {
242
249
  const traced = follow(source, name);
243
- if (traced) return traced;
250
+ if (traced) return own(() => traced);
244
251
  }
245
252
  return void 0;
246
253
  }
254
+ function traceFarmExport(file, name) {
255
+ return _optionalChain([traceExport, 'call', _13 => _13(file, name, 0), 'optionalAccess', _14 => _14.kind]);
256
+ }
247
257
  function isFarmClientExport(file, name) {
248
258
  return traceFarmExport(file, name) === "client";
249
259
  }
@@ -271,8 +281,8 @@ function namespaceMembers(program, local) {
271
281
  }
272
282
  const current = node;
273
283
  if (typeof current.type !== "string") return;
274
- if ((current.type === "Identifier" || current.type === "JSXIdentifier") && current.name === local && _optionalChain([parent, 'optionalAccess', _13 => _13.type]) !== "ImportNamespaceSpecifier") {
275
- const property = (_optionalChain([parent, 'optionalAccess', _14 => _14.type]) === "MemberExpression" || _optionalChain([parent, 'optionalAccess', _15 => _15.type]) === "JSXMemberExpression") && parent.object === current && !parent.computed ? _optionalChain([parent, 'access', _16 => _16.property, 'optionalAccess', _17 => _17.name]) : void 0;
284
+ if ((current.type === "Identifier" || current.type === "JSXIdentifier") && current.name === local && _optionalChain([parent, 'optionalAccess', _15 => _15.type]) !== "ImportNamespaceSpecifier") {
285
+ const property = (_optionalChain([parent, 'optionalAccess', _16 => _16.type]) === "MemberExpression" || _optionalChain([parent, 'optionalAccess', _17 => _17.type]) === "JSXMemberExpression") && parent.object === current && !parent.computed ? _optionalChain([parent, 'access', _18 => _18.property, 'optionalAccess', _19 => _19.name]) : void 0;
276
286
  if (property) members.add(property);
277
287
  else opaque = true;
278
288
  return;
@@ -289,7 +299,7 @@ function findPackageImports(program, accept) {
289
299
  const found = [];
290
300
  for (const node of _nullishCoalesce(program.body, () => ( []))) {
291
301
  if (node.type !== "ImportDeclaration" || node.importKind === "type") continue;
292
- const specifier = _optionalChain([node, 'access', _18 => _18.source, 'optionalAccess', _19 => _19.value]);
302
+ const specifier = _optionalChain([node, 'access', _20 => _20.source, 'optionalAccess', _21 => _21.value]);
293
303
  if (typeof specifier !== "string" || !accept(specifier)) continue;
294
304
  const specifiers = (_nullishCoalesce(node.specifiers, () => ( []))).filter(
295
305
  (entry2) => entry2.importKind !== "type"
@@ -328,12 +338,76 @@ function findFarmReactServerClientNames(code, file, specifier) {
328
338
  const wanted = [
329
339
  ...entry.defaultLocal ? ["default"] : [],
330
340
  ...entry.named.map((binding) => binding.imported),
331
- ..._nullishCoalesce(_optionalChain([entry, 'access', _20 => _20.namespace, 'optionalAccess', _21 => _21.members]), () => ( []))
341
+ ..._nullishCoalesce(_optionalChain([entry, 'access', _22 => _22.namespace, 'optionalAccess', _23 => _23.members]), () => ( []))
332
342
  ];
333
343
  for (const name of wanted) if (isFarmClientExport(target, name)) names.add(name);
334
344
  }
335
345
  return [...names];
336
346
  }
347
+ function clientModuleSource(node) {
348
+ if (node.importKind === "type" || node.exportKind === "type") return null;
349
+ const source = (node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration" && node.source) && _optionalChain([node, 'access', _24 => _24.source, 'optionalAccess', _25 => _25.value]);
350
+ return typeof source === "string" && source.startsWith(".") ? source : null;
351
+ }
352
+ function isClientModuleFile(file) {
353
+ const program = readModule(file);
354
+ return program !== null && isClientModule(program);
355
+ }
356
+ function findFarmReactServerClientModules(code, file, specifier) {
357
+ const target = resolveFarmReactServerExport(file, specifier);
358
+ if (!target) return null;
359
+ const program = parseCode(code, file);
360
+ if (!program) return null;
361
+ const found = /* @__PURE__ */ new Set();
362
+ const seen = /* @__PURE__ */ new Set();
363
+ const walk2 = (current, depth) => {
364
+ if (depth > 8 || seen.has(current)) return;
365
+ seen.add(current);
366
+ const module = readModule(current);
367
+ if (!module || isClientModule(module)) return;
368
+ for (const node of _nullishCoalesce(module.body, () => ( []))) {
369
+ const source = _nullishCoalesce(clientModuleSource(node), () => ( (node.type === "ExportAllDeclaration" && typeof _optionalChain([node, 'access', _26 => _26.source, 'optionalAccess', _27 => _27.value]) === "string" ? node.source.value : null)));
370
+ if (!_optionalChain([source, 'optionalAccess', _28 => _28.startsWith, 'call', _29 => _29(".")])) continue;
371
+ const child = resolveRelative(current, source);
372
+ if (!child) continue;
373
+ if (isClientModuleFile(child)) {
374
+ if (clientModuleSource(node)) found.add(child);
375
+ } else walk2(child, depth + 1);
376
+ }
377
+ };
378
+ for (const entry of findPackageImports(program, (candidate) => candidate === specifier)) {
379
+ const wanted = [
380
+ ...entry.defaultLocal ? ["default"] : [],
381
+ ...entry.named.map((binding) => binding.imported),
382
+ ..._nullishCoalesce(_optionalChain([entry, 'access', _30 => _30.namespace, 'optionalAccess', _31 => _31.members]), () => ( []))
383
+ ];
384
+ for (const name of wanted) {
385
+ const traced = traceExport(target, name, 0);
386
+ if (_optionalChain([traced, 'optionalAccess', _32 => _32.kind]) === "server") walk2(traced.file, 0);
387
+ }
388
+ }
389
+ return [...found].sort();
390
+ }
391
+ function rewriteFarmReactServerClientModuleImports(options) {
392
+ if (!options.code.includes("import") && !options.code.includes("export")) return null;
393
+ const program = parseCode(options.code, options.file);
394
+ if (!program) return null;
395
+ const sources = [];
396
+ for (const node of _nullishCoalesce(program.body, () => ( []))) {
397
+ const source = clientModuleSource(node);
398
+ if (!source) continue;
399
+ const child = resolveRelative(options.file, source);
400
+ if (!child || !isClientModuleFile(child)) continue;
401
+ const reference = options.reference(child);
402
+ if (reference) sources.push({ start: node.source.start, end: node.source.end, reference });
403
+ }
404
+ if (sources.length === 0) return null;
405
+ let output = options.code;
406
+ for (const entry of sources.sort((left, right) => right.start - left.start)) {
407
+ output = output.slice(0, entry.start) + JSON.stringify(entry.reference) + output.slice(entry.end);
408
+ }
409
+ return output;
410
+ }
337
411
  function rewriteFarmReactServerImports(options) {
338
412
  if (!options.code.includes("import")) return null;
339
413
  const program = parseCode(options.code, options.file);
@@ -349,7 +423,7 @@ function rewriteFarmReactServerImports(options) {
349
423
  let next = 0;
350
424
  for (const entry of [...imports].sort((left, right) => right.start - left.start)) {
351
425
  const target = targets.get(entry.specifier);
352
- _optionalChain([options, 'access', _22 => _22.onServerFile, 'optionalCall', _23 => _23(target)]);
426
+ _optionalChain([options, 'access', _33 => _33.onServerFile, 'optionalCall', _34 => _34(target)]);
353
427
  const server = JSON.stringify(target);
354
428
  const lines = [];
355
429
  const bind = (name, local) => {
@@ -386,7 +460,7 @@ function staticImportSources(program) {
386
460
  continue;
387
461
  }
388
462
  if (node.importKind === "type" || node.exportKind === "type") continue;
389
- if (typeof _optionalChain([node, 'access', _24 => _24.source, 'optionalAccess', _25 => _25.value]) === "string") sources.push(node.source.value);
463
+ if (typeof _optionalChain([node, 'access', _35 => _35.source, 'optionalAccess', _36 => _36.value]) === "string") sources.push(node.source.value);
390
464
  }
391
465
  return sources;
392
466
  }
@@ -433,7 +507,7 @@ function farmRelativeImportFiles(code, file) {
433
507
  if (!program) return [];
434
508
  const files = [];
435
509
  for (const node of _nullishCoalesce(program.body, () => ( []))) {
436
- const source = (node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source) && _optionalChain([node, 'access', _26 => _26.source, 'optionalAccess', _27 => _27.value]);
510
+ const source = (node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source) && _optionalChain([node, 'access', _37 => _37.source, 'optionalAccess', _38 => _38.value]);
437
511
  if (typeof source !== "string" || !source.startsWith(".")) continue;
438
512
  const resolved = resolveRelative(file, source);
439
513
  if (resolved) files.push(resolved);
@@ -451,7 +525,7 @@ function farmReactServerBuildReachesClientModules(importer, specifier, serverImp
451
525
  if (!program) return false;
452
526
  if (depth > 0 && isClientModule(program)) return true;
453
527
  for (const node of _nullishCoalesce(program.body, () => ( []))) {
454
- const source = (node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source || node.type === "ImportDeclaration") && _optionalChain([node, 'access', _28 => _28.source, 'optionalAccess', _29 => _29.value]);
528
+ const source = (node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source || node.type === "ImportDeclaration") && _optionalChain([node, 'access', _39 => _39.source, 'optionalAccess', _40 => _40.value]);
455
529
  if (typeof source !== "string" || !source.startsWith(".")) continue;
456
530
  const child = resolveRelative(file, source);
457
531
  if (child && reaches(child, depth + 1)) return true;
@@ -507,12 +581,18 @@ function findFarmServerBundledPackage(importer, specifier) {
507
581
  try {
508
582
  const manifest = JSON.parse(_fs2.default.readFileSync(_path2.default.join(directory, "package.json"), "utf8"));
509
583
  if (manifest.exports === void 0 && manifest.type !== "module" && typeof manifest.module === "string" && typeof manifest.main === "string" && _path2.default.resolve(directory, manifest.main) !== _path2.default.resolve(directory, manifest.module)) {
510
- return parsed.name;
584
+ return { name: parsed.name, prebundle: isSelfContainedPackage(manifest, importer) };
511
585
  }
512
586
  } catch (e8) {
513
587
  return null;
514
588
  }
515
- return scanPackage(directory).stylesheets ? parsed.name : null;
589
+ return scanPackage(directory).stylesheets ? { name: parsed.name, prebundle: false } : null;
590
+ }
591
+ function isSelfContainedPackage(manifest, importer) {
592
+ if (Object.keys(_nullishCoalesce(manifest.dependencies, () => ( {}))).length > 0) return false;
593
+ return Object.keys(_nullishCoalesce(manifest.peerDependencies, () => ( {}))).every(
594
+ (peer) => _optionalChain([manifest, 'access', _41 => _41.peerDependenciesMeta, 'optionalAccess', _42 => _42[peer], 'optionalAccess', _43 => _43.optional]) === true || findPackageDirectory(importer, peer) !== null
595
+ );
516
596
  }
517
597
  function findFarmPackageManifest(importer, specifier) {
518
598
  const parsed = packageNameOf(specifier);
@@ -527,14 +607,16 @@ function findFarmPackageManifest(importer, specifier) {
527
607
  return null;
528
608
  }
529
609
  const dependencies = [...scanPackage(directory).imports].filter((imported) => {
530
- const name = _optionalChain([packageNameOf, 'call', _30 => _30(imported), 'optionalAccess', _31 => _31.name]);
610
+ const name = _optionalChain([packageNameOf, 'call', _44 => _44(imported), 'optionalAccess', _45 => _45.name]);
531
611
  return name !== void 0 && names.has(name);
532
612
  });
533
613
  return { name: parsed.name, dependencies: dependencies.sort() };
534
614
  }
535
615
  function listFarmPackageExports(importer, specifier) {
536
616
  const entry = resolveFarmPackageDefaultEntry(importer, specifier);
537
- if (!entry) return null;
617
+ return entry ? listFarmModuleExports(entry) : null;
618
+ }
619
+ function listFarmModuleExports(entry) {
538
620
  const names = /* @__PURE__ */ new Set();
539
621
  const seen = /* @__PURE__ */ new Set();
540
622
  const collect = (file, depth) => {
@@ -554,13 +636,13 @@ function listFarmPackageExports(importer, specifier) {
554
636
  if (name) names.add(name);
555
637
  } else if (node.type === "ExportNamedDeclaration") {
556
638
  esm = true;
557
- for (const specifier2 of _nullishCoalesce(node.specifiers, () => ( []))) {
558
- const name = exportedName(specifier2.exported);
639
+ for (const specifier of _nullishCoalesce(node.specifiers, () => ( []))) {
640
+ const name = exportedName(specifier.exported);
559
641
  if (name) names.add(name);
560
642
  }
561
- if (_optionalChain([node, 'access', _32 => _32.declaration, 'optionalAccess', _33 => _33.id, 'optionalAccess', _34 => _34.name])) names.add(node.declaration.id.name);
562
- for (const declarator of _nullishCoalesce(_optionalChain([node, 'access', _35 => _35.declaration, 'optionalAccess', _36 => _36.declarations]), () => ( []))) {
563
- if (_optionalChain([declarator, 'access', _37 => _37.id, 'optionalAccess', _38 => _38.type]) === "Identifier") names.add(declarator.id.name);
643
+ if (_optionalChain([node, 'access', _46 => _46.declaration, 'optionalAccess', _47 => _47.id, 'optionalAccess', _48 => _48.name])) names.add(node.declaration.id.name);
644
+ for (const declarator of _nullishCoalesce(_optionalChain([node, 'access', _49 => _49.declaration, 'optionalAccess', _50 => _50.declarations]), () => ( []))) {
645
+ if (_optionalChain([declarator, 'access', _51 => _51.id, 'optionalAccess', _52 => _52.type]) === "Identifier") names.add(declarator.id.name);
564
646
  }
565
647
  } else if (node.type === "ExportDefaultDeclaration") {
566
648
  esm = true;
@@ -652,7 +734,7 @@ function resolveProgrammaticClientRoutes(options) {
652
734
  const definedIn = /* @__PURE__ */ new Map();
653
735
  for (const route of definitions) {
654
736
  const source = _chunkE7QOEV5Zcjs.getProgrammaticRouteDefinitionSource.call(void 0, route);
655
- const callers = (_nullishCoalesce(_optionalChain([source, 'optionalAccess', _39 => _39.stacks]), () => ( []))).map((stack) => findRouteCallers(stack, modulesByFile));
737
+ const callers = (_nullishCoalesce(_optionalChain([source, 'optionalAccess', _53 => _53.stacks]), () => ( []))).map((stack) => findRouteCallers(stack, modulesByFile));
656
738
  for (const caller of callers.flat()) caller.routeSource = true;
657
739
  definedIn.set(route, callers.flat());
658
740
  if (!source || source.raw || (_nullishCoalesce(callers[0], () => ( []))).length === 0) untraced = true;
@@ -749,7 +831,7 @@ function resolveProgrammaticClientRoutes(options) {
749
831
  return { routes, routeSourceFiles };
750
832
  }
751
833
  function createEvaluatedRouteGraph(server) {
752
- const evaluated = _optionalChain([server, 'access', _40 => _40.environments, 'optionalAccess', _41 => _41.ssr, 'optionalAccess', _42 => _42.runner, 'optionalAccess', _43 => _43.evaluatedModules]);
834
+ const evaluated = _optionalChain([server, 'access', _54 => _54.environments, 'optionalAccess', _55 => _55.ssr, 'optionalAccess', _56 => _56.runner, 'optionalAccess', _57 => _57.evaluatedModules]);
753
835
  if (!evaluated) return void 0;
754
836
  const toGraphModule = (node) => ({
755
837
  id: node.id,
@@ -873,7 +955,7 @@ function isNodeBuiltinId(id) {
873
955
  return bare.startsWith("node:") || NODE_BUILTINS.has(bare);
874
956
  }
875
957
  function isProgrammaticRouteActionProxy(code) {
876
- return Boolean(_optionalChain([code, 'optionalAccess', _44 => _44.includes, 'call', _45 => _45("__farmRouteActionTarget: true")]));
958
+ return Boolean(_optionalChain([code, 'optionalAccess', _58 => _58.includes, 'call', _59 => _59("__farmRouteActionTarget: true")]));
877
959
  }
878
960
  function collectGraph(graph, routesFile) {
879
961
  const modules = /* @__PURE__ */ new Map();
@@ -1130,10 +1212,15 @@ function toModuleFile(file) {
1130
1212
 
1131
1213
 
1132
1214
  // src/islands-package-references.ts
1215
+ var _crypto = require('crypto');
1133
1216
 
1134
1217
 
1135
1218
 
1136
1219
  var IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
1220
+ var moduleName = (node) => {
1221
+ const name = _optionalChain([node, 'optionalAccess', _60 => _60.type]) === "Identifier" ? node.name : _optionalChain([node, 'optionalAccess', _61 => _61.value]);
1222
+ return typeof name === "string" ? name : null;
1223
+ };
1137
1224
  function parse(code, file) {
1138
1225
  const extension = _path2.default.extname(file).slice(1);
1139
1226
  const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
@@ -1164,8 +1251,8 @@ function namespaceMembers2(program, local, declaration) {
1164
1251
  if (opaque || node === declaration) return;
1165
1252
  const name = node.type === "Identifier" || node.type === "JSXIdentifier" ? node.name : null;
1166
1253
  if (name !== local) return;
1167
- if (_optionalChain([parent, 'optionalAccess', _46 => _46.type]) === "ImportNamespaceSpecifier") return;
1168
- const member = (_optionalChain([parent, 'optionalAccess', _47 => _47.type]) === "MemberExpression" || _optionalChain([parent, 'optionalAccess', _48 => _48.type]) === "JSXMemberExpression") && parent.object === node ? parent.property : null;
1254
+ if (_optionalChain([parent, 'optionalAccess', _62 => _62.type]) === "ImportNamespaceSpecifier") return;
1255
+ const member = (_optionalChain([parent, 'optionalAccess', _63 => _63.type]) === "MemberExpression" || _optionalChain([parent, 'optionalAccess', _64 => _64.type]) === "JSXMemberExpression") && parent.object === node ? parent.property : null;
1169
1256
  const property = member && !parent.computed && (member.type === "Identifier" || member.type === "JSXIdentifier") ? member.name : null;
1170
1257
  if (property) members.add(property);
1171
1258
  else opaque = true;
@@ -1173,17 +1260,19 @@ function namespaceMembers2(program, local, declaration) {
1173
1260
  return opaque ? null : [...members];
1174
1261
  }
1175
1262
  function findFarmPackageClientImports(code, file, isClientPackage) {
1176
- if (!code.includes("import")) return [];
1263
+ if (!code.includes("import") && !code.includes("export")) return [];
1177
1264
  const program = parse(code, file);
1178
1265
  if (!program) return [];
1179
1266
  const found = [];
1180
1267
  for (const node of _nullishCoalesce(program.body, () => ( []))) {
1181
- if (node.type !== "ImportDeclaration" || node.importKind === "type") continue;
1182
- const specifier = _optionalChain([node, 'access', _49 => _49.source, 'optionalAccess', _50 => _50.value]);
1268
+ const reexport = node.type === "ExportNamedDeclaration" && node.source != null;
1269
+ if (node.type !== "ImportDeclaration" && !reexport) continue;
1270
+ if (node.importKind === "type" || node.exportKind === "type") continue;
1271
+ const specifier = _optionalChain([node, 'access', _65 => _65.source, 'optionalAccess', _66 => _66.value]);
1183
1272
  if (typeof specifier !== "string" || specifier.startsWith(".") || specifier.startsWith("/"))
1184
1273
  continue;
1185
1274
  const specifiers = (_nullishCoalesce(node.specifiers, () => ( []))).filter(
1186
- (entry2) => entry2.importKind !== "type"
1275
+ (entry2) => entry2.importKind !== "type" && entry2.exportKind !== "type"
1187
1276
  );
1188
1277
  if (specifiers.length === 0 || !isClientPackage(specifier)) continue;
1189
1278
  const entry = {
@@ -1191,12 +1280,20 @@ function findFarmPackageClientImports(code, file, isClientPackage) {
1191
1280
  end: node.end,
1192
1281
  specifier,
1193
1282
  named: [],
1194
- kept: []
1283
+ kept: [],
1284
+ ...reexport ? { reexport: true } : {}
1195
1285
  };
1196
1286
  const client = (name) => isFarmPackageClientExport(file, specifier, name);
1197
1287
  let supported = true;
1198
1288
  for (const binding of specifiers) {
1199
- if (binding.type === "ImportDefaultSpecifier") {
1289
+ if (binding.type === "ExportSpecifier") {
1290
+ const imported = moduleName(binding.local);
1291
+ const exported = moduleName(binding.exported);
1292
+ if (!imported || !exported || !IDENTIFIER.test(imported) || !IDENTIFIER.test(exported))
1293
+ supported = false;
1294
+ else if (client(imported)) entry.named.push({ imported, local: exported });
1295
+ else entry.kept.push({ imported, local: exported });
1296
+ } else if (binding.type === "ImportDefaultSpecifier") {
1200
1297
  if (client("default")) entry.defaultLocal = binding.local.name;
1201
1298
  else entry.kept.push({ imported: "default", local: binding.local.name });
1202
1299
  } else if (binding.type === "ImportNamespaceSpecifier") {
@@ -1214,8 +1311,8 @@ function findFarmPackageClientImports(code, file, isClientPackage) {
1214
1311
  ...values.length > 0 ? { values } : {}
1215
1312
  };
1216
1313
  } else {
1217
- const imported = _optionalChain([binding, 'access', _51 => _51.imported, 'optionalAccess', _52 => _52.type]) === "Identifier" ? binding.imported.name : _optionalChain([binding, 'access', _53 => _53.imported, 'optionalAccess', _54 => _54.value]);
1218
- if (typeof imported !== "string" || !IDENTIFIER.test(imported)) supported = false;
1314
+ const imported = moduleName(binding.imported);
1315
+ if (!imported || !IDENTIFIER.test(imported)) supported = false;
1219
1316
  else if (client(imported)) entry.named.push({ imported, local: binding.local.name });
1220
1317
  else entry.kept.push({ imported, local: binding.local.name });
1221
1318
  }
@@ -1228,31 +1325,88 @@ function farmPackageClientImportExports(entry) {
1228
1325
  return [
1229
1326
  ...entry.defaultLocal ? ["default"] : [],
1230
1327
  ...entry.named.map((binding) => binding.imported),
1231
- ..._nullishCoalesce(_optionalChain([entry, 'access', _55 => _55.namespace, 'optionalAccess', _56 => _56.members]), () => ( []))
1328
+ ..._nullishCoalesce(_optionalChain([entry, 'access', _67 => _67.namespace, 'optionalAccess', _68 => _68.members]), () => ( []))
1232
1329
  ];
1233
1330
  }
1234
1331
  var FARM_CLIENT_REFERENCE_PRAGMA = "// @farm-client-reference";
1235
1332
  var FARM_CLIENT_REFERENCE_DIRECTORY = "/.farm/client-references/";
1236
- function farmPackageClientReferencePath(root, specifier, exportName) {
1333
+ var FARM_RESOLVE_FROM_PREFIX = "farm:resolve-from:";
1334
+ function parseFarmResolveFrom(id, importer) {
1335
+ if (!id.startsWith(FARM_RESOLVE_FROM_PREFIX)) return null;
1336
+ const rest = id.slice(FARM_RESOLVE_FROM_PREFIX.length);
1337
+ const separator = rest.indexOf(":");
1338
+ if (separator <= 0) return null;
1339
+ const directory = _path2.default.resolve(
1340
+ _path2.default.dirname(importer),
1341
+ decodeURIComponent(rest.slice(0, separator))
1342
+ );
1343
+ return {
1344
+ specifier: rest.slice(separator + 1),
1345
+ importer: _path2.default.join(directory, "__farm_client_reference__.js")
1346
+ };
1347
+ }
1348
+ function farmPackageClientReferencePath(root, specifier, exportName, scope) {
1237
1349
  const directory = specifier.replace(/^@/, "").replace(/[^A-Za-z0-9._-]/g, "+");
1238
- return _path2.default.join(root, ".farm", "client-references", directory, `${exportName}.tsx`);
1350
+ return _path2.default.join(
1351
+ root,
1352
+ ".farm",
1353
+ "client-references",
1354
+ directory,
1355
+ ...scope ? [scope] : [],
1356
+ `${exportName}.tsx`
1357
+ );
1358
+ }
1359
+ function specifierPackage(specifier) {
1360
+ const parts = specifier.split("/");
1361
+ return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
1362
+ }
1363
+ function packageLookup(directory, packageName) {
1364
+ for (let current = directory; ; current = _path2.default.dirname(current)) {
1365
+ if (_path2.default.basename(current) !== "node_modules") {
1366
+ const candidate = _path2.default.join(current, "node_modules", packageName);
1367
+ try {
1368
+ return { from: current, real: _fs2.default.realpathSync(candidate) };
1369
+ } catch (e17) {
1370
+ }
1371
+ }
1372
+ if (_path2.default.dirname(current) === current) return null;
1373
+ }
1374
+ }
1375
+ function referenceResolveFrom(root, specifier, importer) {
1376
+ const packageName = specifierPackage(specifier);
1377
+ const own = packageLookup(_path2.default.dirname(importer), packageName);
1378
+ if (!own) return null;
1379
+ const app = packageLookup(_path2.default.join(root, ".farm", "client-references"), packageName);
1380
+ if (_optionalChain([app, 'optionalAccess', _69 => _69.real]) === own.real) return null;
1381
+ try {
1382
+ return _fs2.default.realpathSync(own.from);
1383
+ } catch (e18) {
1384
+ return own.from;
1385
+ }
1239
1386
  }
1240
- function ensureFarmPackageClientReference(root, specifier, exportName) {
1241
- const file = farmPackageClientReferencePath(root, specifier, exportName);
1387
+ function ensureFarmPackageClientReference(root, specifier, exportName, importer) {
1388
+ const resolveFrom = importer ? referenceResolveFrom(root, specifier, importer) : null;
1389
+ const scope = resolveFrom ? `__from__${_crypto.createHash.call(void 0, "sha256").update(_path2.default.relative(root, resolveFrom).split(_path2.default.sep).join("/")).digest("hex").slice(0, 8)}` : void 0;
1390
+ const file = farmPackageClientReferencePath(root, specifier, exportName, scope);
1391
+ const target = JSON.stringify(
1392
+ resolveFrom ? `${FARM_RESOLVE_FROM_PREFIX}${encodeURIComponent(
1393
+ _path2.default.relative(_path2.default.dirname(file), resolveFrom).split(_path2.default.sep).join("/")
1394
+ )}:${specifier}` : specifier
1395
+ );
1242
1396
  const source = [
1243
1397
  `// Generated by Farm: ${specifier}'s ${exportName} export, as a client reference for server components.`,
1244
1398
  FARM_CLIENT_REFERENCE_PRAGMA,
1245
1399
  '"use client";',
1246
1400
  // An import, not `export { name } from`: a server graph applies CommonJS interop to imports
1247
1401
  // (react-wrap-balancer's `main` is CommonJS), not to re-exports.
1248
- exportName === "default" ? `import __farm_reference__ from ${JSON.stringify(specifier)};` : `import { ${exportName} as __farm_reference__ } from ${JSON.stringify(specifier)};`,
1402
+ exportName === "default" ? `import __farm_reference__ from ${target};` : `import { ${exportName} as __farm_reference__ } from ${target};`,
1249
1403
  `export { __farm_reference__ as ${exportName} };`,
1250
1404
  ""
1251
1405
  ].join("\n");
1252
1406
  let current = null;
1253
1407
  try {
1254
1408
  current = _fs2.default.readFileSync(file, "utf8");
1255
- } catch (e17) {
1409
+ } catch (e19) {
1256
1410
  }
1257
1411
  if (current !== source) {
1258
1412
  _fs2.default.mkdirSync(_path2.default.dirname(file), { recursive: true });
@@ -1260,27 +1414,84 @@ function ensureFarmPackageClientReference(root, specifier, exportName) {
1260
1414
  }
1261
1415
  return file;
1262
1416
  }
1417
+ function writeIfChanged(file, source) {
1418
+ let current = null;
1419
+ try {
1420
+ current = _fs2.default.readFileSync(file, "utf8");
1421
+ } catch (e20) {
1422
+ }
1423
+ if (current !== source) {
1424
+ _fs2.default.mkdirSync(_path2.default.dirname(file), { recursive: true });
1425
+ _fs2.default.writeFileSync(file, source);
1426
+ }
1427
+ }
1428
+ function owningPackage(file) {
1429
+ for (let current = _path2.default.dirname(file); ; current = _path2.default.dirname(current)) {
1430
+ try {
1431
+ const manifest = JSON.parse(_fs2.default.readFileSync(_path2.default.join(current, "package.json"), "utf8"));
1432
+ if (typeof manifest.name === "string") return { directory: current, name: manifest.name };
1433
+ } catch (e21) {
1434
+ }
1435
+ if (_path2.default.dirname(current) === current) return null;
1436
+ }
1437
+ }
1438
+ function ensureFarmInternalClientReference(root, clientFile) {
1439
+ const owner = owningPackage(clientFile);
1440
+ const names = listFarmModuleExports(clientFile);
1441
+ if (!owner || !names || names.length === 0) return null;
1442
+ const directory = owner.name.replace(/^@/, "").replace(/[^A-Za-z0-9._-]/g, "+");
1443
+ const hash = _crypto.createHash.call(void 0, "sha256").update(owner.directory).digest("hex").slice(0, 8);
1444
+ const relative = _path2.default.relative(owner.directory, clientFile).split(_path2.default.sep).join("+").replace(/[^A-Za-z0-9._+-]/g, "_");
1445
+ const file = _path2.default.join(
1446
+ root,
1447
+ ".farm",
1448
+ "client-references",
1449
+ directory,
1450
+ `__internal__${hash}`,
1451
+ `${relative}.tsx`
1452
+ );
1453
+ const target = JSON.stringify(clientFile);
1454
+ const lines = [
1455
+ `// Generated by Farm: ${owner.name}'s ${_path2.default.relative(owner.directory, clientFile).split(_path2.default.sep).join("/")}, as a client reference for server components.`,
1456
+ FARM_CLIENT_REFERENCE_PRAGMA,
1457
+ '"use client";'
1458
+ ];
1459
+ const exported = [];
1460
+ names.forEach((name, index) => {
1461
+ const local = `__farm_reference_${index}__`;
1462
+ lines.push(
1463
+ name === "default" ? `import ${local} from ${target};` : `import { ${name} as ${local} } from ${target};`
1464
+ );
1465
+ exported.push(`${local} as ${name}`);
1466
+ });
1467
+ lines.push(`export { ${exported.join(", ")} };`, "");
1468
+ writeIfChanged(file, lines.join("\n"));
1469
+ return file;
1470
+ }
1263
1471
  function rewriteFarmPackageClientImports(options) {
1264
1472
  const imports = findFarmPackageClientImports(options.code, options.file, options.isClientPackage);
1265
1473
  if (imports.length === 0) return null;
1266
- const reference = (specifier, exportName) => JSON.stringify(ensureFarmPackageClientReference(options.root, specifier, exportName));
1474
+ const reference = (specifier, exportName) => JSON.stringify(
1475
+ ensureFarmPackageClientReference(options.root, specifier, exportName, options.file)
1476
+ );
1267
1477
  let output = options.code;
1268
1478
  let next = 0;
1269
1479
  let changed = false;
1270
1480
  for (const entry of [...imports].sort((left, right) => right.start - left.start)) {
1271
1481
  if (farmPackageClientImportExports(entry).length === 0) continue;
1272
1482
  changed = true;
1483
+ const keyword = entry.reexport ? "export" : "import";
1273
1484
  const lines = [];
1274
1485
  if (entry.kept.length > 0) {
1275
1486
  const bindings = entry.kept.map((binding) => `${binding.imported} as ${binding.local}`);
1276
- lines.push(`import { ${bindings.join(", ")} } from ${JSON.stringify(entry.specifier)};`);
1487
+ lines.push(`${keyword} { ${bindings.join(", ")} } from ${JSON.stringify(entry.specifier)};`);
1277
1488
  }
1278
1489
  if (entry.defaultLocal) {
1279
1490
  lines.push(`import ${entry.defaultLocal} from ${reference(entry.specifier, "default")};`);
1280
1491
  }
1281
1492
  for (const binding of entry.named) {
1282
1493
  lines.push(
1283
- `import { ${binding.imported} as ${binding.local} } from ${reference(entry.specifier, binding.imported)};`
1494
+ `${keyword} { ${binding.imported} as ${binding.local} } from ${reference(entry.specifier, binding.imported)};`
1284
1495
  );
1285
1496
  }
1286
1497
  if (entry.namespace) {
@@ -1290,7 +1501,7 @@ function rewriteFarmPackageClientImports(options) {
1290
1501
  lines.push(`import { ${member} as ${local} } from ${reference(entry.specifier, member)};`);
1291
1502
  fields.push(`${member}: ${local}`);
1292
1503
  }
1293
- if (_optionalChain([entry, 'access', _57 => _57.namespace, 'access', _58 => _58.values, 'optionalAccess', _59 => _59.length])) {
1504
+ if (_optionalChain([entry, 'access', _70 => _70.namespace, 'access', _71 => _71.values, 'optionalAccess', _72 => _72.length])) {
1294
1505
  const local = `__farm_package_values_${next++}__`;
1295
1506
  lines.push(`import * as ${local} from ${JSON.stringify(entry.specifier)};`);
1296
1507
  for (const value of entry.namespace.values) fields.push(`${value}: ${local}.${value}`);
@@ -1349,7 +1560,7 @@ function stampPackagePath(target, kind) {
1349
1560
  const stat = _fs2.default.statSync(target, { throwIfNoEntry: false });
1350
1561
  if (!stat || (kind === "file" ? !stat.isFile() : !stat.isDirectory())) return void 0;
1351
1562
  return [target, stat.size, stat.mtimeMs, stat.ctimeMs];
1352
- } catch (e18) {
1563
+ } catch (e22) {
1353
1564
  return void 0;
1354
1565
  }
1355
1566
  }
@@ -1385,7 +1596,7 @@ var PackageClientBoundaryCache = class {
1385
1596
  else this.dirty = true;
1386
1597
  }
1387
1598
  }
1388
- return _optionalChain([entries, 'optionalAccess', _60 => _60.find, 'call', _61 => _61(
1599
+ return _optionalChain([entries, 'optionalAccess', _73 => _73.find, 'call', _74 => _74(
1389
1600
  (entry) => entry.stops.every((file) => visited.has(file)) && !entry.files.some((file) => visited.has(file))
1390
1601
  )]);
1391
1602
  }
@@ -1396,8 +1607,40 @@ var PackageClientBoundaryCache = class {
1396
1607
  if (entry.stamps) this.dirty = true;
1397
1608
  }
1398
1609
  async persist() {
1610
+ const pending = this.serialize();
1611
+ if (!pending) return;
1612
+ const { file, contents } = pending;
1613
+ const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
1614
+ try {
1615
+ await _fs2.default.promises.mkdir(_path2.default.dirname(file), { recursive: true });
1616
+ await _fs2.default.promises.writeFile(temporary, contents);
1617
+ await _fs2.default.promises.rename(temporary, file);
1618
+ } catch (e23) {
1619
+ await _fs2.default.promises.rm(temporary, { force: true }).catch(() => {
1620
+ });
1621
+ }
1622
+ }
1623
+ /** As `persist`, for a plan that runs synchronously (the dev server's). */
1624
+ persistSync() {
1625
+ const pending = this.serialize();
1626
+ if (!pending) return;
1627
+ const { file, contents } = pending;
1628
+ const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
1629
+ try {
1630
+ _fs2.default.mkdirSync(_path2.default.dirname(file), { recursive: true });
1631
+ _fs2.default.writeFileSync(temporary, contents);
1632
+ _fs2.default.renameSync(temporary, file);
1633
+ } catch (e24) {
1634
+ try {
1635
+ _fs2.default.rmSync(temporary, { force: true });
1636
+ } catch (e25) {
1637
+ }
1638
+ }
1639
+ }
1640
+ /** The file and its new contents, or `null` when it already holds what this scope learned. */
1641
+ serialize() {
1399
1642
  const file = this.file;
1400
- if (!file || !this.dirty && this.stored.size === 0) return;
1643
+ if (!file || !this.dirty && this.stored.size === 0) return null;
1401
1644
  const paths = [];
1402
1645
  const pathIndexes = /* @__PURE__ */ new Map();
1403
1646
  const indexOf = (stamp) => {
@@ -1424,19 +1667,11 @@ var PackageClientBoundaryCache = class {
1424
1667
  }
1425
1668
  const contents = JSON.stringify({
1426
1669
  schema: SCHEMA_VERSION,
1427
- farm: _chunkBIF5MLTHcjs.FARM_VERSION,
1670
+ farm: _chunkSQ6IWJ3Hcjs.FARM_VERSION,
1428
1671
  paths,
1429
1672
  entries
1430
1673
  });
1431
- const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
1432
- try {
1433
- await _fs2.default.promises.mkdir(_path2.default.dirname(file), { recursive: true });
1434
- await _fs2.default.promises.writeFile(temporary, contents);
1435
- await _fs2.default.promises.rename(temporary, file);
1436
- } catch (e19) {
1437
- await _fs2.default.promises.rm(temporary, { force: true }).catch(() => {
1438
- });
1439
- }
1674
+ return { file, contents };
1440
1675
  }
1441
1676
  restore(entry) {
1442
1677
  const files = this.restoreStamps(entry.files, "file");
@@ -1469,10 +1704,10 @@ function readStoredCache(file) {
1469
1704
  let value;
1470
1705
  try {
1471
1706
  value = JSON.parse(_fs2.default.readFileSync(file, "utf8"));
1472
- } catch (e20) {
1707
+ } catch (e26) {
1473
1708
  return null;
1474
1709
  }
1475
- if (!isRecord(value) || value.schema !== SCHEMA_VERSION || value.farm !== _chunkBIF5MLTHcjs.FARM_VERSION) {
1710
+ if (!isRecord(value) || value.schema !== SCHEMA_VERSION || value.farm !== _chunkSQ6IWJ3Hcjs.FARM_VERSION) {
1476
1711
  return null;
1477
1712
  }
1478
1713
  const { paths, entries } = value;
@@ -1483,7 +1718,7 @@ function readStoredCache(file) {
1483
1718
  const usable = variants.filter((entry) => isStoredEntry(entry, paths.length));
1484
1719
  if (usable.length > 0) valid[key] = usable;
1485
1720
  }
1486
- return { schema: SCHEMA_VERSION, farm: _chunkBIF5MLTHcjs.FARM_VERSION, paths, entries: valid };
1721
+ return { schema: SCHEMA_VERSION, farm: _chunkSQ6IWJ3Hcjs.FARM_VERSION, paths, entries: valid };
1487
1722
  }
1488
1723
  function isRecord(value) {
1489
1724
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -1522,7 +1757,18 @@ async function withPackageClientBoundaryCache(operation) {
1522
1757
  }
1523
1758
  }
1524
1759
  function usePackageClientBoundaryCacheFile(file) {
1525
- _optionalChain([getPackageClientBoundaryCache, 'call', _62 => _62(), 'optionalAccess', _63 => _63.load, 'call', _64 => _64(file)]);
1760
+ _optionalChain([getPackageClientBoundaryCache, 'call', _75 => _75(), 'optionalAccess', _76 => _76.load, 'call', _77 => _77(file)]);
1761
+ }
1762
+ function resolvePackageClientBoundaryCacheFile(root, distDir) {
1763
+ return _path2.default.resolve(root, distDir, "cache", "client-boundaries.json");
1764
+ }
1765
+ function runWithPackageClientBoundaryCacheFile(file, operation) {
1766
+ if (getPackageClientBoundaryCache()) return operation();
1767
+ const cache2 = new PackageClientBoundaryCache();
1768
+ cache2.load(file);
1769
+ const result = getStorage().run(cache2, operation);
1770
+ cache2.persistSync();
1771
+ return result;
1526
1772
  }
1527
1773
 
1528
1774
  // src/utils/client-component.ts
@@ -1532,7 +1778,7 @@ function readIfExists(filePath) {
1532
1778
  return null;
1533
1779
  }
1534
1780
  return _fs2.default.readFileSync(filePath, "utf-8");
1535
- } catch (e21) {
1781
+ } catch (e27) {
1536
1782
  return null;
1537
1783
  }
1538
1784
  }
@@ -1545,7 +1791,7 @@ function resolveModuleSourcePath(modulePath, root) {
1545
1791
  if (modulePath.startsWith("file://")) {
1546
1792
  try {
1547
1793
  candidates.add(_url.fileURLToPath.call(void 0, modulePath));
1548
- } catch (e22) {
1794
+ } catch (e28) {
1549
1795
  }
1550
1796
  }
1551
1797
  if (modulePath.startsWith("/@fs/")) {
@@ -1558,7 +1804,7 @@ function resolveModuleSourcePath(modulePath, root) {
1558
1804
  candidates.add(_path2.default.join(root, normalized));
1559
1805
  candidates.add(_path2.default.resolve(root, normalized));
1560
1806
  }
1561
- if (_optionalChain([withoutQuery, 'optionalAccess', _65 => _65.startsWith, 'call', _66 => _66("/src/")])) {
1807
+ if (_optionalChain([withoutQuery, 'optionalAccess', _78 => _78.startsWith, 'call', _79 => _79("/src/")])) {
1562
1808
  const normalized = withoutQuery.replace(/^\/+/, "");
1563
1809
  candidates.add(_path2.default.join(process.cwd(), normalized));
1564
1810
  candidates.add(_path2.default.resolve(process.cwd(), normalized));
@@ -1571,7 +1817,7 @@ function resolveModuleSourcePath(modulePath, root) {
1571
1817
  return null;
1572
1818
  }
1573
1819
  function getFarmClientHydrationPlanOptions(renderer, hasUnsupportedIntegrationProvider) {
1574
- return { asyncOwnerIslands: _chunkRD623KW4cjs.isReactRenderer.call(void 0, renderer) && !hasUnsupportedIntegrationProvider };
1820
+ return { asyncOwnerIslands: _chunk67MZTLTFcjs.isReactRenderer.call(void 0, renderer) && !hasUnsupportedIntegrationProvider };
1575
1821
  }
1576
1822
  function describeSuppressedAsyncHydration(subject, reason) {
1577
1823
  const remediation = reason ? "Fix the reason above, or render the interactive UI from a synchronous owner." : 'Move the interactive UI into an eligible "use client" boundary, or render it from a synchronous owner.';
@@ -1637,7 +1883,7 @@ function hasHydrateExport(content) {
1637
1883
  for (const match of content.matchAll(/\bexport\s*\{([^}]*)\}/g)) {
1638
1884
  for (const specifier of match[1].split(",")) {
1639
1885
  const parts = specifier.trim().split(/\s+as\s+/);
1640
- const exportedName2 = _optionalChain([(_nullishCoalesce(parts[1], () => ( parts[0]))), 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()]);
1886
+ const exportedName2 = _optionalChain([(_nullishCoalesce(parts[1], () => ( parts[0]))), 'optionalAccess', _80 => _80.trim, 'call', _81 => _81()]);
1641
1887
  if (exportedName2 === "hydrate") {
1642
1888
  return true;
1643
1889
  }
@@ -1714,13 +1960,35 @@ function skipRegularExpression(content, startIndex) {
1714
1960
  }
1715
1961
  return null;
1716
1962
  }
1963
+ var tokenizedModules = /* @__PURE__ */ new Map();
1964
+ var TOKENIZED_MODULE_CACHE_SIZE = 32;
1717
1965
  function tokenizeModuleSource(content) {
1966
+ const cached = tokenizedModules.get(content);
1967
+ if (cached) return cached;
1968
+ const tokens = scanModuleSourceTokens(content);
1969
+ if (tokenizedModules.size >= TOKENIZED_MODULE_CACHE_SIZE) {
1970
+ tokenizedModules.delete(tokenizedModules.keys().next().value);
1971
+ }
1972
+ tokenizedModules.set(content, tokens);
1973
+ return tokens;
1974
+ }
1975
+ function isWhitespaceCode(code) {
1976
+ if (code < 128) return code === 32 || code >= 9 && code <= 13;
1977
+ return /\s/.test(String.fromCharCode(code));
1978
+ }
1979
+ function isIdentifierStartCode(code) {
1980
+ return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code === 95 || code === 36;
1981
+ }
1982
+ function isIdentifierPartCode(code) {
1983
+ return isIdentifierStartCode(code) || code >= 48 && code <= 57;
1984
+ }
1985
+ function scanModuleSourceTokens(content) {
1718
1986
  const tokens = [];
1719
1987
  let index = 0;
1720
1988
  let line = 1;
1721
1989
  while (index < content.length) {
1722
1990
  const character = content[index];
1723
- if (/\s/.test(character)) {
1991
+ if (isWhitespaceCode(content.charCodeAt(index))) {
1724
1992
  if (character === "\n") line++;
1725
1993
  index++;
1726
1994
  continue;
@@ -1790,9 +2058,9 @@ function tokenizeModuleSource(content) {
1790
2058
  }
1791
2059
  continue;
1792
2060
  }
1793
- if (/[A-Za-z_$]/.test(character)) {
2061
+ if (isIdentifierStartCode(content.charCodeAt(index))) {
1794
2062
  const start = index++;
1795
- while (index < content.length && /[\w$]/.test(content[index])) index++;
2063
+ while (index < content.length && isIdentifierPartCode(content.charCodeAt(index))) index++;
1796
2064
  tokens.push({ kind: "identifier", value: content.slice(start, index), line });
1797
2065
  continue;
1798
2066
  }
@@ -1805,7 +2073,7 @@ function isIslandExportStart(tokens, index) {
1805
2073
  const token = tokens[index];
1806
2074
  const previous = tokens[index - 1];
1807
2075
  const startsStatement = !previous || previous.value === ";" || previous.value === "{" || previous.value === "}" || token.line > previous.line;
1808
- return startsStatement && token.value === "export" && _optionalChain([tokens, 'access', _69 => _69[index + 1], 'optionalAccess', _70 => _70.value]) === "const" && _optionalChain([tokens, 'access', _71 => _71[index + 2], 'optionalAccess', _72 => _72.value]) === "island";
2076
+ return startsStatement && token.value === "export" && _optionalChain([tokens, 'access', _82 => _82[index + 1], 'optionalAccess', _83 => _83.value]) === "const" && _optionalChain([tokens, 'access', _84 => _84[index + 2], 'optionalAccess', _85 => _85.value]) === "island";
1809
2077
  }
1810
2078
  function getIslandStrategyExport(content) {
1811
2079
  if (!content) return null;
@@ -1813,15 +2081,15 @@ function getIslandStrategyExport(content) {
1813
2081
  for (let index = 0; index < tokens.length - 2; index++) {
1814
2082
  if (!isIslandExportStart(tokens, index)) continue;
1815
2083
  let valueIndex = index + 3;
1816
- if (_optionalChain([tokens, 'access', _73 => _73[valueIndex], 'optionalAccess', _74 => _74.value]) === ":") {
2084
+ if (_optionalChain([tokens, 'access', _86 => _86[valueIndex], 'optionalAccess', _87 => _87.value]) === ":") {
1817
2085
  while (valueIndex < tokens.length && tokens[valueIndex].value !== "=") valueIndex++;
1818
2086
  }
1819
- if (_optionalChain([tokens, 'access', _75 => _75[valueIndex], 'optionalAccess', _76 => _76.value]) !== "=") break;
2087
+ if (_optionalChain([tokens, 'access', _88 => _88[valueIndex], 'optionalAccess', _89 => _89.value]) !== "=") break;
1820
2088
  valueIndex++;
1821
2089
  const literal = tokens[valueIndex];
1822
2090
  if (!literal || literal.kind !== "string" || !_chunk7KJJ4SBScjs.isFarmIslandStrategy.call(void 0, literal.value)) break;
1823
2091
  let trailingIndex = valueIndex + 1;
1824
- if (_optionalChain([tokens, 'access', _77 => _77[trailingIndex], 'optionalAccess', _78 => _78.value]) === "as" && _optionalChain([tokens, 'access', _79 => _79[trailingIndex + 1], 'optionalAccess', _80 => _80.value]) === "const") {
2092
+ if (_optionalChain([tokens, 'access', _90 => _90[trailingIndex], 'optionalAccess', _91 => _91.value]) === "as" && _optionalChain([tokens, 'access', _92 => _92[trailingIndex + 1], 'optionalAccess', _93 => _93.value]) === "const") {
1825
2093
  trailingIndex += 2;
1826
2094
  }
1827
2095
  const trailing = tokens[trailingIndex];
@@ -1847,13 +2115,13 @@ function hasAsyncDefaultExport(content) {
1847
2115
  for (let index = 0; index < tokens.length - 2; index++) {
1848
2116
  const token = tokens[index];
1849
2117
  if (token.kind !== "identifier" || token.value !== "export") continue;
1850
- if (_optionalChain([tokens, 'access', _81 => _81[index - 1], 'optionalAccess', _82 => _82.value]) === ".") continue;
1851
- if (_optionalChain([tokens, 'access', _83 => _83[index + 1], 'optionalAccess', _84 => _84.value]) !== "default") continue;
2118
+ if (_optionalChain([tokens, 'access', _94 => _94[index - 1], 'optionalAccess', _95 => _95.value]) === ".") continue;
2119
+ if (_optionalChain([tokens, 'access', _96 => _96[index + 1], 'optionalAccess', _97 => _97.value]) !== "default") continue;
1852
2120
  const exported = tokens[index + 2];
1853
2121
  if (exported.kind === "identifier" && exported.value === "async") {
1854
2122
  return true;
1855
2123
  }
1856
- if (exported.kind === "identifier" && !["function", "class"].includes(exported.value) && _optionalChain([tokens, 'access', _85 => _85[index + 3], 'optionalAccess', _86 => _86.value]) !== "(" && isAsyncLocalDeclaration(tokens, exported.value)) {
2124
+ if (exported.kind === "identifier" && !["function", "class"].includes(exported.value) && _optionalChain([tokens, 'access', _98 => _98[index + 3], 'optionalAccess', _99 => _99.value]) !== "(" && isAsyncLocalDeclaration(tokens, exported.value)) {
1857
2125
  return true;
1858
2126
  }
1859
2127
  }
@@ -1861,10 +2129,10 @@ function hasAsyncDefaultExport(content) {
1861
2129
  }
1862
2130
  function isAsyncLocalDeclaration(tokens, name) {
1863
2131
  for (let index = 0; index < tokens.length - 2; index++) {
1864
- if (tokens[index].value === "async" && _optionalChain([tokens, 'access', _87 => _87[index + 1], 'optionalAccess', _88 => _88.value]) === "function" && _optionalChain([tokens, 'access', _89 => _89[index + 2], 'optionalAccess', _90 => _90.value]) === name) {
2132
+ if (tokens[index].value === "async" && _optionalChain([tokens, 'access', _100 => _100[index + 1], 'optionalAccess', _101 => _101.value]) === "function" && _optionalChain([tokens, 'access', _102 => _102[index + 2], 'optionalAccess', _103 => _103.value]) === name) {
1865
2133
  return true;
1866
2134
  }
1867
- if (tokens[index].value === name && _optionalChain([tokens, 'access', _91 => _91[index + 1], 'optionalAccess', _92 => _92.value]) === "=" && _optionalChain([tokens, 'access', _93 => _93[index + 2], 'optionalAccess', _94 => _94.value]) === "async") {
2135
+ if (tokens[index].value === name && _optionalChain([tokens, 'access', _104 => _104[index + 1], 'optionalAccess', _105 => _105.value]) === "=" && _optionalChain([tokens, 'access', _106 => _106[index + 2], 'optionalAccess', _107 => _107.value]) === "async") {
1868
2136
  return true;
1869
2137
  }
1870
2138
  }
@@ -2065,7 +2333,7 @@ function planClientModuleHydration(modulePath, root, mode, options) {
2065
2333
  return plan;
2066
2334
  }
2067
2335
  function usesFarmServerTree(plan) {
2068
- return _optionalChain([plan, 'optionalAccess', _95 => _95.asyncOwnerIslands]) === true && plan.isolatedBoundaries.length > 0 && plan.isolatedBoundaries.every((boundary) => boundary.islandStrategy === "load");
2336
+ return _optionalChain([plan, 'optionalAccess', _108 => _108.asyncOwnerIslands]) === true && plan.isolatedBoundaries.length > 0 && plan.isolatedBoundaries.every((boundary) => boundary.islandStrategy === "load");
2069
2337
  }
2070
2338
  function getMarkdownPageHydrationPlan(componentsModulePath, root, mode = "off", options = {}) {
2071
2339
  const plan = {
@@ -2196,7 +2464,7 @@ function getStaticImportBindings(content) {
2196
2464
  if (!content) return bindings;
2197
2465
  const tokens = tokenizeModuleSource(content);
2198
2466
  for (let index = 0; index < tokens.length; index++) {
2199
- if (tokens[index].value !== "import" || _optionalChain([tokens, 'access', _96 => _96[index - 1], 'optionalAccess', _97 => _97.value]) === ".") continue;
2467
+ if (tokens[index].value !== "import" || _optionalChain([tokens, 'access', _109 => _109[index - 1], 'optionalAccess', _110 => _110.value]) === ".") continue;
2200
2468
  const first = tokens[index + 1];
2201
2469
  if (!first || first.value === "type" || first.value === "(" || first.kind === "string") {
2202
2470
  continue;
@@ -2204,7 +2472,7 @@ function getStaticImportBindings(content) {
2204
2472
  let fromIndex = -1;
2205
2473
  for (let cursor = index + 1; cursor < tokens.length; cursor++) {
2206
2474
  if (tokens[cursor].value === ";") break;
2207
- if (tokens[cursor].value === "from" && _optionalChain([tokens, 'access', _98 => _98[cursor + 1], 'optionalAccess', _99 => _99.kind]) === "string") {
2475
+ if (tokens[cursor].value === "from" && _optionalChain([tokens, 'access', _111 => _111[cursor + 1], 'optionalAccess', _112 => _112.kind]) === "string") {
2208
2476
  fromIndex = cursor;
2209
2477
  break;
2210
2478
  }
@@ -2213,13 +2481,13 @@ function getStaticImportBindings(content) {
2213
2481
  const specifier = tokens[fromIndex + 1].value;
2214
2482
  const clause = tokens.slice(index + 1, fromIndex);
2215
2483
  const localNames = [];
2216
- if (_optionalChain([clause, 'access', _100 => _100[0], 'optionalAccess', _101 => _101.kind]) === "identifier" && clause[0].value !== "type") {
2484
+ if (_optionalChain([clause, 'access', _113 => _113[0], 'optionalAccess', _114 => _114.kind]) === "identifier" && clause[0].value !== "type") {
2217
2485
  localNames.push(clause[0].value);
2218
2486
  }
2219
2487
  const namespaceAs = clause.findIndex(
2220
- (token, clauseIndex) => token.value === "*" && _optionalChain([clause, 'access', _102 => _102[clauseIndex + 1], 'optionalAccess', _103 => _103.value]) === "as"
2488
+ (token, clauseIndex) => token.value === "*" && _optionalChain([clause, 'access', _115 => _115[clauseIndex + 1], 'optionalAccess', _116 => _116.value]) === "as"
2221
2489
  );
2222
- if (namespaceAs !== -1 && _optionalChain([clause, 'access', _104 => _104[namespaceAs + 2], 'optionalAccess', _105 => _105.kind]) === "identifier") {
2490
+ if (namespaceAs !== -1 && _optionalChain([clause, 'access', _117 => _117[namespaceAs + 2], 'optionalAccess', _118 => _118.kind]) === "identifier") {
2223
2491
  localNames.push(clause[namespaceAs + 2].value);
2224
2492
  }
2225
2493
  const openingBrace = clause.findIndex((token) => token.value === "{");
@@ -2229,11 +2497,11 @@ function getStaticImportBindings(content) {
2229
2497
  if (openingBrace !== -1 && closingBrace !== -1) {
2230
2498
  let entryStart = openingBrace + 1;
2231
2499
  for (let cursor = entryStart; cursor <= closingBrace; cursor++) {
2232
- if (cursor !== closingBrace && _optionalChain([clause, 'access', _106 => _106[cursor], 'optionalAccess', _107 => _107.value]) !== ",") continue;
2500
+ if (cursor !== closingBrace && _optionalChain([clause, 'access', _119 => _119[cursor], 'optionalAccess', _120 => _120.value]) !== ",") continue;
2233
2501
  const entry = clause.slice(entryStart, cursor).filter((token) => token.value !== "type");
2234
2502
  const asIndex = entry.findIndex((token) => token.value === "as");
2235
2503
  const local = asIndex === -1 ? entry[0] : entry[asIndex + 1];
2236
- if (_optionalChain([local, 'optionalAccess', _108 => _108.kind]) === "identifier") localNames.push(local.value);
2504
+ if (_optionalChain([local, 'optionalAccess', _121 => _121.kind]) === "identifier") localNames.push(local.value);
2237
2505
  entryStart = cursor + 1;
2238
2506
  }
2239
2507
  }
@@ -2270,14 +2538,14 @@ function findParserSensitiveJsxContainer(content, localBindings) {
2270
2538
  const open = [];
2271
2539
  const isSelfClosing = (openingIndex) => {
2272
2540
  for (let index = openingIndex; index < tokens.length; index++) {
2273
- if (tokens[index].value === ">") return _optionalChain([tokens, 'access', _109 => _109[index - 1], 'optionalAccess', _110 => _110.value]) === "/";
2541
+ if (tokens[index].value === ">") return _optionalChain([tokens, 'access', _122 => _122[index - 1], 'optionalAccess', _123 => _123.value]) === "/";
2274
2542
  }
2275
2543
  return false;
2276
2544
  };
2277
2545
  for (let index = 0; index < tokens.length - 1; index++) {
2278
2546
  if (tokens[index].value !== "<") continue;
2279
2547
  if (tokens[index + 1].value === "/") {
2280
- const closing = _optionalChain([tokens, 'access', _111 => _111[index + 2], 'optionalAccess', _112 => _112.value]);
2548
+ const closing = _optionalChain([tokens, 'access', _124 => _124[index + 2], 'optionalAccess', _125 => _125.value]);
2281
2549
  const at = closing ? open.lastIndexOf(closing) : -1;
2282
2550
  if (at !== -1) open.length = at;
2283
2551
  continue;
@@ -2320,7 +2588,7 @@ function findMatchingToken(tokens, openingIndex, opening, closing) {
2320
2588
  }
2321
2589
  function containsClientJsx(tokens, start, end, clientBindings) {
2322
2590
  for (let index = start; index < end; index++) {
2323
- if (tokens[index].value === "<" && clientBindings.has(_optionalChain([tokens, 'access', _113 => _113[index + 1], 'optionalAccess', _114 => _114.value]))) return true;
2591
+ if (tokens[index].value === "<" && clientBindings.has(_optionalChain([tokens, 'access', _126 => _126[index + 1], 'optionalAccess', _127 => _127.value]))) return true;
2324
2592
  }
2325
2593
  return false;
2326
2594
  }
@@ -2358,7 +2626,7 @@ function getClientRenderingHelpers(tokens, clientBindings) {
2358
2626
  let helperName;
2359
2627
  let bodyStart = -1;
2360
2628
  let bodyEnd = -1;
2361
- if (tokens[index].value === "function" && _optionalChain([tokens, 'access', _115 => _115[index + 1], 'optionalAccess', _116 => _116.kind]) === "identifier") {
2629
+ if (tokens[index].value === "function" && _optionalChain([tokens, 'access', _128 => _128[index + 1], 'optionalAccess', _129 => _129.kind]) === "identifier") {
2362
2630
  helperName = tokens[index + 1].value;
2363
2631
  const parametersStart = tokens.findIndex(
2364
2632
  (token, tokenIndex) => tokenIndex > index + 1 && token.value === "("
@@ -2368,21 +2636,21 @@ function getClientRenderingHelpers(tokens, clientBindings) {
2368
2636
  (token, tokenIndex) => tokenIndex > parametersEnd && token.value === "{"
2369
2637
  );
2370
2638
  if (bodyStart !== -1) bodyEnd = findMatchingToken(tokens, bodyStart, "{", "}");
2371
- } else if ((tokens[index].value === "const" || tokens[index].value === "let" || tokens[index].value === "var") && _optionalChain([tokens, 'access', _117 => _117[index + 1], 'optionalAccess', _118 => _118.kind]) === "identifier") {
2639
+ } else if ((tokens[index].value === "const" || tokens[index].value === "let" || tokens[index].value === "var") && _optionalChain([tokens, 'access', _130 => _130[index + 1], 'optionalAccess', _131 => _131.kind]) === "identifier") {
2372
2640
  helperName = tokens[index + 1].value;
2373
2641
  let assignmentIndex = -1;
2374
2642
  let arrowIndex = -1;
2375
2643
  for (let cursor = index + 2; cursor < tokens.length; cursor++) {
2376
2644
  if (tokens[cursor].value === ";") break;
2377
2645
  if (assignmentIndex === -1 && tokens[cursor].value === "=") assignmentIndex = cursor;
2378
- if (tokens[cursor].value === "=" && _optionalChain([tokens, 'access', _119 => _119[cursor + 1], 'optionalAccess', _120 => _120.value]) === ">") {
2646
+ if (tokens[cursor].value === "=" && _optionalChain([tokens, 'access', _132 => _132[cursor + 1], 'optionalAccess', _133 => _133.value]) === ">") {
2379
2647
  arrowIndex = cursor;
2380
2648
  break;
2381
2649
  }
2382
2650
  }
2383
2651
  if (arrowIndex !== -1) {
2384
2652
  bodyStart = arrowIndex + 2;
2385
- bodyEnd = _optionalChain([tokens, 'access', _121 => _121[bodyStart], 'optionalAccess', _122 => _122.value]) === "{" ? findMatchingToken(tokens, bodyStart, "{", "}") : findStatementEnd(tokens, bodyStart);
2653
+ bodyEnd = _optionalChain([tokens, 'access', _134 => _134[bodyStart], 'optionalAccess', _135 => _135.value]) === "{" ? findMatchingToken(tokens, bodyStart, "{", "}") : findStatementEnd(tokens, bodyStart);
2386
2654
  } else if (assignmentIndex !== -1) {
2387
2655
  bodyStart = assignmentIndex + 1;
2388
2656
  bodyEnd = findStatementEnd(tokens, bodyStart);
@@ -2422,14 +2690,14 @@ function passesElementValuedProps(content, localBindings) {
2422
2690
  else if (value === "}") braceDepth--;
2423
2691
  else if (value === "<" && braceDepth > 0) return true;
2424
2692
  else if (value === ">" && braceDepth === 0) {
2425
- selfClosing = _optionalChain([tokens, 'access', _123 => _123[cursor - 1], 'optionalAccess', _124 => _124.value]) === "/";
2693
+ selfClosing = _optionalChain([tokens, 'access', _136 => _136[cursor - 1], 'optionalAccess', _137 => _137.value]) === "/";
2426
2694
  break;
2427
2695
  }
2428
2696
  }
2429
2697
  if (selfClosing || cursor >= tokens.length) continue;
2430
2698
  for (let child = cursor + 1; child < tokens.length; child++) {
2431
2699
  if (tokens[child].value !== "<") continue;
2432
- const closesBoundary = _optionalChain([tokens, 'access', _125 => _125[child + 1], 'optionalAccess', _126 => _126.value]) === "/" && _optionalChain([tokens, 'access', _127 => _127[child + 2], 'optionalAccess', _128 => _128.value]) === name;
2700
+ const closesBoundary = _optionalChain([tokens, 'access', _138 => _138[child + 1], 'optionalAccess', _139 => _139.value]) === "/" && _optionalChain([tokens, 'access', _140 => _140[child + 2], 'optionalAccess', _141 => _141.value]) === name;
2433
2701
  if (!closesBoundary) return true;
2434
2702
  break;
2435
2703
  }
@@ -2451,7 +2719,7 @@ function rendersOnlyLeafElements(content, localBindings) {
2451
2719
  else if (value === "<" && braceDepth > 0) return false;
2452
2720
  else if (value === ">" && braceDepth === 0) break;
2453
2721
  }
2454
- if (cursor >= tokens.length || _optionalChain([tokens, 'access', _129 => _129[cursor - 1], 'optionalAccess', _130 => _130.value]) !== "/") return false;
2722
+ if (cursor >= tokens.length || _optionalChain([tokens, 'access', _142 => _142[cursor - 1], 'optionalAccess', _143 => _143.value]) !== "/") return false;
2455
2723
  }
2456
2724
  return true;
2457
2725
  }
@@ -2463,9 +2731,9 @@ function hasDynamicJsxCardinality(content, localBindings) {
2463
2731
  const containsDynamicRenderer = (start, end) => containsClientJsx(tokens, start, end, clientBindings) || tokens.slice(start, end).some((token) => renderingHelpers.has(token.value));
2464
2732
  for (let index = 0; index < tokens.length; index++) {
2465
2733
  let callStart = -1;
2466
- if (tokens[index].value === "." && (_optionalChain([tokens, 'access', _131 => _131[index + 1], 'optionalAccess', _132 => _132.value]) === "map" || _optionalChain([tokens, 'access', _133 => _133[index + 1], 'optionalAccess', _134 => _134.value]) === "flatMap") && _optionalChain([tokens, 'access', _135 => _135[index + 2], 'optionalAccess', _136 => _136.value]) === "(") {
2734
+ if (tokens[index].value === "." && (_optionalChain([tokens, 'access', _144 => _144[index + 1], 'optionalAccess', _145 => _145.value]) === "map" || _optionalChain([tokens, 'access', _146 => _146[index + 1], 'optionalAccess', _147 => _147.value]) === "flatMap") && _optionalChain([tokens, 'access', _148 => _148[index + 2], 'optionalAccess', _149 => _149.value]) === "(") {
2467
2735
  callStart = index + 2;
2468
- } else if (tokens[index].value === "Array" && _optionalChain([tokens, 'access', _137 => _137[index + 1], 'optionalAccess', _138 => _138.value]) === "." && _optionalChain([tokens, 'access', _139 => _139[index + 2], 'optionalAccess', _140 => _140.value]) === "from" && _optionalChain([tokens, 'access', _141 => _141[index + 3], 'optionalAccess', _142 => _142.value]) === "(") {
2736
+ } else if (tokens[index].value === "Array" && _optionalChain([tokens, 'access', _150 => _150[index + 1], 'optionalAccess', _151 => _151.value]) === "." && _optionalChain([tokens, 'access', _152 => _152[index + 2], 'optionalAccess', _153 => _153.value]) === "from" && _optionalChain([tokens, 'access', _154 => _154[index + 3], 'optionalAccess', _155 => _155.value]) === "(") {
2469
2737
  callStart = index + 3;
2470
2738
  }
2471
2739
  if (callStart !== -1) {
@@ -2474,10 +2742,10 @@ function hasDynamicJsxCardinality(content, localBindings) {
2474
2742
  index = callEnd;
2475
2743
  continue;
2476
2744
  }
2477
- if ((tokens[index].value === "for" || tokens[index].value === "while") && _optionalChain([tokens, 'access', _143 => _143[index + 1], 'optionalAccess', _144 => _144.value]) === "(") {
2745
+ if ((tokens[index].value === "for" || tokens[index].value === "while") && _optionalChain([tokens, 'access', _156 => _156[index + 1], 'optionalAccess', _157 => _157.value]) === "(") {
2478
2746
  const conditionEnd = findMatchingToken(tokens, index + 1, "(", ")");
2479
2747
  const bodyStart = conditionEnd + 1;
2480
- const bodyEnd = _optionalChain([tokens, 'access', _145 => _145[bodyStart], 'optionalAccess', _146 => _146.value]) === "{" ? findMatchingToken(tokens, bodyStart, "{", "}") : tokens.findIndex((token, tokenIndex) => tokenIndex > bodyStart && token.value === ";");
2748
+ const bodyEnd = _optionalChain([tokens, 'access', _158 => _158[bodyStart], 'optionalAccess', _159 => _159.value]) === "{" ? findMatchingToken(tokens, bodyStart, "{", "}") : tokens.findIndex((token, tokenIndex) => tokenIndex > bodyStart && token.value === ";");
2481
2749
  if (containsDynamicRenderer(bodyStart, bodyEnd === -1 ? tokens.length : bodyEnd)) return true;
2482
2750
  }
2483
2751
  }
@@ -2501,11 +2769,6 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
2501
2769
  const content = readIfExists(moduleSourcePath);
2502
2770
  const parsed = parseClientModuleMetadata(content, false);
2503
2771
  if (parsed.isClientComponent) {
2504
- if (projectRoot && !_path2.default.resolve(moduleSourcePath).startsWith(`${projectRoot}${_path2.default.sep}`)) {
2505
- fallbackReason = `client boundary ${moduleSourcePath} is outside the application root`;
2506
- fallbackHint = "Move the component into the application, or publish it as a package (package client components render as static HTML)";
2507
- return 0;
2508
- }
2509
2772
  if (!isIsolatableClientBoundarySource(content)) {
2510
2773
  fallbackReason = `client boundary ${moduleSourcePath} uses an unsupported export shape`;
2511
2774
  fallbackHint = "Export each component by name (`export function Name`, `export { Name }`, or `export default`) instead of `export *`";
@@ -2531,17 +2794,33 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
2531
2794
  const importedPath = imported.path;
2532
2795
  if (!importedPath) continue;
2533
2796
  let importedBoundaryCount;
2797
+ const workspaceEntry = !imported.local && options.packageReferences ? farmWorkspaceServerEntry(importedPath) : null;
2534
2798
  if (imported.local) {
2535
2799
  importedBoundaryCount = visit(importedPath);
2800
+ } else if (workspaceEntry) {
2801
+ importedBoundaryCount = visit(workspaceEntry);
2536
2802
  } else {
2537
2803
  const reactServerClientNames = options.packageReferences && projectRoot ? findFarmReactServerClientNames(_nullishCoalesce(content, () => ( "")), moduleSourcePath, specifier) : null;
2538
2804
  if (reactServerClientNames) {
2539
2805
  importedBoundaryCount = 0;
2540
2806
  for (const exportName of reactServerClientNames) {
2541
2807
  importedBoundaryCount += visit(
2542
- ensureFarmPackageClientReference(projectRoot, specifier, exportName)
2808
+ ensureFarmPackageClientReference(
2809
+ projectRoot,
2810
+ specifier,
2811
+ exportName,
2812
+ moduleSourcePath
2813
+ )
2543
2814
  );
2544
2815
  }
2816
+ for (const clientFile of _nullishCoalesce(findFarmReactServerClientModules(
2817
+ _nullishCoalesce(content, () => ( "")),
2818
+ moduleSourcePath,
2819
+ specifier
2820
+ ), () => ( []))) {
2821
+ const reference = ensureFarmInternalClientReference(projectRoot, clientFile);
2822
+ if (reference) importedBoundaryCount += visit(reference);
2823
+ }
2545
2824
  } else {
2546
2825
  const packageMetadata = inspectPackageClientBoundary(importedPath, root, /* @__PURE__ */ new Set());
2547
2826
  if (!packageMetadata.shouldHydrate) continue;
@@ -2555,7 +2834,12 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
2555
2834
  for (const reference of references) {
2556
2835
  for (const exportName of farmPackageClientImportExports(reference)) {
2557
2836
  importedBoundaryCount += visit(
2558
- ensureFarmPackageClientReference(projectRoot, specifier, exportName)
2837
+ ensureFarmPackageClientReference(
2838
+ projectRoot,
2839
+ specifier,
2840
+ exportName,
2841
+ moduleSourcePath
2842
+ )
2559
2843
  );
2560
2844
  }
2561
2845
  }
@@ -2658,10 +2942,16 @@ function inspectClientModuleMetadata(resolvedPath, root, visited, inspectIslandE
2658
2942
  islandStrategy: shouldHydrate ? _nullishCoalesce(_nullishCoalesce(parsed.islandStrategy, () => ( importedIslandStrategy)), () => ( "load")) : null
2659
2943
  };
2660
2944
  }
2945
+ function farmWorkspaceServerEntry(entry) {
2946
+ const real = realpathOrSelf(entry);
2947
+ if (real.split(_path2.default.sep).includes("node_modules")) return null;
2948
+ if (parseClientModuleMetadata(readIfExists(real), false).isClientComponent) return null;
2949
+ return real;
2950
+ }
2661
2951
  function realpathOrSelf(file) {
2662
2952
  try {
2663
2953
  return _fs2.default.realpathSync(file);
2664
- } catch (e23) {
2954
+ } catch (e29) {
2665
2955
  return file;
2666
2956
  }
2667
2957
  }
@@ -2688,7 +2978,7 @@ function inspectPackageClientBoundary(resolvedPath, root, visited) {
2688
2978
  }
2689
2979
  function traversePackageClientBoundary(resolvedPath, root, visited, trace) {
2690
2980
  if (!resolvedPath || visited.has(resolvedPath)) {
2691
- if (resolvedPath) _optionalChain([trace, 'optionalAccess', _147 => _147.stop, 'call', _148 => _148(resolvedPath)]);
2981
+ if (resolvedPath) _optionalChain([trace, 'optionalAccess', _160 => _160.stop, 'call', _161 => _161(resolvedPath)]);
2692
2982
  return {
2693
2983
  isClientComponent: false,
2694
2984
  shouldHydrate: false,
@@ -2696,7 +2986,7 @@ function traversePackageClientBoundary(resolvedPath, root, visited, trace) {
2696
2986
  };
2697
2987
  }
2698
2988
  visited.add(resolvedPath);
2699
- _optionalChain([trace, 'optionalAccess', _149 => _149.visit, 'call', _150 => _150(resolvedPath)]);
2989
+ _optionalChain([trace, 'optionalAccess', _162 => _162.visit, 'call', _163 => _163(resolvedPath)]);
2700
2990
  const content = readIfExists(resolvedPath);
2701
2991
  const parsed = parseClientModuleMetadata(content, false);
2702
2992
  let importsClientBoundary = false;
@@ -2746,7 +3036,7 @@ function getImportSpecifiers(content, { reexportsOnly = false, dynamic = false }
2746
3036
  braceDepth = Math.max(0, braceDepth - 1);
2747
3037
  continue;
2748
3038
  }
2749
- if (dynamic && keyword.kind === "identifier" && keyword.value === "import" && _optionalChain([tokens, 'access', _151 => _151[index - 1], 'optionalAccess', _152 => _152.value]) !== "." && _optionalChain([tokens, 'access', _153 => _153[index + 1], 'optionalAccess', _154 => _154.value]) === "(" && _optionalChain([tokens, 'access', _155 => _155[index + 2], 'optionalAccess', _156 => _156.kind]) === "string") {
3039
+ if (dynamic && keyword.kind === "identifier" && keyword.value === "import" && _optionalChain([tokens, 'access', _164 => _164[index - 1], 'optionalAccess', _165 => _165.value]) !== "." && _optionalChain([tokens, 'access', _166 => _166[index + 1], 'optionalAccess', _167 => _167.value]) === "(" && _optionalChain([tokens, 'access', _168 => _168[index + 2], 'optionalAccess', _169 => _169.kind]) === "string") {
2750
3040
  matches.add(tokens[index + 2].value);
2751
3041
  continue;
2752
3042
  }
@@ -2756,7 +3046,7 @@ function getImportSpecifiers(content, { reexportsOnly = false, dynamic = false }
2756
3046
  }
2757
3047
  if (reexportsOnly && keyword.value !== "export") continue;
2758
3048
  const previous = tokens[index - 1];
2759
- if (_optionalChain([previous, 'optionalAccess', _157 => _157.value]) === ".") continue;
3049
+ if (_optionalChain([previous, 'optionalAccess', _170 => _170.value]) === ".") continue;
2760
3050
  const first = tokens[index + 1];
2761
3051
  if (!first || first.value === "type" || first.value === "(" || first.value === ".") {
2762
3052
  continue;
@@ -2772,7 +3062,7 @@ function getImportSpecifiers(content, { reexportsOnly = false, dynamic = false }
2772
3062
  for (let cursor = index + 1; cursor < tokens.length; cursor++) {
2773
3063
  const token = tokens[cursor];
2774
3064
  if (token.value === ";") break;
2775
- if (token.value === "from" && _optionalChain([tokens, 'access', _158 => _158[cursor + 1], 'optionalAccess', _159 => _159.kind]) === "string") {
3065
+ if (token.value === "from" && _optionalChain([tokens, 'access', _171 => _171[cursor + 1], 'optionalAccess', _172 => _172.kind]) === "string") {
2776
3066
  fromIndex = cursor;
2777
3067
  break;
2778
3068
  }
@@ -2790,14 +3080,14 @@ function getImportSpecifiers(content, { reexportsOnly = false, dynamic = false }
2790
3080
  return Array.from(matches);
2791
3081
  }
2792
3082
  function isTypeOnlyNamedClause(tokens, startIndex, endIndex) {
2793
- if (_optionalChain([tokens, 'access', _160 => _160[startIndex], 'optionalAccess', _161 => _161.value]) !== "{") return false;
3083
+ if (_optionalChain([tokens, 'access', _173 => _173[startIndex], 'optionalAccess', _174 => _174.value]) !== "{") return false;
2794
3084
  const closingBraceIndex = tokens.findIndex(
2795
3085
  (token, index) => index > startIndex && index < endIndex && token.value === "}"
2796
3086
  );
2797
3087
  if (closingBraceIndex === -1) return false;
2798
3088
  let entryStartsAt = startIndex + 1;
2799
3089
  for (let index = entryStartsAt; index <= closingBraceIndex; index++) {
2800
- if (index !== closingBraceIndex && _optionalChain([tokens, 'access', _162 => _162[index], 'optionalAccess', _163 => _163.value]) !== ",") continue;
3090
+ if (index !== closingBraceIndex && _optionalChain([tokens, 'access', _175 => _175[index], 'optionalAccess', _176 => _176.value]) !== ",") continue;
2801
3091
  const entry = tokens.slice(entryStartsAt, index);
2802
3092
  if (entry.length > 0 && entry[0].value !== "type") return false;
2803
3093
  entryStartsAt = index + 1;
@@ -2808,6 +3098,13 @@ function resolveImportedModule(importerPath, specifier, root) {
2808
3098
  if (specifier.startsWith(".") || specifier.startsWith("/")) {
2809
3099
  return { path: resolveImportedModuleSourcePath(importerPath, specifier, root), local: true };
2810
3100
  }
3101
+ const resolveFrom = parseFarmResolveFrom(specifier, importerPath);
3102
+ if (resolveFrom) {
3103
+ return {
3104
+ path: resolvePackageModuleSourcePath(resolveFrom.importer, resolveFrom.specifier),
3105
+ local: false
3106
+ };
3107
+ }
2811
3108
  const aliased = resolveProjectAliasSourcePath(specifier, root);
2812
3109
  if (aliased) return { path: aliased, local: true };
2813
3110
  const packagePath = resolvePackageModuleSourcePath(importerPath, specifier, root);
@@ -2854,14 +3151,14 @@ function getProjectImportAliases(projectRoot) {
2854
3151
  const stamp = PROJECT_ALIAS_FILES.map((file) => {
2855
3152
  try {
2856
3153
  return String(_fs2.default.statSync(_path2.default.join(projectRoot, file)).mtimeMs);
2857
- } catch (e24) {
3154
+ } catch (e30) {
2858
3155
  return "-";
2859
3156
  }
2860
3157
  }).join(":");
2861
- const sourceDir = _chunkZIHWAN55cjs.getFarmProjectSourceDir.call(void 0, projectRoot);
3158
+ const sourceDir = _chunkRE5E2G5Scjs.getFarmProjectSourceDir.call(void 0, projectRoot);
2862
3159
  const cacheStamp = `${stamp}:${sourceDir}`;
2863
3160
  const cached = projectImportAliasCache.get(projectRoot);
2864
- if (_optionalChain([cached, 'optionalAccess', _164 => _164.stamp]) === cacheStamp) return cached.aliases;
3161
+ if (_optionalChain([cached, 'optionalAccess', _177 => _177.stamp]) === cacheStamp) return cached.aliases;
2865
3162
  const aliases = [
2866
3163
  ...readTsconfigPathAliases(projectRoot),
2867
3164
  ...readPackageImportAliases(projectRoot)
@@ -2882,7 +3179,7 @@ function readTsconfigPathAliases(projectRoot) {
2882
3179
  const configPath = _path2.default.join(projectRoot, name);
2883
3180
  if (!_fs2.default.existsSync(configPath)) continue;
2884
3181
  const resolved = readTsconfigPaths(configPath, /* @__PURE__ */ new Set());
2885
- if (!_optionalChain([resolved, 'optionalAccess', _165 => _165.paths])) return [];
3182
+ if (!_optionalChain([resolved, 'optionalAccess', _178 => _178.paths])) return [];
2886
3183
  const base = _nullishCoalesce(resolved.baseUrl, () => ( resolved.pathsDirectory));
2887
3184
  return Object.entries(resolved.paths).flatMap(([pattern, targets]) => {
2888
3185
  if (!Array.isArray(targets)) return [];
@@ -2917,18 +3214,18 @@ function readTsconfigPaths(configPath, visited) {
2917
3214
  inherited = _nullishCoalesce(readTsconfigPaths(parentPath, visited), () => ( inherited));
2918
3215
  }
2919
3216
  const options = _nullishCoalesce(config.compilerOptions, () => ( {}));
2920
- const baseUrl = typeof options.baseUrl === "string" ? _path2.default.resolve(directory, options.baseUrl) : _optionalChain([inherited, 'optionalAccess', _166 => _166.baseUrl]);
3217
+ const baseUrl = typeof options.baseUrl === "string" ? _path2.default.resolve(directory, options.baseUrl) : _optionalChain([inherited, 'optionalAccess', _179 => _179.baseUrl]);
2921
3218
  if (options.paths && typeof options.paths === "object") {
2922
3219
  return { paths: options.paths, pathsDirectory: directory, baseUrl };
2923
3220
  }
2924
3221
  return inherited ? { ...inherited, baseUrl } : { pathsDirectory: directory, baseUrl };
2925
3222
  }
2926
3223
  function readPackageImportAliases(projectRoot) {
2927
- const imports = _optionalChain([readPackageJson, 'call', _167 => _167(_path2.default.join(projectRoot, "package.json")), 'optionalAccess', _168 => _168.imports]);
3224
+ const imports = _optionalChain([readPackageJson, 'call', _180 => _180(_path2.default.join(projectRoot, "package.json")), 'optionalAccess', _181 => _181.imports]);
2928
3225
  if (!imports || typeof imports !== "object") return [];
2929
3226
  return Object.entries(imports).flatMap(([pattern, value]) => {
2930
3227
  const target = resolveConditionalExportTarget(value);
2931
- if (!pattern.startsWith("#") || !_optionalChain([target, 'optionalAccess', _169 => _169.startsWith, 'call', _170 => _170("./")])) return [];
3228
+ if (!pattern.startsWith("#") || !_optionalChain([target, 'optionalAccess', _182 => _182.startsWith, 'call', _183 => _183("./")])) return [];
2932
3229
  const wildcardIndex = pattern.indexOf("*");
2933
3230
  return [
2934
3231
  {
@@ -2944,7 +3241,7 @@ function readJsonWithComments(filePath) {
2944
3241
  let source;
2945
3242
  try {
2946
3243
  source = _fs2.default.readFileSync(filePath, "utf8");
2947
- } catch (e25) {
3244
+ } catch (e31) {
2948
3245
  return null;
2949
3246
  }
2950
3247
  let output = "";
@@ -2972,7 +3269,7 @@ function readJsonWithComments(filePath) {
2972
3269
  }
2973
3270
  try {
2974
3271
  return JSON.parse(output.replace(/,(\s*[}\]])/g, "$1"));
2975
- } catch (e26) {
3272
+ } catch (e32) {
2976
3273
  return null;
2977
3274
  }
2978
3275
  }
@@ -2994,15 +3291,15 @@ function resolvePackageModuleSourcePath(importerPath, specifier, root) {
2994
3291
  const packageJsonPath = _path2.default.join(packageDirectory, "package.json");
2995
3292
  const packageJson = readPackageJson(packageJsonPath);
2996
3293
  const exportKey = packageSubpath ? `./${packageSubpath}` : ".";
2997
- const exportTarget = resolvePackageExport(_optionalChain([packageJson, 'optionalAccess', _171 => _171.exports]), exportKey);
3294
+ const exportTarget = resolvePackageExport(_optionalChain([packageJson, 'optionalAccess', _184 => _184.exports]), exportKey);
2998
3295
  const candidates = /* @__PURE__ */ new Set();
2999
- if (_optionalChain([exportTarget, 'optionalAccess', _172 => _172.startsWith, 'call', _173 => _173("./")])) {
3296
+ if (_optionalChain([exportTarget, 'optionalAccess', _185 => _185.startsWith, 'call', _186 => _186("./")])) {
3000
3297
  candidates.add(_path2.default.resolve(packageDirectory, exportTarget));
3001
3298
  }
3002
3299
  if (packageSubpath) {
3003
3300
  candidates.add(_path2.default.join(packageDirectory, packageSubpath));
3004
3301
  } else {
3005
- for (const entry of [_optionalChain([packageJson, 'optionalAccess', _174 => _174.browser]), _optionalChain([packageJson, 'optionalAccess', _175 => _175.module]), _optionalChain([packageJson, 'optionalAccess', _176 => _176.main])]) {
3302
+ for (const entry of [_optionalChain([packageJson, 'optionalAccess', _187 => _187.browser]), _optionalChain([packageJson, 'optionalAccess', _188 => _188.module]), _optionalChain([packageJson, 'optionalAccess', _189 => _189.main])]) {
3006
3303
  if (typeof entry === "string") candidates.add(_path2.default.resolve(packageDirectory, entry));
3007
3304
  }
3008
3305
  candidates.add(_path2.default.join(packageDirectory, "index"));
@@ -3038,7 +3335,7 @@ function findPackageDirectory2(importerPath, packageName, root) {
3038
3335
  function readPackageJson(packageJsonPath) {
3039
3336
  try {
3040
3337
  return JSON.parse(_fs2.default.readFileSync(packageJsonPath, "utf8"));
3041
- } catch (e27) {
3338
+ } catch (e33) {
3042
3339
  return null;
3043
3340
  }
3044
3341
  }
@@ -3067,7 +3364,7 @@ function resolvePackageExport(exportsField, exportKey) {
3067
3364
  if (!exportKey.startsWith(prefix) || !exportKey.endsWith(suffix)) continue;
3068
3365
  const wildcard = exportKey.slice(prefix.length, exportKey.length - suffix.length);
3069
3366
  const target = resolveConditionalExportTarget(value);
3070
- return _nullishCoalesce(_optionalChain([target, 'optionalAccess', _177 => _177.replace, 'call', _178 => _178("*", wildcard)]), () => ( null));
3367
+ return _nullishCoalesce(_optionalChain([target, 'optionalAccess', _190 => _190.replace, 'call', _191 => _191("*", wildcard)]), () => ( null));
3071
3368
  }
3072
3369
  return null;
3073
3370
  }
@@ -3100,7 +3397,7 @@ function resolveSourceCandidate(candidates) {
3100
3397
  for (const sourcePath of paths) {
3101
3398
  try {
3102
3399
  if (_fs2.default.statSync(sourcePath).isFile()) return sourcePath;
3103
- } catch (e28) {
3400
+ } catch (e34) {
3104
3401
  }
3105
3402
  }
3106
3403
  }
@@ -3112,7 +3409,18 @@ function isFarmPackageClientBoundary(importerPath, specifier, root) {
3112
3409
  return inspectPackageClientBoundary(imported.path, root, /* @__PURE__ */ new Set()).shouldHydrate;
3113
3410
  }
3114
3411
  var CLIENT_PACKAGE_SCAN_EXTENSIONS = /\.(?:[cm]?[jt]sx?)$/;
3115
- var CLIENT_PACKAGE_SCAN_SKIP = /* @__PURE__ */ new Set(["node_modules", ".farm", ".git", "dist", ".output"]);
3412
+ var CLIENT_PACKAGE_SCAN_SKIP = /* @__PURE__ */ new Set([
3413
+ "node_modules",
3414
+ ".farm",
3415
+ ".git",
3416
+ "dist",
3417
+ ".output",
3418
+ "__tests__"
3419
+ ]);
3420
+ var TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/;
3421
+ function isScannedSourceFile(name) {
3422
+ return CLIENT_PACKAGE_SCAN_EXTENSIONS.test(name) && !name.endsWith(".d.ts") && !TEST_FILE.test(name);
3423
+ }
3116
3424
  function bareSpecifierPackage(specifier) {
3117
3425
  if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("#") || specifier.startsWith("node:") || specifier.startsWith("virtual:") || specifier.includes("\0") || // A package's stylesheet or asset is not a module for the optimizer.
3118
3426
  /\.(?:css|scss|sass|less|styl|svg|png|jpe?g|gif|webp|avif|ico|woff2?|ttf|json|wasm)$/.test(
@@ -3132,7 +3440,7 @@ function scanFarmPackageImports(directory, root) {
3132
3440
  let entries;
3133
3441
  try {
3134
3442
  entries = _fs2.default.readdirSync(current, { withFileTypes: true });
3135
- } catch (e29) {
3443
+ } catch (e35) {
3136
3444
  return;
3137
3445
  }
3138
3446
  for (const entry of entries) {
@@ -3142,8 +3450,7 @@ function scanFarmPackageImports(directory, root) {
3142
3450
  if (!CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
3143
3451
  continue;
3144
3452
  }
3145
- if (!CLIENT_PACKAGE_SCAN_EXTENSIONS.test(entry.name) || entry.name.endsWith(".d.ts"))
3146
- continue;
3453
+ if (!isScannedSourceFile(entry.name)) continue;
3147
3454
  const content = readIfExists(file);
3148
3455
  if (!content) continue;
3149
3456
  const client = hasUseClientDirective(content);
@@ -3159,14 +3466,14 @@ function scanFarmPackageImports(directory, root) {
3159
3466
  walk2(directory);
3160
3467
  return { client: [...found].sort(), server };
3161
3468
  }
3162
- function collectFarmServerBundledPackages(directory) {
3163
- const found = /* @__PURE__ */ new Set();
3469
+ function collectFarmServerBundledPackageInfo(directory) {
3470
+ const found = /* @__PURE__ */ new Map();
3164
3471
  const checked = /* @__PURE__ */ new Set();
3165
3472
  const walk2 = (current) => {
3166
3473
  let entries;
3167
3474
  try {
3168
3475
  entries = _fs2.default.readdirSync(current, { withFileTypes: true });
3169
- } catch (e30) {
3476
+ } catch (e36) {
3170
3477
  return;
3171
3478
  }
3172
3479
  for (const entry of entries) {
@@ -3176,8 +3483,7 @@ function collectFarmServerBundledPackages(directory) {
3176
3483
  if (!CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
3177
3484
  continue;
3178
3485
  }
3179
- if (!CLIENT_PACKAGE_SCAN_EXTENSIONS.test(entry.name) || entry.name.endsWith(".d.ts"))
3180
- continue;
3486
+ if (!isScannedSourceFile(entry.name)) continue;
3181
3487
  const content = readIfExists(file);
3182
3488
  if (!content) continue;
3183
3489
  for (const specifier of new Set(getImportSpecifiers(content))) {
@@ -3185,12 +3491,12 @@ function collectFarmServerBundledPackages(directory) {
3185
3491
  if (!name || checked.has(name)) continue;
3186
3492
  checked.add(name);
3187
3493
  const bundled = findFarmServerBundledPackage(file, name);
3188
- if (bundled) found.add(bundled);
3494
+ if (bundled) found.set(bundled.name, bundled);
3189
3495
  }
3190
3496
  }
3191
3497
  };
3192
3498
  walk2(directory);
3193
- return [...found].sort();
3499
+ return [...found.values()].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
3194
3500
  }
3195
3501
  var clientReachableModules = /* @__PURE__ */ new Map();
3196
3502
  function invalidateFarmClientReachableModules() {
@@ -3206,14 +3512,14 @@ function getFarmClientReachableModules(directory, root) {
3206
3512
  let entries;
3207
3513
  try {
3208
3514
  entries = _fs2.default.readdirSync(current, { withFileTypes: true });
3209
- } catch (e31) {
3515
+ } catch (e37) {
3210
3516
  return;
3211
3517
  }
3212
3518
  for (const entry of entries) {
3213
3519
  const file = _path2.default.join(current, entry.name);
3214
3520
  if (entry.isDirectory()) {
3215
3521
  if (!entry.name.startsWith(".") && !CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
3216
- } else if (CLIENT_PACKAGE_SCAN_EXTENSIONS.test(entry.name) && !entry.name.endsWith(".d.ts")) {
3522
+ } else if (isScannedSourceFile(entry.name)) {
3217
3523
  const content = readIfExists(file);
3218
3524
  if (hasUseClientDirective(content) || hasHydrateExport(content)) queue.push(file);
3219
3525
  }
@@ -3309,13 +3615,13 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3309
3615
  let projectRoot = process.cwd();
3310
3616
  let sources;
3311
3617
  const routeSourceFiles = () => {
3312
- const clientRoutes = _optionalChain([farmApi, 'optionalAccess', _179 => _179.getProgrammaticClientRoutes, 'call', _180 => _180()]);
3313
- if (_optionalChain([sources, 'optionalAccess', _181 => _181.for]) !== clientRoutes || !sources) {
3618
+ const clientRoutes = _optionalChain([farmApi, 'optionalAccess', _192 => _192.getProgrammaticClientRoutes, 'call', _193 => _193()]);
3619
+ if (_optionalChain([sources, 'optionalAccess', _194 => _194.for]) !== clientRoutes || !sources) {
3314
3620
  sources = {
3315
3621
  for: clientRoutes,
3316
3622
  files: /* @__PURE__ */ new Set([
3317
3623
  ...routesFiles,
3318
- ...[..._nullishCoalesce(_optionalChain([clientRoutes, 'optionalAccess', _182 => _182.routeSourceFiles]), () => ( []))].map(resolvedFile)
3624
+ ...[..._nullishCoalesce(_optionalChain([clientRoutes, 'optionalAccess', _195 => _195.routeSourceFiles]), () => ( []))].map(resolvedFile)
3319
3625
  ])
3320
3626
  };
3321
3627
  }
@@ -3328,10 +3634,10 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3328
3634
  configResolved(config) {
3329
3635
  isBuild = config.command === "build";
3330
3636
  projectRoot = config.root;
3331
- farmApi = _optionalChain([config, 'access', _183 => _183.plugins, 'access', _184 => _184.find, 'call', _185 => _185((plugin) => plugin.name === "farm"), 'optionalAccess', _186 => _186.api]);
3637
+ farmApi = _optionalChain([config, 'access', _196 => _196.plugins, 'access', _197 => _197.find, 'call', _198 => _198((plugin) => plugin.name === "farm"), 'optionalAccess', _199 => _199.api]);
3332
3638
  sources = void 0;
3333
3639
  routesFiles = new Set(
3334
- _chunk5Y2P454Ocjs.getFarmSourceRoots.call(void 0, { ...options, root: _nullishCoalesce(options.root, () => ( config.root)) }).flatMap(
3640
+ _chunkMTBDJ326cjs.getFarmSourceRoots.call(void 0, { ...options, root: _nullishCoalesce(options.root, () => ( config.root)) }).flatMap(
3335
3641
  (source) => _chunkE7QOEV5Zcjs.PROGRAMMATIC_ROUTE_FILE_NAMES.map(
3336
3642
  (name) => resolvedFile(_path2.default.resolve(source.root, source.srcDir, name))
3337
3643
  )
@@ -3341,20 +3647,17 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3341
3647
  transform(code, id, transformOptions) {
3342
3648
  const environment = resolveBuildEnvironment(
3343
3649
  this,
3344
- _optionalChain([transformOptions, 'optionalAccess', _187 => _187.ssr])
3650
+ _optionalChain([transformOptions, 'optionalAccess', _200 => _200.ssr])
3345
3651
  );
3346
3652
  const parse2 = (source) => this.parse(source);
3347
3653
  const result = transformEnvironmentFunctions({ code, id, environment, parse: parse2 });
3348
3654
  if (environment === "client" && !isBuild && !_chunkE7QOEV5Zcjs.parseProgrammaticRouteModuleId.call(void 0, id) && routeSourceFiles().has(moduleFile(id)) && !isProgrammaticRouteActionProxy(code)) {
3349
3655
  this.error(routeSourceError(moduleFile(id)));
3350
3656
  }
3351
- if (environment === "server" && _chunkZIHWAN55cjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([options, 'access', _188 => _188.experimental, 'optionalAccess', _189 => _189.serverComponents])) === "islands" && isApplicationScript(id)) {
3657
+ if (environment === "server" && _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([options, 'access', _201 => _201.experimental, 'optionalAccess', _202 => _202.serverComponents])) === "islands" && isApplicationScript(id)) {
3352
3658
  const file = id.split("?", 1)[0];
3353
3659
  const root = _fs.realpathSync.call(void 0, _nullishCoalesce(options.root, () => ( projectRoot)));
3354
- const clientCode = getFarmClientReachableModules(
3355
- _path2.default.resolve(root, options.srcDir || "src"),
3356
- root
3357
- ).has(_path2.default.resolve(file));
3660
+ const clientCode = getFarmClientReachableModules(root, root).has(_path2.default.resolve(file)) || _fs.existsSync.call(void 0, file) && hasUseClientDirective(_fs.readFileSync.call(void 0, file, "utf8"));
3358
3661
  const reached = clientCode ? null : findFarmClientOnlyImport(code, file);
3359
3662
  if (reached) {
3360
3663
  const chain = reached.chain.map((step) => _path2.default.relative(root, step)).join(" -> ");
@@ -3372,7 +3675,7 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3372
3675
  for (const id of this.getModuleIds()) {
3373
3676
  if (_chunkE7QOEV5Zcjs.parseProgrammaticRouteModuleId.call(void 0, id)) {
3374
3677
  const chain = findClientNodeBuiltinChain(id, (moduleId) => {
3375
- return _optionalChain([this, 'access', _190 => _190.getModuleInfo, 'call', _191 => _191(moduleId), 'optionalAccess', _192 => _192.importedIds]);
3678
+ return _optionalChain([this, 'access', _203 => _203.getModuleInfo, 'call', _204 => _204(moduleId), 'optionalAccess', _205 => _205.importedIds]);
3376
3679
  });
3377
3680
  if (chain) {
3378
3681
  this.error(
@@ -3383,8 +3686,8 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3383
3686
  }
3384
3687
  if (!forbidden.has(moduleFile(id))) continue;
3385
3688
  const info = this.getModuleInfo(id);
3386
- if (isProgrammaticRouteActionProxy(_optionalChain([info, 'optionalAccess', _193 => _193.code]))) continue;
3387
- this.error(routeSourceError(moduleFile(id), _optionalChain([info, 'optionalAccess', _194 => _194.importers, 'access', _195 => _195.map, 'call', _196 => _196(moduleFile)])));
3689
+ if (isProgrammaticRouteActionProxy(_optionalChain([info, 'optionalAccess', _206 => _206.code]))) continue;
3690
+ this.error(routeSourceError(moduleFile(id), _optionalChain([info, 'optionalAccess', _207 => _207.importers, 'access', _208 => _208.map, 'call', _209 => _209(moduleFile)])));
3388
3691
  }
3389
3692
  }
3390
3693
  };
@@ -3398,13 +3701,13 @@ function moduleFile(id) {
3398
3701
  function resolvedFile(filePath) {
3399
3702
  try {
3400
3703
  return moduleFile(_fs.realpathSync.call(void 0, filePath));
3401
- } catch (e32) {
3704
+ } catch (e38) {
3402
3705
  return moduleFile(filePath);
3403
3706
  }
3404
3707
  }
3405
3708
  function resolveBuildEnvironment(context, ssr) {
3406
- if (_optionalChain([context, 'access', _197 => _197.environment, 'optionalAccess', _198 => _198.name]) === "client") return "client";
3407
- if (_optionalChain([context, 'access', _199 => _199.environment, 'optionalAccess', _200 => _200.name]) === "rsc" || _optionalChain([context, 'access', _201 => _201.environment, 'optionalAccess', _202 => _202.name]) === "ssr") {
3709
+ if (_optionalChain([context, 'access', _210 => _210.environment, 'optionalAccess', _211 => _211.name]) === "client") return "client";
3710
+ if (_optionalChain([context, 'access', _212 => _212.environment, 'optionalAccess', _213 => _213.name]) === "rsc" || _optionalChain([context, 'access', _214 => _214.environment, 'optionalAccess', _215 => _215.name]) === "ssr") {
3408
3711
  return "server";
3409
3712
  }
3410
3713
  return ssr ? "server" : "client";
@@ -3701,4 +4004,11 @@ function transformError(id, message) {
3701
4004
 
3702
4005
 
3703
4006
 
3704
- exports.resolveFarmBrowserBuiltin = resolveFarmBrowserBuiltin; exports.loadFarmBrowserBuiltin = loadFarmBrowserBuiltin; exports.farmBrowserBuiltinsOptimizerPlugin = farmBrowserBuiltinsOptimizerPlugin; exports.programmaticClientRouteKey = programmaticClientRouteKey; exports.resolveProgrammaticClientRoutes = resolveProgrammaticClientRoutes; exports.createEvaluatedRouteGraph = createEvaluatedRouteGraph; exports.mergeProgrammaticClientRoutes = mergeProgrammaticClientRoutes; exports.generateProgrammaticClientRouteModule = generateProgrammaticClientRouteModule; exports.rewriteFarmReactServerImports = rewriteFarmReactServerImports; exports.invalidateFarmClientOnlyScan = invalidateFarmClientOnlyScan; exports.farmRelativeImportFiles = farmRelativeImportFiles; exports.FARM_CLIENT_REFERENCE_PRAGMA = FARM_CLIENT_REFERENCE_PRAGMA; exports.FARM_CLIENT_REFERENCE_DIRECTORY = FARM_CLIENT_REFERENCE_DIRECTORY; exports.ensureFarmPackageClientReference = ensureFarmPackageClientReference; exports.rewriteFarmPackageClientImports = rewriteFarmPackageClientImports; exports.withPackageClientBoundaryCache = withPackageClientBoundaryCache; exports.usePackageClientBoundaryCacheFile = usePackageClientBoundaryCacheFile; exports.resolveModuleSourcePath = resolveModuleSourcePath; exports.getFarmClientHydrationPlanOptions = getFarmClientHydrationPlanOptions; exports.describeSuppressedAsyncHydration = describeSuppressedAsyncHydration; exports.resolveFarmIsolatedClientHydrationMode = resolveFarmIsolatedClientHydrationMode; exports.hasUseClientDirective = hasUseClientDirective; exports.getIslandStrategyExport = getIslandStrategyExport; exports.stripUseClientDirective = stripUseClientDirective; exports.collectFarmRenderedClientModules = collectFarmRenderedClientModules; exports.collectFarmServerStylesheets = collectFarmServerStylesheets; exports.getClientModuleMetadata = getClientModuleMetadata; exports.getClientModuleHydrationPlan = getClientModuleHydrationPlan; exports.usesFarmServerTree = usesFarmServerTree; exports.createMarkdownPageHydrationPlanner = createMarkdownPageHydrationPlanner; exports.enforceFarmIsolatedHydrationRouteBudget = enforceFarmIsolatedHydrationRouteBudget; exports.isIsolatableClientBoundarySource = isIsolatableClientBoundarySource; exports.resolveImportedModule = resolveImportedModule; exports.isFarmPackageClientBoundary = isFarmPackageClientBoundary; exports.collectFarmClientPackageImports = collectFarmClientPackageImports; exports.collectFarmServerBundledPackages = collectFarmServerBundledPackages; exports.invalidateFarmClientReachableModules = invalidateFarmClientReachableModules; exports.getFarmClientReachableModules = getFarmClientReachableModules; exports.resolveFarmClientOptimizeDeps = resolveFarmClientOptimizeDeps; exports.transformEnvironmentFunctions = transformEnvironmentFunctions; exports.farmEnvironmentFunctionsPlugin = farmEnvironmentFunctionsPlugin;
4007
+
4008
+
4009
+
4010
+
4011
+
4012
+
4013
+
4014
+ exports.FARM_BROWSER_BUILTIN_PREFIX = FARM_BROWSER_BUILTIN_PREFIX; exports.resolveFarmBrowserBuiltin = resolveFarmBrowserBuiltin; exports.loadFarmBrowserBuiltin = loadFarmBrowserBuiltin; exports.farmBrowserBuiltinsOptimizerPlugin = farmBrowserBuiltinsOptimizerPlugin; exports.programmaticClientRouteKey = programmaticClientRouteKey; exports.resolveProgrammaticClientRoutes = resolveProgrammaticClientRoutes; exports.createEvaluatedRouteGraph = createEvaluatedRouteGraph; exports.mergeProgrammaticClientRoutes = mergeProgrammaticClientRoutes; exports.generateProgrammaticClientRouteModule = generateProgrammaticClientRouteModule; exports.rewriteFarmReactServerClientModuleImports = rewriteFarmReactServerClientModuleImports; exports.rewriteFarmReactServerImports = rewriteFarmReactServerImports; exports.invalidateFarmClientOnlyScan = invalidateFarmClientOnlyScan; exports.farmRelativeImportFiles = farmRelativeImportFiles; exports.FARM_CLIENT_REFERENCE_PRAGMA = FARM_CLIENT_REFERENCE_PRAGMA; exports.FARM_CLIENT_REFERENCE_DIRECTORY = FARM_CLIENT_REFERENCE_DIRECTORY; exports.FARM_RESOLVE_FROM_PREFIX = FARM_RESOLVE_FROM_PREFIX; exports.parseFarmResolveFrom = parseFarmResolveFrom; exports.ensureFarmPackageClientReference = ensureFarmPackageClientReference; exports.ensureFarmInternalClientReference = ensureFarmInternalClientReference; exports.rewriteFarmPackageClientImports = rewriteFarmPackageClientImports; exports.withPackageClientBoundaryCache = withPackageClientBoundaryCache; exports.usePackageClientBoundaryCacheFile = usePackageClientBoundaryCacheFile; exports.resolvePackageClientBoundaryCacheFile = resolvePackageClientBoundaryCacheFile; exports.runWithPackageClientBoundaryCacheFile = runWithPackageClientBoundaryCacheFile; exports.resolveModuleSourcePath = resolveModuleSourcePath; exports.getFarmClientHydrationPlanOptions = getFarmClientHydrationPlanOptions; exports.describeSuppressedAsyncHydration = describeSuppressedAsyncHydration; exports.resolveFarmIsolatedClientHydrationMode = resolveFarmIsolatedClientHydrationMode; exports.hasUseClientDirective = hasUseClientDirective; exports.getIslandStrategyExport = getIslandStrategyExport; exports.stripUseClientDirective = stripUseClientDirective; exports.collectFarmRenderedClientModules = collectFarmRenderedClientModules; exports.collectFarmServerStylesheets = collectFarmServerStylesheets; exports.getClientModuleMetadata = getClientModuleMetadata; exports.getClientModuleHydrationPlan = getClientModuleHydrationPlan; exports.usesFarmServerTree = usesFarmServerTree; exports.createMarkdownPageHydrationPlanner = createMarkdownPageHydrationPlanner; exports.enforceFarmIsolatedHydrationRouteBudget = enforceFarmIsolatedHydrationRouteBudget; exports.isIsolatableClientBoundarySource = isIsolatableClientBoundarySource; exports.resolveImportedModule = resolveImportedModule; exports.isFarmPackageClientBoundary = isFarmPackageClientBoundary; exports.collectFarmClientPackageImports = collectFarmClientPackageImports; exports.collectFarmServerBundledPackageInfo = collectFarmServerBundledPackageInfo; exports.invalidateFarmClientReachableModules = invalidateFarmClientReachableModules; exports.getFarmClientReachableModules = getFarmClientReachableModules; exports.resolveFarmClientOptimizeDeps = resolveFarmClientOptimizeDeps; exports.transformEnvironmentFunctions = transformEnvironmentFunctions; exports.farmEnvironmentFunctionsPlugin = farmEnvironmentFunctionsPlugin;