@tanstack/query-core 5.101.4 → 5.102.1

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 (370) hide show
  1. package/build/legacy/classPrivateFieldSet2-Bo0ZyOIv.cjs +56 -0
  2. package/build/legacy/classPrivateFieldSet2-CV7wyte-.js +27 -0
  3. package/build/legacy/classPrivateMethodInitSpec-CBwa_Y7C.js +7 -0
  4. package/build/legacy/classPrivateMethodInitSpec-DVhcLejn.cjs +12 -0
  5. package/build/legacy/environmentManager.cjs +25 -46
  6. package/build/legacy/environmentManager.cjs.map +1 -1
  7. package/build/legacy/environmentManager.d.cts +18 -2
  8. package/build/legacy/environmentManager.d.cts.map +1 -0
  9. package/build/legacy/environmentManager.d.ts +18 -2
  10. package/build/legacy/environmentManager.d.ts.map +1 -0
  11. package/build/legacy/environmentManager.js +23 -22
  12. package/build/legacy/environmentManager.js.map +1 -1
  13. package/build/legacy/focusManager.cjs +63 -104
  14. package/build/legacy/focusManager.cjs.map +1 -1
  15. package/build/legacy/focusManager.d.cts +18 -2
  16. package/build/legacy/focusManager.d.cts.map +1 -0
  17. package/build/legacy/focusManager.d.ts +18 -2
  18. package/build/legacy/focusManager.d.ts.map +1 -0
  19. package/build/legacy/focusManager.js +60 -76
  20. package/build/legacy/focusManager.js.map +1 -1
  21. package/build/legacy/hydration-BhSbkfZj.d.cts +1374 -0
  22. package/build/legacy/hydration-BhSbkfZj.d.cts.map +1 -0
  23. package/build/legacy/hydration-Hebl6yHM.d.ts +1374 -0
  24. package/build/legacy/hydration-Hebl6yHM.d.ts.map +1 -0
  25. package/build/legacy/hydration.cjs +111 -194
  26. package/build/legacy/hydration.cjs.map +1 -1
  27. package/build/legacy/hydration.d.cts +2 -7
  28. package/build/legacy/hydration.d.ts +2 -7
  29. package/build/legacy/hydration.js +105 -167
  30. package/build/legacy/hydration.js.map +1 -1
  31. package/build/legacy/index.cjs +59 -111
  32. package/build/legacy/index.cjs.map +1 -1
  33. package/build/legacy/index.d.cts +10 -141
  34. package/build/legacy/index.d.ts +10 -141
  35. package/build/legacy/index.js +16 -66
  36. package/build/legacy/index.js.map +1 -1
  37. package/build/legacy/infiniteQueryBehavior.cjs +92 -135
  38. package/build/legacy/infiniteQueryBehavior.cjs.map +1 -1
  39. package/build/legacy/infiniteQueryBehavior.d.cts +14 -3
  40. package/build/legacy/infiniteQueryBehavior.d.cts.map +1 -0
  41. package/build/legacy/infiniteQueryBehavior.d.ts +14 -3
  42. package/build/legacy/infiniteQueryBehavior.d.ts.map +1 -0
  43. package/build/legacy/infiniteQueryBehavior.js +89 -115
  44. package/build/legacy/infiniteQueryBehavior.js.map +1 -1
  45. package/build/legacy/infiniteQueryObserver.cjs +59 -88
  46. package/build/legacy/infiniteQueryObserver.cjs.map +1 -1
  47. package/build/legacy/infiniteQueryObserver.d.cts +20 -1
  48. package/build/legacy/infiniteQueryObserver.d.cts.map +1 -0
  49. package/build/legacy/infiniteQueryObserver.d.ts +20 -1
  50. package/build/legacy/infiniteQueryObserver.d.ts.map +1 -0
  51. package/build/legacy/infiniteQueryObserver.js +57 -64
  52. package/build/legacy/infiniteQueryObserver.js.map +1 -1
  53. package/build/legacy/mutation.cjs +236 -329
  54. package/build/legacy/mutation.cjs.map +1 -1
  55. package/build/legacy/mutation.d.cts +2 -4
  56. package/build/legacy/mutation.d.ts +2 -4
  57. package/build/legacy/mutation.js +231 -299
  58. package/build/legacy/mutation.js.map +1 -1
  59. package/build/legacy/mutationCache.cjs +121 -166
  60. package/build/legacy/mutationCache.cjs.map +1 -1
  61. package/build/legacy/mutationCache.d.cts +2 -2
  62. package/build/legacy/mutationCache.d.ts +2 -2
  63. package/build/legacy/mutationCache.js +117 -130
  64. package/build/legacy/mutationCache.js.map +1 -1
  65. package/build/legacy/mutationObserver.cjs +134 -187
  66. package/build/legacy/mutationObserver.cjs.map +1 -1
  67. package/build/legacy/mutationObserver.d.cts +2 -1
  68. package/build/legacy/mutationObserver.d.ts +2 -1
  69. package/build/legacy/mutationObserver.js +132 -160
  70. package/build/legacy/mutationObserver.js.map +1 -1
  71. package/build/legacy/notifyManager.cjs +76 -110
  72. package/build/legacy/notifyManager.cjs.map +1 -1
  73. package/build/legacy/notifyManager.d.cts +48 -3
  74. package/build/legacy/notifyManager.d.cts.map +1 -0
  75. package/build/legacy/notifyManager.d.ts +48 -3
  76. package/build/legacy/notifyManager.d.ts.map +1 -0
  77. package/build/legacy/notifyManager.js +73 -84
  78. package/build/legacy/notifyManager.js.map +1 -1
  79. package/build/legacy/onlineManager.cjs +57 -93
  80. package/build/legacy/onlineManager.cjs.map +1 -1
  81. package/build/legacy/onlineManager.d.cts +17 -2
  82. package/build/legacy/onlineManager.d.cts.map +1 -0
  83. package/build/legacy/onlineManager.d.ts +17 -2
  84. package/build/legacy/onlineManager.d.ts.map +1 -0
  85. package/build/legacy/onlineManager.js +54 -65
  86. package/build/legacy/onlineManager.js.map +1 -1
  87. package/build/legacy/queriesObserver.cjs +203 -262
  88. package/build/legacy/queriesObserver.cjs.map +1 -1
  89. package/build/legacy/queriesObserver.d.cts +23 -2
  90. package/build/legacy/queriesObserver.d.cts.map +1 -0
  91. package/build/legacy/queriesObserver.d.ts +23 -2
  92. package/build/legacy/queriesObserver.d.ts.map +1 -0
  93. package/build/legacy/queriesObserver.js +199 -233
  94. package/build/legacy/queriesObserver.js.map +1 -1
  95. package/build/legacy/query.cjs +409 -491
  96. package/build/legacy/query.cjs.map +1 -1
  97. package/build/legacy/query.d.cts +2 -9
  98. package/build/legacy/query.d.ts +2 -9
  99. package/build/legacy/query.js +402 -467
  100. package/build/legacy/query.js.map +1 -1
  101. package/build/legacy/queryCache.cjs +99 -128
  102. package/build/legacy/queryCache.cjs.map +1 -1
  103. package/build/legacy/queryCache.d.cts +2 -3
  104. package/build/legacy/queryCache.d.ts +2 -3
  105. package/build/legacy/queryCache.js +96 -100
  106. package/build/legacy/queryCache.js.map +1 -1
  107. package/build/legacy/queryClient.cjs +295 -345
  108. package/build/legacy/queryClient.cjs.map +1 -1
  109. package/build/legacy/queryClient.d.cts +2 -1
  110. package/build/legacy/queryClient.d.ts +2 -1
  111. package/build/legacy/queryClient.js +292 -318
  112. package/build/legacy/queryClient.js.map +1 -1
  113. package/build/legacy/queryObserver.cjs +350 -502
  114. package/build/legacy/queryObserver.cjs.map +1 -1
  115. package/build/legacy/queryObserver.d.cts +2 -1
  116. package/build/legacy/queryObserver.d.ts +2 -1
  117. package/build/legacy/queryObserver.js +345 -480
  118. package/build/legacy/queryObserver.js.map +1 -1
  119. package/build/legacy/removable-DeMjhW5M.d.cts +13 -0
  120. package/build/legacy/removable-DeMjhW5M.d.cts.map +1 -0
  121. package/build/legacy/removable-DeMjhW5M.d.ts +13 -0
  122. package/build/legacy/removable-DeMjhW5M.d.ts.map +1 -0
  123. package/build/legacy/removable.cjs +31 -67
  124. package/build/legacy/removable.cjs.map +1 -1
  125. package/build/legacy/removable.d.cts +2 -1
  126. package/build/legacy/removable.d.ts +2 -1
  127. package/build/legacy/removable.js +28 -39
  128. package/build/legacy/removable.js.map +1 -1
  129. package/build/legacy/retryer.cjs +127 -155
  130. package/build/legacy/retryer.cjs.map +1 -1
  131. package/build/legacy/retryer.d.cts +2 -7
  132. package/build/legacy/retryer.d.ts +2 -7
  133. package/build/legacy/retryer.js +121 -127
  134. package/build/legacy/retryer.js.map +1 -1
  135. package/build/legacy/streamedQuery.cjs +49 -78
  136. package/build/legacy/streamedQuery.cjs.map +1 -1
  137. package/build/legacy/streamedQuery.d.cts +33 -1
  138. package/build/legacy/streamedQuery.d.cts.map +1 -0
  139. package/build/legacy/streamedQuery.d.ts +33 -1
  140. package/build/legacy/streamedQuery.d.ts.map +1 -0
  141. package/build/legacy/streamedQuery.js +47 -54
  142. package/build/legacy/streamedQuery.js.map +1 -1
  143. package/build/legacy/subscribable-CbifVTKz.d.cts +12 -0
  144. package/build/legacy/subscribable-CbifVTKz.d.cts.map +1 -0
  145. package/build/legacy/subscribable-CbifVTKz.d.ts +12 -0
  146. package/build/legacy/subscribable-CbifVTKz.d.ts.map +1 -0
  147. package/build/legacy/subscribable.cjs +22 -48
  148. package/build/legacy/subscribable.cjs.map +1 -1
  149. package/build/legacy/subscribable.d.cts +2 -1
  150. package/build/legacy/subscribable.d.ts +2 -1
  151. package/build/legacy/subscribable.js +21 -25
  152. package/build/legacy/subscribable.js.map +1 -1
  153. package/build/legacy/timeoutManager.cjs +64 -105
  154. package/build/legacy/timeoutManager.cjs.map +1 -1
  155. package/build/legacy/timeoutManager.d.cts +60 -7
  156. package/build/legacy/timeoutManager.d.cts.map +1 -0
  157. package/build/legacy/timeoutManager.d.ts +60 -7
  158. package/build/legacy/timeoutManager.d.ts.map +1 -0
  159. package/build/legacy/timeoutManager.js +60 -76
  160. package/build/legacy/timeoutManager.js.map +1 -1
  161. package/build/legacy/types.cjs +10 -35
  162. package/build/legacy/types.cjs.map +1 -1
  163. package/build/legacy/types.d.cts +2 -94
  164. package/build/legacy/types.d.ts +2 -94
  165. package/build/legacy/types.js +7 -10
  166. package/build/legacy/types.js.map +1 -1
  167. package/build/legacy/utils.cjs +175 -300
  168. package/build/legacy/utils.cjs.map +1 -1
  169. package/build/legacy/utils.d.cts +2 -30
  170. package/build/legacy/utils.d.ts +2 -30
  171. package/build/legacy/utils.js +149 -252
  172. package/build/legacy/utils.js.map +1 -1
  173. package/build/modern/environmentManager.cjs +25 -46
  174. package/build/modern/environmentManager.cjs.map +1 -1
  175. package/build/modern/environmentManager.d.cts +18 -2
  176. package/build/modern/environmentManager.d.cts.map +1 -0
  177. package/build/modern/environmentManager.d.ts +18 -2
  178. package/build/modern/environmentManager.d.ts.map +1 -0
  179. package/build/modern/environmentManager.js +23 -20
  180. package/build/modern/environmentManager.js.map +1 -1
  181. package/build/modern/focusManager.cjs +56 -90
  182. package/build/modern/focusManager.cjs.map +1 -1
  183. package/build/modern/focusManager.d.cts +18 -2
  184. package/build/modern/focusManager.d.cts.map +1 -0
  185. package/build/modern/focusManager.d.ts +18 -2
  186. package/build/modern/focusManager.d.ts.map +1 -0
  187. package/build/modern/focusManager.js +53 -63
  188. package/build/modern/focusManager.js.map +1 -1
  189. package/build/modern/hydration-BhSbkfZj.d.cts +1374 -0
  190. package/build/modern/hydration-BhSbkfZj.d.cts.map +1 -0
  191. package/build/modern/hydration-Hebl6yHM.d.ts +1374 -0
  192. package/build/modern/hydration-Hebl6yHM.d.ts.map +1 -0
  193. package/build/modern/hydration.cjs +102 -189
  194. package/build/modern/hydration.cjs.map +1 -1
  195. package/build/modern/hydration.d.cts +2 -7
  196. package/build/modern/hydration.d.ts +2 -7
  197. package/build/modern/hydration.js +96 -160
  198. package/build/modern/hydration.js.map +1 -1
  199. package/build/modern/index.cjs +59 -111
  200. package/build/modern/index.cjs.map +1 -1
  201. package/build/modern/index.d.cts +10 -141
  202. package/build/modern/index.d.ts +10 -141
  203. package/build/modern/index.js +16 -64
  204. package/build/modern/index.js.map +1 -1
  205. package/build/modern/infiniteQueryBehavior.cjs +89 -131
  206. package/build/modern/infiniteQueryBehavior.cjs.map +1 -1
  207. package/build/modern/infiniteQueryBehavior.d.cts +14 -3
  208. package/build/modern/infiniteQueryBehavior.d.cts.map +1 -0
  209. package/build/modern/infiniteQueryBehavior.d.ts +14 -3
  210. package/build/modern/infiniteQueryBehavior.d.ts.map +1 -0
  211. package/build/modern/infiniteQueryBehavior.js +86 -109
  212. package/build/modern/infiniteQueryBehavior.js.map +1 -1
  213. package/build/modern/infiniteQueryObserver.cjs +58 -87
  214. package/build/modern/infiniteQueryObserver.cjs.map +1 -1
  215. package/build/modern/infiniteQueryObserver.d.cts +20 -1
  216. package/build/modern/infiniteQueryObserver.d.cts.map +1 -0
  217. package/build/modern/infiniteQueryObserver.d.ts +20 -1
  218. package/build/modern/infiniteQueryObserver.d.ts.map +1 -0
  219. package/build/modern/infiniteQueryObserver.js +56 -61
  220. package/build/modern/infiniteQueryObserver.js.map +1 -1
  221. package/build/modern/mutation.cjs +221 -303
  222. package/build/modern/mutation.cjs.map +1 -1
  223. package/build/modern/mutation.d.cts +2 -4
  224. package/build/modern/mutation.d.ts +2 -4
  225. package/build/modern/mutation.js +216 -274
  226. package/build/modern/mutation.js.map +1 -1
  227. package/build/modern/mutationCache.cjs +111 -145
  228. package/build/modern/mutationCache.cjs.map +1 -1
  229. package/build/modern/mutationCache.d.cts +2 -2
  230. package/build/modern/mutationCache.d.ts +2 -2
  231. package/build/modern/mutationCache.js +107 -117
  232. package/build/modern/mutationCache.js.map +1 -1
  233. package/build/modern/mutationObserver.cjs +115 -162
  234. package/build/modern/mutationObserver.cjs.map +1 -1
  235. package/build/modern/mutationObserver.d.cts +2 -1
  236. package/build/modern/mutationObserver.d.ts +2 -1
  237. package/build/modern/mutationObserver.js +113 -136
  238. package/build/modern/mutationObserver.js.map +1 -1
  239. package/build/modern/notifyManager.cjs +76 -110
  240. package/build/modern/notifyManager.cjs.map +1 -1
  241. package/build/modern/notifyManager.d.cts +48 -3
  242. package/build/modern/notifyManager.d.cts.map +1 -0
  243. package/build/modern/notifyManager.d.ts +48 -3
  244. package/build/modern/notifyManager.d.ts.map +1 -0
  245. package/build/modern/notifyManager.js +73 -82
  246. package/build/modern/notifyManager.js.map +1 -1
  247. package/build/modern/onlineManager.cjs +51 -80
  248. package/build/modern/onlineManager.cjs.map +1 -1
  249. package/build/modern/onlineManager.d.cts +17 -2
  250. package/build/modern/onlineManager.d.cts.map +1 -0
  251. package/build/modern/onlineManager.d.ts +17 -2
  252. package/build/modern/onlineManager.d.ts.map +1 -0
  253. package/build/modern/onlineManager.js +48 -53
  254. package/build/modern/onlineManager.js.map +1 -1
  255. package/build/modern/queriesObserver.cjs +185 -237
  256. package/build/modern/queriesObserver.cjs.map +1 -1
  257. package/build/modern/queriesObserver.d.cts +23 -2
  258. package/build/modern/queriesObserver.d.cts.map +1 -0
  259. package/build/modern/queriesObserver.d.ts +23 -2
  260. package/build/modern/queriesObserver.d.ts.map +1 -0
  261. package/build/modern/queriesObserver.js +181 -209
  262. package/build/modern/queriesObserver.js.map +1 -1
  263. package/build/modern/query.cjs +384 -464
  264. package/build/modern/query.cjs.map +1 -1
  265. package/build/modern/query.d.cts +2 -9
  266. package/build/modern/query.d.ts +2 -9
  267. package/build/modern/query.js +377 -441
  268. package/build/modern/query.js.map +1 -1
  269. package/build/modern/queryCache.cjs +97 -119
  270. package/build/modern/queryCache.cjs.map +1 -1
  271. package/build/modern/queryCache.d.cts +2 -3
  272. package/build/modern/queryCache.d.ts +2 -3
  273. package/build/modern/queryCache.js +94 -92
  274. package/build/modern/queryCache.js.map +1 -1
  275. package/build/modern/queryClient.cjs +281 -318
  276. package/build/modern/queryClient.cjs.map +1 -1
  277. package/build/modern/queryClient.d.cts +2 -1
  278. package/build/modern/queryClient.d.ts +2 -1
  279. package/build/modern/queryClient.js +278 -299
  280. package/build/modern/queryClient.js.map +1 -1
  281. package/build/modern/queryObserver.cjs +329 -475
  282. package/build/modern/queryObserver.cjs.map +1 -1
  283. package/build/modern/queryObserver.d.cts +2 -1
  284. package/build/modern/queryObserver.d.ts +2 -1
  285. package/build/modern/queryObserver.js +324 -454
  286. package/build/modern/queryObserver.js.map +1 -1
  287. package/build/modern/removable-DeMjhW5M.d.cts +13 -0
  288. package/build/modern/removable-DeMjhW5M.d.cts.map +1 -0
  289. package/build/modern/removable-DeMjhW5M.d.ts +13 -0
  290. package/build/modern/removable-DeMjhW5M.d.ts.map +1 -0
  291. package/build/modern/removable.cjs +27 -56
  292. package/build/modern/removable.cjs.map +1 -1
  293. package/build/modern/removable.d.cts +2 -1
  294. package/build/modern/removable.d.ts +2 -1
  295. package/build/modern/removable.js +24 -29
  296. package/build/modern/removable.js.map +1 -1
  297. package/build/modern/retryer.cjs +121 -151
  298. package/build/modern/retryer.cjs.map +1 -1
  299. package/build/modern/retryer.d.cts +2 -7
  300. package/build/modern/retryer.d.ts +2 -7
  301. package/build/modern/retryer.js +115 -121
  302. package/build/modern/retryer.js.map +1 -1
  303. package/build/modern/streamedQuery.cjs +49 -78
  304. package/build/modern/streamedQuery.cjs.map +1 -1
  305. package/build/modern/streamedQuery.d.cts +33 -1
  306. package/build/modern/streamedQuery.d.cts.map +1 -0
  307. package/build/modern/streamedQuery.d.ts +33 -1
  308. package/build/modern/streamedQuery.d.ts.map +1 -0
  309. package/build/modern/streamedQuery.js +47 -52
  310. package/build/modern/streamedQuery.js.map +1 -1
  311. package/build/modern/subscribable-CbifVTKz.d.cts +12 -0
  312. package/build/modern/subscribable-CbifVTKz.d.cts.map +1 -0
  313. package/build/modern/subscribable-CbifVTKz.d.ts +12 -0
  314. package/build/modern/subscribable-CbifVTKz.d.ts.map +1 -0
  315. package/build/modern/subscribable.cjs +22 -48
  316. package/build/modern/subscribable.cjs.map +1 -1
  317. package/build/modern/subscribable.d.cts +2 -1
  318. package/build/modern/subscribable.d.ts +2 -1
  319. package/build/modern/subscribable.js +21 -23
  320. package/build/modern/subscribable.js.map +1 -1
  321. package/build/modern/timeoutManager.cjs +59 -93
  322. package/build/modern/timeoutManager.cjs.map +1 -1
  323. package/build/modern/timeoutManager.d.cts +60 -7
  324. package/build/modern/timeoutManager.d.cts.map +1 -0
  325. package/build/modern/timeoutManager.d.ts +60 -7
  326. package/build/modern/timeoutManager.d.ts.map +1 -0
  327. package/build/modern/timeoutManager.js +55 -65
  328. package/build/modern/timeoutManager.js.map +1 -1
  329. package/build/modern/types.cjs +10 -35
  330. package/build/modern/types.cjs.map +1 -1
  331. package/build/modern/types.d.cts +2 -94
  332. package/build/modern/types.d.ts +2 -94
  333. package/build/modern/types.js +8 -9
  334. package/build/modern/types.js.map +1 -1
  335. package/build/modern/utils.cjs +175 -300
  336. package/build/modern/utils.cjs.map +1 -1
  337. package/build/modern/utils.d.cts +2 -30
  338. package/build/modern/utils.d.ts +2 -30
  339. package/build/modern/utils.js +149 -250
  340. package/build/modern/utils.js.map +1 -1
  341. package/package.json +3 -5
  342. package/src/hydration.ts +65 -56
  343. package/src/index.ts +1 -0
  344. package/src/mutation.ts +14 -6
  345. package/src/mutationObserver.ts +8 -0
  346. package/src/queriesObserver.ts +14 -8
  347. package/src/query.ts +14 -6
  348. package/src/queryClient.ts +90 -2
  349. package/src/queryObserver.ts +41 -64
  350. package/src/retryer.ts +20 -12
  351. package/src/types.ts +70 -58
  352. package/build/legacy/_tsup-dts-rollup.d.cts +0 -2188
  353. package/build/legacy/_tsup-dts-rollup.d.ts +0 -2188
  354. package/build/legacy/chunk-PXG64RU4.js +0 -25
  355. package/build/legacy/chunk-PXG64RU4.js.map +0 -1
  356. package/build/legacy/thenable.cjs +0 -76
  357. package/build/legacy/thenable.cjs.map +0 -1
  358. package/build/legacy/thenable.d.cts +0 -6
  359. package/build/legacy/thenable.d.ts +0 -6
  360. package/build/legacy/thenable.js +0 -52
  361. package/build/legacy/thenable.js.map +0 -1
  362. package/build/modern/_tsup-dts-rollup.d.cts +0 -2188
  363. package/build/modern/_tsup-dts-rollup.d.ts +0 -2188
  364. package/build/modern/thenable.cjs +0 -75
  365. package/build/modern/thenable.cjs.map +0 -1
  366. package/build/modern/thenable.d.cts +0 -6
  367. package/build/modern/thenable.d.ts +0 -6
  368. package/build/modern/thenable.js +0 -49
  369. package/build/modern/thenable.js.map +0 -1
  370. package/src/thenable.ts +0 -111
