@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
@@ -0,0 +1,148 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+ var _chunkYKUEJ3MGcjs = require('./chunk-YKUEJ3MG.cjs');
5
+
6
+
7
+
8
+
9
+
10
+ var _chunkH7BLEEAEcjs = require('./chunk-H7BLEEAE.cjs');
11
+
12
+
13
+
14
+ var _chunk6IZWX6EScjs = require('./chunk-6IZWX6ES.cjs');
15
+
16
+
17
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
18
+
19
+ // src/client/island-values.ts
20
+ var FARM_VALUE_MIN_LENGTH = 512;
21
+ function hashFarmValue(json) {
22
+ let h1 = 3735928559 ^ json.length;
23
+ let h2 = 1103547991 ^ json.length;
24
+ for (let index = 0; index < json.length; index++) {
25
+ const code = json.charCodeAt(index);
26
+ h1 = Math.imul(h1 ^ code, 2654435761);
27
+ h2 = Math.imul(h2 ^ code, 1597334677);
28
+ }
29
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
30
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
31
+ return (h2 >>> 0).toString(36).padStart(7, "0") + (h1 >>> 0).toString(36).padStart(7, "0");
32
+ }
33
+ _chunkS3JO3N4Hcjs.__name.call(void 0, hashFarmValue, "hashFarmValue");
34
+ function addressFarmValues(props, minLength = FARM_VALUE_MIN_LENGTH) {
35
+ const values = /* @__PURE__ */ new Map();
36
+ const reference = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (json2, children, parent) => {
37
+ const key = hashFarmValue(json2);
38
+ if (!values.has(key)) values.set(key, { key, json: json2, children });
39
+ parent.push(key);
40
+ return `{"$":"${_chunkH7BLEEAEcjs.FARM_REFERENCE_TAG}","v":"${key}"}`;
41
+ }, "reference");
42
+ const encode = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (value, parent) => {
43
+ if (value === null || typeof value !== "object") {
44
+ const json3 = JSON.stringify(value);
45
+ return [
46
+ typeof value === "string" && json3.length >= minLength ? reference(json3, [], parent) : json3,
47
+ json3.length
48
+ ];
49
+ }
50
+ const own = [];
51
+ let length = 2;
52
+ const parts = [];
53
+ if (Array.isArray(value)) {
54
+ for (const entry of value) {
55
+ const [json3, entryLength] = encode(entry, own);
56
+ parts.push(json3);
57
+ length += entryLength + 1;
58
+ }
59
+ } else {
60
+ for (const [key, entry] of Object.entries(value)) {
61
+ const [json3, entryLength] = encode(entry, own);
62
+ const name = JSON.stringify(key);
63
+ parts.push(`${name}:${json3}`);
64
+ length += name.length + entryLength + 2;
65
+ }
66
+ }
67
+ const json2 = Array.isArray(value) ? `[${parts.join(",")}]` : `{${parts.join(",")}}`;
68
+ const wrapper = own.length === 1 && json2.length < minLength / 4;
69
+ if (length >= minLength && !wrapper) return [reference(json2, own, parent), length];
70
+ parent.push(...own);
71
+ return [json2, length];
72
+ }, "encode");
73
+ const roots = [];
74
+ const json = `{${Object.entries(props).map(([key, entry]) => `${JSON.stringify(key)}:${encode(entry, roots)[0]}`).join(",")}}`;
75
+ return { json, values, roots };
76
+ }
77
+ _chunkS3JO3N4Hcjs.__name.call(void 0, addressFarmValues, "addressFarmValues");
78
+ function selectFarmValuesToSend(addressed, held) {
79
+ const send = [];
80
+ const seen = /* @__PURE__ */ new Set();
81
+ const visit = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (key) => {
82
+ if (seen.has(key)) return;
83
+ seen.add(key);
84
+ if (_optionalChain([held, 'optionalAccess', _ => _.has, 'call', _2 => _2(key)])) return;
85
+ const value = addressed.values.get(key);
86
+ send.push(value);
87
+ value.children.forEach(visit);
88
+ }, "visit");
89
+ addressed.roots.forEach(visit);
90
+ return send;
91
+ }
92
+ _chunkS3JO3N4Hcjs.__name.call(void 0, selectFarmValuesToSend, "selectFarmValuesToSend");
93
+ function parseFarmHeldValues(header) {
94
+ const held = /* @__PURE__ */ new Set();
95
+ if (!header) return held;
96
+ for (const key of header.split(",", _chunkH7BLEEAEcjs.FARM_MAX_HELD_VALUES * 2)) {
97
+ const trimmed = key.trim();
98
+ if (_chunkH7BLEEAEcjs.FARM_VALUE_KEY_PATTERN.test(trimmed)) held.add(trimmed);
99
+ if (held.size === _chunkH7BLEEAEcjs.FARM_MAX_HELD_VALUES) break;
100
+ }
101
+ return held;
102
+ }
103
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseFarmHeldValues, "parseFarmHeldValues");
104
+ var heldByRequest = /* @__PURE__ */ new WeakMap();
105
+ var ignoredRequests = /* @__PURE__ */ new WeakSet();
106
+ function ignoreFarmHeldValues() {
107
+ const request = _chunk6IZWX6EScjs._resolveCurrentRequest.call(void 0, );
108
+ if (request) ignoredRequests.add(request);
109
+ }
110
+ _chunkS3JO3N4Hcjs.__name.call(void 0, ignoreFarmHeldValues, "ignoreFarmHeldValues");
111
+ function readFarmHeldValues() {
112
+ const request = _chunk6IZWX6EScjs._resolveCurrentRequest.call(void 0, );
113
+ if (!request || ignoredRequests.has(request)) return null;
114
+ let held = heldByRequest.get(request);
115
+ if (!held) {
116
+ held = parseFarmHeldValues(request.headers.get(_chunkH7BLEEAEcjs.FARM_VALUES_HEADER));
117
+ heldByRequest.set(request, held);
118
+ if (held.size > 0) void _optionalChain([_chunk6IZWX6EScjs._resolveCurrentRequestForApp.call(void 0, ), 'optionalAccess', _3 => _3.headers]);
119
+ }
120
+ return held.size > 0 ? held : null;
121
+ }
122
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readFarmHeldValues, "readFarmHeldValues");
123
+ var SERVER_KEY = /* @__PURE__ */ Symbol.for("farm.island-values.server");
124
+ var sentByRequest = /* @__PURE__ */ new WeakMap();
125
+ function resolveFarmIslandRenderState() {
126
+ const request = _chunk6IZWX6EScjs._resolveCurrentRequest.call(void 0, );
127
+ if (!request) return null;
128
+ let sent = sentByRequest.get(request);
129
+ if (!sent) sentByRequest.set(request, sent = /* @__PURE__ */ new Set());
130
+ return { held: readFarmHeldValues(), sent };
131
+ }
132
+ _chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmIslandRenderState, "resolveFarmIslandRenderState");
133
+ function installFarmIslandValues() {
134
+ globalThis[SERVER_KEY] = {
135
+ address: addressFarmValues,
136
+ select: selectFarmValuesToSend,
137
+ held: readFarmHeldValues,
138
+ encodeLeaf: _chunkYKUEJ3MGcjs.encodeFarmLeaf,
139
+ decode: _chunkYKUEJ3MGcjs.decodeFarmTagged
140
+ };
141
+ }
142
+ _chunkS3JO3N4Hcjs.__name.call(void 0, installFarmIslandValues, "installFarmIslandValues");
143
+
144
+
145
+
146
+
147
+
148
+ exports.ignoreFarmHeldValues = ignoreFarmHeldValues; exports.resolveFarmIslandRenderState = resolveFarmIslandRenderState; exports.installFarmIslandValues = installFarmIslandValues;
@@ -0,0 +1,132 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+ var _chunkPDU4P2ICcjs = require('./chunk-PDU4P2IC.cjs');
5
+
6
+
7
+ var _chunk5QIKR7RRcjs = require('./chunk-5QIKR7RR.cjs');
8
+
9
+
10
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
11
+
12
+ // src/server-components-status.ts
13
+ var _fs = require('fs');
14
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
15
+ var FARM_RSC_PACKAGES = [
16
+ "@farm.js/plugin",
17
+ "@vitejs/plugin-rsc",
18
+ "react-server-dom-webpack"
19
+ ];
20
+ var FARM_RSC_INSTALL_HINT = `pnpm add ${FARM_RSC_PACKAGES.join(" ")}`;
21
+ var FARM_RSC_BLOCKING_KEYS = [
22
+ "auth",
23
+ "integrations",
24
+ "headers",
25
+ "redirects",
26
+ "rewrites",
27
+ "routeRules",
28
+ "context"
29
+ ];
30
+ var FARM_RSC_IGNORED_KEYS = [
31
+ "plugins",
32
+ "storage",
33
+ "schema",
34
+ "cron",
35
+ "workflows",
36
+ "docs",
37
+ "theme",
38
+ "observability"
39
+ ];
40
+ function farmConfigUsesServerComponents(config) {
41
+ return _chunkPDU4P2ICcjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'optionalAccess', _ => _.experimental, 'optionalAccess', _2 => _2.serverComponents])) === "rsc";
42
+ }
43
+ _chunkS3JO3N4Hcjs.__name.call(void 0, farmConfigUsesServerComponents, "farmConfigUsesServerComponents");
44
+ function findFarmAppPackageDir(root, packageName) {
45
+ for (let dir = _path2.default.resolve(root); ; dir = _path2.default.dirname(dir)) {
46
+ const candidate = _path2.default.join(dir, "node_modules", packageName);
47
+ if (_fs.existsSync.call(void 0, _path2.default.join(candidate, "package.json"))) return _fs.realpathSync.call(void 0, candidate);
48
+ if (_path2.default.dirname(dir) === dir) return void 0;
49
+ }
50
+ }
51
+ _chunkS3JO3N4Hcjs.__name.call(void 0, findFarmAppPackageDir, "findFarmAppPackageDir");
52
+ function isSet(value) {
53
+ if (value === void 0 || value === false || value === null) return false;
54
+ if (Array.isArray(value)) return value.length > 0;
55
+ return typeof value !== "object" || Object.keys(value).length > 0;
56
+ }
57
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isSet, "isSet");
58
+ function inspectFarmServerComponents(config, root) {
59
+ const value = _optionalChain([config, 'optionalAccess', _3 => _3.experimental, 'optionalAccess', _4 => _4.serverComponents]);
60
+ const mode = _chunkPDU4P2ICcjs.resolveFarmServerComponentsMode.call(void 0, value);
61
+ const enabled = mode === "rsc";
62
+ const explicit = enabled && _chunkPDU4P2ICcjs.isExplicitFarmServerComponentsMode.call(void 0, value);
63
+ const missingPackages = enabled ? FARM_RSC_PACKAGES.filter((name) => !findFarmAppPackageDir(root, name)) : [];
64
+ return {
65
+ mode,
66
+ enabled,
67
+ explicit,
68
+ missingPackages,
69
+ // `true` predates the pipeline; `{ mode: "rsc" }` is new and fails with the install command.
70
+ fallback: enabled && !explicit && missingPackages.length > 0,
71
+ blockingKeys: enabled ? FARM_RSC_BLOCKING_KEYS.filter((key) => isSet(_optionalChain([config, 'optionalAccess', _5 => _5[key]]))) : [],
72
+ ignoredKeys: enabled ? FARM_RSC_IGNORED_KEYS.filter((key) => isSet(_optionalChain([config, 'optionalAccess', _6 => _6[key]]))) : []
73
+ };
74
+ }
75
+ _chunkS3JO3N4Hcjs.__name.call(void 0, inspectFarmServerComponents, "inspectFarmServerComponents");
76
+ function formatKeys(keys) {
77
+ return keys.map((key) => `\`${key}\``).join(", ");
78
+ }
79
+ _chunkS3JO3N4Hcjs.__name.call(void 0, formatKeys, "formatKeys");
80
+ function formatFarmRscFallbackMessage(missingPackages, blockingKeys = []) {
81
+ if (blockingKeys.length > 0) {
82
+ return `experimental.serverComponents is true, but this app uses ${formatKeys(
83
+ blockingKeys
84
+ )}, which the RSC pipeline does not run yet, so it runs without React Server Components. Remove the flag, or move ${blockingKeys.length === 1 ? "that feature" : "those features"} out of farm.config to turn RSC on.`;
85
+ }
86
+ return `experimental.serverComponents is true, but ${missingPackages.join(", ")} ${missingPackages.length === 1 ? "is" : "are"} not installed, so the app runs without React Server Components. \`farm dev\` and \`farm build\` install them outside CI; in CI or with another tool, run ${FARM_RSC_INSTALL_HINT}.`;
87
+ }
88
+ _chunkS3JO3N4Hcjs.__name.call(void 0, formatFarmRscFallbackMessage, "formatFarmRscFallbackMessage");
89
+ function formatFarmRscBlockingMessage(blockingKeys) {
90
+ return `experimental.serverComponents runs on the RSC pipeline, which does not run ${formatKeys(
91
+ blockingKeys
92
+ )} yet. Serving the app without ${blockingKeys.length === 1 ? "it" : "them"} could expose what ${blockingKeys.length === 1 ? "it protects" : "they protect"}, so RSC does not start. Remove experimental.serverComponents to keep ${blockingKeys.length === 1 ? "it" : "them"}.`;
93
+ }
94
+ _chunkS3JO3N4Hcjs.__name.call(void 0, formatFarmRscBlockingMessage, "formatFarmRscBlockingMessage");
95
+ var warnedFallback = false;
96
+ function farmAppUsesRscPipeline(config, root) {
97
+ const status = inspectFarmServerComponents(config, root);
98
+ if (status.mode === "islands") return false;
99
+ if (!status.enabled) return false;
100
+ if (status.fallback) {
101
+ if (!warnedFallback) {
102
+ warnedFallback = true;
103
+ _chunk5QIKR7RRcjs.logger.warn(
104
+ `[Farm.js] ${formatFarmRscFallbackMessage(status.missingPackages, status.blockingKeys)}`
105
+ );
106
+ }
107
+ return false;
108
+ }
109
+ if (status.blockingKeys.length > 0) {
110
+ throw new Error(`[Farm.js] ${formatFarmRscBlockingMessage(status.blockingKeys)}`);
111
+ }
112
+ if (status.ignoredKeys.length > 0) {
113
+ _chunk5QIKR7RRcjs.logger.warn(
114
+ `[Farm.js] experimental.serverComponents runs on the RSC pipeline, which does not run ${formatKeys(
115
+ status.ignoredKeys
116
+ )} yet. ${status.ignoredKeys.length === 1 ? "It is" : "They are"} ignored.`
117
+ );
118
+ }
119
+ return true;
120
+ }
121
+ _chunkS3JO3N4Hcjs.__name.call(void 0, farmAppUsesRscPipeline, "farmAppUsesRscPipeline");
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+ exports.FARM_RSC_PACKAGES = FARM_RSC_PACKAGES; exports.FARM_RSC_INSTALL_HINT = FARM_RSC_INSTALL_HINT; exports.farmConfigUsesServerComponents = farmConfigUsesServerComponents; exports.findFarmAppPackageDir = findFarmAppPackageDir; exports.inspectFarmServerComponents = inspectFarmServerComponents; exports.formatFarmRscFallbackMessage = formatFarmRscFallbackMessage; exports.formatFarmRscBlockingMessage = formatFarmRscBlockingMessage; exports.farmAppUsesRscPipeline = farmAppUsesRscPipeline;
@@ -7,7 +7,7 @@ var _chunkPCOTGFSMcjs = require('./chunk-PCOTGFSM.cjs');
7
7
 
