@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
@@ -21,7 +21,7 @@ var _chunkX3GMHKO3cjs = require('./chunk-X3GMHKO3.cjs');
21
21
  var _chunkOI6CMLWXcjs = require('./chunk-OI6CMLWX.cjs');
22
22
 
23
23
 
24
- var _chunkRHGK2JENcjs = require('./chunk-RHGK2JEN.cjs');
24
+ var _chunk3SAWHWDHcjs = require('./chunk-3SAWHWDH.cjs');
25
25
 
26
26
 
27
27
 
@@ -45,7 +45,7 @@ var _chunkKNBBQHO2cjs = require('./chunk-KNBBQHO2.cjs');
45
45
  var _chunk5NAVKJCZcjs = require('./chunk-5NAVKJCZ.cjs');
46
46
 
47
47
 
48
- var _chunkAHFRQMRXcjs = require('./chunk-AHFRQMRX.cjs');
48
+ var _chunk3YJMBQ27cjs = require('./chunk-3YJMBQ27.cjs');
49
49
 
50
50
 
51
51
  var _chunkBIDYX3SLcjs = require('./chunk-BIDYX3SL.cjs');
@@ -56,6 +56,56 @@ var _chunkI57LW5VZcjs = require('./chunk-I57LW5VZ.cjs');
56
56
 
57
57
  var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
58
58
 
59
+ // src/navigation/render-plan.ts
60
+ function createFarmRouteRenderPlan(input = {}) {
61
+ const pageShouldHydrate = input.pageShouldHydrate === true;
62
+ const layoutShouldHydrate = input.layoutShouldHydrate === true;
63
+ const hydration = pageShouldHydrate ? layoutShouldHydrate ? "route-and-layout-islands" : "route-island" : layoutShouldHydrate ? "layout-island" : "none";
64
+ const rendering = input.rendering;
65
+ const cache = _optionalChain([rendering, 'optionalAccess', _ => _.ssg]) ? typeof rendering.revalidate === "number" && rendering.revalidate > 0 ? { mode: "revalidate", revalidate: rendering.revalidate } : { mode: "static" } : { mode: "dynamic" };
66
+ return {
67
+ version: 1,
68
+ output: "html",
69
+ navigation: "html-fragment",
70
+ hydration,
71
+ islandStrategy: hydration === "none" ? null : _nullishCoalesce(input.islandStrategy, () => ( "load")),
72
+ cache
73
+ };
74
+ }
75
+ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmRouteRenderPlan, "createFarmRouteRenderPlan");
76
+ function getFarmFragmentCacheControl(plan) {
77
+ if (plan.cache.mode === "static") {
78
+ return "public, max-age=0, s-maxage=31536000, immutable";
79
+ }
80
+ if (plan.cache.mode === "revalidate") {
81
+ const seconds = Math.max(1, _nullishCoalesce(plan.cache.revalidate, () => ( 1)));
82
+ return `public, max-age=0, s-maxage=${seconds}, stale-while-revalidate=${seconds}`;
83
+ }
84
+ return "private, max-age=0";
85
+ }
86
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getFarmFragmentCacheControl, "getFarmFragmentCacheControl");
87
+ function parseFarmLayoutChainHeader(value) {
88
+ if (!value || value.length > 8192) return [];
89
+ try {
90
+ const parsed = JSON.parse(value);
91
+ if (!Array.isArray(parsed) || parsed.length > 64) return [];
92
+ return parsed.filter(
93
+ (pattern) => typeof pattern === "string" && pattern.startsWith("/") && pattern.length <= 512
94
+ );
95
+ } catch (e) {
96
+ return [];
97
+ }
98
+ }
99
+ _chunkS3JO3N4Hcjs.__name.call(void 0, parseFarmLayoutChainHeader, "parseFarmLayoutChainHeader");
100
+ function getSharedLayoutPrefixLength(current, next) {
101
+ let index = 0;
102
+ while (index < current.length && index < next.length && current[index] === next[index]) {
103
+ index++;
104
+ }
105
+ return index;
106
+ }
107
+ _chunkS3JO3N4Hcjs.__name.call(void 0, getSharedLayoutPrefixLength, "getSharedLayoutPrefixLength");
108
+
59
109
  // src/routing/route-groups.ts
60
110
  function isRouteGroupSegment(part) {
61
111
  return part.startsWith("(") && part.endsWith(")");
@@ -188,12 +238,12 @@ function removeFarmDocumentTitles(markup) {
188
238
  }
189
239
  _chunkS3JO3N4Hcjs.__name.call(void 0, removeFarmDocumentTitles, "removeFarmDocumentTitles");
190
240
  function ensureFarmDocumentMeta(markup, viewport = "") {
191
- const head = _nullishCoalesce(_optionalChain([/<head\b[^>]*>([\s\S]*?)<\/head>/i, 'access', _ => _.exec, 'call', _2 => _2(markup), 'optionalAccess', _3 => _3[1]]), () => ( ""));
241
+ const head = _nullishCoalesce(_optionalChain([/<head\b[^>]*>([\s\S]*?)<\/head>/i, 'access', _2 => _2.exec, 'call', _3 => _3(markup), 'optionalAccess', _4 => _4[1]]), () => ( ""));
192
242
  const hasNamedMeta = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (name) => new RegExp(`<meta\\b[^>]*\\bname=["']?${name}(?=["'\\s/>])`, "i").test(head), "hasNamedMeta");
193
243
  const tags = [
194
244
  /<meta\b[^>]*\bcharset\s*=/i.test(head) ? "" : '<meta charset="utf-8">',
195
245
  ...(_nullishCoalesce(viewport.match(/<meta\b[^>]*>/gi), () => ( []))).filter((tag) => {
196
- const name = _optionalChain([/\bname="([\w-]+)"/, 'access', _4 => _4.exec, 'call', _5 => _5(tag), 'optionalAccess', _6 => _6[1]]);
246
+ const name = _optionalChain([/\bname="([\w-]+)"/, 'access', _5 => _5.exec, 'call', _6 => _6(tag), 'optionalAccess', _7 => _7[1]]);
197
247
  return !name || !hasNamedMeta(name);
198
248
  })
199
249
  ].filter(Boolean);
@@ -289,7 +339,7 @@ function farmPathGuardCoversPage(options, pathname) {
289
339
  return appMiddlewareMayHandlePath(
290
340
  options.middlewareRoutes.filter((route) => route.path !== "/"),
291
341
  pathname
292
- ) || pathSpecificConfigMiddlewareCovers(options.config.middleware, pathname) || _chunkRHGK2JENcjs.integrationMiddlewareMayHandlePath.call(void 0, options.config.integrations, pathname, CATCH_ALL_PROBE);
342
+ ) || pathSpecificConfigMiddlewareCovers(options.config.middleware, pathname) || _chunk3SAWHWDHcjs.integrationMiddlewareMayHandlePath.call(void 0, options.config.integrations, pathname, CATCH_ALL_PROBE);
293
343
  }
