@farm.js/core 0.1.42 → 0.1.43

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 (235) hide show
  1. package/dist/{agent-mcp-ssVy_tea.d.mts → agent-mcp-3KDz4hr9.d.mts} +1 -1
  2. package/dist/{agent-mcp-SSD6L3VZ.d.ts → agent-mcp-6yRebHk7.d.ts} +1 -1
  3. package/dist/agent-runtime.d.mts +1 -1
  4. package/dist/agent-runtime.d.ts +1 -1
  5. package/dist/api/route-manager.d.mts +3 -3
  6. package/dist/api/route-manager.d.ts +3 -3
  7. package/dist/api/runtime.d.mts +2 -2
  8. package/dist/api/runtime.d.ts +2 -2
  9. package/dist/api.cjs +2 -2
  10. package/dist/api.d.mts +8 -3
  11. package/dist/api.d.ts +8 -3
  12. package/dist/api.mjs +1 -1
  13. package/dist/{app-KjFzdCqy.d.ts → app-8Db1zR-2.d.ts} +8 -4
  14. package/dist/{app-1h3lVT4a.d.mts → app-DlTWv4cn.d.mts} +8 -4
  15. package/dist/{app-manifest-D3RkVNuS.d.mts → app-manifest-TRzS7ZZ9.d.mts} +1 -1
  16. package/dist/{app-manifest-DaW8-tvX.d.ts → app-manifest-cO2jkG1F.d.ts} +1 -1
  17. package/dist/app-markdown.d.mts +2 -2
  18. package/dist/app-markdown.d.ts +2 -2
  19. package/dist/{chunk-ECKF2BAM.cjs → chunk-2GVF3C2F.cjs} +255 -42
  20. package/dist/chunk-2NXO5SBY.mjs +57 -0
  21. package/dist/chunk-3BROEWFY.cjs +39 -0
  22. package/dist/{chunk-NU25TRIO.mjs → chunk-4MRQ5OKQ.mjs} +11 -7
  23. package/dist/{chunk-375K2ZVU.mjs → chunk-4OCEMK72.mjs} +259 -48
  24. package/dist/{chunk-6PKXK4TY.mjs → chunk-53ZV6K65.mjs} +1 -1
  25. package/dist/{chunk-LYIZHJTK.cjs → chunk-5LPHJZSI.cjs} +14 -14
  26. package/dist/chunk-5NIWBWDD.mjs +97 -0
  27. package/dist/{chunk-NRDBW4MP.mjs → chunk-7IQQIPRZ.mjs} +10 -0
  28. package/dist/{chunk-QTEJGB5A.mjs → chunk-7SCCY6SI.mjs} +79 -176
  29. package/dist/chunk-APDGOKKE.cjs +148 -0
  30. package/dist/chunk-AZBSVLRM.cjs +132 -0
  31. package/dist/{chunk-ZS6HDNOM.cjs → chunk-BKPXWRTT.cjs} +6 -6
  32. package/dist/chunk-CEDPEDNW.cjs +98 -0
  33. package/dist/chunk-D5RFPV2H.mjs +148 -0
  34. package/dist/{chunk-724JLMS4.mjs → chunk-F646BZ4Y.mjs} +4 -2
  35. package/dist/{chunk-C5KVWHIH.cjs → chunk-G2Z5DGMS.cjs} +5 -3
  36. package/dist/{chunk-7YHSD3Z6.cjs → chunk-GVNCWSQV.cjs} +83 -29
  37. package/dist/{chunk-24SP5TGU.mjs → chunk-H4LXPWI2.mjs} +2 -2
  38. package/dist/chunk-H7BLEEAE.cjs +57 -0
  39. package/dist/{chunk-QKZMB7LY.cjs → chunk-HUMEHX24.cjs} +2 -2
  40. package/dist/{chunk-BD3D7EZV.cjs → chunk-IXFOBGLQ.cjs} +9 -3
  41. package/dist/{chunk-JG3MEQUH.cjs → chunk-JDJAPCR2.cjs} +420 -209
  42. package/dist/{chunk-MHN4UR5U.cjs → chunk-KFZZFZ7J.cjs} +7 -7
  43. package/dist/chunk-LRJRXXQZ.cjs +109 -0
  44. package/dist/{chunk-BXJ5HJTJ.cjs → chunk-LVABUXLA.cjs} +15 -11
  45. package/dist/{chunk-HCSVR4YZ.mjs → chunk-M3BXTWJM.mjs} +18 -0
  46. package/dist/{chunk-2JZHQDUY.mjs → chunk-NXO75WY4.mjs} +1 -1
  47. package/dist/{chunk-TUL355PH.mjs → chunk-OYSGGV6O.mjs} +135 -160
  48. package/dist/{chunk-JR4QCLJY.cjs → chunk-PDU4P2IC.cjs} +19 -1
  49. package/dist/chunk-PJEHUSHA.mjs +229 -0
  50. package/dist/chunk-QGH2RQVF.mjs +132 -0
  51. package/dist/{chunk-YWMZUGIS.mjs → chunk-R3ZFQJEF.mjs} +247 -34
  52. package/dist/{chunk-ZATTDMBW.cjs → chunk-RACQTC7K.cjs} +270 -367
  53. package/dist/{chunk-WSOBCAYO.cjs → chunk-RQYTOFQM.cjs} +23 -23
  54. package/dist/chunk-S34OBRMZ.mjs +109 -0
  55. package/dist/{chunk-TS4JHGUJ.mjs → chunk-S3ZEMCE6.mjs} +9 -3
  56. package/dist/{chunk-WWFTAUFG.cjs → chunk-SBH2JLLF.cjs} +12 -2
  57. package/dist/{chunk-YSLWRWWP.cjs → chunk-SKK6UF5P.cjs} +200 -46
  58. package/dist/chunk-T7J7E63D.cjs +144 -0
  59. package/dist/{chunk-PIZXONIS.mjs → chunk-TESO7EFU.mjs} +55 -1
  60. package/dist/{chunk-TCJ4A4A2.cjs → chunk-VIVQERJ5.cjs} +318 -344
  61. package/dist/{chunk-JIYYX7WU.mjs → chunk-VLXNGUKO.mjs} +1 -1
  62. package/dist/{chunk-OFZUJMCU.mjs → chunk-WPJQN64R.mjs} +195 -41
  63. package/dist/chunk-XARSG2TG.mjs +144 -0
  64. package/dist/chunk-XUGFRFD2.mjs +39 -0
  65. package/dist/{chunk-AHFRQMRX.cjs → chunk-YBDSTNMH.cjs} +1 -1
  66. package/dist/{chunk-U2UC7UGP.mjs → chunk-YGZH4T2X.mjs} +1 -1
  67. package/dist/chunk-YKUEJ3MG.cjs +229 -0
  68. package/dist/{chunk-IVQY6UTY.mjs → chunk-ZYWJIPKQ.mjs} +1 -1
  69. package/dist/{client-plugins-C9Py_50W.d.mts → client-plugins-Cv0OJtnM.d.mts} +21 -2
  70. package/dist/{client-plugins-DIem0I0W.d.ts → client-plugins-kwQuZcWq.d.ts} +21 -2
  71. package/dist/client-plugins.d.mts +1 -1
  72. package/dist/client-plugins.d.ts +1 -1
  73. package/dist/client.cjs +4 -3
  74. package/dist/client.d.mts +5 -5
  75. package/dist/client.d.ts +5 -5
  76. package/dist/client.mjs +3 -2
  77. package/dist/config.d.mts +1 -1
  78. package/dist/config.d.ts +1 -1
  79. package/dist/{devtools-Q3LBNUJ7.mjs → devtools-M22FEFPK.mjs} +3 -3
  80. package/dist/{devtools-2RY3EKHL.cjs → devtools-MLB3JJMC.cjs} +4 -4
  81. package/dist/docs.cjs +5 -5
  82. package/dist/docs.d.mts +2 -2
  83. package/dist/docs.d.ts +2 -2
  84. package/dist/docs.mjs +4 -4
  85. package/dist/index-CQOp8EmB.d.mts +48 -0
  86. package/dist/index-DAl0QTZS.d.ts +48 -0
  87. package/dist/index.cjs +40 -23
  88. package/dist/index.d.mts +15 -15
  89. package/dist/index.d.ts +15 -15
  90. package/dist/index.mjs +45 -28
  91. package/dist/integrations.d.mts +1 -1
  92. package/dist/integrations.d.ts +1 -1
  93. package/dist/internal/app-markdown-runtime.d.mts +2 -2
  94. package/dist/internal/app-markdown-runtime.d.ts +2 -2
  95. package/dist/internal/build-runtime.cjs +28 -14
  96. package/dist/internal/build-runtime.d.mts +12 -16
  97. package/dist/internal/build-runtime.d.ts +12 -16
  98. package/dist/internal/build-runtime.mjs +27 -13
  99. package/dist/internal/cli-runtime.cjs +22 -10
  100. package/dist/internal/cli-runtime.mjs +22 -10
  101. package/dist/internal/client-error-overlay.cjs +4 -4
  102. package/dist/internal/client-error-overlay.mjs +1 -1
  103. package/dist/internal/client-runtime.cjs +5 -1
  104. package/dist/internal/client-runtime.d.mts +1 -0
  105. package/dist/internal/client-runtime.d.ts +1 -0
  106. package/dist/internal/client-runtime.mjs +4 -0
  107. package/dist/internal/compression-runtime.d.mts +1 -1
  108. package/dist/internal/compression-runtime.d.ts +1 -1
  109. package/dist/internal/config-runtime.cjs +4 -4
  110. package/dist/internal/config-runtime.d.mts +2 -2
  111. package/dist/internal/config-runtime.d.ts +2 -2
  112. package/dist/internal/config-runtime.mjs +3 -3
  113. package/dist/internal/form-actions-client.cjs +18 -0
  114. package/dist/internal/form-actions-client.d.mts +5 -0
  115. package/dist/internal/form-actions-client.d.ts +5 -0
  116. package/dist/internal/form-actions-client.mjs +18 -0
  117. package/dist/internal/form-actions.cjs +18 -0
  118. package/dist/internal/form-actions.d.mts +14 -0
  119. package/dist/internal/form-actions.d.ts +14 -0
  120. package/dist/internal/form-actions.mjs +18 -0
  121. package/dist/internal/island-codec.cjs +22 -0
  122. package/dist/internal/island-codec.d.mts +29 -0
  123. package/dist/internal/island-codec.d.ts +29 -0
  124. package/dist/internal/island-codec.mjs +22 -0
  125. package/dist/internal/island-value-store.cjs +13 -0
  126. package/dist/internal/island-value-store.d.mts +6 -0
  127. package/dist/internal/island-value-store.d.ts +6 -0
  128. package/dist/internal/island-value-store.mjs +13 -0
  129. package/dist/internal/islands-runtime.cjs +77 -0
  130. package/dist/internal/islands-runtime.d.mts +57 -0
  131. package/dist/internal/islands-runtime.d.ts +57 -0
  132. package/dist/internal/islands-runtime.mjs +77 -0
  133. package/dist/internal/islands-server.cjs +19 -0
  134. package/dist/internal/islands-server.d.mts +3 -0
  135. package/dist/internal/islands-server.d.ts +3 -0
  136. package/dist/internal/islands-server.mjs +19 -0
  137. package/dist/internal/islx-client.cjs +5 -0
  138. package/dist/internal/islx-client.d.mts +2 -0
  139. package/dist/internal/islx-client.d.ts +2 -0
  140. package/dist/internal/islx-client.mjs +3 -0
  141. package/dist/internal/islx-react.cjs +4 -0
  142. package/dist/internal/islx-react.d.mts +1 -0
  143. package/dist/internal/islx-react.d.ts +1 -0
  144. package/dist/internal/islx-react.mjs +2 -0
  145. package/dist/internal/islx-server.cjs +5 -0
  146. package/dist/internal/islx-server.d.mts +2 -0
  147. package/dist/internal/islx-server.d.ts +2 -0
  148. package/dist/internal/islx-server.mjs +3 -0
  149. package/dist/internal/isolated-boundary.cjs +4 -3
  150. package/dist/internal/isolated-boundary.d.mts +13 -1
  151. package/dist/internal/isolated-boundary.d.ts +13 -1
  152. package/dist/internal/isolated-boundary.mjs +3 -2
  153. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  154. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  155. package/dist/internal/production-runtime.cjs +23 -6
  156. package/dist/internal/production-runtime.d.mts +20 -10
  157. package/dist/internal/production-runtime.d.ts +20 -10
  158. package/dist/internal/production-runtime.mjs +23 -6
  159. package/dist/internal/server-tree.cjs +6 -3
  160. package/dist/internal/server-tree.d.mts +25 -2
  161. package/dist/internal/server-tree.d.ts +25 -2
  162. package/dist/internal/server-tree.mjs +7 -4
  163. package/dist/island-value-protocol-BRayRghM.d.mts +12 -0
  164. package/dist/island-value-protocol-BRayRghM.d.ts +12 -0
  165. package/dist/markdown.d.mts +1 -1
  166. package/dist/markdown.d.ts +1 -1
  167. package/dist/middleware.d.mts +3 -3
  168. package/dist/middleware.d.ts +3 -3
  169. package/dist/navigation.cjs +5 -4
  170. package/dist/navigation.d.mts +4 -4
  171. package/dist/navigation.d.ts +4 -4
  172. package/dist/navigation.mjs +4 -3
  173. package/dist/og.d.mts +5 -0
  174. package/dist/og.d.ts +5 -0
  175. package/dist/plugin.cjs +17 -11
  176. package/dist/plugin.d.mts +3 -3
  177. package/dist/plugin.d.ts +3 -3
  178. package/dist/plugin.mjs +16 -10
  179. package/dist/{production-runtime-bjjWq-DA.d.ts → production-runtime-5nArjFpn.d.ts} +1 -1
  180. package/dist/{production-runtime-CHFKIgpW.d.mts → production-runtime-BzsF2z5F.d.mts} +1 -1
  181. package/dist/query/client.cjs +6 -5
  182. package/dist/query/client.mjs +2 -1
  183. package/dist/{render-plan-DOHg6wdO.d.mts → render-plan-B9yQorV4.d.mts} +4 -2
  184. package/dist/{render-plan-B2UndB4x.d.ts → render-plan-fg6E_HvL.d.ts} +4 -2
  185. package/dist/renderer/react/server.cjs +7 -6
  186. package/dist/renderer/react/server.d.mts +3 -1
  187. package/dist/renderer/react/server.d.ts +3 -1
  188. package/dist/renderer/react/server.mjs +5 -4
  189. package/dist/renderer-client.cjs +5 -4
  190. package/dist/renderer-client.d.mts +3 -3
  191. package/dist/renderer-client.d.ts +3 -3
  192. package/dist/renderer-client.mjs +2 -1
  193. package/dist/renderer.d.mts +3 -1
  194. package/dist/renderer.d.ts +3 -1
  195. package/dist/{request-DQcGfdgQ.d.mts → request-C4j_g-BH.d.mts} +1 -1
  196. package/dist/{request-DVNXRQrI.d.ts → request-gz8vFK0n.d.ts} +1 -1
  197. package/dist/request.d.mts +2 -2
  198. package/dist/request.d.ts +2 -2
  199. package/dist/{route-rendering-B_6fj-GG.d.ts → route-rendering-DamyKVi3.d.ts} +1 -1
  200. package/dist/{route-rendering-CEX4mFn-.d.mts → route-rendering-iTTOwz1f.d.mts} +1 -1
  201. package/dist/{router-CKHPBKXX.d.mts → router-EoSzHlos.d.mts} +1 -1
  202. package/dist/{router-CHEMHm1P.d.ts → router-OVjDqVo8.d.ts} +1 -1
  203. package/dist/routes.d.mts +1 -1
  204. package/dist/routes.d.ts +1 -1
  205. package/dist/rsc-pipeline-LK4K5JFK.mjs +77 -0
  206. package/dist/rsc-pipeline-YCDRJME4.cjs +77 -0
  207. package/dist/{runtime-Br2ZDTAv.d.ts → runtime-CwiuozLd.d.ts} +1 -1
  208. package/dist/{runtime-jj8TKNsy.d.mts → runtime-DDH4tiuF.d.mts} +1 -1
  209. package/dist/{schema-dev-notice-5JPE67AI.cjs → schema-dev-notice-77ZL23PL.cjs} +4 -4
  210. package/dist/{schema-dev-notice-WLPZ6WKU.mjs → schema-dev-notice-BLXOS6U2.mjs} +2 -2
  211. package/dist/server-plugins.d.mts +2 -2
  212. package/dist/server-plugins.d.ts +2 -2
  213. package/dist/server.cjs +55 -37
  214. package/dist/server.d.mts +15 -10
  215. package/dist/server.d.ts +15 -10
  216. package/dist/server.mjs +35 -17
  217. package/dist/{spa-router-BEvS9Erj.d.mts → spa-router-Br4qFCWf.d.mts} +8 -3
  218. package/dist/{spa-router-DmCuH5B7.d.ts → spa-router-BsWUKH73.d.ts} +8 -3
  219. package/dist/{ssg-gT093ETk.d.ts → ssg-Csy2vwpi.d.ts} +2 -2
  220. package/dist/{ssg-57v6cZcW.d.mts → ssg-Donyfcxy.d.mts} +2 -2
  221. package/dist/testing.d.mts +1 -1
  222. package/dist/testing.d.ts +1 -1
  223. package/dist/{utils-CCTKvR-P.d.ts → utils-Luk72LXC.d.ts} +1 -1
  224. package/dist/{utils-raHHQVyL.d.mts → utils-d_k1ZZw0.d.mts} +1 -1
  225. package/dist/version.cjs +2 -2
  226. package/dist/version.mjs +1 -1
  227. package/dist/vite.cjs +17 -11
  228. package/dist/vite.d.mts +6 -4
  229. package/dist/vite.d.ts +6 -4
  230. package/dist/vite.mjs +16 -10
  231. package/package.json +53 -1
  232. package/dist/{chunk-35WS7P2V.mjs → chunk-26CXZR6L.mjs} +3 -3
  233. package/dist/{chunk-QEILRWVV.cjs → chunk-3XEMGDBF.cjs} +2 -2
  234. package/dist/{chunk-BPOTSHDO.cjs → chunk-IOAUK4OI.cjs} +2 -2
  235. package/dist/{chunk-BYR3RQPB.mjs → chunk-T76H22WI.mjs} +4 -4
