@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.
- package/README.md +3 -2
- package/dist/IsRestoringProvider-CBSZo7ur.js +312 -0
- package/dist/ModuleCore-DuJVrj6v.js +11828 -0
- package/dist/QueryClientProvider-DyiNrPkn.js +514 -0
- package/dist/_commonjsHelpers-ByX85dGu.js +33 -0
- package/dist/api-COabZnyn.js +147 -0
- package/dist/assets/ModuleCore.css +1 -1
- package/dist/chunk-LFPYN7LY-D1ls8FXf.js +8643 -0
- package/dist/components/ModuleBase.js +9 -9
- package/dist/components/ModuleCore.js +1 -1
- package/dist/constants.js +2 -3
- package/dist/hooks/useCustom.js +1 -1
- package/dist/hooks/useCustomMutation.js +5 -5
- package/dist/hooks/useEntity.js +30 -30
- package/dist/hooks/useOffline.js +1 -1
- package/dist/hooks/useOption.js +5 -5
- package/dist/hooks/useServiceBus.js +1 -1
- package/dist/hooks/useStores.js +1 -1
- package/dist/{_baseGet-C6jMXSsQ.js → isTypedArray-SkhznY1k.js} +494 -494
- package/dist/lib/constants.d.ts +0 -1
- package/dist/lib/hooks/useCustom.d.ts +4 -2
- package/dist/lib/hooks/useCustomMutation.d.ts +8 -3
- package/dist/lib/hooks/useEntity.d.ts +6 -0
- package/dist/lib/types/Requests.d.ts +0 -17
- package/dist/lib/utils/api.d.ts +6 -13
- package/dist/lib/utils/baseFetches.d.ts +3 -2
- package/dist/main.js +188 -173
- package/dist/module-router.js +2322 -121
- package/dist/{mutation-DSKlaYzY.js → mutation-CmhiEgfA.js} +101 -56
- package/dist/{omit-C9Qe80rl.js → omit-Do6MFRwA.js} +240 -223
- package/dist/provider/SignalR/SignalRProvider.js +2389 -2824
- package/dist/react-c9FSfB30.js +27 -0
- package/dist/stores/BasePropsStore.js +1 -1
- package/dist/stores/EnvironmentStore.js +1 -1
- package/dist/useMutation-Aoachkw_.js +139 -0
- package/dist/useQuery-DEU_AUtf.js +392 -0
- package/dist/utils/api.js +3 -4
- package/dist/utils/baseFetches.js +18 -14
- package/dist/utils/fetches.js +3 -4
- package/dist/utils/helper.js +13 -13
- package/package.json +17 -13
- package/dist/ModuleCore-DpwHP0IU.js +0 -14973
- package/dist/QueryClientProvider-Beog9TR7.js +0 -437
- package/dist/_commonjsHelpers-BkfeUUK-.js +0 -28
- package/dist/api-CogBuK0n.js +0 -473
- package/dist/chunk-IR6S3I6Y-BmDdD3SP.js +0 -8162
- package/dist/isRestoring-CLuxJVSA.js +0 -281
- package/dist/react-QiIgv49H.js +0 -27
- package/dist/useMutation-zu8uxBak.js +0 -97
- package/dist/useQuery-Bj9k9zik.js +0 -395
- package/dist/utils-DxRR_XLb.js +0 -9
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# ModuleBase
|
|
2
|
-
|
|
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
|
|
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
|
+
};
|