@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
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # ModuleBase
2
- The ModuleBase provides a set of components and functions, to get the modulefederation within HortiView to work.
2
+
3
+ The ModuleBase provides a set of components and functions, to get the modulefederation within HortiView to work.
3
4
  To get a more detailed description about the modulefederation-process in HortiView, please [visit the documentation](https://docs.hortiview.com/)
4
5
 
5
6
  It will handle the navigation/routing, breadcrumb translations, usage of Common- and ModuleAPI and my more.
6
7
 
7
8
  > This package is is not the ModuleTemplate.<br />
8
- > It only provides basic and nessecary functions for the implementation of module federation within HortiView
9
+ > It only provides basic and necessary functions for the implementation of module federation within HortiView
@@ -0,0 +1,312 @@
1
+ import { R as v, r as m, a as c, d as b, e as C, f as S, t as F, c as g, C as d, n as q, g as A, i as D } from "./QueryClientProvider-DyiNrPkn.js";
2
+ import * as p from "react";
3
+ var w = class extends v {
4
+ #i;
5
+ #n;
6
+ #e;
7
+ #r;
8
+ #t;
9
+ #o;
10
+ #a;
11
+ constructor(t) {
12
+ super(), this.#a = !1, this.#o = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#r = t.client, this.#e = this.#r.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#i = f(this.options), this.state = t.state ?? this.#i, 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
+ if (this.options = { ...this.#o, ...t }, this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
22
+ const e = f(this.options);
23
+ e.data !== void 0 && (this.setState(
24
+ l(e.data, e.dataUpdatedAt)
25
+ ), this.#i = e);
26
+ }
27
+ }
28
+ optionalRemove() {
29
+ !this.observers.length && this.state.fetchStatus === "idle" && this.#e.remove(this);
30
+ }
31
+ setData(t, e) {
32
+ const i = m(this.state.data, t, this.options);
33
+ return this.#s({
34
+ data: i,
35
+ type: "success",
36
+ dataUpdatedAt: e?.updatedAt,
37
+ manual: e?.manual
38
+ }), i;
39
+ }
40
+ setState(t, e) {
41
+ this.#s({ type: "setState", state: t, setStateOptions: e });
42
+ }
43
+ cancel(t) {
44
+ const e = this.#t?.promise;
45
+ return this.#t?.cancel(t), e ? e.then(c).catch(c) : Promise.resolve();
46
+ }
47
+ destroy() {
48
+ super.destroy(), this.cancel({ silent: !0 });
49
+ }
50
+ reset() {
51
+ this.destroy(), this.setState(this.#i);
52
+ }
53
+ isActive() {
54
+ return this.observers.some(
55
+ (t) => b(t.options.enabled, this) !== !1
56
+ );
57
+ }
58
+ isDisabled() {
59
+ return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === C || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
60
+ }
61
+ isStatic() {
62
+ return this.getObserversCount() > 0 ? this.observers.some(
63
+ (t) => S(t.options.staleTime, this) === "static"
64
+ ) : !1;
65
+ }
66
+ isStale() {
67
+ return this.getObserversCount() > 0 ? this.observers.some(
68
+ (t) => t.getCurrentResult().isStale
69
+ ) : this.state.data === void 0 || this.state.isInvalidated;
70
+ }
71
+ isStaleByTime(t = 0) {
72
+ return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !F(this.state.dataUpdatedAt, t);
73
+ }
74
+ onFocus() {
75
+ this.observers.find((e) => e.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
76
+ }
77
+ onOnline() {
78
+ this.observers.find((e) => e.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
79
+ }
80
+ addObserver(t) {
81
+ this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), this.#e.notify({ type: "observerAdded", query: this, observer: t }));
82
+ }
83
+ removeObserver(t) {
84
+ this.observers.includes(t) && (this.observers = this.observers.filter((e) => e !== t), this.observers.length || (this.#t && (this.#a ? this.#t.cancel({ revert: !0 }) : this.#t.cancelRetry()), this.scheduleGc()), this.#e.notify({ type: "observerRemoved", query: this, observer: t }));
85
+ }
86
+ getObserversCount() {
87
+ return this.observers.length;
88
+ }
89
+ invalidate() {
90
+ this.state.isInvalidated || this.#s({ type: "invalidate" });
91
+ }
92
+ async fetch(t, e) {
93
+ if (this.state.fetchStatus !== "idle" && // If the promise in the retryer is already rejected, we have to definitely
94
+ // re-start the fetch; there is a chance that the query is still in a
95
+ // pending state when that happens
96
+ this.#t?.status() !== "rejected") {
97
+ if (this.state.data !== void 0 && e?.cancelRefetch)
98
+ this.cancel({ silent: !0 });
99
+ else if (this.#t)
100
+ return this.#t.continueRetry(), this.#t.promise;
101
+ }
102
+ if (t && this.setOptions(t), !this.options.queryFn) {
103
+ const s = this.observers.find((o) => o.options.queryFn);
104
+ s && this.setOptions(s.options);
105
+ }
106
+ process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
107
+ "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']"
108
+ ));
109
+ const i = new AbortController(), r = (s) => {
110
+ Object.defineProperty(s, "signal", {
111
+ enumerable: !0,
112
+ get: () => (this.#a = !0, i.signal)
113
+ });
114
+ }, n = () => {
115
+ const s = A(this.options, e), h = (() => {
116
+ const u = {
117
+ client: this.#r,
118
+ queryKey: this.queryKey,
119
+ meta: this.meta
120
+ };
121
+ return r(u), u;
122
+ })();
123
+ return this.#a = !1, this.options.persister ? this.options.persister(
124
+ s,
125
+ h,
126
+ this
127
+ ) : s(h);
128
+ }, a = (() => {
129
+ const s = {
130
+ fetchOptions: e,
131
+ options: this.options,
132
+ queryKey: this.queryKey,
133
+ client: this.#r,
134
+ state: this.state,
135
+ fetchFn: n
136
+ };
137
+ return r(s), s;
138
+ })();
139
+ this.options.behavior?.onFetch(a, this), this.#n = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== a.fetchOptions?.meta) && this.#s({ type: "fetch", meta: a.fetchOptions?.meta }), this.#t = g({
140
+ initialPromise: e?.initialPromise,
141
+ fn: a.fetchFn,
142
+ onCancel: (s) => {
143
+ s instanceof d && s.revert && this.setState({
144
+ ...this.#n,
145
+ fetchStatus: "idle"
146
+ }), i.abort();
147
+ },
148
+ onFail: (s, o) => {
149
+ this.#s({ type: "failed", failureCount: s, error: o });
150
+ },
151
+ onPause: () => {
152
+ this.#s({ type: "pause" });
153
+ },
154
+ onContinue: () => {
155
+ this.#s({ type: "continue" });
156
+ },
157
+ retry: a.options.retry,
158
+ retryDelay: a.options.retryDelay,
159
+ networkMode: a.options.networkMode,
160
+ canRun: () => !0
161
+ });
162
+ try {
163
+ const s = await this.#t.start();
164
+ if (s === void 0)
165
+ throw process.env.NODE_ENV !== "production" && console.error(
166
+ `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
167
+ ), new Error(`${this.queryHash} data is undefined`);
168
+ return this.setData(s), this.#e.config.onSuccess?.(s, this), this.#e.config.onSettled?.(
169
+ s,
170
+ this.state.error,
171
+ this
172
+ ), s;
173
+ } catch (s) {
174
+ if (s instanceof d) {
175
+ if (s.silent)
176
+ return this.#t.promise;
177
+ if (s.revert) {
178
+ if (this.state.data === void 0)
179
+ throw s;
180
+ return this.state.data;
181
+ }
182
+ }
183
+ throw this.#s({
184
+ type: "error",
185
+ error: s
186
+ }), this.#e.config.onError?.(
187
+ s,
188
+ this
189
+ ), this.#e.config.onSettled?.(
190
+ this.state.data,
191
+ s,
192
+ this
193
+ ), s;
194
+ } finally {
195
+ this.scheduleGc();
196
+ }
197
+ }
198
+ #s(t) {
199
+ const e = (i) => {
200
+ switch (t.type) {
201
+ case "failed":
202
+ return {
203
+ ...i,
204
+ fetchFailureCount: t.failureCount,
205
+ fetchFailureReason: t.error
206
+ };
207
+ case "pause":
208
+ return {
209
+ ...i,
210
+ fetchStatus: "paused"
211
+ };
212
+ case "continue":
213
+ return {
214
+ ...i,
215
+ fetchStatus: "fetching"
216
+ };
217
+ case "fetch":
218
+ return {
219
+ ...i,
220
+ ...U(i.data, this.options),
221
+ fetchMeta: t.meta ?? null
222
+ };
223
+ case "success":
224
+ const r = {
225
+ ...i,
226
+ ...l(t.data, t.dataUpdatedAt),
227
+ dataUpdateCount: i.dataUpdateCount + 1,
228
+ ...!t.manual && {
229
+ fetchStatus: "idle",
230
+ fetchFailureCount: 0,
231
+ fetchFailureReason: null
232
+ }
233
+ };
234
+ return this.#n = t.manual ? r : void 0, r;
235
+ case "error":
236
+ const n = t.error;
237
+ return {
238
+ ...i,
239
+ error: n,
240
+ errorUpdateCount: i.errorUpdateCount + 1,
241
+ errorUpdatedAt: Date.now(),
242
+ fetchFailureCount: i.fetchFailureCount + 1,
243
+ fetchFailureReason: n,
244
+ fetchStatus: "idle",
245
+ status: "error",
246
+ // flag existing data as invalidated if we get a background error
247
+ // note that "no data" always means stale so we can set unconditionally here
248
+ isInvalidated: !0
249
+ };
250
+ case "invalidate":
251
+ return {
252
+ ...i,
253
+ isInvalidated: !0
254
+ };
255
+ case "setState":
256
+ return {
257
+ ...i,
258
+ ...t.state
259
+ };
260
+ }
261
+ };
262
+ this.state = e(this.state), q.batch(() => {
263
+ this.observers.forEach((i) => {
264
+ i.onQueryUpdate();
265
+ }), this.#e.notify({ query: this, type: "updated", action: t });
266
+ });
267
+ }
268
+ };
269
+ function U(t, e) {
270
+ return {
271
+ fetchFailureCount: 0,
272
+ fetchFailureReason: null,
273
+ fetchStatus: D(e.networkMode) ? "fetching" : "paused",
274
+ ...t === void 0 && {
275
+ error: null,
276
+ status: "pending"
277
+ }
278
+ };
279
+ }
280
+ function l(t, e) {
281
+ return {
282
+ data: t,
283
+ dataUpdatedAt: e ?? Date.now(),
284
+ error: null,
285
+ isInvalidated: !1,
286
+ status: "success"
287
+ };
288
+ }
289
+ function f(t) {
290
+ const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, i = e !== void 0, r = i ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
291
+ return {
292
+ data: e,
293
+ dataUpdateCount: 0,
294
+ dataUpdatedAt: i ? r ?? Date.now() : 0,
295
+ error: null,
296
+ errorUpdateCount: 0,
297
+ errorUpdatedAt: 0,
298
+ fetchFailureCount: 0,
299
+ fetchFailureReason: null,
300
+ fetchMeta: null,
301
+ isInvalidated: !1,
302
+ status: i ? "success" : "pending",
303
+ fetchStatus: "idle"
304
+ };
305
+ }
306
+ var y = p.createContext(!1), x = () => p.useContext(y), I = y.Provider;
307
+ export {
308
+ I,
309
+ w as Q,
310
+ U as f,
311
+ x as u
312
+ };