@farm.js/core 0.1.0-beta.96 → 0.1.0-beta.97

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 (311) hide show
  1. package/dist/after.cjs +1 -1
  2. package/dist/after.mjs +1 -1
  3. package/dist/agent-runtime.d.mts +3 -2
  4. package/dist/agent-runtime.d.ts +3 -2
  5. package/dist/api/route-manager.cjs +43 -4
  6. package/dist/api/route-manager.d.mts +4 -3
  7. package/dist/api/route-manager.d.ts +4 -3
  8. package/dist/api/route-manager.mjs +6 -6
  9. package/dist/api/runtime.cjs +43 -4
  10. package/dist/api/runtime.d.mts +1 -1
  11. package/dist/api/runtime.d.ts +1 -1
  12. package/dist/api/runtime.mjs +4 -4
  13. package/dist/api.cjs +239 -70
  14. package/dist/api.d.mts +7 -6
  15. package/dist/api.d.ts +7 -6
  16. package/dist/api.mjs +17 -11
  17. package/dist/{app-CIIEvA4r.d.ts → app-CIOx3LvY.d.ts} +4 -4
  18. package/dist/{app-O4AEC1OH.d.mts → app-DBd6437H.d.mts} +4 -4
  19. package/dist/app-markdown.d.mts +4 -3
  20. package/dist/app-markdown.d.ts +4 -3
  21. package/dist/cache.cjs +42 -4
  22. package/dist/cache.d.mts +68 -1
  23. package/dist/cache.d.ts +68 -1
  24. package/dist/cache.mjs +3 -3
  25. package/dist/{chunk-AXVJCMVF.mjs → chunk-2HDOV47R.mjs} +3 -3
  26. package/dist/chunk-2HDOV47R.mjs.map +1 -0
  27. package/dist/{chunk-RBRLLZL5.mjs → chunk-34IAPZBG.mjs} +16 -3
  28. package/dist/chunk-34IAPZBG.mjs.map +1 -0
  29. package/dist/{chunk-VV24CC42.mjs → chunk-35NPLKQJ.mjs} +2 -2
  30. package/dist/{chunk-MM46HTX6.mjs → chunk-3TWQERDE.mjs} +4 -3
  31. package/dist/chunk-3TWQERDE.mjs.map +1 -0
  32. package/dist/{chunk-RWYRFCLG.mjs → chunk-4X57GXQA.mjs} +2 -2
  33. package/dist/{chunk-3I55IGXU.mjs → chunk-52BR7LTX.mjs} +14 -15
  34. package/dist/chunk-52BR7LTX.mjs.map +1 -0
  35. package/dist/{chunk-RAGSHKDC.mjs → chunk-6EJHNHH4.mjs} +38 -3
  36. package/dist/chunk-6EJHNHH4.mjs.map +1 -0
  37. package/dist/{chunk-ZFNK77WN.mjs → chunk-6JNGOC37.mjs} +2 -2
  38. package/dist/{after.cjs.map → chunk-6JNGOC37.mjs.map} +1 -1
  39. package/dist/{chunk-MOW47IF5.mjs → chunk-6UYVU46O.mjs} +2 -2
  40. package/dist/{chunk-7MABZJIM.mjs → chunk-7PYVLJ4J.mjs} +1 -1
  41. package/dist/chunk-7PYVLJ4J.mjs.map +1 -0
  42. package/dist/{chunk-54XSGLKT.mjs → chunk-D7F7YZ7L.mjs} +93 -67
  43. package/dist/chunk-D7F7YZ7L.mjs.map +1 -0
  44. package/dist/{chunk-SCFX4UTD.mjs → chunk-EHTUKVSW.mjs} +1 -1
  45. package/dist/chunk-EHTUKVSW.mjs.map +1 -0
  46. package/dist/{chunk-LZTGDH3H.mjs → chunk-EPDIF432.mjs} +424 -10
  47. package/dist/chunk-EPDIF432.mjs.map +1 -0
  48. package/dist/{chunk-GZHKWHCH.mjs → chunk-FP5Q67FO.mjs} +167 -96
  49. package/dist/chunk-FP5Q67FO.mjs.map +1 -0
  50. package/dist/{chunk-HHZAOTQD.mjs → chunk-GJ7W6LNK.mjs} +7 -6
  51. package/dist/chunk-GJ7W6LNK.mjs.map +1 -0
  52. package/dist/{chunk-RLGUZ3HS.mjs → chunk-I3OOUWO5.mjs} +3 -3
  53. package/dist/{chunk-LKKMI7JG.mjs → chunk-IZBX2TEU.mjs} +153 -68
  54. package/dist/chunk-IZBX2TEU.mjs.map +1 -0
  55. package/dist/{chunk-74QPONAN.mjs → chunk-J3MPQ4MQ.mjs} +2 -2
  56. package/dist/{chunk-74QPONAN.mjs.map → chunk-J3MPQ4MQ.mjs.map} +1 -1
  57. package/dist/{chunk-ODJGAWDH.mjs → chunk-JV7JUD7Q.mjs} +4 -4
  58. package/dist/{chunk-Q3OX763A.mjs → chunk-LXDASSTE.mjs} +2 -2
  59. package/dist/{chunk-ZRBCBOEX.mjs → chunk-N2FY2QZ7.mjs} +28 -3
  60. package/dist/chunk-N2FY2QZ7.mjs.map +1 -0
  61. package/dist/{chunk-MRVJCLYQ.mjs → chunk-PSQ7N4XP.mjs} +4 -2
  62. package/dist/chunk-PSQ7N4XP.mjs.map +1 -0
  63. package/dist/{chunk-HVG3HLQZ.mjs → chunk-Q7WGOOAI.mjs} +3 -3
  64. package/dist/{chunk-WTYAPO5I.mjs → chunk-RCNWMEBT.mjs} +3 -2
  65. package/dist/{chunk-WTYAPO5I.mjs.map → chunk-RCNWMEBT.mjs.map} +1 -1
  66. package/dist/{chunk-3INDBMUU.mjs → chunk-TGDIACZT.mjs} +2 -2
  67. package/dist/{chunk-WB75GIX2.mjs → chunk-TQTB33JS.mjs} +14 -3
  68. package/dist/chunk-TQTB33JS.mjs.map +1 -0
  69. package/dist/{chunk-WMAYETRD.mjs → chunk-TT3E2JOF.mjs} +3 -3
  70. package/dist/{chunk-FVAM43KI.mjs → chunk-UMUWR5XA.mjs} +2 -2
  71. package/dist/{chunk-VOUJW4FL.mjs → chunk-WD2EBM3I.mjs} +70 -15
  72. package/dist/chunk-WD2EBM3I.mjs.map +1 -0
  73. package/dist/{chunk-ZPG6SNHH.mjs → chunk-WMJGA32P.mjs} +47 -5
  74. package/dist/chunk-WMJGA32P.mjs.map +1 -0
  75. package/dist/{chunk-TKQCJMY7.mjs → chunk-X4SFHKFH.mjs} +7 -4
  76. package/dist/{chunk-TKQCJMY7.mjs.map → chunk-X4SFHKFH.mjs.map} +1 -1
  77. package/dist/{chunk-Q7GPJZCO.mjs → chunk-YIBV77KZ.mjs} +26 -7
  78. package/dist/chunk-YIBV77KZ.mjs.map +1 -0
  79. package/dist/client/lifecycle.mjs +2 -2
  80. package/dist/{client-mcMC334J.d.mts → client-DWoLZ3QU.d.mts} +52 -5
  81. package/dist/{client-d5ONQ-Pd.d.ts → client-DuQuQC1h.d.ts} +52 -5
  82. package/dist/client-cache-BMxuFqwH.d.ts +18 -0
  83. package/dist/client-cache-CCK-fCe0.d.mts +18 -0
  84. package/dist/{client-plugins-BvClItiL.d.mts → client-plugins-B6-07YmP.d.mts} +52 -99
  85. package/dist/{client-plugins-B9Sq-iMg.d.ts → client-plugins-By6MVUX-.d.ts} +52 -99
  86. package/dist/client-plugins.cjs +1 -1
  87. package/dist/client-plugins.d.mts +3 -2
  88. package/dist/client-plugins.d.ts +3 -2
  89. package/dist/client-plugins.mjs +2 -2
  90. package/dist/client.cjs +757 -104
  91. package/dist/client.d.mts +124 -16
  92. package/dist/client.d.ts +124 -16
  93. package/dist/client.mjs +28 -14
  94. package/dist/config.d.mts +3 -2
  95. package/dist/config.d.ts +3 -2
  96. package/dist/{devtools-S52RRRMN.mjs → devtools-XWZX6CCL.mjs} +5 -5
  97. package/dist/{devtools-client-EOVDBPOI.mjs → devtools-client-Z7QQA3Q2.mjs} +2 -2
  98. package/dist/{devtools-ui-NJKFORTG.mjs → devtools-ui-2HG5M4EL.mjs} +3 -1
  99. package/dist/devtools-ui-2HG5M4EL.mjs.map +1 -0
  100. package/dist/docs.cjs +24 -5
  101. package/dist/docs.mjs +5 -5
  102. package/dist/i18n/server.cjs +13 -2
  103. package/dist/i18n/server.d.mts +2 -2
  104. package/dist/i18n/server.d.ts +2 -2
  105. package/dist/i18n/server.mjs +1 -1
  106. package/dist/index.cjs +1578 -772
  107. package/dist/index.d.mts +28 -20
  108. package/dist/index.d.ts +28 -20
  109. package/dist/index.mjs +53 -33
  110. package/dist/index.mjs.map +1 -1
  111. package/dist/integration-api-BT024nuJ.d.mts +97 -0
  112. package/dist/integration-api-BT024nuJ.d.ts +97 -0
  113. package/dist/integrations.d.mts +3 -2
  114. package/dist/integrations.d.ts +3 -2
  115. package/dist/internal/build-runtime.cjs +710 -532
  116. package/dist/internal/build-runtime.d.mts +5 -4
  117. package/dist/internal/build-runtime.d.ts +5 -4
  118. package/dist/internal/build-runtime.mjs +15 -15
  119. package/dist/internal/client-runtime.cjs +1 -1
  120. package/dist/internal/client-runtime.mjs +2 -2
  121. package/dist/internal/config-runtime.cjs +4 -1
  122. package/dist/internal/config-runtime.d.mts +4 -3
  123. package/dist/internal/config-runtime.d.ts +4 -3
  124. package/dist/internal/config-runtime.mjs +4 -4
  125. package/dist/internal/product-telemetry-runtime.cjs +1 -1
  126. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  127. package/dist/internal/production-runtime.cjs +29 -3
  128. package/dist/internal/production-runtime.d.mts +8 -7
  129. package/dist/internal/production-runtime.d.ts +8 -7
  130. package/dist/internal/production-runtime.mjs +5 -5
  131. package/dist/{metadata-route-yV4U6X8h.d.ts → metadata-route-8_V3UonT.d.ts} +1 -1
  132. package/dist/{metadata-route-p4K1l92V.d.mts → metadata-route-CWP_HjGU.d.mts} +1 -1
  133. package/dist/middleware.cjs +28 -2
  134. package/dist/middleware.d.mts +5 -4
  135. package/dist/middleware.d.ts +5 -4
  136. package/dist/middleware.mjs +4 -4
  137. package/dist/navigation.cjs +3 -1
  138. package/dist/navigation.mjs +3 -3
  139. package/dist/observability.cjs +27 -2
  140. package/dist/observability.mjs +1 -1
  141. package/dist/plugin.cjs +474 -334
  142. package/dist/plugin.d.mts +3 -2
  143. package/dist/plugin.d.ts +3 -2
  144. package/dist/plugin.mjs +12 -12
  145. package/dist/{production-runtime-IkB0Qj4i.d.mts → production-runtime-BGRH1dKG.d.mts} +1 -1
  146. package/dist/{production-runtime-0JTch4_d.d.ts → production-runtime-CdmzsDax.d.ts} +1 -1
  147. package/dist/query/client.cjs +11 -3
  148. package/dist/query/client.mjs +12 -4
  149. package/dist/query/client.mjs.map +1 -1
  150. package/dist/{render-plan-Dc8CjNI7.d.ts → render-plan-0GeHiGVZ.d.ts} +1 -1
  151. package/dist/{render-plan-CU31j-Jk.d.mts → render-plan-DLxJYAA5.d.mts} +1 -1
  152. package/dist/renderer-client.cjs +140 -26
  153. package/dist/renderer-client.d.mts +7 -6
  154. package/dist/renderer-client.d.ts +7 -6
  155. package/dist/renderer-client.mjs +16 -19
  156. package/dist/renderer-client.mjs.map +1 -1
  157. package/dist/{request-BXa1KY8i.d.mts → request-BCNXSXLh.d.mts} +1 -1
  158. package/dist/{request-CUUBujZt.d.ts → request-BstWbZ6O.d.ts} +1 -1
  159. package/dist/request.d.mts +4 -3
  160. package/dist/request.d.ts +4 -3
  161. package/dist/{route-Y8lfz1wF.d.ts → route-4pd-EVtw.d.ts} +45 -50
  162. package/dist/{route-Cq3aObmj.d.mts → route-CvEr4Uc9.d.mts} +45 -50
  163. package/dist/routes.cjs +27 -2
  164. package/dist/routes.d.mts +3 -2
  165. package/dist/routes.d.ts +3 -2
  166. package/dist/routes.mjs +4 -4
  167. package/dist/{runtime-j1S3sDTh.d.ts → runtime-BgDQzBiu.d.ts} +1 -0
  168. package/dist/{runtime-DDwvDtS4.d.mts → runtime-CV2UCV-5.d.mts} +1 -0
  169. package/dist/server-action-security.mjs +2 -2
  170. package/dist/server-fn-client.cjs +34 -2
  171. package/dist/server-fn-client.d.mts +6 -0
  172. package/dist/server-fn-client.d.ts +6 -0
  173. package/dist/server-fn-client.mjs +1 -1
  174. package/dist/server-fn.cjs +42 -4
  175. package/dist/server-fn.mjs +5 -5
  176. package/dist/server-plugins.d.mts +4 -3
  177. package/dist/server-plugins.d.ts +4 -3
  178. package/dist/server-query-client.cjs +146 -27
  179. package/dist/server-query-client.d.mts +3 -3
  180. package/dist/server-query-client.d.ts +3 -3
  181. package/dist/server-query-client.mjs +7 -7
  182. package/dist/{server-query-runtime-3zAj77yv.d.ts → server-query-runtime-DXRNhX_3.d.ts} +2 -0
  183. package/dist/{server-query-runtime-B50KAcj5.d.mts → server-query-runtime-aP52iuL5.d.mts} +2 -0
  184. package/dist/server-query.cjs +44 -5
  185. package/dist/server-query.d.mts +4 -0
  186. package/dist/server-query.d.ts +4 -0
  187. package/dist/server-query.mjs +7 -7
  188. package/dist/server.cjs +499 -355
  189. package/dist/server.d.mts +11 -10
  190. package/dist/server.d.ts +11 -10
  191. package/dist/server.mjs +16 -16
  192. package/dist/{spa-router-CyLkwst6.d.mts → spa-router-BeyAVSc6.d.mts} +1 -1
  193. package/dist/{spa-router-BkqGXaV_.d.ts → spa-router-COgu4txb.d.ts} +1 -1
  194. package/dist/testing.cjs +27 -2
  195. package/dist/testing.d.mts +3 -2
  196. package/dist/testing.d.ts +3 -2
  197. package/dist/testing.mjs +8 -8
  198. package/dist/{utils-NKR6SoNv.d.mts → utils-DL2VwDQl.d.mts} +1 -1
  199. package/dist/{utils-B2OHrb9F.d.ts → utils-DkU2c_1B.d.ts} +1 -1
  200. package/dist/version.cjs +1 -1
  201. package/dist/version.mjs +1 -1
  202. package/dist/vite.cjs +482 -338
  203. package/dist/vite.d.mts +3 -2
  204. package/dist/vite.d.ts +3 -2
  205. package/dist/vite.mjs +16 -12
  206. package/package.json +17 -17
  207. package/types/client.d.ts +87 -1
  208. package/dist/agent-runtime.cjs.map +0 -1
  209. package/dist/api/route-manager.cjs.map +0 -1
  210. package/dist/api/runtime.cjs.map +0 -1
  211. package/dist/api.cjs.map +0 -1
  212. package/dist/app-markdown.cjs.map +0 -1
  213. package/dist/cache.cjs.map +0 -1
  214. package/dist/chunk-3I55IGXU.mjs.map +0 -1
  215. package/dist/chunk-54XSGLKT.mjs.map +0 -1
  216. package/dist/chunk-7MABZJIM.mjs.map +0 -1
  217. package/dist/chunk-AXVJCMVF.mjs.map +0 -1
  218. package/dist/chunk-GZHKWHCH.mjs.map +0 -1
  219. package/dist/chunk-HHZAOTQD.mjs.map +0 -1
  220. package/dist/chunk-LKKMI7JG.mjs.map +0 -1
  221. package/dist/chunk-LZTGDH3H.mjs.map +0 -1
  222. package/dist/chunk-MM46HTX6.mjs.map +0 -1
  223. package/dist/chunk-MRVJCLYQ.mjs.map +0 -1
  224. package/dist/chunk-Q7GPJZCO.mjs.map +0 -1
  225. package/dist/chunk-RAGSHKDC.mjs.map +0 -1
  226. package/dist/chunk-RBRLLZL5.mjs.map +0 -1
  227. package/dist/chunk-SCFX4UTD.mjs.map +0 -1
  228. package/dist/chunk-VOUJW4FL.mjs.map +0 -1
  229. package/dist/chunk-WB75GIX2.mjs.map +0 -1
  230. package/dist/chunk-ZFNK77WN.mjs.map +0 -1
  231. package/dist/chunk-ZPG6SNHH.mjs.map +0 -1
  232. package/dist/chunk-ZRBCBOEX.mjs.map +0 -1
  233. package/dist/client/lifecycle.cjs.map +0 -1
  234. package/dist/client-cache-CopR_MaI.d.mts +0 -6
  235. package/dist/client-cache-Djy_TlE8.d.ts +0 -6
  236. package/dist/client-plugins.cjs.map +0 -1
  237. package/dist/client.cjs.map +0 -1
  238. package/dist/config.cjs.map +0 -1
  239. package/dist/cron.cjs.map +0 -1
  240. package/dist/deferred.cjs.map +0 -1
  241. package/dist/deployment.cjs.map +0 -1
  242. package/dist/devtools-ui-NJKFORTG.mjs.map +0 -1
  243. package/dist/docs.cjs.map +0 -1
  244. package/dist/env-types.cjs.map +0 -1
  245. package/dist/env.cjs.map +0 -1
  246. package/dist/environment/vite.cjs.map +0 -1
  247. package/dist/environment.cjs.map +0 -1
  248. package/dist/font.cjs.map +0 -1
  249. package/dist/headers.cjs.map +0 -1
  250. package/dist/i18n/client.cjs.map +0 -1
  251. package/dist/i18n/index.cjs.map +0 -1
  252. package/dist/i18n/server.cjs.map +0 -1
  253. package/dist/image/server.cjs.map +0 -1
  254. package/dist/image/sharp.cjs.map +0 -1
  255. package/dist/image.cjs.map +0 -1
  256. package/dist/index.cjs.map +0 -1
  257. package/dist/instrumentation.cjs.map +0 -1
  258. package/dist/integrations.cjs.map +0 -1
  259. package/dist/internal/build-runtime.cjs.map +0 -1
  260. package/dist/internal/client-runtime.cjs.map +0 -1
  261. package/dist/internal/config-runtime.cjs.map +0 -1
  262. package/dist/internal/isolated-boundary.cjs.map +0 -1
  263. package/dist/internal/metadata-image-runtime.cjs.map +0 -1
  264. package/dist/internal/product-telemetry-runtime.cjs.map +0 -1
  265. package/dist/internal/production-node-env.cjs.map +0 -1
  266. package/dist/internal/production-runtime.cjs.map +0 -1
  267. package/dist/markdown.cjs.map +0 -1
  268. package/dist/middleware.cjs.map +0 -1
  269. package/dist/navigation.cjs.map +0 -1
  270. package/dist/observability.cjs.map +0 -1
  271. package/dist/plugin.cjs.map +0 -1
  272. package/dist/query/client.cjs.map +0 -1
  273. package/dist/query/index.cjs.map +0 -1
  274. package/dist/query/parsers.cjs.map +0 -1
  275. package/dist/query/server.cjs.map +0 -1
  276. package/dist/renderer/react/client.cjs.map +0 -1
  277. package/dist/renderer/react/server.cjs.map +0 -1
  278. package/dist/renderer/react/vite.cjs.map +0 -1
  279. package/dist/renderer-client.cjs.map +0 -1
  280. package/dist/renderer.cjs.map +0 -1
  281. package/dist/request.cjs.map +0 -1
  282. package/dist/router.cjs.map +0 -1
  283. package/dist/routes.cjs.map +0 -1
  284. package/dist/server-action-security.cjs.map +0 -1
  285. package/dist/server-fn-client.cjs.map +0 -1
  286. package/dist/server-fn.cjs.map +0 -1
  287. package/dist/server-plugins.cjs.map +0 -1
  288. package/dist/server-query-client.cjs.map +0 -1
  289. package/dist/server-query.cjs.map +0 -1
  290. package/dist/server.cjs.map +0 -1
  291. package/dist/storage.cjs.map +0 -1
  292. package/dist/testing.cjs.map +0 -1
  293. package/dist/theme/client.cjs.map +0 -1
  294. package/dist/theme/index.cjs.map +0 -1
  295. package/dist/theme/runtime.cjs.map +0 -1
  296. package/dist/theme/server.cjs.map +0 -1
  297. package/dist/version.cjs.map +0 -1
  298. package/dist/vite.cjs.map +0 -1
  299. package/dist/workflows.cjs.map +0 -1
  300. /package/dist/{chunk-VV24CC42.mjs.map → chunk-35NPLKQJ.mjs.map} +0 -0
  301. /package/dist/{chunk-RWYRFCLG.mjs.map → chunk-4X57GXQA.mjs.map} +0 -0
  302. /package/dist/{chunk-MOW47IF5.mjs.map → chunk-6UYVU46O.mjs.map} +0 -0
  303. /package/dist/{chunk-RLGUZ3HS.mjs.map → chunk-I3OOUWO5.mjs.map} +0 -0
  304. /package/dist/{chunk-ODJGAWDH.mjs.map → chunk-JV7JUD7Q.mjs.map} +0 -0
  305. /package/dist/{chunk-Q3OX763A.mjs.map → chunk-LXDASSTE.mjs.map} +0 -0
  306. /package/dist/{chunk-HVG3HLQZ.mjs.map → chunk-Q7WGOOAI.mjs.map} +0 -0
  307. /package/dist/{chunk-3INDBMUU.mjs.map → chunk-TGDIACZT.mjs.map} +0 -0
  308. /package/dist/{chunk-WMAYETRD.mjs.map → chunk-TT3E2JOF.mjs.map} +0 -0
  309. /package/dist/{chunk-FVAM43KI.mjs.map → chunk-UMUWR5XA.mjs.map} +0 -0
  310. /package/dist/{devtools-S52RRRMN.mjs.map → devtools-XWZX6CCL.mjs.map} +0 -0
  311. /package/dist/{devtools-client-EOVDBPOI.mjs.map → devtools-client-Z7QQA3Q2.mjs.map} +0 -0
