@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,10 +1,11 @@
1
- import { R as o, c as a, n as r } from "./QueryClientProvider-Beog9TR7.js";
2
- var d = class extends o {
1
+ import { R as r, c as u, n as h } from "./QueryClientProvider-DyiNrPkn.js";
2
+ var l = class extends r {
3
+ #o;
3
4
  #e;
4
5
  #t;
5
6
  #i;
6
7
  constructor(t) {
7
- super(), this.mutationId = t.mutationId, this.#t = t.mutationCache, this.#e = [], this.state = t.state || u(), this.setOptions(t.options), this.scheduleGc();
8
+ super(), this.#o = t.client, this.mutationId = t.mutationId, this.#t = t.mutationCache, this.#e = [], this.state = t.state || c(), this.setOptions(t.options), this.scheduleGc();
8
9
  }
9
10
  setOptions(t) {
10
11
  this.options = t, this.updateGcTime(this.options.gcTime);
@@ -20,7 +21,7 @@ var d = class extends o {
20
21
  }));
21
22
  }
22
23
  removeObserver(t) {
23
- this.#e = this.#e.filter((i) => i !== t), this.scheduleGc(), this.#t.notify({
24
+ this.#e = this.#e.filter((o) => o !== t), this.scheduleGc(), this.#t.notify({
24
25
  type: "observerRemoved",
25
26
  mutation: this,
26
27
  observer: t
@@ -34,102 +35,146 @@ var d = class extends o {
34
35
  this.execute(this.state.variables);
35
36
  }
36
37
  async execute(t) {
37
- this.#i = a({
38
- fn: () => this.options.mutationFn ? this.options.mutationFn(t) : Promise.reject(new Error("No mutationFn found")),
39
- onFail: (e, n) => {
40
- this.#s({ type: "failed", failureCount: e, error: n });
38
+ const o = () => {
39
+ this.#s({ type: "continue" });
40
+ }, e = {
41
+ client: this.#o,
42
+ meta: this.options.meta,
43
+ mutationKey: this.options.mutationKey
44
+ };
45
+ this.#i = u({
46
+ fn: () => this.options.mutationFn ? this.options.mutationFn(t, e) : Promise.reject(new Error("No mutationFn found")),
47
+ onFail: (s, i) => {
48
+ this.#s({ type: "failed", failureCount: s, error: i });
41
49
  },
42
50
  onPause: () => {
43
51
  this.#s({ type: "pause" });
44
52
  },
45
- onContinue: () => {
46
- this.#s({ type: "continue" });
47
- },
53
+ onContinue: o,
48
54
  retry: this.options.retry ?? 0,
49
55
  retryDelay: this.options.retryDelay,
50
56
  networkMode: this.options.networkMode,
51
57
  canRun: () => this.#t.canRun(this)
52
58
  });
53
- const i = this.state.status === "pending", s = !this.#i.canStart();
59
+ const a = this.state.status === "pending", n = !this.#i.canStart();
54
60
  try {
55
- if (!i) {
56
- this.#s({ type: "pending", variables: t, isPaused: s }), await this.#t.config.onMutate?.(
61
+ if (a)
62
+ o();
63
+ else {
64
+ this.#s({ type: "pending", variables: t, isPaused: n }), this.#t.config.onMutate && await this.#t.config.onMutate(
65
+ t,
66
+ this,
67
+ e
68
+ );
69
+ const i = await this.options.onMutate?.(
57
70
  t,
58
- this
71
+ e
59
72
  );
60
- const n = await this.options.onMutate?.(t);
61
- n !== this.state.context && this.#s({
73
+ i !== this.state.context && this.#s({
62
74
  type: "pending",
63
- context: n,
75
+ context: i,
64
76
  variables: t,
65
- isPaused: s
77
+ isPaused: n
66
78
  });
67
79
  }
68
- const e = await this.#i.start();
80
+ const s = await this.#i.start();
69
81
  return await this.#t.config.onSuccess?.(
70
- e,
82
+ s,
83
+ t,
84
+ this.state.context,
85
+ this,
86
+ e
87
+ ), await this.options.onSuccess?.(
88
+ s,
71
89
  t,
72
90
  this.state.context,
73
- this
74
- ), await this.options.onSuccess?.(e, t, this.state.context), await this.#t.config.onSettled?.(
75
- e,
91
+ e
92
+ ), await this.#t.config.onSettled?.(
93
+ s,
76
94
  null,
77
95
  this.state.variables,
