@hortiview/modulebase 0.0.20436 → 1.0.0

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.
Files changed (51) hide show
  1. package/README.md +3 -2
  2. package/dist/IsRestoringProvider-CBSZo7ur.js +312 -0
  3. package/dist/ModuleCore-DuJVrj6v.js +11828 -0
  4. package/dist/QueryClientProvider-DyiNrPkn.js +514 -0
  5. package/dist/_commonjsHelpers-ByX85dGu.js +33 -0
  6. package/dist/api-COabZnyn.js +147 -0
  7. package/dist/assets/ModuleCore.css +1 -1
  8. package/dist/chunk-LFPYN7LY-D1ls8FXf.js +8643 -0
  9. package/dist/components/ModuleBase.js +9 -9
  10. package/dist/components/ModuleCore.js +1 -1
  11. package/dist/constants.js +2 -3
  12. package/dist/hooks/useCustom.js +1 -1
  13. package/dist/hooks/useCustomMutation.js +5 -5
  14. package/dist/hooks/useEntity.js +30 -30
  15. package/dist/hooks/useOffline.js +1 -1
  16. package/dist/hooks/useOption.js +5 -5
  17. package/dist/hooks/useServiceBus.js +1 -1
  18. package/dist/hooks/useStores.js +1 -1
  19. package/dist/{_baseGet-C6jMXSsQ.js → isTypedArray-SkhznY1k.js} +494 -494
  20. package/dist/lib/constants.d.ts +0 -1
  21. package/dist/lib/hooks/useCustom.d.ts +4 -2
  22. package/dist/lib/hooks/useCustomMutation.d.ts +8 -3
  23. package/dist/lib/hooks/useEntity.d.ts +6 -0
  24. package/dist/lib/types/Requests.d.ts +0 -17
  25. package/dist/lib/utils/api.d.ts +6 -13
  26. package/dist/lib/utils/baseFetches.d.ts +3 -2
  27. package/dist/main.js +188 -173
  28. package/dist/module-router.js +2322 -121
  29. package/dist/{mutation-DSKlaYzY.js → mutation-CmhiEgfA.js} +101 -56
  30. package/dist/{omit-C9Qe80rl.js → omit-Do6MFRwA.js} +240 -223
  31. package/dist/provider/SignalR/SignalRProvider.js +2389 -2824
  32. package/dist/react-c9FSfB30.js +27 -0
  33. package/dist/stores/BasePropsStore.js +1 -1
  34. package/dist/stores/EnvironmentStore.js +1 -1
  35. package/dist/useMutation-Aoachkw_.js +139 -0
  36. package/dist/useQuery-DEU_AUtf.js +392 -0
  37. package/dist/utils/api.js +3 -4
  38. package/dist/utils/baseFetches.js +18 -14
  39. package/dist/utils/fetches.js +3 -4
  40. package/dist/utils/helper.js +13 -13
  41. package/package.json +17 -13
  42. package/dist/ModuleCore-DpwHP0IU.js +0 -14973
  43. package/dist/QueryClientProvider-Beog9TR7.js +0 -437
  44. package/dist/_commonjsHelpers-BkfeUUK-.js +0 -28
  45. package/dist/api-CogBuK0n.js +0 -473
  46. package/dist/chunk-IR6S3I6Y-BmDdD3SP.js +0 -8162
  47. package/dist/isRestoring-CLuxJVSA.js +0 -281
  48. package/dist/react-QiIgv49H.js +0 -27
  49. package/dist/useMutation-zu8uxBak.js +0 -97
  50. package/dist/useQuery-Bj9k9zik.js +0 -395
  51. package/dist/utils-DxRR_XLb.js +0 -9
