reactjrx 1.117.0 → 1.118.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.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  var pe = Object.defineProperty;
2
2
  var ge = (e, t, r) => t in e ? pe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var w = (e, t, r) => ge(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { useRef as E, useMemo as W, useCallback as h, useSyncExternalStore as he, useEffect as b, createContext as X, memo as Z, useContext as B, useState as ve } from "react";
5
- import { isObservable as K, from as x, of as p, defer as Q, startWith as Se, identity as ee, distinctUntilChanged as te, tap as re, catchError as M, EMPTY as T, Subject as z, BehaviorSubject as C, retry as be, merge as N, throwError as R, timer as Ie, map as P, switchMap as F, zip as we, share as ne, throttleTime as Ee, asyncScheduler as Ve, concatMap as xe, scan as Ce, takeUntil as se, fromEvent as Fe, take as ue, delay as $e, defaultIfEmpty as Me, filter as Ne, first as Pe, noop as L } from "rxjs";
6
- import { catchError as J, mergeMap as q, retryWhen as Oe, concatMap as Re, first as qe, tap as Ae } from "rxjs/operators";
4
+ import { useRef as E, useMemo as W, useCallback as h, useSyncExternalStore as he, useEffect as b, createContext as X, memo as Z, useContext as B, useState as Se } from "react";
5
+ import { isObservable as K, from as x, of as p, defer as Q, startWith as ve, identity as ee, distinctUntilChanged as te, tap as re, catchError as $, EMPTY as T, Subject as z, BehaviorSubject as F, retry as be, merge as M, throwError as R, timer as Ie, map as N, switchMap as C, zip as we, share as ne, throttleTime as Ee, asyncScheduler as Ve, concatMap as xe, scan as Fe, takeUntil as se, fromEvent as Ce, take as ue, delay as $e, defaultIfEmpty as Me, filter as Ne, first as Pe, noop as L } from "rxjs";
6
+ import { catchError as J, mergeMap as O, retryWhen as Re, concatMap as Oe, first as qe, tap as Ae } from "rxjs/operators";
7
7
  import { jsx as ce } from "react/jsx-runtime";
8
- import { hashKey as oe, useQueryClient as ae, useQuery as Qe, useMutation as Te } from "@tanstack/react-query";
8
+ import { hashKey as ae, useQueryClient as oe, useQuery as Qe, useMutation as Te } from "@tanstack/react-query";
9
9
  function Y(e) {
10
10
  return e instanceof Promise || e && typeof e == "object" && "then" in e && typeof e.then == "function" && "catch" in e && e.catch === "function";
11
11
  }
@@ -19,7 +19,7 @@ function D(e) {
19
19
  return Y(n) ? x(n) : K(n) ? n : p(n);
20
20
  });
21
21
  }