@@ -1,170 +1,125 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __typeError = (msg) => {
7
- throw TypeError(msg);
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_classPrivateFieldSet2 = require("./classPrivateFieldSet2-Bo0ZyOIv.cjs");
3
+ const require_utils = require("./utils.cjs");
4
+ const require_subscribable = require("./subscribable.cjs");
5
+ const require_notifyManager = require("./notifyManager.cjs");
6
+ const require_mutation = require("./mutation.cjs");
7
+ //#region src/mutationCache.ts
8
+ var _mutations = /* @__PURE__ */ new WeakMap();
9
+ var _scopes = /* @__PURE__ */ new WeakMap();
10
+ var _mutationId = /* @__PURE__ */ new WeakMap();
11
+ var MutationCache = class extends require_subscribable.Subscribable {
12
+ constructor(config = {}) {
13
+ super();
14
+ this.config = config;
15
+ require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _mutations, void 0);
16
+ require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _scopes, void 0);
17
+ require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _mutationId, void 0);
18
+ require_classPrivateFieldSet2._classPrivateFieldSet2(_mutations, this, /* @__PURE__ */ new Set());
19
+ require_classPrivateFieldSet2._classPrivateFieldSet2(_scopes, this, /* @__PURE__ */ new Map());
20
+ require_classPrivateFieldSet2._classPrivateFieldSet2(_mutationId, this, 0);
21
+ }
22
+ build(client, options, state) {
23
+ var _this$mutationId;
24
+ const mutation = new require_mutation.Mutation({
25
+ client,
26
+ mutationCache: this,
27
+ mutationId: require_classPrivateFieldSet2._classPrivateFieldSet2(_mutationId, this, (_this$mutationId = require_classPrivateFieldSet2._classPrivateFieldGet2(_mutationId, this), ++_this$mutationId)),
28
+ options: client.defaultMutationOptions(options),
29
+ state
30
+ });
31
+ this.add(mutation);
32
+ return mutation;
33
+ }
34
+ add(mutation) {
35
+ require_classPrivateFieldSet2._classPrivateFieldGet2(_mutations, this).add(mutation);
36
+ const scope = scopeFor(mutation);
37
+ if (typeof scope === "string") {
38
+ const scopedMutations = require_classPrivateFieldSet2._classPrivateFieldGet2(_scopes, this).get(scope);
39
+ if (scopedMutations) scopedMutations.push(mutation);
40
+ else require_classPrivateFieldSet2._classPrivateFieldGet2(_scopes, this).set(scope, [mutation]);
41
+ }
42
+ this.notify({
43
+ type: "added",
44
+ mutation
45
+ });
46
+ }
47
+ remove(mutation) {
48
+ if (require_classPrivateFieldSet2._classPrivateFieldGet2(_mutations, this).delete(mutation)) {
49
+ const scope = scopeFor(mutation);
50
+ if (typeof scope === "string") {
51
+ const scopedMutations = require_classPrivateFieldSet2._classPrivateFieldGet2(_scopes, this).get(scope);
52
+ if (scopedMutations) {
53
+ if (scopedMutations.length > 1) {
54
+ const index = scopedMutations.indexOf(mutation);
55
+ if (index !== -1) scopedMutations.splice(index, 1);
56
+ } else if (scopedMutations[0] === mutation) require_classPrivateFieldSet2._classPrivateFieldGet2(_scopes, this).delete(scope);
57
+ }
58
+ }
59
+ }
60
+ this.notify({
61
+ type: "removed",
62
+ mutation
63
+ });
64
+ }
65
+ canRun(mutation) {
66
+ const scope = scopeFor(mutation);
67
+ if (typeof scope === "string") {
68
+ const mutationsWithSameScope = require_classPrivateFieldSet2._classPrivateFieldGet2(_scopes, this).get(scope);
69
+ const firstPendingMutation = mutationsWithSameScope === null || mutationsWithSameScope === void 0 ? void 0 : mutationsWithSameScope.find((m) => m.state.status === "pending");
70
+ return !firstPendingMutation || firstPendingMutation === mutation;
71
+ } else return true;
72
+ }
73
+ runNext(mutation) {
74
+ const scope = scopeFor(mutation);
75
+ if (typeof scope === "string") {
76
+ var _classPrivateFieldGet2$1;
77
+ const foundMutation = (_classPrivateFieldGet2$1 = require_classPrivateFieldSet2._classPrivateFieldGet2(_scopes, this).get(scope)) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.find((m) => m !== mutation && m.state.isPaused);
78
+ return (foundMutation === null || foundMutation === void 0 ? void 0 : foundMutation.continue()) ?? Promise.resolve();
79
+ } else return Promise.resolve();
80
+ }
81
+ clear() {
82
+ require_notifyManager.notifyManager.batch(() => {
83
+ require_classPrivateFieldSet2._classPrivateFieldGet2(_mutations, this).forEach((mutation) => {
84
+ this.notify({
85
+ type: "removed",
86
+ mutation
87
+ });
88
+ });
89
+ require_classPrivateFieldSet2._classPrivateFieldGet2(_mutations, this).clear();
90
+ require_classPrivateFieldSet2._classPrivateFieldGet2(_scopes, this).clear();
91
+ });
92
+ }
93
+ getAll() {
94
+ return Array.from(require_classPrivateFieldSet2._classPrivateFieldGet2(_mutations, this));
95
+ }
96
+ find(filters) {
97
+ const defaultedFilters = {
98
+ exact: true,
99
+ ...filters
100
+ };
101
+ return this.getAll().find((mutation) => require_utils.matchMutation(defaultedFilters, mutation));
102
+ }
103
+ findAll(filters = {}) {
104
+ return this.getAll().filter((mutation) => require_utils.matchMutation(filters, mutation));
105
+ }
106
+ notify(event) {
107
+ require_notifyManager.notifyManager.batch(() => {
108
+ this.listeners.forEach((listener) => {
109
+ listener(event);
110
+ });
111
+ });
112
+ }
113
+ resumePausedMutations() {
114
+ const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
115
+ return require_notifyManager.notifyManager.batch(() => Promise.all(pausedMutations.map((mutation) => mutation.continue().catch(require_utils.noop))));
116
+ }
8
117
  };
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
23
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
24
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
25
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
26
- var __privateWrapper = (obj, member, setter, getter) => ({
27
- set _(value) {
28
- __privateSet(obj, member, value, setter);
29
- },
30
- get _() {
31
- return __privateGet(obj, member, getter);
32
- }
33
- });
34
-
35
- // src/mutationCache.ts
36
- var mutationCache_exports = {};
37
- __export(mutationCache_exports, {
38
- MutationCache: () => MutationCache
39
- });
40
- module.exports = __toCommonJS(mutationCache_exports);
41
- var import_notifyManager = require("./notifyManager.cjs");
42
- var import_mutation = require("./mutation.cjs");
43
- var import_utils = require("./utils.cjs");
44
- var import_subscribable = require("./subscribable.cjs");
45
- var _mutations, _scopes, _mutationId;
46
- var MutationCache = class extends import_subscribable.Subscribable {
47
- constructor(config = {}) {
48
- super();
49
- this.config = config;
50
- __privateAdd(this, _mutations);
51
- __privateAdd(this, _scopes);
52
- __privateAdd(this, _mutationId);
53
- __privateSet(this, _mutations, /* @__PURE__ */ new Set());
54
- __privateSet(this, _scopes, /* @__PURE__ */ new Map());
55
- __privateSet(this, _mutationId, 0);
56
- }
57
- build(client, options, state) {
58
- const mutation = new import_mutation.Mutation({
59
- client,
60
- mutationCache: this,
61
- mutationId: ++__privateWrapper(this, _mutationId)._,
62
- options: client.defaultMutationOptions(options),
63
- state
64
- });
65
- this.add(mutation);
66
- return mutation;
67
- }
68
- add(mutation) {
69
- __privateGet(this, _mutations).add(mutation);
70
- const scope = scopeFor(mutation);
71
- if (typeof scope === "string") {
72
- const scopedMutations = __privateGet(this, _scopes).get(scope);
73
- if (scopedMutations) {
74
- scopedMutations.push(mutation);
75
- } else {
76
- __privateGet(this, _scopes).set(scope, [mutation]);
77
- }
78
- }
79
- this.notify({ type: "added", mutation });
80
- }
81
- remove(mutation) {
82
- if (__privateGet(this, _mutations).delete(mutation)) {
83
- const scope = scopeFor(mutation);
84
- if (typeof scope === "string") {
85
- const scopedMutations = __privateGet(this, _scopes).get(scope);
86
- if (scopedMutations) {
87
- if (scopedMutations.length > 1) {
88
- const index = scopedMutations.indexOf(mutation);
89
- if (index !== -1) {
90
- scopedMutations.splice(index, 1);
91
- }
92
- } else if (scopedMutations[0] === mutation) {
93
- __privateGet(this, _scopes).delete(scope);
94
- }
95
- }
96
- }
97
- }
98
- this.notify({ type: "removed", mutation });
99
- }
100
- canRun(mutation) {
101
- const scope = scopeFor(mutation);
102
- if (typeof scope === "string") {
103
- const mutationsWithSameScope = __privateGet(this, _scopes).get(scope);
104
- const firstPendingMutation = mutationsWithSameScope == null ? void 0 : mutationsWithSameScope.find(
105
- (m) => m.state.status === "pending"
106
- );
107
- return !firstPendingMutation || firstPendingMutation === mutation;
108
- } else {
109
- return true;
110
- }
111
- }
112
- runNext(mutation) {
113
- var _a;
114
- const scope = scopeFor(mutation);
115
- if (typeof scope === "string") {
116
- const foundMutation = (_a = __privateGet(this, _scopes).get(scope)) == null ? void 0 : _a.find((m) => m !== mutation && m.state.isPaused);
117
- return (foundMutation == null ? void 0 : foundMutation.continue()) ?? Promise.resolve();
118
- } else {
119
- return Promise.resolve();
120
- }
121
- }
122
- clear() {
123
- import_notifyManager.notifyManager.batch(() => {
124
- __privateGet(this, _mutations).forEach((mutation) => {
125
- this.notify({ type: "removed", mutation });
126
- });
127
- __privateGet(this, _mutations).clear();
128
- __privateGet(this, _scopes).clear();
129
- });
130
- }
131
- getAll() {
132
- return Array.from(__privateGet(this, _mutations));
133
- }
134
- find(filters) {
135
- const defaultedFilters = { exact: true, ...filters };
136
- return this.getAll().find(
137
- (mutation) => (0, import_utils.matchMutation)(defaultedFilters, mutation)
138
- );
139
- }
140
- findAll(filters = {}) {
141
- return this.getAll().filter((mutation) => (0, import_utils.matchMutation)(filters, mutation));
142
- }
143
- notify(event) {
144
- import_notifyManager.notifyManager.batch(() => {
145
- this.listeners.forEach((listener) => {
146
- listener(event);
147
- });
148
- });
149
- }
150
- resumePausedMutations() {
151
- const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
152
- return import_notifyManager.notifyManager.batch(
153
- () => Promise.all(
154
- pausedMutations.map((mutation) => mutation.continue().catch(import_utils.noop))
155
- )
156
- );
157
- }
158
- };
159
- _mutations = new WeakMap();
160
- _scopes = new WeakMap();
161
- _mutationId = new WeakMap();
162
118
  function scopeFor(mutation) {
163
- var _a;
164
- return (_a = mutation.options.scope) == null ? void 0 : _a.id;
119
+ var _mutation$options$sco;
120
+ return (_mutation$options$sco = mutation.options.scope) === null || _mutation$options$sco === void 0 ? void 0 : _mutation$options$sco.id;
165
121
  }
