rails-profiler 0.26.0 → 0.27.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.
- checksums.yaml +4 -4
- data/app/assets/builds/profiler-toolbar.js +2888 -72
- data/app/assets/builds/profiler.js +3887 -513
- data/lib/profiler/mcp/resources/recent_console.rb +36 -0
- data/lib/profiler/mcp/server.rb +53 -10
- data/lib/profiler/mcp/tools/clear_profiles.rb +3 -3
- data/lib/profiler/mcp/tools/get_profile_detail.rb +123 -1
- data/lib/profiler/mcp/tools/get_profile_mailers.rb +147 -0
- data/lib/profiler/mcp/tools/query_console_profiles.rb +95 -0
- data/lib/profiler/storage/file_store.rb +36 -22
- data/lib/profiler/version.rb +1 -1
- metadata +5 -2
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
+
var __typeError = (msg) => {
|
|
4
|
+
throw TypeError(msg);
|
|
5
|
+
};
|
|
6
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
7
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
8
|
+
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);
|
|
9
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
10
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
11
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
12
|
+
set _(value) {
|
|
13
|
+
__privateSet(obj, member, value, setter);
|
|
14
|
+
},
|
|
15
|
+
get _() {
|
|
16
|
+
return __privateGet(obj, member, getter);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
3
20
|
// node_modules/preact/dist/preact.module.js
|
|
4
21
|
var n;
|
|
5
22
|
var l;
|
|
@@ -184,25 +201,25 @@
|
|
|
184
201
|
return "object" != typeof n2 || null == n2 || n2.__b > 0 ? n2 : d(n2) ? n2.map(q) : w({}, n2);
|
|
185
202
|
}
|
|
186
203
|
function B(u4, t3, i3, r3, o3, e3, f4, c3, s3) {
|
|
187
|
-
var a3, h3, v3, y3, w3, _3, m3, b = i3.props || p, k3 = t3.props,
|
|
188
|
-
if ("svg" ==
|
|
189
|
-
for (a3 = 0; a3 < e3.length; a3++) if ((w3 = e3[a3]) && "setAttribute" in w3 == !!
|
|
204
|
+
var a3, h3, v3, y3, w3, _3, m3, b = i3.props || p, k3 = t3.props, x3 = t3.type;
|
|
205
|
+
if ("svg" == x3 ? o3 = "http://www.w3.org/2000/svg" : "math" == x3 ? o3 = "http://www.w3.org/1998/Math/MathML" : o3 || (o3 = "http://www.w3.org/1999/xhtml"), null != e3) {
|
|
206
|
+
for (a3 = 0; a3 < e3.length; a3++) if ((w3 = e3[a3]) && "setAttribute" in w3 == !!x3 && (x3 ? w3.localName == x3 : 3 == w3.nodeType)) {
|
|
190
207
|
u4 = w3, e3[a3] = null;
|
|
191
208
|
break;
|
|
192
209
|
}
|
|
193
210
|
}
|
|
194
211
|
if (null == u4) {
|
|
195
|
-
if (null ==
|
|
196
|
-
u4 = document.createElementNS(o3,
|
|
212
|
+
if (null == x3) return document.createTextNode(k3);
|
|
213
|
+
u4 = document.createElementNS(o3, x3, k3.is && k3), c3 && (l.__m && l.__m(t3, e3), c3 = false), e3 = null;
|
|
197
214
|
}
|
|
198
|
-
if (null ==
|
|
215
|
+
if (null == x3) b === k3 || c3 && u4.data == k3 || (u4.data = k3);
|
|
199
216
|
else {
|
|
200
217
|
if (e3 = e3 && n.call(u4.childNodes), !c3 && null != e3) for (b = {}, a3 = 0; a3 < u4.attributes.length; a3++) b[(w3 = u4.attributes[a3]).name] = w3.value;
|
|
201
218
|
for (a3 in b) w3 = b[a3], "dangerouslySetInnerHTML" == a3 ? v3 = w3 : "children" == a3 || a3 in k3 || "value" == a3 && "defaultValue" in k3 || "checked" == a3 && "defaultChecked" in k3 || F(u4, a3, null, w3, o3);
|
|
202
219
|
for (a3 in k3) w3 = k3[a3], "children" == a3 ? y3 = w3 : "dangerouslySetInnerHTML" == a3 ? h3 = w3 : "value" == a3 ? _3 = w3 : "checked" == a3 ? m3 = w3 : c3 && "function" != typeof w3 || b[a3] === w3 || F(u4, a3, w3, b[a3], o3);
|
|
203
220
|
if (h3) c3 || v3 && (h3.__html == v3.__html || h3.__html == u4.innerHTML) || (u4.innerHTML = h3.__html), t3.__k = [];
|
|
204
|
-
else if (v3 && (u4.innerHTML = ""), P("template" == t3.type ? u4.content : u4, d(y3) ? y3 : [y3], t3, i3, r3, "foreignObject" ==
|
|
205
|
-
c3 || (a3 = "value", "progress" ==
|
|
221
|
+
else if (v3 && (u4.innerHTML = ""), P("template" == t3.type ? u4.content : u4, d(y3) ? y3 : [y3], t3, i3, r3, "foreignObject" == x3 ? "http://www.w3.org/1999/xhtml" : o3, e3, f4, e3 ? e3[0] : i3.__k && S(i3, 0), c3, s3), null != e3) for (a3 = e3.length; a3--; ) g(e3[a3]);
|
|
222
|
+
c3 || (a3 = "value", "progress" == x3 && null == _3 ? u4.removeAttribute("value") : null != _3 && (_3 !== u4[a3] || "progress" == x3 && !_3 || "option" == x3 && _3 != b[a3]) && F(u4, a3, _3, b[a3], o3), a3 = "checked", null != m3 && m3 != u4[a3] && F(u4, a3, m3, b[a3], o3));
|
|
206
223
|
}
|
|
207
224
|
return u4;
|
|
208
225
|
}
|
|
@@ -236,6 +253,29 @@
|
|
|
236
253
|
var r3, o3, e3, f4;
|
|
237
254
|
t3 == document && (t3 = document.documentElement), l.__ && l.__(u4, t3), o3 = (r3 = "function" == typeof i3) ? null : i3 && i3.__k || t3.__k, e3 = [], f4 = [], z(t3, u4 = (!r3 && i3 || t3).__k = _(k, null, [u4]), o3 || p, p, t3.namespaceURI, !r3 && i3 ? [i3] : o3 ? null : t3.firstChild ? n.call(t3.childNodes) : null, e3, !r3 && i3 ? i3 : o3 ? o3.__e : t3.firstChild, r3, f4), V(e3, u4, f4);
|
|
238
255
|
}
|
|
256
|
+
function R(n2) {
|
|
257
|
+
function l3(n3) {
|
|
258
|
+
var u4, t3;
|
|
259
|
+
return this.getChildContext || (u4 = /* @__PURE__ */ new Set(), (t3 = {})[l3.__c] = this, this.getChildContext = function() {
|
|
260
|
+
return t3;
|
|
261
|
+
}, this.componentWillUnmount = function() {
|
|
262
|
+
u4 = null;
|
|
263
|
+
}, this.shouldComponentUpdate = function(n4) {
|
|
264
|
+
this.props.value != n4.value && u4.forEach(function(n5) {
|
|
265
|
+
n5.__e = true, $(n5);
|
|
266
|
+
});
|
|
267
|
+
}, this.sub = function(n4) {
|
|
268
|
+
u4.add(n4);
|
|
269
|
+
var l4 = n4.componentWillUnmount;
|
|
270
|
+
n4.componentWillUnmount = function() {
|
|
271
|
+
u4 && u4.delete(n4), l4 && l4.call(n4);
|
|
272
|
+
};
|
|
273
|
+
}), n3.children;
|
|
274
|
+
}
|
|
275
|
+
return l3.__c = "__cC" + h++, l3.__ = n2, l3.Provider = l3.__l = (l3.Consumer = function(n3, l4) {
|
|
276
|
+
return n3.children(l4);
|
|
277
|
+
}).contextType = l3, l3;
|
|
278
|
+
}
|
|
239
279
|
n = v.slice, l = { __e: function(n2, l3, u4, t3) {
|
|
240
280
|
for (var i3, r3, o3; l3 = l3.__; ) if ((i3 = l3.__c) && !i3.__) try {
|
|
241
281
|
if ((r3 = i3.constructor) && null != r3.getDerivedStateFromError && (i3.setState(r3.getDerivedStateFromError(n2)), o3 = i3.__d), null != i3.componentDidCatch && (i3.componentDidCatch(n2, t3 || {}), o3 = i3.__d), o3) return i3.__E = i3;
|
|
@@ -327,6 +367,15 @@
|
|
|
327
367
|
var u4 = p2(t2++, 7);
|
|
328
368
|
return C2(u4.__H, r3) && (u4.__ = n2(), u4.__H = r3, u4.__h = n2), u4.__;
|
|
329
369
|
}
|
|
370
|
+
function q2(n2, t3) {
|
|
371
|
+
return o2 = 8, T2(function() {
|
|
372
|
+
return n2;
|
|
373
|
+
}, t3);
|
|
374
|
+
}
|
|
375
|
+
function x2(n2) {
|
|
376
|
+
var u4 = r2.context[n2.__c], i3 = p2(t2++, 9);
|
|
377
|
+
return i3.c = n2, u4 ? (null == i3.__ && (i3.__ = true, u4.sub(r2)), u4.props.value) : n2.__;
|
|
378
|
+
}
|
|
330
379
|
function j2() {
|
|
331
380
|
for (var n2; n2 = f2.shift(); ) {
|
|
332
381
|
var t3 = n2.__H;
|
|
@@ -337,69 +386,2575 @@
|
|
|
337
386
|
}
|
|
338
387
|
}
|
|
339
388
|
}
|
|
340
|
-
c2.__b = function(n2) {
|
|
341
|
-
r2 = null, e2 && e2(n2);
|
|
342
|
-
}, c2.__ = function(n2, t3) {
|
|
343
|
-
n2 && t3.__k && t3.__k.__m && (n2.__m = t3.__k.__m), s2 && s2(n2, t3);
|
|
344
|
-
}, c2.__r = function(n2) {
|
|
345
|
-
a2 && a2(n2), t2 = 0;
|
|
346
|
-
var i3 = (r2 = n2.__c).__H;
|
|
347
|
-
i3 && (u2 === r2 ? (i3.__h = [], r2.__h = [], i3.__.some(function(n3) {
|
|
348
|
-
n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = void 0;
|
|
349
|
-
})) : (i3.__h.some(z2), i3.__h.some(B2), i3.__h = [], t2 = 0)), u2 = r2;
|
|
350
|
-
}, c2.diffed = function(n2) {
|
|
351
|
-
v2 && v2(n2);
|
|
352
|
-
var t3 = n2.__c;
|
|
353
|
-
t3 && t3.__H && (t3.__H.__h.length && (1 !== f2.push(t3) && i2 === c2.requestAnimationFrame || ((i2 = c2.requestAnimationFrame) || w2)(j2)), t3.__H.__.some(function(n3) {
|
|
354
|
-
n3.u && (n3.__H = n3.u), n3.u = void 0;
|
|
355
|
-
})), u2 = r2 = null;
|
|
356
|
-
}, c2.__c = function(n2, t3) {
|
|
357
|
-
t3.some(function(n3) {
|
|
358
|
-
try {
|
|
359
|
-
n3.__h.some(z2), n3.__h = n3.__h.filter(function(n4) {
|
|
360
|
-
return !n4.__ || B2(n4);
|
|
389
|
+
c2.__b = function(n2) {
|
|
390
|
+
r2 = null, e2 && e2(n2);
|
|
391
|
+
}, c2.__ = function(n2, t3) {
|
|
392
|
+
n2 && t3.__k && t3.__k.__m && (n2.__m = t3.__k.__m), s2 && s2(n2, t3);
|
|
393
|
+
}, c2.__r = function(n2) {
|
|
394
|
+
a2 && a2(n2), t2 = 0;
|
|
395
|
+
var i3 = (r2 = n2.__c).__H;
|
|
396
|
+
i3 && (u2 === r2 ? (i3.__h = [], r2.__h = [], i3.__.some(function(n3) {
|
|
397
|
+
n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = void 0;
|
|
398
|
+
})) : (i3.__h.some(z2), i3.__h.some(B2), i3.__h = [], t2 = 0)), u2 = r2;
|
|
399
|
+
}, c2.diffed = function(n2) {
|
|
400
|
+
v2 && v2(n2);
|
|
401
|
+
var t3 = n2.__c;
|
|
402
|
+
t3 && t3.__H && (t3.__H.__h.length && (1 !== f2.push(t3) && i2 === c2.requestAnimationFrame || ((i2 = c2.requestAnimationFrame) || w2)(j2)), t3.__H.__.some(function(n3) {
|
|
403
|
+
n3.u && (n3.__H = n3.u), n3.u = void 0;
|
|
404
|
+
})), u2 = r2 = null;
|
|
405
|
+
}, c2.__c = function(n2, t3) {
|
|
406
|
+
t3.some(function(n3) {
|
|
407
|
+
try {
|
|
408
|
+
n3.__h.some(z2), n3.__h = n3.__h.filter(function(n4) {
|
|
409
|
+
return !n4.__ || B2(n4);
|
|
410
|
+
});
|
|
411
|
+
} catch (r3) {
|
|
412
|
+
t3.some(function(n4) {
|
|
413
|
+
n4.__h && (n4.__h = []);
|
|
414
|
+
}), t3 = [], c2.__e(r3, n3.__v);
|
|
415
|
+
}
|
|
416
|
+
}), l2 && l2(n2, t3);
|
|
417
|
+
}, c2.unmount = function(n2) {
|
|
418
|
+
m2 && m2(n2);
|
|
419
|
+
var t3, r3 = n2.__c;
|
|
420
|
+
r3 && r3.__H && (r3.__H.__.some(function(n3) {
|
|
421
|
+
try {
|
|
422
|
+
z2(n3);
|
|
423
|
+
} catch (n4) {
|
|
424
|
+
t3 = n4;
|
|
425
|
+
}
|
|
426
|
+
}), r3.__H = void 0, t3 && c2.__e(t3, r3.__v));
|
|
427
|
+
};
|
|
428
|
+
var k2 = "function" == typeof requestAnimationFrame;
|
|
429
|
+
function w2(n2) {
|
|
430
|
+
var t3, r3 = function() {
|
|
431
|
+
clearTimeout(u4), k2 && cancelAnimationFrame(t3), setTimeout(n2);
|
|
432
|
+
}, u4 = setTimeout(r3, 35);
|
|
433
|
+
k2 && (t3 = requestAnimationFrame(r3));
|
|
434
|
+
}
|
|
435
|
+
function z2(n2) {
|
|
436
|
+
var t3 = r2, u4 = n2.__c;
|
|
437
|
+
"function" == typeof u4 && (n2.__c = void 0, u4()), r2 = t3;
|
|
438
|
+
}
|
|
439
|
+
function B2(n2) {
|
|
440
|
+
var t3 = r2;
|
|
441
|
+
n2.__c = n2.__(), r2 = t3;
|
|
442
|
+
}
|
|
443
|
+
function C2(n2, t3) {
|
|
444
|
+
return !n2 || n2.length !== t3.length || t3.some(function(t4, r3) {
|
|
445
|
+
return t4 !== n2[r3];
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function D2(n2, t3) {
|
|
449
|
+
return "function" == typeof t3 ? t3(n2) : t3;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// node_modules/@tanstack/query-core/build/modern/subscribable.js
|
|
453
|
+
var Subscribable = class {
|
|
454
|
+
constructor() {
|
|
455
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
456
|
+
this.subscribe = this.subscribe.bind(this);
|
|
457
|
+
}
|
|
458
|
+
subscribe(listener) {
|
|
459
|
+
this.listeners.add(listener);
|
|
460
|
+
this.onSubscribe();
|
|
461
|
+
return () => {
|
|
462
|
+
this.listeners.delete(listener);
|
|
463
|
+
this.onUnsubscribe();
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
hasListeners() {
|
|
467
|
+
return this.listeners.size > 0;
|
|
468
|
+
}
|
|
469
|
+
onSubscribe() {
|
|
470
|
+
}
|
|
471
|
+
onUnsubscribe() {
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
// node_modules/@tanstack/query-core/build/modern/focusManager.js
|
|
476
|
+
var _focused, _cleanup, _setup, _a;
|
|
477
|
+
var FocusManager = (_a = class extends Subscribable {
|
|
478
|
+
constructor() {
|
|
479
|
+
super();
|
|
480
|
+
__privateAdd(this, _focused);
|
|
481
|
+
__privateAdd(this, _cleanup);
|
|
482
|
+
__privateAdd(this, _setup);
|
|
483
|
+
__privateSet(this, _setup, (onFocus) => {
|
|
484
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
485
|
+
const listener = () => onFocus();
|
|
486
|
+
window.addEventListener("visibilitychange", listener, false);
|
|
487
|
+
return () => {
|
|
488
|
+
window.removeEventListener("visibilitychange", listener);
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
return;
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
onSubscribe() {
|
|
495
|
+
if (!__privateGet(this, _cleanup)) {
|
|
496
|
+
this.setEventListener(__privateGet(this, _setup));
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
onUnsubscribe() {
|
|
500
|
+
var _a11;
|
|
501
|
+
if (!this.hasListeners()) {
|
|
502
|
+
(_a11 = __privateGet(this, _cleanup)) == null ? void 0 : _a11.call(this);
|
|
503
|
+
__privateSet(this, _cleanup, void 0);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
setEventListener(setup) {
|
|
507
|
+
var _a11;
|
|
508
|
+
__privateSet(this, _setup, setup);
|
|
509
|
+
(_a11 = __privateGet(this, _cleanup)) == null ? void 0 : _a11.call(this);
|
|
510
|
+
__privateSet(this, _cleanup, setup((focused) => {
|
|
511
|
+
if (typeof focused === "boolean") {
|
|
512
|
+
this.setFocused(focused);
|
|
513
|
+
} else {
|
|
514
|
+
this.onFocus();
|
|
515
|
+
}
|
|
516
|
+
}));
|
|
517
|
+
}
|
|
518
|
+
setFocused(focused) {
|
|
519
|
+
const changed = __privateGet(this, _focused) !== focused;
|
|
520
|
+
if (changed) {
|
|
521
|
+
__privateSet(this, _focused, focused);
|
|
522
|
+
this.onFocus();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
onFocus() {
|
|
526
|
+
const isFocused = this.isFocused();
|
|
527
|
+
this.listeners.forEach((listener) => {
|
|
528
|
+
listener(isFocused);
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
isFocused() {
|
|
532
|
+
if (typeof __privateGet(this, _focused) === "boolean") {
|
|
533
|
+
return __privateGet(this, _focused);
|
|
534
|
+
}
|
|
535
|
+
return globalThis.document?.visibilityState !== "hidden";
|
|
536
|
+
}
|
|
537
|
+
}, _focused = new WeakMap(), _cleanup = new WeakMap(), _setup = new WeakMap(), _a);
|
|
538
|
+
var focusManager = new FocusManager();
|
|
539
|
+
|
|
540
|
+
// node_modules/@tanstack/query-core/build/modern/timeoutManager.js
|
|
541
|
+
var defaultTimeoutProvider = {
|
|
542
|
+
// We need the wrapper function syntax below instead of direct references to
|
|
543
|
+
// global setTimeout etc.
|
|
544
|
+
//
|
|
545
|
+
// BAD: `setTimeout: setTimeout`
|
|
546
|
+
// GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
|
|
547
|
+
//
|
|
548
|
+
// If we use direct references here, then anything that wants to spy on or
|
|
549
|
+
// replace the global setTimeout (like tests) won't work since we'll already
|
|
550
|
+
// have a hard reference to the original implementation at the time when this
|
|
551
|
+
// file was imported.
|
|
552
|
+
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
553
|
+
clearTimeout: (timeoutId) => clearTimeout(timeoutId),
|
|
554
|
+
setInterval: (callback, delay) => setInterval(callback, delay),
|
|
555
|
+
clearInterval: (intervalId) => clearInterval(intervalId)
|
|
556
|
+
};
|
|
557
|
+
var _provider, _providerCalled, _a2;
|
|
558
|
+
var TimeoutManager = (_a2 = class {
|
|
559
|
+
constructor() {
|
|
560
|
+
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete
|
|
561
|
+
// type at app boot; and if we leave that type, then any new timer provider
|
|
562
|
+
// would need to support the default provider's concrete timer ID, which is
|
|
563
|
+
// infeasible across environments.
|
|
564
|
+
//
|
|
565
|
+
// We settle for type safety for the TimeoutProvider type, and accept that
|
|
566
|
+
// this class is unsafe internally to allow for extension.
|
|
567
|
+
__privateAdd(this, _provider, defaultTimeoutProvider);
|
|
568
|
+
__privateAdd(this, _providerCalled, false);
|
|
569
|
+
}
|
|
570
|
+
setTimeoutProvider(provider) {
|
|
571
|
+
if (true) {
|
|
572
|
+
if (__privateGet(this, _providerCalled) && provider !== __privateGet(this, _provider)) {
|
|
573
|
+
console.error(
|
|
574
|
+
`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
|
|
575
|
+
{ previous: __privateGet(this, _provider), provider }
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
__privateSet(this, _provider, provider);
|
|
580
|
+
if (true) {
|
|
581
|
+
__privateSet(this, _providerCalled, false);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
setTimeout(callback, delay) {
|
|
585
|
+
if (true) {
|
|
586
|
+
__privateSet(this, _providerCalled, true);
|
|
587
|
+
}
|
|
588
|
+
return __privateGet(this, _provider).setTimeout(callback, delay);
|
|
589
|
+
}
|
|
590
|
+
clearTimeout(timeoutId) {
|
|
591
|
+
__privateGet(this, _provider).clearTimeout(timeoutId);
|
|
592
|
+
}
|
|
593
|
+
setInterval(callback, delay) {
|
|
594
|
+
if (true) {
|
|
595
|
+
__privateSet(this, _providerCalled, true);
|
|
596
|
+
}
|
|
597
|
+
return __privateGet(this, _provider).setInterval(callback, delay);
|
|
598
|
+
}
|
|
599
|
+
clearInterval(intervalId) {
|
|
600
|
+
__privateGet(this, _provider).clearInterval(intervalId);
|
|
601
|
+
}
|
|
602
|
+
}, _provider = new WeakMap(), _providerCalled = new WeakMap(), _a2);
|
|
603
|
+
var timeoutManager = new TimeoutManager();
|
|
604
|
+
function systemSetTimeoutZero(callback) {
|
|
605
|
+
setTimeout(callback, 0);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// node_modules/@tanstack/query-core/build/modern/utils.js
|
|
609
|
+
var isServer = typeof window === "undefined" || "Deno" in globalThis;
|
|
610
|
+
function noop() {
|
|
611
|
+
}
|
|
612
|
+
function functionalUpdate(updater, input) {
|
|
613
|
+
return typeof updater === "function" ? updater(input) : updater;
|
|
614
|
+
}
|
|
615
|
+
function isValidTimeout(value) {
|
|
616
|
+
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
617
|
+
}
|
|
618
|
+
function timeUntilStale(updatedAt, staleTime) {
|
|
619
|
+
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
620
|
+
}
|
|
621
|
+
function resolveStaleTime(staleTime, query) {
|
|
622
|
+
return typeof staleTime === "function" ? staleTime(query) : staleTime;
|
|
623
|
+
}
|
|
624
|
+
function resolveQueryBoolean(option, query) {
|
|
625
|
+
return typeof option === "function" ? option(query) : option;
|
|
626
|
+
}
|
|
627
|
+
function matchQuery(filters, query) {
|
|
628
|
+
const {
|
|
629
|
+
type = "all",
|
|
630
|
+
exact,
|
|
631
|
+
fetchStatus,
|
|
632
|
+
predicate,
|
|
633
|
+
queryKey,
|
|
634
|
+
stale
|
|
635
|
+
} = filters;
|
|
636
|
+
if (queryKey) {
|
|
637
|
+
if (exact) {
|
|
638
|
+
if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {
|
|
639
|
+
return false;
|
|
640
|
+
}
|
|
641
|
+
} else if (!partialMatchKey(query.queryKey, queryKey)) {
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
if (type !== "all") {
|
|
646
|
+
const isActive = query.isActive();
|
|
647
|
+
if (type === "active" && !isActive) {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
if (type === "inactive" && isActive) {
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
if (typeof stale === "boolean" && query.isStale() !== stale) {
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
if (fetchStatus && fetchStatus !== query.state.fetchStatus) {
|
|
658
|
+
return false;
|
|
659
|
+
}
|
|
660
|
+
if (predicate && !predicate(query)) {
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
return true;
|
|
664
|
+
}
|
|
665
|
+
function matchMutation(filters, mutation) {
|
|
666
|
+
const { exact, status, predicate, mutationKey } = filters;
|
|
667
|
+
if (mutationKey) {
|
|
668
|
+
if (!mutation.options.mutationKey) {
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
if (exact) {
|
|
672
|
+
if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
} else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
if (status && mutation.state.status !== status) {
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
if (predicate && !predicate(mutation)) {
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
return true;
|
|
686
|
+
}
|
|
687
|
+
function hashQueryKeyByOptions(queryKey, options) {
|
|
688
|
+
const hashFn = options?.queryKeyHashFn || hashKey;
|
|
689
|
+
return hashFn(queryKey);
|
|
690
|
+
}
|
|
691
|
+
function hashKey(queryKey) {
|
|
692
|
+
return JSON.stringify(
|
|
693
|
+
queryKey,
|
|
694
|
+
(_3, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
|
|
695
|
+
result[key] = val[key];
|
|
696
|
+
return result;
|
|
697
|
+
}, {}) : val
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
function partialMatchKey(a3, b) {
|
|
701
|
+
if (a3 === b) {
|
|
702
|
+
return true;
|
|
703
|
+
}
|
|
704
|
+
if (typeof a3 !== typeof b) {
|
|
705
|
+
return false;
|
|
706
|
+
}
|
|
707
|
+
if (a3 && b && typeof a3 === "object" && typeof b === "object") {
|
|
708
|
+
return Object.keys(b).every((key) => partialMatchKey(a3[key], b[key]));
|
|
709
|
+
}
|
|
710
|
+
return false;
|
|
711
|
+
}
|
|
712
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
713
|
+
function replaceEqualDeep(a3, b, depth = 0) {
|
|
714
|
+
if (a3 === b) {
|
|
715
|
+
return a3;
|
|
716
|
+
}
|
|
717
|
+
if (depth > 500) return b;
|
|
718
|
+
const array = isPlainArray(a3) && isPlainArray(b);
|
|
719
|
+
if (!array && !(isPlainObject(a3) && isPlainObject(b))) return b;
|
|
720
|
+
const aItems = array ? a3 : Object.keys(a3);
|
|
721
|
+
const aSize = aItems.length;
|
|
722
|
+
const bItems = array ? b : Object.keys(b);
|
|
723
|
+
const bSize = bItems.length;
|
|
724
|
+
const copy = array ? new Array(bSize) : {};
|
|
725
|
+
let equalItems = 0;
|
|
726
|
+
for (let i3 = 0; i3 < bSize; i3++) {
|
|
727
|
+
const key = array ? i3 : bItems[i3];
|
|
728
|
+
const aItem = a3[key];
|
|
729
|
+
const bItem = b[key];
|
|
730
|
+
if (aItem === bItem) {
|
|
731
|
+
copy[key] = aItem;
|
|
732
|
+
if (array ? i3 < aSize : hasOwn.call(a3, key)) equalItems++;
|
|
733
|
+
continue;
|
|
734
|
+
}
|
|
735
|
+
if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
|
|
736
|
+
copy[key] = bItem;
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
const v3 = replaceEqualDeep(aItem, bItem, depth + 1);
|
|
740
|
+
copy[key] = v3;
|
|
741
|
+
if (v3 === aItem) equalItems++;
|
|
742
|
+
}
|
|
743
|
+
return aSize === bSize && equalItems === aSize ? a3 : copy;
|
|
744
|
+
}
|
|
745
|
+
function shallowEqualObjects(a3, b) {
|
|
746
|
+
if (!b || Object.keys(a3).length !== Object.keys(b).length) {
|
|
747
|
+
return false;
|
|
748
|
+
}
|
|
749
|
+
for (const key in a3) {
|
|
750
|
+
if (a3[key] !== b[key]) {
|
|
751
|
+
return false;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return true;
|
|
755
|
+
}
|
|
756
|
+
function isPlainArray(value) {
|
|
757
|
+
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
758
|
+
}
|
|
759
|
+
function isPlainObject(o3) {
|
|
760
|
+
if (!hasObjectPrototype(o3)) {
|
|
761
|
+
return false;
|
|
762
|
+
}
|
|
763
|
+
const ctor = o3.constructor;
|
|
764
|
+
if (ctor === void 0) {
|
|
765
|
+
return true;
|
|
766
|
+
}
|
|
767
|
+
const prot = ctor.prototype;
|
|
768
|
+
if (!hasObjectPrototype(prot)) {
|
|
769
|
+
return false;
|
|
770
|
+
}
|
|
771
|
+
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
772
|
+
return false;
|
|
773
|
+
}
|
|
774
|
+
if (Object.getPrototypeOf(o3) !== Object.prototype) {
|
|
775
|
+
return false;
|
|
776
|
+
}
|
|
777
|
+
return true;
|
|
778
|
+
}
|
|
779
|
+
function hasObjectPrototype(o3) {
|
|
780
|
+
return Object.prototype.toString.call(o3) === "[object Object]";
|
|
781
|
+
}
|
|
782
|
+
function sleep(timeout) {
|
|
783
|
+
return new Promise((resolve) => {
|
|
784
|
+
timeoutManager.setTimeout(resolve, timeout);
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
function replaceData(prevData, data, options) {
|
|
788
|
+
if (typeof options.structuralSharing === "function") {
|
|
789
|
+
return options.structuralSharing(prevData, data);
|
|
790
|
+
} else if (options.structuralSharing !== false) {
|
|
791
|
+
if (true) {
|
|
792
|
+
try {
|
|
793
|
+
return replaceEqualDeep(prevData, data);
|
|
794
|
+
} catch (error) {
|
|
795
|
+
console.error(
|
|
796
|
+
`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}`
|
|
797
|
+
);
|
|
798
|
+
throw error;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
return replaceEqualDeep(prevData, data);
|
|
802
|
+
}
|
|
803
|
+
return data;
|
|
804
|
+
}
|
|
805
|
+
function addToEnd(items, item, max = 0) {
|
|
806
|
+
const newItems = [...items, item];
|
|
807
|
+
return max && newItems.length > max ? newItems.slice(1) : newItems;
|
|
808
|
+
}
|
|
809
|
+
function addToStart(items, item, max = 0) {
|
|
810
|
+
const newItems = [item, ...items];
|
|
811
|
+
return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
|
|
812
|
+
}
|
|
813
|
+
var skipToken = /* @__PURE__ */ Symbol();
|
|
814
|
+
function ensureQueryFn(options, fetchOptions) {
|
|
815
|
+
if (true) {
|
|
816
|
+
if (options.queryFn === skipToken) {
|
|
817
|
+
console.error(
|
|
818
|
+
`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
if (!options.queryFn && fetchOptions?.initialPromise) {
|
|
823
|
+
return () => fetchOptions.initialPromise;
|
|
824
|
+
}
|
|
825
|
+
if (!options.queryFn || options.queryFn === skipToken) {
|
|
826
|
+
return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));
|
|
827
|
+
}
|
|
828
|
+
return options.queryFn;
|
|
829
|
+
}
|
|
830
|
+
function shouldThrowError(throwOnError, params) {
|
|
831
|
+
if (typeof throwOnError === "function") {
|
|
832
|
+
return throwOnError(...params);
|
|
833
|
+
}
|
|
834
|
+
return !!throwOnError;
|
|
835
|
+
}
|
|
836
|
+
function addConsumeAwareSignal(object, getSignal, onCancelled) {
|
|
837
|
+
let consumed = false;
|
|
838
|
+
let signal;
|
|
839
|
+
Object.defineProperty(object, "signal", {
|
|
840
|
+
enumerable: true,
|
|
841
|
+
get: () => {
|
|
842
|
+
signal ?? (signal = getSignal());
|
|
843
|
+
if (consumed) {
|
|
844
|
+
return signal;
|
|
845
|
+
}
|
|
846
|
+
consumed = true;
|
|
847
|
+
if (signal.aborted) {
|
|
848
|
+
onCancelled();
|
|
849
|
+
} else {
|
|
850
|
+
signal.addEventListener("abort", onCancelled, { once: true });
|
|
851
|
+
}
|
|
852
|
+
return signal;
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
return object;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// node_modules/@tanstack/query-core/build/modern/environmentManager.js
|
|
859
|
+
var environmentManager = /* @__PURE__ */ (() => {
|
|
860
|
+
let isServerFn = () => isServer;
|
|
861
|
+
return {
|
|
862
|
+
/**
|
|
863
|
+
* Returns whether the current runtime should be treated as a server environment.
|
|
864
|
+
*/
|
|
865
|
+
isServer() {
|
|
866
|
+
return isServerFn();
|
|
867
|
+
},
|
|
868
|
+
/**
|
|
869
|
+
* Overrides the server check globally.
|
|
870
|
+
*/
|
|
871
|
+
setIsServer(isServerValue) {
|
|
872
|
+
isServerFn = isServerValue;
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
})();
|
|
876
|
+
|
|
877
|
+
// node_modules/@tanstack/query-core/build/modern/thenable.js
|
|
878
|
+
function pendingThenable() {
|
|
879
|
+
let resolve;
|
|
880
|
+
let reject;
|
|
881
|
+
const thenable = new Promise((_resolve, _reject) => {
|
|
882
|
+
resolve = _resolve;
|
|
883
|
+
reject = _reject;
|
|
884
|
+
});
|
|
885
|
+
thenable.status = "pending";
|
|
886
|
+
thenable.catch(() => {
|
|
887
|
+
});
|
|
888
|
+
function finalize(data) {
|
|
889
|
+
Object.assign(thenable, data);
|
|
890
|
+
delete thenable.resolve;
|
|
891
|
+
delete thenable.reject;
|
|
892
|
+
}
|
|
893
|
+
thenable.resolve = (value) => {
|
|
894
|
+
finalize({
|
|
895
|
+
status: "fulfilled",
|
|
896
|
+
value
|
|
897
|
+
});
|
|
898
|
+
resolve(value);
|
|
899
|
+
};
|
|
900
|
+
thenable.reject = (reason) => {
|
|
901
|
+
finalize({
|
|
902
|
+
status: "rejected",
|
|
903
|
+
reason
|
|
904
|
+
});
|
|
905
|
+
reject(reason);
|
|
906
|
+
};
|
|
907
|
+
return thenable;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// node_modules/@tanstack/query-core/build/modern/notifyManager.js
|
|
911
|
+
var defaultScheduler = systemSetTimeoutZero;
|
|
912
|
+
function createNotifyManager() {
|
|
913
|
+
let queue = [];
|
|
914
|
+
let transactions = 0;
|
|
915
|
+
let notifyFn = (callback) => {
|
|
916
|
+
callback();
|
|
917
|
+
};
|
|
918
|
+
let batchNotifyFn = (callback) => {
|
|
919
|
+
callback();
|
|
920
|
+
};
|
|
921
|
+
let scheduleFn = defaultScheduler;
|
|
922
|
+
const schedule = (callback) => {
|
|
923
|
+
if (transactions) {
|
|
924
|
+
queue.push(callback);
|
|
925
|
+
} else {
|
|
926
|
+
scheduleFn(() => {
|
|
927
|
+
notifyFn(callback);
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
const flush = () => {
|
|
932
|
+
const originalQueue = queue;
|
|
933
|
+
queue = [];
|
|
934
|
+
if (originalQueue.length) {
|
|
935
|
+
scheduleFn(() => {
|
|
936
|
+
batchNotifyFn(() => {
|
|
937
|
+
originalQueue.forEach((callback) => {
|
|
938
|
+
notifyFn(callback);
|
|
939
|
+
});
|
|
940
|
+
});
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
return {
|
|
945
|
+
batch: (callback) => {
|
|
946
|
+
let result;
|
|
947
|
+
transactions++;
|
|
948
|
+
try {
|
|
949
|
+
result = callback();
|
|
950
|
+
} finally {
|
|
951
|
+
transactions--;
|
|
952
|
+
if (!transactions) {
|
|
953
|
+
flush();
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
return result;
|
|
957
|
+
},
|
|
958
|
+
/**
|
|
959
|
+
* All calls to the wrapped function will be batched.
|
|
960
|
+
*/
|
|
961
|
+
batchCalls: (callback) => {
|
|
962
|
+
return (...args) => {
|
|
963
|
+
schedule(() => {
|
|
964
|
+
callback(...args);
|
|
965
|
+
});
|
|
966
|
+
};
|
|
967
|
+
},
|
|
968
|
+
schedule,
|
|
969
|
+
/**
|
|
970
|
+
* Use this method to set a custom notify function.
|
|
971
|
+
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
972
|
+
*/
|
|
973
|
+
setNotifyFunction: (fn) => {
|
|
974
|
+
notifyFn = fn;
|
|
975
|
+
},
|
|
976
|
+
/**
|
|
977
|
+
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
978
|
+
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
979
|
+
*/
|
|
980
|
+
setBatchNotifyFunction: (fn) => {
|
|
981
|
+
batchNotifyFn = fn;
|
|
982
|
+
},
|
|
983
|
+
setScheduler: (fn) => {
|
|
984
|
+
scheduleFn = fn;
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
var notifyManager = createNotifyManager();
|
|
989
|
+
|
|
990
|
+
// node_modules/@tanstack/query-core/build/modern/onlineManager.js
|
|
991
|
+
var _online, _cleanup2, _setup2, _a3;
|
|
992
|
+
var OnlineManager = (_a3 = class extends Subscribable {
|
|
993
|
+
constructor() {
|
|
994
|
+
super();
|
|
995
|
+
__privateAdd(this, _online, true);
|
|
996
|
+
__privateAdd(this, _cleanup2);
|
|
997
|
+
__privateAdd(this, _setup2);
|
|
998
|
+
__privateSet(this, _setup2, (onOnline) => {
|
|
999
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
1000
|
+
const onlineListener = () => onOnline(true);
|
|
1001
|
+
const offlineListener = () => onOnline(false);
|
|
1002
|
+
window.addEventListener("online", onlineListener, false);
|
|
1003
|
+
window.addEventListener("offline", offlineListener, false);
|
|
1004
|
+
return () => {
|
|
1005
|
+
window.removeEventListener("online", onlineListener);
|
|
1006
|
+
window.removeEventListener("offline", offlineListener);
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
return;
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
onSubscribe() {
|
|
1013
|
+
if (!__privateGet(this, _cleanup2)) {
|
|
1014
|
+
this.setEventListener(__privateGet(this, _setup2));
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
onUnsubscribe() {
|
|
1018
|
+
var _a11;
|
|
1019
|
+
if (!this.hasListeners()) {
|
|
1020
|
+
(_a11 = __privateGet(this, _cleanup2)) == null ? void 0 : _a11.call(this);
|
|
1021
|
+
__privateSet(this, _cleanup2, void 0);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
setEventListener(setup) {
|
|
1025
|
+
var _a11;
|
|
1026
|
+
__privateSet(this, _setup2, setup);
|
|
1027
|
+
(_a11 = __privateGet(this, _cleanup2)) == null ? void 0 : _a11.call(this);
|
|
1028
|
+
__privateSet(this, _cleanup2, setup(this.setOnline.bind(this)));
|
|
1029
|
+
}
|
|
1030
|
+
setOnline(online) {
|
|
1031
|
+
const changed = __privateGet(this, _online) !== online;
|
|
1032
|
+
if (changed) {
|
|
1033
|
+
__privateSet(this, _online, online);
|
|
1034
|
+
this.listeners.forEach((listener) => {
|
|
1035
|
+
listener(online);
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
isOnline() {
|
|
1040
|
+
return __privateGet(this, _online);
|
|
1041
|
+
}
|
|
1042
|
+
}, _online = new WeakMap(), _cleanup2 = new WeakMap(), _setup2 = new WeakMap(), _a3);
|
|
1043
|
+
var onlineManager = new OnlineManager();
|
|
1044
|
+
|
|
1045
|
+
// node_modules/@tanstack/query-core/build/modern/retryer.js
|
|
1046
|
+
function defaultRetryDelay(failureCount) {
|
|
1047
|
+
return Math.min(1e3 * 2 ** failureCount, 3e4);
|
|
1048
|
+
}
|
|
1049
|
+
function canFetch(networkMode) {
|
|
1050
|
+
return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
|
|
1051
|
+
}
|
|
1052
|
+
var CancelledError = class extends Error {
|
|
1053
|
+
constructor(options) {
|
|
1054
|
+
super("CancelledError");
|
|
1055
|
+
this.revert = options?.revert;
|
|
1056
|
+
this.silent = options?.silent;
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
function createRetryer(config) {
|
|
1060
|
+
let isRetryCancelled = false;
|
|
1061
|
+
let failureCount = 0;
|
|
1062
|
+
let continueFn;
|
|
1063
|
+
const thenable = pendingThenable();
|
|
1064
|
+
const isResolved = () => thenable.status !== "pending";
|
|
1065
|
+
const cancel = (cancelOptions) => {
|
|
1066
|
+
if (!isResolved()) {
|
|
1067
|
+
const error = new CancelledError(cancelOptions);
|
|
1068
|
+
reject(error);
|
|
1069
|
+
config.onCancel?.(error);
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
const cancelRetry = () => {
|
|
1073
|
+
isRetryCancelled = true;
|
|
1074
|
+
};
|
|
1075
|
+
const continueRetry = () => {
|
|
1076
|
+
isRetryCancelled = false;
|
|
1077
|
+
};
|
|
1078
|
+
const canContinue = () => focusManager.isFocused() && (config.networkMode === "always" || onlineManager.isOnline()) && config.canRun();
|
|
1079
|
+
const canStart = () => canFetch(config.networkMode) && config.canRun();
|
|
1080
|
+
const resolve = (value) => {
|
|
1081
|
+
if (!isResolved()) {
|
|
1082
|
+
continueFn?.();
|
|
1083
|
+
thenable.resolve(value);
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
const reject = (value) => {
|
|
1087
|
+
if (!isResolved()) {
|
|
1088
|
+
continueFn?.();
|
|
1089
|
+
thenable.reject(value);
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
const pause = () => {
|
|
1093
|
+
return new Promise((continueResolve) => {
|
|
1094
|
+
continueFn = (value) => {
|
|
1095
|
+
if (isResolved() || canContinue()) {
|
|
1096
|
+
continueResolve(value);
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
config.onPause?.();
|
|
1100
|
+
}).then(() => {
|
|
1101
|
+
continueFn = void 0;
|
|
1102
|
+
if (!isResolved()) {
|
|
1103
|
+
config.onContinue?.();
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
};
|
|
1107
|
+
const run = () => {
|
|
1108
|
+
if (isResolved()) {
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
let promiseOrValue;
|
|
1112
|
+
const initialPromise = failureCount === 0 ? config.initialPromise : void 0;
|
|
1113
|
+
try {
|
|
1114
|
+
promiseOrValue = initialPromise ?? config.fn();
|
|
1115
|
+
} catch (error) {
|
|
1116
|
+
promiseOrValue = Promise.reject(error);
|
|
1117
|
+
}
|
|
1118
|
+
Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
|
|
1119
|
+
if (isResolved()) {
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
const retry = config.retry ?? (environmentManager.isServer() ? 0 : 3);
|
|
1123
|
+
const retryDelay = config.retryDelay ?? defaultRetryDelay;
|
|
1124
|
+
const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
|
|
1125
|
+
const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
|
|
1126
|
+
if (isRetryCancelled || !shouldRetry) {
|
|
1127
|
+
reject(error);
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
failureCount++;
|
|
1131
|
+
config.onFail?.(failureCount, error);
|
|
1132
|
+
sleep(delay).then(() => {
|
|
1133
|
+
return canContinue() ? void 0 : pause();
|
|
1134
|
+
}).then(() => {
|
|
1135
|
+
if (isRetryCancelled) {
|
|
1136
|
+
reject(error);
|
|
1137
|
+
} else {
|
|
1138
|
+
run();
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
});
|
|
1142
|
+
};
|
|
1143
|
+
return {
|
|
1144
|
+
promise: thenable,
|
|
1145
|
+
status: () => thenable.status,
|
|
1146
|
+
cancel,
|
|
1147
|
+
continue: () => {
|
|
1148
|
+
continueFn?.();
|
|
1149
|
+
return thenable;
|
|
1150
|
+
},
|
|
1151
|
+
cancelRetry,
|
|
1152
|
+
continueRetry,
|
|
1153
|
+
canStart,
|
|
1154
|
+
start: () => {
|
|
1155
|
+
if (canStart()) {
|
|
1156
|
+
run();
|
|
1157
|
+
} else {
|
|
1158
|
+
pause().then(run);
|
|
1159
|
+
}
|
|
1160
|
+
return thenable;
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
// node_modules/@tanstack/query-core/build/modern/removable.js
|
|
1166
|
+
var _gcTimeout, _a4;
|
|
1167
|
+
var Removable = (_a4 = class {
|
|
1168
|
+
constructor() {
|
|
1169
|
+
__privateAdd(this, _gcTimeout);
|
|
1170
|
+
}
|
|
1171
|
+
destroy() {
|
|
1172
|
+
this.clearGcTimeout();
|
|
1173
|
+
}
|
|
1174
|
+
scheduleGc() {
|
|
1175
|
+
this.clearGcTimeout();
|
|
1176
|
+
if (isValidTimeout(this.gcTime)) {
|
|
1177
|
+
__privateSet(this, _gcTimeout, timeoutManager.setTimeout(() => {
|
|
1178
|
+
this.optionalRemove();
|
|
1179
|
+
}, this.gcTime));
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
updateGcTime(newGcTime) {
|
|
1183
|
+
this.gcTime = Math.max(
|
|
1184
|
+
this.gcTime || 0,
|
|
1185
|
+
newGcTime ?? (environmentManager.isServer() ? Infinity : 5 * 60 * 1e3)
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
clearGcTimeout() {
|
|
1189
|
+
if (__privateGet(this, _gcTimeout) !== void 0) {
|
|
1190
|
+
timeoutManager.clearTimeout(__privateGet(this, _gcTimeout));
|
|
1191
|
+
__privateSet(this, _gcTimeout, void 0);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
}, _gcTimeout = new WeakMap(), _a4);
|
|
1195
|
+
|
|
1196
|
+
// node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
|
|
1197
|
+
function infiniteQueryBehavior(pages) {
|
|
1198
|
+
return {
|
|
1199
|
+
onFetch: (context, query) => {
|
|
1200
|
+
const options = context.options;
|
|
1201
|
+
const direction = context.fetchOptions?.meta?.fetchMore?.direction;
|
|
1202
|
+
const oldPages = context.state.data?.pages || [];
|
|
1203
|
+
const oldPageParams = context.state.data?.pageParams || [];
|
|
1204
|
+
let result = { pages: [], pageParams: [] };
|
|
1205
|
+
let currentPage = 0;
|
|
1206
|
+
const fetchFn = async () => {
|
|
1207
|
+
let cancelled = false;
|
|
1208
|
+
const addSignalProperty = (object) => {
|
|
1209
|
+
addConsumeAwareSignal(
|
|
1210
|
+
object,
|
|
1211
|
+
() => context.signal,
|
|
1212
|
+
() => cancelled = true
|
|
1213
|
+
);
|
|
1214
|
+
};
|
|
1215
|
+
const queryFn = ensureQueryFn(context.options, context.fetchOptions);
|
|
1216
|
+
const fetchPage = async (data, param, previous) => {
|
|
1217
|
+
if (cancelled) {
|
|
1218
|
+
return Promise.reject(context.signal.reason);
|
|
1219
|
+
}
|
|
1220
|
+
if (param == null && data.pages.length) {
|
|
1221
|
+
return Promise.resolve(data);
|
|
1222
|
+
}
|
|
1223
|
+
const createQueryFnContext = () => {
|
|
1224
|
+
const queryFnContext2 = {
|
|
1225
|
+
client: context.client,
|
|
1226
|
+
queryKey: context.queryKey,
|
|
1227
|
+
pageParam: param,
|
|
1228
|
+
direction: previous ? "backward" : "forward",
|
|
1229
|
+
meta: context.options.meta
|
|
1230
|
+
};
|
|
1231
|
+
addSignalProperty(queryFnContext2);
|
|
1232
|
+
return queryFnContext2;
|
|
1233
|
+
};
|
|
1234
|
+
const queryFnContext = createQueryFnContext();
|
|
1235
|
+
const page = await queryFn(queryFnContext);
|
|
1236
|
+
const { maxPages } = context.options;
|
|
1237
|
+
const addTo = previous ? addToStart : addToEnd;
|
|
1238
|
+
return {
|
|
1239
|
+
pages: addTo(data.pages, page, maxPages),
|
|
1240
|
+
pageParams: addTo(data.pageParams, param, maxPages)
|
|
1241
|
+
};
|
|
1242
|
+
};
|
|
1243
|
+
if (direction && oldPages.length) {
|
|
1244
|
+
const previous = direction === "backward";
|
|
1245
|
+
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
|
|
1246
|
+
const oldData = {
|
|
1247
|
+
pages: oldPages,
|
|
1248
|
+
pageParams: oldPageParams
|
|
1249
|
+
};
|
|
1250
|
+
const param = pageParamFn(options, oldData);
|
|
1251
|
+
result = await fetchPage(oldData, param, previous);
|
|
1252
|
+
} else {
|
|
1253
|
+
const remainingPages = pages ?? oldPages.length;
|
|
1254
|
+
do {
|
|
1255
|
+
const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result);
|
|
1256
|
+
if (currentPage > 0 && param == null) {
|
|
1257
|
+
break;
|
|
1258
|
+
}
|
|
1259
|
+
result = await fetchPage(result, param);
|
|
1260
|
+
currentPage++;
|
|
1261
|
+
} while (currentPage < remainingPages);
|
|
1262
|
+
}
|
|
1263
|
+
return result;
|
|
1264
|
+
};
|
|
1265
|
+
if (context.options.persister) {
|
|
1266
|
+
context.fetchFn = () => {
|
|
1267
|
+
return context.options.persister?.(
|
|
1268
|
+
fetchFn,
|
|
1269
|
+
{
|
|
1270
|
+
client: context.client,
|
|
1271
|
+
queryKey: context.queryKey,
|
|
1272
|
+
meta: context.options.meta,
|
|
1273
|
+
signal: context.signal
|
|
1274
|
+
},
|
|
1275
|
+
query
|
|
1276
|
+
);
|
|
1277
|
+
};
|
|
1278
|
+
} else {
|
|
1279
|
+
context.fetchFn = fetchFn;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
function getNextPageParam(options, { pages, pageParams }) {
|
|
1285
|
+
const lastIndex = pages.length - 1;
|
|
1286
|
+
return pages.length > 0 ? options.getNextPageParam(
|
|
1287
|
+
pages[lastIndex],
|
|
1288
|
+
pages,
|
|
1289
|
+
pageParams[lastIndex],
|
|
1290
|
+
pageParams
|
|
1291
|
+
) : void 0;
|
|
1292
|
+
}
|
|
1293
|
+
function getPreviousPageParam(options, { pages, pageParams }) {
|
|
1294
|
+
return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
// node_modules/@tanstack/query-core/build/modern/query.js
|
|
1298
|
+
var _queryType, _initialState, _revertState, _cache, _client, _retryer, _defaultOptions, _abortSignalConsumed, _Query_instances, isInitialPausedFetch_fn, dispatch_fn, _a5;
|
|
1299
|
+
var Query = (_a5 = class extends Removable {
|
|
1300
|
+
constructor(config) {
|
|
1301
|
+
super();
|
|
1302
|
+
__privateAdd(this, _Query_instances);
|
|
1303
|
+
__privateAdd(this, _queryType);
|
|
1304
|
+
__privateAdd(this, _initialState);
|
|
1305
|
+
__privateAdd(this, _revertState);
|
|
1306
|
+
__privateAdd(this, _cache);
|
|
1307
|
+
__privateAdd(this, _client);
|
|
1308
|
+
__privateAdd(this, _retryer);
|
|
1309
|
+
__privateAdd(this, _defaultOptions);
|
|
1310
|
+
__privateAdd(this, _abortSignalConsumed);
|
|
1311
|
+
__privateSet(this, _abortSignalConsumed, false);
|
|
1312
|
+
__privateSet(this, _defaultOptions, config.defaultOptions);
|
|
1313
|
+
this.setOptions(config.options);
|
|
1314
|
+
this.observers = [];
|
|
1315
|
+
__privateSet(this, _client, config.client);
|
|
1316
|
+
__privateSet(this, _cache, __privateGet(this, _client).getQueryCache());
|
|
1317
|
+
this.queryKey = config.queryKey;
|
|
1318
|
+
this.queryHash = config.queryHash;
|
|
1319
|
+
__privateSet(this, _initialState, getDefaultState(this.options));
|
|
1320
|
+
this.state = config.state ?? __privateGet(this, _initialState);
|
|
1321
|
+
this.scheduleGc();
|
|
1322
|
+
}
|
|
1323
|
+
get meta() {
|
|
1324
|
+
return this.options.meta;
|
|
1325
|
+
}
|
|
1326
|
+
get queryType() {
|
|
1327
|
+
return __privateGet(this, _queryType);
|
|
1328
|
+
}
|
|
1329
|
+
get promise() {
|
|
1330
|
+
return __privateGet(this, _retryer)?.promise;
|
|
1331
|
+
}
|
|
1332
|
+
setOptions(options) {
|
|
1333
|
+
this.options = { ...__privateGet(this, _defaultOptions), ...options };
|
|
1334
|
+
if (options?._type) {
|
|
1335
|
+
__privateSet(this, _queryType, options._type);
|
|
1336
|
+
}
|
|
1337
|
+
this.updateGcTime(this.options.gcTime);
|
|
1338
|
+
if (this.state && this.state.data === void 0) {
|
|
1339
|
+
const defaultState = getDefaultState(this.options);
|
|
1340
|
+
if (defaultState.data !== void 0) {
|
|
1341
|
+
this.setState(
|
|
1342
|
+
successState(defaultState.data, defaultState.dataUpdatedAt)
|
|
1343
|
+
);
|
|
1344
|
+
__privateSet(this, _initialState, defaultState);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
optionalRemove() {
|
|
1349
|
+
if (!this.observers.length && this.state.fetchStatus === "idle") {
|
|
1350
|
+
__privateGet(this, _cache).remove(this);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
setData(newData, options) {
|
|
1354
|
+
const data = replaceData(this.state.data, newData, this.options);
|
|
1355
|
+
__privateMethod(this, _Query_instances, dispatch_fn).call(this, {
|
|
1356
|
+
data,
|
|
1357
|
+
type: "success",
|
|
1358
|
+
dataUpdatedAt: options?.updatedAt,
|
|
1359
|
+
manual: options?.manual
|
|
1360
|
+
});
|
|
1361
|
+
return data;
|
|
1362
|
+
}
|
|
1363
|
+
setState(state) {
|
|
1364
|
+
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "setState", state });
|
|
1365
|
+
}
|
|
1366
|
+
cancel(options) {
|
|
1367
|
+
const promise = __privateGet(this, _retryer)?.promise;
|
|
1368
|
+
__privateGet(this, _retryer)?.cancel(options);
|
|
1369
|
+
return promise ? promise.then(noop).catch(noop) : Promise.resolve();
|
|
1370
|
+
}
|
|
1371
|
+
destroy() {
|
|
1372
|
+
super.destroy();
|
|
1373
|
+
this.cancel({ silent: true });
|
|
1374
|
+
}
|
|
1375
|
+
get resetState() {
|
|
1376
|
+
return __privateGet(this, _initialState);
|
|
1377
|
+
}
|
|
1378
|
+
reset() {
|
|
1379
|
+
this.destroy();
|
|
1380
|
+
this.setState(this.resetState);
|
|
1381
|
+
}
|
|
1382
|
+
isActive() {
|
|
1383
|
+
return this.observers.some(
|
|
1384
|
+
(observer) => resolveQueryBoolean(observer.options.enabled, this) !== false
|
|
1385
|
+
);
|
|
1386
|
+
}
|
|
1387
|
+
isDisabled() {
|
|
1388
|
+
if (this.getObserversCount() > 0) {
|
|
1389
|
+
return !this.isActive();
|
|
1390
|
+
}
|
|
1391
|
+
return this.options.queryFn === skipToken || !this.isFetched();
|
|
1392
|
+
}
|
|
1393
|
+
isFetched() {
|
|
1394
|
+
return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
|
|
1395
|
+
}
|
|
1396
|
+
isStatic() {
|
|
1397
|
+
if (this.getObserversCount() > 0) {
|
|
1398
|
+
return this.observers.some(
|
|
1399
|
+
(observer) => resolveStaleTime(observer.options.staleTime, this) === "static"
|
|
1400
|
+
);
|
|
1401
|
+
}
|
|
1402
|
+
return false;
|
|
1403
|
+
}
|
|
1404
|
+
isStale() {
|
|
1405
|
+
if (this.getObserversCount() > 0) {
|
|
1406
|
+
return this.observers.some(
|
|
1407
|
+
(observer) => observer.getCurrentResult().isStale
|
|
1408
|
+
);
|
|
1409
|
+
}
|
|
1410
|
+
return this.state.data === void 0 || this.state.isInvalidated;
|
|
1411
|
+
}
|
|
1412
|
+
isStaleByTime(staleTime = 0) {
|
|
1413
|
+
if (this.state.data === void 0) {
|
|
1414
|
+
return true;
|
|
1415
|
+
}
|
|
1416
|
+
if (staleTime === "static") {
|
|
1417
|
+
return false;
|
|
1418
|
+
}
|
|
1419
|
+
if (this.state.isInvalidated) {
|
|
1420
|
+
return true;
|
|
1421
|
+
}
|
|
1422
|
+
return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
|
|
1423
|
+
}
|
|
1424
|
+
onFocus() {
|
|
1425
|
+
const observer = this.observers.find((x3) => x3.shouldFetchOnWindowFocus());
|
|
1426
|
+
observer?.refetch({ cancelRefetch: false });
|
|
1427
|
+
__privateGet(this, _retryer)?.continue();
|
|
1428
|
+
}
|
|
1429
|
+
onOnline() {
|
|
1430
|
+
const observer = this.observers.find((x3) => x3.shouldFetchOnReconnect());
|
|
1431
|
+
observer?.refetch({ cancelRefetch: false });
|
|
1432
|
+
__privateGet(this, _retryer)?.continue();
|
|
1433
|
+
}
|
|
1434
|
+
addObserver(observer) {
|
|
1435
|
+
if (!this.observers.includes(observer)) {
|
|
1436
|
+
this.observers.push(observer);
|
|
1437
|
+
this.clearGcTimeout();
|
|
1438
|
+
__privateGet(this, _cache).notify({ type: "observerAdded", query: this, observer });
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
removeObserver(observer) {
|
|
1442
|
+
if (this.observers.includes(observer)) {
|
|
1443
|
+
this.observers = this.observers.filter((x3) => x3 !== observer);
|
|
1444
|
+
if (!this.observers.length) {
|
|
1445
|
+
if (__privateGet(this, _retryer)) {
|
|
1446
|
+
if (__privateGet(this, _abortSignalConsumed) || __privateMethod(this, _Query_instances, isInitialPausedFetch_fn).call(this)) {
|
|
1447
|
+
__privateGet(this, _retryer).cancel({ revert: true });
|
|
1448
|
+
} else {
|
|
1449
|
+
__privateGet(this, _retryer).cancelRetry();
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
this.scheduleGc();
|
|
1453
|
+
}
|
|
1454
|
+
__privateGet(this, _cache).notify({ type: "observerRemoved", query: this, observer });
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
getObserversCount() {
|
|
1458
|
+
return this.observers.length;
|
|
1459
|
+
}
|
|
1460
|
+
invalidate() {
|
|
1461
|
+
if (!this.state.isInvalidated) {
|
|
1462
|
+
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "invalidate" });
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
async fetch(options, fetchOptions) {
|
|
1466
|
+
if (this.state.fetchStatus !== "idle" && // If the promise in the retryer is already rejected, we have to definitely
|
|
1467
|
+
// re-start the fetch; there is a chance that the query is still in a
|
|
1468
|
+
// pending state when that happens
|
|
1469
|
+
__privateGet(this, _retryer)?.status() !== "rejected") {
|
|
1470
|
+
if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {
|
|
1471
|
+
this.cancel({ silent: true });
|
|
1472
|
+
} else if (__privateGet(this, _retryer)) {
|
|
1473
|
+
__privateGet(this, _retryer).continueRetry();
|
|
1474
|
+
return __privateGet(this, _retryer).promise;
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
if (options) {
|
|
1478
|
+
this.setOptions(options);
|
|
1479
|
+
}
|
|
1480
|
+
if (!this.options.queryFn) {
|
|
1481
|
+
const observer = this.observers.find((x3) => x3.options.queryFn);
|
|
1482
|
+
if (observer) {
|
|
1483
|
+
this.setOptions(observer.options);
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
if (true) {
|
|
1487
|
+
if (!Array.isArray(this.options.queryKey)) {
|
|
1488
|
+
console.error(
|
|
1489
|
+
`As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`
|
|
1490
|
+
);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
const abortController = new AbortController();
|
|
1494
|
+
const addSignalProperty = (object) => {
|
|
1495
|
+
Object.defineProperty(object, "signal", {
|
|
1496
|
+
enumerable: true,
|
|
1497
|
+
get: () => {
|
|
1498
|
+
__privateSet(this, _abortSignalConsumed, true);
|
|
1499
|
+
return abortController.signal;
|
|
1500
|
+
}
|
|
1501
|
+
});
|
|
1502
|
+
};
|
|
1503
|
+
const fetchFn = () => {
|
|
1504
|
+
const queryFn = ensureQueryFn(this.options, fetchOptions);
|
|
1505
|
+
const createQueryFnContext = () => {
|
|
1506
|
+
const queryFnContext2 = {
|
|
1507
|
+
client: __privateGet(this, _client),
|
|
1508
|
+
queryKey: this.queryKey,
|
|
1509
|
+
meta: this.meta
|
|
1510
|
+
};
|
|
1511
|
+
addSignalProperty(queryFnContext2);
|
|
1512
|
+
return queryFnContext2;
|
|
1513
|
+
};
|
|
1514
|
+
const queryFnContext = createQueryFnContext();
|
|
1515
|
+
__privateSet(this, _abortSignalConsumed, false);
|
|
1516
|
+
if (this.options.persister) {
|
|
1517
|
+
return this.options.persister(
|
|
1518
|
+
queryFn,
|
|
1519
|
+
queryFnContext,
|
|
1520
|
+
this
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1523
|
+
return queryFn(queryFnContext);
|
|
1524
|
+
};
|
|
1525
|
+
const createFetchContext = () => {
|
|
1526
|
+
const context2 = {
|
|
1527
|
+
fetchOptions,
|
|
1528
|
+
options: this.options,
|
|
1529
|
+
queryKey: this.queryKey,
|
|
1530
|
+
client: __privateGet(this, _client),
|
|
1531
|
+
state: this.state,
|
|
1532
|
+
fetchFn
|
|
1533
|
+
};
|
|
1534
|
+
addSignalProperty(context2);
|
|
1535
|
+
return context2;
|
|
1536
|
+
};
|
|
1537
|
+
const context = createFetchContext();
|
|
1538
|
+
const behavior = __privateGet(this, _queryType) === "infinite" ? infiniteQueryBehavior(
|
|
1539
|
+
this.options.pages
|
|
1540
|
+
) : this.options.behavior;
|
|
1541
|
+
behavior?.onFetch(context, this);
|
|
1542
|
+
__privateSet(this, _revertState, this.state);
|
|
1543
|
+
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) {
|
|
1544
|
+
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "fetch", meta: context.fetchOptions?.meta });
|
|
1545
|
+
}
|
|
1546
|
+
__privateSet(this, _retryer, createRetryer({
|
|
1547
|
+
initialPromise: fetchOptions?.initialPromise,
|
|
1548
|
+
fn: context.fetchFn,
|
|
1549
|
+
onCancel: (error) => {
|
|
1550
|
+
if (error instanceof CancelledError && error.revert) {
|
|
1551
|
+
this.setState({
|
|
1552
|
+
...__privateGet(this, _revertState),
|
|
1553
|
+
fetchStatus: "idle"
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
abortController.abort();
|
|
1557
|
+
},
|
|
1558
|
+
onFail: (failureCount, error) => {
|
|
1559
|
+
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "failed", failureCount, error });
|
|
1560
|
+
},
|
|
1561
|
+
onPause: () => {
|
|
1562
|
+
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "pause" });
|
|
1563
|
+
},
|
|
1564
|
+
onContinue: () => {
|
|
1565
|
+
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "continue" });
|
|
1566
|
+
},
|
|
1567
|
+
retry: context.options.retry,
|
|
1568
|
+
retryDelay: context.options.retryDelay,
|
|
1569
|
+
networkMode: context.options.networkMode,
|
|
1570
|
+
canRun: () => true
|
|
1571
|
+
}));
|
|
1572
|
+
try {
|
|
1573
|
+
const data = await __privateGet(this, _retryer).start();
|
|
1574
|
+
if (data === void 0) {
|
|
1575
|
+
if (true) {
|
|
1576
|
+
console.error(
|
|
1577
|
+
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
|
|
1578
|
+
);
|
|
1579
|
+
}
|
|
1580
|
+
throw new Error(`${this.queryHash} data is undefined`);
|
|
1581
|
+
}
|
|
1582
|
+
this.setData(data);
|
|
1583
|
+
__privateGet(this, _cache).config.onSuccess?.(data, this);
|
|
1584
|
+
__privateGet(this, _cache).config.onSettled?.(
|
|
1585
|
+
data,
|
|
1586
|
+
this.state.error,
|
|
1587
|
+
this
|
|
1588
|
+
);
|
|
1589
|
+
return data;
|
|
1590
|
+
} catch (error) {
|
|
1591
|
+
if (error instanceof CancelledError) {
|
|
1592
|
+
if (error.silent) {
|
|
1593
|
+
return __privateGet(this, _retryer).promise;
|
|
1594
|
+
} else if (error.revert) {
|
|
1595
|
+
if (this.state.data === void 0) {
|
|
1596
|
+
throw error;
|
|
1597
|
+
}
|
|
1598
|
+
return this.state.data;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
__privateMethod(this, _Query_instances, dispatch_fn).call(this, {
|
|
1602
|
+
type: "error",
|
|
1603
|
+
error
|
|
1604
|
+
});
|
|
1605
|
+
__privateGet(this, _cache).config.onError?.(
|
|
1606
|
+
error,
|
|
1607
|
+
this
|
|
1608
|
+
);
|
|
1609
|
+
__privateGet(this, _cache).config.onSettled?.(
|
|
1610
|
+
this.state.data,
|
|
1611
|
+
error,
|
|
1612
|
+
this
|
|
1613
|
+
);
|
|
1614
|
+
throw error;
|
|
1615
|
+
} finally {
|
|
1616
|
+
this.scheduleGc();
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}, _queryType = new WeakMap(), _initialState = new WeakMap(), _revertState = new WeakMap(), _cache = new WeakMap(), _client = new WeakMap(), _retryer = new WeakMap(), _defaultOptions = new WeakMap(), _abortSignalConsumed = new WeakMap(), _Query_instances = new WeakSet(), isInitialPausedFetch_fn = function() {
|
|
1620
|
+
return this.state.fetchStatus === "paused" && this.state.status === "pending";
|
|
1621
|
+
}, dispatch_fn = function(action) {
|
|
1622
|
+
const reducer = (state) => {
|
|
1623
|
+
switch (action.type) {
|
|
1624
|
+
case "failed":
|
|
1625
|
+
return {
|
|
1626
|
+
...state,
|
|
1627
|
+
fetchFailureCount: action.failureCount,
|
|
1628
|
+
fetchFailureReason: action.error
|
|
1629
|
+
};
|
|
1630
|
+
case "pause":
|
|
1631
|
+
return {
|
|
1632
|
+
...state,
|
|
1633
|
+
fetchStatus: "paused"
|
|
1634
|
+
};
|
|
1635
|
+
case "continue":
|
|
1636
|
+
return {
|
|
1637
|
+
...state,
|
|
1638
|
+
fetchStatus: "fetching"
|
|
1639
|
+
};
|
|
1640
|
+
case "fetch":
|
|
1641
|
+
return {
|
|
1642
|
+
...state,
|
|
1643
|
+
...fetchState(state.data, this.options),
|
|
1644
|
+
fetchMeta: action.meta ?? null
|
|
1645
|
+
};
|
|
1646
|
+
case "success":
|
|
1647
|
+
const newState = {
|
|
1648
|
+
...state,
|
|
1649
|
+
...successState(action.data, action.dataUpdatedAt),
|
|
1650
|
+
dataUpdateCount: state.dataUpdateCount + 1,
|
|
1651
|
+
...!action.manual && {
|
|
1652
|
+
fetchStatus: "idle",
|
|
1653
|
+
fetchFailureCount: 0,
|
|
1654
|
+
fetchFailureReason: null
|
|
1655
|
+
}
|
|
1656
|
+
};
|
|
1657
|
+
__privateSet(this, _revertState, action.manual ? newState : void 0);
|
|
1658
|
+
return newState;
|
|
1659
|
+
case "error":
|
|
1660
|
+
const error = action.error;
|
|
1661
|
+
return {
|
|
1662
|
+
...state,
|
|
1663
|
+
error,
|
|
1664
|
+
errorUpdateCount: state.errorUpdateCount + 1,
|
|
1665
|
+
errorUpdatedAt: Date.now(),
|
|
1666
|
+
fetchFailureCount: state.fetchFailureCount + 1,
|
|
1667
|
+
fetchFailureReason: error,
|
|
1668
|
+
fetchStatus: "idle",
|
|
1669
|
+
status: "error",
|
|
1670
|
+
// flag existing data as invalidated if we get a background error
|
|
1671
|
+
// note that "no data" always means stale so we can set unconditionally here
|
|
1672
|
+
isInvalidated: true
|
|
1673
|
+
};
|
|
1674
|
+
case "invalidate":
|
|
1675
|
+
return {
|
|
1676
|
+
...state,
|
|
1677
|
+
isInvalidated: true
|
|
1678
|
+
};
|
|
1679
|
+
case "setState":
|
|
1680
|
+
return {
|
|
1681
|
+
...state,
|
|
1682
|
+
...action.state
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
this.state = reducer(this.state);
|
|
1687
|
+
notifyManager.batch(() => {
|
|
1688
|
+
this.observers.forEach((observer) => {
|
|
1689
|
+
observer.onQueryUpdate();
|
|
1690
|
+
});
|
|
1691
|
+
__privateGet(this, _cache).notify({ query: this, type: "updated", action });
|
|
1692
|
+
});
|
|
1693
|
+
}, _a5);
|
|
1694
|
+
function fetchState(data, options) {
|
|
1695
|
+
return {
|
|
1696
|
+
fetchFailureCount: 0,
|
|
1697
|
+
fetchFailureReason: null,
|
|
1698
|
+
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
|
|
1699
|
+
...data === void 0 && {
|
|
1700
|
+
error: null,
|
|
1701
|
+
status: "pending"
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
function successState(data, dataUpdatedAt) {
|
|
1706
|
+
return {
|
|
1707
|
+
data,
|
|
1708
|
+
dataUpdatedAt: dataUpdatedAt ?? Date.now(),
|
|
1709
|
+
error: null,
|
|
1710
|
+
isInvalidated: false,
|
|
1711
|
+
status: "success"
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
1714
|
+
function getDefaultState(options) {
|
|
1715
|
+
const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
|
|
1716
|
+
const hasData = data !== void 0;
|
|
1717
|
+
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
|
|
1718
|
+
return {
|
|
1719
|
+
data,
|
|
1720
|
+
dataUpdateCount: 0,
|
|
1721
|
+
dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
|
|
1722
|
+
error: null,
|
|
1723
|
+
errorUpdateCount: 0,
|
|
1724
|
+
errorUpdatedAt: 0,
|
|
1725
|
+
fetchFailureCount: 0,
|
|
1726
|
+
fetchFailureReason: null,
|
|
1727
|
+
fetchMeta: null,
|
|
1728
|
+
isInvalidated: false,
|
|
1729
|
+
status: hasData ? "success" : "pending",
|
|
1730
|
+
fetchStatus: "idle"
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
// node_modules/@tanstack/query-core/build/modern/queryObserver.js
|
|
1735
|
+
var _client2, _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, _a6;
|
|
1736
|
+
var QueryObserver = (_a6 = class extends Subscribable {
|
|
1737
|
+
constructor(client, options) {
|
|
1738
|
+
super();
|
|
1739
|
+
__privateAdd(this, _QueryObserver_instances);
|
|
1740
|
+
__privateAdd(this, _client2);
|
|
1741
|
+
__privateAdd(this, _currentQuery);
|
|
1742
|
+
__privateAdd(this, _currentQueryInitialState);
|
|
1743
|
+
__privateAdd(this, _currentResult);
|
|
1744
|
+
__privateAdd(this, _currentResultState);
|
|
1745
|
+
__privateAdd(this, _currentResultOptions);
|
|
1746
|
+
__privateAdd(this, _currentThenable);
|
|
1747
|
+
__privateAdd(this, _selectError);
|
|
1748
|
+
__privateAdd(this, _selectFn);
|
|
1749
|
+
__privateAdd(this, _selectResult);
|
|
1750
|
+
// This property keeps track of the last query with defined data.
|
|
1751
|
+
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
1752
|
+
__privateAdd(this, _lastQueryWithDefinedData);
|
|
1753
|
+
__privateAdd(this, _staleTimeoutId);
|
|
1754
|
+
__privateAdd(this, _refetchIntervalId);
|
|
1755
|
+
__privateAdd(this, _currentRefetchInterval);
|
|
1756
|
+
__privateAdd(this, _trackedProps, /* @__PURE__ */ new Set());
|
|
1757
|
+
this.options = options;
|
|
1758
|
+
__privateSet(this, _client2, client);
|
|
1759
|
+
__privateSet(this, _selectError, null);
|
|
1760
|
+
__privateSet(this, _currentThenable, pendingThenable());
|
|
1761
|
+
this.bindMethods();
|
|
1762
|
+
this.setOptions(options);
|
|
1763
|
+
}
|
|
1764
|
+
bindMethods() {
|
|
1765
|
+
this.refetch = this.refetch.bind(this);
|
|
1766
|
+
}
|
|
1767
|
+
onSubscribe() {
|
|
1768
|
+
if (this.listeners.size === 1) {
|
|
1769
|
+
__privateGet(this, _currentQuery).addObserver(this);
|
|
1770
|
+
if (shouldFetchOnMount(__privateGet(this, _currentQuery), this.options)) {
|
|
1771
|
+
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
1772
|
+
} else {
|
|
1773
|
+
this.updateResult();
|
|
1774
|
+
}
|
|
1775
|
+
__privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
onUnsubscribe() {
|
|
1779
|
+
if (!this.hasListeners()) {
|
|
1780
|
+
this.destroy();
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
shouldFetchOnReconnect() {
|
|
1784
|
+
return shouldFetchOn(
|
|
1785
|
+
__privateGet(this, _currentQuery),
|
|
1786
|
+
this.options,
|
|
1787
|
+
this.options.refetchOnReconnect
|
|
1788
|
+
);
|
|
1789
|
+
}
|
|
1790
|
+
shouldFetchOnWindowFocus() {
|
|
1791
|
+
return shouldFetchOn(
|
|
1792
|
+
__privateGet(this, _currentQuery),
|
|
1793
|
+
this.options,
|
|
1794
|
+
this.options.refetchOnWindowFocus
|
|
1795
|
+
);
|
|
1796
|
+
}
|
|
1797
|
+
destroy() {
|
|
1798
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
1799
|
+
__privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
|
|
1800
|
+
__privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
|
|
1801
|
+
__privateGet(this, _currentQuery).removeObserver(this);
|
|
1802
|
+
}
|
|
1803
|
+
setOptions(options) {
|
|
1804
|
+
const prevOptions = this.options;
|
|
1805
|
+
const prevQuery = __privateGet(this, _currentQuery);
|
|
1806
|
+
this.options = __privateGet(this, _client2).defaultQueryOptions(options);
|
|
1807
|
+
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryBoolean(this.options.enabled, __privateGet(this, _currentQuery)) !== "boolean") {
|
|
1808
|
+
throw new Error(
|
|
1809
|
+
"Expected enabled to be a boolean or a callback that returns a boolean"
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1812
|
+
__privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
|
|
1813
|
+
__privateGet(this, _currentQuery).setOptions(this.options);
|
|
1814
|
+
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
|
|
1815
|
+
__privateGet(this, _client2).getQueryCache().notify({
|
|
1816
|
+
type: "observerOptionsUpdated",
|
|
1817
|
+
query: __privateGet(this, _currentQuery),
|
|
1818
|
+
observer: this
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
const mounted = this.hasListeners();
|
|
1822
|
+
if (mounted && shouldFetchOptionally(
|
|
1823
|
+
__privateGet(this, _currentQuery),
|
|
1824
|
+
prevQuery,
|
|
1825
|
+
this.options,
|
|
1826
|
+
prevOptions
|
|
1827
|
+
)) {
|
|
1828
|
+
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
1829
|
+
}
|
|
1830
|
+
this.updateResult();
|
|
1831
|
+
if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveQueryBoolean(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveQueryBoolean(prevOptions.enabled, __privateGet(this, _currentQuery)) || resolveStaleTime(this.options.staleTime, __privateGet(this, _currentQuery)) !== resolveStaleTime(prevOptions.staleTime, __privateGet(this, _currentQuery)))) {
|
|
1832
|
+
__privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
|
|
1833
|
+
}
|
|
1834
|
+
const nextRefetchInterval = __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this);
|
|
1835
|
+
if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveQueryBoolean(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveQueryBoolean(prevOptions.enabled, __privateGet(this, _currentQuery)) || nextRefetchInterval !== __privateGet(this, _currentRefetchInterval))) {
|
|
1836
|
+
__privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, nextRefetchInterval);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
getOptimisticResult(options) {
|
|
1840
|
+
const query = __privateGet(this, _client2).getQueryCache().build(__privateGet(this, _client2), options);
|
|
1841
|
+
const result = this.createResult(query, options);
|
|
1842
|
+
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
1843
|
+
__privateSet(this, _currentResult, result);
|
|
1844
|
+
__privateSet(this, _currentResultOptions, this.options);
|
|
1845
|
+
__privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
|
|
1846
|
+
}
|
|
1847
|
+
return result;
|
|
1848
|
+
}
|
|
1849
|
+
getCurrentResult() {
|
|
1850
|
+
return __privateGet(this, _currentResult);
|
|
1851
|
+
}
|
|
1852
|
+
trackResult(result, onPropTracked) {
|
|
1853
|
+
return new Proxy(result, {
|
|
1854
|
+
get: (target, key) => {
|
|
1855
|
+
this.trackProp(key);
|
|
1856
|
+
onPropTracked?.(key);
|
|
1857
|
+
if (key === "promise") {
|
|
1858
|
+
this.trackProp("data");
|
|
1859
|
+
if (!this.options.experimental_prefetchInRender && __privateGet(this, _currentThenable).status === "pending") {
|
|
1860
|
+
__privateGet(this, _currentThenable).reject(
|
|
1861
|
+
new Error(
|
|
1862
|
+
"experimental_prefetchInRender feature flag is not enabled"
|
|
1863
|
+
)
|
|
1864
|
+
);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
return Reflect.get(target, key);
|
|
1868
|
+
}
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1871
|
+
trackProp(key) {
|
|
1872
|
+
__privateGet(this, _trackedProps).add(key);
|
|
1873
|
+
}
|
|
1874
|
+
getCurrentQuery() {
|
|
1875
|
+
return __privateGet(this, _currentQuery);
|
|
1876
|
+
}
|
|
1877
|
+
refetch({ ...options } = {}) {
|
|
1878
|
+
return this.fetch({
|
|
1879
|
+
...options
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
fetchOptimistic(options) {
|
|
1883
|
+
const defaultedOptions = __privateGet(this, _client2).defaultQueryOptions(options);
|
|
1884
|
+
const query = __privateGet(this, _client2).getQueryCache().build(__privateGet(this, _client2), defaultedOptions);
|
|
1885
|
+
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
1886
|
+
}
|
|
1887
|
+
fetch(fetchOptions) {
|
|
1888
|
+
return __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this, {
|
|
1889
|
+
...fetchOptions,
|
|
1890
|
+
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
1891
|
+
}).then(() => {
|
|
1892
|
+
this.updateResult();
|
|
1893
|
+
return __privateGet(this, _currentResult);
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
createResult(query, options) {
|
|
1897
|
+
const prevQuery = __privateGet(this, _currentQuery);
|
|
1898
|
+
const prevOptions = this.options;
|
|
1899
|
+
const prevResult = __privateGet(this, _currentResult);
|
|
1900
|
+
const prevResultState = __privateGet(this, _currentResultState);
|
|
1901
|
+
const prevResultOptions = __privateGet(this, _currentResultOptions);
|
|
1902
|
+
const queryChange = query !== prevQuery;
|
|
1903
|
+
const queryInitialState = queryChange ? query.state : __privateGet(this, _currentQueryInitialState);
|
|
1904
|
+
const { state } = query;
|
|
1905
|
+
let newState = { ...state };
|
|
1906
|
+
let isPlaceholderData = false;
|
|
1907
|
+
let data;
|
|
1908
|
+
if (options._optimisticResults) {
|
|
1909
|
+
const mounted = this.hasListeners();
|
|
1910
|
+
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
1911
|
+
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
1912
|
+
if (fetchOnMount || fetchOptionally) {
|
|
1913
|
+
newState = {
|
|
1914
|
+
...newState,
|
|
1915
|
+
...fetchState(state.data, query.options)
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
if (options._optimisticResults === "isRestoring") {
|
|
1919
|
+
newState.fetchStatus = "idle";
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
let { error, errorUpdatedAt, status } = newState;
|
|
1923
|
+
data = newState.data;
|
|
1924
|
+
let skipSelect = false;
|
|
1925
|
+
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
1926
|
+
let placeholderData;
|
|
1927
|
+
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
1928
|
+
placeholderData = prevResult.data;
|
|
1929
|
+
skipSelect = true;
|
|
1930
|
+
} else {
|
|
1931
|
+
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
|
|
1932
|
+
__privateGet(this, _lastQueryWithDefinedData)?.state.data,
|
|
1933
|
+
__privateGet(this, _lastQueryWithDefinedData)
|
|
1934
|
+
) : options.placeholderData;
|
|
1935
|
+
}
|
|
1936
|
+
if (placeholderData !== void 0) {
|
|
1937
|
+
status = "success";
|
|
1938
|
+
data = replaceData(
|
|
1939
|
+
prevResult?.data,
|
|
1940
|
+
placeholderData,
|
|
1941
|
+
options
|
|
1942
|
+
);
|
|
1943
|
+
isPlaceholderData = true;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
if (options.select && data !== void 0 && !skipSelect) {
|
|
1947
|
+
if (prevResult && data === prevResultState?.data && options.select === __privateGet(this, _selectFn)) {
|
|
1948
|
+
data = __privateGet(this, _selectResult);
|
|
1949
|
+
} else {
|
|
1950
|
+
try {
|
|
1951
|
+
__privateSet(this, _selectFn, options.select);
|
|
1952
|
+
data = options.select(data);
|
|
1953
|
+
data = replaceData(prevResult?.data, data, options);
|
|
1954
|
+
__privateSet(this, _selectResult, data);
|
|
1955
|
+
__privateSet(this, _selectError, null);
|
|
1956
|
+
} catch (selectError) {
|
|
1957
|
+
__privateSet(this, _selectError, selectError);
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
if (__privateGet(this, _selectError)) {
|
|
1962
|
+
error = __privateGet(this, _selectError);
|
|
1963
|
+
data = __privateGet(this, _selectResult);
|
|
1964
|
+
errorUpdatedAt = Date.now();
|
|
1965
|
+
status = "error";
|
|
1966
|
+
}
|
|
1967
|
+
const isFetching = newState.fetchStatus === "fetching";
|
|
1968
|
+
const isPending = status === "pending";
|
|
1969
|
+
const isError = status === "error";
|
|
1970
|
+
const isLoading = isPending && isFetching;
|
|
1971
|
+
const hasData = data !== void 0;
|
|
1972
|
+
const result = {
|
|
1973
|
+
status,
|
|
1974
|
+
fetchStatus: newState.fetchStatus,
|
|
1975
|
+
isPending,
|
|
1976
|
+
isSuccess: status === "success",
|
|
1977
|
+
isError,
|
|
1978
|
+
isInitialLoading: isLoading,
|
|
1979
|
+
isLoading,
|
|
1980
|
+
data,
|
|
1981
|
+
dataUpdatedAt: newState.dataUpdatedAt,
|
|
1982
|
+
error,
|
|
1983
|
+
errorUpdatedAt,
|
|
1984
|
+
failureCount: newState.fetchFailureCount,
|
|
1985
|
+
failureReason: newState.fetchFailureReason,
|
|
1986
|
+
errorUpdateCount: newState.errorUpdateCount,
|
|
1987
|
+
isFetched: query.isFetched(),
|
|
1988
|
+
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
1989
|
+
isFetching,
|
|
1990
|
+
isRefetching: isFetching && !isPending,
|
|
1991
|
+
isLoadingError: isError && !hasData,
|
|
1992
|
+
isPaused: newState.fetchStatus === "paused",
|
|
1993
|
+
isPlaceholderData,
|
|
1994
|
+
isRefetchError: isError && hasData,
|
|
1995
|
+
isStale: isStale(query, options),
|
|
1996
|
+
refetch: this.refetch,
|
|
1997
|
+
promise: __privateGet(this, _currentThenable),
|
|
1998
|
+
isEnabled: resolveQueryBoolean(options.enabled, query) !== false
|
|
1999
|
+
};
|
|
2000
|
+
const nextResult = result;
|
|
2001
|
+
if (this.options.experimental_prefetchInRender) {
|
|
2002
|
+
const hasResultData = nextResult.data !== void 0;
|
|
2003
|
+
const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
|
|
2004
|
+
const finalizeThenableIfPossible = (thenable) => {
|
|
2005
|
+
if (isErrorWithoutData) {
|
|
2006
|
+
thenable.reject(nextResult.error);
|
|
2007
|
+
} else if (hasResultData) {
|
|
2008
|
+
thenable.resolve(nextResult.data);
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
const recreateThenable = () => {
|
|
2012
|
+
const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
|
|
2013
|
+
finalizeThenableIfPossible(pending);
|
|
2014
|
+
};
|
|
2015
|
+
const prevThenable = __privateGet(this, _currentThenable);
|
|
2016
|
+
switch (prevThenable.status) {
|
|
2017
|
+
case "pending":
|
|
2018
|
+
if (query.queryHash === prevQuery.queryHash) {
|
|
2019
|
+
finalizeThenableIfPossible(prevThenable);
|
|
2020
|
+
}
|
|
2021
|
+
break;
|
|
2022
|
+
case "fulfilled":
|
|
2023
|
+
if (isErrorWithoutData || nextResult.data !== prevThenable.value) {
|
|
2024
|
+
recreateThenable();
|
|
2025
|
+
}
|
|
2026
|
+
break;
|
|
2027
|
+
case "rejected":
|
|
2028
|
+
if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) {
|
|
2029
|
+
recreateThenable();
|
|
2030
|
+
}
|
|
2031
|
+
break;
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
return nextResult;
|
|
2035
|
+
}
|
|
2036
|
+
updateResult() {
|
|
2037
|
+
const prevResult = __privateGet(this, _currentResult);
|
|
2038
|
+
const nextResult = this.createResult(__privateGet(this, _currentQuery), this.options);
|
|
2039
|
+
__privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
|
|
2040
|
+
__privateSet(this, _currentResultOptions, this.options);
|
|
2041
|
+
if (__privateGet(this, _currentResultState).data !== void 0) {
|
|
2042
|
+
__privateSet(this, _lastQueryWithDefinedData, __privateGet(this, _currentQuery));
|
|
2043
|
+
}
|
|
2044
|
+
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
2045
|
+
return;
|
|
2046
|
+
}
|
|
2047
|
+
__privateSet(this, _currentResult, nextResult);
|
|
2048
|
+
const shouldNotifyListeners = () => {
|
|
2049
|
+
if (!prevResult) {
|
|
2050
|
+
return true;
|
|
2051
|
+
}
|
|
2052
|
+
const { notifyOnChangeProps } = this.options;
|
|
2053
|
+
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
2054
|
+
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) {
|
|
2055
|
+
return true;
|
|
2056
|
+
}
|
|
2057
|
+
const includedProps = new Set(
|
|
2058
|
+
notifyOnChangePropsValue ?? __privateGet(this, _trackedProps)
|
|
2059
|
+
);
|
|
2060
|
+
if (this.options.throwOnError) {
|
|
2061
|
+
includedProps.add("error");
|
|
2062
|
+
}
|
|
2063
|
+
return Object.keys(__privateGet(this, _currentResult)).some((key) => {
|
|
2064
|
+
const typedKey = key;
|
|
2065
|
+
const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey];
|
|
2066
|
+
return changed && includedProps.has(typedKey);
|
|
2067
|
+
});
|
|
2068
|
+
};
|
|
2069
|
+
__privateMethod(this, _QueryObserver_instances, notify_fn).call(this, { listeners: shouldNotifyListeners() });
|
|
2070
|
+
}
|
|
2071
|
+
onQueryUpdate() {
|
|
2072
|
+
this.updateResult();
|
|
2073
|
+
if (this.hasListeners()) {
|
|
2074
|
+
__privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
}, _client2 = 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) {
|
|
2078
|
+
__privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
|
|
2079
|
+
let promise = __privateGet(this, _currentQuery).fetch(
|
|
2080
|
+
this.options,
|
|
2081
|
+
fetchOptions
|
|
2082
|
+
);
|
|
2083
|
+
if (!fetchOptions?.throwOnError) {
|
|
2084
|
+
promise = promise.catch(noop);
|
|
2085
|
+
}
|
|
2086
|
+
return promise;
|
|
2087
|
+
}, updateStaleTimeout_fn = function() {
|
|
2088
|
+
__privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
|
|
2089
|
+
const staleTime = resolveStaleTime(
|
|
2090
|
+
this.options.staleTime,
|
|
2091
|
+
__privateGet(this, _currentQuery)
|
|
2092
|
+
);
|
|
2093
|
+
if (environmentManager.isServer() || __privateGet(this, _currentResult).isStale || !isValidTimeout(staleTime)) {
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
const time = timeUntilStale(__privateGet(this, _currentResult).dataUpdatedAt, staleTime);
|
|
2097
|
+
const timeout = time + 1;
|
|
2098
|
+
__privateSet(this, _staleTimeoutId, timeoutManager.setTimeout(() => {
|
|
2099
|
+
if (!__privateGet(this, _currentResult).isStale) {
|
|
2100
|
+
this.updateResult();
|
|
2101
|
+
}
|
|
2102
|
+
}, timeout));
|
|
2103
|
+
}, computeRefetchInterval_fn = function() {
|
|
2104
|
+
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(__privateGet(this, _currentQuery)) : this.options.refetchInterval) ?? false;
|
|
2105
|
+
}, updateRefetchInterval_fn = function(nextInterval) {
|
|
2106
|
+
__privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
|
|
2107
|
+
__privateSet(this, _currentRefetchInterval, nextInterval);
|
|
2108
|
+
if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, __privateGet(this, _currentQuery)) === false || !isValidTimeout(__privateGet(this, _currentRefetchInterval)) || __privateGet(this, _currentRefetchInterval) === 0) {
|
|
2109
|
+
return;
|
|
2110
|
+
}
|
|
2111
|
+
__privateSet(this, _refetchIntervalId, timeoutManager.setInterval(() => {
|
|
2112
|
+
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
2113
|
+
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
2114
|
+
}
|
|
2115
|
+
}, __privateGet(this, _currentRefetchInterval)));
|
|
2116
|
+
}, updateTimers_fn = function() {
|
|
2117
|
+
__privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
|
|
2118
|
+
__privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this));
|
|
2119
|
+
}, clearStaleTimeout_fn = function() {
|
|
2120
|
+
if (__privateGet(this, _staleTimeoutId) !== void 0) {
|
|
2121
|
+
timeoutManager.clearTimeout(__privateGet(this, _staleTimeoutId));
|
|
2122
|
+
__privateSet(this, _staleTimeoutId, void 0);
|
|
2123
|
+
}
|
|
2124
|
+
}, clearRefetchInterval_fn = function() {
|
|
2125
|
+
if (__privateGet(this, _refetchIntervalId) !== void 0) {
|
|
2126
|
+
timeoutManager.clearInterval(__privateGet(this, _refetchIntervalId));
|
|
2127
|
+
__privateSet(this, _refetchIntervalId, void 0);
|
|
2128
|
+
}
|
|
2129
|
+
}, updateQuery_fn = function() {
|
|
2130
|
+
const query = __privateGet(this, _client2).getQueryCache().build(__privateGet(this, _client2), this.options);
|
|
2131
|
+
if (query === __privateGet(this, _currentQuery)) {
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
const prevQuery = __privateGet(this, _currentQuery);
|
|
2135
|
+
__privateSet(this, _currentQuery, query);
|
|
2136
|
+
__privateSet(this, _currentQueryInitialState, query.state);
|
|
2137
|
+
if (this.hasListeners()) {
|
|
2138
|
+
prevQuery?.removeObserver(this);
|
|
2139
|
+
query.addObserver(this);
|
|
2140
|
+
}
|
|
2141
|
+
}, notify_fn = function(notifyOptions) {
|
|
2142
|
+
notifyManager.batch(() => {
|
|
2143
|
+
if (notifyOptions.listeners) {
|
|
2144
|
+
this.listeners.forEach((listener) => {
|
|
2145
|
+
listener(__privateGet(this, _currentResult));
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
__privateGet(this, _client2).getQueryCache().notify({
|
|
2149
|
+
query: __privateGet(this, _currentQuery),
|
|
2150
|
+
type: "observerResultsUpdated"
|
|
2151
|
+
});
|
|
2152
|
+
});
|
|
2153
|
+
}, _a6);
|
|
2154
|
+
function shouldLoadOnMount(query, options) {
|
|
2155
|
+
return resolveQueryBoolean(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryBoolean(options.retryOnMount, query) === false);
|
|
2156
|
+
}
|
|
2157
|
+
function shouldFetchOnMount(query, options) {
|
|
2158
|
+
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
2159
|
+
}
|
|
2160
|
+
function shouldFetchOn(query, options, field) {
|
|
2161
|
+
if (resolveQueryBoolean(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
|
|
2162
|
+
const value = typeof field === "function" ? field(query) : field;
|
|
2163
|
+
return value === "always" || value !== false && isStale(query, options);
|
|
2164
|
+
}
|
|
2165
|
+
return false;
|
|
2166
|
+
}
|
|
2167
|
+
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
2168
|
+
return (query !== prevQuery || resolveQueryBoolean(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
2169
|
+
}
|
|
2170
|
+
function isStale(query, options) {
|
|
2171
|
+
return resolveQueryBoolean(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
|
|
2172
|
+
}
|
|
2173
|
+
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
2174
|
+
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
2175
|
+
return true;
|
|
2176
|
+
}
|
|
2177
|
+
return false;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
// node_modules/@tanstack/query-core/build/modern/mutation.js
|
|
2181
|
+
var _client3, _observers, _mutationCache, _retryer2, _Mutation_instances, dispatch_fn2, _a7;
|
|
2182
|
+
var Mutation = (_a7 = class extends Removable {
|
|
2183
|
+
constructor(config) {
|
|
2184
|
+
super();
|
|
2185
|
+
__privateAdd(this, _Mutation_instances);
|
|
2186
|
+
__privateAdd(this, _client3);
|
|
2187
|
+
__privateAdd(this, _observers);
|
|
2188
|
+
__privateAdd(this, _mutationCache);
|
|
2189
|
+
__privateAdd(this, _retryer2);
|
|
2190
|
+
__privateSet(this, _client3, config.client);
|
|
2191
|
+
this.mutationId = config.mutationId;
|
|
2192
|
+
__privateSet(this, _mutationCache, config.mutationCache);
|
|
2193
|
+
__privateSet(this, _observers, []);
|
|
2194
|
+
this.state = config.state || getDefaultState2();
|
|
2195
|
+
this.setOptions(config.options);
|
|
2196
|
+
this.scheduleGc();
|
|
2197
|
+
}
|
|
2198
|
+
setOptions(options) {
|
|
2199
|
+
this.options = options;
|
|
2200
|
+
this.updateGcTime(this.options.gcTime);
|
|
2201
|
+
}
|
|
2202
|
+
get meta() {
|
|
2203
|
+
return this.options.meta;
|
|
2204
|
+
}
|
|
2205
|
+
addObserver(observer) {
|
|
2206
|
+
if (!__privateGet(this, _observers).includes(observer)) {
|
|
2207
|
+
__privateGet(this, _observers).push(observer);
|
|
2208
|
+
this.clearGcTimeout();
|
|
2209
|
+
__privateGet(this, _mutationCache).notify({
|
|
2210
|
+
type: "observerAdded",
|
|
2211
|
+
mutation: this,
|
|
2212
|
+
observer
|
|
361
2213
|
});
|
|
362
|
-
} catch (r3) {
|
|
363
|
-
t3.some(function(n4) {
|
|
364
|
-
n4.__h && (n4.__h = []);
|
|
365
|
-
}), t3 = [], c2.__e(r3, n3.__v);
|
|
366
2214
|
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
2215
|
+
}
|
|
2216
|
+
removeObserver(observer) {
|
|
2217
|
+
__privateSet(this, _observers, __privateGet(this, _observers).filter((x3) => x3 !== observer));
|
|
2218
|
+
this.scheduleGc();
|
|
2219
|
+
__privateGet(this, _mutationCache).notify({
|
|
2220
|
+
type: "observerRemoved",
|
|
2221
|
+
mutation: this,
|
|
2222
|
+
observer
|
|
2223
|
+
});
|
|
2224
|
+
}
|
|
2225
|
+
optionalRemove() {
|
|
2226
|
+
if (!__privateGet(this, _observers).length) {
|
|
2227
|
+
if (this.state.status === "pending") {
|
|
2228
|
+
this.scheduleGc();
|
|
2229
|
+
} else {
|
|
2230
|
+
__privateGet(this, _mutationCache).remove(this);
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
continue() {
|
|
2235
|
+
return __privateGet(this, _retryer2)?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
|
|
2236
|
+
this.execute(this.state.variables);
|
|
2237
|
+
}
|
|
2238
|
+
async execute(variables) {
|
|
2239
|
+
const onContinue = () => {
|
|
2240
|
+
__privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "continue" });
|
|
2241
|
+
};
|
|
2242
|
+
const mutationFnContext = {
|
|
2243
|
+
client: __privateGet(this, _client3),
|
|
2244
|
+
meta: this.options.meta,
|
|
2245
|
+
mutationKey: this.options.mutationKey
|
|
2246
|
+
};
|
|
2247
|
+
__privateSet(this, _retryer2, createRetryer({
|
|
2248
|
+
fn: () => {
|
|
2249
|
+
if (!this.options.mutationFn) {
|
|
2250
|
+
return Promise.reject(new Error("No mutationFn found"));
|
|
2251
|
+
}
|
|
2252
|
+
return this.options.mutationFn(variables, mutationFnContext);
|
|
2253
|
+
},
|
|
2254
|
+
onFail: (failureCount, error) => {
|
|
2255
|
+
__privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "failed", failureCount, error });
|
|
2256
|
+
},
|
|
2257
|
+
onPause: () => {
|
|
2258
|
+
__privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "pause" });
|
|
2259
|
+
},
|
|
2260
|
+
onContinue,
|
|
2261
|
+
retry: this.options.retry ?? 0,
|
|
2262
|
+
retryDelay: this.options.retryDelay,
|
|
2263
|
+
networkMode: this.options.networkMode,
|
|
2264
|
+
canRun: () => __privateGet(this, _mutationCache).canRun(this)
|
|
2265
|
+
}));
|
|
2266
|
+
const restored = this.state.status === "pending";
|
|
2267
|
+
const isPaused = !__privateGet(this, _retryer2).canStart();
|
|
372
2268
|
try {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
2269
|
+
if (restored) {
|
|
2270
|
+
onContinue();
|
|
2271
|
+
} else {
|
|
2272
|
+
__privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "pending", variables, isPaused });
|
|
2273
|
+
if (__privateGet(this, _mutationCache).config.onMutate) {
|
|
2274
|
+
await __privateGet(this, _mutationCache).config.onMutate(
|
|
2275
|
+
variables,
|
|
2276
|
+
this,
|
|
2277
|
+
mutationFnContext
|
|
2278
|
+
);
|
|
2279
|
+
}
|
|
2280
|
+
const context = await this.options.onMutate?.(
|
|
2281
|
+
variables,
|
|
2282
|
+
mutationFnContext
|
|
2283
|
+
);
|
|
2284
|
+
if (context !== this.state.context) {
|
|
2285
|
+
__privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, {
|
|
2286
|
+
type: "pending",
|
|
2287
|
+
context,
|
|
2288
|
+
variables,
|
|
2289
|
+
isPaused
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
const data = await __privateGet(this, _retryer2).start();
|
|
2294
|
+
await __privateGet(this, _mutationCache).config.onSuccess?.(
|
|
2295
|
+
data,
|
|
2296
|
+
variables,
|
|
2297
|
+
this.state.context,
|
|
2298
|
+
this,
|
|
2299
|
+
mutationFnContext
|
|
2300
|
+
);
|
|
2301
|
+
await this.options.onSuccess?.(
|
|
2302
|
+
data,
|
|
2303
|
+
variables,
|
|
2304
|
+
this.state.context,
|
|
2305
|
+
mutationFnContext
|
|
2306
|
+
);
|
|
2307
|
+
await __privateGet(this, _mutationCache).config.onSettled?.(
|
|
2308
|
+
data,
|
|
2309
|
+
null,
|
|
2310
|
+
this.state.variables,
|
|
2311
|
+
this.state.context,
|
|
2312
|
+
this,
|
|
2313
|
+
mutationFnContext
|
|
2314
|
+
);
|
|
2315
|
+
await this.options.onSettled?.(
|
|
2316
|
+
data,
|
|
2317
|
+
null,
|
|
2318
|
+
variables,
|
|
2319
|
+
this.state.context,
|
|
2320
|
+
mutationFnContext
|
|
2321
|
+
);
|
|
2322
|
+
__privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "success", data });
|
|
2323
|
+
return data;
|
|
2324
|
+
} catch (error) {
|
|
2325
|
+
try {
|
|
2326
|
+
await __privateGet(this, _mutationCache).config.onError?.(
|
|
2327
|
+
error,
|
|
2328
|
+
variables,
|
|
2329
|
+
this.state.context,
|
|
2330
|
+
this,
|
|
2331
|
+
mutationFnContext
|
|
2332
|
+
);
|
|
2333
|
+
} catch (e3) {
|
|
2334
|
+
void Promise.reject(e3);
|
|
2335
|
+
}
|
|
2336
|
+
try {
|
|
2337
|
+
await this.options.onError?.(
|
|
2338
|
+
error,
|
|
2339
|
+
variables,
|
|
2340
|
+
this.state.context,
|
|
2341
|
+
mutationFnContext
|
|
2342
|
+
);
|
|
2343
|
+
} catch (e3) {
|
|
2344
|
+
void Promise.reject(e3);
|
|
2345
|
+
}
|
|
2346
|
+
try {
|
|
2347
|
+
await __privateGet(this, _mutationCache).config.onSettled?.(
|
|
2348
|
+
void 0,
|
|
2349
|
+
error,
|
|
2350
|
+
this.state.variables,
|
|
2351
|
+
this.state.context,
|
|
2352
|
+
this,
|
|
2353
|
+
mutationFnContext
|
|
2354
|
+
);
|
|
2355
|
+
} catch (e3) {
|
|
2356
|
+
void Promise.reject(e3);
|
|
2357
|
+
}
|
|
2358
|
+
try {
|
|
2359
|
+
await this.options.onSettled?.(
|
|
2360
|
+
void 0,
|
|
2361
|
+
error,
|
|
2362
|
+
variables,
|
|
2363
|
+
this.state.context,
|
|
2364
|
+
mutationFnContext
|
|
2365
|
+
);
|
|
2366
|
+
} catch (e3) {
|
|
2367
|
+
void Promise.reject(e3);
|
|
2368
|
+
}
|
|
2369
|
+
__privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "error", error });
|
|
2370
|
+
throw error;
|
|
2371
|
+
} finally {
|
|
2372
|
+
__privateGet(this, _mutationCache).runNext(this);
|
|
376
2373
|
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
2374
|
+
}
|
|
2375
|
+
}, _client3 = new WeakMap(), _observers = new WeakMap(), _mutationCache = new WeakMap(), _retryer2 = new WeakMap(), _Mutation_instances = new WeakSet(), dispatch_fn2 = function(action) {
|
|
2376
|
+
const reducer = (state) => {
|
|
2377
|
+
switch (action.type) {
|
|
2378
|
+
case "failed":
|
|
2379
|
+
return {
|
|
2380
|
+
...state,
|
|
2381
|
+
failureCount: action.failureCount,
|
|
2382
|
+
failureReason: action.error
|
|
2383
|
+
};
|
|
2384
|
+
case "pause":
|
|
2385
|
+
return {
|
|
2386
|
+
...state,
|
|
2387
|
+
isPaused: true
|
|
2388
|
+
};
|
|
2389
|
+
case "continue":
|
|
2390
|
+
return {
|
|
2391
|
+
...state,
|
|
2392
|
+
isPaused: false
|
|
2393
|
+
};
|
|
2394
|
+
case "pending":
|
|
2395
|
+
return {
|
|
2396
|
+
...state,
|
|
2397
|
+
context: action.context,
|
|
2398
|
+
data: void 0,
|
|
2399
|
+
failureCount: 0,
|
|
2400
|
+
failureReason: null,
|
|
2401
|
+
error: null,
|
|
2402
|
+
isPaused: action.isPaused,
|
|
2403
|
+
status: "pending",
|
|
2404
|
+
variables: action.variables,
|
|
2405
|
+
submittedAt: Date.now()
|
|
2406
|
+
};
|
|
2407
|
+
case "success":
|
|
2408
|
+
return {
|
|
2409
|
+
...state,
|
|
2410
|
+
data: action.data,
|
|
2411
|
+
failureCount: 0,
|
|
2412
|
+
failureReason: null,
|
|
2413
|
+
error: null,
|
|
2414
|
+
status: "success",
|
|
2415
|
+
isPaused: false
|
|
2416
|
+
};
|
|
2417
|
+
case "error":
|
|
2418
|
+
return {
|
|
2419
|
+
...state,
|
|
2420
|
+
data: void 0,
|
|
2421
|
+
error: action.error,
|
|
2422
|
+
failureCount: state.failureCount + 1,
|
|
2423
|
+
failureReason: action.error,
|
|
2424
|
+
isPaused: false,
|
|
2425
|
+
status: "error"
|
|
2426
|
+
};
|
|
2427
|
+
}
|
|
2428
|
+
};
|
|
2429
|
+
this.state = reducer(this.state);
|
|
2430
|
+
notifyManager.batch(() => {
|
|
2431
|
+
__privateGet(this, _observers).forEach((observer) => {
|
|
2432
|
+
observer.onMutationUpdate(action);
|
|
2433
|
+
});
|
|
2434
|
+
__privateGet(this, _mutationCache).notify({
|
|
2435
|
+
mutation: this,
|
|
2436
|
+
type: "updated",
|
|
2437
|
+
action
|
|
2438
|
+
});
|
|
397
2439
|
});
|
|
2440
|
+
}, _a7);
|
|
2441
|
+
function getDefaultState2() {
|
|
2442
|
+
return {
|
|
2443
|
+
context: void 0,
|
|
2444
|
+
data: void 0,
|
|
2445
|
+
error: null,
|
|
2446
|
+
failureCount: 0,
|
|
2447
|
+
failureReason: null,
|
|
2448
|
+
isPaused: false,
|
|
2449
|
+
status: "idle",
|
|
2450
|
+
variables: void 0,
|
|
2451
|
+
submittedAt: 0
|
|
2452
|
+
};
|
|
398
2453
|
}
|
|
399
|
-
|
|
400
|
-
|
|
2454
|
+
|
|
2455
|
+
// node_modules/@tanstack/query-core/build/modern/mutationCache.js
|
|
2456
|
+
var _mutations, _scopes, _mutationId, _a8;
|
|
2457
|
+
var MutationCache = (_a8 = class extends Subscribable {
|
|
2458
|
+
constructor(config = {}) {
|
|
2459
|
+
super();
|
|
2460
|
+
__privateAdd(this, _mutations);
|
|
2461
|
+
__privateAdd(this, _scopes);
|
|
2462
|
+
__privateAdd(this, _mutationId);
|
|
2463
|
+
this.config = config;
|
|
2464
|
+
__privateSet(this, _mutations, /* @__PURE__ */ new Set());
|
|
2465
|
+
__privateSet(this, _scopes, /* @__PURE__ */ new Map());
|
|
2466
|
+
__privateSet(this, _mutationId, 0);
|
|
2467
|
+
}
|
|
2468
|
+
build(client, options, state) {
|
|
2469
|
+
const mutation = new Mutation({
|
|
2470
|
+
client,
|
|
2471
|
+
mutationCache: this,
|
|
2472
|
+
mutationId: ++__privateWrapper(this, _mutationId)._,
|
|
2473
|
+
options: client.defaultMutationOptions(options),
|
|
2474
|
+
state
|
|
2475
|
+
});
|
|
2476
|
+
this.add(mutation);
|
|
2477
|
+
return mutation;
|
|
2478
|
+
}
|
|
2479
|
+
add(mutation) {
|
|
2480
|
+
__privateGet(this, _mutations).add(mutation);
|
|
2481
|
+
const scope = scopeFor(mutation);
|
|
2482
|
+
if (typeof scope === "string") {
|
|
2483
|
+
const scopedMutations = __privateGet(this, _scopes).get(scope);
|
|
2484
|
+
if (scopedMutations) {
|
|
2485
|
+
scopedMutations.push(mutation);
|
|
2486
|
+
} else {
|
|
2487
|
+
__privateGet(this, _scopes).set(scope, [mutation]);
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
this.notify({ type: "added", mutation });
|
|
2491
|
+
}
|
|
2492
|
+
remove(mutation) {
|
|
2493
|
+
if (__privateGet(this, _mutations).delete(mutation)) {
|
|
2494
|
+
const scope = scopeFor(mutation);
|
|
2495
|
+
if (typeof scope === "string") {
|
|
2496
|
+
const scopedMutations = __privateGet(this, _scopes).get(scope);
|
|
2497
|
+
if (scopedMutations) {
|
|
2498
|
+
if (scopedMutations.length > 1) {
|
|
2499
|
+
const index = scopedMutations.indexOf(mutation);
|
|
2500
|
+
if (index !== -1) {
|
|
2501
|
+
scopedMutations.splice(index, 1);
|
|
2502
|
+
}
|
|
2503
|
+
} else if (scopedMutations[0] === mutation) {
|
|
2504
|
+
__privateGet(this, _scopes).delete(scope);
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
this.notify({ type: "removed", mutation });
|
|
2510
|
+
}
|
|
2511
|
+
canRun(mutation) {
|
|
2512
|
+
const scope = scopeFor(mutation);
|
|
2513
|
+
if (typeof scope === "string") {
|
|
2514
|
+
const mutationsWithSameScope = __privateGet(this, _scopes).get(scope);
|
|
2515
|
+
const firstPendingMutation = mutationsWithSameScope?.find(
|
|
2516
|
+
(m3) => m3.state.status === "pending"
|
|
2517
|
+
);
|
|
2518
|
+
return !firstPendingMutation || firstPendingMutation === mutation;
|
|
2519
|
+
} else {
|
|
2520
|
+
return true;
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
runNext(mutation) {
|
|
2524
|
+
const scope = scopeFor(mutation);
|
|
2525
|
+
if (typeof scope === "string") {
|
|
2526
|
+
const foundMutation = __privateGet(this, _scopes).get(scope)?.find((m3) => m3 !== mutation && m3.state.isPaused);
|
|
2527
|
+
return foundMutation?.continue() ?? Promise.resolve();
|
|
2528
|
+
} else {
|
|
2529
|
+
return Promise.resolve();
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
clear() {
|
|
2533
|
+
notifyManager.batch(() => {
|
|
2534
|
+
__privateGet(this, _mutations).forEach((mutation) => {
|
|
2535
|
+
this.notify({ type: "removed", mutation });
|
|
2536
|
+
});
|
|
2537
|
+
__privateGet(this, _mutations).clear();
|
|
2538
|
+
__privateGet(this, _scopes).clear();
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2541
|
+
getAll() {
|
|
2542
|
+
return Array.from(__privateGet(this, _mutations));
|
|
2543
|
+
}
|
|
2544
|
+
find(filters) {
|
|
2545
|
+
const defaultedFilters = { exact: true, ...filters };
|
|
2546
|
+
return this.getAll().find(
|
|
2547
|
+
(mutation) => matchMutation(defaultedFilters, mutation)
|
|
2548
|
+
);
|
|
2549
|
+
}
|
|
2550
|
+
findAll(filters = {}) {
|
|
2551
|
+
return this.getAll().filter((mutation) => matchMutation(filters, mutation));
|
|
2552
|
+
}
|
|
2553
|
+
notify(event) {
|
|
2554
|
+
notifyManager.batch(() => {
|
|
2555
|
+
this.listeners.forEach((listener) => {
|
|
2556
|
+
listener(event);
|
|
2557
|
+
});
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
resumePausedMutations() {
|
|
2561
|
+
const pausedMutations = this.getAll().filter((x3) => x3.state.isPaused);
|
|
2562
|
+
return notifyManager.batch(
|
|
2563
|
+
() => Promise.all(
|
|
2564
|
+
pausedMutations.map((mutation) => mutation.continue().catch(noop))
|
|
2565
|
+
)
|
|
2566
|
+
);
|
|
2567
|
+
}
|
|
2568
|
+
}, _mutations = new WeakMap(), _scopes = new WeakMap(), _mutationId = new WeakMap(), _a8);
|
|
2569
|
+
function scopeFor(mutation) {
|
|
2570
|
+
return mutation.options.scope?.id;
|
|
401
2571
|
}
|
|
402
2572
|
|
|
2573
|
+
// node_modules/@tanstack/query-core/build/modern/queryCache.js
|
|
2574
|
+
var _queries, _a9;
|
|
2575
|
+
var QueryCache = (_a9 = class extends Subscribable {
|
|
2576
|
+
constructor(config = {}) {
|
|
2577
|
+
super();
|
|
2578
|
+
__privateAdd(this, _queries);
|
|
2579
|
+
this.config = config;
|
|
2580
|
+
__privateSet(this, _queries, /* @__PURE__ */ new Map());
|
|
2581
|
+
}
|
|
2582
|
+
build(client, options, state) {
|
|
2583
|
+
const queryKey = options.queryKey;
|
|
2584
|
+
const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
|
|
2585
|
+
let query = this.get(queryHash);
|
|
2586
|
+
if (!query) {
|
|
2587
|
+
query = new Query({
|
|
2588
|
+
client,
|
|
2589
|
+
queryKey,
|
|
2590
|
+
queryHash,
|
|
2591
|
+
options: client.defaultQueryOptions(options),
|
|
2592
|
+
state,
|
|
2593
|
+
defaultOptions: client.getQueryDefaults(queryKey)
|
|
2594
|
+
});
|
|
2595
|
+
this.add(query);
|
|
2596
|
+
}
|
|
2597
|
+
return query;
|
|
2598
|
+
}
|
|
2599
|
+
add(query) {
|
|
2600
|
+
if (!__privateGet(this, _queries).has(query.queryHash)) {
|
|
2601
|
+
__privateGet(this, _queries).set(query.queryHash, query);
|
|
2602
|
+
this.notify({
|
|
2603
|
+
type: "added",
|
|
2604
|
+
query
|
|
2605
|
+
});
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
remove(query) {
|
|
2609
|
+
const queryInMap = __privateGet(this, _queries).get(query.queryHash);
|
|
2610
|
+
if (queryInMap) {
|
|
2611
|
+
query.destroy();
|
|
2612
|
+
if (queryInMap === query) {
|
|
2613
|
+
__privateGet(this, _queries).delete(query.queryHash);
|
|
2614
|
+
}
|
|
2615
|
+
this.notify({ type: "removed", query });
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
clear() {
|
|
2619
|
+
notifyManager.batch(() => {
|
|
2620
|
+
this.getAll().forEach((query) => {
|
|
2621
|
+
this.remove(query);
|
|
2622
|
+
});
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
2625
|
+
get(queryHash) {
|
|
2626
|
+
return __privateGet(this, _queries).get(queryHash);
|
|
2627
|
+
}
|
|
2628
|
+
getAll() {
|
|
2629
|
+
return [...__privateGet(this, _queries).values()];
|
|
2630
|
+
}
|
|
2631
|
+
find(filters) {
|
|
2632
|
+
const defaultedFilters = { exact: true, ...filters };
|
|
2633
|
+
return this.getAll().find(
|
|
2634
|
+
(query) => matchQuery(defaultedFilters, query)
|
|
2635
|
+
);
|
|
2636
|
+
}
|
|
2637
|
+
findAll(filters = {}) {
|
|
2638
|
+
const queries = this.getAll();
|
|
2639
|
+
return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
|
|
2640
|
+
}
|
|
2641
|
+
notify(event) {
|
|
2642
|
+
notifyManager.batch(() => {
|
|
2643
|
+
this.listeners.forEach((listener) => {
|
|
2644
|
+
listener(event);
|
|
2645
|
+
});
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
onFocus() {
|
|
2649
|
+
notifyManager.batch(() => {
|
|
2650
|
+
this.getAll().forEach((query) => {
|
|
2651
|
+
query.onFocus();
|
|
2652
|
+
});
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2655
|
+
onOnline() {
|
|
2656
|
+
notifyManager.batch(() => {
|
|
2657
|
+
this.getAll().forEach((query) => {
|
|
2658
|
+
query.onOnline();
|
|
2659
|
+
});
|
|
2660
|
+
});
|
|
2661
|
+
}
|
|
2662
|
+
}, _queries = new WeakMap(), _a9);
|
|
2663
|
+
|
|
2664
|
+
// node_modules/@tanstack/query-core/build/modern/queryClient.js
|
|
2665
|
+
var _queryCache, _mutationCache2, _defaultOptions2, _queryDefaults, _mutationDefaults, _mountCount, _unsubscribeFocus, _unsubscribeOnline, _a10;
|
|
2666
|
+
var QueryClient = (_a10 = class {
|
|
2667
|
+
constructor(config = {}) {
|
|
2668
|
+
__privateAdd(this, _queryCache);
|
|
2669
|
+
__privateAdd(this, _mutationCache2);
|
|
2670
|
+
__privateAdd(this, _defaultOptions2);
|
|
2671
|
+
__privateAdd(this, _queryDefaults);
|
|
2672
|
+
__privateAdd(this, _mutationDefaults);
|
|
2673
|
+
__privateAdd(this, _mountCount);
|
|
2674
|
+
__privateAdd(this, _unsubscribeFocus);
|
|
2675
|
+
__privateAdd(this, _unsubscribeOnline);
|
|
2676
|
+
__privateSet(this, _queryCache, config.queryCache || new QueryCache());
|
|
2677
|
+
__privateSet(this, _mutationCache2, config.mutationCache || new MutationCache());
|
|
2678
|
+
__privateSet(this, _defaultOptions2, config.defaultOptions || {});
|
|
2679
|
+
__privateSet(this, _queryDefaults, /* @__PURE__ */ new Map());
|
|
2680
|
+
__privateSet(this, _mutationDefaults, /* @__PURE__ */ new Map());
|
|
2681
|
+
__privateSet(this, _mountCount, 0);
|
|
2682
|
+
}
|
|
2683
|
+
mount() {
|
|
2684
|
+
__privateWrapper(this, _mountCount)._++;
|
|
2685
|
+
if (__privateGet(this, _mountCount) !== 1) return;
|
|
2686
|
+
__privateSet(this, _unsubscribeFocus, focusManager.subscribe(async (focused) => {
|
|
2687
|
+
if (focused) {
|
|
2688
|
+
await this.resumePausedMutations();
|
|
2689
|
+
__privateGet(this, _queryCache).onFocus();
|
|
2690
|
+
}
|
|
2691
|
+
}));
|
|
2692
|
+
__privateSet(this, _unsubscribeOnline, onlineManager.subscribe(async (online) => {
|
|
2693
|
+
if (online) {
|
|
2694
|
+
await this.resumePausedMutations();
|
|
2695
|
+
__privateGet(this, _queryCache).onOnline();
|
|
2696
|
+
}
|
|
2697
|
+
}));
|
|
2698
|
+
}
|
|
2699
|
+
unmount() {
|
|
2700
|
+
var _a11, _b;
|
|
2701
|
+
__privateWrapper(this, _mountCount)._--;
|
|
2702
|
+
if (__privateGet(this, _mountCount) !== 0) return;
|
|
2703
|
+
(_a11 = __privateGet(this, _unsubscribeFocus)) == null ? void 0 : _a11.call(this);
|
|
2704
|
+
__privateSet(this, _unsubscribeFocus, void 0);
|
|
2705
|
+
(_b = __privateGet(this, _unsubscribeOnline)) == null ? void 0 : _b.call(this);
|
|
2706
|
+
__privateSet(this, _unsubscribeOnline, void 0);
|
|
2707
|
+
}
|
|
2708
|
+
isFetching(filters) {
|
|
2709
|
+
return __privateGet(this, _queryCache).findAll({ ...filters, fetchStatus: "fetching" }).length;
|
|
2710
|
+
}
|
|
2711
|
+
isMutating(filters) {
|
|
2712
|
+
return __privateGet(this, _mutationCache2).findAll({ ...filters, status: "pending" }).length;
|
|
2713
|
+
}
|
|
2714
|
+
/**
|
|
2715
|
+
* Imperative (non-reactive) way to retrieve data for a QueryKey.
|
|
2716
|
+
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
|
|
2717
|
+
*
|
|
2718
|
+
* Hint: Do not use this function inside a component, because it won't receive updates.
|
|
2719
|
+
* Use `useQuery` to create a `QueryObserver` that subscribes to changes.
|
|
2720
|
+
*/
|
|
2721
|
+
getQueryData(queryKey) {
|
|
2722
|
+
const options = this.defaultQueryOptions({ queryKey });
|
|
2723
|
+
return __privateGet(this, _queryCache).get(options.queryHash)?.state.data;
|
|
2724
|
+
}
|
|
2725
|
+
ensureQueryData(options) {
|
|
2726
|
+
const defaultedOptions = this.defaultQueryOptions(options);
|
|
2727
|
+
const query = __privateGet(this, _queryCache).build(this, defaultedOptions);
|
|
2728
|
+
const cachedData = query.state.data;
|
|
2729
|
+
if (cachedData === void 0) {
|
|
2730
|
+
return this.fetchQuery(options);
|
|
2731
|
+
}
|
|
2732
|
+
if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) {
|
|
2733
|
+
void this.prefetchQuery(defaultedOptions);
|
|
2734
|
+
}
|
|
2735
|
+
return Promise.resolve(cachedData);
|
|
2736
|
+
}
|
|
2737
|
+
getQueriesData(filters) {
|
|
2738
|
+
return __privateGet(this, _queryCache).findAll(filters).map(({ queryKey, state }) => {
|
|
2739
|
+
const data = state.data;
|
|
2740
|
+
return [queryKey, data];
|
|
2741
|
+
});
|
|
2742
|
+
}
|
|
2743
|
+
setQueryData(queryKey, updater, options) {
|
|
2744
|
+
const defaultedOptions = this.defaultQueryOptions({ queryKey });
|
|
2745
|
+
const query = __privateGet(this, _queryCache).get(
|
|
2746
|
+
defaultedOptions.queryHash
|
|
2747
|
+
);
|
|
2748
|
+
const prevData = query?.state.data;
|
|
2749
|
+
const data = functionalUpdate(updater, prevData);
|
|
2750
|
+
if (data === void 0) {
|
|
2751
|
+
return void 0;
|
|
2752
|
+
}
|
|
2753
|
+
return __privateGet(this, _queryCache).build(this, defaultedOptions).setData(data, { ...options, manual: true });
|
|
2754
|
+
}
|
|
2755
|
+
setQueriesData(filters, updater, options) {
|
|
2756
|
+
return notifyManager.batch(
|
|
2757
|
+
() => __privateGet(this, _queryCache).findAll(filters).map(({ queryKey }) => [
|
|
2758
|
+
queryKey,
|
|
2759
|
+
this.setQueryData(queryKey, updater, options)
|
|
2760
|
+
])
|
|
2761
|
+
);
|
|
2762
|
+
}
|
|
2763
|
+
getQueryState(queryKey) {
|
|
2764
|
+
const options = this.defaultQueryOptions({ queryKey });
|
|
2765
|
+
return __privateGet(this, _queryCache).get(
|
|
2766
|
+
options.queryHash
|
|
2767
|
+
)?.state;
|
|
2768
|
+
}
|
|
2769
|
+
removeQueries(filters) {
|
|
2770
|
+
const queryCache = __privateGet(this, _queryCache);
|
|
2771
|
+
notifyManager.batch(() => {
|
|
2772
|
+
queryCache.findAll(filters).forEach((query) => {
|
|
2773
|
+
queryCache.remove(query);
|
|
2774
|
+
});
|
|
2775
|
+
});
|
|
2776
|
+
}
|
|
2777
|
+
resetQueries(filters, options) {
|
|
2778
|
+
const queryCache = __privateGet(this, _queryCache);
|
|
2779
|
+
return notifyManager.batch(() => {
|
|
2780
|
+
queryCache.findAll(filters).forEach((query) => {
|
|
2781
|
+
query.reset();
|
|
2782
|
+
});
|
|
2783
|
+
return this.refetchQueries(
|
|
2784
|
+
{
|
|
2785
|
+
type: "active",
|
|
2786
|
+
...filters
|
|
2787
|
+
},
|
|
2788
|
+
options
|
|
2789
|
+
);
|
|
2790
|
+
});
|
|
2791
|
+
}
|
|
2792
|
+
cancelQueries(filters, cancelOptions = {}) {
|
|
2793
|
+
const defaultedCancelOptions = { revert: true, ...cancelOptions };
|
|
2794
|
+
const promises = notifyManager.batch(
|
|
2795
|
+
() => __privateGet(this, _queryCache).findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
|
|
2796
|
+
);
|
|
2797
|
+
return Promise.all(promises).then(noop).catch(noop);
|
|
2798
|
+
}
|
|
2799
|
+
invalidateQueries(filters, options = {}) {
|
|
2800
|
+
return notifyManager.batch(() => {
|
|
2801
|
+
__privateGet(this, _queryCache).findAll(filters).forEach((query) => {
|
|
2802
|
+
query.invalidate();
|
|
2803
|
+
});
|
|
2804
|
+
if (filters?.refetchType === "none") {
|
|
2805
|
+
return Promise.resolve();
|
|
2806
|
+
}
|
|
2807
|
+
return this.refetchQueries(
|
|
2808
|
+
{
|
|
2809
|
+
...filters,
|
|
2810
|
+
type: filters?.refetchType ?? filters?.type ?? "active"
|
|
2811
|
+
},
|
|
2812
|
+
options
|
|
2813
|
+
);
|
|
2814
|
+
});
|
|
2815
|
+
}
|
|
2816
|
+
refetchQueries(filters, options = {}) {
|
|
2817
|
+
const fetchOptions = {
|
|
2818
|
+
...options,
|
|
2819
|
+
cancelRefetch: options.cancelRefetch ?? true
|
|
2820
|
+
};
|
|
2821
|
+
const promises = notifyManager.batch(
|
|
2822
|
+
() => __privateGet(this, _queryCache).findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => {
|
|
2823
|
+
let promise = query.fetch(void 0, fetchOptions);
|
|
2824
|
+
if (!fetchOptions.throwOnError) {
|
|
2825
|
+
promise = promise.catch(noop);
|
|
2826
|
+
}
|
|
2827
|
+
return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
|
|
2828
|
+
})
|
|
2829
|
+
);
|
|
2830
|
+
return Promise.all(promises).then(noop);
|
|
2831
|
+
}
|
|
2832
|
+
fetchQuery(options) {
|
|
2833
|
+
const defaultedOptions = this.defaultQueryOptions(options);
|
|
2834
|
+
if (defaultedOptions.retry === void 0) {
|
|
2835
|
+
defaultedOptions.retry = false;
|
|
2836
|
+
}
|
|
2837
|
+
const query = __privateGet(this, _queryCache).build(this, defaultedOptions);
|
|
2838
|
+
return query.isStaleByTime(
|
|
2839
|
+
resolveStaleTime(defaultedOptions.staleTime, query)
|
|
2840
|
+
) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
|
|
2841
|
+
}
|
|
2842
|
+
prefetchQuery(options) {
|
|
2843
|
+
return this.fetchQuery(options).then(noop).catch(noop);
|
|
2844
|
+
}
|
|
2845
|
+
fetchInfiniteQuery(options) {
|
|
2846
|
+
options._type = "infinite";
|
|
2847
|
+
return this.fetchQuery(options);
|
|
2848
|
+
}
|
|
2849
|
+
prefetchInfiniteQuery(options) {
|
|
2850
|
+
return this.fetchInfiniteQuery(options).then(noop).catch(noop);
|
|
2851
|
+
}
|
|
2852
|
+
ensureInfiniteQueryData(options) {
|
|
2853
|
+
options._type = "infinite";
|
|
2854
|
+
return this.ensureQueryData(options);
|
|
2855
|
+
}
|
|
2856
|
+
resumePausedMutations() {
|
|
2857
|
+
if (onlineManager.isOnline()) {
|
|
2858
|
+
return __privateGet(this, _mutationCache2).resumePausedMutations();
|
|
2859
|
+
}
|
|
2860
|
+
return Promise.resolve();
|
|
2861
|
+
}
|
|
2862
|
+
getQueryCache() {
|
|
2863
|
+
return __privateGet(this, _queryCache);
|
|
2864
|
+
}
|
|
2865
|
+
getMutationCache() {
|
|
2866
|
+
return __privateGet(this, _mutationCache2);
|
|
2867
|
+
}
|
|
2868
|
+
getDefaultOptions() {
|
|
2869
|
+
return __privateGet(this, _defaultOptions2);
|
|
2870
|
+
}
|
|
2871
|
+
setDefaultOptions(options) {
|
|
2872
|
+
__privateSet(this, _defaultOptions2, options);
|
|
2873
|
+
}
|
|
2874
|
+
setQueryDefaults(queryKey, options) {
|
|
2875
|
+
__privateGet(this, _queryDefaults).set(hashKey(queryKey), {
|
|
2876
|
+
queryKey,
|
|
2877
|
+
defaultOptions: options
|
|
2878
|
+
});
|
|
2879
|
+
}
|
|
2880
|
+
getQueryDefaults(queryKey) {
|
|
2881
|
+
const defaults = [...__privateGet(this, _queryDefaults).values()];
|
|
2882
|
+
const result = {};
|
|
2883
|
+
defaults.forEach((queryDefault) => {
|
|
2884
|
+
if (partialMatchKey(queryKey, queryDefault.queryKey)) {
|
|
2885
|
+
Object.assign(result, queryDefault.defaultOptions);
|
|
2886
|
+
}
|
|
2887
|
+
});
|
|
2888
|
+
return result;
|
|
2889
|
+
}
|
|
2890
|
+
setMutationDefaults(mutationKey, options) {
|
|
2891
|
+
__privateGet(this, _mutationDefaults).set(hashKey(mutationKey), {
|
|
2892
|
+
mutationKey,
|
|
2893
|
+
defaultOptions: options
|
|
2894
|
+
});
|
|
2895
|
+
}
|
|
2896
|
+
getMutationDefaults(mutationKey) {
|
|
2897
|
+
const defaults = [...__privateGet(this, _mutationDefaults).values()];
|
|
2898
|
+
const result = {};
|
|
2899
|
+
defaults.forEach((queryDefault) => {
|
|
2900
|
+
if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {
|
|
2901
|
+
Object.assign(result, queryDefault.defaultOptions);
|
|
2902
|
+
}
|
|
2903
|
+
});
|
|
2904
|
+
return result;
|
|
2905
|
+
}
|
|
2906
|
+
defaultQueryOptions(options) {
|
|
2907
|
+
if (options._defaulted) {
|
|
2908
|
+
return options;
|
|
2909
|
+
}
|
|
2910
|
+
const defaultedOptions = {
|
|
2911
|
+
...__privateGet(this, _defaultOptions2).queries,
|
|
2912
|
+
...this.getQueryDefaults(options.queryKey),
|
|
2913
|
+
...options,
|
|
2914
|
+
_defaulted: true
|
|
2915
|
+
};
|
|
2916
|
+
if (!defaultedOptions.queryHash) {
|
|
2917
|
+
defaultedOptions.queryHash = hashQueryKeyByOptions(
|
|
2918
|
+
defaultedOptions.queryKey,
|
|
2919
|
+
defaultedOptions
|
|
2920
|
+
);
|
|
2921
|
+
}
|
|
2922
|
+
if (defaultedOptions.refetchOnReconnect === void 0) {
|
|
2923
|
+
defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
|
|
2924
|
+
}
|
|
2925
|
+
if (defaultedOptions.throwOnError === void 0) {
|
|
2926
|
+
defaultedOptions.throwOnError = !!defaultedOptions.suspense;
|
|
2927
|
+
}
|
|
2928
|
+
if (!defaultedOptions.networkMode && defaultedOptions.persister) {
|
|
2929
|
+
defaultedOptions.networkMode = "offlineFirst";
|
|
2930
|
+
}
|
|
2931
|
+
if (defaultedOptions.queryFn === skipToken) {
|
|
2932
|
+
defaultedOptions.enabled = false;
|
|
2933
|
+
}
|
|
2934
|
+
return defaultedOptions;
|
|
2935
|
+
}
|
|
2936
|
+
defaultMutationOptions(options) {
|
|
2937
|
+
if (options?._defaulted) {
|
|
2938
|
+
return options;
|
|
2939
|
+
}
|
|
2940
|
+
return {
|
|
2941
|
+
...__privateGet(this, _defaultOptions2).mutations,
|
|
2942
|
+
...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
|
|
2943
|
+
...options,
|
|
2944
|
+
_defaulted: true
|
|
2945
|
+
};
|
|
2946
|
+
}
|
|
2947
|
+
clear() {
|
|
2948
|
+
__privateGet(this, _queryCache).clear();
|
|
2949
|
+
__privateGet(this, _mutationCache2).clear();
|
|
2950
|
+
}
|
|
2951
|
+
}, _queryCache = new WeakMap(), _mutationCache2 = new WeakMap(), _defaultOptions2 = new WeakMap(), _queryDefaults = new WeakMap(), _mutationDefaults = new WeakMap(), _mountCount = new WeakMap(), _unsubscribeFocus = new WeakMap(), _unsubscribeOnline = new WeakMap(), _a10);
|
|
2952
|
+
|
|
2953
|
+
// node_modules/@tanstack/preact-query/build/modern/IsRestoringProvider.js
|
|
2954
|
+
var IsRestoringContext = R(false);
|
|
2955
|
+
var useIsRestoring = () => x2(IsRestoringContext);
|
|
2956
|
+
var IsRestoringProvider = IsRestoringContext.Provider;
|
|
2957
|
+
|
|
403
2958
|
// node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
|
|
404
2959
|
var f3 = 0;
|
|
405
2960
|
function u3(e3, t3, n2, o3, i3, u4) {
|
|
@@ -411,6 +2966,218 @@
|
|
|
411
2966
|
return l.vnode && l.vnode(l3), l3;
|
|
412
2967
|
}
|
|
413
2968
|
|
|
2969
|
+
// node_modules/@tanstack/preact-query/build/modern/QueryClientProvider.js
|
|
2970
|
+
var QueryClientContext = R(
|
|
2971
|
+
void 0
|
|
2972
|
+
);
|
|
2973
|
+
var useQueryClient = (queryClient) => {
|
|
2974
|
+
const client = x2(QueryClientContext);
|
|
2975
|
+
if (queryClient) {
|
|
2976
|
+
return queryClient;
|
|
2977
|
+
}
|
|
2978
|
+
if (!client) {
|
|
2979
|
+
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
2980
|
+
}
|
|
2981
|
+
return client;
|
|
2982
|
+
};
|
|
2983
|
+
var QueryClientProvider = ({
|
|
2984
|
+
client,
|
|
2985
|
+
children
|
|
2986
|
+
}) => {
|
|
2987
|
+
y2(() => {
|
|
2988
|
+
client.mount();
|
|
2989
|
+
return () => {
|
|
2990
|
+
client.unmount();
|
|
2991
|
+
};
|
|
2992
|
+
}, [client]);
|
|
2993
|
+
return /* @__PURE__ */ u3(QueryClientContext.Provider, { value: client, children });
|
|
2994
|
+
};
|
|
2995
|
+
|
|
2996
|
+
// node_modules/@tanstack/preact-query/build/modern/QueryErrorResetBoundary.js
|
|
2997
|
+
function createValue() {
|
|
2998
|
+
let isReset = false;
|
|
2999
|
+
return {
|
|
3000
|
+
clearReset: () => {
|
|
3001
|
+
isReset = false;
|
|
3002
|
+
},
|
|
3003
|
+
reset: () => {
|
|
3004
|
+
isReset = true;
|
|
3005
|
+
},
|
|
3006
|
+
isReset: () => {
|
|
3007
|
+
return isReset;
|
|
3008
|
+
}
|
|
3009
|
+
};
|
|
3010
|
+
}
|
|
3011
|
+
var QueryErrorResetBoundaryContext = R(createValue());
|
|
3012
|
+
var useQueryErrorResetBoundary = () => x2(QueryErrorResetBoundaryContext);
|
|
3013
|
+
|
|
3014
|
+
// node_modules/@tanstack/preact-query/build/modern/errorBoundaryUtils.js
|
|
3015
|
+
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
|
|
3016
|
+
if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) {
|
|
3017
|
+
if (!errorResetBoundary.isReset()) {
|
|
3018
|
+
options.retryOnMount = false;
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
};
|
|
3022
|
+
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
3023
|
+
y2(() => {
|
|
3024
|
+
errorResetBoundary.clearReset();
|
|
3025
|
+
}, [errorResetBoundary]);
|
|
3026
|
+
};
|
|
3027
|
+
var getHasError = ({
|
|
3028
|
+
result,
|
|
3029
|
+
errorResetBoundary,
|
|
3030
|
+
throwOnError,
|
|
3031
|
+
query,
|
|
3032
|
+
suspense
|
|
3033
|
+
}) => {
|
|
3034
|
+
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
|
|
3035
|
+
};
|
|
3036
|
+
|
|
3037
|
+
// node_modules/@tanstack/preact-query/build/modern/suspense.js
|
|
3038
|
+
var ensureSuspenseTimers = (defaultedOptions) => {
|
|
3039
|
+
if (defaultedOptions.suspense) {
|
|
3040
|
+
const MIN_SUSPENSE_TIME_MS = 1e3;
|
|
3041
|
+
const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
|
|
3042
|
+
const originalStaleTime = defaultedOptions.staleTime;
|
|
3043
|
+
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
|
|
3044
|
+
if (typeof defaultedOptions.gcTime === "number") {
|
|
3045
|
+
defaultedOptions.gcTime = Math.max(
|
|
3046
|
+
defaultedOptions.gcTime,
|
|
3047
|
+
MIN_SUSPENSE_TIME_MS
|
|
3048
|
+
);
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
};
|
|
3052
|
+
var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
|
|
3053
|
+
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
|
|
3054
|
+
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
3055
|
+
errorResetBoundary.clearReset();
|
|
3056
|
+
});
|
|
3057
|
+
|
|
3058
|
+
// node_modules/@tanstack/preact-query/build/modern/utils.js
|
|
3059
|
+
function useSyncExternalStore(subscribe, getSnapshot) {
|
|
3060
|
+
const value = getSnapshot();
|
|
3061
|
+
const [{ _instance }, forceUpdate] = d2({
|
|
3062
|
+
_instance: { _value: value, _getSnapshot: getSnapshot }
|
|
3063
|
+
});
|
|
3064
|
+
_2(() => {
|
|
3065
|
+
_instance._value = value;
|
|
3066
|
+
_instance._getSnapshot = getSnapshot;
|
|
3067
|
+
if (didSnapshotChange(_instance)) {
|
|
3068
|
+
forceUpdate({ _instance });
|
|
3069
|
+
}
|
|
3070
|
+
}, [subscribe, value, getSnapshot]);
|
|
3071
|
+
y2(() => {
|
|
3072
|
+
if (didSnapshotChange(_instance)) {
|
|
3073
|
+
forceUpdate({ _instance });
|
|
3074
|
+
}
|
|
3075
|
+
return subscribe(() => {
|
|
3076
|
+
if (didSnapshotChange(_instance)) {
|
|
3077
|
+
forceUpdate({ _instance });
|
|
3078
|
+
}
|
|
3079
|
+
});
|
|
3080
|
+
}, [subscribe]);
|
|
3081
|
+
return value;
|
|
3082
|
+
}
|
|
3083
|
+
function didSnapshotChange(inst) {
|
|
3084
|
+
const latestGetSnapshot = inst._getSnapshot;
|
|
3085
|
+
const prevValue = inst._value;
|
|
3086
|
+
try {
|
|
3087
|
+
const nextValue = latestGetSnapshot();
|
|
3088
|
+
return !Object.is(prevValue, nextValue);
|
|
3089
|
+
} catch (_error) {
|
|
3090
|
+
return true;
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
// node_modules/@tanstack/preact-query/build/modern/useBaseQuery.js
|
|
3095
|
+
function useBaseQuery(options, Observer, queryClient) {
|
|
3096
|
+
if (true) {
|
|
3097
|
+
if (typeof options !== "object" || Array.isArray(options)) {
|
|
3098
|
+
throw new Error(
|
|
3099
|
+
'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'
|
|
3100
|
+
);
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
const isRestoring = useIsRestoring();
|
|
3104
|
+
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
3105
|
+
const client = useQueryClient(queryClient);
|
|
3106
|
+
const defaultedOptions = client.defaultQueryOptions(options);
|
|
3107
|
+
client.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
3108
|
+
defaultedOptions
|
|
3109
|
+
);
|
|
3110
|
+
if (true) {
|
|
3111
|
+
if (!defaultedOptions.queryFn) {
|
|
3112
|
+
console.error(
|
|
3113
|
+
`[${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`
|
|
3114
|
+
);
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
3118
|
+
ensureSuspenseTimers(defaultedOptions);
|
|
3119
|
+
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
3120
|
+
useClearResetErrorBoundary(errorResetBoundary);
|
|
3121
|
+
const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
|
|
3122
|
+
const [observer] = d2(
|
|
3123
|
+
() => new Observer(
|
|
3124
|
+
client,
|
|
3125
|
+
defaultedOptions
|
|
3126
|
+
)
|
|
3127
|
+
);
|
|
3128
|
+
const result = observer.getOptimisticResult(defaultedOptions);
|
|
3129
|
+
const shouldSubscribe = !isRestoring && options.subscribed !== false;
|
|
3130
|
+
useSyncExternalStore(
|
|
3131
|
+
q2(
|
|
3132
|
+
(onStoreChange) => {
|
|
3133
|
+
const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;
|
|
3134
|
+
observer.updateResult();
|
|
3135
|
+
return unsubscribe;
|
|
3136
|
+
},
|
|
3137
|
+
[observer, shouldSubscribe]
|
|
3138
|
+
),
|
|
3139
|
+
() => observer.getCurrentResult()
|
|
3140
|
+
);
|
|
3141
|
+
y2(() => {
|
|
3142
|
+
observer.setOptions(defaultedOptions);
|
|
3143
|
+
}, [defaultedOptions, observer]);
|
|
3144
|
+
if (shouldSuspend(defaultedOptions, result)) {
|
|
3145
|
+
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
3146
|
+
}
|
|
3147
|
+
if (getHasError({
|
|
3148
|
+
result,
|
|
3149
|
+
errorResetBoundary,
|
|
3150
|
+
throwOnError: defaultedOptions.throwOnError,
|
|
3151
|
+
query: client.getQueryCache().get(defaultedOptions.queryHash),
|
|
3152
|
+
suspense: defaultedOptions.suspense
|
|
3153
|
+
})) {
|
|
3154
|
+
throw result.error;
|
|
3155
|
+
}
|
|
3156
|
+
;
|
|
3157
|
+
client.getDefaultOptions().queries?._experimental_afterQuery?.(
|
|
3158
|
+
defaultedOptions,
|
|
3159
|
+
result
|
|
3160
|
+
);
|
|
3161
|
+
if (defaultedOptions.experimental_prefetchInRender && !environmentManager.isServer() && willFetch(result, isRestoring)) {
|
|
3162
|
+
const promise = isNewCacheEntry ? (
|
|
3163
|
+
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
3164
|
+
fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
|
|
3165
|
+
) : (
|
|
3166
|
+
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
3167
|
+
client.getQueryCache().get(defaultedOptions.queryHash)?.promise
|
|
3168
|
+
);
|
|
3169
|
+
promise?.catch(noop).finally(() => {
|
|
3170
|
+
observer.updateResult();
|
|
3171
|
+
});
|
|
3172
|
+
}
|
|
3173
|
+
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
3174
|
+
}
|
|
3175
|
+
|
|
3176
|
+
// node_modules/@tanstack/preact-query/build/modern/useQuery.js
|
|
3177
|
+
function useQuery(options, queryClient) {
|
|
3178
|
+
return useBaseQuery(options, QueryObserver, queryClient);
|
|
3179
|
+
}
|
|
3180
|
+
|
|
414
3181
|
// app/assets/typescript/profiler/components/toolbar/ToolbarItem.tsx
|
|
415
3182
|
function ToolbarItem({ children, panel, href, className, panelLarge }) {
|
|
416
3183
|
const [visible, setVisible] = d2(false);
|
|
@@ -1379,6 +4146,52 @@
|
|
|
1379
4146
|
] }) });
|
|
1380
4147
|
}
|
|
1381
4148
|
|
|
4149
|
+
// app/assets/typescript/profiler/api-fetcher.ts
|
|
4150
|
+
async function apiFetch(config) {
|
|
4151
|
+
const { url, method, params, data, headers = {}, signal } = config;
|
|
4152
|
+
const qs = params ? "?" + new URLSearchParams(Object.entries(params).map(([k3, v3]) => [k3, String(v3)])).toString() : "";
|
|
4153
|
+
const res = await fetch(url + qs, {
|
|
4154
|
+
method,
|
|
4155
|
+
signal,
|
|
4156
|
+
headers: data !== void 0 ? { "Content-Type": "application/json", ...headers } : headers,
|
|
4157
|
+
body: data !== void 0 ? JSON.stringify(data) : void 0
|
|
4158
|
+
});
|
|
4159
|
+
if (res.status === 204) return {};
|
|
4160
|
+
const json = await res.json();
|
|
4161
|
+
if (!res.ok) {
|
|
4162
|
+
throw Object.assign(new Error(json?.error ?? `HTTP ${res.status}`), { status: res.status, data: json });
|
|
4163
|
+
}
|
|
4164
|
+
return json;
|
|
4165
|
+
}
|
|
4166
|
+
|
|
4167
|
+
// app/assets/typescript/profiler/generated/api.ts
|
|
4168
|
+
var getToolbar = (token, signal) => {
|
|
4169
|
+
return apiFetch(
|
|
4170
|
+
{
|
|
4171
|
+
url: `/_profiler/api/toolbar/${token}`,
|
|
4172
|
+
method: "GET",
|
|
4173
|
+
signal
|
|
4174
|
+
}
|
|
4175
|
+
);
|
|
4176
|
+
};
|
|
4177
|
+
var getGetToolbarQueryKey = (token) => {
|
|
4178
|
+
return [
|
|
4179
|
+
`/_profiler/api/toolbar/${token}`
|
|
4180
|
+
];
|
|
4181
|
+
};
|
|
4182
|
+
var getGetToolbarQueryOptions = (token, options) => {
|
|
4183
|
+
const { query: queryOptions } = options ?? {};
|
|
4184
|
+
const queryKey = queryOptions?.queryKey ?? getGetToolbarQueryKey(token);
|
|
4185
|
+
const queryFn = ({ signal }) => getToolbar(token, signal);
|
|
4186
|
+
return { queryKey, queryFn, enabled: !!token, ...queryOptions };
|
|
4187
|
+
};
|
|
4188
|
+
function useGetToolbar(token, options) {
|
|
4189
|
+
const queryOptions = getGetToolbarQueryOptions(token, options);
|
|
4190
|
+
const query = useQuery(queryOptions);
|
|
4191
|
+
query.queryKey = queryOptions.queryKey;
|
|
4192
|
+
return query;
|
|
4193
|
+
}
|
|
4194
|
+
|
|
1382
4195
|
// app/assets/typescript/profiler/toolbar-bundle.tsx
|
|
1383
4196
|
var ANIM_MS = 280;
|
|
1384
4197
|
function applyTheme(elements) {
|
|
@@ -1386,17 +4199,17 @@
|
|
|
1386
4199
|
const theme = stored === "light" ? "light" : stored === "dark" ? "dark" : window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
|
|
1387
4200
|
elements.forEach((el) => el.setAttribute("data-theme", theme));
|
|
1388
4201
|
}
|
|
4202
|
+
var toolbarQueryClient = new QueryClient({
|
|
4203
|
+
defaultOptions: { queries: { staleTime: 3e4, retry: 1 } }
|
|
4204
|
+
});
|
|
1389
4205
|
function ToolbarMount({ token }) {
|
|
1390
|
-
const
|
|
4206
|
+
const { data, refetch } = useGetToolbar(token, { query: { refetchOnWindowFocus: false } });
|
|
1391
4207
|
y2(() => {
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
if (data.profile) setProfile(data.profile);
|
|
1395
|
-
}).catch((err) => console.debug("Profiler toolbar load failed:", err));
|
|
4208
|
+
window.__PROFILER_REFRESH_TOOLBAR__ = () => {
|
|
4209
|
+
refetch();
|
|
1396
4210
|
};
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
}, [token]);
|
|
4211
|
+
}, [refetch]);
|
|
4212
|
+
const profile = data?.profile ?? null;
|
|
1400
4213
|
if (!profile) return null;
|
|
1401
4214
|
return /* @__PURE__ */ u3(ToolbarApp, { profile, token });
|
|
1402
4215
|
}
|
|
@@ -1452,7 +4265,10 @@
|
|
|
1452
4265
|
toggleCollapse();
|
|
1453
4266
|
}
|
|
1454
4267
|
});
|
|
1455
|
-
J(
|
|
4268
|
+
J(
|
|
4269
|
+
/* @__PURE__ */ u3(QueryClientProvider, { client: toolbarQueryClient, children: /* @__PURE__ */ u3(ToolbarMount, { token }) }),
|
|
4270
|
+
el
|
|
4271
|
+
);
|
|
1456
4272
|
}
|
|
1457
4273
|
if (document.readyState === "loading") {
|
|
1458
4274
|
document.addEventListener("DOMContentLoaded", mountToolbar);
|