22
- const S = (e) => {
22
+ const v = (e) => {
23
23
  const t = E(e);
24
24
  return W(() => {
25
25
  t.current = e;
@@ -32,33 +32,33 @@ function k(e, t, r) {
32
32
  compareFn: void 0
33
33
  }, s = !r && Array.isArray(t) ? t : typeof e == "function" ? r ?? [] : [e], c = E(
34
34
  "getValue" in e && typeof e.getValue == "function" ? e.getValue() : n.defaultValue
35
- ), u = S(e), i = S(n), o = h(() => c.current, []), a = h(
36
- (l) => {
35
+ ), u = v(e), l = v(n), a = h(() => c.current, []), o = h(
36
+ (i) => {
37
37
  const m = u.current, g = D(m)().pipe(
38
- i.current.defaultValue ? Se(i.current.defaultValue) : ee,
38
+ l.current.defaultValue ? ve(l.current.defaultValue) : ee,
39
39
  /**
40
40
  * @important there is already a Object.is comparison in place from react
41
41
  * so we only add a custom compareFn if provided
42
42
  */
43
- te((d, y) => i.current.compareFn ? d === void 0 || y === void 0 ? !1 : i.current.compareFn(d, y) : !1),
43
+ te((d, y) => l.current.compareFn ? d === void 0 || y === void 0 ? !1 : l.current.compareFn(d, y) : !1),
44
44
  re((d) => {
45
45
  c.current = d;
46
46
  }),
47
- M((d) => (console.error(d), T))
48
- ).subscribe(l);
47
+ $((d) => (console.error(d), T))
48
+ ).subscribe(i);
49
49
  return () => {
50
- i.current.unsubscribeOnUnmount !== !1 && g.unsubscribe();
50
+ l.current.unsubscribeOnUnmount !== !1 && g.unsubscribe();
51
51
  };
52
52
  },
53
53
  [...s]
54
54
  );
55
- return he(a, o, o);
55
+ return he(o, a, a);
56
56
  }
57
57
  function De(e, t = []) {
58
- const r = S(e);
58
+ const r = v(e);
59
59
  b(() => {
60
60
  const n = D(r.current)().pipe(
61
- M((s) => (console.error(s), T))
61
+ $((s) => (console.error(s), T))
62
62
  ).subscribe();
63
63
  return () => {
64
64
  n.unsubscribe();
@@ -74,7 +74,7 @@ const _ = (e) => {
74
74
  onBeforeComplete: e,
75
75
  completeOnUnmount: t = !0
76
76
  } = {}) => {
77
- const r = _(() => new z()), n = E(!1), s = S(e), c = S(t);
77
+ const r = _(() => new z()), n = E(!1), s = v(e), c = v(t);
78
78
  return b(() => (n.current && (r.current = new z(), n.current = !1), () => {
79
79
  if (!c.current) {
80
80
  n.current = !0;
@@ -88,12 +88,12 @@ const _ = (e) => {
88
88
  }, []);
89
89
  return [e.current, t];
90
90
  }, j = (e) => {
91
- const t = _(() => new C(e)), r = E(!1), n = E(e);
92
- return r.current && (t.current = new C(n.current), r.current = !1), b(() => () => {
91
+ const t = _(() => new F(e)), r = E(!1), n = E(e);
92
+ return r.current && (t.current = new F(n.current), r.current = !1), b(() => () => {
93
93
  r.current || (t.current.complete(), r.current = !0);
94
94
  }, [t]), t.current;
95
95
  }, ot = (e) => {
96
- const t = j(e), r = S(t), n = h(
96
+ const t = j(e), r = v(t), n = h(
97
97
  (s) => {
98
98
  t.next(s);
99
99
  },
@@ -106,24 +106,24 @@ const _ = (e) => {
106
106
  t.next(e);
107
107
  }, [e, t]), t;
108
108
  };
109
- function at(e, t, r = []) {
110
- const n = t != null && !Array.isArray(t) ? t : {}, s = n.retry ?? !0, c = S(
111
- n.onError ?? ((o) => {
112
- console.error(o);
109
+ function it(e, t, r = []) {
110
+ const n = t != null && !Array.isArray(t) ? t : {}, s = n.retry ?? !0, c = v(
111
+ n.onError ?? ((a) => {
112
+ console.error(a);
113
113
  })
114
- ), u = h(() => D(e)(), r), i = h(
114
+ ), u = h(() => D(e)(), r), l = h(
115
115
  () => u().pipe(
116
- M((o) => {
117
- throw c.current(o), o;
116
+ $((a) => {
117
+ throw c.current(a), a;
118
118
  }),
119
119
  s ? be() : ee
120
120
  ),
121
121
  [u, s, c]
122
122
  );
123
- De(i, r);
123
+ De(l, r);
124
124
  }
125
125
  const _e = Symbol("SIGNAL_RESET");
126
- class le extends C {
126
+ class le extends F {
127
127
  constructor(r) {
128
128
  super(r.default);
129
129
  w(this, "update", (r) => {
@@ -151,22 +151,22 @@ class le extends C {
151
151
  return this.config.key;
152
152
  }
153
153
  }
154
- class $ {
154
+ class A {
155
155
  constructor(t) {
156
156
  this.config = t;
157
157
  }
158
158
  }
159
- function it(e = {}) {
159
+ function lt(e = {}) {
160
160
  return new le({
161
161
  key: void 0,
162
162
  ...e,
163
163
  default: e.default ?? void 0
164
164
  });
165
165
  }
166
- function lt(e) {
167
- return new $(e);
166
+ function ft(e) {
167
+ return new A(e);
168
168
  }
169
- const ft = () => {
169
+ const yt = () => {
170
170
  const e = ie({
171
171
  onBeforeComplete: () => {
172
172
  e.current.next();
@@ -175,7 +175,7 @@ const ft = () => {
175
175
  return e;
176
176
  }, je = (e) => {
177
177
  b(e, []);
178
- }, yt = (e) => {
178
+ }, dt = (e) => {
179
179
  je(() => {
180
180
  e();
181
181
  });
@@ -186,7 +186,7 @@ function He(e, t) {
186
186
  function Ke(e, t) {
187
187
  return 2 ** e * t;
188
188
  }
189
- function dt(e) {
189
+ function mt(e) {
190
190
  const {
191
191
  retry: t,
192
192
  retryDelay: r,
@@ -195,45 +195,45 @@ function dt(e) {
195
195
  } = e, c = typeof t != "function" ? t === !1 ? 0 : t === !0 ? Number.POSITIVE_INFINITY : t ?? Number.POSITIVE_INFINITY : Number.POSITIVE_INFINITY, u = typeof t == "function" ? (
196
196
  // ? (attempt: number, error: TError) => of(retry(attempt, error))
197
197
  t
198
- ) : () => !0, i = typeof r == "number" ? r : 100, o = {
198
+ ) : () => !0, l = typeof r == "number" ? r : 100, a = {
199
199
  ...e
200
200
  }, {
201
- maxInterval: a = Number.POSITIVE_INFINITY,
201
+ maxInterval: o = Number.POSITIVE_INFINITY,
202
202
  resetOnSuccess: f = !1,
203
- backoffDelay: l = Ke
204
- } = o;
203
+ backoffDelay: i = Ke
204
+ } = a;
205
205
  return (m) => Q(() => {
206
206
  let g = 0;
207
- const d = (y, v) => y < c ? u(y, v) : !1;
207
+ const d = (y, S) => y < c ? u(y, S) : !1;
208
208
  return m.pipe(
209
209
  J((y) => {
210
210
  var I;
211
211
  if (g++, !d(g - 1, y)) throw y;
212
- const v = (I = e.caughtError) == null ? void 0 : I.call(e, g, y);
213
- if (!v) throw y;
214
- return v.pipe(
215
- q(
216
- (O) => N(
217
- p(O),
212
+ const S = (I = e.caughtError) == null ? void 0 : I.call(e, g, y);
213
+ if (!S) throw y;
214
+ return S.pipe(
215
+ O(
216
+ (P) => M(
217
+ p(P),
218
218
  R(() => y)
219
219
  )
220
220
  )
221
221
  );
222
222
  }),
223
- Oe((y) => y.pipe(
224
- Re((v) => {
223
+ Re((y) => y.pipe(
224
+ Oe((S) => {
225
225
  const I = g - 1;
226
226
  return s().pipe(
227
227
  qe(),
228
- q(
229
- () => d(I, v) ? Ie(
228
+ O(
229
+ () => d(I, S) ? Ie(
230
230
  He(
231
- l(I, i),
232
- a
231
+ i(I, l),
232
+ o
233
233
  )
234
234
  ).pipe(
235
- q((O) => n && !n(I, v) ? R(() => v) : p(O))
236
- ) : R(() => v)
235
+ O((P) => n && !n(I, S) ? R(() => S) : p(P))
236
+ ) : R(() => S)
237
237
  )
238
238
  );
239
239
  })
@@ -249,14 +249,19 @@ function dt(e) {
249
249
  );
250
250
  });
251
251
  }
252
- function mt(e) {
252
+ function pt(e) {
253
253
  return e != null;
254
254
  }
255
- const pt = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]), gt = typeof window > "u" || "Deno" in window;
255
+ const gt = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]), ht = typeof window > "u" || "Deno" in window;
256
256
  class G {
257
257
  constructor() {
258
+ /**
259
+ * items only get added as they are created. The only time we should cleanup
260
+ * are on context destroy. This is to ensure later re-use of virtual signals
261
+ * return the same persisted state.
262
+ */
258
263
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
259
- w(this, "signals", new C(/* @__PURE__ */ new Map()));
264
+ w(this, "signals", new F(/* @__PURE__ */ new Map()));
260
265
  w(this, "isDestroyed", !1);
261
266
  }
262
267
  getOrCreateSignal(t) {
@@ -272,8 +277,7 @@ class G {
272
277
  }), this.signals.value.clear(), this.signals.complete(), this.isDestroyed = !0;
273
278
  }
274
279
  }
275
- const fe = X(void 0);
276
- Z(
280
+ const fe = X(void 0), St = Z(
277
281
  ({ children: e }) => {
278
282
  const t = _(() => new G());
279
283
  t.current.isDestroyed && (t.current = new G());
@@ -282,9 +286,8 @@ Z(
282
286
  t.current.destroy();
283
287
  }, [t]), /* @__PURE__ */ ce(fe.Provider, { value: r, children: e });
284
288
  }
285
- );
286
- const H = () => B(fe), ye = (e) => {
287
- const t = H();
289
+ ), ye = () => B(fe), ze = (e) => {
290
+ const t = ye();
288
291
  if (!t) {
289
292
  if (e)
290
293
  throw new Error(
@@ -295,7 +298,7 @@ const H = () => B(fe), ye = (e) => {
295
298
  const r = t.signals;
296
299
  return k(
297
300
  () => r.pipe(
298
- P(
301
+ N(
299
302
  () => e ? t.getOrCreateSignal(e) : void 0
300
303
  )
301
304
  ),
@@ -305,44 +308,40 @@ const H = () => B(fe), ye = (e) => {
305
308
  [r]
306
309
  );
307
310
  };
308
- function ze(e, t) {
309
- const r = S(t), n = H();
310
- if (e instanceof $ && !n)
311
+ function H(e) {
312
+ const t = ye();
313
+ if (e instanceof A && !t)
311
314
  throw new Error(
312
315
  "useSignalValue must be used within a SignalContextProvider"
313
316
  );
314
- const s = ye(
315
- e instanceof $ ? e : void 0
317
+ return ze(
318
+ e instanceof A ? e : void 0
316
319
  ) ?? e;
320
+ }
321
+ function Le(e, t) {
322
+ const r = v(t), n = H(e);
317
323
  return k(
318
324
  () => {
319
- const c = r.current ?? ((i) => i);
320
- return s.pipe(
321
- P(c),
325
+ const s = r.current ?? ((u) => u);
326
+ return n.pipe(
327
+ N(s),
322
328
  te()
323
329
  );
324
330
  },
325
331
  {
326
- defaultValue: t ? t == null ? void 0 : t(s.value) : s.value
332
+ defaultValue: t ? t == null ? void 0 : t(n.value) : n.value
327
333
  },
328
- [s]
334
+ [n]
329
335
  );
330
336
  }
331
- function Le(e) {
332
- const t = H();
333
- if (e instanceof $ && !t)
334
- throw new Error(
335
- "useSignalValue must be used within a SignalContextProvider"
336
- );
337
- return (ye(
338
- e instanceof $ ? e : void 0
339
- ) ?? e).update;
337
+ function Je(e) {
338
+ return H(e).update;
340
339
  }
341
- function ht(e) {
342
- const t = ze(e), r = Le(e);
343
- return [t, r];
340
+ function vt(e) {
341
+ const t = H(e), r = Le(e), n = Je(e);
342
+ return [r, n, t];
344
343
  }
345
- const vt = (e) => ({
344
+ const bt = (e) => ({
346
345
  getItem: async (t) => {
347
346
  const r = await e.getItem(t);
348
347
  if (r)
@@ -355,10 +354,10 @@ const vt = (e) => ({
355
354
  },
356
355
  clear: async () => {
357
356
  }
358
- }), A = (e) => {
357
+ }), q = (e) => {
359
358
  if (!(!e || typeof e != "object"))
360
359
  return e;
361
- }, Je = ({
360
+ }, Ye = ({
362
361
  adapter: e,
363
362
  key: t
364
363
  }) => ({
@@ -366,23 +365,23 @@ const vt = (e) => ({
366
365
  removeItem: async (r) => {
367
366
  const n = await e.getItem(t), { [r]: s, ...c } = (
368
367
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
369
- A(n) ?? {}
368
+ q(n) ?? {}
370
369
  );
371
370
  await e.setItem(t, c);
372
371
  },
373
372
  getItem: async (r) => {
374
- const n = await e.getItem(t), s = A(n) ?? {};
373
+ const n = await e.getItem(t), s = q(n) ?? {};
375
374
  if (r in s)
376
375
  return s[r];
377
376
  },
378
377
  setItem: async (r, n) => {
379
- const s = await e.getItem(t), c = A(s) ?? {};
378
+ const s = await e.getItem(t), c = q(s) ?? {};
380
379
  await e.setItem(t, { ...c, [r]: n });
381
380
  }
382
- }), Ye = ({
381
+ }), Ue = ({
383
382
  key: e
384
- } = {}) => e ? Je({
385
- adapter: Ye(),
383
+ } = {}) => e ? Ye({
384
+ adapter: Ue(),
386
385
  key: e
387
386
  }) : {
388
387
  clear: async () => {
@@ -400,7 +399,7 @@ const vt = (e) => ({
400
399
  localStorage.setItem(t, JSON.stringify(r));
401
400
  }
402
401
  };
403
- function Ue(e, t) {
402
+ function Ge(e, t) {
404
403
  if (e == null || t === void 0 || typeof e != "object" || typeof t != "object")
405
404
  return e === t;
406
405
  if (e.constructor !== (t == null ? void 0 : t.constructor))
@@ -413,10 +412,10 @@ function Ue(e, t) {
413
412
  return !1;
414
413
  return !0;
415
414
  }
416
- const V = "__reactjrx", Ge = (e) => {
415
+ const V = "__reactjrx", We = (e) => {
417
416
  if (typeof e == "object" && e !== null && V in e && e[V] === V)
418
417
  return e;
419
- }, We = ({
418
+ }, Xe = ({
420
419
  adapter: e,
421
420
  config: t
422
421
  }) => {
@@ -431,58 +430,58 @@ const V = "__reactjrx", Ge = (e) => {
431
430
  c,
432
431
  `for signal ${r.config.key}`
433
432
  ), x(e.setItem(r.config.key, c)).pipe(
434
- M((u) => (console.error(u), p(null)))
433
+ $((u) => (console.error(u), p(null)))
435
434
  );
436
435
  };
437
- function Xe({
436
+ function Ze({
438
437
  adapter: e,
439
438
  config: t
440
439
  }) {
441
440
  const { hydrate: r = ({ value: c }) => c, signal: n, version: s } = t;
442
441
  return x(e.getItem(n.config.key)).pipe(
443
- F((c) => {
444
- const u = Ge(c);
442
+ C((c) => {
443
+ const u = We(c);
445
444
  if (!u) return p(c);
446
- const i = typeof u.migrationVersion != "number", o = u.migrationVersion !== void 0 && s > u.migrationVersion;
447
- if (i || o || u.value === void 0)
445
+ const l = typeof u.migrationVersion != "number", a = u.migrationVersion !== void 0 && s > u.migrationVersion;
446
+ if (l || a || u.value === void 0)
448
447
  return p(c);
449
- const a = u.value;
448
+ const o = u.value;
450
449
  return process.env.NODE_ENV === "development" && console.log(
451
450
  "[reactjrx][state][persistance]:",
452
451
  "Hydrate value",
453
452
  u,
454
453
  `for signal ${n.config.key}`
455
- ), n.setValue(r({ value: a, version: s })), p(c);
454
+ ), n.setValue(r({ value: o, version: s })), p(c);
456
455
  })
457
456
  );
458
457
  }
459
- function Ze({
458
+ function Be({
460
459
  entries: e = [],
461
460
  onHydrated: t,
462
461
  adapter: r
463
462
  }) {
464
463
  const s = (e.length === 0 ? p([]) : we(
465
464
  ...e.map(
466
- (u) => Xe({
465
+ (u) => Ze({
467
466
  adapter: r,
468
467
  config: u
469
468
  })
470
469
  )
471
470
  )).pipe(
472
471
  re(t),
473
- M((u) => (console.error("Unable to hydrate", u), T)),
472
+ $((u) => (console.error("Unable to hydrate", u), T)),
474
473
  ne()
475
474
  ), c = s.pipe(
476
- F(
477
- () => N(
475
+ C(
476
+ () => M(
478
477
  ...e.map(
479
478
  (u) => u.signal.pipe(
480
479
  Ee(500, Ve, {
481
480
  trailing: !0
482
481
  }),
483
- F(
482
+ C(
484
483
  () => x(
485
- We({
484
+ Xe({
486
485
  adapter: r,
487
486
  config: u
488
487
  })
@@ -493,53 +492,53 @@ function Ze({
493
492
  )
494
493
  )
495
494
  );
496
- return N(
495
+ return M(
497
496
  s.pipe(
498
- P(() => ({
497
+ N(() => ({
499
498
  type: "hydrated"
500
499
  }))
501
500
  ),
502
501
  c.pipe(
503
- P(() => ({
502
+ N(() => ({
504
503
  type: "persisted"
505
504
  }))
506
505
  )
507
506
  );
508
507
  }
509
- function St({
508
+ function It({
510
509
  entries: e = [],
511
510
  onHydrated: t,
512
511
  adapter: r
513
512
  }) {
514
- const n = S(t), s = U(r), c = U(e);
513
+ const n = v(t), s = U(r), c = U(e);
515
514
  return k(
516
515
  () => s.pipe(
517
- F((i) => i ? N(
516
+ C((l) => l ? M(
518
517
  p({ type: "reset" }),
519
518
  c.pipe(
520
519
  xe(
521
- (o) => Ze({
522
- adapter: i,
523
- entries: o,
520
+ (a) => Be({
521
+ adapter: l,
522
+ entries: a,
524
523
  onHydrated: () => {
525
- var a;
526
- (a = n.current) == null || a.call(n);
524
+ var o;
525
+ (o = n.current) == null || o.call(n);
527
526
  }
528
527
  })
529
528
  )
530
529
  )
531
530
  ) : p({ type: "reset" }))
532
531
  ).pipe(
533
- Ce(
534
- (i, o) => o.type === "reset" ? { isHydrated: !1 } : o.type === "hydrated" ? { isHydrated: !0 } : i,
532
+ Fe(
533
+ (l, a) => a.type === "reset" ? { isHydrated: !1 } : a.type === "hydrated" ? { isHydrated: !0 } : l,
535
534
  { isHydrated: !1 }
536
535
  )
537
536
  ),
538
- { defaultValue: { isHydrated: !1 }, compareFn: Ue },
537
+ { defaultValue: { isHydrated: !1 }, compareFn: Ge },
539
538
  [s, c]
540
539
  );
541
540
  }
542
- class Be {
541
+ class et {
543
542
  constructor() {
544
543
  w(this, "queryMap", /* @__PURE__ */ new Map());
545
544
  }
@@ -547,14 +546,14 @@ class Be {
547
546
  return this.queryMap.get(t);
548
547
  }
549
548
  setQuery(t, r, n) {
550
- const s = oe(t), c = r.pipe(
549
+ const s = ae(t), c = r.pipe(
551
550
  /**
552
551
  * abort signal is triggered on:
553
552
  * - manual cancellation from user
554
553
  * - unmounting the component
555
554
  * @see https://tanstack.com/query/latest/docs/framework/react/guides/query-cancellation
556
555
  */
557
- se(Fe(n, "abort")),
556
+ se(Ce(n, "abort")),
558
557
  ne()
559
558
  ), u = {
560
559
  query$: c,
@@ -564,16 +563,16 @@ class Be {
564
563
  lastData: void 0
565
564
  };
566
565
  this.queryMap.set(s, u);
567
- const i = c.subscribe({
568
- next: (o) => {
569
- const a = this.queryMap.get(s);
570
- a && (a.lastData = { value: o });
566
+ const l = c.subscribe({
567
+ next: (a) => {
568
+ const o = this.queryMap.get(s);
569
+ o && (o.lastData = { value: a });
571
570
  },
572
571
  complete: () => {
573
572
  this.deleteQuery(s);
574
573
  }
575
574
  });
576
- return u.sub = i, u;
575
+ return u.sub = l, u;
577
576
  }
578
577
  deleteQuery(t) {
579
578
  const r = this.queryMap.get(t);
@@ -585,17 +584,17 @@ class Be {
585
584
  });
586
585
  }
587
586
  }
588
- const de = X(void 0), bt = Z(
587
+ const de = X(void 0), wt = Z(
589
588
  ({
590
589
  children: e,
591
590
  client: t
592
591
  }) => {
593
- const [r] = ve(() => t ?? new Be());
592
+ const [r] = Se(() => t ?? new et());
594
593
  return b(() => () => {
595
594
  r.destroy();
596
595
  }, [r]), /* @__PURE__ */ ce(de.Provider, { value: r, children: e });
597
596
  }
598
- ), et = () => {
597
+ ), tt = () => {
599
598
  const e = B(de);
600
599
  if (!e)
601
600
  throw new Error(
@@ -603,16 +602,16 @@ const de = X(void 0), bt = Z(
603
602
  );
604
603
  return e;
605
604
  };
606
- function It(e, t) {
607
- const r = ae(t), n = et();
605
+ function Et(e, t) {
606
+ const r = oe(t), n = tt();
608
607
  return Qe(
609
608
  {
610
609
  ...e,
611
- queryFn: (u) => new Promise((i, o) => {
612
- const a = () => Q(
610
+ queryFn: (u) => new Promise((l, a) => {
611
+ const o = () => Q(
613
612
  () => typeof e.queryFn == "function" ? e.queryFn(u) : e.queryFn
614
- ), f = oe(u.queryKey), l = n.getQuery(f) ?? n.setQuery(u.queryKey, a(), u.signal);
615
- l.query$.pipe(
613
+ ), f = ae(u.queryKey), i = n.getQuery(f) ?? n.setQuery(u.queryKey, o(), u.signal);
614
+ i.query$.pipe(
616
615
  ue(1),
617
616
  /**
618
617
  * If several values are emitted during this delay, we will only
@@ -621,17 +620,17 @@ function It(e, t) {
621
620
  */
622
621
  $e(1)
623
622
  ).subscribe({
624
- error: (g) => o(g),
623
+ error: (g) => a(g),
625
624
  complete: () => {
626
- if ((l == null ? void 0 : l.lastData) === void 0)
627
- return l.signal.aborted || (console.log(
625
+ if ((i == null ? void 0 : i.lastData) === void 0)
626
+ return i.signal.aborted || (console.log(
628
627
  `cancelled due to stream completing without data for query ${f}`,
629
- l == null ? void 0 : l.lastData
628
+ i == null ? void 0 : i.lastData
630
629
  ), r.cancelQueries({
631
630
  queryKey: u.queryKey,
632
631
  exact: !0
633
- })), i(void 0);
634
- i(l.lastData.value), (l == null ? void 0 : l.isCompleted) === !1 && setTimeout(() => {
632
+ })), l(void 0);
633
+ l(i.lastData.value), (i == null ? void 0 : i.isCompleted) === !1 && setTimeout(() => {
635
634
  r == null || r.refetchQueries({
636
635
  queryKey: u.queryKey,
637
636
  exact: !0
@@ -654,10 +653,10 @@ function me(e, t) {
654
653
  }), n = Te(
655
654
  {
656
655
  ...e,
657
- mutationFn: (a) => {
656
+ mutationFn: (o) => {
658
657
  let f;
659
- return new Promise((l, m) => {
660
- (typeof e.mutationFn == "function" ? e.mutationFn(a) : e.mutationFn).pipe(ue(1)).subscribe({
658
+ return new Promise((i, m) => {
659
+ (typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(ue(1)).subscribe({
661
660
  next: (d) => {
662
661
  f = { value: d };
663
662
  },
@@ -667,128 +666,133 @@ function me(e, t) {
667
666
  complete: () => {
668
667
  if (f === void 0)
669
668
  return m(new Error("Stream completed without any data"));
670
- l(f.value);
669
+ i(f.value);
671
670
  }
672
671
  });
673
672
  });
674
673
  }
675
674
  },
676
675
  t
677
- ), { status: s, isPending: c, isError: u, isSuccess: i, isIdle: o } = n;
676
+ ), { status: s, isPending: c, isError: u, isSuccess: l, isIdle: a } = n;
678
677
  return b(() => {
679
678
  r.next({
680
679
  status: s,
681
680
  isPending: c,
682
681
  isError: u,
683
- isSuccess: i,
684
- isIdle: o
682
+ isSuccess: l,
683
+ isIdle: a
685
684
  });
686
- }, [s, c, u, i, o, r]), { ...n, state$: r };
685
+ }, [s, c, u, l, a, r]), { ...n, state$: r };
687
686
  }
688
- function wt(e, t) {
687
+ function Vt(e, t) {
689
688
  const [r, n] = ke(), { mutate: s, mutateAsync: c, ...u } = me(
690
689
  {
691
690
  ...e,
692
- mutationFn: (a) => (typeof e.mutationFn == "function" ? e.mutationFn(a) : e.mutationFn).pipe(se(r), Me(null))
691
+ mutationFn: (o) => (typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(se(r), Me(null))
693
692
  },
694
693
  t
695
- ), i = h(
696
- (a) => (n(), s(a)),
694
+ ), l = h(
695
+ (o) => (n(), s(o)),
697
696
  [s, n]
698
- ), o = h(
699
- (a) => (n(), c(a)),
697
+ ), a = h(
698
+ (o) => (n(), c(o)),
700
699
  [c, n]
701
700
  );
702
- return { ...u, mutate: i, mutateAsync: o };
701
+ return { ...u, mutate: l, mutateAsync: a };
703
702
  }
704
- function Et(e, t) {
705
- const r = ae(t), n = e.mutationKey, { mutateAsync: s, ...c } = me(
703
+ function xt(e, t) {
704
+ const r = oe(t), n = e.mutationKey, { mutateAsync: s, ...c } = me(
706
705
  {
707
706
  ...e,
708
- onMutate({ variables: o }) {
709
- var a;
710
- return (a = e.onMutate) == null ? void 0 : a.call(e, o);
707
+ onMutate({ variables: a }) {
708
+ var o;
709
+ return (o = e.onMutate) == null ? void 0 : o.call(e, a);
711
710
  },
712
- onSuccess(o, a, f) {
713
- var l;
714
- return (l = e.onSuccess) == null ? void 0 : l.call(e, o, a.variables, f);
711
+ onSuccess(a, o, f) {
712
+ var i;
713
+ return (i = e.onSuccess) == null ? void 0 : i.call(e, a, o.variables, f);
715
714
  },
716
- onError(o, a, f) {
717
- var l;
718
- return (l = e.onError) == null ? void 0 : l.call(e, o, a.variables, f);
715
+ onError(a, o, f) {
716
+ var i;
717
+ return (i = e.onError) == null ? void 0 : i.call(e, a, o.variables, f);
719
718
  },
720
- onSettled(o, a, f, l) {
719
+ onSettled(a, o, f, i) {
721
720
  var m;
722
- return (m = e.onSettled) == null ? void 0 : m.call(e, o, a, f.variables, l);
721
+ return (m = e.onSettled) == null ? void 0 : m.call(e, a, o, f.variables, i);
723
722
  },
724
- mutationFn: ({ ready$: o, variables: a }) => {
725
- const f = typeof e.mutationFn == "function" ? e.mutationFn(a) : e.mutationFn;
726
- return o.pipe(
727
- Ne((l) => l),
723
+ mutationFn: ({ ready$: a, variables: o }) => {
724
+ const f = typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn;
725
+ return a.pipe(
726
+ Ne((i) => i),
728
727
  Pe(),
729
- F(() => f)
728
+ C(() => f)
730
729
  );
731
730
  }
732
731
  },
733
732
  t
734
733
  ), u = h(
735
- async (o) => {
736
- const a = r.getMutationCache().findAll({
734
+ async (a) => {
735
+ const o = r.getMutationCache().findAll({
737
736
  mutationKey: n,
738
737
  exact: !0
739
- }), f = new C(!1), l = s({ variables: o, ready$: f });
738
+ }), f = new F(!1), i = s({ variables: a, ready$: f });
740
739
  return await Promise.all(
741
- a.map((m) => m.continue().catch(L))
742
- ), f.next(!0), await l.finally(() => {
740
+ o.map((m) => m.continue().catch(L))
741
+ ), f.next(!0), await i.finally(() => {
743
742
  f.complete();
744
743
  });
745
744
  },
746
745
  [s, r, n]
747
- ), i = h(
748
- (o) => {
749
- u(o).catch(L);
746
+ ), l = h(
747
+ (a) => {
748
+ u(a).catch(L);
750
749
  },
751
750
  [u]
752
751
  );
753
- return { ...c, mutate: i, mutateAsync: u };
752
+ return { ...c, mutate: l, mutateAsync: u };
754
753
  }
755
754
  export {
756
755
  de as Context,
757
- Be as QueryClient$,
758
- bt as QueryClientProvider$,
756
+ et as QueryClient$,
757
+ wt as QueryClientProvider$,
759
758
  _e as SIGNAL_RESET,
760
759
  le as Signal,
761
- $ as VirtualSignal,
762
- pt as arrayEqual,
763
- Ye as createLocalStorageAdapter,
764
- vt as createLocalforageAdapter,
760
+ St as SignalContextProvider,
761
+ fe as SignalReactContext,
762
+ A as VirtualSignal,
763
+ gt as arrayEqual,
764
+ Ue as createLocalStorageAdapter,
765
+ bt as createLocalforageAdapter,
765
766
  Ke as exponentialBackoffDelay,
766
767
  He as getDelay,
767
- mt as isDefined,
768
+ pt as isDefined,
768
769
  Y as isPromiseLike,
769
- gt as isServer,
770
- dt as retryBackoff,
771
- it as signal,
770
+ ht as isServer,
771
+ mt as retryBackoff,
772
+ lt as signal,
772
773
  j as useBehaviorSubject,
773
- Et as useContactMutation$,
774
+ xt as useContactMutation$,
774
775
  je as useEffectOnce,
775
776
  U as useLiveBehaviorSubject,
776
- S as useLiveRef,
777
- yt as useMount,
777
+ v as useLiveRef,
778
+ ze as useMakeOrRetrieveSignal,
779
+ dt as useMount,
778
780
  me as useMutation$,
779
781
  ke as useObservableCallback,
780
782
  ot as useObservableState,
781
783
  k as useObserve,
782
- St as usePersistSignals,
783
- It as useQuery$,
784
- et as useQueryClient$,
785
- ht as useSignal,
786
- ze as useSignalValue,
784
+ It as usePersistSignals,
785
+ Et as useQuery$,
786
+ tt as useQueryClient$,
787
+ Je as useSetSignal,
788
+ vt as useSignal,
789
+ ye as useSignalContext,
790
+ Le as useSignalValue,
787
791
  ie as useSubject,
788
792
  De as useSubscribe,
789
- at as useSubscribeEffect,
790
- wt as useSwitchMutation$,
791
- ft as useUnmountObservable,
792
- lt as virtualSignal
793
+ it as useSubscribeEffect,
794
+ Vt as useSwitchMutation$,
795
+ yt as useUnmountObservable,
796
+ ft as virtualSignal
793
797
  };
794
798
  //# sourceMappingURL=index.js.map