@farm.js/core 0.1.71 → 0.1.73

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 (256) hide show
  1. package/dist/{agent-mcp-handler-VIT4GOSR.mjs → agent-mcp-handler-RK7LDYEL.mjs} +5 -5
  2. package/dist/{agent-mcp-handler-KE4J3W7S.cjs → agent-mcp-handler-VBCA3WZ6.cjs} +6 -6
  3. package/dist/{agent-mcp.d-BzNw6JI8.d.ts → agent-mcp.d-D_gHjCAE.d.ts} +2 -2
  4. package/dist/{agent-mcp.d-CgFen3EH.d.mts → agent-mcp.d-PvEf-1mi.d.mts} +2 -2
  5. package/dist/agent-runtime.d.mts +4 -4
  6. package/dist/agent-runtime.d.ts +4 -4
  7. package/dist/{analyzer-VK3BAOFI.mjs → analyzer-MFYCJT75.mjs} +2 -2
  8. package/dist/analyzer-V5ZMRIIY.cjs +16 -0
  9. package/dist/api/node.d.mts +6 -6
  10. package/dist/api/node.d.ts +6 -6
  11. package/dist/api/route-manager.cjs +7 -6
  12. package/dist/api/route-manager.d.mts +8 -8
  13. package/dist/api/route-manager.d.ts +8 -8
  14. package/dist/api/route-manager.mjs +6 -5
  15. package/dist/api/runtime.d.mts +5 -5
  16. package/dist/api/runtime.d.ts +5 -5
  17. package/dist/api.cjs +8 -7
  18. package/dist/api.d.mts +9 -9
  19. package/dist/api.d.ts +9 -9
  20. package/dist/api.mjs +7 -6
  21. package/dist/{app-manifest.d-DY4JfJxi.d.ts → app-manifest.d-BpVTg43i.d.ts} +1 -1
  22. package/dist/{app-manifest.d-DpDK_B1k.d.mts → app-manifest.d-CN7cEWHX.d.mts} +1 -1
  23. package/dist/app-markdown.cjs +4 -4
  24. package/dist/app-markdown.d.mts +5 -5
  25. package/dist/app-markdown.d.ts +5 -5
  26. package/dist/app-markdown.mjs +3 -3
  27. package/dist/{app.d-D-5UNrFd.d.mts → app.d-BFWzAdTe.d.mts} +54 -6
  28. package/dist/{app.d-BeK6bb1c.d.ts → app.d-DO4PTCWm.d.ts} +54 -6
  29. package/dist/{chunk-7A3URI2F.mjs → chunk-2EVESLP3.mjs} +8 -1
  30. package/dist/{chunk-IYDJNCR7.mjs → chunk-462MUII7.mjs} +10 -5
  31. package/dist/{chunk-MWUDEYBI.mjs → chunk-4CTCSKAF.mjs} +1 -1
  32. package/dist/{chunk-SXMWVP2L.cjs → chunk-4YHGQDTT.cjs} +12 -12
  33. package/dist/{chunk-YCNHUIPR.cjs → chunk-4Z3YLMSW.cjs} +10 -10
  34. package/dist/{chunk-K66JILV3.cjs → chunk-5LOARKDP.cjs} +2 -2
  35. package/dist/{chunk-O32QPFVV.cjs → chunk-5PDMBWAF.cjs} +5 -5
  36. package/dist/{chunk-IGXS54GC.mjs → chunk-6O6PAZZR.mjs} +1 -1
  37. package/dist/{chunk-LXEJNWF5.mjs → chunk-73K53YPP.mjs} +2 -2
  38. package/dist/{chunk-2CQC5CMD.mjs → chunk-7GMBETHM.mjs} +1 -1
  39. package/dist/{chunk-W2T6NDNP.mjs → chunk-B67CW2LM.mjs} +2 -2
  40. package/dist/{chunk-CSQPMV3Q.cjs → chunk-CLEWORVY.cjs} +6 -6
  41. package/dist/{chunk-KPJYBSHL.mjs → chunk-CPMME66W.mjs} +149 -22
  42. package/dist/{chunk-BBPDJGCU.cjs → chunk-CYOTNHDF.cjs} +2 -2
  43. package/dist/{chunk-4OD2LXF2.mjs → chunk-CYRIIVD4.mjs} +26 -15
  44. package/dist/{chunk-DPIGYXSV.mjs → chunk-FRO4BB2T.mjs} +1 -1
  45. package/dist/{chunk-Y2SZVIVH.cjs → chunk-GPICBTDV.cjs} +8 -1
  46. package/dist/{chunk-N3XO5AL5.cjs → chunk-GPO3LJDJ.cjs} +2 -2
  47. package/dist/{chunk-MITIAOUQ.mjs → chunk-GZOKWJIW.mjs} +4 -4
  48. package/dist/{chunk-NAXKOTPP.cjs → chunk-HFUOLILA.cjs} +21 -21
  49. package/dist/{chunk-C2JOS77Z.cjs → chunk-HGB4PM2C.cjs} +178 -51
  50. package/dist/{chunk-2IFT2CSA.cjs → chunk-HTXKSREF.cjs} +515 -151
  51. package/dist/{chunk-Z3GPAFIA.mjs → chunk-HY6IVQ54.mjs} +1 -1
  52. package/dist/{chunk-X7LGLF33.mjs → chunk-IBVN7SW5.mjs} +480 -116
  53. package/dist/{chunk-DPYBVVL3.cjs → chunk-ILQ5DKYF.cjs} +2 -2
  54. package/dist/{chunk-V25GSH43.mjs → chunk-IXZSBO76.mjs} +1 -1
  55. package/dist/{chunk-RJUCNO7R.mjs → chunk-JMOCMXTQ.mjs} +1 -1
  56. package/dist/{chunk-UISZLYKY.cjs → chunk-KDOZORJD.cjs} +52 -41
  57. package/dist/{chunk-PLXD2MJV.cjs → chunk-KTDG4THT.cjs} +2 -2
  58. package/dist/{chunk-L6E4SHUB.cjs → chunk-LGR7565L.cjs} +6 -6
  59. package/dist/chunk-LRPPXKCX.mjs +58 -0
  60. package/dist/{chunk-GUU3IZSM.mjs → chunk-MJEKMT6B.mjs} +324 -148
  61. package/dist/chunk-NDOE76QC.cjs +58 -0
  62. package/dist/{chunk-2AM26UGI.cjs → chunk-NLBK37HI.cjs} +5 -4
  63. package/dist/{chunk-REP6HWJN.mjs → chunk-OBYM5S5G.mjs} +2 -2
  64. package/dist/{chunk-ZUVAGMQ5.cjs → chunk-ODBM54RT.cjs} +7 -7
  65. package/dist/{chunk-J5ASGNKF.mjs → chunk-OIP62QEL.mjs} +1 -1
  66. package/dist/{chunk-KEB7AGS6.cjs → chunk-OXNZUCHN.cjs} +16 -11
  67. package/dist/{chunk-2MR4MABG.cjs → chunk-PXAHSCR6.cjs} +58 -8
  68. package/dist/{chunk-7BUE2GM6.mjs → chunk-QGCSUC5O.mjs} +174 -81
  69. package/dist/{chunk-VXB5CMNC.cjs → chunk-QKEZLYON.cjs} +2 -2
  70. package/dist/{chunk-UQUOSNRN.mjs → chunk-REK6HZSU.mjs} +470 -267
  71. package/dist/{chunk-E77IA5IF.mjs → chunk-RLFGKJQ6.mjs} +1 -1
  72. package/dist/{chunk-3BQ7QHUH.cjs → chunk-ROCF6UQD.cjs} +17 -8
  73. package/dist/{chunk-KQAB5LML.mjs → chunk-SUQACHER.mjs} +2 -2
  74. package/dist/{chunk-NA77GEIU.mjs → chunk-SVQX5HYW.mjs} +53 -3
  75. package/dist/{chunk-KWST2O22.cjs → chunk-TAU3OF5B.cjs} +611 -435
  76. package/dist/{chunk-ZPUAOKHV.cjs → chunk-TDCP3Z4T.cjs} +3 -3
  77. package/dist/{chunk-3AUINHFG.mjs → chunk-TNYC3TYP.mjs} +3 -2
  78. package/dist/{chunk-TP4RAV7Y.cjs → chunk-TU6VAH4V.cjs} +8 -8
  79. package/dist/{chunk-MEJCP2LX.cjs → chunk-UVQRMUAR.cjs} +1 -1
  80. package/dist/{chunk-JMFTKNBA.mjs → chunk-UVZMSRHF.mjs} +2 -2
  81. package/dist/{chunk-MU5V7XHL.mjs → chunk-VJSXPN3W.mjs} +3 -0
  82. package/dist/{chunk-DU4VHHPJ.mjs → chunk-VO55MMBX.mjs} +1 -1
  83. package/dist/{chunk-GF22VGMS.cjs → chunk-VPETSSWN.cjs} +2 -2
  84. package/dist/{chunk-LDVJIBGN.mjs → chunk-VT25ERQK.mjs} +1 -1
  85. package/dist/{chunk-AYVGD3PK.mjs → chunk-XI3OXOMK.mjs} +1 -1
  86. package/dist/{chunk-7OHJWFLB.cjs → chunk-XUSJVHHD.cjs} +466 -373
  87. package/dist/{chunk-FILXOEWD.cjs → chunk-YXIQYWOK.cjs} +2 -2
  88. package/dist/{chunk-JVA4PIYN.cjs → chunk-YZK64PZT.cjs} +635 -432
  89. package/dist/{chunk-THG2TVDH.mjs → chunk-YZLEOMMA.mjs} +3 -3
  90. package/dist/{chunk-QUFENL7Q.mjs → chunk-Z3IN6GEX.mjs} +16 -7
  91. package/dist/{chunk-Q5HMVGR5.cjs → chunk-ZFEJ2SF2.cjs} +13 -13
  92. package/dist/{chunk-LNVGXUL3.cjs → chunk-ZMSVKVI3.cjs} +3 -0
  93. package/dist/{client-component.d-DwpH251K.d.mts → client-component.d-C71rMuHF.d.mts} +2 -2
  94. package/dist/{client-component.d-fYupugbZ.d.ts → client-component.d-sF-Znk0j.d.ts} +2 -2
  95. package/dist/{client-plugins.d-k3bOT5gz.d.mts → client-plugins.d-B-Gd9mWR.d.mts} +5 -4
  96. package/dist/{client-plugins.d-BxqFfHpM.d.ts → client-plugins.d-MFibjgBg.d.ts} +5 -4
  97. package/dist/client-plugins.d.mts +4 -4
  98. package/dist/client-plugins.d.ts +4 -4
  99. package/dist/client.cjs +1 -1
  100. package/dist/client.d.mts +9 -9
  101. package/dist/client.d.ts +9 -9
  102. package/dist/client.mjs +1 -1
  103. package/dist/config.d.mts +4 -4
  104. package/dist/config.d.ts +4 -4
  105. package/dist/desktop.d.mts +5 -5
  106. package/dist/desktop.d.ts +5 -5
  107. package/dist/{devtools-O5625KCK.cjs → devtools-6K4QXFRL.cjs} +7 -7
  108. package/dist/{devtools-6MXPFPNJ.mjs → devtools-TDIJ6HVC.mjs} +6 -6
  109. package/dist/docs.cjs +10 -10
  110. package/dist/docs.d.mts +5 -5
  111. package/dist/docs.d.ts +5 -5
  112. package/dist/docs.mjs +9 -9
  113. package/dist/environment/vite.cjs +3 -3
  114. package/dist/environment/vite.mjs +2 -2
  115. package/dist/{headers.d-sNT7ZQiU.d.mts → headers.d-BUxGJTsj.d.mts} +2 -2
  116. package/dist/{headers.d-DalIGbVO.d.ts → headers.d-uQ6BR59u.d.ts} +2 -2
  117. package/dist/i18n/client.cjs +3 -2
  118. package/dist/i18n/client.d.mts +2 -2
  119. package/dist/i18n/client.d.ts +2 -2
  120. package/dist/i18n/client.mjs +2 -1
  121. package/dist/i18n/index.cjs +3 -2
  122. package/dist/i18n/index.d.mts +3 -3
  123. package/dist/i18n/index.d.ts +3 -3
  124. package/dist/i18n/index.mjs +2 -1
  125. package/dist/i18n/server.cjs +6 -5
  126. package/dist/i18n/server.d.mts +5 -5
  127. package/dist/i18n/server.d.ts +5 -5
  128. package/dist/i18n/server.mjs +5 -4
  129. package/dist/index.cjs +32 -30
  130. package/dist/{index.d-BcA-secm.d.ts → index.d-BCGfxCXY.d.ts} +1 -1
  131. package/dist/{index.d-DDHHAv7j.d.mts → index.d-CuWOJ-un.d.mts} +1 -1
  132. package/dist/index.d.mts +24 -24
  133. package/dist/index.d.ts +24 -24
  134. package/dist/index.mjs +31 -29
  135. package/dist/integrations/orm.d.mts +4 -4
  136. package/dist/integrations/orm.d.ts +4 -4
  137. package/dist/integrations.d.mts +4 -4
  138. package/dist/integrations.d.ts +4 -4
  139. package/dist/internal/app-markdown-runtime.cjs +3 -3
  140. package/dist/internal/app-markdown-runtime.d.mts +5 -5
  141. package/dist/internal/app-markdown-runtime.d.ts +5 -5
  142. package/dist/internal/app-markdown-runtime.mjs +2 -2
  143. package/dist/internal/build-runtime.cjs +29 -29
  144. package/dist/internal/build-runtime.d.mts +6 -6
  145. package/dist/internal/build-runtime.d.ts +6 -6
  146. package/dist/internal/build-runtime.mjs +28 -28
  147. package/dist/internal/cli-runtime.cjs +12 -12
  148. package/dist/internal/cli-runtime.mjs +11 -11
  149. package/dist/internal/client-error-overlay.cjs +4 -4
  150. package/dist/internal/client-error-overlay.mjs +1 -1
  151. package/dist/internal/client-runtime.cjs +2 -2
  152. package/dist/internal/client-runtime.d.mts +7 -7
  153. package/dist/internal/client-runtime.d.ts +7 -7
  154. package/dist/internal/client-runtime.mjs +3 -3
  155. package/dist/internal/compression-runtime.d.mts +4 -4
  156. package/dist/internal/compression-runtime.d.ts +4 -4
  157. package/dist/internal/config-runtime.cjs +8 -8
  158. package/dist/internal/config-runtime.d.mts +7 -7
  159. package/dist/internal/config-runtime.d.ts +7 -7
  160. package/dist/internal/config-runtime.mjs +7 -7
  161. package/dist/internal/infra-analytics-runtime.cjs +10 -10
  162. package/dist/internal/infra-analytics-runtime.mjs +8 -8
  163. package/dist/internal/native-server-fns.cjs +4 -4
  164. package/dist/internal/native-server-fns.mjs +3 -3
  165. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  166. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  167. package/dist/internal/production-runtime.cjs +19 -19
  168. package/dist/internal/production-runtime.d.mts +37 -25
  169. package/dist/internal/production-runtime.d.ts +37 -25
  170. package/dist/internal/production-runtime.mjs +18 -18
  171. package/dist/internal/vercel-edge-middleware.d.mts +2 -2
  172. package/dist/internal/vercel-edge-middleware.d.ts +2 -2
  173. package/dist/markdown.cjs +2 -2
  174. package/dist/markdown.d.mts +4 -4
  175. package/dist/markdown.d.ts +4 -4
  176. package/dist/markdown.mjs +1 -1
  177. package/dist/middleware.cjs +3 -3
  178. package/dist/middleware.d.mts +5 -5
  179. package/dist/middleware.d.ts +5 -5
  180. package/dist/middleware.mjs +2 -2
  181. package/dist/mobile.d.mts +3 -3
  182. package/dist/mobile.d.ts +3 -3
  183. package/dist/{mount.d-C1PONsEe.d.mts → mount.d-BIYmcGGg.d.mts} +1 -1
  184. package/dist/{mount.d-D3JOux2V.d.ts → mount.d-q8k0cJV0.d.ts} +1 -1
  185. package/dist/{native-tree-L2IIEBXH.mjs → native-tree-OYGKP2NZ.mjs} +2 -2
  186. package/dist/{native-tree-GF4BH33L.cjs → native-tree-R6CQMDTI.cjs} +3 -3
  187. package/dist/{navigation-delegate.d-CQQPbdkE.d.ts → navigation-delegate.d-Btfs6Uoa.d.ts} +1 -1
  188. package/dist/{navigation-delegate.d-CJQQHboA.d.mts → navigation-delegate.d-CYBUupsv.d.mts} +1 -1
  189. package/dist/navigation.d.mts +7 -7
  190. package/dist/navigation.d.ts +7 -7
  191. package/dist/{observability.d-B2363jB6.d.mts → observability.d-DdJRiaIX.d.mts} +27 -3
  192. package/dist/{observability.d-B2363jB6.d.ts → observability.d-DdJRiaIX.d.ts} +27 -3
  193. package/dist/observability.d.mts +1 -1
  194. package/dist/observability.d.ts +1 -1
  195. package/dist/plugin.cjs +21 -21
  196. package/dist/plugin.d.mts +7 -7
  197. package/dist/plugin.d.ts +7 -7
  198. package/dist/plugin.mjs +20 -20
  199. package/dist/{production-runtime.d-B0IeWWyO.d.mts → production-runtime.d-Bcu37SCo.d.mts} +1 -1
  200. package/dist/{production-runtime.d-q3aHIv5Y.d.ts → production-runtime.d-qPj3XRET.d.ts} +1 -1
  201. package/dist/{render-plan.d-DHuJMJRP.d.ts → render-plan.d-0FHusf1D.d.ts} +1 -1
  202. package/dist/{render-plan.d-CiUj0rq5.d.mts → render-plan.d-BlyxqKMu.d.mts} +1 -1
  203. package/dist/renderer-client.cjs +3 -2
  204. package/dist/renderer-client.d.mts +7 -7
  205. package/dist/renderer-client.d.ts +7 -7
  206. package/dist/renderer-client.mjs +2 -1
  207. package/dist/{request.d-DRUbOmYD.d.ts → request.d-CPdVjssg.d.ts} +1 -1
  208. package/dist/{request.d-D-F7o7tb.d.mts → request.d-CX-gks1l.d.mts} +1 -1
  209. package/dist/request.d.mts +5 -5
  210. package/dist/request.d.ts +5 -5
  211. package/dist/{resolver.d-9iKC79CU.d.mts → resolver.d-DJgzbdsp.d.mts} +1 -1
  212. package/dist/{resolver.d-CY6mEa_F.d.ts → resolver.d-yaHcGCCG.d.ts} +1 -1
  213. package/dist/{route-rendering.d-6smgwT2t.d.mts → route-rendering.d-CcvZ_4N2.d.mts} +1 -1
  214. package/dist/{route-rendering.d-KwqM_mlK.d.ts → route-rendering.d-DcOoSNoG.d.ts} +1 -1
  215. package/dist/{router.d-BYmDeDlp.d.mts → router.d-C8RHma4A.d.mts} +1 -1
  216. package/dist/{router.d-B6sesMRD.d.ts → router.d-D2QnK8cM.d.ts} +1 -1
  217. package/dist/{routes.d-D3aJw1H5.d.mts → routes.d-CCccJRrp.d.mts} +1 -1
  218. package/dist/{routes.d-K-Qg79AA.d.ts → routes.d-b7khoRoU.d.ts} +1 -1
  219. package/dist/routes.d.mts +4 -4
  220. package/dist/routes.d.ts +4 -4
  221. package/dist/{routing.d-DwSUVZbF.d.mts → routing.d-BhPgtN_S.d.ts} +2 -1
  222. package/dist/{routing.d-BxOZ2YWc.d.ts → routing.d-D67HQmnv.d.mts} +2 -1
  223. package/dist/{rsc-pipeline-R2GOKIMU.mjs → rsc-pipeline-LC2FBZAR.mjs} +7 -7
  224. package/dist/{rsc-pipeline-P4PCWDO2.cjs → rsc-pipeline-NTAM65NT.cjs} +8 -8
  225. package/dist/{runtime-DP5DYGW5.mjs → runtime-MWAC7NWR.mjs} +7 -7
  226. package/dist/{runtime-WA2Q4SLG.cjs → runtime-U4PAMTVH.cjs} +9 -9
  227. package/dist/{runtime.d-CbdMI0Oy.d.ts → runtime.d-1l_1bLrL.d.ts} +1 -1
  228. package/dist/{runtime.d-BFSJf-ww.d.mts → runtime.d-BQUHHq8M.d.mts} +1 -1
  229. package/dist/{runtime.d-nUz0HAL4.d.mts → runtime.d-CTAXWZby.d.mts} +2 -2
  230. package/dist/{runtime.d-B_uPfMjA.d.ts → runtime.d-PUA5qBnd.d.ts} +2 -2
  231. package/dist/server-plugins.d.mts +6 -6
  232. package/dist/server-plugins.d.ts +6 -6
  233. package/dist/server.cjs +43 -41
  234. package/dist/server.d.mts +15 -15
  235. package/dist/server.d.ts +15 -15
  236. package/dist/server.mjs +26 -24
  237. package/dist/{spa-router.d-mC1D5cTN.d.ts → spa-router.d-BJtXNeqo.d.ts} +3 -3
  238. package/dist/{spa-router.d-D4EDwR20.d.mts → spa-router.d-BzPdi48R.d.mts} +3 -3
  239. package/dist/testing.cjs +6 -5
  240. package/dist/testing.d.mts +4 -4
  241. package/dist/testing.d.ts +4 -4
  242. package/dist/testing.mjs +6 -5
  243. package/dist/{types.d-wVRlLtBf.d.ts → types.d-euATAbE4.d.mts} +4 -0
  244. package/dist/{types.d-wVRlLtBf.d.mts → types.d-euATAbE4.d.ts} +4 -0
  245. package/dist/{utils.d-DxMzteqE.d.mts → utils.d-B4ZW-6z6.d.mts} +1 -1
  246. package/dist/{utils.d-A2X3a6z_.d.ts → utils.d-DquC6qxy.d.ts} +1 -1
  247. package/dist/version.cjs +2 -2
  248. package/dist/version.mjs +1 -1
  249. package/dist/vite.cjs +23 -21
  250. package/dist/vite.d.mts +18 -9
  251. package/dist/vite.d.ts +18 -9
  252. package/dist/vite.mjs +22 -20
  253. package/package.json +1 -1
  254. package/dist/analyzer-LPIVRSTJ.cjs +0 -16
  255. package/dist/chunk-V3UOEWCB.cjs +0 -46
  256. package/dist/chunk-VE3FWJBO.mjs +0 -46
