@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.
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 +13 -13
  41. package/package.json +17 -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,437 +0,0 @@
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
- };
@@ -1,28 +0,0 @@
1
- var u = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
- function f(e) {
3
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4
- }
5
- function l(e) {
6
- if (e.__esModule) return e;
7
- var r = e.default;
8
- if (typeof r == "function") {
9
- var t = function o() {
10
- return this instanceof o ? Reflect.construct(r, arguments, this.constructor) : r.apply(this, arguments);
11
- };
12
- t.prototype = r.prototype;
13
- } else t = {};
14
- return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(o) {
15
- var n = Object.getOwnPropertyDescriptor(e, o);
16
- Object.defineProperty(t, o, n.get ? n : {
17
- enumerable: !0,
18
- get: function() {
19
- return e[o];
20
- }
21
- });
22
- }), t;
23
- }
24
- export {
25
- l as a,
26
- u as c,
27
- f as g
28
- };