@@ -1,4 +1,4 @@
1
- import { q as FarmConfig, P as ParsedRoute, ag as ResolvedFarmRouteRuntimeConfig, h as RouteModule, X as LayoutModule, a1 as SSGCollectionResult, Y as FarmRequest, Z as FarmResponse, ah as ResolvedFarmAPIConfig, j as FarmMdxResolvedConfig, ai as ResolvedFarmDevtoolsConfig, aj as ResolvedFarmDevIndicatorsConfig, ak as ResolvedFarmAuthConfig, al as ResolvedFarmPerformanceConfig, am as ResolvedFarmSecurityConfig } from './client-plugins-B9Sq-iMg.js';
1
+ import { q as FarmConfig, P as ParsedRoute, ag as ResolvedFarmRouteRuntimeConfig, h as RouteModule, X as LayoutModule, a1 as SSGCollectionResult, Y as FarmRequest, Z as FarmResponse, ah as ResolvedFarmAPIConfig, j as FarmMdxResolvedConfig, ai as ResolvedFarmDevtoolsConfig, aj as ResolvedFarmDevIndicatorsConfig, ak as ResolvedFarmAuthConfig, al as ResolvedFarmPerformanceConfig, am as ResolvedFarmSecurityConfig } from './client-plugins-By6MVUX-.js';
2
2
  import { F as FarmDocsResolvedConfig } from './types-CKwggz9n.js';
3
3
  import { FarmMarkdownResolvedConfig } from './markdown.js';
4
4
  import { F as FarmWorkflowsResolvedConfig } from './workflows-ChyK_oTu.js';
@@ -7,11 +7,11 @@ import { R as ResolvedFarmImageConfig } from './image-config-Duob7wER.js';
7
7
  import { ProgrammaticRedirectRoute, ProgrammaticRouteSearchClientOptions } from './routes.js';
8
8
  import { ViteDevServer } from 'vite';