78
96
  this.state.context,
79
- this
80
- ), await this.options.onSettled?.(e, null, t, this.state.context), this.#s({ type: "success", data: e }), e;
81
- } catch (e) {
97
+ this,
98
+ e
99
+ ), await this.options.onSettled?.(
100
+ s,
101
+ null,
102
+ t,
103
+ this.state.context,
104
+ e
105
+ ), this.#s({ type: "success", data: s }), s;
106
+ } catch (s) {
82
107
  try {
83
- throw await this.#t.config.onError?.(
84
- e,
108
+ await this.#t.config.onError?.(
109
+ s,
85
110
  t,
86
111
  this.state.context,
87
- this
88
- ), await this.options.onError?.(
89
- e,
112
+ this,
113
+ e
114
+ );
115
+ } catch (i) {
116
+ Promise.reject(i);
117
+ }
118
+ try {
119
+ await this.options.onError?.(
120
+ s,
90
121
  t,
91
- this.state.context
92
- ), await this.#t.config.onSettled?.(
122
+ this.state.context,
123
+ e
124
+ );
125
+ } catch (i) {
126
+ Promise.reject(i);
127
+ }
128
+ try {
129
+ await this.#t.config.onSettled?.(
93
130
  void 0,
94
- e,
131
+ s,
95
132
  this.state.variables,
96
133
  this.state.context,
97
- this
98
- ), await this.options.onSettled?.(
134
+ this,
135
+ e
136
+ );
137
+ } catch (i) {
138
+ Promise.reject(i);
139
+ }
140
+ try {
141
+ await this.options.onSettled?.(
99
142
  void 0,
100
- e,
143
+ s,
101
144
  t,
102
- this.state.context
103
- ), e;
104
- } finally {
105
- this.#s({ type: "error", error: e });
145
+ this.state.context,
146
+ e
147
+ );
148
+ } catch (i) {
149
+ Promise.reject(i);
106
150
  }
151
+ throw this.#s({ type: "error", error: s }), s;
107
152
  } finally {
108
153
  this.#t.runNext(this);
109
154
  }
110
155
  }
111
156
  #s(t) {
112
- const i = (s) => {
157
+ const o = (e) => {
113
158
  switch (t.type) {
114
159
  case "failed":
115
160
  return {
116
- ...s,
161
+ ...e,
117
162
  failureCount: t.failureCount,
118
163
  failureReason: t.error
119
164
  };
120
165
  case "pause":
121
166
  return {
122
- ...s,
167
+ ...e,
123
168
  isPaused: !0
124
169
  };
125
170
  case "continue":
126
171
  return {
127
- ...s,
172
+ ...e,
128
173
  isPaused: !1
129
174
  };
130
175
  case "pending":
131
176
  return {
132
- ...s,
177
+ ...e,
133
178
  context: t.context,
134
179
  data: void 0,
135
180
  failureCount: 0,
@@ -142,7 +187,7 @@ var d = class extends o {
142
187
  };
143
188
  case "success":
144
189
  return {
145
- ...s,
190
+ ...e,
146
191
  data: t.data,
147
192
  failureCount: 0,
148
193
  failureReason: null,
@@ -152,19 +197,19 @@ var d = class extends o {
152
197
  };
153
198
  case "error":
154
199
  return {
155
- ...s,
200
+ ...e,
156
201
  data: void 0,
157
202
  error: t.error,
158
- failureCount: s.failureCount + 1,
203
+ failureCount: e.failureCount + 1,
159
204
  failureReason: t.error,
160
205
  isPaused: !1,
161
206
  status: "error"
162
207
  };
163
208
  }
164
209
  };
165
- this.state = i(this.state), r.batch(() => {
166
- this.#e.forEach((s) => {
167
- s.onMutationUpdate(t);
210
+ this.state = o(this.state), h.batch(() => {
211
+ this.#e.forEach((e) => {
212
+ e.onMutationUpdate(t);
168
213
  }), this.#t.notify({
169
214
  mutation: this,
170
215
  type: "updated",
@@ -173,7 +218,7 @@ var d = class extends o {
173
218
  });
174
219
  }
175
220
  };
176
- function u() {
221
+ function c() {
177
222
  return {
178
223
  context: void 0,
179
224
  data: void 0,
@@ -187,6 +232,6 @@ function u() {
187
232
  };
188
233
  }
189
234
  export {
190
- d as M,
191
- u as g
235
+ l as M,
236
+ c as g
192
237
  };