@farm.js/core 0.1.0-beta.95 → 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 (317) 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 +7 -7
  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 +5 -5
  13. package/dist/api.cjs +352 -109
  14. package/dist/api.d.mts +7 -6
  15. package/dist/api.d.ts +7 -6
  16. package/dist/api.mjs +19 -12
  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-D7QH7MDU.mjs → chunk-3TWQERDE.mjs} +5 -4
  31. package/dist/chunk-3TWQERDE.mjs.map +1 -0
  32. package/dist/{chunk-RWYRFCLG.mjs → chunk-4X57GXQA.mjs} +2 -2
  33. package/dist/{chunk-KOTSX5JH.mjs → chunk-52BR7LTX.mjs} +30 -21
  34. package/dist/chunk-52BR7LTX.mjs.map +1 -0
  35. package/dist/{chunk-SALMKQXH.mjs → chunk-6EJHNHH4.mjs} +80 -27
  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-FLHLPB57.mjs → chunk-D7F7YZ7L.mjs} +93 -67
  43. package/dist/chunk-D7F7YZ7L.mjs.map +1 -0
  44. package/dist/chunk-DU3PKDVQ.mjs +35 -0
  45. package/dist/chunk-DU3PKDVQ.mjs.map +1 -0
  46. package/dist/{chunk-SCFX4UTD.mjs → chunk-EHTUKVSW.mjs} +1 -1
  47. package/dist/chunk-EHTUKVSW.mjs.map +1 -0
  48. package/dist/{chunk-KWCNQUH5.mjs → chunk-EPDIF432.mjs} +526 -50
  49. package/dist/chunk-EPDIF432.mjs.map +1 -0
  50. package/dist/{chunk-A3636IHN.mjs → chunk-FP5Q67FO.mjs} +167 -96
  51. package/dist/chunk-FP5Q67FO.mjs.map +1 -0
  52. package/dist/{chunk-HHZAOTQD.mjs → chunk-GJ7W6LNK.mjs} +7 -6
  53. package/dist/chunk-GJ7W6LNK.mjs.map +1 -0
  54. package/dist/{chunk-RLGUZ3HS.mjs → chunk-I3OOUWO5.mjs} +3 -3
  55. package/dist/{chunk-75CGAL6E.mjs → chunk-IZBX2TEU.mjs} +217 -105
  56. package/dist/chunk-IZBX2TEU.mjs.map +1 -0
  57. package/dist/{chunk-22VG4DFJ.mjs → chunk-J3MPQ4MQ.mjs} +2 -2
  58. package/dist/{chunk-22VG4DFJ.mjs.map → chunk-J3MPQ4MQ.mjs.map} +1 -1
  59. package/dist/{chunk-2LS3KKE7.mjs → chunk-JV7JUD7Q.mjs} +4 -4
  60. package/dist/{chunk-Q3OX763A.mjs → chunk-LXDASSTE.mjs} +2 -2
  61. package/dist/{chunk-ZRBCBOEX.mjs → chunk-N2FY2QZ7.mjs} +28 -3
  62. package/dist/chunk-N2FY2QZ7.mjs.map +1 -0
  63. package/dist/{chunk-MRVJCLYQ.mjs → chunk-PSQ7N4XP.mjs} +4 -2
  64. package/dist/chunk-PSQ7N4XP.mjs.map +1 -0
  65. package/dist/{chunk-HVG3HLQZ.mjs → chunk-Q7WGOOAI.mjs} +3 -3
  66. package/dist/{chunk-WTYAPO5I.mjs → chunk-RCNWMEBT.mjs} +3 -2
  67. package/dist/{chunk-WTYAPO5I.mjs.map → chunk-RCNWMEBT.mjs.map} +1 -1
  68. package/dist/{chunk-3INDBMUU.mjs → chunk-TGDIACZT.mjs} +2 -2
  69. package/dist/{chunk-WB75GIX2.mjs → chunk-TQTB33JS.mjs} +14 -3
  70. package/dist/chunk-TQTB33JS.mjs.map +1 -0
  71. package/dist/{chunk-MH27UH72.mjs → chunk-TT3E2JOF.mjs} +3 -3
  72. package/dist/{chunk-UWRGX3J3.mjs → chunk-UMUWR5XA.mjs} +2 -2
  73. package/dist/{chunk-XTLLHCWU.mjs → chunk-V4VRLVLW.mjs} +52 -31
  74. package/dist/chunk-V4VRLVLW.mjs.map +1 -0
  75. package/dist/{chunk-EXCGBERG.mjs → chunk-WD2EBM3I.mjs} +79 -17
  76. package/dist/chunk-WD2EBM3I.mjs.map +1 -0
  77. package/dist/{chunk-DLBUAJTK.mjs → chunk-WMJGA32P.mjs} +74 -5
  78. package/dist/chunk-WMJGA32P.mjs.map +1 -0
  79. package/dist/{chunk-TKQCJMY7.mjs → chunk-X4SFHKFH.mjs} +7 -4
  80. package/dist/{chunk-TKQCJMY7.mjs.map → chunk-X4SFHKFH.mjs.map} +1 -1
  81. package/dist/{chunk-Q7GPJZCO.mjs → chunk-YIBV77KZ.mjs} +26 -7
  82. package/dist/chunk-YIBV77KZ.mjs.map +1 -0
  83. package/dist/client/lifecycle.mjs +2 -2
  84. package/dist/{client-mcMC334J.d.mts → client-DWoLZ3QU.d.mts} +52 -5
  85. package/dist/{client-d5ONQ-Pd.d.ts → client-DuQuQC1h.d.ts} +52 -5
  86. package/dist/client-cache-BMxuFqwH.d.ts +18 -0
  87. package/dist/client-cache-CCK-fCe0.d.mts +18 -0
  88. package/dist/{client-plugins-BvClItiL.d.mts → client-plugins-B6-07YmP.d.mts} +52 -99
  89. package/dist/{client-plugins-B9Sq-iMg.d.ts → client-plugins-By6MVUX-.d.ts} +52 -99
  90. package/dist/client-plugins.cjs +1 -1
  91. package/dist/client-plugins.d.mts +3 -2
  92. package/dist/client-plugins.d.ts +3 -2
  93. package/dist/client-plugins.mjs +2 -2
  94. package/dist/client.cjs +1046 -211
  95. package/dist/client.d.mts +136 -18
  96. package/dist/client.d.ts +136 -18
  97. package/dist/client.mjs +32 -15
  98. package/dist/config.d.mts +3 -2
  99. package/dist/config.d.ts +3 -2
  100. package/dist/{devtools-S52RRRMN.mjs → devtools-XWZX6CCL.mjs} +5 -5
  101. package/dist/{devtools-client-3XRTBND5.mjs → devtools-client-Z7QQA3Q2.mjs} +56 -17
  102. package/dist/devtools-client-Z7QQA3Q2.mjs.map +1 -0
  103. package/dist/{devtools-ui-NJKFORTG.mjs → devtools-ui-2HG5M4EL.mjs} +3 -1
  104. package/dist/devtools-ui-2HG5M4EL.mjs.map +1 -0
  105. package/dist/docs.cjs +24 -5
  106. package/dist/docs.mjs +5 -5
  107. package/dist/i18n/server.cjs +13 -2
  108. package/dist/i18n/server.d.mts +2 -2
  109. package/dist/i18n/server.d.ts +2 -2
  110. package/dist/i18n/server.mjs +1 -1
  111. package/dist/index.cjs +1928 -894
  112. package/dist/index.d.mts +139 -21
  113. package/dist/index.d.ts +139 -21
  114. package/dist/index.mjs +57 -34
  115. package/dist/index.mjs.map +1 -1
  116. package/dist/integration-api-BT024nuJ.d.mts +97 -0
  117. package/dist/integration-api-BT024nuJ.d.ts +97 -0
  118. package/dist/integrations.d.mts +3 -2
  119. package/dist/integrations.d.ts +3 -2
  120. package/dist/internal/build-runtime.cjs +764 -547
  121. package/dist/internal/build-runtime.d.mts +5 -4
  122. package/dist/internal/build-runtime.d.ts +5 -4
  123. package/dist/internal/build-runtime.mjs +16 -16
  124. package/dist/internal/client-runtime.cjs +1 -1
  125. package/dist/internal/client-runtime.mjs +2 -2
  126. package/dist/internal/config-runtime.cjs +4 -1
  127. package/dist/internal/config-runtime.d.mts +4 -3
  128. package/dist/internal/config-runtime.d.ts +4 -3
  129. package/dist/internal/config-runtime.mjs +4 -4
  130. package/dist/internal/product-telemetry-runtime.cjs +1 -1
  131. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  132. package/dist/internal/production-runtime.cjs +29 -3
  133. package/dist/internal/production-runtime.d.mts +8 -7
  134. package/dist/internal/production-runtime.d.ts +8 -7
  135. package/dist/internal/production-runtime.mjs +5 -5
  136. package/dist/{metadata-route-yV4U6X8h.d.ts → metadata-route-8_V3UonT.d.ts} +1 -1
  137. package/dist/{metadata-route-p4K1l92V.d.mts → metadata-route-CWP_HjGU.d.mts} +1 -1
  138. package/dist/middleware.cjs +28 -2
  139. package/dist/middleware.d.mts +5 -4
  140. package/dist/middleware.d.ts +5 -4
  141. package/dist/middleware.mjs +4 -4
  142. package/dist/navigation.cjs +3 -1
  143. package/dist/navigation.mjs +3 -3
  144. package/dist/observability.cjs +27 -2
  145. package/dist/observability.mjs +1 -1
  146. package/dist/plugin.cjs +528 -349
  147. package/dist/plugin.d.mts +3 -2
  148. package/dist/plugin.d.ts +3 -2
  149. package/dist/plugin.mjs +13 -13
  150. package/dist/{production-runtime-IkB0Qj4i.d.mts → production-runtime-BGRH1dKG.d.mts} +1 -1
  151. package/dist/{production-runtime-0JTch4_d.d.ts → production-runtime-CdmzsDax.d.ts} +1 -1
  152. package/dist/query/client.cjs +68 -29
  153. package/dist/query/client.mjs +69 -30
  154. package/dist/query/client.mjs.map +1 -1
  155. package/dist/{render-plan-Dc8CjNI7.d.ts → render-plan-0GeHiGVZ.d.ts} +1 -1
  156. package/dist/{render-plan-CU31j-Jk.d.mts → render-plan-DLxJYAA5.d.mts} +1 -1
  157. package/dist/renderer-client.cjs +169 -26
  158. package/dist/renderer-client.d.mts +7 -6
  159. package/dist/renderer-client.d.ts +7 -6
  160. package/dist/renderer-client.mjs +16 -19
  161. package/dist/renderer-client.mjs.map +1 -1
  162. package/dist/{request-BXa1KY8i.d.mts → request-BCNXSXLh.d.mts} +1 -1
  163. package/dist/{request-CUUBujZt.d.ts → request-BstWbZ6O.d.ts} +1 -1
  164. package/dist/request.d.mts +4 -3
  165. package/dist/request.d.ts +4 -3
  166. package/dist/{route-Y8lfz1wF.d.ts → route-4pd-EVtw.d.ts} +45 -50
  167. package/dist/{route-Cq3aObmj.d.mts → route-CvEr4Uc9.d.mts} +45 -50
  168. package/dist/routes.cjs +27 -2
  169. package/dist/routes.d.mts +3 -2
  170. package/dist/routes.d.ts +3 -2
  171. package/dist/routes.mjs +4 -4
  172. package/dist/{runtime-j1S3sDTh.d.ts → runtime-BgDQzBiu.d.ts} +1 -0
  173. package/dist/{runtime-DDwvDtS4.d.mts → runtime-CV2UCV-5.d.mts} +1 -0
  174. package/dist/server-action-security.mjs +2 -2
  175. package/dist/server-fn-client.cjs +102 -26
  176. package/dist/server-fn-client.d.mts +6 -0
  177. package/dist/server-fn-client.d.ts +6 -0
  178. package/dist/server-fn-client.mjs +2 -1
  179. package/dist/server-fn.cjs +42 -4
  180. package/dist/server-fn.mjs +5 -5
  181. package/dist/server-plugins.d.mts +4 -3
  182. package/dist/server-plugins.d.ts +4 -3
  183. package/dist/server-query-client.cjs +195 -34
  184. package/dist/server-query-client.d.mts +3 -3
  185. package/dist/server-query-client.d.ts +3 -3
  186. package/dist/server-query-client.mjs +7 -7
  187. package/dist/{server-query-runtime-3zAj77yv.d.ts → server-query-runtime-DXRNhX_3.d.ts} +2 -0
  188. package/dist/{server-query-runtime-B50KAcj5.d.mts → server-query-runtime-aP52iuL5.d.mts} +2 -0
  189. package/dist/server-query.cjs +44 -5
  190. package/dist/server-query.d.mts +4 -0
  191. package/dist/server-query.d.ts +4 -0
  192. package/dist/server-query.mjs +7 -7
  193. package/dist/server.cjs +553 -370
  194. package/dist/server.d.mts +11 -10
  195. package/dist/server.d.ts +11 -10
  196. package/dist/server.mjs +17 -17
  197. package/dist/{spa-router-CyLkwst6.d.mts → spa-router-BeyAVSc6.d.mts} +1 -1
  198. package/dist/{spa-router-BkqGXaV_.d.ts → spa-router-COgu4txb.d.ts} +1 -1
  199. package/dist/testing.cjs +27 -2
  200. package/dist/testing.d.mts +3 -2
  201. package/dist/testing.d.ts +3 -2
  202. package/dist/testing.mjs +9 -9
  203. package/dist/{utils-NKR6SoNv.d.mts → utils-DL2VwDQl.d.mts} +1 -1
  204. package/dist/{utils-B2OHrb9F.d.ts → utils-DkU2c_1B.d.ts} +1 -1
  205. package/dist/version.cjs +1 -1
  206. package/dist/version.mjs +1 -1
  207. package/dist/vite.cjs +536 -353
  208. package/dist/vite.d.mts +3 -2
  209. package/dist/vite.d.ts +3 -2
  210. package/dist/vite.mjs +17 -13
  211. package/package.json +17 -17
  212. package/types/client.d.ts +115 -10
  213. package/dist/agent-runtime.cjs.map +0 -1
  214. package/dist/api/route-manager.cjs.map +0 -1
  215. package/dist/api/runtime.cjs.map +0 -1
  216. package/dist/api.cjs.map +0 -1
  217. package/dist/app-markdown.cjs.map +0 -1
  218. package/dist/cache.cjs.map +0 -1
  219. package/dist/chunk-75CGAL6E.mjs.map +0 -1
  220. package/dist/chunk-7MABZJIM.mjs.map +0 -1
  221. package/dist/chunk-A3636IHN.mjs.map +0 -1
  222. package/dist/chunk-AXVJCMVF.mjs.map +0 -1
  223. package/dist/chunk-D7QH7MDU.mjs.map +0 -1
  224. package/dist/chunk-DLBUAJTK.mjs.map +0 -1
  225. package/dist/chunk-EXCGBERG.mjs.map +0 -1
  226. package/dist/chunk-FLHLPB57.mjs.map +0 -1
  227. package/dist/chunk-HHZAOTQD.mjs.map +0 -1
  228. package/dist/chunk-KOTSX5JH.mjs.map +0 -1
  229. package/dist/chunk-KWCNQUH5.mjs.map +0 -1
  230. package/dist/chunk-MRVJCLYQ.mjs.map +0 -1
  231. package/dist/chunk-Q7GPJZCO.mjs.map +0 -1
  232. package/dist/chunk-RBRLLZL5.mjs.map +0 -1
  233. package/dist/chunk-SALMKQXH.mjs.map +0 -1
  234. package/dist/chunk-SCFX4UTD.mjs.map +0 -1
  235. package/dist/chunk-WB75GIX2.mjs.map +0 -1
  236. package/dist/chunk-XTLLHCWU.mjs.map +0 -1
  237. package/dist/chunk-ZFNK77WN.mjs.map +0 -1
  238. package/dist/chunk-ZRBCBOEX.mjs.map +0 -1
  239. package/dist/client/lifecycle.cjs.map +0 -1
  240. package/dist/client-cache-CopR_MaI.d.mts +0 -6
  241. package/dist/client-cache-Djy_TlE8.d.ts +0 -6
  242. package/dist/client-plugins.cjs.map +0 -1
  243. package/dist/client.cjs.map +0 -1
  244. package/dist/config.cjs.map +0 -1
  245. package/dist/cron.cjs.map +0 -1
  246. package/dist/deferred.cjs.map +0 -1
  247. package/dist/deployment.cjs.map +0 -1
  248. package/dist/devtools-client-3XRTBND5.mjs.map +0 -1
  249. package/dist/devtools-ui-NJKFORTG.mjs.map +0 -1
  250. package/dist/docs.cjs.map +0 -1
  251. package/dist/env-types.cjs.map +0 -1
  252. package/dist/env.cjs.map +0 -1
  253. package/dist/environment/vite.cjs.map +0 -1
  254. package/dist/environment.cjs.map +0 -1
  255. package/dist/font.cjs.map +0 -1
  256. package/dist/headers.cjs.map +0 -1
  257. package/dist/i18n/client.cjs.map +0 -1
  258. package/dist/i18n/index.cjs.map +0 -1
  259. package/dist/i18n/server.cjs.map +0 -1
  260. package/dist/image/server.cjs.map +0 -1
  261. package/dist/image/sharp.cjs.map +0 -1
  262. package/dist/image.cjs.map +0 -1
  263. package/dist/index.cjs.map +0 -1
  264. package/dist/instrumentation.cjs.map +0 -1
  265. package/dist/integrations.cjs.map +0 -1
  266. package/dist/internal/build-runtime.cjs.map +0 -1
  267. package/dist/internal/client-runtime.cjs.map +0 -1
  268. package/dist/internal/config-runtime.cjs.map +0 -1
  269. package/dist/internal/isolated-boundary.cjs.map +0 -1
  270. package/dist/internal/metadata-image-runtime.cjs.map +0 -1
  271. package/dist/internal/product-telemetry-runtime.cjs.map +0 -1
  272. package/dist/internal/production-node-env.cjs.map +0 -1
  273. package/dist/internal/production-runtime.cjs.map +0 -1
  274. package/dist/markdown.cjs.map +0 -1
  275. package/dist/middleware.cjs.map +0 -1
  276. package/dist/navigation.cjs.map +0 -1
  277. package/dist/observability.cjs.map +0 -1
  278. package/dist/plugin.cjs.map +0 -1
  279. package/dist/query/client.cjs.map +0 -1
  280. package/dist/query/index.cjs.map +0 -1
  281. package/dist/query/parsers.cjs.map +0 -1
  282. package/dist/query/server.cjs.map +0 -1
  283. package/dist/renderer/react/client.cjs.map +0 -1
  284. package/dist/renderer/react/server.cjs.map +0 -1
  285. package/dist/renderer/react/vite.cjs.map +0 -1
  286. package/dist/renderer-client.cjs.map +0 -1
  287. package/dist/renderer.cjs.map +0 -1
  288. package/dist/request.cjs.map +0 -1
  289. package/dist/router.cjs.map +0 -1
  290. package/dist/routes.cjs.map +0 -1
  291. package/dist/server-action-security.cjs.map +0 -1
  292. package/dist/server-fn-client.cjs.map +0 -1
  293. package/dist/server-fn.cjs.map +0 -1
  294. package/dist/server-plugins.cjs.map +0 -1
  295. package/dist/server-query-client.cjs.map +0 -1
  296. package/dist/server-query.cjs.map +0 -1
  297. package/dist/server.cjs.map +0 -1
  298. package/dist/storage.cjs.map +0 -1
  299. package/dist/testing.cjs.map +0 -1
  300. package/dist/theme/client.cjs.map +0 -1
  301. package/dist/theme/index.cjs.map +0 -1
  302. package/dist/theme/runtime.cjs.map +0 -1
  303. package/dist/theme/server.cjs.map +0 -1
  304. package/dist/version.cjs.map +0 -1
  305. package/dist/vite.cjs.map +0 -1
  306. package/dist/workflows.cjs.map +0 -1
  307. /package/dist/{chunk-VV24CC42.mjs.map → chunk-35NPLKQJ.mjs.map} +0 -0
  308. /package/dist/{chunk-RWYRFCLG.mjs.map → chunk-4X57GXQA.mjs.map} +0 -0
  309. /package/dist/{chunk-MOW47IF5.mjs.map → chunk-6UYVU46O.mjs.map} +0 -0
  310. /package/dist/{chunk-RLGUZ3HS.mjs.map → chunk-I3OOUWO5.mjs.map} +0 -0
  311. /package/dist/{chunk-2LS3KKE7.mjs.map → chunk-JV7JUD7Q.mjs.map} +0 -0
  312. /package/dist/{chunk-Q3OX763A.mjs.map → chunk-LXDASSTE.mjs.map} +0 -0
  313. /package/dist/{chunk-HVG3HLQZ.mjs.map → chunk-Q7WGOOAI.mjs.map} +0 -0
  314. /package/dist/{chunk-3INDBMUU.mjs.map → chunk-TGDIACZT.mjs.map} +0 -0
  315. /package/dist/{chunk-MH27UH72.mjs.map → chunk-TT3E2JOF.mjs.map} +0 -0
  316. /package/dist/{chunk-UWRGX3J3.mjs.map → chunk-UMUWR5XA.mjs.map} +0 -0
  317. /package/dist/{devtools-S52RRRMN.mjs.map → devtools-XWZX6CCL.mjs.map} +0 -0