@@ -1,12 +1,29 @@
1
1
  import {
2
+ getFarmActionId,
2
3
  markFarmClientReference,
3
4
  updateFarmServerTreeModule
4
- } from "./chunk-NRDBW4MP.mjs";
5
+ } from "./chunk-7IQQIPRZ.mjs";
6
+ import {
7
+ FARM_ACTION_TAG,
8
+ FARM_ISLAND_ELEMENT,
9
+ FARM_OBJECT_TAG,
10
+ FARM_PROPS_SCRIPT_TYPE,
11
+ FARM_REFERENCE_TAG,
12
+ FARM_SLOT_ELEMENT,
13
+ FARM_SLOT_TAG,
14
+ FARM_TAG,
15
+ FARM_TAG_VALUE,
16
+ FARM_VALUE_SCRIPT_TYPE,
17
+ getFarmIslandValuesServer,
18
+ getFarmTag
19
+ } from "./chunk-2NXO5SBY.mjs";
5
20
  import {
6
21
  __name
7
22
  } from "./chunk-LPEX4YW6.mjs";
8
23
 
9
24
  // src/client/isolated-boundary.ts
25
+ var ISLAND_SELECTOR = `${FARM_ISLAND_ELEMENT}[src]`;
26
+ var runtimeTagged = /* @__PURE__ */ new WeakSet();
10
27
  var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element");
