@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,277 +0,0 @@
1
- import { R as d, r as l, a as u, b as f, s as p, t as y, c as v, n as b, e as m, i as h, d as S } from "./QueryClientProvider-VtJdNkDw.js";
2
- var q = class extends d {
3
- #a;
4
- #n;
5
- #e;
6
- #i;
7
- #t;
8
- #o;
9
- #r;
10
- constructor(t) {
11
- super(), this.#r = !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.#a = F(this.options), this.state = t.state ?? this.#a, this.scheduleGc();
12
- }
13
- get meta() {
14
- return this.options.meta;
15
- }
16
- get promise() {
17
- return this.#t?.promise;
18
- }
19
- setOptions(t) {
20
- this.options = { ...this.#o, ...t }, this.updateGcTime(this.options.gcTime);
21
- }
22
- optionalRemove() {
23
- !this.observers.length && this.state.fetchStatus === "idle" && this.#e.remove(this);
24
- }
25
- setData(t, e) {
26
- const s = l(this.state.data, t, this.options);
27
- return this.#s({
28
- data: s,
29
- type: "success",
30
- dataUpdatedAt: e?.updatedAt,
31
- manual: e?.manual
32
- }), s;
33
- }
34
- setState(t, e) {
35
- this.#s({ type: "setState", state: t, setStateOptions: e });
36
- }
37
- cancel(t) {
38
- const e = this.#t?.promise;
39
- return this.#t?.cancel(t), e ? e.then(u).catch(u) : Promise.resolve();
40
- }
41
- destroy() {
42
- super.destroy(), this.cancel({ silent: !0 });
43
- }
44
- reset() {
45
- this.destroy(), this.setState(this.#a);
46
- }
47
- isActive() {
48
- return this.observers.some(
49
- (t) => f(t.options.enabled, this) !== !1
50
- );
51
- }
52
- isDisabled() {
53
- return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === p || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
54
- }
55
- isStale() {
56
- return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
57
- (t) => t.getCurrentResult().isStale
58
- ) : this.state.data === void 0;
59
- }
60
- isStaleByTime(t = 0) {
61
- return this.state.isInvalidated || this.state.data === void 0 || !y(this.state.dataUpdatedAt, t);
62
- }
63
- onFocus() {
64
- this.observers.find((e) => e.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
65
- }
66
- onOnline() {
67
- this.observers.find((e) => e.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
68
- }
69
- addObserver(t) {
70
- this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), this.#e.notify({ type: "observerAdded", query: this, observer: t }));
71
- }
72
- removeObserver(t) {
73
- this.observers.includes(t) && (this.observers = this.observers.filter((e) => e !== t), this.observers.length || (this.#t && (this.#r ? this.#t.cancel({ revert: !0 }) : this.#t.cancelRetry()), this.scheduleGc()), this.#e.notify({ type: "observerRemoved", query: this, observer: t }));
74
- }
75
- getObserversCount() {
76
- return this.observers.length;
77
- }
78
- invalidate() {
79
- this.state.isInvalidated || this.#s({ type: "invalidate" });
80
- }
81
- fetch(t, e) {
82
- if (this.state.fetchStatus !== "idle") {
83
- if (this.state.data !== void 0 && e?.cancelRefetch)
84
- this.cancel({ silent: !0 });
85
- else if (this.#t)
86
- return this.#t.continueRetry(), this.#t.promise;
87
- }
88
- if (t && this.setOptions(t), !this.options.queryFn) {
89
- const i = this.observers.find((a) => a.options.queryFn);
90
- i && this.setOptions(i.options);
91
- }
92
- process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
93
- "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']"
94
- ));
95
- const s = new AbortController(), r = (i) => {
96
- Object.defineProperty(i, "signal", {
97
- enumerable: !0,
98
- get: () => (this.#r = !0, s.signal)
99
- });
100
- }, c = () => {
101
- const i = m(this.options, e), a = {
102
- client: this.#i,
103
- queryKey: this.queryKey,
104
- meta: this.meta
105
- };
106
- return r(a), this.#r = !1, this.options.persister ? this.options.persister(
107
- i,
108
- a,
109
- this
110
- ) : i(a);
111
- }, n = {
112
- fetchOptions: e,
113
- options: this.options,
114
- queryKey: this.queryKey,
115
- client: this.#i,
116
- state: this.state,
117
- fetchFn: c
118
- };
119
- r(n), this.options.behavior?.onFetch(
120
- n,
121
- this
122
- ), this.#n = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== n.fetchOptions?.meta) && this.#s({ type: "fetch", meta: n.fetchOptions?.meta });
123
- const o = (i) => {
124
- h(i) && i.silent || this.#s({
125
- type: "error",
126
- error: i
127
- }), h(i) || (this.#e.config.onError?.(
128
- i,
129
- this
130
- ), this.#e.config.onSettled?.(
131
- this.state.data,
132
- i,
133
- this
134
- )), this.scheduleGc();
135
- };
136
- return this.#t = v({
137
- initialPromise: e?.initialPromise,
138
- fn: n.fetchFn,
139
- abort: s.abort.bind(s),
140
- onSuccess: (i) => {
141
- if (i === void 0) {
142
- process.env.NODE_ENV !== "production" && console.error(
143
- `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
144
- ), o(new Error(`${this.queryHash} data is undefined`));
145
- return;
146
- }
147
- try {
148
- this.setData(i);
149
- } catch (a) {
150
- o(a);
151
- return;
152
- }
153
- this.#e.config.onSuccess?.(i, this), this.#e.config.onSettled?.(
154
- i,
155
- this.state.error,
156
- this
157
- ), this.scheduleGc();
158
- },
159
- onError: o,
160
- onFail: (i, a) => {
161
- this.#s({ type: "failed", failureCount: i, error: a });
162
- },
163
- onPause: () => {
164
- this.#s({ type: "pause" });
165
- },
166
- onContinue: () => {
167
- this.#s({ type: "continue" });
168
- },
169
- retry: n.options.retry,
170
- retryDelay: n.options.retryDelay,
171
- networkMode: n.options.networkMode,
172
- canRun: () => !0
173
- }), this.#t.start();
174
- }
175
- #s(t) {
176
- const e = (s) => {
177
- switch (t.type) {
178
- case "failed":
179
- return {
180
- ...s,
181
- fetchFailureCount: t.failureCount,
182
- fetchFailureReason: t.error
183
- };
184
- case "pause":
185
- return {
186
- ...s,
187
- fetchStatus: "paused"
188
- };
189
- case "continue":
190
- return {
191
- ...s,
192
- fetchStatus: "fetching"
193
- };
194
- case "fetch":
195
- return {
196
- ...s,
197
- ...C(s.data, this.options),
198
- fetchMeta: t.meta ?? null
199
- };
200
- case "success":
201
- return {
202
- ...s,
203
- data: t.data,
204
- dataUpdateCount: s.dataUpdateCount + 1,
205
- dataUpdatedAt: t.dataUpdatedAt ?? Date.now(),
206
- error: null,
207
- isInvalidated: !1,
208
- status: "success",
209
- ...!t.manual && {
210
- fetchStatus: "idle",
211
- fetchFailureCount: 0,
212
- fetchFailureReason: null
213
- }
214
- };
215
- case "error":
216
- const r = t.error;
217
- return h(r) && r.revert && this.#n ? { ...this.#n, fetchStatus: "idle" } : {
218
- ...s,
219
- error: r,
220
- errorUpdateCount: s.errorUpdateCount + 1,
221
- errorUpdatedAt: Date.now(),
222
- fetchFailureCount: s.fetchFailureCount + 1,
223
- fetchFailureReason: r,
224
- fetchStatus: "idle",
225
- status: "error"
226
- };
227
- case "invalidate":
228
- return {
229
- ...s,
230
- isInvalidated: !0
231
- };
232
- case "setState":
233
- return {
234
- ...s,
235
- ...t.state
236
- };
237
- }
238
- };
239
- this.state = e(this.state), b.batch(() => {
240
- this.observers.forEach((s) => {
241
- s.onQueryUpdate();
242
- }), this.#e.notify({ query: this, type: "updated", action: t });
243
- });
244
- }
245
- };
246
- function C(t, e) {
247
- return {
248
- fetchFailureCount: 0,
249
- fetchFailureReason: null,
250
- fetchStatus: S(e.networkMode) ? "fetching" : "paused",
251
- ...t === void 0 && {
252
- error: null,
253
- status: "pending"
254
- }
255
- };
256
- }
257
- function F(t) {
258
- const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = e !== void 0, r = s ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
259
- return {
260
- data: e,
261
- dataUpdateCount: 0,
262
- dataUpdatedAt: s ? r ?? Date.now() : 0,
263
- error: null,
264
- errorUpdateCount: 0,
265
- errorUpdatedAt: 0,
266
- fetchFailureCount: 0,
267
- fetchFailureReason: null,
268
- fetchMeta: null,
269
- isInvalidated: !1,
270
- status: s ? "success" : "pending",
271
- fetchStatus: "idle"
272
- };
273
- }
274
- export {
275
- q as Q,
276
- C as f
277
- };
@@ -1,27 +0,0 @@
1
- import a from "react";
2
- const S = (t) => {
3
- let e;
4
- const n = /* @__PURE__ */ new Set(), c = (s, u) => {
5
- const o = typeof s == "function" ? s(e) : s;
6
- if (!Object.is(o, e)) {
7
- const f = e;
8
- e = u ?? (typeof o != "object" || o === null) ? o : Object.assign({}, e, o), n.forEach((g) => g(e, f));
9
- }
10
- }, i = () => e, r = { setState: c, getState: i, getInitialState: () => b, subscribe: (s) => (n.add(s), () => n.delete(s)) }, b = e = t(c, i, r);
11
- return r;
12
- }, d = (t) => t ? S(t) : S, I = (t) => t;
13
- function j(t, e = I) {
14
- const n = a.useSyncExternalStore(
15
- t.subscribe,
16
- () => e(t.getState()),
17
- () => e(t.getInitialState())
18
- );
19
- return a.useDebugValue(n), n;
20
- }
21
- const l = (t) => {
22
- const e = d(t), n = (c) => j(e, c);
23
- return Object.assign(n, e), n;
24
- }, x = (t) => t ? l(t) : l;
25
- export {
26
- x as c
27
- };
@@ -1,97 +0,0 @@
1
- import * as n from "react";
2
- import { g as l } from "./mutation-CnKIetRs.js";
3
- import { S as d, f as p, h, n as a, u as b } from "./QueryClientProvider-VtJdNkDw.js";
4
- import { n as m, s as f } from "./utils-DxRR_XLb.js";
5
- var v = class extends d {
6
- #e;
7
- #i = void 0;
8
- #t;
9
- #s;
10
- constructor(t, s) {
11
- super(), this.#e = t, this.setOptions(s), this.bindMethods(), this.#r();
12
- }
13
- bindMethods() {
14
- this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
15
- }
16
- setOptions(t) {
17
- const s = this.options;
18
- this.options = this.#e.defaultMutationOptions(t), p(this.options, s) || this.#e.getMutationCache().notify({
19
- type: "observerOptionsUpdated",
20
- mutation: this.#t,
21
- observer: this
22
- }), s?.mutationKey && this.options.mutationKey && h(s.mutationKey) !== h(this.options.mutationKey) ? this.reset() : this.#t?.state.status === "pending" && this.#t.setOptions(this.options);
23
- }
24
- onUnsubscribe() {
25
- this.hasListeners() || this.#t?.removeObserver(this);
26
- }
27
- onMutationUpdate(t) {
28
- this.#r(), this.#n(t);
29
- }
30
- getCurrentResult() {
31
- return this.#i;
32
- }
33
- reset() {
34
- this.#t?.removeObserver(this), this.#t = void 0, this.#r(), this.#n();
35
- }
36
- mutate(t, s) {
37
- return this.#s = s, this.#t?.removeObserver(this), this.#t = this.#e.getMutationCache().build(this.#e, this.options), this.#t.addObserver(this), this.#t.execute(t);
38
- }
39
- #r() {
40
- const t = this.#t?.state ?? l();
41
- this.#i = {
42
- ...t,
43
- isPending: t.status === "pending",
44
- isSuccess: t.status === "success",
45
- isError: t.status === "error",
46
- isIdle: t.status === "idle",
47
- mutate: this.mutate,
48
- reset: this.reset
49
- };
50
- }
51
- #n(t) {
52
- a.batch(() => {
53
- if (this.#s && this.hasListeners()) {
54
- const s = this.#i.variables, i = this.#i.context;
55
- t?.type === "success" ? (this.#s.onSuccess?.(t.data, s, i), this.#s.onSettled?.(t.data, null, s, i)) : t?.type === "error" && (this.#s.onError?.(t.error, s, i), this.#s.onSettled?.(
56
- void 0,
57
- t.error,
58
- s,
59
- i
60
- ));
61
- }
62
- this.listeners.forEach((s) => {
63
- s(this.#i);
64
- });
65
- });
66
- }
67
- };
68
- function C(t, s) {
69
- const i = b(), [e] = n.useState(
70
- () => new v(
71
- i,
72
- t
73
- )
74
- );
75
- n.useEffect(() => {
76
- e.setOptions(t);
77
- }, [e, t]);
78
- const r = n.useSyncExternalStore(
79
- n.useCallback(
80
- (o) => e.subscribe(a.batchCalls(o)),
81
- [e]
82
- ),
83
- () => e.getCurrentResult(),
84
- () => e.getCurrentResult()
85
- ), u = n.useCallback(
86
- (o, c) => {
87
- e.mutate(o, c).catch(m);
88
- },
89
- [e]
90
- );
91
- if (r.error && f(e.options.throwOnError, [r.error]))
92
- throw r.error;
93
- return { ...r, mutate: u, mutateAsync: r.mutate };
94
- }
95
- export {
96
- C as u
97
- };