@hortiview/modulebase 0.0.13101-beta → 0.0.13103-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.
@@ -1,15 +1,15 @@
1
- import { R as f, r as p, a as u, b as y, d as v, t as b, c as m, n as C, e as g, i as h, f as S } from "./QueryClientProvider-BSM1ol7r.js";
2
- import * as c from "react";
3
- var D = class extends f {
4
- #a;
1
+ import { R as y, r as v, a as d, d as b, e as m, f as C, t as F, c as g, n as S, i as h, g as q, j as A } from "./QueryClientProvider-C7EHlqBQ.js";
2
+ import * as l from "react";
3
+ var x = class extends y {
5
4
  #n;
5
+ #r;
6
6
  #e;
7
7
  #i;
8
8
  #t;
9
9
  #o;
10
- #r;
10
+ #a;
11
11
  constructor(t) {
12
- super(), this.#r = !1, this.#o = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#i = t.client, this.#e = this.#i.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#a = q(this.options), this.state = t.state ?? this.#a, this.scheduleGc();
12
+ super(), this.#a = !1, this.#o = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#i = t.client, this.#e = this.#i.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#n = R(this.options), this.state = t.state ?? this.#n, this.scheduleGc();
13
13
  }
14
14
  get meta() {
15
15
  return this.options.meta;
@@ -24,7 +24,7 @@ var D = class extends f {
24
24
  !this.observers.length && this.state.fetchStatus === "idle" && this.#e.remove(this);
25
25
  }
26
26
  setData(t, e) {
27
- const s = p(this.state.data, t, this.options);
27
+ const s = v(this.state.data, t, this.options);
28
28
  return this.#s({
29
29
  data: s,
30
30
  type: "success",
@@ -37,29 +37,34 @@ var D = class extends f {
37
37
  }
38
38
  cancel(t) {
39
39
  const e = this.#t?.promise;
40
- return this.#t?.cancel(t), e ? e.then(u).catch(u) : Promise.resolve();
40
+ return this.#t?.cancel(t), e ? e.then(d).catch(d) : Promise.resolve();
41
41
  }
42
42
  destroy() {
43
43
  super.destroy(), this.cancel({ silent: !0 });
44
44
  }
45
45
  reset() {
46
- this.destroy(), this.setState(this.#a);
46
+ this.destroy(), this.setState(this.#n);
47
47
  }
48
48
  isActive() {
49
49
  return this.observers.some(
50
- (t) => y(t.options.enabled, this) !== !1
50
+ (t) => b(t.options.enabled, this) !== !1
51
51
  );
52
52
  }
53
53
  isDisabled() {
54
- return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === v || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
54
+ return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === m || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
55
+ }
56
+ isStatic() {
57
+ return this.getObserversCount() > 0 ? this.observers.some(
58
+ (t) => C(t.options.staleTime, this) === "static"
59
+ ) : !1;
55
60
  }
56
61
  isStale() {
57
- return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
62
+ return this.getObserversCount() > 0 ? this.observers.some(
58
63
  (t) => t.getCurrentResult().isStale
59
- ) : this.state.data === void 0;
64
+ ) : this.state.data === void 0 || this.state.isInvalidated;
60
65
  }
61
66
  isStaleByTime(t = 0) {
62
- return this.state.isInvalidated || this.state.data === void 0 || !b(this.state.dataUpdatedAt, t);
67
+ return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !F(this.state.dataUpdatedAt, t);
63
68
  }
64
69
  onFocus() {
65
70
  this.observers.find((e) => e.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
@@ -71,7 +76,7 @@ var D = class extends f {
71
76
  this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), this.#e.notify({ type: "observerAdded", query: this, observer: t }));
72
77
  }
73
78
  removeObserver(t) {
74
- this.observers.includes(t) && (this.observers = this.observers.filter((e) => e !== t), this.observers.length || (this.#t && (this.#r ? this.#t.cancel({ revert: !0 }) : this.#t.cancelRetry()), this.scheduleGc()), this.#e.notify({ type: "observerRemoved", query: this, observer: t }));
79
+ 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 }));
75
80
  }
76
81
  getObserversCount() {
77
82
  return this.observers.length;
@@ -87,79 +92,82 @@ var D = class extends f {
87
92
  return this.#t.continueRetry(), this.#t.promise;
88
93
  }
89
94
  if (t && this.setOptions(t), !this.options.queryFn) {
90
- const i = this.observers.find((a) => a.options.queryFn);
91
- i && this.setOptions(i.options);
95
+ const r = this.observers.find((n) => n.options.queryFn);
96
+ r && this.setOptions(r.options);
92
97
  }
93
98
  process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
94
99
  "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']"
95
100
  ));
96
- const s = new AbortController(), r = (i) => {
97
- Object.defineProperty(i, "signal", {
101
+ const s = new AbortController(), i = (r) => {
102
+ Object.defineProperty(r, "signal", {
98
103
  enumerable: !0,
99
- get: () => (this.#r = !0, s.signal)
104
+ get: () => (this.#a = !0, s.signal)
100
105
  });
101
- }, l = () => {
102
- const i = g(this.options, e), a = {
103
- client: this.#i,
106
+ }, p = () => {
107
+ const r = A(this.options, e), u = (() => {
108
+ const c = {
109
+ client: this.#i,
110
+ queryKey: this.queryKey,
111
+ meta: this.meta
112
+ };
113
+ return i(c), c;
114
+ })();
115
+ return this.#a = !1, this.options.persister ? this.options.persister(
116
+ r,
117
+ u,
118
+ this
119
+ ) : r(u);
120
+ }, a = (() => {
121
+ const r = {
122
+ fetchOptions: e,
123
+ options: this.options,
104
124
  queryKey: this.queryKey,
105
- meta: this.meta
125
+ client: this.#i,
126
+ state: this.state,
127
+ fetchFn: p
106
128
  };
107
- return r(a), this.#r = !1, this.options.persister ? this.options.persister(
108
- i,
109
- a,
110
- this
111
- ) : i(a);
112
- }, n = {
113
- fetchOptions: e,
114
- options: this.options,
115
- queryKey: this.queryKey,
116
- client: this.#i,
117
- state: this.state,
118
- fetchFn: l
119
- };
120
- r(n), this.options.behavior?.onFetch(
121
- n,
122
- this
123
- ), this.#n = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== n.fetchOptions?.meta) && this.#s({ type: "fetch", meta: n.fetchOptions?.meta });
124
- const o = (i) => {
125
- h(i) && i.silent || this.#s({
129
+ return i(r), r;
130
+ })();
131
+ this.options.behavior?.onFetch(a, this), this.#r = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== a.fetchOptions?.meta) && this.#s({ type: "fetch", meta: a.fetchOptions?.meta });
132
+ const o = (r) => {
133
+ h(r) && r.silent || this.#s({
126
134
  type: "error",
127
- error: i
128
- }), h(i) || (this.#e.config.onError?.(
129
- i,
135
+ error: r
136
+ }), h(r) || (this.#e.config.onError?.(
137
+ r,
130
138
  this
131
139
  ), this.#e.config.onSettled?.(
132
140
  this.state.data,
133
- i,
141
+ r,
134
142
  this
135
143
  )), this.scheduleGc();
136
144
  };
137
- return this.#t = m({
145
+ return this.#t = g({
138
146
  initialPromise: e?.initialPromise,
139
- fn: n.fetchFn,
147
+ fn: a.fetchFn,
140
148
  abort: s.abort.bind(s),
141
- onSuccess: (i) => {
142
- if (i === void 0) {
149
+ onSuccess: (r) => {
150
+ if (r === void 0) {
143
151
  process.env.NODE_ENV !== "production" && console.error(
144
152
  `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
145
153
  ), o(new Error(`${this.queryHash} data is undefined`));
146
154
  return;
147
155
  }
148
156
  try {
149
- this.setData(i);
150
- } catch (a) {
151
- o(a);
157
+ this.setData(r);
158
+ } catch (n) {
159
+ o(n);
152
160
  return;
153
161
  }
154
- this.#e.config.onSuccess?.(i, this), this.#e.config.onSettled?.(
155
- i,
162
+ this.#e.config.onSuccess?.(r, this), this.#e.config.onSettled?.(
163
+ r,
156
164
  this.state.error,
157
165
  this
158
166
  ), this.scheduleGc();
159
167
  },
160
168
  onError: o,
161
- onFail: (i, a) => {
162
- this.#s({ type: "failed", failureCount: i, error: a });
169
+ onFail: (r, n) => {
170
+ this.#s({ type: "failed", failureCount: r, error: n });
163
171
  },
164
172
  onPause: () => {
165
173
  this.#s({ type: "pause" });
@@ -167,9 +175,9 @@ var D = class extends f {
167
175
  onContinue: () => {
168
176
  this.#s({ type: "continue" });
169
177
  },
170
- retry: n.options.retry,
171
- retryDelay: n.options.retryDelay,
172
- networkMode: n.options.networkMode,
178
+ retry: a.options.retry,
179
+ retryDelay: a.options.retryDelay,
180
+ networkMode: a.options.networkMode,
173
181
  canRun: () => !0
174
182
  }), this.#t.start();
175
183
  }
@@ -195,11 +203,11 @@ var D = class extends f {
195
203
  case "fetch":
196
204
  return {
197
205
  ...s,
198
- ...F(s.data, this.options),
206
+ ...D(s.data, this.options),
199
207
  fetchMeta: t.meta ?? null
200
208
  };
201
209
  case "success":
202
- return {
210
+ return this.#r = void 0, {
203
211
  ...s,
204
212
  data: t.data,
205
213
  dataUpdateCount: s.dataUpdateCount + 1,
@@ -214,14 +222,14 @@ var D = class extends f {
214
222
  }
215
223
  };
216
224
  case "error":
217
- const r = t.error;
218
- return h(r) && r.revert && this.#n ? { ...this.#n, fetchStatus: "idle" } : {
225
+ const i = t.error;
226
+ return h(i) && i.revert && this.#r ? { ...this.#r, fetchStatus: "idle" } : {
219
227
  ...s,
220
- error: r,
228
+ error: i,
221
229
  errorUpdateCount: s.errorUpdateCount + 1,
222
230
  errorUpdatedAt: Date.now(),
223
231
  fetchFailureCount: s.fetchFailureCount + 1,
224
- fetchFailureReason: r,
232
+ fetchFailureReason: i,
225
233
  fetchStatus: "idle",
226
234
  status: "error"
227
235
  };
@@ -237,30 +245,30 @@ var D = class extends f {
237
245
  };
238
246
  }
239
247
  };
240
- this.state = e(this.state), C.batch(() => {
248
+ this.state = e(this.state), S.batch(() => {
241
249
  this.observers.forEach((s) => {
242
250
  s.onQueryUpdate();
243
251
  }), this.#e.notify({ query: this, type: "updated", action: t });
244
252
  });
245
253
  }
246
254
  };
247
- function F(t, e) {
255
+ function D(t, e) {
248
256
  return {
249
257
  fetchFailureCount: 0,
250
258
  fetchFailureReason: null,
251
- fetchStatus: S(e.networkMode) ? "fetching" : "paused",
259
+ fetchStatus: q(e.networkMode) ? "fetching" : "paused",
252
260
  ...t === void 0 && {
253
261
  error: null,
254
262
  status: "pending"
255
263
  }
256
264
  };
257
265
  }
258
- function q(t) {
259
- const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = e !== void 0, r = s ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
266
+ function R(t) {
267
+ const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = e !== void 0, i = s ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
260
268
  return {
261
269
  data: e,
262
270
  dataUpdateCount: 0,
263
- dataUpdatedAt: s ? r ?? Date.now() : 0,
271
+ dataUpdatedAt: s ? i ?? Date.now() : 0,
264
272
  error: null,
265
273
  errorUpdateCount: 0,
266
274
  errorUpdatedAt: 0,
@@ -272,10 +280,10 @@ function q(t) {
272
280
  fetchStatus: "idle"
273
281
  };
274
282
  }
275
- var d = c.createContext(!1), R = () => c.useContext(d), U = d.Provider;
283
+ var f = l.createContext(!1), I = () => l.useContext(f), w = f.Provider;
276
284
  export {
277
- U as I,
278
- D as Q,
279
- F as f,
280
- R as u
285
+ w as I,
286
+ x as Q,
287
+ D as f,
288
+ I as u
281
289
  };