11
28
  var LEGACY_REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.element");
12
29
  var BOUNDARY_GRAPH_CONTEXT = /* @__PURE__ */ Symbol.for("farm.isolated-hydration.client-graph-context");
@@ -23,6 +40,9 @@ function getBoundaryGraphContext(ReactRuntime) {
23
40
  }
24
41
  __name(getBoundaryGraphContext, "getBoundaryGraphContext");
25
42
  function serializeBoundaryProps(value, seen = /* @__PURE__ */ new Set()) {
43
+ const codec = getFarmIslandValuesServer();
44
+ const leaf = codec?.encodeLeaf(value);
45
+ if (leaf) return leaf;
26
46
  if (value === null || typeof value === "string" || typeof value === "boolean") return value;
27
47
  if (typeof value === "number") {
28
48
  if (!Number.isFinite(value)) throw new TypeError("non-finite numbers are not serializable");
@@ -31,6 +51,10 @@ function serializeBoundaryProps(value, seen = /* @__PURE__ */ new Set()) {
31
51
  if (typeof value === "undefined") {
32
52
  throw new TypeError("undefined values are not serializable");
33
53
  }
54
+ if (typeof value === "function") {
55
+ const actionId = getFarmActionId(value);
56
+ if (actionId) return { [FARM_TAG]: FARM_ACTION_TAG, [FARM_TAG_VALUE]: actionId };
57
+ }
34
58
  if (typeof value !== "object") {
35
59
  throw new TypeError(`${typeof value} values are not serializable`);
36
60
  }
@@ -41,22 +65,143 @@ function serializeBoundaryProps(value, seen = /* @__PURE__ */ new Set()) {
41
65
  seen.add(value);
42
66
  try {
43
67
  if (Array.isArray(value)) return value.map((entry) => serializeBoundaryProps(entry, seen));
68
+ if (codec && value instanceof Map) {
69
+ return {
70
+ [FARM_TAG]: "M",
71
+ [FARM_TAG_VALUE]: Array.from(value, ([key, entry]) => [
72
+ serializeBoundaryProps(key, seen),
73
+ serializeBoundaryProps(entry, seen)
74
+ ])
75
+ };
76
+ }
77
+ if (codec && value instanceof Set) {
78
+ return {
79
+ [FARM_TAG]: "S",
80
+ [FARM_TAG_VALUE]: Array.from(value, (entry) => serializeBoundaryProps(entry, seen))
81
+ };
82
+ }
44
83
  const prototype = Object.getPrototypeOf(value);
45
84
  if (prototype !== Object.prototype && prototype !== null) {
46
85
  throw new TypeError("class instances are not serializable");
47
86
  }
48
- return Object.fromEntries(
87
+ const serialized = Object.fromEntries(
49
88
  Object.entries(value).map(([key, entry]) => [key, serializeBoundaryProps(entry, seen)])
50
89
  );
90
+ return codec && !runtimeTagged.has(value) && Object.prototype.hasOwnProperty.call(value, FARM_TAG) ? { [FARM_TAG]: FARM_OBJECT_TAG, [FARM_TAG_VALUE]: serialized } : serialized;
51
91
  } finally {
52
92
  seen.delete(value);
53
93
  }
54
94
  }
55
95
  __name(serializeBoundaryProps, "serializeBoundaryProps");
56
96
  function serializeBoundaryPayload(value) {
57
- return JSON.stringify(serializeBoundaryProps(value)).replace(/&/g, "\\u0026").replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
97
+ return escapeScriptJson(JSON.stringify(serializeBoundaryProps(value)));
58
98
  }
59
99
  __name(serializeBoundaryPayload, "serializeBoundaryPayload");
100
+ function escapeScriptJson(json) {
101
+ return json.replace(/&/g, "\\u0026").replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
102
+ }
103
+ __name(escapeScriptJson, "escapeScriptJson");
104
+ var SLOT_ELEMENT = FARM_SLOT_ELEMENT;
105
+ function isReactElementValue(value) {
106
+ const type = value?.$$typeof;
107
+ return type === REACT_ELEMENT_TYPE || type === LEGACY_REACT_ELEMENT_TYPE;
108
+ }
109
+ __name(isReactElementValue, "isReactElementValue");
110
+ function slotReference(id) {
111
+ const reference = { [FARM_TAG]: FARM_SLOT_TAG, [FARM_TAG_VALUE]: id };
112
+ runtimeTagged.add(reference);
113
+ return reference;
114
+ }
115
+ __name(slotReference, "slotReference");
116
+ function splitSlotProps(ReactRuntime, value, slotPrefix, counter) {
117
+ if (isReactElementValue(value)) {
118
+ const id = `${slotPrefix}${counter.next++}`;
119
+ return {
120
+ render: ReactRuntime.createElement(
121
+ SLOT_ELEMENT,
122
+ { key: value.key ?? id, name: id, style: { display: "contents" } },
123
+ value
124
+ ),
125
+ wire: slotReference(id)
126
+ };
127
+ }
128
+ if (Array.isArray(value)) {
129
+ const parts = value.map((entry) => splitSlotProps(ReactRuntime, entry, slotPrefix, counter));
130
+ return { render: parts.map((part) => part.render), wire: parts.map((part) => part.wire) };
131
+ }
132
+ if (value && typeof value === "object") {
133
+ const prototype = Object.getPrototypeOf(value);
134
+ if (prototype !== Object.prototype && prototype !== null) return { render: value, wire: value };
135
+ const render = {};
136
+ const wire = {};
137
+ for (const [key, entry] of Object.entries(value)) {
138
+ const part = splitSlotProps(ReactRuntime, entry, slotPrefix, counter);
139
+ render[key] = part.render;
140
+ wire[key] = part.wire;
141
+ }
142
+ return { render, wire };
143
+ }
144
+ return { render: value, wire: value };
145
+ }
146
+ __name(splitSlotProps, "splitSlotProps");
147
+ var FARM_NOT_A_MARKER = /* @__PURE__ */ Symbol.for("farm.codec.not-a-marker");
148
+ function reviveSlotProps(ReactRuntime, value, container, actions, decode) {
149
+ if (Array.isArray(value)) {
150
+ let changed2 = false;
151
+ const revived2 = value.map((entry) => {
152
+ const next = reviveSlotProps(ReactRuntime, entry, container, actions, decode);
153
+ if (next !== entry) changed2 = true;
154
+ return next;
155
+ });
156
+ return changed2 ? revived2 : value;
157
+ }
158
+ if (!value || typeof value !== "object") return value;
159
+ const tag = decode || actions ? getFarmTag(value) : void 0;
160
+ const data = tag === void 0 ? void 0 : value[FARM_TAG_VALUE];
161
+ if (tag === FARM_ACTION_TAG && typeof data === "string") {
162
+ if (!actions) throw new Error("server action props need islands mode");
163
+ return actions(data);
164
+ }
165
+ if (tag === FARM_SLOT_TAG && typeof data === "string") {
166
+ let html = "";
167
+ for (const slot of container.querySelectorAll(SLOT_ELEMENT)) {
168
+ if (slot.getAttribute("name") === data) {
169
+ html = slot.innerHTML;
170
+ break;
171
+ }
172
+ }
173
+ return ReactRuntime.createElement(SLOT_ELEMENT, {
174
+ key: data,
175
+ name: data,
176
+ style: { display: "contents" },
177
+ suppressHydrationWarning: true,
178
+ dangerouslySetInnerHTML: { __html: html }
179
+ });
180
+ }
181
+ if (tag === FARM_REFERENCE_TAG) throw new Error(`island value ${String(data)} was not resolved`);
182
+ if (tag !== void 0) {
183
+ if (!decode) throw new Error("typed props need islands mode");
184
+ const decoded = decode(
185
+ value,
186
+ (child) => reviveSlotProps(ReactRuntime, child, container, actions, decode)
187
+ );
188
+ if (decoded !== FARM_NOT_A_MARKER) return decoded;
189
+ }
190
+ let changed = false;
191
+ const revived = {};
192
+ for (const [key, entry] of Object.entries(value)) {
193
+ const next = reviveSlotProps(ReactRuntime, entry, container, actions, decode);
194
+ Object.defineProperty(revived, key, {
195
+ value: next,
196
+ enumerable: true,
197
+ writable: true,
198
+ configurable: true
199
+ });
200
+ if (next !== entry) changed = true;
201
+ }
202
+ return changed ? revived : value;
203
+ }
204
+ __name(reviveSlotProps, "reviveSlotProps");
60
205
  function wrapFarmIsolatedClientGraph(ReactRuntime, element) {
61
206
  const Context = getBoundaryGraphContext(ReactRuntime);
62
207
  return ReactRuntime.createElement(Context.Provider, { value: true }, element);
@@ -68,7 +213,7 @@ function isolateFarmServerPageGraph(ReactRuntime, element) {
68
213
  }
69
214
  __name(isolateFarmServerPageGraph, "isolateFarmServerPageGraph");
70
215
  var warnedUnserializableBoundaries = /* @__PURE__ */ new Set();
71
- function createFarmIsolatedClientBoundary(ReactRuntime, Component, moduleReference, exportName, islandStrategy) {
216
+ function createFarmIsolatedClientBoundary(ReactRuntime, Component, moduleReference, exportName, islandStrategy, boundaryOptions = {}) {
72
217
  function FarmIsolatedClientBoundary(props) {
73
218
  const Context = getBoundaryGraphContext(ReactRuntime);
74
219
  const belongsToParentClientGraph = ReactRuntime.useContext(Context);
@@ -77,8 +222,30 @@ function createFarmIsolatedClientBoundary(ReactRuntime, Component, moduleReferen
77
222
  return ReactRuntime.createElement(Component, props);
78
223
  }
79
224
  let serializedProps;
225
+ let renderProps = props;
226
+ let valueScripts = [];
80
227
  try {
81
- serializedProps = serializeBoundaryPayload(props);
228
+ if (boundaryOptions.slots) {
229
+ const { render, wire } = splitSlotProps(ReactRuntime, props, `${boundaryId}s`, { next: 0 });
230
+ renderProps = render;
231
+ const values = boundaryOptions.values ? getFarmIslandValuesServer() : void 0;
232
+ if (values) {
233
+ const addressed = values.address(serializeBoundaryProps(wire));
234
+ serializedProps = escapeScriptJson(addressed.json);
235
+ valueScripts = values.select(addressed, values.held()).map(
236
+ (value) => ReactRuntime.createElement("script", {
237
+ key: value.key,
238
+ type: FARM_VALUE_SCRIPT_TYPE,
239
+ name: value.key,
240
+ dangerouslySetInnerHTML: { __html: escapeScriptJson(value.json) }
241
+ })
242
+ );
243
+ } else {
244
+ serializedProps = serializeBoundaryPayload(wire);
245
+ }
246
+ } else {
247
+ serializedProps = serializeBoundaryPayload(props);
248
+ }
82
249
  } catch (error) {
83
250
  const message = error instanceof Error ? error.message : String(error);
84
251
  const warningKey = `${moduleReference}#${exportName}:${message}`;
@@ -93,24 +260,25 @@ function createFarmIsolatedClientBoundary(ReactRuntime, Component, moduleReferen
93
260
  return ReactRuntime.createElement(
94
261
  ReactRuntime.Fragment,
95
262
  null,
263
+ ...valueScripts,
96
264
  ReactRuntime.createElement(
97
- "farm-client-boundary",
265
+ FARM_ISLAND_ELEMENT,
98
266
  {
99
- "data-farm-client-boundary": moduleReference,
100
- "data-farm-client-id": boundaryId,
101
- "data-farm-client-export": exportName,
102
- "data-farm-island-strategy": islandStrategy,
267
+ src: moduleReference,
268
+ export: exportName,
269
+ props: boundaryId,
270
+ strategy: islandStrategy,
103
271
  style: { display: "contents" }
104
272
  },
105
273
  ReactRuntime.createElement(
106
274
  Context.Provider,
107
275
  { value: true },
108
- ReactRuntime.createElement(Component, props)
276
+ ReactRuntime.createElement(Component, renderProps)
109
277
  )
110
278
  ),
111
279
  ReactRuntime.createElement("script", {
112
- type: "application/json",
113
- "data-farm-client-props": boundaryId,
280
+ type: FARM_PROPS_SCRIPT_TYPE,
281
+ htmlFor: boundaryId,
114
282
  dangerouslySetInnerHTML: { __html: serializedProps }
115
283
  })
116
284
  );
@@ -131,13 +299,13 @@ function isEarlyHydrationUpdate(error) {
131
299
  __name(isEarlyHydrationUpdate, "isEarlyHydrationUpdate");
132
300
  function findBoundaryPayload(container, boundaryId) {
133
301
  const sibling = container.nextElementSibling;
134
- if (sibling instanceof HTMLScriptElement && sibling.type === "application/json" && sibling.getAttribute("data-farm-client-props") === boundaryId) {
302
+ if (sibling instanceof HTMLScriptElement && sibling.type === FARM_PROPS_SCRIPT_TYPE && sibling.getAttribute("for") === boundaryId) {
135
303
  return sibling;
136
304
  }
137
305
  for (const candidate of container.ownerDocument.querySelectorAll(
138
- 'script[type="application/json"][data-farm-client-props]'
306
+ `script[type="${FARM_PROPS_SCRIPT_TYPE}"]`
139
307
  )) {
140
- if (candidate.getAttribute("data-farm-client-props") === boundaryId) return candidate;
308
+ if (candidate.getAttribute("for") === boundaryId) return candidate;
141
309
  }
142
310
  return null;
143
311
  }
@@ -191,23 +359,73 @@ function createFarmIsolatedHydrationRuntime(options) {
191
359
  )
192
360
  );
193
361
  }, "createBoundaryGraph");
194
- async function hydrate(scope = document, signal) {
195
- const candidates = Array.from(
196
- scope.querySelectorAll("farm-client-boundary[data-farm-client-boundary]")
362
+ function readBoundaryProps(container, boundaryId) {
363
+ const payload = findBoundaryPayload(container, boundaryId);
364
+ if (!payload) throw new Error(`serialized props ${boundaryId} were not found`);
365
+ const parsedProps = JSON.parse(payload.textContent || "{}");
366
+ if (!parsedProps || typeof parsedProps !== "object" || Array.isArray(parsedProps)) {
367
+ throw new Error("serialized props must be an object");
368
+ }
369
+ let resolvedProps = parsedProps;
370
+ if (payload.textContent?.includes(`"${FARM_TAG}":"${FARM_REFERENCE_TAG}"`)) {
371
+ if (!options.values) throw new Error("island values need islands mode");
372
+ options.values.ingest(container.ownerDocument);
373
+ resolvedProps = options.values.resolve(parsedProps);
374
+ }
375
+ return reviveSlotProps(
376
+ options.ReactRuntime,
377
+ resolvedProps,
378
+ container,
379
+ options.actions,
380
+ options.decode
197
381
  );
198
- if (scope instanceof Element && scope.matches("farm-client-boundary[data-farm-client-boundary]")) {
382
+ }
383
+ __name(readBoundaryProps, "readBoundaryProps");
384
+ const topLevelBoundaries = /* @__PURE__ */ __name((scope) => Array.from(scope.querySelectorAll(ISLAND_SELECTOR)).filter(
385
+ (container) => !container.parentElement?.closest(ISLAND_SELECTOR)
386
+ ), "topLevelBoundaries");
387
+ const boundaryKey = /* @__PURE__ */ __name((container) => `${container.getAttribute("src")}#${container.getAttribute("export") || "default"}`, "boundaryKey");
388
+ function carryOver(current, next) {
389
+ const live = /* @__PURE__ */ new Map();
390
+ for (const container of topLevelBoundaries(current)) {
391
+ if (!roots.has(container)) continue;
392
+ const key = boundaryKey(container);
393
+ live.set(key, [...live.get(key) ?? [], container]);
394
+ }
395
+ let carried = 0;
396
+ for (const container of topLevelBoundaries(next)) {
397
+ const previous = live.get(boundaryKey(container))?.shift();
398
+ const record = previous && roots.get(previous);
399
+ const boundaryId = container.getAttribute("props");
400
+ if (!previous || !record || !boundaryId) continue;
401
+ try {
402
+ const props = readBoundaryProps(container, boundaryId);
403
+ record.root.render(createBoundaryGraph(record.Component, props, record.restore));
404
+ record.props = props;
405
+ container.replaceWith(previous);
406
+ carried++;
407
+ } catch (error) {
408
+ report(`Could not keep ${boundaryKey(container)} across the refresh.`, error);
409
+ }
410
+ }
411
+ return carried;
412
+ }
413
+ __name(carryOver, "carryOver");
414
+ async function hydrate(scope = document, signal) {
415
+ const candidates = Array.from(scope.querySelectorAll(ISLAND_SELECTOR));
416
+ if (scope instanceof Element && scope.matches(ISLAND_SELECTOR)) {
199
417
  candidates.unshift(scope);
200
418
  }
201
419
  const boundaries = candidates.filter((container) => {
202
420
  if (roots.has(container) || pending.has(container)) return false;
203
- return !container.parentElement?.closest("farm-client-boundary[data-farm-client-boundary]");
421
+ return !container.parentElement?.closest(ISLAND_SELECTOR);
204
422
  });
205
423
  await Promise.all(
206
424
  boundaries.map(async (container) => {
207
- const reference = container.getAttribute("data-farm-client-boundary");
208
- const boundaryId = container.getAttribute("data-farm-client-id");
209
- const exportName = container.getAttribute("data-farm-client-export") || "default";
210
- const strategy = container.getAttribute("data-farm-island-strategy") ?? "load";
425
+ const reference = container.getAttribute("src");
426
+ const boundaryId = container.getAttribute("props");
427
+ const exportName = container.getAttribute("export") || "default";
428
+ const strategy = container.getAttribute("strategy") ?? "load";
211
429
  if (!reference || !boundaryId) {
212
430
  report("An isolated client boundary is missing its module reference or payload ID.");
213
431
  return;
@@ -242,12 +460,7 @@ function createFarmIsolatedHydrationRuntime(options) {
242
460
  if (typeof Component !== "function" && typeof Component !== "object") {
243
461
  throw new Error("compiled original export was not found");
244
462
  }
245
- const payload = findBoundaryPayload(container, boundaryId);
246
- if (!payload) throw new Error(`serialized props ${boundaryId} were not found`);
247
- const props = JSON.parse(payload.textContent || "{}");
248
- if (!props || typeof props !== "object" || Array.isArray(props)) {
249
- throw new Error("serialized props must be an object");
250
- }
463
+ const props = readBoundaryProps(container, boundaryId);
251
464
  let rootFailure;
252
465
  const restore = /* @__PURE__ */ __name((error) => {
253
466
  if (rootFailure !== void 0) return;
@@ -271,6 +484,7 @@ function createFarmIsolatedHydrationRuntime(options) {
271
484
  });
272
485
  roots.set(container, {
273
486
  root,
487
+ Component,
274
488
  dispose() {
275
489
  disposing = true;
276
490
  try {
@@ -361,6 +575,7 @@ function createFarmIsolatedHydrationRuntime(options) {
361
575
  __name(dispose, "dispose");
362
576
  return {
363
577
  hydrate,
578
+ carryOver,
364
579
  updateModule,
365
580
  dispose,
366
581
  rootCount: /* @__PURE__ */ __name(() => roots.size, "rootCount")
@@ -374,9 +589,7 @@ function createFarmServerPageBoundary(ReactRuntime, runtime) {
374
589
  ReactRuntime.useLayoutEffect(() => {
375
590
  const page = ref.current;
376
591
  if (!page) return;
377
- const islands = Array.from(
378
- page.querySelectorAll("farm-client-boundary[data-farm-client-boundary]")
379
- );
592
+ const islands = Array.from(page.querySelectorAll(ISLAND_SELECTOR));
380
593
  if (islands.length === 0) return;
381
594
  const controller = new AbortController();
382
595
  runtime.hydrate(page, controller.signal).catch((error) => {