@hortiview/modulebase 1.1.2-alpha.a0b1047e.1 → 1.1.2-alpha.a87fc893.1

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 (92) hide show
  1. package/{dist/ModuleCore-DRMqZO8r.js → ModuleCore-C4Z4zObE.js} +3030 -3110
  2. package/{dist/api-COabZnyn.js → api-CikhPcJj.js} +10 -10
  3. package/{dist/chunk-EVOBXE3Y-B43QN6RE.js → chunk-KS7C4IRE-CT7Z8Xx_.js} +3866 -3585
  4. package/components/ModuleBase.js +30 -0
  5. package/{dist/components → components}/ModuleCore.js +2 -3
  6. package/{dist/constants.js → constants.js} +8 -8
  7. package/{dist/hooks → hooks}/useCustom.js +9 -9
  8. package/{dist/hooks → hooks}/useCustomMutation.js +6 -6
  9. package/{dist/hooks → hooks}/useEntity.js +5 -5
  10. package/hooks/useOffline.js +57 -0
  11. package/{dist/hooks → hooks}/useOption.js +6 -6
  12. package/{dist/hooks → hooks}/useSignalRMessages.js +1 -1
  13. package/{dist/hooks → hooks}/useStores.js +1 -1
  14. package/{dist/isTypedArray-SkhznY1k.js → isTypedArray-T1_r8YHg.js} +33 -33
  15. package/{dist/lib → lib}/components/ModuleBase.d.ts +1 -1
  16. package/{dist/lib → lib}/components/ModuleCore.d.ts +1 -2
  17. package/{dist/lib → lib}/hooks/useCustom.d.ts +1 -1
  18. package/{dist/lib → lib}/hooks/useCustomMutation.d.ts +1 -1
  19. package/{dist/lib → lib}/hooks/useOffline.d.ts +5 -5
  20. package/lib/provider/SignalR/SignalRModuleContext.d.ts +4 -0
  21. package/lib/provider/SignalR/SignalRProvider.d.ts +9 -0
  22. package/lib/types/BaseProps.d.ts +98 -0
  23. package/lib/utils/IndexedDbService.d.ts +6 -0
  24. package/main.js +228 -0
  25. package/{dist/module-router.js → module-router.js} +813 -847
  26. package/{dist/omit-DYPaIq41.js → omit-CiJPWayj.js} +66 -66
  27. package/package.json +22 -56
  28. package/provider/SignalR/SignalRModuleContext.js +6205 -0
  29. package/provider/SignalR/SignalRProvider.js +35 -0
  30. package/{dist/stores → stores}/BasePropsStore.js +1 -0
  31. package/{dist/stores → stores}/EnvironmentStore.js +5 -5
  32. package/{dist/types → types}/Entities.js +5 -5
  33. package/{dist/useCustomMutation-9VUQ7NbQ.js → useCustomMutation-BX8lKAYe.js} +10 -10
  34. package/{dist/useQuery-DUDyh33-.js → useQuery-URJEw3ly.js} +128 -126
  35. package/utils/IndexedDbService.js +43 -0
  36. package/{dist/utils → utils}/api.js +1 -1
  37. package/{dist/utils → utils}/baseFetches.js +1 -1
  38. package/README.md +0 -9
  39. package/dist/components/ModuleBase.js +0 -21
  40. package/dist/hooks/useOffline.js +0 -57
  41. package/dist/lib/provider/SignalR/SignalRProvider.d.ts +0 -13
  42. package/dist/lib/types/BaseProps.d.ts +0 -48
  43. package/dist/lib/utils/IndexedDbService.d.ts +0 -33
  44. package/dist/main.js +0 -228
  45. package/dist/provider/SignalR/SignalRProvider.js +0 -5979
  46. package/dist/utils/IndexedDbService.js +0 -43
  47. package/{dist/IsRestoringProvider-SzKJZczp.js → IsRestoringProvider-SzKJZczp.js} +0 -0
  48. package/{dist/_commonjsHelpers-ByX85dGu.js → _commonjsHelpers-ByX85dGu.js} +0 -0
  49. package/{dist/assets → assets}/ModuleCore.css +0 -0
  50. package/{dist/enum → enum}/ActionStorage.js +0 -0
  51. package/{dist/hooks → hooks}/useBreadcrumbTranslation.js +0 -0
  52. package/{dist/lib → lib}/constants.d.ts +8 -8
  53. /package/{dist/lib → lib}/enum/ActionStorage.d.ts +0 -0
  54. /package/{dist/lib → lib}/hooks/useBreadcrumbTranslation.d.ts +0 -0
  55. /package/{dist/lib → lib}/hooks/useEntity.d.ts +0 -0
  56. /package/{dist/lib → lib}/hooks/useOption.d.ts +0 -0
  57. /package/{dist/lib → lib}/hooks/useSignalRMessages.d.ts +0 -0
  58. /package/{dist/lib → lib}/hooks/useStores.d.ts +0 -0
  59. /package/{dist/lib → lib}/main.d.ts +0 -0
  60. /package/{dist/lib → lib}/module-router.d.ts +0 -0
  61. /package/{dist/lib → lib}/provider/SignalR/signalR.d.ts +0 -0
  62. /package/{dist/lib → lib}/stores/BasePropsStore.d.ts +0 -0
  63. /package/{dist/lib → lib}/stores/EnvironmentStore.d.ts +0 -0
  64. /package/{dist/lib → lib}/types/ActionStorage.d.ts +0 -0
  65. /package/{dist/lib → lib}/types/AppInsights.d.ts +0 -0
  66. /package/{dist/lib → lib}/types/CommonOptions.d.ts +0 -0
  67. /package/{dist/lib → lib}/types/Entities.d.ts +0 -0
  68. /package/{dist/lib → lib}/types/Environment.d.ts +0 -0
  69. /package/{dist/lib → lib}/types/EnvironmentVariable.d.ts +0 -0
  70. /package/{dist/lib → lib}/types/ModuleApi.d.ts +0 -0
  71. /package/{dist/lib → lib}/types/Requests.d.ts +0 -0
  72. /package/{dist/lib → lib}/types/ServiceBus.d.ts +0 -0
  73. /package/{dist/lib → lib}/types/SystemMessage.d.ts +0 -0
  74. /package/{dist/lib → lib}/utils/api.d.ts +0 -0
  75. /package/{dist/lib → lib}/utils/baseFetches.d.ts +0 -0
  76. /package/{dist/lib → lib}/utils/fetches.d.ts +0 -0
  77. /package/{dist/lib → lib}/utils/helper.d.ts +0 -0
  78. /package/{dist/provider → provider}/SignalR/signalR.js +0 -0
  79. /package/{dist/react-c9FSfB30.js → react-c9FSfB30.js} +0 -0
  80. /package/{dist/types → types}/ActionStorage.js +0 -0
  81. /package/{dist/types → types}/AppInsights.js +0 -0
  82. /package/{dist/types → types}/BaseProps.js +0 -0
  83. /package/{dist/types → types}/CommonOptions.js +0 -0
  84. /package/{dist/types → types}/Environment.js +0 -0
  85. /package/{dist/types → types}/EnvironmentVariable.js +0 -0
  86. /package/{dist/types → types}/ModuleApi.js +0 -0
  87. /package/{dist/types → types}/Requests.js +0 -0
  88. /package/{dist/types → types}/ServiceBus.js +0 -0
  89. /package/{dist/types → types}/SystemMessage.js +0 -0
  90. /package/{dist/utils → utils}/fetches.js +0 -0
  91. /package/{dist/utils → utils}/helper.js +0 -0
  92. /package/{dist/vite-env.d.js → vite-env.d.js} +0 -0
