@hortiview/modulebase 0.0.16348 → 0.0.20524

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 (65) 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 +9 -14698
  11. package/dist/constants.js +2 -3
  12. package/dist/enum/ActionStorage.js +4 -0
  13. package/dist/hooks/useCustom.js +15 -18
  14. package/dist/hooks/useCustomMutation.js +12 -11
  15. package/dist/hooks/useEntity.js +48 -60
  16. package/dist/hooks/useOffline.js +57 -0
  17. package/dist/hooks/useOption.js +19 -19
  18. package/dist/hooks/useServiceBus.js +1 -1
  19. package/dist/hooks/useStores.js +1 -1
  20. package/dist/{_baseGet-B7FwMMGI.js → isTypedArray-SkhznY1k.js} +496 -496
  21. package/dist/lib/constants.d.ts +0 -1
  22. package/dist/lib/enum/ActionStorage.d.ts +7 -0
  23. package/dist/lib/hooks/useCustom.d.ts +6 -3
  24. package/dist/lib/hooks/useCustomMutation.d.ts +9 -3
  25. package/dist/lib/hooks/useEntity.d.ts +15 -23
  26. package/dist/lib/hooks/useOffline.d.ts +15 -0
  27. package/dist/lib/hooks/useStores.d.ts +10 -2
  28. package/dist/lib/main.d.ts +4 -0
  29. package/dist/lib/types/ActionStorage.d.ts +8 -0
  30. package/dist/lib/types/BaseProps.d.ts +10 -1
  31. package/dist/lib/types/Deprecated.d.ts +4 -0
  32. package/dist/lib/types/Entities.d.ts +22 -0
  33. package/dist/lib/types/Requests.d.ts +0 -17
  34. package/dist/lib/utils/IndexedDbService.d.ts +33 -0
  35. package/dist/lib/utils/api.d.ts +7 -14
  36. package/dist/lib/utils/baseFetches.d.ts +4 -3
  37. package/dist/lib/utils/fetches.d.ts +2 -2
  38. package/dist/lib/utils/helper.d.ts +1 -0
  39. package/dist/main.js +233 -144
  40. package/dist/module-router.js +2322 -121
  41. package/dist/{mutation-CnKIetRs.js → mutation-CmhiEgfA.js} +101 -56
  42. package/dist/{omit-B7MWDtHq.js → omit-Do6MFRwA.js} +240 -223
  43. package/dist/provider/SignalR/SignalRProvider.js +2389 -2824
  44. package/dist/react-c9FSfB30.js +27 -0
  45. package/dist/stores/BasePropsStore.js +1 -1
  46. package/dist/stores/EnvironmentStore.js +1 -1
  47. package/dist/types/ActionStorage.js +1 -0
  48. package/dist/types/Entities.js +25 -0
  49. package/dist/useMutation-Aoachkw_.js +139 -0
  50. package/dist/useQuery-DEU_AUtf.js +392 -0
  51. package/dist/utils/IndexedDbService.js +43 -0
  52. package/dist/utils/api.js +3 -4
  53. package/dist/utils/baseFetches.js +18 -14
  54. package/dist/utils/fetches.js +12 -13
  55. package/dist/utils/helper.js +30 -25
  56. package/package.json +19 -12
  57. package/dist/QueryClientProvider-VtJdNkDw.js +0 -435
  58. package/dist/_commonjsHelpers-BkfeUUK-.js +0 -28
  59. package/dist/api-D9Lmqe6S.js +0 -458
  60. package/dist/chunk-IR6S3I6Y-BmDdD3SP.js +0 -8162
  61. package/dist/query-CFoO2uy7.js +0 -277
  62. package/dist/react-QiIgv49H.js +0 -27
  63. package/dist/useMutation-Num57Ulc.js +0 -97
  64. package/dist/useQuery-XBGd5Kep.js +0 -395
  65. package/dist/utils-DxRR_XLb.js +0 -9