package/dist/plugin.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- export { Z as PluginRoutes, P as PluginRoutesFactory, W as RouteDefinition } from './route-Cq3aObmj.mjs';
2
- export { bs as APIHandlerLifecyclePayload, bo as APIRouteDiscoveredPayload, bv as BundleLifecyclePayload, B as BundleResultPayload, bt as ErrorLifecyclePayload, ec as FARM_NODE_RESPONSE_END_PENDING, a as FarmPlugin, bi as FarmPluginBuildHooks, bk as FarmPluginClientConfig, aX as FarmPluginContext, bj as FarmPluginDevHooks, bf as FarmPluginDiscoveredRoute, aY as FarmPluginIntegrationContext, aZ as FarmPluginLifecycle, bh as FarmPluginRenderHooks, b1 as FarmPluginRouteRuntimePayload, bg as FarmPluginRouterHooks, b7 as FarmPluginRuntimeAfterEvent, b4 as FarmPluginRuntimeBaseEvent, b6 as FarmPluginRuntimeBeforeEvent, ba as FarmPluginRuntimeCloseEvent, b5 as FarmPluginRuntimeContextEvent, b8 as FarmPluginRuntimeErrorEvent, bb as FarmPluginRuntimeHooks, b0 as FarmPluginRuntimeKind, bd as FarmPluginRuntimeRequestHandler, bc as FarmPluginRuntimeRequestOptions, be as FarmPluginRuntimeSession, b9 as FarmPluginRuntimeStartEvent, b2 as FarmPluginSetupContext, b3 as FarmPluginStateContext, a_ as FarmRequestPluginContext, a$ as FarmRequestStore, aw as FarmRuntimeShutdownError, bu as HMRUpdatePayload, bn as MiddlewareDiscoveredPayload, bw as NitroBuildLifecyclePayload, ax as PluginManager, aW as PluginRequestContext, br as RenderLifecyclePayload, bl as RouteDiscoveredPayload, bp as RouteMatchPayload, bq as RouteMatchResultPayload, bm as RoutesGeneratedPayload, bx as ShutdownPayload, av as definePlugin, s as farmPlugin } from './client-plugins-BvClItiL.mjs';
1
+ export { Z as PluginRoutes, P as PluginRoutesFactory, W as RouteDefinition } from './route-CvEr4Uc9.mjs';
2
+ export { bq as APIHandlerLifecyclePayload, bm as APIRouteDiscoveredPayload, bt as BundleLifecyclePayload, B as BundleResultPayload, br as ErrorLifecyclePayload, e4 as FARM_NODE_RESPONSE_END_PENDING, a as FarmPlugin, bg as FarmPluginBuildHooks, bi as FarmPluginClientConfig, aV as FarmPluginContext, bh as FarmPluginDevHooks, bd as FarmPluginDiscoveredRoute, aW as FarmPluginIntegrationContext, aX as FarmPluginLifecycle, bf as FarmPluginRenderHooks, a$ as FarmPluginRouteRuntimePayload, be as FarmPluginRouterHooks, b5 as FarmPluginRuntimeAfterEvent, b2 as FarmPluginRuntimeBaseEvent, b4 as FarmPluginRuntimeBeforeEvent, b8 as FarmPluginRuntimeCloseEvent, b3 as FarmPluginRuntimeContextEvent, b6 as FarmPluginRuntimeErrorEvent, b9 as FarmPluginRuntimeHooks, a_ as FarmPluginRuntimeKind, bb as FarmPluginRuntimeRequestHandler, ba as FarmPluginRuntimeRequestOptions, bc as FarmPluginRuntimeSession, b7 as FarmPluginRuntimeStartEvent, b0 as FarmPluginSetupContext, b1 as FarmPluginStateContext, aY as FarmRequestPluginContext, aZ as FarmRequestStore, au as FarmRuntimeShutdownError, bs as HMRUpdatePayload, bl as MiddlewareDiscoveredPayload, bu as NitroBuildLifecyclePayload, av as PluginManager, aU as PluginRequestContext, bp as RenderLifecyclePayload, bj as RouteDiscoveredPayload, bn as RouteMatchPayload, bo as RouteMatchResultPayload, bk as RoutesGeneratedPayload, bv as ShutdownPayload, at as definePlugin, s as farmPlugin } from './client-plugins-B6-07YmP.mjs';
3
3
  import 'vite';