@@ -0,0 +1,35 @@
1
+ import { jsx as m, Fragment as d } from "react/jsx-runtime";
2
+ import { useMemo as u } from "react";
3
+ import { useBasePropsStore as t } from "../../stores/BasePropsStore.js";
4
+ import { useEnvironmentStore as p } from "../../stores/EnvironmentStore.js";
5
+ import { SignalRModuleContext as l } from "./SignalRModuleContext.js";
6
+ const A = ({
7
+ children: i,
8
+ enabled: c
9
+ }) => {
10
+ const e = t((o) => o.modulePermissionToken), r = t((o) => o.moduleId), n = t((o) => o.organizationId), s = p((o) => o.environment), a = u(
11
+ () => ({
12
+ accessTokenFactory: () => e ?? "",
13
+ automaticReconnect: [1e4, 2e4, 3e4, 6e4],
14
+ // 10s, 20s, 30s, 60s four retries
15
+ headers: {
16
+ Authorization: `Bearer ${e}`
17
+ },
18
+ onError: async (o) => console.error("SignalR connection error", o)
19
+ }),
20
+ [e]
21
+ );
22
+ return c ? /* @__PURE__ */ m(
23
+ l.Provider,
24
+ {
25
+ ...a,
26
+ connectEnabled: !!e && !!r && !!n,
27
+ dependencies: [e, r, s?.MODULE_AUTH_API, n],
28
+ url: `${s?.MODULE_AUTH_API}/api/${n}/${r}/pushNotifications`,
29
+ children: i
30
+ }
31
+ ) : /* @__PURE__ */ m(d, { children: i });
32
+ };
33
+ export {
34
+ A as SignalRProvider
35
+ };
@@ -1,5 +1,6 @@
1
1
  import { c as o } from "../react-c9FSfB30.js";
2
2
  const t = o((e) => ({
3
+ basePath: "",
3
4
  setBaseProps: (s) => e({ ...s })
4
5
  }));
