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