9
9
  import { F as FarmIslandStrategy } from './island-CfGru1MO.js';
10
- import { M as MetadataImageKind, A as ApplicationMetadataRouteKind } from './metadata-route-yV4U6X8h.js';
10
+ import { M as MetadataImageKind, A as ApplicationMetadataRouteKind } from './metadata-route-8_V3UonT.js';
11
11
  import { FarmServerRendererRuntime, FarmRenderer } from './renderer.js';
12
- import { F as FarmRouteRenderPlan } from './render-plan-Dc8CjNI7.js';
12
+ import { F as FarmRouteRenderPlan } from './render-plan-0GeHiGVZ.js';
13
13
  import { R as ResolvedFarmI18nConfig } from './types-CnH8DOqo.js';
14
- import { F as FarmI18nRuntime } from './runtime-j1S3sDTh.js';
14
+ import { F as FarmI18nRuntime } from './runtime-BgDQzBiu.js';
15
15
  import { R as ResolvedFarmThemeConfig } from './types-DQnyD3VD.js';
16
16
 
17
17
  interface IsolatedClientBoundaryReference {
@@ -1,4 +1,4 @@
1
- import { q as FarmConfig, P as ParsedRoute, ag as ResolvedFarmRouteRuntimeConfig, h as RouteModule, X as LayoutModule, a1 as SSGCollectionResult, Y as FarmRequest, Z as FarmResponse, ah as ResolvedFarmAPIConfig, j as FarmMdxResolvedConfig, ai as ResolvedFarmDevtoolsConfig, aj as ResolvedFarmDevIndicatorsConfig, ak as ResolvedFarmAuthConfig, al as ResolvedFarmPerformanceConfig, am as ResolvedFarmSecurityConfig } from './client-plugins-BvClItiL.mjs';
1
+ import { q as FarmConfig, P as ParsedRoute, ag as ResolvedFarmRouteRuntimeConfig, h as RouteModule, X as LayoutModule, a1 as SSGCollectionResult, Y as FarmRequest, Z as FarmResponse, ah as ResolvedFarmAPIConfig, j as FarmMdxResolvedConfig, ai as ResolvedFarmDevtoolsConfig, aj as ResolvedFarmDevIndicatorsConfig, ak as ResolvedFarmAuthConfig, al as ResolvedFarmPerformanceConfig, am as ResolvedFarmSecurityConfig } from './client-plugins-B6-07YmP.mjs';
2
2
  import { F as FarmDocsResolvedConfig } from './types-CKwggz9n.mjs';
3
3
  import { FarmMarkdownResolvedConfig } from './markdown.mjs';
4
4
  import { F as FarmWorkflowsResolvedConfig } from './workflows-ChyK_oTu.mjs';
@@ -7,11 +7,11 @@ import { R as ResolvedFarmImageConfig } from './image-config-Duob7wER.mjs';
7
7
  import { ProgrammaticRedirectRoute, ProgrammaticRouteSearchClientOptions } from './routes.mjs';
8
8
  import { ViteDevServer } from 'vite';
9
9
  import { F as FarmIslandStrategy } from './island-CfGru1MO.mjs';
10
- import { M as MetadataImageKind, A as ApplicationMetadataRouteKind } from './metadata-route-p4K1l92V.mjs';
10
+ import { M as MetadataImageKind, A as ApplicationMetadataRouteKind } from './metadata-route-CWP_HjGU.mjs';
11
11
  import { FarmServerRendererRuntime, FarmRenderer } from './renderer.mjs';
12
- import { F as FarmRouteRenderPlan } from './render-plan-CU31j-Jk.mjs';
12
+ import { F as FarmRouteRenderPlan } from './render-plan-DLxJYAA5.mjs';
13
13
  import { R as ResolvedFarmI18nConfig } from './types-CnH8DOqo.mjs';
14
- import { F as FarmI18nRuntime } from './runtime-DDwvDtS4.mjs';
14
+ import { F as FarmI18nRuntime } from './runtime-CV2UCV-5.mjs';
15
15
  import { R as ResolvedFarmThemeConfig } from './types-DQnyD3VD.mjs';
16
16
 
17
17
  interface IsolatedClientBoundaryReference {
@@ -1,7 +1,7 @@
1
- import { i as FarmMdxComponents, j as FarmMdxResolvedConfig, M as Metadata, h as RouteModule } from './client-plugins-BvClItiL.mjs';
2
- export { k as FarmMdxComponent, l as FarmMdxUserConfig, r as resolveMdxConfig } from './client-plugins-BvClItiL.mjs';
1
+ import { i as FarmMdxComponents, j as FarmMdxResolvedConfig, M as Metadata, h as RouteModule } from './client-plugins-B6-07YmP.mjs';
2
+ export { k as FarmMdxComponent, l as FarmMdxUserConfig, r as resolveMdxConfig } from './client-plugins-B6-07YmP.mjs';
3
3
  import './lifecycle-De0vQG45.mjs';
4
- import './route-Cq3aObmj.mjs';
4
+ import './route-CvEr4Uc9.mjs';
5
5
  import './cache.mjs';
6
6
  import './renderer.mjs';
7
7
  import 'http';
@@ -9,6 +9,7 @@ import './types-Cc8l9IqS.mjs';
9
9
  import 'db0';
10
10
  import 'unstorage';
11
11
  import 'react';
12
+ import './integration-api-BT024nuJ.mjs';
12
13
  import '@farming-labs/orm';
13
14
  import './types-CKwggz9n.mjs';
14
15
  import '@farming-labs/docs';
@@ -1,7 +1,7 @@
1
- import { i as FarmMdxComponents, j as FarmMdxResolvedConfig, M as Metadata, h as RouteModule } from './client-plugins-B9Sq-iMg.js';
2
- export { k as FarmMdxComponent, l as FarmMdxUserConfig, r as resolveMdxConfig } from './client-plugins-B9Sq-iMg.js';
1
+ import { i as FarmMdxComponents, j as FarmMdxResolvedConfig, M as Metadata, h as RouteModule } from './client-plugins-By6MVUX-.js';
2
+ export { k as FarmMdxComponent, l as FarmMdxUserConfig, r as resolveMdxConfig } from './client-plugins-By6MVUX-.js';
3
3
  import './lifecycle-De0vQG45.js';
4
- import './route-Y8lfz1wF.js';
4
+ import './route-4pd-EVtw.js';
5
5
  import './cache.js';
6
6
  import './renderer.js';
7
7
  import 'http';
@@ -9,6 +9,7 @@ import './types-Cc8l9IqS.js';
9
9
  import 'db0';
10
10
  import 'unstorage';
11
11
  import 'react';
12
+ import './integration-api-BT024nuJ.js';
12
13
  import '@farming-labs/orm';
13
14
  import './types-CKwggz9n.js';
14
15
  import '@farming-labs/docs';
package/dist/cache.cjs CHANGED
@@ -111,7 +111,13 @@ function recordFarmEventTrace(event) {
111
111
  activeSpan.addEvent(event.type, toEventAttributes(event), event.timestamp);
112
112
  }
113
113
  const error = event.type === "request.error" ? void 0 : getEventError(event);
114
- if (error !== void 0) recordSpanError(activeSpan, error);
114
+ if (error !== void 0) {
115
+ if (event.type === "render.error") {
116
+ recordSpanException(activeSpan, error);
117
+ } else {
118
+ recordSpanError(activeSpan, error);
119
+ }
120
+ }
115
121
  }
116
122
  const completedTraceContext = recordCompletedEventSpan(event, activeContext);
117
123
  return traceContext ?? completedTraceContext;
@@ -208,12 +214,26 @@ function getCompletedSpanDescriptor(event) {
208
214
  }
209
215
  }
210
216
  __name(getCompletedSpanDescriptor, "getCompletedSpanDescriptor");