166
- // Annotate the CommonJS export names for ESM import in node:
167
- 0 && (module.exports = {
168
- MutationCache
169
- });
122
+ //#endregion
123
+ exports.MutationCache = MutationCache;
124
+
170
125
  //# sourceMappingURL=mutationCache.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mutationCache.ts"],"sourcesContent":["import { notifyManager } from './notifyManager'\nimport { Mutation } from './mutation'\nimport { matchMutation, noop } from './utils'\nimport { Subscribable } from './subscribable'\nimport type { MutationObserver } from './mutationObserver'\nimport type {\n DefaultError,\n MutationFunctionContext,\n MutationOptions,\n NotifyEvent,\n} from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Action, MutationState } from './mutation'\nimport type { MutationFilters } from './utils'\n\n// TYPES\n\ninterface MutationCacheConfig {\n onError?: (\n error: DefaultError,\n variables: unknown,\n onMutateResult: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n context: MutationFunctionContext,\n ) => Promise<unknown> | unknown\n onSuccess?: (\n data: unknown,\n variables: unknown,\n onMutateResult: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n context: MutationFunctionContext,\n ) => Promise<unknown> | unknown\n onMutate?: (\n variables: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n context: MutationFunctionContext,\n ) => Promise<unknown> | unknown\n onSettled?: (\n data: unknown | undefined,\n error: DefaultError | null,\n variables: unknown,\n onMutateResult: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n context: MutationFunctionContext,\n ) => Promise<unknown> | unknown\n}\n\ninterface NotifyEventMutationAdded extends NotifyEvent {\n type: 'added'\n mutation: Mutation<any, any, any, any>\n}\ninterface NotifyEventMutationRemoved extends NotifyEvent {\n type: 'removed'\n mutation: Mutation<any, any, any, any>\n}\n\ninterface NotifyEventMutationObserverAdded extends NotifyEvent {\n type: 'observerAdded'\n mutation: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any>\n}\n\ninterface NotifyEventMutationObserverRemoved extends NotifyEvent {\n type: 'observerRemoved'\n mutation: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any>\n}\n\ninterface NotifyEventMutationObserverOptionsUpdated extends NotifyEvent {\n type: 'observerOptionsUpdated'\n mutation?: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any, any>\n}\n\ninterface NotifyEventMutationUpdated extends NotifyEvent {\n type: 'updated'\n mutation: Mutation<any, any, any, any>\n action: Action<any, any, any, any>\n}\n\nexport type MutationCacheNotifyEvent =\n | NotifyEventMutationAdded\n | NotifyEventMutationRemoved\n | NotifyEventMutationObserverAdded\n | NotifyEventMutationObserverRemoved\n | NotifyEventMutationObserverOptionsUpdated\n | NotifyEventMutationUpdated\n\ntype MutationCacheListener = (event: MutationCacheNotifyEvent) => void\n\n// CLASS\n\nexport class MutationCache extends Subscribable<MutationCacheListener> {\n #mutations: Set<Mutation<any, any, any, any>>\n #scopes: Map<string, Array<Mutation<any, any, any, any>>>\n #mutationId: number\n\n constructor(public config: MutationCacheConfig = {}) {\n super()\n this.#mutations = new Set()\n this.#scopes = new Map()\n this.#mutationId = 0\n }\n\n build<TData, TError, TVariables, TOnMutateResult>(\n client: QueryClient,\n options: MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n state?: MutationState<TData, TError, TVariables, TOnMutateResult>,\n ): Mutation<TData, TError, TVariables, TOnMutateResult> {\n const mutation = new Mutation({\n client,\n mutationCache: this,\n mutationId: ++this.#mutationId,\n options: client.defaultMutationOptions(options),\n state,\n })\n\n this.add(mutation)\n\n return mutation\n }\n\n add(mutation: Mutation<any, any, any, any>): void {\n this.#mutations.add(mutation)\n const scope = scopeFor(mutation)\n if (typeof scope === 'string') {\n const scopedMutations = this.#scopes.get(scope)\n if (scopedMutations) {\n scopedMutations.push(mutation)\n } else {\n this.#scopes.set(scope, [mutation])\n }\n }\n this.notify({ type: 'added', mutation })\n }\n\n remove(mutation: Mutation<any, any, any, any>): void {\n if (this.#mutations.delete(mutation)) {\n const scope = scopeFor(mutation)\n if (typeof scope === 'string') {\n const scopedMutations = this.#scopes.get(scope)\n if (scopedMutations) {\n if (scopedMutations.length > 1) {\n const index = scopedMutations.indexOf(mutation)\n if (index !== -1) {\n scopedMutations.splice(index, 1)\n }\n } else if (scopedMutations[0] === mutation) {\n this.#scopes.delete(scope)\n }\n }\n }\n }\n\n // Currently we notify the removal even if the mutation was already removed.\n // Consider making this an error or not notifying of the removal depending on the desired semantics.\n this.notify({ type: 'removed', mutation })\n }\n\n canRun(mutation: Mutation<any, any, any, any>): boolean {\n const scope = scopeFor(mutation)\n if (typeof scope === 'string') {\n const mutationsWithSameScope = this.#scopes.get(scope)\n const firstPendingMutation = mutationsWithSameScope?.find(\n (m) => m.state.status === 'pending',\n )\n // we can run if there is no current pending mutation (start use-case)\n // or if WE are the first pending mutation (continue use-case)\n return !firstPendingMutation || firstPendingMutation === mutation\n } else {\n // For unscoped mutations there are never any pending mutations in front of the\n // current mutation\n return true\n }\n }\n\n runNext(mutation: Mutation<any, any, any, any>): Promise<unknown> {\n const scope = scopeFor(mutation)\n if (typeof scope === 'string') {\n const foundMutation = this.#scopes\n .get(scope)\n ?.find((m) => m !== mutation && m.state.isPaused)\n\n return foundMutation?.continue() ?? Promise.resolve()\n } else {\n return Promise.resolve()\n }\n }\n\n clear(): void {\n notifyManager.batch(() => {\n this.#mutations.forEach((mutation) => {\n this.notify({ type: 'removed', mutation })\n })\n this.#mutations.clear()\n this.#scopes.clear()\n })\n }\n\n getAll(): Array<Mutation> {\n return Array.from(this.#mutations)\n }\n\n find<\n TData = unknown,\n TError = DefaultError,\n TVariables = any,\n TOnMutateResult = unknown,\n >(\n filters: MutationFilters,\n ): Mutation<TData, TError, TVariables, TOnMutateResult> | undefined {\n const defaultedFilters = { exact: true, ...filters }\n\n return this.getAll().find((mutation) =>\n matchMutation(defaultedFilters, mutation),\n ) as Mutation<TData, TError, TVariables, TOnMutateResult> | undefined\n }\n\n findAll(filters: MutationFilters = {}): Array<Mutation> {\n return this.getAll().filter((mutation) => matchMutation(filters, mutation))\n }\n\n notify(event: MutationCacheNotifyEvent) {\n notifyManager.batch(() => {\n this.listeners.forEach((listener) => {\n listener(event)\n })\n })\n }\n\n resumePausedMutations(): Promise<unknown> {\n const pausedMutations = this.getAll().filter((x) => x.state.isPaused)\n\n return notifyManager.batch(() =>\n Promise.all(\n pausedMutations.map((mutation) => mutation.continue().catch(noop)),\n ),\n )\n }\n}\n\nfunction scopeFor(mutation: Mutation<any, any, any, any>) {\n return mutation.options.scope?.id\n}\n"],"mappings":"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","names":[]}
