@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,7 +1,9 @@
|
|
|
1
|
-
import { S as N,
|
|
1
|
+
import { S as N, x as U, b as f, f as w, q as O, a as H, y as Q, z as M, t as V, o as z, r as k, n as A, u as W } from "./QueryClientProvider-Q_mWQTzQ.js";
|
|
2
|
+
import { f as $ } from "./query-CRIVoEP7.js";
|
|
2
3
|
import * as p from "react";
|
|
3
4
|
import "react/jsx-runtime";
|
|
4
|
-
|
|
5
|
+
import { s as K, n as _ } from "./utils-DxRR_XLb.js";
|
|
6
|
+
var G = class extends N {
|
|
5
7
|
constructor(e, t) {
|
|
6
8
|
super(), this.options = t, this.#s = e, this.#r = null, this.#i = U(), this.options.experimental_prefetchInRender || this.#i.reject(
|
|
7
9
|
new Error("experimental_prefetchInRender feature flag is not enabled")
|
|
@@ -28,7 +30,7 @@ var K = class extends N {
|
|
|
28
30
|
this.refetch = this.refetch.bind(this);
|
|
29
31
|
}
|
|
30
32
|
onSubscribe() {
|
|
31
|
-
this.listeners.size === 1 && (this.#e.addObserver(this),
|
|
33
|
+
this.listeners.size === 1 && (this.#e.addObserver(this), q(this.#e, this.options) ? this.#u() : this.updateResult(), this.#R());
|
|
32
34
|
}
|
|
33
35
|
onUnsubscribe() {
|
|
34
36
|
this.hasListeners() || this.destroy();
|
|
@@ -56,24 +58,24 @@ var K = class extends N {
|
|
|
56
58
|
throw new Error(
|
|
57
59
|
"Expected enabled to be a boolean or a callback that returns a boolean"
|
|
58
60
|
);
|
|
59
|
-
this.#C(), this.#e.setOptions(this.options), s._defaulted && !
|
|
61
|
+
this.#C(), this.#e.setOptions(this.options), s._defaulted && !w(this.options, s) && this.#s.getQueryCache().notify({
|
|
60
62
|
type: "observerOptionsUpdated",
|
|
61
63
|
query: this.#e,
|
|
62
64
|
observer: this
|
|
63
65
|
});
|
|
64
66
|
const a = this.hasListeners();
|
|
65
|
-
a &&
|
|
67
|
+
a && L(
|
|
66
68
|
this.#e,
|
|
67
69
|
r,
|
|
68
70
|
this.options,
|
|
69
71
|
s
|
|
70
72
|
) && this.#u(), this.updateResult(t), a && (this.#e !== r || f(this.options.enabled, this.#e) !== f(s.enabled, this.#e) || O(this.options.staleTime, this.#e) !== O(s.staleTime, this.#e)) && this.#b();
|
|
71
|
-
const u = this.#
|
|
72
|
-
a && (this.#e !== r || f(this.options.enabled, this.#e) !== f(s.enabled, this.#e) || u !== this.#n) && this.#
|
|
73
|
+
const u = this.#m();
|
|
74
|
+
a && (this.#e !== r || f(this.options.enabled, this.#e) !== f(s.enabled, this.#e) || u !== this.#n) && this.#g(u);
|
|
73
75
|
}
|
|
74
76
|
getOptimisticResult(e) {
|
|
75
77
|
const t = this.#s.getQueryCache().build(this.#s, e), s = this.createResult(t, e);
|
|
76
|
-
return
|
|
78
|
+
return X(this, s) && (this.#t = s, this.#c = this.options, this.#a = this.#e.state), s;
|
|
77
79
|
}
|
|
78
80
|
getCurrentResult() {
|
|
79
81
|
return this.#t;
|
|
@@ -130,16 +132,16 @@ var K = class extends N {
|
|
|
130
132
|
this.#t.isStale || this.updateResult();
|
|
131
133
|
}, s);
|
|
132
134
|
}
|
|
133
|
-
#
|
|
135
|
+
#m() {
|
|
134
136
|
return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#e) : this.options.refetchInterval) ?? !1;
|
|
135
137
|
}
|
|
136
|
-
#
|
|
138
|
+
#g(e) {
|
|
137
139
|
this.#O(), this.#n = e, !(Q || f(this.options.enabled, this.#e) === !1 || !M(this.#n) || this.#n === 0) && (this.#h = setInterval(() => {
|
|
138
140
|
(this.options.refetchIntervalInBackground || z.isFocused()) && this.#u();
|
|
139
141
|
}, this.#n));
|
|
140
142
|
}
|
|
141
143
|
#R() {
|
|
142
|
-
this.#b(), this.#
|
|
144
|
+
this.#b(), this.#g(this.#m());
|
|
143
145
|
}
|
|
144
146
|
#v() {
|
|
145
147
|
this.#o && (clearTimeout(this.#o), this.#o = void 0);
|
|
@@ -151,10 +153,10 @@ var K = class extends N {
|
|
|
151
153
|
const s = this.#e, r = this.options, a = this.#t, u = this.#a, i = this.#c, o = e !== s ? e.state : this.#p, { state: c } = e;
|
|
152
154
|
let n = { ...c }, R = !1, l;
|
|
153
155
|
if (t._optimisticResults) {
|
|
154
|
-
const h = this.hasListeners(), b = !h &&
|
|
155
|
-
(b ||
|
|
156
|
+
const h = this.hasListeners(), b = !h && q(e, t), m = h && L(e, s, t, r);
|
|
157
|
+
(b || m) && (n = {
|
|
156
158
|
...n,
|
|
157
|
-
|
|
159
|
+
...$(c.data, e.options)
|
|
158
160
|
}), t._optimisticResults === "isRestoring" && (n.fetchStatus = "idle");
|
|
159
161
|
}
|
|
160
162
|
let { error: x, errorUpdatedAt: F, status: y } = n;
|
|
@@ -189,12 +191,12 @@ var K = class extends N {
|
|
|
189
191
|
), R = !0);
|
|
190
192
|
}
|
|
191
193
|
this.#r && (x = this.#r, l = this.#l, F = Date.now(), y = "error");
|
|
192
|
-
const C = n.fetchStatus === "fetching", S = y === "pending",
|
|
194
|
+
const C = n.fetchStatus === "fetching", S = y === "pending", E = y === "error", D = S && C, P = l !== void 0, d = {
|
|
193
195
|
status: y,
|
|
194
196
|
fetchStatus: n.fetchStatus,
|
|
195
197
|
isPending: S,
|
|
196
198
|
isSuccess: y === "success",
|
|
197
|
-
isError:
|
|
199
|
+
isError: E,
|
|
198
200
|
isInitialLoading: D,
|
|
199
201
|
isLoading: D,
|
|
200
202
|
data: l,
|
|
@@ -208,10 +210,10 @@ var K = class extends N {
|
|
|
208
210
|
isFetchedAfterMount: n.dataUpdateCount > o.dataUpdateCount || n.errorUpdateCount > o.errorUpdateCount,
|
|
209
211
|
isFetching: C,
|
|
210
212
|
isRefetching: C && !S,
|
|
211
|
-
isLoadingError:
|
|
213
|
+
isLoadingError: E && !P,
|
|
212
214
|
isPaused: n.fetchStatus === "paused",
|
|
213
215
|
isPlaceholderData: R,
|
|
214
|
-
isRefetchError:
|
|
216
|
+
isRefetchError: E && P,
|
|
215
217
|
isStale: I(e, t),
|
|
216
218
|
refetch: this.refetch,
|
|
217
219
|
promise: this.#i
|
|
@@ -222,16 +224,16 @@ var K = class extends N {
|
|
|
222
224
|
}, b = () => {
|
|
223
225
|
const v = this.#i = d.promise = U();
|
|
224
226
|
h(v);
|
|
225
|
-
},
|
|
226
|
-
switch (
|
|
227
|
+
}, m = this.#i;
|
|
228
|
+
switch (m.status) {
|
|
227
229
|
case "pending":
|
|
228
|
-
e.queryHash === s.queryHash && h(
|
|
230
|
+
e.queryHash === s.queryHash && h(m);
|
|
229
231
|
break;
|
|
230
232
|
case "fulfilled":
|
|
231
|
-
(d.status === "error" || d.data !==
|
|
233
|
+
(d.status === "error" || d.data !== m.value) && b();
|
|
232
234
|
break;
|
|
233
235
|
case "rejected":
|
|
234
|
-
(d.status !== "error" || d.error !==
|
|
236
|
+
(d.status !== "error" || d.error !== m.reason) && b();
|
|
235
237
|
break;
|
|
236
238
|
}
|
|
237
239
|
}
|
|
@@ -239,7 +241,7 @@ var K = class extends N {
|
|
|
239
241
|
}
|
|
240
242
|
updateResult(e) {
|
|
241
243
|
const t = this.#t, s = this.createResult(this.#e, this.options);
|
|
242
|
-
if (this.#a = this.#e.state, this.#c = this.options, this.#a.data !== void 0 && (this.#d = this.#e),
|
|
244
|
+
if (this.#a = this.#e.state, this.#c = this.options, this.#a.data !== void 0 && (this.#d = this.#e), w(s, t))
|
|
243
245
|
return;
|
|
244
246
|
this.#t = s;
|
|
245
247
|
const r = {}, a = () => {
|
|
@@ -248,12 +250,12 @@ var K = class extends N {
|
|
|
248
250
|
const { notifyOnChangeProps: u } = this.options, i = typeof u == "function" ? u() : u;
|
|
249
251
|
if (i === "all" || !i && !this.#f.size)
|
|
250
252
|
return !0;
|
|
251
|
-
const
|
|
253
|
+
const g = new Set(
|
|
252
254
|
i ?? this.#f
|
|
253
255
|
);
|
|
254
|
-
return this.options.throwOnError &&
|
|
256
|
+
return this.options.throwOnError && g.add("error"), Object.keys(this.#t).some((o) => {
|
|
255
257
|
const c = o;
|
|
256
|
-
return this.#t[c] !== t[c] &&
|
|
258
|
+
return this.#t[c] !== t[c] && g.has(c);
|
|
257
259
|
});
|
|
258
260
|
};
|
|
259
261
|
e?.listeners !== !1 && a() && (r.listeners = !0), this.#S({ ...r, ...e });
|
|
@@ -279,11 +281,11 @@ var K = class extends N {
|
|
|
279
281
|
});
|
|
280
282
|
}
|
|
281
283
|
};
|
|
282
|
-
function
|
|
284
|
+
function J(e, t) {
|
|
283
285
|
return f(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
|
|
284
286
|
}
|
|
285
|
-
function
|
|
286
|
-
return
|
|
287
|
+
function q(e, t) {
|
|
288
|
+
return J(e, t) || e.state.data !== void 0 && T(e, t, t.refetchOnMount);
|
|
287
289
|
}
|
|
288
290
|
function T(e, t, s) {
|
|
289
291
|
if (f(t.enabled, e) !== !1) {
|
|
@@ -292,18 +294,18 @@ function T(e, t, s) {
|
|
|
292
294
|
}
|
|
293
295
|
return !1;
|
|
294
296
|
}
|
|
295
|
-
function
|
|
297
|
+
function L(e, t, s, r) {
|
|
296
298
|
return (e !== t || f(r.enabled, e) === !1) && (!s.suspense || e.state.status !== "error") && I(e, s);
|
|
297
299
|
}
|
|
298
300
|
function I(e, t) {
|
|
299
301
|
return f(t.enabled, e) !== !1 && e.isStaleByTime(O(t.staleTime, e));
|
|
300
302
|
}
|
|
301
|
-
function
|
|
302
|
-
return !
|
|
303
|
+
function X(e, t) {
|
|
304
|
+
return !w(e.getCurrentResult(), t);
|
|
303
305
|
}
|
|
304
|
-
var B = p.createContext(!1),
|
|
306
|
+
var B = p.createContext(!1), Y = () => p.useContext(B);
|
|
305
307
|
B.Provider;
|
|
306
|
-
function
|
|
308
|
+
function Z() {
|
|
307
309
|
let e = !1;
|
|
308
310
|
return {
|
|
309
311
|
clearReset: () => {
|
|
@@ -315,13 +317,7 @@ function Y() {
|
|
|
315
317
|
isReset: () => e
|
|
316
318
|
};
|
|
317
319
|
}
|
|
318
|
-
var
|
|
319
|
-
function te(e, t) {
|
|
320
|
-
return typeof e == "function" ? e(...t) : !!e;
|
|
321
|
-
}
|
|
322
|
-
function L() {
|
|
323
|
-
}
|
|
324
|
-
var se = (e, t) => {
|
|
320
|
+
var ee = p.createContext(Z()), te = () => p.useContext(ee), se = (e, t) => {
|
|
325
321
|
(e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1));
|
|
326
322
|
}, re = (e) => {
|
|
327
323
|
p.useEffect(() => {
|
|
@@ -333,7 +329,7 @@ var se = (e, t) => {
|
|
|
333
329
|
throwOnError: s,
|
|
334
330
|
query: r,
|
|
335
331
|
suspense: a
|
|
336
|
-
}) => e.isError && !t.isReset() && !e.isFetching && r && (a && e.data === void 0 ||
|
|
332
|
+
}) => e.isError && !t.isReset() && !e.isFetching && r && (a && e.data === void 0 || K(s, [e.error, r])), ne = (e) => {
|
|
337
333
|
const t = e.staleTime;
|
|
338
334
|
e.suspense && (e.staleTime = typeof t == "function" ? (...s) => Math.max(t(...s), 1e3) : Math.max(t ?? 1e3, 1e3), typeof e.gcTime == "number" && (e.gcTime = Math.max(e.gcTime, 1e3)));
|
|
339
335
|
}, ae = (e, t) => e.isLoading && e.isFetching && !t, oe = (e, t) => e?.suspense && t.isPending, j = (e, t, s) => t.fetchOptimistic(e).catch(() => {
|
|
@@ -344,13 +340,13 @@ function he(e, t, s) {
|
|
|
344
340
|
throw new Error(
|
|
345
341
|
'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'
|
|
346
342
|
);
|
|
347
|
-
const r =
|
|
343
|
+
const r = W(), a = Y(), u = te(), i = r.defaultQueryOptions(e);
|
|
348
344
|
r.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
349
345
|
i
|
|
350
346
|
), process.env.NODE_ENV !== "production" && (i.queryFn || console.error(
|
|
351
347
|
`[${i.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`
|
|
352
348
|
)), i._optimisticResults = a ? "isRestoring" : "optimistic", ne(i), se(i, u), re(u);
|
|
353
|
-
const
|
|
349
|
+
const g = !r.getQueryCache().get(i.queryHash), [o] = p.useState(
|
|
354
350
|
() => new t(
|
|
355
351
|
r,
|
|
356
352
|
i
|
|
@@ -359,7 +355,7 @@ function he(e, t, s) {
|
|
|
359
355
|
if (p.useSyncExternalStore(
|
|
360
356
|
p.useCallback(
|
|
361
357
|
(R) => {
|
|
362
|
-
const l = n ? o.subscribe(A.batchCalls(R)) :
|
|
358
|
+
const l = n ? o.subscribe(A.batchCalls(R)) : _;
|
|
363
359
|
return o.updateResult(), l;
|
|
364
360
|
},
|
|
365
361
|
[o, n]
|
|
@@ -381,21 +377,19 @@ function he(e, t, s) {
|
|
|
381
377
|
return r.getDefaultOptions().queries?._experimental_afterQuery?.(
|
|
382
378
|
i,
|
|
383
379
|
c
|
|
384
|
-
), i.experimental_prefetchInRender && !Q && ae(c, a) && (
|
|
380
|
+
), i.experimental_prefetchInRender && !Q && ae(c, a) && (g ? (
|
|
385
381
|
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
386
382
|
j(i, o, u)
|
|
387
383
|
) : (
|
|
388
384
|
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
389
385
|
r.getQueryCache().get(i.queryHash)?.promise
|
|
390
|
-
))?.catch(
|
|
386
|
+
))?.catch(_).finally(() => {
|
|
391
387
|
o.updateResult();
|
|
392
388
|
}), i.notifyOnChangeProps ? c : o.trackResult(c);
|
|
393
389
|
}
|
|
394
|
-
function
|
|
395
|
-
return he(e,
|
|
390
|
+
function pe(e, t) {
|
|
391
|
+
return he(e, G);
|
|
396
392
|
}
|
|
397
393
|
export {
|
|
398
|
-
|
|
399
|
-
te as s,
|
|
400
|
-
de as u
|
|
394
|
+
pe as u
|
|
401
395
|
};
|
package/package.json
CHANGED