4
4
  import './lifecycle-De0vQG45.mjs';
5
5
  import './env.mjs';
@@ -10,6 +10,7 @@ import './types-Cc8l9IqS.mjs';
10
10
  import 'db0';
11
11
  import 'unstorage';
12
12
  import 'react';
13
+ import './integration-api-BT024nuJ.mjs';
13
14
  import '@farming-labs/orm';
14
15
  import './types-CKwggz9n.mjs';
15
16
  import '@farming-labs/docs';
package/dist/plugin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { Z as PluginRoutes, P as PluginRoutesFactory, W as RouteDefinition } from './route-Y8lfz1wF.js';
2
- export { bs as APIHandlerLifecyclePayload, bo as APIRouteDiscoveredPayload, bv as BundleLifecyclePayload, B as BundleResultPayload, bt as ErrorLifecyclePayload, ec as FARM_NODE_RESPONSE_END_PENDING, a as FarmPlugin, bi as FarmPluginBuildHooks, bk as FarmPluginClientConfig, aX as FarmPluginContext, bj as FarmPluginDevHooks, bf as FarmPluginDiscoveredRoute, aY as FarmPluginIntegrationContext, aZ as FarmPluginLifecycle, bh as FarmPluginRenderHooks, b1 as FarmPluginRouteRuntimePayload, bg as FarmPluginRouterHooks, b7 as FarmPluginRuntimeAfterEvent, b4 as FarmPluginRuntimeBaseEvent, b6 as FarmPluginRuntimeBeforeEvent, ba as FarmPluginRuntimeCloseEvent, b5 as FarmPluginRuntimeContextEvent, b8 as FarmPluginRuntimeErrorEvent, bb as FarmPluginRuntimeHooks, b0 as FarmPluginRuntimeKind, bd as FarmPluginRuntimeRequestHandler, bc as FarmPluginRuntimeRequestOptions, be as FarmPluginRuntimeSession, b9 as FarmPluginRuntimeStartEvent, b2 as FarmPluginSetupContext, b3 as FarmPluginStateContext, a_ as FarmRequestPluginContext, a$ as FarmRequestStore, aw as FarmRuntimeShutdownError, bu as HMRUpdatePayload, bn as MiddlewareDiscoveredPayload, bw as NitroBuildLifecyclePayload, ax as PluginManager, aW as PluginRequestContext, br as RenderLifecyclePayload, bl as RouteDiscoveredPayload, bp as RouteMatchPayload, bq as RouteMatchResultPayload, bm as RoutesGeneratedPayload, bx as ShutdownPayload, av as definePlugin, s as farmPlugin } from './client-plugins-B9Sq-iMg.js';
1
+ export { Z as PluginRoutes, P as PluginRoutesFactory, W as RouteDefinition } from './route-4pd-EVtw.js';
2
+ export { bq as APIHandlerLifecyclePayload, bm as APIRouteDiscoveredPayload, bt as BundleLifecyclePayload, B as BundleResultPayload, br as ErrorLifecyclePayload, e4 as FARM_NODE_RESPONSE_END_PENDING, a as FarmPlugin, bg as FarmPluginBuildHooks, bi as FarmPluginClientConfig, aV as FarmPluginContext, bh as FarmPluginDevHooks, bd as FarmPluginDiscoveredRoute, aW as FarmPluginIntegrationContext, aX as FarmPluginLifecycle, bf as FarmPluginRenderHooks, a$ as FarmPluginRouteRuntimePayload, be as FarmPluginRouterHooks, b5 as FarmPluginRuntimeAfterEvent, b2 as FarmPluginRuntimeBaseEvent, b4 as FarmPluginRuntimeBeforeEvent, b8 as FarmPluginRuntimeCloseEvent, b3 as FarmPluginRuntimeContextEvent, b6 as FarmPluginRuntimeErrorEvent, b9 as FarmPluginRuntimeHooks, a_ as FarmPluginRuntimeKind, bb as FarmPluginRuntimeRequestHandler, ba as FarmPluginRuntimeRequestOptions, bc as FarmPluginRuntimeSession, b7 as FarmPluginRuntimeStartEvent, b0 as FarmPluginSetupContext, b1 as FarmPluginStateContext, aY as FarmRequestPluginContext, aZ as FarmRequestStore, au as FarmRuntimeShutdownError, bs as HMRUpdatePayload, bl as MiddlewareDiscoveredPayload, bu as NitroBuildLifecyclePayload, av as PluginManager, aU as PluginRequestContext, bp as RenderLifecyclePayload, bj as RouteDiscoveredPayload, bn as RouteMatchPayload, bo as RouteMatchResultPayload, bk as RoutesGeneratedPayload, bv as ShutdownPayload, at as definePlugin, s as farmPlugin } from './client-plugins-By6MVUX-.js';
3
3
  import 'vite';
