@tanstack/query-core 4.36.1 → 4.39.0

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 (181) hide show
  1. package/build/lib/queryCache.d.ts +14 -4
  2. package/build/lib/queryClient.d.ts +83 -20
  3. package/build/lib/tests/queryClient.types.test.d.ts +2 -0
  4. package/build/lib/tests/utils.d.ts +1 -0
  5. package/build/lib/types.d.ts +8 -0
  6. package/package.json +2 -9
  7. package/src/mutationObserver.ts +3 -1
  8. package/src/queryCache.ts +37 -6
  9. package/src/queryClient.ts +202 -37
  10. package/src/tests/mutations.test.tsx +8 -0
  11. package/src/tests/queryClient.types.test.tsx +13 -0
  12. package/src/tests/utils.ts +2 -0
  13. package/src/types.ts +20 -0
  14. package/build/lib/focusManager.d.ts.map +0 -1
  15. package/build/lib/focusManager.esm.js +0 -91
  16. package/build/lib/focusManager.esm.js.map +0 -1
  17. package/build/lib/focusManager.js +0 -96
  18. package/build/lib/focusManager.js.map +0 -1
  19. package/build/lib/focusManager.mjs +0 -91
  20. package/build/lib/focusManager.mjs.map +0 -1
  21. package/build/lib/hydration.d.ts.map +0 -1
  22. package/build/lib/hydration.esm.js +0 -109
  23. package/build/lib/hydration.esm.js.map +0 -1
  24. package/build/lib/hydration.js +0 -116
  25. package/build/lib/hydration.js.map +0 -1
  26. package/build/lib/hydration.mjs +0 -109
  27. package/build/lib/hydration.mjs.map +0 -1
  28. package/build/lib/index.d.ts.map +0 -1
  29. package/build/lib/index.esm.js +0 -15
  30. package/build/lib/index.esm.js.map +0 -1
  31. package/build/lib/index.js +0 -48
  32. package/build/lib/index.js.map +0 -1
  33. package/build/lib/index.mjs +0 -15
  34. package/build/lib/index.mjs.map +0 -1
  35. package/build/lib/infiniteQueryBehavior.d.ts.map +0 -1
  36. package/build/lib/infiniteQueryBehavior.esm.js +0 -146
  37. package/build/lib/infiniteQueryBehavior.esm.js.map +0 -1
  38. package/build/lib/infiniteQueryBehavior.js +0 -154
  39. package/build/lib/infiniteQueryBehavior.js.map +0 -1
  40. package/build/lib/infiniteQueryBehavior.mjs +0 -146
  41. package/build/lib/infiniteQueryBehavior.mjs.map +0 -1
  42. package/build/lib/infiniteQueryObserver.d.ts.map +0 -1
  43. package/build/lib/infiniteQueryObserver.esm.js +0 -85
  44. package/build/lib/infiniteQueryObserver.esm.js.map +0 -1
  45. package/build/lib/infiniteQueryObserver.js +0 -89
  46. package/build/lib/infiniteQueryObserver.js.map +0 -1
  47. package/build/lib/infiniteQueryObserver.mjs +0 -85
  48. package/build/lib/infiniteQueryObserver.mjs.map +0 -1
  49. package/build/lib/logger.d.ts.map +0 -1
  50. package/build/lib/logger.esm.js +0 -4
  51. package/build/lib/logger.esm.js.map +0 -1
  52. package/build/lib/logger.js +0 -8
  53. package/build/lib/logger.js.map +0 -1
  54. package/build/lib/logger.mjs +0 -4
  55. package/build/lib/logger.mjs.map +0 -1
  56. package/build/lib/logger.native.d.ts.map +0 -1
  57. package/build/lib/logger.native.esm.js +0 -12
  58. package/build/lib/logger.native.esm.js.map +0 -1
  59. package/build/lib/logger.native.js +0 -16
  60. package/build/lib/logger.native.js.map +0 -1
  61. package/build/lib/logger.native.mjs +0 -12
  62. package/build/lib/logger.native.mjs.map +0 -1
  63. package/build/lib/mutation.d.ts.map +0 -1
  64. package/build/lib/mutation.esm.js +0 -261
  65. package/build/lib/mutation.esm.js.map +0 -1
  66. package/build/lib/mutation.js +0 -266
  67. package/build/lib/mutation.js.map +0 -1
  68. package/build/lib/mutation.mjs +0 -261
  69. package/build/lib/mutation.mjs.map +0 -1
  70. package/build/lib/mutationCache.d.ts.map +0 -1
  71. package/build/lib/mutationCache.esm.js +0 -93
  72. package/build/lib/mutationCache.esm.js.map +0 -1
  73. package/build/lib/mutationCache.js +0 -97
  74. package/build/lib/mutationCache.js.map +0 -1
  75. package/build/lib/mutationCache.mjs +0 -93
  76. package/build/lib/mutationCache.mjs.map +0 -1
  77. package/build/lib/mutationObserver.d.ts.map +0 -1
  78. package/build/lib/mutationObserver.esm.js +0 -132
  79. package/build/lib/mutationObserver.esm.js.map +0 -1
  80. package/build/lib/mutationObserver.js +0 -136
  81. package/build/lib/mutationObserver.js.map +0 -1
  82. package/build/lib/mutationObserver.mjs +0 -132
  83. package/build/lib/mutationObserver.mjs.map +0 -1
  84. package/build/lib/notifyManager.d.ts.map +0 -1
  85. package/build/lib/notifyManager.esm.js +0 -99
  86. package/build/lib/notifyManager.esm.js.map +0 -1
  87. package/build/lib/notifyManager.js +0 -104
  88. package/build/lib/notifyManager.js.map +0 -1
  89. package/build/lib/notifyManager.mjs +0 -99
  90. package/build/lib/notifyManager.mjs.map +0 -1
  91. package/build/lib/onlineManager.d.ts.map +0 -1
  92. package/build/lib/onlineManager.esm.js +0 -93
  93. package/build/lib/onlineManager.esm.js.map +0 -1
  94. package/build/lib/onlineManager.js +0 -98
  95. package/build/lib/onlineManager.js.map +0 -1
  96. package/build/lib/onlineManager.mjs +0 -93
  97. package/build/lib/onlineManager.mjs.map +0 -1
  98. package/build/lib/queriesObserver.d.ts.map +0 -1
  99. package/build/lib/queriesObserver.esm.js +0 -168
  100. package/build/lib/queriesObserver.esm.js.map +0 -1
  101. package/build/lib/queriesObserver.js +0 -172
  102. package/build/lib/queriesObserver.js.map +0 -1
  103. package/build/lib/queriesObserver.mjs +0 -168
  104. package/build/lib/queriesObserver.mjs.map +0 -1
  105. package/build/lib/query.d.ts.map +0 -1
  106. package/build/lib/query.esm.js +0 -475
  107. package/build/lib/query.esm.js.map +0 -1
  108. package/build/lib/query.js +0 -479
  109. package/build/lib/query.js.map +0 -1
  110. package/build/lib/query.mjs +0 -475
  111. package/build/lib/query.mjs.map +0 -1
  112. package/build/lib/queryCache.d.ts.map +0 -1
  113. package/build/lib/queryCache.esm.js +0 -127
  114. package/build/lib/queryCache.esm.js.map +0 -1
  115. package/build/lib/queryCache.js +0 -131
  116. package/build/lib/queryCache.js.map +0 -1
  117. package/build/lib/queryCache.mjs +0 -127
  118. package/build/lib/queryCache.mjs.map +0 -1
  119. package/build/lib/queryClient.d.ts.map +0 -1
  120. package/build/lib/queryClient.esm.js +0 -356
  121. package/build/lib/queryClient.esm.js.map +0 -1
  122. package/build/lib/queryClient.js +0 -360
  123. package/build/lib/queryClient.js.map +0 -1
  124. package/build/lib/queryClient.mjs +0 -356
  125. package/build/lib/queryClient.mjs.map +0 -1
  126. package/build/lib/queryObserver.d.ts.map +0 -1
  127. package/build/lib/queryObserver.esm.js +0 -580
  128. package/build/lib/queryObserver.esm.js.map +0 -1
  129. package/build/lib/queryObserver.js +0 -584
  130. package/build/lib/queryObserver.js.map +0 -1
  131. package/build/lib/queryObserver.mjs +0 -580
  132. package/build/lib/queryObserver.mjs.map +0 -1
  133. package/build/lib/removable.d.ts.map +0 -1
  134. package/build/lib/removable.esm.js +0 -33
  135. package/build/lib/removable.esm.js.map +0 -1
  136. package/build/lib/removable.js +0 -37
  137. package/build/lib/removable.js.map +0 -1
  138. package/build/lib/removable.mjs +0 -33
  139. package/build/lib/removable.mjs.map +0 -1
  140. package/build/lib/retryer.d.ts.map +0 -1
  141. package/build/lib/retryer.esm.js +0 -167
  142. package/build/lib/retryer.esm.js.map +0 -1
  143. package/build/lib/retryer.js +0 -174
  144. package/build/lib/retryer.js.map +0 -1
  145. package/build/lib/retryer.mjs +0 -167
  146. package/build/lib/retryer.mjs.map +0 -1
  147. package/build/lib/subscribable.d.ts.map +0 -1
  148. package/build/lib/subscribable.esm.js +0 -32
  149. package/build/lib/subscribable.esm.js.map +0 -1
  150. package/build/lib/subscribable.js +0 -36
  151. package/build/lib/subscribable.js.map +0 -1
  152. package/build/lib/subscribable.mjs +0 -32
  153. package/build/lib/subscribable.mjs.map +0 -1
  154. package/build/lib/tests/focusManager.test.d.ts.map +0 -1
  155. package/build/lib/tests/hydration.test.d.ts.map +0 -1
  156. package/build/lib/tests/infiniteQueryBehavior.test.d.ts.map +0 -1
  157. package/build/lib/tests/infiniteQueryObserver.test.d.ts.map +0 -1
  158. package/build/lib/tests/mutationCache.test.d.ts.map +0 -1
  159. package/build/lib/tests/mutationObserver.test.d.ts.map +0 -1
  160. package/build/lib/tests/mutations.test.d.ts.map +0 -1
  161. package/build/lib/tests/notifyManager.test.d.ts.map +0 -1
  162. package/build/lib/tests/onlineManager.test.d.ts.map +0 -1
  163. package/build/lib/tests/queriesObserver.test.d.ts.map +0 -1
  164. package/build/lib/tests/query.test.d.ts.map +0 -1
  165. package/build/lib/tests/queryCache.test.d.ts.map +0 -1
  166. package/build/lib/tests/queryClient.test.d.ts.map +0 -1
  167. package/build/lib/tests/queryObserver.test.d.ts.map +0 -1
  168. package/build/lib/tests/utils.d.ts.map +0 -1
  169. package/build/lib/tests/utils.test.d.ts.map +0 -1
  170. package/build/lib/types.d.ts.map +0 -1
  171. package/build/lib/utils.d.ts.map +0 -1
  172. package/build/lib/utils.esm.js +0 -320
  173. package/build/lib/utils.esm.js.map +0 -1
  174. package/build/lib/utils.js +0 -350
  175. package/build/lib/utils.js.map +0 -1
  176. package/build/lib/utils.mjs +0 -320
  177. package/build/lib/utils.mjs.map +0 -1
  178. package/build/umd/index.development.js +0 -3307
  179. package/build/umd/index.development.js.map +0 -1
  180. package/build/umd/index.production.js +0 -2
  181. package/build/umd/index.production.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"mutationCache.js","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 { MutationOptions, NotifyEvent } 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: unknown,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onSuccess?: (\n data: unknown,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onMutate?: (\n variables: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onSettled?: (\n data: unknown | undefined,\n error: unknown | null,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\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\ntype 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 config: MutationCacheConfig\n\n private mutations: Mutation<any, any, any, any>[]\n private mutationId: number\n private resuming: Promise<unknown> | undefined\n\n constructor(config?: MutationCacheConfig) {\n super()\n this.config = config || {}\n this.mutations = []\n this.mutationId = 0\n }\n\n build<TData, TError, TVariables, TContext>(\n client: QueryClient,\n options: MutationOptions<TData, TError, TVariables, TContext>,\n state?: MutationState<TData, TError, TVariables, TContext>,\n ): Mutation<TData, TError, TVariables, TContext> {\n const mutation = new Mutation({\n mutationCache: this,\n logger: client.getLogger(),\n mutationId: ++this.mutationId,\n options: client.defaultMutationOptions(options),\n state,\n defaultOptions: options.mutationKey\n ? client.getMutationDefaults(options.mutationKey)\n : undefined,\n })\n\n this.add(mutation)\n\n return mutation\n }\n\n add(mutation: Mutation<any, any, any, any>): void {\n this.mutations.push(mutation)\n this.notify({ type: 'added', mutation })\n }\n\n remove(mutation: Mutation<any, any, any, any>): void {\n this.mutations = this.mutations.filter((x) => x !== mutation)\n this.notify({ type: 'removed', mutation })\n }\n\n clear(): void {\n notifyManager.batch(() => {\n this.mutations.forEach((mutation) => {\n this.remove(mutation)\n })\n })\n }\n\n getAll(): Mutation[] {\n return this.mutations\n }\n\n find<TData = unknown, TError = unknown, TVariables = any, TContext = unknown>(\n filters: MutationFilters,\n ): Mutation<TData, TError, TVariables, TContext> | undefined {\n if (typeof filters.exact === 'undefined') {\n filters.exact = true\n }\n\n return this.mutations.find((mutation) => matchMutation(filters, mutation))\n }\n\n findAll(filters: MutationFilters): Mutation[] {\n return this.mutations.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 this.resuming = (this.resuming ?? Promise.resolve())\n .then(() => {\n const pausedMutations = this.mutations.filter((x) => x.state.isPaused)\n return notifyManager.batch(() =>\n pausedMutations.reduce(\n (promise, mutation) =>\n promise.then(() => mutation.continue().catch(noop)),\n Promise.resolve() as Promise<unknown>,\n ),\n )\n })\n .then(() => {\n this.resuming = undefined\n })\n\n return this.resuming\n }\n}\n"],"names":["MutationCache","Subscribable","constructor","config","mutations","mutationId","build","client","options","state","mutation","Mutation","mutationCache","logger","getLogger","defaultMutationOptions","defaultOptions","mutationKey","getMutationDefaults","undefined","add","push","notify","type","remove","filter","x","clear","notifyManager","batch","forEach","getAll","find","filters","exact","matchMutation","findAll","event","listeners","listener","resumePausedMutations","resuming","Promise","resolve","then","pausedMutations","isPaused","reduce","promise","continue","catch","noop"],"mappings":";;;;;;;;;AAiFA;AAEO,MAAMA,aAAN,SAA4BC,yBAA5B,CAAgE;EAOrEC,WAAW,CAACC,MAAD,EAA+B;AACxC,IAAA,KAAA,EAAA,CAAA;AACA,IAAA,IAAA,CAAKA,MAAL,GAAcA,MAAM,IAAI,EAAxB,CAAA;IACA,IAAKC,CAAAA,SAAL,GAAiB,EAAjB,CAAA;IACA,IAAKC,CAAAA,UAAL,GAAkB,CAAlB,CAAA;AACD,GAAA;;AAEDC,EAAAA,KAAK,CACHC,MADG,EAEHC,OAFG,EAGHC,KAHG,EAI4C;AAC/C,IAAA,MAAMC,UAAQ,GAAG,IAAIC,iBAAJ,CAAa;AAC5BC,MAAAA,aAAa,EAAE,IADa;AAE5BC,MAAAA,MAAM,EAAEN,MAAM,CAACO,SAAP,EAFoB;MAG5BT,UAAU,EAAE,EAAE,IAAA,CAAKA,UAHS;AAI5BG,MAAAA,OAAO,EAAED,MAAM,CAACQ,sBAAP,CAA8BP,OAA9B,CAJmB;MAK5BC,KAL4B;AAM5BO,MAAAA,cAAc,EAAER,OAAO,CAACS,WAAR,GACZV,MAAM,CAACW,mBAAP,CAA2BV,OAAO,CAACS,WAAnC,CADY,GAEZE,SAAAA;AARwB,KAAb,CAAjB,CAAA;IAWA,IAAKC,CAAAA,GAAL,CAASV,UAAT,CAAA,CAAA;AAEA,IAAA,OAAOA,UAAP,CAAA;AACD,GAAA;;EAEDU,GAAG,CAACV,QAAD,EAA+C;AAChD,IAAA,IAAA,CAAKN,SAAL,CAAeiB,IAAf,CAAoBX,QAApB,CAAA,CAAA;AACA,IAAA,IAAA,CAAKY,MAAL,CAAY;AAAEC,MAAAA,IAAI,EAAE,OAAR;AAAiBb,MAAAA,QAAAA;KAA7B,CAAA,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,QAAAA;AAAF,OAAD,KAAkB;QACvCA,QAAQ,CAACF,KAAD,CAAR,CAAA;OADF,CAAA,CAAA;KADF,CAAA,CAAA;AAKD,GAAA;;AAEDG,EAAAA,qBAAqB,GAAqB;AAAA,IAAA,IAAA,cAAA,CAAA;;AACxC,IAAA,IAAA,CAAKC,QAAL,GAAgB,CAAC,CAAA,cAAA,GAAA,IAAA,CAAKA,QAAN,KAAA,IAAA,GAAA,cAAA,GAAkBC,OAAO,CAACC,OAAR,EAAlB,EACbC,IADa,CACR,MAAM;AACV,MAAA,MAAMC,eAAe,GAAG,IAAKzC,CAAAA,SAAL,CAAeqB,MAAf,CAAuBC,CAAD,IAAOA,CAAC,CAACjB,KAAF,CAAQqC,QAArC,CAAxB,CAAA;AACA,MAAA,OAAOlB,2BAAa,CAACC,KAAd,CAAoB,MACzBgB,eAAe,CAACE,MAAhB,CACE,CAACC,OAAD,EAAUtC,QAAV,KACEsC,OAAO,CAACJ,IAAR,CAAa,MAAMlC,QAAQ,CAACuC,QAAT,EAAA,CAAoBC,KAApB,CAA0BC,UAA1B,CAAnB,CAFJ,EAGET,OAAO,CAACC,OAAR,EAHF,CADK,CAAP,CAAA;KAHY,CAAA,CAWbC,IAXa,CAWR,MAAM;MACV,IAAKH,CAAAA,QAAL,GAAgBtB,SAAhB,CAAA;AACD,KAba,CAAhB,CAAA;AAeA,IAAA,OAAO,KAAKsB,QAAZ,CAAA;AACD,GAAA;;AAhGoE;;;;"}
