@farm.js/core 0.1.42 → 0.1.44

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 (243) hide show
  1. package/dist/{agent-mcp-ssVy_tea.d.mts → agent-mcp-CWI-awqd.d.mts} +1 -1
  2. package/dist/{agent-mcp-SSD6L3VZ.d.ts → agent-mcp-EnzWYv_X.d.ts} +1 -1
  3. package/dist/agent-runtime.cjs +3 -2
  4. package/dist/agent-runtime.d.mts +1 -1
  5. package/dist/agent-runtime.d.ts +1 -1
  6. package/dist/agent-runtime.mjs +2 -1
  7. package/dist/api/route-manager.d.mts +3 -3
  8. package/dist/api/route-manager.d.ts +3 -3
  9. package/dist/api/runtime.d.mts +2 -2
  10. package/dist/api/runtime.d.ts +2 -2
  11. package/dist/api.cjs +2 -2
  12. package/dist/api.d.mts +8 -3
  13. package/dist/api.d.ts +8 -3
  14. package/dist/api.mjs +1 -1
  15. package/dist/{app-KjFzdCqy.d.ts → app-CAN_2Cqo.d.ts} +8 -4
  16. package/dist/{app-1h3lVT4a.d.mts → app-DG3dE8v5.d.mts} +8 -4
  17. package/dist/{app-manifest-D3RkVNuS.d.mts → app-manifest-8x5VjZ0L.d.mts} +1 -1
  18. package/dist/{app-manifest-DaW8-tvX.d.ts → app-manifest-DazjgQya.d.ts} +1 -1
  19. package/dist/app-markdown.d.mts +2 -2
  20. package/dist/app-markdown.d.ts +2 -2
  21. package/dist/{chunk-ECKF2BAM.cjs → chunk-2GVF3C2F.cjs} +255 -42
  22. package/dist/{chunk-TUL355PH.mjs → chunk-2MKTHHEU.mjs} +136 -161
  23. package/dist/chunk-2NXO5SBY.mjs +57 -0
  24. package/dist/{chunk-AX7S67YV.mjs → chunk-37VKVISD.mjs} +9 -173
  25. package/dist/chunk-3BROEWFY.cjs +39 -0
  26. package/dist/chunk-3SAWHWDH.cjs +186 -0
  27. package/dist/{chunk-AHFRQMRX.cjs → chunk-3YJMBQ27.cjs} +1 -1
  28. package/dist/{chunk-6PKXK4TY.mjs → chunk-53ZV6K65.mjs} +1 -1
  29. package/dist/{chunk-JG3MEQUH.cjs → chunk-5GBL2LKD.cjs} +430 -217
  30. package/dist/{chunk-LYIZHJTK.cjs → chunk-5LPHJZSI.cjs} +14 -14
  31. package/dist/chunk-5NIWBWDD.mjs +97 -0
  32. package/dist/{chunk-NRDBW4MP.mjs → chunk-7IQQIPRZ.mjs} +10 -0
  33. package/dist/{chunk-TCJ4A4A2.cjs → chunk-AI3WVJNP.cjs} +324 -350
  34. package/dist/chunk-APDGOKKE.cjs +148 -0
  35. package/dist/chunk-AZBSVLRM.cjs +132 -0
  36. package/dist/{chunk-RHGK2JEN.cjs → chunk-B6XAA7V6.cjs} +18 -182
  37. package/dist/chunk-CEDPEDNW.cjs +98 -0
  38. package/dist/{chunk-WSOBCAYO.cjs → chunk-CW6SNEN2.cjs} +25 -25
  39. package/dist/chunk-D5RFPV2H.mjs +148 -0
  40. package/dist/chunk-E22SWCXB.cjs +144 -0
  41. package/dist/{chunk-375K2ZVU.mjs → chunk-ERA5RP3L.mjs} +263 -50
  42. package/dist/{chunk-724JLMS4.mjs → chunk-F646BZ4Y.mjs} +4 -2
  43. package/dist/{chunk-C5KVWHIH.cjs → chunk-G2Z5DGMS.cjs} +5 -3
  44. package/dist/{chunk-ZATTDMBW.cjs → chunk-GA6JM4L6.cjs} +279 -376
  45. package/dist/chunk-GZWHCWLB.mjs +186 -0
  46. package/dist/{chunk-24SP5TGU.mjs → chunk-H4LXPWI2.mjs} +2 -2
  47. package/dist/chunk-H7BLEEAE.cjs +57 -0
  48. package/dist/chunk-IOMVXBLZ.mjs +144 -0
  49. package/dist/{chunk-BD3D7EZV.cjs → chunk-IXFOBGLQ.cjs} +9 -3
  50. package/dist/{chunk-JIYYX7WU.mjs → chunk-JVXW76I7.mjs} +2 -2
  51. package/dist/{chunk-MHN4UR5U.cjs → chunk-KFZZFZ7J.cjs} +7 -7
  52. package/dist/{chunk-BXJ5HJTJ.cjs → chunk-LPE3ED4R.cjs} +17 -13
  53. package/dist/chunk-LRJRXXQZ.cjs +109 -0
  54. package/dist/{chunk-HCSVR4YZ.mjs → chunk-M3BXTWJM.mjs} +18 -0
  55. package/dist/{chunk-2JZHQDUY.mjs → chunk-OYZGFRPA.mjs} +1 -1
  56. package/dist/{chunk-JR4QCLJY.cjs → chunk-PDU4P2IC.cjs} +19 -1
  57. package/dist/chunk-PJEHUSHA.mjs +229 -0
  58. package/dist/{chunk-QTEJGB5A.mjs → chunk-QGFKXYC7.mjs} +80 -177
  59. package/dist/chunk-QGH2RQVF.mjs +132 -0
  60. package/dist/{chunk-YWMZUGIS.mjs → chunk-R3ZFQJEF.mjs} +247 -34
  61. package/dist/{chunk-U2UC7UGP.mjs → chunk-R4J2UOV4.mjs} +1 -1
  62. package/dist/chunk-S34OBRMZ.mjs +109 -0
  63. package/dist/{chunk-TS4JHGUJ.mjs → chunk-S3ZEMCE6.mjs} +9 -3
  64. package/dist/{chunk-WWFTAUFG.cjs → chunk-SBH2JLLF.cjs} +12 -2
  65. package/dist/{chunk-YSLWRWWP.cjs → chunk-SKK6UF5P.cjs} +200 -46
  66. package/dist/{chunk-ZS6HDNOM.cjs → chunk-T44ECMEP.cjs} +6 -6
  67. package/dist/{chunk-OFZUJMCU.mjs → chunk-WPJQN64R.mjs} +195 -41
  68. package/dist/{chunk-NU25TRIO.mjs → chunk-WWYXIECF.mjs} +12 -8
  69. package/dist/{chunk-7YHSD3Z6.cjs → chunk-XPSGGECF.cjs} +85 -31
  70. package/dist/chunk-XUGFRFD2.mjs +39 -0
  71. package/dist/{chunk-IVQY6UTY.mjs → chunk-XUHIRBXY.mjs} +1 -1
  72. package/dist/{chunk-PIZXONIS.mjs → chunk-YFLBG2W3.mjs} +56 -2
  73. package/dist/chunk-YKUEJ3MG.cjs +229 -0
  74. package/dist/{chunk-QKZMB7LY.cjs → chunk-YN2QEMMO.cjs} +2 -2
  75. package/dist/{client-plugins-DIem0I0W.d.ts → client-plugins-BGS0wqzc.d.ts} +36 -16
  76. package/dist/{client-plugins-C9Py_50W.d.mts → client-plugins-nQ0tYt4l.d.mts} +36 -16
  77. package/dist/client-plugins.d.mts +1 -1
  78. package/dist/client-plugins.d.ts +1 -1
  79. package/dist/client.cjs +4 -3
  80. package/dist/client.d.mts +5 -5
  81. package/dist/client.d.ts +5 -5
  82. package/dist/client.mjs +3 -2
  83. package/dist/config.d.mts +1 -1
  84. package/dist/config.d.ts +1 -1
  85. package/dist/{devtools-2RY3EKHL.cjs → devtools-5Q7VRKVH.cjs} +6 -5
  86. package/dist/{devtools-Q3LBNUJ7.mjs → devtools-LJ4IGYGW.mjs} +5 -4
  87. package/dist/docs.cjs +7 -6
  88. package/dist/docs.d.mts +2 -2
  89. package/dist/docs.d.ts +2 -2
  90. package/dist/docs.mjs +6 -5
  91. package/dist/index-Cy26isrh.d.ts +48 -0
  92. package/dist/index-y1jgR74U.d.mts +48 -0
  93. package/dist/index.cjs +44 -25
  94. package/dist/index.d.mts +15 -15
  95. package/dist/index.d.ts +15 -15
  96. package/dist/index.mjs +51 -32
  97. package/dist/integrations.cjs +5 -3
  98. package/dist/integrations.d.mts +1 -1
  99. package/dist/integrations.d.ts +1 -1
  100. package/dist/integrations.mjs +6 -4
  101. package/dist/internal/app-markdown-runtime.d.mts +2 -2
  102. package/dist/internal/app-markdown-runtime.d.ts +2 -2
  103. package/dist/internal/build-runtime.cjs +30 -15
  104. package/dist/internal/build-runtime.d.mts +12 -16
  105. package/dist/internal/build-runtime.d.ts +12 -16
  106. package/dist/internal/build-runtime.mjs +29 -14
  107. package/dist/internal/cli-runtime.cjs +24 -11
  108. package/dist/internal/cli-runtime.mjs +24 -11
  109. package/dist/internal/client-error-overlay.cjs +4 -4
  110. package/dist/internal/client-error-overlay.mjs +1 -1
  111. package/dist/internal/client-runtime.cjs +5 -1
  112. package/dist/internal/client-runtime.d.mts +1 -0
  113. package/dist/internal/client-runtime.d.ts +1 -0
  114. package/dist/internal/client-runtime.mjs +4 -0
  115. package/dist/internal/compression-runtime.d.mts +1 -1
  116. package/dist/internal/compression-runtime.d.ts +1 -1
  117. package/dist/internal/config-runtime.cjs +6 -5
  118. package/dist/internal/config-runtime.d.mts +2 -2
  119. package/dist/internal/config-runtime.d.ts +2 -2
  120. package/dist/internal/config-runtime.mjs +5 -4
  121. package/dist/internal/form-actions-client.cjs +18 -0
  122. package/dist/internal/form-actions-client.d.mts +5 -0
  123. package/dist/internal/form-actions-client.d.ts +5 -0
  124. package/dist/internal/form-actions-client.mjs +18 -0
  125. package/dist/internal/form-actions.cjs +18 -0
  126. package/dist/internal/form-actions.d.mts +14 -0
  127. package/dist/internal/form-actions.d.ts +14 -0
  128. package/dist/internal/form-actions.mjs +18 -0
  129. package/dist/internal/island-codec.cjs +22 -0
  130. package/dist/internal/island-codec.d.mts +29 -0
  131. package/dist/internal/island-codec.d.ts +29 -0
  132. package/dist/internal/island-codec.mjs +22 -0
  133. package/dist/internal/island-value-store.cjs +13 -0
  134. package/dist/internal/island-value-store.d.mts +6 -0
  135. package/dist/internal/island-value-store.d.ts +6 -0
  136. package/dist/internal/island-value-store.mjs +13 -0
  137. package/dist/internal/islands-runtime.cjs +77 -0
  138. package/dist/internal/islands-runtime.d.mts +57 -0
  139. package/dist/internal/islands-runtime.d.ts +57 -0
  140. package/dist/internal/islands-runtime.mjs +77 -0
  141. package/dist/internal/islands-server.cjs +19 -0
  142. package/dist/internal/islands-server.d.mts +3 -0
  143. package/dist/internal/islands-server.d.ts +3 -0
  144. package/dist/internal/islands-server.mjs +19 -0
  145. package/dist/internal/islx-client.cjs +5 -0
  146. package/dist/internal/islx-client.d.mts +2 -0
  147. package/dist/internal/islx-client.d.ts +2 -0
  148. package/dist/internal/islx-client.mjs +3 -0
  149. package/dist/internal/islx-react.cjs +4 -0
  150. package/dist/internal/islx-react.d.mts +1 -0
  151. package/dist/internal/islx-react.d.ts +1 -0
  152. package/dist/internal/islx-react.mjs +2 -0
  153. package/dist/internal/islx-server.cjs +5 -0
  154. package/dist/internal/islx-server.d.mts +2 -0
  155. package/dist/internal/islx-server.d.ts +2 -0
  156. package/dist/internal/islx-server.mjs +3 -0
  157. package/dist/internal/isolated-boundary.cjs +4 -3
  158. package/dist/internal/isolated-boundary.d.mts +13 -1
  159. package/dist/internal/isolated-boundary.d.ts +13 -1
  160. package/dist/internal/isolated-boundary.mjs +3 -2
  161. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  162. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  163. package/dist/internal/production-runtime.cjs +24 -13
  164. package/dist/internal/production-runtime.d.mts +20 -10
  165. package/dist/internal/production-runtime.d.ts +20 -10
  166. package/dist/internal/production-runtime.mjs +24 -13
  167. package/dist/internal/server-tree.cjs +6 -3
  168. package/dist/internal/server-tree.d.mts +25 -2
  169. package/dist/internal/server-tree.d.ts +25 -2
  170. package/dist/internal/server-tree.mjs +7 -4
  171. package/dist/island-value-protocol-BRayRghM.d.mts +12 -0
  172. package/dist/island-value-protocol-BRayRghM.d.ts +12 -0
  173. package/dist/markdown.d.mts +1 -1
  174. package/dist/markdown.d.ts +1 -1
  175. package/dist/middleware.d.mts +3 -3
  176. package/dist/middleware.d.ts +3 -3
  177. package/dist/navigation.cjs +5 -4
  178. package/dist/navigation.d.mts +4 -4
  179. package/dist/navigation.d.ts +4 -4
  180. package/dist/navigation.mjs +4 -3
  181. package/dist/og.d.mts +5 -0
  182. package/dist/og.d.ts +5 -0
  183. package/dist/plugin.cjs +19 -12
  184. package/dist/plugin.d.mts +3 -3
  185. package/dist/plugin.d.ts +3 -3
  186. package/dist/plugin.mjs +18 -11
  187. package/dist/{production-runtime-bjjWq-DA.d.ts → production-runtime-BVMDgHrA.d.ts} +1 -1
  188. package/dist/{production-runtime-CHFKIgpW.d.mts → production-runtime-ClFA_1KQ.d.mts} +1 -1
  189. package/dist/query/client.cjs +6 -5
  190. package/dist/query/client.mjs +2 -1
  191. package/dist/{render-plan-DOHg6wdO.d.mts → render-plan-CoSovy_O.d.mts} +4 -2
  192. package/dist/{render-plan-B2UndB4x.d.ts → render-plan-y2DefWf8.d.ts} +4 -2
  193. package/dist/renderer/react/server.cjs +7 -6
  194. package/dist/renderer/react/server.d.mts +3 -1
  195. package/dist/renderer/react/server.d.ts +3 -1
  196. package/dist/renderer/react/server.mjs +5 -4
  197. package/dist/renderer-client.cjs +5 -4
  198. package/dist/renderer-client.d.mts +3 -3
  199. package/dist/renderer-client.d.ts +3 -3
  200. package/dist/renderer-client.mjs +2 -1
  201. package/dist/renderer.d.mts +3 -1
  202. package/dist/renderer.d.ts +3 -1
  203. package/dist/{request-DVNXRQrI.d.ts → request-aG5Wovm5.d.ts} +1 -1
  204. package/dist/{request-DQcGfdgQ.d.mts → request-cNM09Q7e.d.mts} +1 -1
  205. package/dist/request.d.mts +2 -2
  206. package/dist/request.d.ts +2 -2
  207. package/dist/{route-rendering-B_6fj-GG.d.ts → route-rendering-B3uQmCWX.d.ts} +1 -1
  208. package/dist/{route-rendering-CEX4mFn-.d.mts → route-rendering-EyInfsjI.d.mts} +1 -1
  209. package/dist/{router-CHEMHm1P.d.ts → router-DNUf-Bg1.d.ts} +1 -1
  210. package/dist/{router-CKHPBKXX.d.mts → router-Devibh4r.d.mts} +1 -1
  211. package/dist/routes.d.mts +1 -1
  212. package/dist/routes.d.ts +1 -1
  213. package/dist/rsc-pipeline-4ZJ6GUVQ.cjs +78 -0
  214. package/dist/rsc-pipeline-KK6GFDET.mjs +78 -0
  215. package/dist/{runtime-jj8TKNsy.d.mts → runtime-9KZb8AI5.d.mts} +1 -1
  216. package/dist/{runtime-Br2ZDTAv.d.ts → runtime-CLr9P5kn.d.ts} +1 -1
  217. package/dist/{schema-dev-notice-5JPE67AI.cjs → schema-dev-notice-77ZL23PL.cjs} +4 -4
  218. package/dist/{schema-dev-notice-WLPZ6WKU.mjs → schema-dev-notice-BLXOS6U2.mjs} +2 -2
  219. package/dist/server-plugins.d.mts +2 -2
  220. package/dist/server-plugins.d.ts +2 -2
  221. package/dist/server.cjs +57 -38
  222. package/dist/server.d.mts +15 -10
  223. package/dist/server.d.ts +15 -10
  224. package/dist/server.mjs +37 -18
  225. package/dist/{spa-router-BEvS9Erj.d.mts → spa-router-BIxh4IY-.d.mts} +8 -3
  226. package/dist/{spa-router-DmCuH5B7.d.ts → spa-router-Ds6R_oe-.d.ts} +8 -3
  227. package/dist/{ssg-57v6cZcW.d.mts → ssg-ByrOVYdM.d.mts} +2 -2
  228. package/dist/{ssg-gT093ETk.d.ts → ssg-XnMHCyEc.d.ts} +2 -2
  229. package/dist/testing.d.mts +1 -1
  230. package/dist/testing.d.ts +1 -1
  231. package/dist/{utils-CCTKvR-P.d.ts → utils-BN70ueSN.d.ts} +1 -1
  232. package/dist/{utils-raHHQVyL.d.mts → utils-BrjR5xRs.d.mts} +1 -1
  233. package/dist/version.cjs +2 -2
  234. package/dist/version.mjs +1 -1
  235. package/dist/vite.cjs +19 -12
  236. package/dist/vite.d.mts +6 -4
  237. package/dist/vite.d.ts +6 -4
  238. package/dist/vite.mjs +18 -11
  239. package/package.json +53 -1
  240. package/dist/{chunk-35WS7P2V.mjs → chunk-26CXZR6L.mjs} +3 -3
  241. package/dist/{chunk-QEILRWVV.cjs → chunk-3XEMGDBF.cjs} +2 -2
  242. package/dist/{chunk-BPOTSHDO.cjs → chunk-IOAUK4OI.cjs} +2 -2
  243. package/dist/{chunk-BYR3RQPB.mjs → chunk-T76H22WI.mjs} +4 -4