4
4
  import './lifecycle-De0vQG45.js';
5
5
  import './env.js';
@@ -10,6 +10,7 @@ import './types-Cc8l9IqS.js';
10
10
  import 'db0';
11
11
  import 'unstorage';
12
12
  import 'react';
13
+ import './integration-api-BT024nuJ.js';
13
14
  import '@farming-labs/orm';
14
15
  import './types-CKwggz9n.js';
15
16
  import '@farming-labs/docs';
package/dist/plugin.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  PluginManager,
5
5
  definePlugin,
6
6
  farmPlugin
7
- } from "./chunk-A3636IHN.mjs";
7
+ } from "./chunk-FP5Q67FO.mjs";
8
8
  import "./chunk-YVPFZ2TK.mjs";
9
9
  import "./chunk-KDP5ZSWP.mjs";
10
10
  import "./chunk-WQDQCTC5.mjs";
@@ -16,7 +16,7 @@ import "./chunk-USWZZUEH.mjs";
16
16
  import "./chunk-USLFXFFH.mjs";
17
17
  import "./chunk-CG4GPK3Z.mjs";
18
18
  import "./chunk-YKAUAZA4.mjs";
19
- import "./chunk-7MABZJIM.mjs";
19
+ import "./chunk-7PYVLJ4J.mjs";
20
20
  import "./chunk-7T2QYWDH.mjs";
