hookery 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -26
- package/dist/index.d.ts +147 -1
- package/dist/index.js +10 -4304
- package/dist/index.mjs +10 -4164
- package/package.json +10 -81
- package/dist/bridges/auth0.d.mts +0 -16
- package/dist/bridges/auth0.d.ts +0 -16
- package/dist/bridges/auth0.js +0 -3015
- package/dist/bridges/auth0.js.map +0 -1
- package/dist/bridges/auth0.mjs +0 -2977
- package/dist/bridges/auth0.mjs.map +0 -1
- package/dist/bridges/axios.d.mts +0 -17
- package/dist/bridges/axios.d.ts +0 -17
- package/dist/bridges/axios.js +0 -15351
- package/dist/bridges/axios.js.map +0 -1
- package/dist/bridges/axios.mjs +0 -15347
- package/dist/bridges/axios.mjs.map +0 -1
- package/dist/bridges/clerk.d.mts +0 -1
- package/dist/bridges/clerk.d.ts +0 -1
- package/dist/bridges/clerk.js +0 -5991
- package/dist/bridges/clerk.js.map +0 -1
- package/dist/bridges/clerk.mjs +0 -5985
- package/dist/bridges/clerk.mjs.map +0 -1
- package/dist/bridges/firebase.d.mts +0 -14
- package/dist/bridges/firebase.d.ts +0 -14
- package/dist/bridges/firebase.js +0 -52
- package/dist/bridges/firebase.js.map +0 -1
- package/dist/bridges/firebase.mjs +0 -25
- package/dist/bridges/firebase.mjs.map +0 -1
- package/dist/bridges/jotai.d.mts +0 -11
- package/dist/bridges/jotai.d.ts +0 -11
- package/dist/bridges/jotai.js +0 -870
- package/dist/bridges/jotai.js.map +0 -1
- package/dist/bridges/jotai.mjs +0 -827
- package/dist/bridges/jotai.mjs.map +0 -1
- package/dist/bridges/motion.d.mts +0 -6
- package/dist/bridges/motion.d.ts +0 -6
- package/dist/bridges/motion.js +0 -3752
- package/dist/bridges/motion.js.map +0 -1
- package/dist/bridges/motion.mjs +0 -3721
- package/dist/bridges/motion.mjs.map +0 -1
- package/dist/bridges/next.d.mts +0 -10
- package/dist/bridges/next.d.ts +0 -10
- package/dist/bridges/next.js +0 -2588
- package/dist/bridges/next.js.map +0 -1
- package/dist/bridges/next.mjs +0 -2582
- package/dist/bridges/next.mjs.map +0 -1
- package/dist/bridges/redux.d.mts +0 -15
- package/dist/bridges/redux.d.ts +0 -15
- package/dist/bridges/redux.js +0 -410
- package/dist/bridges/redux.js.map +0 -1
- package/dist/bridges/redux.mjs +0 -402
- package/dist/bridges/redux.mjs.map +0 -1
- package/dist/bridges/remix.d.mts +0 -1
- package/dist/bridges/remix.d.ts +0 -1
- package/dist/bridges/remix.js +0 -2215
- package/dist/bridges/remix.js.map +0 -1
- package/dist/bridges/remix.mjs +0 -2174
- package/dist/bridges/remix.mjs.map +0 -1
- package/dist/bridges/stripe.d.mts +0 -15
- package/dist/bridges/stripe.d.ts +0 -15
- package/dist/bridges/stripe.js +0 -1572
- package/dist/bridges/stripe.js.map +0 -1
- package/dist/bridges/stripe.mjs +0 -1556
- package/dist/bridges/stripe.mjs.map +0 -1
- package/dist/bridges/supabase.d.mts +0 -13
- package/dist/bridges/supabase.d.ts +0 -13
- package/dist/bridges/supabase.js +0 -51
- package/dist/bridges/supabase.js.map +0 -1
- package/dist/bridges/supabase.mjs +0 -24
- package/dist/bridges/supabase.mjs.map +0 -1
- package/dist/bridges/tanstack.d.mts +0 -3
- package/dist/bridges/tanstack.d.ts +0 -3
- package/dist/bridges/tanstack.js +0 -1319
- package/dist/bridges/tanstack.js.map +0 -1
- package/dist/bridges/tanstack.mjs +0 -1281
- package/dist/bridges/tanstack.mjs.map +0 -1
- package/dist/bridges/yup.d.mts +0 -16
- package/dist/bridges/yup.d.ts +0 -16
- package/dist/bridges/yup.js +0 -80
- package/dist/bridges/yup.js.map +0 -1
- package/dist/bridges/yup.mjs +0 -43
- package/dist/bridges/yup.mjs.map +0 -1
- package/dist/bridges/zod.d.mts +0 -19
- package/dist/bridges/zod.d.ts +0 -19
- package/dist/bridges/zod.js +0 -66
- package/dist/bridges/zod.js.map +0 -1
- package/dist/bridges/zod.mjs +0 -39
- package/dist/bridges/zod.mjs.map +0 -1
- package/dist/bridges/zustand.d.mts +0 -14
- package/dist/bridges/zustand.d.ts +0 -14
- package/dist/bridges/zustand.js +0 -58
- package/dist/bridges/zustand.js.map +0 -1
- package/dist/bridges/zustand.mjs +0 -21
- package/dist/bridges/zustand.mjs.map +0 -1
- package/dist/index.d.mts +0 -3130
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -1,1281 +0,0 @@
|
|
|
1
|
-
var __typeError = (msg) => {
|
|
2
|
-
throw TypeError(msg);
|
|
3
|
-
};
|
|
4
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
-
|
|
10
|
-
// node_modules/@tanstack/query-core/build/modern/subscribable.js
|
|
11
|
-
var Subscribable = class {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
14
|
-
this.subscribe = this.subscribe.bind(this);
|
|
15
|
-
}
|
|
16
|
-
subscribe(listener) {
|
|
17
|
-
this.listeners.add(listener);
|
|
18
|
-
this.onSubscribe();
|
|
19
|
-
return () => {
|
|
20
|
-
this.listeners.delete(listener);
|
|
21
|
-
this.onUnsubscribe();
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
hasListeners() {
|
|
25
|
-
return this.listeners.size > 0;
|
|
26
|
-
}
|
|
27
|
-
onSubscribe() {
|
|
28
|
-
}
|
|
29
|
-
onUnsubscribe() {
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// node_modules/@tanstack/query-core/build/modern/timeoutManager.js
|
|
34
|
-
var defaultTimeoutProvider = {
|
|
35
|
-
// We need the wrapper function syntax below instead of direct references to
|
|
36
|
-
// global setTimeout etc.
|
|
37
|
-
//
|
|
38
|
-
// BAD: `setTimeout: setTimeout`
|
|
39
|
-
// GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
|
|
40
|
-
//
|
|
41
|
-
// If we use direct references here, then anything that wants to spy on or
|
|
42
|
-
// replace the global setTimeout (like tests) won't work since we'll already
|
|
43
|
-
// have a hard reference to the original implementation at the time when this
|
|
44
|
-
// file was imported.
|
|
45
|
-
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
46
|
-
clearTimeout: (timeoutId) => clearTimeout(timeoutId),
|
|
47
|
-
setInterval: (callback, delay) => setInterval(callback, delay),
|
|
48
|
-
clearInterval: (intervalId) => clearInterval(intervalId)
|
|
49
|
-
};
|
|
50
|
-
var _provider, _providerCalled, _a;
|
|
51
|
-
var TimeoutManager = (_a = class {
|
|
52
|
-
constructor() {
|
|
53
|
-
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete
|
|
54
|
-
// type at app boot; and if we leave that type, then any new timer provider
|
|
55
|
-
// would need to support ReturnType<typeof setTimeout>, which is infeasible.
|
|
56
|
-
//
|
|
57
|
-
// We settle for type safety for the TimeoutProvider type, and accept that
|
|
58
|
-
// this class is unsafe internally to allow for extension.
|
|
59
|
-
__privateAdd(this, _provider, defaultTimeoutProvider);
|
|
60
|
-
__privateAdd(this, _providerCalled, false);
|
|
61
|
-
}
|
|
62
|
-
setTimeoutProvider(provider) {
|
|
63
|
-
if (process.env.NODE_ENV !== "production") {
|
|
64
|
-
if (__privateGet(this, _providerCalled) && provider !== __privateGet(this, _provider)) {
|
|
65
|
-
console.error(
|
|
66
|
-
`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
|
|
67
|
-
{ previous: __privateGet(this, _provider), provider }
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
__privateSet(this, _provider, provider);
|
|
72
|
-
if (process.env.NODE_ENV !== "production") {
|
|
73
|
-
__privateSet(this, _providerCalled, false);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
setTimeout(callback, delay) {
|
|
77
|
-
if (process.env.NODE_ENV !== "production") {
|
|
78
|
-
__privateSet(this, _providerCalled, true);
|
|
79
|
-
}
|
|
80
|
-
return __privateGet(this, _provider).setTimeout(callback, delay);
|
|
81
|
-
}
|
|
82
|
-
clearTimeout(timeoutId) {
|
|
83
|
-
__privateGet(this, _provider).clearTimeout(timeoutId);
|
|
84
|
-
}
|
|
85
|
-
setInterval(callback, delay) {
|
|
86
|
-
if (process.env.NODE_ENV !== "production") {
|
|
87
|
-
__privateSet(this, _providerCalled, true);
|
|
88
|
-
}
|
|
89
|
-
return __privateGet(this, _provider).setInterval(callback, delay);
|
|
90
|
-
}
|
|
91
|
-
clearInterval(intervalId) {
|
|
92
|
-
__privateGet(this, _provider).clearInterval(intervalId);
|
|
93
|
-
}
|
|
94
|
-
}, _provider = new WeakMap(), _providerCalled = new WeakMap(), _a);
|
|
95
|
-
var timeoutManager = new TimeoutManager();
|
|
96
|
-
function systemSetTimeoutZero(callback) {
|
|
97
|
-
setTimeout(callback, 0);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// node_modules/@tanstack/query-core/build/modern/utils.js
|
|
101
|
-
var isServer = typeof window === "undefined" || "Deno" in globalThis;
|
|
102
|
-
function noop() {
|
|
103
|
-
}
|
|
104
|
-
function isValidTimeout(value) {
|
|
105
|
-
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
106
|
-
}
|
|
107
|
-
function timeUntilStale(updatedAt, staleTime) {
|
|
108
|
-
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
109
|
-
}
|
|
110
|
-
function resolveStaleTime(staleTime, query) {
|
|
111
|
-
return typeof staleTime === "function" ? staleTime(query) : staleTime;
|
|
112
|
-
}
|
|
113
|
-
function resolveEnabled(enabled, query) {
|
|
114
|
-
return typeof enabled === "function" ? enabled(query) : enabled;
|
|
115
|
-
}
|
|
116
|
-
function hashKey(queryKey) {
|
|
117
|
-
return JSON.stringify(
|
|
118
|
-
queryKey,
|
|
119
|
-
(_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
|
|
120
|
-
result[key] = val[key];
|
|
121
|
-
return result;
|
|
122
|
-
}, {}) : val
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
var hasOwn = Object.prototype.hasOwnProperty;
|
|
126
|
-
function replaceEqualDeep(a, b, depth = 0) {
|
|
127
|
-
if (a === b) {
|
|
128
|
-
return a;
|
|
129
|
-
}
|
|
130
|
-
if (depth > 500) return b;
|
|
131
|
-
const array = isPlainArray(a) && isPlainArray(b);
|
|
132
|
-
if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
|
|
133
|
-
const aItems = array ? a : Object.keys(a);
|
|
134
|
-
const aSize = aItems.length;
|
|
135
|
-
const bItems = array ? b : Object.keys(b);
|
|
136
|
-
const bSize = bItems.length;
|
|
137
|
-
const copy = array ? new Array(bSize) : {};
|
|
138
|
-
let equalItems = 0;
|
|
139
|
-
for (let i = 0; i < bSize; i++) {
|
|
140
|
-
const key = array ? i : bItems[i];
|
|
141
|
-
const aItem = a[key];
|
|
142
|
-
const bItem = b[key];
|
|
143
|
-
if (aItem === bItem) {
|
|
144
|
-
copy[key] = aItem;
|
|
145
|
-
if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
|
|
149
|
-
copy[key] = bItem;
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
const v = replaceEqualDeep(aItem, bItem, depth + 1);
|
|
153
|
-
copy[key] = v;
|
|
154
|
-
if (v === aItem) equalItems++;
|
|
155
|
-
}
|
|
156
|
-
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
157
|
-
}
|
|
158
|
-
function shallowEqualObjects(a, b) {
|
|
159
|
-
if (!b || Object.keys(a).length !== Object.keys(b).length) {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
for (const key in a) {
|
|
163
|
-
if (a[key] !== b[key]) {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
function isPlainArray(value) {
|
|
170
|
-
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
171
|
-
}
|
|
172
|
-
function isPlainObject(o) {
|
|
173
|
-
if (!hasObjectPrototype(o)) {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
const ctor = o.constructor;
|
|
177
|
-
if (ctor === void 0) {
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
const prot = ctor.prototype;
|
|
181
|
-
if (!hasObjectPrototype(prot)) {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
if (Object.getPrototypeOf(o) !== Object.prototype) {
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
return true;
|
|
191
|
-
}
|
|
192
|
-
function hasObjectPrototype(o) {
|
|
193
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
194
|
-
}
|
|
195
|
-
function replaceData(prevData, data, options) {
|
|
196
|
-
if (typeof options.structuralSharing === "function") {
|
|
197
|
-
return options.structuralSharing(prevData, data);
|
|
198
|
-
} else if (options.structuralSharing !== false) {
|
|
199
|
-
if (process.env.NODE_ENV !== "production") {
|
|
200
|
-
try {
|
|
201
|
-
return replaceEqualDeep(prevData, data);
|
|
202
|
-
} catch (error) {
|
|
203
|
-
console.error(
|
|
204
|
-
`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`
|
|
205
|
-
);
|
|
206
|
-
throw error;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return replaceEqualDeep(prevData, data);
|
|
210
|
-
}
|
|
211
|
-
return data;
|
|
212
|
-
}
|
|
213
|
-
function shouldThrowError(throwOnError, params) {
|
|
214
|
-
if (typeof throwOnError === "function") {
|
|
215
|
-
return throwOnError(...params);
|
|
216
|
-
}
|
|
217
|
-
return !!throwOnError;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// node_modules/@tanstack/query-core/build/modern/focusManager.js
|
|
221
|
-
var _focused, _cleanup, _setup, _a2;
|
|
222
|
-
var FocusManager = (_a2 = class extends Subscribable {
|
|
223
|
-
constructor() {
|
|
224
|
-
super();
|
|
225
|
-
__privateAdd(this, _focused);
|
|
226
|
-
__privateAdd(this, _cleanup);
|
|
227
|
-
__privateAdd(this, _setup);
|
|
228
|
-
__privateSet(this, _setup, (onFocus) => {
|
|
229
|
-
if (!isServer && window.addEventListener) {
|
|
230
|
-
const listener = () => onFocus();
|
|
231
|
-
window.addEventListener("visibilitychange", listener, false);
|
|
232
|
-
return () => {
|
|
233
|
-
window.removeEventListener("visibilitychange", listener);
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
return;
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
onSubscribe() {
|
|
240
|
-
if (!__privateGet(this, _cleanup)) {
|
|
241
|
-
this.setEventListener(__privateGet(this, _setup));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
onUnsubscribe() {
|
|
245
|
-
var _a6;
|
|
246
|
-
if (!this.hasListeners()) {
|
|
247
|
-
(_a6 = __privateGet(this, _cleanup)) == null ? void 0 : _a6.call(this);
|
|
248
|
-
__privateSet(this, _cleanup, void 0);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
setEventListener(setup) {
|
|
252
|
-
var _a6;
|
|
253
|
-
__privateSet(this, _setup, setup);
|
|
254
|
-
(_a6 = __privateGet(this, _cleanup)) == null ? void 0 : _a6.call(this);
|
|
255
|
-
__privateSet(this, _cleanup, setup((focused) => {
|
|
256
|
-
if (typeof focused === "boolean") {
|
|
257
|
-
this.setFocused(focused);
|
|
258
|
-
} else {
|
|
259
|
-
this.onFocus();
|
|
260
|
-
}
|
|
261
|
-
}));
|
|
262
|
-
}
|
|
263
|
-
setFocused(focused) {
|
|
264
|
-
const changed = __privateGet(this, _focused) !== focused;
|
|
265
|
-
if (changed) {
|
|
266
|
-
__privateSet(this, _focused, focused);
|
|
267
|
-
this.onFocus();
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
onFocus() {
|
|
271
|
-
const isFocused = this.isFocused();
|
|
272
|
-
this.listeners.forEach((listener) => {
|
|
273
|
-
listener(isFocused);
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
isFocused() {
|
|
277
|
-
if (typeof __privateGet(this, _focused) === "boolean") {
|
|
278
|
-
return __privateGet(this, _focused);
|
|
279
|
-
}
|
|
280
|
-
return globalThis.document?.visibilityState !== "hidden";
|
|
281
|
-
}
|
|
282
|
-
}, _focused = new WeakMap(), _cleanup = new WeakMap(), _setup = new WeakMap(), _a2);
|
|
283
|
-
var focusManager = new FocusManager();
|
|
284
|
-
|
|
285
|
-
// node_modules/@tanstack/query-core/build/modern/thenable.js
|
|
286
|
-
function pendingThenable() {
|
|
287
|
-
let resolve;
|
|
288
|
-
let reject;
|
|
289
|
-
const thenable = new Promise((_resolve, _reject) => {
|
|
290
|
-
resolve = _resolve;
|
|
291
|
-
reject = _reject;
|
|
292
|
-
});
|
|
293
|
-
thenable.status = "pending";
|
|
294
|
-
thenable.catch(() => {
|
|
295
|
-
});
|
|
296
|
-
function finalize(data) {
|
|
297
|
-
Object.assign(thenable, data);
|
|
298
|
-
delete thenable.resolve;
|
|
299
|
-
delete thenable.reject;
|
|
300
|
-
}
|
|
301
|
-
thenable.resolve = (value) => {
|
|
302
|
-
finalize({
|
|
303
|
-
status: "fulfilled",
|
|
304
|
-
value
|
|
305
|
-
});
|
|
306
|
-
resolve(value);
|
|
307
|
-
};
|
|
308
|
-
thenable.reject = (reason) => {
|
|
309
|
-
finalize({
|
|
310
|
-
status: "rejected",
|
|
311
|
-
reason
|
|
312
|
-
});
|
|
313
|
-
reject(reason);
|
|
314
|
-
};
|
|
315
|
-
return thenable;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// node_modules/@tanstack/query-core/build/modern/notifyManager.js
|
|
319
|
-
var defaultScheduler = systemSetTimeoutZero;
|
|
320
|
-
function createNotifyManager() {
|
|
321
|
-
let queue = [];
|
|
322
|
-
let transactions = 0;
|
|
323
|
-
let notifyFn = (callback) => {
|
|
324
|
-
callback();
|
|
325
|
-
};
|
|
326
|
-
let batchNotifyFn = (callback) => {
|
|
327
|
-
callback();
|
|
328
|
-
};
|
|
329
|
-
let scheduleFn = defaultScheduler;
|
|
330
|
-
const schedule = (callback) => {
|
|
331
|
-
if (transactions) {
|
|
332
|
-
queue.push(callback);
|
|
333
|
-
} else {
|
|
334
|
-
scheduleFn(() => {
|
|
335
|
-
notifyFn(callback);
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
const flush = () => {
|
|
340
|
-
const originalQueue = queue;
|
|
341
|
-
queue = [];
|
|
342
|
-
if (originalQueue.length) {
|
|
343
|
-
scheduleFn(() => {
|
|
344
|
-
batchNotifyFn(() => {
|
|
345
|
-
originalQueue.forEach((callback) => {
|
|
346
|
-
notifyFn(callback);
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
return {
|
|
353
|
-
batch: (callback) => {
|
|
354
|
-
let result;
|
|
355
|
-
transactions++;
|
|
356
|
-
try {
|
|
357
|
-
result = callback();
|
|
358
|
-
} finally {
|
|
359
|
-
transactions--;
|
|
360
|
-
if (!transactions) {
|
|
361
|
-
flush();
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
return result;
|
|
365
|
-
},
|
|
366
|
-
/**
|
|
367
|
-
* All calls to the wrapped function will be batched.
|
|
368
|
-
*/
|
|
369
|
-
batchCalls: (callback) => {
|
|
370
|
-
return (...args) => {
|
|
371
|
-
schedule(() => {
|
|
372
|
-
callback(...args);
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
},
|
|
376
|
-
schedule,
|
|
377
|
-
/**
|
|
378
|
-
* Use this method to set a custom notify function.
|
|
379
|
-
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
380
|
-
*/
|
|
381
|
-
setNotifyFunction: (fn) => {
|
|
382
|
-
notifyFn = fn;
|
|
383
|
-
},
|
|
384
|
-
/**
|
|
385
|
-
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
386
|
-
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
387
|
-
*/
|
|
388
|
-
setBatchNotifyFunction: (fn) => {
|
|
389
|
-
batchNotifyFn = fn;
|
|
390
|
-
},
|
|
391
|
-
setScheduler: (fn) => {
|
|
392
|
-
scheduleFn = fn;
|
|
393
|
-
}
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
var notifyManager = createNotifyManager();
|
|
397
|
-
|
|
398
|
-
// node_modules/@tanstack/query-core/build/modern/onlineManager.js
|
|
399
|
-
var _online, _cleanup2, _setup2, _a3;
|
|
400
|
-
var OnlineManager = (_a3 = class extends Subscribable {
|
|
401
|
-
constructor() {
|
|
402
|
-
super();
|
|
403
|
-
__privateAdd(this, _online, true);
|
|
404
|
-
__privateAdd(this, _cleanup2);
|
|
405
|
-
__privateAdd(this, _setup2);
|
|
406
|
-
__privateSet(this, _setup2, (onOnline) => {
|
|
407
|
-
if (!isServer && window.addEventListener) {
|
|
408
|
-
const onlineListener = () => onOnline(true);
|
|
409
|
-
const offlineListener = () => onOnline(false);
|
|
410
|
-
window.addEventListener("online", onlineListener, false);
|
|
411
|
-
window.addEventListener("offline", offlineListener, false);
|
|
412
|
-
return () => {
|
|
413
|
-
window.removeEventListener("online", onlineListener);
|
|
414
|
-
window.removeEventListener("offline", offlineListener);
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
return;
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
onSubscribe() {
|
|
421
|
-
if (!__privateGet(this, _cleanup2)) {
|
|
422
|
-
this.setEventListener(__privateGet(this, _setup2));
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
onUnsubscribe() {
|
|
426
|
-
var _a6;
|
|
427
|
-
if (!this.hasListeners()) {
|
|
428
|
-
(_a6 = __privateGet(this, _cleanup2)) == null ? void 0 : _a6.call(this);
|
|
429
|
-
__privateSet(this, _cleanup2, void 0);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
setEventListener(setup) {
|
|
433
|
-
var _a6;
|
|
434
|
-
__privateSet(this, _setup2, setup);
|
|
435
|
-
(_a6 = __privateGet(this, _cleanup2)) == null ? void 0 : _a6.call(this);
|
|
436
|
-
__privateSet(this, _cleanup2, setup(this.setOnline.bind(this)));
|
|
437
|
-
}
|
|
438
|
-
setOnline(online) {
|
|
439
|
-
const changed = __privateGet(this, _online) !== online;
|
|
440
|
-
if (changed) {
|
|
441
|
-
__privateSet(this, _online, online);
|
|
442
|
-
this.listeners.forEach((listener) => {
|
|
443
|
-
listener(online);
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
isOnline() {
|
|
448
|
-
return __privateGet(this, _online);
|
|
449
|
-
}
|
|
450
|
-
}, _online = new WeakMap(), _cleanup2 = new WeakMap(), _setup2 = new WeakMap(), _a3);
|
|
451
|
-
var onlineManager = new OnlineManager();
|
|
452
|
-
|
|
453
|
-
// node_modules/@tanstack/query-core/build/modern/retryer.js
|
|
454
|
-
function canFetch(networkMode) {
|
|
455
|
-
return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// node_modules/@tanstack/query-core/build/modern/query.js
|
|
459
|
-
function fetchState(data, options) {
|
|
460
|
-
return {
|
|
461
|
-
fetchFailureCount: 0,
|
|
462
|
-
fetchFailureReason: null,
|
|
463
|
-
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
|
|
464
|
-
...data === void 0 && {
|
|
465
|
-
error: null,
|
|
466
|
-
status: "pending"
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
// node_modules/@tanstack/query-core/build/modern/queryObserver.js
|
|
472
|
-
var _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _currentThenable, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _a4;
|
|
473
|
-
var QueryObserver = (_a4 = class extends Subscribable {
|
|
474
|
-
constructor(client, options) {
|
|
475
|
-
super();
|
|
476
|
-
__privateAdd(this, _QueryObserver_instances);
|
|
477
|
-
__privateAdd(this, _client);
|
|
478
|
-
__privateAdd(this, _currentQuery);
|
|
479
|
-
__privateAdd(this, _currentQueryInitialState);
|
|
480
|
-
__privateAdd(this, _currentResult);
|
|
481
|
-
__privateAdd(this, _currentResultState);
|
|
482
|
-
__privateAdd(this, _currentResultOptions);
|
|
483
|
-
__privateAdd(this, _currentThenable);
|
|
484
|
-
__privateAdd(this, _selectError);
|
|
485
|
-
__privateAdd(this, _selectFn);
|
|
486
|
-
__privateAdd(this, _selectResult);
|
|
487
|
-
// This property keeps track of the last query with defined data.
|
|
488
|
-
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
489
|
-
__privateAdd(this, _lastQueryWithDefinedData);
|
|
490
|
-
__privateAdd(this, _staleTimeoutId);
|
|
491
|
-
__privateAdd(this, _refetchIntervalId);
|
|
492
|
-
__privateAdd(this, _currentRefetchInterval);
|
|
493
|
-
__privateAdd(this, _trackedProps, /* @__PURE__ */ new Set());
|
|
494
|
-
this.options = options;
|
|
495
|
-
__privateSet(this, _client, client);
|
|
496
|
-
__privateSet(this, _selectError, null);
|
|
497
|
-
__privateSet(this, _currentThenable, pendingThenable());
|
|
498
|
-
this.bindMethods();
|
|
499
|
-
this.setOptions(options);
|
|
500
|
-
}
|
|
501
|
-
bindMethods() {
|
|
502
|
-
this.refetch = this.refetch.bind(this);
|
|
503
|
-
}
|
|
504
|
-
onSubscribe() {
|
|
505
|
-
if (this.listeners.size === 1) {
|
|
506
|
-
__privateGet(this, _currentQuery).addObserver(this);
|
|
507
|
-
if (shouldFetchOnMount(__privateGet(this, _currentQuery), this.options)) {
|
|
508
|
-
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
509
|
-
} else {
|
|
510
|
-
this.updateResult();
|
|
511
|
-
}
|
|
512
|
-
__privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
onUnsubscribe() {
|
|
516
|
-
if (!this.hasListeners()) {
|
|
517
|
-
this.destroy();
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
shouldFetchOnReconnect() {
|
|
521
|
-
return shouldFetchOn(
|
|
522
|
-
__privateGet(this, _currentQuery),
|
|
523
|
-
this.options,
|
|
524
|
-
this.options.refetchOnReconnect
|
|
525
|
-
);
|
|
526
|
-
}
|
|
527
|
-
shouldFetchOnWindowFocus() {
|
|
528
|
-
return shouldFetchOn(
|
|
529
|
-
__privateGet(this, _currentQuery),
|
|
530
|
-
this.options,
|
|
531
|
-
this.options.refetchOnWindowFocus
|
|
532
|
-
);
|
|
533
|
-
}
|
|
534
|
-
destroy() {
|
|
535
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
536
|
-
__privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
|
|
537
|
-
__privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
|
|
538
|
-
__privateGet(this, _currentQuery).removeObserver(this);
|
|
539
|
-
}
|
|
540
|
-
setOptions(options) {
|
|
541
|
-
const prevOptions = this.options;
|
|
542
|
-
const prevQuery = __privateGet(this, _currentQuery);
|
|
543
|
-
this.options = __privateGet(this, _client).defaultQueryOptions(options);
|
|
544
|
-
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== "boolean") {
|
|
545
|
-
throw new Error(
|
|
546
|
-
"Expected enabled to be a boolean or a callback that returns a boolean"
|
|
547
|
-
);
|
|
548
|
-
}
|
|
549
|
-
__privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
|
|
550
|
-
__privateGet(this, _currentQuery).setOptions(this.options);
|
|
551
|
-
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
|
|
552
|
-
__privateGet(this, _client).getQueryCache().notify({
|
|
553
|
-
type: "observerOptionsUpdated",
|
|
554
|
-
query: __privateGet(this, _currentQuery),
|
|
555
|
-
observer: this
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
const mounted = this.hasListeners();
|
|
559
|
-
if (mounted && shouldFetchOptionally(
|
|
560
|
-
__privateGet(this, _currentQuery),
|
|
561
|
-
prevQuery,
|
|
562
|
-
this.options,
|
|
563
|
-
prevOptions
|
|
564
|
-
)) {
|
|
565
|
-
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
566
|
-
}
|
|
567
|
-
this.updateResult();
|
|
568
|
-
if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || resolveStaleTime(this.options.staleTime, __privateGet(this, _currentQuery)) !== resolveStaleTime(prevOptions.staleTime, __privateGet(this, _currentQuery)))) {
|
|
569
|
-
__privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
|
|
570
|
-
}
|
|
571
|
-
const nextRefetchInterval = __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this);
|
|
572
|
-
if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || nextRefetchInterval !== __privateGet(this, _currentRefetchInterval))) {
|
|
573
|
-
__privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, nextRefetchInterval);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
getOptimisticResult(options) {
|
|
577
|
-
const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), options);
|
|
578
|
-
const result = this.createResult(query, options);
|
|
579
|
-
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
580
|
-
__privateSet(this, _currentResult, result);
|
|
581
|
-
__privateSet(this, _currentResultOptions, this.options);
|
|
582
|
-
__privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
|
|
583
|
-
}
|
|
584
|
-
return result;
|
|
585
|
-
}
|
|
586
|
-
getCurrentResult() {
|
|
587
|
-
return __privateGet(this, _currentResult);
|
|
588
|
-
}
|
|
589
|
-
trackResult(result, onPropTracked) {
|
|
590
|
-
return new Proxy(result, {
|
|
591
|
-
get: (target, key) => {
|
|
592
|
-
this.trackProp(key);
|
|
593
|
-
onPropTracked?.(key);
|
|
594
|
-
if (key === "promise") {
|
|
595
|
-
this.trackProp("data");
|
|
596
|
-
if (!this.options.experimental_prefetchInRender && __privateGet(this, _currentThenable).status === "pending") {
|
|
597
|
-
__privateGet(this, _currentThenable).reject(
|
|
598
|
-
new Error(
|
|
599
|
-
"experimental_prefetchInRender feature flag is not enabled"
|
|
600
|
-
)
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
return Reflect.get(target, key);
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
trackProp(key) {
|
|
609
|
-
__privateGet(this, _trackedProps).add(key);
|
|
610
|
-
}
|
|
611
|
-
getCurrentQuery() {
|
|
612
|
-
return __privateGet(this, _currentQuery);
|
|
613
|
-
}
|
|
614
|
-
refetch({ ...options } = {}) {
|
|
615
|
-
return this.fetch({
|
|
616
|
-
...options
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
fetchOptimistic(options) {
|
|
620
|
-
const defaultedOptions = __privateGet(this, _client).defaultQueryOptions(options);
|
|
621
|
-
const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), defaultedOptions);
|
|
622
|
-
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
623
|
-
}
|
|
624
|
-
fetch(fetchOptions) {
|
|
625
|
-
return __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this, {
|
|
626
|
-
...fetchOptions,
|
|
627
|
-
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
628
|
-
}).then(() => {
|
|
629
|
-
this.updateResult();
|
|
630
|
-
return __privateGet(this, _currentResult);
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
createResult(query, options) {
|
|
634
|
-
const prevQuery = __privateGet(this, _currentQuery);
|
|
635
|
-
const prevOptions = this.options;
|
|
636
|
-
const prevResult = __privateGet(this, _currentResult);
|
|
637
|
-
const prevResultState = __privateGet(this, _currentResultState);
|
|
638
|
-
const prevResultOptions = __privateGet(this, _currentResultOptions);
|
|
639
|
-
const queryChange = query !== prevQuery;
|
|
640
|
-
const queryInitialState = queryChange ? query.state : __privateGet(this, _currentQueryInitialState);
|
|
641
|
-
const { state } = query;
|
|
642
|
-
let newState = { ...state };
|
|
643
|
-
let isPlaceholderData = false;
|
|
644
|
-
let data;
|
|
645
|
-
if (options._optimisticResults) {
|
|
646
|
-
const mounted = this.hasListeners();
|
|
647
|
-
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
648
|
-
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
649
|
-
if (fetchOnMount || fetchOptionally) {
|
|
650
|
-
newState = {
|
|
651
|
-
...newState,
|
|
652
|
-
...fetchState(state.data, query.options)
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
if (options._optimisticResults === "isRestoring") {
|
|
656
|
-
newState.fetchStatus = "idle";
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
let { error, errorUpdatedAt, status } = newState;
|
|
660
|
-
data = newState.data;
|
|
661
|
-
let skipSelect = false;
|
|
662
|
-
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
663
|
-
let placeholderData;
|
|
664
|
-
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
665
|
-
placeholderData = prevResult.data;
|
|
666
|
-
skipSelect = true;
|
|
667
|
-
} else {
|
|
668
|
-
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
|
|
669
|
-
__privateGet(this, _lastQueryWithDefinedData)?.state.data,
|
|
670
|
-
__privateGet(this, _lastQueryWithDefinedData)
|
|
671
|
-
) : options.placeholderData;
|
|
672
|
-
}
|
|
673
|
-
if (placeholderData !== void 0) {
|
|
674
|
-
status = "success";
|
|
675
|
-
data = replaceData(
|
|
676
|
-
prevResult?.data,
|
|
677
|
-
placeholderData,
|
|
678
|
-
options
|
|
679
|
-
);
|
|
680
|
-
isPlaceholderData = true;
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
if (options.select && data !== void 0 && !skipSelect) {
|
|
684
|
-
if (prevResult && data === prevResultState?.data && options.select === __privateGet(this, _selectFn)) {
|
|
685
|
-
data = __privateGet(this, _selectResult);
|
|
686
|
-
} else {
|
|
687
|
-
try {
|
|
688
|
-
__privateSet(this, _selectFn, options.select);
|
|
689
|
-
data = options.select(data);
|
|
690
|
-
data = replaceData(prevResult?.data, data, options);
|
|
691
|
-
__privateSet(this, _selectResult, data);
|
|
692
|
-
__privateSet(this, _selectError, null);
|
|
693
|
-
} catch (selectError) {
|
|
694
|
-
__privateSet(this, _selectError, selectError);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
if (__privateGet(this, _selectError)) {
|
|
699
|
-
error = __privateGet(this, _selectError);
|
|
700
|
-
data = __privateGet(this, _selectResult);
|
|
701
|
-
errorUpdatedAt = Date.now();
|
|
702
|
-
status = "error";
|
|
703
|
-
}
|
|
704
|
-
const isFetching = newState.fetchStatus === "fetching";
|
|
705
|
-
const isPending = status === "pending";
|
|
706
|
-
const isError = status === "error";
|
|
707
|
-
const isLoading = isPending && isFetching;
|
|
708
|
-
const hasData = data !== void 0;
|
|
709
|
-
const result = {
|
|
710
|
-
status,
|
|
711
|
-
fetchStatus: newState.fetchStatus,
|
|
712
|
-
isPending,
|
|
713
|
-
isSuccess: status === "success",
|
|
714
|
-
isError,
|
|
715
|
-
isInitialLoading: isLoading,
|
|
716
|
-
isLoading,
|
|
717
|
-
data,
|
|
718
|
-
dataUpdatedAt: newState.dataUpdatedAt,
|
|
719
|
-
error,
|
|
720
|
-
errorUpdatedAt,
|
|
721
|
-
failureCount: newState.fetchFailureCount,
|
|
722
|
-
failureReason: newState.fetchFailureReason,
|
|
723
|
-
errorUpdateCount: newState.errorUpdateCount,
|
|
724
|
-
isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
|
|
725
|
-
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
726
|
-
isFetching,
|
|
727
|
-
isRefetching: isFetching && !isPending,
|
|
728
|
-
isLoadingError: isError && !hasData,
|
|
729
|
-
isPaused: newState.fetchStatus === "paused",
|
|
730
|
-
isPlaceholderData,
|
|
731
|
-
isRefetchError: isError && hasData,
|
|
732
|
-
isStale: isStale(query, options),
|
|
733
|
-
refetch: this.refetch,
|
|
734
|
-
promise: __privateGet(this, _currentThenable),
|
|
735
|
-
isEnabled: resolveEnabled(options.enabled, query) !== false
|
|
736
|
-
};
|
|
737
|
-
const nextResult = result;
|
|
738
|
-
if (this.options.experimental_prefetchInRender) {
|
|
739
|
-
const hasResultData = nextResult.data !== void 0;
|
|
740
|
-
const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
|
|
741
|
-
const finalizeThenableIfPossible = (thenable) => {
|
|
742
|
-
if (isErrorWithoutData) {
|
|
743
|
-
thenable.reject(nextResult.error);
|
|
744
|
-
} else if (hasResultData) {
|
|
745
|
-
thenable.resolve(nextResult.data);
|
|
746
|
-
}
|
|
747
|
-
};
|
|
748
|
-
const recreateThenable = () => {
|
|
749
|
-
const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
|
|
750
|
-
finalizeThenableIfPossible(pending);
|
|
751
|
-
};
|
|
752
|
-
const prevThenable = __privateGet(this, _currentThenable);
|
|
753
|
-
switch (prevThenable.status) {
|
|
754
|
-
case "pending":
|
|
755
|
-
if (query.queryHash === prevQuery.queryHash) {
|
|
756
|
-
finalizeThenableIfPossible(prevThenable);
|
|
757
|
-
}
|
|
758
|
-
break;
|
|
759
|
-
case "fulfilled":
|
|
760
|
-
if (isErrorWithoutData || nextResult.data !== prevThenable.value) {
|
|
761
|
-
recreateThenable();
|
|
762
|
-
}
|
|
763
|
-
break;
|
|
764
|
-
case "rejected":
|
|
765
|
-
if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) {
|
|
766
|
-
recreateThenable();
|
|
767
|
-
}
|
|
768
|
-
break;
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
return nextResult;
|
|
772
|
-
}
|
|
773
|
-
updateResult() {
|
|
774
|
-
const prevResult = __privateGet(this, _currentResult);
|
|
775
|
-
const nextResult = this.createResult(__privateGet(this, _currentQuery), this.options);
|
|
776
|
-
__privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
|
|
777
|
-
__privateSet(this, _currentResultOptions, this.options);
|
|
778
|
-
if (__privateGet(this, _currentResultState).data !== void 0) {
|
|
779
|
-
__privateSet(this, _lastQueryWithDefinedData, __privateGet(this, _currentQuery));
|
|
780
|
-
}
|
|
781
|
-
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
__privateSet(this, _currentResult, nextResult);
|
|
785
|
-
const shouldNotifyListeners = () => {
|
|
786
|
-
if (!prevResult) {
|
|
787
|
-
return true;
|
|
788
|
-
}
|
|
789
|
-
const { notifyOnChangeProps } = this.options;
|
|
790
|
-
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
791
|
-
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) {
|
|
792
|
-
return true;
|
|
793
|
-
}
|
|
794
|
-
const includedProps = new Set(
|
|
795
|
-
notifyOnChangePropsValue ?? __privateGet(this, _trackedProps)
|
|
796
|
-
);
|
|
797
|
-
if (this.options.throwOnError) {
|
|
798
|
-
includedProps.add("error");
|
|
799
|
-
}
|
|
800
|
-
return Object.keys(__privateGet(this, _currentResult)).some((key) => {
|
|
801
|
-
const typedKey = key;
|
|
802
|
-
const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey];
|
|
803
|
-
return changed && includedProps.has(typedKey);
|
|
804
|
-
});
|
|
805
|
-
};
|
|
806
|
-
__privateMethod(this, _QueryObserver_instances, notify_fn).call(this, { listeners: shouldNotifyListeners() });
|
|
807
|
-
}
|
|
808
|
-
onQueryUpdate() {
|
|
809
|
-
this.updateResult();
|
|
810
|
-
if (this.hasListeners()) {
|
|
811
|
-
__privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
}, _client = new WeakMap(), _currentQuery = new WeakMap(), _currentQueryInitialState = new WeakMap(), _currentResult = new WeakMap(), _currentResultState = new WeakMap(), _currentResultOptions = new WeakMap(), _currentThenable = new WeakMap(), _selectError = new WeakMap(), _selectFn = new WeakMap(), _selectResult = new WeakMap(), _lastQueryWithDefinedData = new WeakMap(), _staleTimeoutId = new WeakMap(), _refetchIntervalId = new WeakMap(), _currentRefetchInterval = new WeakMap(), _trackedProps = new WeakMap(), _QueryObserver_instances = new WeakSet(), executeFetch_fn = function(fetchOptions) {
|
|
815
|
-
__privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
|
|
816
|
-
let promise = __privateGet(this, _currentQuery).fetch(
|
|
817
|
-
this.options,
|
|
818
|
-
fetchOptions
|
|
819
|
-
);
|
|
820
|
-
if (!fetchOptions?.throwOnError) {
|
|
821
|
-
promise = promise.catch(noop);
|
|
822
|
-
}
|
|
823
|
-
return promise;
|
|
824
|
-
}, updateStaleTimeout_fn = function() {
|
|
825
|
-
__privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
|
|
826
|
-
const staleTime = resolveStaleTime(
|
|
827
|
-
this.options.staleTime,
|
|
828
|
-
__privateGet(this, _currentQuery)
|
|
829
|
-
);
|
|
830
|
-
if (isServer || __privateGet(this, _currentResult).isStale || !isValidTimeout(staleTime)) {
|
|
831
|
-
return;
|
|
832
|
-
}
|
|
833
|
-
const time = timeUntilStale(__privateGet(this, _currentResult).dataUpdatedAt, staleTime);
|
|
834
|
-
const timeout = time + 1;
|
|
835
|
-
__privateSet(this, _staleTimeoutId, timeoutManager.setTimeout(() => {
|
|
836
|
-
if (!__privateGet(this, _currentResult).isStale) {
|
|
837
|
-
this.updateResult();
|
|
838
|
-
}
|
|
839
|
-
}, timeout));
|
|
840
|
-
}, computeRefetchInterval_fn = function() {
|
|
841
|
-
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(__privateGet(this, _currentQuery)) : this.options.refetchInterval) ?? false;
|
|
842
|
-
}, updateRefetchInterval_fn = function(nextInterval) {
|
|
843
|
-
__privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
|
|
844
|
-
__privateSet(this, _currentRefetchInterval, nextInterval);
|
|
845
|
-
if (isServer || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) === false || !isValidTimeout(__privateGet(this, _currentRefetchInterval)) || __privateGet(this, _currentRefetchInterval) === 0) {
|
|
846
|
-
return;
|
|
847
|
-
}
|
|
848
|
-
__privateSet(this, _refetchIntervalId, timeoutManager.setInterval(() => {
|
|
849
|
-
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
850
|
-
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
851
|
-
}
|
|
852
|
-
}, __privateGet(this, _currentRefetchInterval)));
|
|
853
|
-
}, updateTimers_fn = function() {
|
|
854
|
-
__privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
|
|
855
|
-
__privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this));
|
|
856
|
-
}, clearStaleTimeout_fn = function() {
|
|
857
|
-
if (__privateGet(this, _staleTimeoutId)) {
|
|
858
|
-
timeoutManager.clearTimeout(__privateGet(this, _staleTimeoutId));
|
|
859
|
-
__privateSet(this, _staleTimeoutId, void 0);
|
|
860
|
-
}
|
|
861
|
-
}, clearRefetchInterval_fn = function() {
|
|
862
|
-
if (__privateGet(this, _refetchIntervalId)) {
|
|
863
|
-
timeoutManager.clearInterval(__privateGet(this, _refetchIntervalId));
|
|
864
|
-
__privateSet(this, _refetchIntervalId, void 0);
|
|
865
|
-
}
|
|
866
|
-
}, updateQuery_fn = function() {
|
|
867
|
-
const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), this.options);
|
|
868
|
-
if (query === __privateGet(this, _currentQuery)) {
|
|
869
|
-
return;
|
|
870
|
-
}
|
|
871
|
-
const prevQuery = __privateGet(this, _currentQuery);
|
|
872
|
-
__privateSet(this, _currentQuery, query);
|
|
873
|
-
__privateSet(this, _currentQueryInitialState, query.state);
|
|
874
|
-
if (this.hasListeners()) {
|
|
875
|
-
prevQuery?.removeObserver(this);
|
|
876
|
-
query.addObserver(this);
|
|
877
|
-
}
|
|
878
|
-
}, notify_fn = function(notifyOptions) {
|
|
879
|
-
notifyManager.batch(() => {
|
|
880
|
-
if (notifyOptions.listeners) {
|
|
881
|
-
this.listeners.forEach((listener) => {
|
|
882
|
-
listener(__privateGet(this, _currentResult));
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
__privateGet(this, _client).getQueryCache().notify({
|
|
886
|
-
query: __privateGet(this, _currentQuery),
|
|
887
|
-
type: "observerResultsUpdated"
|
|
888
|
-
});
|
|
889
|
-
});
|
|
890
|
-
}, _a4);
|
|
891
|
-
function shouldLoadOnMount(query, options) {
|
|
892
|
-
return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
|
|
893
|
-
}
|
|
894
|
-
function shouldFetchOnMount(query, options) {
|
|
895
|
-
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
896
|
-
}
|
|
897
|
-
function shouldFetchOn(query, options, field) {
|
|
898
|
-
if (resolveEnabled(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
|
|
899
|
-
const value = typeof field === "function" ? field(query) : field;
|
|
900
|
-
return value === "always" || value !== false && isStale(query, options);
|
|
901
|
-
}
|
|
902
|
-
return false;
|
|
903
|
-
}
|
|
904
|
-
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
905
|
-
return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
906
|
-
}
|
|
907
|
-
function isStale(query, options) {
|
|
908
|
-
return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
|
|
909
|
-
}
|
|
910
|
-
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
911
|
-
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
912
|
-
return true;
|
|
913
|
-
}
|
|
914
|
-
return false;
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
// node_modules/@tanstack/query-core/build/modern/mutation.js
|
|
918
|
-
function getDefaultState() {
|
|
919
|
-
return {
|
|
920
|
-
context: void 0,
|
|
921
|
-
data: void 0,
|
|
922
|
-
error: null,
|
|
923
|
-
failureCount: 0,
|
|
924
|
-
failureReason: null,
|
|
925
|
-
isPaused: false,
|
|
926
|
-
status: "idle",
|
|
927
|
-
variables: void 0,
|
|
928
|
-
submittedAt: 0
|
|
929
|
-
};
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
// node_modules/@tanstack/query-core/build/modern/mutationObserver.js
|
|
933
|
-
var _client2, _currentResult2, _currentMutation, _mutateOptions, _MutationObserver_instances, updateResult_fn, notify_fn2, _a5;
|
|
934
|
-
var MutationObserver = (_a5 = class extends Subscribable {
|
|
935
|
-
constructor(client, options) {
|
|
936
|
-
super();
|
|
937
|
-
__privateAdd(this, _MutationObserver_instances);
|
|
938
|
-
__privateAdd(this, _client2);
|
|
939
|
-
__privateAdd(this, _currentResult2);
|
|
940
|
-
__privateAdd(this, _currentMutation);
|
|
941
|
-
__privateAdd(this, _mutateOptions);
|
|
942
|
-
__privateSet(this, _client2, client);
|
|
943
|
-
this.setOptions(options);
|
|
944
|
-
this.bindMethods();
|
|
945
|
-
__privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
|
|
946
|
-
}
|
|
947
|
-
bindMethods() {
|
|
948
|
-
this.mutate = this.mutate.bind(this);
|
|
949
|
-
this.reset = this.reset.bind(this);
|
|
950
|
-
}
|
|
951
|
-
setOptions(options) {
|
|
952
|
-
const prevOptions = this.options;
|
|
953
|
-
this.options = __privateGet(this, _client2).defaultMutationOptions(options);
|
|
954
|
-
if (!shallowEqualObjects(this.options, prevOptions)) {
|
|
955
|
-
__privateGet(this, _client2).getMutationCache().notify({
|
|
956
|
-
type: "observerOptionsUpdated",
|
|
957
|
-
mutation: __privateGet(this, _currentMutation),
|
|
958
|
-
observer: this
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) {
|
|
962
|
-
this.reset();
|
|
963
|
-
} else if (__privateGet(this, _currentMutation)?.state.status === "pending") {
|
|
964
|
-
__privateGet(this, _currentMutation).setOptions(this.options);
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
onUnsubscribe() {
|
|
968
|
-
if (!this.hasListeners()) {
|
|
969
|
-
__privateGet(this, _currentMutation)?.removeObserver(this);
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
onMutationUpdate(action) {
|
|
973
|
-
__privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
|
|
974
|
-
__privateMethod(this, _MutationObserver_instances, notify_fn2).call(this, action);
|
|
975
|
-
}
|
|
976
|
-
getCurrentResult() {
|
|
977
|
-
return __privateGet(this, _currentResult2);
|
|
978
|
-
}
|
|
979
|
-
reset() {
|
|
980
|
-
__privateGet(this, _currentMutation)?.removeObserver(this);
|
|
981
|
-
__privateSet(this, _currentMutation, void 0);
|
|
982
|
-
__privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
|
|
983
|
-
__privateMethod(this, _MutationObserver_instances, notify_fn2).call(this);
|
|
984
|
-
}
|
|
985
|
-
mutate(variables, options) {
|
|
986
|
-
__privateSet(this, _mutateOptions, options);
|
|
987
|
-
__privateGet(this, _currentMutation)?.removeObserver(this);
|
|
988
|
-
__privateSet(this, _currentMutation, __privateGet(this, _client2).getMutationCache().build(__privateGet(this, _client2), this.options));
|
|
989
|
-
__privateGet(this, _currentMutation).addObserver(this);
|
|
990
|
-
return __privateGet(this, _currentMutation).execute(variables);
|
|
991
|
-
}
|
|
992
|
-
}, _client2 = new WeakMap(), _currentResult2 = new WeakMap(), _currentMutation = new WeakMap(), _mutateOptions = new WeakMap(), _MutationObserver_instances = new WeakSet(), updateResult_fn = function() {
|
|
993
|
-
const state = __privateGet(this, _currentMutation)?.state ?? getDefaultState();
|
|
994
|
-
__privateSet(this, _currentResult2, {
|
|
995
|
-
...state,
|
|
996
|
-
isPending: state.status === "pending",
|
|
997
|
-
isSuccess: state.status === "success",
|
|
998
|
-
isError: state.status === "error",
|
|
999
|
-
isIdle: state.status === "idle",
|
|
1000
|
-
mutate: this.mutate,
|
|
1001
|
-
reset: this.reset
|
|
1002
|
-
});
|
|
1003
|
-
}, notify_fn2 = function(action) {
|
|
1004
|
-
notifyManager.batch(() => {
|
|
1005
|
-
if (__privateGet(this, _mutateOptions) && this.hasListeners()) {
|
|
1006
|
-
const variables = __privateGet(this, _currentResult2).variables;
|
|
1007
|
-
const onMutateResult = __privateGet(this, _currentResult2).context;
|
|
1008
|
-
const context = {
|
|
1009
|
-
client: __privateGet(this, _client2),
|
|
1010
|
-
meta: this.options.meta,
|
|
1011
|
-
mutationKey: this.options.mutationKey
|
|
1012
|
-
};
|
|
1013
|
-
if (action?.type === "success") {
|
|
1014
|
-
try {
|
|
1015
|
-
__privateGet(this, _mutateOptions).onSuccess?.(
|
|
1016
|
-
action.data,
|
|
1017
|
-
variables,
|
|
1018
|
-
onMutateResult,
|
|
1019
|
-
context
|
|
1020
|
-
);
|
|
1021
|
-
} catch (e) {
|
|
1022
|
-
void Promise.reject(e);
|
|
1023
|
-
}
|
|
1024
|
-
try {
|
|
1025
|
-
__privateGet(this, _mutateOptions).onSettled?.(
|
|
1026
|
-
action.data,
|
|
1027
|
-
null,
|
|
1028
|
-
variables,
|
|
1029
|
-
onMutateResult,
|
|
1030
|
-
context
|
|
1031
|
-
);
|
|
1032
|
-
} catch (e) {
|
|
1033
|
-
void Promise.reject(e);
|
|
1034
|
-
}
|
|
1035
|
-
} else if (action?.type === "error") {
|
|
1036
|
-
try {
|
|
1037
|
-
__privateGet(this, _mutateOptions).onError?.(
|
|
1038
|
-
action.error,
|
|
1039
|
-
variables,
|
|
1040
|
-
onMutateResult,
|
|
1041
|
-
context
|
|
1042
|
-
);
|
|
1043
|
-
} catch (e) {
|
|
1044
|
-
void Promise.reject(e);
|
|
1045
|
-
}
|
|
1046
|
-
try {
|
|
1047
|
-
__privateGet(this, _mutateOptions).onSettled?.(
|
|
1048
|
-
void 0,
|
|
1049
|
-
action.error,
|
|
1050
|
-
variables,
|
|
1051
|
-
onMutateResult,
|
|
1052
|
-
context
|
|
1053
|
-
);
|
|
1054
|
-
} catch (e) {
|
|
1055
|
-
void Promise.reject(e);
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
this.listeners.forEach((listener) => {
|
|
1060
|
-
listener(__privateGet(this, _currentResult2));
|
|
1061
|
-
});
|
|
1062
|
-
});
|
|
1063
|
-
}, _a5);
|
|
1064
|
-
|
|
1065
|
-
// node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js
|
|
1066
|
-
import * as React from "react";
|
|
1067
|
-
import { jsx } from "react/jsx-runtime";
|
|
1068
|
-
var QueryClientContext = React.createContext(
|
|
1069
|
-
void 0
|
|
1070
|
-
);
|
|
1071
|
-
var useQueryClient = (queryClient) => {
|
|
1072
|
-
const client = React.useContext(QueryClientContext);
|
|
1073
|
-
if (queryClient) {
|
|
1074
|
-
return queryClient;
|
|
1075
|
-
}
|
|
1076
|
-
if (!client) {
|
|
1077
|
-
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
1078
|
-
}
|
|
1079
|
-
return client;
|
|
1080
|
-
};
|
|
1081
|
-
|
|
1082
|
-
// node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js
|
|
1083
|
-
import * as React2 from "react";
|
|
1084
|
-
var IsRestoringContext = React2.createContext(false);
|
|
1085
|
-
var useIsRestoring = () => React2.useContext(IsRestoringContext);
|
|
1086
|
-
var IsRestoringProvider = IsRestoringContext.Provider;
|
|
1087
|
-
|
|
1088
|
-
// node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
|
|
1089
|
-
import * as React3 from "react";
|
|
1090
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
1091
|
-
function createValue() {
|
|
1092
|
-
let isReset = false;
|
|
1093
|
-
return {
|
|
1094
|
-
clearReset: () => {
|
|
1095
|
-
isReset = false;
|
|
1096
|
-
},
|
|
1097
|
-
reset: () => {
|
|
1098
|
-
isReset = true;
|
|
1099
|
-
},
|
|
1100
|
-
isReset: () => {
|
|
1101
|
-
return isReset;
|
|
1102
|
-
}
|
|
1103
|
-
};
|
|
1104
|
-
}
|
|
1105
|
-
var QueryErrorResetBoundaryContext = React3.createContext(createValue());
|
|
1106
|
-
var useQueryErrorResetBoundary = () => React3.useContext(QueryErrorResetBoundaryContext);
|
|
1107
|
-
|
|
1108
|
-
// node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
|
|
1109
|
-
import * as React4 from "react";
|
|
1110
|
-
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {
|
|
1111
|
-
const throwOnError = query?.state.error && typeof options.throwOnError === "function" ? shouldThrowError(options.throwOnError, [query.state.error, query]) : options.throwOnError;
|
|
1112
|
-
if (options.suspense || options.experimental_prefetchInRender || throwOnError) {
|
|
1113
|
-
if (!errorResetBoundary.isReset()) {
|
|
1114
|
-
options.retryOnMount = false;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
};
|
|
1118
|
-
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
1119
|
-
React4.useEffect(() => {
|
|
1120
|
-
errorResetBoundary.clearReset();
|
|
1121
|
-
}, [errorResetBoundary]);
|
|
1122
|
-
};
|
|
1123
|
-
var getHasError = ({
|
|
1124
|
-
result,
|
|
1125
|
-
errorResetBoundary,
|
|
1126
|
-
throwOnError,
|
|
1127
|
-
query,
|
|
1128
|
-
suspense
|
|
1129
|
-
}) => {
|
|
1130
|
-
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
|
|
1131
|
-
};
|
|
1132
|
-
|
|
1133
|
-
// node_modules/@tanstack/react-query/build/modern/suspense.js
|
|
1134
|
-
var ensureSuspenseTimers = (defaultedOptions) => {
|
|
1135
|
-
if (defaultedOptions.suspense) {
|
|
1136
|
-
const MIN_SUSPENSE_TIME_MS = 1e3;
|
|
1137
|
-
const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
|
|
1138
|
-
const originalStaleTime = defaultedOptions.staleTime;
|
|
1139
|
-
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
|
|
1140
|
-
if (typeof defaultedOptions.gcTime === "number") {
|
|
1141
|
-
defaultedOptions.gcTime = Math.max(
|
|
1142
|
-
defaultedOptions.gcTime,
|
|
1143
|
-
MIN_SUSPENSE_TIME_MS
|
|
1144
|
-
);
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
};
|
|
1148
|
-
var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
|
|
1149
|
-
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
|
|
1150
|
-
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
1151
|
-
errorResetBoundary.clearReset();
|
|
1152
|
-
});
|
|
1153
|
-
|
|
1154
|
-
// node_modules/@tanstack/react-query/build/modern/useBaseQuery.js
|
|
1155
|
-
import * as React5 from "react";
|
|
1156
|
-
function useBaseQuery(options, Observer, queryClient) {
|
|
1157
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1158
|
-
if (typeof options !== "object" || Array.isArray(options)) {
|
|
1159
|
-
throw new Error(
|
|
1160
|
-
'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
|
|
1161
|
-
);
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
const isRestoring = useIsRestoring();
|
|
1165
|
-
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
1166
|
-
const client = useQueryClient(queryClient);
|
|
1167
|
-
const defaultedOptions = client.defaultQueryOptions(options);
|
|
1168
|
-
client.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
1169
|
-
defaultedOptions
|
|
1170
|
-
);
|
|
1171
|
-
const query = client.getQueryCache().get(defaultedOptions.queryHash);
|
|
1172
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1173
|
-
if (!defaultedOptions.queryFn) {
|
|
1174
|
-
console.error(
|
|
1175
|
-
`[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
|
|
1176
|
-
);
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
1180
|
-
ensureSuspenseTimers(defaultedOptions);
|
|
1181
|
-
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);
|
|
1182
|
-
useClearResetErrorBoundary(errorResetBoundary);
|
|
1183
|
-
const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
|
|
1184
|
-
const [observer] = React5.useState(
|
|
1185
|
-
() => new Observer(
|
|
1186
|
-
client,
|
|
1187
|
-
defaultedOptions
|
|
1188
|
-
)
|
|
1189
|
-
);
|
|
1190
|
-
const result = observer.getOptimisticResult(defaultedOptions);
|
|
1191
|
-
const shouldSubscribe = !isRestoring && options.subscribed !== false;
|
|
1192
|
-
React5.useSyncExternalStore(
|
|
1193
|
-
React5.useCallback(
|
|
1194
|
-
(onStoreChange) => {
|
|
1195
|
-
const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;
|
|
1196
|
-
observer.updateResult();
|
|
1197
|
-
return unsubscribe;
|
|
1198
|
-
},
|
|
1199
|
-
[observer, shouldSubscribe]
|
|
1200
|
-
),
|
|
1201
|
-
() => observer.getCurrentResult(),
|
|
1202
|
-
() => observer.getCurrentResult()
|
|
1203
|
-
);
|
|
1204
|
-
React5.useEffect(() => {
|
|
1205
|
-
observer.setOptions(defaultedOptions);
|
|
1206
|
-
}, [defaultedOptions, observer]);
|
|
1207
|
-
if (shouldSuspend(defaultedOptions, result)) {
|
|
1208
|
-
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
1209
|
-
}
|
|
1210
|
-
if (getHasError({
|
|
1211
|
-
result,
|
|
1212
|
-
errorResetBoundary,
|
|
1213
|
-
throwOnError: defaultedOptions.throwOnError,
|
|
1214
|
-
query,
|
|
1215
|
-
suspense: defaultedOptions.suspense
|
|
1216
|
-
})) {
|
|
1217
|
-
throw result.error;
|
|
1218
|
-
}
|
|
1219
|
-
;
|
|
1220
|
-
client.getDefaultOptions().queries?._experimental_afterQuery?.(
|
|
1221
|
-
defaultedOptions,
|
|
1222
|
-
result
|
|
1223
|
-
);
|
|
1224
|
-
if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) {
|
|
1225
|
-
const promise = isNewCacheEntry ? (
|
|
1226
|
-
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
1227
|
-
fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
|
|
1228
|
-
) : (
|
|
1229
|
-
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
1230
|
-
query?.promise
|
|
1231
|
-
);
|
|
1232
|
-
promise?.catch(noop).finally(() => {
|
|
1233
|
-
observer.updateResult();
|
|
1234
|
-
});
|
|
1235
|
-
}
|
|
1236
|
-
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
// node_modules/@tanstack/react-query/build/modern/useQuery.js
|
|
1240
|
-
function useQuery(options, queryClient) {
|
|
1241
|
-
return useBaseQuery(options, QueryObserver, queryClient);
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
// node_modules/@tanstack/react-query/build/modern/useMutation.js
|
|
1245
|
-
import * as React6 from "react";
|
|
1246
|
-
function useMutation(options, queryClient) {
|
|
1247
|
-
const client = useQueryClient(queryClient);
|
|
1248
|
-
const [observer] = React6.useState(
|
|
1249
|
-
() => new MutationObserver(
|
|
1250
|
-
client,
|
|
1251
|
-
options
|
|
1252
|
-
)
|
|
1253
|
-
);
|
|
1254
|
-
React6.useEffect(() => {
|
|
1255
|
-
observer.setOptions(options);
|
|
1256
|
-
}, [observer, options]);
|
|
1257
|
-
const result = React6.useSyncExternalStore(
|
|
1258
|
-
React6.useCallback(
|
|
1259
|
-
(onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)),
|
|
1260
|
-
[observer]
|
|
1261
|
-
),
|
|
1262
|
-
() => observer.getCurrentResult(),
|
|
1263
|
-
() => observer.getCurrentResult()
|
|
1264
|
-
);
|
|
1265
|
-
const mutate = React6.useCallback(
|
|
1266
|
-
(variables, mutateOptions) => {
|
|
1267
|
-
observer.mutate(variables, mutateOptions).catch(noop);
|
|
1268
|
-
},
|
|
1269
|
-
[observer]
|
|
1270
|
-
);
|
|
1271
|
-
if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) {
|
|
1272
|
-
throw result.error;
|
|
1273
|
-
}
|
|
1274
|
-
return { ...result, mutate, mutateAsync: result.mutate };
|
|
1275
|
-
}
|
|
1276
|
-
export {
|
|
1277
|
-
useMutation,
|
|
1278
|
-
useQuery,
|
|
1279
|
-
useQueryClient
|
|
1280
|
-
};
|
|
1281
|
-
//# sourceMappingURL=tanstack.mjs.map
|