@farm.js/core 0.1.72 → 0.1.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/dist/{agent-mcp-handler-VIT4GOSR.mjs → agent-mcp-handler-RK7LDYEL.mjs} +4 -4
  2. package/dist/{agent-mcp-handler-KE4J3W7S.cjs → agent-mcp-handler-VBCA3WZ6.cjs} +5 -5
  3. package/dist/{agent-mcp.d-BO3rZXEM.d.ts → agent-mcp.d-D_gHjCAE.d.ts} +1 -1
  4. package/dist/{agent-mcp.d-Cwff7lcA.d.mts → agent-mcp.d-PvEf-1mi.d.mts} +1 -1
  5. package/dist/agent-runtime.d.mts +2 -2
  6. package/dist/agent-runtime.d.ts +2 -2
  7. package/dist/{analyzer-5Q75LTIL.mjs → analyzer-MFYCJT75.mjs} +2 -2
  8. package/dist/analyzer-V5ZMRIIY.cjs +16 -0
  9. package/dist/api/node.d.mts +4 -4
  10. package/dist/api/node.d.ts +4 -4
  11. package/dist/api/route-manager.d.mts +4 -4
  12. package/dist/api/route-manager.d.ts +4 -4
  13. package/dist/api/runtime.d.mts +3 -3
  14. package/dist/api/runtime.d.ts +3 -3
  15. package/dist/api.d.mts +5 -5
  16. package/dist/api.d.ts +5 -5
  17. package/dist/{app-manifest.d-DwjGkYlP.d.ts → app-manifest.d-BpVTg43i.d.ts} +1 -1
  18. package/dist/{app-manifest.d-USD_IbFd.d.mts → app-manifest.d-CN7cEWHX.d.mts} +1 -1
  19. package/dist/app-markdown.cjs +4 -4
  20. package/dist/app-markdown.d.mts +3 -3
  21. package/dist/app-markdown.d.ts +3 -3
  22. package/dist/app-markdown.mjs +3 -3
  23. package/dist/{app.d-fW06_h8h.d.mts → app.d-BFWzAdTe.d.mts} +10 -4
  24. package/dist/{app.d-DAmF2MAk.d.ts → app.d-DO4PTCWm.d.ts} +10 -4
  25. package/dist/{chunk-OSMUE5ST.mjs → chunk-462MUII7.mjs} +3 -3
  26. package/dist/{chunk-MWUDEYBI.mjs → chunk-4CTCSKAF.mjs} +1 -1
  27. package/dist/{chunk-FSSONJRV.cjs → chunk-4YHGQDTT.cjs} +12 -12
  28. package/dist/{chunk-YCNHUIPR.cjs → chunk-4Z3YLMSW.cjs} +10 -10
  29. package/dist/{chunk-O32QPFVV.cjs → chunk-5PDMBWAF.cjs} +5 -5
  30. package/dist/{chunk-E2V7RRFL.mjs → chunk-6O6PAZZR.mjs} +1 -1
  31. package/dist/{chunk-LXEJNWF5.mjs → chunk-73K53YPP.mjs} +2 -2
  32. package/dist/{chunk-WIJF3PBM.mjs → chunk-7GMBETHM.mjs} +1 -1
  33. package/dist/{chunk-DGNMXL2O.mjs → chunk-B67CW2LM.mjs} +1 -1
  34. package/dist/{chunk-E3LE6EZH.cjs → chunk-CLEWORVY.cjs} +2 -2
  35. package/dist/{chunk-KPJYBSHL.mjs → chunk-CPMME66W.mjs} +149 -22
  36. package/dist/{chunk-VAWDGGW3.mjs → chunk-CYRIIVD4.mjs} +26 -15
  37. package/dist/{chunk-RFWWXEIF.mjs → chunk-FRO4BB2T.mjs} +1 -1
  38. package/dist/{chunk-N3XO5AL5.cjs → chunk-GPO3LJDJ.cjs} +2 -2
  39. package/dist/{chunk-645ENY7W.mjs → chunk-GZOKWJIW.mjs} +4 -4
  40. package/dist/{chunk-NAXKOTPP.cjs → chunk-HFUOLILA.cjs} +21 -21
  41. package/dist/{chunk-C2JOS77Z.cjs → chunk-HGB4PM2C.cjs} +178 -51
  42. package/dist/{chunk-BE7AQXJB.cjs → chunk-HTXKSREF.cjs} +255 -89
  43. package/dist/{chunk-Z3GPAFIA.mjs → chunk-HY6IVQ54.mjs} +1 -1
  44. package/dist/{chunk-3JN5M3T5.mjs → chunk-IBVN7SW5.mjs} +247 -81
  45. package/dist/{chunk-OSEQL34Q.cjs → chunk-ILQ5DKYF.cjs} +2 -2
  46. package/dist/{chunk-AUAMXI6N.mjs → chunk-IXZSBO76.mjs} +1 -1
  47. package/dist/{chunk-77VNYVVX.mjs → chunk-JMOCMXTQ.mjs} +1 -1
  48. package/dist/{chunk-5R4Q5FN7.cjs → chunk-KDOZORJD.cjs} +52 -41
  49. package/dist/{chunk-7QCJDYZQ.cjs → chunk-KTDG4THT.cjs} +2 -2
  50. package/dist/{chunk-L6E4SHUB.cjs → chunk-LGR7565L.cjs} +6 -6
  51. package/dist/chunk-LRPPXKCX.mjs +58 -0
  52. package/dist/{chunk-5XFKWHZD.mjs → chunk-MJEKMT6B.mjs} +95 -106
  53. package/dist/chunk-NDOE76QC.cjs +58 -0
  54. package/dist/{chunk-REP6HWJN.mjs → chunk-OBYM5S5G.mjs} +2 -2
  55. package/dist/{chunk-ZUVAGMQ5.cjs → chunk-ODBM54RT.cjs} +7 -7
  56. package/dist/{chunk-J5ASGNKF.mjs → chunk-OIP62QEL.mjs} +1 -1
  57. package/dist/{chunk-3WG7GJQL.cjs → chunk-OXNZUCHN.cjs} +9 -9
  58. package/dist/{chunk-C5AM2XDN.cjs → chunk-PXAHSCR6.cjs} +4 -4
  59. package/dist/{chunk-BSXKZPFE.mjs → chunk-QGCSUC5O.mjs} +112 -70
  60. package/dist/{chunk-EXN4DTVF.cjs → chunk-QKEZLYON.cjs} +2 -2
  61. package/dist/{chunk-QUYAGU65.mjs → chunk-REK6HZSU.mjs} +267 -231
  62. package/dist/{chunk-5X6OHJEE.cjs → chunk-ROCF6UQD.cjs} +5 -8
  63. package/dist/{chunk-KQAB5LML.mjs → chunk-SUQACHER.mjs} +2 -2
  64. package/dist/{chunk-NV26EGMC.mjs → chunk-SVQX5HYW.mjs} +2 -2
  65. package/dist/{chunk-CBLRSZQL.cjs → chunk-TAU3OF5B.cjs} +223 -234
  66. package/dist/{chunk-IWCYRDRQ.cjs → chunk-TDCP3Z4T.cjs} +3 -3
  67. package/dist/{chunk-TP4RAV7Y.cjs → chunk-TU6VAH4V.cjs} +8 -8
  68. package/dist/{chunk-ZDZUFD67.cjs → chunk-UVQRMUAR.cjs} +1 -1
  69. package/dist/{chunk-JMFTKNBA.mjs → chunk-UVZMSRHF.mjs} +2 -2
  70. package/dist/{chunk-GF22VGMS.cjs → chunk-VPETSSWN.cjs} +2 -2
  71. package/dist/{chunk-AYVGD3PK.mjs → chunk-XI3OXOMK.mjs} +1 -1
  72. package/dist/{chunk-HLMUWKAP.cjs → chunk-XUSJVHHD.cjs} +408 -366
  73. package/dist/{chunk-ET6WW3FY.cjs → chunk-YZK64PZT.cjs} +433 -397
  74. package/dist/{chunk-DS7JGFW5.mjs → chunk-Z3IN6GEX.mjs} +4 -7
  75. package/dist/{client-component.d-ciHeCxr-.d.mts → client-component.d-C71rMuHF.d.mts} +2 -2
  76. package/dist/{client-component.d-9J7CkTWW.d.ts → client-component.d-sF-Znk0j.d.ts} +2 -2
  77. package/dist/{client-plugins.d-JnRz5a1o.d.mts → client-plugins.d-B-Gd9mWR.d.mts} +1 -1
  78. package/dist/{client-plugins.d-CUOhfapO.d.ts → client-plugins.d-MFibjgBg.d.ts} +1 -1
  79. package/dist/client-plugins.d.mts +2 -2
  80. package/dist/client-plugins.d.ts +2 -2
  81. package/dist/client.d.mts +7 -7
  82. package/dist/client.d.ts +7 -7
  83. package/dist/config.d.mts +2 -2
  84. package/dist/config.d.ts +2 -2
  85. package/dist/desktop.d.mts +3 -3
  86. package/dist/desktop.d.ts +3 -3
  87. package/dist/{devtools-IZFUYWPG.cjs → devtools-6K4QXFRL.cjs} +5 -5
  88. package/dist/{devtools-7JPQMSTQ.mjs → devtools-TDIJ6HVC.mjs} +4 -4
  89. package/dist/docs.cjs +8 -8
  90. package/dist/docs.d.mts +3 -3
  91. package/dist/docs.d.ts +3 -3
  92. package/dist/docs.mjs +7 -7
  93. package/dist/environment/vite.cjs +3 -3
  94. package/dist/environment/vite.mjs +2 -2
  95. package/dist/{headers.d-rbbTKGaN.d.mts → headers.d-BUxGJTsj.d.mts} +1 -1
  96. package/dist/{headers.d-CqpTL_fZ.d.ts → headers.d-uQ6BR59u.d.ts} +1 -1
  97. package/dist/index.cjs +24 -22
  98. package/dist/{index.d-CMKvzHLW.d.ts → index.d-BCGfxCXY.d.ts} +1 -1
  99. package/dist/{index.d-D_B2D9Il.d.mts → index.d-CuWOJ-un.d.mts} +1 -1
  100. package/dist/index.d.mts +18 -18
  101. package/dist/index.d.ts +18 -18
  102. package/dist/index.mjs +23 -21
  103. package/dist/integrations/orm.d.mts +2 -2
  104. package/dist/integrations/orm.d.ts +2 -2
  105. package/dist/integrations.d.mts +2 -2
  106. package/dist/integrations.d.ts +2 -2
  107. package/dist/internal/app-markdown-runtime.cjs +3 -3
  108. package/dist/internal/app-markdown-runtime.d.mts +3 -3
  109. package/dist/internal/app-markdown-runtime.d.ts +3 -3
  110. package/dist/internal/app-markdown-runtime.mjs +2 -2
  111. package/dist/internal/build-runtime.cjs +23 -23
  112. package/dist/internal/build-runtime.d.mts +4 -4
  113. package/dist/internal/build-runtime.d.ts +4 -4
  114. package/dist/internal/build-runtime.mjs +22 -22
  115. package/dist/internal/cli-runtime.cjs +9 -9
  116. package/dist/internal/cli-runtime.mjs +8 -8
  117. package/dist/internal/client-error-overlay.cjs +4 -4
  118. package/dist/internal/client-error-overlay.mjs +1 -1
  119. package/dist/internal/client-runtime.d.mts +5 -5
  120. package/dist/internal/client-runtime.d.ts +5 -5
  121. package/dist/internal/compression-runtime.d.mts +2 -2
  122. package/dist/internal/compression-runtime.d.ts +2 -2
  123. package/dist/internal/config-runtime.cjs +6 -6
  124. package/dist/internal/config-runtime.d.mts +4 -4
  125. package/dist/internal/config-runtime.d.ts +4 -4
  126. package/dist/internal/config-runtime.mjs +5 -5
  127. package/dist/internal/infra-analytics-runtime.cjs +9 -9
  128. package/dist/internal/infra-analytics-runtime.mjs +7 -7
  129. package/dist/internal/native-server-fns.cjs +4 -4
  130. package/dist/internal/native-server-fns.mjs +3 -3
  131. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  132. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  133. package/dist/internal/production-runtime.cjs +11 -11
  134. package/dist/internal/production-runtime.d.mts +10 -10
  135. package/dist/internal/production-runtime.d.ts +10 -10
  136. package/dist/internal/production-runtime.mjs +10 -10
  137. package/dist/markdown.cjs +2 -2
  138. package/dist/markdown.d.mts +2 -2
  139. package/dist/markdown.d.ts +2 -2
  140. package/dist/markdown.mjs +1 -1
  141. package/dist/middleware.d.mts +2 -2
  142. package/dist/middleware.d.ts +2 -2
  143. package/dist/{mount.d-ImEO7q8a.d.mts → mount.d-BIYmcGGg.d.mts} +1 -1
  144. package/dist/{mount.d-B0XMxDRh.d.ts → mount.d-q8k0cJV0.d.ts} +1 -1
  145. package/dist/{native-tree-L2IIEBXH.mjs → native-tree-OYGKP2NZ.mjs} +2 -2
  146. package/dist/{native-tree-GF4BH33L.cjs → native-tree-R6CQMDTI.cjs} +3 -3
  147. package/dist/{navigation-delegate.d-RRx1CSlb.d.ts → navigation-delegate.d-Btfs6Uoa.d.ts} +1 -1
  148. package/dist/{navigation-delegate.d-83Q7ksf7.d.mts → navigation-delegate.d-CYBUupsv.d.mts} +1 -1
  149. package/dist/navigation.d.mts +5 -5
  150. package/dist/navigation.d.ts +5 -5
  151. package/dist/{observability.d-B2363jB6.d.mts → observability.d-DdJRiaIX.d.mts} +27 -3
  152. package/dist/{observability.d-B2363jB6.d.ts → observability.d-DdJRiaIX.d.ts} +27 -3
  153. package/dist/observability.d.mts +1 -1
  154. package/dist/observability.d.ts +1 -1
  155. package/dist/plugin.cjs +15 -15
  156. package/dist/plugin.d.mts +5 -5
  157. package/dist/plugin.d.ts +5 -5
  158. package/dist/plugin.mjs +14 -14
  159. package/dist/{render-plan.d-Ds2sXJ5m.d.ts → render-plan.d-0FHusf1D.d.ts} +1 -1
  160. package/dist/{render-plan.d-wP8nTeRV.d.mts → render-plan.d-BlyxqKMu.d.mts} +1 -1
  161. package/dist/renderer-client.d.mts +5 -5
  162. package/dist/renderer-client.d.ts +5 -5
  163. package/dist/{request.d-zpSn6pu_.d.ts → request.d-CPdVjssg.d.ts} +1 -1
  164. package/dist/{request.d-F3h7K37m.d.mts → request.d-CX-gks1l.d.mts} +1 -1
  165. package/dist/request.d.mts +3 -3
  166. package/dist/request.d.ts +3 -3
  167. package/dist/{route-rendering.d-Mw0ZKG2e.d.mts → route-rendering.d-CcvZ_4N2.d.mts} +1 -1
  168. package/dist/{route-rendering.d-BL0_AdKj.d.ts → route-rendering.d-DcOoSNoG.d.ts} +1 -1
  169. package/dist/{router.d-NGVsU11T.d.mts → router.d-C8RHma4A.d.mts} +1 -1
  170. package/dist/{router.d-BwXigemZ.d.ts → router.d-D2QnK8cM.d.ts} +1 -1
  171. package/dist/routes.d.mts +2 -2
  172. package/dist/routes.d.ts +2 -2
  173. package/dist/{rsc-pipeline-DHYZLWSF.mjs → rsc-pipeline-LC2FBZAR.mjs} +5 -5
  174. package/dist/{rsc-pipeline-BNXYMG4G.cjs → rsc-pipeline-NTAM65NT.cjs} +6 -6
  175. package/dist/{runtime-XPYKUNL3.mjs → runtime-MWAC7NWR.mjs} +5 -5
  176. package/dist/{runtime-IWOT6ZVC.cjs → runtime-U4PAMTVH.cjs} +7 -7
  177. package/dist/{runtime.d-OBIZWpx1.d.ts → runtime.d-1l_1bLrL.d.ts} +1 -1
  178. package/dist/{runtime.d-BA3MzhXz.d.mts → runtime.d-BQUHHq8M.d.mts} +1 -1
  179. package/dist/server-plugins.d.mts +4 -4
  180. package/dist/server-plugins.d.ts +4 -4
  181. package/dist/server.cjs +37 -35
  182. package/dist/server.d.mts +11 -11
  183. package/dist/server.d.ts +11 -11
  184. package/dist/server.mjs +20 -18
  185. package/dist/{spa-router.d-DrYT944-.d.ts → spa-router.d-BJtXNeqo.d.ts} +2 -2
  186. package/dist/{spa-router.d-BG2XzE5p.d.mts → spa-router.d-BzPdi48R.d.mts} +2 -2
  187. package/dist/testing.d.mts +2 -2
  188. package/dist/testing.d.ts +2 -2
  189. package/dist/{utils.d-C1k9BJeD.d.mts → utils.d-B4ZW-6z6.d.mts} +1 -1
  190. package/dist/{utils.d-DcF4wxey.d.ts → utils.d-DquC6qxy.d.ts} +1 -1
  191. package/dist/version.cjs +2 -2
  192. package/dist/version.mjs +1 -1
  193. package/dist/vite.cjs +17 -15
  194. package/dist/vite.d.mts +16 -7
  195. package/dist/vite.d.ts +16 -7
  196. package/dist/vite.mjs +16 -14
  197. package/package.json +1 -1
  198. package/dist/analyzer-UJG4MIZW.cjs +0 -16
  199. package/dist/chunk-V3UOEWCB.cjs +0 -46
  200. package/dist/chunk-VE3FWJBO.mjs +0 -46
