@hortiview/modulebase 0.0.1 → 0.0.17-beta

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 (80) hide show
  1. package/README.md +8 -8
  2. package/dist/ModuleCore-YCIFN_02.js +14973 -0
  3. package/dist/QueryClientProvider-Beog9TR7.js +437 -0
  4. package/dist/{_baseGet-Bh5zJ_C8.js → _baseGet-C6jMXSsQ.js} +448 -448
  5. package/dist/api-s6E2GJtu.js +458 -0
  6. package/dist/assets/ModuleCore.css +1 -0
  7. package/dist/chunk-QMGIS6GS-C4bgXQXY.js +9203 -0
  8. package/dist/components/ModuleBase.js +20 -681
  9. package/dist/components/ModuleCore.js +10 -0
  10. package/dist/hooks/useBreadcrumbTranslation.js +16 -13
  11. package/dist/hooks/useCustom.js +15 -15
  12. package/dist/hooks/useCustomMutation.js +23 -0
  13. package/dist/hooks/useEntity.js +53 -54
  14. package/dist/hooks/useOffline.js +45 -0
  15. package/dist/hooks/useOption.js +19 -17
  16. package/dist/hooks/useServiceBus.js +25 -0
  17. package/dist/hooks/useStores.js +11 -841
  18. package/dist/isRestoring-CLuxJVSA.js +281 -0
  19. package/dist/lib/components/ModuleBase.d.ts +36 -0
  20. package/dist/lib/components/ModuleCore.d.ts +32 -0
  21. package/dist/{constants.d.ts → lib/constants.d.ts} +1 -1
  22. package/dist/{hooks → lib/hooks}/useBreadcrumbTranslation.d.ts +1 -1
  23. package/dist/lib/hooks/useCustom.d.ts +8 -0
  24. package/dist/lib/hooks/useCustomMutation.d.ts +9 -0
  25. package/dist/{hooks → lib/hooks}/useEntity.d.ts +6 -30
  26. package/dist/lib/hooks/useOffline.d.ts +15 -0
  27. package/dist/{hooks → lib/hooks}/useOption.d.ts +1 -1
  28. package/dist/lib/hooks/useServiceBus.d.ts +19 -0
  29. package/dist/lib/hooks/useStores.d.ts +38 -0
  30. package/dist/lib/main.d.ts +27 -0
  31. package/dist/lib/module-router.d.ts +7 -0
  32. package/dist/{stores → lib/stores}/EnvironmentStore.d.ts +1 -1
  33. package/dist/lib/types/ActionStorage.d.ts +16 -0
  34. package/dist/{types → lib/types}/BaseProps.d.ts +14 -2
  35. package/dist/{types → lib/types}/Deprecated.d.ts +7 -1
  36. package/dist/lib/types/Entities.d.ts +22 -0
  37. package/dist/{types → lib/types}/Environment.d.ts +3 -2
  38. package/dist/lib/types/EnvironmentVariable.d.ts +6 -0
  39. package/dist/lib/types/ModuleApi.d.ts +163 -0
  40. package/dist/{types → lib/types}/Requests.d.ts +6 -11
  41. package/dist/lib/types/ServiceBus.d.ts +17 -0
  42. package/dist/{utils/fetches.d.ts → lib/utils/api.d.ts} +2 -8
  43. package/dist/lib/utils/baseFetches.d.ts +19 -0
  44. package/dist/lib/utils/fetches.d.ts +43 -0
  45. package/dist/lib/utils/helper.d.ts +29 -0
  46. package/dist/main.js +224 -17
  47. package/dist/module-router.js +137 -0
  48. package/dist/mutation-DSKlaYzY.js +192 -0
  49. package/dist/omit-C9Qe80rl.js +835 -0
  50. package/dist/stores/EnvironmentStore.js +9 -3
  51. package/dist/types/ActionStorage.js +4 -0
  52. package/dist/types/Entities.js +25 -0
  53. package/dist/types/EnvironmentVariable.js +1 -0
  54. package/dist/types/Requests.js +1 -4
  55. package/dist/types/ServiceBus.js +1 -0
  56. package/dist/useMutation-zu8uxBak.js +97 -0
  57. package/dist/{useQuery-znAyMQW1.js → useQuery-Bj9k9zik.js} +106 -108
  58. package/dist/utils/api.js +9 -0
  59. package/dist/utils/baseFetches.js +19 -0
  60. package/dist/utils/fetches.js +20 -14
  61. package/dist/utils/helper.js +55 -0
  62. package/dist/utils-DxRR_XLb.js +9 -0
  63. package/package.json +8 -3
  64. package/dist/QueryClientProvider-DQv4Y3Qu.js +0 -707
  65. package/dist/chunk-IR6S3I6Y-BvQXS3A3.js +0 -3908
  66. package/dist/components/ModuleBase.d.ts +0 -11
  67. package/dist/fetches-DUCQo_6B.js +0 -477
  68. package/dist/hooks/useCustom.d.ts +0 -6
  69. package/dist/hooks/useNavigate.d.ts +0 -5
  70. package/dist/hooks/useNavigate.js +0 -27
  71. package/dist/hooks/useStores.d.ts +0 -29
  72. package/dist/main.d.ts +0 -9
  73. package/dist/types/ModuleApi.d.ts +0 -80
  74. /package/dist/{hooks → lib/hooks}/useSignalRMessages.d.ts +0 -0
  75. /package/dist/{provider → lib/provider}/SignalR/SignalRProvider.d.ts +0 -0
  76. /package/dist/{provider → lib/provider}/SignalR/signalR.d.ts +0 -0
  77. /package/dist/{stores → lib/stores}/BasePropsStore.d.ts +0 -0
  78. /package/dist/{types → lib/types}/AppInsights.d.ts +0 -0
  79. /package/dist/{types → lib/types}/CommonOptions.d.ts +0 -0
  80. /package/dist/{types → lib/types}/SystemMessage.d.ts +0 -0
