@farm.js/core 0.1.62 → 0.1.64

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 (194) hide show
  1. package/dist/{agent-mcp-handler-OV4WRFBL.cjs → agent-mcp-handler-OXT73ZBY.cjs} +5 -5
  2. package/dist/{agent-mcp-handler-7QMX2LUY.mjs → agent-mcp-handler-QLFDDTYN.mjs} +4 -4
  3. package/dist/{agent-mcp.d-BKZ3UNbt.d.mts → agent-mcp.d-CO_ABmNK.d.mts} +1 -1
  4. package/dist/{agent-mcp.d-C1zr_nGS.d.ts → agent-mcp.d-QD2WZ9BS.d.ts} +1 -1
  5. package/dist/agent-runtime.d.mts +1 -1
  6. package/dist/agent-runtime.d.ts +1 -1
  7. package/dist/analyzer-ODLF2Z6O.cjs +16 -0
  8. package/dist/{analyzer-YESYU3GK.mjs → analyzer-Q3QXC6PD.mjs} +3 -2
  9. package/dist/api/route-manager.d.mts +3 -3
  10. package/dist/api/route-manager.d.ts +3 -3
  11. package/dist/api/runtime.d.mts +2 -2
  12. package/dist/api/runtime.d.ts +2 -2
  13. package/dist/api.d.mts +3 -3
  14. package/dist/api.d.ts +3 -3
  15. package/dist/{app-manifest.d-ntch_bvA.d.ts → app-manifest.d-BpKxiU_E.d.mts} +9 -1
  16. package/dist/{app-manifest.d-BpvhfKRH.d.mts → app-manifest.d-DDmNkYQQ.d.ts} +9 -1
  17. package/dist/app-markdown.cjs +4 -4
  18. package/dist/app-markdown.d.mts +2 -2
  19. package/dist/app-markdown.d.ts +2 -2
  20. package/dist/app-markdown.mjs +3 -3
  21. package/dist/{app.d-CysWA_8v.d.mts → app.d-kuoVWhWM.d.mts} +4 -4
  22. package/dist/{app.d-AE8_v3Db.d.ts → app.d-x68Cwr0_.d.ts} +4 -4
  23. package/dist/{chunk-LT4VAF5Z.cjs → chunk-2C5L5RPM.cjs} +7 -6
  24. package/dist/{chunk-RMUD75WT.cjs → chunk-3EBHJET2.cjs} +355 -270
  25. package/dist/{chunk-RZNCMRD3.mjs → chunk-6NHSGVVA.mjs} +1 -1
  26. package/dist/{chunk-LVWGURLD.mjs → chunk-6NNYPY5W.mjs} +327 -13
  27. package/dist/{chunk-PRFNLQSP.cjs → chunk-7XGWBPQQ.cjs} +4 -4
  28. package/dist/{chunk-SG57PX7K.cjs → chunk-BTVDYS4B.cjs} +7 -2
  29. package/dist/{chunk-545WJ5UG.cjs → chunk-DUSHDZQL.cjs} +11 -11
  30. package/dist/{chunk-GVOMPU3Y.cjs → chunk-EL4364S2.cjs} +209 -32
  31. package/dist/{chunk-GGNJAGGE.cjs → chunk-FAP7CX7C.cjs} +1056 -529
  32. package/dist/{chunk-T46NNU4D.mjs → chunk-FH45OB37.mjs} +2 -2
  33. package/dist/{chunk-55U5QIXQ.mjs → chunk-FIR62CR3.mjs} +1 -1
  34. package/dist/{chunk-MEQN6DDA.cjs → chunk-FJWN7RV4.cjs} +5 -5
  35. package/dist/chunk-IOEXXZK3.mjs +88 -0
  36. package/dist/{chunk-EXXFSZOC.cjs → chunk-JCPSA4X5.cjs} +135 -134
  37. package/dist/{chunk-YSXTNSXS.mjs → chunk-K7OZAVOI.mjs} +7 -6
  38. package/dist/{chunk-KVW2M6PI.mjs → chunk-KL7SHLQB.mjs} +1 -1
  39. package/dist/{chunk-NT3QDN2E.mjs → chunk-LQDLEWPO.mjs} +1 -1
  40. package/dist/{chunk-UZZ6IEQP.mjs → chunk-MESQF2JC.mjs} +2 -2
  41. package/dist/{chunk-WKJQ2FJA.cjs → chunk-MG356ROI.cjs} +5 -5
  42. package/dist/{chunk-AJB3DHN6.cjs → chunk-N3Z3PLHC.cjs} +2 -2
  43. package/dist/{chunk-2CNKQC3G.mjs → chunk-NNLFW3P4.mjs} +2 -2
  44. package/dist/{chunk-XX32BOMM.cjs → chunk-NXFA7G3Y.cjs} +52 -26
  45. package/dist/{chunk-SM25ZC4S.cjs → chunk-O2XFIPNL.cjs} +1 -1
  46. package/dist/{chunk-VWW4Q3BJ.mjs → chunk-O4FWNLQK.mjs} +4 -4
  47. package/dist/{chunk-DZPR2W6U.cjs → chunk-O6L3YYPM.cjs} +5 -5
  48. package/dist/{chunk-UWI3SJAK.cjs → chunk-O7IEMY55.cjs} +3 -3
  49. package/dist/{chunk-6BJJYOFL.cjs → chunk-OLIGNTWU.cjs} +7 -7
  50. package/dist/{chunk-OUWRNHTV.mjs → chunk-OYF23QLG.mjs} +17 -16
  51. package/dist/{chunk-IQIKPKFP.mjs → chunk-RAH5MT53.mjs} +110 -25
  52. package/dist/{chunk-E72UD6ME.mjs → chunk-RVGSVQWT.mjs} +1 -1
  53. package/dist/{chunk-ZVIEFTUA.cjs → chunk-S25BQIFW.cjs} +16 -16
  54. package/dist/chunk-S7ZW72JH.cjs +254 -0
  55. package/dist/{chunk-VM7X5CKC.mjs → chunk-SLYDIHLW.mjs} +31 -5
  56. package/dist/chunk-SNFTMSHX.mjs +254 -0
  57. package/dist/{chunk-2WZTGPK6.mjs → chunk-SQ5O7I3L.mjs} +7 -2
  58. package/dist/{chunk-PCXIJKPM.mjs → chunk-TNBJ4LZG.mjs} +2 -2
  59. package/dist/{chunk-O27PLNQZ.cjs → chunk-UJ3R2AH2.cjs} +4 -4
  60. package/dist/{chunk-T4TBK5NY.mjs → chunk-VQ4NWOWO.mjs} +2 -2
  61. package/dist/{chunk-ZZ2QKCKW.mjs → chunk-WAY6LOQH.mjs} +1 -1
  62. package/dist/chunk-WBTHHTBO.cjs +88 -0
  63. package/dist/{chunk-ZBUAOGMY.mjs → chunk-WFNAOWH4.mjs} +1 -1
  64. package/dist/{chunk-IWRLV46X.cjs → chunk-WMTBBQHY.cjs} +4 -4
  65. package/dist/{chunk-2JYBLE63.mjs → chunk-WNYRYI4D.mjs} +770 -243
  66. package/dist/{chunk-CI4UNQHO.cjs → chunk-XBSKPLHF.cjs} +2 -2
  67. package/dist/{chunk-IOF4KXMP.mjs → chunk-XVWSDSUM.mjs} +201 -24
  68. package/dist/{chunk-JEJQGZI7.cjs → chunk-XZLZ6YPP.cjs} +346 -32
  69. package/dist/{chunk-QAS7KE7J.cjs → chunk-Y5TOT5F6.cjs} +5 -5
  70. package/dist/{chunk-DPE53XWL.mjs → chunk-ZEXE4TGY.mjs} +1 -1
  71. package/dist/{client-component.d-BoqC2MLC.d.mts → client-component.d-D74pqdea.d.mts} +14 -3
  72. package/dist/{client-component.d-Bgt3x5Fu.d.ts → client-component.d-D8VcypQA.d.ts} +14 -3
  73. package/dist/{client-plugins.d-BcqIy4au.d.ts → client-plugins.d-CXElzotB.d.ts} +18 -2
  74. package/dist/{client-plugins.d-CWyYBxXf.d.mts → client-plugins.d-D4-6hNx7.d.mts} +18 -2
  75. package/dist/client-plugins.d.mts +1 -1
  76. package/dist/client-plugins.d.ts +1 -1
  77. package/dist/client.d.mts +6 -6
  78. package/dist/client.d.ts +6 -6
  79. package/dist/config.d.mts +1 -1
  80. package/dist/config.d.ts +1 -1
  81. package/dist/desktop.d.mts +2 -2
  82. package/dist/desktop.d.ts +2 -2
  83. package/dist/{devtools-NUVXYG7I.mjs → devtools-MX3FE733.mjs} +5 -5
  84. package/dist/{devtools-SVRSGPNC.cjs → devtools-WET5NAKO.cjs} +6 -6
  85. package/dist/docs.cjs +8 -8
  86. package/dist/docs.d.mts +2 -2
  87. package/dist/docs.d.ts +2 -2
  88. package/dist/docs.mjs +7 -7
  89. package/dist/index.cjs +21 -20
  90. package/dist/{index.d-nAncqTXz.d.ts → index.d-A_x10zGS.d.ts} +1 -1
  91. package/dist/{index.d-BDaiu2i5.d.mts → index.d-SSgYDv4D.d.mts} +1 -1
  92. package/dist/index.d.mts +16 -16
  93. package/dist/index.d.ts +16 -16
  94. package/dist/index.mjs +20 -19
  95. package/dist/integrations.d.mts +1 -1
  96. package/dist/integrations.d.ts +1 -1
  97. package/dist/internal/app-markdown-runtime.cjs +3 -3
  98. package/dist/internal/app-markdown-runtime.d.mts +2 -2
  99. package/dist/internal/app-markdown-runtime.d.ts +2 -2
  100. package/dist/internal/app-markdown-runtime.mjs +2 -2
  101. package/dist/internal/build-runtime.cjs +22 -21
  102. package/dist/internal/build-runtime.d.mts +3 -3
  103. package/dist/internal/build-runtime.d.ts +3 -3
  104. package/dist/internal/build-runtime.mjs +21 -20
  105. package/dist/internal/cli-runtime.cjs +7 -7
  106. package/dist/internal/cli-runtime.mjs +6 -6
  107. package/dist/internal/client-error-overlay.cjs +4 -4
  108. package/dist/internal/client-error-overlay.mjs +1 -1
  109. package/dist/internal/client-runtime.d.mts +4 -4
  110. package/dist/internal/client-runtime.d.ts +4 -4
  111. package/dist/internal/compression-runtime.d.mts +1 -1
  112. package/dist/internal/compression-runtime.d.ts +1 -1
  113. package/dist/internal/config-runtime.cjs +7 -7
  114. package/dist/internal/config-runtime.d.mts +4 -4
  115. package/dist/internal/config-runtime.d.ts +4 -4
  116. package/dist/internal/config-runtime.mjs +6 -6
  117. package/dist/internal/infra-analytics-runtime.cjs +11 -9
  118. package/dist/internal/infra-analytics-runtime.mjs +9 -7
  119. package/dist/internal/native-server-fns.cjs +5 -4
  120. package/dist/internal/native-server-fns.mjs +4 -3
  121. package/dist/internal/product-telemetry-runtime.cjs +17 -211
  122. package/dist/internal/product-telemetry-runtime.mjs +10 -204
  123. package/dist/internal/production-runtime.cjs +13 -12
  124. package/dist/internal/production-runtime.d.mts +13 -12
  125. package/dist/internal/production-runtime.d.ts +13 -12
  126. package/dist/internal/production-runtime.mjs +14 -13
  127. package/dist/internal/react-cache.cjs +21 -1
  128. package/dist/internal/react-cache.d.mts +8 -1
  129. package/dist/internal/react-cache.d.ts +8 -1
  130. package/dist/internal/react-cache.mjs +21 -1
  131. package/dist/markdown.cjs +2 -2
  132. package/dist/markdown.d.mts +1 -1
  133. package/dist/markdown.d.ts +1 -1
  134. package/dist/markdown.mjs +1 -1
  135. package/dist/middleware.d.mts +3 -3
  136. package/dist/middleware.d.ts +3 -3
  137. package/dist/mobile.d.mts +2 -2
  138. package/dist/mobile.d.ts +2 -2
  139. package/dist/{native-tree-AS5L3ID3.mjs → native-tree-BPEE2LAL.mjs} +2 -2
  140. package/dist/{native-tree-Z2WYUJEV.cjs → native-tree-WOX3JMBG.cjs} +3 -3
  141. package/dist/{navigation-delegate.d-CSCm8ZxL.d.mts → navigation-delegate.d-DQVYKoaZ.d.mts} +1 -1
  142. package/dist/{navigation-delegate.d-BbUHRXxG.d.ts → navigation-delegate.d-GghbHJuK.d.ts} +1 -1
  143. package/dist/navigation.d.mts +4 -4
  144. package/dist/navigation.d.ts +4 -4
  145. package/dist/plugin.cjs +14 -14
  146. package/dist/plugin.d.mts +3 -3
  147. package/dist/plugin.d.ts +3 -3
  148. package/dist/plugin.mjs +13 -13
  149. package/dist/{production-runtime.d-DgT24A0f.d.ts → production-runtime.d-Bzns3NW9.d.ts} +1 -1
  150. package/dist/{production-runtime.d-CcQiDko5.d.mts → production-runtime.d-DiFa5vHW.d.mts} +1 -1
  151. package/dist/{render-plan.d-CyrX6MDs.d.ts → render-plan.d-CL_Ikfg_.d.ts} +1 -1
  152. package/dist/{render-plan.d-BH9WF-JZ.d.mts → render-plan.d-CcF0MeCf.d.mts} +1 -1
  153. package/dist/renderer-client.d.mts +4 -4
  154. package/dist/renderer-client.d.ts +4 -4
  155. package/dist/{request.d-BB8M8bcD.d.ts → request.d-B1RnTLri.d.ts} +1 -1
  156. package/dist/{request.d-CUrPnCW7.d.mts → request.d-DarDOCk9.d.mts} +1 -1
  157. package/dist/request.d.mts +2 -2
  158. package/dist/request.d.ts +2 -2
  159. package/dist/{route-rendering.d-DYqZMIf4.d.ts → route-rendering.d-BTUYCIj4.d.ts} +1 -1
  160. package/dist/{route-rendering.d-CYxlzaFm.d.mts → route-rendering.d-D_2Ual0-.d.mts} +1 -1
  161. package/dist/{router.d-DaKo507j.d.ts → router.d-CMANF6da.d.ts} +1 -1
  162. package/dist/{router.d-7o24CD8u.d.mts → router.d-Cuv1jntg.d.mts} +1 -1
  163. package/dist/{routes.d-BknKQcTu.d.ts → routes.d-B6yFe6jm.d.ts} +1 -1
  164. package/dist/{routes.d-D1IrO9KK.d.mts → routes.d-c2HKfrfL.d.mts} +1 -1
  165. package/dist/routes.d.mts +1 -1
  166. package/dist/routes.d.ts +1 -1
  167. package/dist/{rsc-pipeline-RFLHDAKD.mjs → rsc-pipeline-3LNVP2OO.mjs} +6 -6
  168. package/dist/{rsc-pipeline-OF2I7PCX.cjs → rsc-pipeline-G5WELVW3.cjs} +7 -7
  169. package/dist/{runtime-LBTK62AD.cjs → runtime-DMEULPE7.cjs} +22 -11
  170. package/dist/{runtime-M6UJCSLA.mjs → runtime-HQJ2LLQL.mjs} +20 -9
  171. package/dist/{runtime.d-CN73a-IL.d.ts → runtime.d-C3RQUj6_.d.ts} +1 -1
  172. package/dist/{runtime.d-CcNuzhX6.d.mts → runtime.d-wvh4ngU0.d.mts} +1 -1
  173. package/dist/server-plugins.d.mts +2 -2
  174. package/dist/server-plugins.d.ts +2 -2
  175. package/dist/server.cjs +31 -31
  176. package/dist/server.d.mts +9 -9
  177. package/dist/server.d.ts +9 -9
  178. package/dist/server.mjs +16 -16
  179. package/dist/{spa-router.d-CNi77LZm.d.mts → spa-router.d-WU_qS5gJ.d.mts} +2 -2
  180. package/dist/{spa-router.d-Cvgf5QP4.d.ts → spa-router.d-m8H_Kl_B.d.ts} +2 -2
  181. package/dist/testing.d.mts +1 -1
  182. package/dist/testing.d.ts +1 -1
  183. package/dist/{utils.d-C3H-14_Y.d.ts → utils.d-C9dQD5Zg.d.ts} +1 -1
  184. package/dist/{utils.d-D8VfzZYn.d.mts → utils.d-W9IiEqmW.d.mts} +1 -1
  185. package/dist/version.cjs +2 -2
  186. package/dist/version.mjs +1 -1
  187. package/dist/vite.cjs +18 -14
  188. package/dist/vite.d.mts +23 -5
  189. package/dist/vite.d.ts +23 -5
  190. package/dist/vite.mjs +17 -13
  191. package/package.json +1 -1
  192. package/dist/analyzer-2AHWJJR7.cjs +0 -15
  193. package/dist/chunk-CSLUBKGG.mjs +0 -44
  194. package/dist/chunk-SGBNF56S.cjs +0 -44
