@hortiview/modulebase 1.1.0 → 1.1.1-alpha.3d69639d.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IsRestoringProvider-SzKJZczp.js +931 -0
- package/dist/{ModuleCore-U32BXXin.js → ModuleCore-DRMqZO8r.js} +1388 -1158
- package/dist/components/ModuleBase.js +1 -1
- package/dist/components/ModuleCore.js +1 -1
- package/dist/constants.js +2 -2
- package/dist/hooks/useBreadcrumbTranslation.js +13 -14
- package/dist/hooks/useCustom.js +1 -1
- package/dist/hooks/useCustomMutation.js +4 -15
- package/dist/hooks/useEntity.js +1 -1
- package/dist/hooks/useOffline.js +1 -1
- package/dist/hooks/useOption.js +1 -1
- package/dist/lib/hooks/useStores.d.ts +2 -33
- package/dist/lib/main.d.ts +2 -4
- package/dist/lib/module-router.d.ts +1 -1
- package/dist/lib/types/BaseProps.d.ts +3 -6
- package/dist/main.js +145 -149
- package/dist/module-router.js +132 -138
- package/dist/{useMutation-a0q2LJY6.js → useCustomMutation-9VUQ7NbQ.js} +40 -20
- package/dist/{useQuery-Cepqe-Ee.js → useQuery-DUDyh33-.js} +9 -10
- package/dist/utils/helper.js +1 -1
- package/package.json +1 -1
- package/dist/IsRestoringProvider-BfrdLTDw.js +0 -410
- package/dist/QueryClientProvider-Bak-4BVu.js +0 -531
- package/dist/hooks/useServiceBus.js +0 -25
- package/dist/lib/hooks/useServiceBus.d.ts +0 -19
- package/dist/lib/types/Deprecated.d.ts +0 -103
- package/dist/mutation-DztCHC7y.js +0 -237
- package/dist/types/Deprecated.js +0 -1
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { g as
|
|
3
|
-
import { S as
|
|
4
|
-
|
|
1
|
+
import * as n from "react";
|
|
2
|
+
import { g as m } from "./ModuleCore-DRMqZO8r.js";
|
|
3
|
+
import { S as p, s as l, b as u, n as c, u as d, c as b, d as v } from "./IsRestoringProvider-SzKJZczp.js";
|
|
4
|
+
import "react/jsx-runtime";
|
|
5
|
+
import "./provider/SignalR/SignalRProvider.js";
|
|
6
|
+
import "./stores/BasePropsStore.js";
|
|
7
|
+
import { mutateOnCustomApi as f } from "./utils/fetches.js";
|
|
8
|
+
import "./types/Entities.js";
|
|
9
|
+
import "./api-COabZnyn.js";
|
|
10
|
+
import "./omit-DYPaIq41.js";
|
|
11
|
+
import "./stores/EnvironmentStore.js";
|
|
12
|
+
var y = class extends p {
|
|
5
13
|
#s;
|
|
6
14
|
#i = void 0;
|
|
7
15
|
#t;
|
|
@@ -14,11 +22,11 @@ var f = class extends d {
|
|
|
14
22
|
}
|
|
15
23
|
setOptions(t) {
|
|
16
24
|
const s = this.options;
|
|
17
|
-
this.options = this.#s.defaultMutationOptions(t),
|
|
25
|
+
this.options = this.#s.defaultMutationOptions(t), l(this.options, s) || this.#s.getMutationCache().notify({
|
|
18
26
|
type: "observerOptionsUpdated",
|
|
19
27
|
mutation: this.#t,
|
|
20
28
|
observer: this
|
|
21
|
-
}), s?.mutationKey && this.options.mutationKey &&
|
|
29
|
+
}), s?.mutationKey && this.options.mutationKey && u(s.mutationKey) !== u(this.options.mutationKey) ? this.reset() : this.#t?.state.status === "pending" && this.#t.setOptions(this.options);
|
|
22
30
|
}
|
|
23
31
|
onUnsubscribe() {
|
|
24
32
|
this.hasListeners() || this.#t?.removeObserver(this);
|
|
@@ -36,7 +44,7 @@ var f = class extends d {
|
|
|
36
44
|
return this.#e = s, this.#t?.removeObserver(this), this.#t = this.#s.getMutationCache().build(this.#s, this.options), this.#t.addObserver(this), this.#t.execute(t);
|
|
37
45
|
}
|
|
38
46
|
#r() {
|
|
39
|
-
const t = this.#t?.state ??
|
|
47
|
+
const t = this.#t?.state ?? m();
|
|
40
48
|
this.#i = {
|
|
41
49
|
...t,
|
|
42
50
|
isPending: t.status === "pending",
|
|
@@ -48,7 +56,7 @@ var f = class extends d {
|
|
|
48
56
|
};
|
|
49
57
|
}
|
|
50
58
|
#o(t) {
|
|
51
|
-
|
|
59
|
+
c.batch(() => {
|
|
52
60
|
if (this.#e && this.hasListeners()) {
|
|
53
61
|
const s = this.#i.variables, r = this.#i.context, e = {
|
|
54
62
|
client: this.#s,
|
|
@@ -107,33 +115,45 @@ var f = class extends d {
|
|
|
107
115
|
});
|
|
108
116
|
}
|
|
109
117
|
};
|
|
110
|
-
function
|
|
111
|
-
const r =
|
|
112
|
-
() => new
|
|
118
|
+
function O(t, s) {
|
|
119
|
+
const r = d(s), [e] = n.useState(
|
|
120
|
+
() => new y(
|
|
113
121
|
r,
|
|
114
122
|
t
|
|
115
123
|
)
|
|
116
124
|
);
|
|
117
|
-
|
|
125
|
+
n.useEffect(() => {
|
|
118
126
|
e.setOptions(t);
|
|
119
127
|
}, [e, t]);
|
|
120
|
-
const i =
|
|
121
|
-
|
|
122
|
-
(
|
|
128
|
+
const i = n.useSyncExternalStore(
|
|
129
|
+
n.useCallback(
|
|
130
|
+
(o) => e.subscribe(c.batchCalls(o)),
|
|
123
131
|
[e]
|
|
124
132
|
),
|
|
125
133
|
() => e.getCurrentResult(),
|
|
126
134
|
() => e.getCurrentResult()
|
|
127
|
-
),
|
|
128
|
-
(
|
|
129
|
-
e.mutate(
|
|
135
|
+
), a = n.useCallback(
|
|
136
|
+
(o, h) => {
|
|
137
|
+
e.mutate(o, h).catch(b);
|
|
130
138
|
},
|
|
131
139
|
[e]
|
|
132
140
|
);
|
|
133
141
|
if (i.error && v(e.options.throwOnError, [i.error]))
|
|
134
142
|
throw i.error;
|
|
135
|
-
return { ...i, mutate:
|
|
143
|
+
return { ...i, mutate: a, mutateAsync: i.mutate };
|
|
136
144
|
}
|
|
145
|
+
const P = ({
|
|
146
|
+
endpoint: t,
|
|
147
|
+
method: s,
|
|
148
|
+
token: r,
|
|
149
|
+
headers: e,
|
|
150
|
+
noAuth: i,
|
|
151
|
+
...a
|
|
152
|
+
}) => O({
|
|
153
|
+
mutationFn: ({ input: o, replaceEndpointWith: h }) => f(h ?? t, o, s, r, e, i),
|
|
154
|
+
...a
|
|
155
|
+
});
|
|
137
156
|
export {
|
|
138
|
-
|
|
157
|
+
O as a,
|
|
158
|
+
P as u
|
|
139
159
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { S as q, p as L,
|
|
2
|
-
import { f as J, u as X } from "./IsRestoringProvider-BfrdLTDw.js";
|
|
1
|
+
import { S as q, p as L, r as u, s as M, e as y, c as Q, f as _, i as j, t as K, g as w, j as $, k as G, l as B, n as W, d as z, m as J, u as X } from "./IsRestoringProvider-SzKJZczp.js";
|
|
3
2
|
import * as m from "react";
|
|
4
3
|
import "react/jsx-runtime";
|
|
5
4
|
var Y = class extends q {
|
|
@@ -121,7 +120,7 @@ var Y = class extends q {
|
|
|
121
120
|
this.options.staleTime,
|
|
122
121
|
this.#t
|
|
123
122
|
);
|
|
124
|
-
if (_.isServer() || this.#e.isStale || !
|
|
123
|
+
if (_.isServer() || this.#e.isStale || !j(t))
|
|
125
124
|
return;
|
|
126
125
|
const s = K(this.#e.dataUpdatedAt, t) + 1;
|
|
127
126
|
this.#o = w.setTimeout(() => {
|
|
@@ -132,7 +131,7 @@ var Y = class extends q {
|
|
|
132
131
|
return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#t) : this.options.refetchInterval) ?? !1;
|
|
133
132
|
}
|
|
134
133
|
#g(t) {
|
|
135
|
-
this.#S(), this.#n = t, !(_.isServer() || u(this.options.enabled, this.#t) === !1 || !
|
|
134
|
+
this.#S(), this.#n = t, !(_.isServer() || u(this.options.enabled, this.#t) === !1 || !j(this.#n) || this.#n === 0) && (this.#h = w.setInterval(() => {
|
|
136
135
|
(this.options.refetchIntervalInBackground || $.isFocused()) && this.#c();
|
|
137
136
|
}, this.#n));
|
|
138
137
|
}
|
|
@@ -152,7 +151,7 @@ var Y = class extends q {
|
|
|
152
151
|
const c = this.hasListeners(), g = !c && A(t, e), S = c && H(t, s, e, r);
|
|
153
152
|
(g || S) && (a = {
|
|
154
153
|
...a,
|
|
155
|
-
...
|
|
154
|
+
...G(h.data, t.options)
|
|
156
155
|
}), e._optimisticResults === "isRestoring" && (a.fetchStatus = "idle");
|
|
157
156
|
}
|
|
158
157
|
let { error: R, errorUpdatedAt: x, status: p } = a;
|
|
@@ -163,7 +162,7 @@ var Y = class extends q {
|
|
|
163
162
|
i?.isPlaceholderData && e.placeholderData === n?.placeholderData ? (c = i.data, D = !0) : c = typeof e.placeholderData == "function" ? e.placeholderData(
|
|
164
163
|
this.#d?.state.data,
|
|
165
164
|
this.#d
|
|
166
|
-
) : e.placeholderData, c !== void 0 && (p = "success", o =
|
|
165
|
+
) : e.placeholderData, c !== void 0 && (p = "success", o = B(
|
|
167
166
|
i?.data,
|
|
168
167
|
c,
|
|
169
168
|
e
|
|
@@ -174,7 +173,7 @@ var Y = class extends q {
|
|
|
174
173
|
o = this.#l;
|
|
175
174
|
else
|
|
176
175
|
try {
|
|
177
|
-
this.#m = e.select, o = e.select(o), o =
|
|
176
|
+
this.#m = e.select, o = e.select(o), o = B(i?.data, o, e), this.#l = o, this.#i = null;
|
|
178
177
|
} catch (c) {
|
|
179
178
|
this.#i = c;
|
|
180
179
|
}
|
|
@@ -333,7 +332,7 @@ function ut(t, e, s) {
|
|
|
333
332
|
throw new Error(
|
|
334
333
|
'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'
|
|
335
334
|
);
|
|
336
|
-
const r =
|
|
335
|
+
const r = J(), i = rt(), l = X(s), n = l.defaultQueryOptions(t);
|
|
337
336
|
l.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
338
337
|
n
|
|
339
338
|
);
|
|
@@ -382,11 +381,11 @@ function ut(t, e, s) {
|
|
|
382
381
|
h.updateResult();
|
|
383
382
|
}), n.notifyOnChangeProps ? a : h.trackResult(a);
|
|
384
383
|
}
|
|
385
|
-
function
|
|
384
|
+
function pt(t, e) {
|
|
386
385
|
return ut(t, Y, e);
|
|
387
386
|
}
|
|
388
387
|
export {
|
|
389
388
|
Y as Q,
|
|
390
389
|
ut as a,
|
|
391
|
-
|
|
390
|
+
pt as u
|
|
392
391
|
};
|
package/dist/utils/helper.js
CHANGED
|
@@ -25,7 +25,7 @@ const g = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([
|
|
|
25
25
|
}, E = (r, e) => {
|
|
26
26
|
const t = c(r), n = c(e), o = t.pop(), i = n.pop(), s = p(t, n);
|
|
27
27
|
return s !== 0 ? s : o && i ? p(o.split("."), i.split(".")) : o || i ? o ? -1 : 1 : 0;
|
|
28
|
-
}, d = "1.0
|
|
28
|
+
}, d = "1.1.0", w = (r) => m.every((e) => y(e, r)), y = (r, e) => {
|
|
29
29
|
if (!e[r]) {
|
|
30
30
|
if (e.throwError)
|
|
31
31
|
return e.throwError(`Missing required prop: ${r}`, 404), !1;
|
package/package.json
CHANGED
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import { e as A, d as k, f as K, g as Q, R as T, r as E, a as P, i as M, j as N, k as G, t as j, c as H, C, n as _, l as x } from "./QueryClientProvider-Bak-4BVu.js";
|
|
2
|
-
import * as w from "react";
|
|
3
|
-
function B(t) {
|
|
4
|
-
return {
|
|
5
|
-
onFetch: (e, r) => {
|
|
6
|
-
const a = e.options, u = e.fetchOptions?.meta?.fetchMore?.direction, f = e.state.data?.pages || [], n = e.state.data?.pageParams || [];
|
|
7
|
-
let c = { pages: [], pageParams: [] }, s = 0;
|
|
8
|
-
const h = async () => {
|
|
9
|
-
let l = !1;
|
|
10
|
-
const p = (i) => {
|
|
11
|
-
Q(
|
|
12
|
-
i,
|
|
13
|
-
() => e.signal,
|
|
14
|
-
() => l = !0
|
|
15
|
-
);
|
|
16
|
-
}, R = A(e.options, e.fetchOptions), v = async (i, o, d) => {
|
|
17
|
-
if (l)
|
|
18
|
-
return Promise.reject(e.signal.reason);
|
|
19
|
-
if (o == null && i.pages.length)
|
|
20
|
-
return Promise.resolve(i);
|
|
21
|
-
const O = (() => {
|
|
22
|
-
const b = {
|
|
23
|
-
client: e.client,
|
|
24
|
-
queryKey: e.queryKey,
|
|
25
|
-
pageParam: o,
|
|
26
|
-
direction: d ? "backward" : "forward",
|
|
27
|
-
meta: e.options.meta
|
|
28
|
-
};
|
|
29
|
-
return p(b), b;
|
|
30
|
-
})(), I = await R(O), { maxPages: m } = e.options, F = d ? k : K;
|
|
31
|
-
return {
|
|
32
|
-
pages: F(i.pages, I, m),
|
|
33
|
-
pageParams: F(i.pageParams, o, m)
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
if (u && f.length) {
|
|
37
|
-
const i = u === "backward", o = i ? D : y, d = {
|
|
38
|
-
pages: f,
|
|
39
|
-
pageParams: n
|
|
40
|
-
}, g = o(a, d);
|
|
41
|
-
c = await v(d, g, i);
|
|
42
|
-
} else {
|
|
43
|
-
const i = t ?? f.length;
|
|
44
|
-
do {
|
|
45
|
-
const o = s === 0 ? n[0] ?? a.initialPageParam : y(a, c);
|
|
46
|
-
if (s > 0 && o == null)
|
|
47
|
-
break;
|
|
48
|
-
c = await v(c, o), s++;
|
|
49
|
-
} while (s < i);
|
|
50
|
-
}
|
|
51
|
-
return c;
|
|
52
|
-
};
|
|
53
|
-
e.options.persister ? e.fetchFn = () => e.options.persister?.(
|
|
54
|
-
h,
|
|
55
|
-
{
|
|
56
|
-
client: e.client,
|
|
57
|
-
queryKey: e.queryKey,
|
|
58
|
-
meta: e.options.meta,
|
|
59
|
-
signal: e.signal
|
|
60
|
-
},
|
|
61
|
-
r
|
|
62
|
-
) : e.fetchFn = h;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function y(t, { pages: e, pageParams: r }) {
|
|
67
|
-
const a = e.length - 1;
|
|
68
|
-
return e.length > 0 ? t.getNextPageParam(
|
|
69
|
-
e[a],
|
|
70
|
-
e,
|
|
71
|
-
r[a],
|
|
72
|
-
r
|
|
73
|
-
) : void 0;
|
|
74
|
-
}
|
|
75
|
-
function D(t, { pages: e, pageParams: r }) {
|
|
76
|
-
return e.length > 0 ? t.getPreviousPageParam?.(e[0], e, r[0], r) : void 0;
|
|
77
|
-
}
|
|
78
|
-
function W(t, e) {
|
|
79
|
-
return e ? y(t, e) != null : !1;
|
|
80
|
-
}
|
|
81
|
-
function z(t, e) {
|
|
82
|
-
return !e || !t.getPreviousPageParam ? !1 : D(t, e) != null;
|
|
83
|
-
}
|
|
84
|
-
var J = class extends T {
|
|
85
|
-
#n;
|
|
86
|
-
#r;
|
|
87
|
-
#o;
|
|
88
|
-
#e;
|
|
89
|
-
#a;
|
|
90
|
-
#t;
|
|
91
|
-
#u;
|
|
92
|
-
#i;
|
|
93
|
-
constructor(t) {
|
|
94
|
-
super(), this.#i = !1, this.#u = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#a = t.client, this.#e = this.#a.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#r = q(this.options), this.state = t.state ?? this.#r, this.scheduleGc();
|
|
95
|
-
}
|
|
96
|
-
get meta() {
|
|
97
|
-
return this.options.meta;
|
|
98
|
-
}
|
|
99
|
-
get queryType() {
|
|
100
|
-
return this.#n;
|
|
101
|
-
}
|
|
102
|
-
get promise() {
|
|
103
|
-
return this.#t?.promise;
|
|
104
|
-
}
|
|
105
|
-
setOptions(t) {
|
|
106
|
-
if (this.options = { ...this.#u, ...t }, t?._type && (this.#n = t._type), this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
|
|
107
|
-
const e = q(this.options);
|
|
108
|
-
e.data !== void 0 && (this.setState(
|
|
109
|
-
S(e.data, e.dataUpdatedAt)
|
|
110
|
-
), this.#r = e);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
optionalRemove() {
|
|
114
|
-
!this.observers.length && this.state.fetchStatus === "idle" && this.#e.remove(this);
|
|
115
|
-
}
|
|
116
|
-
setData(t, e) {
|
|
117
|
-
const r = E(this.state.data, t, this.options);
|
|
118
|
-
return this.#s({
|
|
119
|
-
data: r,
|
|
120
|
-
type: "success",
|
|
121
|
-
dataUpdatedAt: e?.updatedAt,
|
|
122
|
-
manual: e?.manual
|
|
123
|
-
}), r;
|
|
124
|
-
}
|
|
125
|
-
setState(t) {
|
|
126
|
-
this.#s({ type: "setState", state: t });
|
|
127
|
-
}
|
|
128
|
-
cancel(t) {
|
|
129
|
-
const e = this.#t?.promise;
|
|
130
|
-
return this.#t?.cancel(t), e ? e.then(P).catch(P) : Promise.resolve();
|
|
131
|
-
}
|
|
132
|
-
destroy() {
|
|
133
|
-
super.destroy(), this.cancel({ silent: !0 });
|
|
134
|
-
}
|
|
135
|
-
get resetState() {
|
|
136
|
-
return this.#r;
|
|
137
|
-
}
|
|
138
|
-
reset() {
|
|
139
|
-
this.destroy(), this.setState(this.resetState);
|
|
140
|
-
}
|
|
141
|
-
isActive() {
|
|
142
|
-
return this.observers.some(
|
|
143
|
-
(t) => M(t.options.enabled, this) !== !1
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
isDisabled() {
|
|
147
|
-
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === N || !this.isFetched();
|
|
148
|
-
}
|
|
149
|
-
isFetched() {
|
|
150
|
-
return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
|
|
151
|
-
}
|
|
152
|
-
isStatic() {
|
|
153
|
-
return this.getObserversCount() > 0 ? this.observers.some(
|
|
154
|
-
(t) => G(t.options.staleTime, this) === "static"
|
|
155
|
-
) : !1;
|
|
156
|
-
}
|
|
157
|
-
isStale() {
|
|
158
|
-
return this.getObserversCount() > 0 ? this.observers.some(
|
|
159
|
-
(t) => t.getCurrentResult().isStale
|
|
160
|
-
) : this.state.data === void 0 || this.state.isInvalidated;
|
|
161
|
-
}
|
|
162
|
-
isStaleByTime(t = 0) {
|
|
163
|
-
return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !j(this.state.dataUpdatedAt, t);
|
|
164
|
-
}
|
|
165
|
-
onFocus() {
|
|
166
|
-
this.observers.find((e) => e.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
|
|
167
|
-
}
|
|
168
|
-
onOnline() {
|
|
169
|
-
this.observers.find((e) => e.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
|
|
170
|
-
}
|
|
171
|
-
addObserver(t) {
|
|
172
|
-
this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), this.#e.notify({ type: "observerAdded", query: this, observer: t }));
|
|
173
|
-
}
|
|
174
|
-
removeObserver(t) {
|
|
175
|
-
this.observers.includes(t) && (this.observers = this.observers.filter((e) => e !== t), this.observers.length || (this.#t && (this.#i || this.#h() ? this.#t.cancel({ revert: !0 }) : this.#t.cancelRetry()), this.scheduleGc()), this.#e.notify({ type: "observerRemoved", query: this, observer: t }));
|
|
176
|
-
}
|
|
177
|
-
getObserversCount() {
|
|
178
|
-
return this.observers.length;
|
|
179
|
-
}
|
|
180
|
-
#h() {
|
|
181
|
-
return this.state.fetchStatus === "paused" && this.state.status === "pending";
|
|
182
|
-
}
|
|
183
|
-
invalidate() {
|
|
184
|
-
this.state.isInvalidated || this.#s({ type: "invalidate" });
|
|
185
|
-
}
|
|
186
|
-
async fetch(t, e) {
|
|
187
|
-
if (this.state.fetchStatus !== "idle" && // If the promise in the retryer is already rejected, we have to definitely
|
|
188
|
-
// re-start the fetch; there is a chance that the query is still in a
|
|
189
|
-
// pending state when that happens
|
|
190
|
-
this.#t?.status() !== "rejected") {
|
|
191
|
-
if (this.state.data !== void 0 && e?.cancelRefetch)
|
|
192
|
-
this.cancel({ silent: !0 });
|
|
193
|
-
else if (this.#t)
|
|
194
|
-
return this.#t.continueRetry(), this.#t.promise;
|
|
195
|
-
}
|
|
196
|
-
if (t && this.setOptions(t), !this.options.queryFn) {
|
|
197
|
-
const s = this.observers.find((h) => h.options.queryFn);
|
|
198
|
-
s && this.setOptions(s.options);
|
|
199
|
-
}
|
|
200
|
-
process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
|
|
201
|
-
"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']"
|
|
202
|
-
));
|
|
203
|
-
const r = new AbortController(), a = (s) => {
|
|
204
|
-
Object.defineProperty(s, "signal", {
|
|
205
|
-
enumerable: !0,
|
|
206
|
-
get: () => (this.#i = !0, r.signal)
|
|
207
|
-
});
|
|
208
|
-
}, u = () => {
|
|
209
|
-
const s = A(this.options, e), l = (() => {
|
|
210
|
-
const p = {
|
|
211
|
-
client: this.#a,
|
|
212
|
-
queryKey: this.queryKey,
|
|
213
|
-
meta: this.meta
|
|
214
|
-
};
|
|
215
|
-
return a(p), p;
|
|
216
|
-
})();
|
|
217
|
-
return this.#i = !1, this.options.persister ? this.options.persister(
|
|
218
|
-
s,
|
|
219
|
-
l,
|
|
220
|
-
this
|
|
221
|
-
) : s(l);
|
|
222
|
-
}, n = (() => {
|
|
223
|
-
const s = {
|
|
224
|
-
fetchOptions: e,
|
|
225
|
-
options: this.options,
|
|
226
|
-
queryKey: this.queryKey,
|
|
227
|
-
client: this.#a,
|
|
228
|
-
state: this.state,
|
|
229
|
-
fetchFn: u
|
|
230
|
-
};
|
|
231
|
-
return a(s), s;
|
|
232
|
-
})();
|
|
233
|
-
(this.#n === "infinite" ? B(
|
|
234
|
-
this.options.pages
|
|
235
|
-
) : this.options.behavior)?.onFetch(n, this), this.#o = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== n.fetchOptions?.meta) && this.#s({ type: "fetch", meta: n.fetchOptions?.meta }), this.#t = H({
|
|
236
|
-
initialPromise: e?.initialPromise,
|
|
237
|
-
fn: n.fetchFn,
|
|
238
|
-
onCancel: (s) => {
|
|
239
|
-
s instanceof C && s.revert && this.setState({
|
|
240
|
-
...this.#o,
|
|
241
|
-
fetchStatus: "idle"
|
|
242
|
-
}), r.abort();
|
|
243
|
-
},
|
|
244
|
-
onFail: (s, h) => {
|
|
245
|
-
this.#s({ type: "failed", failureCount: s, error: h });
|
|
246
|
-
},
|
|
247
|
-
onPause: () => {
|
|
248
|
-
this.#s({ type: "pause" });
|
|
249
|
-
},
|
|
250
|
-
onContinue: () => {
|
|
251
|
-
this.#s({ type: "continue" });
|
|
252
|
-
},
|
|
253
|
-
retry: n.options.retry,
|
|
254
|
-
retryDelay: n.options.retryDelay,
|
|
255
|
-
networkMode: n.options.networkMode,
|
|
256
|
-
canRun: () => !0
|
|
257
|
-
});
|
|
258
|
-
try {
|
|
259
|
-
const s = await this.#t.start();
|
|
260
|
-
if (s === void 0)
|
|
261
|
-
throw process.env.NODE_ENV !== "production" && console.error(
|
|
262
|
-
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
|
|
263
|
-
), new Error(`${this.queryHash} data is undefined`);
|
|
264
|
-
return this.setData(s), this.#e.config.onSuccess?.(s, this), this.#e.config.onSettled?.(
|
|
265
|
-
s,
|
|
266
|
-
this.state.error,
|
|
267
|
-
this
|
|
268
|
-
), s;
|
|
269
|
-
} catch (s) {
|
|
270
|
-
if (s instanceof C) {
|
|
271
|
-
if (s.silent)
|
|
272
|
-
return this.#t.promise;
|
|
273
|
-
if (s.revert) {
|
|
274
|
-
if (this.state.data === void 0)
|
|
275
|
-
throw s;
|
|
276
|
-
return this.state.data;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
throw this.#s({
|
|
280
|
-
type: "error",
|
|
281
|
-
error: s
|
|
282
|
-
}), this.#e.config.onError?.(
|
|
283
|
-
s,
|
|
284
|
-
this
|
|
285
|
-
), this.#e.config.onSettled?.(
|
|
286
|
-
this.state.data,
|
|
287
|
-
s,
|
|
288
|
-
this
|
|
289
|
-
), s;
|
|
290
|
-
} finally {
|
|
291
|
-
this.scheduleGc();
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
#s(t) {
|
|
295
|
-
const e = (r) => {
|
|
296
|
-
switch (t.type) {
|
|
297
|
-
case "failed":
|
|
298
|
-
return {
|
|
299
|
-
...r,
|
|
300
|
-
fetchFailureCount: t.failureCount,
|
|
301
|
-
fetchFailureReason: t.error
|
|
302
|
-
};
|
|
303
|
-
case "pause":
|
|
304
|
-
return {
|
|
305
|
-
...r,
|
|
306
|
-
fetchStatus: "paused"
|
|
307
|
-
};
|
|
308
|
-
case "continue":
|
|
309
|
-
return {
|
|
310
|
-
...r,
|
|
311
|
-
fetchStatus: "fetching"
|
|
312
|
-
};
|
|
313
|
-
case "fetch":
|
|
314
|
-
return {
|
|
315
|
-
...r,
|
|
316
|
-
...V(r.data, this.options),
|
|
317
|
-
fetchMeta: t.meta ?? null
|
|
318
|
-
};
|
|
319
|
-
case "success":
|
|
320
|
-
const a = {
|
|
321
|
-
...r,
|
|
322
|
-
...S(t.data, t.dataUpdatedAt),
|
|
323
|
-
dataUpdateCount: r.dataUpdateCount + 1,
|
|
324
|
-
...!t.manual && {
|
|
325
|
-
fetchStatus: "idle",
|
|
326
|
-
fetchFailureCount: 0,
|
|
327
|
-
fetchFailureReason: null
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
return this.#o = t.manual ? a : void 0, a;
|
|
331
|
-
case "error":
|
|
332
|
-
const u = t.error;
|
|
333
|
-
return {
|
|
334
|
-
...r,
|
|
335
|
-
error: u,
|
|
336
|
-
errorUpdateCount: r.errorUpdateCount + 1,
|
|
337
|
-
errorUpdatedAt: Date.now(),
|
|
338
|
-
fetchFailureCount: r.fetchFailureCount + 1,
|
|
339
|
-
fetchFailureReason: u,
|
|
340
|
-
fetchStatus: "idle",
|
|
341
|
-
status: "error",
|
|
342
|
-
// flag existing data as invalidated if we get a background error
|
|
343
|
-
// note that "no data" always means stale so we can set unconditionally here
|
|
344
|
-
isInvalidated: !0
|
|
345
|
-
};
|
|
346
|
-
case "invalidate":
|
|
347
|
-
return {
|
|
348
|
-
...r,
|
|
349
|
-
isInvalidated: !0
|
|
350
|
-
};
|
|
351
|
-
case "setState":
|
|
352
|
-
return {
|
|
353
|
-
...r,
|
|
354
|
-
...t.state
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
this.state = e(this.state), _.batch(() => {
|
|
359
|
-
this.observers.forEach((r) => {
|
|
360
|
-
r.onQueryUpdate();
|
|
361
|
-
}), this.#e.notify({ query: this, type: "updated", action: t });
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
function V(t, e) {
|
|
366
|
-
return {
|
|
367
|
-
fetchFailureCount: 0,
|
|
368
|
-
fetchFailureReason: null,
|
|
369
|
-
fetchStatus: x(e.networkMode) ? "fetching" : "paused",
|
|
370
|
-
...t === void 0 && {
|
|
371
|
-
error: null,
|
|
372
|
-
status: "pending"
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
function S(t, e) {
|
|
377
|
-
return {
|
|
378
|
-
data: t,
|
|
379
|
-
dataUpdatedAt: e ?? Date.now(),
|
|
380
|
-
error: null,
|
|
381
|
-
isInvalidated: !1,
|
|
382
|
-
status: "success"
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
function q(t) {
|
|
386
|
-
const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, r = e !== void 0, a = r ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
|
|
387
|
-
return {
|
|
388
|
-
data: e,
|
|
389
|
-
dataUpdateCount: 0,
|
|
390
|
-
dataUpdatedAt: r ? a ?? Date.now() : 0,
|
|
391
|
-
error: null,
|
|
392
|
-
errorUpdateCount: 0,
|
|
393
|
-
errorUpdatedAt: 0,
|
|
394
|
-
fetchFailureCount: 0,
|
|
395
|
-
fetchFailureReason: null,
|
|
396
|
-
fetchMeta: null,
|
|
397
|
-
isInvalidated: !1,
|
|
398
|
-
status: r ? "success" : "pending",
|
|
399
|
-
fetchStatus: "idle"
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
var U = w.createContext(!1), L = () => w.useContext(U), X = U.Provider;
|
|
403
|
-
export {
|
|
404
|
-
X as I,
|
|
405
|
-
J as Q,
|
|
406
|
-
W as a,
|
|
407
|
-
V as f,
|
|
408
|
-
z as h,
|
|
409
|
-
L as u
|
|
410
|
-
};
|