1
+ {"version":3,"file":"mutationCache.cjs","names":["Subscribable","Mutation","matchMutation","notifyManager","noop"],"sources":["../../src/mutationCache.ts"],"sourcesContent":["import { notifyManager } from './notifyManager'\nimport { Mutation } from './mutation'\nimport { matchMutation, noop } from './utils'\nimport { Subscribable } from './subscribable'\nimport type { MutationObserver } from './mutationObserver'\nimport type {\n DefaultError,\n MutationFunctionContext,\n MutationOptions,\n NotifyEvent,\n} from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Action, MutationState } from './mutation'\nimport type { MutationFilters } from './utils'\n\n// TYPES\n\ninterface MutationCacheConfig {\n onError?: (\n error: DefaultError,\n variables: unknown,\n onMutateResult: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n context: MutationFunctionContext,\n ) => Promise<unknown> | unknown\n onSuccess?: (\n data: unknown,\n variables: unknown,\n onMutateResult: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n context: MutationFunctionContext,\n ) => Promise<unknown> | unknown\n onMutate?: (\n variables: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n context: MutationFunctionContext,\n ) => Promise<unknown> | unknown\n onSettled?: (\n data: unknown | undefined,\n error: DefaultError | null,\n variables: unknown,\n onMutateResult: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n context: MutationFunctionContext,\n ) => Promise<unknown> | unknown\n}\n\ninterface NotifyEventMutationAdded extends NotifyEvent {\n type: 'added'\n mutation: Mutation<any, any, any, any>\n}\ninterface NotifyEventMutationRemoved extends NotifyEvent {\n type: 'removed'\n mutation: Mutation<any, any, any, any>\n}\n\ninterface NotifyEventMutationObserverAdded extends NotifyEvent {\n type: 'observerAdded'\n mutation: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any>\n}\n\ninterface NotifyEventMutationObserverRemoved extends NotifyEvent {\n type: 'observerRemoved'\n mutation: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any>\n}\n\ninterface NotifyEventMutationObserverOptionsUpdated extends NotifyEvent {\n type: 'observerOptionsUpdated'\n mutation?: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any, any>\n}\n\ninterface NotifyEventMutationUpdated extends NotifyEvent {\n type: 'updated'\n mutation: Mutation<any, any, any, any>\n action: Action<any, any, any, any>\n}\n\nexport type MutationCacheNotifyEvent =\n | NotifyEventMutationAdded\n | NotifyEventMutationRemoved\n | NotifyEventMutationObserverAdded\n | NotifyEventMutationObserverRemoved\n | NotifyEventMutationObserverOptionsUpdated\n | NotifyEventMutationUpdated\n\ntype MutationCacheListener = (event: MutationCacheNotifyEvent) => void\n\n// CLASS\n\nexport class MutationCache extends Subscribable<MutationCacheListener> {\n #mutations: Set<Mutation<any, any, any, any>>\n #scopes: Map<string, Array<Mutation<any, any, any, any>>>\n #mutationId: number\n\n constructor(public config: MutationCacheConfig = {}) {\n super()\n this.#mutations = new Set()\n this.#scopes = new Map()\n this.#mutationId = 0\n }\n\n build<TData, TError, TVariables, TOnMutateResult>(\n client: QueryClient,\n options: MutationOptions<TData, TError, TVariables, TOnMutateResult>,\n state?: MutationState<TData, TError, TVariables, TOnMutateResult>,\n ): Mutation<TData, TError, TVariables, TOnMutateResult> {\n const mutation = new Mutation({\n client,\n mutationCache: this,\n mutationId: ++this.#mutationId,\n options: client.defaultMutationOptions(options),\n state,\n })\n\n this.add(mutation)\n\n return mutation\n }\n\n add(mutation: Mutation<any, any, any, any>): void {\n this.#mutations.add(mutation)\n const scope = scopeFor(mutation)\n if (typeof scope === 'string') {\n const scopedMutations = this.#scopes.get(scope)\n if (scopedMutations) {\n scopedMutations.push(mutation)\n } else {\n this.#scopes.set(scope, [mutation])\n }\n }\n this.notify({ type: 'added', mutation })\n }\n\n remove(mutation: Mutation<any, any, any, any>): void {\n if (this.#mutations.delete(mutation)) {\n const scope = scopeFor(mutation)\n if (typeof scope === 'string') {\n const scopedMutations = this.#scopes.get(scope)\n if (scopedMutations) {\n if (scopedMutations.length > 1) {\n const index = scopedMutations.indexOf(mutation)\n if (index !== -1) {\n scopedMutations.splice(index, 1)\n }\n } else if (scopedMutations[0] === mutation) {\n this.#scopes.delete(scope)\n }\n }\n }\n }\n\n // Currently we notify the removal even if the mutation was already removed.\n // Consider making this an error or not notifying of the removal depending on the desired semantics.\n this.notify({ type: 'removed', mutation })\n }\n\n canRun(mutation: Mutation<any, any, any, any>): boolean {\n const scope = scopeFor(mutation)\n if (typeof scope === 'string') {\n const mutationsWithSameScope = this.#scopes.get(scope)\n const firstPendingMutation = mutationsWithSameScope?.find(\n (m) => m.state.status === 'pending',\n )\n // we can run if there is no current pending mutation (start use-case)\n // or if WE are the first pending mutation (continue use-case)\n return !firstPendingMutation || firstPendingMutation === mutation\n } else {\n // For unscoped mutations there are never any pending mutations in front of the\n // current mutation\n return true\n }\n }\n\n runNext(mutation: Mutation<any, any, any, any>): Promise<unknown> {\n const scope = scopeFor(mutation)\n if (typeof scope === 'string') {\n const foundMutation = this.#scopes\n .get(scope)\n ?.find((m) => m !== mutation && m.state.isPaused)\n\n return foundMutation?.continue() ?? Promise.resolve()\n } else {\n return Promise.resolve()\n }\n }\n\n clear(): void {\n notifyManager.batch(() => {\n this.#mutations.forEach((mutation) => {\n this.notify({ type: 'removed', mutation })\n })\n this.#mutations.clear()\n this.#scopes.clear()\n })\n }\n\n getAll(): Array<Mutation> {\n return Array.from(this.#mutations)\n }\n\n find<\n TData = unknown,\n TError = DefaultError,\n TVariables = any,\n TOnMutateResult = unknown,\n >(\n filters: MutationFilters,\n ): Mutation<TData, TError, TVariables, TOnMutateResult> | undefined {\n const defaultedFilters = { exact: true, ...filters }\n\n return this.getAll().find((mutation) =>\n matchMutation(defaultedFilters, mutation),\n ) as Mutation<TData, TError, TVariables, TOnMutateResult> | undefined\n }\n\n findAll(filters: MutationFilters = {}): Array<Mutation> {\n return this.getAll().filter((mutation) => matchMutation(filters, mutation))\n }\n\n notify(event: MutationCacheNotifyEvent) {\n notifyManager.batch(() => {\n this.listeners.forEach((listener) => {\n listener(event)\n })\n })\n }\n\n resumePausedMutations(): Promise<unknown> {\n const pausedMutations = this.getAll().filter((x) => x.state.isPaused)\n\n return notifyManager.batch(() =>\n Promise.all(\n pausedMutations.map((mutation) => mutation.continue().catch(noop)),\n ),\n )\n }\n}\n\nfunction scopeFor(mutation: Mutation<any, any, any, any>) {\n return mutation.options.scope?.id\n}\n"],"mappings":";;;;;;;;;;AA4FA,IAAa,gBAAb,cAAmCA,qBAAAA,aAAoC;CAKrE,YAAY,SAAqC,CAAC,GAAG;EACnD,MAAM;EADW,KAAA,SAAA;;;;EAEjB,8BAAA,uBAAA,YAAA,sBAAkB,IAAI,IAAI,CAAA;EAC1B,8BAAA,uBAAA,SAAA,sBAAe,IAAI,IAAI,CAAA;EACvB,8BAAA,uBAAA,aAAA,MAAmB,CAAA;CACrB;CAEA,MACE,QACA,SACA,OACsD;;EACtD,MAAM,WAAW,IAAIC,iBAAAA,SAAS;GAC5B;GACA,eAAe;GACf,YAAA,8BAAA,uBAAA,aAAc,OAAA,mBAAA,8BAAA,uBAAA,aAAA,IAAA,GAAA,EAAA,iBAAA;GACd,SAAS,OAAO,uBAAuB,OAAO;GAC9C;EACF,CAAC;EAED,KAAK,IAAI,QAAQ;EAEjB,OAAO;CACT;CAEA,IAAI,UAA8C;EAChD,8BAAA,uBAAA,YAAA,IAAA,CAAA,CAAgB,IAAI,QAAQ;EAC5B,MAAM,QAAQ,SAAS,QAAQ;EAC/B,IAAI,OAAO,UAAU,UAAU;GAC7B,MAAM,kBAAA,8BAAA,uBAAA,SAAkB,IAAA,CAAA,CAAa,IAAI,KAAK;GAC9C,IAAI,iBACF,gBAAgB,KAAK,QAAQ;QAE7B,8BAAA,uBAAA,SAAA,IAAA,CAAA,CAAa,IAAI,OAAO,CAAC,QAAQ,CAAC;EAEtC;EACA,KAAK,OAAO;GAAE,MAAM;GAAS;EAAS,CAAC;CACzC;CAEA,OAAO,UAA8C;EACnD,IAAA,8BAAA,uBAAA,YAAI,IAAA,CAAA,CAAgB,OAAO,QAAQ,GAAG;GACpC,MAAM,QAAQ,SAAS,QAAQ;GAC/B,IAAI,OAAO,UAAU,UAAU;IAC7B,MAAM,kBAAA,8BAAA,uBAAA,SAAkB,IAAA,CAAA,CAAa,IAAI,KAAK;IAC9C,IAAI,iBAAiB;KACnB,IAAI,gBAAgB,SAAS,GAAG;MAC9B,MAAM,QAAQ,gBAAgB,QAAQ,QAAQ;MAC9C,IAAI,UAAU,IACZ,gBAAgB,OAAO,OAAO,CAAC;KAEnC,OAAO,IAAI,gBAAgB,OAAO,UAChC,8BAAA,uBAAA,SAAA,IAAA,CAAA,CAAa,OAAO,KAAK;IAE7B;GACF;EACF;EAIA,KAAK,OAAO;GAAE,MAAM;GAAW;EAAS,CAAC;CAC3C;CAEA,OAAO,UAAiD;EACtD,MAAM,QAAQ,SAAS,QAAQ;EAC/B,IAAI,OAAO,UAAU,UAAU;GAC7B,MAAM,yBAAA,8BAAA,uBAAA,SAAyB,IAAA,CAAA,CAAa,IAAI,KAAK;GACrD,MAAM,uBAAA,2BAAA,QAAA,2BAAA,KAAA,IAAA,KAAA,IAAuB,uBAAwB,MAClD,MAAM,EAAE,MAAM,WAAW,SAC5B;GAGA,OAAO,CAAC,wBAAwB,yBAAyB;EAC3D,OAGE,OAAO;CAEX;CAEA,QAAQ,UAA0D;EAChE,MAAM,QAAQ,SAAS,QAAQ;EAC/B,IAAI,OAAO,UAAU,UAAU;;GAC7B,MAAM,iBAAA,2BAAA,8BAAA,uBAAA,SAAgB,IAAA,CAAA,CACnB,IAAI,KAAK,OAAA,QAAA,6BAAA,KAAA,IAAA,KAAA,IAAA,yBACR,MAAM,MAAM,MAAM,YAAY,EAAE,MAAM,QAAQ;GAElD,QAAA,kBAAA,QAAA,kBAAA,KAAA,IAAA,KAAA,IAAO,cAAe,SAAS,MAAK,QAAQ,QAAQ;EACtD,OACE,OAAO,QAAQ,QAAQ;CAE3B;CAEA,QAAc;EACZ,sBAAA,cAAc,YAAY;GACxB,8BAAA,uBAAA,YAAA,IAAA,CAAA,CAAgB,SAAS,aAAa;IACpC,KAAK,OAAO;KAAE,MAAM;KAAW;IAAS,CAAC;GAC3C,CAAC;GACD,8BAAA,uBAAA,YAAA,IAAA,CAAA,CAAgB,MAAM;GACtB,8BAAA,uBAAA,SAAA,IAAA,CAAA,CAAa,MAAM;EACrB,CAAC;CACH;CAEA,SAA0B;EACxB,OAAO,MAAM,KAAA,8BAAA,uBAAA,YAAK,IAAA,CAAe;CACnC;CAEA,KAME,SACkE;EAClE,MAAM,mBAAmB;GAAE,OAAO;GAAM,GAAG;EAAQ;EAEnD,OAAO,KAAK,OAAO,CAAC,CAAC,MAAM,aACzBC,cAAAA,cAAc,kBAAkB,QAAQ,CAC1C;CACF;CAEA,QAAQ,UAA2B,CAAC,GAAoB;EACtD,OAAO,KAAK,OAAO,CAAC,CAAC,QAAQ,aAAaA,cAAAA,cAAc,SAAS,QAAQ,CAAC;CAC5E;CAEA,OAAO,OAAiC;EACtC,sBAAA,cAAc,YAAY;GACxB,KAAK,UAAU,SAAS,aAAa;IACnC,SAAS,KAAK;GAChB,CAAC;EACH,CAAC;CACH;CAEA,wBAA0C;EACxC,MAAM,kBAAkB,KAAK,OAAO,CAAC,CAAC,QAAQ,MAAM,EAAE,MAAM,QAAQ;EAEpE,OAAOC,sBAAAA,cAAc,YACnB,QAAQ,IACN,gBAAgB,KAAK,aAAa,SAAS,SAAS,CAAC,CAAC,MAAMC,cAAAA,IAAI,CAAC,CACnE,CACF;CACF;AACF;AAEA,SAAS,SAAS,UAAwC;;CACxD,QAAA,wBAAO,SAAS,QAAQ,WAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAO;AACjC"}
@@ -1,2 +1,2 @@
1
- export { MutationCacheNotifyEvent_alias_1 as MutationCacheNotifyEvent } from './_tsup-dts-rollup.cjs';
2
- export { MutationCache_alias_1 as MutationCache } from './_tsup-dts-rollup.cjs';
1
+ import { Gn as MutationCacheNotifyEvent, Wn as MutationCache } from "./hydration-BhSbkfZj.cjs";
2
+ export { MutationCache, MutationCacheNotifyEvent };
@@ -1,2 +1,2 @@
1
- export { MutationCacheNotifyEvent_alias_1 as MutationCacheNotifyEvent } from './_tsup-dts-rollup.js';
2
- export { MutationCache_alias_1 as MutationCache } from './_tsup-dts-rollup.js';
1
+ import { Gn as MutationCacheNotifyEvent, Wn as MutationCache } from "./hydration-Hebl6yHM.js";
2
+ export { MutationCache, MutationCacheNotifyEvent };
@@ -1,137 +1,124 @@
1
- import {
2
- __privateAdd,
3
- __privateGet,
4
- __privateSet,
5
- __privateWrapper
6
- } from "./chunk-PXG64RU4.js";
7
-
8
- // src/mutationCache.ts
9
- import { notifyManager } from "./notifyManager.js";
10
- import { Mutation } from "./mutation.js";
1
+ import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldGet2, t as _classPrivateFieldSet2 } from "./classPrivateFieldSet2-CV7wyte-.js";
11
2
  import { matchMutation, noop } from "./utils.js";