@@ -1,395 +0,0 @@
1
- import { S as B, p as U, b as f, s as w, g as O, a as N, j as Q, k, t as H, l as V, r as M, n as A, u as z } from "./QueryClientProvider-Beog9TR7.js";
2
- import { f as W, u as $ } from "./isRestoring-CLuxJVSA.js";
3
- import * as y from "react";
4
- import "react/jsx-runtime";
5
- import { s as K, n as _ } from "./utils-DxRR_XLb.js";
6
- var G = class extends B {
7
- constructor(e, t) {
8
- super(), this.options = t, this.#s = e, this.#r = null, this.#i = U(), this.options.experimental_prefetchInRender || this.#i.reject(
9
- new Error("experimental_prefetchInRender feature flag is not enabled")
10
- ), this.bindMethods(), this.setOptions(t);
11
- }
12
- #s;
13
- #e = void 0;
14
- #p = void 0;
15
- #t = void 0;
16
- #a;
17
- #c;
18
- #i;
19
- #r;
20
- #y;
21
- #l;
22
- // This property keeps track of the last query with defined data.
23
- // It will be used to pass the previous data and query to the placeholder function between renders.
24
- #d;
25
- #o;
26
- #h;
27
- #n;
28
- #f = /* @__PURE__ */ new Set();
29
- bindMethods() {
30
- this.refetch = this.refetch.bind(this);
31
- }
32
- onSubscribe() {
33
- this.listeners.size === 1 && (this.#e.addObserver(this), j(this.#e, this.options) ? this.#u() : this.updateResult(), this.#R());
34
- }
35
- onUnsubscribe() {
36
- this.hasListeners() || this.destroy();
37
- }
38
- shouldFetchOnReconnect() {
39
- return T(
40
- this.#e,
41
- this.options,
42
- this.options.refetchOnReconnect
43
- );
44
- }
45
- shouldFetchOnWindowFocus() {
46
- return T(
47
- this.#e,
48
- this.options,
49
- this.options.refetchOnWindowFocus
50
- );
51
- }
52
- destroy() {
53
- this.listeners = /* @__PURE__ */ new Set(), this.#v(), this.#O(), this.#e.removeObserver(this);
54
- }
55
- setOptions(e, t) {
56
- const s = this.options, r = this.#e;
57
- if (this.options = this.#s.defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof f(this.options.enabled, this.#e) != "boolean")
58
- throw new Error(
59
- "Expected enabled to be a boolean or a callback that returns a boolean"
60
- );
61
- this.#C(), this.#e.setOptions(this.options), s._defaulted && !w(this.options, s) && this.#s.getQueryCache().notify({
62
- type: "observerOptionsUpdated",
63
- query: this.#e,
64
- observer: this
65
- });
66
- const a = this.hasListeners();
67
- a && L(
68
- this.#e,
69
- r,
70
- this.options,
71
- s
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();
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);
75
- }
76
- getOptimisticResult(e) {
77
- const t = this.#s.getQueryCache().build(this.#s, e), s = this.createResult(t, e);
78
- return X(this, s) && (this.#t = s, this.#c = this.options, this.#a = this.#e.state), s;
79
- }
80
- getCurrentResult() {
81
- return this.#t;
82
- }
83
- trackResult(e, t) {
84
- const s = {};
85
- return Object.keys(e).forEach((r) => {
86
- Object.defineProperty(s, r, {
87
- configurable: !1,
88
- enumerable: !0,
89
- get: () => (this.trackProp(r), t?.(r), e[r])
90
- });
91
- }), s;
92
- }
93
- trackProp(e) {
94
- this.#f.add(e);
95
- }
96
- getCurrentQuery() {
97
- return this.#e;
98
- }
99
- refetch({ ...e } = {}) {
100
- return this.fetch({
101
- ...e
102
- });
103
- }
104
- fetchOptimistic(e) {
105
- const t = this.#s.defaultQueryOptions(e), s = this.#s.getQueryCache().build(this.#s, t);
106
- return s.fetch().then(() => this.createResult(s, t));
107
- }
108
- fetch(e) {
109
- return this.#u({
110
- ...e,
111
- cancelRefetch: e.cancelRefetch ?? !0
112
- }).then(() => (this.updateResult(), this.#t));
113
- }
114
- #u(e) {
115
- this.#C();
116
- let t = this.#e.fetch(
117
- this.options,
118
- e
119
- );
120
- return e?.throwOnError || (t = t.catch(N)), t;
121
- }
122
- #b() {
123
- this.#v();
124
- const e = O(
125
- this.options.staleTime,
126
- this.#e
127
- );
128
- if (Q || this.#t.isStale || !k(e))
129
- return;
130
- const s = H(this.#t.dataUpdatedAt, e) + 1;
131
- this.#o = setTimeout(() => {
132
- this.#t.isStale || this.updateResult();
133
- }, s);
134
- }
135
- #m() {
136
- return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#e) : this.options.refetchInterval) ?? !1;
137
- }
138
- #g(e) {
139
- this.#O(), this.#n = e, !(Q || f(this.options.enabled, this.#e) === !1 || !k(this.#n) || this.#n === 0) && (this.#h = setInterval(() => {
140
- (this.options.refetchIntervalInBackground || V.isFocused()) && this.#u();
141
- }, this.#n));
142
- }
143
- #R() {
144
- this.#b(), this.#g(this.#m());
145
- }
146
- #v() {
147
- this.#o && (clearTimeout(this.#o), this.#o = void 0);
148
- }
149
- #O() {
150
- this.#h && (clearInterval(this.#h), this.#h = void 0);
151
- }
152
- createResult(e, t) {
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;
154
- let n = { ...c }, R = !1, l;
155
- if (t._optimisticResults) {
156
- const h = this.hasListeners(), b = !h && j(e, t), m = h && L(e, s, t, r);
157
- (b || m) && (n = {
158
- ...n,
159
- ...W(c.data, e.options)
160
- }), t._optimisticResults === "isRestoring" && (n.fetchStatus = "idle");
161
- }
162
- let { error: F, errorUpdatedAt: x, status: p } = n;
163
- if (t.select && n.data !== void 0)
164
- if (a && n.data === u?.data && t.select === this.#y)
165
- l = this.#l;
166
- else
167
- try {
168
- this.#y = t.select, l = t.select(n.data), l = M(a?.data, l, t), this.#l = l, this.#r = null;
169
- } catch (h) {
170
- this.#r = h;
171
- }
172
- else
173
- l = n.data;
174
- if (t.placeholderData !== void 0 && l === void 0 && p === "pending") {
175
- let h;
176
- if (a?.isPlaceholderData && t.placeholderData === i?.placeholderData)
177
- h = a.data;
178
- else if (h = typeof t.placeholderData == "function" ? t.placeholderData(
179
- this.#d?.state.data,
180
- this.#d
181
- ) : t.placeholderData, t.select && h !== void 0)
182
- try {
183
- h = t.select(h), this.#r = null;
184
- } catch (b) {
185
- this.#r = b;
186
- }
187
- h !== void 0 && (p = "success", l = M(
188
- a?.data,
189
- h,
190
- t
191
- ), R = !0);
192
- }
193
- this.#r && (F = this.#r, l = this.#l, x = Date.now(), p = "error");
194
- const C = n.fetchStatus === "fetching", S = p === "pending", E = p === "error", D = S && C, P = l !== void 0, d = {
195
- status: p,
196
- fetchStatus: n.fetchStatus,
197
- isPending: S,
198
- isSuccess: p === "success",
199
- isError: E,
200
- isInitialLoading: D,
201
- isLoading: D,
202
- data: l,
203
- dataUpdatedAt: n.dataUpdatedAt,
204
- error: F,
205
- errorUpdatedAt: x,
206
- failureCount: n.fetchFailureCount,
207
- failureReason: n.fetchFailureReason,
208
- errorUpdateCount: n.errorUpdateCount,
209
- isFetched: n.dataUpdateCount > 0 || n.errorUpdateCount > 0,
210
- isFetchedAfterMount: n.dataUpdateCount > o.dataUpdateCount || n.errorUpdateCount > o.errorUpdateCount,
211
- isFetching: C,
212
- isRefetching: C && !S,
213
- isLoadingError: E && !P,
214
- isPaused: n.fetchStatus === "paused",
215
- isPlaceholderData: R,
216
- isRefetchError: E && P,
217
- isStale: I(e, t),
218
- refetch: this.refetch,
219
- promise: this.#i
220
- };
221
- if (this.options.experimental_prefetchInRender) {
222
- const h = (v) => {
223
- d.status === "error" ? v.reject(d.error) : d.data !== void 0 && v.resolve(d.data);
224
- }, b = () => {
225
- const v = this.#i = d.promise = U();
226
- h(v);
227
- }, m = this.#i;
228
- switch (m.status) {
229
- case "pending":
230
- e.queryHash === s.queryHash && h(m);
231
- break;
232
- case "fulfilled":
233
- (d.status === "error" || d.data !== m.value) && b();
234
- break;
235
- case "rejected":
236
- (d.status !== "error" || d.error !== m.reason) && b();
237
- break;
238
- }
239
- }
240
- return d;
241
- }
242
- updateResult(e) {
243
- const t = this.#t, s = this.createResult(this.#e, this.options);
244
- if (this.#a = this.#e.state, this.#c = this.options, this.#a.data !== void 0 && (this.#d = this.#e), w(s, t))
245
- return;
246
- this.#t = s;
247
- const r = {}, a = () => {
248
- if (!t)
249
- return !0;
250
- const { notifyOnChangeProps: u } = this.options, i = typeof u == "function" ? u() : u;
251
- if (i === "all" || !i && !this.#f.size)
252
- return !0;
253
- const g = new Set(
254
- i ?? this.#f
255
- );
256
- return this.options.throwOnError && g.add("error"), Object.keys(this.#t).some((o) => {
257
- const c = o;
258
- return this.#t[c] !== t[c] && g.has(c);
259
- });
260
- };
261
- e?.listeners !== !1 && a() && (r.listeners = !0), this.#S({ ...r, ...e });
262
- }
263
- #C() {
264
- const e = this.#s.getQueryCache().build(this.#s, this.options);
265
- if (e === this.#e)
266
- return;
267
- const t = this.#e;
268
- this.#e = e, this.#p = e.state, this.hasListeners() && (t?.removeObserver(this), e.addObserver(this));
269
- }
270
- onQueryUpdate() {
271
- this.updateResult(), this.hasListeners() && this.#R();
272
- }
273
- #S(e) {
274
- A.batch(() => {
275
- e.listeners && this.listeners.forEach((t) => {
276
- t(this.#t);
277
- }), this.#s.getQueryCache().notify({
278
- query: this.#e,
279
- type: "observerResultsUpdated"
280
- });
281
- });
282
- }
283
- };
284
- function J(e, t) {
285
- return f(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
286
- }
287
- function j(e, t) {
288
- return J(e, t) || e.state.data !== void 0 && T(e, t, t.refetchOnMount);
289
- }
290
- function T(e, t, s) {
291
- if (f(t.enabled, e) !== !1) {
292
- const r = typeof s == "function" ? s(e) : s;
293
- return r === "always" || r !== !1 && I(e, t);
294
- }
295
- return !1;
296
- }
297
- function L(e, t, s, r) {
298
- return (e !== t || f(r.enabled, e) === !1) && (!s.suspense || e.state.status !== "error") && I(e, s);
299
- }
300
- function I(e, t) {
301
- return f(t.enabled, e) !== !1 && e.isStaleByTime(O(t.staleTime, e));
302
- }
303
- function X(e, t) {
304
- return !w(e.getCurrentResult(), t);
305
- }
306
- function Y() {
307
- let e = !1;
308
- return {
309
- clearReset: () => {
310
- e = !1;
311
- },
312
- reset: () => {
313
- e = !0;
314
- },
315
- isReset: () => e
316
- };
317
- }
318
- var Z = y.createContext(Y()), ee = () => y.useContext(Z), te = (e, t) => {
319
- (e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1));
320
- }, se = (e) => {
321
- y.useEffect(() => {
322
- e.clearReset();
323
- }, [e]);
324
- }, re = ({
325
- result: e,
326
- errorResetBoundary: t,
327
- throwOnError: s,
328
- query: r,
329
- suspense: a
330
- }) => e.isError && !t.isReset() && !e.isFetching && r && (a && e.data === void 0 || K(s, [e.error, r])), ie = (e) => {
331
- const t = e.staleTime;
332
- 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)));
333
- }, ne = (e, t) => e.isLoading && e.isFetching && !t, ae = (e, t) => e?.suspense && t.isPending, q = (e, t, s) => t.fetchOptimistic(e).catch(() => {
334
- s.clearReset();
335
- });
336
- function oe(e, t, s) {
337
- if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e)))
338
- throw new Error(
339
- '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'
340
- );
341
- const r = z(s), a = $(), u = ee(), i = r.defaultQueryOptions(e);
342
- r.getDefaultOptions().queries?._experimental_beforeQuery?.(
343
- i
344
- ), process.env.NODE_ENV !== "production" && (i.queryFn || console.error(
345
- `[${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`
346
- )), i._optimisticResults = a ? "isRestoring" : "optimistic", ie(i), te(i, u), se(u);
347
- const g = !r.getQueryCache().get(i.queryHash), [o] = y.useState(
348
- () => new t(
349
- r,
350
- i
351
- )
352
- ), c = o.getOptimisticResult(i), n = !a && e.subscribed !== !1;
353
- if (y.useSyncExternalStore(
354
- y.useCallback(
355
- (R) => {
356
- const l = n ? o.subscribe(A.batchCalls(R)) : _;
357
- return o.updateResult(), l;
358
- },
359
- [o, n]
360
- ),
361
- () => o.getCurrentResult(),
362
- () => o.getCurrentResult()
363
- ), y.useEffect(() => {
364
- o.setOptions(i, { listeners: !1 });
365
- }, [i, o]), ae(i, c))
366
- throw q(i, o, u);
367
- if (re({
368
- result: c,
369
- errorResetBoundary: u,
370
- throwOnError: i.throwOnError,
371
- query: r.getQueryCache().get(i.queryHash),
372
- suspense: i.suspense
373
- }))
374
- throw c.error;
375
- return r.getDefaultOptions().queries?._experimental_afterQuery?.(
376
- i,
377
- c
378
- ), i.experimental_prefetchInRender && !Q && ne(c, a) && (g ? (
379
- // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
380
- q(i, o, u)
381
- ) : (
382
- // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
383
- r.getQueryCache().get(i.queryHash)?.promise
384
- ))?.catch(_).finally(() => {
385
- o.updateResult();
386
- }), i.notifyOnChangeProps ? c : o.trackResult(c);
387
- }
388
- function fe(e, t) {
389
- return oe(e, G, t);
390
- }
391
- export {
392
- G as Q,
393
- oe as a,
394
- fe as u
395
- };
@@ -1,9 +0,0 @@
1
- function u(n, o) {
2
- return typeof n == "function" ? n(...o) : !!n;
3
- }
4
- function f() {
5
- }
6
- export {
7
- f as n,
8
- u as s
9
- };