8
8
 
9
9
 
10
- var _chunk7YHSD3Z6cjs = require('./chunk-7YHSD3Z6.cjs');
10
+ var _chunkGVNCWSQVcjs = require('./chunk-GVNCWSQV.cjs');
11
11
 
12
12
 
13
13
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
@@ -59,7 +59,7 @@ function createFarmLayoutSelector(layouts, resolveRouteDirectory) {
59
59
  return {
60
60
  layout,
61
61
  segments: segments.length === 0 ? null : segments,
62
- groupScope: _chunk7YHSD3Z6cjs.getRouteGroupScope.call(void 0, layout.pattern)
62
+ groupScope: _chunkGVNCWSQVcjs.getRouteGroupScope.call(void 0, layout.pattern)
63
63
  };
64
64
  });
65
65
  return (pathname, routeDirectory) => {
@@ -73,7 +73,7 @@ function createFarmLayoutSelector(layouts, resolveRouteDirectory) {
73
73
  }
74
74
  if (groupScope !== null) {
75
75
  if (directory === void 0) directory = _nullishCoalesce(_optionalChain([resolveRouteDirectory, 'optionalCall', _2 => _2(pathname)]), () => ( null));
76
- if (!_chunk7YHSD3Z6cjs.isInRouteGroupScope.call(void 0, directory, groupScope)) continue;
76
+ if (!_chunkGVNCWSQVcjs.isInRouteGroupScope.call(void 0, directory, groupScope)) continue;
77
77
  }
78
78
  applicable.push(layout);
79
79
  }
