@tanstack/query-core 5.0.0-alpha.5 → 5.0.0-alpha.51
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.
- package/build/lib/{focusManager.esm.js → focusManager.cjs} +9 -6
- package/build/lib/{focusManager.mjs.map → focusManager.cjs.map} +1 -1
- package/build/lib/focusManager.d.ts +2 -1
- package/build/lib/focusManager.d.ts.map +1 -0
- package/build/lib/focusManager.js +5 -8
- package/build/lib/focusManager.js.map +1 -1
- package/build/lib/{hydration.mjs → hydration.cjs} +11 -20
- package/build/lib/hydration.cjs.map +1 -0
- package/build/lib/hydration.d.ts +3 -6
- package/build/lib/hydration.d.ts.map +1 -0
- package/build/lib/hydration.js +5 -24
- package/build/lib/hydration.js.map +1 -1
- package/build/lib/index.cjs +40 -0
- package/build/lib/index.cjs.map +1 -0
- package/build/lib/index.d.ts +5 -3
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +13 -39
- package/build/lib/index.js.map +1 -1
- package/build/lib/{infiniteQueryBehavior.esm.js → infiniteQueryBehavior.cjs} +9 -4
- package/build/lib/infiniteQueryBehavior.cjs.map +1 -0
- package/build/lib/infiniteQueryBehavior.d.ts +1 -0
- package/build/lib/infiniteQueryBehavior.d.ts.map +1 -0
- package/build/lib/infiniteQueryBehavior.js +4 -7
- package/build/lib/infiniteQueryBehavior.js.map +1 -1
- package/build/lib/{infiniteQueryObserver.esm.js → infiniteQueryObserver.cjs} +11 -9
- package/build/lib/{infiniteQueryObserver.mjs.map → infiniteQueryObserver.cjs.map} +1 -1
- package/build/lib/infiniteQueryObserver.d.ts +2 -1
- package/build/lib/infiniteQueryObserver.d.ts.map +1 -0
- package/build/lib/infiniteQueryObserver.js +8 -10
- package/build/lib/infiniteQueryObserver.js.map +1 -1
- package/build/lib/{mutation.esm.js → mutation.cjs} +12 -9
- package/build/lib/{mutation.mjs.map → mutation.cjs.map} +1 -1
- package/build/lib/mutation.d.ts +2 -1
- package/build/lib/mutation.d.ts.map +1 -0
- package/build/lib/mutation.js +8 -11
- package/build/lib/mutation.js.map +1 -1
- package/build/lib/{mutationCache.esm.js → mutationCache.cjs} +21 -18
- package/build/lib/mutationCache.cjs.map +1 -0
- package/build/lib/mutationCache.d.ts +3 -2
- package/build/lib/mutationCache.d.ts.map +1 -0
- package/build/lib/mutationCache.js +18 -19
- package/build/lib/mutationCache.js.map +1 -1
- package/build/lib/{mutationObserver.esm.js → mutationObserver.cjs} +13 -11
- package/build/lib/mutationObserver.cjs.map +1 -0
- package/build/lib/mutationObserver.d.ts +2 -1
- package/build/lib/mutationObserver.d.ts.map +1 -0
- package/build/lib/mutationObserver.js +10 -12
- package/build/lib/mutationObserver.js.map +1 -1
- package/build/lib/{notifyManager.esm.js → notifyManager.cjs} +8 -5
- package/build/lib/{notifyManager.mjs.map → notifyManager.cjs.map} +1 -1
- package/build/lib/notifyManager.d.ts +4 -3
- package/build/lib/notifyManager.d.ts.map +1 -0
- package/build/lib/notifyManager.js +4 -7
- package/build/lib/notifyManager.js.map +1 -1
- package/build/lib/{onlineManager.esm.js → onlineManager.cjs} +9 -6
- package/build/lib/{onlineManager.mjs.map → onlineManager.cjs.map} +1 -1
- package/build/lib/onlineManager.d.ts +2 -1
- package/build/lib/onlineManager.d.ts.map +1 -0
- package/build/lib/onlineManager.js +5 -8
- package/build/lib/onlineManager.js.map +1 -1
- package/build/lib/{queriesObserver.esm.js → queriesObserver.cjs} +50 -25
- package/build/lib/queriesObserver.cjs.map +1 -0
- package/build/lib/queriesObserver.d.ts +14 -6
- package/build/lib/queriesObserver.d.ts.map +1 -0
- package/build/lib/queriesObserver.js +47 -26
- package/build/lib/queriesObserver.js.map +1 -1
- package/build/lib/{query.mjs → query.cjs} +20 -18
- package/build/lib/query.cjs.map +1 -0
- package/build/lib/query.d.ts +6 -4
- package/build/lib/query.d.ts.map +1 -0
- package/build/lib/query.js +17 -19
- package/build/lib/query.js.map +1 -1
- package/build/lib/{queryCache.mjs → queryCache.cjs} +28 -23
- package/build/lib/queryCache.cjs.map +1 -0
- package/build/lib/queryCache.d.ts +3 -3
- package/build/lib/queryCache.d.ts.map +1 -0
- package/build/lib/queryCache.js +24 -23
- package/build/lib/queryCache.js.map +1 -1
- package/build/lib/{queryClient.esm.js → queryClient.cjs} +50 -42
- package/build/lib/queryClient.cjs.map +1 -0
- package/build/lib/queryClient.d.ts +2 -2
- package/build/lib/queryClient.d.ts.map +1 -0
- package/build/lib/queryClient.js +46 -42
- package/build/lib/queryClient.js.map +1 -1
- package/build/lib/{queryObserver.mjs → queryObserver.cjs} +36 -46
- package/build/lib/queryObserver.cjs.map +1 -0
- package/build/lib/queryObserver.d.ts +5 -7
- package/build/lib/queryObserver.d.ts.map +1 -0
- package/build/lib/queryObserver.js +33 -47
- package/build/lib/queryObserver.js.map +1 -1
- package/build/lib/{removable.esm.js → removable.cjs} +7 -5
- package/build/lib/{removable.mjs.map → removable.cjs.map} +1 -1
- package/build/lib/removable.d.ts +1 -0
- package/build/lib/removable.d.ts.map +1 -0
- package/build/lib/removable.js +4 -6
- package/build/lib/removable.js.map +1 -1
- package/build/lib/{retryer.esm.js → retryer.cjs} +15 -8
- package/build/lib/{retryer.mjs.map → retryer.cjs.map} +1 -1
- package/build/lib/retryer.d.ts +5 -4
- package/build/lib/retryer.d.ts.map +1 -0
- package/build/lib/retryer.js +8 -11
- package/build/lib/retryer.js.map +1 -1
- package/build/lib/{subscribable.esm.js → subscribable.cjs} +8 -6
- package/build/lib/subscribable.cjs.map +1 -0
- package/build/lib/subscribable.d.ts +3 -2
- package/build/lib/subscribable.d.ts.map +1 -0
- package/build/lib/subscribable.js +5 -7
- package/build/lib/subscribable.js.map +1 -1
- package/build/lib/tests/focusManager.test.d.ts +1 -0
- package/build/lib/tests/focusManager.test.d.ts.map +1 -0
- package/build/lib/tests/hydration.test.d.ts +1 -0
- package/build/lib/tests/hydration.test.d.ts.map +1 -0
- package/build/lib/tests/infiniteQueryBehavior.test.d.ts +1 -0
- package/build/lib/tests/infiniteQueryBehavior.test.d.ts.map +1 -0
- package/build/lib/tests/infiniteQueryObserver.test.d.ts +1 -0
- package/build/lib/tests/infiniteQueryObserver.test.d.ts.map +1 -0
- package/build/lib/tests/mutationCache.test.d.ts +1 -0
- package/build/lib/tests/mutationCache.test.d.ts.map +1 -0
- package/build/lib/tests/mutationObserver.test.d.ts +1 -0
- package/build/lib/tests/mutationObserver.test.d.ts.map +1 -0
- package/build/lib/tests/mutations.test.d.ts +1 -0
- package/build/lib/tests/mutations.test.d.ts.map +1 -0
- package/build/lib/tests/notifyManager.test.d.ts +1 -0
- package/build/lib/tests/notifyManager.test.d.ts.map +1 -0
- package/build/lib/tests/onlineManager.test.d.ts +1 -0
- package/build/lib/tests/onlineManager.test.d.ts.map +1 -0
- package/build/lib/tests/queriesObserver.test.d.ts +1 -0
- package/build/lib/tests/queriesObserver.test.d.ts.map +1 -0
- package/build/lib/tests/query.test.d.ts +1 -0
- package/build/lib/tests/query.test.d.ts.map +1 -0
- package/build/lib/tests/queryCache.test.d.ts +1 -0
- package/build/lib/tests/queryCache.test.d.ts.map +1 -0
- package/build/lib/tests/queryClient.test.d.ts +1 -0
- package/build/lib/tests/queryClient.test.d.ts.map +1 -0
- package/build/lib/tests/queryObserver.test.d.ts +1 -0
- package/build/lib/tests/queryObserver.test.d.ts.map +1 -0
- package/build/lib/tests/utils.d.ts +3 -2
- package/build/lib/tests/utils.d.ts.map +1 -0
- package/build/lib/tests/utils.test.d.ts +1 -0
- package/build/lib/tests/utils.test.d.ts.map +1 -0
- package/build/lib/types.d.ts +35 -45
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/{utils.esm.js → utils.cjs} +23 -2
- package/build/lib/{utils.mjs.map → utils.cjs.map} +1 -1
- package/build/lib/utils.d.ts +4 -3
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +1 -22
- package/build/lib/utils.js.map +1 -1
- package/package.json +12 -9
- package/src/hydration.ts +18 -37
- package/src/index.ts +3 -4
- package/src/infiniteQueryBehavior.ts +1 -0
- package/src/mutationCache.ts +4 -4
- package/src/mutationObserver.ts +1 -1
- package/src/queriesObserver.ts +74 -24
- package/src/query.ts +7 -5
- package/src/queryCache.ts +5 -8
- package/src/queryClient.ts +20 -20
- package/src/queryObserver.ts +43 -51
- package/src/subscribable.ts +5 -5
- package/src/tests/hydration.test.tsx +7 -3
- package/src/tests/infiniteQueryBehavior.test.tsx +9 -0
- package/src/tests/query.test.tsx +1 -1
- package/src/tests/queryCache.test.tsx +1 -19
- package/src/tests/queryClient.test.tsx +39 -3
- package/src/tests/queryObserver.test.tsx +121 -0
- package/src/types.ts +15 -20
- package/build/lib/focusManager.esm.js.map +0 -1
- package/build/lib/focusManager.mjs +0 -71
- package/build/lib/hydration.esm.js +0 -98
- package/build/lib/hydration.esm.js.map +0 -1
- package/build/lib/hydration.mjs.map +0 -1
- package/build/lib/index.esm.js +0 -14
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.mjs +0 -14
- package/build/lib/index.mjs.map +0 -1
- package/build/lib/infiniteQueryBehavior.esm.js.map +0 -1
- package/build/lib/infiniteQueryBehavior.mjs +0 -125
- package/build/lib/infiniteQueryBehavior.mjs.map +0 -1
- package/build/lib/infiniteQueryObserver.esm.js.map +0 -1
- package/build/lib/infiniteQueryObserver.mjs +0 -75
- package/build/lib/mutation.esm.js.map +0 -1
- package/build/lib/mutation.mjs +0 -234
- package/build/lib/mutationCache.esm.js.map +0 -1
- package/build/lib/mutationCache.mjs +0 -82
- package/build/lib/mutationCache.mjs.map +0 -1
- package/build/lib/mutationObserver.esm.js.map +0 -1
- package/build/lib/mutationObserver.mjs +0 -96
- package/build/lib/mutationObserver.mjs.map +0 -1
- package/build/lib/notifyManager.esm.js.map +0 -1
- package/build/lib/notifyManager.mjs +0 -89
- package/build/lib/onlineManager.esm.js.map +0 -1
- package/build/lib/onlineManager.mjs +0 -73
- package/build/lib/queriesObserver.esm.js.map +0 -1
- package/build/lib/queriesObserver.mjs +0 -136
- package/build/lib/queriesObserver.mjs.map +0 -1
- package/build/lib/query.esm.js +0 -420
- package/build/lib/query.esm.js.map +0 -1
- package/build/lib/query.mjs.map +0 -1
- package/build/lib/queryCache.esm.js +0 -101
- package/build/lib/queryCache.esm.js.map +0 -1
- package/build/lib/queryCache.mjs.map +0 -1
- package/build/lib/queryClient.esm.js.map +0 -1
- package/build/lib/queryClient.mjs +0 -277
- package/build/lib/queryClient.mjs.map +0 -1
- package/build/lib/queryObserver.esm.js +0 -440
- package/build/lib/queryObserver.esm.js.map +0 -1
- package/build/lib/queryObserver.mjs.map +0 -1
- package/build/lib/removable.esm.js.map +0 -1
- package/build/lib/removable.mjs +0 -29
- package/build/lib/retryer.esm.js.map +0 -1
- package/build/lib/retryer.mjs +0 -150
- package/build/lib/subscribable.esm.js.map +0 -1
- package/build/lib/subscribable.mjs +0 -26
- package/build/lib/subscribable.mjs.map +0 -1
- package/build/lib/utils.esm.js.map +0 -1
- package/build/lib/utils.mjs +0 -227
- package/build/umd/index.development.js +0 -2682
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -2
- package/build/umd/index.production.js.map +0 -1
package/build/lib/mutation.mjs
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { notifyManager } from './notifyManager.mjs';
|
|
2
|
-
import { Removable } from './removable.mjs';
|
|
3
|
-
import { createRetryer, canFetch } from './retryer.mjs';
|
|
4
|
-
|
|
5
|
-
// TYPES
|
|
6
|
-
|
|
7
|
-
// CLASS
|
|
8
|
-
|
|
9
|
-
class Mutation extends Removable {
|
|
10
|
-
#observers;
|
|
11
|
-
#defaultOptions;
|
|
12
|
-
#mutationCache;
|
|
13
|
-
#retryer;
|
|
14
|
-
constructor(config) {
|
|
15
|
-
super();
|
|
16
|
-
this.mutationId = config.mutationId;
|
|
17
|
-
this.#defaultOptions = config.defaultOptions;
|
|
18
|
-
this.#mutationCache = config.mutationCache;
|
|
19
|
-
this.#observers = [];
|
|
20
|
-
this.state = config.state || getDefaultState();
|
|
21
|
-
this.setOptions(config.options);
|
|
22
|
-
this.scheduleGc();
|
|
23
|
-
}
|
|
24
|
-
setOptions(options) {
|
|
25
|
-
this.options = {
|
|
26
|
-
...this.#defaultOptions,
|
|
27
|
-
...options
|
|
28
|
-
};
|
|
29
|
-
this.updateGcTime(this.options.gcTime);
|
|
30
|
-
}
|
|
31
|
-
get meta() {
|
|
32
|
-
return this.options.meta;
|
|
33
|
-
}
|
|
34
|
-
addObserver(observer) {
|
|
35
|
-
if (this.#observers.indexOf(observer) === -1) {
|
|
36
|
-
this.#observers.push(observer);
|
|
37
|
-
|
|
38
|
-
// Stop the mutation from being garbage collected
|
|
39
|
-
this.clearGcTimeout();
|
|
40
|
-
this.#mutationCache.notify({
|
|
41
|
-
type: 'observerAdded',
|
|
42
|
-
mutation: this,
|
|
43
|
-
observer
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
removeObserver(observer) {
|
|
48
|
-
this.#observers = this.#observers.filter(x => x !== observer);
|
|
49
|
-
this.scheduleGc();
|
|
50
|
-
this.#mutationCache.notify({
|
|
51
|
-
type: 'observerRemoved',
|
|
52
|
-
mutation: this,
|
|
53
|
-
observer
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
optionalRemove() {
|
|
57
|
-
if (!this.#observers.length) {
|
|
58
|
-
if (this.state.status === 'pending') {
|
|
59
|
-
this.scheduleGc();
|
|
60
|
-
} else {
|
|
61
|
-
this.#mutationCache.remove(this);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
continue() {
|
|
66
|
-
return this.#retryer?.continue() ??
|
|
67
|
-
// continuing a mutation assumes that variables are set, mutation must have been dehydrated before
|
|
68
|
-
this.execute(this.state.variables);
|
|
69
|
-
}
|
|
70
|
-
async execute(variables) {
|
|
71
|
-
const executeMutation = () => {
|
|
72
|
-
this.#retryer = createRetryer({
|
|
73
|
-
fn: () => {
|
|
74
|
-
if (!this.options.mutationFn) {
|
|
75
|
-
return Promise.reject(new Error('No mutationFn found'));
|
|
76
|
-
}
|
|
77
|
-
return this.options.mutationFn(variables);
|
|
78
|
-
},
|
|
79
|
-
onFail: (failureCount, error) => {
|
|
80
|
-
this.#dispatch({
|
|
81
|
-
type: 'failed',
|
|
82
|
-
failureCount,
|
|
83
|
-
error
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
onPause: () => {
|
|
87
|
-
this.#dispatch({
|
|
88
|
-
type: 'pause'
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
onContinue: () => {
|
|
92
|
-
this.#dispatch({
|
|
93
|
-
type: 'continue'
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
retry: this.options.retry ?? 0,
|
|
97
|
-
retryDelay: this.options.retryDelay,
|
|
98
|
-
networkMode: this.options.networkMode
|
|
99
|
-
});
|
|
100
|
-
return this.#retryer.promise;
|
|
101
|
-
};
|
|
102
|
-
const restored = this.state.status === 'pending';
|
|
103
|
-
try {
|
|
104
|
-
if (!restored) {
|
|
105
|
-
this.#dispatch({
|
|
106
|
-
type: 'pending',
|
|
107
|
-
variables
|
|
108
|
-
});
|
|
109
|
-
// Notify cache callback
|
|
110
|
-
await this.#mutationCache.config.onMutate?.(variables, this);
|
|
111
|
-
const context = await this.options.onMutate?.(variables);
|
|
112
|
-
if (context !== this.state.context) {
|
|
113
|
-
this.#dispatch({
|
|
114
|
-
type: 'pending',
|
|
115
|
-
context,
|
|
116
|
-
variables
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const data = await executeMutation();
|
|
121
|
-
|
|
122
|
-
// Notify cache callback
|
|
123
|
-
await this.#mutationCache.config.onSuccess?.(data, variables, this.state.context, this);
|
|
124
|
-
await this.options.onSuccess?.(data, variables, this.state.context);
|
|
125
|
-
|
|
126
|
-
// Notify cache callback
|
|
127
|
-
await this.#mutationCache.config.onSettled?.(data, null, this.state.variables, this.state.context, this);
|
|
128
|
-
await this.options.onSettled?.(data, null, variables, this.state.context);
|
|
129
|
-
this.#dispatch({
|
|
130
|
-
type: 'success',
|
|
131
|
-
data
|
|
132
|
-
});
|
|
133
|
-
return data;
|
|
134
|
-
} catch (error) {
|
|
135
|
-
try {
|
|
136
|
-
// Notify cache callback
|
|
137
|
-
await this.#mutationCache.config.onError?.(error, variables, this.state.context, this);
|
|
138
|
-
await this.options.onError?.(error, variables, this.state.context);
|
|
139
|
-
|
|
140
|
-
// Notify cache callback
|
|
141
|
-
await this.#mutationCache.config.onSettled?.(undefined, error, this.state.variables, this.state.context, this);
|
|
142
|
-
await this.options.onSettled?.(undefined, error, variables, this.state.context);
|
|
143
|
-
throw error;
|
|
144
|
-
} finally {
|
|
145
|
-
this.#dispatch({
|
|
146
|
-
type: 'error',
|
|
147
|
-
error: error
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
#dispatch(action) {
|
|
153
|
-
const reducer = state => {
|
|
154
|
-
switch (action.type) {
|
|
155
|
-
case 'failed':
|
|
156
|
-
return {
|
|
157
|
-
...state,
|
|
158
|
-
failureCount: action.failureCount,
|
|
159
|
-
failureReason: action.error
|
|
160
|
-
};
|
|
161
|
-
case 'pause':
|
|
162
|
-
return {
|
|
163
|
-
...state,
|
|
164
|
-
isPaused: true
|
|
165
|
-
};
|
|
166
|
-
case 'continue':
|
|
167
|
-
return {
|
|
168
|
-
...state,
|
|
169
|
-
isPaused: false
|
|
170
|
-
};
|
|
171
|
-
case 'pending':
|
|
172
|
-
return {
|
|
173
|
-
...state,
|
|
174
|
-
context: action.context,
|
|
175
|
-
data: undefined,
|
|
176
|
-
failureCount: 0,
|
|
177
|
-
failureReason: null,
|
|
178
|
-
error: null,
|
|
179
|
-
isPaused: !canFetch(this.options.networkMode),
|
|
180
|
-
status: 'pending',
|
|
181
|
-
variables: action.variables,
|
|
182
|
-
submittedAt: Date.now()
|
|
183
|
-
};
|
|
184
|
-
case 'success':
|
|
185
|
-
return {
|
|
186
|
-
...state,
|
|
187
|
-
data: action.data,
|
|
188
|
-
failureCount: 0,
|
|
189
|
-
failureReason: null,
|
|
190
|
-
error: null,
|
|
191
|
-
status: 'success',
|
|
192
|
-
isPaused: false
|
|
193
|
-
};
|
|
194
|
-
case 'error':
|
|
195
|
-
return {
|
|
196
|
-
...state,
|
|
197
|
-
data: undefined,
|
|
198
|
-
error: action.error,
|
|
199
|
-
failureCount: state.failureCount + 1,
|
|
200
|
-
failureReason: action.error,
|
|
201
|
-
isPaused: false,
|
|
202
|
-
status: 'error'
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
this.state = reducer(this.state);
|
|
207
|
-
notifyManager.batch(() => {
|
|
208
|
-
this.#observers.forEach(observer => {
|
|
209
|
-
observer.onMutationUpdate(action);
|
|
210
|
-
});
|
|
211
|
-
this.#mutationCache.notify({
|
|
212
|
-
mutation: this,
|
|
213
|
-
type: 'updated',
|
|
214
|
-
action
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
function getDefaultState() {
|
|
220
|
-
return {
|
|
221
|
-
context: undefined,
|
|
222
|
-
data: undefined,
|
|
223
|
-
error: null,
|
|
224
|
-
failureCount: 0,
|
|
225
|
-
failureReason: null,
|
|
226
|
-
isPaused: false,
|
|
227
|
-
status: 'idle',
|
|
228
|
-
variables: undefined,
|
|
229
|
-
submittedAt: 0
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export { Mutation, getDefaultState };
|
|
234
|
-
//# sourceMappingURL=mutation.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutationCache.esm.js","sources":["../../src/mutationCache.ts"],"sourcesContent":["import type { MutationObserver } from './mutationObserver'\nimport type { NotifyEvent, MutationOptions, DefaultError } from './types'\nimport type { QueryClient } from './queryClient'\nimport { notifyManager } from './notifyManager'\nimport type { Action, MutationState } from './mutation'\nimport { Mutation } from './mutation'\nimport type { MutationFilters } from './utils'\nimport { matchMutation, noop } from './utils'\nimport { Subscribable } from './subscribable'\n\n// TYPES\n\ninterface MutationCacheConfig {\n onError?: (\n error: DefaultError,\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: DefaultError | 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 #mutations: Mutation<any, any, any, any>[]\n #mutationId: number\n #resuming: Promise<unknown> | undefined\n\n constructor(public config: MutationCacheConfig = {}) {\n super()\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 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.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<\n TData = unknown,\n TError = DefaultError,\n TVariables = any,\n TContext = unknown,\n >(\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) =>\n matchMutation(filters, mutation),\n )\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","build","client","options","state","mutation","Mutation","mutationCache","mutationId","defaultMutationOptions","add","push","notify","type","remove","filter","x","clear","notifyManager","batch","forEach","getAll","find","filters","exact","matchMutation","findAll","event","listeners","listener","resumePausedMutations","Promise","resolve","then","pausedMutations","isPaused","reduce","promise","continue","catch","noop","undefined"],"mappings":";;;;;AAUA;;AAuEA;;AAEO,MAAMA,aAAa,SAASC,YAAY,CAAwB;AACrE,EAAA,UAAU,CAAA;AACV,EAAA,WAAW,CAAA;AACX,EAAA,SAAS,CAAA;AAETC,EAAAA,WAAW,CAAQC,MAA2B,GAAG,EAAE,EAAE;AACnD,IAAA,KAAK,EAAE,CAAA;IAAA,IADUA,CAAAA,MAA2B,GAA3BA,MAA2B,CAAA;AAE5C,IAAA,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;AACpB,IAAA,IAAI,CAAC,WAAW,GAAG,CAAC,CAAA;AACtB,GAAA;AAEAC,EAAAA,KAAK,CACHC,MAAmB,EACnBC,OAA6D,EAC7DC,KAA0D,EACX;AAC/C,IAAA,MAAMC,QAAQ,GAAG,IAAIC,QAAQ,CAAC;AAC5BC,MAAAA,aAAa,EAAE,IAAI;AACnBC,MAAAA,UAAU,EAAE,EAAE,IAAI,CAAC,WAAW;AAC9BL,MAAAA,OAAO,EAAED,MAAM,CAACO,sBAAsB,CAACN,OAAO,CAAC;AAC/CC,MAAAA,KAAAA;AACF,KAAC,CAAC,CAAA;AAEF,IAAA,IAAI,CAACM,GAAG,CAACL,QAAQ,CAAC,CAAA;AAElB,IAAA,OAAOA,QAAQ,CAAA;AACjB,GAAA;EAEAK,GAAG,CAACL,QAAsC,EAAQ;AAChD,IAAA,IAAI,CAAC,UAAU,CAACM,IAAI,CAACN,QAAQ,CAAC,CAAA;IAC9B,IAAI,CAACO,MAAM,CA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,MAAA,IAAI,CAACS,SAAS,CAACR,OAAO,CAAES,QAAQ,IAAK;QACnCA,QAAQ,CAACF,KAAK,CAAC,CAAA;AACjB,OAAC,CAAC,CAAA;AACJ,KAAC,CAAC,CAAA;AACJ,GAAA;AAEAG,EAAAA,qBAAqB,GAAqB;AACxC,IAAA,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,SAAS,IAAIC,OAAO,CAACC,OAAO,EAAE,EAClDC,IAAI,CAAC,MAAM;AACV,MAAA,MAAMC,eAAe,GAAG,IAAI,CAAC,UAAU,CAACnB,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACZ,KAAK,CAAC+B,QAAQ,CAAC,CAAA;AACvE,MAAA,OAAOjB,aAAa,CAACC,KAAK,CAAC,MACzBe,eAAe,CAACE,MAAM,CACpB,CAACC,OAAO,EAAEhC,QAAQ,KAChBgC,OAAO,CAACJ,IAAI,CAAC,MAAM5B,QAAQ,CAACiC,QAAQ,EAAE,CAACC,KAAK,CAACC,IAAI,CAAC,CAAC,EACrDT,OAAO,CAACC,OAAO,EAAE,CAClB,CACF,CAAA;AACH,KAAC,CAAC,CACDC,IAAI,CAAC,MAAM;AACV,MAAA,IAAI,CAAC,SAAS,GAAGQ,SAAS,CAAA;AAC5B,KAAC,CAAC,CAAA;IAEJ,OAAO,IAAI,CAAC,SAAS,CAAA;AACvB,GAAA;AACF;;;;"}
|
|
@@ -1,82 +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
|
-
// TYPES
|
|
7
|
-
|
|
8
|
-
// CLASS
|
|
9
|
-
|
|
10
|
-
class MutationCache extends Subscribable {
|
|
11
|
-
#mutations;
|
|
12
|
-
#mutationId;
|
|
13
|
-
#resuming;
|
|
14
|
-
constructor(config = {}) {
|
|
15
|
-
super();
|
|
16
|
-
this.config = config;
|
|
17
|
-
this.#mutations = [];
|
|
18
|
-
this.#mutationId = 0;
|
|
19
|
-
}
|
|
20
|
-
build(client, options, state) {
|
|
21
|
-
const mutation = new Mutation({
|
|
22
|
-
mutationCache: this,
|
|
23
|
-
mutationId: ++this.#mutationId,
|
|
24
|
-
options: client.defaultMutationOptions(options),
|
|
25
|
-
state
|
|
26
|
-
});
|
|
27
|
-
this.add(mutation);
|
|
28
|
-
return mutation;
|
|
29
|
-
}
|
|
30
|
-
add(mutation) {
|
|
31
|
-
this.#mutations.push(mutation);
|
|
32
|
-
this.notify({
|
|
33
|
-
type: 'added',
|
|
34
|
-
mutation
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
remove(mutation) {
|
|
38
|
-
this.#mutations = this.#mutations.filter(x => x !== mutation);
|
|
39
|
-
this.notify({
|
|
40
|
-
type: 'removed',
|
|
41
|
-
mutation
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
clear() {
|
|
45
|
-
notifyManager.batch(() => {
|
|
46
|
-
this.#mutations.forEach(mutation => {
|
|
47
|
-
this.remove(mutation);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
getAll() {
|
|
52
|
-
return this.#mutations;
|
|
53
|
-
}
|
|
54
|
-
find(filters) {
|
|
55
|
-
if (typeof filters.exact === 'undefined') {
|
|
56
|
-
filters.exact = true;
|
|
57
|
-
}
|
|
58
|
-
return this.#mutations.find(mutation => matchMutation(filters, mutation));
|
|
59
|
-
}
|
|
60
|
-
findAll(filters = {}) {
|
|
61
|
-
return this.#mutations.filter(mutation => matchMutation(filters, mutation));
|
|
62
|
-
}
|
|
63
|
-
notify(event) {
|
|
64
|
-
notifyManager.batch(() => {
|
|
65
|
-
this.listeners.forEach(listener => {
|
|
66
|
-
listener(event);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
resumePausedMutations() {
|
|
71
|
-
this.#resuming = (this.#resuming ?? Promise.resolve()).then(() => {
|
|
72
|
-
const pausedMutations = this.#mutations.filter(x => x.state.isPaused);
|
|
73
|
-
return notifyManager.batch(() => pausedMutations.reduce((promise, mutation) => promise.then(() => mutation.continue().catch(noop)), Promise.resolve()));
|
|
74
|
-
}).then(() => {
|
|
75
|
-
this.#resuming = undefined;
|
|
76
|
-
});
|
|
77
|
-
return this.#resuming;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export { MutationCache };
|
|
82
|
-
//# sourceMappingURL=mutationCache.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutationCache.mjs","sources":["../../src/mutationCache.ts"],"sourcesContent":["import type { MutationObserver } from './mutationObserver'\nimport type { NotifyEvent, MutationOptions, DefaultError } from './types'\nimport type { QueryClient } from './queryClient'\nimport { notifyManager } from './notifyManager'\nimport type { Action, MutationState } from './mutation'\nimport { Mutation } from './mutation'\nimport type { MutationFilters } from './utils'\nimport { matchMutation, noop } from './utils'\nimport { Subscribable } from './subscribable'\n\n// TYPES\n\ninterface MutationCacheConfig {\n onError?: (\n error: DefaultError,\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: DefaultError | 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 #mutations: Mutation<any, any, any, any>[]\n #mutationId: number\n #resuming: Promise<unknown> | undefined\n\n constructor(public config: MutationCacheConfig = {}) {\n super()\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 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.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<\n TData = unknown,\n TError = DefaultError,\n TVariables = any,\n TContext = unknown,\n >(\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) =>\n matchMutation(filters, mutation),\n )\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","build","client","options","state","mutation","Mutation","mutationCache","mutationId","defaultMutationOptions","add","push","notify","type","remove","filter","x","clear","notifyManager","batch","forEach","getAll","find","filters","exact","matchMutation","findAll","event","listeners","listener","resumePausedMutations","Promise","resolve","then","pausedMutations","isPaused","reduce","promise","continue","catch","noop","undefined"],"mappings":";;;;;AAUA;;AAuEA;;AAEO,MAAMA,aAAa,SAASC,YAAY,CAAwB;AACrE,EAAA,UAAU,CAAA;AACV,EAAA,WAAW,CAAA;AACX,EAAA,SAAS,CAAA;AAETC,EAAAA,WAAW,CAAQC,MAA2B,GAAG,EAAE,EAAE;AACnD,IAAA,KAAK,EAAE,CAAA;IAAA,IADUA,CAAAA,MAA2B,GAA3BA,MAA2B,CAAA;AAE5C,IAAA,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;AACpB,IAAA,IAAI,CAAC,WAAW,GAAG,CAAC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EAAE,CAClB,CACF,CAAA;AACH,KAAC,CAAC,CACDC,IAAI,CAAC,MAAM;AACV,MAAA,IAAI,CAAC,SAAS,GAAGQ,SAAS,CAAA;AAC5B,KAAC,CAAC,CAAA;IAEJ,OAAO,IAAI,CAAC,SAAS,CAAA;AACvB,GAAA;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutationObserver.esm.js","sources":["../../src/mutationObserver.ts"],"sourcesContent":["import type { Action, Mutation } from './mutation'\nimport { getDefaultState } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport type { QueryClient } from './queryClient'\nimport { Subscribable } from './subscribable'\nimport type {\n MutateOptions,\n MutationObserverResult,\n MutationObserverOptions,\n DefaultError,\n} from './types'\nimport { shallowEqualObjects } from './utils'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TContext> = (\n result: MutationObserverResult<TData, TError, TVariables, TContext>,\n) => void\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = DefaultError,\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 #client: QueryClient\n #currentResult: MutationObserverResult<TData, TError, TVariables, TContext> =\n undefined!\n #currentMutation?: Mutation<TData, TError, TVariables, TContext>\n #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.listeners.length) {\n this.#currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(action: Action<TData, TError, TVariables, TContext>): void {\n this.#updateResult()\n\n this.#notify(action)\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()\n }\n\n mutate(\n variables: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\n ): Promise<TData> {\n this.#mutateOptions = options\n\n this.#currentMutation?.removeObserver(this)\n\n this.#currentMutation = this.#client\n .getMutationCache()\n .build(this.#client, this.options)\n\n this.#currentMutation.addObserver(this)\n\n return this.#currentMutation.execute(variables)\n }\n\n #updateResult(): void {\n const state =\n this.#currentMutation?.state ??\n getDefaultState<TData, TError, TVariables, TContext>()\n\n this.#currentResult = {\n ...state,\n isPending: state.status === 'pending',\n isSuccess: state.status === 'success',\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n mutate: this.mutate,\n reset: this.reset,\n } as MutationObserverResult<TData, TError, TVariables, TContext>\n }\n\n #notify(action?: Action<TData, TError, TVariables, TContext>): void {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.#mutateOptions && this.hasListeners()) {\n if (action?.type === 'success') {\n this.#mutateOptions.onSuccess?.(\n action.data,\n this.#currentResult.variables!,\n this.#currentResult.context!,\n )\n this.#mutateOptions.onSettled?.(\n action.data,\n null,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n } else if (action?.type === 'error') {\n this.#mutateOptions.onError?.(\n action.error,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n this.#mutateOptions.onSettled?.(\n undefined,\n action.error,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n }\n }\n\n // Then trigger the listeners\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n })\n }\n}\n"],"names":["MutationObserver","Subscribable","undefined","constructor","client","options","setOptions","bindMethods","mutate","bind","reset","prevOptions","defaultMutationOptions","shallowEqualObjects","getMutationCache","notify","type","mutation","observer","onUnsubscribe","listeners","length","removeObserver","onMutationUpdate","action","getCurrentResult","variables","build","addObserver","execute","state","getDefaultState","isPending","status","isSuccess","isError","isIdle","notifyManager","batch","hasListeners","onSuccess","data","context","onSettled","onError","error","forEach","listener"],"mappings":";;;;;AAaA;;AAMA;;AAEO,MAAMA,gBAAgB,SAKnBC,YAAY,CAEpB;AAGA,EAAA,OAAO,CAAA;EACP,cAAc,GACZC,SAAS,CAAA;AACX,EAAA,gBAAgB,CAAA;AAChB,EAAA,cAAc,CAAA;AAEdC,EAAAA,WAAW,CACTC,MAAmB,EACnBC,OAAqE,EACrE;AACA,IAAA,KAAK,EAAE,CAAA;AAEP,IAAA,IAAI,CAAC,OAAO,GAAGD,MAAM,CAAA;AACrB,IAAA,IAAI,CAACE,UAAU,CAACD,OAAO,CAAC,CAAA;IACxB,IAAI,CAACE,WAAW,EAAE,CAAA;IAClB,IAAI,CAAC,aAAa,EAAE,CAAA;AACtB,GAAA;AAEUA,EAAAA,WAAW,GAAS;IAC5B,IAAI,CAACC,MAAM,GAAG,IAAI,CAACA,MAAM,CAACC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpC,IAAI,CAACC,KAAK,GAAG,IAAI,CAACA,KAAK,CAACD,IAAI,CAAC,IAAI,CAAC,CAAA;AACpC,GAAA;EAEAH,UAAU,CACRD,OAAsE,EACtE;AACA,IAAA,MAAMM,WAAW,GAAG,IAAI,CAACN,OAAO,CAAA;IAChC,IAAI,CAACA,OAAO,GAAG,IAAI,CAAC,OAAO,CAACO,sBAAsB,CAACP,OAAO,CAAC,CAAA;IAC3D,IAAI,CAACQ,mBAAmB,CAACF,WAAW,EAAE,IAAI,CAACN,OAAO,CAAC,EAAE;MACnD,IAAI,CAAC,OAAO,CAACS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,IAAI,CAAC,cAAc,CAACnB,SAAS,EAC7B,IAAI,CAAC,cAAc,CAACgB,OAAO,CAC5B,CAAA;UACD,IAAI,CAAC,cAAc,CAACC,SAAS,GAC3BzC,SAAS,EACTsB,MAAM,CAACqB,KAAK,EACZ,IAAI,CAAC,cAAc,CAACnB,SAAS,EAC7B,IAAI,CAAC,cAAc,CAACgB,OAAO,CAC5B,CAAA;AACH,SAAA;AACF,OAAA;;AAEA;AACA,MAAA,IAAI,CAACtB,SAAS,CAAC0B,OAAO,CAAEC,QAAQ,IAAK;AACnCA,QAAAA,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;AAC/B,OAAC,CAAC,CAAA;AACJ,KAAC,CAAC,CAAA;AACJ,GAAA;AACF;;;;"}
|
|
@@ -1,96 +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
|
-
// TYPES
|
|
7
|
-
|
|
8
|
-
// CLASS
|
|
9
|
-
|
|
10
|
-
class MutationObserver extends Subscribable {
|
|
11
|
-
#client;
|
|
12
|
-
#currentResult = undefined;
|
|
13
|
-
#currentMutation;
|
|
14
|
-
#mutateOptions;
|
|
15
|
-
constructor(client, options) {
|
|
16
|
-
super();
|
|
17
|
-
this.#client = client;
|
|
18
|
-
this.setOptions(options);
|
|
19
|
-
this.bindMethods();
|
|
20
|
-
this.#updateResult();
|
|
21
|
-
}
|
|
22
|
-
bindMethods() {
|
|
23
|
-
this.mutate = this.mutate.bind(this);
|
|
24
|
-
this.reset = this.reset.bind(this);
|
|
25
|
-
}
|
|
26
|
-
setOptions(options) {
|
|
27
|
-
const prevOptions = this.options;
|
|
28
|
-
this.options = this.#client.defaultMutationOptions(options);
|
|
29
|
-
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
30
|
-
this.#client.getMutationCache().notify({
|
|
31
|
-
type: 'observerOptionsUpdated',
|
|
32
|
-
mutation: this.#currentMutation,
|
|
33
|
-
observer: this
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
this.#currentMutation?.setOptions(this.options);
|
|
37
|
-
}
|
|
38
|
-
onUnsubscribe() {
|
|
39
|
-
if (!this.listeners.length) {
|
|
40
|
-
this.#currentMutation?.removeObserver(this);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
onMutationUpdate(action) {
|
|
44
|
-
this.#updateResult();
|
|
45
|
-
this.#notify(action);
|
|
46
|
-
}
|
|
47
|
-
getCurrentResult() {
|
|
48
|
-
return this.#currentResult;
|
|
49
|
-
}
|
|
50
|
-
reset() {
|
|
51
|
-
this.#currentMutation = undefined;
|
|
52
|
-
this.#updateResult();
|
|
53
|
-
this.#notify();
|
|
54
|
-
}
|
|
55
|
-
mutate(variables, options) {
|
|
56
|
-
this.#mutateOptions = options;
|
|
57
|
-
this.#currentMutation?.removeObserver(this);
|
|
58
|
-
this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);
|
|
59
|
-
this.#currentMutation.addObserver(this);
|
|
60
|
-
return this.#currentMutation.execute(variables);
|
|
61
|
-
}
|
|
62
|
-
#updateResult() {
|
|
63
|
-
const state = this.#currentMutation?.state ?? getDefaultState();
|
|
64
|
-
this.#currentResult = {
|
|
65
|
-
...state,
|
|
66
|
-
isPending: state.status === 'pending',
|
|
67
|
-
isSuccess: state.status === 'success',
|
|
68
|
-
isError: state.status === 'error',
|
|
69
|
-
isIdle: state.status === 'idle',
|
|
70
|
-
mutate: this.mutate,
|
|
71
|
-
reset: this.reset
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
#notify(action) {
|
|
75
|
-
notifyManager.batch(() => {
|
|
76
|
-
// First trigger the mutate callbacks
|
|
77
|
-
if (this.#mutateOptions && this.hasListeners()) {
|
|
78
|
-
if (action?.type === 'success') {
|
|
79
|
-
this.#mutateOptions.onSuccess?.(action.data, this.#currentResult.variables, this.#currentResult.context);
|
|
80
|
-
this.#mutateOptions.onSettled?.(action.data, null, this.#currentResult.variables, this.#currentResult.context);
|
|
81
|
-
} else if (action?.type === 'error') {
|
|
82
|
-
this.#mutateOptions.onError?.(action.error, this.#currentResult.variables, this.#currentResult.context);
|
|
83
|
-
this.#mutateOptions.onSettled?.(undefined, action.error, this.#currentResult.variables, this.#currentResult.context);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Then trigger the listeners
|
|
88
|
-
this.listeners.forEach(listener => {
|
|
89
|
-
listener(this.#currentResult);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export { MutationObserver };
|
|
96
|
-
//# sourceMappingURL=mutationObserver.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutationObserver.mjs","sources":["../../src/mutationObserver.ts"],"sourcesContent":["import type { Action, Mutation } from './mutation'\nimport { getDefaultState } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport type { QueryClient } from './queryClient'\nimport { Subscribable } from './subscribable'\nimport type {\n MutateOptions,\n MutationObserverResult,\n MutationObserverOptions,\n DefaultError,\n} from './types'\nimport { shallowEqualObjects } from './utils'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TContext> = (\n result: MutationObserverResult<TData, TError, TVariables, TContext>,\n) => void\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = DefaultError,\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 #client: QueryClient\n #currentResult: MutationObserverResult<TData, TError, TVariables, TContext> =\n undefined!\n #currentMutation?: Mutation<TData, TError, TVariables, TContext>\n #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.listeners.length) {\n this.#currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(action: Action<TData, TError, TVariables, TContext>): void {\n this.#updateResult()\n\n this.#notify(action)\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()\n }\n\n mutate(\n variables: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\n ): Promise<TData> {\n this.#mutateOptions = options\n\n this.#currentMutation?.removeObserver(this)\n\n this.#currentMutation = this.#client\n .getMutationCache()\n .build(this.#client, this.options)\n\n this.#currentMutation.addObserver(this)\n\n return this.#currentMutation.execute(variables)\n }\n\n #updateResult(): void {\n const state =\n this.#currentMutation?.state ??\n getDefaultState<TData, TError, TVariables, TContext>()\n\n this.#currentResult = {\n ...state,\n isPending: state.status === 'pending',\n isSuccess: state.status === 'success',\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n mutate: this.mutate,\n reset: this.reset,\n } as MutationObserverResult<TData, TError, TVariables, TContext>\n }\n\n #notify(action?: Action<TData, TError, TVariables, TContext>): void {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.#mutateOptions && this.hasListeners()) {\n if (action?.type === 'success') {\n this.#mutateOptions.onSuccess?.(\n action.data,\n this.#currentResult.variables!,\n this.#currentResult.context!,\n )\n this.#mutateOptions.onSettled?.(\n action.data,\n null,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n } else if (action?.type === 'error') {\n this.#mutateOptions.onError?.(\n action.error,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n this.#mutateOptions.onSettled?.(\n undefined,\n action.error,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n }\n }\n\n // Then trigger the listeners\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n })\n }\n}\n"],"names":["MutationObserver","Subscribable","undefined","constructor","client","options","setOptions","bindMethods","mutate","bind","reset","prevOptions","defaultMutationOptions","shallowEqualObjects","getMutationCache","notify","type","mutation","observer","onUnsubscribe","listeners","length","removeObserver","onMutationUpdate","action","getCurrentResult","variables","build","addObserver","execute","state","getDefaultState","isPending","status","isSuccess","isError","isIdle","notifyManager","batch","hasListeners","onSuccess","data","context","onSettled","onError","error","forEach","listener"],"mappings":";;;;;AAaA;;AAMA;;AAEO,MAAMA,gBAAgB,SAKnBC,YAAY,CAEpB;AAGA,EAAA,OAAO,CAAA;EACP,cAAc,GACZC,SAAS,CAAA;AACX,EAAA,gBAAgB,CAAA;AAChB,EAAA,cAAc,CAAA;AAEdC,EAAAA,WAAW,CACTC,MAAmB,EACnBC,OAAqE,EACrE;AACA,IAAA,KAAK,EAAE,CAAA;AAEP,IAAA,IAAI,CAAC,OAAO,GAAGD,MAAM,CAAA;AACrB,IAAA,IAAI,CAACE,UAAU,CAACD,OAAO,CAAC,CAAA;IACxB,IAAI,CAACE,WAAW,EAAE,CAAA;IAClB,IAAI,CAAC,aAAa,EAAE,CAAA;AACtB,GAAA;AAEUA,EAAAA,WAAW,GAAS;IAC5B,IAAI,CAACC,MAAM,GAAG,IAAI,CAACA,MAAM,CAACC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpC,IAAI,CAACC,KAAK,GAAG,IAAI,CAACA,KAAK,CA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Ac,CAACgB,OAAO,CAC5B,CAAA;UACD,IAAI,CAAC,cAAc,CAACC,SAAS,GAC3BnB,MAAM,CAACiB,IAAI,EACX,IAAI,EACJ,IAAI,CAAC,cAAc,CAACf,SAAS,EAC7B,IAAI,CAAC,cAAc,CAACgB,OAAO,CAC5B,CAAA;AACH,SAAC,MAAM,IAAIlB,MAAM,EAAER,IAAI,KAAK,OAAO,EAAE;UACnC,IAAI,CAAC,cAAc,CAAC4B,OAAO,GACzBpB,MAAM,CAACqB,KAAK,EACZ,IAAI,CAAC,cAAc,CAACnB,SAAS,EAC7B,IAAI,CAAC,cAAc,CAACgB,OAAO,CAC5B,CAAA;UACD,IAAI,CAAC,cAAc,CAACC,SAAS,GAC3BzC,SAAS,EACTsB,MAAM,CAACqB,KAAK,EACZ,IAAI,CAAC,cAAc,CAACnB,SAAS,EAC7B,IAAI,CAAC,cAAc,CAACgB,OAAO,CAC5B,CAAA;AACH,SAAA;AACF,OAAA;;AAEA;AACA,MAAA,IAAI,CAACtB,SAAS,CAAC0B,OAAO,CAAEC,QAAQ,IAAK;AACnCA,QAAAA,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;AAC/B,OAAC,CAAC,CAAA;AACJ,KAAC,CAAC,CAAA;AACJ,GAAA;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notifyManager.esm.js","sources":["../../src/notifyManager.ts"],"sourcesContent":["import { scheduleMicrotask } from './utils'\n\n// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: NotifyCallback[] = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n\n const batch = <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n }\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleMicrotask(() => {\n notifyFn(callback)\n })\n }\n }\n\n /**\n * All calls to the wrapped function will be batched.\n */\n const batchCalls = <T extends Function>(callback: T): T => {\n return ((...args: any[]) => {\n schedule(() => {\n callback(...args)\n })\n }) as any\n }\n\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleMicrotask(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n const setNotifyFunction = (fn: NotifyFunction) => {\n notifyFn = fn\n }\n\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n const setBatchNotifyFunction = (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n }\n\n return {\n batch,\n batchCalls,\n schedule,\n setNotifyFunction,\n setBatchNotifyFunction,\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"names":["createNotifyManager","queue","transactions","notifyFn","callback","batchNotifyFn","batch","result","flush","schedule","push","scheduleMicrotask","batchCalls","args","originalQueue","length","forEach","setNotifyFunction","fn","setBatchNotifyFunction","notifyManager"],"mappings":";;AAEA;;AAQO,SAASA,mBAAmB,GAAG;EACpC,IAAIC,KAAuB,GAAG,EAAE,CAAA;EAChC,IAAIC,YAAY,GAAG,CAAC,CAAA;EACpB,IAAIC,QAAwB,GAAIC,QAAQ,IAAK;AAC3CA,IAAAA,QAAQ,EAAE,CAAA;GACX,CAAA;EACD,IAAIC,aAAkC,GAAID,QAAoB,IAAK;AACjEA,IAAAA,QAAQ,EAAE,CAAA;GACX,CAAA;EAED,MAAME,KAAK,GAAOF,QAAiB,IAAQ;AACzC,IAAA,IAAIG,MAAM,CAAA;AACVL,IAAAA,YAAY,EA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;;AAED;AACF;AACA;AACA;EACE,MAAMC,sBAAsB,GAAID,EAAuB,IAAK;AAC1Db,IAAAA,aAAa,GAAGa,EAAE,CAAA;GACnB,CAAA;EAED,OAAO;IACLZ,KAAK;IACLM,UAAU;IACVH,QAAQ;IACRQ,iBAAiB;AACjBE,IAAAA,sBAAAA;GACD,CAAA;AACH,CAAA;;AAEA;AACaC,MAAAA,aAAa,GAAGpB,mBAAmB;;;;"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { scheduleMicrotask } from './utils.mjs';
|
|
2
|
-
|
|
3
|
-
// TYPES
|
|
4
|
-
|
|
5
|
-
function createNotifyManager() {
|
|
6
|
-
let queue = [];
|
|
7
|
-
let transactions = 0;
|
|
8
|
-
let notifyFn = callback => {
|
|
9
|
-
callback();
|
|
10
|
-
};
|
|
11
|
-
let batchNotifyFn = callback => {
|
|
12
|
-
callback();
|
|
13
|
-
};
|
|
14
|
-
const batch = callback => {
|
|
15
|
-
let result;
|
|
16
|
-
transactions++;
|
|
17
|
-
try {
|
|
18
|
-
result = callback();
|
|
19
|
-
} finally {
|
|
20
|
-
transactions--;
|
|
21
|
-
if (!transactions) {
|
|
22
|
-
flush();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
const schedule = callback => {
|
|
28
|
-
if (transactions) {
|
|
29
|
-
queue.push(callback);
|
|
30
|
-
} else {
|
|
31
|
-
scheduleMicrotask(() => {
|
|
32
|
-
notifyFn(callback);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* All calls to the wrapped function will be batched.
|
|
39
|
-
*/
|
|
40
|
-
const batchCalls = callback => {
|
|
41
|
-
return (...args) => {
|
|
42
|
-
schedule(() => {
|
|
43
|
-
callback(...args);
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
const flush = () => {
|
|
48
|
-
const originalQueue = queue;
|
|
49
|
-
queue = [];
|
|
50
|
-
if (originalQueue.length) {
|
|
51
|
-
scheduleMicrotask(() => {
|
|
52
|
-
batchNotifyFn(() => {
|
|
53
|
-
originalQueue.forEach(callback => {
|
|
54
|
-
notifyFn(callback);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Use this method to set a custom notify function.
|
|
63
|
-
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
64
|
-
*/
|
|
65
|
-
const setNotifyFunction = fn => {
|
|
66
|
-
notifyFn = fn;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
71
|
-
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
72
|
-
*/
|
|
73
|
-
const setBatchNotifyFunction = fn => {
|
|
74
|
-
batchNotifyFn = fn;
|
|
75
|
-
};
|
|
76
|
-
return {
|
|
77
|
-
batch,
|
|
78
|
-
batchCalls,
|
|
79
|
-
schedule,
|
|
80
|
-
setNotifyFunction,
|
|
81
|
-
setBatchNotifyFunction
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// SINGLETON
|
|
86
|
-
const notifyManager = createNotifyManager();
|
|
87
|
-
|
|
88
|
-
export { createNotifyManager, notifyManager };
|
|
89
|
-
//# sourceMappingURL=notifyManager.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onlineManager.esm.js","sources":["../../src/onlineManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\nimport { isServer } from './utils'\n\ntype SetupFn = (\n setOnline: (online?: boolean) => void,\n) => (() => void) | undefined\n\nexport class OnlineManager extends Subscribable {\n #online?: boolean\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!isServer && window.addEventListener) {\n const listener = () => onOnline()\n // Listen to online\n window.addEventListener('online', listener, false)\n window.addEventListener('offline', listener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', listener)\n window.removeEventListener('offline', listener)\n }\n }\n\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup((online?: boolean) => {\n if (typeof online === 'boolean') {\n this.setOnline(online)\n } else {\n this.onOnline()\n }\n })\n }\n\n setOnline(online?: boolean): void {\n this.#online = online\n\n if (online) {\n this.onOnline()\n }\n }\n\n onOnline(): void {\n this.listeners.forEach((listener) => {\n listener()\n })\n }\n\n isOnline(): boolean {\n if (typeof this.#online === 'boolean') {\n return this.#online\n }\n\n if (\n typeof navigator === 'undefined' ||\n typeof navigator.onLine === 'undefined'\n ) {\n return true\n }\n\n return navigator.onLine\n }\n}\n\nexport const onlineManager = new OnlineManager()\n"],"names":["OnlineManager","Subscribable","constructor","onOnline","isServer","window","addEventListener","listener","removeEventListener","onSubscribe","setEventListener","onUnsubscribe","hasListeners","undefined","setup","online","setOnline","listeners","forEach","isOnline","navigator","onLine","onlineManager"],"mappings":";;;AAOO,MAAMA,aAAa,SAASC,YAAY,CAAC;AAC9C,EAAA,OAAO,CAAA;AACP,EAAA,QAAQ,CAAA;AAER,EAAA,MAAM,CAAA;AAENC,EAAAA,WAAW,GAAG;AACZ,IAAA,KAAK,EAAE,CAAA;AACP,IAAA,IAAI,CAAC,MAAM,GAAIC,QAAQ,IAAK;AAC1B;AACA;AACA,MAAA,IAAI,CAACC,QAAQ,IAAIC,MAAM,CAACC,gBAAgB,EAAE;AACxC,QAAA,MA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