@hortiview/modulebase 0.0.12333 → 0.0.12550
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/QueryClientProvider-Q_mWQTzQ.js +435 -0
- package/dist/components/ModuleBase.js +509 -10
- package/dist/hooks/useCustom.js +1 -1
- package/dist/hooks/useCustomMutation.js +11 -102
- package/dist/hooks/useEntity.d.ts +2 -8
- package/dist/hooks/useEntity.js +1 -1
- package/dist/hooks/useOption.js +1 -1
- package/dist/hooks/useServiceBus.d.ts +15 -0
- package/dist/hooks/useServiceBus.js +17 -0
- package/dist/hooks/useStores.d.ts +2 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.js +118 -116
- package/dist/mutation-X73nm7Df.js +192 -0
- package/dist/query-CRIVoEP7.js +277 -0
- package/dist/types/BaseProps.d.ts +3 -0
- package/dist/types/ModuleApi.d.ts +75 -4
- package/dist/types/ServiceBus.d.ts +17 -0
- package/dist/types/ServiceBus.js +1 -0
- package/dist/useMutation-3rykrmeD.js +97 -0
- package/dist/{useQuery-DtzakC1A.js → useQuery-CwwWze9O.js} +47 -53
- package/dist/utils-DxRR_XLb.js +9 -0
- package/package.json +1 -1
- package/dist/ModuleBase-brrfWM_W.js +0 -697
- package/dist/QueryClientProvider-QWqHaM3I.js +0 -707
|
@@ -1,707 +0,0 @@
|
|
|
1
|
-
import * as C from "react";
|
|
2
|
-
import { jsx as N } from "react/jsx-runtime";
|
|
3
|
-
var R = class {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
|
|
6
|
-
}
|
|
7
|
-
subscribe(e) {
|
|
8
|
-
return this.listeners.add(e), this.onSubscribe(), () => {
|
|
9
|
-
this.listeners.delete(e), this.onUnsubscribe();
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
hasListeners() {
|
|
13
|
-
return this.listeners.size > 0;
|
|
14
|
-
}
|
|
15
|
-
onSubscribe() {
|
|
16
|
-
}
|
|
17
|
-
onUnsubscribe() {
|
|
18
|
-
}
|
|
19
|
-
}, y = typeof window > "u" || "Deno" in globalThis;
|
|
20
|
-
function j() {
|
|
21
|
-
}
|
|
22
|
-
function ne(e, t) {
|
|
23
|
-
return typeof e == "function" ? e(t) : e;
|
|
24
|
-
}
|
|
25
|
-
function x(e) {
|
|
26
|
-
return typeof e == "number" && e >= 0 && e !== 1 / 0;
|
|
27
|
-
}
|
|
28
|
-
function Q(e, t) {
|
|
29
|
-
return Math.max(e + (t || 0) - Date.now(), 0);
|
|
30
|
-
}
|
|
31
|
-
function ie(e, t) {
|
|
32
|
-
return typeof e == "function" ? e(t) : e;
|
|
33
|
-
}
|
|
34
|
-
function I(e, t) {
|
|
35
|
-
return typeof e == "function" ? e(t) : e;
|
|
36
|
-
}
|
|
37
|
-
function ae(e, t) {
|
|
38
|
-
const {
|
|
39
|
-
type: s = "all",
|
|
40
|
-
exact: n,
|
|
41
|
-
fetchStatus: i,
|
|
42
|
-
predicate: a,
|
|
43
|
-
queryKey: u,
|
|
44
|
-
stale: r
|
|
45
|
-
} = e;
|
|
46
|
-
if (u) {
|
|
47
|
-
if (n) {
|
|
48
|
-
if (t.queryHash !== G(u, t.options))
|
|
49
|
-
return !1;
|
|
50
|
-
} else if (!E(t.queryKey, u))
|
|
51
|
-
return !1;
|
|
52
|
-
}
|
|
53
|
-
if (s !== "all") {
|
|
54
|
-
const o = t.isActive();
|
|
55
|
-
if (s === "active" && !o || s === "inactive" && o)
|
|
56
|
-
return !1;
|
|
57
|
-
}
|
|
58
|
-
return !(typeof r == "boolean" && t.isStale() !== r || i && i !== t.state.fetchStatus || a && !a(t));
|
|
59
|
-
}
|
|
60
|
-
function oe(e, t) {
|
|
61
|
-
const { exact: s, status: n, predicate: i, mutationKey: a } = e;
|
|
62
|
-
if (a) {
|
|
63
|
-
if (!t.options.mutationKey)
|
|
64
|
-
return !1;
|
|
65
|
-
if (s) {
|
|
66
|
-
if (g(t.options.mutationKey) !== g(a))
|
|
67
|
-
return !1;
|
|
68
|
-
} else if (!E(t.options.mutationKey, a))
|
|
69
|
-
return !1;
|
|
70
|
-
}
|
|
71
|
-
return !(n && t.state.status !== n || i && !i(t));
|
|
72
|
-
}
|
|
73
|
-
function G(e, t) {
|
|
74
|
-
return (t?.queryKeyHashFn || g)(e);
|
|
75
|
-
}
|
|
76
|
-
function g(e) {
|
|
77
|
-
return JSON.stringify(
|
|
78
|
-
e,
|
|
79
|
-
(t, s) => w(s) ? Object.keys(s).sort().reduce((n, i) => (n[i] = s[i], n), {}) : s
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
function E(e, t) {
|
|
83
|
-
return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? !Object.keys(t).some((s) => !E(e[s], t[s])) : !1;
|
|
84
|
-
}
|
|
85
|
-
function F(e, t) {
|
|
86
|
-
if (e === t)
|
|
87
|
-
return e;
|
|
88
|
-
const s = A(e) && A(t);
|
|
89
|
-
if (s || w(e) && w(t)) {
|
|
90
|
-
const n = s ? e : Object.keys(e), i = n.length, a = s ? t : Object.keys(t), u = a.length, r = s ? [] : {};
|
|
91
|
-
let o = 0;
|
|
92
|
-
for (let l = 0; l < u; l++) {
|
|
93
|
-
const c = s ? l : a[l];
|
|
94
|
-
(!s && n.includes(c) || s) && e[c] === void 0 && t[c] === void 0 ? (r[c] = void 0, o++) : (r[c] = F(e[c], t[c]), r[c] === e[c] && e[c] !== void 0 && o++);
|
|
95
|
-
}
|
|
96
|
-
return i === u && o === i ? e : r;
|
|
97
|
-
}
|
|
98
|
-
return t;
|
|
99
|
-
}
|
|
100
|
-
function ue(e, t) {
|
|
101
|
-
if (!t || Object.keys(e).length !== Object.keys(t).length)
|
|
102
|
-
return !1;
|
|
103
|
-
for (const s in e)
|
|
104
|
-
if (e[s] !== t[s])
|
|
105
|
-
return !1;
|
|
106
|
-
return !0;
|
|
107
|
-
}
|
|
108
|
-
function A(e) {
|
|
109
|
-
return Array.isArray(e) && e.length === Object.keys(e).length;
|
|
110
|
-
}
|
|
111
|
-
function w(e) {
|
|
112
|
-
if (!D(e))
|
|
113
|
-
return !1;
|
|
114
|
-
const t = e.constructor;
|
|
115
|
-
if (t === void 0)
|
|
116
|
-
return !0;
|
|
117
|
-
const s = t.prototype;
|
|
118
|
-
return !(!D(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
|
|
119
|
-
}
|
|
120
|
-
function D(e) {
|
|
121
|
-
return Object.prototype.toString.call(e) === "[object Object]";
|
|
122
|
-
}
|
|
123
|
-
function H(e) {
|
|
124
|
-
return new Promise((t) => {
|
|
125
|
-
setTimeout(t, e);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
function z(e, t, s) {
|
|
129
|
-
if (typeof s.structuralSharing == "function")
|
|
130
|
-
return s.structuralSharing(e, t);
|
|
131
|
-
if (s.structuralSharing !== !1) {
|
|
132
|
-
if (process.env.NODE_ENV !== "production")
|
|
133
|
-
try {
|
|
134
|
-
return F(e, t);
|
|
135
|
-
} catch (n) {
|
|
136
|
-
console.error(
|
|
137
|
-
`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${n}`
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
return F(e, t);
|
|
141
|
-
}
|
|
142
|
-
return t;
|
|
143
|
-
}
|
|
144
|
-
function ce(e, t, s = 0) {
|
|
145
|
-
const n = [...e, t];
|
|
146
|
-
return s && n.length > s ? n.slice(1) : n;
|
|
147
|
-
}
|
|
148
|
-
function he(e, t, s = 0) {
|
|
149
|
-
const n = [t, ...e];
|
|
150
|
-
return s && n.length > s ? n.slice(0, -1) : n;
|
|
151
|
-
}
|
|
152
|
-
var O = Symbol();
|
|
153
|
-
function V(e, t) {
|
|
154
|
-
return process.env.NODE_ENV !== "production" && e.queryFn === O && console.error(
|
|
155
|
-
`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`
|
|
156
|
-
), !e.queryFn && t?.initialPromise ? () => t.initialPromise : !e.queryFn || e.queryFn === O ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
|
|
157
|
-
}
|
|
158
|
-
var $ = class extends R {
|
|
159
|
-
#e;
|
|
160
|
-
#s;
|
|
161
|
-
#t;
|
|
162
|
-
constructor() {
|
|
163
|
-
super(), this.#t = (e) => {
|
|
164
|
-
if (!y && window.addEventListener) {
|
|
165
|
-
const t = () => e();
|
|
166
|
-
return window.addEventListener("visibilitychange", t, !1), () => {
|
|
167
|
-
window.removeEventListener("visibilitychange", t);
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
onSubscribe() {
|
|
173
|
-
this.#s || this.setEventListener(this.#t);
|
|
174
|
-
}
|
|
175
|
-
onUnsubscribe() {
|
|
176
|
-
this.hasListeners() || (this.#s?.(), this.#s = void 0);
|
|
177
|
-
}
|
|
178
|
-
setEventListener(e) {
|
|
179
|
-
this.#t = e, this.#s?.(), this.#s = e((t) => {
|
|
180
|
-
typeof t == "boolean" ? this.setFocused(t) : this.onFocus();
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
setFocused(e) {
|
|
184
|
-
this.#e !== e && (this.#e = e, this.onFocus());
|
|
185
|
-
}
|
|
186
|
-
onFocus() {
|
|
187
|
-
const e = this.isFocused();
|
|
188
|
-
this.listeners.forEach((t) => {
|
|
189
|
-
t(e);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
isFocused() {
|
|
193
|
-
return typeof this.#e == "boolean" ? this.#e : globalThis.document?.visibilityState !== "hidden";
|
|
194
|
-
}
|
|
195
|
-
}, _ = new $(), B = class extends R {
|
|
196
|
-
#e = !0;
|
|
197
|
-
#s;
|
|
198
|
-
#t;
|
|
199
|
-
constructor() {
|
|
200
|
-
super(), this.#t = (e) => {
|
|
201
|
-
if (!y && window.addEventListener) {
|
|
202
|
-
const t = () => e(!0), s = () => e(!1);
|
|
203
|
-
return window.addEventListener("online", t, !1), window.addEventListener("offline", s, !1), () => {
|
|
204
|
-
window.removeEventListener("online", t), window.removeEventListener("offline", s);
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
onSubscribe() {
|
|
210
|
-
this.#s || this.setEventListener(this.#t);
|
|
211
|
-
}
|
|
212
|
-
onUnsubscribe() {
|
|
213
|
-
this.hasListeners() || (this.#s?.(), this.#s = void 0);
|
|
214
|
-
}
|
|
215
|
-
setEventListener(e) {
|
|
216
|
-
this.#t = e, this.#s?.(), this.#s = e(this.setOnline.bind(this));
|
|
217
|
-
}
|
|
218
|
-
setOnline(e) {
|
|
219
|
-
this.#e !== e && (this.#e = e, this.listeners.forEach((s) => {
|
|
220
|
-
s(e);
|
|
221
|
-
}));
|
|
222
|
-
}
|
|
223
|
-
isOnline() {
|
|
224
|
-
return this.#e;
|
|
225
|
-
}
|
|
226
|
-
}, P = new B();
|
|
227
|
-
function J() {
|
|
228
|
-
let e, t;
|
|
229
|
-
const s = new Promise((i, a) => {
|
|
230
|
-
e = i, t = a;
|
|
231
|
-
});
|
|
232
|
-
s.status = "pending", s.catch(() => {
|
|
233
|
-
});
|
|
234
|
-
function n(i) {
|
|
235
|
-
Object.assign(s, i), delete s.resolve, delete s.reject;
|
|
236
|
-
}
|
|
237
|
-
return s.resolve = (i) => {
|
|
238
|
-
n({
|
|
239
|
-
status: "fulfilled",
|
|
240
|
-
value: i
|
|
241
|
-
}), e(i);
|
|
242
|
-
}, s.reject = (i) => {
|
|
243
|
-
n({
|
|
244
|
-
status: "rejected",
|
|
245
|
-
reason: i
|
|
246
|
-
}), t(i);
|
|
247
|
-
}, s;
|
|
248
|
-
}
|
|
249
|
-
function W(e) {
|
|
250
|
-
return Math.min(1e3 * 2 ** e, 3e4);
|
|
251
|
-
}
|
|
252
|
-
function T(e) {
|
|
253
|
-
return (e ?? "online") === "online" ? P.isOnline() : !0;
|
|
254
|
-
}
|
|
255
|
-
var U = class extends Error {
|
|
256
|
-
constructor(e) {
|
|
257
|
-
super("CancelledError"), this.revert = e?.revert, this.silent = e?.silent;
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
function S(e) {
|
|
261
|
-
return e instanceof U;
|
|
262
|
-
}
|
|
263
|
-
function X(e) {
|
|
264
|
-
let t = !1, s = 0, n = !1, i;
|
|
265
|
-
const a = J(), u = (h) => {
|
|
266
|
-
n || (p(new U(h)), e.abort?.());
|
|
267
|
-
}, r = () => {
|
|
268
|
-
t = !0;
|
|
269
|
-
}, o = () => {
|
|
270
|
-
t = !1;
|
|
271
|
-
}, l = () => _.isFocused() && (e.networkMode === "always" || P.isOnline()) && e.canRun(), c = () => T(e.networkMode) && e.canRun(), M = (h) => {
|
|
272
|
-
n || (n = !0, e.onSuccess?.(h), i?.(), a.resolve(h));
|
|
273
|
-
}, p = (h) => {
|
|
274
|
-
n || (n = !0, e.onError?.(h), i?.(), a.reject(h));
|
|
275
|
-
}, q = () => new Promise((h) => {
|
|
276
|
-
i = (b) => {
|
|
277
|
-
(n || l()) && h(b);
|
|
278
|
-
}, e.onPause?.();
|
|
279
|
-
}).then(() => {
|
|
280
|
-
i = void 0, n || e.onContinue?.();
|
|
281
|
-
}), v = () => {
|
|
282
|
-
if (n)
|
|
283
|
-
return;
|
|
284
|
-
let h;
|
|
285
|
-
const b = s === 0 ? e.initialPromise : void 0;
|
|
286
|
-
try {
|
|
287
|
-
h = b ?? e.fn();
|
|
288
|
-
} catch (f) {
|
|
289
|
-
h = Promise.reject(f);
|
|
290
|
-
}
|
|
291
|
-
Promise.resolve(h).then(M).catch((f) => {
|
|
292
|
-
if (n)
|
|
293
|
-
return;
|
|
294
|
-
const d = e.retry ?? (y ? 0 : 3), m = e.retryDelay ?? W, K = typeof m == "function" ? m(s, f) : m, L = d === !0 || typeof d == "number" && s < d || typeof d == "function" && d(s, f);
|
|
295
|
-
if (t || !L) {
|
|
296
|
-
p(f);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
s++, e.onFail?.(s, f), H(K).then(() => l() ? void 0 : q()).then(() => {
|
|
300
|
-
t ? p(f) : v();
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
return {
|
|
305
|
-
promise: a,
|
|
306
|
-
cancel: u,
|
|
307
|
-
continue: () => (i?.(), a),
|
|
308
|
-
cancelRetry: r,
|
|
309
|
-
continueRetry: o,
|
|
310
|
-
canStart: c,
|
|
311
|
-
start: () => (c() ? v() : q().then(v), a)
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
function Y() {
|
|
315
|
-
let e = [], t = 0, s = (r) => {
|
|
316
|
-
r();
|
|
317
|
-
}, n = (r) => {
|
|
318
|
-
r();
|
|
319
|
-
}, i = (r) => setTimeout(r, 0);
|
|
320
|
-
const a = (r) => {
|
|
321
|
-
t ? e.push(r) : i(() => {
|
|
322
|
-
s(r);
|
|
323
|
-
});
|
|
324
|
-
}, u = () => {
|
|
325
|
-
const r = e;
|
|
326
|
-
e = [], r.length && i(() => {
|
|
327
|
-
n(() => {
|
|
328
|
-
r.forEach((o) => {
|
|
329
|
-
s(o);
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
};
|
|
334
|
-
return {
|
|
335
|
-
batch: (r) => {
|
|
336
|
-
let o;
|
|
337
|
-
t++;
|
|
338
|
-
try {
|
|
339
|
-
o = r();
|
|
340
|
-
} finally {
|
|
341
|
-
t--, t || u();
|
|
342
|
-
}
|
|
343
|
-
return o;
|
|
344
|
-
},
|
|
345
|
-
/**
|
|
346
|
-
* All calls to the wrapped function will be batched.
|
|
347
|
-
*/
|
|
348
|
-
batchCalls: (r) => (...o) => {
|
|
349
|
-
a(() => {
|
|
350
|
-
r(...o);
|
|
351
|
-
});
|
|
352
|
-
},
|
|
353
|
-
schedule: a,
|
|
354
|
-
/**
|
|
355
|
-
* Use this method to set a custom notify function.
|
|
356
|
-
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
357
|
-
*/
|
|
358
|
-
setNotifyFunction: (r) => {
|
|
359
|
-
s = r;
|
|
360
|
-
},
|
|
361
|
-
/**
|
|
362
|
-
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
363
|
-
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
364
|
-
*/
|
|
365
|
-
setBatchNotifyFunction: (r) => {
|
|
366
|
-
n = r;
|
|
367
|
-
},
|
|
368
|
-
setScheduler: (r) => {
|
|
369
|
-
i = r;
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
var Z = Y(), ee = class {
|
|
374
|
-
#e;
|
|
375
|
-
destroy() {
|
|
376
|
-
this.clearGcTimeout();
|
|
377
|
-
}
|
|
378
|
-
scheduleGc() {
|
|
379
|
-
this.clearGcTimeout(), x(this.gcTime) && (this.#e = setTimeout(() => {
|
|
380
|
-
this.optionalRemove();
|
|
381
|
-
}, this.gcTime));
|
|
382
|
-
}
|
|
383
|
-
updateGcTime(e) {
|
|
384
|
-
this.gcTime = Math.max(
|
|
385
|
-
this.gcTime || 0,
|
|
386
|
-
e ?? (y ? 1 / 0 : 5 * 60 * 1e3)
|
|
387
|
-
);
|
|
388
|
-
}
|
|
389
|
-
clearGcTimeout() {
|
|
390
|
-
this.#e && (clearTimeout(this.#e), this.#e = void 0);
|
|
391
|
-
}
|
|
392
|
-
}, le = class extends ee {
|
|
393
|
-
#e;
|
|
394
|
-
#s;
|
|
395
|
-
#t;
|
|
396
|
-
#i;
|
|
397
|
-
#r;
|
|
398
|
-
#o;
|
|
399
|
-
#a;
|
|
400
|
-
constructor(e) {
|
|
401
|
-
super(), this.#a = !1, this.#o = e.defaultOptions, this.setOptions(e.options), this.observers = [], this.#i = e.client, this.#t = this.#i.getQueryCache(), this.queryKey = e.queryKey, this.queryHash = e.queryHash, this.#e = se(this.options), this.state = e.state ?? this.#e, this.scheduleGc();
|
|
402
|
-
}
|
|
403
|
-
get meta() {
|
|
404
|
-
return this.options.meta;
|
|
405
|
-
}
|
|
406
|
-
get promise() {
|
|
407
|
-
return this.#r?.promise;
|
|
408
|
-
}
|
|
409
|
-
setOptions(e) {
|
|
410
|
-
this.options = { ...this.#o, ...e }, this.updateGcTime(this.options.gcTime);
|
|
411
|
-
}
|
|
412
|
-
optionalRemove() {
|
|
413
|
-
!this.observers.length && this.state.fetchStatus === "idle" && this.#t.remove(this);
|
|
414
|
-
}
|
|
415
|
-
setData(e, t) {
|
|
416
|
-
const s = z(this.state.data, e, this.options);
|
|
417
|
-
return this.#n({
|
|
418
|
-
data: s,
|
|
419
|
-
type: "success",
|
|
420
|
-
dataUpdatedAt: t?.updatedAt,
|
|
421
|
-
manual: t?.manual
|
|
422
|
-
}), s;
|
|
423
|
-
}
|
|
424
|
-
setState(e, t) {
|
|
425
|
-
this.#n({ type: "setState", state: e, setStateOptions: t });
|
|
426
|
-
}
|
|
427
|
-
cancel(e) {
|
|
428
|
-
const t = this.#r?.promise;
|
|
429
|
-
return this.#r?.cancel(e), t ? t.then(j).catch(j) : Promise.resolve();
|
|
430
|
-
}
|
|
431
|
-
destroy() {
|
|
432
|
-
super.destroy(), this.cancel({ silent: !0 });
|
|
433
|
-
}
|
|
434
|
-
reset() {
|
|
435
|
-
this.destroy(), this.setState(this.#e);
|
|
436
|
-
}
|
|
437
|
-
isActive() {
|
|
438
|
-
return this.observers.some(
|
|
439
|
-
(e) => I(e.options.enabled, this) !== !1
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
isDisabled() {
|
|
443
|
-
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === O || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
|
|
444
|
-
}
|
|
445
|
-
isStale() {
|
|
446
|
-
return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
|
|
447
|
-
(e) => e.getCurrentResult().isStale
|
|
448
|
-
) : this.state.data === void 0;
|
|
449
|
-
}
|
|
450
|
-
isStaleByTime(e = 0) {
|
|
451
|
-
return this.state.isInvalidated || this.state.data === void 0 || !Q(this.state.dataUpdatedAt, e);
|
|
452
|
-
}
|
|
453
|
-
onFocus() {
|
|
454
|
-
this.observers.find((t) => t.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#r?.continue();
|
|
455
|
-
}
|
|
456
|
-
onOnline() {
|
|
457
|
-
this.observers.find((t) => t.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#r?.continue();
|
|
458
|
-
}
|
|
459
|
-
addObserver(e) {
|
|
460
|
-
this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), this.#t.notify({ type: "observerAdded", query: this, observer: e }));
|
|
461
|
-
}
|
|
462
|
-
removeObserver(e) {
|
|
463
|
-
this.observers.includes(e) && (this.observers = this.observers.filter((t) => t !== e), this.observers.length || (this.#r && (this.#a ? this.#r.cancel({ revert: !0 }) : this.#r.cancelRetry()), this.scheduleGc()), this.#t.notify({ type: "observerRemoved", query: this, observer: e }));
|
|
464
|
-
}
|
|
465
|
-
getObserversCount() {
|
|
466
|
-
return this.observers.length;
|
|
467
|
-
}
|
|
468
|
-
invalidate() {
|
|
469
|
-
this.state.isInvalidated || this.#n({ type: "invalidate" });
|
|
470
|
-
}
|
|
471
|
-
fetch(e, t) {
|
|
472
|
-
if (this.state.fetchStatus !== "idle") {
|
|
473
|
-
if (this.state.data !== void 0 && t?.cancelRefetch)
|
|
474
|
-
this.cancel({ silent: !0 });
|
|
475
|
-
else if (this.#r)
|
|
476
|
-
return this.#r.continueRetry(), this.#r.promise;
|
|
477
|
-
}
|
|
478
|
-
if (e && this.setOptions(e), !this.options.queryFn) {
|
|
479
|
-
const r = this.observers.find((o) => o.options.queryFn);
|
|
480
|
-
r && this.setOptions(r.options);
|
|
481
|
-
}
|
|
482
|
-
process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
|
|
483
|
-
"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']"
|
|
484
|
-
));
|
|
485
|
-
const s = new AbortController(), n = (r) => {
|
|
486
|
-
Object.defineProperty(r, "signal", {
|
|
487
|
-
enumerable: !0,
|
|
488
|
-
get: () => (this.#a = !0, s.signal)
|
|
489
|
-
});
|
|
490
|
-
}, i = () => {
|
|
491
|
-
const r = V(this.options, t), o = {
|
|
492
|
-
client: this.#i,
|
|
493
|
-
queryKey: this.queryKey,
|
|
494
|
-
meta: this.meta
|
|
495
|
-
};
|
|
496
|
-
return n(o), this.#a = !1, this.options.persister ? this.options.persister(
|
|
497
|
-
r,
|
|
498
|
-
o,
|
|
499
|
-
this
|
|
500
|
-
) : r(o);
|
|
501
|
-
}, a = {
|
|
502
|
-
fetchOptions: t,
|
|
503
|
-
options: this.options,
|
|
504
|
-
queryKey: this.queryKey,
|
|
505
|
-
client: this.#i,
|
|
506
|
-
state: this.state,
|
|
507
|
-
fetchFn: i
|
|
508
|
-
};
|
|
509
|
-
n(a), this.options.behavior?.onFetch(
|
|
510
|
-
a,
|
|
511
|
-
this
|
|
512
|
-
), this.#s = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== a.fetchOptions?.meta) && this.#n({ type: "fetch", meta: a.fetchOptions?.meta });
|
|
513
|
-
const u = (r) => {
|
|
514
|
-
S(r) && r.silent || this.#n({
|
|
515
|
-
type: "error",
|
|
516
|
-
error: r
|
|
517
|
-
}), S(r) || (this.#t.config.onError?.(
|
|
518
|
-
r,
|
|
519
|
-
this
|
|
520
|
-
), this.#t.config.onSettled?.(
|
|
521
|
-
this.state.data,
|
|
522
|
-
r,
|
|
523
|
-
this
|
|
524
|
-
)), this.scheduleGc();
|
|
525
|
-
};
|
|
526
|
-
return this.#r = X({
|
|
527
|
-
initialPromise: t?.initialPromise,
|
|
528
|
-
fn: a.fetchFn,
|
|
529
|
-
abort: s.abort.bind(s),
|
|
530
|
-
onSuccess: (r) => {
|
|
531
|
-
if (r === void 0) {
|
|
532
|
-
process.env.NODE_ENV !== "production" && console.error(
|
|
533
|
-
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
|
|
534
|
-
), u(new Error(`${this.queryHash} data is undefined`));
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
try {
|
|
538
|
-
this.setData(r);
|
|
539
|
-
} catch (o) {
|
|
540
|
-
u(o);
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
this.#t.config.onSuccess?.(r, this), this.#t.config.onSettled?.(
|
|
544
|
-
r,
|
|
545
|
-
this.state.error,
|
|
546
|
-
this
|
|
547
|
-
), this.scheduleGc();
|
|
548
|
-
},
|
|
549
|
-
onError: u,
|
|
550
|
-
onFail: (r, o) => {
|
|
551
|
-
this.#n({ type: "failed", failureCount: r, error: o });
|
|
552
|
-
},
|
|
553
|
-
onPause: () => {
|
|
554
|
-
this.#n({ type: "pause" });
|
|
555
|
-
},
|
|
556
|
-
onContinue: () => {
|
|
557
|
-
this.#n({ type: "continue" });
|
|
558
|
-
},
|
|
559
|
-
retry: a.options.retry,
|
|
560
|
-
retryDelay: a.options.retryDelay,
|
|
561
|
-
networkMode: a.options.networkMode,
|
|
562
|
-
canRun: () => !0
|
|
563
|
-
}), this.#r.start();
|
|
564
|
-
}
|
|
565
|
-
#n(e) {
|
|
566
|
-
const t = (s) => {
|
|
567
|
-
switch (e.type) {
|
|
568
|
-
case "failed":
|
|
569
|
-
return {
|
|
570
|
-
...s,
|
|
571
|
-
fetchFailureCount: e.failureCount,
|
|
572
|
-
fetchFailureReason: e.error
|
|
573
|
-
};
|
|
574
|
-
case "pause":
|
|
575
|
-
return {
|
|
576
|
-
...s,
|
|
577
|
-
fetchStatus: "paused"
|
|
578
|
-
};
|
|
579
|
-
case "continue":
|
|
580
|
-
return {
|
|
581
|
-
...s,
|
|
582
|
-
fetchStatus: "fetching"
|
|
583
|
-
};
|
|
584
|
-
case "fetch":
|
|
585
|
-
return {
|
|
586
|
-
...s,
|
|
587
|
-
...te(s.data, this.options),
|
|
588
|
-
fetchMeta: e.meta ?? null
|
|
589
|
-
};
|
|
590
|
-
case "success":
|
|
591
|
-
return {
|
|
592
|
-
...s,
|
|
593
|
-
data: e.data,
|
|
594
|
-
dataUpdateCount: s.dataUpdateCount + 1,
|
|
595
|
-
dataUpdatedAt: e.dataUpdatedAt ?? Date.now(),
|
|
596
|
-
error: null,
|
|
597
|
-
isInvalidated: !1,
|
|
598
|
-
status: "success",
|
|
599
|
-
...!e.manual && {
|
|
600
|
-
fetchStatus: "idle",
|
|
601
|
-
fetchFailureCount: 0,
|
|
602
|
-
fetchFailureReason: null
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
case "error":
|
|
606
|
-
const n = e.error;
|
|
607
|
-
return S(n) && n.revert && this.#s ? { ...this.#s, fetchStatus: "idle" } : {
|
|
608
|
-
...s,
|
|
609
|
-
error: n,
|
|
610
|
-
errorUpdateCount: s.errorUpdateCount + 1,
|
|
611
|
-
errorUpdatedAt: Date.now(),
|
|
612
|
-
fetchFailureCount: s.fetchFailureCount + 1,
|
|
613
|
-
fetchFailureReason: n,
|
|
614
|
-
fetchStatus: "idle",
|
|
615
|
-
status: "error"
|
|
616
|
-
};
|
|
617
|
-
case "invalidate":
|
|
618
|
-
return {
|
|
619
|
-
...s,
|
|
620
|
-
isInvalidated: !0
|
|
621
|
-
};
|
|
622
|
-
case "setState":
|
|
623
|
-
return {
|
|
624
|
-
...s,
|
|
625
|
-
...e.state
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
|
-
this.state = t(this.state), Z.batch(() => {
|
|
630
|
-
this.observers.forEach((s) => {
|
|
631
|
-
s.onQueryUpdate();
|
|
632
|
-
}), this.#t.notify({ query: this, type: "updated", action: e });
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
};
|
|
636
|
-
function te(e, t) {
|
|
637
|
-
return {
|
|
638
|
-
fetchFailureCount: 0,
|
|
639
|
-
fetchFailureReason: null,
|
|
640
|
-
fetchStatus: T(t.networkMode) ? "fetching" : "paused",
|
|
641
|
-
...e === void 0 && {
|
|
642
|
-
error: null,
|
|
643
|
-
status: "pending"
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
function se(e) {
|
|
648
|
-
const t = typeof e.initialData == "function" ? e.initialData() : e.initialData, s = t !== void 0, n = s ? typeof e.initialDataUpdatedAt == "function" ? e.initialDataUpdatedAt() : e.initialDataUpdatedAt : 0;
|
|
649
|
-
return {
|
|
650
|
-
data: t,
|
|
651
|
-
dataUpdateCount: 0,
|
|
652
|
-
dataUpdatedAt: s ? n ?? Date.now() : 0,
|
|
653
|
-
error: null,
|
|
654
|
-
errorUpdateCount: 0,
|
|
655
|
-
errorUpdatedAt: 0,
|
|
656
|
-
fetchFailureCount: 0,
|
|
657
|
-
fetchFailureReason: null,
|
|
658
|
-
fetchMeta: null,
|
|
659
|
-
isInvalidated: !1,
|
|
660
|
-
status: s ? "success" : "pending",
|
|
661
|
-
fetchStatus: "idle"
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
var k = C.createContext(
|
|
665
|
-
void 0
|
|
666
|
-
), fe = (e) => {
|
|
667
|
-
const t = C.useContext(k);
|
|
668
|
-
if (!t)
|
|
669
|
-
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
670
|
-
return t;
|
|
671
|
-
}, de = ({
|
|
672
|
-
client: e,
|
|
673
|
-
children: t
|
|
674
|
-
}) => (C.useEffect(() => (e.mount(), () => {
|
|
675
|
-
e.unmount();
|
|
676
|
-
}), [e]), /* @__PURE__ */ N(k.Provider, { value: e, children: t }));
|
|
677
|
-
export {
|
|
678
|
-
le as Q,
|
|
679
|
-
ee as R,
|
|
680
|
-
R as S,
|
|
681
|
-
G as a,
|
|
682
|
-
oe as b,
|
|
683
|
-
X as c,
|
|
684
|
-
j as d,
|
|
685
|
-
V as e,
|
|
686
|
-
he as f,
|
|
687
|
-
ce as g,
|
|
688
|
-
g as h,
|
|
689
|
-
_ as i,
|
|
690
|
-
ne as j,
|
|
691
|
-
O as k,
|
|
692
|
-
de as l,
|
|
693
|
-
ae as m,
|
|
694
|
-
Z as n,
|
|
695
|
-
P as o,
|
|
696
|
-
E as p,
|
|
697
|
-
J as q,
|
|
698
|
-
ie as r,
|
|
699
|
-
ue as s,
|
|
700
|
-
I as t,
|
|
701
|
-
fe as u,
|
|
702
|
-
y as v,
|
|
703
|
-
x as w,
|
|
704
|
-
Q as x,
|
|
705
|
-
te as y,
|
|
706
|
-
z
|
|
707
|
-
};
|