217
+ function hashFarmCacheKey(value) {
218
+ let hash = 2166136261;
219
+ for (let index = 0; index < value.length; index++) {
220
+ hash ^= value.charCodeAt(index);
221
+ hash = Math.imul(hash, 16777619);
222
+ }
223
+ return (hash >>> 0).toString(16).padStart(8, "0");
224
+ }
225
+ __name(hashFarmCacheKey, "hashFarmCacheKey");
211
226
  function toEventAttributes(event) {
212
227
  const attributes = {};
228
+ const redactKey = typeof event.type === "string" && event.type.startsWith("cache.");
213
229
  for (const [key, value] of Object.entries(event)) {
214
230
  if (key === "timestamp" || key === "level" || key === "error" || key === "traceId" || key === "spanId" || key === "traceSampled" || value === void 0) {
215
231
  continue;
216
232
  }
233
+ if (redactKey && key === "key" && typeof value === "string") {
234
+ attributes["farm.key_hash"] = hashFarmCacheKey(value);
235
+ continue;
236
+ }
217
237
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
218
238
  attributes[`farm.${key}`] = value;
219
239
  } else if (Array.isArray(value)) {
@@ -233,9 +253,14 @@ function getEventError(event) {
233
253
  return "error" in event ? event.error : void 0;
234
254
  }
235
255
  __name(getEventError, "getEventError");
236
- function recordSpanError(span, error) {
256
+ function recordSpanException(span, error) {
237
257
  const normalized = error instanceof Error ? error : new Error(String(error));
238
258
  span.recordException(normalized);
259
+ return normalized;
260
+ }
261
+ __name(recordSpanException, "recordSpanException");
262
+ function recordSpanError(span, error) {
263
+ const normalized = recordSpanException(span, error);
239
264
  span.setStatus({ code: import_api.SpanStatusCode.ERROR, message: normalized.message });
240
265
  }
241
266
  __name(recordSpanError, "recordSpanError");
@@ -394,16 +419,29 @@ function getFarmCacheInvalidationState() {
394
419
  });
395
420
  }
396
421
  __name(getFarmCacheInvalidationState, "getFarmCacheInvalidationState");
422
+ function warnFarmCacheListenerError(scope, error) {
423
+ const detail = error instanceof Error ? error.stack ?? error.message : String(error);
424
+ console.warn(`[farm:cache] ${scope} listener failed: ${detail}`);
425
+ }
426
+ __name(warnFarmCacheListenerError, "warnFarmCacheListenerError");
397
427
  function notifyFarmCacheInvalidation(key) {
398
428
  if (typeof key !== "string" || key.length === 0) return;
399
429
  for (const listener of getFarmCacheInvalidationState().listeners) {
400
- listener(key);
430
+ try {
431
+ listener(key);
432
+ } catch (error) {
433
+ warnFarmCacheListenerError("invalidation", error);
434
+ }
401
435
  }
402
436
  }
403
437
  __name(notifyFarmCacheInvalidation, "notifyFarmCacheInvalidation");
404
438
  function notifyFarmCacheTask(task) {
405
439
  for (const listener of getFarmCacheInvalidationState().taskListeners) {
406
- listener(task);
440
+ try {
441
+ listener(task);
442
+ } catch (error) {
443
+ warnFarmCacheListenerError("task", error);
444
+ }
407
445
  }
408
446
  }
409
447
  __name(notifyFarmCacheTask, "notifyFarmCacheTask");
package/dist/cache.d.mts CHANGED
@@ -80,11 +80,25 @@ interface FarmCacheAdapter {
80
80
  /** Release the lease only when the supplied ownership token still matches. */
81
81
  releaseLease?(key: string, token: string): Promise<void>;
82
82
  }
83
+ interface FarmClientCacheUserConfig {
84
+ /**
85
+ * Module path, relative to the project root, whose default export is a
86
+ * client cache adapter (`defineClientCacheAdapter`). The module is bundled
87
+ * into the browser entry; the server never imports it.
88
+ */
89
+ adapter?: string;
90
+ /** Extra version salt, typically a build or deploy id; entries persisted under another salt are dropped. */
91
+ version?: string;
92
+ /** Debounce for persisted write-behind flushes, in milliseconds. */
93
+ flushDelayMs?: number;
94
+ }
83
95
  interface FarmCacheUserConfig {
84
96
  /** Shared cache implementation, for example a Redis-backed adapter. */
85
97
  adapter?: FarmCacheAdapter;
86
98
  /** Prefix isolating applications and deployments sharing one adapter. */
87
99
  namespace?: string;
100
+ /** Browser cache persistence; see the client cache adapter documentation. */
101
+ client?: FarmClientCacheUserConfig;
88
102
  /**
89
103
  * Coordinate cache fills across processes when the adapter implements
90
104
  * acquireLease/releaseLease. Set false to disable.
@@ -174,9 +188,62 @@ declare class FarmDataCache {
174
188
  }
175
189
  declare function getFarmDataCache(): FarmDataCache;
176
190
  declare function configureFarmCache(config: FarmCacheUserConfig | undefined): void;
191
+ /**
192
+ * Wrap an async function so its results are cached and shared across requests,
193
+ * processes, and restarts.
194
+ *
195
+ * The cache key is built from the wrapped function's identity (its name and a
196
+ * hash of its source), the active locale, `keyParts`, and the call arguments.
197
+ * Deriving identity from the source — rather than the closure instance — is
198
+ * deliberate: it keeps the key stable across processes and restarts so a
199
+ * distributed cache adapter can share entries between server instances.
200
+ *
201
+ * The consequence is that two closures with **identical source text but
202
+ * different captured variables** produce the same identity. Pass those captured
203
+ * values in `keyParts` so they take part in the key; otherwise the closures
204
+ * share a cache entry and return each other's data:
205
+ *
206
+ * ```ts
207
+ * // Collides: both closures have identical source, and `table` is captured,
208
+ * // not an argument, so it never reaches the key.
209
+ * const makeLoader = (table: string) =>
210
+ * unstable_cache(async (id: number) => db.get(table, id));
211
+ *
212
+ * // Correct: the captured value disambiguates the two closures.
213
+ * const makeLoader = (table: string) =>
214
+ * unstable_cache(async (id: number) => db.get(table, id), [table]);
215
+ * ```
216
+ *
217
+ * Values passed as call arguments already participate in the key and do not
218
+ * need to be repeated in `keyParts`.
219
+ *
220
+ * @param fn The async function to memoize.
221
+ * @param keyParts Extra values that identify this call site. Include every
222
+ * variable the function closes over that is not one of its arguments.
223
+ * @param options Tags, paths, and revalidation settings for the cached entry.
224
+ */
177
225
  declare function unstable_cache<Args extends unknown[], Result>(fn: (...args: Args) => Result | Promise<Result>, keyParts?: readonly unknown[], options?: FarmCacheOptions): (...args: Args) => Promise<Result>;
226
+ /**
227
+ * Invalidate every cache entry carrying `tag`.
228
+ *
229
+ * Observability note: the `count` on the emitted `cache.revalidateTag` event is
230
+ * derived from Farm's process-local entry tracking. With a shared `cache.adapter`
231
+ * configured, entries live in the adapter rather than in local memory, so the
232
+ * count can read as `0` even though the invalidation is still propagated to the
233
+ * adapter and applied. Treat it as a best-effort signal, not a distributed count.
234
+ */
178
235
  declare function revalidateTag(_tag: string, _profile?: RevalidateTagProfile): void | Promise<void>;
179
236
  declare function updateTag(tag: string): void | Promise<void>;
237
+ /**
238
+ * Invalidate cached data for a route path (and its PPR shell, if any).
239
+ *
240
+ * Observability note: the `count` on the emitted `cache.revalidatePath` event and
241
+ * the `ppr.shell.invalidated` event are derived from process-local entry tracking.
242
+ * With a shared `cache.adapter`, PPR shells live in the adapter rather than in
243
+ * local memory, so the count can read as `0` and `ppr.shell.invalidated` may not
244
+ * be emitted even though the invalidation is still propagated to the adapter and
245
+ * applied.
246
+ */
180
247
  declare function revalidatePath(routePath: string): void | Promise<void>;
181
248
  declare function invalidate(key: RouteDataCacheKey): void | Promise<void>;
182
249
  declare function invalidateRouteData(key: RouteDataCacheKey): void | Promise<void>;
@@ -191,4 +258,4 @@ declare function createRouteDataCacheKey(key: RouteDataCacheKey): string;
191
258
  declare function normalizeRevalidatePath(routePath: string): string;
192
259
  declare function createFarmCacheKey(parts: readonly unknown[]): string;
193
260
 
194
- export { type CacheKeyFactory, type DefinedCacheKey, type FarmCacheAdapter, type FarmCacheEntry, type FarmCacheInvalidationTarget, type FarmCacheOptions, type FarmCacheSetOptions, type FarmCacheStorage, type FarmCacheUserConfig, FarmDataCache, type GetFarmCacheEntryOptions, type InferCacheKeyData, type RevalidateTagProfile, type RouteDataCacheKey, type StorageFarmCacheAdapterOptions, applyFarmCacheInvalidationTargets, applyFarmCacheInvalidations, configureFarmCache, createFarmCacheKey, createPathCacheTag, createRouteDataCacheKey, createRouteDataCacheTag, defineCacheKey, getFarmDataCache, invalidate, invalidateRouteData, normalizeRevalidatePath, revalidatePath, revalidateTag, storageCacheAdapter, unstable_cache, updateTag };
261
+ export { type CacheKeyFactory, type DefinedCacheKey, type FarmCacheAdapter, type FarmCacheEntry, type FarmCacheInvalidationTarget, type FarmCacheOptions, type FarmCacheSetOptions, type FarmCacheStorage, type FarmCacheUserConfig, type FarmClientCacheUserConfig, FarmDataCache, type GetFarmCacheEntryOptions, type InferCacheKeyData, type RevalidateTagProfile, type RouteDataCacheKey, type StorageFarmCacheAdapterOptions, applyFarmCacheInvalidationTargets, applyFarmCacheInvalidations, configureFarmCache, createFarmCacheKey, createPathCacheTag, createRouteDataCacheKey, createRouteDataCacheTag, defineCacheKey, getFarmDataCache, invalidate, invalidateRouteData, normalizeRevalidatePath, revalidatePath, revalidateTag, storageCacheAdapter, unstable_cache, updateTag };
package/dist/cache.d.ts CHANGED
@@ -80,11 +80,25 @@ interface FarmCacheAdapter {
80
80
  /** Release the lease only when the supplied ownership token still matches. */
81
81
  releaseLease?(key: string, token: string): Promise<void>;
82
82
  }
83
+ interface FarmClientCacheUserConfig {
84
+ /**
85
+ * Module path, relative to the project root, whose default export is a
86
+ * client cache adapter (`defineClientCacheAdapter`). The module is bundled
87
+ * into the browser entry; the server never imports it.
88
+ */
89
+ adapter?: string;
90
+ /** Extra version salt, typically a build or deploy id; entries persisted under another salt are dropped. */
91
+ version?: string;
92
+ /** Debounce for persisted write-behind flushes, in milliseconds. */
93
+ flushDelayMs?: number;
94
+ }
83
95
  interface FarmCacheUserConfig {
84
96
  /** Shared cache implementation, for example a Redis-backed adapter. */
85
97
  adapter?: FarmCacheAdapter;
86
98
  /** Prefix isolating applications and deployments sharing one adapter. */
87
99
  namespace?: string;
100
+ /** Browser cache persistence; see the client cache adapter documentation. */
101
+ client?: FarmClientCacheUserConfig;
88
102
  /**
89
103
  * Coordinate cache fills across processes when the adapter implements
90
104
  * acquireLease/releaseLease. Set false to disable.
@@ -174,9 +188,62 @@ declare class FarmDataCache {
174
188
  }
175
189
  declare function getFarmDataCache(): FarmDataCache;
176
190
  declare function configureFarmCache(config: FarmCacheUserConfig | undefined): void;
191
+ /**
192
+ * Wrap an async function so its results are cached and shared across requests,
193
+ * processes, and restarts.
194
+ *
195
+ * The cache key is built from the wrapped function's identity (its name and a
196
+ * hash of its source), the active locale, `keyParts`, and the call arguments.
197
+ * Deriving identity from the source — rather than the closure instance — is
198
+ * deliberate: it keeps the key stable across processes and restarts so a
199
+ * distributed cache adapter can share entries between server instances.
200
+ *
201
+ * The consequence is that two closures with **identical source text but
202
+ * different captured variables** produce the same identity. Pass those captured
203
+ * values in `keyParts` so they take part in the key; otherwise the closures
204
+ * share a cache entry and return each other's data:
205
+ *
206
+ * ```ts
207
+ * // Collides: both closures have identical source, and `table` is captured,
208
+ * // not an argument, so it never reaches the key.
209
+ * const makeLoader = (table: string) =>
210
+ * unstable_cache(async (id: number) => db.get(table, id));
211
+ *
212
+ * // Correct: the captured value disambiguates the two closures.
213
+ * const makeLoader = (table: string) =>
214
+ * unstable_cache(async (id: number) => db.get(table, id), [table]);
215
+ * ```
216
+ *
217
+ * Values passed as call arguments already participate in the key and do not
218
+ * need to be repeated in `keyParts`.
219
+ *
220
+ * @param fn The async function to memoize.
221
+ * @param keyParts Extra values that identify this call site. Include every
222
+ * variable the function closes over that is not one of its arguments.
223
+ * @param options Tags, paths, and revalidation settings for the cached entry.
224
+ */
177
225
  declare function unstable_cache<Args extends unknown[], Result>(fn: (...args: Args) => Result | Promise<Result>, keyParts?: readonly unknown[], options?: FarmCacheOptions): (...args: Args) => Promise<Result>;
226
+ /**
227
+ * Invalidate every cache entry carrying `tag`.
228
+ *
229
+ * Observability note: the `count` on the emitted `cache.revalidateTag` event is
230
+ * derived from Farm's process-local entry tracking. With a shared `cache.adapter`
231
+ * configured, entries live in the adapter rather than in local memory, so the
232
+ * count can read as `0` even though the invalidation is still propagated to the
233
+ * adapter and applied. Treat it as a best-effort signal, not a distributed count.
234
+ */
178
235
  declare function revalidateTag(_tag: string, _profile?: RevalidateTagProfile): void | Promise<void>;
179
236
  declare function updateTag(tag: string): void | Promise<void>;
237
+ /**
238
+ * Invalidate cached data for a route path (and its PPR shell, if any).
239
+ *
240
+ * Observability note: the `count` on the emitted `cache.revalidatePath` event and
241
+ * the `ppr.shell.invalidated` event are derived from process-local entry tracking.
242
+ * With a shared `cache.adapter`, PPR shells live in the adapter rather than in
243
+ * local memory, so the count can read as `0` and `ppr.shell.invalidated` may not
244
+ * be emitted even though the invalidation is still propagated to the adapter and
245
+ * applied.
246
+ */
180
247
  declare function revalidatePath(routePath: string): void | Promise<void>;
181
248
  declare function invalidate(key: RouteDataCacheKey): void | Promise<void>;
182
249
  declare function invalidateRouteData(key: RouteDataCacheKey): void | Promise<void>;
@@ -191,4 +258,4 @@ declare function createRouteDataCacheKey(key: RouteDataCacheKey): string;
191
258
  declare function normalizeRevalidatePath(routePath: string): string;
192
259
  declare function createFarmCacheKey(parts: readonly unknown[]): string;
193
260
 
194
- export { type CacheKeyFactory, type DefinedCacheKey, type FarmCacheAdapter, type FarmCacheEntry, type FarmCacheInvalidationTarget, type FarmCacheOptions, type FarmCacheSetOptions, type FarmCacheStorage, type FarmCacheUserConfig, FarmDataCache, type GetFarmCacheEntryOptions, type InferCacheKeyData, type RevalidateTagProfile, type RouteDataCacheKey, type StorageFarmCacheAdapterOptions, applyFarmCacheInvalidationTargets, applyFarmCacheInvalidations, configureFarmCache, createFarmCacheKey, createPathCacheTag, createRouteDataCacheKey, createRouteDataCacheTag, defineCacheKey, getFarmDataCache, invalidate, invalidateRouteData, normalizeRevalidatePath, revalidatePath, revalidateTag, storageCacheAdapter, unstable_cache, updateTag };
261
+ export { type CacheKeyFactory, type DefinedCacheKey, type FarmCacheAdapter, type FarmCacheEntry, type FarmCacheInvalidationTarget, type FarmCacheOptions, type FarmCacheSetOptions, type FarmCacheStorage, type FarmCacheUserConfig, type FarmClientCacheUserConfig, FarmDataCache, type GetFarmCacheEntryOptions, type InferCacheKeyData, type RevalidateTagProfile, type RouteDataCacheKey, type StorageFarmCacheAdapterOptions, applyFarmCacheInvalidationTargets, applyFarmCacheInvalidations, configureFarmCache, createFarmCacheKey, createPathCacheTag, createRouteDataCacheKey, createRouteDataCacheTag, defineCacheKey, getFarmDataCache, invalidate, invalidateRouteData, normalizeRevalidatePath, revalidatePath, revalidateTag, storageCacheAdapter, unstable_cache, updateTag };
package/dist/cache.mjs CHANGED
@@ -16,12 +16,12 @@ import {
16
16
  storageCacheAdapter,
17
17
  unstable_cache,
18
18
  updateTag
19
- } from "./chunk-AXVJCMVF.mjs";
19
+ } from "./chunk-2HDOV47R.mjs";
20
20
  import {
21
21
  applyFarmCacheInvalidations
22
- } from "./chunk-RBRLLZL5.mjs";
22
+ } from "./chunk-34IAPZBG.mjs";
23
23
  import "./chunk-WZ5QFROO.mjs";
24
- import "./chunk-ZRBCBOEX.mjs";
24
+ import "./chunk-N2FY2QZ7.mjs";
25
25
  import "./chunk-CGILA3WO.mjs";
26
26
  export {
27
27
  FarmDataCache,
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  notifyFarmCacheInvalidation,
3
3
  notifyFarmCacheTask
4
- } from "./chunk-RBRLLZL5.mjs";
4
+ } from "./chunk-34IAPZBG.mjs";
5
5
  import {
6
6
  getActiveFarmI18nSnapshot
7
7
  } from "./chunk-WZ5QFROO.mjs";