@@ -82,9 +82,9 @@ function createFarmLayoutSelector(layouts, resolveRouteDirectory) {
82
82
  }
83
83
  _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmLayoutSelector, "createFarmLayoutSelector");
84
84
  function layoutsCanCoverSamePage(a, b) {
85
- const scopeA = _chunk7YHSD3Z6cjs.getRouteGroupScope.call(void 0, a);
86
- const scopeB = _chunk7YHSD3Z6cjs.getRouteGroupScope.call(void 0, b);
87
- if (scopeA !== null && scopeB !== null && !_chunk7YHSD3Z6cjs.isInRouteGroupScope.call(void 0, scopeA, scopeB) && !_chunk7YHSD3Z6cjs.isInRouteGroupScope.call(void 0, scopeB, scopeA)) {
85
+ const scopeA = _chunkGVNCWSQVcjs.getRouteGroupScope.call(void 0, a);
86
+ const scopeB = _chunkGVNCWSQVcjs.getRouteGroupScope.call(void 0, b);
87
+ if (scopeA !== null && scopeB !== null && !_chunkGVNCWSQVcjs.isInRouteGroupScope.call(void 0, scopeA, scopeB) && !_chunkGVNCWSQVcjs.isInRouteGroupScope.call(void 0, scopeB, scopeA)) {
88
88
  return false;
89
89
  }
90
90
  const segmentsA = a === "/" ? [] : _chunkPCOTGFSMcjs.parseRoutePattern.call(void 0, a);
@@ -0,0 +1,98 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
5
+
6
+ // src/react-refresh.ts
7
+ var _module = require('module');
8
+ var _url = require('url');
9
+ var REACT_REFRESH_PLUGIN = "vite:react-refresh";
10
+ var FARM_REACT_REFRESH_PREAMBLE_ID = "/@farm/react-refresh-preamble";
11
+ var FARM_OWNED = /* @__PURE__ */ Symbol.for("farm.react-refresh.owned");
12
+ function isFarmReactRefreshActive(config) {
13
+ return config.command === "serve" && !config.isProduction && config.server.hmr !== false && config.plugins.some((plugin) => plugin.name === REACT_REFRESH_PLUGIN);
14
+ }
15
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isFarmReactRefreshActive, "isFarmReactRefreshActive");
16
+ function isFarmClientEntryId(id) {
17
+ const pathname = id.split("?", 1)[0];
18
+ return pathname === "/@farm/client" || pathname === "/@farm/client.js";
19
+ }
20
+ _chunkS3JO3N4Hcjs.__name.call(void 0, isFarmClientEntryId, "isFarmClientEntryId");
21
+ function hasAppReactPlugin(plugins) {
22
+ const pending = [..._nullishCoalesce(plugins, () => ( []))];
23
+ while (pending.length > 0) {
24
+ const entry = pending.pop();
25
+ if (Array.isArray(entry)) {
26
+ pending.push(...entry);
27
+ continue;
28
+ }
29
+ if (!entry || typeof entry !== "object" || "then" in entry) continue;
30
+ if (entry.name === REACT_REFRESH_PLUGIN && !(FARM_OWNED in entry)) return true;
31
+ }
32
+ return false;
33
+ }
34
+ _chunkS3JO3N4Hcjs.__name.call(void 0, hasAppReactPlugin, "hasAppReactPlugin");
35
+ function createFarmReactRefreshPreamblePlugin() {
36
+ let active = false;
37
+ return {
38
+ name: "farm:react-refresh-preamble",
39
+ apply: "serve",
40
+ configResolved(config) {
41
+ active = isFarmReactRefreshActive(config);
42
+ },
43
+ resolveId(id) {
44
+ if (id === FARM_REACT_REFRESH_PREAMBLE_ID) return id;
45
+ },
46
+ load(id) {
47
+ if (id !== FARM_REACT_REFRESH_PREAMBLE_ID) return;
48
+ if (!active) return "";
49
+ return `import RefreshRuntime from "/@react-refresh";
50
+ RefreshRuntime.injectIntoGlobalHook(window);
51
+ window.$RefreshReg$ = () => {};
52
+ window.$RefreshSig$ = () => (type) => type;
53
+ window.__vite_plugin_react_preamble_installed__ = true;
54
+ `;
55
+ },
56
+ transform(code, id) {
57
+ if (!active || _optionalChain([this, 'access', _ => _.environment, 'optionalAccess', _2 => _2.config, 'access', _3 => _3.consumer]) !== "client" || !isFarmClientEntryId(id)) {
58
+ return;
59
+ }
60
+ return {
61
+ code: `import ${JSON.stringify(FARM_REACT_REFRESH_PREAMBLE_ID)};
62
+ ${code}`,
63
+ map: null
64
+ };
65
+ }
66
+ };
67
+ }
68
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmReactRefreshPreamblePlugin, "createFarmReactRefreshPreamblePlugin");
69
+ async function loadFarmReactPlugin() {
70
+ const entry = _module.createRequire.call(void 0,
71
+ typeof __filename === "string" ? __filename : _chunkS3JO3N4Hcjs.define_import_meta_default.url
72
+ ).resolve("@vitejs/plugin-react");
73
+ return await import(
74
+ /* @vite-ignore */
75
+ _url.pathToFileURL.call(void 0, entry).href
76
+ );
77
+ }
78
+ _chunkS3JO3N4Hcjs.__name.call(void 0, loadFarmReactPlugin, "loadFarmReactPlugin");
79
+ async function createFarmReactRefreshPlugins() {
80
+ const { default: react } = await loadFarmReactPlugin();
81
+ const plugins = react().map(
82
+ (plugin) => Object.assign(
83
+ {
84
+ ...plugin,
85
+ apply: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (config, env) => env.command === "serve" && !hasAppReactPlugin(config.plugins), "apply")
86
+ },
87
+ { [FARM_OWNED]: true }
88
+ )
89
+ );
90
+ return [...plugins, createFarmReactRefreshPreamblePlugin()];
91
+ }
92
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmReactRefreshPlugins, "createFarmReactRefreshPlugins");
93
+
94
+
95
+
96
+
97
+
98
+ exports.isFarmReactRefreshActive = isFarmReactRefreshActive; exports.loadFarmReactPlugin = loadFarmReactPlugin; exports.createFarmReactRefreshPlugins = createFarmReactRefreshPlugins;
@@ -0,0 +1,148 @@
1
+ import {
2
+ decodeFarmTagged,
3
+ encodeFarmLeaf
4
+ } from "./chunk-PJEHUSHA.mjs";
5
+ import {
6
+ FARM_MAX_HELD_VALUES,
7
+ FARM_REFERENCE_TAG,
8
+ FARM_VALUES_HEADER,
9
+ FARM_VALUE_KEY_PATTERN
10
+ } from "./chunk-2NXO5SBY.mjs";
11
+ import {
12
+ _resolveCurrentRequest,
13
+ _resolveCurrentRequestForApp
14
+ } from "./chunk-6LVRDOAW.mjs";
15
+ import {
16
+ __name
17
+ } from "./chunk-LPEX4YW6.mjs";
18
+
19
+ // src/client/island-values.ts
20
+ var FARM_VALUE_MIN_LENGTH = 512;
21
+ function hashFarmValue(json) {
22
+ let h1 = 3735928559 ^ json.length;
23
+ let h2 = 1103547991 ^ json.length;
24
+ for (let index = 0; index < json.length; index++) {
25
+ const code = json.charCodeAt(index);
26
+ h1 = Math.imul(h1 ^ code, 2654435761);
27
+ h2 = Math.imul(h2 ^ code, 1597334677);
28
+ }
29
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
30
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
31
+ return (h2 >>> 0).toString(36).padStart(7, "0") + (h1 >>> 0).toString(36).padStart(7, "0");
32
+ }
33
+ __name(hashFarmValue, "hashFarmValue");
34
+ function addressFarmValues(props, minLength = FARM_VALUE_MIN_LENGTH) {
35
+ const values = /* @__PURE__ */ new Map();
36
+ const reference = /* @__PURE__ */ __name((json2, children, parent) => {
37
+ const key = hashFarmValue(json2);
38
+ if (!values.has(key)) values.set(key, { key, json: json2, children });
39
+ parent.push(key);
40
+ return `{"$":"${FARM_REFERENCE_TAG}","v":"${key}"}`;
41
+ }, "reference");
42
+ const encode = /* @__PURE__ */ __name((value, parent) => {
43
+ if (value === null || typeof value !== "object") {
44
+ const json3 = JSON.stringify(value);
45
+ return [
46
+ typeof value === "string" && json3.length >= minLength ? reference(json3, [], parent) : json3,
47
+ json3.length
48
+ ];
49
+ }
50
+ const own = [];
51
+ let length = 2;
52
+ const parts = [];
53
+ if (Array.isArray(value)) {
54
+ for (const entry of value) {
55
+ const [json3, entryLength] = encode(entry, own);
56
+ parts.push(json3);
57
+ length += entryLength + 1;
58
+ }
59
+ } else {
60
+ for (const [key, entry] of Object.entries(value)) {
61
+ const [json3, entryLength] = encode(entry, own);
62
+ const name = JSON.stringify(key);
63
+ parts.push(`${name}:${json3}`);
64
+ length += name.length + entryLength + 2;
65
+ }
66
+ }
67
+ const json2 = Array.isArray(value) ? `[${parts.join(",")}]` : `{${parts.join(",")}}`;
68
+ const wrapper = own.length === 1 && json2.length < minLength / 4;
69
+ if (length >= minLength && !wrapper) return [reference(json2, own, parent), length];
70
+ parent.push(...own);
71
+ return [json2, length];
72
+ }, "encode");
73
+ const roots = [];
74
+ const json = `{${Object.entries(props).map(([key, entry]) => `${JSON.stringify(key)}:${encode(entry, roots)[0]}`).join(",")}}`;
75
+ return { json, values, roots };
76
+ }
77
+ __name(addressFarmValues, "addressFarmValues");
78
+ function selectFarmValuesToSend(addressed, held) {
79
+ const send = [];
80
+ const seen = /* @__PURE__ */ new Set();
81
+ const visit = /* @__PURE__ */ __name((key) => {
82
+ if (seen.has(key)) return;
83
+ seen.add(key);
84
+ if (held?.has(key)) return;
85
+ const value = addressed.values.get(key);
86
+ send.push(value);
87
+ value.children.forEach(visit);
88
+ }, "visit");
89
+ addressed.roots.forEach(visit);
90
+ return send;
91
+ }
92
+ __name(selectFarmValuesToSend, "selectFarmValuesToSend");
93
+ function parseFarmHeldValues(header) {
94
+ const held = /* @__PURE__ */ new Set();
95
+ if (!header) return held;
96
+ for (const key of header.split(",", FARM_MAX_HELD_VALUES * 2)) {
97
+ const trimmed = key.trim();
98
+ if (FARM_VALUE_KEY_PATTERN.test(trimmed)) held.add(trimmed);
99
+ if (held.size === FARM_MAX_HELD_VALUES) break;
100
+ }
101
+ return held;
102
+ }
103
+ __name(parseFarmHeldValues, "parseFarmHeldValues");
104
+ var heldByRequest = /* @__PURE__ */ new WeakMap();
105
+ var ignoredRequests = /* @__PURE__ */ new WeakSet();
106
+ function ignoreFarmHeldValues() {
107
+ const request = _resolveCurrentRequest();
108
+ if (request) ignoredRequests.add(request);
109
+ }
110
+ __name(ignoreFarmHeldValues, "ignoreFarmHeldValues");
111
+ function readFarmHeldValues() {
112
+ const request = _resolveCurrentRequest();
113
+ if (!request || ignoredRequests.has(request)) return null;
114
+ let held = heldByRequest.get(request);
115
+ if (!held) {
116
+ held = parseFarmHeldValues(request.headers.get(FARM_VALUES_HEADER));
117
+ heldByRequest.set(request, held);
118
+ if (held.size > 0) void _resolveCurrentRequestForApp()?.headers;
119
+ }
120
+ return held.size > 0 ? held : null;
121
+ }
122
+ __name(readFarmHeldValues, "readFarmHeldValues");
123
+ var SERVER_KEY = /* @__PURE__ */ Symbol.for("farm.island-values.server");
124
+ var sentByRequest = /* @__PURE__ */ new WeakMap();
125
+ function resolveFarmIslandRenderState() {
126
+ const request = _resolveCurrentRequest();
127
+ if (!request) return null;
128
+ let sent = sentByRequest.get(request);
129
+ if (!sent) sentByRequest.set(request, sent = /* @__PURE__ */ new Set());
130
+ return { held: readFarmHeldValues(), sent };
131
+ }
132
+ __name(resolveFarmIslandRenderState, "resolveFarmIslandRenderState");
133
+ function installFarmIslandValues() {
134
+ globalThis[SERVER_KEY] = {
135
+ address: addressFarmValues,
136
+ select: selectFarmValuesToSend,
137
+ held: readFarmHeldValues,
138
+ encodeLeaf: encodeFarmLeaf,
139
+ decode: decodeFarmTagged
140
+ };
141
+ }
142
+ __name(installFarmIslandValues, "installFarmIslandValues");
143
+
144
+ export {
145
+ ignoreFarmHeldValues,
146
+ resolveFarmIslandRenderState,
147
+ installFarmIslandValues
148
+ };
@@ -58,8 +58,10 @@ import {
58
58
  } from "./chunk-LPEX4YW6.mjs";