21
21
  import "./chunk-5EZRXIFH.mjs";
22
22
  import "./chunk-7ZVN3YZI.mjs";
@@ -27,19 +27,19 @@ import "./chunk-A5VG2BDG.mjs";
27
27
  import "./chunk-EUYRVVXL.mjs";
28
28
  import "./chunk-2SKCXYLB.mjs";
29
29
  import "./chunk-BZAIS65C.mjs";
30
- import "./chunk-VV24CC42.mjs";
30
+ import "./chunk-35NPLKQJ.mjs";
31
31
  import "./chunk-N2KC75H7.mjs";
32
32
  import "./chunk-H53KVQUU.mjs";
33
33
  import "./chunk-QKVUNGAH.mjs";
34
34
  import "./chunk-AAC66ILR.mjs";
35
35
  import "./chunk-ISSFLGJ5.mjs";
36
- import "./chunk-RWYRFCLG.mjs";
36
+ import "./chunk-4X57GXQA.mjs";
37
37
  import "./chunk-IGOLMCE3.mjs";
38
38
  import "./chunk-YUE4CJNB.mjs";
39
- import "./chunk-ZFNK77WN.mjs";
40
- import "./chunk-MH27UH72.mjs";
39
+ import "./chunk-6JNGOC37.mjs";
40
+ import "./chunk-TT3E2JOF.mjs";
41
41
  import "./chunk-NXV52RNX.mjs";
42
- import "./chunk-WB75GIX2.mjs";
42
+ import "./chunk-TQTB33JS.mjs";
43
43
  import "./chunk-STV7A2LH.mjs";
44
44
  import "./chunk-XNWHZQ6A.mjs";
45
45
  import "./chunk-SXWF4QRU.mjs";
@@ -48,7 +48,7 @@ import "./chunk-LBRRZEEK.mjs";
48
48
  import "./chunk-HAG2HEDU.mjs";
49
49
  import "./chunk-VFPFBYG5.mjs";
50
50
  import "./chunk-35SSRS5K.mjs";
51
- import "./chunk-D7QH7MDU.mjs";
51
+ import "./chunk-3TWQERDE.mjs";
52
52
  import "./chunk-4OAR7CTF.mjs";
53
53
  import "./chunk-O2IGROSM.mjs";
54
54
  import "./chunk-4N7DAFLY.mjs";
@@ -57,17 +57,17 @@ import "./chunk-RCNUKRBF.mjs";
57
57
  import "./chunk-GQVQESLY.mjs";
58
58
  import "./chunk-HKXMMPYI.mjs";
59
59
  import "./chunk-YECMFULZ.mjs";
60
- import "./chunk-XTLLHCWU.mjs";
60
+ import "./chunk-V4VRLVLW.mjs";
61
61
  import "./chunk-6YPPIPKR.mjs";
62
62
  import "./chunk-776TTMU3.mjs";
63
63
  import "./chunk-3BXGOVKE.mjs";
64
64
  import "./chunk-4C3Z34O7.mjs";
65
- import "./chunk-AXVJCMVF.mjs";
66
- import "./chunk-RBRLLZL5.mjs";
65
+ import "./chunk-2HDOV47R.mjs";
66
+ import "./chunk-34IAPZBG.mjs";
67
67
  import "./chunk-WZ5QFROO.mjs";
68
- import "./chunk-ZRBCBOEX.mjs";
68
+ import "./chunk-N2FY2QZ7.mjs";
69
69
  import "./chunk-FXG2PS27.mjs";
70
- import "./chunk-22VG4DFJ.mjs";
70
+ import "./chunk-J3MPQ4MQ.mjs";
71
71
  import "./chunk-PHN22XB2.mjs";
72
72
  import "./chunk-XYTDSPBD.mjs";
73
73
  import "./chunk-OMQWEX4N.mjs";
@@ -1,4 +1,4 @@
1
- import { ad as ReadonlyMiddlewareStore, ae as FarmMiddlewareConfig, af as MiddlewareModule } from './client-plugins-BvClItiL.mjs';
1
+ import { ad as ReadonlyMiddlewareStore, ae as FarmMiddlewareConfig, af as MiddlewareModule } from './client-plugins-B6-07YmP.mjs';
2
2
  import { R as ResolvedFarmI18nConfig } from './types-CnH8DOqo.mjs';
3
3
  import { R as ResolvedFarmServerConfig } from './workflows-ChyK_oTu.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { ad as ReadonlyMiddlewareStore, ae as FarmMiddlewareConfig, af as MiddlewareModule } from './client-plugins-B9Sq-iMg.js';