8
8
  import {
9
9
  emitFarmEvent
10
- } from "./chunk-ZRBCBOEX.mjs";
10
+ } from "./chunk-N2FY2QZ7.mjs";
11
11
  import {
12
12
  __name
13
13
  } from "./chunk-CGILA3WO.mjs";
@@ -844,4 +844,4 @@ export {
844
844
  normalizeRevalidatePath,
845
845
  createFarmCacheKey
846
846
  };
847
- //# sourceMappingURL=chunk-AXVJCMVF.mjs.map
847
+ //# sourceMappingURL=chunk-2HDOV47R.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cache.ts"],"sourcesContent":["import { emitFarmEvent } from \"./observability\";\nimport { notifyFarmCacheInvalidation, notifyFarmCacheTask } from \"./cache-invalidation\";\nimport { getActiveFarmI18nSnapshot } from \"./i18n/bridge\";\n\nexport { applyFarmCacheInvalidations } from \"./cache-invalidation\";\n\nexport type RevalidateTagProfile =\n | \"max\"\n | \"default\"\n | \"seconds\"\n | \"minutes\"\n | \"hours\"\n | \"days\"\n | \"weeks\"\n | \"months\"\n | { expire?: number };\n\nexport interface FarmCacheOptions {\n /**\n * Tag cached data so it can be invalidated with revalidateTag/updateTag.\n */\n tags?: readonly string[];\n /**\n * Path tags let revalidatePath invalidate data tied to a route.\n */\n paths?: readonly string[];\n /**\n * Time in seconds before the entry becomes stale. False means no TTL.\n */\n revalidate?: number | false;\n}\n\nexport interface FarmCacheSetOptions extends FarmCacheOptions {\n createdAt?: number;\n}\n\nexport type RouteDataCacheKey = string | readonly unknown[];\n\nexport type FarmCacheInvalidationTarget =\n | { key: RouteDataCacheKey }\n | { path: string }\n | { tag: string };\n\ndeclare const FARM_DEFINED_CACHE_KEY_DATA: unique symbol;\n\n/**\n * A regular Farm cache key carrying the data shape stored under that key.\n *\n * The brand exists only in TypeScript. At runtime the value remains the\n * original string or structured array, so all existing cache APIs continue to\n * accept untyped keys.\n */\nexport type DefinedCacheKey<TData, TKey extends RouteDataCacheKey = RouteDataCacheKey> = TKey & {\n readonly [FARM_DEFINED_CACHE_KEY_DATA]: TData;\n};\n\nexport type CacheKeyFactory<\n TData,\n TArguments extends readonly unknown[],\n TKey extends RouteDataCacheKey = RouteDataCacheKey,\n> = (...args: TArguments) => DefinedCacheKey<TData, TKey>;\n\nexport type InferCacheKeyData<TKey> =\n TKey extends DefinedCacheKey<infer TData, RouteDataCacheKey> ? TData : unknown;\n\n/**\n * Optionally add a data type to an existing string/array cache-key factory.\n *\n * This helper does not introduce a new runtime key representation. Calling the\n * returned factory produces the exact key returned by `factory`.\n */\nexport function defineCacheKey<TData>() {\n return <const TArguments extends readonly unknown[], const TKey extends RouteDataCacheKey>(\n factory: (...args: TArguments) => TKey,\n ): CacheKeyFactory<TData, TArguments, TKey> => {\n if (typeof factory !== \"function\") {\n throw new TypeError(\"defineCacheKey expects a key factory function.\");\n }\n\n return ((...args: TArguments) => {\n const key = factory(...args);\n if (typeof key !== \"string\" && !Array.isArray(key)) {\n throw new TypeError(\n \"A defined cache key factory must return a string or structured array.\",\n );\n }\n return key as DefinedCacheKey<TData, TKey>;\n }) as CacheKeyFactory<TData, TArguments, TKey>;\n };\n}\n\nexport interface FarmCacheEntry<T = unknown> {\n key: string;\n value: T;\n tags: readonly string[];\n /**\n * Adapter tag versions captured before the cached value was produced.\n * A later version makes the entry stale across every server instance.\n */\n tagVersions?: Readonly<Record<string, number>>;\n createdAt: number;\n createdVersion?: number;\n revalidate?: number | false;\n}\n\ninterface InternalFarmCacheEntry<T = unknown> {\n key: string;\n value: T;\n tags: Set<string>;\n tagVersions?: Readonly<Record<string, number>>;\n createdAt: number;\n createdVersion: number;\n revalidate?: number | false;\n}\n\n/**\n * Asynchronous persistence contract used by distributed Farm caches.\n *\n * Implementations are responsible for serializing cache entries and making\n * tag version updates atomic when the backing service supports it.\n */\nexport interface FarmCacheAdapter {\n readonly name?: string;\n get<T = unknown>(key: string): Promise<FarmCacheEntry<T> | null | undefined>;\n set<T = unknown>(key: string, entry: FarmCacheEntry<T>): Promise<void>;\n delete(key: string): Promise<void>;\n clear?(): Promise<void>;\n getTagVersions?(tags: readonly string[]): Promise<Readonly<Record<string, number>>>;\n invalidateTags?(tags: readonly string[]): Promise<void>;\n /** Atomically acquire a short-lived regeneration lease. */\n acquireLease?(key: string, ttlMs: number): Promise<string | null | undefined>;\n /** Release the lease only when the supplied ownership token still matches. */\n releaseLease?(key: string, token: string): Promise<void>;\n}\n\nexport interface FarmClientCacheUserConfig {\n /**\n * Module path, relative to the project root, whose default export is a\n * client cache adapter (`defineClientCacheAdapter`). The module is bundled\n * into the browser entry; the server never imports it.\n */\n adapter?: string;\n /** Extra version salt, typically a build or deploy id; entries persisted under another salt are dropped. */\n version?: string;\n /** Debounce for persisted write-behind flushes, in milliseconds. */\n flushDelayMs?: number;\n}\n\nexport interface FarmCacheUserConfig {\n /** Shared cache implementation, for example a Redis-backed adapter. */\n adapter?: FarmCacheAdapter;\n /** Prefix isolating applications and deployments sharing one adapter. */\n namespace?: string;\n /** Browser cache persistence; see the client cache adapter documentation. */\n client?: FarmClientCacheUserConfig;\n /**\n * Coordinate cache fills across processes when the adapter implements\n * acquireLease/releaseLease. Set false to disable.\n */\n lease?:\n | false\n | {\n ttlMs?: number;\n waitTimeoutMs?: number;\n pollIntervalMs?: number;\n };\n}\n\nexport interface FarmCacheStorage {\n getItem<T = unknown>(key: string): Promise<T | null>;\n setItem<T = unknown>(key: string, value: T): Promise<unknown>;\n removeItem(key: string): Promise<unknown>;\n clear?(base?: string): Promise<unknown>;\n}\n\nexport interface StorageFarmCacheAdapterOptions {\n /** Prefix used inside the supplied storage client. */\n base?: string;\n}\n\n/**\n * Adapt a Farm/unstorage-compatible key-value client to the cache contract.\n *\n * This is a portable baseline adapter. Provider-specific adapters should use\n * their atomic increment/transaction primitives for tag invalidation.\n */\nexport function storageCacheAdapter(\n storage: FarmCacheStorage,\n options: StorageFarmCacheAdapterOptions = {},\n): FarmCacheAdapter {\n if (!storage || typeof storage.getItem !== \"function\" || typeof storage.setItem !== \"function\") {\n throw new TypeError(\"storageCacheAdapter expects a compatible storage client.\");\n }\n\n const base = normalizeCacheNamespace(options.base || \"farm-cache\");\n const entryKey = (key: string) => `${base}:entry:${key}`;\n const tagKey = (tag: string) => `${base}:tag:${tag}`;\n\n return {\n name: \"storage\",\n get: <T>(key: string) => storage.getItem<FarmCacheEntry<T>>(entryKey(key)),\n set: async <T>(key: string, entry: FarmCacheEntry<T>) => {\n await storage.setItem(entryKey(key), entry);\n },\n delete: async (key: string) => {\n await storage.removeItem(entryKey(key));\n },\n clear: storage.clear\n ? async () => {\n await storage.clear!(base);\n }\n : undefined,\n getTagVersions: async (tags) => {\n const versions = await Promise.all(\n tags.map(async (tag) => {\n const value = await storage.getItem<number>(tagKey(tag));\n return [tag, normalizeAdapterVersion(value)] as const;\n }),\n );\n return Object.fromEntries(versions);\n },\n invalidateTags: async (tags) => {\n await Promise.all(\n tags.map(async (tag) => {\n const key = tagKey(tag);\n const current = normalizeAdapterVersion(await storage.getItem<number>(key));\n await storage.setItem(key, Math.max(Date.now(), current + 1));\n }),\n );\n },\n };\n}\n\nexport interface GetFarmCacheEntryOptions {\n allowStale?: boolean;\n now?: number;\n}\n\ninterface FarmCacheStaleEntry {\n tags: Iterable<string>;\n createdAt: number;\n createdVersion?: number;\n revalidate?: number | false;\n}\n\nexport class FarmDataCache {\n private entries = new Map<string, InternalFarmCacheEntry>();\n private inflight = new Map<string, Promise<unknown>>();\n private invalidatedTagVersions = new Map<string, number>();\n private version = 0;\n private generation = 0;\n private adapter?: FarmCacheAdapter;\n private namespace = \"farm\";\n private local = true;\n private lease = {\n enabled: true,\n ttlMs: 10_000,\n waitTimeoutMs: 10_000,\n pollIntervalMs: 25,\n };\n\n constructor(config: FarmCacheUserConfig = {}) {\n this.configure(config);\n }\n\n configure(config: FarmCacheUserConfig = {}): void {\n this.generation++;\n this.entries.clear();\n this.inflight.clear();\n this.invalidatedTagVersions.clear();\n this.version = 0;\n this.adapter = config.adapter;\n this.namespace = normalizeCacheNamespace(config.namespace || \"farm\");\n this.local = !config.adapter;\n this.lease =\n config.lease === false\n ? { ...this.lease, enabled: false }\n : {\n enabled: true,\n ttlMs: normalizePositiveDuration(config.lease?.ttlMs, 10_000, \"cache.lease.ttlMs\"),\n waitTimeoutMs: normalizePositiveDuration(\n config.lease?.waitTimeoutMs,\n 10_000,\n \"cache.lease.waitTimeoutMs\",\n ),\n pollIntervalMs: normalizePositiveDuration(\n config.lease?.pollIntervalMs,\n 25,\n \"cache.lease.pollIntervalMs\",\n ),\n };\n }\n\n get adapterName(): string {\n return this.adapter?.name || (this.adapter ? \"custom\" : \"memory\");\n }\n\n get hasAdapter(): boolean {\n return this.adapter !== undefined;\n }\n\n get size(): number {\n return this.entries.size;\n }\n\n get<T>(key: string, options: GetFarmCacheEntryOptions = {}): T | undefined {\n return this.getEntry<T>(key, options)?.value;\n }\n\n getEntry<T = unknown>(\n key: string,\n options: GetFarmCacheEntryOptions = {},\n ): FarmCacheEntry<T> | undefined {\n const entry = this.entries.get(key) as InternalFarmCacheEntry<T> | undefined;\n if (!entry) {\n emitFarmEvent({ type: \"cache.miss\", key });\n return undefined;\n }\n\n const stale = this.isStale(entry, options.now);\n if (stale) {\n emitFarmEvent({\n type: \"cache.stale\",\n key,\n tags: Array.from(entry.tags),\n revalidate: entry.revalidate,\n });\n }\n\n if (!options.allowStale && stale) {\n emitFarmEvent({ type: \"cache.miss\", key, reason: \"stale\" });\n return undefined;\n }\n\n emitFarmEvent({\n type: \"cache.hit\",\n key,\n tags: Array.from(entry.tags),\n revalidate: entry.revalidate,\n stale,\n });\n\n return this.toPublicEntry(entry);\n }\n\n async getEntryAsync<T = unknown>(\n key: string,\n options: GetFarmCacheEntryOptions = {},\n ): Promise<FarmCacheEntry<T> | undefined> {\n if (this.local) {\n const localEntry = this.getEntry<T>(key, options);\n if (localEntry) return localEntry;\n }\n\n if (!this.adapter) {\n return this.local ? undefined : this.getEntry<T>(key, options);\n }\n\n const generation = this.generation;\n const adapter = this.adapter;\n const namespace = this.namespace;\n const entry = await adapter.get<T>(`${namespace}:entry:${key}`);\n if (generation !== this.generation) return undefined;\n if (!entry) {\n emitFarmEvent({ type: \"cache.miss\", key });\n return undefined;\n }\n\n assertFarmCacheEntry(entry, key);\n const stale = await this.isAdapterEntryStale(entry, options.now, adapter, namespace);\n if (generation !== this.generation) return undefined;\n if (stale) {\n emitFarmEvent({\n type: \"cache.stale\",\n key,\n tags: [...entry.tags],\n revalidate: entry.revalidate,\n });\n if (!options.allowStale) {\n emitFarmEvent({ type: \"cache.miss\", key, reason: \"stale\" });\n return undefined;\n }\n }\n\n emitFarmEvent({\n type: \"cache.hit\",\n key,\n tags: [...entry.tags],\n revalidate: entry.revalidate,\n stale,\n });\n\n if (this.local && !stale) {\n this.hydrateLocalEntry(entry);\n }\n return { ...entry, key };\n }\n\n set<T>(key: string, value: T, options: FarmCacheSetOptions = {}): FarmCacheEntry<T> {\n const tags = new Set<string>();\n for (const tag of options.tags ?? []) {\n tags.add(normalizeCacheTag(tag));\n }\n for (const routePath of options.paths ?? []) {\n tags.add(createPathCacheTag(routePath));\n }\n\n const entry: InternalFarmCacheEntry<T> = {\n key,\n value,\n tags,\n tagVersions: undefined,\n createdAt: options.createdAt ?? Date.now(),\n createdVersion: ++this.version,\n revalidate: normalizeRevalidate(options.revalidate),\n };\n\n this.entries.set(key, entry);\n emitFarmEvent({\n type: \"cache.set\",\n key,\n tags: Array.from(tags),\n revalidate: entry.revalidate,\n });\n return this.toPublicEntry(entry);\n }\n\n async setAsync<T>(\n key: string,\n value: T,\n options: FarmCacheSetOptions = {},\n tagVersions?: Readonly<Record<string, number>>,\n ): Promise<FarmCacheEntry<T>> {\n return this.writeAsync(key, value, options, tagVersions);\n }\n\n private async writeAsync<T>(\n key: string,\n value: T,\n options: FarmCacheSetOptions,\n tagVersions?: Readonly<Record<string, number>>,\n createdVersion?: number,\n ): Promise<FarmCacheEntry<T>> {\n const tags = normalizeCacheOptionsTags(options);\n const capturedVersions =\n tagVersions ?? (await this.getAdapterTagVersions(Array.from(tags.values())));\n const entry: FarmCacheEntry<T> = {\n key,\n value,\n tags: Array.from(tags),\n tagVersions: capturedVersions,\n createdAt: options.createdAt ?? Date.now(),\n createdVersion: createdVersion ?? ++this.version,\n revalidate: normalizeRevalidate(options.revalidate),\n };\n\n if (this.local) {\n this.hydrateLocalEntry(entry);\n }\n if (this.adapter) {\n await this.adapter.set(this.createAdapterKey(key), entry);\n }\n\n emitFarmEvent({\n type: \"cache.set\",\n key,\n tags: [...entry.tags],\n revalidate: entry.revalidate,\n });\n return entry;\n }\n\n delete(key: string): boolean {\n const deleted = this.entries.delete(key);\n emitFarmEvent({ type: \"cache.delete\", key, deleted });\n return deleted;\n }\n\n async deleteAsync(key: string): Promise<boolean> {\n const deleted = this.entries.delete(key);\n if (this.adapter) {\n await this.adapter.delete(this.createAdapterKey(key));\n }\n emitFarmEvent({ type: \"cache.delete\", key, deleted: this.adapter ? true : deleted });\n return this.adapter ? true : deleted;\n }\n\n clear(): void {\n const count = this.entries.size;\n this.generation++;\n this.entries.clear();\n this.inflight.clear();\n this.invalidatedTagVersions.clear();\n this.version = 0;\n emitFarmEvent({ type: \"cache.clear\", count });\n }\n\n async clearAsync(): Promise<void> {\n this.clear();\n await this.adapter?.clear?.();\n }\n\n isStale(entry: FarmCacheStaleEntry, now = Date.now()): boolean {\n if (\n typeof entry.revalidate === \"number\" &&\n entry.revalidate >= 0 &&\n now - entry.createdAt >= entry.revalidate * 1000\n ) {\n return true;\n }\n\n for (const tag of entry.tags) {\n const invalidatedVersion = this.invalidatedTagVersions.get(normalizeCacheTag(tag));\n if (\n typeof invalidatedVersion === \"number\" &&\n typeof entry.createdVersion === \"number\" &&\n invalidatedVersion > entry.createdVersion\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n async isStaleAsync(entry: FarmCacheEntry, now = Date.now()): Promise<boolean> {\n if (this.adapter) {\n return this.isAdapterEntryStale(entry, now);\n }\n return this.isStale(entry, now);\n }\n\n revalidateTag(\n tag: string,\n options: { source?: \"revalidateTag\" | \"updateTag\"; profile?: RevalidateTagProfile } = {},\n ): number {\n const normalized = normalizeCacheTag(tag);\n const count = this.invalidateTag(normalized);\n emitFarmEvent(\n options.source === \"updateTag\"\n ? { type: \"cache.updateTag\", tag: normalized, count }\n : { type: \"cache.revalidateTag\", tag: normalized, profile: options.profile, count },\n );\n return count;\n }\n\n async revalidateTagAsync(\n tag: string,\n options: { source?: \"revalidateTag\" | \"updateTag\"; profile?: RevalidateTagProfile } = {},\n ): Promise<number> {\n const normalized = normalizeCacheTag(tag);\n const count = this.invalidateTag(normalized);\n await this.adapter?.invalidateTags?.([this.createAdapterTag(normalized)]);\n emitFarmEvent(\n options.source === \"updateTag\"\n ? { type: \"cache.updateTag\", tag: normalized, count }\n : { type: \"cache.revalidateTag\", tag: normalized, profile: options.profile, count },\n );\n return count;\n }\n\n revalidatePath(routePath: string): number {\n const normalizedPath = normalizeRevalidatePath(routePath);\n const pathTag = createPathCacheTag(normalizedPath);\n const pprCount = this.countEntriesForTags([pathTag, \"ppr\"]);\n const count = this.invalidateTag(pathTag);\n emitFarmEvent({ type: \"cache.revalidatePath\", path: normalizedPath, count });\n\n if (pprCount > 0) {\n emitFarmEvent({\n type: \"ppr.shell.invalidated\",\n route: normalizedPath,\n reason: \"revalidatePath\",\n count: pprCount,\n });\n }\n\n return count;\n }\n\n async revalidatePathAsync(routePath: string): Promise<number> {\n const normalizedPath = normalizeRevalidatePath(routePath);\n const pathTag = createPathCacheTag(normalizedPath);\n const pprCount = this.countEntriesForTags([pathTag, \"ppr\"]);\n const count = this.invalidateTag(pathTag);\n await this.adapter?.invalidateTags?.([this.createAdapterTag(pathTag)]);\n emitFarmEvent({ type: \"cache.revalidatePath\", path: normalizedPath, count });\n\n if (pprCount > 0) {\n emitFarmEvent({\n type: \"ppr.shell.invalidated\",\n route: normalizedPath,\n reason: \"revalidatePath\",\n count: pprCount,\n });\n }\n\n return count;\n }\n\n async getOrSet<T>(\n key: string,\n producer: () => Promise<T> | T,\n options: FarmCacheOptions = {},\n ): Promise<T> {\n const cached = await this.getEntryAsync<T>(key);\n if (cached) {\n return cached.value;\n }\n\n const inflight = this.inflight.get(key) as Promise<T> | undefined;\n if (inflight) {\n emitFarmEvent({ type: \"cache.dedupe\", key });\n return inflight;\n }\n\n const tags = Array.from(normalizeCacheOptionsTags(options));\n const generation = this.generation;\n const promise = this.fillCacheEntry(key, producer, options, tags, generation)\n .catch((error) => {\n emitFarmEvent({ type: \"cache.error\", key, operation: \"set\", error });\n throw error;\n })\n .finally(() => {\n if (this.inflight.get(key) === promise) {\n this.inflight.delete(key);\n }\n });\n\n this.inflight.set(key, promise);\n return promise;\n }\n\n private async fillCacheEntry<T>(\n key: string,\n producer: () => Promise<T> | T,\n options: FarmCacheOptions,\n tags: readonly string[],\n generation: number,\n ): Promise<T> {\n const adapter = this.adapter;\n const namespace = this.namespace;\n const lease = { ...this.lease };\n const leaseKey = `${namespace}:lease:${key}`;\n let leaseToken: string | null | undefined;\n\n if (adapter?.acquireLease && adapter.releaseLease && lease.enabled) {\n leaseToken = await adapter.acquireLease(leaseKey, lease.ttlMs);\n if (!leaseToken) {\n const shared = await this.waitForAdapterEntry<T>(\n key,\n adapter,\n namespace,\n lease,\n generation,\n );\n if (shared) {\n emitFarmEvent({ type: \"cache.dedupe\", key });\n return shared.value;\n }\n if (generation === this.generation) {\n leaseToken = await adapter.acquireLease(leaseKey, lease.ttlMs);\n }\n }\n }\n\n try {\n const initialCreatedVersion = this.version;\n const initialTagVersions = await this.getAdapterTagVersions(tags, adapter, namespace);\n const value = await producer();\n if (generation === this.generation) {\n await this.writeAsync(key, value, options, initialTagVersions, initialCreatedVersion);\n }\n return value;\n } finally {\n if (leaseToken && adapter?.releaseLease) {\n await adapter.releaseLease(leaseKey, leaseToken);\n }\n }\n }\n\n private async waitForAdapterEntry<T>(\n key: string,\n adapter: FarmCacheAdapter,\n namespace: string,\n lease: typeof this.lease,\n generation: number,\n ): Promise<FarmCacheEntry<T> | undefined> {\n const deadline = Date.now() + lease.waitTimeoutMs;\n while (Date.now() < deadline) {\n await delay(lease.pollIntervalMs);\n if (generation !== this.generation) return undefined;\n const entry = await adapter.get<T>(`${namespace}:entry:${key}`);\n if (generation !== this.generation) return undefined;\n if (!entry) {\n emitFarmEvent({ type: \"cache.miss\", key });\n continue;\n }\n assertFarmCacheEntry(entry, key);\n const stale = await this.isAdapterEntryStale(entry, Date.now(), adapter, namespace);\n if (generation !== this.generation) return undefined;\n if (stale) {\n emitFarmEvent({\n type: \"cache.stale\",\n key,\n tags: [...entry.tags],\n revalidate: entry.revalidate,\n });\n emitFarmEvent({ type: \"cache.miss\", key, reason: \"stale\" });\n } else {\n emitFarmEvent({\n type: \"cache.hit\",\n key,\n tags: [...entry.tags],\n revalidate: entry.revalidate,\n stale: false,\n });\n return { ...entry, key };\n }\n }\n return undefined;\n }\n\n private countEntriesForTag(tag: string): number {\n let count = 0;\n for (const entry of this.entries.values()) {\n if (entry.tags.has(tag)) {\n count++;\n }\n }\n return count;\n }\n\n private countEntriesForTags(tags: readonly string[]): number {\n let count = 0;\n for (const entry of this.entries.values()) {\n if (tags.every((tag) => entry.tags.has(tag))) {\n count++;\n }\n }\n return count;\n }\n\n private invalidateTag(normalizedTag: string): number {\n this.invalidatedTagVersions.set(normalizedTag, ++this.version);\n return this.countEntriesForTag(normalizedTag);\n }\n\n private toPublicEntry<T>(entry: InternalFarmCacheEntry<T>): FarmCacheEntry<T> {\n return {\n key: entry.key,\n value: entry.value,\n tags: Array.from(entry.tags),\n tagVersions: entry.tagVersions,\n createdAt: entry.createdAt,\n createdVersion: entry.createdVersion,\n revalidate: entry.revalidate,\n };\n }\n\n private hydrateLocalEntry<T>(entry: FarmCacheEntry<T>): void {\n this.entries.set(entry.key, {\n key: entry.key,\n value: entry.value,\n tags: new Set(entry.tags.map(normalizeCacheTag)),\n tagVersions: entry.tagVersions,\n createdAt: entry.createdAt,\n createdVersion: entry.createdVersion ?? ++this.version,\n revalidate: normalizeRevalidate(entry.revalidate),\n });\n }\n\n private createAdapterKey(key: string): string {\n return `${this.namespace}:entry:${key}`;\n }\n\n private createAdapterTag(tag: string): string {\n return `${this.namespace}:tag:${tag}`;\n }\n\n private async getAdapterTagVersions(\n tags: readonly string[],\n adapter = this.adapter,\n namespace = this.namespace,\n ): Promise<Readonly<Record<string, number>>> {\n if (!adapter?.getTagVersions || tags.length === 0) return {};\n\n const normalized = tags.map(normalizeCacheTag);\n const physicalTags = normalized.map((tag) => `${namespace}:tag:${tag}`);\n const versions = await adapter.getTagVersions(physicalTags);\n return Object.fromEntries(\n normalized.map((tag, index) => [\n tag,\n normalizeAdapterVersion(versions[physicalTags[index]!]),\n ]),\n );\n }\n\n private async isAdapterEntryStale(\n entry: FarmCacheEntry,\n now = Date.now(),\n adapter = this.adapter,\n namespace = this.namespace,\n ): Promise<boolean> {\n if (\n typeof entry.revalidate === \"number\" &&\n entry.revalidate >= 0 &&\n now - entry.createdAt >= entry.revalidate * 1000\n ) {\n return true;\n }\n\n const currentVersions = await this.getAdapterTagVersions(entry.tags, adapter, namespace);\n for (const tag of entry.tags) {\n if (\n normalizeAdapterVersion(currentVersions[tag]) >\n normalizeAdapterVersion(entry.tagVersions?.[tag])\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\nconst FARM_DATA_CACHE_SYMBOL = Symbol.for(\"farm.dataCache\");\nconst farmDataCacheGlobal = globalThis as typeof globalThis & {\n [FARM_DATA_CACHE_SYMBOL]?: FarmDataCache;\n};\nconst sharedFarmDataCache = (farmDataCacheGlobal[FARM_DATA_CACHE_SYMBOL] ??= new FarmDataCache());\n\nexport function getFarmDataCache(): FarmDataCache {\n return sharedFarmDataCache;\n}\n\nexport function configureFarmCache(config: FarmCacheUserConfig | undefined): void {\n sharedFarmDataCache.configure(config);\n}\n\n/**\n * Wrap an async function so its results are cached and shared across requests,\n * processes, and restarts.\n *\n * The cache key is built from the wrapped function's identity (its name and a\n * hash of its source), the active locale, `keyParts`, and the call arguments.\n * Deriving identity from the source — rather than the closure instance — is\n * deliberate: it keeps the key stable across processes and restarts so a\n * distributed cache adapter can share entries between server instances.\n *\n * The consequence is that two closures with **identical source text but\n * different captured variables** produce the same identity. Pass those captured\n * values in `keyParts` so they take part in the key; otherwise the closures\n * share a cache entry and return each other's data:\n *\n * ```ts\n * // Collides: both closures have identical source, and `table` is captured,\n * // not an argument, so it never reaches the key.\n * const makeLoader = (table: string) =>\n * unstable_cache(async (id: number) => db.get(table, id));\n *\n * // Correct: the captured value disambiguates the two closures.\n * const makeLoader = (table: string) =>\n * unstable_cache(async (id: number) => db.get(table, id), [table]);\n * ```\n *\n * Values passed as call arguments already participate in the key and do not\n * need to be repeated in `keyParts`.\n *\n * @param fn The async function to memoize.\n * @param keyParts Extra values that identify this call site. Include every\n * variable the function closes over that is not one of its arguments.\n * @param options Tags, paths, and revalidation settings for the cached entry.\n */\nexport function unstable_cache<Args extends unknown[], Result>(\n fn: (...args: Args) => Result | Promise<Result>,\n keyParts: readonly unknown[] = [],\n options: FarmCacheOptions = {},\n): (...args: Args) => Promise<Result> {\n return async (...args: Args): Promise<Result> => {\n const locale = getActiveFarmI18nSnapshot()?.locale;\n const key = createFarmCacheKey([\n \"unstable_cache\",\n getFunctionCacheIdentity(fn),\n locale ? [\"locale\", locale] : null,\n keyParts,\n args,\n ]);\n return getFarmDataCache().getOrSet<Result>(key, () => fn(...args), options);\n };\n}\n\n/**\n * Invalidate every cache entry carrying `tag`.\n *\n * Observability note: the `count` on the emitted `cache.revalidateTag` event is\n * derived from Farm's process-local entry tracking. With a shared `cache.adapter`\n * configured, entries live in the adapter rather than in local memory, so the\n * count can read as `0` even though the invalidation is still propagated to the\n * adapter and applied. Treat it as a best-effort signal, not a distributed count.\n */\nexport function revalidateTag(_tag: string, _profile?: RevalidateTagProfile): void | Promise<void> {\n const cache = getFarmDataCache();\n if (cache.hasAdapter) {\n const task = cache\n .revalidateTagAsync(_tag, {\n source: \"revalidateTag\",\n profile: _profile,\n })\n .then(() => undefined);\n notifyFarmCacheTask(task);\n return task;\n }\n cache.revalidateTag(_tag, {\n source: \"revalidateTag\",\n profile: _profile,\n });\n}\n\nexport function updateTag(tag: string): void | Promise<void> {\n const cache = getFarmDataCache();\n if (cache.hasAdapter) {\n const task = cache.revalidateTagAsync(tag, { source: \"updateTag\" }).then(() => undefined);\n notifyFarmCacheTask(task);\n return task;\n }\n cache.revalidateTag(tag, { source: \"updateTag\" });\n}\n\n/**\n * Invalidate cached data for a route path (and its PPR shell, if any).\n *\n * Observability note: the `count` on the emitted `cache.revalidatePath` event and\n * the `ppr.shell.invalidated` event are derived from process-local entry tracking.\n * With a shared `cache.adapter`, PPR shells live in the adapter rather than in\n * local memory, so the count can read as `0` and `ppr.shell.invalidated` may not\n * be emitted even though the invalidation is still propagated to the adapter and\n * applied.\n */\nexport function revalidatePath(routePath: string): void | Promise<void> {\n const cache = getFarmDataCache();\n if (cache.hasAdapter) {\n const task = cache.revalidatePathAsync(routePath).then(() => undefined);\n notifyFarmCacheTask(task);\n return task;\n }\n cache.revalidatePath(routePath);\n}\n\nexport function invalidate(key: RouteDataCacheKey): void | Promise<void> {\n const clientKey = createRouteDataCacheKey(key);\n const task = updateTag(createRouteDataCacheTag(key));\n notifyFarmCacheInvalidation(clientKey);\n return task;\n}\n\nexport function invalidateRouteData(key: RouteDataCacheKey): void | Promise<void> {\n return invalidate(key);\n}\n\n/**\n * Apply a normalized set of invalidation targets and return browser cache keys\n * that should be carried with an action/endpoint response.\n */\nexport async function applyFarmCacheInvalidationTargets(\n targets: readonly FarmCacheInvalidationTarget[],\n): Promise<readonly string[]> {\n if (!Array.isArray(targets)) {\n throw new TypeError(\"Cache invalidations must resolve to an array of targets.\");\n }\n\n const clientKeys: string[] = [];\n for (const target of targets) {\n assertFarmCacheInvalidationTarget(target);\n if (\"key\" in target) {\n await invalidate(target.key);\n clientKeys.push(createRouteDataCacheKey(target.key));\n } else if (\"path\" in target) {\n await revalidatePath(target.path);\n } else {\n await updateTag(target.tag);\n }\n }\n return Array.from(new Set(clientKeys));\n}\n\nexport function createPathCacheTag(routePath: string): string {\n return `path:${normalizeRevalidatePath(routePath)}`;\n}\n\nexport function createRouteDataCacheTag(key: RouteDataCacheKey): string {\n return `route-data:${createRouteDataCacheKey(key)}`;\n}\n\nexport function createRouteDataCacheKey(key: RouteDataCacheKey): string {\n return createFarmCacheKey(Array.isArray(key) ? key : [key]);\n}\n\nexport function normalizeRevalidatePath(routePath: string): string {\n if (typeof routePath !== \"string\") {\n throw new TypeError(\"revalidatePath expects a path string.\");\n }\n\n let normalized = routePath.trim();\n if (!normalized) {\n throw new Error(\"revalidatePath expects a non-empty path.\");\n }\n\n try {\n if (/^https?:\\/\\//i.test(normalized)) {\n normalized = new URL(normalized).pathname;\n }\n } catch {\n // Keep the original path if URL parsing fails.\n }\n\n normalized = normalized.split(/[?#]/, 1)[0] ?? normalized;\n normalized = normalized.startsWith(\"/\") ? normalized : `/${normalized}`;\n normalized = normalized.replace(/\\/{2,}/g, \"/\");\n if (normalized.length > 1) {\n normalized = normalized.replace(/\\/+$/, \"\");\n }\n return normalized || \"/\";\n}\n\nexport function createFarmCacheKey(parts: readonly unknown[]): string {\n return stableSerialize(parts);\n}\n\nfunction normalizeRevalidate(revalidate: number | false | undefined): number | false | undefined {\n if (revalidate === false || revalidate === undefined) {\n return revalidate;\n }\n if (!Number.isFinite(revalidate) || revalidate < 0) {\n return undefined;\n }\n // 0 is meaningful: the entry is stale immediately, i.e. always re-produced.\n return revalidate;\n}\n\nfunction normalizeCacheTag(tag: string): string {\n if (typeof tag !== \"string\") {\n throw new TypeError(\"Cache tags must be strings.\");\n }\n const normalized = tag.trim();\n if (!normalized) {\n throw new Error(\"Cache tags cannot be empty.\");\n }\n return normalized;\n}\n\nfunction normalizeCacheNamespace(namespace: string): string {\n if (typeof namespace !== \"string\") {\n throw new TypeError(\"Cache namespace must be a string.\");\n }\n const normalized = namespace.trim().replace(/:+$/g, \"\");\n if (!normalized) {\n throw new Error(\"Cache namespace cannot be empty.\");\n }\n return normalized;\n}\n\nfunction normalizeAdapterVersion(value: unknown): number {\n return typeof value === \"number\" && Number.isFinite(value) && value > 0 ? value : 0;\n}\n\nfunction normalizePositiveDuration(\n value: number | undefined,\n fallback: number,\n name: string,\n): number {\n if (value === undefined) return fallback;\n if (!Number.isFinite(value) || value <= 0) {\n throw new TypeError(`${name} must be a positive number of milliseconds.`);\n }\n return Math.floor(value);\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction normalizeCacheOptionsTags(options: FarmCacheOptions): Set<string> {\n const tags = new Set<string>();\n for (const tag of options.tags ?? []) {\n tags.add(normalizeCacheTag(tag));\n }\n for (const routePath of options.paths ?? []) {\n tags.add(createPathCacheTag(routePath));\n }\n return tags;\n}\n\nfunction assertFarmCacheEntry(\n entry: FarmCacheEntry,\n expectedKey: string,\n): asserts entry is FarmCacheEntry {\n if (\n !entry ||\n typeof entry !== \"object\" ||\n entry.key !== expectedKey ||\n !Array.isArray(entry.tags) ||\n typeof entry.createdAt !== \"number\"\n ) {\n throw new TypeError(\n `Cache adapter returned an invalid entry for ${JSON.stringify(expectedKey)}.`,\n );\n }\n}\n\nfunction assertFarmCacheInvalidationTarget(\n target: unknown,\n): asserts target is FarmCacheInvalidationTarget {\n if (!target || typeof target !== \"object\") {\n throw new TypeError(\"Cache invalidation targets must be { key }, { path }, or { tag }.\");\n }\n\n if (\"key\" in target) {\n const key = (target as { key?: unknown }).key;\n if (typeof key === \"string\" || Array.isArray(key)) return;\n } else if (\"path\" in target && typeof (target as { path?: unknown }).path === \"string\") {\n return;\n } else if (\"tag\" in target && typeof (target as { tag?: unknown }).tag === \"string\") {\n return;\n }\n\n throw new TypeError(\"Cache invalidation targets must contain a string/array key, path, or tag.\");\n}\n\nfunction getFunctionCacheIdentity(fn: Function): string {\n // The name alone collides across modules — two different functions both\n // named getUser would share cache entries. Include a hash of the source so\n // only genuinely identical functions share, and the identity stays stable\n // across processes and restarts.\n const name = fn.name || \"anonymous\";\n return `${name}:${hashFunctionSource(String(fn))}`;\n}\n\nfunction hashFunctionSource(source: string): string {\n // FNV-1a, 32-bit.\n let hash = 0x811c9dc5;\n for (let index = 0; index < source.length; index++) {\n hash ^= source.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n return (hash >>> 0).toString(36);\n}\n\nfunction compareCodepoint(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\nfunction serializeBinaryBytes(bytes: Uint8Array): string {\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nfunction stableSerialize(value: unknown, seen = new WeakSet<object>()): string {\n if (value === null) return \"null\";\n if (value === undefined) return \"undefined\";\n\n const valueType = typeof value;\n if (valueType === \"string\") return JSON.stringify(value);\n if (valueType === \"number\" || valueType === \"boolean\" || valueType === \"bigint\") {\n return `${valueType}:${String(value)}`;\n }\n if (valueType === \"symbol\") {\n return `symbol:${String(value)}`;\n }\n if (valueType === \"function\") {\n return `function:${getFunctionCacheIdentity(value as Function)}`;\n }\n\n if (value instanceof Date) {\n // toISOString throws on an Invalid Date. Key building must not throw on a\n // supported type, so all invalid dates share one stable marker and the\n // caller's own validation decides what to do with the input.\n return Number.isNaN(value.getTime()) ? \"date:invalid\" : `date:${value.toISOString()}`;\n }\n if (value instanceof URL) {\n return `url:${value.toString()}`;\n }\n if (value instanceof RegExp) {\n return `regexp:${value.toString()}`;\n }\n if (value instanceof ArrayBuffer) {\n return `arraybuffer:${serializeBinaryBytes(new Uint8Array(value))}`;\n }\n if (typeof SharedArrayBuffer !== \"undefined\" && value instanceof SharedArrayBuffer) {\n return `sharedarraybuffer:${serializeBinaryBytes(new Uint8Array(value))}`;\n }\n if (ArrayBuffer.isView(value)) {\n const viewType = Object.prototype.toString.call(value).slice(8, -1);\n const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n return `binary:${viewType}:${serializeBinaryBytes(bytes)}`;\n }\n\n if (value && typeof value === \"object\") {\n if (seen.has(value)) {\n return \"[Circular]\";\n }\n seen.add(value);\n\n if (Array.isArray(value)) {\n const items: string[] = [];\n for (let index = 0; index < value.length; index++) {\n items.push(\n Object.prototype.hasOwnProperty.call(value, index)\n ? stableSerialize(value[index], seen)\n : \"[Hole]\",\n );\n }\n seen.delete(value);\n return `[${items.join(\",\")}]`;\n }\n\n // Set and Map keep their contents internally, so Object.entries is empty\n // for both. Serialize the contents and sort them by codepoint so equal\n // contents give the same key regardless of insertion order.\n if (value instanceof Set) {\n const items = Array.from(value, (item) => stableSerialize(item, seen)).sort(compareCodepoint);\n seen.delete(value);\n return `set:[${items.join(\",\")}]`;\n }\n if (value instanceof Map) {\n const items = Array.from(\n value,\n ([key, item]) => `[${stableSerialize(key, seen)},${stableSerialize(item, seen)}]`,\n ).sort(compareCodepoint);\n seen.delete(value);\n return `map:[${items.join(\",\")}]`;\n }\n\n // Codepoint comparison, not localeCompare: the host locale must not\n // change how a \"stable\" key serializes, or invalidations computed on one\n // server can miss entries written by another.\n const entries = Object.entries(value as Record<string, unknown>).sort(([a], [b]) =>\n compareCodepoint(a, b),\n );\n const serialized = entries\n .map(([key, item]) => `${JSON.stringify(key)}:${stableSerialize(item, seen)}`)\n .join(\",\");\n\n seen.delete(value);\n return `{${serialized}}`;\n }\n\n return String(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuEO,SAAS,iBAAwB;AACtC,SAAO,CACL,YAC6C;AAC7C,QAAI,OAAO,YAAY,YAAY;AACjC,YAAM,IAAI,UAAU,gDAAgD;AAAA,IACtE;AAEA,YAAQ,IAAI,SAAqB;AAC/B,YAAM,MAAM,QAAQ,GAAG,IAAI;AAC3B,UAAI,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG,GAAG;AAClD,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAlBgB;AAmHT,SAAS,oBACd,SACA,UAA0C,CAAC,GACzB;AAClB,MAAI,CAAC,WAAW,OAAO,QAAQ,YAAY,cAAc,OAAO,QAAQ,YAAY,YAAY;AAC9F,UAAM,IAAI,UAAU,0DAA0D;AAAA,EAChF;AAEA,QAAM,OAAO,wBAAwB,QAAQ,QAAQ,YAAY;AACjE,QAAM,WAAW,wBAAC,QAAgB,GAAG,IAAI,UAAU,GAAG,IAArC;AACjB,QAAM,SAAS,wBAAC,QAAgB,GAAG,IAAI,QAAQ,GAAG,IAAnC;AAEf,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK,wBAAI,QAAgB,QAAQ,QAA2B,S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;AACvB,WAAK,OAAO,KAAK;AACjB,aAAO,QAAQ,MAAM,KAAK,GAAG,CAAC;AAAA,IAChC;AAKA,UAAM,UAAU,OAAO,QAAQ,KAAgC,EAAE;AAAA,MAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAC5E,iBAAiB,GAAG,CAAC;AAAA,IACvB;AACA,UAAM,aAAa,QAChB,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,GAAG,KAAK,UAAU,GAAG,CAAC,IAAI,gBAAgB,MAAM,IAAI,CAAC,EAAE,EAC5E,KAAK,GAAG;AAEX,SAAK,OAAO,KAAK;AACjB,WAAO,IAAI,UAAU;AAAA,EACvB;AAEA,SAAO,OAAO,KAAK;AACrB;AA3FS;","names":[]}
@@ -13,16 +13,29 @@ function getFarmCacheInvalidationState() {
13
13
  });