@@ -35,13 +35,13 @@ import {
35
35
  renderFarmLocaleAlternateLinks,
36
36
  resolveDefaultErrorStatus,
37
37
  routeBoundaryCoversDirectory
38
- } from "./chunk-PCXIJKPM.mjs";
38
+ } from "./chunk-TNBJ4LZG.mjs";
39
39
  import {
40
40
  handleFarmFormActionRequest
41
41
  } from "./chunk-MK5E44WP.mjs";
42
42
  import {
43
43
  listFarmMCPLlmsTxtLinks
44
- } from "./chunk-VM7X5CKC.mjs";
44
+ } from "./chunk-SLYDIHLW.mjs";
45
45
  import {
46
46
  FARM_DEFAULT_MCP_PATH,
47
47
  collectFarmDefaultMCPPages,
@@ -49,7 +49,7 @@ import {
49
49
  farmConfigMountsMCP,
50
50
  isFarmDefaultMCPPathname,
51
51
  resolveFarmDefaultMCPServer
52
- } from "./chunk-UZZ6IEQP.mjs";
52
+ } from "./chunk-MESQF2JC.mjs";
53
53
  import {
54
54
  installFarmIslandValues,
55
55
  uninstallFarmIslandValues
@@ -96,7 +96,7 @@ import {
96
96
  resolveFarmAgentCrawlers,
97
97
  resolveFarmAgentSitemap,
98
98
  resolveFarmPerformanceConfig
99
- } from "./chunk-T4TBK5NY.mjs";
99
+ } from "./chunk-VQ4NWOWO.mjs";
100
100
  import {
101
101
  createFarmCspNonce,
102
102
  createFarmCspNonceRewriter,
@@ -111,7 +111,7 @@ import {
111
111
  createFarmLlmsMarkdownReader,
112
112
  renderFarmLlmsFullTxt,
113
113
  resolveFarmLlmsTxtConfig
114
- } from "./chunk-KVW2M6PI.mjs";
114
+ } from "./chunk-KL7SHLQB.mjs";
115
115
  import {
116
116
  getFarmAppDirectories,
117
117
  getFarmSourceRoots
@@ -122,10 +122,10 @@ import {
122
122
  import {
123
123
  createFarmMarkdownRouteModuleFromFile,
124
124
  loadFarmMdxComponents
125
- } from "./chunk-55U5QIXQ.mjs";
125
+ } from "./chunk-FIR62CR3.mjs";
126
126
  import {
127
127
  isFarmMarkdownPageFile
128
- } from "./chunk-E72UD6ME.mjs";
128
+ } from "./chunk-RVGSVQWT.mjs";
129
129
  import {
130
130
  resolveFarmMdxComponentsModulePath,
131
131
  resolveMdxConfig
@@ -138,7 +138,7 @@ import {
138
138
  farmRequestWantsMarkdown,
139
139
  getFarmMarkdownAlternatePath,
140
140
  resolveMarkdownConfig
141
- } from "./chunk-YSXTNSXS.mjs";
141
+ } from "./chunk-K7OZAVOI.mjs";
142
142
  import {
143
143
  resolveWorkflowsConfig
144
144
  } from "./chunk-TZVUF5JJ.mjs";
@@ -256,7 +256,7 @@ import {
256
256
  } from "./chunk-D2LCAV6L.mjs";
