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