14
14
  }
15
15
  __name(getFarmCacheInvalidationState, "getFarmCacheInvalidationState");
16
+ function warnFarmCacheListenerError(scope, error) {
17
+ const detail = error instanceof Error ? error.stack ?? error.message : String(error);
18
+ console.warn(`[farm:cache] ${scope} listener failed: ${detail}`);
19
+ }
20
+ __name(warnFarmCacheListenerError, "warnFarmCacheListenerError");
16
21
  function notifyFarmCacheInvalidation(key) {
17
22
  if (typeof key !== "string" || key.length === 0) return;
18
23
  for (const listener of getFarmCacheInvalidationState().listeners) {
19
- listener(key);
24
+ try {
25
+ listener(key);
26
+ } catch (error) {
27
+ warnFarmCacheListenerError("invalidation", error);
28
+ }
20
29
  }
21
30
  }
22
31
  __name(notifyFarmCacheInvalidation, "notifyFarmCacheInvalidation");
23
32
  function notifyFarmCacheTask(task) {
24
33
  for (const listener of getFarmCacheInvalidationState().taskListeners) {
25
- listener(task);
34
+ try {
35
+ listener(task);
36
+ } catch (error) {
37
+ warnFarmCacheListenerError("task", error);
38
+ }
26
39
  }
27
40
  }