294
344
  _chunkS3JO3N4Hcjs.__name.call(void 0, farmPathGuardCoversPage, "farmPathGuardCoversPage");
295
345
  function farmPathGuardCoversEndpoint(options, path, apiServerBasePath) {
@@ -317,7 +367,7 @@ function resolveAlternateBase(options) {
317
367
  try {
318
368
  const url = new URL(candidate);
319
369
  if (url.protocol === "http:" || url.protocol === "https:") return url;
320
- } catch (e) {
370
+ } catch (e2) {
321
371
  }
322
372
  }
323
373
  return void 0;
@@ -344,7 +394,7 @@ function isLateRedirectTarget(url) {
344
394
  try {
345
395
  const protocol = new URL(url, "https://farm.invalid").protocol;
346
396
  return protocol === "http:" || protocol === "https:";
347
- } catch (e2) {
397
+ } catch (e3) {
348
398
  return false;
349
399
  }
350
400
  }
@@ -401,7 +451,7 @@ function serializeSitemap(value) {
401
451
  return candidate;
402
452
  });
403
453
  const hasLanguageAlternates = entries.some(
404
- (entry) => _optionalChain([entry, 'access', _7 => _7.alternates, 'optionalAccess', _8 => _8.languages]) && Object.keys(entry.alternates.languages).length > 0
454
+ (entry) => _optionalChain([entry, 'access', _8 => _8.alternates, 'optionalAccess', _9 => _9.languages]) && Object.keys(entry.alternates.languages).length > 0
405
455
  );
406
456
  const namespace = hasLanguageAlternates ? ' xmlns:xhtml="http://www.w3.org/1999/xhtml"' : "";