1
+ import { ad as ReadonlyMiddlewareStore, ae as FarmMiddlewareConfig, af as MiddlewareModule } from './client-plugins-By6MVUX-.js';
2
2
  import { R as ResolvedFarmI18nConfig } from './types-CnH8DOqo.js';
3
3
  import { R as ResolvedFarmServerConfig } from './workflows-ChyK_oTu.js';
4
4
 
@@ -457,7 +457,14 @@ __name(createParser, "createParser");
457
457
 
458
458
  // src/query/client.ts
459
459
  var getCurrentSearchParams = /* @__PURE__ */ __name(() => {
460
- if (typeof window !== "undefined") return new URLSearchParams(window.location.search);
460
+ if (typeof window !== "undefined") {
461
+ discardDepartedURLUpdates();
462
+ let params = new URLSearchParams(window.location.search);
463
+ for (const pending of throttleTimers.values()) {
464
+ if (pending.href === window.location.href) params = applyChange(params, pending.updates);
465
+ }
466
+ return params;
467
+ }
461
468
  const request = _resolveCurrentRequest();
462
469
  if (!request) return new URLSearchParams();
463
470
  try {
@@ -471,10 +478,28 @@ var readSearchParam = /* @__PURE__ */ __name((searchParams, key) => {
471
478
  return values.length > 1 ? values.join(",") : values[0] ?? "";
472
479
  }, "readSearchParam");
473
480
  var throttleTimers = /* @__PURE__ */ new Map();
481
+ function discardDepartedURLUpdates() {
482
+ for (const [key, pending] of throttleTimers) {
483
+ if (pending.href === window.location.href) continue;
484
+ clearTimeout(pending.timer);
485
+ throttleTimers.delete(key);
486
+ }
487
+ }
488
+ __name(discardDepartedURLUpdates, "discardDepartedURLUpdates");
474
489
  function getUpdateKey(updates) {
475
490
  return JSON.stringify(Object.keys(updates).sort());
476
491
  }
477
492
  __name(getUpdateKey, "getUpdateKey");
493
+ function supersedeQueuedKeys(updates) {
494
+ const keys = Object.keys(updates);
495
+ for (const [queueKey, pending] of throttleTimers) {
496
+ for (const key of keys) delete pending.updates[key];
497
+ if (Object.keys(pending.updates).length > 0) continue;
498
+ clearTimeout(pending.timer);
499
+ throttleTimers.delete(queueKey);
500
+ }
501
+ }
502
+ __name(supersedeQueuedKeys, "supersedeQueuedKeys");
478
503
  var compareStructuredValues = /* @__PURE__ */ __name((current, next, seen = /* @__PURE__ */ new WeakMap()) => {
479
504
  if (Object.is(current, next)) return true;
480
505
  if (current === null || next === null || typeof current !== typeof next) return false;
@@ -554,8 +579,10 @@ var commitURLUpdate = /* @__PURE__ */ __name((updates, options, emitUpdate) => {
554
579
  window.history[history](nextHistoryState, "", newUrl);
555
580
  }
556
581
  if (emitUpdate) {
557
- const actualSearchParams = new URLSearchParams(window.location.search);
558
- emitter.emitUpdate(actualSearchParams);
582
+ for (const pending of throttleTimers.values()) {
583
+ if (pending.href === url.href) pending.href = window.location.href;
584
+ }
585
+ emitter.emitUpdate(getCurrentSearchParams());
559
586
  }
560
587
  if (shallow) notifyHistoryChange("url-search");
561
588
  if (scroll) {
@@ -564,31 +591,30 @@ var commitURLUpdate = /* @__PURE__ */ __name((updates, options, emitUpdate) => {
564
591
  }, "commitURLUpdate");
565
592
  var updateURL = /* @__PURE__ */ __name((updates, options = {}, emitUpdate = true) => {
566
593
  if (typeof window === "undefined") return;
594
+ discardDepartedURLUpdates();
567
595
  const { throttleMs } = options;
596
+ supersedeQueuedKeys(updates);
568
597
  if (!throttleMs || throttleMs <= 0) {
569
598
  commitURLUpdate(updates, options, emitUpdate);
570
599
  return;
571
600
  }
572
601
  const throttleKey = getUpdateKey(updates);
573
- const existingTimeout = throttleTimers.get(throttleKey);
574
- if (existingTimeout) {
575
- clearTimeout(existingTimeout);
576
- throttleTimers.delete(throttleKey);
577
- }
578
602
  const currentUrl = new URL(window.location.href);
579
603
  const nextSearch = applyChange(currentUrl.searchParams, updates).toString();
580
604
  if (nextSearch === currentUrl.searchParams.toString()) return;
581
605
  const timeout = setTimeout(() => {
582
- if (throttleTimers.get(throttleKey) === timeout) {
583
- throttleTimers.delete(throttleKey);
584
- }
606
+ const pending = throttleTimers.get(throttleKey);
607
+ if (pending?.timer !== timeout) return;
608
+ throttleTimers.delete(throttleKey);
609
+ if (pending.href !== window.location.href) return;
585
610
  commitURLUpdate(updates, options, emitUpdate);
586
611
  }, throttleMs);
587
- throttleTimers.set(throttleKey, timeout);
612
+ throttleTimers.set(throttleKey, { timer: timeout, updates, href: currentUrl.href });
588
613
  return () => {
589
- if (throttleTimers.get(throttleKey) !== timeout) return;
614
+ if (throttleTimers.get(throttleKey)?.timer !== timeout) return false;
590
615
  clearTimeout(timeout);
591
616
  throttleTimers.delete(throttleKey);
617
+ return true;
592
618
  };
593
619
  }, "updateURL");
594
620
  function useQueryState(key, parser, options) {
@@ -599,21 +625,16 @@ function useQueryState(key, parser, options) {
599
625
  });
600
626
  const stateRef = (0, import_react.useRef)(state);
601
627
  const stateKeyRef = (0, import_react.useRef)(key);
602
- const isInternalUpdateRef = (0, import_react.useRef)(false);
603
628
  const cancelPendingUpdateRef = (0, import_react.useRef)(void 0);
604
629
  stateRef.current = state;
605
630
  const setValue = (0, import_react.useCallback)(
606
631
  (value) => {
607
- isInternalUpdateRef.current = true;
608
632
  setState(value);
609
633
  stateRef.current = value;
610
634
  const serialized = value === null ? null : parser.serialize(value);
611
- emitter.emitKey(key, { state: value, query: serialized });
635
+ emitter.emitKey(key, { state: value, query: serialized, source: stateRef });
612
636
  cancelPendingUpdateRef.current?.();
613
637
  cancelPendingUpdateRef.current = updateURL({ [key]: serialized }, options, true);
614
- setTimeout(() => {
615
- isInternalUpdateRef.current = false;
616
- }, 10);
617
638
  },
618
639
  [key, parser, options]
619
640
  );
@@ -630,9 +651,6 @@ function useQueryState(key, parser, options) {
630
651
  }
631
652
  }, "onPopState");
632
653
  const onEmitterUpdate = /* @__PURE__ */ __name((searchParams) => {
633
- if (isInternalUpdateRef.current) {
634
- return;
635
- }
636
654
  const parsed = parser.parse(readSearchParam(searchParams, key));
637
655
  if (!areParsedValuesEqual(parser, stateRef.current, parsed)) {
638
656
  setState(parsed);
@@ -640,12 +658,13 @@ function useQueryState(key, parser, options) {
640
658
  }
641
659
  }, "onEmitterUpdate");
642
660
  const onKeyUpdate = /* @__PURE__ */ __name((payload) => {
643
- if (isInternalUpdateRef.current) {
661
+ if (payload.source === stateRef) {
644
662
  return;
645
663
  }
646
- if (!areParsedValuesEqual(parser, stateRef.current, payload.state)) {
647
- setState(payload.state);
648
- stateRef.current = payload.state;
664
+ const parsed = parser.parse(payload.query ?? "");
665
+ if (!areParsedValuesEqual(parser, stateRef.current, parsed)) {
666
+ setState(parsed);
667
+ stateRef.current = parsed;
649
668
  }
650
669
  }, "onKeyUpdate");
651
670
  onPopState();
@@ -660,8 +679,11 @@ function useQueryState(key, parser, options) {
660
679
  }, [key, parser]);
661
680
  (0, import_react.useEffect)(
662
681
  () => () => {
663
- cancelPendingUpdateRef.current?.();
682
+ const canceledPendingWrite = cancelPendingUpdateRef.current?.() ?? false;
664
683
  cancelPendingUpdateRef.current = void 0;
684
+ if (canceledPendingWrite && typeof window !== "undefined") {
685
+ emitter.emitUpdate(getCurrentSearchParams());
686
+ }
665
687
  },
666
688
  [key]
667
689
  );
@@ -691,7 +713,7 @@ function useQueryStates(parsers, options = {}) {
691
713
  const parser = parsers[key];
692
714
  if (parser) {
693
715
  const serialized = value === null ? null : parser.serialize(value);
694
- emitter.emitKey(key, { state: value, query: serialized });
716
+ emitter.emitKey(key, { state: value, query: serialized, source: stateRef });
695
717
  }
696
718
  });
697
719
  const urlUpdates = {};
@@ -742,17 +764,34 @@ function useQueryStates(parsers, options = {}) {
742
764
  applyChange2(getCurrentSearchParams());
743
765
  const unsubscribeHistory = subscribeHistoryChange(onPopState);
744
766
  emitter.on("update", onEmitterUpdate);
767
+ const unsubscribeKeys = Object.entries(parsers).map(([key, parser]) => {
768
+ const onKeyUpdate = /* @__PURE__ */ __name((payload) => {
769
+ if (payload.source === stateRef) return;
770
+ const parsed = parser.parse(payload.query ?? "");
771
+ if (areParsedValuesEqual(parser, stateRef.current[key], parsed)) return;
772
+ const next = { ...stateRef.current, [key]: parsed };
773
+ stateRef.current = next;
774
+ setState(next);
775
+ }, "onKeyUpdate");
776
+ emitter.onKey(key, onKeyUpdate);
777
+ return () => emitter.offKey(key, onKeyUpdate);
778
+ });
745
779
  return () => {
746
780
  unsubscribeHistory();
747
781
  emitter.off("update", onEmitterUpdate);
782
+ for (const unsubscribe of unsubscribeKeys) unsubscribe();
748
783
  };
749
784
  }, [watchKeys, parsers]);
750
785
  (0, import_react.useEffect)(
751
786
  () => () => {
787
+ let canceledPendingWrite = false;
752
788
  for (const cancelPendingUpdate of pendingUpdatesRef.current.values()) {
753
- cancelPendingUpdate();
789
+ if (cancelPendingUpdate()) canceledPendingWrite = true;
754
790
  }
755
791
  pendingUpdatesRef.current.clear();
792
+ if (canceledPendingWrite && typeof window !== "undefined") {
793
+ emitter.emitUpdate(getCurrentSearchParams());
794
+ }
756
795
  },
757
796
  [watchKeys]
758
797
  );
@@ -17,7 +17,7 @@ import {
17
17
  notifyHistoryChange,
18
18
  subscribeHistoryChange,
19
19
  writeFarmURLSearchHistory
20
- } from "../chunk-MRVJCLYQ.mjs";
20
+ } from "../chunk-PSQ7N4XP.mjs";
21
21
  import "../chunk-ULD4ENAH.mjs";
22
22
  import "../chunk-JIT7GXDP.mjs";
23
23
  import "../chunk-3BXGOVKE.mjs";
@@ -98,7 +98,14 @@ var emitter = new Emitter();
98
98
 
99
99
  // src/query/client.ts
100
100
  var getCurrentSearchParams = /* @__PURE__ */ __name(() => {
101
- if (typeof window !== "undefined") return new URLSearchParams(window.location.search);
101
+ if (typeof window !== "undefined") {
102
+ discardDepartedURLUpdates();
103
+ let params = new URLSearchParams(window.location.search);
104
+ for (const pending of throttleTimers.values()) {
105
+ if (pending.href === window.location.href) params = applyChange(params, pending.updates);
106
+ }
107
+ return params;
108
+ }
102
109
  const request = _resolveCurrentRequest();
103
110
  if (!request) return new URLSearchParams();
104
111
  try {
@@ -112,10 +119,28 @@ var readSearchParam = /* @__PURE__ */ __name((searchParams, key) => {
112
119
  return values.length > 1 ? values.join(",") : values[0] ?? "";
113
120
  }, "readSearchParam");
114
121
  var throttleTimers = /* @__PURE__ */ new Map();
122
+ function discardDepartedURLUpdates() {
123
+ for (const [key, pending] of throttleTimers) {
124
+ if (pending.href === window.location.href) continue;
125
+ clearTimeout(pending.timer);
126
+ throttleTimers.delete(key);
127
+ }
128
+ }
129
+ __name(discardDepartedURLUpdates, "discardDepartedURLUpdates");
115
130
  function getUpdateKey(updates) {
116
131
  return JSON.stringify(Object.keys(updates).sort());
117
132
  }
118
133
  __name(getUpdateKey, "getUpdateKey");
134
+ function supersedeQueuedKeys(updates) {
135
+ const keys = Object.keys(updates);
136
+ for (const [queueKey, pending] of throttleTimers) {
137
+ for (const key of keys) delete pending.updates[key];
138
+ if (Object.keys(pending.updates).length > 0) continue;
139
+ clearTimeout(pending.timer);
140
+ throttleTimers.delete(queueKey);
141
+ }
142
+ }
143
+ __name(supersedeQueuedKeys, "supersedeQueuedKeys");
119
144
  var compareStructuredValues = /* @__PURE__ */ __name((current, next, seen = /* @__PURE__ */ new WeakMap()) => {
120
145
  if (Object.is(current, next)) return true;
121
146
  if (current === null || next === null || typeof current !== typeof next) return false;
@@ -195,8 +220,10 @@ var commitURLUpdate = /* @__PURE__ */ __name((updates, options, emitUpdate) => {
195
220
  window.history[history](nextHistoryState, "", newUrl);
196
221
  }
197
222
  if (emitUpdate) {
198
- const actualSearchParams = new URLSearchParams(window.location.search);
199
- emitter.emitUpdate(actualSearchParams);
223
+ for (const pending of throttleTimers.values()) {
224
+ if (pending.href === url.href) pending.href = window.location.href;
225
+ }
226
+ emitter.emitUpdate(getCurrentSearchParams());
200
227
  }
201
228
  if (shallow) notifyHistoryChange("url-search");
202
229
  if (scroll) {
@@ -205,31 +232,30 @@ var commitURLUpdate = /* @__PURE__ */ __name((updates, options, emitUpdate) => {
205
232
  }, "commitURLUpdate");
206
233
  var updateURL = /* @__PURE__ */ __name((updates, options = {}, emitUpdate = true) => {
207
234
  if (typeof window === "undefined") return;
235
+ discardDepartedURLUpdates();
208
236
  const { throttleMs } = options;
237
+ supersedeQueuedKeys(updates);
209
238
  if (!throttleMs || throttleMs <= 0) {
210
239
  commitURLUpdate(updates, options, emitUpdate);
211
240
  return;
212
241
  }
213
242
  const throttleKey = getUpdateKey(updates);
214
- const existingTimeout = throttleTimers.get(throttleKey);
215
- if (existingTimeout) {
216
- clearTimeout(existingTimeout);
217
- throttleTimers.delete(throttleKey);
218
- }
219
243
  const currentUrl = new URL(window.location.href);
220
244
  const nextSearch = applyChange(currentUrl.searchParams, updates).toString();
221
245
  if (nextSearch === currentUrl.searchParams.toString()) return;
222
246
  const timeout = setTimeout(() => {
223
- if (throttleTimers.get(throttleKey) === timeout) {
224
- throttleTimers.delete(throttleKey);
225
- }
247
+ const pending = throttleTimers.get(throttleKey);
248
+ if (pending?.timer !== timeout) return;
249
+ throttleTimers.delete(throttleKey);
250
+ if (pending.href !== window.location.href) return;
226
251
  commitURLUpdate(updates, options, emitUpdate);
227
252
  }, throttleMs);
228
- throttleTimers.set(throttleKey, timeout);
253
+ throttleTimers.set(throttleKey, { timer: timeout, updates, href: currentUrl.href });
229
254
  return () => {
230
- if (throttleTimers.get(throttleKey) !== timeout) return;
255
+ if (throttleTimers.get(throttleKey)?.timer !== timeout) return false;
231
256
  clearTimeout(timeout);
232
257
  throttleTimers.delete(throttleKey);
258
+ return true;
233
259
  };
234
260
  }, "updateURL");
235
261
  function useQueryState(key, parser, options) {
@@ -240,21 +266,16 @@ function useQueryState(key, parser, options) {
240
266
  });
241
267
  const stateRef = useRef(state);
242
268
  const stateKeyRef = useRef(key);
243
- const isInternalUpdateRef = useRef(false);
244
269
  const cancelPendingUpdateRef = useRef(void 0);
245
270
  stateRef.current = state;
246
271
  const setValue = useCallback(
247
272
  (value) => {
248
- isInternalUpdateRef.current = true;
249
273
  setState(value);
250
274
  stateRef.current = value;
251
275
  const serialized = value === null ? null : parser.serialize(value);
252
- emitter.emitKey(key, { state: value, query: serialized });
276
+ emitter.emitKey(key, { state: value, query: serialized, source: stateRef });
253
277
  cancelPendingUpdateRef.current?.();
254
278
  cancelPendingUpdateRef.current = updateURL({ [key]: serialized }, options, true);
255
- setTimeout(() => {
256
- isInternalUpdateRef.current = false;
257
- }, 10);
258
279
  },
259
280
  [key, parser, options]
260
281
  );
@@ -271,9 +292,6 @@ function useQueryState(key, parser, options) {
271
292
  }
272
293
  }, "onPopState");
273
294
  const onEmitterUpdate = /* @__PURE__ */ __name((searchParams) => {
274
- if (isInternalUpdateRef.current) {
275
- return;
276
- }
277
295
  const parsed = parser.parse(readSearchParam(searchParams, key));
278
296
  if (!areParsedValuesEqual(parser, stateRef.current, parsed)) {
279
297
  setState(parsed);
@@ -281,12 +299,13 @@ function useQueryState(key, parser, options) {
281
299
  }
282
300
  }, "onEmitterUpdate");
283
301
  const onKeyUpdate = /* @__PURE__ */ __name((payload) => {
284
- if (isInternalUpdateRef.current) {
302
+ if (payload.source === stateRef) {
285
303
  return;
286
304
  }
287
- if (!areParsedValuesEqual(parser, stateRef.current, payload.state)) {
288
- setState(payload.state);
289
- stateRef.current = payload.state;
305
+ const parsed = parser.parse(payload.query ?? "");
306
+ if (!areParsedValuesEqual(parser, stateRef.current, parsed)) {
307
+ setState(parsed);
308
+ stateRef.current = parsed;
290
309
  }
291
310
  }, "onKeyUpdate");
292
311
  onPopState();
@@ -301,8 +320,11 @@ function useQueryState(key, parser, options) {
301
320
  }, [key, parser]);
302
321
  useEffect(
303
322
  () => () => {
304
- cancelPendingUpdateRef.current?.();
323
+ const canceledPendingWrite = cancelPendingUpdateRef.current?.() ?? false;
305
324
  cancelPendingUpdateRef.current = void 0;
325
+ if (canceledPendingWrite && typeof window !== "undefined") {
326
+ emitter.emitUpdate(getCurrentSearchParams());
327
+ }
306
328
  },
307
329
  [key]
308
330
  );
@@ -332,7 +354,7 @@ function useQueryStates(parsers, options = {}) {
332
354
  const parser = parsers[key];
333
355
  if (parser) {
334
356
  const serialized = value === null ? null : parser.serialize(value);
335
- emitter.emitKey(key, { state: value, query: serialized });
357
+ emitter.emitKey(key, { state: value, query: serialized, source: stateRef });
336
358
  }
337
359
  });
338
360
  const urlUpdates = {};
@@ -383,17 +405,34 @@ function useQueryStates(parsers, options = {}) {
383
405
  applyChange2(getCurrentSearchParams());
384
406
  const unsubscribeHistory = subscribeHistoryChange(onPopState);
385
407
  emitter.on("update", onEmitterUpdate);
408
+ const unsubscribeKeys = Object.entries(parsers).map(([key, parser]) => {
409
+ const onKeyUpdate = /* @__PURE__ */ __name((payload) => {
410
+ if (payload.source === stateRef) return;
411
+ const parsed = parser.parse(payload.query ?? "");
412
+ if (areParsedValuesEqual(parser, stateRef.current[key], parsed)) return;
413
+ const next = { ...stateRef.current, [key]: parsed };
414
+ stateRef.current = next;
415
+ setState(next);
416
+ }, "onKeyUpdate");
417
+ emitter.onKey(key, onKeyUpdate);
418
+ return () => emitter.offKey(key, onKeyUpdate);
419
+ });
386
420
  return () => {
387
421
  unsubscribeHistory();
388
422
  emitter.off("update", onEmitterUpdate);
423
+ for (const unsubscribe of unsubscribeKeys) unsubscribe();
389
424
  };
390
425
  }, [watchKeys, parsers]);
391
426
  useEffect(
392
427
  () => () => {
428
+ let canceledPendingWrite = false;
393
429
  for (const cancelPendingUpdate of pendingUpdatesRef.current.values()) {
394
- cancelPendingUpdate();
430
+ if (cancelPendingUpdate()) canceledPendingWrite = true;
395
431
  }
396
432
  pendingUpdatesRef.current.clear();
433
+ if (canceledPendingWrite && typeof window !== "undefined") {
434
+ emitter.emitUpdate(getCurrentSearchParams());
435
+ }
397
436
  },
398
437
  [watchKeys]
399
438
  );