28
41
  __name(notifyFarmCacheTask, "notifyFarmCacheTask");
@@ -78,4 +91,4 @@ export {
78
91
  subscribeFarmCacheInvalidation,
79
92
  subscribeFarmCacheTask
80
93
  };
81
- //# sourceMappingURL=chunk-RBRLLZL5.mjs.map
94
+ //# sourceMappingURL=chunk-34IAPZBG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cache-invalidation.ts"],"sourcesContent":["export type FarmCacheInvalidationListener = (key: string) => void;\nexport type FarmCacheTaskListener = (task: Promise<void>) => void;\n\nexport const FARM_CACHE_INVALIDATION_HEADER = \"x-farm-cache-invalidations\";\n\ntype FarmCacheInvalidationState = {\n listeners: Set<FarmCacheInvalidationListener>;\n taskListeners: Set<FarmCacheTaskListener>;\n};\n\nconst FARM_CACHE_INVALIDATION_STATE = Symbol.for(\"farm.cacheInvalidationState\");\nconst globalState = globalThis as typeof globalThis & {\n [FARM_CACHE_INVALIDATION_STATE]?: FarmCacheInvalidationState;\n};\n\nfunction getFarmCacheInvalidationState(): FarmCacheInvalidationState {\n return (globalState[FARM_CACHE_INVALIDATION_STATE] ??= {\n listeners: new Set(),\n taskListeners: new Set(),\n });\n}\n\nfunction warnFarmCacheListenerError(scope: string, error: unknown): void {\n const detail = error instanceof Error ? (error.stack ?? error.message) : String(error);\n console.warn(`[farm:cache] ${scope} listener failed: ${detail}`);\n}\n\nexport function notifyFarmCacheInvalidation(key: string): void {\n if (typeof key !== \"string\" || key.length === 0) return;\n\n for (const listener of getFarmCacheInvalidationState().listeners) {\n // Isolate listeners: one throwing observer must not abort the remaining\n // listeners (or the rest of a multi-key batch in applyFarmCacheInvalidations)\n // and must not surface as a 500 when invalidation runs inside a request.\n try {\n listener(key);\n } catch (error) {\n warnFarmCacheListenerError(\"invalidation\", error);\n }\n }\n}\n\nexport function notifyFarmCacheTask(task: Promise<void>): void {\n for (const listener of getFarmCacheInvalidationState().taskListeners) {\n try {\n listener(task);\n } catch (error) {\n warnFarmCacheListenerError(\"task\", error);\n }\n }\n}\n\nexport function applyFarmCacheInvalidations(keys: unknown): void {\n if (!Array.isArray(keys)) return;\n\n for (const key of keys) {\n if (typeof key === \"string\") {\n notifyFarmCacheInvalidation(key);\n }\n }\n}\n\nexport function encodeFarmCacheInvalidations(keys: readonly string[]): string | null {\n const normalized = Array.from(\n new Set(keys.filter((key) => typeof key === \"string\" && key.length > 0)),\n );\n if (normalized.length === 0) return null;\n return encodeURIComponent(JSON.stringify(normalized));\n}\n\nexport function decodeFarmCacheInvalidations(value: string | null | undefined): readonly string[] {\n if (!value) return [];\n\n try {\n const parsed = JSON.parse(decodeURIComponent(value));\n return Array.isArray(parsed)\n ? Array.from(\n new Set(parsed.filter((key): key is string => typeof key === \"string\" && key.length > 0)),\n )\n : [];\n } catch {\n return [];\n }\n}\n\nexport function subscribeFarmCacheInvalidation(\n listener: FarmCacheInvalidationListener,\n): () => void {\n const state = getFarmCacheInvalidationState();\n state.listeners.add(listener);\n return () => state.listeners.delete(listener);\n}\n\nexport function subscribeFarmCacheTask(listener: FarmCacheTaskListener): () => void {\n const state = getFarmCacheInvalidationState();\n state.taskListeners.add(listener);\n return () => state.taskListeners.delete(listener);\n}\n"],"mappings":";;;;;AAGO,IAAM,iCAAiC;AAO9C,IAAM,gCAAgC,uBAAO,IAAI,6BAA6B;AAC9E,IAAM,cAAc;AAIpB,SAAS,gCAA4D;AACnE,SAAQ,4FAA+C;AAAA,IACrD,WAAW,oBAAI,IAAI;AAAA,IACnB,eAAe,oBAAI,IAAI;AAAA,EACzB;AACF;AALS;AAOT,SAAS,2BAA2B,OAAe,OAAsB;AACvE,QAAM,SAAS,iBAAiB,QAAS,MAAM,SAAS,MAAM,UAAW,OAAO,KAAK;AACrF,UAAQ,KAAK,gBAAgB,KAAK,qBAAqB,MAAM,EAAE;AACjE;AAHS;AAKF,SAAS,4BAA4B,KAAmB;AAC7D,MAAI,OAAO,QAAQ,YAAY,IAAI,WAAW,EAAG;AAEjD,aAAW,YAAY,8BAA8B,EAAE,WAAW;AAIhE,QAAI;AACF,eAAS,GAAG;AAAA,IACd,SAAS,OAAO;AACd,iCAA2B,gBAAgB,KAAK;AAAA,I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AAM,cAAc,OAAO,QAAQ;AAClD;AAJgB;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  subscribeFarmCacheInvalidation,
6
6
  subscribeFarmCacheTask
7
- } from "./chunk-RBRLLZL5.mjs";
7
+ } from "./chunk-34IAPZBG.mjs";
8
8
  import {
9
9
  __name
10
10
  } from "./chunk-CGILA3WO.mjs";
@@ -499,4 +499,4 @@ export {
499
499
  getServerActionSignal,
500
500
  getServerActionInvalidations
501
501
  };
502
- //# sourceMappingURL=chunk-VV24CC42.mjs.map
502
+ //# sourceMappingURL=chunk-35NPLKQJ.mjs.map