59
59
 
60
60
  // src/api/vite-plugin.ts
61
+ import nodePath from "path";
61
62
  function farmApiPlugin(options = {}) {
62
63
  const srcDir = options.srcDir ?? "src";
64
+ const apiDirFromRoot = options.apiDir ?? nodePath.join(srcDir, "api");
63
65
  const debug = options.debug ?? false;
64
66
  const bodySizeLimit = resolveFarmServerConfig({
65
67
  bodySizeLimit: options.bodySizeLimit
@@ -356,7 +358,7 @@ function farmApiPlugin(options = {}) {
356
358
  }, "discoverProgrammaticRoutes");
357
359
  const initializeDiscovery = /* @__PURE__ */ __name(async () => {
358
360
  const path = await import("path");
359
- const apiDir = path.join(server.config.root, srcDir, "api");
361
+ const apiDir = path.join(server.config.root, apiDirFromRoot);
360
362
  log(`Discovering API routes in: ${apiDir}`);
361
363
  await discoverFileRoutes(apiDir);
362
364
  await discoverRootRoutes();
@@ -541,7 +543,7 @@ function farmApiPlugin(options = {}) {
541
543
  const previousState = snapshotRouteState();
542
544
  try {
543
545
  const path = await import("path");
544
- const apiDir = path.join(server.config.root, srcDir, "api");
546
+ const apiDir = path.join(server.config.root, apiDirFromRoot);
545
547
  const relativePath = path.relative(apiDir, path.dirname(file));
546
548
  const routePath = "/api/" + (relativePath === "." ? "" : relativePath.replace(/\\/g, "/"));
547
549
  const fs = await import("fs");
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
  var _chunkUXHS27O6cjs = require('./chunk-UXHS27O6.cjs');
4
4
 
@@ -58,8 +58,10 @@ var _chunkNO3WWW3Ncjs = require('./chunk-NO3WWW3N.cjs');
58
58
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
59
59
 
60
60
  // src/api/vite-plugin.ts
61
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
61
62
  function farmApiPlugin(options = {}) {
62
63
  const srcDir = _nullishCoalesce(options.srcDir, () => ( "src"));
64
+ const apiDirFromRoot = _nullishCoalesce(options.apiDir, () => ( _path2.default.join(srcDir, "api")));
63
65
  const debug = _nullishCoalesce(options.debug, () => ( false));
64
66
  const bodySizeLimit = _chunk5NAVKJCZcjs.resolveFarmServerConfig.call(void 0, {
65
67
  bodySizeLimit: options.bodySizeLimit
@@ -356,7 +358,7 @@ function farmApiPlugin(options = {}) {
356
358
  }, "discoverProgrammaticRoutes");
357
359
  const initializeDiscovery = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
358
360
  const path = await import("path");
359
- const apiDir = path.join(server.config.root, srcDir, "api");
361
+ const apiDir = path.join(server.config.root, apiDirFromRoot);
360
362
  log(`Discovering API routes in: ${apiDir}`);
361
363
  await discoverFileRoutes(apiDir);
362
364
  await discoverRootRoutes();
@@ -541,7 +543,7 @@ function farmApiPlugin(options = {}) {
541
543
  const previousState = snapshotRouteState();
542
544
  try {
543
545
  const path = await import("path");
544
- const apiDir = path.join(server.config.root, srcDir, "api");
546
+ const apiDir = path.join(server.config.root, apiDirFromRoot);
545
547
  const relativePath = path.relative(apiDir, path.dirname(file));
546
548
  const routePath = "/api/" + (relativePath === "." ? "" : relativePath.replace(/\\/g, "/"));
547
549
  const fs = await import("fs");