407
457
  const lines = [
@@ -420,7 +470,7 @@ function serializeSitemap(value) {
420
470
  if (entry.priority !== void 0) {
421
471
  lines.push(` <priority>${escapeXml(entry.priority)}</priority>`);
422
472
  }
423
- for (const [language, href] of Object.entries(_optionalChain([entry, 'access', _9 => _9.alternates, 'optionalAccess', _10 => _10.languages]) || {})) {
473
+ for (const [language, href] of Object.entries(_optionalChain([entry, 'access', _10 => _10.alternates, 'optionalAccess', _11 => _11.languages]) || {})) {
424
474
  lines.push(
425
475
  ` <xhtml:link rel="alternate" hreflang="${escapeXml(language)}" href="${escapeXml(href)}" />`
426
476
  );
@@ -516,7 +566,7 @@ function listFarmMCPServerSources(input) {
516
566
  if (sources.has(endpoint)) continue;
517
567
  sources.set(endpoint, {
518
568
  ...server,
519
- protocolVersions: _optionalChain([details, 'optionalAccess', _11 => _11.protocolVersions]),
569
+ protocolVersions: _optionalChain([details, 'optionalAccess', _12 => _12.protocolVersions]),
520
570
  endpoint,
521
571
  local: true
522
572
  });
@@ -546,7 +596,7 @@ function listFarmMCPServerCards(origin, input = {}) {
546
596
  const endpointUrl = server.local ? `${origin}${server.endpoint}` : server.endpoint;
547
597
  const cardPath = server.local ? serverCardLocation(server.endpoint) : void 0;
548
598
  const slug = cardSlug(server.name);
549
- const description = truncate(_optionalChain([server, 'access', _12 => _12.description, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]) || `MCP server for ${host}`);
599
+ const description = truncate(_optionalChain([server, 'access', _13 => _13.description, 'optionalAccess', _14 => _14.trim, 'call', _15 => _15()]) || `MCP server for ${host}`);
550
600
  const card = {
551
601
  $schema: SERVER_CARD_SCHEMA,
552
602
  // The card's name is reverse-DNS; a plain server name is namespaced by the host.
@@ -559,7 +609,7 @@ function listFarmMCPServerCards(origin, input = {}) {
559
609
  {
560
610
  type: "streamable-http",
561
611
  url: endpointUrl,
562
- ..._optionalChain([server, 'access', _15 => _15.protocolVersions, 'optionalAccess', _16 => _16.length]) ? { supportedProtocolVersions: [...server.protocolVersions] } : {}
612
+ ..._optionalChain([server, 'access', _16 => _16.protocolVersions, 'optionalAccess', _17 => _17.length]) ? { supportedProtocolVersions: [...server.protocolVersions] } : {}
563
613
  }
564
614
  ]
565
615
  };
@@ -599,7 +649,7 @@ function createFarmAiCatalogResponse(request, input = {}, requestUrl) {
599
649
  let url;
600
650
  try {
601
651
  url = _nullishCoalesce(requestUrl, () => ( new URL(request.url)));
602
- } catch (e3) {
652
+ } catch (e4) {
603
653
  return null;
604
654
  }
605
655
  const { pathname } = url;
@@ -903,8 +953,8 @@ function resolveFarmApiCatalogInput(config) {
903
953
  const mcp = config.mcp && config.mcp.enabled !== false ? config.mcp : void 0;
904
954
  return {
905
955
  basePath: config.basePath,
906
- apiBaseURL: _nullishCoalesce(_optionalChain([config, 'access', _17 => _17.openapi, 'optionalAccess', _18 => _18.servers, 'optionalAccess', _19 => _19[0], 'optionalAccess', _20 => _20.url]), () => ( config.api.baseURL)),
907
- openapi: _optionalChain([config, 'access', _21 => _21.openapi, 'optionalAccess', _22 => _22.enabled]) ? { specRoute: config.openapi.specRoute, route: config.openapi.route } : void 0,
956
+ apiBaseURL: _nullishCoalesce(_optionalChain([config, 'access', _18 => _18.openapi, 'optionalAccess', _19 => _19.servers, 'optionalAccess', _20 => _20[0], 'optionalAccess', _21 => _21.url]), () => ( config.api.baseURL)),
957
+ openapi: _optionalChain([config, 'access', _22 => _22.openapi, 'optionalAccess', _23 => _23.enabled]) ? { specRoute: config.openapi.specRoute, route: config.openapi.route } : void 0,
908
958
  mcpPath: mcp ? _chunkKNBBQHO2cjs.resolveFarmAPIServerRoutePath.call(void 0,
909
959
  _nullishCoalesce(mcp.path, () => ( "/api/mcp")),
910
960
  _chunkKNBBQHO2cjs.resolveFarmAPIServerBasePath.call(void 0, config.api)
@@ -916,8 +966,8 @@ function createFarmApiCatalog(input) {
916
966
  const appPath = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (path) => _chunkI57LW5VZcjs.applyFarmBasePath.call(void 0, path, input.basePath), "appPath");
917
967
  const items = [];
918
968
  const contexts = [];
919
- const specRoute = _optionalChain([input, 'access', _23 => _23.openapi, 'optionalAccess', _24 => _24.specRoute]);
920
- const reference = _optionalChain([input, 'access', _25 => _25.openapi, 'optionalAccess', _26 => _26.route]);
969
+ const specRoute = _optionalChain([input, 'access', _24 => _24.openapi, 'optionalAccess', _25 => _25.specRoute]);
970
+ const reference = _optionalChain([input, 'access', _26 => _26.openapi, 'optionalAccess', _27 => _27.route]);
921
971
  if (specRoute || reference) {
922
972
  const api = { anchor: input.apiBaseURL };
923
973
  if (specRoute) {
@@ -965,24 +1015,24 @@ function isFarmAppManifestPath(pathname) {
965
1015
  }
966
1016
  _chunkS3JO3N4Hcjs.__name.call(void 0, isFarmAppManifestPath, "isFarmAppManifestPath");
967
1017
  function resolveFarmAppManifestInput(config, extra) {
968
- const llms = _optionalChain([config, 'access', _27 => _27.agent, 'optionalAccess', _28 => _28.llmsTxt]);
1018
+ const llms = _optionalChain([config, 'access', _28 => _28.agent, 'optionalAccess', _29 => _29.llmsTxt]);
969
1019
  const plugins = (_nullishCoalesce(config.plugins, () => ( []))).map(({ name }) => name);
970
1020
  const webmcp = plugins.includes("farm:webmcp");
971
- const sections = _chunkJAXDRRRCcjs.resolveFarmAppManifestConfig.call(void 0, _optionalChain([config, 'access', _29 => _29.agent, 'optionalAccess', _30 => _30.manifest]));
1021
+ const sections = _chunkJAXDRRRCcjs.resolveFarmAppManifestConfig.call(void 0, _optionalChain([config, 'access', _30 => _30.agent, 'optionalAccess', _31 => _31.manifest]));
972
1022
  return {
973
- renderer: _nullishCoalesce(_optionalChain([config, 'access', _31 => _31.renderer, 'optionalAccess', _32 => _32.name]), () => ( "react")),
1023
+ renderer: _nullishCoalesce(_optionalChain([config, 'access', _32 => _32.renderer, 'optionalAccess', _33 => _33.name]), () => ( "react")),
974
1024
  basePath: config.basePath || "/",
975
1025
  build: extra.build,
976
1026
  packages: extra.packages,
977
1027
  webmcp: { enabled: webmcp, tools: webmcp ? _nullishCoalesce(extra.webmcpTools, () => ( [])) : [] },
978
1028
  integrations: Object.entries(_nullishCoalesce(config.integrations, () => ( {}))).flatMap(([key, integration]) => {
979
- const category = _nullishCoalesce(_optionalChain([integration, 'optionalAccess', _33 => _33.category]), () => ( _optionalChain([integration, 'optionalAccess', _34 => _34.slot])));
1029
+ const category = _nullishCoalesce(_optionalChain([integration, 'optionalAccess', _34 => _34.category]), () => ( _optionalChain([integration, 'optionalAccess', _35 => _35.slot])));
980
1030
  return integration && category && integration.type ? [{ key, category, type: integration.type }] : [];
981
1031
  }),
982
1032
  agent: {
983
- apiCatalog: _optionalChain([config, 'access', _35 => _35.agent, 'optionalAccess', _36 => _36.apiCatalog]) ? "/.well-known/api-catalog" : null,
1033
+ apiCatalog: _optionalChain([config, 'access', _36 => _36.agent, 'optionalAccess', _37 => _37.apiCatalog]) ? "/.well-known/api-catalog" : null,
984
1034
  llmsTxt: llms === true || typeof llms === "object" && llms !== null && llms.enabled !== false,
985
- openapi: _optionalChain([config, 'access', _37 => _37.openapi, 'optionalAccess', _38 => _38.enabled]) && config.openapi.specRoute ? config.openapi.specRoute : null
1035
+ openapi: _optionalChain([config, 'access', _38 => _38.openapi, 'optionalAccess', _39 => _39.enabled]) && config.openapi.specRoute ? config.openapi.specRoute : null
986
1036
  },
987
1037
  plugins,
988
1038
  ...sections ? { sections } : {}
@@ -1001,7 +1051,7 @@ function createFarmAppManifest(input) {
1001
1051
  return {
1002
1052
  schemaVersion: 1,
1003
1053
  app: app ? {
1004
- ...app.version ? { farm: _chunkAHFRQMRXcjs.FARM_VERSION } : {},
1054
+ ...app.version ? { farm: _chunk3YJMBQ27cjs.FARM_VERSION } : {},
1005
1055
  ...app.renderer ? { renderer: input.renderer } : {},
1006
1056
  basePath: input.basePath,
1007
1057
  ...app.build ? { build: input.build } : {}
@@ -1020,16 +1070,16 @@ function createFarmAppManifest(input) {
1020
1070
  _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmAppManifest, "createFarmAppManifest");
1021
1071
  function listServers(input, mcp) {
1022
1072
  const servers = _chunk75RZHGLScjs._listFarmMCPCatalogs.call(void 0, ).map(({ server, tools, details }) => {
1023
- const open = _optionalChain([details, 'optionalAccess', _39 => _39.public]) === true && !_optionalChain([input, 'access', _40 => _40.guardCoversPath, 'optionalCall', _41 => _41(server.path)]);
1073
+ const open = _optionalChain([details, 'optionalAccess', _40 => _40.public]) === true && !_optionalChain([input, 'access', _41 => _41.guardCoversPath, 'optionalCall', _42 => _42(server.path)]);
1024
1074
  return {
1025
1075
  name: server.name,
1026
1076
  version: server.version,
1027
1077
  path: server.path,
1028
1078
  authorization: open ? "none" : "required",
1029
- resources: open ? [..._nullishCoalesce(_optionalChain([details, 'optionalAccess', _42 => _42.resources]), () => ( []))] : [],
1030
- prompts: open ? [..._nullishCoalesce(_optionalChain([details, 'optionalAccess', _43 => _43.prompts]), () => ( []))] : [],
1079
+ resources: open ? [..._nullishCoalesce(_optionalChain([details, 'optionalAccess', _43 => _43.resources]), () => ( []))] : [],
1080
+ prompts: open ? [..._nullishCoalesce(_optionalChain([details, 'optionalAccess', _44 => _44.prompts]), () => ( []))] : [],
1031
1081
  tools: (open ? tools : []).map((tool) => {
1032
- const schemas = _optionalChain([details, 'optionalAccess', _44 => _44.schemas, 'optionalAccess', _45 => _45[tool.name]]);
1082
+ const schemas = _optionalChain([details, 'optionalAccess', _45 => _45.schemas, 'optionalAccess', _46 => _46[tool.name]]);
1033
1083
  const hints = Object.fromEntries(
1034
1084
  ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"].filter((hint) => typeof tool[hint] === "boolean").map((hint) => [hint, tool[hint]])
1035
1085
  );
@@ -1040,7 +1090,7 @@ function listServers(input, mcp) {
1040
1090
  source: SOURCES[tool.kind],
1041
1091
  ...hints,
1042
1092
  ...schemas ? { inputSchema: schemas.input } : {},
1043
- ..._optionalChain([schemas, 'optionalAccess', _46 => _46.output]) ? { outputSchema: schemas.output } : {}
1093
+ ..._optionalChain([schemas, 'optionalAccess', _47 => _47.output]) ? { outputSchema: schemas.output } : {}
1044
1094
  };
1045
1095
  })
1046
1096
  };
@@ -1060,7 +1110,7 @@ function withoutSchemas({
1060
1110
  }
1061
1111
  _chunkS3JO3N4Hcjs.__name.call(void 0, withoutSchemas, "withoutSchemas");
1062
1112
  function listDefaultServer(input) {
1063
- const server = _optionalChain([input, 'access', _47 => _47.defaultMCP, 'optionalCall', _48 => _48()]);
1113
+ const server = _optionalChain([input, 'access', _48 => _48.defaultMCP, 'optionalCall', _49 => _49()]);
1064
1114
  if (!server) return [];
1065
1115
  return [
1066
1116
  {
@@ -1153,4 +1203,8 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmAppManifestResponse, "createFarm
1153
1203
 
1154
1204
 
1155
1205
 
1156
- exports.formatRouteSegment = formatRouteSegment; exports.createRouteDirectoryPattern = createRouteDirectoryPattern; exports.stripRouteGroups = stripRouteGroups; exports.getRouteGroupScope = getRouteGroupScope; exports.isInRouteGroupScope = isInRouteGroupScope; exports.getRouteDirectoryDepth = getRouteDirectoryDepth; exports.routeBoundaryCoversDirectory = routeBoundaryCoversDirectory; exports.HOISTED_HEAD_ELEMENT = HOISTED_HEAD_ELEMENT; exports.extractFarmFullDocument = extractFarmFullDocument; exports.classifyFarmDocumentPrefix = classifyFarmDocumentPrefix; exports.removeFarmDocumentTitles = removeFarmDocumentTitles; exports.ensureFarmDocumentMeta = ensureFarmDocumentMeta; exports.composeFarmFullDocument = composeFarmFullDocument; exports.hasFarmMiddlewareConfig = hasFarmMiddlewareConfig; exports.configMiddlewareMayHandlePath = configMiddlewareMayHandlePath; exports.appMiddlewareMayHandlePath = appMiddlewareMayHandlePath; exports.farmPathGuardCoversPage = farmPathGuardCoversPage; exports.farmPathGuardCoversEndpoint = farmPathGuardCoversEndpoint; exports.renderFarmLocaleAlternateLinks = renderFarmLocaleAlternateLinks; exports.createLateRedirectRecovery = createLateRedirectRecovery; exports.createLateNotFoundRecovery = createLateNotFoundRecovery; exports.createFarmMetadataRouteResponse = createFarmMetadataRouteResponse; exports.listFarmMCPLlmsTxtLinks = listFarmMCPLlmsTxtLinks; exports.createFarmAiCatalogResponse = createFarmAiCatalogResponse; exports.resolveDefaultErrorStatus = resolveDefaultErrorStatus; exports.getDefaultErrorStatusText = getDefaultErrorStatusText; exports.createDefaultErrorMarkup = createDefaultErrorMarkup; exports.createFarmThemeDocumentParts = createFarmThemeDocumentParts; exports.applyFarmThemeDocument = applyFarmThemeDocument; exports.FARM_API_CATALOG_PATH = FARM_API_CATALOG_PATH; exports.resolveFarmApiCatalogInput = resolveFarmApiCatalogInput; exports.createFarmApiCatalogResponse = createFarmApiCatalogResponse; exports.FARM_APP_MANIFEST_PATH = FARM_APP_MANIFEST_PATH; exports.FARM_APP_MANIFEST_LEGACY_PATH = FARM_APP_MANIFEST_LEGACY_PATH; exports.isFarmAppManifestPath = isFarmAppManifestPath; exports.resolveFarmAppManifestInput = resolveFarmAppManifestInput; exports.createFarmAppManifestResponse = createFarmAppManifestResponse;
1206
+
1207
+
1208
+
1209
+
1210
+ exports.createFarmRouteRenderPlan = createFarmRouteRenderPlan; exports.getFarmFragmentCacheControl = getFarmFragmentCacheControl; exports.parseFarmLayoutChainHeader = parseFarmLayoutChainHeader; exports.getSharedLayoutPrefixLength = getSharedLayoutPrefixLength; exports.formatRouteSegment = formatRouteSegment; exports.createRouteDirectoryPattern = createRouteDirectoryPattern; exports.stripRouteGroups = stripRouteGroups; exports.getRouteGroupScope = getRouteGroupScope; exports.isInRouteGroupScope = isInRouteGroupScope; exports.getRouteDirectoryDepth = getRouteDirectoryDepth; exports.routeBoundaryCoversDirectory = routeBoundaryCoversDirectory; exports.HOISTED_HEAD_ELEMENT = HOISTED_HEAD_ELEMENT; exports.extractFarmFullDocument = extractFarmFullDocument; exports.classifyFarmDocumentPrefix = classifyFarmDocumentPrefix; exports.removeFarmDocumentTitles = removeFarmDocumentTitles; exports.ensureFarmDocumentMeta = ensureFarmDocumentMeta; exports.composeFarmFullDocument = composeFarmFullDocument; exports.hasFarmMiddlewareConfig = hasFarmMiddlewareConfig; exports.configMiddlewareMayHandlePath = configMiddlewareMayHandlePath; exports.appMiddlewareMayHandlePath = appMiddlewareMayHandlePath; exports.farmPathGuardCoversPage = farmPathGuardCoversPage; exports.farmPathGuardCoversEndpoint = farmPathGuardCoversEndpoint; exports.renderFarmLocaleAlternateLinks = renderFarmLocaleAlternateLinks; exports.createLateRedirectRecovery = createLateRedirectRecovery; exports.createLateNotFoundRecovery = createLateNotFoundRecovery; exports.createFarmMetadataRouteResponse = createFarmMetadataRouteResponse; exports.listFarmMCPLlmsTxtLinks = listFarmMCPLlmsTxtLinks; exports.createFarmAiCatalogResponse = createFarmAiCatalogResponse; exports.resolveDefaultErrorStatus = resolveDefaultErrorStatus; exports.getDefaultErrorStatusText = getDefaultErrorStatusText; exports.createDefaultErrorMarkup = createDefaultErrorMarkup; exports.createFarmThemeDocumentParts = createFarmThemeDocumentParts; exports.applyFarmThemeDocument = applyFarmThemeDocument; exports.FARM_API_CATALOG_PATH = FARM_API_CATALOG_PATH; exports.resolveFarmApiCatalogInput = resolveFarmApiCatalogInput; exports.createFarmApiCatalogResponse = createFarmApiCatalogResponse; exports.FARM_APP_MANIFEST_PATH = FARM_APP_MANIFEST_PATH; exports.FARM_APP_MANIFEST_LEGACY_PATH = FARM_APP_MANIFEST_LEGACY_PATH; exports.isFarmAppManifestPath = isFarmAppManifestPath; exports.resolveFarmAppManifestInput = resolveFarmAppManifestInput; exports.createFarmAppManifestResponse = createFarmAppManifestResponse;
@@ -0,0 +1,39 @@
1
+ import {
2
+ runWithServerActionRequest
3
+ } from "./chunk-WMHG64DA.mjs";
4
+ import {
5
+ getFarmRedirectError,
6
+ isFarmNotFoundError
7
+ } from "./chunk-CBBLJMR5.mjs";
8
+ import {
9
+ __name
10
+ } from "./chunk-LPEX4YW6.mjs";
11
+
12
+ // src/form-actions.ts
13
+ import { handleAction, registerServerReference } from "@farm.js/islx/server";
14
+ var FARM_FORM_ACTION_HEADER = "F-Action";
15
+ function registerFarmFormAction(action, id) {
16
+ return registerServerReference(action, id);
17
+ }
18
+ __name(registerFarmFormAction, "registerFarmFormAction");
19
+ function handleFarmFormActionRequest(request, config) {
20
+ return handleAction(request, {
21
+ allowedOrigins: config.allowedOrigins,
22
+ bodySizeLimit: config.bodySizeLimit,
23
+ run: /* @__PURE__ */ __name((actionRequest, action) => runWithServerActionRequest(actionRequest, action), "run"),
24
+ mapError(error) {
25
+ const redirect = getFarmRedirectError(error);
26
+ if (redirect) return { redirect: redirect.url };
27
+ if (isFarmNotFoundError(error)) return { status: 404 };
28
+ return void 0;
29
+ },
30
+ onError: /* @__PURE__ */ __name((error) => console.error("[Farm.js] Server action failed:", error), "onError")
31
+ });
32
+ }
33
+ __name(handleFarmFormActionRequest, "handleFarmFormActionRequest");
34
+
35
+ export {
36
+ FARM_FORM_ACTION_HEADER,
37
+ registerFarmFormAction,
38
+ handleFarmFormActionRequest
39
+ };
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  getRouteGroupScope,
9
9
  isInRouteGroupScope
10
- } from "./chunk-PIZXONIS.mjs";
10
+ } from "./chunk-YFLBG2W3.mjs";
11
11
  import {
12
12
  __name
13
13
  } from "./chunk-LPEX4YW6.mjs";
@@ -21,7 +21,7 @@ import {
21
21
  } from "./chunk-AELACLOB.mjs";
22
22
  import {
23
23
  integrationMiddlewareMayHandlePath
24
- } from "./chunk-AX7S67YV.mjs";
24
+ } from "./chunk-GZWHCWLB.mjs";
25
25
  import {
26
26
  compileMiddlewareConfig,
27
27
  matchesCompiledMiddlewareConfig,
@@ -45,7 +45,7 @@ import {
45
45
  } from "./chunk-ZZGQD7A4.mjs";
46
46
  import {
47
47
  FARM_VERSION
48
- } from "./chunk-U2UC7UGP.mjs";
48
+ } from "./chunk-R4J2UOV4.mjs";
49
49
  import {
50
50
  localizeFarmPathname
51
51
  } from "./chunk-L3KT7IXV.mjs";
@@ -56,6 +56,56 @@ import {
56
56
  __name
57
57
  } from "./chunk-LPEX4YW6.mjs";
58
58
 
59
+ // src/navigation/render-plan.ts
60
+ function createFarmRouteRenderPlan(input = {}) {
61
+ const pageShouldHydrate = input.pageShouldHydrate === true;
62
+ const layoutShouldHydrate = input.layoutShouldHydrate === true;
63
+ const hydration = pageShouldHydrate ? layoutShouldHydrate ? "route-and-layout-islands" : "route-island" : layoutShouldHydrate ? "layout-island" : "none";
64
+ const rendering = input.rendering;
65
+ const cache = rendering?.ssg ? typeof rendering.revalidate === "number" && rendering.revalidate > 0 ? { mode: "revalidate", revalidate: rendering.revalidate } : { mode: "static" } : { mode: "dynamic" };
66
+ return {
67
+ version: 1,
68
+ output: "html",
69
+ navigation: "html-fragment",
70
+ hydration,
71
+ islandStrategy: hydration === "none" ? null : input.islandStrategy ?? "load",
72
+ cache
73
+ };
74
+ }
75
+ __name(createFarmRouteRenderPlan, "createFarmRouteRenderPlan");
76
+ function getFarmFragmentCacheControl(plan) {
77
+ if (plan.cache.mode === "static") {
78
+ return "public, max-age=0, s-maxage=31536000, immutable";
79
+ }
80
+ if (plan.cache.mode === "revalidate") {
81
+ const seconds = Math.max(1, plan.cache.revalidate ?? 1);
82
+ return `public, max-age=0, s-maxage=${seconds}, stale-while-revalidate=${seconds}`;
83
+ }
84
+ return "private, max-age=0";
85
+ }
86
+ __name(getFarmFragmentCacheControl, "getFarmFragmentCacheControl");
87
+ function parseFarmLayoutChainHeader(value) {
88
+ if (!value || value.length > 8192) return [];
89
+ try {
90
+ const parsed = JSON.parse(value);
91
+ if (!Array.isArray(parsed) || parsed.length > 64) return [];
92
+ return parsed.filter(
93
+ (pattern) => typeof pattern === "string" && pattern.startsWith("/") && pattern.length <= 512
94
+ );
95
+ } catch {
96
+ return [];
97
+ }
98
+ }
99
+ __name(parseFarmLayoutChainHeader, "parseFarmLayoutChainHeader");
100
+ function getSharedLayoutPrefixLength(current, next) {
101
+ let index = 0;
102
+ while (index < current.length && index < next.length && current[index] === next[index]) {
103
+ index++;
104
+ }
105
+ return index;
106
+ }
107
+ __name(getSharedLayoutPrefixLength, "getSharedLayoutPrefixLength");
108
+
59
109
  // src/routing/route-groups.ts
60
110
  function isRouteGroupSegment(part) {
61
111
  return part.startsWith("(") && part.endsWith(")");
@@ -1116,6 +1166,10 @@ async function createFarmAppManifestResponse(request, input) {
1116
1166
  __name(createFarmAppManifestResponse, "createFarmAppManifestResponse");
1117
1167
 
1118
1168
  export {
1169
+ createFarmRouteRenderPlan,
1170
+ getFarmFragmentCacheControl,
1171
+ parseFarmLayoutChainHeader,
1172
+ getSharedLayoutPrefixLength,
1119
1173
  formatRouteSegment,
1120
1174
  createRouteDirectoryPattern,
1121
1175
  stripRouteGroups,
@@ -0,0 +1,229 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+ var _chunkH7BLEEAEcjs = require('./chunk-H7BLEEAE.cjs');
10
+
11
+
12
+ var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
13
+
14
+ // src/client/island-codec.ts
15
+ var TYPED_ARRAYS = {
16
+ Int8Array,
17
+ Uint8Array,
18
+ Uint8ClampedArray,
19
+ Int16Array,
20
+ Uint16Array,
21
+ Int32Array,
22
+ Uint32Array,
23
+ Float32Array,
24
+ Float64Array,
25
+ BigInt64Array,
26
+ BigUint64Array
27
+ };
28
+ function toBase64(bytes) {
29
+ let binary = "";
30
+ for (let index = 0; index < bytes.length; index += 32768) {
31
+ binary += String.fromCharCode(...bytes.subarray(index, index + 32768));
32
+ }
33
+ return btoa(binary);
34
+ }
35
+ _chunkS3JO3N4Hcjs.__name.call(void 0, toBase64, "toBase64");
36
+ function fromBase64(base64) {
37
+ const binary = atob(base64);
38
+ const bytes = new Uint8Array(binary.length);
39
+ for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index);
40
+ return bytes;
41
+ }
42
+ _chunkS3JO3N4Hcjs.__name.call(void 0, fromBase64, "fromBase64");
43
+ function farmTagged(tag, value) {
44
+ return value === void 0 ? { [_chunkH7BLEEAEcjs.FARM_TAG]: tag } : { [_chunkH7BLEEAEcjs.FARM_TAG]: tag, [_chunkH7BLEEAEcjs.FARM_TAG_VALUE]: value };
45
+ }
46
+ _chunkS3JO3N4Hcjs.__name.call(void 0, farmTagged, "farmTagged");
47
+ function needsFarmObjectTag(object) {
48
+ return Object.prototype.hasOwnProperty.call(object, _chunkH7BLEEAEcjs.FARM_TAG);
49
+ }
50
+ _chunkS3JO3N4Hcjs.__name.call(void 0, needsFarmObjectTag, "needsFarmObjectTag");
51
+ function encodeFarmLeaf(value) {
52
+ switch (typeof value) {
53
+ case "undefined":
54
+ return farmTagged("u");
55
+ case "bigint":
56
+ return farmTagged("B", value.toString());
57
+ case "number":
58
+ if (Number.isNaN(value)) return farmTagged("n", "NaN");
59
+ if (value === Infinity) return farmTagged("n", "Infinity");
60
+ if (value === -Infinity) return farmTagged("n", "-Infinity");
61
+ if (Object.is(value, -0)) return farmTagged("n", "-0");
62
+ return void 0;
63
+ case "object":
64
+ break;
65
+ default:
66
+ return void 0;
67
+ }
68
+ if (value === null) return void 0;
69
+ if (value instanceof Date) {
70
+ return farmTagged("D", Number.isNaN(value.getTime()) ? null : value.toISOString());
71
+ }
72
+ if (typeof URL === "function" && value instanceof URL) return farmTagged("U", value.href);
73
+ if (value instanceof RegExp) return farmTagged("R", [value.source, value.flags]);
74
+ if (value instanceof ArrayBuffer) {
75
+ return farmTagged("Y", ["ArrayBuffer", toBase64(new Uint8Array(value))]);
76
+ }
77
+ if (ArrayBuffer.isView(value)) {
78
+ const name = value instanceof DataView ? "DataView" : value.constructor.name;
79
+ if (name !== "DataView" && !(name in TYPED_ARRAYS)) return void 0;
80
+ const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
81
+ return farmTagged("Y", [name, toBase64(bytes)]);
82
+ }
83
+ return void 0;
84
+ }
85
+ _chunkS3JO3N4Hcjs.__name.call(void 0, encodeFarmLeaf, "encodeFarmLeaf");
86
+ var NOT_A_FARM_MARKER = /* @__PURE__ */ Symbol.for("farm.codec.not-a-marker");
87
+ function farmPlainObject(entries) {
88
+ const object = {};
89
+ for (const [key, value] of entries) {
90
+ Object.defineProperty(object, key, {
91
+ value,
92
+ enumerable: true,
93
+ writable: true,
94
+ configurable: true
95
+ });
96
+ }
97
+ return object;
98
+ }
99
+ _chunkS3JO3N4Hcjs.__name.call(void 0, farmPlainObject, "farmPlainObject");
100
+ function decodeFarmTagged(object, decodeChild) {
101
+ const tag = object[_chunkH7BLEEAEcjs.FARM_TAG];
102
+ const data = object[_chunkH7BLEEAEcjs.FARM_TAG_VALUE];
103
+ switch (tag) {
104
+ case _chunkH7BLEEAEcjs.FARM_REFERENCE_TAG:
105
+ case _chunkH7BLEEAEcjs.FARM_SLOT_TAG:
106
+ case _chunkH7BLEEAEcjs.FARM_ACTION_TAG:
107
+ return NOT_A_FARM_MARKER;
108
+ case _chunkH7BLEEAEcjs.FARM_OBJECT_TAG:
109
+ if (data && typeof data === "object" && !Array.isArray(data)) {
110
+ return farmPlainObject(
111
+ Object.entries(data).map(([key, value]) => [key, decodeChild(value)])
112
+ );
113
+ }
114
+ break;
115
+ case "u":
116
+ return void 0;
117
+ case "n":
118
+ if (data === "NaN") return Number.NaN;
119
+ if (data === "Infinity") return Infinity;
120
+ if (data === "-Infinity") return -Infinity;
121
+ if (data === "-0") return -0;
122
+ break;
123
+ case "B":
124
+ if (typeof data === "string" && /^-?\d+$/.test(data)) return BigInt(data);
125
+ break;
126
+ case "D":
127
+ if (data === null) return new Date(Number.NaN);
128
+ if (typeof data === "string") return new Date(data);
129
+ break;
130
+ case "U":
131
+ if (typeof data === "string") return new URL(data);
132
+ break;
133
+ case "R":
134
+ if (Array.isArray(data) && typeof data[0] === "string" && typeof data[1] === "string") {
135
+ return new RegExp(data[0], data[1]);
136
+ }
137
+ break;
138
+ case "Y": {
139
+ if (!Array.isArray(data) || typeof data[0] !== "string" || typeof data[1] !== "string") break;
140
+ const bytes = fromBase64(data[1]);
141
+ if (data[0] === "ArrayBuffer") return bytes.buffer;
142
+ if (data[0] === "DataView") return new DataView(bytes.buffer);
143
+ const TypedArray = Object.prototype.hasOwnProperty.call(TYPED_ARRAYS, data[0]) ? TYPED_ARRAYS[data[0]] : void 0;
144
+ if (!TypedArray || bytes.byteLength % TypedArray.BYTES_PER_ELEMENT !== 0) break;
145
+ return new TypedArray(
146
+ bytes.buffer,
147
+ 0,
148
+ bytes.byteLength / TypedArray.BYTES_PER_ELEMENT
149
+ );
150
+ }
151
+ case "M":
152
+ if (Array.isArray(data) && data.every((entry) => Array.isArray(entry) && entry.length === 2)) {
153
+ return new Map(data.map(([key, value]) => [decodeChild(key), decodeChild(value)]));
154
+ }
155
+ break;
156
+ case "S":
157
+ if (Array.isArray(data)) return new Set(data.map(decodeChild));
158
+ break;
159
+ default:
160
+ throw new TypeError(`unknown ${JSON.stringify(tag)} tag`);
161
+ }
162
+ throw new TypeError(`malformed ${JSON.stringify(tag)} tag`);
163
+ }
164
+ _chunkS3JO3N4Hcjs.__name.call(void 0, decodeFarmTagged, "decodeFarmTagged");
165
+ function encodeFarmJson(value, seen = /* @__PURE__ */ new Set()) {
166
+ const leaf = encodeFarmLeaf(value);
167
+ if (leaf) return leaf;
168
+ if (value === null || typeof value === "string" || typeof value === "boolean") return value;
169
+ if (typeof value === "number") return value;
170
+ if (typeof value !== "object") throw new TypeError(`${typeof value} values are not serializable`);
171
+ if (seen.has(value)) throw new TypeError("circular values are not serializable");
172
+ seen.add(value);
173
+ try {
174
+ if (Array.isArray(value)) return value.map((entry) => encodeFarmJson(entry, seen));
175
+ if (value instanceof Map) {
176
+ return farmTagged(
177
+ "M",
178
+ Array.from(value, ([key, entry]) => [
179
+ encodeFarmJson(key, seen),
180
+ encodeFarmJson(entry, seen)
181
+ ])
182
+ );
183
+ }
184
+ if (value instanceof Set) {
185
+ return farmTagged(
186
+ "S",
187
+ Array.from(value, (entry) => encodeFarmJson(entry, seen))
188
+ );
189
+ }
190
+ const prototype = Object.getPrototypeOf(value);
191
+ if (prototype !== Object.prototype && prototype !== null) {
192
+ throw new TypeError("class instances are not serializable");
193
+ }
194
+ const encoded = Object.fromEntries(
195
+ Object.entries(value).map(([key, entry]) => [key, encodeFarmJson(entry, seen)])
196
+ );
197
+ return needsFarmObjectTag(value) ? farmTagged(_chunkH7BLEEAEcjs.FARM_OBJECT_TAG, encoded) : encoded;
198
+ } finally {
199
+ seen.delete(value);
200
+ }
201
+ }
202
+ _chunkS3JO3N4Hcjs.__name.call(void 0, encodeFarmJson, "encodeFarmJson");
203
+ function decodeFarmJson(value) {
204
+ if (Array.isArray(value)) return value.map(decodeFarmJson);
205
+ if (!value || typeof value !== "object") return value;
206
+ if (_chunkH7BLEEAEcjs.getFarmTag.call(void 0, value) !== void 0) {
207
+ const decoded = decodeFarmTagged(value, decodeFarmJson);
208
+ if (decoded === NOT_A_FARM_MARKER) {
209
+ throw new TypeError(
210
+ `a ${JSON.stringify(value[_chunkH7BLEEAEcjs.FARM_TAG])} reference is not allowed here`
211
+ );
212
+ }
213
+ return decoded;
214
+ }
215
+ if (needsFarmObjectTag(value)) throw new TypeError('malformed "$" tag');
216
+ return farmPlainObject(Object.entries(value).map(([key, entry]) => [key, decodeFarmJson(entry)]));
217
+ }
218
+ _chunkS3JO3N4Hcjs.__name.call(void 0, decodeFarmJson, "decodeFarmJson");
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+ exports.farmTagged = farmTagged; exports.needsFarmObjectTag = needsFarmObjectTag; exports.encodeFarmLeaf = encodeFarmLeaf; exports.NOT_A_FARM_MARKER = NOT_A_FARM_MARKER; exports.farmPlainObject = farmPlainObject; exports.decodeFarmTagged = decodeFarmTagged; exports.encodeFarmJson = encodeFarmJson; exports.decodeFarmJson = decodeFarmJson;