12
3
  import { Subscribable } from "./subscribable.js";
13
- var _mutations, _scopes, _mutationId;
4
+ import { notifyManager } from "./notifyManager.js";
5
+ import { Mutation } from "./mutation.js";
6
+ //#region src/mutationCache.ts
7
+ var _mutations = /* @__PURE__ */ new WeakMap();
8
+ var _scopes = /* @__PURE__ */ new WeakMap();
9
+ var _mutationId = /* @__PURE__ */ new WeakMap();
14
10
  var MutationCache = class extends Subscribable {
15
- constructor(config = {}) {
16
- super();
17
- this.config = config;
18
- __privateAdd(this, _mutations);
19
- __privateAdd(this, _scopes);
20
- __privateAdd(this, _mutationId);
21
- __privateSet(this, _mutations, /* @__PURE__ */ new Set());
22
- __privateSet(this, _scopes, /* @__PURE__ */ new Map());
23
- __privateSet(this, _mutationId, 0);
24
- }
25
- build(client, options, state) {
26
- const mutation = new Mutation({
27
- client,
28
- mutationCache: this,
29
- mutationId: ++__privateWrapper(this, _mutationId)._,
30
- options: client.defaultMutationOptions(options),
31
- state
32
- });
33
- this.add(mutation);
34
- return mutation;
35
- }
36
- add(mutation) {
37
- __privateGet(this, _mutations).add(mutation);
38
- const scope = scopeFor(mutation);
39
- if (typeof scope === "string") {
40
- const scopedMutations = __privateGet(this, _scopes).get(scope);
41
- if (scopedMutations) {
42
- scopedMutations.push(mutation);
43
- } else {
44
- __privateGet(this, _scopes).set(scope, [mutation]);
45
- }
46
- }
47
- this.notify({ type: "added", mutation });
48
- }
49
- remove(mutation) {
50
- if (__privateGet(this, _mutations).delete(mutation)) {
51
- const scope = scopeFor(mutation);
52
- if (typeof scope === "string") {
53
- const scopedMutations = __privateGet(this, _scopes).get(scope);
54
- if (scopedMutations) {
55
- if (scopedMutations.length > 1) {
56
- const index = scopedMutations.indexOf(mutation);
57
- if (index !== -1) {
58
- scopedMutations.splice(index, 1);
59
- }
60
- } else if (scopedMutations[0] === mutation) {
61
- __privateGet(this, _scopes).delete(scope);
62
- }
63
- }
64
- }
65
- }
66
- this.notify({ type: "removed", mutation });
67
- }
68
- canRun(mutation) {
69
- const scope = scopeFor(mutation);
70
- if (typeof scope === "string") {
71
- const mutationsWithSameScope = __privateGet(this, _scopes).get(scope);
72
- const firstPendingMutation = mutationsWithSameScope == null ? void 0 : mutationsWithSameScope.find(
73
- (m) => m.state.status === "pending"
74
- );
75
- return !firstPendingMutation || firstPendingMutation === mutation;
76
- } else {
77
- return true;
78
- }
79
- }
80
- runNext(mutation) {
81
- var _a;
82
- const scope = scopeFor(mutation);
83
- if (typeof scope === "string") {
84
- const foundMutation = (_a = __privateGet(this, _scopes).get(scope)) == null ? void 0 : _a.find((m) => m !== mutation && m.state.isPaused);
85
- return (foundMutation == null ? void 0 : foundMutation.continue()) ?? Promise.resolve();
86
- } else {
87
- return Promise.resolve();
88
- }
89
- }
90
- clear() {
91
- notifyManager.batch(() => {
92
- __privateGet(this, _mutations).forEach((mutation) => {
93
- this.notify({ type: "removed", mutation });
94
- });
95
- __privateGet(this, _mutations).clear();
96
- __privateGet(this, _scopes).clear();
97
- });
98
- }
99
- getAll() {
100
- return Array.from(__privateGet(this, _mutations));
101
- }
102
- find(filters) {
103
- const defaultedFilters = { exact: true, ...filters };
104
- return this.getAll().find(
105
- (mutation) => matchMutation(defaultedFilters, mutation)
106
- );
107
- }
108
- findAll(filters = {}) {
109
- return this.getAll().filter((mutation) => matchMutation(filters, mutation));
110
- }
111
- notify(event) {
112
- notifyManager.batch(() => {
113
- this.listeners.forEach((listener) => {
114
- listener(event);
115
- });
116
- });
117
- }
118
- resumePausedMutations() {
119
- const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
120
- return notifyManager.batch(
121
- () => Promise.all(
122
- pausedMutations.map((mutation) => mutation.continue().catch(noop))
123
- )
124
- );
125
- }
11
+ constructor(config = {}) {
12
+ super();
13
+ this.config = config;
14
+ _classPrivateFieldInitSpec(this, _mutations, void 0);
15
+ _classPrivateFieldInitSpec(this, _scopes, void 0);
16
+ _classPrivateFieldInitSpec(this, _mutationId, void 0);
17
+ _classPrivateFieldSet2(_mutations, this, /* @__PURE__ */ new Set());
18
+ _classPrivateFieldSet2(_scopes, this, /* @__PURE__ */ new Map());
19
+ _classPrivateFieldSet2(_mutationId, this, 0);
20
+ }
21
+ build(client, options, state) {
22
+ var _this$mutationId;
23
+ const mutation = new Mutation({
24
+ client,
25
+ mutationCache: this,
26
+ mutationId: _classPrivateFieldSet2(_mutationId, this, (_this$mutationId = _classPrivateFieldGet2(_mutationId, this), ++_this$mutationId)),
27
+ options: client.defaultMutationOptions(options),
28
+ state
29
+ });
30
+ this.add(mutation);
31
+ return mutation;
32
+ }
33
+ add(mutation) {
34
+ _classPrivateFieldGet2(_mutations, this).add(mutation);
35
+ const scope = scopeFor(mutation);
36
+ if (typeof scope === "string") {
37
+ const scopedMutations = _classPrivateFieldGet2(_scopes, this).get(scope);
38
+ if (scopedMutations) scopedMutations.push(mutation);
39
+ else _classPrivateFieldGet2(_scopes, this).set(scope, [mutation]);
40
+ }
41
+ this.notify({
42
+ type: "added",
43
+ mutation
44
+ });
45
+ }
46
+ remove(mutation) {
47
+ if (_classPrivateFieldGet2(_mutations, this).delete(mutation)) {
48
+ const scope = scopeFor(mutation);
49
+ if (typeof scope === "string") {
50
+ const scopedMutations = _classPrivateFieldGet2(_scopes, this).get(scope);
51
+ if (scopedMutations) {
52
+ if (scopedMutations.length > 1) {
53
+ const index = scopedMutations.indexOf(mutation);
54
+ if (index !== -1) scopedMutations.splice(index, 1);
55
+ } else if (scopedMutations[0] === mutation) _classPrivateFieldGet2(_scopes, this).delete(scope);
56
+ }
57
+ }
58
+ }
59
+ this.notify({
60
+ type: "removed",
61
+ mutation
62
+ });
63
+ }
64
+ canRun(mutation) {
65
+ const scope = scopeFor(mutation);
66
+ if (typeof scope === "string") {
67
+ const mutationsWithSameScope = _classPrivateFieldGet2(_scopes, this).get(scope);
68
+ const firstPendingMutation = mutationsWithSameScope === null || mutationsWithSameScope === void 0 ? void 0 : mutationsWithSameScope.find((m) => m.state.status === "pending");
69
+ return !firstPendingMutation || firstPendingMutation === mutation;
70
+ } else return true;
71
+ }
72
+ runNext(mutation) {
73
+ const scope = scopeFor(mutation);
74
+ if (typeof scope === "string") {
75
+ var _classPrivateFieldGet2$1;
76
+ const foundMutation = (_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_scopes, this).get(scope)) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.find((m) => m !== mutation && m.state.isPaused);
77
+ return (foundMutation === null || foundMutation === void 0 ? void 0 : foundMutation.continue()) ?? Promise.resolve();
78
+ } else return Promise.resolve();
79
+ }
80
+ clear() {
81
+ notifyManager.batch(() => {
82
+ _classPrivateFieldGet2(_mutations, this).forEach((mutation) => {
83
+ this.notify({
84
+ type: "removed",
85
+ mutation
86
+ });
87
+ });
88
+ _classPrivateFieldGet2(_mutations, this).clear();
89
+ _classPrivateFieldGet2(_scopes, this).clear();
90
+ });
91
+ }
92
+ getAll() {
93
+ return Array.from(_classPrivateFieldGet2(_mutations, this));
94
+ }
95
+ find(filters) {
96
+ const defaultedFilters = {
97
+ exact: true,
98
+ ...filters
99
+ };
100
+ return this.getAll().find((mutation) => matchMutation(defaultedFilters, mutation));
101
+ }
102
+ findAll(filters = {}) {
103
+ return this.getAll().filter((mutation) => matchMutation(filters, mutation));
104
+ }
105
+ notify(event) {
106
+ notifyManager.batch(() => {
107
+ this.listeners.forEach((listener) => {
108
+ listener(event);
109
+ });
110
+ });
111
+ }
112
+ resumePausedMutations() {
113
+ const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
114
+ return notifyManager.batch(() => Promise.all(pausedMutations.map((mutation) => mutation.continue().catch(noop))));
115
+ }
126
116
  };
127
- _mutations = new WeakMap();
128
- _scopes = new WeakMap();
129
- _mutationId = new WeakMap();
130
117
  function scopeFor(mutation) {
131
- var _a;
132
- return (_a = mutation.options.scope) == null ? void 0 : _a.id;
118
+ var _mutation$options$sco;
119
+ return (_mutation$options$sco = mutation.options.scope) === null || _mutation$options$sco === void 0 ? void 0 : _mutation$options$sco.id;
133
120
  }
134
- export {
135
- MutationCache
136
- };
121
+ //#endregion
122
+ export { MutationCache };
123
+
137
124
  //# sourceMappingURL=mutationCache.js.map