@@ -21,7 +21,7 @@ var _chunkE7QOEV5Zcjs = require('./chunk-E7QOEV5Z.cjs');
21
21
  var _chunkQMNWKQL4cjs = require('./chunk-QMNWKQL4.cjs');
22
22
 
23
23
 
24
- var _chunkMEJCP2LXcjs = require('./chunk-MEJCP2LX.cjs');
24
+ var _chunkUVQRMUARcjs = require('./chunk-UVQRMUAR.cjs');
25
25
 
26
26
  // src/environment-vite.ts
27
27
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
@@ -31,6 +31,117 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
31
31
 
32
32
 
33
33
  var _parseAst = require('rolldown/parseAst');
34
+
35
+ // src/utils/source-snapshot.ts
36
+
37
+ var snapshot;
38
+ var volatile;
39
+ var trace;
40
+ function stampOf(file) {
41
+ try {
42
+ const stat = _fs2.default.statSync(file);
43
+ return `${stat.mtimeMs}:${stat.size}`;
44
+ } catch (e) {
45
+ return "missing";
46
+ }
47
+ }
48
+ var FarmSourceSnapshotStore = class {
49
+ constructor() {
50
+ this.entries = /* @__PURE__ */ new Map();
51
+ this.stamps = /* @__PURE__ */ new Map();
52
+ }
53
+ /**
54
+ * Drops the entries that read a file changed on disk since the last plan, or one of `edited`
55
+ * (edits the watcher reported, which a coarse mtime can miss). Returns each such file with the
56
+ * source text the snapshot held for it, if any.
57
+ */
58
+ refresh(edited = []) {
59
+ const changed = /* @__PURE__ */ new Map();
60
+ for (const file of edited) changed.set(file, void 0);
61
+ for (const [file, stamp] of this.stamps) {
62
+ if (stampOf(file) !== stamp) changed.set(file, void 0);
63
+ }
64
+ if (changed.size === 0) return changed;
65
+ const replaced = /* @__PURE__ */ new Set();
66
+ for (const [scope, entries] of this.entries) {
67
+ for (const [key, entry] of entries) {
68
+ if (!entry.files.some((file) => changed.has(file))) continue;
69
+ entries.delete(key);
70
+ if (scope !== "source" || typeof entry.value !== "string") continue;
71
+ replaced.add(entry.value);
72
+ if (changed.has(key)) changed.set(key, entry.value);
73
+ }
74
+ }
75
+ for (const entries of this.entries.values()) {
76
+ for (const source of replaced) entries.delete(source);
77
+ }
78
+ for (const file of changed.keys()) this.stamps.delete(file);
79
+ return changed;
80
+ }
81
+ /** The source text the last plan read for `file`, if it read it. */
82
+ peekSource(file) {
83
+ const value = _optionalChain([this, 'access', _ => _.entries, 'access', _2 => _2.get, 'call', _3 => _3("source"), 'optionalAccess', _4 => _4.get, 'call', _5 => _5(file), 'optionalAccess', _6 => _6.value]);
84
+ return typeof value === "string" ? value : void 0;
85
+ }
86
+ /** Records the stamp of every file an entry read that has none yet. */
87
+ stamp() {
88
+ for (const entries of this.entries.values()) {
89
+ for (const entry of entries.values()) {
90
+ for (const file of entry.files) {
91
+ if (!this.stamps.has(file)) this.stamps.set(file, stampOf(file));
92
+ }
93
+ }
94
+ }
95
+ }
96
+ clear() {
97
+ this.entries.clear();
98
+ this.stamps.clear();
99
+ }
100
+ };
101
+ function withFarmSourceSnapshot(operation, store) {
102
+ if (snapshot) return operation();
103
+ const entries = _nullishCoalesce(_optionalChain([store, 'optionalAccess', _7 => _7.entries]), () => ( /* @__PURE__ */ new Map()));
104
+ snapshot = entries;
105
+ volatile = [];
106
+ try {
107
+ return operation();
108
+ } finally {
109
+ for (const [scope, key] of volatile) _optionalChain([entries, 'access', _8 => _8.get, 'call', _9 => _9(scope), 'optionalAccess', _10 => _10.delete, 'call', _11 => _11(key)]);
110
+ snapshot = void 0;
111
+ volatile = void 0;
112
+ _optionalChain([store, 'optionalAccess', _12 => _12.stamp, 'call', _13 => _13()]);
113
+ }
114
+ }
115
+ function memoizeInFarmSourceSnapshot(scope, key, compute, lasting) {
116
+ if (!snapshot) return compute();
117
+ let entries = snapshot.get(scope);
118
+ if (!entries) snapshot.set(scope, entries = /* @__PURE__ */ new Map());
119
+ const memoized = entries.get(key);
120
+ if (memoized) {
121
+ if (trace) for (const file of memoized.files) trace.add(file);
122
+ return memoized.value;
123
+ }
124
+ const { result, files } = traceFarmSourceReads(compute);
125
+ entries.set(key, { value: result, files });
126
+ if (lasting && !lasting(result)) _optionalChain([volatile, 'optionalAccess', _14 => _14.push, 'call', _15 => _15([scope, key])]);
127
+ return result;
128
+ }
129
+ function noteFarmSourceRead(file) {
130
+ _optionalChain([trace, 'optionalAccess', _16 => _16.add, 'call', _17 => _17(file)]);
131
+ }
132
+ function traceFarmSourceReads(operation) {
133
+ const outer = trace;
134
+ const files = /* @__PURE__ */ new Set();
135
+ trace = files;
136
+ try {
137
+ return { result: operation(), files: [...files] };
138
+ } finally {
139
+ trace = outer;
140
+ if (outer) for (const file of files) outer.add(file);
141
+ }
142
+ }
143
+
144
+ // src/islands-react-server-exports.ts
34
145
  var REACT_PACKAGES = /* @__PURE__ */ new Set([
35
146
  "react",
36
147
  "react-dom",
@@ -122,7 +233,7 @@ function resolveFarmReactServerExport(importer, specifier) {
122
233
  const file = _path2.default.resolve(directory, server);
123
234
  if (_fs2.default.existsSync(file)) resolved = file;
124
235
  }
125
- } catch (e) {
236
+ } catch (e2) {
126
237
  resolved = null;
127
238
  }
128
239
  cache.set(key, resolved);
@@ -133,9 +244,10 @@ function readModule(file) {
133
244
  let stat;
134
245
  try {
135
246
  stat = _fs2.default.statSync(file);
136
- } catch (e2) {
247
+ } catch (e3) {
137
248
  return null;
138
249
  }
250
+ noteFarmSourceRead(file);
139
251
  const cached = parsedModules.get(file);
140
252
  if (cached && cached.size === stat.size && cached.mtimeMs === stat.mtimeMs) return cached.program;
141
253
  let program = null;
@@ -144,7 +256,7 @@ function readModule(file) {
144
256
  const extension = _path2.default.extname(file).slice(1);
145
257
  const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
146
258
  program = _parseAst.parseAst.call(void 0, code, { lang });
147
- } catch (e3) {
259
+ } catch (e4) {
148
260
  program = null;
149
261
  }
150
262
  parsedModules.set(file, { size: stat.size, mtimeMs: stat.mtimeMs, program });
@@ -170,7 +282,7 @@ function resolveRelative(from, specifier) {
170
282
  return null;
171
283
  }
172
284
  function exportedName(node) {
173
- return _optionalChain([node, 'optionalAccess', _ => _.type]) === "Identifier" ? node.name : _optionalChain([node, 'optionalAccess', _2 => _2.value]);
285
+ return _optionalChain([node, 'optionalAccess', _18 => _18.type]) === "Identifier" ? node.name : _optionalChain([node, 'optionalAccess', _19 => _19.value]);
174
286
  }
175
287
  function resolveFarmPackageDefaultEntry(importer, specifier, conditions = ["browser", ...DEFAULT_CONDITIONS]) {
176
288
  const parsed = packageNameOf(specifier);
@@ -184,7 +296,7 @@ function resolveFarmPackageDefaultEntry(importer, specifier, conditions = ["brow
184
296
  _path2.default.join(directory, "package.json"),
185
297
  `./${String(target).replace(/^\.\//, "")}`
186
298
  );
187
- } catch (e4) {
299
+ } catch (e5) {
188
300
  return null;
189
301
  }
190
302
  }
@@ -207,7 +319,7 @@ function traceExport(file, name, depth) {
207
319
  };
208
320
  const imports = /* @__PURE__ */ new Map();
209
321
  for (const node of _nullishCoalesce(program.body, () => ( []))) {
210
- if (node.type !== "ImportDeclaration" || typeof _optionalChain([node, 'access', _3 => _3.source, 'optionalAccess', _4 => _4.value]) !== "string") continue;
322
+ if (node.type !== "ImportDeclaration" || typeof _optionalChain([node, 'access', _20 => _20.source, 'optionalAccess', _21 => _21.value]) !== "string") continue;
211
323
  for (const specifier of _nullishCoalesce(node.specifiers, () => ( []))) {
212
324
  if (specifier.type === "ImportNamespaceSpecifier") continue;
213
325
  const imported = specifier.type === "ImportDefaultSpecifier" ? "default" : _nullishCoalesce(exportedName(specifier.imported), () => ( specifier.local.name));
@@ -235,13 +347,13 @@ function traceExport(file, name, depth) {
235
347
  }
236
348
  }
237
349
  const declared = [
238
- ..._optionalChain([node, 'access', _5 => _5.declaration, 'optionalAccess', _6 => _6.id]) ? [node.declaration.id.name] : [],
239
- ...(_nullishCoalesce(_optionalChain([node, 'access', _7 => _7.declaration, 'optionalAccess', _8 => _8.declarations]), () => ( []))).map((declarator) => _optionalChain([declarator, 'access', _9 => _9.id, 'optionalAccess', _10 => _10.name]))
350
+ ..._optionalChain([node, 'access', _22 => _22.declaration, 'optionalAccess', _23 => _23.id]) ? [node.declaration.id.name] : [],
351
+ ...(_nullishCoalesce(_optionalChain([node, 'access', _24 => _24.declaration, 'optionalAccess', _25 => _25.declarations]), () => ( []))).map((declarator) => _optionalChain([declarator, 'access', _26 => _26.id, 'optionalAccess', _27 => _27.name]))
240
352
  ];
241
353
  if (declared.includes(name)) return here(client ? "client" : "server");
242
354
  } else if (node.type === "ExportDefaultDeclaration" && name === "default") {
243
355
  return own(
244
- () => _optionalChain([node, 'access', _11 => _11.declaration, 'optionalAccess', _12 => _12.type]) === "Identifier" ? local(node.declaration.name) : here("server")
356
+ () => _optionalChain([node, 'access', _28 => _28.declaration, 'optionalAccess', _29 => _29.type]) === "Identifier" ? local(node.declaration.name) : here("server")
245
357
  );
246
358
  }
247
359
  }
@@ -252,21 +364,27 @@ function traceExport(file, name, depth) {
252
364
  return void 0;
253
365
  }
254
366
  function traceFarmExport(file, name) {
255
- return _optionalChain([traceExport, 'call', _13 => _13(file, name, 0), 'optionalAccess', _14 => _14.kind]);
367
+ return _optionalChain([traceExport, 'call', _30 => _30(file, name, 0), 'optionalAccess', _31 => _31.kind]);
256
368
  }
257
369
  function isFarmClientExport(file, name) {
258
370
  return traceFarmExport(file, name) === "client";
259
371
  }
260
372
  function isFarmPackageClientExport(importer, specifier, name) {
261
- const entry = resolveFarmPackageDefaultEntry(importer, specifier);
262
- return !entry || traceFarmExport(entry, name) !== "server";
373
+ return memoizeInFarmSourceSnapshot(
374
+ "package-client-export",
375
+ `${_path2.default.dirname(importer)}\0${specifier}\0${name}`,
376
+ () => {
377
+ const entry = resolveFarmPackageDefaultEntry(importer, specifier);
378
+ return !entry || traceFarmExport(entry, name) !== "server";
379
+ }
380
+ );
263
381
  }
264
382
  function parseCode(code, file) {
265
383
  const extension = _path2.default.extname(file).slice(1);
266
384
  const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
267
385
  try {
268
386
  return _parseAst.parseAst.call(void 0, code, { lang });
269
- } catch (e5) {
387
+ } catch (e6) {
270
388
  return null;
271
389
  }
272
390
  }
@@ -281,8 +399,8 @@ function namespaceMembers(program, local) {
281
399
  }
282
400
  const current = node;
283
401
  if (typeof current.type !== "string") return;
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;
402
+ if ((current.type === "Identifier" || current.type === "JSXIdentifier") && current.name === local && _optionalChain([parent, 'optionalAccess', _32 => _32.type]) !== "ImportNamespaceSpecifier") {
403
+ const property = (_optionalChain([parent, 'optionalAccess', _33 => _33.type]) === "MemberExpression" || _optionalChain([parent, 'optionalAccess', _34 => _34.type]) === "JSXMemberExpression") && parent.object === current && !parent.computed ? _optionalChain([parent, 'access', _35 => _35.property, 'optionalAccess', _36 => _36.name]) : void 0;
286
404
  if (property) members.add(property);
287
405
  else opaque = true;
288
406
  return;
@@ -299,7 +417,7 @@ function findPackageImports(program, accept) {
299
417
  const found = [];
300
418
  for (const node of _nullishCoalesce(program.body, () => ( []))) {
301
419
  if (node.type !== "ImportDeclaration" || node.importKind === "type") continue;
302
- const specifier = _optionalChain([node, 'access', _20 => _20.source, 'optionalAccess', _21 => _21.value]);
420
+ const specifier = _optionalChain([node, 'access', _37 => _37.source, 'optionalAccess', _38 => _38.value]);
303
421
  if (typeof specifier !== "string" || !accept(specifier)) continue;
304
422
  const specifiers = (_nullishCoalesce(node.specifiers, () => ( []))).filter(
305
423
  (entry2) => entry2.importKind !== "type"
@@ -338,7 +456,7 @@ function findFarmReactServerClientNames(code, file, specifier) {
338
456
  const wanted = [
339
457
  ...entry.defaultLocal ? ["default"] : [],
340
458
  ...entry.named.map((binding) => binding.imported),
341
- ..._nullishCoalesce(_optionalChain([entry, 'access', _22 => _22.namespace, 'optionalAccess', _23 => _23.members]), () => ( []))
459
+ ..._nullishCoalesce(_optionalChain([entry, 'access', _39 => _39.namespace, 'optionalAccess', _40 => _40.members]), () => ( []))
342
460
  ];
343
461
  for (const name of wanted) if (isFarmClientExport(target, name)) names.add(name);
344
462
  }
@@ -346,7 +464,7 @@ function findFarmReactServerClientNames(code, file, specifier) {
346
464
  }
347
465
  function clientModuleSource(node) {
348
466
  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]);
467
+ const source = (node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration" && node.source) && _optionalChain([node, 'access', _41 => _41.source, 'optionalAccess', _42 => _42.value]);
350
468
  return typeof source === "string" && source.startsWith(".") ? source : null;
351
469
  }
352
470
  function isClientModuleFile(file) {
@@ -366,8 +484,8 @@ function findFarmReactServerClientModules(code, file, specifier) {
366
484
  const module = readModule(current);
367
485
  if (!module || isClientModule(module)) return;
368
486
  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;
487
+ const source = _nullishCoalesce(clientModuleSource(node), () => ( (node.type === "ExportAllDeclaration" && typeof _optionalChain([node, 'access', _43 => _43.source, 'optionalAccess', _44 => _44.value]) === "string" ? node.source.value : null)));
488
+ if (!_optionalChain([source, 'optionalAccess', _45 => _45.startsWith, 'call', _46 => _46(".")])) continue;
371
489
  const child = resolveRelative(current, source);
372
490
  if (!child) continue;
373
491
  if (isClientModuleFile(child)) {
@@ -379,11 +497,11 @@ function findFarmReactServerClientModules(code, file, specifier) {
379
497
  const wanted = [
380
498
  ...entry.defaultLocal ? ["default"] : [],
381
499
  ...entry.named.map((binding) => binding.imported),
382
- ..._nullishCoalesce(_optionalChain([entry, 'access', _30 => _30.namespace, 'optionalAccess', _31 => _31.members]), () => ( []))
500
+ ..._nullishCoalesce(_optionalChain([entry, 'access', _47 => _47.namespace, 'optionalAccess', _48 => _48.members]), () => ( []))
383
501
  ];
384
502
  for (const name of wanted) {
385
503
  const traced = traceExport(target, name, 0);
386
- if (_optionalChain([traced, 'optionalAccess', _32 => _32.kind]) === "server") walk2(traced.file, 0);
504
+ if (_optionalChain([traced, 'optionalAccess', _49 => _49.kind]) === "server") walk2(traced.file, 0);
387
505
  }
388
506
  }
389
507
  return [...found].sort();
@@ -423,7 +541,7 @@ function rewriteFarmReactServerImports(options) {
423
541
  let next = 0;
424
542
  for (const entry of [...imports].sort((left, right) => right.start - left.start)) {
425
543
  const target = targets.get(entry.specifier);
426
- _optionalChain([options, 'access', _33 => _33.onServerFile, 'optionalCall', _34 => _34(target)]);
544
+ _optionalChain([options, 'access', _50 => _50.onServerFile, 'optionalCall', _51 => _51(target)]);
427
545
  const server = JSON.stringify(target);
428
546
  const lines = [];
429
547
  const bind = (name, local) => {
@@ -460,7 +578,7 @@ function staticImportSources(program) {
460
578
  continue;
461
579
  }
462
580
  if (node.importKind === "type" || node.exportKind === "type") continue;
463
- if (typeof _optionalChain([node, 'access', _35 => _35.source, 'optionalAccess', _36 => _36.value]) === "string") sources.push(node.source.value);
581
+ if (typeof _optionalChain([node, 'access', _52 => _52.source, 'optionalAccess', _53 => _53.value]) === "string") sources.push(node.source.value);
464
582
  }
465
583
  return sources;
466
584
  }
@@ -507,7 +625,7 @@ function farmRelativeImportFiles(code, file) {
507
625
  if (!program) return [];
508
626
  const files = [];
509
627
  for (const node of _nullishCoalesce(program.body, () => ( []))) {
510
- const source = (node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source) && _optionalChain([node, 'access', _37 => _37.source, 'optionalAccess', _38 => _38.value]);
628
+ const source = (node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source) && _optionalChain([node, 'access', _54 => _54.source, 'optionalAccess', _55 => _55.value]);
511
629
  if (typeof source !== "string" || !source.startsWith(".")) continue;
512
630
  const resolved = resolveRelative(file, source);
513
631
  if (resolved) files.push(resolved);
@@ -525,7 +643,7 @@ function farmReactServerBuildReachesClientModules(importer, specifier, serverImp
525
643
  if (!program) return false;
526
644
  if (depth > 0 && isClientModule(program)) return true;
527
645
  for (const node of _nullishCoalesce(program.body, () => ( []))) {
528
- const source = (node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source || node.type === "ImportDeclaration") && _optionalChain([node, 'access', _39 => _39.source, 'optionalAccess', _40 => _40.value]);
646
+ const source = (node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source || node.type === "ImportDeclaration") && _optionalChain([node, 'access', _56 => _56.source, 'optionalAccess', _57 => _57.value]);
529
647
  if (typeof source !== "string" || !source.startsWith(".")) continue;
530
648
  const child = resolveRelative(file, source);
531
649
  if (child && reaches(child, depth + 1)) return true;
@@ -549,7 +667,7 @@ function scanPackage(directory) {
549
667
  let entries;
550
668
  try {
551
669
  entries = _fs2.default.readdirSync(current, { withFileTypes: true });
552
- } catch (e6) {
670
+ } catch (e7) {
553
671
  continue;
554
672
  }
555
673
  for (const entry of entries) {
@@ -560,7 +678,7 @@ function scanPackage(directory) {
560
678
  let code;
561
679
  try {
562
680
  code = _fs2.default.readFileSync(file, "utf8");
563
- } catch (e7) {
681
+ } catch (e8) {
564
682
  continue;
565
683
  }
566
684
  for (const match of code.matchAll(IMPORT_SPECIFIER)) scan.imports.add(match[1]);
@@ -583,7 +701,7 @@ function findFarmServerBundledPackage(importer, specifier) {
583
701
  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)) {
584
702
  return { name: parsed.name, prebundle: isSelfContainedPackage(manifest, importer) };
585
703
  }
586
- } catch (e8) {
704
+ } catch (e9) {
587
705
  return null;
588
706
  }
589
707
  return scanPackage(directory).stylesheets ? { name: parsed.name, prebundle: false } : null;
@@ -591,7 +709,7 @@ function findFarmServerBundledPackage(importer, specifier) {
591
709
  function isSelfContainedPackage(manifest, importer) {
592
710
  if (Object.keys(_nullishCoalesce(manifest.dependencies, () => ( {}))).length > 0) return false;
593
711
  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
712
+ (peer) => _optionalChain([manifest, 'access', _58 => _58.peerDependenciesMeta, 'optionalAccess', _59 => _59[peer], 'optionalAccess', _60 => _60.optional]) === true || findPackageDirectory(importer, peer) !== null
595
713
  );
596
714
  }
597
715
  function findFarmPackageManifest(importer, specifier) {
@@ -603,11 +721,11 @@ function findFarmPackageManifest(importer, specifier) {
603
721
  try {
604
722
  const manifest = JSON.parse(_fs2.default.readFileSync(_path2.default.join(directory, "package.json"), "utf8"));
605
723
  names = new Set(Object.keys(_nullishCoalesce(manifest.dependencies, () => ( {}))));
606
- } catch (e9) {
724
+ } catch (e10) {
607
725
  return null;
608
726
  }
609
727
  const dependencies = [...scanPackage(directory).imports].filter((imported) => {
610
- const name = _optionalChain([packageNameOf, 'call', _44 => _44(imported), 'optionalAccess', _45 => _45.name]);
728
+ const name = _optionalChain([packageNameOf, 'call', _61 => _61(imported), 'optionalAccess', _62 => _62.name]);
611
729
  return name !== void 0 && names.has(name);
612
730
  });
613
731
  return { name: parsed.name, dependencies: dependencies.sort() };
@@ -640,9 +758,9 @@ function listFarmModuleExports(entry) {
640
758
  const name = exportedName(specifier.exported);
641
759
  if (name) names.add(name);
642
760
  }
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);
761
+ if (_optionalChain([node, 'access', _63 => _63.declaration, 'optionalAccess', _64 => _64.id, 'optionalAccess', _65 => _65.name])) names.add(node.declaration.id.name);
762
+ for (const declarator of _nullishCoalesce(_optionalChain([node, 'access', _66 => _66.declaration, 'optionalAccess', _67 => _67.declarations]), () => ( []))) {
763
+ if (_optionalChain([declarator, 'access', _68 => _68.id, 'optionalAccess', _69 => _69.type]) === "Identifier") names.add(declarator.id.name);
646
764
  }
647
765
  } else if (node.type === "ExportDefaultDeclaration") {
648
766
  esm = true;
@@ -734,7 +852,7 @@ function resolveProgrammaticClientRoutes(options) {
734
852
  const definedIn = /* @__PURE__ */ new Map();
735
853
  for (const route of definitions) {
736
854
  const source = _chunkE7QOEV5Zcjs.getProgrammaticRouteDefinitionSource.call(void 0, route);
737
- const callers = (_nullishCoalesce(_optionalChain([source, 'optionalAccess', _53 => _53.stacks]), () => ( []))).map((stack) => findRouteCallers(stack, modulesByFile));
855
+ const callers = (_nullishCoalesce(_optionalChain([source, 'optionalAccess', _70 => _70.stacks]), () => ( []))).map((stack) => findRouteCallers(stack, modulesByFile));
738
856
  for (const caller of callers.flat()) caller.routeSource = true;
739
857
  definedIn.set(route, callers.flat());
740
858
  if (!source || source.raw || (_nullishCoalesce(callers[0], () => ( []))).length === 0) untraced = true;
@@ -831,7 +949,7 @@ function resolveProgrammaticClientRoutes(options) {
831
949
  return { routes, routeSourceFiles };
832
950
  }
833
951
  function createEvaluatedRouteGraph(server) {
834
- const evaluated = _optionalChain([server, 'access', _54 => _54.environments, 'optionalAccess', _55 => _55.ssr, 'optionalAccess', _56 => _56.runner, 'optionalAccess', _57 => _57.evaluatedModules]);
952
+ const evaluated = _optionalChain([server, 'access', _71 => _71.environments, 'optionalAccess', _72 => _72.ssr, 'optionalAccess', _73 => _73.runner, 'optionalAccess', _74 => _74.evaluatedModules]);
835
953
  if (!evaluated) return void 0;
836
954
  const toGraphModule = (node) => ({
837
955
  id: node.id,
@@ -955,7 +1073,7 @@ function isNodeBuiltinId(id) {
955
1073
  return bare.startsWith("node:") || NODE_BUILTINS.has(bare);
956
1074
  }
957
1075
  function isProgrammaticRouteActionProxy(code) {
958
- return Boolean(_optionalChain([code, 'optionalAccess', _58 => _58.includes, 'call', _59 => _59("__farmRouteActionTarget: true")]));
1076
+ return Boolean(_optionalChain([code, 'optionalAccess', _75 => _75.includes, 'call', _76 => _76("__farmRouteActionTarget: true")]));
959
1077
  }
960
1078
  function collectGraph(graph, routesFile) {
961
1079
  const modules = /* @__PURE__ */ new Map();
@@ -1049,7 +1167,7 @@ function holdsRouteDefinition(value, definitions) {
1049
1167
  if (descriptor && "value" in descriptor) next(descriptor.value);
1050
1168
  }
1051
1169
  }
1052
- } catch (e10) {
1170
+ } catch (e11) {
1053
1171
  }
1054
1172
  }
1055
1173
  return false;
@@ -1142,7 +1260,7 @@ function readJsonString(text) {
1142
1260
  try {
1143
1261
  const value = JSON.parse(text);
1144
1262
  return typeof value === "string" ? value : void 0;
1145
- } catch (e11) {
1263
+ } catch (e12) {
1146
1264
  return void 0;
1147
1265
  }
1148
1266
  }
@@ -1150,7 +1268,7 @@ function readJsonArray(text) {
1150
1268
  try {
1151
1269
  const value = JSON.parse(text);
1152
1270
  return Array.isArray(value) ? value : void 0;
1153
- } catch (e12) {
1271
+ } catch (e13) {
1154
1272
  return void 0;
1155
1273
  }
1156
1274
  }
@@ -1160,13 +1278,13 @@ function readExports(namespace) {
1160
1278
  let keys;
1161
1279
  try {
1162
1280
  keys = Object.keys(namespace);
1163
- } catch (e13) {
1281
+ } catch (e14) {
1164
1282
  return [];
1165
1283
  }
1166
1284
  for (const key of keys) {
1167
1285
  try {
1168
1286
  entries.push([key, namespace[key]]);
1169
- } catch (e14) {
1287
+ } catch (e15) {
1170
1288
  }
1171
1289
  }
1172
1290
  return entries;
@@ -1199,7 +1317,7 @@ function toModuleFile(file) {
1199
1317
  if (file.startsWith("file://")) {
1200
1318
  try {
1201
1319
  return toPosixPath(_url.fileURLToPath.call(void 0, file));
1202
- } catch (e15) {
1320
+ } catch (e16) {
1203
1321
  return toPosixPath(file);
1204
1322
  }
1205
1323
  }
@@ -1218,15 +1336,18 @@ var _crypto = require('crypto');
1218
1336
 
1219
1337
  var IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
1220
1338
  var moduleName = (node) => {
1221
- const name = _optionalChain([node, 'optionalAccess', _60 => _60.type]) === "Identifier" ? node.name : _optionalChain([node, 'optionalAccess', _61 => _61.value]);
1339
+ const name = _optionalChain([node, 'optionalAccess', _77 => _77.type]) === "Identifier" ? node.name : _optionalChain([node, 'optionalAccess', _78 => _78.value]);
1222
1340
  return typeof name === "string" ? name : null;
1223
1341
  };
1224
1342
  function parse(code, file) {
1225
1343
  const extension = _path2.default.extname(file).slice(1);
1226
1344
  const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
1345
+ return memoizeInFarmSourceSnapshot(`ast:${lang}`, code, () => parseAs(code, lang));
1346
+ }
1347
+ function parseAs(code, lang) {
1227
1348
  try {
1228
1349
  return _parseAst.parseAst.call(void 0, code, { lang });
1229
- } catch (e16) {
1350
+ } catch (e17) {
1230
1351
  return null;
1231
1352
  }
1232
1353
  }
@@ -1251,8 +1372,8 @@ function namespaceMembers2(program, local, declaration) {
1251
1372
  if (opaque || node === declaration) return;
1252
1373
  const name = node.type === "Identifier" || node.type === "JSXIdentifier" ? node.name : null;
1253
1374
  if (name !== local) return;
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;
1375
+ if (_optionalChain([parent, 'optionalAccess', _79 => _79.type]) === "ImportNamespaceSpecifier") return;
1376
+ const member = (_optionalChain([parent, 'optionalAccess', _80 => _80.type]) === "MemberExpression" || _optionalChain([parent, 'optionalAccess', _81 => _81.type]) === "JSXMemberExpression") && parent.object === node ? parent.property : null;
1256
1377
  const property = member && !parent.computed && (member.type === "Identifier" || member.type === "JSXIdentifier") ? member.name : null;
1257
1378
  if (property) members.add(property);
1258
1379
  else opaque = true;
@@ -1268,7 +1389,7 @@ function findFarmPackageClientImports(code, file, isClientPackage) {
1268
1389
  const reexport = node.type === "ExportNamedDeclaration" && node.source != null;
1269
1390
  if (node.type !== "ImportDeclaration" && !reexport) continue;
1270
1391
  if (node.importKind === "type" || node.exportKind === "type") continue;
1271
- const specifier = _optionalChain([node, 'access', _65 => _65.source, 'optionalAccess', _66 => _66.value]);
1392
+ const specifier = _optionalChain([node, 'access', _82 => _82.source, 'optionalAccess', _83 => _83.value]);
1272
1393
  if (typeof specifier !== "string" || specifier.startsWith(".") || specifier.startsWith("/"))
1273
1394
  continue;
1274
1395
  const specifiers = (_nullishCoalesce(node.specifiers, () => ( []))).filter(
@@ -1325,7 +1446,7 @@ function farmPackageClientImportExports(entry) {
1325
1446
  return [
1326
1447
  ...entry.defaultLocal ? ["default"] : [],
1327
1448
  ...entry.named.map((binding) => binding.imported),
1328
- ..._nullishCoalesce(_optionalChain([entry, 'access', _67 => _67.namespace, 'optionalAccess', _68 => _68.members]), () => ( []))
1449
+ ..._nullishCoalesce(_optionalChain([entry, 'access', _84 => _84.namespace, 'optionalAccess', _85 => _85.members]), () => ( []))
1329
1450
  ];
1330
1451
  }
1331
1452
  var FARM_CLIENT_REFERENCE_PRAGMA = "// @farm-client-reference";
@@ -1366,7 +1487,7 @@ function packageLookup(directory, packageName) {
1366
1487
  const candidate = _path2.default.join(current, "node_modules", packageName);
1367
1488
  try {
1368
1489
  return { from: current, real: _fs2.default.realpathSync(candidate) };
1369
- } catch (e17) {
1490
+ } catch (e18) {
1370
1491
  }
1371
1492
  }
1372
1493
  if (_path2.default.dirname(current) === current) return null;
@@ -1377,10 +1498,10 @@ function referenceResolveFrom(root, specifier, importer) {
1377
1498
  const own = packageLookup(_path2.default.dirname(importer), packageName);
1378
1499
  if (!own) return null;
1379
1500
  const app = packageLookup(_path2.default.join(root, ".farm", "client-references"), packageName);
1380
- if (_optionalChain([app, 'optionalAccess', _69 => _69.real]) === own.real) return null;
1501
+ if (_optionalChain([app, 'optionalAccess', _86 => _86.real]) === own.real) return null;
1381
1502
  try {
1382
1503
  return _fs2.default.realpathSync(own.from);
1383
- } catch (e18) {
1504
+ } catch (e19) {
1384
1505
  return own.from;
1385
1506
  }
1386
1507
  }
@@ -1406,7 +1527,7 @@ function ensureFarmPackageClientReference(root, specifier, exportName, importer)
1406
1527
  let current = null;
1407
1528
  try {
1408
1529
  current = _fs2.default.readFileSync(file, "utf8");
1409
- } catch (e19) {
1530
+ } catch (e20) {
1410
1531
  }
1411
1532
  if (current !== source) {
1412
1533
  _fs2.default.mkdirSync(_path2.default.dirname(file), { recursive: true });
@@ -1418,7 +1539,7 @@ function writeIfChanged(file, source) {
1418
1539
  let current = null;
1419
1540
  try {
1420
1541
  current = _fs2.default.readFileSync(file, "utf8");
1421
- } catch (e20) {
1542
+ } catch (e21) {
1422
1543
  }
1423
1544
  if (current !== source) {
1424
1545
  _fs2.default.mkdirSync(_path2.default.dirname(file), { recursive: true });
@@ -1430,7 +1551,7 @@ function owningPackage(file) {
1430
1551
  try {
1431
1552
  const manifest = JSON.parse(_fs2.default.readFileSync(_path2.default.join(current, "package.json"), "utf8"));
1432
1553
  if (typeof manifest.name === "string") return { directory: current, name: manifest.name };
1433
- } catch (e21) {
1554
+ } catch (e22) {
1434
1555
  }
1435
1556
  if (_path2.default.dirname(current) === current) return null;
1436
1557
  }
@@ -1501,7 +1622,7 @@ function rewriteFarmPackageClientImports(options) {
1501
1622
  lines.push(`import { ${member} as ${local} } from ${reference(entry.specifier, member)};`);
1502
1623
  fields.push(`${member}: ${local}`);
1503
1624
  }
1504
- if (_optionalChain([entry, 'access', _70 => _70.namespace, 'access', _71 => _71.values, 'optionalAccess', _72 => _72.length])) {
1625
+ if (_optionalChain([entry, 'access', _87 => _87.namespace, 'access', _88 => _88.values, 'optionalAccess', _89 => _89.length])) {
1505
1626
  const local = `__farm_package_values_${next++}__`;
1506
1627
  lines.push(`import * as ${local} from ${JSON.stringify(entry.specifier)};`);
1507
1628
  for (const value of entry.namespace.values) fields.push(`${value}: ${local}.${value}`);
@@ -1513,6 +1634,149 @@ function rewriteFarmPackageClientImports(options) {
1513
1634
  return changed ? output : null;
1514
1635
  }
1515
1636
 
1637
+ // src/islands-containers.ts
1638
+
1639
+
1640
+
1641
+ var FARM_ISLAND_CONTAINER_EXPORT = "FarmIslandContainer";
1642
+ var CONTAINER_LOCAL = "__FarmIslandContainer__";
1643
+ var ISLAND_CONTAINER_TAGS = /* @__PURE__ */ new Set([
1644
+ "table",
1645
+ "thead",
1646
+ "tbody",
1647
+ "tfoot",
1648
+ "tr",
1649
+ "select",
1650
+ "optgroup",
1651
+ "datalist",
1652
+ "svg",
1653
+ "ul",
1654
+ "ol"
1655
+ ]);
1656
+ var FLOW_CONTENT_TAGS = /* @__PURE__ */ new Set(["td", "th", "caption", "foreignObject", "li"]);
1657
+ function farmIslandContainerReferencePath(root) {
1658
+ return _path2.default.join(root, ".farm", "client-references", "farm.js+core", "__island-container.tsx");
1659
+ }
1660
+ function ensureFarmIslandContainerReference(root) {
1661
+ const file = farmIslandContainerReferencePath(root);
1662
+ const source = [
1663
+ "// Generated by Farm: the island around an element whose children are client components (RFC 0006).",
1664
+ FARM_CLIENT_REFERENCE_PRAGMA,
1665
+ '"use client";',
1666
+ `export function ${FARM_ISLAND_CONTAINER_EXPORT}({ children }: { children?: unknown }) {`,
1667
+ " return children as never;",
1668
+ "}",
1669
+ ""
1670
+ ].join("\n");
1671
+ let current = null;
1672
+ try {
1673
+ current = _fs2.default.readFileSync(file, "utf8");
1674
+ } catch (e23) {
1675
+ }
1676
+ if (current !== source) {
1677
+ _fs2.default.mkdirSync(_path2.default.dirname(file), { recursive: true });
1678
+ _fs2.default.writeFileSync(file, source);
1679
+ }
1680
+ return file;
1681
+ }
1682
+ function parse2(code, file) {
1683
+ const extension = _path2.default.extname(file).slice(1);
1684
+ const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : extension === "js" || extension === "mjs" || extension === "cjs" || extension === "jsx" ? "jsx" : "tsx";
1685
+ return memoizeInFarmSourceSnapshot(`ast:${lang}`, code, () => {
1686
+ try {
1687
+ return _parseAst.parseAst.call(void 0, code, { lang });
1688
+ } catch (e24) {
1689
+ return null;
1690
+ }
1691
+ });
1692
+ }
1693
+ function jsxName(node) {
1694
+ if (!node) return null;
1695
+ if (node.type === "JSXIdentifier") return node.name;
1696
+ if (node.type === "JSXMemberExpression") {
1697
+ let object = node.object;
1698
+ while (object.type === "JSXMemberExpression") object = object.object;
1699
+ return object.type === "JSXIdentifier" ? object.name : null;
1700
+ }
1701
+ return null;
1702
+ }
1703
+ function findFarmIslandContainers(code, file, bindings) {
1704
+ if (bindings.length === 0) return [];
1705
+ if (!/<(?:table|thead|tbody|tfoot|tr|select|optgroup|datalist|svg|ul|ol)[\s>/]/.test(code)) {
1706
+ return [];
1707
+ }
1708
+ const program = parse2(code, file);
1709
+ if (!program) return null;
1710
+ const names = new Set(bindings);
1711
+ const found = /* @__PURE__ */ new Map();
1712
+ const open = [];
1713
+ const visit = (node) => {
1714
+ if (!node || typeof node !== "object") return;
1715
+ if (Array.isArray(node)) {
1716
+ for (const child of node) visit(child);
1717
+ return;
1718
+ }
1719
+ const current = node;
1720
+ if (typeof current.type !== "string") return;
1721
+ if (current.type === "JSXElement") {
1722
+ const name = jsxName(_optionalChain([current, 'access', _90 => _90.openingElement, 'optionalAccess', _91 => _91.name]));
1723
+ if (name && names.has(name)) {
1724
+ let container;
1725
+ for (let depth = open.length - 1; depth >= 0; depth--) {
1726
+ const tag = jsxName(open[depth].openingElement.name);
1727
+ if (FLOW_CONTENT_TAGS.has(tag)) break;
1728
+ if (ISLAND_CONTAINER_TAGS.has(tag)) container = open[depth];
1729
+ }
1730
+ if (container && !found.has(container.start)) {
1731
+ found.set(container.start, {
1732
+ tag: jsxName(container.openingElement.name),
1733
+ start: container.start,
1734
+ end: container.end
1735
+ });
1736
+ }
1737
+ }
1738
+ const host = _optionalChain([current, 'access', _92 => _92.openingElement, 'optionalAccess', _93 => _93.name, 'optionalAccess', _94 => _94.type]) === "JSXIdentifier" && (ISLAND_CONTAINER_TAGS.has(name) || FLOW_CONTENT_TAGS.has(name));
1739
+ if (host) open.push(current);
1740
+ visit(_optionalChain([current, 'access', _95 => _95.openingElement, 'optionalAccess', _96 => _96.attributes]));
1741
+ visit(current.children);
1742
+ if (host) open.pop();
1743
+ return;
1744
+ }
1745
+ for (const [key, value] of Object.entries(current)) {
1746
+ if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
1747
+ if (value && typeof value === "object") visit(value);
1748
+ }
1749
+ };
1750
+ visit(program);
1751
+ const sorted = [...found.values()].sort((a, b) => a.start - b.start);
1752
+ const outermost = [];
1753
+ for (const container of sorted) {
1754
+ const last = outermost[outermost.length - 1];
1755
+ if (last && container.start >= last.start && container.end <= last.end) continue;
1756
+ outermost.push(container);
1757
+ }
1758
+ return outermost;
1759
+ }
1760
+ function wrapFarmIslandContainers(options) {
1761
+ const containers = findFarmIslandContainers(options.code, options.file, options.bindings);
1762
+ if (!containers || containers.length === 0) return null;
1763
+ let code = options.code;
1764
+ for (const container of [...containers].reverse()) {
1765
+ code = code.slice(0, container.start) + `<${CONTAINER_LOCAL}>` + code.slice(container.start, container.end) + `</${CONTAINER_LOCAL}>` + code.slice(container.end);
1766
+ }
1767
+ const specifier = JSON.stringify(options.reference.split(_path2.default.sep).join("/"));
1768
+ const declaration = `import { ${FARM_ISLAND_CONTAINER_EXPORT} as ${CONTAINER_LOCAL} } from ${specifier};
1769
+ `;
1770
+ let prologueEnd = 0;
1771
+ for (const statement of _nullishCoalesce(_optionalChain([parse2, 'call', _97 => _97(options.code, options.file), 'optionalAccess', _98 => _98.body]), () => ( []))) {
1772
+ if (statement.type !== "ExpressionStatement" || typeof statement.directive !== "string") break;
1773
+ prologueEnd = statement.end;
1774
+ }
1775
+ if (prologueEnd === 0) return declaration + code;
1776
+ return `${code.slice(0, prologueEnd)}
1777
+ ${declaration}${code.slice(prologueEnd)}`;
1778
+ }
1779
+
1516
1780
  // src/utils/package-client-boundary-cache.ts
1517
1781
  var _async_hooks = require('async_hooks');
1518
1782
 
@@ -1560,7 +1824,7 @@ function stampPackagePath(target, kind) {
1560
1824
  const stat = _fs2.default.statSync(target, { throwIfNoEntry: false });
1561
1825
  if (!stat || (kind === "file" ? !stat.isFile() : !stat.isDirectory())) return void 0;
1562
1826
  return [target, stat.size, stat.mtimeMs, stat.ctimeMs];
1563
- } catch (e22) {
1827
+ } catch (e25) {
1564
1828
  return void 0;
1565
1829
  }
1566
1830
  }
@@ -1596,7 +1860,7 @@ var PackageClientBoundaryCache = class {
1596
1860
  else this.dirty = true;
1597
1861
  }
1598
1862
  }
1599
- return _optionalChain([entries, 'optionalAccess', _73 => _73.find, 'call', _74 => _74(
1863
+ return _optionalChain([entries, 'optionalAccess', _99 => _99.find, 'call', _100 => _100(
1600
1864
  (entry) => entry.stops.every((file) => visited.has(file)) && !entry.files.some((file) => visited.has(file))
1601
1865
  )]);
1602
1866
  }
@@ -1615,7 +1879,7 @@ var PackageClientBoundaryCache = class {
1615
1879
  await _fs2.default.promises.mkdir(_path2.default.dirname(file), { recursive: true });
1616
1880
  await _fs2.default.promises.writeFile(temporary, contents);
1617
1881
  await _fs2.default.promises.rename(temporary, file);
1618
- } catch (e23) {
1882
+ } catch (e26) {
1619
1883
  await _fs2.default.promises.rm(temporary, { force: true }).catch(() => {
1620
1884
  });
1621
1885
  }
@@ -1630,10 +1894,10 @@ var PackageClientBoundaryCache = class {
1630
1894
  _fs2.default.mkdirSync(_path2.default.dirname(file), { recursive: true });
1631
1895
  _fs2.default.writeFileSync(temporary, contents);
1632
1896
  _fs2.default.renameSync(temporary, file);
1633
- } catch (e24) {
1897
+ } catch (e27) {
1634
1898
  try {
1635
1899
  _fs2.default.rmSync(temporary, { force: true });
1636
- } catch (e25) {
1900
+ } catch (e28) {
1637
1901
  }
1638
1902
  }
1639
1903
  }
@@ -1667,7 +1931,7 @@ var PackageClientBoundaryCache = class {
1667
1931
  }
1668
1932
  const contents = JSON.stringify({
1669
1933
  schema: SCHEMA_VERSION,
1670
- farm: _chunkMEJCP2LXcjs.FARM_VERSION,
1934
+ farm: _chunkUVQRMUARcjs.FARM_VERSION,
1671
1935
  paths,
1672
1936
  entries
1673
1937
  });
@@ -1704,10 +1968,10 @@ function readStoredCache(file) {
1704
1968
  let value;
1705
1969
  try {
1706
1970
  value = JSON.parse(_fs2.default.readFileSync(file, "utf8"));
1707
- } catch (e26) {
1971
+ } catch (e29) {
1708
1972
  return null;
1709
1973
  }
1710
- if (!isRecord(value) || value.schema !== SCHEMA_VERSION || value.farm !== _chunkMEJCP2LXcjs.FARM_VERSION) {
1974
+ if (!isRecord(value) || value.schema !== SCHEMA_VERSION || value.farm !== _chunkUVQRMUARcjs.FARM_VERSION) {
1711
1975
  return null;
1712
1976
  }
1713
1977
  const { paths, entries } = value;
@@ -1718,7 +1982,7 @@ function readStoredCache(file) {
1718
1982
  const usable = variants.filter((entry) => isStoredEntry(entry, paths.length));
1719
1983
  if (usable.length > 0) valid[key] = usable;
1720
1984
  }
1721
- return { schema: SCHEMA_VERSION, farm: _chunkMEJCP2LXcjs.FARM_VERSION, paths, entries: valid };
1985
+ return { schema: SCHEMA_VERSION, farm: _chunkUVQRMUARcjs.FARM_VERSION, paths, entries: valid };
1722
1986
  }
1723
1987
  function isRecord(value) {
1724
1988
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -1757,7 +2021,7 @@ async function withPackageClientBoundaryCache(operation) {
1757
2021
  }
1758
2022
  }
1759
2023
  function usePackageClientBoundaryCacheFile(file) {
1760
- _optionalChain([getPackageClientBoundaryCache, 'call', _75 => _75(), 'optionalAccess', _76 => _76.load, 'call', _77 => _77(file)]);
2024
+ _optionalChain([getPackageClientBoundaryCache, 'call', _101 => _101(), 'optionalAccess', _102 => _102.load, 'call', _103 => _103(file)]);
1761
2025
  }
1762
2026
  function resolvePackageClientBoundaryCacheFile(root, distDir) {
1763
2027
  return _path2.default.resolve(root, distDir, "cache", "client-boundaries.json");
@@ -1768,17 +2032,47 @@ function runWithPackageClientBoundaryCacheFile(file, operation) {
1768
2032
  cache2.load(file);
1769
2033
  const result = getStorage().run(cache2, operation);
1770
2034
  cache2.persistSync();
2035
+ latestDevCache = { file, cache: cache2 };
1771
2036
  return result;
1772
2037
  }
2038
+ var latestDevCache;
2039
+ function runWithLatestPackageClientBoundaryCache(file, operation) {
2040
+ if (getPackageClientBoundaryCache()) return operation();
2041
+ if (_optionalChain([latestDevCache, 'optionalAccess', _104 => _104.file]) !== file) {
2042
+ const cache2 = new PackageClientBoundaryCache();
2043
+ cache2.load(file);
2044
+ latestDevCache = { file, cache: cache2 };
2045
+ }
2046
+ return getStorage().run(latestDevCache.cache, operation);
2047
+ }
2048
+ function dropLatestPackageClientBoundaryCache() {
2049
+ latestDevCache = void 0;
2050
+ }
1773
2051
 
1774
2052
  // src/utils/client-component.ts
1775
2053
  function readIfExists(filePath) {
2054
+ if (filePath.replace(/\\/g, "/").includes(FARM_CLIENT_REFERENCE_DIRECTORY)) {
2055
+ return readSourceFile(filePath);
2056
+ }
2057
+ return memoizeInFarmSourceSnapshot(
2058
+ "source",
2059
+ filePath,
2060
+ () => readSourceFile(filePath),
2061
+ (content) => content !== null
2062
+ );
2063
+ }
2064
+ function readSourceFile(filePath) {
2065
+ const content = readSourceFileContents(filePath);
2066
+ if (content !== null) noteFarmSourceRead(filePath);
2067
+ return content;
2068
+ }
2069
+ function readSourceFileContents(filePath) {
1776
2070
  try {
1777
2071
  if (!filePath || !_fs2.default.existsSync(filePath)) {
1778
2072
  return null;
1779
2073
  }
1780
2074
  return _fs2.default.readFileSync(filePath, "utf-8");
1781
- } catch (e27) {
2075
+ } catch (e30) {
1782
2076
  return null;
1783
2077
  }
1784
2078
  }
@@ -1791,7 +2085,7 @@ function resolveModuleSourcePath(modulePath, root) {
1791
2085
  if (modulePath.startsWith("file://")) {
1792
2086
  try {
1793
2087
  candidates.add(_url.fileURLToPath.call(void 0, modulePath));
1794
- } catch (e28) {
2088
+ } catch (e31) {
1795
2089
  }
1796
2090
  }
1797
2091
  if (modulePath.startsWith("/@fs/")) {
@@ -1804,7 +2098,7 @@ function resolveModuleSourcePath(modulePath, root) {
1804
2098
  candidates.add(_path2.default.join(root, normalized));
1805
2099
  candidates.add(_path2.default.resolve(root, normalized));
1806
2100
  }
1807
- if (_optionalChain([withoutQuery, 'optionalAccess', _78 => _78.startsWith, 'call', _79 => _79("/src/")])) {
2101
+ if (_optionalChain([withoutQuery, 'optionalAccess', _105 => _105.startsWith, 'call', _106 => _106("/src/")])) {
1808
2102
  const normalized = withoutQuery.replace(/^\/+/, "");
1809
2103
  candidates.add(_path2.default.join(process.cwd(), normalized));
1810
2104
  candidates.add(_path2.default.resolve(process.cwd(), normalized));
@@ -1883,7 +2177,7 @@ function hasHydrateExport(content) {
1883
2177
  for (const match of content.matchAll(/\bexport\s*\{([^}]*)\}/g)) {
1884
2178
  for (const specifier of match[1].split(",")) {
1885
2179
  const parts = specifier.trim().split(/\s+as\s+/);
1886
- const exportedName2 = _optionalChain([(_nullishCoalesce(parts[1], () => ( parts[0]))), 'optionalAccess', _80 => _80.trim, 'call', _81 => _81()]);
2180
+ const exportedName2 = _optionalChain([(_nullishCoalesce(parts[1], () => ( parts[0]))), 'optionalAccess', _107 => _107.trim, 'call', _108 => _108()]);
1887
2181
  if (exportedName2 === "hydrate") {
1888
2182
  return true;
1889
2183
  }
@@ -1963,6 +2257,9 @@ function skipRegularExpression(content, startIndex) {
1963
2257
  var tokenizedModules = /* @__PURE__ */ new Map();
1964
2258
  var TOKENIZED_MODULE_CACHE_SIZE = 32;
1965
2259
  function tokenizeModuleSource(content) {
2260
+ return memoizeInFarmSourceSnapshot("tokens", content, () => tokenizeRecentModuleSource(content));
2261
+ }
2262
+ function tokenizeRecentModuleSource(content) {
1966
2263
  const cached = tokenizedModules.get(content);
1967
2264
  if (cached) return cached;
1968
2265
  const tokens = scanModuleSourceTokens(content);
@@ -2073,7 +2370,7 @@ function isIslandExportStart(tokens, index) {
2073
2370
  const token = tokens[index];
2074
2371
  const previous = tokens[index - 1];
2075
2372
  const startsStatement = !previous || previous.value === ";" || previous.value === "{" || previous.value === "}" || token.line > previous.line;
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";
2373
+ return startsStatement && token.value === "export" && _optionalChain([tokens, 'access', _109 => _109[index + 1], 'optionalAccess', _110 => _110.value]) === "const" && _optionalChain([tokens, 'access', _111 => _111[index + 2], 'optionalAccess', _112 => _112.value]) === "island";
2077
2374
  }
2078
2375
  function getIslandStrategyExport(content) {
2079
2376
  if (!content) return null;
@@ -2081,15 +2378,15 @@ function getIslandStrategyExport(content) {
2081
2378
  for (let index = 0; index < tokens.length - 2; index++) {
2082
2379
  if (!isIslandExportStart(tokens, index)) continue;
2083
2380
  let valueIndex = index + 3;
2084
- if (_optionalChain([tokens, 'access', _86 => _86[valueIndex], 'optionalAccess', _87 => _87.value]) === ":") {
2381
+ if (_optionalChain([tokens, 'access', _113 => _113[valueIndex], 'optionalAccess', _114 => _114.value]) === ":") {
2085
2382
  while (valueIndex < tokens.length && tokens[valueIndex].value !== "=") valueIndex++;
2086
2383
  }
2087
- if (_optionalChain([tokens, 'access', _88 => _88[valueIndex], 'optionalAccess', _89 => _89.value]) !== "=") break;
2384
+ if (_optionalChain([tokens, 'access', _115 => _115[valueIndex], 'optionalAccess', _116 => _116.value]) !== "=") break;
2088
2385
  valueIndex++;
2089
2386
  const literal = tokens[valueIndex];
2090
2387
  if (!literal || literal.kind !== "string" || !_chunk7KJJ4SBScjs.isFarmIslandStrategy.call(void 0, literal.value)) break;
2091
2388
  let trailingIndex = valueIndex + 1;
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") {
2389
+ if (_optionalChain([tokens, 'access', _117 => _117[trailingIndex], 'optionalAccess', _118 => _118.value]) === "as" && _optionalChain([tokens, 'access', _119 => _119[trailingIndex + 1], 'optionalAccess', _120 => _120.value]) === "const") {
2093
2390
  trailingIndex += 2;
2094
2391
  }
2095
2392
  const trailing = tokens[trailingIndex];
@@ -2115,13 +2412,13 @@ function hasAsyncDefaultExport(content) {
2115
2412
  for (let index = 0; index < tokens.length - 2; index++) {
2116
2413
  const token = tokens[index];
2117
2414
  if (token.kind !== "identifier" || token.value !== "export") 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;
2415
+ if (_optionalChain([tokens, 'access', _121 => _121[index - 1], 'optionalAccess', _122 => _122.value]) === ".") continue;
2416
+ if (_optionalChain([tokens, 'access', _123 => _123[index + 1], 'optionalAccess', _124 => _124.value]) !== "default") continue;
2120
2417
  const exported = tokens[index + 2];
2121
2418
  if (exported.kind === "identifier" && exported.value === "async") {
2122
2419
  return true;
2123
2420
  }
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)) {
2421
+ if (exported.kind === "identifier" && !["function", "class"].includes(exported.value) && _optionalChain([tokens, 'access', _125 => _125[index + 3], 'optionalAccess', _126 => _126.value]) !== "(" && isAsyncLocalDeclaration(tokens, exported.value)) {
2125
2422
  return true;
2126
2423
  }
2127
2424
  }
@@ -2129,10 +2426,10 @@ function hasAsyncDefaultExport(content) {
2129
2426
  }
2130
2427
  function isAsyncLocalDeclaration(tokens, name) {
2131
2428
  for (let index = 0; index < tokens.length - 2; index++) {
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) {
2429
+ if (tokens[index].value === "async" && _optionalChain([tokens, 'access', _127 => _127[index + 1], 'optionalAccess', _128 => _128.value]) === "function" && _optionalChain([tokens, 'access', _129 => _129[index + 2], 'optionalAccess', _130 => _130.value]) === name) {
2133
2430
  return true;
2134
2431
  }
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") {
2432
+ if (tokens[index].value === name && _optionalChain([tokens, 'access', _131 => _131[index + 1], 'optionalAccess', _132 => _132.value]) === "=" && _optionalChain([tokens, 'access', _133 => _133[index + 2], 'optionalAccess', _134 => _134.value]) === "async") {
2136
2433
  return true;
2137
2434
  }
2138
2435
  }
@@ -2172,6 +2469,16 @@ function resolveOwnerSourcePath(resolvedPath, root) {
2172
2469
  }
2173
2470
  return current;
2174
2471
  }
2472
+ function getFarmClientRenderingBindings(code, file, root) {
2473
+ const bindings = [];
2474
+ for (const [specifier, locals] of getStaticImportBindings(code)) {
2475
+ const imported = resolveImportedModule(file, specifier, root);
2476
+ if (!imported.path) continue;
2477
+ const metadata = imported.local ? inspectClientModuleMetadata(imported.path, root, /* @__PURE__ */ new Set([_path2.default.resolve(file)]), false) : inspectPackageClientBoundary(imported.path, root, /* @__PURE__ */ new Set());
2478
+ if (metadata.isClientComponent || metadata.shouldHydrate) bindings.push(...locals);
2479
+ }
2480
+ return bindings;
2481
+ }
2175
2482
  function collectFarmRenderedClientModules(modulePath, root) {
2176
2483
  const resolvedPath = resolveOwnerSourcePath(resolveModuleSourcePath(modulePath, root), root);
2177
2484
  if (!resolvedPath) return null;
@@ -2333,7 +2640,7 @@ function planClientModuleHydration(modulePath, root, mode, options) {
2333
2640
  return plan;
2334
2641
  }
2335
2642
  function usesFarmServerTree(plan) {
2336
- return _optionalChain([plan, 'optionalAccess', _108 => _108.asyncOwnerIslands]) === true && plan.isolatedBoundaries.length > 0 && plan.isolatedBoundaries.every((boundary) => boundary.islandStrategy === "load");
2643
+ return _optionalChain([plan, 'optionalAccess', _135 => _135.asyncOwnerIslands]) === true && plan.isolatedBoundaries.length > 0;
2337
2644
  }
2338
2645
  function getMarkdownPageHydrationPlan(componentsModulePath, root, mode = "off", options = {}) {
2339
2646
  const plan = {
@@ -2437,6 +2744,13 @@ function enforceFarmIsolatedHydrationRouteBudget(layouts, routes, layoutAppliesT
2437
2744
  (ancestor) => ancestor !== layout && ancestor.depth < layout.depth && ancestor.metadata.shouldHydrate && layoutAppliesToRoute(ancestor.pattern, layout.pattern)
2438
2745
  );
2439
2746
  if (hasRouteWideAncestor && layout.metadata.hasIsolatedClientBoundaries) {
2747
+ if (options.serverOwners && !layout.metadata.asyncOwnerIslands) {
2748
+ layout.metadata.shouldHydrate = layout.metadata.legacyShouldHydrate;
2749
+ layout.metadata.islandStrategy = layout.metadata.legacyIslandStrategy;
2750
+ layout.metadata.hasIsolatedClientBoundaries = false;
2751
+ layout.metadata.serverTreeLayout = true;
2752
+ continue;
2753
+ }
2440
2754
  restoreRouteWideHydration(layout.metadata);
2441
2755
  }
2442
2756
  }
@@ -2447,6 +2761,23 @@ function isIsolatableClientBoundarySource(content) {
2447
2761
  if (/\bexport\s*\*/.test(content)) return false;
2448
2762
  return /\bexport\s+default\s+(?!(?:type|interface)\b)/.test(content) || /\bexport\s+(?:async\s+)?function\s+[A-Z][$\w]*/.test(content) || /\bexport\s+(?:const|let|var|class)\s+[A-Z][$\w]*/.test(content) || exportListNames(content).some((name) => name === "default" || /^[A-Z]/.test(name));
2449
2763
  }
2764
+ function clientModulePlanSignature(content) {
2765
+ if (!content || !hasUseClientDirective(content)) return null;
2766
+ try {
2767
+ return JSON.stringify([
2768
+ getIslandStrategyExport(content),
2769
+ hasHydrateExport(content),
2770
+ isIsolatableClientBoundarySource(content),
2771
+ getImportSpecifiers(content).sort()
2772
+ ]);
2773
+ } catch (e32) {
2774
+ return null;
2775
+ }
2776
+ }
2777
+ function isFarmClientModulePlanUnchanged(file, previous) {
2778
+ const signature = clientModulePlanSignature(previous);
2779
+ return signature !== null && signature === clientModulePlanSignature(readSourceFileContents(file));
2780
+ }
2450
2781
  function exportListNames(content) {
2451
2782
  const names = [];
2452
2783
  for (const match of content.matchAll(/\bexport\s*(type\s*)?\{([^}]*)\}/g)) {
@@ -2464,7 +2795,7 @@ function getStaticImportBindings(content) {
2464
2795
  if (!content) return bindings;
2465
2796
  const tokens = tokenizeModuleSource(content);
2466
2797
  for (let index = 0; index < tokens.length; index++) {
2467
- if (tokens[index].value !== "import" || _optionalChain([tokens, 'access', _109 => _109[index - 1], 'optionalAccess', _110 => _110.value]) === ".") continue;
2798
+ if (tokens[index].value !== "import" || _optionalChain([tokens, 'access', _136 => _136[index - 1], 'optionalAccess', _137 => _137.value]) === ".") continue;
2468
2799
  const first = tokens[index + 1];
2469
2800
  if (!first || first.value === "type" || first.value === "(" || first.kind === "string") {
2470
2801
  continue;
@@ -2472,7 +2803,7 @@ function getStaticImportBindings(content) {
2472
2803
  let fromIndex = -1;
2473
2804
  for (let cursor = index + 1; cursor < tokens.length; cursor++) {
2474
2805
  if (tokens[cursor].value === ";") break;
2475
- if (tokens[cursor].value === "from" && _optionalChain([tokens, 'access', _111 => _111[cursor + 1], 'optionalAccess', _112 => _112.kind]) === "string") {
2806
+ if (tokens[cursor].value === "from" && _optionalChain([tokens, 'access', _138 => _138[cursor + 1], 'optionalAccess', _139 => _139.kind]) === "string") {
2476
2807
  fromIndex = cursor;
2477
2808
  break;
2478
2809
  }
@@ -2481,13 +2812,13 @@ function getStaticImportBindings(content) {
2481
2812
  const specifier = tokens[fromIndex + 1].value;
2482
2813
  const clause = tokens.slice(index + 1, fromIndex);
2483
2814
  const localNames = [];
2484
- if (_optionalChain([clause, 'access', _113 => _113[0], 'optionalAccess', _114 => _114.kind]) === "identifier" && clause[0].value !== "type") {
2815
+ if (_optionalChain([clause, 'access', _140 => _140[0], 'optionalAccess', _141 => _141.kind]) === "identifier" && clause[0].value !== "type") {
2485
2816
  localNames.push(clause[0].value);
2486
2817
  }
2487
2818
  const namespaceAs = clause.findIndex(
2488
- (token, clauseIndex) => token.value === "*" && _optionalChain([clause, 'access', _115 => _115[clauseIndex + 1], 'optionalAccess', _116 => _116.value]) === "as"
2819
+ (token, clauseIndex) => token.value === "*" && _optionalChain([clause, 'access', _142 => _142[clauseIndex + 1], 'optionalAccess', _143 => _143.value]) === "as"
2489
2820
  );
2490
- if (namespaceAs !== -1 && _optionalChain([clause, 'access', _117 => _117[namespaceAs + 2], 'optionalAccess', _118 => _118.kind]) === "identifier") {
2821
+ if (namespaceAs !== -1 && _optionalChain([clause, 'access', _144 => _144[namespaceAs + 2], 'optionalAccess', _145 => _145.kind]) === "identifier") {
2491
2822
  localNames.push(clause[namespaceAs + 2].value);
2492
2823
  }
2493
2824
  const openingBrace = clause.findIndex((token) => token.value === "{");
@@ -2497,11 +2828,11 @@ function getStaticImportBindings(content) {
2497
2828
  if (openingBrace !== -1 && closingBrace !== -1) {
2498
2829
  let entryStart = openingBrace + 1;
2499
2830
  for (let cursor = entryStart; cursor <= closingBrace; cursor++) {
2500
- if (cursor !== closingBrace && _optionalChain([clause, 'access', _119 => _119[cursor], 'optionalAccess', _120 => _120.value]) !== ",") continue;
2831
+ if (cursor !== closingBrace && _optionalChain([clause, 'access', _146 => _146[cursor], 'optionalAccess', _147 => _147.value]) !== ",") continue;
2501
2832
  const entry = clause.slice(entryStart, cursor).filter((token) => token.value !== "type");
2502
2833
  const asIndex = entry.findIndex((token) => token.value === "as");
2503
2834
  const local = asIndex === -1 ? entry[0] : entry[asIndex + 1];
2504
- if (_optionalChain([local, 'optionalAccess', _121 => _121.kind]) === "identifier") localNames.push(local.value);
2835
+ if (_optionalChain([local, 'optionalAccess', _148 => _148.kind]) === "identifier") localNames.push(local.value);
2505
2836
  entryStart = cursor + 1;
2506
2837
  }
2507
2838
  }
@@ -2538,14 +2869,14 @@ function findParserSensitiveJsxContainer(content, localBindings) {
2538
2869
  const open = [];
2539
2870
  const isSelfClosing = (openingIndex) => {
2540
2871
  for (let index = openingIndex; index < tokens.length; index++) {
2541
- if (tokens[index].value === ">") return _optionalChain([tokens, 'access', _122 => _122[index - 1], 'optionalAccess', _123 => _123.value]) === "/";
2872
+ if (tokens[index].value === ">") return _optionalChain([tokens, 'access', _149 => _149[index - 1], 'optionalAccess', _150 => _150.value]) === "/";
2542
2873
  }
2543
2874
  return false;
2544
2875
  };
2545
2876
  for (let index = 0; index < tokens.length - 1; index++) {
2546
2877
  if (tokens[index].value !== "<") continue;
2547
2878
  if (tokens[index + 1].value === "/") {
2548
- const closing = _optionalChain([tokens, 'access', _124 => _124[index + 2], 'optionalAccess', _125 => _125.value]);
2879
+ const closing = _optionalChain([tokens, 'access', _151 => _151[index + 2], 'optionalAccess', _152 => _152.value]);
2549
2880
  const at = closing ? open.lastIndexOf(closing) : -1;
2550
2881
  if (at !== -1) open.length = at;
2551
2882
  continue;
@@ -2588,7 +2919,7 @@ function findMatchingToken(tokens, openingIndex, opening, closing) {
2588
2919
  }
2589
2920
  function containsClientJsx(tokens, start, end, clientBindings) {
2590
2921
  for (let index = start; index < end; index++) {
2591
- if (tokens[index].value === "<" && clientBindings.has(_optionalChain([tokens, 'access', _126 => _126[index + 1], 'optionalAccess', _127 => _127.value]))) return true;
2922
+ if (tokens[index].value === "<" && clientBindings.has(_optionalChain([tokens, 'access', _153 => _153[index + 1], 'optionalAccess', _154 => _154.value]))) return true;
2592
2923
  }
2593
2924
  return false;
2594
2925
  }
@@ -2626,7 +2957,7 @@ function getClientRenderingHelpers(tokens, clientBindings) {
2626
2957
  let helperName;
2627
2958
  let bodyStart = -1;
2628
2959
  let bodyEnd = -1;
2629
- if (tokens[index].value === "function" && _optionalChain([tokens, 'access', _128 => _128[index + 1], 'optionalAccess', _129 => _129.kind]) === "identifier") {
2960
+ if (tokens[index].value === "function" && _optionalChain([tokens, 'access', _155 => _155[index + 1], 'optionalAccess', _156 => _156.kind]) === "identifier") {
2630
2961
  helperName = tokens[index + 1].value;
2631
2962
  const parametersStart = tokens.findIndex(
2632
2963
  (token, tokenIndex) => tokenIndex > index + 1 && token.value === "("
@@ -2636,21 +2967,21 @@ function getClientRenderingHelpers(tokens, clientBindings) {
2636
2967
  (token, tokenIndex) => tokenIndex > parametersEnd && token.value === "{"
2637
2968
  );
2638
2969
  if (bodyStart !== -1) bodyEnd = findMatchingToken(tokens, bodyStart, "{", "}");
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") {
2970
+ } else if ((tokens[index].value === "const" || tokens[index].value === "let" || tokens[index].value === "var") && _optionalChain([tokens, 'access', _157 => _157[index + 1], 'optionalAccess', _158 => _158.kind]) === "identifier") {
2640
2971
  helperName = tokens[index + 1].value;
2641
2972
  let assignmentIndex = -1;
2642
2973
  let arrowIndex = -1;
2643
2974
  for (let cursor = index + 2; cursor < tokens.length; cursor++) {
2644
2975
  if (tokens[cursor].value === ";") break;
2645
2976
  if (assignmentIndex === -1 && tokens[cursor].value === "=") assignmentIndex = cursor;
2646
- if (tokens[cursor].value === "=" && _optionalChain([tokens, 'access', _132 => _132[cursor + 1], 'optionalAccess', _133 => _133.value]) === ">") {
2977
+ if (tokens[cursor].value === "=" && _optionalChain([tokens, 'access', _159 => _159[cursor + 1], 'optionalAccess', _160 => _160.value]) === ">") {
2647
2978
  arrowIndex = cursor;
2648
2979
  break;
2649
2980
  }
2650
2981
  }
2651
2982
  if (arrowIndex !== -1) {
2652
2983
  bodyStart = arrowIndex + 2;
2653
- bodyEnd = _optionalChain([tokens, 'access', _134 => _134[bodyStart], 'optionalAccess', _135 => _135.value]) === "{" ? findMatchingToken(tokens, bodyStart, "{", "}") : findStatementEnd(tokens, bodyStart);
2984
+ bodyEnd = _optionalChain([tokens, 'access', _161 => _161[bodyStart], 'optionalAccess', _162 => _162.value]) === "{" ? findMatchingToken(tokens, bodyStart, "{", "}") : findStatementEnd(tokens, bodyStart);
2654
2985
  } else if (assignmentIndex !== -1) {
2655
2986
  bodyStart = assignmentIndex + 1;
2656
2987
  bodyEnd = findStatementEnd(tokens, bodyStart);
@@ -2690,14 +3021,14 @@ function passesElementValuedProps(content, localBindings) {
2690
3021
  else if (value === "}") braceDepth--;
2691
3022
  else if (value === "<" && braceDepth > 0) return true;
2692
3023
  else if (value === ">" && braceDepth === 0) {
2693
- selfClosing = _optionalChain([tokens, 'access', _136 => _136[cursor - 1], 'optionalAccess', _137 => _137.value]) === "/";
3024
+ selfClosing = _optionalChain([tokens, 'access', _163 => _163[cursor - 1], 'optionalAccess', _164 => _164.value]) === "/";
2694
3025
  break;
2695
3026
  }
2696
3027
  }
2697
3028
  if (selfClosing || cursor >= tokens.length) continue;
2698
3029
  for (let child = cursor + 1; child < tokens.length; child++) {
2699
3030
  if (tokens[child].value !== "<") continue;
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;
3031
+ const closesBoundary = _optionalChain([tokens, 'access', _165 => _165[child + 1], 'optionalAccess', _166 => _166.value]) === "/" && _optionalChain([tokens, 'access', _167 => _167[child + 2], 'optionalAccess', _168 => _168.value]) === name;
2701
3032
  if (!closesBoundary) return true;
2702
3033
  break;
2703
3034
  }
@@ -2719,7 +3050,7 @@ function rendersOnlyLeafElements(content, localBindings) {
2719
3050
  else if (value === "<" && braceDepth > 0) return false;
2720
3051
  else if (value === ">" && braceDepth === 0) break;
2721
3052
  }
2722
- if (cursor >= tokens.length || _optionalChain([tokens, 'access', _142 => _142[cursor - 1], 'optionalAccess', _143 => _143.value]) !== "/") return false;
3053
+ if (cursor >= tokens.length || _optionalChain([tokens, 'access', _169 => _169[cursor - 1], 'optionalAccess', _170 => _170.value]) !== "/") return false;
2723
3054
  }
2724
3055
  return true;
2725
3056
  }
@@ -2731,9 +3062,9 @@ function hasDynamicJsxCardinality(content, localBindings) {
2731
3062
  const containsDynamicRenderer = (start, end) => containsClientJsx(tokens, start, end, clientBindings) || tokens.slice(start, end).some((token) => renderingHelpers.has(token.value));
2732
3063
  for (let index = 0; index < tokens.length; index++) {
2733
3064
  let callStart = -1;
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]) === "(") {
3065
+ if (tokens[index].value === "." && (_optionalChain([tokens, 'access', _171 => _171[index + 1], 'optionalAccess', _172 => _172.value]) === "map" || _optionalChain([tokens, 'access', _173 => _173[index + 1], 'optionalAccess', _174 => _174.value]) === "flatMap") && _optionalChain([tokens, 'access', _175 => _175[index + 2], 'optionalAccess', _176 => _176.value]) === "(") {
2735
3066
  callStart = index + 2;
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]) === "(") {
3067
+ } else if (tokens[index].value === "Array" && _optionalChain([tokens, 'access', _177 => _177[index + 1], 'optionalAccess', _178 => _178.value]) === "." && _optionalChain([tokens, 'access', _179 => _179[index + 2], 'optionalAccess', _180 => _180.value]) === "from" && _optionalChain([tokens, 'access', _181 => _181[index + 3], 'optionalAccess', _182 => _182.value]) === "(") {
2737
3068
  callStart = index + 3;
2738
3069
  }
2739
3070
  if (callStart !== -1) {
@@ -2742,10 +3073,10 @@ function hasDynamicJsxCardinality(content, localBindings) {
2742
3073
  index = callEnd;
2743
3074
  continue;
2744
3075
  }
2745
- if ((tokens[index].value === "for" || tokens[index].value === "while") && _optionalChain([tokens, 'access', _156 => _156[index + 1], 'optionalAccess', _157 => _157.value]) === "(") {
3076
+ if ((tokens[index].value === "for" || tokens[index].value === "while") && _optionalChain([tokens, 'access', _183 => _183[index + 1], 'optionalAccess', _184 => _184.value]) === "(") {
2746
3077
  const conditionEnd = findMatchingToken(tokens, index + 1, "(", ")");
2747
3078
  const bodyStart = conditionEnd + 1;
2748
- const bodyEnd = _optionalChain([tokens, 'access', _158 => _158[bodyStart], 'optionalAccess', _159 => _159.value]) === "{" ? findMatchingToken(tokens, bodyStart, "{", "}") : tokens.findIndex((token, tokenIndex) => tokenIndex > bodyStart && token.value === ";");
3079
+ const bodyEnd = _optionalChain([tokens, 'access', _185 => _185[bodyStart], 'optionalAccess', _186 => _186.value]) === "{" ? findMatchingToken(tokens, bodyStart, "{", "}") : tokens.findIndex((token, tokenIndex) => tokenIndex > bodyStart && token.value === ";");
2749
3080
  if (containsDynamicRenderer(bodyStart, bodyEnd === -1 ? tokens.length : bodyEnd)) return true;
2750
3081
  }
2751
3082
  }
@@ -2857,7 +3188,9 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
2857
3188
  const localBindings = _nullishCoalesce(importedBindings.get(specifier), () => ( []));
2858
3189
  const staticUses = countStaticJsxUses(content, localBindings);
2859
3190
  if (staticUses > 0) {
2860
- const container = findParserSensitiveJsxContainer(content, localBindings);
3191
+ const grows = options.packageReferences === true && projectRoot !== void 0 && (_nullishCoalesce(_optionalChain([findFarmIslandContainers, 'call', _187 => _187(_nullishCoalesce(content, () => ( "")), moduleSourcePath, localBindings), 'optionalAccess', _188 => _188.length]), () => ( 0))) > 0;
3192
+ if (grows) visit(ensureFarmIslandContainerReference(projectRoot));
3193
+ const container = grows ? void 0 : findParserSensitiveJsxContainer(content, localBindings);
2861
3194
  if (container) {
2862
3195
  fallbackReason = `the client boundary imported from ${specifier} renders inside <${container}>, where the HTML parser relocates its hydration marker`;
2863
3196
  fallbackHint = `Move "use client" up to a component that renders the whole <${container}>${_nullishCoalesce(PARSER_SENSITIVE_FLOW_HINTS[container], () => ( ""))}`;
@@ -2951,7 +3284,7 @@ function farmWorkspaceServerEntry(entry) {
2951
3284
  function realpathOrSelf(file) {
2952
3285
  try {
2953
3286
  return _fs2.default.realpathSync(file);
2954
- } catch (e29) {
3287
+ } catch (e33) {
2955
3288
  return file;
2956
3289
  }
2957
3290
  }
@@ -2968,17 +3301,20 @@ function inspectPackageClientBoundary(resolvedPath, root, visited) {
2968
3301
  const key = `${_nullishCoalesce(root, () => ( ""))}\0${resolvedPath}`;
2969
3302
  const cached = cache2.find(key, visited);
2970
3303
  if (cached) {
2971
- for (const file of cached.files) visited.add(file);
3304
+ for (const file of cached.files) {
3305
+ visited.add(file);
3306
+ noteFarmSourceRead(file);
3307
+ }
2972
3308
  return { ...cached.result };
2973
3309
  }
2974
- const trace = new PackageInspectionTrace();
2975
- const result = traversePackageClientBoundary(resolvedPath, root, visited, trace);
2976
- cache2.add(key, trace.toEntry(result));
3310
+ const trace2 = new PackageInspectionTrace();
3311
+ const result = traversePackageClientBoundary(resolvedPath, root, visited, trace2);
3312
+ cache2.add(key, trace2.toEntry(result));
2977
3313
  return result;
2978
3314
  }
2979
- function traversePackageClientBoundary(resolvedPath, root, visited, trace) {
3315
+ function traversePackageClientBoundary(resolvedPath, root, visited, trace2) {
2980
3316
  if (!resolvedPath || visited.has(resolvedPath)) {
2981
- if (resolvedPath) _optionalChain([trace, 'optionalAccess', _160 => _160.stop, 'call', _161 => _161(resolvedPath)]);
3317
+ if (resolvedPath) _optionalChain([trace2, 'optionalAccess', _189 => _189.stop, 'call', _190 => _190(resolvedPath)]);
2982
3318
  return {
2983
3319
  isClientComponent: false,
2984
3320
  shouldHydrate: false,
@@ -2986,7 +3322,7 @@ function traversePackageClientBoundary(resolvedPath, root, visited, trace) {
2986
3322
  };
2987
3323
  }
2988
3324
  visited.add(resolvedPath);
2989
- _optionalChain([trace, 'optionalAccess', _162 => _162.visit, 'call', _163 => _163(resolvedPath)]);
3325
+ _optionalChain([trace2, 'optionalAccess', _191 => _191.visit, 'call', _192 => _192(resolvedPath)]);
2990
3326
  const content = readIfExists(resolvedPath);
2991
3327
  const parsed = parseClientModuleMetadata(content, false);
2992
3328
  let importsClientBoundary = false;
@@ -3005,7 +3341,7 @@ function traversePackageClientBoundary(resolvedPath, root, visited, trace) {
3005
3341
  specifier,
3006
3342
  root
3007
3343
  );
3008
- const importedMetadata = traversePackageClientBoundary(importedPath, root, visited, trace);
3344
+ const importedMetadata = traversePackageClientBoundary(importedPath, root, visited, trace2);
3009
3345
  if (!importedMetadata.shouldHydrate) continue;
3010
3346
  importsClientBoundary = true;
3011
3347
  if (importedIslandStrategy === null) {
@@ -3021,8 +3357,16 @@ function traversePackageClientBoundary(resolvedPath, root, visited, trace) {
3021
3357
  islandStrategy: shouldHydrate ? _nullishCoalesce(_nullishCoalesce(parsed.islandStrategy, () => ( importedIslandStrategy)), () => ( "load")) : null
3022
3358
  };
3023
3359
  }
3024
- function getImportSpecifiers(content, { reexportsOnly = false, dynamic = false } = {}) {
3360
+ function getImportSpecifiers(content, options = {}) {
3025
3361
  if (!content) return [];
3362
+ const specifiers = memoizeInFarmSourceSnapshot(
3363
+ `specifiers:${options.reexportsOnly === true}:${options.dynamic === true}`,
3364
+ content,
3365
+ () => scanImportSpecifiers(content, options)
3366
+ );
3367
+ return [...specifiers];
3368
+ }
3369
+ function scanImportSpecifiers(content, { reexportsOnly = false, dynamic = false }) {
3026
3370
  const tokens = tokenizeModuleSource(content);
3027
3371
  const matches = /* @__PURE__ */ new Set();
3028
3372
  let braceDepth = 0;
@@ -3036,7 +3380,7 @@ function getImportSpecifiers(content, { reexportsOnly = false, dynamic = false }
3036
3380
  braceDepth = Math.max(0, braceDepth - 1);
3037
3381
  continue;
3038
3382
  }
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") {
3383
+ if (dynamic && keyword.kind === "identifier" && keyword.value === "import" && _optionalChain([tokens, 'access', _193 => _193[index - 1], 'optionalAccess', _194 => _194.value]) !== "." && _optionalChain([tokens, 'access', _195 => _195[index + 1], 'optionalAccess', _196 => _196.value]) === "(" && _optionalChain([tokens, 'access', _197 => _197[index + 2], 'optionalAccess', _198 => _198.kind]) === "string") {
3040
3384
  matches.add(tokens[index + 2].value);
3041
3385
  continue;
3042
3386
  }
@@ -3046,7 +3390,7 @@ function getImportSpecifiers(content, { reexportsOnly = false, dynamic = false }
3046
3390
  }
3047
3391
  if (reexportsOnly && keyword.value !== "export") continue;
3048
3392
  const previous = tokens[index - 1];
3049
- if (_optionalChain([previous, 'optionalAccess', _170 => _170.value]) === ".") continue;
3393
+ if (_optionalChain([previous, 'optionalAccess', _199 => _199.value]) === ".") continue;
3050
3394
  const first = tokens[index + 1];
3051
3395
  if (!first || first.value === "type" || first.value === "(" || first.value === ".") {
3052
3396
  continue;
@@ -3062,7 +3406,7 @@ function getImportSpecifiers(content, { reexportsOnly = false, dynamic = false }
3062
3406
  for (let cursor = index + 1; cursor < tokens.length; cursor++) {
3063
3407
  const token = tokens[cursor];
3064
3408
  if (token.value === ";") break;
3065
- if (token.value === "from" && _optionalChain([tokens, 'access', _171 => _171[cursor + 1], 'optionalAccess', _172 => _172.kind]) === "string") {
3409
+ if (token.value === "from" && _optionalChain([tokens, 'access', _200 => _200[cursor + 1], 'optionalAccess', _201 => _201.kind]) === "string") {
3066
3410
  fromIndex = cursor;
3067
3411
  break;
3068
3412
  }
@@ -3080,14 +3424,14 @@ function getImportSpecifiers(content, { reexportsOnly = false, dynamic = false }
3080
3424
  return Array.from(matches);
3081
3425
  }
3082
3426
  function isTypeOnlyNamedClause(tokens, startIndex, endIndex) {
3083
- if (_optionalChain([tokens, 'access', _173 => _173[startIndex], 'optionalAccess', _174 => _174.value]) !== "{") return false;
3427
+ if (_optionalChain([tokens, 'access', _202 => _202[startIndex], 'optionalAccess', _203 => _203.value]) !== "{") return false;
3084
3428
  const closingBraceIndex = tokens.findIndex(
3085
3429
  (token, index) => index > startIndex && index < endIndex && token.value === "}"
3086
3430
  );
3087
3431
  if (closingBraceIndex === -1) return false;
3088
3432
  let entryStartsAt = startIndex + 1;
3089
3433
  for (let index = entryStartsAt; index <= closingBraceIndex; index++) {
3090
- if (index !== closingBraceIndex && _optionalChain([tokens, 'access', _175 => _175[index], 'optionalAccess', _176 => _176.value]) !== ",") continue;
3434
+ if (index !== closingBraceIndex && _optionalChain([tokens, 'access', _204 => _204[index], 'optionalAccess', _205 => _205.value]) !== ",") continue;
3091
3435
  const entry = tokens.slice(entryStartsAt, index);
3092
3436
  if (entry.length > 0 && entry[0].value !== "type") return false;
3093
3437
  entryStartsAt = index + 1;
@@ -3095,6 +3439,16 @@ function isTypeOnlyNamedClause(tokens, startIndex, endIndex) {
3095
3439
  return true;
3096
3440
  }
3097
3441
  function resolveImportedModule(importerPath, specifier, root) {
3442
+ const resolved = memoizeInFarmSourceSnapshot(
3443
+ "resolution",
3444
+ `${_nullishCoalesce(root, () => ( ""))}\0${importerPath}\0${specifier}`,
3445
+ () => resolveImportedModuleUncached(importerPath, specifier, root),
3446
+ // A file added later may resolve an import that does not resolve now.
3447
+ (result) => result.path !== null
3448
+ );
3449
+ return { ...resolved };
3450
+ }
3451
+ function resolveImportedModuleUncached(importerPath, specifier, root) {
3098
3452
  if (specifier.startsWith(".") || specifier.startsWith("/")) {
3099
3453
  return { path: resolveImportedModuleSourcePath(importerPath, specifier, root), local: true };
3100
3454
  }
@@ -3151,14 +3505,14 @@ function getProjectImportAliases(projectRoot) {
3151
3505
  const stamp = PROJECT_ALIAS_FILES.map((file) => {
3152
3506
  try {
3153
3507
  return String(_fs2.default.statSync(_path2.default.join(projectRoot, file)).mtimeMs);
3154
- } catch (e30) {
3508
+ } catch (e34) {
3155
3509
  return "-";
3156
3510
  }
3157
3511
  }).join(":");
3158
3512
  const sourceDir = _chunkRE5E2G5Scjs.getFarmProjectSourceDir.call(void 0, projectRoot);
3159
3513
  const cacheStamp = `${stamp}:${sourceDir}`;
3160
3514
  const cached = projectImportAliasCache.get(projectRoot);
3161
- if (_optionalChain([cached, 'optionalAccess', _177 => _177.stamp]) === cacheStamp) return cached.aliases;
3515
+ if (_optionalChain([cached, 'optionalAccess', _206 => _206.stamp]) === cacheStamp) return cached.aliases;
3162
3516
  const aliases = [
3163
3517
  ...readTsconfigPathAliases(projectRoot),
3164
3518
  ...readPackageImportAliases(projectRoot)
@@ -3179,7 +3533,7 @@ function readTsconfigPathAliases(projectRoot) {
3179
3533
  const configPath = _path2.default.join(projectRoot, name);
3180
3534
  if (!_fs2.default.existsSync(configPath)) continue;
3181
3535
  const resolved = readTsconfigPaths(configPath, /* @__PURE__ */ new Set());
3182
- if (!_optionalChain([resolved, 'optionalAccess', _178 => _178.paths])) return [];
3536
+ if (!_optionalChain([resolved, 'optionalAccess', _207 => _207.paths])) return [];
3183
3537
  const base = _nullishCoalesce(resolved.baseUrl, () => ( resolved.pathsDirectory));
3184
3538
  return Object.entries(resolved.paths).flatMap(([pattern, targets]) => {
3185
3539
  if (!Array.isArray(targets)) return [];
@@ -3214,18 +3568,18 @@ function readTsconfigPaths(configPath, visited) {
3214
3568
  inherited = _nullishCoalesce(readTsconfigPaths(parentPath, visited), () => ( inherited));
3215
3569
  }
3216
3570
  const options = _nullishCoalesce(config.compilerOptions, () => ( {}));
3217
- const baseUrl = typeof options.baseUrl === "string" ? _path2.default.resolve(directory, options.baseUrl) : _optionalChain([inherited, 'optionalAccess', _179 => _179.baseUrl]);
3571
+ const baseUrl = typeof options.baseUrl === "string" ? _path2.default.resolve(directory, options.baseUrl) : _optionalChain([inherited, 'optionalAccess', _208 => _208.baseUrl]);
3218
3572
  if (options.paths && typeof options.paths === "object") {
3219
3573
  return { paths: options.paths, pathsDirectory: directory, baseUrl };
3220
3574
  }
3221
3575
  return inherited ? { ...inherited, baseUrl } : { pathsDirectory: directory, baseUrl };
3222
3576
  }
3223
3577
  function readPackageImportAliases(projectRoot) {
3224
- const imports = _optionalChain([readPackageJson, 'call', _180 => _180(_path2.default.join(projectRoot, "package.json")), 'optionalAccess', _181 => _181.imports]);
3578
+ const imports = _optionalChain([readPackageJson, 'call', _209 => _209(_path2.default.join(projectRoot, "package.json")), 'optionalAccess', _210 => _210.imports]);
3225
3579
  if (!imports || typeof imports !== "object") return [];
3226
3580
  return Object.entries(imports).flatMap(([pattern, value]) => {
3227
3581
  const target = resolveConditionalExportTarget(value);
3228
- if (!pattern.startsWith("#") || !_optionalChain([target, 'optionalAccess', _182 => _182.startsWith, 'call', _183 => _183("./")])) return [];
3582
+ if (!pattern.startsWith("#") || !_optionalChain([target, 'optionalAccess', _211 => _211.startsWith, 'call', _212 => _212("./")])) return [];
3229
3583
  const wildcardIndex = pattern.indexOf("*");
3230
3584
  return [
3231
3585
  {
@@ -3241,7 +3595,7 @@ function readJsonWithComments(filePath) {
3241
3595
  let source;
3242
3596
  try {
3243
3597
  source = _fs2.default.readFileSync(filePath, "utf8");
3244
- } catch (e31) {
3598
+ } catch (e35) {
3245
3599
  return null;
3246
3600
  }
3247
3601
  let output = "";
@@ -3269,7 +3623,7 @@ function readJsonWithComments(filePath) {
3269
3623
  }
3270
3624
  try {
3271
3625
  return JSON.parse(output.replace(/,(\s*[}\]])/g, "$1"));
3272
- } catch (e32) {
3626
+ } catch (e36) {
3273
3627
  return null;
3274
3628
  }
3275
3629
  }
@@ -3291,15 +3645,15 @@ function resolvePackageModuleSourcePath(importerPath, specifier, root) {
3291
3645
  const packageJsonPath = _path2.default.join(packageDirectory, "package.json");
3292
3646
  const packageJson = readPackageJson(packageJsonPath);
3293
3647
  const exportKey = packageSubpath ? `./${packageSubpath}` : ".";
3294
- const exportTarget = resolvePackageExport(_optionalChain([packageJson, 'optionalAccess', _184 => _184.exports]), exportKey);
3648
+ const exportTarget = resolvePackageExport(_optionalChain([packageJson, 'optionalAccess', _213 => _213.exports]), exportKey);
3295
3649
  const candidates = /* @__PURE__ */ new Set();
3296
- if (_optionalChain([exportTarget, 'optionalAccess', _185 => _185.startsWith, 'call', _186 => _186("./")])) {
3650
+ if (_optionalChain([exportTarget, 'optionalAccess', _214 => _214.startsWith, 'call', _215 => _215("./")])) {
3297
3651
  candidates.add(_path2.default.resolve(packageDirectory, exportTarget));
3298
3652
  }
3299
3653
  if (packageSubpath) {
3300
3654
  candidates.add(_path2.default.join(packageDirectory, packageSubpath));
3301
3655
  } else {
3302
- for (const entry of [_optionalChain([packageJson, 'optionalAccess', _187 => _187.browser]), _optionalChain([packageJson, 'optionalAccess', _188 => _188.module]), _optionalChain([packageJson, 'optionalAccess', _189 => _189.main])]) {
3656
+ for (const entry of [_optionalChain([packageJson, 'optionalAccess', _216 => _216.browser]), _optionalChain([packageJson, 'optionalAccess', _217 => _217.module]), _optionalChain([packageJson, 'optionalAccess', _218 => _218.main])]) {
3303
3657
  if (typeof entry === "string") candidates.add(_path2.default.resolve(packageDirectory, entry));
3304
3658
  }
3305
3659
  candidates.add(_path2.default.join(packageDirectory, "index"));
@@ -3335,7 +3689,7 @@ function findPackageDirectory2(importerPath, packageName, root) {
3335
3689
  function readPackageJson(packageJsonPath) {
3336
3690
  try {
3337
3691
  return JSON.parse(_fs2.default.readFileSync(packageJsonPath, "utf8"));
3338
- } catch (e33) {
3692
+ } catch (e37) {
3339
3693
  return null;
3340
3694
  }
3341
3695
  }
@@ -3364,7 +3718,7 @@ function resolvePackageExport(exportsField, exportKey) {
3364
3718
  if (!exportKey.startsWith(prefix) || !exportKey.endsWith(suffix)) continue;
3365
3719
  const wildcard = exportKey.slice(prefix.length, exportKey.length - suffix.length);
3366
3720
  const target = resolveConditionalExportTarget(value);
3367
- return _nullishCoalesce(_optionalChain([target, 'optionalAccess', _190 => _190.replace, 'call', _191 => _191("*", wildcard)]), () => ( null));
3721
+ return _nullishCoalesce(_optionalChain([target, 'optionalAccess', _219 => _219.replace, 'call', _220 => _220("*", wildcard)]), () => ( null));
3368
3722
  }
3369
3723
  return null;
3370
3724
  }
@@ -3397,7 +3751,7 @@ function resolveSourceCandidate(candidates) {
3397
3751
  for (const sourcePath of paths) {
3398
3752
  try {
3399
3753
  if (_fs2.default.statSync(sourcePath).isFile()) return sourcePath;
3400
- } catch (e34) {
3754
+ } catch (e38) {
3401
3755
  }
3402
3756
  }
3403
3757
  }
@@ -3440,7 +3794,7 @@ function scanFarmPackageImports(directory, root) {
3440
3794
  let entries;
3441
3795
  try {
3442
3796
  entries = _fs2.default.readdirSync(current, { withFileTypes: true });
3443
- } catch (e35) {
3797
+ } catch (e39) {
3444
3798
  return;
3445
3799
  }
3446
3800
  for (const entry of entries) {
@@ -3473,7 +3827,7 @@ function collectFarmServerBundledPackageInfo(directory) {
3473
3827
  let entries;
3474
3828
  try {
3475
3829
  entries = _fs2.default.readdirSync(current, { withFileTypes: true });
3476
- } catch (e36) {
3830
+ } catch (e40) {
3477
3831
  return;
3478
3832
  }
3479
3833
  for (const entry of entries) {
@@ -3512,7 +3866,7 @@ function getFarmClientReachableModules(directory, root) {
3512
3866
  let entries;
3513
3867
  try {
3514
3868
  entries = _fs2.default.readdirSync(current, { withFileTypes: true });
3515
- } catch (e37) {
3869
+ } catch (e41) {
3516
3870
  return;
3517
3871
  }
3518
3872
  for (const entry of entries) {
@@ -3615,13 +3969,13 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3615
3969
  let projectRoot = process.cwd();
3616
3970
  let sources;
3617
3971
  const routeSourceFiles = () => {
3618
- const clientRoutes = _optionalChain([farmApi, 'optionalAccess', _192 => _192.getProgrammaticClientRoutes, 'call', _193 => _193()]);
3619
- if (_optionalChain([sources, 'optionalAccess', _194 => _194.for]) !== clientRoutes || !sources) {
3972
+ const clientRoutes = _optionalChain([farmApi, 'optionalAccess', _221 => _221.getProgrammaticClientRoutes, 'call', _222 => _222()]);
3973
+ if (_optionalChain([sources, 'optionalAccess', _223 => _223.for]) !== clientRoutes || !sources) {
3620
3974
  sources = {
3621
3975
  for: clientRoutes,
3622
3976
  files: /* @__PURE__ */ new Set([
3623
3977
  ...routesFiles,
3624
- ...[..._nullishCoalesce(_optionalChain([clientRoutes, 'optionalAccess', _195 => _195.routeSourceFiles]), () => ( []))].map(resolvedFile)
3978
+ ...[..._nullishCoalesce(_optionalChain([clientRoutes, 'optionalAccess', _224 => _224.routeSourceFiles]), () => ( []))].map(resolvedFile)
3625
3979
  ])
3626
3980
  };
3627
3981
  }
@@ -3634,7 +3988,7 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3634
3988
  configResolved(config) {
3635
3989
  isBuild = config.command === "build";
3636
3990
  projectRoot = config.root;
3637
- farmApi = _optionalChain([config, 'access', _196 => _196.plugins, 'access', _197 => _197.find, 'call', _198 => _198((plugin) => plugin.name === "farm"), 'optionalAccess', _199 => _199.api]);
3991
+ farmApi = _optionalChain([config, 'access', _225 => _225.plugins, 'access', _226 => _226.find, 'call', _227 => _227((plugin) => plugin.name === "farm"), 'optionalAccess', _228 => _228.api]);
3638
3992
  sources = void 0;
3639
3993
  routesFiles = new Set(
3640
3994
  _chunkMTBDJ326cjs.getFarmSourceRoots.call(void 0, { ...options, root: _nullishCoalesce(options.root, () => ( config.root)) }).flatMap(
@@ -3647,14 +4001,14 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3647
4001
  transform(code, id, transformOptions) {
3648
4002
  const environment = resolveBuildEnvironment(
3649
4003
  this,
3650
- _optionalChain([transformOptions, 'optionalAccess', _200 => _200.ssr])
4004
+ _optionalChain([transformOptions, 'optionalAccess', _229 => _229.ssr])
3651
4005
  );
3652
- const parse2 = (source) => this.parse(source);
3653
- const result = transformEnvironmentFunctions({ code, id, environment, parse: parse2 });
4006
+ const parse3 = (source) => this.parse(source);
4007
+ const result = transformEnvironmentFunctions({ code, id, environment, parse: parse3 });
3654
4008
  if (environment === "client" && !isBuild && !_chunkE7QOEV5Zcjs.parseProgrammaticRouteModuleId.call(void 0, id) && routeSourceFiles().has(moduleFile(id)) && !isProgrammaticRouteActionProxy(code)) {
3655
4009
  this.error(routeSourceError(moduleFile(id)));
3656
4010
  }
3657
- if (environment === "server" && _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([options, 'access', _201 => _201.experimental, 'optionalAccess', _202 => _202.serverComponents])) === "islands" && isApplicationScript(id)) {
4011
+ if (environment === "server" && _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([options, 'access', _230 => _230.experimental, 'optionalAccess', _231 => _231.serverComponents])) === "islands" && isApplicationScript(id)) {
3658
4012
  const file = id.split("?", 1)[0];
3659
4013
  const root = _fs.realpathSync.call(void 0, _nullishCoalesce(options.root, () => ( projectRoot)));
3660
4014
  const clientCode = getFarmClientReachableModules(root, root).has(_path2.default.resolve(file)) || _fs.existsSync.call(void 0, file) && hasUseClientDirective(_fs.readFileSync.call(void 0, file, "utf8"));
@@ -3675,7 +4029,7 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3675
4029
  for (const id of this.getModuleIds()) {
3676
4030
  if (_chunkE7QOEV5Zcjs.parseProgrammaticRouteModuleId.call(void 0, id)) {
3677
4031
  const chain = findClientNodeBuiltinChain(id, (moduleId) => {
3678
- return _optionalChain([this, 'access', _203 => _203.getModuleInfo, 'call', _204 => _204(moduleId), 'optionalAccess', _205 => _205.importedIds]);
4032
+ return _optionalChain([this, 'access', _232 => _232.getModuleInfo, 'call', _233 => _233(moduleId), 'optionalAccess', _234 => _234.importedIds]);
3679
4033
  });
3680
4034
  if (chain) {
3681
4035
  this.error(
@@ -3686,8 +4040,8 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3686
4040
  }
3687
4041
  if (!forbidden.has(moduleFile(id))) continue;
3688
4042
  const info = this.getModuleInfo(id);
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)])));
4043
+ if (isProgrammaticRouteActionProxy(_optionalChain([info, 'optionalAccess', _235 => _235.code]))) continue;
4044
+ this.error(routeSourceError(moduleFile(id), _optionalChain([info, 'optionalAccess', _236 => _236.importers, 'access', _237 => _237.map, 'call', _238 => _238(moduleFile)])));
3691
4045
  }
3692
4046
  }
3693
4047
  };
@@ -3701,13 +4055,13 @@ function moduleFile(id) {
3701
4055
  function resolvedFile(filePath) {
3702
4056
  try {
3703
4057
  return moduleFile(_fs.realpathSync.call(void 0, filePath));
3704
- } catch (e38) {
4058
+ } catch (e42) {
3705
4059
  return moduleFile(filePath);
3706
4060
  }
3707
4061
  }
3708
4062
  function resolveBuildEnvironment(context, 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") {
4063
+ if (_optionalChain([context, 'access', _239 => _239.environment, 'optionalAccess', _240 => _240.name]) === "client") return "client";
4064
+ if (_optionalChain([context, 'access', _241 => _241.environment, 'optionalAccess', _242 => _242.name]) === "rsc" || _optionalChain([context, 'access', _243 => _243.environment, 'optionalAccess', _244 => _244.name]) === "ssr") {
3711
4065
  return "server";
3712
4066
  }
3713
4067
  return ssr ? "server" : "client";
@@ -4011,4 +4365,14 @@ function transformError(id, message) {
4011
4365
 
4012
4366
 
4013
4367
 
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;
4368
+
4369
+
4370
+
4371
+
4372
+
4373
+
4374
+
4375
+
4376
+
4377
+
4378
+ 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.FarmSourceSnapshotStore = FarmSourceSnapshotStore; exports.withFarmSourceSnapshot = withFarmSourceSnapshot; exports.traceFarmSourceReads = traceFarmSourceReads; 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.farmIslandContainerReferencePath = farmIslandContainerReferencePath; exports.ensureFarmIslandContainerReference = ensureFarmIslandContainerReference; exports.wrapFarmIslandContainers = wrapFarmIslandContainers; exports.withPackageClientBoundaryCache = withPackageClientBoundaryCache; exports.usePackageClientBoundaryCacheFile = usePackageClientBoundaryCacheFile; exports.resolvePackageClientBoundaryCacheFile = resolvePackageClientBoundaryCacheFile; exports.runWithPackageClientBoundaryCacheFile = runWithPackageClientBoundaryCacheFile; exports.runWithLatestPackageClientBoundaryCache = runWithLatestPackageClientBoundaryCache; exports.dropLatestPackageClientBoundaryCache = dropLatestPackageClientBoundaryCache; exports.resolveModuleSourcePath = resolveModuleSourcePath; exports.getFarmClientHydrationPlanOptions = getFarmClientHydrationPlanOptions; exports.describeSuppressedAsyncHydration = describeSuppressedAsyncHydration; exports.resolveFarmIsolatedClientHydrationMode = resolveFarmIsolatedClientHydrationMode; exports.hasUseClientDirective = hasUseClientDirective; exports.getIslandStrategyExport = getIslandStrategyExport; exports.stripUseClientDirective = stripUseClientDirective; exports.getFarmClientRenderingBindings = getFarmClientRenderingBindings; 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.isFarmClientModulePlanUnchanged = isFarmClientModulePlanUnchanged; 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;