@scrippsproduct/networks-ui-library 1.1.0-alpha.8 → 1.1.0-alpha.9
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.
|
@@ -13,8 +13,9 @@ var Ht = (e, t, s, i) => ({
|
|
|
13
13
|
});
|
|
14
14
|
import { jsx as Bt } from "react/jsx-runtime";
|
|
15
15
|
import * as K from "react";
|
|
16
|
-
import { createContext as
|
|
16
|
+
import { createContext as ze, useState as pe, useRef as $e, useCallback as We, useEffect as Je, useMemo as Ze } from "react";
|
|
17
17
|
import { f as Wt } from "../../format-YhWt2D8M.mjs";
|
|
18
|
+
import { l as me } from "../../logger-C0N7U0YY.mjs";
|
|
18
19
|
var Kt = class {
|
|
19
20
|
constructor() {
|
|
20
21
|
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
|
|
@@ -31,7 +32,7 @@ var Kt = class {
|
|
|
31
32
|
}
|
|
32
33
|
onUnsubscribe() {
|
|
33
34
|
}
|
|
34
|
-
},
|
|
35
|
+
}, Xe = {
|
|
35
36
|
// We need the wrapper function syntax below instead of direct references to
|
|
36
37
|
// global setTimeout etc.
|
|
37
38
|
//
|
|
@@ -46,7 +47,7 @@ var Kt = class {
|
|
|
46
47
|
clearTimeout: (e) => clearTimeout(e),
|
|
47
48
|
setInterval: (e, t) => setInterval(e, t),
|
|
48
49
|
clearInterval: (e) => clearInterval(e)
|
|
49
|
-
}, G, ht,
|
|
50
|
+
}, G, ht, Me, Ye = (Me = class {
|
|
50
51
|
constructor() {
|
|
51
52
|
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete
|
|
52
53
|
// type at app boot; and if we leave that type, then any new timer provider
|
|
@@ -54,7 +55,7 @@ var Kt = class {
|
|
|
54
55
|
//
|
|
55
56
|
// We settle for type safety for the TimeoutProvider type, and accept that
|
|
56
57
|
// this class is unsafe internally to allow for extension.
|
|
57
|
-
c(this, G,
|
|
58
|
+
c(this, G, Xe);
|
|
58
59
|
c(this, ht, !1);
|
|
59
60
|
}
|
|
60
61
|
setTimeoutProvider(e) {
|
|
@@ -75,20 +76,20 @@ var Kt = class {
|
|
|
75
76
|
clearInterval(e) {
|
|
76
77
|
r(this, G).clearInterval(e);
|
|
77
78
|
}
|
|
78
|
-
}, G = new WeakMap(), ht = new WeakMap(),
|
|
79
|
-
function
|
|
79
|
+
}, G = new WeakMap(), ht = new WeakMap(), Me), ut = new Ye();
|
|
80
|
+
function ts(e) {
|
|
80
81
|
setTimeout(e, 0);
|
|
81
82
|
}
|
|
82
83
|
var bt = typeof window > "u" || "Deno" in globalThis;
|
|
83
84
|
function j() {
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
+
function es(e, t) {
|
|
86
87
|
return typeof e == "function" ? e(t) : e;
|
|
87
88
|
}
|
|
88
89
|
function Jt(e) {
|
|
89
90
|
return typeof e == "number" && e >= 0 && e !== 1 / 0;
|
|
90
91
|
}
|
|
91
|
-
function
|
|
92
|
+
function Ne(e, t) {
|
|
92
93
|
return Math.max(e + (t || 0) - Date.now(), 0);
|
|
93
94
|
}
|
|
94
95
|
function ot(e, t) {
|
|
@@ -97,7 +98,7 @@ function ot(e, t) {
|
|
|
97
98
|
function k(e, t) {
|
|
98
99
|
return typeof e == "function" ? e(t) : e;
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
+
function ve(e, t) {
|
|
101
102
|
const {
|
|
102
103
|
type: s = "all",
|
|
103
104
|
exact: i,
|
|
@@ -120,7 +121,7 @@ function me(e, t) {
|
|
|
120
121
|
}
|
|
121
122
|
return !(typeof u == "boolean" && t.isStale() !== u || n && n !== t.state.fetchStatus || a && !a(t));
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
+
function ge(e, t) {
|
|
124
125
|
const { exact: s, status: i, predicate: n, mutationKey: a } = e;
|
|
125
126
|
if (a) {
|
|
126
127
|
if (!t.options.mutationKey)
|
|
@@ -145,26 +146,26 @@ function At(e) {
|
|
|
145
146
|
function xt(e, t) {
|
|
146
147
|
return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? Object.keys(t).every((s) => xt(e[s], t[s])) : !1;
|
|
147
148
|
}
|
|
148
|
-
var
|
|
149
|
+
var ss = Object.prototype.hasOwnProperty;
|
|
149
150
|
function Zt(e, t) {
|
|
150
151
|
if (e === t)
|
|
151
152
|
return e;
|
|
152
|
-
const s =
|
|
153
|
+
const s = be(e) && be(t);
|
|
153
154
|
if (!s && !(Yt(e) && Yt(t))) return t;
|
|
154
155
|
const n = (s ? e : Object.keys(e)).length, a = s ? t : Object.keys(t), h = a.length, u = s ? new Array(h) : {};
|
|
155
156
|
let d = 0;
|
|
156
157
|
for (let b = 0; b < h; b++) {
|
|
157
|
-
const
|
|
158
|
+
const S = s ? b : a[b], f = e[S], O = t[S];
|
|
158
159
|
if (f === O) {
|
|
159
|
-
u[
|
|
160
|
+
u[S] = f, (s ? b < n : ss.call(e, S)) && d++;
|
|
160
161
|
continue;
|
|
161
162
|
}
|
|
162
163
|
if (f === null || O === null || typeof f != "object" || typeof O != "object") {
|
|
163
|
-
u[
|
|
164
|
+
u[S] = O;
|
|
164
165
|
continue;
|
|
165
166
|
}
|
|
166
167
|
const y = Zt(f, O);
|
|
167
|
-
u[
|
|
168
|
+
u[S] = y, y === f && d++;
|
|
168
169
|
}
|
|
169
170
|
return n === h && d === n ? e : u;
|
|
170
171
|
}
|
|
@@ -176,22 +177,22 @@ function Xt(e, t) {
|
|
|
176
177
|
return !1;
|
|
177
178
|
return !0;
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
+
function be(e) {
|
|
180
181
|
return Array.isArray(e) && e.length === Object.keys(e).length;
|
|
181
182
|
}
|
|
182
183
|
function Yt(e) {
|
|
183
|
-
if (!
|
|
184
|
+
if (!we(e))
|
|
184
185
|
return !1;
|
|
185
186
|
const t = e.constructor;
|
|
186
187
|
if (t === void 0)
|
|
187
188
|
return !0;
|
|
188
189
|
const s = t.prototype;
|
|
189
|
-
return !(!
|
|
190
|
+
return !(!we(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
|
|
190
191
|
}
|
|
191
|
-
function
|
|
192
|
+
function we(e) {
|
|
192
193
|
return Object.prototype.toString.call(e) === "[object Object]";
|
|
193
194
|
}
|
|
194
|
-
function
|
|
195
|
+
function rs(e) {
|
|
195
196
|
return new Promise((t) => {
|
|
196
197
|
ut.setTimeout(t, e);
|
|
197
198
|
});
|
|
@@ -212,30 +213,30 @@ function te(e, t, s) {
|
|
|
212
213
|
}
|
|
213
214
|
return t;
|
|
214
215
|
}
|
|
215
|
-
function
|
|
216
|
+
function is(e, t, s = 0) {
|
|
216
217
|
const i = [...e, t];
|
|
217
218
|
return s && i.length > s ? i.slice(1) : i;
|
|
218
219
|
}
|
|
219
|
-
function
|
|
220
|
+
function ns(e, t, s = 0) {
|
|
220
221
|
const i = [t, ...e];
|
|
221
222
|
return s && i.length > s ? i.slice(0, -1) : i;
|
|
222
223
|
}
|
|
223
224
|
var Vt = Symbol();
|
|
224
|
-
function
|
|
225
|
+
function _e(e, t) {
|
|
225
226
|
return process.env.NODE_ENV !== "production" && e.queryFn === Vt && console.error(
|
|
226
227
|
`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`
|
|
227
228
|
), !e.queryFn && (t != null && t.initialPromise) ? () => t.initialPromise : !e.queryFn || e.queryFn === Vt ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
|
|
228
229
|
}
|
|
229
|
-
function
|
|
230
|
+
function as(e, t) {
|
|
230
231
|
return typeof e == "function" ? e(...t) : !!e;
|
|
231
232
|
}
|
|
232
|
-
var ct, tt,
|
|
233
|
+
var ct, tt, Ct, Qe, os = (Qe = class extends Kt {
|
|
233
234
|
constructor() {
|
|
234
235
|
super();
|
|
235
236
|
c(this, ct);
|
|
236
237
|
c(this, tt);
|
|
237
|
-
c(this,
|
|
238
|
-
o(this,
|
|
238
|
+
c(this, Ct);
|
|
239
|
+
o(this, Ct, (t) => {
|
|
239
240
|
if (!bt && window.addEventListener) {
|
|
240
241
|
const s = () => t();
|
|
241
242
|
return window.addEventListener("visibilitychange", s, !1), () => {
|
|
@@ -245,7 +246,7 @@ var ct, tt, St, Me, as = (Me = class extends Kt {
|
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
248
|
onSubscribe() {
|
|
248
|
-
r(this, tt) || this.setEventListener(r(this,
|
|
249
|
+
r(this, tt) || this.setEventListener(r(this, Ct));
|
|
249
250
|
}
|
|
250
251
|
onUnsubscribe() {
|
|
251
252
|
var t;
|
|
@@ -253,7 +254,7 @@ var ct, tt, St, Me, as = (Me = class extends Kt {
|
|
|
253
254
|
}
|
|
254
255
|
setEventListener(t) {
|
|
255
256
|
var s;
|
|
256
|
-
o(this,
|
|
257
|
+
o(this, Ct, t), (s = r(this, tt)) == null || s.call(this), o(this, tt, t((i) => {
|
|
257
258
|
typeof i == "boolean" ? this.setFocused(i) : this.onFocus();
|
|
258
259
|
}));
|
|
259
260
|
}
|
|
@@ -270,7 +271,7 @@ var ct, tt, St, Me, as = (Me = class extends Kt {
|
|
|
270
271
|
var t;
|
|
271
272
|
return typeof r(this, ct) == "boolean" ? r(this, ct) : ((t = globalThis.document) == null ? void 0 : t.visibilityState) !== "hidden";
|
|
272
273
|
}
|
|
273
|
-
}, ct = new WeakMap(), tt = new WeakMap(),
|
|
274
|
+
}, ct = new WeakMap(), tt = new WeakMap(), Ct = new WeakMap(), Qe), de = new os();
|
|
274
275
|
function ee() {
|
|
275
276
|
let e, t;
|
|
276
277
|
const s = new Promise((n, a) => {
|
|
@@ -293,13 +294,13 @@ function ee() {
|
|
|
293
294
|
}), t(n);
|
|
294
295
|
}, s;
|
|
295
296
|
}
|
|
296
|
-
var
|
|
297
|
-
function
|
|
297
|
+
var us = ts;
|
|
298
|
+
function hs() {
|
|
298
299
|
let e = [], t = 0, s = (u) => {
|
|
299
300
|
u();
|
|
300
301
|
}, i = (u) => {
|
|
301
302
|
u();
|
|
302
|
-
}, n =
|
|
303
|
+
}, n = us;
|
|
303
304
|
const a = (u) => {
|
|
304
305
|
t ? e.push(u) : n(() => {
|
|
305
306
|
s(u);
|
|
@@ -353,10 +354,10 @@ function us() {
|
|
|
353
354
|
}
|
|
354
355
|
};
|
|
355
356
|
}
|
|
356
|
-
var T =
|
|
357
|
+
var T = hs(), St, et, Ot, De, cs = (De = class extends Kt {
|
|
357
358
|
constructor() {
|
|
358
359
|
super();
|
|
359
|
-
c(this,
|
|
360
|
+
c(this, St, !0);
|
|
360
361
|
c(this, et);
|
|
361
362
|
c(this, Ot);
|
|
362
363
|
o(this, Ot, (t) => {
|
|
@@ -380,18 +381,18 @@ var T = us(), Ct, et, Ot, Qe, hs = (Qe = class extends Kt {
|
|
|
380
381
|
o(this, Ot, t), (s = r(this, et)) == null || s.call(this), o(this, et, t(this.setOnline.bind(this)));
|
|
381
382
|
}
|
|
382
383
|
setOnline(t) {
|
|
383
|
-
r(this,
|
|
384
|
+
r(this, St) !== t && (o(this, St, t), this.listeners.forEach((i) => {
|
|
384
385
|
i(t);
|
|
385
386
|
}));
|
|
386
387
|
}
|
|
387
388
|
isOnline() {
|
|
388
|
-
return r(this,
|
|
389
|
+
return r(this, St);
|
|
389
390
|
}
|
|
390
|
-
},
|
|
391
|
-
function
|
|
391
|
+
}, St = new WeakMap(), et = new WeakMap(), Ot = new WeakMap(), De), zt = new cs();
|
|
392
|
+
function ls(e) {
|
|
392
393
|
return Math.min(1e3 * 2 ** e, 3e4);
|
|
393
394
|
}
|
|
394
|
-
function
|
|
395
|
+
function ke(e) {
|
|
395
396
|
return (e ?? "online") === "online" ? zt.isOnline() : !0;
|
|
396
397
|
}
|
|
397
398
|
var se = class extends Error {
|
|
@@ -399,7 +400,7 @@ var se = class extends Error {
|
|
|
399
400
|
super("CancelledError"), this.revert = e == null ? void 0 : e.revert, this.silent = e == null ? void 0 : e.silent;
|
|
400
401
|
}
|
|
401
402
|
};
|
|
402
|
-
function
|
|
403
|
+
function Ke(e) {
|
|
403
404
|
let t = !1, s = 0, i;
|
|
404
405
|
const n = ee(), a = () => n.status !== "pending", h = (p) => {
|
|
405
406
|
var m;
|
|
@@ -411,7 +412,7 @@ function ke(e) {
|
|
|
411
412
|
t = !0;
|
|
412
413
|
}, d = () => {
|
|
413
414
|
t = !1;
|
|
414
|
-
}, b = () => de.isFocused() && (e.networkMode === "always" || zt.isOnline()) && e.canRun(),
|
|
415
|
+
}, b = () => de.isFocused() && (e.networkMode === "always" || zt.isOnline()) && e.canRun(), S = () => ke(e.networkMode) && e.canRun(), f = (p) => {
|
|
415
416
|
a() || (i == null || i(), n.resolve(p));
|
|
416
417
|
}, O = (p) => {
|
|
417
418
|
a() || (i == null || i(), n.reject(p));
|
|
@@ -437,12 +438,12 @@ function ke(e) {
|
|
|
437
438
|
var x;
|
|
438
439
|
if (a())
|
|
439
440
|
return;
|
|
440
|
-
const M = e.retry ?? (bt ? 0 : 3), E = e.retryDelay ??
|
|
441
|
+
const M = e.retry ?? (bt ? 0 : 3), E = e.retryDelay ?? ls, l = typeof E == "function" ? E(s, P) : E, Q = M === !0 || typeof M == "number" && s < M || typeof M == "function" && M(s, P);
|
|
441
442
|
if (t || !Q) {
|
|
442
443
|
O(P);
|
|
443
444
|
return;
|
|
444
445
|
}
|
|
445
|
-
s++, (x = e.onFail) == null || x.call(e, s, P),
|
|
446
|
+
s++, (x = e.onFail) == null || x.call(e, s, P), rs(l).then(() => b() ? void 0 : y()).then(() => {
|
|
446
447
|
t ? O(P) : R();
|
|
447
448
|
});
|
|
448
449
|
});
|
|
@@ -454,11 +455,11 @@ function ke(e) {
|
|
|
454
455
|
continue: () => (i == null || i(), n),
|
|
455
456
|
cancelRetry: u,
|
|
456
457
|
continueRetry: d,
|
|
457
|
-
canStart:
|
|
458
|
-
start: () => (
|
|
458
|
+
canStart: S,
|
|
459
|
+
start: () => (S() ? R() : y().then(R), n)
|
|
459
460
|
};
|
|
460
461
|
}
|
|
461
|
-
var lt,
|
|
462
|
+
var lt, Te, Le = (Te = class {
|
|
462
463
|
constructor() {
|
|
463
464
|
c(this, lt);
|
|
464
465
|
}
|
|
@@ -479,7 +480,7 @@ var lt, De, Ke = (De = class {
|
|
|
479
480
|
clearGcTimeout() {
|
|
480
481
|
r(this, lt) && (ut.clearTimeout(r(this, lt)), o(this, lt, void 0));
|
|
481
482
|
}
|
|
482
|
-
}, lt = new WeakMap(),
|
|
483
|
+
}, lt = new WeakMap(), Te), dt, Pt, _, ft, D, Ut, yt, L, $, Ie, ds = (Ie = class extends Le {
|
|
483
484
|
constructor(t) {
|
|
484
485
|
super();
|
|
485
486
|
c(this, L);
|
|
@@ -503,7 +504,7 @@ var lt, De, Ke = (De = class {
|
|
|
503
504
|
if (this.options = { ...r(this, Ut), ...t }, this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
|
|
504
505
|
const s = Se(this.options);
|
|
505
506
|
s.data !== void 0 && (this.setState(
|
|
506
|
-
|
|
507
|
+
Ce(s.data, s.dataUpdatedAt)
|
|
507
508
|
), o(this, dt, s));
|
|
508
509
|
}
|
|
509
510
|
}
|
|
@@ -552,7 +553,7 @@ var lt, De, Ke = (De = class {
|
|
|
552
553
|
) : this.state.data === void 0 || this.state.isInvalidated;
|
|
553
554
|
}
|
|
554
555
|
isStaleByTime(t = 0) {
|
|
555
|
-
return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !
|
|
556
|
+
return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !Ne(this.state.dataUpdatedAt, t);
|
|
556
557
|
}
|
|
557
558
|
onFocus() {
|
|
558
559
|
var s;
|
|
@@ -577,7 +578,7 @@ var lt, De, Ke = (De = class {
|
|
|
577
578
|
this.state.isInvalidated || v(this, L, $).call(this, { type: "invalidate" });
|
|
578
579
|
}
|
|
579
580
|
async fetch(t, s) {
|
|
580
|
-
var d, b,
|
|
581
|
+
var d, b, S, f, O, y, R, p, m, P, M, E;
|
|
581
582
|
if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
|
|
582
583
|
// re-start the fetch; there is a chance that the query is still in a
|
|
583
584
|
// pending state when that happens
|
|
@@ -600,7 +601,7 @@ var lt, De, Ke = (De = class {
|
|
|
600
601
|
get: () => (o(this, yt, !0), i.signal)
|
|
601
602
|
});
|
|
602
603
|
}, a = () => {
|
|
603
|
-
const l =
|
|
604
|
+
const l = _e(this.options, s), x = (() => {
|
|
604
605
|
const Z = {
|
|
605
606
|
client: r(this, ft),
|
|
606
607
|
queryKey: this.queryKey,
|
|
@@ -624,7 +625,7 @@ var lt, De, Ke = (De = class {
|
|
|
624
625
|
};
|
|
625
626
|
return n(l), l;
|
|
626
627
|
})();
|
|
627
|
-
(b = this.options.behavior) == null || b.onFetch(u, this), o(this, Pt, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((
|
|
628
|
+
(b = this.options.behavior) == null || b.onFetch(u, this), o(this, Pt, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((S = u.fetchOptions) == null ? void 0 : S.meta)) && v(this, L, $).call(this, { type: "fetch", meta: (f = u.fetchOptions) == null ? void 0 : f.meta }), o(this, D, Ke({
|
|
628
629
|
initialPromise: s == null ? void 0 : s.initialPromise,
|
|
629
630
|
fn: u.fetchFn,
|
|
630
631
|
onCancel: (l) => {
|
|
@@ -708,13 +709,13 @@ var lt, De, Ke = (De = class {
|
|
|
708
709
|
case "fetch":
|
|
709
710
|
return {
|
|
710
711
|
...i,
|
|
711
|
-
...
|
|
712
|
+
...He(i.data, this.options),
|
|
712
713
|
fetchMeta: t.meta ?? null
|
|
713
714
|
};
|
|
714
715
|
case "success":
|
|
715
716
|
const n = {
|
|
716
717
|
...i,
|
|
717
|
-
...
|
|
718
|
+
...Ce(t.data, t.dataUpdatedAt),
|
|
718
719
|
dataUpdateCount: i.dataUpdateCount + 1,
|
|
719
720
|
...!t.manual && {
|
|
720
721
|
fetchStatus: "idle",
|
|
@@ -752,19 +753,19 @@ var lt, De, Ke = (De = class {
|
|
|
752
753
|
i.onQueryUpdate();
|
|
753
754
|
}), r(this, _).notify({ query: this, type: "updated", action: t });
|
|
754
755
|
});
|
|
755
|
-
},
|
|
756
|
-
function
|
|
756
|
+
}, Ie);
|
|
757
|
+
function He(e, t) {
|
|
757
758
|
return {
|
|
758
759
|
fetchFailureCount: 0,
|
|
759
760
|
fetchFailureReason: null,
|
|
760
|
-
fetchStatus:
|
|
761
|
+
fetchStatus: ke(t.networkMode) ? "fetching" : "paused",
|
|
761
762
|
...e === void 0 && {
|
|
762
763
|
error: null,
|
|
763
764
|
status: "pending"
|
|
764
765
|
}
|
|
765
766
|
};
|
|
766
767
|
}
|
|
767
|
-
function
|
|
768
|
+
function Ce(e, t) {
|
|
768
769
|
return {
|
|
769
770
|
data: e,
|
|
770
771
|
dataUpdatedAt: t ?? Date.now(),
|
|
@@ -790,10 +791,10 @@ function Se(e) {
|
|
|
790
791
|
fetchStatus: "idle"
|
|
791
792
|
};
|
|
792
793
|
}
|
|
793
|
-
var U, g, jt, q, pt, Et, W, st, Nt, Ft, Rt, mt, vt, rt, Mt,
|
|
794
|
+
var U, g, jt, q, pt, Et, W, st, Nt, Ft, Rt, mt, vt, rt, Mt, C, qt, re, ie, ne, ae, oe, ue, he, Ge, qe, fs = (qe = class extends Kt {
|
|
794
795
|
constructor(t, s) {
|
|
795
796
|
super();
|
|
796
|
-
c(this,
|
|
797
|
+
c(this, C);
|
|
797
798
|
c(this, U);
|
|
798
799
|
c(this, g);
|
|
799
800
|
c(this, jt);
|
|
@@ -817,7 +818,7 @@ var U, g, jt, q, pt, Et, W, st, Nt, Ft, Rt, mt, vt, rt, Mt, S, qt, re, ie, ne, a
|
|
|
817
818
|
this.refetch = this.refetch.bind(this);
|
|
818
819
|
}
|
|
819
820
|
onSubscribe() {
|
|
820
|
-
this.listeners.size === 1 && (r(this, g).addObserver(this),
|
|
821
|
+
this.listeners.size === 1 && (r(this, g).addObserver(this), Oe(r(this, g), this.options) ? v(this, C, qt).call(this) : this.updateResult(), v(this, C, ae).call(this));
|
|
821
822
|
}
|
|
822
823
|
onUnsubscribe() {
|
|
823
824
|
this.hasListeners() || this.destroy();
|
|
@@ -837,7 +838,7 @@ var U, g, jt, q, pt, Et, W, st, Nt, Ft, Rt, mt, vt, rt, Mt, S, qt, re, ie, ne, a
|
|
|
837
838
|
);
|
|
838
839
|
}
|
|
839
840
|
destroy() {
|
|
840
|
-
this.listeners = /* @__PURE__ */ new Set(), v(this,
|
|
841
|
+
this.listeners = /* @__PURE__ */ new Set(), v(this, C, oe).call(this), v(this, C, ue).call(this), r(this, g).removeObserver(this);
|
|
841
842
|
}
|
|
842
843
|
setOptions(t) {
|
|
843
844
|
const s = this.options, i = r(this, g);
|
|
@@ -845,24 +846,24 @@ var U, g, jt, q, pt, Et, W, st, Nt, Ft, Rt, mt, vt, rt, Mt, S, qt, re, ie, ne, a
|
|
|
845
846
|
throw new Error(
|
|
846
847
|
"Expected enabled to be a boolean or a callback that returns a boolean"
|
|
847
848
|
);
|
|
848
|
-
v(this,
|
|
849
|
+
v(this, C, he).call(this), r(this, g).setOptions(this.options), s._defaulted && !Xt(this.options, s) && r(this, U).getQueryCache().notify({
|
|
849
850
|
type: "observerOptionsUpdated",
|
|
850
851
|
query: r(this, g),
|
|
851
852
|
observer: this
|
|
852
853
|
});
|
|
853
854
|
const n = this.hasListeners();
|
|
854
|
-
n &&
|
|
855
|
+
n && Pe(
|
|
855
856
|
r(this, g),
|
|
856
857
|
i,
|
|
857
858
|
this.options,
|
|
858
859
|
s
|
|
859
|
-
) && v(this,
|
|
860
|
-
const a = v(this,
|
|
861
|
-
n && (r(this, g) !== i || k(this.options.enabled, r(this, g)) !== k(s.enabled, r(this, g)) || a !== r(this, rt)) && v(this,
|
|
860
|
+
) && v(this, C, qt).call(this), this.updateResult(), n && (r(this, g) !== i || k(this.options.enabled, r(this, g)) !== k(s.enabled, r(this, g)) || ot(this.options.staleTime, r(this, g)) !== ot(s.staleTime, r(this, g))) && v(this, C, re).call(this);
|
|
861
|
+
const a = v(this, C, ie).call(this);
|
|
862
|
+
n && (r(this, g) !== i || k(this.options.enabled, r(this, g)) !== k(s.enabled, r(this, g)) || a !== r(this, rt)) && v(this, C, ne).call(this, a);
|
|
862
863
|
}
|
|
863
864
|
getOptimisticResult(t) {
|
|
864
865
|
const s = r(this, U).getQueryCache().build(r(this, U), t), i = this.createResult(s, t);
|
|
865
|
-
return
|
|
866
|
+
return ps(this, i) && (o(this, q, i), o(this, Et, this.options), o(this, pt, r(this, g).state)), i;
|
|
866
867
|
}
|
|
867
868
|
getCurrentResult() {
|
|
868
869
|
return r(this, q);
|
|
@@ -892,20 +893,20 @@ var U, g, jt, q, pt, Et, W, st, Nt, Ft, Rt, mt, vt, rt, Mt, S, qt, re, ie, ne, a
|
|
|
892
893
|
return i.fetch().then(() => this.createResult(i, s));
|
|
893
894
|
}
|
|
894
895
|
fetch(t) {
|
|
895
|
-
return v(this,
|
|
896
|
+
return v(this, C, qt).call(this, {
|
|
896
897
|
...t,
|
|
897
898
|
cancelRefetch: t.cancelRefetch ?? !0
|
|
898
899
|
}).then(() => (this.updateResult(), r(this, q)));
|
|
899
900
|
}
|
|
900
901
|
createResult(t, s) {
|
|
901
902
|
var X;
|
|
902
|
-
const i = r(this, g), n = this.options, a = r(this, q), h = r(this, pt), u = r(this, Et), b = t !== i ? t.state : r(this, jt), { state:
|
|
903
|
-
let f = { ...
|
|
903
|
+
const i = r(this, g), n = this.options, a = r(this, q), h = r(this, pt), u = r(this, Et), b = t !== i ? t.state : r(this, jt), { state: S } = t;
|
|
904
|
+
let f = { ...S }, O = !1, y;
|
|
904
905
|
if (s._optimisticResults) {
|
|
905
|
-
const w = this.hasListeners(), N = !w &&
|
|
906
|
+
const w = this.hasListeners(), N = !w && Oe(t, s), wt = w && Pe(t, i, s, n);
|
|
906
907
|
(N || wt) && (f = {
|
|
907
908
|
...f,
|
|
908
|
-
...
|
|
909
|
+
...He(S.data, t.options)
|
|
909
910
|
}), s._optimisticResults === "isRestoring" && (f.fetchStatus = "idle");
|
|
910
911
|
}
|
|
911
912
|
let { error: R, errorUpdatedAt: p, status: m } = f;
|
|
@@ -1000,38 +1001,38 @@ var U, g, jt, q, pt, Et, W, st, Nt, Ft, Rt, mt, vt, rt, Mt, S, qt, re, ie, ne, a
|
|
|
1000
1001
|
return r(this, q)[d] !== t[d] && h.has(d);
|
|
1001
1002
|
});
|
|
1002
1003
|
};
|
|
1003
|
-
v(this,
|
|
1004
|
+
v(this, C, Ge).call(this, { listeners: i() });
|
|
1004
1005
|
}
|
|
1005
1006
|
onQueryUpdate() {
|
|
1006
|
-
this.updateResult(), this.hasListeners() && v(this,
|
|
1007
|
+
this.updateResult(), this.hasListeners() && v(this, C, ae).call(this);
|
|
1007
1008
|
}
|
|
1008
|
-
}, U = new WeakMap(), g = new WeakMap(), jt = new WeakMap(), q = new WeakMap(), pt = new WeakMap(), Et = new WeakMap(), W = new WeakMap(), st = new WeakMap(), Nt = new WeakMap(), Ft = new WeakMap(), Rt = new WeakMap(), mt = new WeakMap(), vt = new WeakMap(), rt = new WeakMap(), Mt = new WeakMap(),
|
|
1009
|
-
v(this,
|
|
1009
|
+
}, U = new WeakMap(), g = new WeakMap(), jt = new WeakMap(), q = new WeakMap(), pt = new WeakMap(), Et = new WeakMap(), W = new WeakMap(), st = new WeakMap(), Nt = new WeakMap(), Ft = new WeakMap(), Rt = new WeakMap(), mt = new WeakMap(), vt = new WeakMap(), rt = new WeakMap(), Mt = new WeakMap(), C = new WeakSet(), qt = function(t) {
|
|
1010
|
+
v(this, C, he).call(this);
|
|
1010
1011
|
let s = r(this, g).fetch(
|
|
1011
1012
|
this.options,
|
|
1012
1013
|
t
|
|
1013
1014
|
);
|
|
1014
1015
|
return t != null && t.throwOnError || (s = s.catch(j)), s;
|
|
1015
1016
|
}, re = function() {
|
|
1016
|
-
v(this,
|
|
1017
|
+
v(this, C, oe).call(this);
|
|
1017
1018
|
const t = ot(
|
|
1018
1019
|
this.options.staleTime,
|
|
1019
1020
|
r(this, g)
|
|
1020
1021
|
);
|
|
1021
1022
|
if (bt || r(this, q).isStale || !Jt(t))
|
|
1022
1023
|
return;
|
|
1023
|
-
const i =
|
|
1024
|
+
const i = Ne(r(this, q).dataUpdatedAt, t) + 1;
|
|
1024
1025
|
o(this, mt, ut.setTimeout(() => {
|
|
1025
1026
|
r(this, q).isStale || this.updateResult();
|
|
1026
1027
|
}, i));
|
|
1027
1028
|
}, ie = function() {
|
|
1028
1029
|
return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(r(this, g)) : this.options.refetchInterval) ?? !1;
|
|
1029
1030
|
}, ne = function(t) {
|
|
1030
|
-
v(this,
|
|
1031
|
-
(this.options.refetchIntervalInBackground || de.isFocused()) && v(this,
|
|
1031
|
+
v(this, C, ue).call(this), o(this, rt, t), !(bt || k(this.options.enabled, r(this, g)) === !1 || !Jt(r(this, rt)) || r(this, rt) === 0) && o(this, vt, ut.setInterval(() => {
|
|
1032
|
+
(this.options.refetchIntervalInBackground || de.isFocused()) && v(this, C, qt).call(this);
|
|
1032
1033
|
}, r(this, rt)));
|
|
1033
1034
|
}, ae = function() {
|
|
1034
|
-
v(this,
|
|
1035
|
+
v(this, C, re).call(this), v(this, C, ne).call(this, v(this, C, ie).call(this));
|
|
1035
1036
|
}, oe = function() {
|
|
1036
1037
|
r(this, mt) && (ut.clearTimeout(r(this, mt)), o(this, mt, void 0));
|
|
1037
1038
|
}, ue = function() {
|
|
@@ -1042,7 +1043,7 @@ var U, g, jt, q, pt, Et, W, st, Nt, Ft, Rt, mt, vt, rt, Mt, S, qt, re, ie, ne, a
|
|
|
1042
1043
|
return;
|
|
1043
1044
|
const s = r(this, g);
|
|
1044
1045
|
o(this, g, t), o(this, jt, t.state), this.hasListeners() && (s == null || s.removeObserver(this), t.addObserver(this));
|
|
1045
|
-
},
|
|
1046
|
+
}, Ge = function(t) {
|
|
1046
1047
|
T.batch(() => {
|
|
1047
1048
|
t.listeners && this.listeners.forEach((s) => {
|
|
1048
1049
|
s(r(this, q));
|
|
@@ -1051,12 +1052,12 @@ var U, g, jt, q, pt, Et, W, st, Nt, Ft, Rt, mt, vt, rt, Mt, S, qt, re, ie, ne, a
|
|
|
1051
1052
|
type: "observerResultsUpdated"
|
|
1052
1053
|
});
|
|
1053
1054
|
});
|
|
1054
|
-
},
|
|
1055
|
-
function
|
|
1055
|
+
}, qe);
|
|
1056
|
+
function ys(e, t) {
|
|
1056
1057
|
return k(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
|
|
1057
1058
|
}
|
|
1058
|
-
function
|
|
1059
|
-
return
|
|
1059
|
+
function Oe(e, t) {
|
|
1060
|
+
return ys(e, t) || e.state.data !== void 0 && ce(e, t, t.refetchOnMount);
|
|
1060
1061
|
}
|
|
1061
1062
|
function ce(e, t, s) {
|
|
1062
1063
|
if (k(t.enabled, e) !== !1 && ot(t.staleTime, e) !== "static") {
|
|
@@ -1065,20 +1066,20 @@ function ce(e, t, s) {
|
|
|
1065
1066
|
}
|
|
1066
1067
|
return !1;
|
|
1067
1068
|
}
|
|
1068
|
-
function
|
|
1069
|
+
function Pe(e, t, s, i) {
|
|
1069
1070
|
return (e !== t || k(i.enabled, e) === !1) && (!s.suspense || e.state.status !== "error") && fe(e, s);
|
|
1070
1071
|
}
|
|
1071
1072
|
function fe(e, t) {
|
|
1072
1073
|
return k(t.enabled, e) !== !1 && e.isStaleByTime(ot(t.staleTime, e));
|
|
1073
1074
|
}
|
|
1074
|
-
function
|
|
1075
|
+
function ps(e, t) {
|
|
1075
1076
|
return !Xt(e.getCurrentResult(), t);
|
|
1076
1077
|
}
|
|
1077
|
-
function
|
|
1078
|
+
function Ee(e) {
|
|
1078
1079
|
return {
|
|
1079
1080
|
onFetch: (t, s) => {
|
|
1080
|
-
var
|
|
1081
|
-
const i = t.options, n = (O = (f = (
|
|
1081
|
+
var S, f, O, y, R;
|
|
1082
|
+
const i = t.options, n = (O = (f = (S = t.fetchOptions) == null ? void 0 : S.meta) == null ? void 0 : f.fetchMore) == null ? void 0 : O.direction, a = ((y = t.state.data) == null ? void 0 : y.pages) || [], h = ((R = t.state.data) == null ? void 0 : R.pageParams) || [];
|
|
1082
1083
|
let u = { pages: [], pageParams: [] }, d = 0;
|
|
1083
1084
|
const b = async () => {
|
|
1084
1085
|
let p = !1;
|
|
@@ -1089,7 +1090,7 @@ function Pe(e) {
|
|
|
1089
1090
|
p = !0;
|
|
1090
1091
|
}), t.signal)
|
|
1091
1092
|
});
|
|
1092
|
-
}, P =
|
|
1093
|
+
}, P = _e(t.options, t.fetchOptions), M = async (E, l, Q) => {
|
|
1093
1094
|
if (p)
|
|
1094
1095
|
return Promise.reject();
|
|
1095
1096
|
if (l == null && E.pages.length)
|
|
@@ -1103,14 +1104,14 @@ function Pe(e) {
|
|
|
1103
1104
|
meta: t.options.meta
|
|
1104
1105
|
};
|
|
1105
1106
|
return m(N), N;
|
|
1106
|
-
})(), I = await P(Z), { maxPages: X } = t.options, w = Q ?
|
|
1107
|
+
})(), I = await P(Z), { maxPages: X } = t.options, w = Q ? ns : is;
|
|
1107
1108
|
return {
|
|
1108
1109
|
pages: w(E.pages, I, X),
|
|
1109
1110
|
pageParams: w(E.pageParams, l, X)
|
|
1110
1111
|
};
|
|
1111
1112
|
};
|
|
1112
1113
|
if (n && a.length) {
|
|
1113
|
-
const E = n === "backward", l = E ?
|
|
1114
|
+
const E = n === "backward", l = E ? ms : Fe, Q = {
|
|
1114
1115
|
pages: a,
|
|
1115
1116
|
pageParams: h
|
|
1116
1117
|
}, x = l(i, Q);
|
|
@@ -1118,7 +1119,7 @@ function Pe(e) {
|
|
|
1118
1119
|
} else {
|
|
1119
1120
|
const E = e ?? a.length;
|
|
1120
1121
|
do {
|
|
1121
|
-
const l = d === 0 ? h[0] ?? i.initialPageParam :
|
|
1122
|
+
const l = d === 0 ? h[0] ?? i.initialPageParam : Fe(i, u);
|
|
1122
1123
|
if (d > 0 && l == null)
|
|
1123
1124
|
break;
|
|
1124
1125
|
u = await M(u, l), d++;
|
|
@@ -1143,7 +1144,7 @@ function Pe(e) {
|
|
|
1143
1144
|
}
|
|
1144
1145
|
};
|
|
1145
1146
|
}
|
|
1146
|
-
function
|
|
1147
|
+
function Fe(e, { pages: t, pageParams: s }) {
|
|
1147
1148
|
const i = t.length - 1;
|
|
1148
1149
|
return t.length > 0 ? e.getNextPageParam(
|
|
1149
1150
|
t[i],
|
|
@@ -1152,11 +1153,11 @@ function Ee(e, { pages: t, pageParams: s }) {
|
|
|
1152
1153
|
s
|
|
1153
1154
|
) : void 0;
|
|
1154
1155
|
}
|
|
1155
|
-
function
|
|
1156
|
+
function ms(e, { pages: t, pageParams: s }) {
|
|
1156
1157
|
var i;
|
|
1157
1158
|
return t.length > 0 ? (i = e.getPreviousPageParam) == null ? void 0 : i.call(e, t[0], t, s[0], s) : void 0;
|
|
1158
1159
|
}
|
|
1159
|
-
var _t, B, A, gt, V, Y,
|
|
1160
|
+
var _t, B, A, gt, V, Y, Ae, vs = (Ae = class extends Le {
|
|
1160
1161
|
constructor(t) {
|
|
1161
1162
|
super();
|
|
1162
1163
|
c(this, V);
|
|
@@ -1164,7 +1165,7 @@ var _t, B, A, gt, V, Y, qe, ms = (qe = class extends Ke {
|
|
|
1164
1165
|
c(this, B);
|
|
1165
1166
|
c(this, A);
|
|
1166
1167
|
c(this, gt);
|
|
1167
|
-
o(this, _t, t.client), this.mutationId = t.mutationId, o(this, A, t.mutationCache), o(this, B, []), this.state = t.state ||
|
|
1168
|
+
o(this, _t, t.client), this.mutationId = t.mutationId, o(this, A, t.mutationCache), o(this, B, []), this.state = t.state || gs(), this.setOptions(t.options), this.scheduleGc();
|
|
1168
1169
|
}
|
|
1169
1170
|
setOptions(t) {
|
|
1170
1171
|
this.options = t, this.updateGcTime(this.options.gcTime);
|
|
@@ -1195,7 +1196,7 @@ var _t, B, A, gt, V, Y, qe, ms = (qe = class extends Ke {
|
|
|
1195
1196
|
this.execute(this.state.variables);
|
|
1196
1197
|
}
|
|
1197
1198
|
async execute(t) {
|
|
1198
|
-
var h, u, d, b,
|
|
1199
|
+
var h, u, d, b, S, f, O, y, R, p, m, P, M, E, l, Q, x, Z, I, X;
|
|
1199
1200
|
const s = () => {
|
|
1200
1201
|
v(this, V, Y).call(this, { type: "continue" });
|
|
1201
1202
|
}, i = {
|
|
@@ -1203,7 +1204,7 @@ var _t, B, A, gt, V, Y, qe, ms = (qe = class extends Ke {
|
|
|
1203
1204
|
meta: this.options.meta,
|
|
1204
1205
|
mutationKey: this.options.mutationKey
|
|
1205
1206
|
};
|
|
1206
|
-
o(this, gt,
|
|
1207
|
+
o(this, gt, Ke({
|
|
1207
1208
|
fn: () => this.options.mutationFn ? this.options.mutationFn(t, i) : Promise.reject(new Error("No mutationFn found")),
|
|
1208
1209
|
onFail: (w, N) => {
|
|
1209
1210
|
v(this, V, Y).call(this, { type: "failed", failureCount: w, error: N });
|
|
@@ -1241,8 +1242,8 @@ var _t, B, A, gt, V, Y, qe, ms = (qe = class extends Ke {
|
|
|
1241
1242
|
});
|
|
1242
1243
|
}
|
|
1243
1244
|
const w = await r(this, gt).start();
|
|
1244
|
-
return await ((f = (
|
|
1245
|
-
|
|
1245
|
+
return await ((f = (S = r(this, A).config).onSuccess) == null ? void 0 : f.call(
|
|
1246
|
+
S,
|
|
1246
1247
|
w,
|
|
1247
1248
|
t,
|
|
1248
1249
|
this.state.context,
|
|
@@ -1371,8 +1372,8 @@ var _t, B, A, gt, V, Y, qe, ms = (qe = class extends Ke {
|
|
|
1371
1372
|
action: t
|
|
1372
1373
|
});
|
|
1373
1374
|
});
|
|
1374
|
-
},
|
|
1375
|
-
function
|
|
1375
|
+
}, Ae);
|
|
1376
|
+
function gs() {
|
|
1376
1377
|
return {
|
|
1377
1378
|
context: void 0,
|
|
1378
1379
|
data: void 0,
|
|
@@ -1385,7 +1386,7 @@ function vs() {
|
|
|
1385
1386
|
submittedAt: 0
|
|
1386
1387
|
};
|
|
1387
1388
|
}
|
|
1388
|
-
var J, H, kt,
|
|
1389
|
+
var J, H, kt, xe, bs = (xe = class extends Kt {
|
|
1389
1390
|
constructor(t = {}) {
|
|
1390
1391
|
super();
|
|
1391
1392
|
c(this, J);
|
|
@@ -1394,7 +1395,7 @@ var J, H, kt, Ae, gs = (Ae = class extends Kt {
|
|
|
1394
1395
|
this.config = t, o(this, J, /* @__PURE__ */ new Set()), o(this, H, /* @__PURE__ */ new Map()), o(this, kt, 0);
|
|
1395
1396
|
}
|
|
1396
1397
|
build(t, s, i) {
|
|
1397
|
-
const n = new
|
|
1398
|
+
const n = new vs({
|
|
1398
1399
|
client: t,
|
|
1399
1400
|
mutationCache: this,
|
|
1400
1401
|
mutationId: ++Ht(this, kt)._,
|
|
@@ -1458,11 +1459,11 @@ var J, H, kt, Ae, gs = (Ae = class extends Kt {
|
|
|
1458
1459
|
find(t) {
|
|
1459
1460
|
const s = { exact: !0, ...t };
|
|
1460
1461
|
return this.getAll().find(
|
|
1461
|
-
(i) =>
|
|
1462
|
+
(i) => ge(s, i)
|
|
1462
1463
|
);
|
|
1463
1464
|
}
|
|
1464
1465
|
findAll(t = {}) {
|
|
1465
|
-
return this.getAll().filter((s) =>
|
|
1466
|
+
return this.getAll().filter((s) => ge(t, s));
|
|
1466
1467
|
}
|
|
1467
1468
|
notify(t) {
|
|
1468
1469
|
T.batch(() => {
|
|
@@ -1479,12 +1480,12 @@ var J, H, kt, Ae, gs = (Ae = class extends Kt {
|
|
|
1479
1480
|
)
|
|
1480
1481
|
);
|
|
1481
1482
|
}
|
|
1482
|
-
}, J = new WeakMap(), H = new WeakMap(), kt = new WeakMap(),
|
|
1483
|
+
}, J = new WeakMap(), H = new WeakMap(), kt = new WeakMap(), xe);
|
|
1483
1484
|
function Gt(e) {
|
|
1484
1485
|
var t;
|
|
1485
1486
|
return (t = e.options.scope) == null ? void 0 : t.id;
|
|
1486
1487
|
}
|
|
1487
|
-
var z,
|
|
1488
|
+
var z, Ue, ws = (Ue = class extends Kt {
|
|
1488
1489
|
constructor(t = {}) {
|
|
1489
1490
|
super();
|
|
1490
1491
|
c(this, z);
|
|
@@ -1493,7 +1494,7 @@ var z, xe, bs = (xe = class extends Kt {
|
|
|
1493
1494
|
build(t, s, i) {
|
|
1494
1495
|
const n = s.queryKey, a = s.queryHash ?? le(n, s);
|
|
1495
1496
|
let h = this.get(a);
|
|
1496
|
-
return h || (h = new
|
|
1497
|
+
return h || (h = new ds({
|
|
1497
1498
|
client: t,
|
|
1498
1499
|
queryKey: n,
|
|
1499
1500
|
queryHash: a,
|
|
@@ -1528,12 +1529,12 @@ var z, xe, bs = (xe = class extends Kt {
|
|
|
1528
1529
|
find(t) {
|
|
1529
1530
|
const s = { exact: !0, ...t };
|
|
1530
1531
|
return this.getAll().find(
|
|
1531
|
-
(i) =>
|
|
1532
|
+
(i) => ve(s, i)
|
|
1532
1533
|
);
|
|
1533
1534
|
}
|
|
1534
1535
|
findAll(t = {}) {
|
|
1535
1536
|
const s = this.getAll();
|
|
1536
|
-
return Object.keys(t).length > 0 ? s.filter((i) =>
|
|
1537
|
+
return Object.keys(t).length > 0 ? s.filter((i) => ve(t, i)) : s;
|
|
1537
1538
|
}
|
|
1538
1539
|
notify(t) {
|
|
1539
1540
|
T.batch(() => {
|
|
@@ -1556,7 +1557,7 @@ var z, xe, bs = (xe = class extends Kt {
|
|
|
1556
1557
|
});
|
|
1557
1558
|
});
|
|
1558
1559
|
}
|
|
1559
|
-
}, z = new WeakMap(),
|
|
1560
|
+
}, z = new WeakMap(), Ue), F, it, nt, Qt, Dt, at, Tt, It, je, Cs = (je = class {
|
|
1560
1561
|
constructor(e = {}) {
|
|
1561
1562
|
c(this, F);
|
|
1562
1563
|
c(this, it);
|
|
@@ -1566,7 +1567,7 @@ var z, xe, bs = (xe = class extends Kt {
|
|
|
1566
1567
|
c(this, at);
|
|
1567
1568
|
c(this, Tt);
|
|
1568
1569
|
c(this, It);
|
|
1569
|
-
o(this, F, e.queryCache || new
|
|
1570
|
+
o(this, F, e.queryCache || new ws()), o(this, it, e.mutationCache || new bs()), o(this, nt, e.defaultOptions || {}), o(this, Qt, /* @__PURE__ */ new Map()), o(this, Dt, /* @__PURE__ */ new Map()), o(this, at, 0);
|
|
1570
1571
|
}
|
|
1571
1572
|
mount() {
|
|
1572
1573
|
Ht(this, at)._++, r(this, at) === 1 && (o(this, Tt, de.subscribe(async (e) => {
|
|
@@ -1610,7 +1611,7 @@ var z, xe, bs = (xe = class extends Kt {
|
|
|
1610
1611
|
setQueryData(e, t, s) {
|
|
1611
1612
|
const i = this.defaultQueryOptions({ queryKey: e }), n = r(this, F).get(
|
|
1612
1613
|
i.queryHash
|
|
1613
|
-
), a = n == null ? void 0 : n.state.data, h =
|
|
1614
|
+
), a = n == null ? void 0 : n.state.data, h = es(t, a);
|
|
1614
1615
|
if (h !== void 0)
|
|
1615
1616
|
return r(this, F).build(this, i).setData(h, { ...s, manual: !0 });
|
|
1616
1617
|
}
|
|
@@ -1690,13 +1691,13 @@ var z, xe, bs = (xe = class extends Kt {
|
|
|
1690
1691
|
return this.fetchQuery(e).then(j).catch(j);
|
|
1691
1692
|
}
|
|
1692
1693
|
fetchInfiniteQuery(e) {
|
|
1693
|
-
return e.behavior =
|
|
1694
|
+
return e.behavior = Ee(e.pages), this.fetchQuery(e);
|
|
1694
1695
|
}
|
|
1695
1696
|
prefetchInfiniteQuery(e) {
|
|
1696
1697
|
return this.fetchInfiniteQuery(e).then(j).catch(j);
|
|
1697
1698
|
}
|
|
1698
1699
|
ensureInfiniteQueryData(e) {
|
|
1699
|
-
return e.behavior =
|
|
1700
|
+
return e.behavior = Ee(e.pages), this.ensureQueryData(e);
|
|
1700
1701
|
}
|
|
1701
1702
|
resumePausedMutations() {
|
|
1702
1703
|
return zt.isOnline() ? r(this, it).resumePausedMutations() : Promise.resolve();
|
|
@@ -1762,21 +1763,21 @@ var z, xe, bs = (xe = class extends Kt {
|
|
|
1762
1763
|
clear() {
|
|
1763
1764
|
r(this, F).clear(), r(this, it).clear();
|
|
1764
1765
|
}
|
|
1765
|
-
}, F = new WeakMap(), it = new WeakMap(), nt = new WeakMap(), Qt = new WeakMap(), Dt = new WeakMap(), at = new WeakMap(), Tt = new WeakMap(), It = new WeakMap(),
|
|
1766
|
+
}, F = new WeakMap(), it = new WeakMap(), nt = new WeakMap(), Qt = new WeakMap(), Dt = new WeakMap(), at = new WeakMap(), Tt = new WeakMap(), It = new WeakMap(), je), Be = K.createContext(
|
|
1766
1767
|
void 0
|
|
1767
1768
|
), Ss = (e) => {
|
|
1768
|
-
const t = K.useContext(
|
|
1769
|
+
const t = K.useContext(Be);
|
|
1769
1770
|
if (!t)
|
|
1770
1771
|
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
1771
1772
|
return t;
|
|
1772
|
-
},
|
|
1773
|
+
}, Os = ({
|
|
1773
1774
|
client: e,
|
|
1774
1775
|
children: t
|
|
1775
1776
|
}) => (K.useEffect(() => (e.mount(), () => {
|
|
1776
1777
|
e.unmount();
|
|
1777
|
-
}), [e]), /* @__PURE__ */ Bt(
|
|
1778
|
-
|
|
1779
|
-
function
|
|
1778
|
+
}), [e]), /* @__PURE__ */ Bt(Be.Provider, { value: e, children: t })), Ve = K.createContext(!1), Ps = () => K.useContext(Ve);
|
|
1779
|
+
Ve.Provider;
|
|
1780
|
+
function Es() {
|
|
1780
1781
|
let e = !1;
|
|
1781
1782
|
return {
|
|
1782
1783
|
clearReset: () => {
|
|
@@ -1788,19 +1789,19 @@ function Ps() {
|
|
|
1788
1789
|
isReset: () => e
|
|
1789
1790
|
};
|
|
1790
1791
|
}
|
|
1791
|
-
var
|
|
1792
|
+
var Fs = K.createContext(Es()), Rs = () => K.useContext(Fs), Ms = (e, t) => {
|
|
1792
1793
|
(e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1));
|
|
1793
|
-
},
|
|
1794
|
+
}, Qs = (e) => {
|
|
1794
1795
|
K.useEffect(() => {
|
|
1795
1796
|
e.clearReset();
|
|
1796
1797
|
}, [e]);
|
|
1797
|
-
},
|
|
1798
|
+
}, Ds = ({
|
|
1798
1799
|
result: e,
|
|
1799
1800
|
errorResetBoundary: t,
|
|
1800
1801
|
throwOnError: s,
|
|
1801
1802
|
query: i,
|
|
1802
1803
|
suspense: n
|
|
1803
|
-
}) => e.isError && !t.isReset() && !e.isFetching && i && (n && e.data === void 0 ||
|
|
1804
|
+
}) => e.isError && !t.isReset() && !e.isFetching && i && (n && e.data === void 0 || as(s, [e.error, i])), Ts = (e) => {
|
|
1804
1805
|
if (e.suspense) {
|
|
1805
1806
|
const s = (n) => n === "static" ? n : Math.max(n ?? 1e3, 1e3), i = e.staleTime;
|
|
1806
1807
|
e.staleTime = typeof i == "function" ? (...n) => s(i(...n)) : s(i), typeof e.gcTime == "number" && (e.gcTime = Math.max(
|
|
@@ -1808,43 +1809,43 @@ var Es = K.createContext(Ps()), Fs = () => K.useContext(Es), Rs = (e, t) => {
|
|
|
1808
1809
|
1e3
|
|
1809
1810
|
));
|
|
1810
1811
|
}
|
|
1811
|
-
},
|
|
1812
|
+
}, Is = (e, t) => e.isLoading && e.isFetching && !t, qs = (e, t) => (e == null ? void 0 : e.suspense) && t.isPending, Re = (e, t, s) => t.fetchOptimistic(e).catch(() => {
|
|
1812
1813
|
s.clearReset();
|
|
1813
1814
|
});
|
|
1814
|
-
function
|
|
1815
|
+
function As(e, t, s) {
|
|
1815
1816
|
var f, O, y, R, p;
|
|
1816
1817
|
if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e)))
|
|
1817
1818
|
throw new Error(
|
|
1818
1819
|
'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'
|
|
1819
1820
|
);
|
|
1820
|
-
const i =
|
|
1821
|
+
const i = Ps(), n = Rs(), a = Ss(), h = a.defaultQueryOptions(e);
|
|
1821
1822
|
(O = (f = a.getDefaultOptions().queries) == null ? void 0 : f._experimental_beforeQuery) == null || O.call(
|
|
1822
1823
|
f,
|
|
1823
1824
|
h
|
|
1824
1825
|
), process.env.NODE_ENV !== "production" && (h.queryFn || console.error(
|
|
1825
1826
|
`[${h.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`
|
|
1826
|
-
)), h._optimisticResults = i ? "isRestoring" : "optimistic",
|
|
1827
|
+
)), h._optimisticResults = i ? "isRestoring" : "optimistic", Ts(h), Ms(h, n), Qs(n);
|
|
1827
1828
|
const u = !a.getQueryCache().get(h.queryHash), [d] = K.useState(
|
|
1828
1829
|
() => new t(
|
|
1829
1830
|
a,
|
|
1830
1831
|
h
|
|
1831
1832
|
)
|
|
1832
|
-
), b = d.getOptimisticResult(h),
|
|
1833
|
+
), b = d.getOptimisticResult(h), S = !i && e.subscribed !== !1;
|
|
1833
1834
|
if (K.useSyncExternalStore(
|
|
1834
1835
|
K.useCallback(
|
|
1835
1836
|
(m) => {
|
|
1836
|
-
const P =
|
|
1837
|
+
const P = S ? d.subscribe(T.batchCalls(m)) : j;
|
|
1837
1838
|
return d.updateResult(), P;
|
|
1838
1839
|
},
|
|
1839
|
-
[d,
|
|
1840
|
+
[d, S]
|
|
1840
1841
|
),
|
|
1841
1842
|
() => d.getCurrentResult(),
|
|
1842
1843
|
() => d.getCurrentResult()
|
|
1843
1844
|
), K.useEffect(() => {
|
|
1844
1845
|
d.setOptions(h);
|
|
1845
|
-
}, [h, d]),
|
|
1846
|
-
throw
|
|
1847
|
-
if (
|
|
1846
|
+
}, [h, d]), qs(h, b))
|
|
1847
|
+
throw Re(h, d, n);
|
|
1848
|
+
if (Ds({
|
|
1848
1849
|
result: b,
|
|
1849
1850
|
errorResetBoundary: n,
|
|
1850
1851
|
throwOnError: h.throwOnError,
|
|
@@ -1856,10 +1857,10 @@ function qs(e, t, s) {
|
|
|
1856
1857
|
y,
|
|
1857
1858
|
h,
|
|
1858
1859
|
b
|
|
1859
|
-
), h.experimental_prefetchInRender && !bt &&
|
|
1860
|
+
), h.experimental_prefetchInRender && !bt && Is(b, i)) {
|
|
1860
1861
|
const m = u ? (
|
|
1861
1862
|
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
1862
|
-
|
|
1863
|
+
Re(h, d, n)
|
|
1863
1864
|
) : (
|
|
1864
1865
|
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
1865
1866
|
(p = a.getQueryCache().get(h.queryHash)) == null ? void 0 : p.promise
|
|
@@ -1870,10 +1871,10 @@ function qs(e, t, s) {
|
|
|
1870
1871
|
}
|
|
1871
1872
|
return h.notifyOnChangeProps ? b : d.trackResult(b);
|
|
1872
1873
|
}
|
|
1873
|
-
function
|
|
1874
|
-
return
|
|
1874
|
+
function xs(e, t) {
|
|
1875
|
+
return As(e, fs);
|
|
1875
1876
|
}
|
|
1876
|
-
const
|
|
1877
|
+
const Us = ze(void 0), js = new Cs({
|
|
1877
1878
|
defaultOptions: {
|
|
1878
1879
|
queries: {
|
|
1879
1880
|
retry: 1,
|
|
@@ -1883,41 +1884,43 @@ const xs = Ve(void 0), Us = new ws({
|
|
|
1883
1884
|
}
|
|
1884
1885
|
}
|
|
1885
1886
|
});
|
|
1886
|
-
function
|
|
1887
|
+
function Ns({
|
|
1887
1888
|
fetchSchedule: e,
|
|
1888
1889
|
initialSchedule: t = [],
|
|
1889
1890
|
weeks: s,
|
|
1890
1891
|
handleDateChanged: i = () => !0,
|
|
1891
1892
|
children: n
|
|
1892
1893
|
}) {
|
|
1893
|
-
const [a, h] = pe(s[0][0].date), [u, d] = pe(!1), b =
|
|
1894
|
+
const [a, h] = pe(s[0][0].date), [u, d] = pe(!1), b = $e(Wt(s[0][0].date, "yyyy-MM-dd"));
|
|
1895
|
+
me.setComponent("ScheduleContext"), me.log("fetchSchedule:", e);
|
|
1896
|
+
const S = We((p) => {
|
|
1894
1897
|
const m = Wt(p, "yyyy-MM-dd");
|
|
1895
1898
|
m !== b.current && (d(!0), b.current = m), h(p), i(p);
|
|
1896
|
-
}, [i]), { data: f, isLoading: O, isError: y } =
|
|
1899
|
+
}, [i]), { data: f, isLoading: O, isError: y } = xs({
|
|
1897
1900
|
queryKey: ["schedule", Wt(a, "yyyy-MM-dd")],
|
|
1898
1901
|
queryFn: () => e(a),
|
|
1899
1902
|
staleTime: 1e3 * 60 * 15,
|
|
1900
1903
|
// 15 minutes
|
|
1901
1904
|
retry: 1
|
|
1902
1905
|
});
|
|
1903
|
-
|
|
1906
|
+
Je(() => {
|
|
1904
1907
|
f !== void 0 && u && d(!1);
|
|
1905
1908
|
}, [f, u]);
|
|
1906
|
-
const R =
|
|
1909
|
+
const R = Ze(() => ({
|
|
1907
1910
|
schedule: f ?? t,
|
|
1908
1911
|
weeks: s,
|
|
1909
1912
|
currentDate: a,
|
|
1910
1913
|
isLoading: O || u,
|
|
1911
1914
|
isError: y,
|
|
1912
|
-
setCurrentDate:
|
|
1913
|
-
}), [f, t, s, a, O, u, y,
|
|
1914
|
-
return /* @__PURE__ */ Bt(
|
|
1915
|
+
setCurrentDate: S
|
|
1916
|
+
}), [f, t, s, a, O, u, y, S]);
|
|
1917
|
+
return /* @__PURE__ */ Bt(Us.Provider, { value: R, children: n });
|
|
1915
1918
|
}
|
|
1916
|
-
function
|
|
1917
|
-
return /* @__PURE__ */ Bt(
|
|
1919
|
+
function Gs(e) {
|
|
1920
|
+
return /* @__PURE__ */ Bt(Os, { client: js, children: /* @__PURE__ */ Bt(Ns, { ...e }) });
|
|
1918
1921
|
}
|
|
1919
1922
|
export {
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
+
Us as ScheduleContext,
|
|
1924
|
+
Gs as ScheduleProvider,
|
|
1925
|
+
Gs as default
|
|
1923
1926
|
};
|
|
@@ -16,7 +16,7 @@ type UseGetScheduleParams = {
|
|
|
16
16
|
*
|
|
17
17
|
* @returns {Object[]|{ queryStatus: 'no-results' }} - Array of objects or an object with a queryStatus of 'no-results'
|
|
18
18
|
*/
|
|
19
|
-
declare const
|
|
19
|
+
declare const getSchedule: ({ dateStr, schedEndpoint, network, showEpisodeNumber, showUpcoming, }: UseGetScheduleParams) => Promise<ScheduleItem[] | [{
|
|
20
20
|
queryStatus: string;
|
|
21
21
|
}]>;
|
|
22
|
-
export default
|
|
22
|
+
export default getSchedule;
|
package/package.json
CHANGED
|
File without changes
|