@@ -1,7 +1,14 @@
1
1
  import {
2
+ getFarmActionId,
2
3
  getFarmClientReference,
3
4
  subscribeFarmServerTreeUpdates
4
- } from "./chunk-NRDBW4MP.mjs";
5
+ } from "./chunk-7IQQIPRZ.mjs";
6
+ import {
7
+ FARM_REFERENCE_TAG,
8
+ FARM_TAG,
9
+ FARM_VALUE_SCRIPT_TYPE,
10
+ getFarmIslandValuesServer
11
+ } from "./chunk-2NXO5SBY.mjs";
5
12
  import {
6
13
  __name
7
14
  } from "./chunk-LPEX4YW6.mjs";
@@ -9,10 +16,12 @@ import {
9
16
  // src/client/server-tree.ts
10
17
  var MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
11
18
  var FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref");
12
- var SERVER_HTML_TAG = "farm-server-html";
13
- var FARM_SERVER_TREE_ATTRIBUTE = "data-farm-server-tree";
14
- var SERVER_TREE_CHUNK_ATTRIBUTE = "data-farm-server-tree-chunk";
15
- var SERVER_HTML_ATTRIBUTE = "data-farm-server-html";
19
+ var SERVER_HTML_TAG = "f-html";
20
+ var FARM_SERVER_TREE_SCRIPT_TYPE = "f/tree";
21
+ var FARM_NOT_A_MARKER = /* @__PURE__ */ Symbol.for("farm.codec.not-a-marker");
22
+ var SERVER_TREE_CHUNK_SCRIPT_TYPE = "f/chunk";
23
+ var FARM_SERVER_TREE_PAYLOAD_ONLY_ATTRIBUTE = "partial";
24
+ var SERVER_HTML_ATTRIBUTE = "name";
16
25
  var PARSER_SENSITIVE_TAGS = /* @__PURE__ */ new Set([
17
26
  "caption",
18
27
  "colgroup",
@@ -105,7 +114,7 @@ __name(serverHtmlNode, "serverHtmlNode");
105
114
  async function resolveProps(state, props, context, host) {
106
115
  const entries = await Promise.all(
107
116
  Object.entries(props).map(async ([name, value]) => {
108
- if (value === void 0) return null;
117
+ if (value === void 0 && (host || !state.codec)) return null;
109
118
  if (name === "ref") {
110
119
  if (value === null) return null;
111
120
  throw new UnsupportedNode("receives a ref");
@@ -120,11 +129,21 @@ async function resolveProps(state, props, context, host) {
120
129
  }
121
130
  __name(resolveProps, "resolveProps");
122
131
  async function resolveValue(state, value, context, seen) {
132
+ const codec = state.codec;
133
+ const leaf = codec?.encodeLeaf(value);
134
+ if (leaf) return leaf;
123
135
  if (value === null || value === void 0) return null;
124
136
  if (typeof value === "string" || typeof value === "boolean") return value;
125
137
  if (typeof value === "number") {
126
138
  return Number.isFinite(value) ? value : { $: "n", v: String(value) };
127
139
  }
140
+ if (typeof value === "function") {
141
+ const actionId = getFarmActionId(value);
142
+ if (actionId) {
143
+ state.actions.set(actionId, value);
144
+ return { $: "a", v: actionId };
145
+ }
146
+ }
128
147
  if (typeof value !== "object") throw new UnsupportedNode(`passes a ${typeof value} value`);
129
148
  if (state.ReactRuntime.isValidElement(value)) {
130
149
  return resolveElement(state, value, context);
@@ -143,12 +162,18 @@ async function resolveValue(state, value, context, seen) {
143
162
  if (Array.isArray(value)) {
144
163
  return await Promise.all(value.map((entry) => resolveValue(state, entry, context, seen)));
145
164
  }
165
+ if (codec && value instanceof Map) {
166
+ return { $: "M", v: await resolveValue(state, Array.from(value), context, seen) };
167
+ }
168
+ if (codec && value instanceof Set) {
169
+ return { $: "S", v: await resolveValue(state, Array.from(value), context, seen) };
170
+ }
146
171
  const prototype = Object.getPrototypeOf(value);
147
172
  if (prototype !== Object.prototype && prototype !== null) {
148
173
  throw new UnsupportedNode("passes a class instance");
149
174
  }
150
175
  const entries = await Promise.all(
151
- Object.entries(value).filter(([, entry]) => entry !== void 0).map(
176
+ Object.entries(value).filter(([, entry]) => entry !== void 0 || codec).map(
152
177
  async ([name, entry]) => [
153
178
  name,
154
179
  await resolveValue(state, entry, context, seen)
@@ -212,7 +237,7 @@ async function resolveElement(state, element, context) {
212
237
  encoded.catch(() => {
213
238
  });
214
239
  state.chunks.set(id, { encoded });
215
- return withKey({ $: "s", f: fallback, i: id });
240
+ return withKey({ $: "p", f: fallback, i: id });
216
241
  }
217
242
  const clientReference = getFarmClientReference(type);
218
243
  if (clientReference) {
@@ -276,9 +301,13 @@ async function resolveElement(state, element, context) {
276
301
  }
277
302
  __name(resolveElement, "resolveElement");
278
303
  function serializeTreePayload(value) {
279
- return JSON.stringify(value).replace(/&/g, "\\u0026").replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
304
+ return escapeTreeJson(JSON.stringify(value));
280
305
  }
281
306
  __name(serializeTreePayload, "serializeTreePayload");
307
+ function escapeTreeJson(json) {
308
+ return json.replace(/&/g, "\\u0026").replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
309
+ }
310
+ __name(escapeTreeJson, "escapeTreeJson");
282
311
  var chunkComponents = /* @__PURE__ */ new WeakMap();
283
312
  function getChunkComponent(ReactRuntime) {
284
313
  const existing = chunkComponents.get(ReactRuntime.createElement);
@@ -351,7 +380,7 @@ function createTreeValue(ReactRuntime, value, resolver) {
351
380
  typeof value.k === "string" ? { key: value.k } : null,
352
381
  ...createTreeChildren(ReactRuntime, value.c, resolver)
353
382
  );
354
- case "s":
383
+ case "p":
355
384
  return ReactRuntime.createElement(
356
385
  ReactRuntime.Suspense,
357
386
  {
@@ -370,6 +399,8 @@ function createTreeValue(ReactRuntime, value, resolver) {
370
399
  return resolver.serverHtml(value.i, typeof value.k === "string" ? value.k : null);
371
400
  case "n":
372
401
  return Number(value.v);
402
+ case "a":
403
+ return resolver.action(value.v);
373
404
  case "P":
374
405
  return fulfilledThenable(createTreeValue(ReactRuntime, value.v, resolver));
375
406
  case "o": {
@@ -381,42 +412,134 @@ function createTreeValue(ReactRuntime, value, resolver) {
381
412
  ])
382
413
  );
383
414
  }
384
- default:
415
+ default: {
416
+ if (value.$ !== void 0) {
417
+ if (!resolver.decode) throw new Error("typed props need islands mode");
418
+ const decoded = resolver.decode(
419
+ value,
420
+ (child) => createTreeValue(ReactRuntime, child, resolver)
421
+ );
422
+ if (decoded !== FARM_NOT_A_MARKER) return decoded;
423
+ }
385
424
  return Object.fromEntries(
386
425
  Object.entries(value).map(([name, entry]) => [
387
426
  name,
388
427
  createTreeValue(ReactRuntime, entry, resolver)
389
428
  ])
390
429
  );
430
+ }
391
431
  }
392
432
  }
393
433
  __name(createTreeValue, "createTreeValue");
394
- function createTreeScript(ReactRuntime, attribute, value, json) {
395
- return ReactRuntime.createElement("script", {
396
- type: "application/json",
397
- [attribute]: value,
434
+ function createTreeScript(ReactRuntime, type, name, json, values = [], attributes = {}) {
435
+ const script = ReactRuntime.createElement("script", {
436
+ type,
437
+ ...name ? { name } : {},
438
+ ...attributes,
398
439
  dangerouslySetInnerHTML: { __html: json }
399
440
  });
441
+ if (values.length === 0) return script;
442
+ return ReactRuntime.createElement(
443
+ ReactRuntime.Fragment,
444
+ null,
445
+ ...values.map(
446
+ ([valueKey, valueJson]) => ReactRuntime.createElement("script", {
447
+ key: valueKey,
448
+ type: FARM_VALUE_SCRIPT_TYPE,
449
+ name: valueKey,
450
+ dangerouslySetInnerHTML: { __html: valueJson }
451
+ })
452
+ ),
453
+ script
454
+ );
400
455
  }
401
456
  __name(createTreeScript, "createTreeScript");
402
- function createTreePage(ReactRuntime, tree, json, resolver, key) {
457
+ function createTreePage(ReactRuntime, tree, json, resolver, key, values = []) {
403
458
  return ReactRuntime.createElement(
404
459
  ReactRuntime.Fragment,
405
460
  key === void 0 ? null : { key },
406
461
  createTreeValue(ReactRuntime, tree, resolver),
407
- createTreeScript(ReactRuntime, FARM_SERVER_TREE_ATTRIBUTE, "", json)
462
+ createTreeScript(ReactRuntime, FARM_SERVER_TREE_SCRIPT_TYPE, "", json, values)
408
463
  );
409
464
  }
410
465
  __name(createTreePage, "createTreePage");
466
+ function readTreeValueScripts(script) {
467
+ const values = [];
468
+ for (let node = script.previousElementSibling; node?.tagName === "SCRIPT" && node.getAttribute("type") === FARM_VALUE_SCRIPT_TYPE; node = node.previousElementSibling) {
469
+ values.unshift([node.getAttribute("name") ?? "", node.textContent ?? ""]);
470
+ }
471
+ return values;
472
+ }
473
+ __name(readTreeValueScripts, "readTreeValueScripts");
474
+ async function createPayloadOnlyPage(state, payload, encode, resolver) {
475
+ const { ReactRuntime } = state;
476
+ const chunks = /* @__PURE__ */ new Map();
477
+ for (let pending = [...state.chunks.keys()]; pending.length > 0; ) {
478
+ const settled = await Promise.allSettled(
479
+ pending.map(async (id) => [id, await state.chunks.get(id).encoded])
480
+ );
481
+ for (const result of settled) {
482
+ if (result.status === "rejected") return null;
483
+ chunks.set(result.value[0], result.value[1]);
484
+ }
485
+ pending = [...state.chunks.keys()].filter((id) => !chunks.has(id));
486
+ }
487
+ return ReactRuntime.createElement(
488
+ ReactRuntime.Fragment,
489
+ null,
490
+ ...Array.from(state.serverHtml.keys(), (id) => resolver.serverHtml(id, `h${id}`)),
491
+ ReactRuntime.createElement(
492
+ ReactRuntime.Fragment,
493
+ { key: "payload" },
494
+ createTreeScript(
495
+ ReactRuntime,
496
+ FARM_SERVER_TREE_SCRIPT_TYPE,
497
+ "",
498
+ payload.json,
499
+ payload.values,
500
+ {
501
+ [FARM_SERVER_TREE_PAYLOAD_ONLY_ATTRIBUTE]: ""
502
+ }
503
+ )
504
+ ),
505
+ ...Array.from(chunks, ([id, encoded]) => {
506
+ const chunk = encode({ t: encoded });
507
+ return ReactRuntime.createElement(
508
+ ReactRuntime.Fragment,
509
+ { key: `c${id}` },
510
+ createTreeScript(
511
+ ReactRuntime,
512
+ SERVER_TREE_CHUNK_SCRIPT_TYPE,
513
+ String(id),
514
+ chunk.json,
515
+ chunk.values
516
+ )
517
+ );
518
+ })
519
+ );
520
+ }
521
+ __name(createPayloadOnlyPage, "createPayloadOnlyPage");
411
522
  async function renderFarmServerTreePage(ReactRuntime, element, options) {
412
523
  const state = {
413
524
  ReactRuntime,
414
525
  nextId: 0,
415
526
  components: /* @__PURE__ */ new Map(),
416
527
  serverHtml: /* @__PURE__ */ new Map(),
417
- chunks: /* @__PURE__ */ new Map()
528
+ chunks: /* @__PURE__ */ new Map(),
529
+ actions: /* @__PURE__ */ new Map(),
530
+ codec: options.values ? getFarmIslandValuesServer() : void 0
418
531
  };
419
532
  const tree = await resolveValue(state, element, { parserSensitive: false }, /* @__PURE__ */ new Set());
533
+ const values = options.values ? getFarmIslandValuesServer() : void 0;
534
+ const held = values ? values.held() : null;
535
+ const encode = /* @__PURE__ */ __name((payload2) => {
536
+ if (!values) return { json: serializeTreePayload(payload2), values: [] };
537
+ const addressed = values.address(payload2);
538
+ return {
539
+ json: escapeTreeJson(addressed.json),
540
+ values: values.select(addressed, held).map((value) => [value.key, escapeTreeJson(value.json)])
541
+ };
542
+ }, "encode");
420
543
  const resolver = {
421
544
  component(reference, exportName) {
422
545
  const Component = state.components.get(`${reference}#${exportName}`);
@@ -435,12 +558,16 @@ async function renderFarmServerTreePage(ReactRuntime, element, options) {
435
558
  ReactRuntime.Fragment,
436
559
  null,
437
560
  createTreeValue(ReactRuntime, encoded, resolver),
438
- createTreeScript(
439
- ReactRuntime,
440
- SERVER_TREE_CHUNK_ATTRIBUTE,
441
- String(id),
442
- serializeTreePayload({ t: encoded })
443
- )
561
+ (() => {
562
+ const payload2 = encode({ t: encoded });
563
+ return createTreeScript(
564
+ ReactRuntime,
565
+ SERVER_TREE_CHUNK_SCRIPT_TYPE,
566
+ String(id),
567
+ payload2.json,
568
+ payload2.values
569
+ );
570
+ })()
444
571
  );
445
572
  chunk.status = "fulfilled";
446
573
  return chunk.value;
@@ -467,14 +594,14 @@ async function renderFarmServerTreePage(ReactRuntime, element, options) {
467
594
  },
468
595
  options.isolate(state.serverHtml.get(id))
469
596
  );
470
- }
597
+ },
598
+ action(id) {
599
+ return state.actions.get(id);
600
+ },
601
+ decode: state.codec ? (object, decodeChild) => getFarmIslandValuesServer().decode(object, decodeChild) : void 0
471
602
  };
472
- const page = createTreePage(
473
- ReactRuntime,
474
- tree,
475
- serializeTreePayload({ v: 1, t: tree }),
476
- resolver
477
- );
603
+ const payload = encode({ v: 1, t: tree });
604
+ const page = options.payloadOnly && await createPayloadOnlyPage(state, payload, encode, resolver) || createTreePage(ReactRuntime, tree, payload.json, resolver, void 0, payload.values);
478
605
  return ReactRuntime.createElement(/* @__PURE__ */ __name(function FarmServerTreePage() {
479
606
  return page;
480
607
  }, "FarmServerTreePage"));
@@ -506,19 +633,34 @@ function originalExport(module, exportName) {
506
633
  __name(originalExport, "originalExport");
507
634
  async function createFarmServerTreeElement(ReactRuntime, source, options) {
508
635
  const root = typeof source === "string" ? parseHtml(source) : source;
509
- const script = root.querySelector(`script[${FARM_SERVER_TREE_ATTRIBUTE}]`);
636
+ const script = root.querySelector(
637
+ `script[type="${FARM_SERVER_TREE_SCRIPT_TYPE}"]`
638
+ );
510
639
  if (!script) return null;
511
640
  const json = script.textContent ?? "";
512
- const payload = JSON.parse(json);
641
+ let ingested = false;
642
+ const parsePayload = /* @__PURE__ */ __name((text) => {
643
+ const parsed = JSON.parse(text);
644
+ if (!text.includes(`"${FARM_TAG}":"${FARM_REFERENCE_TAG}"`)) return parsed;
645
+ if (!options.values) throw new Error("island values need islands mode");
646
+ if (!ingested) {
647
+ options.values.ingest(root);
648
+ ingested = true;
649
+ }
650
+ return options.values.resolve(parsed);
651
+ }, "parsePayload");
652
+ const payload = parsePayload(json);
513
653
  if (payload.v !== 1) throw new Error("unsupported server tree payload version");
654
+ const values = readTreeValueScripts(script);
514
655
  const chunks = /* @__PURE__ */ new Map();
515
656
  for (const chunkScript of root.querySelectorAll(
516
- `script[${SERVER_TREE_CHUNK_ATTRIBUTE}]`
657
+ `script[type="${SERVER_TREE_CHUNK_SCRIPT_TYPE}"]`
517
658
  )) {
518
659
  const chunkJson = chunkScript.textContent ?? "";
519
- chunks.set(Number(chunkScript.getAttribute(SERVER_TREE_CHUNK_ATTRIBUTE)), {
520
- tree: JSON.parse(chunkJson).t,
521
- json: chunkJson
660
+ chunks.set(Number(chunkScript.getAttribute("name")), {
661
+ tree: parsePayload(chunkJson).t,
662
+ json: chunkJson,
663
+ values: readTreeValueScripts(chunkScript)
522
664
  });
523
665
  }
524
666
  const references = /* @__PURE__ */ new Set();
@@ -549,7 +691,13 @@ async function createFarmServerTreeElement(ReactRuntime, source, options) {
549
691
  ReactRuntime.Fragment,
550
692
  null,
551
693
  createTreeValue(ReactRuntime, chunk.tree, resolver),
552
- createTreeScript(ReactRuntime, SERVER_TREE_CHUNK_ATTRIBUTE, String(id), chunk.json)
694
+ createTreeScript(
695
+ ReactRuntime,
696
+ SERVER_TREE_CHUNK_SCRIPT_TYPE,
697
+ String(id),
698
+ chunk.json,
699
+ chunk.values
700
+ )
553
701
  );
554
702
  return { status: "fulfilled", value, promise: Promise.resolve(value) };
555
703
  },
@@ -564,9 +712,14 @@ async function createFarmServerTreeElement(ReactRuntime, source, options) {
564
712
  suppressHydrationWarning: true,
565
713
  dangerouslySetInnerHTML: { __html: html }
566
714
  });
567
- }
715
+ },
716
+ action(id) {
717
+ if (!options.actions) throw new Error("server action props need islands mode");
718
+ return options.actions(id);
719
+ },
720
+ decode: options.decode ? (object, decodeChild) => options.decode(object, decodeChild) : void 0
568
721
  };
569
- const build = /* @__PURE__ */ __name(() => createTreePage(ReactRuntime, payload.t, json, resolver), "build");
722
+ const build = /* @__PURE__ */ __name(() => createTreePage(ReactRuntime, payload.t, json, resolver, void 0, values), "build");
570
723
  build();
571
724
  function FarmServerTreePage() {
572
725
  const [, setVersion] = ReactRuntime.useState(0);
@@ -595,7 +748,8 @@ async function createFarmServerTreeElement(ReactRuntime, source, options) {
595
748
  __name(createFarmServerTreeElement, "createFarmServerTreeElement");
596
749
 
597
750
  export {
598
- FARM_SERVER_TREE_ATTRIBUTE,
751
+ FARM_SERVER_TREE_SCRIPT_TYPE,
752
+ FARM_SERVER_TREE_PAYLOAD_ONLY_ATTRIBUTE,
599
753
  renderFarmServerTreePage,
600
754
  createFarmServerTreeElement
601
755
  };
@@ -2,19 +2,20 @@ import {
2
2
  resolveFarmAuthConfig,
3
3
  resolveFarmAuthIntegration,
4
4
  resolveFarmDevIndicatorsConfig,
5
+ resolveFarmServerComponentsMode,
5
6
  setFarmProjectSourceDir
6
- } from "./chunk-HCSVR4YZ.mjs";
7
- import {
8
- normalizeRouteRules,
9
- routeRulesToHeaders,
10
- routeRulesToRedirects
11
- } from "./chunk-GHFS7RUB.mjs";
7
+ } from "./chunk-M3BXTWJM.mjs";
12
8
  import {
13
9
  assertPluginDependencies
14
10
  } from "./chunk-CZS6OACQ.mjs";
15
11
  import {
16
12
  resolveFarmDevtoolsConfig
17
13
  } from "./chunk-JBSVKMC5.mjs";
14
+ import {
15
+ normalizeRouteRules,
16
+ routeRulesToHeaders,
17
+ routeRulesToRedirects
18
+ } from "./chunk-GHFS7RUB.mjs";
18
19
  import {
19
20
  isReactRenderer,
20
21
  resolveFarmRenderer
@@ -68,7 +69,7 @@ import {
68
69
  } from "./chunk-AELACLOB.mjs";
69
70
  import {
70
71
  resolveIntegrationPlugins
71
- } from "./chunk-AX7S67YV.mjs";
72
+ } from "./chunk-37VKVISD.mjs";
72
73
  import {
73
74
  compileMiddlewareConfig
74
75
  } from "./chunk-HKFBMHCD.mjs";
@@ -680,6 +681,7 @@ function validateConfigRouteSources(routes, field) {
680
681
  }
681
682
  __name(validateConfigRouteSources, "validateConfigRouteSources");
682
683
  async function resolveConfig(userConfig, mode) {
684
+ resolveFarmServerComponentsMode(userConfig.experimental?.serverComponents);
683
685
  const projectRoot = userConfig.root || process.cwd();
684
686
  const layerResolution = await resolveFarmLayers(userConfig, {
685
687
  root: projectRoot,
@@ -794,7 +796,9 @@ async function resolveConfig(userConfig, mode) {
794
796
  experimental: {
795
797
  serverComponents: false,
796
798
  serverActions: false,
797
- isolatedClientHydration: "off",
799
+ // Islands mode hydrates client components as islands (RFC 0003); an app can still pick
800
+ // isolatedClientHydration itself.
801
+ isolatedClientHydration: resolveFarmServerComponentsMode(userConfig.experimental?.serverComponents) === "islands" ? "enabled" : "off",
798
802
  ppr: false,
799
803
  ...userConfig.experimental
800
804
  },