@@ -21,11 +21,11 @@ import {
21
21
  } from "./chunk-JSDV2NUN.mjs";
22
22
  import {
23
23
  FARM_VERSION
24
- } from "./chunk-77VNYVVX.mjs";
24
+ } from "./chunk-JMOCMXTQ.mjs";
25
25
 
26
26
  // src/environment-vite.ts
27
27
  import { existsSync, readFileSync, realpathSync } from "fs";
28
- import path5 from "path";
28
+ import path6 from "path";
29
29
 
30
30
  // src/islands-react-server-exports.ts
31
31
  import fs2 from "fs";
@@ -1325,8 +1325,8 @@ function toModuleFile(file) {
1325
1325
  }
1326
1326
 
1327
1327
  // src/utils/client-component.ts
1328
- import fs5 from "fs";
1329
- import path4 from "path";
1328
+ import fs6 from "fs";
1329
+ import path5 from "path";
1330
1330
  import { fileURLToPath as fileURLToPath2 } from "url";
1331
1331
 
1332
1332
  // src/islands-package-references.ts
@@ -1634,12 +1634,155 @@ function rewriteFarmPackageClientImports(options) {
1634
1634
  return changed ? output : null;
1635
1635
  }
1636
1636
 
1637
- // src/utils/package-client-boundary-cache.ts
1638
- import { AsyncLocalStorage } from "async_hooks";
1637
+ // src/islands-containers.ts
1639
1638
  import fs4 from "fs";