5
6
  export {
@@ -1,14 +1,14 @@
1
1
  import { c as r } from "../react-c9FSfB30.js";
2
2
  const E = r((e) => ({
3
+ addEnvironment: (n) => e((o) => ({ environment: { ...n, ...o.environment } })),
3
4
  environment: {
4
- ENVIRONMENT: "DEV",
5
+ API_PREFIX: "",
5
6
  COMMON_API: "",
6
- REQ_VERSION: "",
7
+ ENVIRONMENT: "DEV",
7
8
  MODULE_AUTH_API: "",
8
- API_PREFIX: ""
9
+ REQ_VERSION: ""
9
10
  },
10
- setEnvironment: (n) => e({ environment: n }),
11
- addEnvironment: (n) => e((o) => ({ environment: { ...n, ...o.environment } }))
11
+ setEnvironment: (n) => e({ environment: n })
12
12
  }));
13
13
  export {
14
14
  E as useEnvironmentStore
@@ -1,17 +1,17 @@
1
1
  const e = {
2
+ alert_rules: "farmAlertRule",
3
+ farm_organizations: "farmOrg",
2
4
  farms: "farm",
3
5
  fields: "field",
4
- zones: "block",
5
6
  irrigation_stations: "irrigationStation",
6
- farm_organizations: "farmOrg",
7
- alert_rules: "farmAlertRule"
7
+ zones: "block"
8
8
  }, t = {
9
9
  farm_members: "member"
10
10
  }, a = {
11
- Season: "season",
12
11
  BlockPlantLayout: "blockPlantLayout",
13
12
  Record: "recordLight",
14
- Scouting: "scouting"
13
+ Scouting: "scouting",
14
+ Season: "season"
15
15
  }, r = {
16
16
  ...e,
17
17
  ...t,
@@ -1,14 +1,14 @@
1
1
  import * as n from "react";
2
- import { g as m } from "./ModuleCore-DRMqZO8r.js";
2
+ import { g as m } from "./ModuleCore-C4Z4zObE.js";
3
3
  import { S as p, s as l, b as u, n as c, u as d, c as b, d as v } from "./IsRestoringProvider-SzKJZczp.js";
4
4
  import "react/jsx-runtime";
5
- import "./provider/SignalR/SignalRProvider.js";
6
5
  import "./stores/BasePropsStore.js";
6
+ import "./stores/EnvironmentStore.js";
7
+ import "./provider/SignalR/SignalRModuleContext.js";
7
8
  import { mutateOnCustomApi as f } from "./utils/fetches.js";
8
9
  import "./types/Entities.js";
9
- import "./api-COabZnyn.js";
10
- import "./omit-DYPaIq41.js";
11
- import "./stores/EnvironmentStore.js";
10
+ import "./api-CikhPcJj.js";
11
+ import "./omit-CiJPWayj.js";
12
12
  var y = class extends p {
13
13
  #s;
14
14
  #i = void 0;
@@ -144,13 +144,13 @@ function O(t, s) {
144
144
  }
145
145
  const P = ({
146
146
  endpoint: t,
147
- method: s,
148
- token: r,
149
- headers: e,
150
- noAuth: i,
147
+ headers: s,
148
+ method: r,
149
+ noAuth: e,
150
+ token: i,
151
151
  ...a
152
152
  }) => O({
153
- mutationFn: ({ input: o, replaceEndpointWith: h }) => f(h ?? t, o, s, r, e, i),
153
+ mutationFn: ({ input: o, replaceEndpointWith: h }) => f(h ?? t, o, r, i, s, e),
154
154
  ...a
155
155
  });
156
156
  export {
@@ -1,5 +1,5 @@
1
- import { S as q, p as L, r as u, s as M, e as y, c as Q, f as _, i as j, t as K, g as w, j as $, k as G, l as B, n as W, d as z, m as J, u as X } from "./IsRestoringProvider-SzKJZczp.js";
2
- import * as m from "react";
1
+ import { S as q, p as L, r as c, s as Q, e as y, c as _, f as F, i as j, t as K, g as C, j as $, k as G, l as B, n as W, d as z, m as J, u as X } from "./IsRestoringProvider-SzKJZczp.js";
2
+ import * as v from "react";
3
3
  import "react/jsx-runtime";
4
4
  var Y = class extends q {
5
5
  constructor(t, e) {
@@ -13,7 +13,7 @@ var Y = class extends q {
13
13
  #u;
14
14
  #r;
15
15
  #i;
16
- #m;
16
+ #v;
17
17
  #l;
18
18
  // This property keeps track of the last query with defined data.
19
19
  // It will be used to pass the previous data and query to the placeholder function between renders.
@@ -32,14 +32,14 @@ var Y = class extends q {
32
32
  this.hasListeners() || this.destroy();
33
33
  }
34
34
  shouldFetchOnReconnect() {
35
- return F(
35
+ return P(
36
36
  this.#t,
37
37
  this.options,
38
38
  this.options.refetchOnReconnect
39
39
  );
40
40
  }
41
41
  shouldFetchOnWindowFocus() {
42
- return F(
42
+ return P(
43
43
  this.#t,
44
44
  this.options,
45
45
  this.options.refetchOnWindowFocus
@@ -50,11 +50,11 @@ var Y = class extends q {
50
50
  }
51
51
  setOptions(t) {
52
52
  const e = this.options, s = this.#t;
53
- if (this.options = this.#s.defaultQueryOptions(t), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof u(this.options.enabled, this.#t) != "boolean")
53
+ if (this.options = this.#s.defaultQueryOptions(t), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof c(this.options.enabled, this.#t) != "boolean")
54
54
  throw new Error(
55
55
  "Expected enabled to be a boolean or a callback that returns a boolean"
56
56
  );
57
- this.#O(), this.#t.setOptions(this.options), e._defaulted && !M(this.options, e) && this.#s.getQueryCache().notify({
57
+ this.#O(), this.#t.setOptions(this.options), e._defaulted && !Q(this.options, e) && this.#s.getQueryCache().notify({
58
58
  type: "observerOptionsUpdated",
59
59
  query: this.#t,
60
60
  observer: this
@@ -65,9 +65,9 @@ var Y = class extends q {
65
65
  s,
66
66
  this.options,
67
67
  e
68
- ) && this.#c(), this.updateResult(), r && (this.#t !== s || u(this.options.enabled, this.#t) !== u(e.enabled, this.#t) || y(this.options.staleTime, this.#t) !== y(e.staleTime, this.#t)) && this.#v();
69
- const i = this.#b();
70
- r && (this.#t !== s || u(this.options.enabled, this.#t) !== u(e.enabled, this.#t) || i !== this.#n) && this.#g(i);
68
+ ) && this.#c(), this.updateResult(), r && (this.#t !== s || c(this.options.enabled, this.#t) !== c(e.enabled, this.#t) || y(this.options.staleTime, this.#t) !== y(e.staleTime, this.#t)) && this.#b();
69
+ const n = this.#m();
70
+ r && (this.#t !== s || c(this.options.enabled, this.#t) !== c(e.enabled, this.#t) || n !== this.#n) && this.#g(n);
71
71
  }
72
72
  getOptimisticResult(t) {
73
73
  const e = this.#s.getQueryCache().build(this.#s, t), s = this.createResult(e, t);
@@ -112,116 +112,116 @@ var Y = class extends q {
112
112
  this.options,
113
113
  t
114
114
  );
115
- return t?.throwOnError || (e = e.catch(Q)), e;
115
+ return t?.throwOnError || (e = e.catch(_)), e;
116
116
  }
117
- #v() {
117
+ #b() {
118
118
  this.#R();
119
119
  const t = y(
120
120
  this.options.staleTime,
121
121
  this.#t
122
122
  );
123
- if (_.isServer() || this.#e.isStale || !j(t))
123
+ if (F.isServer() || this.#e.isStale || !j(t))
124
124
  return;
125
125
  const s = K(this.#e.dataUpdatedAt, t) + 1;
126
- this.#o = w.setTimeout(() => {
126
+ this.#o = C.setTimeout(() => {
127
127
  this.#e.isStale || this.updateResult();
128
128
  }, s);
129
129
  }
130
- #b() {
130
+ #m() {
131
131
  return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#t) : this.options.refetchInterval) ?? !1;
132
132
  }
133
133
  #g(t) {
134
- this.#S(), this.#n = t, !(_.isServer() || u(this.options.enabled, this.#t) === !1 || !j(this.#n) || this.#n === 0) && (this.#h = w.setInterval(() => {
134
+ this.#S(), this.#n = t, !(F.isServer() || c(this.options.enabled, this.#t) === !1 || !j(this.#n) || this.#n === 0) && (this.#h = C.setInterval(() => {
135
135
  (this.options.refetchIntervalInBackground || $.isFocused()) && this.#c();
136
136
  }, this.#n));
137
137
  }
138
138
  #y() {
139
- this.#v(), this.#g(this.#b());
139
+ this.#b(), this.#g(this.#m());
140
140
  }
141
141
  #R() {
142
- this.#o !== void 0 && (w.clearTimeout(this.#o), this.#o = void 0);
142
+ this.#o !== void 0 && (C.clearTimeout(this.#o), this.#o = void 0);
143
143
  }
144
144
  #S() {
145
- this.#h !== void 0 && (w.clearInterval(this.#h), this.#h = void 0);
145
+ this.#h !== void 0 && (C.clearInterval(this.#h), this.#h = void 0);
146
146
  }
147
147
  createResult(t, e) {
148
- const s = this.#t, r = this.options, i = this.#e, l = this.#a, n = this.#u, v = t !== s ? t.state : this.#p, { state: h } = t;
149
- let a = { ...h }, b = !1, o;
148
+ const s = this.#t, r = this.options, n = this.#e, u = this.#a, a = this.#u, b = t !== s ? t.state : this.#p, { state: R } = t;
149
+ let i = { ...R }, l = !1, o;
150
150
  if (e._optimisticResults) {
151
- const c = this.hasListeners(), g = !c && A(t, e), S = c && H(t, s, e, r);
152
- (g || S) && (a = {
153
- ...a,
154
- ...G(h.data, t.options)
155
- }), e._optimisticResults === "isRestoring" && (a.fetchStatus = "idle");
151
+ const h = this.hasListeners(), g = !h && A(t, e), O = h && H(t, s, e, r);
152
+ (g || O) && (i = {
153
+ ...i,
154
+ ...G(R.data, t.options)
155
+ }), e._optimisticResults === "isRestoring" && (i.fetchStatus = "idle");
156
156
  }
157
- let { error: R, errorUpdatedAt: x, status: p } = a;
158
- o = a.data;
157
+ let { error: m, errorUpdatedAt: S, status: p } = i;
158
+ o = i.data;
159
159
  let D = !1;
160
160
  if (e.placeholderData !== void 0 && o === void 0 && p === "pending") {
161
- let c;
162
- i?.isPlaceholderData && e.placeholderData === n?.placeholderData ? (c = i.data, D = !0) : c = typeof e.placeholderData == "function" ? e.placeholderData(
161
+ let h;
162
+ n?.isPlaceholderData && e.placeholderData === a?.placeholderData ? (h = n.data, D = !0) : h = typeof e.placeholderData == "function" ? e.placeholderData(
163
163
  this.#d?.state.data,
164
164
  this.#d
165
- ) : e.placeholderData, c !== void 0 && (p = "success", o = B(
166
- i?.data,
167
- c,
165
+ ) : e.placeholderData, h !== void 0 && (p = "success", o = B(
166
+ n?.data,
167
+ h,
168
168
  e
169
- ), b = !0);
169
+ ), l = !0);
170
170
  }
171
171
  if (e.select && o !== void 0 && !D)
172
- if (i && o === l?.data && e.select === this.#m)
172
+ if (n && o === u?.data && e.select === this.#v)
173
173
  o = this.#l;
174
174
  else
175
175
  try {
176
- this.#m = e.select, o = e.select(o), o = B(i?.data, o, e), this.#l = o, this.#i = null;
177
- } catch (c) {
178
- this.#i = c;
176
+ this.#v = e.select, o = e.select(o), o = B(n?.data, o, e), this.#l = o, this.#i = null;
177
+ } catch (h) {
178
+ this.#i = h;
179
179
  }
180
- this.#i && (R = this.#i, o = this.#l, x = Date.now(), p = "error");
181
- const C = a.fetchStatus === "fetching", I = p === "pending", T = p === "error", U = I && C, k = o !== void 0, f = {
180
+ this.#i && (m = this.#i, o = this.#l, S = Date.now(), p = "error");
181
+ const I = i.fetchStatus === "fetching", T = p === "pending", M = p === "error", U = T && I, k = o !== void 0, f = {
182
182
  status: p,
183
- fetchStatus: a.fetchStatus,
184
- isPending: I,
183
+ fetchStatus: i.fetchStatus,
184
+ isPending: T,
185
185
  isSuccess: p === "success",
186
- isError: T,
186
+ isError: M,
187
187
  isInitialLoading: U,
188
188
  isLoading: U,
189
189
  data: o,
190
- dataUpdatedAt: a.dataUpdatedAt,
191
- error: R,
192
- errorUpdatedAt: x,
193
- failureCount: a.fetchFailureCount,
194
- failureReason: a.fetchFailureReason,
195
- errorUpdateCount: a.errorUpdateCount,
190
+ dataUpdatedAt: i.dataUpdatedAt,
191
+ error: m,
192
+ errorUpdatedAt: S,
193
+ failureCount: i.fetchFailureCount,
194
+ failureReason: i.fetchFailureReason,
195
+ errorUpdateCount: i.errorUpdateCount,
196
196
  isFetched: t.isFetched(),
197
- isFetchedAfterMount: a.dataUpdateCount > v.dataUpdateCount || a.errorUpdateCount > v.errorUpdateCount,
198
- isFetching: C,
199
- isRefetching: C && !I,
200
- isLoadingError: T && !k,
201
- isPaused: a.fetchStatus === "paused",
202
- isPlaceholderData: b,
203
- isRefetchError: T && k,
204
- isStale: P(t, e),
197
+ isFetchedAfterMount: i.dataUpdateCount > b.dataUpdateCount || i.errorUpdateCount > b.errorUpdateCount,
198
+ isFetching: I,
199
+ isRefetching: I && !T,
200
+ isLoadingError: M && !k,
201
+ isPaused: i.fetchStatus === "paused",
202
+ isPlaceholderData: l,
203
+ isRefetchError: M && k,
204
+ isStale: x(t, e),
205
205
  refetch: this.refetch,
206
206
  promise: this.#r,
207
- isEnabled: u(e.enabled, t) !== !1
207
+ isEnabled: c(e.enabled, t) !== !1
208
208
  };
209
209
  if (this.options.experimental_prefetchInRender) {
210
- const c = f.data !== void 0, g = f.status === "error" && !c, S = (E) => {
211
- g ? E.reject(f.error) : c && E.resolve(f.data);
210
+ const h = f.data !== void 0, g = f.status === "error" && !h, O = (w) => {
211
+ g ? w.reject(f.error) : h && w.resolve(f.data);
212
212
  }, N = () => {
213
- const E = this.#r = f.promise = L();
214
- S(E);
215
- }, O = this.#r;
216
- switch (O.status) {
213
+ const w = this.#r = f.promise = L();
214
+ O(w);
215
+ }, E = this.#r;
216
+ switch (E.status) {
217
217
  case "pending":
218
- t.queryHash === s.queryHash && S(O);
218
+ t.queryHash === s.queryHash && O(E);
219
219
  break;
220
220
  case "fulfilled":
221
- (g || f.data !== O.value) && N();
221
+ (g || f.data !== E.value) && N();
222
222
  break;
223
223
  case "rejected":
224
- (!g || f.error !== O.reason) && N();
224
+ (!g || f.error !== E.reason) && N();
225
225
  break;
226
226
  }
227
227
  }
@@ -229,21 +229,21 @@ var Y = class extends q {
229
229
  }
230
230
  updateResult() {
231
231
  const t = this.#e, e = this.createResult(this.#t, this.options);
232
- if (this.#a = this.#t.state, this.#u = this.options, this.#a.data !== void 0 && (this.#d = this.#t), M(e, t))
232
+ if (this.#a = this.#t.state, this.#u = this.options, this.#a.data !== void 0 && (this.#d = this.#t), Q(e, t))
233
233
  return;
234
234
  this.#e = e;
235
235
  const s = () => {
236
236
  if (!t)
237
237
  return !0;
238
- const { notifyOnChangeProps: r } = this.options, i = typeof r == "function" ? r() : r;
239
- if (i === "all" || !i && !this.#f.size)
238
+ const { notifyOnChangeProps: r } = this.options, n = typeof r == "function" ? r() : r;
239
+ if (n === "all" || !n && !this.#f.size)
240
240
  return !0;
241
- const l = new Set(
242
- i ?? this.#f
241
+ const u = new Set(
242
+ n ?? this.#f
243
243
  );
244
- return this.options.throwOnError && l.add("error"), Object.keys(this.#e).some((n) => {
245
- const d = n;
246
- return this.#e[d] !== t[d] && l.has(d);
244
+ return this.options.throwOnError && u.add("error"), Object.keys(this.#e).some((a) => {
245
+ const d = a;
246
+ return this.#e[d] !== t[d] && u.has(d);
247
247
  });
248
248
  };
249
249
  this.#E({ listeners: s() });
@@ -270,26 +270,26 @@ var Y = class extends q {
270
270
  }
271
271
  };
272
272
  function Z(t, e) {
273
- return u(e.enabled, t) !== !1 && t.state.data === void 0 && !(t.state.status === "error" && u(e.retryOnMount, t) === !1);
273
+ return c(e.enabled, t) !== !1 && t.state.data === void 0 && !(t.state.status === "error" && c(e.retryOnMount, t) === !1);
274
274
  }
275
275
  function A(t, e) {
276
- return Z(t, e) || t.state.data !== void 0 && F(t, e, e.refetchOnMount);
276
+ return Z(t, e) || t.state.data !== void 0 && P(t, e, e.refetchOnMount);
277
277
  }
278
- function F(t, e, s) {
279
- if (u(e.enabled, t) !== !1 && y(e.staleTime, t) !== "static") {
278
+ function P(t, e, s) {
279
+ if (c(e.enabled, t) !== !1 && y(e.staleTime, t) !== "static") {
280
280
  const r = typeof s == "function" ? s(t) : s;
281
- return r === "always" || r !== !1 && P(t, e);
281
+ return r === "always" || r !== !1 && x(t, e);
282
282
  }
283
283
  return !1;
284
284
  }
285
285
  function H(t, e, s, r) {
286
- return (t !== e || u(r.enabled, t) === !1) && (!s.suspense || t.state.status !== "error") && P(t, s);
286
+ return (t !== e || c(r.enabled, t) === !1) && (!s.suspense || t.state.status !== "error") && x(t, s);
287
287
  }
288
- function P(t, e) {
289
- return u(e.enabled, t) !== !1 && t.isStaleByTime(y(e.staleTime, t));
288
+ function x(t, e) {
289
+ return c(e.enabled, t) !== !1 && t.isStaleByTime(y(e.staleTime, t));
290
290
  }
291
291
  function tt(t, e) {
292
- return !M(t.getCurrentResult(), e);
292
+ return !Q(t.getCurrentResult(), e);
293
293
  }
294
294
  function et() {
295
295
  let t = !1;
@@ -303,11 +303,11 @@ function et() {
303
303
  isReset: () => t
304
304
  };
305
305
  }
306
- var st = m.createContext(et()), rt = () => m.useContext(st), it = (t, e, s) => {
306
+ var st = v.createContext(et()), rt = () => v.useContext(st), it = (t, e, s) => {
307
307
  const r = s?.state.error && typeof t.throwOnError == "function" ? z(t.throwOnError, [s.state.error, s]) : t.throwOnError;
308
308
  (t.suspense || t.experimental_prefetchInRender || r) && (e.isReset() || (t.retryOnMount = !1));
309
309
  }, nt = (t) => {
310
- m.useEffect(() => {
310
+ v.useEffect(() => {
311
311
  t.clearReset();
312
312
  }, [t]);
313
313
  }, at = ({
@@ -315,11 +315,11 @@ var st = m.createContext(et()), rt = () => m.useContext(st), it = (t, e, s) => {
315
315
  errorResetBoundary: e,
316
316
  throwOnError: s,
317
317
  query: r,
318
- suspense: i
319
- }) => t.isError && !e.isReset() && !t.isFetching && r && (i && t.data === void 0 || z(s, [t.error, r])), ot = (t) => {
318
+ suspense: n
319
+ }) => t.isError && !e.isReset() && !t.isFetching && r && (n && t.data === void 0 || z(s, [t.error, r])), ot = (t) => {
320
320
  if (t.suspense) {
321
- const s = (i) => i === "static" ? i : Math.max(i ?? 1e3, 1e3), r = t.staleTime;
322
- t.staleTime = typeof r == "function" ? (...i) => s(r(...i)) : s(r), typeof t.gcTime == "number" && (t.gcTime = Math.max(
321
+ const s = (n) => n === "static" ? n : Math.max(n ?? 1e3, 1e3), r = t.staleTime;
322
+ t.staleTime = typeof r == "function" ? (...n) => s(r(...n)) : s(r), typeof t.gcTime == "number" && (t.gcTime = Math.max(
323
323
  t.gcTime,
324
324
  1e3
325
325
  ));
@@ -332,54 +332,56 @@ function ut(t, e, s) {
332
332
  throw new Error(
333
333
  'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
334
334
  );
335
- const r = J(), i = rt(), l = X(s), n = l.defaultQueryOptions(t);
336
- l.getDefaultOptions().queries?._experimental_beforeQuery?.(
337
- n
335
+ const r = J(), n = rt(), u = X(s), a = u.defaultQueryOptions(t);
336
+ u.getDefaultOptions().queries?._experimental_beforeQuery?.(
337
+ a
338
338
  );
339
- const d = l.getQueryCache().get(n.queryHash);
340
- process.env.NODE_ENV !== "production" && (n.queryFn || console.error(
341
- `[${n.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
342
- )), n._optimisticResults = r ? "isRestoring" : "optimistic", ot(n), it(n, i, d), nt(i);
343
- const v = !l.getQueryCache().get(n.queryHash), [h] = m.useState(
339
+ const d = u.getQueryCache().get(a.queryHash);
340
+ process.env.NODE_ENV !== "production" && (a.queryFn || console.error(
341
+ `[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
342
+ ));
343
+ const b = t.subscribed !== !1;
344
+ a._optimisticResults = r ? "isRestoring" : b ? "optimistic" : void 0, ot(a), it(a, n, d), nt(n);
345
+ const R = !u.getQueryCache().get(a.queryHash), [i] = v.useState(
344
346
  () => new e(
345
- l,
346
- n
347
+ u,
348
+ a
347
349
  )
348
- ), a = h.getOptimisticResult(n), b = !r && t.subscribed !== !1;
349
- if (m.useSyncExternalStore(
350
- m.useCallback(
351
- (o) => {
352
- const R = b ? h.subscribe(W.batchCalls(o)) : Q;
353
- return h.updateResult(), R;
350
+ ), l = i.getOptimisticResult(a), o = !r && b;
351
+ if (v.useSyncExternalStore(
352
+ v.useCallback(
353
+ (m) => {
354
+ const S = o ? i.subscribe(W.batchCalls(m)) : _;
355
+ return i.updateResult(), S;
354
356
  },
355
- [h, b]
357
+ [i, o]
356
358
  ),
357
- () => h.getCurrentResult(),
358
- () => h.getCurrentResult()
359
- ), m.useEffect(() => {
360
- h.setOptions(n);
361
- }, [n, h]), ct(n, a))
362
- throw V(n, h, i);
359
+ () => i.getCurrentResult(),
360
+ () => i.getCurrentResult()
361
+ ), v.useEffect(() => {
362
+ i.setOptions(a);
363
+ }, [a, i]), ct(a, l))
364
+ throw V(a, i, n);
363
365
  if (at({
364
- result: a,
365
- errorResetBoundary: i,
366
- throwOnError: n.throwOnError,
366
+ result: l,
367
+ errorResetBoundary: n,
368
+ throwOnError: a.throwOnError,
367
369
  query: d,
368
- suspense: n.suspense
370
+ suspense: a.suspense
369
371
  }))
370
- throw a.error;
371
- return l.getDefaultOptions().queries?._experimental_afterQuery?.(
372
- n,
373
- a
374
- ), n.experimental_prefetchInRender && !_.isServer() && ht(a, r) && (v ? (
372
+ throw l.error;
373
+ return u.getDefaultOptions().queries?._experimental_afterQuery?.(
374
+ a,
375
+ l
376
+ ), a.experimental_prefetchInRender && !F.isServer() && ht(l, r) && (R ? (
375
377
  // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
376
- V(n, h, i)
378
+ V(a, i, n)
377
379
  ) : (
378
380
  // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
379
381
  d?.promise
380
- ))?.catch(Q).finally(() => {
381
- h.updateResult();
382
- }), n.notifyOnChangeProps ? a : h.trackResult(a);
382
+ ))?.catch(_).finally(() => {
383
+ i.updateResult();
384
+ }), a.notifyOnChangeProps ? l : i.trackResult(l);
383
385
  }
384
386
  function pt(t, e) {
385
387
  return ut(t, Y, e);
@@ -0,0 +1,43 @@
1
+ function c(e) {
2
+ return new Promise((n, t) => {
3
+ e.oncomplete = e.onsuccess = () => n(e.result), e.onabort = e.onerror = () => t(e.error);
4
+ });
5
+ }
6
+ function l(e, n) {
7
+ let t;
8
+ const o = () => {
9
+ if (t)
10
+ return t;
11
+ const r = indexedDB.open(e);
12
+ return r.onupgradeneeded = () => r.result.createObjectStore(n), t = c(r), t.then((u) => {
13
+ u.onclose = () => t = void 0;
14
+ }, () => {
15
+ }), t;
16
+ };
17
+ return (r, u) => o().then((s) => u(s.transaction(n, r).objectStore(n)));
18
+ }
19
+ let a;
20
+ function i() {
21
+ return a || (a = l("keyval-store", "keyval")), a;
22
+ }
23
+ function f(e, n = i()) {
24
+ return n("readonly", (t) => c(t.get(e)));
25
+ }
26
+ function d(e, n, t = i()) {
27
+ return t("readwrite", (o) => (o.put(n, e), c(o.transaction)));
28
+ }
29
+ function p(e, n = i()) {
30
+ return n("readwrite", (t) => (t.delete(e), c(t.transaction)));
31
+ }
32
+ const w = (e = "reactQuery") => ({
33
+ persistClient: async (n) => {
34
+ await d(e, n);
35
+ },
36
+ removeClient: async () => {
37
+ await p(e);
38
+ },
39
+ restoreClient: async () => await f(e)
40
+ });
41
+ export {
42
+ w as createIDBPersister
43
+ };
@@ -1,4 +1,4 @@
1
- import { f as t, a as i, h as n } from "../api-COabZnyn.js";
1
+ import { f as t, a as i, h as n } from "../api-CikhPcJj.js";
2
2
  import "../constants.js";
3
3
  import "../stores/BasePropsStore.js";
4
4
  export {
@@ -1,5 +1,5 @@
1
1
  import { useBasePropsStore as t } from "../stores/BasePropsStore.js";
2
- import { a as u, f } from "../api-COabZnyn.js";
2
+ import { a as u, f } from "../api-CikhPcJj.js";
3
3
  const k = (a, s, e, i, g, o = !1) => {
4
4
  const r = o ? void 0 : i ?? t.getState().modulePermissionToken, n = t.getState().organizationId, c = t.getState().currentLanguageId, l = t.getState().throwError;
5
5
  if (!o && !r)
package/README.md DELETED
@@ -1,9 +0,0 @@
1
- # ModuleBase
2
-
3
- The ModuleBase provides a set of components and functions, to get the modulefederation within HortiView to work.
4
- To get a more detailed description about the modulefederation-process in HortiView, please [visit the documentation](https://docs.hortiview.com/)
5
-
6
- It will handle the navigation/routing, breadcrumb translations, usage of Common- and ModuleAPI and my more.
7
-
8
- > This package is is not the ModuleTemplate.<br />
9
- > It only provides basic and necessary functions for the implementation of module federation within HortiView
@@ -1,21 +0,0 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { useEffect as h } from "react";
3
- import { R as p, a as i, O as c, u as m } from "../chunk-EVOBXE3Y-B43QN6RE.js";
4
- import { SignalRProvider as u } from "../provider/SignalR/SignalRProvider.js";
5
- import { useBasePropsStore as o } from "../stores/BasePropsStore.js";
6
- import { M as d, a as f } from "../ModuleCore-DRMqZO8r.js";
7
- const s = (t) => t.map((e) => e.children ? /* @__PURE__ */ a(i, { path: e.path, element: e.element, children: s(e.children) }, e.path) : /* @__PURE__ */ a(i, { path: e.path, element: e.element }, e.path)), v = () => {
8
- const t = o((r) => r.currentNavigationPath), e = o((r) => r.basePath), n = m();
9
- h(() => {
10
- t && e && t.startsWith(e) && n(t, { replace: !0 });
11
- }, [t, e, n]);
12
- }, g = () => (v(), /* @__PURE__ */ a(c, {})), B = ({
13
- props: t,
14
- routes: e,
15
- env: n = void 0,
16
- useSignalR: r = !1,
17
- queryClient: l = f
18
- }) => /* @__PURE__ */ a(d, { props: t, env: n, queryClient: l, children: /* @__PURE__ */ a(u, { enabled: r, children: /* @__PURE__ */ a(p, { children: /* @__PURE__ */ a(i, { path: t.basePath, element: /* @__PURE__ */ a(g, {}), children: s(e) }) }) }) });
19
- export {
20
- B as ModuleBase
21
- };