@@ -1,395 +0,0 @@
1
- import { S as N, p as U, b as f, f as w, g as O, a as H, j as Q, k, t as V, l as z, r as M, n as A, u as W } from "./QueryClientProvider-VtJdNkDw.js";
2
- import { f as $ } from "./query-CFoO2uy7.js";
3
- import * as p from "react";
4
- import "react/jsx-runtime";
5
- import { s as K, n as _ } from "./utils-DxRR_XLb.js";
6
- var G = class extends N {
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(H)), 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 = V(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 || z.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
- ...$(c.data, e.options)
160
- }), t._optimisticResults === "isRestoring" && (n.fetchStatus = "idle");
161
- }
162
- let { error: x, errorUpdatedAt: F, status: y } = 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 && y === "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 && (y = "success", l = M(
188
- a?.data,
189
- h,
190
- t
191
- ), R = !0);
192
- }
193
- this.#r && (x = this.#r, l = this.#l, F = Date.now(), y = "error");
194
- const C = n.fetchStatus === "fetching", S = y === "pending", E = y === "error", D = S && C, P = l !== void 0, d = {
195
- status: y,
196
- fetchStatus: n.fetchStatus,
197
- isPending: S,
198
- isSuccess: y === "success",
199
- isError: E,
200
- isInitialLoading: D,
201
- isLoading: D,
202
- data: l,
203
- dataUpdatedAt: n.dataUpdatedAt,
204
- error: x,
205
- errorUpdatedAt: F,
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
- var B = p.createContext(!1), Y = () => p.useContext(B);
307
- B.Provider;
308
- function Z() {
309
- let e = !1;
310
- return {
311
- clearReset: () => {
312
- e = !1;
313
- },
314
- reset: () => {
315
- e = !0;
316
- },
317
- isReset: () => e
318
- };
319
- }
320
- var ee = p.createContext(Z()), te = () => p.useContext(ee), se = (e, t) => {
321
- (e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1));
322
- }, re = (e) => {
323
- p.useEffect(() => {
324
- e.clearReset();
325
- }, [e]);
326
- }, ie = ({
327
- result: e,
328
- errorResetBoundary: t,
329
- throwOnError: s,
330
- query: r,
331
- suspense: a
332
- }) => e.isError && !t.isReset() && !e.isFetching && r && (a && e.data === void 0 || K(s, [e.error, r])), ne = (e) => {
333
- const t = e.staleTime;
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)));
335
- }, ae = (e, t) => e.isLoading && e.isFetching && !t, oe = (e, t) => e?.suspense && t.isPending, q = (e, t, s) => t.fetchOptimistic(e).catch(() => {
336
- s.clearReset();
337
- });
338
- function he(e, t, s) {
339
- if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e)))
340
- throw new Error(
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'
342
- );
343
- const r = W(), a = Y(), u = te(), i = r.defaultQueryOptions(e);
344
- r.getDefaultOptions().queries?._experimental_beforeQuery?.(
345
- i
346
- ), process.env.NODE_ENV !== "production" && (i.queryFn || console.error(
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`
348
- )), i._optimisticResults = a ? "isRestoring" : "optimistic", ne(i), se(i, u), re(u);
349
- const g = !r.getQueryCache().get(i.queryHash), [o] = p.useState(
350
- () => new t(
351
- r,
352
- i
353
- )
354
- ), c = o.getOptimisticResult(i), n = !a && e.subscribed !== !1;
355
- if (p.useSyncExternalStore(
356
- p.useCallback(
357
- (R) => {
358
- const l = n ? o.subscribe(A.batchCalls(R)) : _;
359
- return o.updateResult(), l;
360
- },
361
- [o, n]
362
- ),
363
- () => o.getCurrentResult(),
364
- () => o.getCurrentResult()
365
- ), p.useEffect(() => {
366
- o.setOptions(i, { listeners: !1 });
367
- }, [i, o]), oe(i, c))
368
- throw q(i, o, u);
369
- if (ie({
370
- result: c,
371
- errorResetBoundary: u,
372
- throwOnError: i.throwOnError,
373
- query: r.getQueryCache().get(i.queryHash),
374
- suspense: i.suspense
375
- }))
376
- throw c.error;
377
- return r.getDefaultOptions().queries?._experimental_afterQuery?.(
378
- i,
379
- c
380
- ), i.experimental_prefetchInRender && !Q && ae(c, a) && (g ? (
381
- // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
382
- q(i, o, u)
383
- ) : (
384
- // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
385
- r.getQueryCache().get(i.queryHash)?.promise
386
- ))?.catch(_).finally(() => {
387
- o.updateResult();
388
- }), i.notifyOnChangeProps ? c : o.trackResult(c);
389
- }
390
- function pe(e, t) {
391
- return he(e, G);
392
- }
393
- export {
394
- pe 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
- };