1640
1639
  import path3 from "path";
1640
+ import { parseAst as parseAst3 } from "rolldown/parseAst";
1641
+ var FARM_ISLAND_CONTAINER_EXPORT = "FarmIslandContainer";
1642
+ var CONTAINER_LOCAL = "__FarmIslandContainer__";
1643
+ var ISLAND_CONTAINER_TAGS = /* @__PURE__ */ new Set([
1644
+ "table",
1645
+ "thead",
1646
+ "tbody",
1647
+ "tfoot",
1648
+ "tr",
1649
+ "select",
1650
+ "optgroup",
1651
+ "datalist",
1652
+ "svg",
1653
+ "ul",
1654
+ "ol"
1655
+ ]);
1656
+ var FLOW_CONTENT_TAGS = /* @__PURE__ */ new Set(["td", "th", "caption", "foreignObject", "li"]);
1657
+ function farmIslandContainerReferencePath(root) {
1658
+ return path3.join(root, ".farm", "client-references", "farm.js+core", "__island-container.tsx");
1659
+ }
1660
+ function ensureFarmIslandContainerReference(root) {
1661
+ const file = farmIslandContainerReferencePath(root);
1662
+ const source = [
1663
+ "// Generated by Farm: the island around an element whose children are client components (RFC 0006).",
1664
+ FARM_CLIENT_REFERENCE_PRAGMA,
1665
+ '"use client";',
1666
+ `export function ${FARM_ISLAND_CONTAINER_EXPORT}({ children }: { children?: unknown }) {`,
1667
+ " return children as never;",
1668
+ "}",
1669
+ ""
1670
+ ].join("\n");
1671
+ let current = null;
1672
+ try {
1673
+ current = fs4.readFileSync(file, "utf8");
1674
+ } catch {
1675
+ }
1676
+ if (current !== source) {
1677
+ fs4.mkdirSync(path3.dirname(file), { recursive: true });
1678
+ fs4.writeFileSync(file, source);
1679
+ }
1680
+ return file;
1681
+ }
1682
+ function parse2(code, file) {
1683
+ const extension = path3.extname(file).slice(1);
1684
+ const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : extension === "js" || extension === "mjs" || extension === "cjs" || extension === "jsx" ? "jsx" : "tsx";
1685
+ return memoizeInFarmSourceSnapshot(`ast:${lang}`, code, () => {
1686
+ try {
1687
+ return parseAst3(code, { lang });
1688
+ } catch {
1689
+ return null;
1690
+ }
1691
+ });
1692
+ }
1693
+ function jsxName(node) {
1694
+ if (!node) return null;
1695
+ if (node.type === "JSXIdentifier") return node.name;
1696
+ if (node.type === "JSXMemberExpression") {
1697
+ let object = node.object;
1698
+ while (object.type === "JSXMemberExpression") object = object.object;
1699
+ return object.type === "JSXIdentifier" ? object.name : null;
1700
+ }
1701
+ return null;
1702
+ }
1703
+ function findFarmIslandContainers(code, file, bindings) {
1704
+ if (bindings.length === 0) return [];
1705
+ if (!/<(?:table|thead|tbody|tfoot|tr|select|optgroup|datalist|svg|ul|ol)[\s>/]/.test(code)) {
1706
+ return [];
1707
+ }
1708
+ const program = parse2(code, file);
1709
+ if (!program) return null;
1710
+ const names = new Set(bindings);
1711
+ const found = /* @__PURE__ */ new Map();
1712
+ const open = [];
1713
+ const visit = (node) => {
1714
+ if (!node || typeof node !== "object") return;
1715
+ if (Array.isArray(node)) {
1716
+ for (const child of node) visit(child);
1717
+ return;
1718
+ }
1719
+ const current = node;
1720
+ if (typeof current.type !== "string") return;
1721
+ if (current.type === "JSXElement") {
1722
+ const name = jsxName(current.openingElement?.name);
1723
+ if (name && names.has(name)) {
1724
+ let container;
1725
+ for (let depth = open.length - 1; depth >= 0; depth--) {
1726
+ const tag = jsxName(open[depth].openingElement.name);
1727
+ if (FLOW_CONTENT_TAGS.has(tag)) break;
1728
+ if (ISLAND_CONTAINER_TAGS.has(tag)) container = open[depth];
1729
+ }
1730
+ if (container && !found.has(container.start)) {
1731
+ found.set(container.start, {
1732
+ tag: jsxName(container.openingElement.name),
1733
+ start: container.start,
1734
+ end: container.end
1735
+ });
1736
+ }
1737
+ }
1738
+ const host = current.openingElement?.name?.type === "JSXIdentifier" && (ISLAND_CONTAINER_TAGS.has(name) || FLOW_CONTENT_TAGS.has(name));
1739
+ if (host) open.push(current);
1740
+ visit(current.openingElement?.attributes);
1741
+ visit(current.children);
1742
+ if (host) open.pop();
1743
+ return;
1744
+ }
1745
+ for (const [key, value] of Object.entries(current)) {
1746
+ if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
1747
+ if (value && typeof value === "object") visit(value);
1748
+ }
1749
+ };
1750
+ visit(program);
1751
+ const sorted = [...found.values()].sort((a, b) => a.start - b.start);
1752
+ const outermost = [];
1753
+ for (const container of sorted) {
1754
+ const last = outermost[outermost.length - 1];
1755
+ if (last && container.start >= last.start && container.end <= last.end) continue;
1756
+ outermost.push(container);
1757
+ }
1758
+ return outermost;
1759
+ }
1760
+ function wrapFarmIslandContainers(options) {
1761
+ const containers = findFarmIslandContainers(options.code, options.file, options.bindings);
1762
+ if (!containers || containers.length === 0) return null;
1763
+ let code = options.code;
1764
+ for (const container of [...containers].reverse()) {
1765
+ code = code.slice(0, container.start) + `<${CONTAINER_LOCAL}>` + code.slice(container.start, container.end) + `</${CONTAINER_LOCAL}>` + code.slice(container.end);
1766
+ }
1767
+ const specifier = JSON.stringify(options.reference.split(path3.sep).join("/"));
1768
+ const declaration = `import { ${FARM_ISLAND_CONTAINER_EXPORT} as ${CONTAINER_LOCAL} } from ${specifier};
1769
+ `;
1770
+ let prologueEnd = 0;
1771
+ for (const statement of parse2(options.code, options.file)?.body ?? []) {
1772
+ if (statement.type !== "ExpressionStatement" || typeof statement.directive !== "string") break;
1773
+ prologueEnd = statement.end;
1774
+ }
1775
+ if (prologueEnd === 0) return declaration + code;
1776
+ return `${code.slice(0, prologueEnd)}
1777
+ ${declaration}${code.slice(prologueEnd)}`;
1778
+ }
1779
+
1780
+ // src/utils/package-client-boundary-cache.ts
1781
+ import { AsyncLocalStorage } from "async_hooks";
1782
+ import fs5 from "fs";
1783
+ import path4 from "path";
1641
1784
  var SCHEMA_VERSION = 2;
