@hortiview/modulebase 0.0.13101-beta → 0.0.13102-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,11 +1,10 @@
1
- import { S as B, p as U, b as f, s as w, g as O, a as H, j as Q, k, t as N, l as V, r as M, n as A, u as z } from "./QueryClientProvider-BSM1ol7r.js";
2
- import { f as W, u as $ } from "./isRestoring-LSIsLTaI.js";
1
+ import { S as H, p as M, d as f, s as E, f as R, a as Q, k as T, l as _, t as N, m as V, r as L, n as q, b as z, u as W } from "./QueryClientProvider-C7EHlqBQ.js";
2
+ import { f as K, u as $ } from "./IsRestoringProvider-B1U_sG8s.js";
3
3
  import * as y from "react";
4
4
  import "react/jsx-runtime";
5
- import { s as K, n as _ } from "./utils-DxRR_XLb.js";
6
- var G = class extends B {
5
+ var G = class extends H {
7
6
  constructor(e, t) {
8
- super(), this.options = t, this.#s = e, this.#r = null, this.#i = U(), this.options.experimental_prefetchInRender || this.#i.reject(
7
+ super(), this.options = t, this.#s = e, this.#i = null, this.#r = M(), this.options.experimental_prefetchInRender || this.#r.reject(
9
8
  new Error("experimental_prefetchInRender feature flag is not enabled")
10
9
  ), this.bindMethods(), this.setOptions(t);
11
10
  }
@@ -15,8 +14,8 @@ var G = class extends B {
15
14
  #t = void 0;
16
15
  #a;
17
16
  #c;
18
- #i;
19
17
  #r;
18
+ #i;
20
19
  #y;
21
20
  #l;
22
21
  // This property keeps track of the last query with defined data.
@@ -36,14 +35,14 @@ var G = class extends B {
36
35
  this.hasListeners() || this.destroy();
37
36
  }
38
37
  shouldFetchOnReconnect() {
39
- return T(
38
+ return I(
40
39
  this.#e,
41
40
  this.options,
42
41
  this.options.refetchOnReconnect
43
42
  );
44
43
  }
45
44
  shouldFetchOnWindowFocus() {
46
- return T(
45
+ return I(
47
46
  this.#e,
48
47
  this.options,
49
48
  this.options.refetchOnWindowFocus
@@ -58,20 +57,20 @@ var G = class extends B {
58
57
  throw new Error(
59
58
  "Expected enabled to be a boolean or a callback that returns a boolean"
60
59
  );
61
- this.#C(), this.#e.setOptions(this.options), t._defaulted && !w(this.options, t) && this.#s.getQueryCache().notify({
60
+ this.#C(), this.#e.setOptions(this.options), t._defaulted && !E(this.options, t) && this.#s.getQueryCache().notify({
62
61
  type: "observerOptionsUpdated",
63
62
  query: this.#e,
64
63
  observer: this
65
64
  });
66
65
  const r = this.hasListeners();
67
- r && L(
66
+ r && A(
68
67
  this.#e,
69
68
  s,
70
69
  this.options,
71
70
  t
72
- ) && this.#u(), this.updateResult(), r && (this.#e !== s || f(this.options.enabled, this.#e) !== f(t.enabled, this.#e) || O(this.options.staleTime, this.#e) !== O(t.staleTime, this.#e)) && this.#b();
73
- const a = this.#m();
74
- r && (this.#e !== s || f(this.options.enabled, this.#e) !== f(t.enabled, this.#e) || a !== this.#n) && this.#g(a);
71
+ ) && this.#u(), this.updateResult(), r && (this.#e !== s || f(this.options.enabled, this.#e) !== f(t.enabled, this.#e) || R(this.options.staleTime, this.#e) !== R(t.staleTime, this.#e)) && this.#m();
72
+ const n = this.#b();
73
+ r && (this.#e !== s || f(this.options.enabled, this.#e) !== f(t.enabled, this.#e) || n !== this.#n) && this.#g(n);
75
74
  }
76
75
  getOptimisticResult(e) {
77
76
  const t = this.#s.getQueryCache().build(this.#s, e), s = this.createResult(t, e);
@@ -81,14 +80,9 @@ var G = class extends B {
81
80
  return this.#t;
82
81
  }
83
82
  trackResult(e, t) {
84
- const s = {};
85
- return Object.keys(e).forEach((r) => {
86
- Object.defineProperty(s, r, {
87
- configurable: !1,
88
- enumerable: !0,
89
- get: () => (this.trackProp(r), t?.(r), e[r])
90
- });
91
- }), s;
83
+ return new Proxy(e, {
84
+ get: (s, r) => (this.trackProp(r), t?.(r), Reflect.get(s, r))
85
+ });
92
86
  }
93
87
  trackProp(e) {
94
88
  this.#f.add(e);
@@ -117,31 +111,31 @@ var G = class extends B {
117
111
  this.options,
118
112
  e
119
113
  );
120
- return e?.throwOnError || (t = t.catch(H)), t;
114
+ return e?.throwOnError || (t = t.catch(Q)), t;
121
115
  }
122
- #b() {
116
+ #m() {
123
117
  this.#v();
124
- const e = O(
118
+ const e = R(
125
119
  this.options.staleTime,
126
120
  this.#e
127
121
  );
128
- if (Q || this.#t.isStale || !k(e))
122
+ if (T || this.#t.isStale || !_(e))
129
123
  return;
130
124
  const s = N(this.#t.dataUpdatedAt, e) + 1;
131
125
  this.#o = setTimeout(() => {
132
126
  this.#t.isStale || this.updateResult();
133
127
  }, s);
134
128
  }
135
- #m() {
129
+ #b() {
136
130
  return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#e) : this.options.refetchInterval) ?? !1;
137
131
  }
138
132
  #g(e) {
139
- this.#O(), this.#n = e, !(Q || f(this.options.enabled, this.#e) === !1 || !k(this.#n) || this.#n === 0) && (this.#h = setInterval(() => {
133
+ this.#O(), this.#n = e, !(T || f(this.options.enabled, this.#e) === !1 || !_(this.#n) || this.#n === 0) && (this.#h = setInterval(() => {
140
134
  (this.options.refetchIntervalInBackground || V.isFocused()) && this.#u();
141
135
  }, this.#n));
142
136
  }
143
137
  #R() {
144
- this.#b(), this.#g(this.#m());
138
+ this.#m(), this.#g(this.#b());
145
139
  }
146
140
  #v() {
147
141
  this.#o && (clearTimeout(this.#o), this.#o = void 0);
@@ -150,90 +144,82 @@ var G = class extends B {
150
144
  this.#h && (clearInterval(this.#h), this.#h = void 0);
151
145
  }
152
146
  createResult(e, t) {
153
- const s = this.#e, r = this.options, a = this.#t, c = this.#a, i = this.#c, o = e !== s ? e.state : this.#p, { state: l } = e;
154
- let n = { ...l }, R = !1, u;
147
+ const s = this.#e, r = this.options, n = this.#t, u = this.#a, i = this.#c, o = e !== s ? e.state : this.#p, { state: l } = e;
148
+ let a = { ...l }, g = !1, h;
155
149
  if (t._optimisticResults) {
156
- const h = this.hasListeners(), m = !h && j(e, t), g = h && L(e, s, t, r);
157
- (m || g) && (n = {
158
- ...n,
159
- ...W(l.data, e.options)
160
- }), t._optimisticResults === "isRestoring" && (n.fetchStatus = "idle");
150
+ const c = this.hasListeners(), v = !c && j(e, t), b = c && A(e, s, t, r);
151
+ (v || b) && (a = {
152
+ ...a,
153
+ ...K(l.data, e.options)
154
+ }), t._optimisticResults === "isRestoring" && (a.fetchStatus = "idle");
161
155
  }
162
- let { error: F, errorUpdatedAt: x, status: p } = n;
163
- if (t.select && n.data !== void 0)
164
- if (a && n.data === c?.data && t.select === this.#y)
165
- u = this.#l;
166
- else
167
- try {
168
- this.#y = t.select, u = t.select(n.data), u = M(a?.data, u, t), this.#l = u, this.#r = null;
169
- } catch (h) {
170
- this.#r = h;
171
- }
172
- else
173
- u = n.data;
174
- if (t.placeholderData !== void 0 && u === void 0 && p === "pending") {
175
- let h;
176
- if (a?.isPlaceholderData && t.placeholderData === i?.placeholderData)
177
- h = a.data;
178
- else if (h = typeof t.placeholderData == "function" ? t.placeholderData(
156
+ let { error: x, errorUpdatedAt: D, status: p } = a;
157
+ h = a.data;
158
+ let P = !1;
159
+ if (t.placeholderData !== void 0 && h === void 0 && p === "pending") {
160
+ let c;
161
+ n?.isPlaceholderData && t.placeholderData === i?.placeholderData ? (c = n.data, P = !0) : c = typeof t.placeholderData == "function" ? t.placeholderData(
179
162
  this.#d?.state.data,
180
163
  this.#d
181
- ) : t.placeholderData, t.select && h !== void 0)
182
- try {
183
- h = t.select(h), this.#r = null;
184
- } catch (m) {
185
- this.#r = m;
186
- }
187
- h !== void 0 && (p = "success", u = M(
188
- a?.data,
189
- h,
164
+ ) : t.placeholderData, c !== void 0 && (p = "success", h = L(
165
+ n?.data,
166
+ c,
190
167
  t
191
- ), R = !0);
168
+ ), g = !0);
192
169
  }
193
- this.#r && (F = this.#r, u = this.#l, x = Date.now(), p = "error");
194
- const C = n.fetchStatus === "fetching", S = p === "pending", E = p === "error", D = S && C, P = u !== void 0, d = {
170
+ if (t.select && h !== void 0 && !P)
171
+ if (n && h === u?.data && t.select === this.#y)
172
+ h = this.#l;
173
+ else
174
+ try {
175
+ this.#y = t.select, h = t.select(h), h = L(n?.data, h, t), this.#l = h, this.#i = null;
176
+ } catch (c) {
177
+ this.#i = c;
178
+ }
179
+ this.#i && (x = this.#i, h = this.#l, D = Date.now(), p = "error");
180
+ const C = a.fetchStatus === "fetching", S = p === "pending", w = p === "error", U = S && C, k = h !== void 0, d = {
195
181
  status: p,
196
- fetchStatus: n.fetchStatus,
182
+ fetchStatus: a.fetchStatus,
197
183
  isPending: S,
198
184
  isSuccess: p === "success",
199
- isError: E,
200
- isInitialLoading: D,
201
- isLoading: D,
202
- data: u,
203
- dataUpdatedAt: n.dataUpdatedAt,
204
- error: F,
205
- errorUpdatedAt: x,
206
- failureCount: n.fetchFailureCount,
207
- failureReason: n.fetchFailureReason,
208
- errorUpdateCount: n.errorUpdateCount,
209
- isFetched: n.dataUpdateCount > 0 || n.errorUpdateCount > 0,
210
- isFetchedAfterMount: n.dataUpdateCount > o.dataUpdateCount || n.errorUpdateCount > o.errorUpdateCount,
185
+ isError: w,
186
+ isInitialLoading: U,
187
+ isLoading: U,
188
+ data: h,
189
+ dataUpdatedAt: a.dataUpdatedAt,
190
+ error: x,
191
+ errorUpdatedAt: D,
192
+ failureCount: a.fetchFailureCount,
193
+ failureReason: a.fetchFailureReason,
194
+ errorUpdateCount: a.errorUpdateCount,
195
+ isFetched: a.dataUpdateCount > 0 || a.errorUpdateCount > 0,
196
+ isFetchedAfterMount: a.dataUpdateCount > o.dataUpdateCount || a.errorUpdateCount > o.errorUpdateCount,
211
197
  isFetching: C,
212
198
  isRefetching: C && !S,
213
- isLoadingError: E && !P,
214
- isPaused: n.fetchStatus === "paused",
215
- isPlaceholderData: R,
216
- isRefetchError: E && P,
217
- isStale: I(e, t),
199
+ isLoadingError: w && !k,
200
+ isPaused: a.fetchStatus === "paused",
201
+ isPlaceholderData: g,
202
+ isRefetchError: w && k,
203
+ isStale: F(e, t),
218
204
  refetch: this.refetch,
219
- promise: this.#i
205
+ promise: this.#r
220
206
  };
221
207
  if (this.options.experimental_prefetchInRender) {
222
- const h = (v) => {
223
- d.status === "error" ? v.reject(d.error) : d.data !== void 0 && v.resolve(d.data);
224
- }, m = () => {
225
- const v = this.#i = d.promise = U();
226
- h(v);
227
- }, g = this.#i;
228
- switch (g.status) {
208
+ const c = (O) => {
209
+ d.status === "error" ? O.reject(d.error) : d.data !== void 0 && O.resolve(d.data);
210
+ }, v = () => {
211
+ const O = this.#r = d.promise = M();
212
+ c(O);
213
+ }, b = this.#r;
214
+ switch (b.status) {
229
215
  case "pending":
230
- e.queryHash === s.queryHash && h(g);
216
+ e.queryHash === s.queryHash && c(b);
231
217
  break;
232
218
  case "fulfilled":
233
- (d.status === "error" || d.data !== g.value) && m();
219
+ (d.status === "error" || d.data !== b.value) && v();
234
220
  break;
235
221
  case "rejected":
236
- (d.status !== "error" || d.error !== g.reason) && m();
222
+ (d.status !== "error" || d.error !== b.reason) && v();
237
223
  break;
238
224
  }
239
225
  }
@@ -241,21 +227,21 @@ var G = class extends B {
241
227
  }
242
228
  updateResult() {
243
229
  const e = this.#t, t = this.createResult(this.#e, this.options);
244
- if (this.#a = this.#e.state, this.#c = this.options, this.#a.data !== void 0 && (this.#d = this.#e), w(t, e))
230
+ if (this.#a = this.#e.state, this.#c = this.options, this.#a.data !== void 0 && (this.#d = this.#e), E(t, e))
245
231
  return;
246
232
  this.#t = t;
247
233
  const s = () => {
248
234
  if (!e)
249
235
  return !0;
250
- const { notifyOnChangeProps: r } = this.options, a = typeof r == "function" ? r() : r;
251
- if (a === "all" || !a && !this.#f.size)
236
+ const { notifyOnChangeProps: r } = this.options, n = typeof r == "function" ? r() : r;
237
+ if (n === "all" || !n && !this.#f.size)
252
238
  return !0;
253
- const c = new Set(
254
- a ?? this.#f
239
+ const u = new Set(
240
+ n ?? this.#f
255
241
  );
256
- return this.options.throwOnError && c.add("error"), Object.keys(this.#t).some((i) => {
257
- const b = i;
258
- return this.#t[b] !== e[b] && c.has(b);
242
+ return this.options.throwOnError && u.add("error"), Object.keys(this.#t).some((i) => {
243
+ const m = i;
244
+ return this.#t[m] !== e[m] && u.has(m);
259
245
  });
260
246
  };
261
247
  this.#S({ listeners: s() });
@@ -271,7 +257,7 @@ var G = class extends B {
271
257
  this.updateResult(), this.hasListeners() && this.#R();
272
258
  }
273
259
  #S(e) {
274
- A.batch(() => {
260
+ q.batch(() => {
275
261
  e.listeners && this.listeners.forEach((t) => {
276
262
  t(this.#t);
277
263
  }), this.#s.getQueryCache().notify({
@@ -285,23 +271,23 @@ function J(e, t) {
285
271
  return f(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
286
272
  }
287
273
  function j(e, t) {
288
- return J(e, t) || e.state.data !== void 0 && T(e, t, t.refetchOnMount);
274
+ return J(e, t) || e.state.data !== void 0 && I(e, t, t.refetchOnMount);
289
275
  }
290
- function T(e, t, s) {
291
- if (f(t.enabled, e) !== !1) {
276
+ function I(e, t, s) {
277
+ if (f(t.enabled, e) !== !1 && R(t.staleTime, e) !== "static") {
292
278
  const r = typeof s == "function" ? s(e) : s;
293
- return r === "always" || r !== !1 && I(e, t);
279
+ return r === "always" || r !== !1 && F(e, t);
294
280
  }
295
281
  return !1;
296
282
  }
297
- function L(e, t, s, r) {
298
- return (e !== t || f(r.enabled, e) === !1) && (!s.suspense || e.state.status !== "error") && I(e, s);
283
+ function A(e, t, s, r) {
284
+ return (e !== t || f(r.enabled, e) === !1) && (!s.suspense || e.state.status !== "error") && F(e, s);
299
285
  }
300
- function I(e, t) {
301
- return f(t.enabled, e) !== !1 && e.isStaleByTime(O(t.staleTime, e));
286
+ function F(e, t) {
287
+ return f(t.enabled, e) !== !1 && e.isStaleByTime(R(t.staleTime, e));
302
288
  }
303
289
  function X(e, t) {
304
- return !w(e.getCurrentResult(), t);
290
+ return !E(e.getCurrentResult(), t);
305
291
  }
306
292
  function Y() {
307
293
  let e = !1;
@@ -326,11 +312,13 @@ var Z = y.createContext(Y()), ee = () => y.useContext(Z), te = (e, t) => {
326
312
  errorResetBoundary: t,
327
313
  throwOnError: s,
328
314
  query: r,
329
- suspense: a
330
- }) => e.isError && !t.isReset() && !e.isFetching && r && (a && e.data === void 0 || K(s, [e.error, r])), ie = (e) => {
331
- const t = e.staleTime;
332
- e.suspense && (e.staleTime = typeof t == "function" ? (...s) => Math.max(t(...s), 1e3) : Math.max(t ?? 1e3, 1e3), typeof e.gcTime == "number" && (e.gcTime = Math.max(e.gcTime, 1e3)));
333
- }, ne = (e, t) => e.isLoading && e.isFetching && !t, ae = (e, t) => e?.suspense && t.isPending, q = (e, t, s) => t.fetchOptimistic(e).catch(() => {
315
+ suspense: n
316
+ }) => e.isError && !t.isReset() && !e.isFetching && r && (n && e.data === void 0 || z(s, [e.error, r])), ie = (e) => {
317
+ if (e.suspense) {
318
+ const t = (r) => r === "static" ? r : Math.max(r ?? 1e3, 1e3), s = e.staleTime;
319
+ e.staleTime = typeof s == "function" ? (...r) => t(s(...r)) : t(s), typeof e.gcTime == "number" && (e.gcTime = Math.max(e.gcTime, 1e3));
320
+ }
321
+ }, ne = (e, t) => e.isLoading && e.isFetching && !t, ae = (e, t) => e?.suspense && t.isPending, B = (e, t, s) => t.fetchOptimistic(e).catch(() => {
334
322
  s.clearReset();
335
323
  });
336
324
  function oe(e, t, s) {
@@ -338,58 +326,58 @@ function oe(e, t, s) {
338
326
  throw new Error(
339
327
  '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'
340
328
  );
341
- const r = z(s), a = $(), c = ee(), i = r.defaultQueryOptions(e);
342
- r.getDefaultOptions().queries?._experimental_beforeQuery?.(
329
+ const r = $(), n = ee(), u = W(s), i = u.defaultQueryOptions(e);
330
+ u.getDefaultOptions().queries?._experimental_beforeQuery?.(
343
331
  i
344
332
  ), process.env.NODE_ENV !== "production" && (i.queryFn || console.error(
345
333
  `[${i.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`
346
- )), i._optimisticResults = a ? "isRestoring" : "optimistic", ie(i), te(i, c), se(c);
347
- const b = !r.getQueryCache().get(i.queryHash), [o] = y.useState(
334
+ )), i._optimisticResults = r ? "isRestoring" : "optimistic", ie(i), te(i, n), se(n);
335
+ const m = !u.getQueryCache().get(i.queryHash), [o] = y.useState(
348
336
  () => new t(
349
- r,
337
+ u,
350
338
  i
351
339
  )
352
- ), l = o.getOptimisticResult(i), n = !a && e.subscribed !== !1;
340
+ ), l = o.getOptimisticResult(i), a = !r && e.subscribed !== !1;
353
341
  if (y.useSyncExternalStore(
354
342
  y.useCallback(
355
- (R) => {
356
- const u = n ? o.subscribe(A.batchCalls(R)) : _;
357
- return o.updateResult(), u;
343
+ (g) => {
344
+ const h = a ? o.subscribe(q.batchCalls(g)) : Q;
345
+ return o.updateResult(), h;
358
346
  },
359
- [o, n]
347
+ [o, a]
360
348
  ),
361
349
  () => o.getCurrentResult(),
362
350
  () => o.getCurrentResult()
363
351
  ), y.useEffect(() => {
364
352
  o.setOptions(i);
365
353
  }, [i, o]), ae(i, l))
366
- throw q(i, o, c);
354
+ throw B(i, o, n);
367
355
  if (re({
368
356
  result: l,
369
- errorResetBoundary: c,
357
+ errorResetBoundary: n,
370
358
  throwOnError: i.throwOnError,
371
- query: r.getQueryCache().get(i.queryHash),
359
+ query: u.getQueryCache().get(i.queryHash),
372
360
  suspense: i.suspense
373
361
  }))
374
362
  throw l.error;
375
- return r.getDefaultOptions().queries?._experimental_afterQuery?.(
363
+ return u.getDefaultOptions().queries?._experimental_afterQuery?.(
376
364
  i,
377
365
  l
378
- ), i.experimental_prefetchInRender && !Q && ne(l, a) && (b ? (
366
+ ), i.experimental_prefetchInRender && !T && ne(l, r) && (m ? (
379
367
  // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
380
- q(i, o, c)
368
+ B(i, o, n)
381
369
  ) : (
382
370
  // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
383
- r.getQueryCache().get(i.queryHash)?.promise
384
- ))?.catch(_).finally(() => {
371
+ u.getQueryCache().get(i.queryHash)?.promise
372
+ ))?.catch(Q).finally(() => {
385
373
  o.updateResult();
386
374
  }), i.notifyOnChangeProps ? l : o.trackResult(l);
387
375
  }
388
- function fe(e, t) {
376
+ function de(e, t) {
389
377
  return oe(e, G, t);
390
378
  }
391
379
  export {
392
380
  G as Q,
393
381
  oe as a,
394
- fe as u
382
+ de as u
395
383
  };
@@ -25,7 +25,7 @@ const g = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([
25
25
  }, a = (r, e) => {
26
26
  const t = c(r), n = c(e), o = t.pop(), i = n.pop(), s = p(t, n);
27
27
  return s !== 0 ? s : o && i ? p(o.split("."), i.split(".")) : o || i ? o ? -1 : 1 : 0;
28
- }, d = "0.0.13100-beta", w = (r) => m.every((e) => y(e, r)), y = (r, e) => {
28
+ }, d = "0.0.13101-beta", w = (r) => m.every((e) => y(e, r)), y = (r, e) => {
29
29
  if (!e[r]) {
30
30
  if (e.throwError)
31
31
  return e.throwError(`Missing required prop: ${r}`, 404), !1;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hortiview/modulebase",
3
3
  "description": "This is a base module for hortiview",
4
- "version": "0.0.13101-beta",
4
+ "version": "0.0.13102-beta",
5
5
  "type": "module",
6
6
  "author": "Falk Menge <falk.menge.ext@bayer.com>",
7
7
  "contributors": [