@hortiview/modulebase 0.0.13101-beta → 0.0.13103-beta
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/{isRestoring-LSIsLTaI.js → IsRestoringProvider-B1U_sG8s.js} +86 -78
- package/dist/{ModuleCore-BWvRhZyP.js → ModuleCore-DcwaLp89.js} +4360 -4318
- package/dist/{QueryClientProvider-BSM1ol7r.js → QueryClientProvider-C7EHlqBQ.js} +102 -98
- package/dist/chunk-QMGIS6GS-C4bgXQXY.js +9203 -0
- package/dist/components/ModuleBase.js +2 -2
- package/dist/components/ModuleCore.js +1 -1
- package/dist/enum/ActionStorage.js +4 -0
- package/dist/hooks/useCustom.js +1 -1
- package/dist/hooks/useCustomMutation.js +2 -2
- package/dist/hooks/useEntity.js +1 -1
- package/dist/hooks/useOffline.js +1 -1
- package/dist/hooks/useOption.js +1 -1
- package/dist/hooks/useServiceBus.js +1 -1
- package/dist/lib/enum/ActionStorage.d.ts +7 -0
- package/dist/lib/hooks/useCustom.d.ts +1 -1
- package/dist/lib/hooks/useStores.d.ts +2 -1
- package/dist/lib/main.d.ts +1 -0
- package/dist/lib/types/ActionStorage.d.ts +1 -6
- package/dist/lib/types/BaseProps.d.ts +1 -0
- package/dist/main.js +175 -165
- package/dist/module-router.js +101 -93
- package/dist/{mutation-EhVtpjb0.js → mutation-CJplExaP.js} +17 -14
- package/dist/types/ActionStorage.js +1 -4
- package/dist/{useMutation-BYO7aks8.js → useMutation-BEK2_IOo.js} +16 -17
- package/dist/{useQuery-Jx956wwH.js → useQuery-B23OSvXW.js} +124 -136
- package/dist/utils/helper.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-IR6S3I6Y-BmDdD3SP.js +0 -8162
- package/dist/utils-DxRR_XLb.js +0 -9
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { R as
|
|
2
|
-
import * as
|
|
3
|
-
var
|
|
4
|
-
#a;
|
|
1
|
+
import { R as y, r as v, a as d, d as b, e as m, f as C, t as F, c as g, n as S, i as h, g as q, j as A } from "./QueryClientProvider-C7EHlqBQ.js";
|
|
2
|
+
import * as l from "react";
|
|
3
|
+
var x = class extends y {
|
|
5
4
|
#n;
|
|
5
|
+
#r;
|
|
6
6
|
#e;
|
|
7
7
|
#i;
|
|
8
8
|
#t;
|
|
9
9
|
#o;
|
|
10
|
-
#
|
|
10
|
+
#a;
|
|
11
11
|
constructor(t) {
|
|
12
|
-
super(), this.#
|
|
12
|
+
super(), this.#a = !1, this.#o = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#i = t.client, this.#e = this.#i.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#n = R(this.options), this.state = t.state ?? this.#n, this.scheduleGc();
|
|
13
13
|
}
|
|
14
14
|
get meta() {
|
|
15
15
|
return this.options.meta;
|
|
@@ -24,7 +24,7 @@ var D = class extends f {
|
|
|
24
24
|
!this.observers.length && this.state.fetchStatus === "idle" && this.#e.remove(this);
|
|
25
25
|
}
|
|
26
26
|
setData(t, e) {
|
|
27
|
-
const s =
|
|
27
|
+
const s = v(this.state.data, t, this.options);
|
|
28
28
|
return this.#s({
|
|
29
29
|
data: s,
|
|
30
30
|
type: "success",
|
|
@@ -37,29 +37,34 @@ var D = class extends f {
|
|
|
37
37
|
}
|
|
38
38
|
cancel(t) {
|
|
39
39
|
const e = this.#t?.promise;
|
|
40
|
-
return this.#t?.cancel(t), e ? e.then(
|
|
40
|
+
return this.#t?.cancel(t), e ? e.then(d).catch(d) : Promise.resolve();
|
|
41
41
|
}
|
|
42
42
|
destroy() {
|
|
43
43
|
super.destroy(), this.cancel({ silent: !0 });
|
|
44
44
|
}
|
|
45
45
|
reset() {
|
|
46
|
-
this.destroy(), this.setState(this.#
|
|
46
|
+
this.destroy(), this.setState(this.#n);
|
|
47
47
|
}
|
|
48
48
|
isActive() {
|
|
49
49
|
return this.observers.some(
|
|
50
|
-
(t) =>
|
|
50
|
+
(t) => b(t.options.enabled, this) !== !1
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
isDisabled() {
|
|
54
|
-
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn ===
|
|
54
|
+
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === m || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
|
|
55
|
+
}
|
|
56
|
+
isStatic() {
|
|
57
|
+
return this.getObserversCount() > 0 ? this.observers.some(
|
|
58
|
+
(t) => C(t.options.staleTime, this) === "static"
|
|
59
|
+
) : !1;
|
|
55
60
|
}
|
|
56
61
|
isStale() {
|
|
57
|
-
return this.
|
|
62
|
+
return this.getObserversCount() > 0 ? this.observers.some(
|
|
58
63
|
(t) => t.getCurrentResult().isStale
|
|
59
|
-
) : this.state.data === void 0;
|
|
64
|
+
) : this.state.data === void 0 || this.state.isInvalidated;
|
|
60
65
|
}
|
|
61
66
|
isStaleByTime(t = 0) {
|
|
62
|
-
return this.state.
|
|
67
|
+
return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !F(this.state.dataUpdatedAt, t);
|
|
63
68
|
}
|
|
64
69
|
onFocus() {
|
|
65
70
|
this.observers.find((e) => e.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
|
|
@@ -71,7 +76,7 @@ var D = class extends f {
|
|
|
71
76
|
this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), this.#e.notify({ type: "observerAdded", query: this, observer: t }));
|
|
72
77
|
}
|
|
73
78
|
removeObserver(t) {
|
|
74
|
-
this.observers.includes(t) && (this.observers = this.observers.filter((e) => e !== t), this.observers.length || (this.#t && (this.#
|
|
79
|
+
this.observers.includes(t) && (this.observers = this.observers.filter((e) => e !== t), this.observers.length || (this.#t && (this.#a ? this.#t.cancel({ revert: !0 }) : this.#t.cancelRetry()), this.scheduleGc()), this.#e.notify({ type: "observerRemoved", query: this, observer: t }));
|
|
75
80
|
}
|
|
76
81
|
getObserversCount() {
|
|
77
82
|
return this.observers.length;
|
|
@@ -87,79 +92,82 @@ var D = class extends f {
|
|
|
87
92
|
return this.#t.continueRetry(), this.#t.promise;
|
|
88
93
|
}
|
|
89
94
|
if (t && this.setOptions(t), !this.options.queryFn) {
|
|
90
|
-
const
|
|
91
|
-
|
|
95
|
+
const r = this.observers.find((n) => n.options.queryFn);
|
|
96
|
+
r && this.setOptions(r.options);
|
|
92
97
|
}
|
|
93
98
|
process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
|
|
94
99
|
"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']"
|
|
95
100
|
));
|
|
96
|
-
const s = new AbortController(),
|
|
97
|
-
Object.defineProperty(
|
|
101
|
+
const s = new AbortController(), i = (r) => {
|
|
102
|
+
Object.defineProperty(r, "signal", {
|
|
98
103
|
enumerable: !0,
|
|
99
|
-
get: () => (this.#
|
|
104
|
+
get: () => (this.#a = !0, s.signal)
|
|
100
105
|
});
|
|
101
|
-
},
|
|
102
|
-
const
|
|
103
|
-
|
|
106
|
+
}, p = () => {
|
|
107
|
+
const r = A(this.options, e), u = (() => {
|
|
108
|
+
const c = {
|
|
109
|
+
client: this.#i,
|
|
110
|
+
queryKey: this.queryKey,
|
|
111
|
+
meta: this.meta
|
|
112
|
+
};
|
|
113
|
+
return i(c), c;
|
|
114
|
+
})();
|
|
115
|
+
return this.#a = !1, this.options.persister ? this.options.persister(
|
|
116
|
+
r,
|
|
117
|
+
u,
|
|
118
|
+
this
|
|
119
|
+
) : r(u);
|
|
120
|
+
}, a = (() => {
|
|
121
|
+
const r = {
|
|
122
|
+
fetchOptions: e,
|
|
123
|
+
options: this.options,
|
|
104
124
|
queryKey: this.queryKey,
|
|
105
|
-
|
|
125
|
+
client: this.#i,
|
|
126
|
+
state: this.state,
|
|
127
|
+
fetchFn: p
|
|
106
128
|
};
|
|
107
|
-
return r
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
)
|
|
112
|
-
}, n = {
|
|
113
|
-
fetchOptions: e,
|
|
114
|
-
options: this.options,
|
|
115
|
-
queryKey: this.queryKey,
|
|
116
|
-
client: this.#i,
|
|
117
|
-
state: this.state,
|
|
118
|
-
fetchFn: l
|
|
119
|
-
};
|
|
120
|
-
r(n), this.options.behavior?.onFetch(
|
|
121
|
-
n,
|
|
122
|
-
this
|
|
123
|
-
), this.#n = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== n.fetchOptions?.meta) && this.#s({ type: "fetch", meta: n.fetchOptions?.meta });
|
|
124
|
-
const o = (i) => {
|
|
125
|
-
h(i) && i.silent || this.#s({
|
|
129
|
+
return i(r), r;
|
|
130
|
+
})();
|
|
131
|
+
this.options.behavior?.onFetch(a, this), this.#r = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== a.fetchOptions?.meta) && this.#s({ type: "fetch", meta: a.fetchOptions?.meta });
|
|
132
|
+
const o = (r) => {
|
|
133
|
+
h(r) && r.silent || this.#s({
|
|
126
134
|
type: "error",
|
|
127
|
-
error:
|
|
128
|
-
}), h(
|
|
129
|
-
|
|
135
|
+
error: r
|
|
136
|
+
}), h(r) || (this.#e.config.onError?.(
|
|
137
|
+
r,
|
|
130
138
|
this
|
|
131
139
|
), this.#e.config.onSettled?.(
|
|
132
140
|
this.state.data,
|
|
133
|
-
|
|
141
|
+
r,
|
|
134
142
|
this
|
|
135
143
|
)), this.scheduleGc();
|
|
136
144
|
};
|
|
137
|
-
return this.#t =
|
|
145
|
+
return this.#t = g({
|
|
138
146
|
initialPromise: e?.initialPromise,
|
|
139
|
-
fn:
|
|
147
|
+
fn: a.fetchFn,
|
|
140
148
|
abort: s.abort.bind(s),
|
|
141
|
-
onSuccess: (
|
|
142
|
-
if (
|
|
149
|
+
onSuccess: (r) => {
|
|
150
|
+
if (r === void 0) {
|
|
143
151
|
process.env.NODE_ENV !== "production" && console.error(
|
|
144
152
|
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
|
|
145
153
|
), o(new Error(`${this.queryHash} data is undefined`));
|
|
146
154
|
return;
|
|
147
155
|
}
|
|
148
156
|
try {
|
|
149
|
-
this.setData(
|
|
150
|
-
} catch (
|
|
151
|
-
o(
|
|
157
|
+
this.setData(r);
|
|
158
|
+
} catch (n) {
|
|
159
|
+
o(n);
|
|
152
160
|
return;
|
|
153
161
|
}
|
|
154
|
-
this.#e.config.onSuccess?.(
|
|
155
|
-
|
|
162
|
+
this.#e.config.onSuccess?.(r, this), this.#e.config.onSettled?.(
|
|
163
|
+
r,
|
|
156
164
|
this.state.error,
|
|
157
165
|
this
|
|
158
166
|
), this.scheduleGc();
|
|
159
167
|
},
|
|
160
168
|
onError: o,
|
|
161
|
-
onFail: (
|
|
162
|
-
this.#s({ type: "failed", failureCount:
|
|
169
|
+
onFail: (r, n) => {
|
|
170
|
+
this.#s({ type: "failed", failureCount: r, error: n });
|
|
163
171
|
},
|
|
164
172
|
onPause: () => {
|
|
165
173
|
this.#s({ type: "pause" });
|
|
@@ -167,9 +175,9 @@ var D = class extends f {
|
|
|
167
175
|
onContinue: () => {
|
|
168
176
|
this.#s({ type: "continue" });
|
|
169
177
|
},
|
|
170
|
-
retry:
|
|
171
|
-
retryDelay:
|
|
172
|
-
networkMode:
|
|
178
|
+
retry: a.options.retry,
|
|
179
|
+
retryDelay: a.options.retryDelay,
|
|
180
|
+
networkMode: a.options.networkMode,
|
|
173
181
|
canRun: () => !0
|
|
174
182
|
}), this.#t.start();
|
|
175
183
|
}
|
|
@@ -195,11 +203,11 @@ var D = class extends f {
|
|
|
195
203
|
case "fetch":
|
|
196
204
|
return {
|
|
197
205
|
...s,
|
|
198
|
-
...
|
|
206
|
+
...D(s.data, this.options),
|
|
199
207
|
fetchMeta: t.meta ?? null
|
|
200
208
|
};
|
|
201
209
|
case "success":
|
|
202
|
-
return {
|
|
210
|
+
return this.#r = void 0, {
|
|
203
211
|
...s,
|
|
204
212
|
data: t.data,
|
|
205
213
|
dataUpdateCount: s.dataUpdateCount + 1,
|
|
@@ -214,14 +222,14 @@ var D = class extends f {
|
|
|
214
222
|
}
|
|
215
223
|
};
|
|
216
224
|
case "error":
|
|
217
|
-
const
|
|
218
|
-
return h(
|
|
225
|
+
const i = t.error;
|
|
226
|
+
return h(i) && i.revert && this.#r ? { ...this.#r, fetchStatus: "idle" } : {
|
|
219
227
|
...s,
|
|
220
|
-
error:
|
|
228
|
+
error: i,
|
|
221
229
|
errorUpdateCount: s.errorUpdateCount + 1,
|
|
222
230
|
errorUpdatedAt: Date.now(),
|
|
223
231
|
fetchFailureCount: s.fetchFailureCount + 1,
|
|
224
|
-
fetchFailureReason:
|
|
232
|
+
fetchFailureReason: i,
|
|
225
233
|
fetchStatus: "idle",
|
|
226
234
|
status: "error"
|
|
227
235
|
};
|
|
@@ -237,30 +245,30 @@ var D = class extends f {
|
|
|
237
245
|
};
|
|
238
246
|
}
|
|
239
247
|
};
|
|
240
|
-
this.state = e(this.state),
|
|
248
|
+
this.state = e(this.state), S.batch(() => {
|
|
241
249
|
this.observers.forEach((s) => {
|
|
242
250
|
s.onQueryUpdate();
|
|
243
251
|
}), this.#e.notify({ query: this, type: "updated", action: t });
|
|
244
252
|
});
|
|
245
253
|
}
|
|
246
254
|
};
|
|
247
|
-
function
|
|
255
|
+
function D(t, e) {
|
|
248
256
|
return {
|
|
249
257
|
fetchFailureCount: 0,
|
|
250
258
|
fetchFailureReason: null,
|
|
251
|
-
fetchStatus:
|
|
259
|
+
fetchStatus: q(e.networkMode) ? "fetching" : "paused",
|
|
252
260
|
...t === void 0 && {
|
|
253
261
|
error: null,
|
|
254
262
|
status: "pending"
|
|
255
263
|
}
|
|
256
264
|
};
|
|
257
265
|
}
|
|
258
|
-
function
|
|
259
|
-
const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = e !== void 0,
|
|
266
|
+
function R(t) {
|
|
267
|
+
const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = e !== void 0, i = s ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
|
|
260
268
|
return {
|
|
261
269
|
data: e,
|
|
262
270
|
dataUpdateCount: 0,
|
|
263
|
-
dataUpdatedAt: s ?
|
|
271
|
+
dataUpdatedAt: s ? i ?? Date.now() : 0,
|
|
264
272
|
error: null,
|
|
265
273
|
errorUpdateCount: 0,
|
|
266
274
|
errorUpdatedAt: 0,
|
|
@@ -272,10 +280,10 @@ function q(t) {
|
|
|
272
280
|
fetchStatus: "idle"
|
|
273
281
|
};
|
|
274
282
|
}
|
|
275
|
-
var
|
|
283
|
+
var f = l.createContext(!1), I = () => l.useContext(f), w = f.Provider;
|
|
276
284
|
export {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
285
|
+
w as I,
|
|
286
|
+
x as Q,
|
|
287
|
+
D as f,
|
|
288
|
+
I as u
|
|
281
289
|
};
|