1642
- var NODE_MODULES_SEGMENT = `${path3.sep}node_modules${path3.sep}`;
1785
+ var NODE_MODULES_SEGMENT = `${path4.sep}node_modules${path4.sep}`;
1643
1786
  var PackageInspectionTrace = class {
1644
1787
  constructor() {
1645
1788
  this.files = /* @__PURE__ */ new Set();
@@ -1649,7 +1792,7 @@ var PackageInspectionTrace = class {
1649
1792
  }
1650
1793
  visit(file) {
1651
1794
  this.files.add(file);
1652
- const directory = path3.dirname(file);
1795
+ const directory = path4.dirname(file);
1653
1796
  if (!this.directoryStamps.has(directory)) {
1654
1797
  this.directoryStamps.set(directory, stampPackagePath(directory, "directory"));
1655
1798
  }
@@ -1676,9 +1819,9 @@ var PackageInspectionTrace = class {
1676
1819
  }
1677
1820
  };
1678
1821
  function stampPackagePath(target, kind) {
1679
- if (!`${target}${path3.sep}`.includes(NODE_MODULES_SEGMENT)) return void 0;
1822
+ if (!`${target}${path4.sep}`.includes(NODE_MODULES_SEGMENT)) return void 0;
1680
1823
  try {
1681
- const stat = fs4.statSync(target, { throwIfNoEntry: false });
1824
+ const stat = fs5.statSync(target, { throwIfNoEntry: false });
1682
1825
  if (!stat || (kind === "file" ? !stat.isFile() : !stat.isDirectory())) return void 0;
1683
1826
  return [target, stat.size, stat.mtimeMs, stat.ctimeMs];
1684
1827
  } catch {
@@ -1733,11 +1876,11 @@ var PackageClientBoundaryCache = class {
1733
1876
  const { file, contents } = pending;
1734
1877
  const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
1735
1878
  try {
1736
- await fs4.promises.mkdir(path3.dirname(file), { recursive: true });
1737
- await fs4.promises.writeFile(temporary, contents);
1738
- await fs4.promises.rename(temporary, file);
1879
+ await fs5.promises.mkdir(path4.dirname(file), { recursive: true });
1880
+ await fs5.promises.writeFile(temporary, contents);
1881
+ await fs5.promises.rename(temporary, file);
1739
1882
  } catch {
1740
- await fs4.promises.rm(temporary, { force: true }).catch(() => {
1883
+ await fs5.promises.rm(temporary, { force: true }).catch(() => {
1741
1884
  });
1742
1885
  }
1743
1886
  }
@@ -1748,12 +1891,12 @@ var PackageClientBoundaryCache = class {
1748
1891
  const { file, contents } = pending;
1749
1892
  const temporary = `${file}.${process.pid}.${Date.now()}.tmp`;
1750
1893
  try {
1751
- fs4.mkdirSync(path3.dirname(file), { recursive: true });
1752
- fs4.writeFileSync(temporary, contents);
1753
- fs4.renameSync(temporary, file);
1894
+ fs5.mkdirSync(path4.dirname(file), { recursive: true });
1895
+ fs5.writeFileSync(temporary, contents);
1896
+ fs5.renameSync(temporary, file);
1754
1897
  } catch {
1755
1898
  try {
1756
- fs4.rmSync(temporary, { force: true });
1899
+ fs5.rmSync(temporary, { force: true });
1757
1900
  } catch {
1758
1901
  }
1759
1902
  }
@@ -1824,7 +1967,7 @@ var PackageClientBoundaryCache = class {
1824
1967
  function readStoredCache(file) {
1825
1968
  let value;
1826
1969
  try {
1827
- value = JSON.parse(fs4.readFileSync(file, "utf8"));
1970
+ value = JSON.parse(fs5.readFileSync(file, "utf8"));
1828
1971
  } catch {
1829
1972
  return null;
1830
1973
  }
@@ -1845,7 +1988,7 @@ function isRecord(value) {
1845
1988
  return typeof value === "object" && value !== null && !Array.isArray(value);
1846
1989
  }
1847
1990
  function isPathStamp(value) {
1848
- 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));
1991
+ return Array.isArray(value) && value.length === 4 && typeof value[0] === "string" && path4.isAbsolute(value[0]) && value.slice(1).every((part) => typeof part === "number" && Number.isFinite(part));
1849
1992
  }
1850
1993
  function isPathIndexList(value, pathCount) {
1851
1994
  return Array.isArray(value) && value.length > 0 && value.every((index) => Number.isSafeInteger(index) && index >= 0 && index < pathCount);
@@ -1853,7 +1996,7 @@ function isPathIndexList(value, pathCount) {
1853
1996
  function isStoredEntry(value, pathCount) {
1854
1997
  if (!isRecord(value) || !isRecord(value.result)) return false;
1855
1998
  const { isClientComponent, shouldHydrate, islandStrategy } = value.result;
1856
- 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;
1999
+ return isPathIndexList(value.files, pathCount) && isPathIndexList(value.directories, pathCount) && Array.isArray(value.stops) && value.stops.every((file) => typeof file === "string" && path4.isAbsolute(file)) && typeof isClientComponent === "boolean" && typeof shouldHydrate === "boolean" && (islandStrategy === null || isFarmIslandStrategy(islandStrategy)) && Object.keys(value.result).length === 3;
1857
2000
  }
1858
2001
  var STORAGE_KEY = /* @__PURE__ */ Symbol.for("@farm.js/core/package-client-boundary-cache");
1859
2002
  function getStorage() {
@@ -1881,7 +2024,7 @@ function usePackageClientBoundaryCacheFile(file) {
1881
2024
  getPackageClientBoundaryCache()?.load(file);
1882
2025
  }
1883
2026
  function resolvePackageClientBoundaryCacheFile(root, distDir) {
1884
- return path3.resolve(root, distDir, "cache", "client-boundaries.json");
2027
+ return path4.resolve(root, distDir, "cache", "client-boundaries.json");
1885
2028
  }
1886
2029
  function runWithPackageClientBoundaryCacheFile(file, operation) {
1887
2030
  if (getPackageClientBoundaryCache()) return operation();
@@ -1925,10 +2068,10 @@ function readSourceFile(filePath) {
1925
2068
  }
1926
2069
  function readSourceFileContents(filePath) {
1927
2070
  try {
1928
- if (!filePath || !fs5.existsSync(filePath)) {
2071
+ if (!filePath || !fs6.existsSync(filePath)) {
1929
2072
  return null;
1930
2073
  }
1931
- return fs5.readFileSync(filePath, "utf-8");
2074
+ return fs6.readFileSync(filePath, "utf-8");
1932
2075
  } catch {
1933
2076
  return null;
1934
2077
  }
@@ -1947,21 +2090,21 @@ function resolveModuleSourcePath(modulePath, root) {
1947
2090
  }
1948
2091
  if (modulePath.startsWith("/@fs/")) {
1949
2092
  const fsPath = withoutQuery.slice("/@fs/".length);
1950
- candidates.add(path4.normalize(/^[A-Za-z]:/.test(fsPath) ? fsPath : `/${fsPath}`));
2093
+ candidates.add(path5.normalize(/^[A-Za-z]:/.test(fsPath) ? fsPath : `/${fsPath}`));
1951
2094
  }
1952
2095
  }
1953
2096
  if (root && modulePath) {
1954
2097
  const normalized = withoutQuery.replace(/^\/+/, "");
1955
- candidates.add(path4.join(root, normalized));
1956
- candidates.add(path4.resolve(root, normalized));
2098
+ candidates.add(path5.join(root, normalized));
2099
+ candidates.add(path5.resolve(root, normalized));
1957
2100
  }
1958
2101
  if (withoutQuery?.startsWith("/src/")) {
1959
2102
  const normalized = withoutQuery.replace(/^\/+/, "");
1960
- candidates.add(path4.join(process.cwd(), normalized));
1961
- candidates.add(path4.resolve(process.cwd(), normalized));
2103
+ candidates.add(path5.join(process.cwd(), normalized));
2104
+ candidates.add(path5.resolve(process.cwd(), normalized));
1962
2105
  }
1963
2106
  for (const candidate of candidates) {
1964
- if (fs5.existsSync(candidate)) {
2107
+ if (fs6.existsSync(candidate)) {
1965
2108
  return candidate;
1966
2109
  }
1967
2110
  }
@@ -1978,8 +2121,8 @@ var FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES = 4;
1978
2121
  function isolatedHydrationBoundaryLimit() {
1979
2122
  const benchmarkRoot = process.env.FARM_INTERNAL_ISOLATED_HYDRATION_BENCHMARK_ROOT;
1980
2123
  const benchmarkLimit = Number(process.env.FARM_INTERNAL_ISOLATED_HYDRATION_BENCHMARK_LIMIT);
1981
- const resolvedBenchmarkRoot = benchmarkRoot ? path4.resolve(benchmarkRoot) : null;
1982
- const isBenchmarkFixture = process.env.FARM_INTERNAL_BENCHMARK === "isolated-hydration" && resolvedBenchmarkRoot !== null && (process.cwd() === resolvedBenchmarkRoot || process.cwd().startsWith(`${resolvedBenchmarkRoot}${path4.sep}`));
2124
+ const resolvedBenchmarkRoot = benchmarkRoot ? path5.resolve(benchmarkRoot) : null;
2125
+ const isBenchmarkFixture = process.env.FARM_INTERNAL_BENCHMARK === "isolated-hydration" && resolvedBenchmarkRoot !== null && (process.cwd() === resolvedBenchmarkRoot || process.cwd().startsWith(`${resolvedBenchmarkRoot}${path5.sep}`));
1983
2126
  return isBenchmarkFixture && Number.isSafeInteger(benchmarkLimit) && benchmarkLimit > FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES ? benchmarkLimit : FARM_ISOLATED_HYDRATION_MAX_BOUNDARIES;
1984
2127
  }
1985
2128
  var RESOLVABLE_SOURCE_EXTENSIONS = [
@@ -2326,6 +2469,16 @@ function resolveOwnerSourcePath(resolvedPath, root) {
2326
2469
  }
2327
2470
  return current;
2328
2471
  }
2472
+ function getFarmClientRenderingBindings(code, file, root) {
2473
+ const bindings = [];
2474
+ for (const [specifier, locals] of getStaticImportBindings(code)) {
2475
+ const imported = resolveImportedModule(file, specifier, root);
2476
+ if (!imported.path) continue;
2477
+ const metadata = imported.local ? inspectClientModuleMetadata(imported.path, root, /* @__PURE__ */ new Set([path5.resolve(file)]), false) : inspectPackageClientBoundary(imported.path, root, /* @__PURE__ */ new Set());
2478
+ if (metadata.isClientComponent || metadata.shouldHydrate) bindings.push(...locals);
2479
+ }
2480
+ return bindings;
2481
+ }
2329
2482
  function collectFarmRenderedClientModules(modulePath, root) {
2330
2483
  const resolvedPath = resolveOwnerSourcePath(resolveModuleSourcePath(modulePath, root), root);
2331
2484
  if (!resolvedPath) return null;
@@ -2591,6 +2744,13 @@ function enforceFarmIsolatedHydrationRouteBudget(layouts, routes, layoutAppliesT
2591
2744
  (ancestor) => ancestor !== layout && ancestor.depth < layout.depth && ancestor.metadata.shouldHydrate && layoutAppliesToRoute(ancestor.pattern, layout.pattern)
2592
2745
  );
2593
2746
  if (hasRouteWideAncestor && layout.metadata.hasIsolatedClientBoundaries) {
2747
+ if (options.serverOwners && !layout.metadata.asyncOwnerIslands) {
2748
+ layout.metadata.shouldHydrate = layout.metadata.legacyShouldHydrate;
2749
+ layout.metadata.islandStrategy = layout.metadata.legacyIslandStrategy;
2750
+ layout.metadata.hasIsolatedClientBoundaries = false;
2751
+ layout.metadata.serverTreeLayout = true;
2752
+ continue;
2753
+ }
2594
2754
  restoreRouteWideHydration(layout.metadata);
2595
2755
  }
2596
2756
  }
@@ -2930,7 +3090,7 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
2930
3090
  let fallbackReason;
2931
3091
  let fallbackHint;
2932
3092
  let costGuardExceeded = false;
2933
- const projectRoot = root ? path4.resolve(root) : void 0;
3093
+ const projectRoot = root ? path5.resolve(root) : void 0;
2934
3094
  const visit = (moduleSourcePath) => {
2935
3095
  if (fallbackReason) return 0;
2936
3096
  const cached = estimates.get(moduleSourcePath);
@@ -3028,7 +3188,9 @@ function collectIsolatedClientBoundaries(ownerPath, root, options = {}) {
3028
3188
  const localBindings = importedBindings.get(specifier) ?? [];
3029
3189
  const staticUses = countStaticJsxUses(content, localBindings);
3030
3190
  if (staticUses > 0) {
3031
- const container = findParserSensitiveJsxContainer(content, localBindings);
3191
+ const grows = options.packageReferences === true && projectRoot !== void 0 && (findFarmIslandContainers(content ?? "", moduleSourcePath, localBindings)?.length ?? 0) > 0;
3192
+ if (grows) visit(ensureFarmIslandContainerReference(projectRoot));
3193
+ const container = grows ? void 0 : findParserSensitiveJsxContainer(content, localBindings);
3032
3194
  if (container) {
3033
3195
  fallbackReason = `the client boundary imported from ${specifier} renders inside <${container}>, where the HTML parser relocates its hydration marker`;
3034
3196
  fallbackHint = `Move "use client" up to a component that renders the whole <${container}>${PARSER_SENSITIVE_FLOW_HINTS[container] ?? ""}`;
@@ -3115,13 +3277,13 @@ function inspectClientModuleMetadata(resolvedPath, root, visited, inspectIslandE
3115
3277
  }
3116
3278
  function farmWorkspaceServerEntry(entry) {
3117
3279
  const real = realpathOrSelf(entry);
3118
- if (real.split(path4.sep).includes("node_modules")) return null;
3280
+ if (real.split(path5.sep).includes("node_modules")) return null;
3119
3281
  if (parseClientModuleMetadata(readIfExists(real), false).isClientComponent) return null;
3120
3282
  return real;
3121
3283
  }
3122
3284
  function realpathOrSelf(file) {
3123
3285
  try {
3124
- return fs5.realpathSync(file);
3286
+ return fs6.realpathSync(file);
3125
3287
  } catch {
3126
3288
  return file;
3127
3289
  }
@@ -3308,7 +3470,7 @@ var ALIAS_IMPORT = /^(?:@\/|~\/|#)/;
3308
3470
  function warnUnresolvedAliasImport(importerPath, specifier, root) {
3309
3471
  if (!ALIAS_IMPORT.test(specifier) || warnedUnresolvedAliasImports.has(specifier)) return;
3310
3472
  warnedUnresolvedAliasImports.add(specifier);
3311
- const importer = root ? path4.relative(root, importerPath) : importerPath;
3473
+ const importer = root ? path5.relative(root, importerPath) : importerPath;
3312
3474
  logger.warn(
3313
3475
  `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".`
3314
3476
  );
@@ -3317,7 +3479,7 @@ var projectImportAliasCache = /* @__PURE__ */ new Map();
3317
3479
  var PROJECT_ALIAS_FILES = ["tsconfig.json", "jsconfig.json", "package.json"];
3318
3480
  function resolveProjectAliasSourcePath(specifier, root) {
3319
3481
  if (!root) return void 0;
3320
- const projectRoot = path4.resolve(root);
3482
+ const projectRoot = path5.resolve(root);
3321
3483
  let match;
3322
3484
  for (const alias of getProjectImportAliases(projectRoot)) {
3323
3485
  const captured = matchProjectImportAlias(alias, specifier);
@@ -3327,7 +3489,7 @@ function resolveProjectAliasSourcePath(specifier, root) {
3327
3489
  if (!match) return void 0;
3328
3490
  const resolved = resolveSourceCandidate(
3329
3491
  match.alias.targets.map(
3330
- (target) => path4.normalize(match.alias.wildcard ? target.replace("*", match.captured) : target)
3492
+ (target) => path5.normalize(match.alias.wildcard ? target.replace("*", match.captured) : target)
3331
3493
  )
3332
3494
  );
3333
3495
  return resolved && /\.d\.[cm]?ts$/.test(resolved) ? null : resolved;
@@ -3342,7 +3504,7 @@ function matchProjectImportAlias(alias, specifier) {
3342
3504
  function getProjectImportAliases(projectRoot) {
3343
3505
  const stamp = PROJECT_ALIAS_FILES.map((file) => {
3344
3506
  try {
3345
- return String(fs5.statSync(path4.join(projectRoot, file)).mtimeMs);
3507
+ return String(fs6.statSync(path5.join(projectRoot, file)).mtimeMs);
3346
3508
  } catch {
3347
3509
  return "-";
3348
3510
  }
@@ -3360,7 +3522,7 @@ function getProjectImportAliases(projectRoot) {
3360
3522
  prefix: "@/",
3361
3523
  suffix: "",
3362
3524
  wildcard: true,
3363
- targets: [path4.join(projectRoot, sourceDir, "*")]
3525
+ targets: [path5.join(projectRoot, sourceDir, "*")]
3364
3526
  });
3365
3527
  }
3366
3528
  projectImportAliasCache.set(projectRoot, { stamp: cacheStamp, aliases });
@@ -3368,8 +3530,8 @@ function getProjectImportAliases(projectRoot) {
3368
3530
  }
3369
3531
  function readTsconfigPathAliases(projectRoot) {
3370
3532
  for (const name of ["tsconfig.json", "jsconfig.json"]) {
3371
- const configPath = path4.join(projectRoot, name);
3372
- if (!fs5.existsSync(configPath)) continue;
3533
+ const configPath = path5.join(projectRoot, name);
3534
+ if (!fs6.existsSync(configPath)) continue;
3373
3535
  const resolved = readTsconfigPaths(configPath, /* @__PURE__ */ new Set());
3374
3536
  if (!resolved?.paths) return [];
3375
3537
  const base = resolved.baseUrl ?? resolved.pathsDirectory;
@@ -3381,7 +3543,7 @@ function readTsconfigPathAliases(projectRoot) {
3381
3543
  prefix: wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex),
3382
3544
  suffix: wildcardIndex === -1 ? "" : pattern.slice(wildcardIndex + 1),
3383
3545
  wildcard: wildcardIndex !== -1,
3384
- targets: targets.filter((target) => typeof target === "string").map((target) => path4.resolve(base, target))
3546
+ targets: targets.filter((target) => typeof target === "string").map((target) => path5.resolve(base, target))
3385
3547
  }
3386
3548
  ];
3387
3549
  });
@@ -3393,27 +3555,27 @@ function readTsconfigPaths(configPath, visited) {
3393
3555
  visited.add(configPath);
3394
3556
  const config = readJsonWithComments(configPath);
3395
3557
  if (!config) return null;
3396
- const directory = path4.dirname(configPath);
3558
+ const directory = path5.dirname(configPath);
3397
3559
  const parents = (Array.isArray(config.extends) ? config.extends : [config.extends]).filter(
3398
3560
  (parent) => typeof parent === "string" && parent.startsWith(".")
3399
3561
  );
3400
3562
  let inherited = null;
3401
3563
  for (const parent of parents) {
3402
- const parentPath = path4.resolve(
3564
+ const parentPath = path5.resolve(
3403
3565
  directory,
3404
3566
  parent.endsWith(".json") ? parent : `${parent}.json`
3405
3567
  );
3406
3568
  inherited = readTsconfigPaths(parentPath, visited) ?? inherited;
3407
3569
  }
3408
3570
  const options = config.compilerOptions ?? {};
3409
- const baseUrl = typeof options.baseUrl === "string" ? path4.resolve(directory, options.baseUrl) : inherited?.baseUrl;
3571
+ const baseUrl = typeof options.baseUrl === "string" ? path5.resolve(directory, options.baseUrl) : inherited?.baseUrl;
3410
3572
  if (options.paths && typeof options.paths === "object") {
3411
3573
  return { paths: options.paths, pathsDirectory: directory, baseUrl };
3412
3574
  }
3413
3575
  return inherited ? { ...inherited, baseUrl } : { pathsDirectory: directory, baseUrl };
3414
3576
  }
3415
3577
  function readPackageImportAliases(projectRoot) {
3416
- const imports = readPackageJson(path4.join(projectRoot, "package.json"))?.imports;
3578
+ const imports = readPackageJson(path5.join(projectRoot, "package.json"))?.imports;
3417
3579
  if (!imports || typeof imports !== "object") return [];
3418
3580
  return Object.entries(imports).flatMap(([pattern, value]) => {
3419
3581
  const target = resolveConditionalExportTarget(value);
@@ -3424,7 +3586,7 @@ function readPackageImportAliases(projectRoot) {
3424
3586
  prefix: wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex),
3425
3587
  suffix: wildcardIndex === -1 ? "" : pattern.slice(wildcardIndex + 1),
3426
3588
  wildcard: wildcardIndex !== -1,
3427
- targets: [path4.resolve(projectRoot, target)]
3589
+ targets: [path5.resolve(projectRoot, target)]
3428
3590
  }
3429
3591
  ];
3430
3592
  });
@@ -3432,7 +3594,7 @@ function readPackageImportAliases(projectRoot) {
3432
3594
  function readJsonWithComments(filePath) {
3433
3595
  let source;
3434
3596
  try {
3435
- source = fs5.readFileSync(filePath, "utf8");
3597
+ source = fs6.readFileSync(filePath, "utf8");
3436
3598
  } catch {
3437
3599
  return null;
3438
3600
  }
@@ -3470,7 +3632,7 @@ function resolveImportedModuleSourcePath(importerPath, specifier, root) {
3470
3632
  return resolvePackageModuleSourcePath(importerPath, specifier, root);
3471
3633
  }
3472
3634
  const candidates = /* @__PURE__ */ new Set();
3473
- const basePath = specifier.startsWith(".") ? path4.resolve(path4.dirname(importerPath), specifier) : root ? path4.resolve(root, specifier.replace(/^\/+/, "")) : path4.resolve(specifier);
3635
+ const basePath = specifier.startsWith(".") ? path5.resolve(path5.dirname(importerPath), specifier) : root ? path5.resolve(root, specifier.replace(/^\/+/, "")) : path5.resolve(specifier);
3474
3636
  candidates.add(basePath);
3475
3637
  return resolveSourceCandidate(candidates);
3476
3638
  }
@@ -3480,45 +3642,45 @@ function resolvePackageModuleSourcePath(importerPath, specifier, root) {
3480
3642
  const packageSubpath = packageParts.slice(packageName.startsWith("@") ? 2 : 1).join("/");
3481
3643
  const packageDirectory = findPackageDirectory2(importerPath, packageName, root);
3482
3644
  if (!packageDirectory) return null;
3483
- const packageJsonPath = path4.join(packageDirectory, "package.json");
3645
+ const packageJsonPath = path5.join(packageDirectory, "package.json");
3484
3646
  const packageJson = readPackageJson(packageJsonPath);
3485
3647
  const exportKey = packageSubpath ? `./${packageSubpath}` : ".";
3486
3648
  const exportTarget = resolvePackageExport(packageJson?.exports, exportKey);
3487
3649
  const candidates = /* @__PURE__ */ new Set();
3488
3650
  if (exportTarget?.startsWith("./")) {
3489
- candidates.add(path4.resolve(packageDirectory, exportTarget));
3651
+ candidates.add(path5.resolve(packageDirectory, exportTarget));
3490
3652
  }
3491
3653
  if (packageSubpath) {
3492
- candidates.add(path4.join(packageDirectory, packageSubpath));
3654
+ candidates.add(path5.join(packageDirectory, packageSubpath));
3493
3655
  } else {
3494
3656
  for (const entry of [packageJson?.browser, packageJson?.module, packageJson?.main]) {
3495
- if (typeof entry === "string") candidates.add(path4.resolve(packageDirectory, entry));
3657
+ if (typeof entry === "string") candidates.add(path5.resolve(packageDirectory, entry));
3496
3658
  }
3497
- candidates.add(path4.join(packageDirectory, "index"));
3659
+ candidates.add(path5.join(packageDirectory, "index"));
3498
3660
  }
3499
3661
  return resolveSourceCandidate(candidates);
3500
3662
  }
3501
3663
  function findPackageDirectory2(importerPath, packageName, root) {
3502
3664
  const searchRoots = /* @__PURE__ */ new Set();
3503
- let current = path4.dirname(importerPath);
3665
+ let current = path5.dirname(importerPath);
3504
3666
  while (true) {
3505
3667
  searchRoots.add(current);
3506
- const parent = path4.dirname(current);
3668
+ const parent = path5.dirname(current);
3507
3669
  if (parent === current) break;
3508
3670
  current = parent;
3509
3671
  }
3510
3672
  if (root) {
3511
- current = path4.resolve(root);
3673
+ current = path5.resolve(root);
3512
3674
  while (true) {
3513
3675
  searchRoots.add(current);
3514
- const parent = path4.dirname(current);
3676
+ const parent = path5.dirname(current);
3515
3677
  if (parent === current) break;
3516
3678
  current = parent;
3517
3679
  }
3518
3680
  }
3519
3681
  for (const searchRoot of searchRoots) {
3520
- const packageDirectory = path4.join(searchRoot, "node_modules", packageName);
3521
- if (fs5.existsSync(path4.join(packageDirectory, "package.json"))) {
3682
+ const packageDirectory = path5.join(searchRoot, "node_modules", packageName);
3683
+ if (fs6.existsSync(path5.join(packageDirectory, "package.json"))) {
3522
3684
  return packageDirectory;
3523
3685
  }
3524
3686
  }
@@ -3526,7 +3688,7 @@ function findPackageDirectory2(importerPath, packageName, root) {
3526
3688
  }
3527
3689
  function readPackageJson(packageJsonPath) {
3528
3690
  try {
3529
- return JSON.parse(fs5.readFileSync(packageJsonPath, "utf8"));
3691
+ return JSON.parse(fs6.readFileSync(packageJsonPath, "utf8"));
3530
3692
  } catch {
3531
3693
  return null;
3532
3694
  }
@@ -3584,11 +3746,11 @@ function resolveSourceCandidate(candidates) {
3584
3746
  for (const candidate of candidates) {
3585
3747
  const paths = [candidate];
3586
3748
  for (const extension of RESOLVABLE_SOURCE_EXTENSIONS) {
3587
- paths.push(`${candidate}${extension}`, path4.join(candidate, `index${extension}`));
3749
+ paths.push(`${candidate}${extension}`, path5.join(candidate, `index${extension}`));
3588
3750
  }
3589
3751
  for (const sourcePath of paths) {
3590
3752
  try {
3591
- if (fs5.statSync(sourcePath).isFile()) return sourcePath;
3753
+ if (fs6.statSync(sourcePath).isFile()) return sourcePath;
3592
3754
  } catch {
3593
3755
  }
3594
3756
  }
@@ -3631,13 +3793,13 @@ function scanFarmPackageImports(directory, root) {
3631
3793
  const walk2 = (current) => {
3632
3794
  let entries;
3633
3795
  try {
3634
- entries = fs5.readdirSync(current, { withFileTypes: true });
3796
+ entries = fs6.readdirSync(current, { withFileTypes: true });
3635
3797
  } catch {
3636
3798
  return;
3637
3799
  }
3638
3800
  for (const entry of entries) {
3639
3801
  if (entry.name.startsWith(".") && entry.isDirectory()) continue;
3640
- const file = path4.join(current, entry.name);
3802
+ const file = path5.join(current, entry.name);
3641
3803
  if (entry.isDirectory()) {
3642
3804
  if (!CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
3643
3805
  continue;
@@ -3664,13 +3826,13 @@ function collectFarmServerBundledPackageInfo(directory) {
3664
3826
  const walk2 = (current) => {
3665
3827
  let entries;
3666
3828
  try {
3667
- entries = fs5.readdirSync(current, { withFileTypes: true });
3829
+ entries = fs6.readdirSync(current, { withFileTypes: true });
3668
3830
  } catch {
3669
3831
  return;
3670
3832
  }
3671
3833
  for (const entry of entries) {
3672
3834
  if (entry.name.startsWith(".") && entry.isDirectory()) continue;
3673
- const file = path4.join(current, entry.name);
3835
+ const file = path5.join(current, entry.name);
3674
3836
  if (entry.isDirectory()) {
3675
3837
  if (!CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
3676
3838
  continue;
@@ -3695,7 +3857,7 @@ function invalidateFarmClientReachableModules() {
3695
3857
  clientReachableModules.clear();
3696
3858
  }
3697
3859
  function getFarmClientReachableModules(directory, root) {
3698
- const key = `${path4.resolve(root)}\0${path4.resolve(directory)}`;
3860
+ const key = `${path5.resolve(root)}\0${path5.resolve(directory)}`;
3699
3861
  const cached = clientReachableModules.get(key);
3700
3862
  if (cached) return cached;
3701
3863
  const reachable = /* @__PURE__ */ new Set();
@@ -3703,12 +3865,12 @@ function getFarmClientReachableModules(directory, root) {
3703
3865
  const walk2 = (current) => {
3704
3866
  let entries;
3705
3867
  try {
3706
- entries = fs5.readdirSync(current, { withFileTypes: true });
3868
+ entries = fs6.readdirSync(current, { withFileTypes: true });
3707
3869
  } catch {
3708
3870
  return;
3709
3871
  }
3710
3872
  for (const entry of entries) {
3711
- const file = path4.join(current, entry.name);
3873
+ const file = path5.join(current, entry.name);
3712
3874
  if (entry.isDirectory()) {
3713
3875
  if (!entry.name.startsWith(".") && !CLIENT_PACKAGE_SCAN_SKIP.has(entry.name)) walk2(file);
3714
3876
  } else if (isScannedSourceFile(entry.name)) {
@@ -3719,12 +3881,12 @@ function getFarmClientReachableModules(directory, root) {
3719
3881
  };
3720
3882
  walk2(directory);
3721
3883
  while (queue.length > 0) {
3722
- const file = path4.resolve(queue.pop());
3884
+ const file = path5.resolve(queue.pop());
3723
3885
  if (reachable.has(file)) continue;
3724
3886
  reachable.add(file);
3725
3887
  for (const specifier of getImportSpecifiers(readIfExists(file), { dynamic: true })) {
3726
3888
  const imported = resolveImportedModule(file, specifier, root);
3727
- if (imported.local && imported.path && !reachable.has(path4.resolve(imported.path))) {
3889
+ if (imported.local && imported.path && !reachable.has(path5.resolve(imported.path))) {
3728
3890
  queue.push(imported.path);
3729
3891
  }
3730
3892
  }
@@ -3733,7 +3895,7 @@ function getFarmClientReachableModules(directory, root) {
3733
3895
  return reachable;
3734
3896
  }
3735
3897
  function resolveFarmClientOptimizeDeps(directory, root) {
3736
- const importer = path4.join(path4.resolve(root), "package.json");
3898
+ const importer = path5.join(path5.resolve(root), "package.json");
3737
3899
  const include = /* @__PURE__ */ new Set();
3738
3900
  const exclude = /* @__PURE__ */ new Set();
3739
3901
  const imports = scanFarmPackageImports(directory, root);
@@ -3831,7 +3993,7 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3831
3993
  routesFiles = new Set(
3832
3994
  getFarmSourceRoots({ ...options, root: options.root ?? config.root }).flatMap(
3833
3995
  (source) => PROGRAMMATIC_ROUTE_FILE_NAMES.map(
3834
- (name) => resolvedFile(path5.resolve(source.root, source.srcDir, name))
3996
+ (name) => resolvedFile(path6.resolve(source.root, source.srcDir, name))
3835
3997
  )
3836
3998
  )
3837
3999
  );
@@ -3841,20 +4003,20 @@ function farmEnvironmentFunctionsPlugin(options = {}) {
3841
4003
  this,
3842
4004
  transformOptions?.ssr
3843
4005
  );
3844
- const parse2 = (source) => this.parse(source);
3845
- const result = transformEnvironmentFunctions({ code, id, environment, parse: parse2 });
4006
+ const parse3 = (source) => this.parse(source);
4007
+ const result = transformEnvironmentFunctions({ code, id, environment, parse: parse3 });
3846
4008
  if (environment === "client" && !isBuild && !parseProgrammaticRouteModuleId(id) && routeSourceFiles().has(moduleFile(id)) && !isProgrammaticRouteActionProxy(code)) {
3847
4009
  this.error(routeSourceError(moduleFile(id)));
3848
4010
  }
3849
4011
  if (environment === "server" && resolveFarmServerComponentsMode(options.experimental?.serverComponents) === "islands" && isApplicationScript(id)) {
3850
4012
  const file = id.split("?", 1)[0];
3851
4013
  const root = realpathSync(options.root ?? projectRoot);
3852
- const clientCode = getFarmClientReachableModules(root, root).has(path5.resolve(file)) || existsSync(file) && hasUseClientDirective(readFileSync(file, "utf8"));
4014
+ const clientCode = getFarmClientReachableModules(root, root).has(path6.resolve(file)) || existsSync(file) && hasUseClientDirective(readFileSync(file, "utf8"));
3853
4015
  const reached = clientCode ? null : findFarmClientOnlyImport(code, file);
3854
4016
  if (reached) {
3855
- const chain = reached.chain.map((step) => path5.relative(root, step)).join(" -> ");
4017
+ const chain = reached.chain.map((step) => path6.relative(root, step)).join(" -> ");
3856
4018
  this.error(
3857
- `[Farm.js] ${path5.relative(root, file)} is server code, but its import of "${reached.specifier}" reaches "client-only" (${chain}), so that package can only run in the browser. Add "use client" to this module, or import the package from a "use client" module.`
4019
+ `[Farm.js] ${path6.relative(root, file)} is server code, but its import of "${reached.specifier}" reaches "client-only" (${chain}), so that package can only run in the browser. Add "use client" to this module, or import the package from a "use client" module.`
3858
4020
  );
3859
4021
  }
3860
4022
  }
@@ -4178,6 +4340,9 @@ export {
4178
4340
  ensureFarmPackageClientReference,
4179
4341
  ensureFarmInternalClientReference,
4180
4342
  rewriteFarmPackageClientImports,
4343
+ farmIslandContainerReferencePath,
4344
+ ensureFarmIslandContainerReference,
4345
+ wrapFarmIslandContainers,
4181
4346
  withPackageClientBoundaryCache,
4182
4347
  usePackageClientBoundaryCacheFile,
4183
4348
  resolvePackageClientBoundaryCacheFile,
@@ -4191,6 +4356,7 @@ export {
4191
4356
  hasUseClientDirective,
4192
4357
  getIslandStrategyExport,
4193
4358
  stripUseClientDirective,
4359
+ getFarmClientRenderingBindings,
4194
4360
  collectFarmRenderedClientModules,
4195
4361
  collectFarmServerStylesheets,
4196
4362
  getClientModuleMetadata,