257
257
  import {
258
258
  FARM_VERSION
259
- } from "./chunk-NT3QDN2E.mjs";
259
+ } from "./chunk-LQDLEWPO.mjs";
260
260
  import {
261
261
  resolveFarmTrailingSlashRedirect,
262
262
  setFarmTrailingSlashPreference
@@ -327,12 +327,171 @@ import {
327
327
  getRoutePatternShape
328
328
  } from "./chunk-AYP2YFVN.mjs";
329
329
 
330
- // src/islands-package-references.ts
330
+ // src/islands-react-server-exports.ts
331
331
  import fs from "fs";
332
332
  import path from "path";
333
333
  import { parseAst } from "rolldown/parseAst";
334
- var IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
335
- function parse(code, file) {
334
+ var REACT_PACKAGES = /* @__PURE__ */ new Set([
335
+ "react",
336
+ "react-dom",
337
+ "scheduler",
338
+ "react-server-dom-webpack",
339
+ "react-server-dom-esm",
340
+ "react-server-dom-turbopack"
341
+ ]);
342
+ var SERVER_CONDITIONS = ["react-server", "node", "import", "module", "default"];
343
+ var DEFAULT_CONDITIONS = ["node", "import", "module", "default"];
344
+ var SCRIPT_EXTENSIONS = ["", ".js", ".mjs", ".cjs", ".jsx", ".ts", ".tsx", ".mts"];
345
+ var INDEX_FILES = ["index.js", "index.mjs", "index.cjs", "index.ts", "index.tsx"];
346
+ function packageNameOf(specifier) {
347
+ if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("#") || specifier.includes(":") || specifier.includes("\0")) {
348
+ return null;
349
+ }
350
+ const parts = specifier.split("/");
351
+ const name = specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
352
+ if (!name || specifier.startsWith("@") && parts.length < 2) return null;
353
+ return { name, subpath: parts.slice(name.startsWith("@") ? 2 : 1).join("/") };
354
+ }
355
+ function findPackageDirectory(importer, name) {
356
+ for (let current = path.dirname(importer); ; current = path.dirname(current)) {
357
+ const directory = path.join(current, "node_modules", name);
358
+ if (fs.existsSync(path.join(directory, "package.json"))) return fs.realpathSync(directory);
359
+ if (path.dirname(current) === current) return null;
360
+ }
361
+ }
362
+ function pickTarget(value, conditions) {
363
+ if (typeof value === "string") return value;
364
+ if (Array.isArray(value)) {
365
+ for (const entry of value) {
366
+ const target = pickTarget(entry, conditions);
367
+ if (target) return target;
368
+ }
369
+ return null;
370
+ }
371
+ if (!value || typeof value !== "object") return null;
372
+ for (const [key, entry] of Object.entries(value)) {
373
+ if (key === "types" || !conditions.includes(key)) continue;
374
+ const target = pickTarget(entry, conditions);
375
+ if (target) return target;
376
+ }
377
+ return null;
378
+ }
379
+ function exportEntry(exportsField, subpath) {
380
+ const key = subpath ? `./${subpath}` : ".";
381
+ if (typeof exportsField === "string" || Array.isArray(exportsField)) {
382
+ return key === "." ? exportsField : void 0;
383
+ }
384
+ if (!exportsField || typeof exportsField !== "object") return void 0;
385
+ const entries = exportsField;
386
+ if (!Object.keys(entries).some((entry) => entry.startsWith("."))) {
387
+ return key === "." ? entries : void 0;
388
+ }
389
+ if (entries[key] !== void 0) return entries[key];
390
+ for (const [pattern, value] of Object.entries(entries)) {
391
+ const star = pattern.indexOf("*");
392
+ if (star === -1) continue;
393
+ const prefix = pattern.slice(0, star);
394
+ const suffix = pattern.slice(star + 1);
395
+ if (key.startsWith(prefix) && key.endsWith(suffix)) {
396
+ const match = key.slice(prefix.length, key.length - suffix.length);
397
+ const replace = (target) => typeof target === "string" ? target.replace("*", match) : target && typeof target === "object" && !Array.isArray(target) ? Object.fromEntries(
398
+ Object.entries(target).map(([k, v]) => [k, replace(v)])
399
+ ) : target;
400
+ return replace(value);
401
+ }
402
+ }
403
+ return void 0;
404
+ }
405
+ var cache = /* @__PURE__ */ new Map();
406
+ function resolveFarmReactServerExport(importer, specifier) {
407
+ const parsed = packageNameOf(specifier);
408
+ if (!parsed || REACT_PACKAGES.has(parsed.name) || parsed.name.startsWith("@farm.js/"))
409
+ return null;
410
+ const directory = findPackageDirectory(importer, parsed.name);
411
+ if (!directory) return null;
412
+ const key = `${directory}\0${parsed.subpath}`;
413
+ if (cache.has(key)) return cache.get(key);
414
+ let resolved = null;
415
+ try {
416
+ const manifest = JSON.parse(fs.readFileSync(path.join(directory, "package.json"), "utf8"));
417
+ const entry = exportEntry(manifest.exports, parsed.subpath);
418
+ const server = pickTarget(entry, SERVER_CONDITIONS);
419
+ const fallback = pickTarget(entry, DEFAULT_CONDITIONS);
420
+ if (server && server !== fallback && server.startsWith("./")) {
421
+ const file = path.resolve(directory, server);
422
+ if (fs.existsSync(file)) resolved = file;
423
+ }
424
+ } catch {
425
+ resolved = null;
426
+ }
427
+ cache.set(key, resolved);
428
+ return resolved;
429
+ }
430
+ function readModule(file) {
431
+ try {
432
+ const code = fs.readFileSync(file, "utf8");
433
+ const extension = path.extname(file).slice(1);
434
+ const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
435
+ return parseAst(code, { lang });
436
+ } catch {
437
+ return null;
438
+ }
439
+ }
440
+ function isClientModule(program) {
441
+ for (const node of program.body ?? []) {
442
+ if (node.type !== "ExpressionStatement" || typeof node.directive !== "string") break;
443
+ if (node.directive === "use client") return true;
444
+ }
445
+ return false;
446
+ }
447
+ function resolveRelative(from, specifier) {
448
+ const base = path.resolve(path.dirname(from), specifier);
449
+ for (const extension of SCRIPT_EXTENSIONS) {
450
+ const file = `${base}${extension}`;
451
+ if (fs.existsSync(file) && fs.statSync(file).isFile()) return file;
452
+ }
453
+ for (const index of INDEX_FILES) {
454
+ const file = path.join(base, index);
455
+ if (fs.existsSync(file)) return file;
456
+ }
457
+ return null;
458
+ }
459
+ function exportedName(node) {
460
+ return node?.type === "Identifier" ? node.name : node?.value;
461
+ }
462
+ function isFarmClientExport(file, name, depth = 0) {
463
+ if (depth > 6) return false;
464
+ const program = readModule(file);
465
+ if (!program) return false;
466
+ if (isClientModule(program)) return true;
467
+ const stars = [];
468
+ for (const node of program.body ?? []) {
469
+ if (node.type === "ExportNamedDeclaration" && node.source) {
470
+ for (const specifier of node.specifiers ?? []) {
471
+ if (exportedName(specifier.exported) !== name) continue;
472
+ const target = resolveRelative(file, node.source.value);
473
+ return target ? isFarmClientExport(target, exportedName(specifier.local) ?? name, depth + 1) : false;
474
+ }
475
+ } else if (node.type === "ExportAllDeclaration" && node.source && !node.exported) {
476
+ stars.push(node.source.value);
477
+ } else if (node.type === "ExportNamedDeclaration" && !node.source) {
478
+ const names = [
479
+ ...(node.specifiers ?? []).map((specifier) => exportedName(specifier.exported)),
480
+ ...node.declaration?.id ? [node.declaration.id.name] : [],
481
+ ...(node.declaration?.declarations ?? []).map((declarator) => declarator.id?.name)
482
+ ];
483
+ if (names.includes(name)) return false;
484
+ } else if (node.type === "ExportDefaultDeclaration" && name === "default") {
485
+ return false;
486
+ }
487
+ }
488
+ for (const source of stars) {
489
+ const target = resolveRelative(file, source);
490
+ if (target && isFarmClientExport(target, name, depth + 1)) return true;
491
+ }
492
+ return false;
493
+ }
494
+ function parseCode(code, file) {
336
495
  const extension = path.extname(file).slice(1);
337
496
  const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
338
497
  try {
@@ -341,6 +500,280 @@ function parse(code, file) {
341
500
  return null;
342
501
  }
343
502
  }
503
+ function namespaceMembers(program, local) {
504
+ const members = /* @__PURE__ */ new Set();
505
+ let opaque = false;
506
+ const visit = (node, parent) => {
507
+ if (opaque || !node || typeof node !== "object") return;
508
+ if (Array.isArray(node)) {
509
+ for (const child of node) visit(child, parent);
510
+ return;
511
+ }
512
+ const current = node;
513
+ if (typeof current.type !== "string") return;
514
+ if ((current.type === "Identifier" || current.type === "JSXIdentifier") && current.name === local && parent?.type !== "ImportNamespaceSpecifier") {
515
+ const property2 = (parent?.type === "MemberExpression" || parent?.type === "JSXMemberExpression") && parent.object === current && !parent.computed ? parent.property?.name : void 0;
516
+ if (property2) members.add(property2);
517
+ else opaque = true;
518
+ return;
519
+ }
520
+ for (const [key, value] of Object.entries(current)) {
521
+ if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
522
+ if (value && typeof value === "object") visit(value, current);
523
+ }
524
+ };
525
+ visit(program, null);
526
+ return opaque ? null : [...members];
527
+ }
528
+ function findPackageImports(program, accept) {
529
+ const found = [];
530
+ for (const node of program.body ?? []) {
531
+ if (node.type !== "ImportDeclaration" || node.importKind === "type") continue;
532
+ const specifier = node.source?.value;
533
+ if (typeof specifier !== "string" || !accept(specifier)) continue;
534
+ const specifiers = (node.specifiers ?? []).filter(
535
+ (entry2) => entry2.importKind !== "type"
536
+ );
537
+ if ((node.specifiers ?? []).length > 0 && specifiers.length === 0) continue;
538
+ const entry = {
539
+ start: node.start,
540
+ end: node.end,
541
+ specifier,
542
+ sideEffect: specifiers.length === 0,
543
+ named: []
544
+ };
545
+ for (const binding of specifiers) {
546
+ if (binding.type === "ImportDefaultSpecifier") entry.defaultLocal = binding.local.name;
547
+ else if (binding.type === "ImportNamespaceSpecifier") {
548
+ entry.namespace = {
549
+ local: binding.local.name,
550
+ members: namespaceMembers(program, binding.local.name)
551
+ };
552
+ } else {
553
+ const imported = exportedName(binding.imported);
554
+ if (imported) entry.named.push({ imported, local: binding.local.name });
555
+ }
556
+ }
557
+ found.push(entry);
558
+ }
559
+ return found;
560
+ }
561
+ function findFarmReactServerClientNames(code, file, specifier) {
562
+ const target = resolveFarmReactServerExport(file, specifier);
563
+ if (!target) return null;
564
+ const program = parseCode(code, file);
565
+ if (!program) return null;
566
+ const names = /* @__PURE__ */ new Set();
567
+ for (const entry of findPackageImports(program, (candidate) => candidate === specifier)) {
568
+ const wanted = [
569
+ ...entry.defaultLocal ? ["default"] : [],
570
+ ...entry.named.map((binding) => binding.imported),
571
+ ...entry.namespace?.members ?? []
572
+ ];
573
+ for (const name of wanted) if (isFarmClientExport(target, name)) names.add(name);
574
+ }
575
+ return [...names];
576
+ }
577
+ function rewriteFarmReactServerImports(options) {
578
+ if (!options.code.includes("import")) return null;
579
+ const program = parseCode(options.code, options.file);
580
+ if (!program) return null;
581
+ const targets = /* @__PURE__ */ new Map();
582
+ const imports = findPackageImports(program, (specifier) => {
583
+ const target = resolveFarmReactServerExport(options.file, specifier);
584
+ if (target) targets.set(specifier, target);
585
+ return target !== null;
586
+ });
587
+ if (imports.length === 0) return null;
588
+ let output = options.code;
589
+ let next = 0;
590
+ for (const entry of [...imports].sort((left, right) => right.start - left.start)) {
591
+ const target = targets.get(entry.specifier);
592
+ options.onServerFile?.(target);
593
+ const server = JSON.stringify(target);
594
+ const lines = [];
595
+ const bind = (name, local) => {
596
+ if (isFarmClientExport(target, name)) {
597
+ lines.push(
598
+ `import { ${name} as ${local} } from ${JSON.stringify(options.reference(entry.specifier, name))};`
599
+ );
600
+ } else lines.push(`import { ${name} as ${local} } from ${server};`);
601
+ };
602
+ if (entry.sideEffect) lines.push(`import ${server};`);
603
+ if (entry.defaultLocal) bind("default", entry.defaultLocal);
604
+ for (const binding of entry.named) bind(binding.imported, binding.local);
605
+ if (entry.namespace) {
606
+ if (entry.namespace.members === null) {
607
+ lines.push(`import * as ${entry.namespace.local} from ${server};`);
608
+ } else {
609
+ const fields = [];
610
+ for (const member of entry.namespace.members) {
611
+ const local = `__farm_react_server_${next++}__`;
612
+ bind(member, local);
613
+ fields.push(`${member}: ${local}`);
614
+ }
615
+ lines.push(`const ${entry.namespace.local} = Object.freeze({ ${fields.join(", ")} });`);
616
+ }
617
+ }
618
+ output = output.slice(0, entry.start) + lines.join("\n") + output.slice(entry.end);
619
+ }
620
+ return output;
621
+ }
622
+ function farmRelativeImportFiles(code, file) {
623
+ const program = parseCode(code, file);
624
+ if (!program) return [];
625
+ const files = [];
626
+ for (const node of program.body ?? []) {
627
+ const source = (node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source) && node.source?.value;
628
+ if (typeof source !== "string" || !source.startsWith(".")) continue;
629
+ const resolved = resolveRelative(file, source);
630
+ if (resolved) files.push(resolved);
631
+ }
632
+ return files;
633
+ }
634
+ function farmReactServerBuildReachesClientModules(importer, specifier) {
635
+ const target = resolveFarmReactServerExport(importer, specifier);
636
+ if (!target) return false;
637
+ const seen = /* @__PURE__ */ new Set();
638
+ const reaches = (file, depth) => {
639
+ if (depth > 6 || seen.has(file)) return false;
640
+ seen.add(file);
641
+ const program = readModule(file);
642
+ if (!program) return false;
643
+ if (depth > 0 && isClientModule(program)) return true;
644
+ for (const node of program.body ?? []) {
645
+ const source = (node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration" && node.source || node.type === "ImportDeclaration") && node.source?.value;
646
+ if (typeof source !== "string" || !source.startsWith(".")) continue;
647
+ const child = resolveRelative(file, source);
648
+ if (child && reaches(child, depth + 1)) return true;
649
+ }
650
+ return false;
651
+ };
652
+ return reaches(target, 0);
653
+ }
654
+ var IMPORT_SPECIFIER = /(?:\bfrom\s*|\bimport\s*\(?\s*)["']([^"'./][^"']*)["']/g;
655
+ var MAX_SCANNED_FILES = 2e3;
656
+ function packageImportSpecifiers(directory) {
657
+ const found = /* @__PURE__ */ new Set();
658
+ const pending = [directory];
659
+ let scanned = 0;
660
+ while (pending.length > 0 && scanned < MAX_SCANNED_FILES) {
661
+ const current = pending.pop();
662
+ let entries;
663
+ try {
664
+ entries = fs.readdirSync(current, { withFileTypes: true });
665
+ } catch {
666
+ continue;
667
+ }
668
+ for (const entry of entries) {
669
+ if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
670
+ const file = path.join(current, entry.name);
671
+ if (entry.isDirectory()) pending.push(file);
672
+ else if (/\.(?:m?js|jsx)$/.test(entry.name) && scanned++ < MAX_SCANNED_FILES) {
673
+ let code;
674
+ try {
675
+ code = fs.readFileSync(file, "utf8");
676
+ } catch {
677
+ continue;
678
+ }
679
+ for (const match of code.matchAll(IMPORT_SPECIFIER)) found.add(match[1]);
680
+ }
681
+ }
682
+ }
683
+ return found;
684
+ }
685
+ function findFarmPackageManifest(importer, specifier) {
686
+ const parsed = packageNameOf(specifier);
687
+ if (!parsed) return null;
688
+ const directory = findPackageDirectory(importer, parsed.name);
689
+ if (!directory) return null;
690
+ let names;
691
+ try {
692
+ const manifest = JSON.parse(fs.readFileSync(path.join(directory, "package.json"), "utf8"));
693
+ names = new Set(Object.keys(manifest.dependencies ?? {}));
694
+ } catch {
695
+ return null;
696
+ }
697
+ const dependencies = [...packageImportSpecifiers(directory)].filter((imported) => {
698
+ const name = packageNameOf(imported)?.name;
699
+ return name !== void 0 && names.has(name);
700
+ });
701
+ return { name: parsed.name, dependencies: dependencies.sort() };
702
+ }
703
+ function listFarmPackageExports(importer, specifier) {
704
+ const parsed = packageNameOf(specifier);
705
+ if (!parsed) return null;
706
+ const directory = findPackageDirectory(importer, parsed.name);
707
+ if (!directory) return null;
708
+ let entry = null;
709
+ try {
710
+ const manifest = JSON.parse(fs.readFileSync(path.join(directory, "package.json"), "utf8"));
711
+ const target = pickTarget(exportEntry(manifest.exports, parsed.subpath), [
712
+ "browser",
713
+ ...DEFAULT_CONDITIONS
714
+ ]) ?? (!parsed.subpath ? manifest.module ?? manifest.main ?? "index.js" : parsed.subpath);
715
+ entry = resolveRelative(
716
+ path.join(directory, "package.json"),
717
+ `./${String(target).replace(/^\.\//, "")}`
718
+ );
719
+ } catch {
720
+ return null;
721
+ }
722
+ if (!entry) return null;
723
+ const names = /* @__PURE__ */ new Set();
724
+ const seen = /* @__PURE__ */ new Set();
725
+ const collect = (file, depth) => {
726
+ if (depth > 8 || seen.has(file)) return true;
727
+ seen.add(file);
728
+ const program = readModule(file);
729
+ if (!program) return false;
730
+ let esm = false;
731
+ for (const node of program.body ?? []) {
732
+ if (node.type === "ExportAllDeclaration" && node.source && !node.exported) {
733
+ esm = true;
734
+ const child = resolveRelative(file, node.source.value);
735
+ if (!child || !collect(child, depth + 1)) return false;
736
+ } else if (node.type === "ExportAllDeclaration" && node.exported) {
737
+ esm = true;
738
+ const name = exportedName(node.exported);
739
+ if (name) names.add(name);
740
+ } else if (node.type === "ExportNamedDeclaration") {
741
+ esm = true;
742
+ for (const specifier2 of node.specifiers ?? []) {
743
+ const name = exportedName(specifier2.exported);
744
+ if (name) names.add(name);
745
+ }
746
+ if (node.declaration?.id?.name) names.add(node.declaration.id.name);
747
+ for (const declarator of node.declaration?.declarations ?? []) {
748
+ if (declarator.id?.type === "Identifier") names.add(declarator.id.name);
749
+ }
750
+ } else if (node.type === "ExportDefaultDeclaration") {
751
+ esm = true;
752
+ names.add("default");
753
+ } else if (node.type === "ImportDeclaration") {
754
+ esm = true;
755
+ }
756
+ }
757
+ return esm || depth > 0;
758
+ };
759
+ if (!collect(entry, 0)) return null;
760
+ return [...names].filter((name) => /^[A-Za-z_$][\w$]*$/.test(name)).sort();
761
+ }
762
+
763
+ // src/islands-package-references.ts
764
+ import fs2 from "fs";
765
+ import path2 from "path";
766
+ import { parseAst as parseAst2 } from "rolldown/parseAst";
767
+ var IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
768
+ function parse(code, file) {
769
+ const extension = path2.extname(file).slice(1);
770
+ const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
771
+ try {
772
+ return parseAst2(code, { lang });
773
+ } catch {
774
+ return null;
775
+ }
776
+ }
344
777
  function walk(node, visit, parent = null) {
345
778
  if (!node || typeof node !== "object") return;
346
779
  if (Array.isArray(node)) {
@@ -355,7 +788,7 @@ function walk(node, visit, parent = null) {
355
788
  if (value && typeof value === "object") walk(value, visit, current);
356
789
  }
357
790
  }
358
- function namespaceMembers(program, local, declaration) {
791
+ function namespaceMembers2(program, local, declaration) {
359
792
  const members = /* @__PURE__ */ new Set();
360
793
  let opaque = false;
361
794
  walk(program, (node, parent) => {
@@ -394,9 +827,18 @@ function findFarmPackageClientImports(code, file, isClientPackage) {
394
827
  for (const binding of specifiers) {
395
828
  if (binding.type === "ImportDefaultSpecifier") entry.defaultLocal = binding.local.name;
396
829
  else if (binding.type === "ImportNamespaceSpecifier") {
397
- const members = namespaceMembers(program, binding.local.name, node);
830
+ const read = namespaceMembers2(program, binding.local.name, node);
831
+ const members = read ?? listFarmPackageExports(file, specifier);
398
832
  if (!members || members.some((member) => !IDENTIFIER.test(member))) supported = false;
399
- else entry.namespace = { local: binding.local.name, members };
833
+ else if (read) entry.namespace = { local: binding.local.name, members };
834
+ else {
835
+ const component = (name) => name === "default" || /^[A-Z]/.test(name);
836
+ entry.namespace = {
837
+ local: binding.local.name,
838
+ members: members.filter(component),
839
+ values: members.filter((name) => !component(name))
840
+ };
841
+ }
400
842
  } else {
401
843
  const imported = binding.imported?.type === "Identifier" ? binding.imported.name : binding.imported?.value;
402
844
  if (typeof imported !== "string" || !IDENTIFIER.test(imported)) supported = false;
@@ -416,7 +858,7 @@ function farmPackageClientImportExports(entry) {
416
858
  }
417
859
  function farmPackageClientReferencePath(root, specifier, exportName) {
418
860
  const directory = specifier.replace(/^@/, "").replace(/[^A-Za-z0-9._-]/g, "+");
419
- return path.join(root, ".farm", "client-references", directory, `${exportName}.tsx`);
861
+ return path2.join(root, ".farm", "client-references", directory, `${exportName}.tsx`);
420
862
  }
421
863
  function ensureFarmPackageClientReference(root, specifier, exportName) {
422
864
  const file = farmPackageClientReferencePath(root, specifier, exportName);
@@ -428,12 +870,12 @@ function ensureFarmPackageClientReference(root, specifier, exportName) {
428
870
  ].join("\n");
429
871
  let current = null;
430
872
  try {
431
- current = fs.readFileSync(file, "utf8");
873
+ current = fs2.readFileSync(file, "utf8");
432
874
  } catch {
433
875
  }
434
876
  if (current !== source) {
435
- fs.mkdirSync(path.dirname(file), { recursive: true });
436
- fs.writeFileSync(file, source);
877
+ fs2.mkdirSync(path2.dirname(file), { recursive: true });
878
+ fs2.writeFileSync(file, source);
437
879
  }
438
880
  return file;
439
881
  }
@@ -460,6 +902,11 @@ function rewriteFarmPackageClientImports(options) {
460
902
  lines.push(`import { ${member} as ${local} } from ${reference(entry.specifier, member)};`);
461
903
  fields.push(`${member}: ${local}`);
462
904
  }
905
+ if (entry.namespace.values?.length) {
906
+ const local = `__farm_package_values_${next++}__`;
907
+ lines.push(`import * as ${local} from ${JSON.stringify(entry.specifier)};`);
908
+ for (const value of entry.namespace.values) fields.push(`${value}: ${local}.${value}`);
909
+ }
463
910
  lines.push(`const ${entry.namespace.local} = Object.freeze({ ${fields.join(", ")} });`);
464
911
  }
465
912
  output = output.slice(0, entry.start) + lines.join("\n") + output.slice(entry.end);
@@ -468,16 +915,16 @@ function rewriteFarmPackageClientImports(options) {
468
915
  }
469
916
 
470
917
  // src/utils/client-component.ts
471
- import fs3 from "fs";
472
- import path3 from "path";
918
+ import fs4 from "fs";
919
+ import path4 from "path";
473
920
  import { fileURLToPath } from "url";
474
921
 
475
922
  // src/utils/package-client-boundary-cache.ts
476
923
  import { AsyncLocalStorage } from "async_hooks";
477
- import fs2 from "fs";
478
- import path2 from "path";
924
+ import fs3 from "fs";
925
+ import path3 from "path";
479
926
  var SCHEMA_VERSION = 1;
480
- var NODE_MODULES_SEGMENT = `${path2.sep}node_modules${path2.sep}`;
927
+ var NODE_MODULES_SEGMENT = `${path3.sep}node_modules${path3.sep}`;
481
928
  var PackageInspectionTrace = class {
482
929
  constructor() {
483
930
  this.files = /* @__PURE__ */ new Set();
@@ -487,7 +934,7 @@ var PackageInspectionTrace = class {
487
934
  }
488
935
  visit(file) {
489
936
  this.files.add(file);
490
- const directory = path2.dirname(file);
937
+ const directory = path3.dirname(file);
491
938
  if (!this.directoryStamps.has(directory)) {
492
939
  this.directoryStamps.set(directory, stampPackagePath(directory, "directory"));
493
940
  }
@@ -514,9 +961,9 @@ var PackageInspectionTrace = class {
514
961
  }
515
962
  };
516
963
  function stampPackagePath(target, kind) {
517
- if (!`${target}${path2.sep}`.includes(NODE_MODULES_SEGMENT)) return void 0;
964
+ if (!`${target}${path3.sep}`.includes(NODE_MODULES_SEGMENT)) return void 0;
518
965
  try {
519
- const stat = fs2.statSync(target, { throwIfNoEntry: false });
966
+ const stat = fs3.statSync(target, { throwIfNoEntry: false });
520
967
  if (!stat || (kind === "file" ? !stat.isFile() : !stat.isDirectory())) return void 0;
521
968
  return [target, stat.size, stat.mtimeMs, stat.ctimeMs];
522
969
  } catch {
@@ -600,11 +1047,11 @@ var PackageClientBoundaryCache = class {
600
1047
  });
601
1048
  const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
602
1049
  try {
603
- await fs2.promises.mkdir(path2.dirname(file), { recursive: true });
604
- await fs2.promises.writeFile(temporary, contents);
605
- await fs2.promises.rename(temporary, file);
1050
+ await fs3.promises.mkdir(path3.dirname(file), { recursive: true });
1051
+ await fs3.promises.writeFile(temporary, contents);
1052
+ await fs3.promises.rename(temporary, file);
606
1053
  } catch {
607
- await fs2.promises.rm(temporary, { force: true }).catch(() => {
1054
+ await fs3.promises.rm(temporary, { force: true }).catch(() => {
608
1055
  });
609
1056
  }
610
1057
  }
@@ -638,7 +1085,7 @@ var PackageClientBoundaryCache = class {
638
1085
  function readStoredCache(file) {
639
1086
  let value;
640
1087
  try {
641
- value = JSON.parse(fs2.readFileSync(file, "utf8"));
1088
+ value = JSON.parse(fs3.readFileSync(file, "utf8"));
642
1089
  } catch {
643
1090
  return null;
644
1091
  }
@@ -659,7 +1106,7 @@ function isRecord(value) {
659
1106
  return typeof value === "object" && value !== null && !Array.isArray(value);
660
1107
  }
661
1108
  function isPathStamp(value) {
662
- return Array.isArray(value) && value.length === 4 && typeof value[0] === "string" && path2.isAbsolute(value[0]) && value.slice(1).every((part) => typeof part === "number" && Number.isFinite(part));
1109
+ return Array.isArray(value) && value.length === 4 && typeof value[0] === "string" && path3.isAbsolute(value[0]) && value.slice(1).every((part) => typeof part === "number" && Number.isFinite(part));
663
1110
  }
664
1111
  function isPathIndexList(value, pathCount) {
665
1112
  return Array.isArray(value) && value.length > 0 && value.every((index) => Number.isSafeInteger(index) && index >= 0 && index < pathCount);
@@ -667,7 +1114,7 @@ function isPathIndexList(value, pathCount) {
667
1114
  function isStoredEntry(value, pathCount) {
668
1115
  if (!isRecord(value) || !isRecord(value.result)) return false;
669
1116
  const { isClientComponent, shouldHydrate, islandStrategy } = value.result;
670
- return isPathIndexList(value.files, pathCount) && isPathIndexList(value.directories, pathCount) && Array.isArray(value.stops) && value.stops.every((file) => typeof file === "string" && path2.isAbsolute(file)) && typeof isClientComponent === "boolean" && typeof shouldHydrate === "boolean" && (islandStrategy === null || isFarmIslandStrategy(islandStrategy)) && Object.keys(value.result).length === 3;
1117
+ return isPathIndexList(value.files, pathCount) && isPathIndexList(value.directories, pathCount) && Array.isArray(value.stops) && value.stops.every((file) => typeof file === "string" && path3.isAbsolute(file)) && typeof isClientComponent === "boolean" && typeof shouldHydrate === "boolean" && (islandStrategy === null || isFarmIslandStrategy(islandStrategy)) && Object.keys(value.result).length === 3;
671
1118
  }
672
1119
  var STORAGE_KEY = /* @__PURE__ */ Symbol.for("@farm.js/core/package-client-boundary-cache");
673
1120
  function getStorage() {
@@ -684,11 +1131,11 @@ function getPackageClientBoundaryCache() {
684
1131
  return getStorage().getStore();
685
1132
  }
686
1133
  async function withPackageClientBoundaryCache(operation) {
687
- const cache2 = new PackageClientBoundaryCache();
1134
+ const cache3 = new PackageClientBoundaryCache();
688
1135
  try {
689
- return await getStorage().run(cache2, operation);
1136
+ return await getStorage().run(cache3, operation);
690
1137
  } finally {
691
- await cache2.persist();
1138
+ await cache3.persist();
692
1139
  }
693
1140
  }
694
1141
  function usePackageClientBoundaryCacheFile(file) {
@@ -698,10 +1145,10 @@ function usePackageClientBoundaryCacheFile(file) {
698
1145
  // src/utils/client-component.ts
699
1146
  function readIfExists(filePath) {
700
1147
  try {
701
- if (!filePath || !fs3.existsSync(filePath)) {
1148
+ if (!filePath || !fs4.existsSync(filePath)) {
702
1149
  return null;
703
1150
  }
704
- return fs3.readFileSync(filePath, "utf-8");
1151
+ return fs4.readFileSync(filePath, "utf-8");
705
1152
  } catch {
706
1153
  return null;
707
1154
  }
@@ -720,21 +1167,21 @@ function resolveModuleSourcePath(modulePath, root) {
720
1167
  }
721
1168
  if (modulePath.startsWith("/@fs/")) {
722
1169
  const fsPath = withoutQuery.slice("/@fs/".length);
723
- candidates.add(path3.normalize(/^[A-Za-z]:/.test(fsPath) ? fsPath : `/${fsPath}`));
1170
+ candidates.add(path4.normalize(/^[A-Za-z]:/.test(fsPath) ? fsPath : `/${fsPath}`));
724
1171
  }
725
1172
  }
726
1173
  if (root && modulePath) {
727
1174
  const normalized = withoutQuery.replace(/^\/+/, "");
728
- candidates.add(path3.join(root, normalized));
729
- candidates.add(path3.resolve(root, normalized));
1175
+ candidates.add(path4.join(root, normalized));
1176
+ candidates.add(path4.resolve(root, normalized));
730
1177
  }
731
1178
  if (withoutQuery?.startsWith("/src/")) {
732
1179
  const normalized = withoutQuery.replace(/^\/+/, "");
733
- candidates.add(path3.join(process.cwd(), normalized));
734
- candidates.add(path3.resolve(process.cwd(), normalized));
1180
+ candidates.add(path4.join(process.cwd(), normalized));
1181
+ candidates.add(path4.resolve(process.cwd(), normalized));
735
1182
  }
736
1183
  for (const candidate of candidates) {
737
- if (fs3.existsSync(candidate)) {
1184
+ if (fs4.existsSync(candidate)) {
738
1185
  return candidate;
739
1186
  }
740
1187
  }
@@ -751,8 +1198,8 @@ var FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES = 4;
751
1198
  function isolatedHydrationBoundaryLimit() {
752
1199
  const benchmarkRoot = process.env.FARM_INTERNAL_ISOLATED_HYDRATION_BENCHMARK_ROOT;
753
1200
  const benchmarkLimit = Number(process.env.FARM_INTERNAL_ISOLATED_HYDRATION_BENCHMARK_LIMIT);
754
- const resolvedBenchmarkRoot = benchmarkRoot ? path3.resolve(benchmarkRoot) : null;
755
- const isBenchmarkFixture = process.env.FARM_INTERNAL_BENCHMARK === "isolated-hydration" && resolvedBenchmarkRoot !== null && (process.cwd() === resolvedBenchmarkRoot || process.cwd().startsWith(`${resolvedBenchmarkRoot}${path3.sep}`));
1201
+ const resolvedBenchmarkRoot = benchmarkRoot ? path4.resolve(benchmarkRoot) : null;
1202
+ const isBenchmarkFixture = process.env.FARM_INTERNAL_BENCHMARK === "isolated-hydration" && resolvedBenchmarkRoot !== null && (process.cwd() === resolvedBenchmarkRoot || process.cwd().startsWith(`${resolvedBenchmarkRoot}${path4.sep}`));
756
1203
  return isBenchmarkFixture && Number.isSafeInteger(benchmarkLimit) && benchmarkLimit > FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES ? benchmarkLimit : FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES;
757
1204
  }
758
1205
  var RESOLVABLE_SOURCE_EXTENSIONS = [
@@ -807,8 +1254,8 @@ function hasHydrateExport(content) {
807
1254
  for (const match of content.matchAll(/\bexport\s*\{([^}]*)\}/g)) {
808
1255
  for (const specifier of match[1].split(",")) {
809
1256
  const parts = specifier.trim().split(/\s+as\s+/);
810
- const exportedName = (parts[1] ?? parts[0])?.trim();
811
- if (exportedName === "hydrate") {
1257
+ const exportedName2 = (parts[1] ?? parts[0])?.trim();
1258
+ if (exportedName2 === "hydrate") {
812
1259
  return true;
813
1260
  }
814
1261
  }
@@ -1660,7 +2107,7 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
1660
2107
  let fallbackReason;
1661
2108
  let fallbackHint;
1662
2109
  let costGuardExceeded = false;
1663
- const projectRoot = root ? path3.resolve(root) : void 0;
2110
+ const projectRoot = root ? path4.resolve(root) : void 0;
1664
2111
  const visit = (moduleSourcePath) => {
1665
2112
  if (fallbackReason) return 0;
1666
2113
  const cached = estimates.get(moduleSourcePath);
@@ -1670,7 +2117,7 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
1670
2117
  const content = readIfExists(moduleSourcePath);
1671
2118
  const parsed = parseClientModuleMetadata(content, false);
1672
2119
  if (parsed.isClientComponent) {
1673
- if (projectRoot && !path3.resolve(moduleSourcePath).startsWith(`${projectRoot}${path3.sep}`)) {
2120
+ if (projectRoot && !path4.resolve(moduleSourcePath).startsWith(`${projectRoot}${path4.sep}`)) {
1674
2121
  fallbackReason = `client boundary ${moduleSourcePath} is outside the application root`;
1675
2122
  fallbackHint = "Move the component into the application, or publish it as a package (package client components render as static HTML)";
1676
2123
  return 0;
@@ -1703,29 +2150,39 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
1703
2150
  if (imported.local) {
1704
2151
  importedBoundaryCount = visit(importedPath);
1705
2152
  } else {
1706
- const packageMetadata = inspectPackageClientBoundary(importedPath, root, /* @__PURE__ */ new Set());
1707
- if (!packageMetadata.shouldHydrate) continue;
1708
- const references = options.packageReferences && projectRoot ? findFarmPackageClientImports(
1709
- content ?? "",
1710
- moduleSourcePath,
1711
- (candidate) => candidate === specifier
1712
- ) : [];
1713
- if (references.length > 0) {
2153
+ const reactServerClientNames = options.packageReferences && projectRoot ? findFarmReactServerClientNames(content ?? "", moduleSourcePath, specifier) : null;
2154
+ if (reactServerClientNames) {
1714
2155
  importedBoundaryCount = 0;
1715
- for (const reference of references) {
1716
- for (const exportName of farmPackageClientImportExports(reference)) {
1717
- importedBoundaryCount += visit(
1718
- ensureFarmPackageClientReference(projectRoot, specifier, exportName)
1719
- );
1720
- }
2156
+ for (const exportName of reactServerClientNames) {
2157
+ importedBoundaryCount += visit(
2158
+ ensureFarmPackageClientReference(projectRoot, specifier, exportName)
2159
+ );
1721
2160
  }
1722
- } else if (options.staticPackageBoundaries || options.staticPackageLeaves && rendersOnlyLeafElements(content, importedBindings.get(specifier) ?? [])) {
1723
- staticPackages.add(specifier);
1724
- continue;
1725
2161
  } else {
1726
- fallbackReason = `package client boundary ${specifier} cannot yet be isolated`;
1727
- fallbackHint = `Render it from a local "use client" module (a providers.tsx that renders the ${specifier} component)`;
1728
- return 0;
2162
+ const packageMetadata = inspectPackageClientBoundary(importedPath, root, /* @__PURE__ */ new Set());
2163
+ if (!packageMetadata.shouldHydrate) continue;
2164
+ const references = options.packageReferences && projectRoot ? findFarmPackageClientImports(
2165
+ content ?? "",
2166
+ moduleSourcePath,
2167
+ (candidate) => candidate === specifier
2168
+ ) : [];
2169
+ if (references.length > 0) {
2170
+ importedBoundaryCount = 0;
2171
+ for (const reference of references) {
2172
+ for (const exportName of farmPackageClientImportExports(reference)) {
2173
+ importedBoundaryCount += visit(
2174
+ ensureFarmPackageClientReference(projectRoot, specifier, exportName)
2175
+ );
2176
+ }
2177
+ }
2178
+ } else if (options.staticPackageBoundaries || options.staticPackageLeaves && rendersOnlyLeafElements(content, importedBindings.get(specifier) ?? [])) {
2179
+ staticPackages.add(specifier);
2180
+ continue;
2181
+ } else {
2182
+ fallbackReason = `package client boundary ${specifier} cannot yet be isolated`;
2183
+ fallbackHint = `Render it from a local "use client" module (a providers.tsx that renders the ${specifier} component)`;
2184
+ return 0;
2185
+ }
1729
2186
  }
1730
2187
  }
1731
2188
  if (fallbackReason || importedBoundaryCount === 0) continue;
@@ -1818,19 +2275,19 @@ function inspectClientModuleMetadata(resolvedPath, root, visited, inspectIslandE
1818
2275
  };
1819
2276
  }
1820
2277
  function inspectPackageClientBoundary(resolvedPath, root, visited) {
1821
- const cache2 = getPackageClientBoundaryCache();
1822
- if (!cache2 || !resolvedPath || visited.has(resolvedPath)) {
2278
+ const cache3 = getPackageClientBoundaryCache();
2279
+ if (!cache3 || !resolvedPath || visited.has(resolvedPath)) {
1823
2280
  return traversePackageClientBoundary(resolvedPath, root, visited);
1824
2281
  }
1825
2282
  const key = `${root ?? ""}\0${resolvedPath}`;
1826
- const cached = cache2.find(key, visited);
2283
+ const cached = cache3.find(key, visited);
1827
2284
  if (cached) {
1828
2285
  for (const file of cached.files) visited.add(file);
1829
2286
  return { ...cached.result };
1830
2287
  }
1831
2288
  const trace = new PackageInspectionTrace();
1832
2289
  const result = traversePackageClientBoundary(resolvedPath, root, visited, trace);
1833
- cache2.add(key, trace.toEntry(result));
2290
+ cache3.add(key, trace.toEntry(result));
1834
2291
  return result;
1835
2292
  }
1836
2293
  function traversePackageClientBoundary(resolvedPath, root, visited, trace) {
@@ -1950,7 +2407,7 @@ var ALIAS_IMPORT = /^(?:@\/|~\/|#)/;
1950
2407
  function warnUnresolvedAliasImport(importerPath, specifier, root) {
1951
2408
  if (!ALIAS_IMPORT.test(specifier) || warnedUnresolvedAliasImports.has(specifier)) return;
1952
2409
  warnedUnresolvedAliasImports.add(specifier);
1953
- const importer = root ? path3.relative(root, importerPath) : importerPath;
2410
+ const importer = root ? path4.relative(root, importerPath) : importerPath;
1954
2411
  logger.warn(
1955
2412
  `Could not resolve "${specifier}" (imported by ${importer}) while checking which pages need client JavaScript. If it holds client components, they will not hydrate. Map the alias in tsconfig.json "paths" or package.json "imports".`
1956
2413
  );
@@ -1959,7 +2416,7 @@ var projectImportAliasCache = /* @__PURE__ */ new Map();
1959
2416
  var PROJECT_ALIAS_FILES = ["tsconfig.json", "jsconfig.json", "package.json"];
1960
2417
  function resolveProjectAliasSourcePath(specifier, root) {
1961
2418
  if (!root) return void 0;
1962
- const projectRoot = path3.resolve(root);
2419
+ const projectRoot = path4.resolve(root);
1963
2420
  let match;
1964
2421
  for (const alias of getProjectImportAliases(projectRoot)) {
1965
2422
  const captured = matchProjectImportAlias(alias, specifier);
@@ -1969,7 +2426,7 @@ function resolveProjectAliasSourcePath(specifier, root) {
1969
2426
  if (!match) return void 0;
1970
2427
  const resolved = resolveSourceCandidate(
1971
2428
  match.alias.targets.map(
1972
- (target) => path3.normalize(match.alias.wildcard ? target.replace("*", match.captured) : target)
2429
+ (target) => path4.normalize(match.alias.wildcard ? target.replace("*", match.captured) : target)
1973
2430
  )
1974
2431
  );
1975
2432
  return resolved && /\.d\.[cm]?ts$/.test(resolved) ? null : resolved;
@@ -1984,7 +2441,7 @@ function matchProjectImportAlias(alias, specifier) {
1984
2441
  function getProjectImportAliases(projectRoot) {
1985
2442
  const stamp = PROJECT_ALIAS_FILES.map((file) => {
1986
2443
  try {
1987
- return String(fs3.statSync(path3.join(projectRoot, file)).mtimeMs);
2444
+ return String(fs4.statSync(path4.join(projectRoot, file)).mtimeMs);
1988
2445
  } catch {
1989
2446
  return "-";
1990
2447
  }
@@ -2002,7 +2459,7 @@ function getProjectImportAliases(projectRoot) {
2002
2459
  prefix: "@/",
2003
2460
  suffix: "",
2004
2461
  wildcard: true,
2005
- targets: [path3.join(projectRoot, sourceDir, "*")]
2462
+ targets: [path4.join(projectRoot, sourceDir, "*")]
2006
2463
  });
2007
2464
  }
2008
2465
  projectImportAliasCache.set(projectRoot, { stamp: cacheStamp, aliases });
@@ -2010,8 +2467,8 @@ function getProjectImportAliases(projectRoot) {
2010
2467
  }
2011
2468
  function readTsconfigPathAliases(projectRoot) {
2012
2469
  for (const name of ["tsconfig.json", "jsconfig.json"]) {
2013
- const configPath = path3.join(projectRoot, name);
2014
- if (!fs3.existsSync(configPath)) continue;
2470
+ const configPath = path4.join(projectRoot, name);
2471
+ if (!fs4.existsSync(configPath)) continue;
2015
2472
  const resolved = readTsconfigPaths(configPath, /* @__PURE__ */ new Set());
2016
2473
  if (!resolved?.paths) return [];
2017
2474
  const base = resolved.baseUrl ?? resolved.pathsDirectory;
@@ -2023,7 +2480,7 @@ function readTsconfigPathAliases(projectRoot) {
2023
2480
  prefix: wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex),
2024
2481
  suffix: wildcardIndex === -1 ? "" : pattern.slice(wildcardIndex + 1),
2025
2482
  wildcard: wildcardIndex !== -1,
2026
- targets: targets.filter((target) => typeof target === "string").map((target) => path3.resolve(base, target))
2483
+ targets: targets.filter((target) => typeof target === "string").map((target) => path4.resolve(base, target))
2027
2484
  }
2028
2485
  ];
2029
2486
  });
@@ -2035,27 +2492,27 @@ function readTsconfigPaths(configPath, visited) {
2035
2492
  visited.add(configPath);
2036
2493
  const config = readJsonWithComments(configPath);
2037
2494
  if (!config) return null;
2038
- const directory = path3.dirname(configPath);
2495
+ const directory = path4.dirname(configPath);
2039
2496
  const parents = (Array.isArray(config.extends) ? config.extends : [config.extends]).filter(
2040
2497
  (parent) => typeof parent === "string" && parent.startsWith(".")
2041
2498
  );
2042
2499
  let inherited = null;
2043
2500
  for (const parent of parents) {
2044
- const parentPath = path3.resolve(
2501
+ const parentPath = path4.resolve(
2045
2502
  directory,
2046
2503
  parent.endsWith(".json") ? parent : `${parent}.json`
2047
2504
  );
2048
2505
  inherited = readTsconfigPaths(parentPath, visited) ?? inherited;
2049
2506
  }
2050
2507
  const options = config.compilerOptions ?? {};
2051
- const baseUrl = typeof options.baseUrl === "string" ? path3.resolve(directory, options.baseUrl) : inherited?.baseUrl;
2508
+ const baseUrl = typeof options.baseUrl === "string" ? path4.resolve(directory, options.baseUrl) : inherited?.baseUrl;
2052
2509
  if (options.paths && typeof options.paths === "object") {
2053
2510
  return { paths: options.paths, pathsDirectory: directory, baseUrl };
2054
2511
  }
2055
2512
  return inherited ? { ...inherited, baseUrl } : { pathsDirectory: directory, baseUrl };
2056
2513
  }
2057
2514
  function readPackageImportAliases(projectRoot) {
2058
- const imports = readPackageJson(path3.join(projectRoot, "package.json"))?.imports;
2515
+ const imports = readPackageJson(path4.join(projectRoot, "package.json"))?.imports;
2059
2516
  if (!imports || typeof imports !== "object") return [];
2060
2517
  return Object.entries(imports).flatMap(([pattern, value]) => {
2061
2518
  const target = resolveConditionalExportTarget(value);
@@ -2066,7 +2523,7 @@ function readPackageImportAliases(projectRoot) {
2066
2523
  prefix: wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex),
2067
2524
  suffix: wildcardIndex === -1 ? "" : pattern.slice(wildcardIndex + 1),
2068
2525
  wildcard: wildcardIndex !== -1,
2069
- targets: [path3.resolve(projectRoot, target)]
2526
+ targets: [path4.resolve(projectRoot, target)]
2070
2527
  }
2071
2528
  ];
2072
2529
  });
@@ -2074,7 +2531,7 @@ function readPackageImportAliases(projectRoot) {
2074
2531
  function readJsonWithComments(filePath) {
2075
2532
  let source;
2076
2533
  try {
2077
- source = fs3.readFileSync(filePath, "utf8");
2534
+ source = fs4.readFileSync(filePath, "utf8");
2078
2535
  } catch {
2079
2536
  return null;
2080
2537
  }
@@ -2112,7 +2569,7 @@ function resolveImportedModuleSourcePath(importerPath, specifier, root) {
2112
2569
  return resolvePackageModuleSourcePath(importerPath, specifier, root);
2113
2570
  }
2114
2571
  const candidates = /* @__PURE__ */ new Set();
2115
- const basePath = specifier.startsWith(".") ? path3.resolve(path3.dirname(importerPath), specifier) : root ? path3.resolve(root, specifier.replace(/^\/+/, "")) : path3.resolve(specifier);
2572
+ const basePath = specifier.startsWith(".") ? path4.resolve(path4.dirname(importerPath), specifier) : root ? path4.resolve(root, specifier.replace(/^\/+/, "")) : path4.resolve(specifier);
2116
2573
  candidates.add(basePath);
2117
2574
  return resolveSourceCandidate(candidates);
2118
2575
  }
@@ -2120,47 +2577,47 @@ function resolvePackageModuleSourcePath(importerPath, specifier, root) {
2120
2577
  const packageParts = specifier.split("/");
2121
2578
  const packageName = specifier.startsWith("@") ? packageParts.slice(0, 2).join("/") : packageParts[0];
2122
2579
  const packageSubpath = packageParts.slice(packageName.startsWith("@") ? 2 : 1).join("/");
2123
- const packageDirectory = findPackageDirectory(importerPath, packageName, root);
2580
+ const packageDirectory = findPackageDirectory2(importerPath, packageName, root);
2124
2581
  if (!packageDirectory) return null;
2125
- const packageJsonPath = path3.join(packageDirectory, "package.json");
2582
+ const packageJsonPath = path4.join(packageDirectory, "package.json");
2126
2583
  const packageJson = readPackageJson(packageJsonPath);
2127
2584
  const exportKey = packageSubpath ? `./${packageSubpath}` : ".";
2128
2585
  const exportTarget = resolvePackageExport(packageJson?.exports, exportKey);
2129
2586
  const candidates = /* @__PURE__ */ new Set();
2130
2587
  if (exportTarget?.startsWith("./")) {
2131
- candidates.add(path3.resolve(packageDirectory, exportTarget));
2588
+ candidates.add(path4.resolve(packageDirectory, exportTarget));
2132
2589
  }
2133
2590
  if (packageSubpath) {
2134
- candidates.add(path3.join(packageDirectory, packageSubpath));
2591
+ candidates.add(path4.join(packageDirectory, packageSubpath));
2135
2592
  } else {
2136
2593
  for (const entry of [packageJson?.browser, packageJson?.module, packageJson?.main]) {
2137
- if (typeof entry === "string") candidates.add(path3.resolve(packageDirectory, entry));
2594
+ if (typeof entry === "string") candidates.add(path4.resolve(packageDirectory, entry));
2138
2595
  }
2139
- candidates.add(path3.join(packageDirectory, "index"));
2596
+ candidates.add(path4.join(packageDirectory, "index"));
2140
2597
  }
2141
2598
  return resolveSourceCandidate(candidates);
2142
2599
  }
2143
- function findPackageDirectory(importerPath, packageName, root) {
2600
+ function findPackageDirectory2(importerPath, packageName, root) {
2144
2601
  const searchRoots = /* @__PURE__ */ new Set();
2145
- let current = path3.dirname(importerPath);
2602
+ let current = path4.dirname(importerPath);
2146
2603
  while (true) {
2147
2604
  searchRoots.add(current);
2148
- const parent = path3.dirname(current);
2605
+ const parent = path4.dirname(current);
2149
2606
  if (parent === current) break;
2150
2607
  current = parent;
2151
2608
  }
2152
2609
  if (root) {
2153
- current = path3.resolve(root);
2610
+ current = path4.resolve(root);
2154
2611
  while (true) {
2155
2612
  searchRoots.add(current);
2156
- const parent = path3.dirname(current);
2613
+ const parent = path4.dirname(current);
2157
2614
  if (parent === current) break;
2158
2615
  current = parent;
2159
2616
  }
2160
2617
  }
2161
2618
  for (const searchRoot of searchRoots) {
2162
- const packageDirectory = path3.join(searchRoot, "node_modules", packageName);
2163
- if (fs3.existsSync(path3.join(packageDirectory, "package.json"))) {
2619
+ const packageDirectory = path4.join(searchRoot, "node_modules", packageName);
2620
+ if (fs4.existsSync(path4.join(packageDirectory, "package.json"))) {
2164
2621
  return packageDirectory;
2165
2622
  }
2166
2623
  }
@@ -2168,7 +2625,7 @@ function findPackageDirectory(importerPath, packageName, root) {
2168
2625
  }
2169
2626
  function readPackageJson(packageJsonPath) {
2170
2627
  try {
2171
- return JSON.parse(fs3.readFileSync(packageJsonPath, "utf8"));
2628
+ return JSON.parse(fs4.readFileSync(packageJsonPath, "utf8"));
2172
2629
  } catch {
2173
2630
  return null;
2174
2631
  }
@@ -2226,11 +2683,11 @@ function resolveSourceCandidate(candidates) {
2226
2683
  for (const candidate of candidates) {
2227
2684
  const paths = [candidate];
2228
2685
  for (const extension of RESOLVABLE_SOURCE_EXTENSIONS) {
2229
- paths.push(`${candidate}${extension}`, path3.join(candidate, `index${extension}`));
2686
+ paths.push(`${candidate}${extension}`, path4.join(candidate, `index${extension}`));
2230
2687
  }
2231
2688
  for (const sourcePath of paths) {
2232
2689
  try {
2233
- if (fs3.statSync(sourcePath).isFile()) return sourcePath;
2690
+ if (fs4.statSync(sourcePath).isFile()) return sourcePath;
2234
2691
  } catch {
2235
2692
  }
2236
2693
  }
@@ -2258,13 +2715,13 @@ function collectFarmClientPackageImports(directory, root) {
2258
2715
  const walk2 = (current) => {
2259
2716
  let entries;
2260
2717
  try {
2261
- entries = fs3.readdirSync(current, { withFileTypes: true });
2718
+ entries = fs4.readdirSync(current, { withFileTypes: true });
2262
2719
  } catch {
2263
2720
  return;
2264
2721
  }
2265
2722
  for (const entry of entries) {
2266
2723
  if (entry.name.startsWith(".") && entry.isDirectory()) continue;
2267
- const file = path3.join(current, entry.name);
2724
+ const file = path4.join(current, entry.name);
2268
2725
  if (entry.isDirectory()) {
2269
2726
  if (!CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
2270
2727
  continue;
@@ -2284,15 +2741,78 @@ function collectFarmClientPackageImports(directory, root) {
2284
2741
  walk2(directory);
2285
2742
  return [...found].sort();
2286
2743
  }
2744
+ var clientReachableModules = /* @__PURE__ */ new Map();
2745
+ function invalidateFarmClientReachableModules() {
2746
+ clientReachableModules.clear();
2747
+ }
2748
+ function getFarmClientReachableModules(directory, root) {
2749
+ const key = `${path4.resolve(root)}\0${path4.resolve(directory)}`;
2750
+ const cached = clientReachableModules.get(key);
2751
+ if (cached) return cached;
2752
+ const reachable = /* @__PURE__ */ new Set();
2753
+ const queue = [];
2754
+ const walk2 = (current) => {
2755
+ let entries;
2756
+ try {
2757
+ entries = fs4.readdirSync(current, { withFileTypes: true });
2758
+ } catch {
2759
+ return;
2760
+ }
2761
+ for (const entry of entries) {
2762
+ const file = path4.join(current, entry.name);
2763
+ if (entry.isDirectory()) {
2764
+ if (!entry.name.startsWith(".") && !CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
2765
+ } else if (CLIENT_PACKAGE_SCAN_EXTENSIONS.test(entry.name) && !entry.name.endsWith(".d.ts") && hasUseClientDirective(readIfExists(file))) {
2766
+ queue.push(file);
2767
+ }
2768
+ }
2769
+ };
2770
+ walk2(directory);
2771
+ while (queue.length > 0) {
2772
+ const file = path4.resolve(queue.pop());
2773
+ if (reachable.has(file)) continue;
2774
+ reachable.add(file);
2775
+ for (const specifier of getImportSpecifiers(readIfExists(file))) {
2776
+ const imported = resolveImportedModule(file, specifier, root);
2777
+ if (imported.local && imported.path && !reachable.has(path4.resolve(imported.path))) {
2778
+ queue.push(imported.path);
2779
+ }
2780
+ }
2781
+ }
2782
+ clientReachableModules.set(key, reachable);
2783
+ return reachable;
2784
+ }
2785
+ function resolveFarmClientOptimizeDeps(directory, root) {
2786
+ const importer = path4.join(path4.resolve(root), "package.json");
2787
+ const include = /* @__PURE__ */ new Set();
2788
+ const exclude = /* @__PURE__ */ new Set();
2789
+ for (const specifier of collectFarmClientPackageImports(directory, root)) {
2790
+ const manifest = findFarmPackageManifest(importer, specifier);
2791
+ if (manifest && farmReactServerBuildReachesClientModules(importer, manifest.name)) {
2792
+ exclude.add(manifest.name);
2793
+ for (const dependency of manifest.dependencies) {
2794
+ include.add(`${manifest.name} > ${dependency}`);
2795
+ }
2796
+ } else {
2797
+ include.add(specifier);
2798
+ }
2799
+ }
2800
+ for (const name of exclude) {
2801
+ for (const entry of include) {
2802
+ if (entry === name || entry.startsWith(`${name}/`)) include.delete(entry);
2803
+ }
2804
+ }
2805
+ return { include: [...include].sort(), exclude: [...exclude].sort() };
2806
+ }
2287
2807
 
2288
2808
  // src/routing/route-manager.ts
2289
2809
  import { realpathSync } from "fs";
2290
- import path5 from "path";
2810
+ import path6 from "path";
2291
2811
 
2292
2812
  // src/static-metadata-image.ts
2293
2813
  import { createHash } from "crypto";
2294
2814
  import { readFile } from "fs/promises";
2295
- import path4 from "path";
2815
+ import path5 from "path";
2296
2816
  import { imageSize } from "image-size";
2297
2817
  var STATIC_METADATA_IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp"];
2298
2818
  var CONTENT_TYPES = {
@@ -2333,13 +2853,13 @@ async function inspectStaticMetadataImage(filePath) {
2333
2853
  };
2334
2854
  }
2335
2855
  function getStaticMetadataImageAltPath(filePath) {
2336
- return path4.join(
2337
- path4.dirname(filePath),
2338
- `${path4.basename(filePath, path4.extname(filePath))}.alt.txt`
2856
+ return path5.join(
2857
+ path5.dirname(filePath),
2858
+ `${path5.basename(filePath, path5.extname(filePath))}.alt.txt`
2339
2859
  );
2340
2860
  }
2341
2861
  function getStaticMetadataImageExtension(filePath) {
2342
- const extension = path4.extname(filePath).slice(1).toLowerCase();
2862
+ const extension = path5.extname(filePath).slice(1).toLowerCase();
2343
2863
  return STATIC_METADATA_IMAGE_EXTENSIONS.includes(extension) ? extension : null;
2344
2864
  }
2345
2865
  async function readAltText(filePath) {
@@ -2667,14 +3187,14 @@ var RouteManager = class {
2667
3187
  * Requests still fetch route data, but never inspect component source.
2668
3188
  */
2669
3189
  generateClientManifest(projectRoot = this.config.root) {
2670
- const normalizedProjectRoot = path5.resolve(projectRoot);
3190
+ const normalizedProjectRoot = path6.resolve(projectRoot);
2671
3191
  if (this.clientManifestCache?.projectRoot === normalizedProjectRoot) {
2672
3192
  return this.clientManifestCache.manifest;
2673
3193
  }
2674
3194
  const toUrlPath = (absolutePath) => {
2675
3195
  const rootRelative = toRootRelativeUrlPath(absolutePath, normalizedProjectRoot);
2676
3196
  if (rootRelative !== void 0) return rootRelative;
2677
- if (path5.isAbsolute(absolutePath)) {
3197
+ if (path6.isAbsolute(absolutePath)) {
2678
3198
  const normalized = absolutePath.replace(/\\/g, "/");
2679
3199
  return normalized.startsWith("/") ? `/@fs${normalized}` : `/@fs/${normalized}`;
2680
3200
  }
@@ -2854,7 +3374,7 @@ var RouteManager = class {
2854
3374
  for (const { metadata } of [...layoutEntries, ...routeEntries]) {
2855
3375
  if (!metadata.hasIsolatedClientBoundaries && !metadata.serverTreeLayout) continue;
2856
3376
  for (const boundary of metadata.isolatedBoundaries) {
2857
- isolatedClientBoundaryModules.add(path5.resolve(boundary.modulePath));
3377
+ isolatedClientBoundaryModules.add(path6.resolve(boundary.modulePath));
2858
3378
  }
2859
3379
  }
2860
3380
  const islandsErrors = [
@@ -2905,7 +3425,7 @@ var RouteManager = class {
2905
3425
  }
2906
3426
  /** @internal Client modules selected by the compiled hydration ownership plan. */
2907
3427
  getIsolatedClientBoundaryModules(projectRoot = this.config.root) {
2908
- const normalizedProjectRoot = path5.resolve(projectRoot);
3428
+ const normalizedProjectRoot = path6.resolve(projectRoot);
2909
3429
  this.generateClientManifest(normalizedProjectRoot);
2910
3430
  return this.clientManifestCache?.isolatedClientBoundaryModules ?? /* @__PURE__ */ new Set();
2911
3431
  }
@@ -2914,7 +3434,7 @@ var RouteManager = class {
2914
3434
  * such a page whole would ship its server code to the browser, so it stays static instead.
2915
3435
  */
2916
3436
  getIslandsErrors(projectRoot = this.config.root) {
2917
- this.generateClientManifest(path5.resolve(projectRoot));
3437
+ this.generateClientManifest(path6.resolve(projectRoot));
2918
3438
  return this.clientManifestCache?.islandsErrors ?? [];
2919
3439
  }
2920
3440
  /**
@@ -3045,19 +3565,19 @@ var RouteManager = class {
3045
3565
  const markdownFiles = group.files.filter(isFarmMarkdownPageFile);
3046
3566
  if (componentFiles.length > 1) {
3047
3567
  throw new Error(
3048
- `Duplicate page route "${pattern}". Found ${componentFiles.map((file) => path5.join(appDir, file)).join(" and ")}.`
3568
+ `Duplicate page route "${pattern}". Found ${componentFiles.map((file) => path6.join(appDir, file)).join(" and ")}.`
3049
3569
  );
3050
3570
  }
3051
3571
  if (markdownFiles.length > 1) {
3052
3572
  throw new Error(
3053
- `Duplicate markdown representation for page route "${pattern}". Found ${markdownFiles.map((file) => path5.join(appDir, file)).join(" and ")}.`
3573
+ `Duplicate markdown representation for page route "${pattern}". Found ${markdownFiles.map((file) => path6.join(appDir, file)).join(" and ")}.`
3054
3574
  );
3055
3575
  }
3056
3576
  const componentFile = componentFiles[0];
3057
3577
  const markdownFile = markdownFiles[0];
3058
3578
  const primaryFile = componentFile || markdownFile;
3059
3579
  if (!primaryFile) continue;
3060
- const modulePath = path5.join(appDir, primaryFile);
3580
+ const modulePath = path6.join(appDir, primaryFile);
3061
3581
  const existing = this.routes.get(pattern);
3062
3582
  if (existing?.sourceRoot === source.root) {
3063
3583
  throw new Error(
@@ -3068,7 +3588,7 @@ var RouteManager = class {
3068
3588
  route: group.route,
3069
3589
  modulePath,
3070
3590
  ...markdownFile ? {
3071
- markdownSourcePath: path5.join(appDir, markdownFile)
3591
+ markdownSourcePath: path6.join(appDir, markdownFile)
3072
3592
  } : {},
3073
3593
  pattern,
3074
3594
  ...getPageDirectoryField(group.route, pattern),
@@ -3083,7 +3603,7 @@ var RouteManager = class {
3083
3603
  ]) {
3084
3604
  for (const file of files) {
3085
3605
  const route = parseRoutePath(file);
3086
- const modulePath = path5.join(appDir, file);
3606
+ const modulePath = path6.join(appDir, file);
3087
3607
  const pattern = createRouteDirectoryPattern(route);
3088
3608
  const existing = target.get(pattern);
3089
3609
  if (existing?.sourceRoot === source.root) {
@@ -3103,7 +3623,7 @@ var RouteManager = class {
3103
3623
  for (const file of [...pageFiles, ...slotDefaultFiles]) {
3104
3624
  const slot = parseRouteSlotFile(file);
3105
3625
  if (!slot) continue;
3106
- const modulePath = path5.join(appDir, file);
3626
+ const modulePath = path6.join(appDir, file);
3107
3627
  const pattern = this.createRoutePattern(slot.route);
3108
3628
  const ownerPattern = this.createRoutePattern(slot.ownerRoute);
3109
3629
  const ownerDirectory = createRouteDirectoryPattern(slot.ownerRoute);
@@ -3129,11 +3649,11 @@ var RouteManager = class {
3129
3649
  });
3130
3650
  }
3131
3651
  for (const file of metadataImageFiles) {
3132
- const fileBase = path5.basename(file, path5.extname(file));
3652
+ const fileBase = path6.basename(file, path6.extname(file));
3133
3653
  const kind = fileBase === "twitter-image" ? "twitter" : "opengraph";
3134
3654
  const fileName = kind === "twitter" ? "twitter-image" : "opengraph-image";
3135
3655
  const route = parseRoutePath(file);
3136
- const modulePath = path5.join(appDir, file);
3656
+ const modulePath = path6.join(appDir, file);
3137
3657
  const pattern = this.createRoutePattern(route);
3138
3658
  const key = `${kind}:${pattern}`;
3139
3659
  const existing = this.metadataImages.get(key);
@@ -3158,11 +3678,11 @@ var RouteManager = class {
3158
3678
  }
3159
3679
  for (const file of metadataRouteFiles) {
3160
3680
  const descriptor = getApplicationMetadataRouteDescriptor(
3161
- path5.basename(file, path5.extname(file))
3681
+ path6.basename(file, path6.extname(file))
3162
3682
  );
3163
3683
  if (!descriptor) continue;
3164
3684
  const route = parseRoutePath(file);
3165
- const modulePath = path5.join(appDir, file);
3685
+ const modulePath = path6.join(appDir, file);
3166
3686
  const pattern = this.createRoutePattern(route);
3167
3687
  const key = `${descriptor.kind}:${pattern}`;
3168
3688
  const existing = this.metadataRoutes.get(key);
@@ -3573,12 +4093,12 @@ function toRealPath(filePath) {
3573
4093
  }
3574
4094
 
3575
4095
  // src/server/dev-styles.ts
3576
- import * as fs4 from "fs";
3577
- import * as path6 from "path";
4096
+ import * as fs5 from "fs";
4097
+ import * as path7 from "path";
3578
4098
  function resolveDevGlobalStylesheetHref(root, srcDir = "src") {
3579
- const file = path6.join(root, srcDir, "app", "globals.css");
3580
- if (!fs4.existsSync(file)) return void 0;
3581
- return `/${path6.relative(root, file).split(path6.sep).join("/")}`;
4099
+ const file = path7.join(root, srcDir, "app", "globals.css");
4100
+ if (!fs5.existsSync(file)) return void 0;
4101
+ return `/${path7.relative(root, file).split(path7.sep).join("/")}`;
3582
4102
  }
3583
4103
  var STYLE_EXTENSIONS = /\.(css|scss|sass|less|styl|stylus)(?:$|\?)/;
3584
4104
  var ALREADY_LINKED = "/src/app/globals.css";
@@ -3602,7 +4122,7 @@ function collectDevStylesheetUrls(modules, alreadyLinked = ALREADY_LINKED, optio
3602
4122
  import { createHash as createHash2, timingSafeEqual } from "crypto";
3603
4123
  import { existsSync as existsSync2 } from "fs";
3604
4124
  import { readFile as readFile2 } from "fs/promises";
3605
- import path7 from "path";
4125
+ import path8 from "path";
3606
4126
  import { createRequire } from "module";
3607
4127
  import { pathToFileURL } from "url";
3608
4128
  var FONT_IMPORTS = /* @__PURE__ */ new Set(["@farm.js/core", "@farm.js/core/font"]);
@@ -3959,7 +4479,7 @@ ${FONT_SECTION_END}
3959
4479
  return resource;
3960
4480
  }
3961
4481
  const bytes2 = await fetchRemoteFont(url, input.integrity);
3962
- return this.createSelfHostedResource(bytes2, extension, path7.basename(url.pathname));
4482
+ return this.createSelfHostedResource(bytes2, extension, path8.basename(url.pathname));
3963
4483
  }
3964
4484
  if (input.source.startsWith("/")) {
3965
4485
  return this.createPublicResource(input.moduleId, input.source);
@@ -3982,8 +4502,8 @@ ${FONT_SECTION_END}
3982
4502
  }
3983
4503
  return this.createSelfHostedResource(
3984
4504
  bytes,
3985
- path7.extname(resolvedPath),
3986
- path7.basename(resolvedPath)
4505
+ path8.extname(resolvedPath),
4506
+ path8.basename(resolvedPath)
3987
4507
  );
3988
4508
  }
3989
4509
  async createPublicResource(moduleId, source) {
@@ -3994,7 +4514,7 @@ ${FONT_SECTION_END}
3994
4514
  );
3995
4515
  }
3996
4516
  const publicPath = normalizePublicFontPath(source, moduleId);
3997
- const resolvedPath = path7.resolve(this.publicDir, `.${publicPath}`);
4517
+ const resolvedPath = path8.resolve(this.publicDir, `.${publicPath}`);
3998
4518
  if (!isPathInside(this.publicDir, resolvedPath)) {
3999
4519
  throw fontError(moduleId, `public font path must stay inside publicDir`);
4000
4520
  }
@@ -4010,7 +4530,7 @@ ${FONT_SECTION_END}
4010
4530
  `could not read ${JSON.stringify(source)} from publicDir: ${error.message}`
4011
4531
  );
4012
4532
  }
4013
- const extension = path7.extname(resolvedPath).toLowerCase();
4533
+ const extension = path8.extname(resolvedPath).toLowerCase();
4014
4534
  const hash = createHash2("sha256").update(bytes).digest("hex").slice(0, 12);
4015
4535
  const resource = {
4016
4536
  extension,
@@ -4025,7 +4545,7 @@ ${FONT_SECTION_END}
4025
4545
  createSelfHostedResource(bytes, extension, fileName) {
4026
4546
  const normalizedExtension = extension.toLowerCase();
4027
4547
  const hash = createHash2("sha256").update(bytes).digest("hex").slice(0, 12);
4028
- const baseName = sanitizeFileName(path7.basename(fileName, extension)) || "font";
4548
+ const baseName = sanitizeFileName(path8.basename(fileName, extension)) || "font";
4029
4549
  const outputFileName = `assets/fonts/${baseName}-h${hash}${normalizedExtension}`;
4030
4550
  const key = `${hash}${normalizedExtension}`;
4031
4551
  const existing = this.resources.get(key);
@@ -4378,24 +4898,24 @@ function verifyIntegrity(bytes, integrity) {
4378
4898
  if (!matches) throw new Error("downloaded font did not match its integrity value");
4379
4899
  }
4380
4900
  function resolveLocalFontPath(source, importer, root) {
4381
- if (source.startsWith(".")) return path7.resolve(path7.dirname(importer), source);
4382
- if (path7.isAbsolute(source)) {
4901
+ if (source.startsWith(".")) return path8.resolve(path8.dirname(importer), source);
4902
+ if (path8.isAbsolute(source)) {
4383
4903
  return source;
4384
4904
  }
4385
4905
  try {
4386
4906
  return createRequire(pathToFileURL(importer)).resolve(source);
4387
4907
  } catch {
4388
4908
  const segments = source.replace(/\\/g, "/").split("/");
4389
- if (segments.includes("..")) return path7.resolve(root, source);
4390
- let current = path7.dirname(importer);
4391
- const filesystemRoot = path7.parse(current).root;
4909
+ if (segments.includes("..")) return path8.resolve(root, source);
4910
+ let current = path8.dirname(importer);
4911
+ const filesystemRoot = path8.parse(current).root;
4392
4912
  while (true) {
4393
- const candidate = path7.join(current, "node_modules", ...segments);
4913
+ const candidate = path8.join(current, "node_modules", ...segments);
4394
4914
  if (existsSync2(candidate)) return candidate;
4395
4915
  if (current === filesystemRoot) break;
4396
- current = path7.dirname(current);
4916
+ current = path8.dirname(current);
4397
4917
  }
4398
- return path7.resolve(root, "node_modules", ...segments);
4918
+ return path8.resolve(root, "node_modules", ...segments);
4399
4919
  }
4400
4920
  }
4401
4921
  function replaceFontSection(css, section) {
@@ -4428,11 +4948,11 @@ function getGlobalMap(key) {
4428
4948
  return created;
4429
4949
  }
4430
4950
  function normalizeRoot(root) {
4431
- return path7.resolve(root).replace(/\\/g, "/");
4951
+ return path8.resolve(root).replace(/\\/g, "/");
4432
4952
  }
4433
4953
  function normalizePublicDir(root, publicDir) {
4434
4954
  if (publicDir === false || publicDir === "") return false;
4435
- return path7.resolve(root, publicDir || "public");
4955
+ return path8.resolve(root, publicDir || "public");
4436
4956
  }
4437
4957
  function normalizePublicFontPath(source, moduleId) {
4438
4958
  if (source.includes("?") || source.includes("#")) {
@@ -4441,8 +4961,8 @@ function normalizePublicFontPath(source, moduleId) {
4441
4961
  return `/${source.replace(/\\/g, "/").replace(/^\/+/, "")}`;
4442
4962
  }
4443
4963
  function isPathInside(parent, child) {
4444
- const relative3 = path7.relative(parent, child);
4445
- return relative3 === "" || !relative3.startsWith("..") && !path7.isAbsolute(relative3);
4964
+ const relative3 = path8.relative(parent, child);
4965
+ return relative3 === "" || !relative3.startsWith("..") && !path8.isAbsolute(relative3);
4446
4966
  }
4447
4967
  function normalizeBasePath(value) {
4448
4968
  if (!value || value === "/") return "/";
@@ -4452,7 +4972,7 @@ function joinBasePath(basePath, value) {
4452
4972
  return basePath === "/" ? value : `${basePath.replace(/\/$/, "")}${value}`;
4453
4973
  }
4454
4974
  function extensionFromPath(pathname) {
4455
- const extension = path7.extname(pathname).toLowerCase();
4975
+ const extension = path8.extname(pathname).toLowerCase();
4456
4976
  if (!FONT_EXTENSION_RE.test(extension)) {
4457
4977
  throw new Error(`[Farm fonts] Remote font URL must end in .woff2, .woff, .ttf, or .otf`);
4458
4978
  }
@@ -4592,7 +5112,7 @@ function fontError(id, message) {
4592
5112
  }
4593
5113
 
4594
5114
  // src/integration-provider-build.ts
4595
- import path8 from "path";
5115
+ import path9 from "path";
4596
5116
  function isRendererCompiledComponent(moduleId, rendererComponentExtensions) {
4597
5117
  const lowered = moduleId.toLowerCase();
4598
5118
  return rendererComponentExtensions.some((extension) => lowered.endsWith(extension.toLowerCase()));
@@ -4694,14 +5214,14 @@ function generateFarmIntegrationProviderServerModules(providers, root, rendererC
4694
5214
  }
4695
5215
  function resolveProviderModule(moduleId, root) {
4696
5216
  if (!moduleId.startsWith(".")) return moduleId;
4697
- return toViteModuleId(path8.resolve(root, moduleId), root);
5217
+ return toViteModuleId(path9.resolve(root, moduleId), root);
4698
5218
  }
4699
5219
 
4700
5220
  // src/island-inference.ts
4701
- import fs5 from "fs";
4702
- import path9 from "path";
5221
+ import fs6 from "fs";
5222
+ import path10 from "path";
4703
5223
  import { inferStrategy } from "@farm.js/islx/compiler";
4704
- import { parseAst as parseAst2 } from "rolldown/parseAst";
5224
+ import { parseAst as parseAst3 } from "rolldown/parseAst";
4705
5225
  var PARSE_LANGS = /* @__PURE__ */ new Map([
4706
5226
  [".tsx", "tsx"],
4707
5227
  [".ts", "ts"],
@@ -4710,29 +5230,29 @@ var PARSE_LANGS = /* @__PURE__ */ new Map([
4710
5230
  [".mjs", "js"]
4711
5231
  ]);
4712
5232
  function parseFarmIslandSource(file, code) {
4713
- const lang = PARSE_LANGS.get(path9.extname(file));
4714
- if (!lang) throw new Error(`${path9.basename(file)} is not a script module`);
4715
- return parseAst2(code, { lang });
5233
+ const lang = PARSE_LANGS.get(path10.extname(file));
5234
+ if (!lang) throw new Error(`${path10.basename(file)} is not a script module`);
5235
+ return parseAst3(code, { lang });
4716
5236
  }
4717
5237
  function modifiedAt(file) {
4718
5238
  try {
4719
- return fs5.statSync(file).mtimeMs;
5239
+ return fs6.statSync(file).mtimeMs;
4720
5240
  } catch {
4721
5241
  return -1;
4722
5242
  }
4723
5243
  }
4724
5244
  var inferences = /* @__PURE__ */ new Map();
4725
5245
  function inferFarmIslandStrategy(filePath, root) {
4726
- const file = path9.resolve(filePath);
5246
+ const file = path10.resolve(filePath);
4727
5247
  const cached = inferences.get(file);
4728
5248
  if (cached && cached.stamps.every(([read, stamp]) => modifiedAt(read) === stamp)) {
4729
5249
  return cached.result;
4730
5250
  }
4731
5251
  let code;
4732
5252
  try {
4733
- code = fs5.readFileSync(file, "utf8");
5253
+ code = fs6.readFileSync(file, "utf8");
4734
5254
  } catch {
4735
- return { strategy: null, files: [file], reason: `${path9.basename(file)} could not be read` };
5255
+ return { strategy: null, files: [file], reason: `${path10.basename(file)} could not be read` };
4736
5256
  }
4737
5257
  const result = inferStrategy(file, code, {
4738
5258
  parse: parseFarmIslandSource,
@@ -4756,7 +5276,7 @@ function inferFarmRouteRootStrategy(owners, root) {
4756
5276
  return {
4757
5277
  strategy: null,
4758
5278
  files,
4759
- reason: `${path9.basename(owner)}: its client components could not be listed`
5279
+ reason: `${path10.basename(owner)}: its client components could not be listed`
4760
5280
  };
4761
5281
  }
4762
5282
  modules.push(...rendered);
@@ -4764,7 +5284,7 @@ function inferFarmRouteRootStrategy(owners, root) {
4764
5284
  for (const module of modules) {
4765
5285
  let source = null;
4766
5286
  try {
4767
- source = fs5.readFileSync(module, "utf8");
5287
+ source = fs6.readFileSync(module, "utf8");
4768
5288
  } catch {
4769
5289
  }
4770
5290
  if (getIslandStrategyExport(source) !== null) return { strategy: null, files, declared: true };
@@ -4800,8 +5320,8 @@ function resolveFarmRouteRootStrategy(route, page, layouts, root, islandsMode) {
4800
5320
  }
4801
5321
 
4802
5322
  // src/client-plugin-build.ts
4803
- import fs6 from "fs";
4804
- import path10 from "path";
5323
+ import fs7 from "fs";
5324
+ import path11 from "path";
4805
5325
  var CLIENT_KEYS = [
4806
5326
  "public",
4807
5327
  "setup",
@@ -4821,10 +5341,10 @@ var MOBILE_SHELL_CLIENT_REGISTRATION = ` {
4821
5341
  }`;
4822
5342
  var APP_CLIENT_EXTENSIONS = ["ts", "tsx", "js", "jsx", "mts", "mjs"];
4823
5343
  function resolveFarmAppClientEntry(root = process.cwd(), srcDir = "src") {
4824
- const sourceRoot = path10.resolve(root, srcDir);
5344
+ const sourceRoot = path11.resolve(root, srcDir);
4825
5345
  for (const extension of APP_CLIENT_EXTENSIONS) {
4826
- const candidate = path10.join(sourceRoot, `client.${extension}`);
4827
- if (fs6.existsSync(candidate) && fs6.statSync(candidate).isFile()) return candidate;
5346
+ const candidate = path11.join(sourceRoot, `client.${extension}`);
5347
+ if (fs7.existsSync(candidate) && fs7.statSync(candidate).isFile()) return candidate;
4828
5348
  }
4829
5349
  return void 0;
4830
5350
  }
@@ -5066,27 +5586,27 @@ function isArrayIndex(key) {
5066
5586
  }
5067
5587
 
5068
5588
  // src/server/renderer.ts
5069
- import * as fs9 from "fs";
5589
+ import * as fs10 from "fs";
5070
5590
  import * as https from "https";
5071
5591
  import { isIP } from "net";
5072
- import * as path13 from "path";
5592
+ import * as path14 from "path";
5073
5593
  import * as tls from "tls";
5074
5594
  import { Readable, Writable } from "stream";
5075
5595
 
5076
5596
  // src/not-found.ts
5077
- import fs7 from "fs";
5078
- import path11 from "path";
5597
+ import fs8 from "fs";
5598
+ import path12 from "path";
5079
5599
  function resolveFarmNotFoundComponentPath(config, appDirs) {
5080
5600
  const extensions = getFarmRendererComponentExtensions(config.renderer);
5081
5601
  const configuredPath = config.notFound?.component?.trim();
5082
5602
  if (configuredPath) {
5083
- const componentPath = path11.isAbsolute(configuredPath) ? path11.normalize(configuredPath) : path11.resolve(config.root, configuredPath);
5603
+ const componentPath = path12.isAbsolute(configuredPath) ? path12.normalize(configuredPath) : path12.resolve(config.root, configuredPath);
5084
5604
  if (!extensions.some((extension) => componentPath.endsWith(extension))) {
5085
5605
  throw new Error(
5086
5606
  `notFound.component must use one of the configured renderer extensions: ${extensions.join(", ")}`
5087
5607
  );
5088
5608
  }
5089
- if (!fs7.existsSync(componentPath) || !fs7.statSync(componentPath).isFile()) {
5609
+ if (!fs8.existsSync(componentPath) || !fs8.statSync(componentPath).isFile()) {
5090
5610
  throw new Error(`notFound.component was not found: ${componentPath}`);
5091
5611
  }
5092
5612
  return componentPath;
@@ -5094,8 +5614,8 @@ function resolveFarmNotFoundComponentPath(config, appDirs) {
5094
5614
  let discoveredPath = null;
5095
5615
  for (const appDir of appDirs) {
5096
5616
  for (const extension of extensions) {
5097
- const candidate = path11.join(appDir, `not-found${extension}`);
5098
- if (fs7.existsSync(candidate) && fs7.statSync(candidate).isFile()) {
5617
+ const candidate = path12.join(appDir, `not-found${extension}`);
5618
+ if (fs8.existsSync(candidate) && fs8.statSync(candidate).isFile()) {
5099
5619
  discoveredPath = candidate;
5100
5620
  break;
5101
5621
  }
@@ -5291,8 +5811,8 @@ body {
5291
5811
  import { pathToFileURL as pathToFileURL2 } from "url";
5292
5812
 
5293
5813
  // src/server/error-diagnostics.ts
5294
- import * as fs8 from "fs";
5295
- import * as path12 from "path";
5814
+ import * as fs9 from "fs";
5815
+ import * as path13 from "path";
5296
5816
  import { fileURLToPath as fileURLToPath2 } from "url";
5297
5817
  var SECRET_VALUE_PATTERN = /\b(api[_-]?key|access[_-]?token|auth[_-]?token|client[_-]?secret|secret[_-]?key|token|password|secret)\s*[:=]\s*([^\s,;]+)/gi;
5298
5818
  var BEARER_PATTERN = /\b(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi;
@@ -5300,8 +5820,8 @@ function redactErrorText(value) {
5300
5820
  return value.replace(BEARER_PATTERN, "$1[REDACTED]").replace(SECRET_VALUE_PATTERN, "$1=[REDACTED]");
5301
5821
  }
5302
5822
  function isPathInsideRoot(root, filePath) {
5303
- const relative3 = path12.relative(root, filePath);
5304
- return relative3 === "" || !relative3.startsWith("..") && !path12.isAbsolute(relative3);
5823
+ const relative3 = path13.relative(root, filePath);
5824
+ return relative3 === "" || !relative3.startsWith("..") && !path13.isAbsolute(relative3);
5305
5825
  }
5306
5826
  function normalizeStackPath(value) {
5307
5827
  const withoutQuery = value.replace(/[?#].*$/, "");
@@ -5318,13 +5838,13 @@ function findStackLocation(stack, root) {
5318
5838
  );
5319
5839
  if (!match) continue;
5320
5840
  const candidate = normalizeStackPath(match[1]);
5321
- if (!candidate || candidate.includes(`${path12.sep}node_modules${path12.sep}`)) continue;
5322
- const absolutePath = path12.resolve(candidate);
5323
- if (!isPathInsideRoot(root, absolutePath) || !fs8.existsSync(absolutePath)) continue;
5324
- const relativePath = path12.relative(root, absolutePath).split(path12.sep).join("/");
5841
+ if (!candidate || candidate.includes(`${path13.sep}node_modules${path13.sep}`)) continue;
5842
+ const absolutePath = path13.resolve(candidate);
5843
+ if (!isPathInsideRoot(root, absolutePath) || !fs9.existsSync(absolutePath)) continue;
5844
+ const relativePath = path13.relative(root, absolutePath).split(path13.sep).join("/");
5325
5845
  return {
5326
5846
  absolutePath,
5327
- displayPath: relativePath || path12.basename(absolutePath),
5847
+ displayPath: relativePath || path13.basename(absolutePath),
5328
5848
  line: Number(match[2]),
5329
5849
  column: Number(match[3])
5330
5850
  };
@@ -5333,7 +5853,7 @@ function findStackLocation(stack, root) {
5333
5853
  }
5334
5854
  function createSourceFrame(location) {
5335
5855
  try {
5336
- const sourceLines = fs8.readFileSync(location.absolutePath, "utf8").split(/\r?\n/);
5856
+ const sourceLines = fs9.readFileSync(location.absolutePath, "utf8").split(/\r?\n/);
5337
5857
  if (location.line < 1 || location.line > sourceLines.length) return void 0;
5338
5858
  const start = Math.max(1, location.line - 2);
5339
5859
  const end = Math.min(sourceLines.length, location.line + 2);
@@ -5356,13 +5876,13 @@ function createSourceFrame(location) {
5356
5876
  }
5357
5877
  }
5358
5878
  function sanitizeStack(stack, root) {
5359
- const normalizedRoot = path12.resolve(root);
5879
+ const normalizedRoot = path13.resolve(root);
5360
5880
  return redactErrorText(stack).split(normalizedRoot).join("<project>").replace(/<project>[^\s)]*/g, (segment) => segment.split("\\").join("/")).split("\n").filter((line, index) => index === 0 || !line.includes("node:internal")).slice(0, 14).join("\n");
5361
5881
  }
5362
5882
  function createDefaultErrorDiagnostics(error, root) {
5363
5883
  const normalizedError = error instanceof Error ? error : new Error(typeof error === "string" ? error : "Unknown server rendering error");
5364
5884
  const rawStack = normalizedError.stack || `${normalizedError.name}: ${normalizedError.message}`;
5365
- const location = findStackLocation(rawStack, path12.resolve(root));
5885
+ const location = findStackLocation(rawStack, path13.resolve(root));
5366
5886
  return {
5367
5887
  name: redactErrorText(normalizedError.name || "Error"),
5368
5888
  message: redactErrorText(normalizedError.message || "Unknown server rendering error"),
@@ -5631,7 +6151,7 @@ function createRouteStateProps(input) {
5631
6151
  function readAppPackageIdentity(root) {
5632
6152
  try {
5633
6153
  return JSON.parse(
5634
- fs9.readFileSync(path13.join(root || process.cwd(), "package.json"), "utf8")
6154
+ fs10.readFileSync(path14.join(root || process.cwd(), "package.json"), "utf8")
5635
6155
  );
5636
6156
  } catch {
5637
6157
  return {};
@@ -5938,10 +6458,10 @@ var ServerRenderer = class {
5938
6458
  * Load SSG manifest from build output
5939
6459
  */
5940
6460
  loadSSGManifest() {
5941
- const manifestPath = path13.join(this.config.root, this.config.outDir, "__ssg_manifest.json");
6461
+ const manifestPath = path14.join(this.config.root, this.config.outDir, "__ssg_manifest.json");
5942
6462
  let content;
5943
6463
  try {
5944
- content = fs9.readFileSync(manifestPath, "utf-8");
6464
+ content = fs10.readFileSync(manifestPath, "utf-8");
5945
6465
  } catch (error) {
5946
6466
  if (error.code === "ENOENT") {
5947
6467
  return;
@@ -6160,10 +6680,10 @@ var ServerRenderer = class {
6160
6680
  return true;
6161
6681
  }
6162
6682
  try {
6163
- const htmlPath = page.urlPath === "/" ? path13.join(this.config.root, this.config.outDir, "client", "index.html") : path13.join(this.config.root, this.config.outDir, "client", page.urlPath + ".html");
6164
- if (fs9.existsSync(htmlPath)) {
6165
- const stat = fs9.statSync(htmlPath);
6166
- const html = fs9.readFileSync(htmlPath, "utf-8");
6683
+ const htmlPath = page.urlPath === "/" ? path14.join(this.config.root, this.config.outDir, "client", "index.html") : path14.join(this.config.root, this.config.outDir, "client", page.urlPath + ".html");
6684
+ if (fs10.existsSync(htmlPath)) {
6685
+ const stat = fs10.statSync(htmlPath);
6686
+ const html = fs10.readFileSync(htmlPath, "utf-8");
6167
6687
  await this.cacheSSGPage(page, html, {
6168
6688
  document: true,
6169
6689
  createdAt: stat.mtimeMs
@@ -6926,11 +7446,11 @@ var ServerRenderer = class {
6926
7446
  if (isFarmIntegrationProviderComponentReference(provider.component)) {
6927
7447
  providerSourceModule = provider.component.module;
6928
7448
  const providerModuleId = provider.component.module.startsWith(".") ? toViteModuleId(
6929
- path13.resolve(this.config.root, provider.component.module),
7449
+ path14.resolve(this.config.root, provider.component.module),
6930
7450
  this.config.root
6931
7451
  ) : provider.component.module;
6932
7452
  const providerModule = this.viteServer ? await loadFarmDevModule(this.viteServer, providerModuleId) : await importRuntimeModule(
6933
- provider.component.module.startsWith(".") ? pathToFileURL2(path13.resolve(this.config.root, provider.component.module)).href : provider.component.module
7453
+ provider.component.module.startsWith(".") ? pathToFileURL2(path14.resolve(this.config.root, provider.component.module)).href : provider.component.module
6934
7454
  );
6935
7455
  ProviderComponent = providerModule[provider.component.export || "default"];
6936
7456
  } else if (typeof provider.component === "function") {
@@ -7197,7 +7717,7 @@ var ServerRenderer = class {
7197
7717
  logger.warn(`Could not read metadata for ${pattern} in sitemap.xml: ${error}`);
7198
7718
  return void 0;
7199
7719
  }),
7200
- fs9.promises.stat(route.modulePath).catch(() => void 0)
7720
+ fs10.promises.stat(route.modulePath).catch(() => void 0)
7201
7721
  ]);
7202
7722
  return { pattern, module, lastModified: stat?.mtime.toISOString() };
7203
7723
  })
@@ -7263,7 +7783,7 @@ var ServerRenderer = class {
7263
7783
  const server = this.getDefaultMCPServer();
7264
7784
  const request2 = getCurrentRequestOrNull() ?? createWebRequestFromFarmRequest(req, { trustProxy: this.config.server?.trustProxy });
7265
7785
  try {
7266
- const { handleFarmDefaultMCPRequest } = await import("./agent-mcp-handler-7QMX2LUY.mjs");
7786
+ const { handleFarmDefaultMCPRequest } = await import("./agent-mcp-handler-QLFDDTYN.mjs");
7267
7787
  const origin = new URL(request2.url).origin;
7268
7788
  const response = await handleFarmDefaultMCPRequest(request2, {
7269
7789
  server,
@@ -7448,7 +7968,7 @@ var ServerRenderer = class {
7448
7968
  res.end();
7449
7969
  return;
7450
7970
  }
7451
- res.write(await fs9.promises.readFile(image.modulePath));
7971
+ res.write(await fs10.promises.readFile(image.modulePath));
7452
7972
  res.end();
7453
7973
  }
7454
7974
  async renderRouteErrorBoundary(req, res, options) {
@@ -8269,13 +8789,13 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
8269
8789
  res.end(createFarmMarkdownErrorBody(404, pathname, this.config.basePath || "/"));
8270
8790
  return;
8271
8791
  }
8272
- const appDir = path13.join(this.config.root, this.config.srcDir, "app");
8792
+ const appDir = path14.join(this.config.root, this.config.srcDir, "app");
8273
8793
  const notFoundExtensions = getFarmRendererComponentExtensions(this.config.renderer);
8274
8794
  let layoutModule = null;
8275
8795
  try {
8276
8796
  for (const ext of notFoundExtensions) {
8277
- const layoutPath = path13.join(appDir, `layout${ext}`);
8278
- if (fs9.existsSync(layoutPath)) {
8797
+ const layoutPath = path14.join(appDir, `layout${ext}`);
8798
+ if (fs10.existsSync(layoutPath)) {
8279
8799
  layoutModule = await this.routeManager.loadLayoutModule(layoutPath);
8280
8800
  break;
8281
8801
  }
@@ -8488,7 +9008,7 @@ ${clientScript}
8488
9008
  };
8489
9009
 
8490
9010
  // src/app.ts
8491
- import path14 from "path";
9011
+ import path15 from "path";
8492
9012
  var defaultDocsConfig = {
8493
9013
  enabled: false,
8494
9014
  entry: "/docs",
@@ -8628,7 +9148,7 @@ var FarmApp = class {
8628
9148
  }
8629
9149
  const componentExtensions = getFarmRendererComponentExtensions(this.config.renderer);
8630
9150
  const rootLayoutPaths = appDirs.flatMap(
8631
- (appDir) => componentExtensions.map((extension) => path14.join(appDir, `layout${extension}`))
9151
+ (appDir) => componentExtensions.map((extension) => path15.join(appDir, `layout${extension}`))
8632
9152
  );
8633
9153
  const hasRootLayout = await Promise.all(rootLayoutPaths.map((p) => fileExists(p))).then(
8634
9154
  (results) => results.some(Boolean)
@@ -8692,13 +9212,13 @@ function resolveFarmImageServerRuntime(images, preset) {
8692
9212
  }
8693
9213
 
8694
9214
  // src/app-manifest-packages.ts
8695
- import fs10 from "fs";
8696
- import path15 from "path";
9215
+ import fs11 from "fs";
9216
+ import path16 from "path";
8697
9217
  var FARM_PACKAGE = /^@(?:farm\.js|farming-labs)\/[a-z0-9._-]+$/;
8698
9218
  function resolveFarmAppPackages(root) {
8699
9219
  let manifest;
8700
9220
  try {
8701
- manifest = JSON.parse(fs10.readFileSync(path15.join(root, "package.json"), "utf8"));
9221
+ manifest = JSON.parse(fs11.readFileSync(path16.join(root, "package.json"), "utf8"));
8702
9222
  } catch {
8703
9223
  return {};
8704
9224
  }
@@ -8713,13 +9233,13 @@ function resolveFarmAppPackages(root) {
8713
9233
  for (let dir = root; ; ) {
8714
9234
  try {
8715
9235
  const { version } = JSON.parse(
8716
- fs10.readFileSync(path15.join(dir, "node_modules", name, "package.json"), "utf8")
9236
+ fs11.readFileSync(path16.join(dir, "node_modules", name, "package.json"), "utf8")
8717
9237
  );
8718
9238
  if (typeof version === "string" && /^[0-9A-Za-z.+-]{1,64}$/.test(version))
8719
9239
  versions[name] = version;
8720
9240
  break;
8721
9241
  } catch {
8722
- const parent = path15.dirname(dir);
9242
+ const parent = path16.dirname(dir);
8723
9243
  if (parent === dir) break;
8724
9244
  dir = parent;
8725
9245
  }
@@ -8729,9 +9249,9 @@ function resolveFarmAppPackages(root) {
8729
9249
  }
8730
9250
 
8731
9251
  // src/app-manifest-webmcp.ts
8732
- import fs11 from "fs";
9252
+ import fs12 from "fs";
8733
9253
  import { createRequire as createRequire2 } from "module";
8734
- import path16 from "path";
9254
+ import path17 from "path";
8735
9255
  import { globSync } from "tinyglobby";
8736
9256
  var WEBMCP_CLIENT = "@farm.js/webmcp/client";
8737
9257
  var DEFINERS = /* @__PURE__ */ new Set(["defineWebMCPTool", "registerWebMCPTool", "registerWebMCPTools"]);
@@ -8749,7 +9269,7 @@ var LANGS = {
8749
9269
  cjs: "jsx",
8750
9270
  jsx: "jsx"
8751
9271
  };
8752
- var parseAst3;
9272
+ var parseAst4;
8753
9273
  function staticValue(node) {
8754
9274
  if (!node) return NOT_STATIC;
8755
9275
  switch (node.type) {
@@ -8826,13 +9346,13 @@ function toolFromObject(object) {
8826
9346
  }
8827
9347
  function findFarmWebMCPTools(code, filename = "module.tsx") {
8828
9348
  if (!code.includes(WEBMCP_CLIENT)) return [];
8829
- const lang = LANGS[path16.extname(filename).slice(1)] ?? "tsx";
8830
- parseAst3 ?? (parseAst3 = createRequire2(typeof __filename === "string" ? __filename : import.meta.url)(
9349
+ const lang = LANGS[path17.extname(filename).slice(1)] ?? "tsx";
9350
+ parseAst4 ?? (parseAst4 = createRequire2(typeof __filename === "string" ? __filename : import.meta.url)(
8831
9351
  "rolldown/parseAst"
8832
9352
  ).parseAst);
8833
9353
  let program;
8834
9354
  try {
8835
- program = parseAst3(code, { lang });
9355
+ program = parseAst4(code, { lang });
8836
9356
  } catch {
8837
9357
  return [];
8838
9358
  }
@@ -8871,9 +9391,9 @@ function findFarmWebMCPTools(code, filename = "module.tsx") {
8871
9391
  visit(program.body);
8872
9392
  return found.sort((a, b) => a.start - b.start).map(({ tool }) => tool);
8873
9393
  }
8874
- var cache = /* @__PURE__ */ new Map();
9394
+ var cache2 = /* @__PURE__ */ new Map();
8875
9395
  function collectFarmWebMCPTools(root, srcDir = "src") {
8876
- const base = path16.resolve(root, srcDir);
9396
+ const base = path17.resolve(root, srcDir);
8877
9397
  let files;
8878
9398
  try {
8879
9399
  files = globSync("**/*.{ts,tsx,js,jsx,mts,mjs,cts,cjs}", {
@@ -8890,19 +9410,19 @@ function collectFarmWebMCPTools(root, srcDir = "src") {
8890
9410
  for (const file of files.sort()) {
8891
9411
  let mtimeMs;
8892
9412
  try {
8893
- mtimeMs = fs11.statSync(file).mtimeMs;
9413
+ mtimeMs = fs12.statSync(file).mtimeMs;
8894
9414
  } catch {
8895
9415
  continue;
8896
9416
  }
8897
- let entry = cache.get(file);
9417
+ let entry = cache2.get(file);
8898
9418
  if (!entry || entry.mtimeMs !== mtimeMs) {
8899
9419
  let code = "";
8900
9420
  try {
8901
- code = fs11.readFileSync(file, "utf8");
9421
+ code = fs12.readFileSync(file, "utf8");
8902
9422
  } catch {
8903
9423
  }
8904
9424
  entry = { mtimeMs, tools: findFarmWebMCPTools(code, file) };
8905
- cache.set(file, entry);
9425
+ cache2.set(file, entry);
8906
9426
  }
8907
9427
  for (const tool of entry.tools) {
8908
9428
  if (seen.has(tool.name) || tools.length >= MAX_TOOLS) continue;
@@ -8914,11 +9434,11 @@ function collectFarmWebMCPTools(root, srcDir = "src") {
8914
9434
  }
8915
9435
 
8916
9436
  // src/client-cache-persistence-build.ts
8917
- import fs12 from "fs";
8918
- import path17 from "path";
9437
+ import fs13 from "fs";
9438
+ import path18 from "path";
8919
9439
  var ADAPTER_EXTENSIONS = ["ts", "tsx", "js", "jsx", "mts", "mjs"];
8920
- function resolveFarmClientCacheAdapterEntry(root, cache2) {
8921
- const client = cache2?.client;
9440
+ function resolveFarmClientCacheAdapterEntry(root, cache3) {
9441
+ const client = cache3?.client;
8922
9442
  const adapter = client?.adapter;
8923
9443
  if (adapter === void 0) return void 0;
8924
9444
  if (typeof adapter !== "string" || adapter.trim().length === 0) {
@@ -8926,7 +9446,7 @@ function resolveFarmClientCacheAdapterEntry(root, cache2) {
8926
9446
  'cache.client.adapter must be a module path string, for example "./src/cache-adapter".'
8927
9447
  );
8928
9448
  }
8929
- const resolved = path17.resolve(root, adapter);
9449
+ const resolved = path18.resolve(root, adapter);
8930
9450
  const found = resolveAdapterFile(resolved);
8931
9451
  if (!found) {
8932
9452
  throw new Error(
@@ -8939,10 +9459,10 @@ function resolveFarmClientCacheAdapterEntry(root, cache2) {
8939
9459
  return { importPath: found.replace(/\\/g, "/"), options };
8940
9460
  }
8941
9461
  function resolveAdapterFile(resolved) {
8942
- if (fs12.existsSync(resolved) && fs12.statSync(resolved).isFile()) return resolved;
9462
+ if (fs13.existsSync(resolved) && fs13.statSync(resolved).isFile()) return resolved;
8943
9463
  for (const extension of ADAPTER_EXTENSIONS) {
8944
9464
  const candidate = `${resolved}.${extension}`;
8945
- if (fs12.existsSync(candidate) && fs12.statSync(candidate).isFile()) return candidate;
9465
+ if (fs13.existsSync(candidate) && fs13.statSync(candidate).isFile()) return candidate;
8946
9466
  }
8947
9467
  return void 0;
8948
9468
  }
@@ -9152,8 +9672,8 @@ async function readFarmNavigationStream(body, flushToken) {
9152
9672
  // src/docs/client-config.ts
9153
9673
  import { realpathSync as realpathSync2 } from "fs";
9154
9674
  import { createRequire as createRequire3 } from "module";
9155
- import path18 from "path";
9156
- var parseAst4;
9675
+ import path19 from "path";
9676
+ var parseAst5;
9157
9677
  function propertyKeyName(property2) {
9158
9678
  if (property2.computed) return void 0;
9159
9679
  const key = property2.key;
@@ -9162,11 +9682,11 @@ function propertyKeyName(property2) {
9162
9682
  return void 0;
9163
9683
  }
9164
9684
  function redactFarmDocsClientConfig(code, filename) {
9165
- parseAst4 ?? (parseAst4 = createRequire3(typeof __filename === "string" ? __filename : import.meta.url)(
9685
+ parseAst5 ?? (parseAst5 = createRequire3(typeof __filename === "string" ? __filename : import.meta.url)(
9166
9686
  "rolldown/parseAst"
9167
9687
  ).parseAst);
9168
- const extension = path18.extname(filename);
9169
- const program = parseAst4(code, {
9688
+ const extension = path19.extname(filename);
9689
+ const program = parseAst5(code, {
9170
9690
  lang: extension === ".tsx" || extension === ".jsx" ? "tsx" : "ts"
9171
9691
  });
9172
9692
  const edits = [];
@@ -9227,7 +9747,7 @@ function farmDocsClientConfigPlugin(configModule) {
9227
9747
  }
9228
9748
 
9229
9749
  // src/server/vite-config.ts
9230
- import path19 from "path";
9750
+ import path20 from "path";
9231
9751
  var FARM_CLIENT_ENTRY_PATTERN = "**/{page,layout,loading,error,not-found,default}.{js,jsx,ts,tsx}";
9232
9752
  var FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE = [
9233
9753
  "react",
@@ -9254,9 +9774,9 @@ function getFarmClientOptimizeDepsInclude(renderer) {
9254
9774
  );
9255
9775
  }
9256
9776
  function createFarmClientOptimizeDepsEntries(projectRoot, appDirectories) {
9257
- const resolvedProjectRoot = path19.resolve(projectRoot);
9777
+ const resolvedProjectRoot = path20.resolve(projectRoot);
9258
9778
  return appDirectories.map((appDirectory) => {
9259
- const relativeAppDirectory = path19.relative(resolvedProjectRoot, path19.resolve(appDirectory)).replace(/\\/g, "/");
9779
+ const relativeAppDirectory = path20.relative(resolvedProjectRoot, path20.resolve(appDirectory)).replace(/\\/g, "/");
9260
9780
  const prefix = relativeAppDirectory || ".";
9261
9781
  return `${prefix}/${FARM_CLIENT_ENTRY_PATTERN}`;
9262
9782
  });
@@ -9278,7 +9798,7 @@ function createFarmClientOptimizeDepsConfig(entries, renderer) {
9278
9798
  }
9279
9799
  function createFarmSourceAlias(projectRoot, srcDir = "src") {
9280
9800
  return {
9281
- "@": path19.resolve(projectRoot, srcDir)
9801
+ "@": path20.resolve(projectRoot, srcDir)
9282
9802
  };
9283
9803
  }
9284
9804
  function mergeNoExternal(farmValue, userValue) {
@@ -9426,6 +9946,9 @@ ${FARM_DARK_VARIANT}
9426
9946
  }
9427
9947
 
9428
9948
  export {
9949
+ rewriteFarmReactServerImports,
9950
+ farmRelativeImportFiles,
9951
+ ensureFarmPackageClientReference,
9429
9952
  rewriteFarmPackageClientImports,
9430
9953
  withPackageClientBoundaryCache,
9431
9954
  usePackageClientBoundaryCacheFile,
@@ -9445,8 +9968,12 @@ export {
9445
9968
  isIsolatableClientBoundarySource,
9446
9969
  isFarmPackageClientBoundary,
9447
9970
  collectFarmClientPackageImports,
9971
+ invalidateFarmClientReachableModules,
9972
+ getFarmClientReachableModules,
9973
+ resolveFarmClientOptimizeDeps,
9448
9974
  RouteManager,
9449
9975
  resolveDevGlobalStylesheetHref,
9976
+ collectDevStylesheetUrls,
9450
9977
  resolveFarmNotFoundComponentPath,
9451
9978
  farmFontImportsPlugin,
9452
9979
  mergeFarmFontCss,