@@ -1,93 +0,0 @@
1
- import { notifyManager } from './notifyManager.mjs';
2
- import { Mutation } from './mutation.mjs';
3
- import { matchMutation, noop } from './utils.mjs';
4
- import { Subscribable } from './subscribable.mjs';
5
-
6
- // CLASS
7
- class MutationCache extends Subscribable {
8
- constructor(config) {
9
- super();
10
- this.config = config || {};
11
- this.mutations = [];
12
- this.mutationId = 0;
13
- }
14
-
15
- build(client, options, state) {
16
- const mutation = new Mutation({
17
- mutationCache: this,
18
- logger: client.getLogger(),
19
- mutationId: ++this.mutationId,
20
- options: client.defaultMutationOptions(options),
21
- state,
22
- defaultOptions: options.mutationKey ? client.getMutationDefaults(options.mutationKey) : undefined
23
- });
24
- this.add(mutation);
25
- return mutation;
26
- }
27
-
28
- add(mutation) {
29
- this.mutations.push(mutation);
30
- this.notify({
31
- type: 'added',
32
- mutation
33
- });
34
- }
35
-
36
- remove(mutation) {
37
- this.mutations = this.mutations.filter(x => x !== mutation);
38
- this.notify({
39
- type: 'removed',
40
- mutation
41
- });
42
- }
43
-
44
- clear() {
45
- notifyManager.batch(() => {
46
- this.mutations.forEach(mutation => {
47
- this.remove(mutation);
48
- });
49
- });
50
- }
51
-
52
- getAll() {
53
- return this.mutations;
54
- }
55
-
56
- find(filters) {
57
- if (typeof filters.exact === 'undefined') {
58
- filters.exact = true;
59
- }
60
-
61
- return this.mutations.find(mutation => matchMutation(filters, mutation));
62
- }
63
-
64
- findAll(filters) {
65
- return this.mutations.filter(mutation => matchMutation(filters, mutation));
66
- }
67
-
68
- notify(event) {
69
- notifyManager.batch(() => {
70
- this.listeners.forEach(({
71
- listener
72
- }) => {
73
- listener(event);
74
- });
75
- });
76
- }
77
-
78
- resumePausedMutations() {
79
- var _this$resuming;
80
-
81
- this.resuming = ((_this$resuming = this.resuming) != null ? _this$resuming : Promise.resolve()).then(() => {
82
- const pausedMutations = this.mutations.filter(x => x.state.isPaused);
83
- return notifyManager.batch(() => pausedMutations.reduce((promise, mutation) => promise.then(() => mutation.continue().catch(noop)), Promise.resolve()));
84
- }).then(() => {
85
- this.resuming = undefined;
86
- });
87
- return this.resuming;
88
- }
89
-
90
- }
91
-
92
- export { MutationCache };
93
- //# sourceMappingURL=mutationCache.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mutationCache.mjs","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 { MutationOptions, NotifyEvent } 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: unknown,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onSuccess?: (\n data: unknown,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onMutate?: (\n variables: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onSettled?: (\n data: unknown | undefined,\n error: unknown | null,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\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\ntype 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 config: MutationCacheConfig\n\n private mutations: Mutation<any, any, any, any>[]\n private mutationId: number\n private resuming: Promise<unknown> | undefined\n\n constructor(config?: MutationCacheConfig) {\n super()\n this.config = config || {}\n this.mutations = []\n this.mutationId = 0\n }\n\n build<TData, TError, TVariables, TContext>(\n client: QueryClient,\n options: MutationOptions<TData, TError, TVariables, TContext>,\n state?: MutationState<TData, TError, TVariables, TContext>,\n ): Mutation<TData, TError, TVariables, TContext> {\n const mutation = new Mutation({\n mutationCache: this,\n logger: client.getLogger(),\n mutationId: ++this.mutationId,\n options: client.defaultMutationOptions(options),\n state,\n defaultOptions: options.mutationKey\n ? client.getMutationDefaults(options.mutationKey)\n : undefined,\n })\n\n this.add(mutation)\n\n return mutation\n }\n\n add(mutation: Mutation<any, any, any, any>): void {\n this.mutations.push(mutation)\n this.notify({ type: 'added', mutation })\n }\n\n remove(mutation: Mutation<any, any, any, any>): void {\n this.mutations = this.mutations.filter((x) => x !== mutation)\n this.notify({ type: 'removed', mutation })\n }\n\n clear(): void {\n notifyManager.batch(() => {\n this.mutations.forEach((mutation) => {\n this.remove(mutation)\n })\n })\n }\n\n getAll(): Mutation[] {\n return this.mutations\n }\n\n find<TData = unknown, TError = unknown, TVariables = any, TContext = unknown>(\n filters: MutationFilters,\n ): Mutation<TData, TError, TVariables, TContext> | undefined {\n if (typeof filters.exact === 'undefined') {\n filters.exact = true\n }\n\n return this.mutations.find((mutation) => matchMutation(filters, mutation))\n }\n\n findAll(filters: MutationFilters): Mutation[] {\n return this.mutations.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 this.resuming = (this.resuming ?? Promise.resolve())\n .then(() => {\n const pausedMutations = this.mutations.filter((x) => x.state.isPaused)\n return notifyManager.batch(() =>\n pausedMutations.reduce(\n (promise, mutation) =>\n promise.then(() => mutation.continue().catch(noop)),\n Promise.resolve() as Promise<unknown>,\n ),\n )\n })\n .then(() => {\n this.resuming = undefined\n })\n\n return this.resuming\n }\n}\n"],"names":["MutationCache","Subscribable","constructor","config","mutations","mutationId","build","client","options","state","mutation","Mutation","mutationCache","logger","getLogger","defaultMutationOptions","defaultOptions","mutationKey","getMutationDefaults","undefined","add","push","notify","type","remove","filter","x","clear","notifyManager","batch","forEach","getAll","find","filters","exact","matchMutation","findAll","event","listeners","listener","resumePausedMutations","resuming","Promise","resolve","then","pausedMutations","isPaused","reduce","promise","continue","catch","noop"],"mappings":";;;;;AAiFA;AAEO,MAAMA,aAAN,SAA4BC,YAA5B,CAAgE;EAOrEC,WAAW,CAACC,MAAD,EAA+B;AACxC,IAAA,KAAA,EAAA,CAAA;AACA,IAAA,IAAA,CAAKA,MAAL,GAAcA,MAAM,IAAI,EAAxB,CAAA;IACA,IAAKC,CAAAA,SAAL,GAAiB,EAAjB,CAAA;IACA,IAAKC,CAAAA,UAAL,GAAkB,CAAlB,CAAA;AACD,GAAA;;AAEDC,EAAAA,KAAK,CACHC,MADG,EAEHC,OAFG,EAGHC,KAHG,EAI4C;AAC/C,IAAA,MAAMC,QAAQ,GAAG,IAAIC,QAAJ,CAAa;AAC5BC,MAAAA,aAAa,EAAE,IADa;AAE5BC,MAAAA,MAAM,EAAEN,MAAM,CAACO,SAAP,EAFoB;MAG5BT,UAAU,EAAE,EAAE,IAAA,CAAKA,UAHS;AAI5BG,MAAAA,OAAO,EAAED,MAAM,CAACQ,sBAAP,CAA8BP,OAA9B,CAJmB;MAK5BC,KAL4B;AAM5BO,MAAAA,cAAc,EAAER,OAAO,CAACS,WAAR,GACZV,MAAM,CAACW,mBAAP,CAA2BV,OAAO,CAACS,WAAnC,CADY,GAEZE,SAAAA;AARwB,KAAb,CAAjB,CAAA;IAWA,IAAKC,CAAAA,GAAL,CAASV,QAAT,CAAA,CAAA;AAEA,I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,QAAQ,CAAC,GAAG,IAAI;IAiB3E,gBAAgB,IAAI,sBAAsB,CACxC,KAAK,EACL,MAAM,EACN,UAAU,EACV,QAAQ,CACT;IAID,KAAK,IAAI,IAAI;IAMb,MAAM,CACJ,SAAS,CAAC,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,GAC3D,OAAO,CAAC,KAAK,CAAC;IAkBjB,OAAO,CAAC,YAAY;IA4BpB,OAAO,CAAC,MAAM;CAuCf"}
@@ -1,132 +0,0 @@
1
- import { getDefaultState } from './mutation.esm.js';
2
- import { notifyManager } from './notifyManager.esm.js';
3
- import { Subscribable } from './subscribable.esm.js';
4
- import { shallowEqualObjects } from './utils.esm.js';
5
-
6
- // CLASS
7
- class MutationObserver extends Subscribable {
8
- constructor(client, options) {
9
- super();
10
- this.client = client;
11
- this.setOptions(options);
12
- this.bindMethods();
13
- this.updateResult();
14
- }
15
-
16
- bindMethods() {
17
- this.mutate = this.mutate.bind(this);
18
- this.reset = this.reset.bind(this);
19
- }
20
-
21
- setOptions(options) {
22
- var _this$currentMutation;
23
-
24
- const prevOptions = this.options;
25
- this.options = this.client.defaultMutationOptions(options);
26
-
27
- if (!shallowEqualObjects(prevOptions, this.options)) {
28
- this.client.getMutationCache().notify({
29
- type: 'observerOptionsUpdated',
30
- mutation: this.currentMutation,
31
- observer: this
32
- });
33
- }
34
-
35
- (_this$currentMutation = this.currentMutation) == null ? void 0 : _this$currentMutation.setOptions(this.options);
36
- }
37
-
38
- onUnsubscribe() {
39
- if (!this.hasListeners()) {
40
- var _this$currentMutation2;
41
-
42
- (_this$currentMutation2 = this.currentMutation) == null ? void 0 : _this$currentMutation2.removeObserver(this);
43
- }
44
- }
45
-
46
- onMutationUpdate(action) {
47
- this.updateResult(); // Determine which callbacks to trigger
48
-
49
- const notifyOptions = {
50
- listeners: true
51
- };
52
-
53
- if (action.type === 'success') {
54
- notifyOptions.onSuccess = true;
55
- } else if (action.type === 'error') {
56
- notifyOptions.onError = true;
57
- }
58
-
59
- this.notify(notifyOptions);
60
- }
61
-
62
- getCurrentResult() {
63
- return this.currentResult;
64
- }
65
-
66
- reset() {
67
- this.currentMutation = undefined;
68
- this.updateResult();
69
- this.notify({
70
- listeners: true
71
- });
72
- }
73
-
74
- mutate(variables, options) {
75
- this.mutateOptions = options;
76
-
77
- if (this.currentMutation) {
78
- this.currentMutation.removeObserver(this);
79
- }
80
-
81
- this.currentMutation = this.client.getMutationCache().build(this.client, { ...this.options,
82
- variables: typeof variables !== 'undefined' ? variables : this.options.variables
83
- });
84
- this.currentMutation.addObserver(this);
85
- return this.currentMutation.execute();
86
- }
87
-
88
- updateResult() {
89
- const state = this.currentMutation ? this.currentMutation.state : getDefaultState();
90
- const result = { ...state,
91
- isLoading: state.status === 'loading',
92
- isSuccess: state.status === 'success',
93
- isError: state.status === 'error',
94
- isIdle: state.status === 'idle',
95
- mutate: this.mutate,
96
- reset: this.reset
97
- };
98
- this.currentResult = result;
99
- }
100
-
101
- notify(options) {
102
- notifyManager.batch(() => {
103
- // First trigger the mutate callbacks
104
- if (this.mutateOptions && this.hasListeners()) {
105
- if (options.onSuccess) {
106
- var _this$mutateOptions$o, _this$mutateOptions, _this$mutateOptions$o2, _this$mutateOptions2;
107
-
108
- (_this$mutateOptions$o = (_this$mutateOptions = this.mutateOptions).onSuccess) == null ? void 0 : _this$mutateOptions$o.call(_this$mutateOptions, this.currentResult.data, this.currentResult.variables, this.currentResult.context);
109
- (_this$mutateOptions$o2 = (_this$mutateOptions2 = this.mutateOptions).onSettled) == null ? void 0 : _this$mutateOptions$o2.call(_this$mutateOptions2, this.currentResult.data, null, this.currentResult.variables, this.currentResult.context);
110
- } else if (options.onError) {
111
- var _this$mutateOptions$o3, _this$mutateOptions3, _this$mutateOptions$o4, _this$mutateOptions4;
112
-
113
- (_this$mutateOptions$o3 = (_this$mutateOptions3 = this.mutateOptions).onError) == null ? void 0 : _this$mutateOptions$o3.call(_this$mutateOptions3, this.currentResult.error, this.currentResult.variables, this.currentResult.context);
114
- (_this$mutateOptions$o4 = (_this$mutateOptions4 = this.mutateOptions).onSettled) == null ? void 0 : _this$mutateOptions$o4.call(_this$mutateOptions4, undefined, this.currentResult.error, this.currentResult.variables, this.currentResult.context);
115
- }
116
- } // Then trigger the listeners
117
-
118
-
119
- if (options.listeners) {
120
- this.listeners.forEach(({
121
- listener
122
- }) => {
123
- listener(this.currentResult);
124
- });
125
- }
126
- });
127
- }
128
-
129
- }
130
-
131
- export { MutationObserver };
132
- //# sourceMappingURL=mutationObserver.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mutationObserver.esm.js","sources":["../../src/mutationObserver.ts"],"sourcesContent":["import { getDefaultState } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport { Subscribable } from './subscribable'\nimport { shallowEqualObjects } from './utils'\nimport type { QueryClient } from './queryClient'\nimport type {\n MutateOptions,\n MutationObserverBaseResult,\n MutationObserverOptions,\n MutationObserverResult,\n} from './types'\nimport type { Action, Mutation } from './mutation'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TContext> = (\n result: MutationObserverResult<TData, TError, TVariables, TContext>,\n) => void\n\ninterface NotifyOptions {\n listeners?: boolean\n onError?: boolean\n onSuccess?: boolean\n}\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n> extends Subscribable<\n MutationObserverListener<TData, TError, TVariables, TContext>\n> {\n options!: MutationObserverOptions<TData, TError, TVariables, TContext>\n\n private client: QueryClient\n private currentResult!: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n private currentMutation?: Mutation<TData, TError, TVariables, TContext>\n private mutateOptions?: MutateOptions<TData, TError, TVariables, TContext>\n\n constructor(\n client: QueryClient,\n options: MutationObserverOptions<TData, TError, TVariables, TContext>,\n ) {\n super()\n\n this.client = client\n this.setOptions(options)\n this.bindMethods()\n this.updateResult()\n }\n\n protected bindMethods(): void {\n this.mutate = this.mutate.bind(this)\n this.reset = this.reset.bind(this)\n }\n\n setOptions(\n options?: MutationObserverOptions<TData, TError, TVariables, TContext>,\n ) {\n const prevOptions = this.options\n this.options = this.client.defaultMutationOptions(options)\n if (!shallowEqualObjects(prevOptions, this.options)) {\n this.client.getMutationCache().notify({\n type: 'observerOptionsUpdated',\n mutation: this.currentMutation,\n observer: this,\n })\n }\n this.currentMutation?.setOptions(this.options)\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(action: Action<TData, TError, TVariables, TContext>): void {\n this.updateResult()\n\n // Determine which callbacks to trigger\n const notifyOptions: NotifyOptions = {\n listeners: true,\n }\n\n if (action.type === 'success') {\n notifyOptions.onSuccess = true\n } else if (action.type === 'error') {\n notifyOptions.onError = true\n }\n\n this.notify(notifyOptions)\n }\n\n getCurrentResult(): MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n > {\n return this.currentResult\n }\n\n reset(): void {\n this.currentMutation = undefined\n this.updateResult()\n this.notify({ listeners: true })\n }\n\n mutate(\n variables?: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\n ): Promise<TData> {\n this.mutateOptions = options\n\n if (this.currentMutation) {\n this.currentMutation.removeObserver(this)\n }\n\n this.currentMutation = this.client.getMutationCache().build(this.client, {\n ...this.options,\n variables:\n typeof variables !== 'undefined' ? variables : this.options.variables,\n })\n\n this.currentMutation.addObserver(this)\n\n return this.currentMutation.execute()\n }\n\n private updateResult(): void {\n const state = this.currentMutation\n ? this.currentMutation.state\n : getDefaultState<TData, TError, TVariables, TContext>()\n\n const result: MutationObserverBaseResult<\n TData,\n TError,\n TVariables,\n TContext\n > = {\n ...state,\n isLoading: state.status === 'loading',\n isSuccess: state.status === 'success',\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n mutate: this.mutate,\n reset: this.reset,\n }\n\n this.currentResult = result as MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n }\n\n private notify(options: NotifyOptions) {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.mutateOptions && this.hasListeners()) {\n if (options.onSuccess) {\n this.mutateOptions.onSuccess?.(\n this.currentResult.data!,\n this.currentResult.variables!,\n this.currentResult.context!,\n )\n this.mutateOptions.onSettled?.(\n this.currentResult.data!,\n null,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n } else if (options.onError) {\n this.mutateOptions.onError?.(\n this.currentResult.error!,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n this.mutateOptions.onSettled?.(\n undefined,\n this.currentResult.error,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n }\n }\n\n // Then trigger the listeners\n if (options.listeners) {\n this.listeners.forEach(({ listener }) => {\n listener(this.currentResult)\n })\n }\n })\n }\n}\n"],"names":["MutationObserver","Subscribable","constructor","client","options","setOptions","bindMethods","updateResult","mutate","bind","reset","prevOptions","defaultMutationOptions","shallowEqualObjects","getMutationCache","notify","type","mutation","currentMutation","observer","onUnsubscribe","hasListeners","removeObserver","onMutationUpdate","action","notifyOptions","listeners","onSuccess","onError","getCurrentResult","currentResult","undefined","variables","mutateOptions","build","addObserver","execute","state","getDefaultState","result","isLoading","status","isSuccess","isError","isIdle","notifyManager","batch","data","context","onSettled","error","forEach","listener"],"mappings":";;;;;AAyBA;AAEO,MAAMA,gBAAN,SAKGC,YALH,CAOL;AAaAC,EAAAA,WAAW,CACTC,MADS,EAETC,OAFS,EAGT;AACA,IAAA,KAAA,EAAA,CAAA;IAEA,IAAKD,CAAAA,MAAL,GAAcA,MAAd,CAAA;IACA,IAAKE,CAAAA,UAAL,CAAgBD,OAAhB,CAAA,CAAA;AACA,IAAA,IAAA,CAAKE,WAAL,EAAA,CAAA;AACA,IAAA,IAAA,CAAKC,YAAL,EAAA,CAAA;AACD,GAAA;;AAESD,EAAAA,WAAW,GAAS;IAC5B,IAAKE,CAAAA,MAAL,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ation = require('./mutation.js');
6
- var notifyManager = require('./notifyManager.js');
7
- var subscribable = require('./subscribable.js');
8
- var utils = require('./utils.js');
9
-
10
- // CLASS
11
- class MutationObserver extends subscribable.Subscribable {
12
- constructor(client, options) {
13
- super();
14
- this.client = client;
15
- this.setOptions(options);
16
- this.bindMethods();
17
- this.updateResult();
18
- }
19
-
20
- bindMethods() {
21
- this.mutate = this.mutate.bind(this);
22
- this.reset = this.reset.bind(this);
23
- }
24
-
25
- setOptions(options) {
26
- var _this$currentMutation;
27
-
28
- const prevOptions = this.options;
29
- this.options = this.client.defaultMutationOptions(options);
30
-
31
- if (!utils.shallowEqualObjects(prevOptions, this.options)) {
32
- this.client.getMutationCache().notify({
33
- type: 'observerOptionsUpdated',
34
- mutation: this.currentMutation,
35
- observer: this
36
- });
37
- }
38
-
39
- (_this$currentMutation = this.currentMutation) == null ? void 0 : _this$currentMutation.setOptions(this.options);
40
- }
41
-
42
- onUnsubscribe() {
43
- if (!this.hasListeners()) {
44
- var _this$currentMutation2;
45
-
46
- (_this$currentMutation2 = this.currentMutation) == null ? void 0 : _this$currentMutation2.removeObserver(this);
47
- }
48
- }
49
-
50
- onMutationUpdate(action) {
51
- this.updateResult(); // Determine which callbacks to trigger
52
-
53
- const notifyOptions = {
54
- listeners: true
55
- };
56
-
57
- if (action.type === 'success') {
58
- notifyOptions.onSuccess = true;
59
- } else if (action.type === 'error') {
60
- notifyOptions.onError = true;
61
- }
62
-
63
- this.notify(notifyOptions);
64
- }
65
-
66
- getCurrentResult() {
67
- return this.currentResult;
68
- }
69
-
70
- reset() {
71
- this.currentMutation = undefined;
72
- this.updateResult();
73
- this.notify({
74
- listeners: true
75
- });
76
- }
77
-
78
- mutate(variables, options) {
79
- this.mutateOptions = options;
80
-
81
- if (this.currentMutation) {
82
- this.currentMutation.removeObserver(this);
83
- }
84
-
85
- this.currentMutation = this.client.getMutationCache().build(this.client, { ...this.options,
86
- variables: typeof variables !== 'undefined' ? variables : this.options.variables
87
- });
88
- this.currentMutation.addObserver(this);
89
- return this.currentMutation.execute();
90
- }
91
-
92
- updateResult() {
93
- const state = this.currentMutation ? this.currentMutation.state : mutation.getDefaultState();
94
- const result = { ...state,
95
- isLoading: state.status === 'loading',
96
- isSuccess: state.status === 'success',
97
- isError: state.status === 'error',
98
- isIdle: state.status === 'idle',
99
- mutate: this.mutate,
100
- reset: this.reset
101
- };
102
- this.currentResult = result;
103
- }
104
-
105
- notify(options) {
106
- notifyManager.notifyManager.batch(() => {
107
- // First trigger the mutate callbacks
108
- if (this.mutateOptions && this.hasListeners()) {
109
- if (options.onSuccess) {
110
- var _this$mutateOptions$o, _this$mutateOptions, _this$mutateOptions$o2, _this$mutateOptions2;
111
-
112
- (_this$mutateOptions$o = (_this$mutateOptions = this.mutateOptions).onSuccess) == null ? void 0 : _this$mutateOptions$o.call(_this$mutateOptions, this.currentResult.data, this.currentResult.variables, this.currentResult.context);
113
- (_this$mutateOptions$o2 = (_this$mutateOptions2 = this.mutateOptions).onSettled) == null ? void 0 : _this$mutateOptions$o2.call(_this$mutateOptions2, this.currentResult.data, null, this.currentResult.variables, this.currentResult.context);
114
- } else if (options.onError) {
115
- var _this$mutateOptions$o3, _this$mutateOptions3, _this$mutateOptions$o4, _this$mutateOptions4;
116
-
117
- (_this$mutateOptions$o3 = (_this$mutateOptions3 = this.mutateOptions).onError) == null ? void 0 : _this$mutateOptions$o3.call(_this$mutateOptions3, this.currentResult.error, this.currentResult.variables, this.currentResult.context);
118
- (_this$mutateOptions$o4 = (_this$mutateOptions4 = this.mutateOptions).onSettled) == null ? void 0 : _this$mutateOptions$o4.call(_this$mutateOptions4, undefined, this.currentResult.error, this.currentResult.variables, this.currentResult.context);
119
- }
120
- } // Then trigger the listeners
121
-
122
-
123
- if (options.listeners) {
124
- this.listeners.forEach(({
125
- listener
126
- }) => {
127
- listener(this.currentResult);
128
- });
129
- }
130
- });
131
- }
132
-
133
- }
134
-
135
- exports.MutationObserver = MutationObserver;
136
- //# sourceMappingURL=mutationObserver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mutationObserver.js","sources":["../../src/mutationObserver.ts"],"sourcesContent":["import { getDefaultState } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport { Subscribable } from './subscribable'\nimport { shallowEqualObjects } from './utils'\nimport type { QueryClient } from './queryClient'\nimport type {\n MutateOptions,\n MutationObserverBaseResult,\n MutationObserverOptions,\n MutationObserverResult,\n} from './types'\nimport type { Action, Mutation } from './mutation'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TContext> = (\n result: MutationObserverResult<TData, TError, TVariables, TContext>,\n) => void\n\ninterface NotifyOptions {\n listeners?: boolean\n onError?: boolean\n onSuccess?: boolean\n}\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n> extends Subscribable<\n MutationObserverListener<TData, TError, TVariables, TContext>\n> {\n options!: MutationObserverOptions<TData, TError, TVariables, TContext>\n\n private client: QueryClient\n private currentResult!: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n private currentMutation?: Mutation<TData, TError, TVariables, TContext>\n private mutateOptions?: MutateOptions<TData, TError, TVariables, TContext>\n\n constructor(\n client: QueryClient,\n options: MutationObserverOptions<TData, TError, TVariables, TContext>,\n ) {\n super()\n\n this.client = client\n this.setOptions(options)\n this.bindMethods()\n this.updateResult()\n }\n\n protected bindMethods(): void {\n this.mutate = this.mutate.bind(this)\n this.reset = this.reset.bind(this)\n }\n\n setOptions(\n options?: MutationObserverOptions<TData, TError, TVariables, TContext>,\n ) {\n const prevOptions = this.options\n this.options = this.client.defaultMutationOptions(options)\n if (!shallowEqualObjects(prevOptions, this.options)) {\n this.client.getMutationCache().notify({\n type: 'observerOptionsUpdated',\n mutation: this.currentMutation,\n observer: this,\n })\n }\n this.currentMutation?.setOptions(this.options)\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(action: Action<TData, TError, TVariables, TContext>): void {\n this.updateResult()\n\n // Determine which callbacks to trigger\n const notifyOptions: NotifyOptions = {\n listeners: true,\n }\n\n if (action.type === 'success') {\n notifyOptions.onSuccess = true\n } else if (action.type === 'error') {\n notifyOptions.onError = true\n }\n\n this.notify(notifyOptions)\n }\n\n getCurrentResult(): MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n > {\n return this.currentResult\n }\n\n reset(): void {\n this.currentMutation = undefined\n this.updateResult()\n this.notify({ listeners: true })\n }\n\n mutate(\n variables?: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\n ): Promise<TData> {\n this.mutateOptions = options\n\n if (this.currentMutation) {\n this.currentMutation.removeObserver(this)\n }\n\n this.currentMutation = this.client.getMutationCache().build(this.client, {\n ...this.options,\n variables:\n typeof variables !== 'undefined' ? variables : this.options.variables,\n })\n\n this.currentMutation.addObserver(this)\n\n return this.currentMutation.execute()\n }\n\n private updateResult(): void {\n const state = this.currentMutation\n ? this.currentMutation.state\n : getDefaultState<TData, TError, TVariables, TContext>()\n\n const result: MutationObserverBaseResult<\n TData,\n TError,\n TVariables,\n TContext\n > = {\n ...state,\n isLoading: state.status === 'loading',\n isSuccess: state.status === 'success',\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n mutate: this.mutate,\n reset: this.reset,\n }\n\n this.currentResult = result as MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n }\n\n private notify(options: NotifyOptions) {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.mutateOptions && this.hasListeners()) {\n if (options.onSuccess) {\n this.mutateOptions.onSuccess?.(\n this.currentResult.data!,\n this.currentResult.variables!,\n this.currentResult.context!,\n )\n this.mutateOptions.onSettled?.(\n this.currentResult.data!,\n null,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n } else if (options.onError) {\n this.mutateOptions.onError?.(\n this.currentResult.error!,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n this.mutateOptions.onSettled?.(\n undefined,\n this.currentResult.error,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n }\n }\n\n // Then trigger the listeners\n if (options.listeners) {\n this.listeners.forEach(({ listener }) => {\n listener(this.currentResult)\n })\n }\n })\n }\n}\n"],"names":["MutationObserver","Subscribable","constructor","client","options","setOptions","bindMethods","updateResult","mutate","bind","reset","prevOptions","defaultMutationOptions","shallowEqualObjects","getMutationCache","notify","type","mutation","currentMutation","observer","onUnsubscribe","hasListeners","removeObserver","onMutationUpdate","action","notifyOptions","listeners","onSuccess","onError","getCurrentResult","currentResult","undefined","variables","mutateOptions","build","addObserver","execute","state","getDefaultState","result","isLoading","status","isSuccess","isError","isIdle","notifyManager","batch","data","context","onSettled","error","forEach","listener"],"mappings":";;;;;;;;;AAyBA;AAEO,MAAMA,gBAAN,SAKGC,yBALH,CAOL;AAaAC,EAAAA,WAAW,CACTC,MADS,EAETC,OAFS,EAGT;AACA,IAAA,KAAA,EAAA,CAAA;IAEA,IAAKD,CAAAA,MAAL,GAAcA,MAAd,CAAA;IACA,IAAKE,CAAAA,UAAL,CAAgBD,OAAhB,CAAA,CAAA;AACA,IAAA,IAAA,CAAKE,WAAL,EAAA,CAAA;AACA,IAAA,IAAA,CAAKC,YAAL,EAAA,CAAA;AACD,GAAA;;AAESD,EAAAA,WAAW,GAAS;IAC5B,IAAKE,CAAAA,MAAL,GAAc,IAAKA,CAAAA,MAAL,CAAYC,IAAZ,CAAiB,IAAjB,CAAd,CAAA;IACA,IAAKC,CAAAA,KAAL,GAAa,IAAKA,CAAAA,KAAL,CAAWD,IAAX,CAAgB,IAAhB,CAAb,CAAA;AACD,GAAA;;EAEDJ,UAAU,CACRD,OADQ,EAER;AAAA,IAAA,IAAA,qBAAA,CAAA;;IACA,MAAMO,WAAW,GAAG,IAAA,CAAKP,OAAzB,CAAA;IACA,IAAKA,CAAAA,OAAL,GAAe,IAAKD,CAAAA,MAAL,CAAYS,sBAAZ,CAAmCR,OAAnC,CAAf,CA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,IAAA,CAAKK,aAAL,EAAmBL,OAAnB,KACE,IAAA,GAAA,KAAA,CAAA,GAAA,sBAAA,CAAA,IAAA,CAAA,oBAAA,EAAA,IAAA,CAAKE,aAAL,CAAmBoB,KADrB,EAEE,IAAA,CAAKpB,aAAL,CAAmBE,SAFrB,EAGE,IAAKF,CAAAA,aAAL,CAAmBkB,OAHrB,CAAA,CAAA;AAKA,UAAA,CAAA,sBAAA,GAAA,CAAA,oBAAA,GAAA,IAAA,CAAKf,aAAL,EAAmBgB,SAAnB,uEACElB,SADF,EAEE,KAAKD,aAAL,CAAmBoB,KAFrB,EAGE,IAAA,CAAKpB,aAAL,CAAmBE,SAHrB,EAIE,IAAKF,CAAAA,aAAL,CAAmBkB,OAJrB,CAAA,CAAA;AAMD,SAAA;AACF,OA5BuB;;;MA+BxB,IAAI5C,OAAO,CAACsB,SAAZ,EAAuB;AACrB,QAAA,IAAA,CAAKA,SAAL,CAAeyB,OAAf,CAAuB,CAAC;AAAEC,UAAAA,QAAAA;AAAF,SAAD,KAAkB;UACvCA,QAAQ,CAAC,IAAKtB,CAAAA,aAAN,CAAR,CAAA;SADF,CAAA,CAAA;AAGD,OAAA;KAnCH,CAAA,CAAA;AAqCD,GAAA;;AA1KD;;;;"}
@@ -1,132 +0,0 @@
1
- import { getDefaultState } from './mutation.mjs';
2
- import { notifyManager } from './notifyManager.mjs';
3
- import { Subscribable } from './subscribable.mjs';
4
- import { shallowEqualObjects } from './utils.mjs';
5
-
6
- // CLASS
7
- class MutationObserver extends Subscribable {
8
- constructor(client, options) {
9
- super();
10
- this.client = client;
11
- this.setOptions(options);
12
- this.bindMethods();
13
- this.updateResult();
14
- }
15
-
16
- bindMethods() {
17
- this.mutate = this.mutate.bind(this);
18
- this.reset = this.reset.bind(this);
19
- }
20
-
21
- setOptions(options) {
22
- var _this$currentMutation;
23
-
24
- const prevOptions = this.options;
25
- this.options = this.client.defaultMutationOptions(options);
26
-
27
- if (!shallowEqualObjects(prevOptions, this.options)) {
28
- this.client.getMutationCache().notify({
29
- type: 'observerOptionsUpdated',
30
- mutation: this.currentMutation,
31
- observer: this
32
- });
33
- }
34
-
35
- (_this$currentMutation = this.currentMutation) == null ? void 0 : _this$currentMutation.setOptions(this.options);
36
- }
37
-
38
- onUnsubscribe() {
39
- if (!this.hasListeners()) {
40
- var _this$currentMutation2;
41
-
42
- (_this$currentMutation2 = this.currentMutation) == null ? void 0 : _this$currentMutation2.removeObserver(this);
43
- }
44
- }
45
-
46
- onMutationUpdate(action) {
47
- this.updateResult(); // Determine which callbacks to trigger
48
-
49
- const notifyOptions = {
50
- listeners: true
51
- };
52
-
53
- if (action.type === 'success') {
54
- notifyOptions.onSuccess = true;
55
- } else if (action.type === 'error') {
56
- notifyOptions.onError = true;
57
- }
58
-
59
- this.notify(notifyOptions);
60
- }
61
-
62
- getCurrentResult() {
63
- return this.currentResult;
64
- }
65
-
66
- reset() {
67
- this.currentMutation = undefined;
68
- this.updateResult();
69
- this.notify({
70
- listeners: true
71
- });
72
- }
73
-
74
- mutate(variables, options) {
75
- this.mutateOptions = options;
76
-
77
- if (this.currentMutation) {
78
- this.currentMutation.removeObserver(this);
79
- }
80
-
81
- this.currentMutation = this.client.getMutationCache().build(this.client, { ...this.options,
82
- variables: typeof variables !== 'undefined' ? variables : this.options.variables
83
- });
84
- this.currentMutation.addObserver(this);
85
- return this.currentMutation.execute();
86
- }
87
-
88
- updateResult() {
89
- const state = this.currentMutation ? this.currentMutation.state : getDefaultState();
90
- const result = { ...state,
91
- isLoading: state.status === 'loading',
92
- isSuccess: state.status === 'success',
93
- isError: state.status === 'error',
94
- isIdle: state.status === 'idle',
95
- mutate: this.mutate,
96
- reset: this.reset
97
- };
98
- this.currentResult = result;
99
- }
100
-
101
- notify(options) {
102
- notifyManager.batch(() => {
103
- // First trigger the mutate callbacks
104
- if (this.mutateOptions && this.hasListeners()) {
105
- if (options.onSuccess) {
106
- var _this$mutateOptions$o, _this$mutateOptions, _this$mutateOptions$o2, _this$mutateOptions2;
107
-
108
- (_this$mutateOptions$o = (_this$mutateOptions = this.mutateOptions).onSuccess) == null ? void 0 : _this$mutateOptions$o.call(_this$mutateOptions, this.currentResult.data, this.currentResult.variables, this.currentResult.context);
109
- (_this$mutateOptions$o2 = (_this$mutateOptions2 = this.mutateOptions).onSettled) == null ? void 0 : _this$mutateOptions$o2.call(_this$mutateOptions2, this.currentResult.data, null, this.currentResult.variables, this.currentResult.context);
110
- } else if (options.onError) {
111
- var _this$mutateOptions$o3, _this$mutateOptions3, _this$mutateOptions$o4, _this$mutateOptions4;
112
-
113
- (_this$mutateOptions$o3 = (_this$mutateOptions3 = this.mutateOptions).onError) == null ? void 0 : _this$mutateOptions$o3.call(_this$mutateOptions3, this.currentResult.error, this.currentResult.variables, this.currentResult.context);
114
- (_this$mutateOptions$o4 = (_this$mutateOptions4 = this.mutateOptions).onSettled) == null ? void 0 : _this$mutateOptions$o4.call(_this$mutateOptions4, undefined, this.currentResult.error, this.currentResult.variables, this.currentResult.context);
115
- }
116
- } // Then trigger the listeners
117
-
118
-
119
- if (options.listeners) {
120
- this.listeners.forEach(({
121
- listener
122
- }) => {
123
- listener(this.currentResult);
124
- });
125
- }
126
- });
127
- }
128
-
129
- }
130
-
131
- export { MutationObserver };
132
- //# sourceMappingURL=mutationObserver.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mutationObserver.mjs","sources":["../../src/mutationObserver.ts"],"sourcesContent":["import { getDefaultState } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport { Subscribable } from './subscribable'\nimport { shallowEqualObjects } from './utils'\nimport type { QueryClient } from './queryClient'\nimport type {\n MutateOptions,\n MutationObserverBaseResult,\n MutationObserverOptions,\n MutationObserverResult,\n} from './types'\nimport type { Action, Mutation } from './mutation'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TContext> = (\n result: MutationObserverResult<TData, TError, TVariables, TContext>,\n) => void\n\ninterface NotifyOptions {\n listeners?: boolean\n onError?: boolean\n onSuccess?: boolean\n}\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = unknown,\n TVariables = void,\n TContext = unknown,\n> extends Subscribable<\n MutationObserverListener<TData, TError, TVariables, TContext>\n> {\n options!: MutationObserverOptions<TData, TError, TVariables, TContext>\n\n private client: QueryClient\n private currentResult!: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n private currentMutation?: Mutation<TData, TError, TVariables, TContext>\n private mutateOptions?: MutateOptions<TData, TError, TVariables, TContext>\n\n constructor(\n client: QueryClient,\n options: MutationObserverOptions<TData, TError, TVariables, TContext>,\n ) {\n super()\n\n this.client = client\n this.setOptions(options)\n this.bindMethods()\n this.updateResult()\n }\n\n protected bindMethods(): void {\n this.mutate = this.mutate.bind(this)\n this.reset = this.reset.bind(this)\n }\n\n setOptions(\n options?: MutationObserverOptions<TData, TError, TVariables, TContext>,\n ) {\n const prevOptions = this.options\n this.options = this.client.defaultMutationOptions(options)\n if (!shallowEqualObjects(prevOptions, this.options)) {\n this.client.getMutationCache().notify({\n type: 'observerOptionsUpdated',\n mutation: this.currentMutation,\n observer: this,\n })\n }\n this.currentMutation?.setOptions(this.options)\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(action: Action<TData, TError, TVariables, TContext>): void {\n this.updateResult()\n\n // Determine which callbacks to trigger\n const notifyOptions: NotifyOptions = {\n listeners: true,\n }\n\n if (action.type === 'success') {\n notifyOptions.onSuccess = true\n } else if (action.type === 'error') {\n notifyOptions.onError = true\n }\n\n this.notify(notifyOptions)\n }\n\n getCurrentResult(): MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n > {\n return this.currentResult\n }\n\n reset(): void {\n this.currentMutation = undefined\n this.updateResult()\n this.notify({ listeners: true })\n }\n\n mutate(\n variables?: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\n ): Promise<TData> {\n this.mutateOptions = options\n\n if (this.currentMutation) {\n this.currentMutation.removeObserver(this)\n }\n\n this.currentMutation = this.client.getMutationCache().build(this.client, {\n ...this.options,\n variables:\n typeof variables !== 'undefined' ? variables : this.options.variables,\n })\n\n this.currentMutation.addObserver(this)\n\n return this.currentMutation.execute()\n }\n\n private updateResult(): void {\n const state = this.currentMutation\n ? this.currentMutation.state\n : getDefaultState<TData, TError, TVariables, TContext>()\n\n const result: MutationObserverBaseResult<\n TData,\n TError,\n TVariables,\n TContext\n > = {\n ...state,\n isLoading: state.status === 'loading',\n isSuccess: state.status === 'success',\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n mutate: this.mutate,\n reset: this.reset,\n }\n\n this.currentResult = result as MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n }\n\n private notify(options: NotifyOptions) {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.mutateOptions && this.hasListeners()) {\n if (options.onSuccess) {\n this.mutateOptions.onSuccess?.(\n this.currentResult.data!,\n this.currentResult.variables!,\n this.currentResult.context!,\n )\n this.mutateOptions.onSettled?.(\n this.currentResult.data!,\n null,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n } else if (options.onError) {\n this.mutateOptions.onError?.(\n this.currentResult.error!,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n this.mutateOptions.onSettled?.(\n undefined,\n this.currentResult.error,\n this.currentResult.variables!,\n this.currentResult.context,\n )\n }\n }\n\n // Then trigger the listeners\n if (options.listeners) {\n this.listeners.forEach(({ listener }) => {\n listener(this.currentResult)\n })\n }\n })\n }\n}\n"],"names":["MutationObserver","Subscribable","constructor","client","options","setOptions","bindMethods","updateResult","mutate","bind","reset","prevOptions","defaultMutationOptions","shallowEqualObjects","getMutationCache","notify","type","mutation","currentMutation","observer","onUnsubscribe","hasListeners","removeObserver","onMutationUpdate","action","notifyOptions","listeners","onSuccess","onError","getCurrentResult","currentResult","undefined","variables","mutateOptions","build","addObserver","execute","state","getDefaultState","result","isLoading","status","isSuccess","isError","isIdle","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