@@ -0,0 +1,437 @@
1
+ import * as F from "react";
2
+ import { jsx as R } from "react/jsx-runtime";
3
+ var L = class {
4
+ constructor() {
5
+ this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
6
+ }
7
+ subscribe(e) {
8
+ return this.listeners.add(e), this.onSubscribe(), () => {
9
+ this.listeners.delete(e), this.onUnsubscribe();
10
+ };
11
+ }
12
+ hasListeners() {
13
+ return this.listeners.size > 0;
14
+ }
15
+ onSubscribe() {
16
+ }
17
+ onUnsubscribe() {
18
+ }
19
+ }, y = typeof window > "u" || "Deno" in globalThis;
20
+ function J() {
21
+ }
22
+ function _(e, t) {
23
+ return typeof e == "function" ? e(t) : e;
24
+ }
25
+ function Q(e) {
26
+ return typeof e == "number" && e >= 0 && e !== 1 / 0;
27
+ }
28
+ function B(e, t) {
29
+ return Math.max(e + (t || 0) - Date.now(), 0);
30
+ }
31
+ function W(e, t) {
32
+ return typeof e == "function" ? e(t) : e;
33
+ }
34
+ function X(e, t) {
35
+ return typeof e == "function" ? e(t) : e;
36
+ }
37
+ function Y(e, t) {
38
+ const {
39
+ type: n = "all",
40
+ exact: r,
41
+ fetchStatus: s,
42
+ predicate: o,
43
+ queryKey: l,
44
+ stale: i
45
+ } = e;
46
+ if (l) {
47
+ if (r) {
48
+ if (t.queryHash !== K(l, t.options))
49
+ return !1;
50
+ } else if (!S(t.queryKey, l))
51
+ return !1;
52
+ }
53
+ if (n !== "all") {
54
+ const u = t.isActive();
55
+ if (n === "active" && !u || n === "inactive" && u)
56
+ return !1;
57
+ }
58
+ return !(typeof i == "boolean" && t.isStale() !== i || s && s !== t.state.fetchStatus || o && !o(t));
59
+ }
60
+ function Z(e, t) {
61
+ const { exact: n, status: r, predicate: s, mutationKey: o } = e;
62
+ if (o) {
63
+ if (!t.options.mutationKey)
64
+ return !1;
65
+ if (n) {
66
+ if (w(t.options.mutationKey) !== w(o))
67
+ return !1;
68
+ } else if (!S(t.options.mutationKey, o))
69
+ return !1;
70
+ }
71
+ return !(r && t.state.status !== r || s && !s(t));
72
+ }
73
+ function K(e, t) {
74
+ return (t?.queryKeyHashFn || w)(e);
75
+ }
76
+ function w(e) {
77
+ return JSON.stringify(
78
+ e,
79
+ (t, n) => g(n) ? Object.keys(n).sort().reduce((r, s) => (r[s] = n[s], r), {}) : n
80
+ );
81
+ }
82
+ function S(e, t) {
83
+ return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? !Object.keys(t).some((n) => !S(e[n], t[n])) : !1;
84
+ }
85
+ function E(e, t) {
86
+ if (e === t)
87
+ return e;
88
+ const n = j(e) && j(t);
89
+ if (n || g(e) && g(t)) {
90
+ const r = n ? e : Object.keys(e), s = r.length, o = n ? t : Object.keys(t), l = o.length, i = n ? [] : {};
91
+ let u = 0;
92
+ for (let f = 0; f < l; f++) {
93
+ const c = n ? f : o[f];
94
+ (!n && r.includes(c) || n) && e[c] === void 0 && t[c] === void 0 ? (i[c] = void 0, u++) : (i[c] = E(e[c], t[c]), i[c] === e[c] && e[c] !== void 0 && u++);
95
+ }
96
+ return s === l && u === s ? e : i;
97
+ }
98
+ return t;
99
+ }
100
+ function ee(e, t) {
101
+ if (!t || Object.keys(e).length !== Object.keys(t).length)
102
+ return !1;
103
+ for (const n in e)
104
+ if (e[n] !== t[n])
105
+ return !1;
106
+ return !0;
107
+ }
108
+ function j(e) {
109
+ return Array.isArray(e) && e.length === Object.keys(e).length;
110
+ }
111
+ function g(e) {
112
+ if (!T(e))
113
+ return !1;
114
+ const t = e.constructor;
115
+ if (t === void 0)
116
+ return !0;
117
+ const n = t.prototype;
118
+ return !(!T(n) || !n.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
119
+ }
120
+ function T(e) {
121
+ return Object.prototype.toString.call(e) === "[object Object]";
122
+ }
123
+ function z(e) {
124
+ return new Promise((t) => {
125
+ setTimeout(t, e);
126
+ });
127
+ }
128
+ function te(e, t, n) {
129
+ if (typeof n.structuralSharing == "function")
130
+ return n.structuralSharing(e, t);
131
+ if (n.structuralSharing !== !1) {
132
+ if (process.env.NODE_ENV !== "production")
133
+ try {
134
+ return E(e, t);
135
+ } catch (r) {
136
+ console.error(
137
+ `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`
138
+ );
139
+ }
140
+ return E(e, t);
141
+ }
142
+ return t;
143
+ }
144
+ function ne(e, t, n = 0) {
145
+ const r = [...e, t];
146
+ return n && r.length > n ? r.slice(1) : r;
147
+ }
148
+ function re(e, t, n = 0) {
149
+ const r = [t, ...e];
150
+ return n && r.length > n ? r.slice(0, -1) : r;
151
+ }
152
+ var P = Symbol();
153
+ function se(e, t) {
154
+ return process.env.NODE_ENV !== "production" && e.queryFn === P && console.error(
155
+ `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`
156
+ ), !e.queryFn && t?.initialPromise ? () => t.initialPromise : !e.queryFn || e.queryFn === P ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
157
+ }
158
+ var D = class extends L {
159
+ #e;
160
+ #t;
161
+ #n;
162
+ constructor() {
163
+ super(), this.#n = (e) => {
164
+ if (!y && window.addEventListener) {
165
+ const t = () => e();
166
+ return window.addEventListener("visibilitychange", t, !1), () => {
167
+ window.removeEventListener("visibilitychange", t);
168
+ };
169
+ }
170
+ };
171
+ }
172
+ onSubscribe() {
173
+ this.#t || this.setEventListener(this.#n);
174
+ }
175
+ onUnsubscribe() {
176
+ this.hasListeners() || (this.#t?.(), this.#t = void 0);
177
+ }
178
+ setEventListener(e) {
179
+ this.#n = e, this.#t?.(), this.#t = e((t) => {
180
+ typeof t == "boolean" ? this.setFocused(t) : this.onFocus();
181
+ });
182
+ }
183
+ setFocused(e) {
184
+ this.#e !== e && (this.#e = e, this.onFocus());
185
+ }
186
+ onFocus() {
187
+ const e = this.isFocused();
188
+ this.listeners.forEach((t) => {
189
+ t(e);
190
+ });
191
+ }
192
+ isFocused() {
193
+ return typeof this.#e == "boolean" ? this.#e : globalThis.document?.visibilityState !== "hidden";
194
+ }
195
+ }, I = new D(), A = class extends L {
196
+ #e = !0;
197
+ #t;
198
+ #n;
199
+ constructor() {
200
+ super(), this.#n = (e) => {
201
+ if (!y && window.addEventListener) {
202
+ const t = () => e(!0), n = () => e(!1);
203
+ return window.addEventListener("online", t, !1), window.addEventListener("offline", n, !1), () => {
204
+ window.removeEventListener("online", t), window.removeEventListener("offline", n);
205
+ };
206
+ }
207
+ };
208
+ }
209
+ onSubscribe() {
210
+ this.#t || this.setEventListener(this.#n);
211
+ }
212
+ onUnsubscribe() {
213
+ this.hasListeners() || (this.#t?.(), this.#t = void 0);
214
+ }
215
+ setEventListener(e) {
216
+ this.#n = e, this.#t?.(), this.#t = e(this.setOnline.bind(this));
217
+ }
218
+ setOnline(e) {
219
+ this.#e !== e && (this.#e = e, this.listeners.forEach((n) => {
220
+ n(e);
221
+ }));
222
+ }
223
+ isOnline() {
224
+ return this.#e;
225
+ }
226
+ }, k = new A();
227
+ function U() {
228
+ let e, t;
229
+ const n = new Promise((s, o) => {
230
+ e = s, t = o;
231
+ });
232
+ n.status = "pending", n.catch(() => {
233
+ });
234
+ function r(s) {
235
+ Object.assign(n, s), delete n.resolve, delete n.reject;
236
+ }
237
+ return n.resolve = (s) => {
238
+ r({
239
+ status: "fulfilled",
240
+ value: s
241
+ }), e(s);
242
+ }, n.reject = (s) => {
243
+ r({
244
+ status: "rejected",
245
+ reason: s
246
+ }), t(s);
247
+ }, n;
248
+ }
249
+ function G(e) {
250
+ return Math.min(1e3 * 2 ** e, 3e4);
251
+ }
252
+ function H(e) {
253
+ return (e ?? "online") === "online" ? k.isOnline() : !0;
254
+ }
255
+ var C = class extends Error {
256
+ constructor(e) {
257
+ super("CancelledError"), this.revert = e?.revert, this.silent = e?.silent;
258
+ }
259
+ };
260
+ function ie(e) {
261
+ return e instanceof C;
262
+ }
263
+ function oe(e) {
264
+ let t = !1, n = 0, r = !1, s;
265
+ const o = U(), l = (a) => {
266
+ r || (b(new C(a)), e.abort?.());
267
+ }, i = () => {
268
+ t = !0;
269
+ }, u = () => {
270
+ t = !1;
271
+ }, f = () => I.isFocused() && (e.networkMode === "always" || k.isOnline()) && e.canRun(), c = () => H(e.networkMode) && e.canRun(), M = (a) => {
272
+ r || (r = !0, e.onSuccess?.(a), s?.(), o.resolve(a));
273
+ }, b = (a) => {
274
+ r || (r = !0, e.onError?.(a), s?.(), o.reject(a));
275
+ }, O = () => new Promise((a) => {
276
+ s = (p) => {
277
+ (r || f()) && a(p);
278
+ }, e.onPause?.();
279
+ }).then(() => {
280
+ s = void 0, r || e.onContinue?.();
281
+ }), m = () => {
282
+ if (r)
283
+ return;
284
+ let a;
285
+ const p = n === 0 ? e.initialPromise : void 0;
286
+ try {
287
+ a = p ?? e.fn();
288
+ } catch (h) {
289
+ a = Promise.reject(h);
290
+ }
291
+ Promise.resolve(a).then(M).catch((h) => {
292
+ if (r)
293
+ return;
294
+ const d = e.retry ?? (y ? 0 : 3), v = e.retryDelay ?? G, x = typeof v == "function" ? v(n, h) : v, N = d === !0 || typeof d == "number" && n < d || typeof d == "function" && d(n, h);
295
+ if (t || !N) {
296
+ b(h);
297
+ return;
298
+ }
299
+ n++, e.onFail?.(n, h), z(x).then(() => f() ? void 0 : O()).then(() => {
300
+ t ? b(h) : m();
301
+ });
302
+ });
303
+ };
304
+ return {
305
+ promise: o,
306
+ cancel: l,
307
+ continue: () => (s?.(), o),
308
+ cancelRetry: i,
309
+ continueRetry: u,
310
+ canStart: c,
311
+ start: () => (c() ? m() : O().then(m), o)
312
+ };
313
+ }
314
+ function V() {
315
+ let e = [], t = 0, n = (i) => {
316
+ i();
317
+ }, r = (i) => {
318
+ i();
319
+ }, s = (i) => setTimeout(i, 0);
320
+ const o = (i) => {
321
+ t ? e.push(i) : s(() => {
322
+ n(i);
323
+ });
324
+ }, l = () => {
325
+ const i = e;
326
+ e = [], i.length && s(() => {
327
+ r(() => {
328
+ i.forEach((u) => {
329
+ n(u);
330
+ });
331
+ });
332
+ });
333
+ };
334
+ return {
335
+ batch: (i) => {
336
+ let u;
337
+ t++;
338
+ try {
339
+ u = i();
340
+ } finally {
341
+ t--, t || l();
342
+ }
343
+ return u;
344
+ },
345
+ /**
346
+ * All calls to the wrapped function will be batched.
347
+ */
348
+ batchCalls: (i) => (...u) => {
349
+ o(() => {
350
+ i(...u);
351
+ });
352
+ },
353
+ schedule: o,
354
+ /**
355
+ * Use this method to set a custom notify function.
356
+ * This can be used to for example wrap notifications with `React.act` while running tests.
357
+ */
358
+ setNotifyFunction: (i) => {
359
+ n = i;
360
+ },
361
+ /**
362
+ * Use this method to set a custom function to batch notifications together into a single tick.
363
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
364
+ */
365
+ setBatchNotifyFunction: (i) => {
366
+ r = i;
367
+ },
368
+ setScheduler: (i) => {
369
+ s = i;
370
+ }
371
+ };
372
+ }
373
+ var ue = V(), ce = class {
374
+ #e;
375
+ destroy() {
376
+ this.clearGcTimeout();
377
+ }
378
+ scheduleGc() {
379
+ this.clearGcTimeout(), Q(this.gcTime) && (this.#e = setTimeout(() => {
380
+ this.optionalRemove();
381
+ }, this.gcTime));
382
+ }
383
+ updateGcTime(e) {
384
+ this.gcTime = Math.max(
385
+ this.gcTime || 0,
386
+ e ?? (y ? 1 / 0 : 5 * 60 * 1e3)
387
+ );
388
+ }
389
+ clearGcTimeout() {
390
+ this.#e && (clearTimeout(this.#e), this.#e = void 0);
391
+ }
392
+ }, q = F.createContext(
393
+ void 0
394
+ ), ae = (e) => {
395
+ const t = F.useContext(q);
396
+ if (e)
397
+ return e;
398
+ if (!t)
399
+ throw new Error("No QueryClient set, use QueryClientProvider to set one");
400
+ return t;
401
+ }, le = ({
402
+ client: e,
403
+ children: t
404
+ }) => (F.useEffect(() => (e.mount(), () => {
405
+ e.unmount();
406
+ }), [e]), /* @__PURE__ */ R(q.Provider, { value: e, children: t }));
407
+ export {
408
+ le as Q,
409
+ ce as R,
410
+ L as S,
411
+ J as a,
412
+ X as b,
413
+ oe as c,
414
+ P as d,
415
+ se as e,
416
+ H as f,
417
+ W as g,
418
+ w as h,
419
+ ie as i,
420
+ y as j,
421
+ Q as k,
422
+ I as l,
423
+ K as m,
424
+ ue as n,
425
+ Y as o,
426
+ U as p,
427
+ Z as q,
428
+ te as r,
429
+ ee as s,
430
+ B as t,
431
+ ae as u,
432
+ re as v,
433
+ ne as w,
434
+ k as x,
435
+ _ as y,
436
+ S as z
437
+ };