reactjrx 1.117.0 → 1.117.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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +212 -213
- package/dist/index.js.map +1 -1
- package/dist/lib/state/react/useSignal.d.ts +3 -3
- package/dist/lib/state/react/useSignalReference.d.ts +2 -0
- package/package.json +1 -1
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
|
|
5
|
-
import { isObservable as K, from as x, of as p, defer as Q, startWith as
|
|
6
|
-
import { catchError as J, mergeMap as
|
|
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
|
|
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
|
|
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 =
|
|
36
|
-
(
|
|
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
|
-
|
|
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) =>
|
|
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
|
-
|
|
48
|
-
).subscribe(
|
|
47
|
+
$((d) => (console.error(d), T))
|
|
48
|
+
).subscribe(i);
|
|
49
49
|
return () => {
|
|
50
|
-
|
|
50
|
+
l.current.unsubscribeOnUnmount !== !1 && g.unsubscribe();
|
|
51
51
|
};
|
|
52
52
|
},
|
|
53
53
|
[...s]
|
|
54
54
|
);
|
|
55
|
-
return he(
|
|
55
|
+
return he(o, a, a);
|
|
56
56
|
}
|
|
57
57
|
function De(e, t = []) {
|
|
58
|
-
const r =
|
|
58
|
+
const r = v(e);
|
|
59
59
|
b(() => {
|
|
60
60
|
const n = D(r.current)().pipe(
|
|
61
|
-
|
|
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 =
|
|
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
|
|
92
|
-
return r.current && (t.current = new
|
|
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 =
|
|
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
|
|
110
|
-
const n = t != null && !Array.isArray(t) ? t : {}, s = n.retry ?? !0, c =
|
|
111
|
-
n.onError ?? ((
|
|
112
|
-
console.error(
|
|
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),
|
|
114
|
+
), u = h(() => D(e)(), r), l = h(
|
|
115
115
|
() => u().pipe(
|
|
116
|
-
|
|
117
|
-
throw c.current(
|
|
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(
|
|
123
|
+
De(l, r);
|
|
124
124
|
}
|
|
125
125
|
const _e = Symbol("SIGNAL_RESET");
|
|
126
|
-
class le extends
|
|
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
|
|
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
|
|
167
|
-
return new
|
|
166
|
+
function ft(e) {
|
|
167
|
+
return new A(e);
|
|
168
168
|
}
|
|
169
|
-
const
|
|
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
|
-
},
|
|
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
|
|
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,
|
|
198
|
+
) : () => !0, l = typeof r == "number" ? r : 100, a = {
|
|
199
199
|
...e
|
|
200
200
|
}, {
|
|
201
|
-
maxInterval:
|
|
201
|
+
maxInterval: o = Number.POSITIVE_INFINITY,
|
|
202
202
|
resetOnSuccess: f = !1,
|
|
203
|
-
backoffDelay:
|
|
204
|
-
} =
|
|
203
|
+
backoffDelay: i = Ke
|
|
204
|
+
} = a;
|
|
205
205
|
return (m) => Q(() => {
|
|
206
206
|
let g = 0;
|
|
207
|
-
const d = (y,
|
|
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
|
|
213
|
-
if (!
|
|
214
|
-
return
|
|
215
|
-
|
|
216
|
-
(
|
|
217
|
-
p(
|
|
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
|
-
|
|
224
|
-
|
|
223
|
+
Re((y) => y.pipe(
|
|
224
|
+
Oe((S) => {
|
|
225
225
|
const I = g - 1;
|
|
226
226
|
return s().pipe(
|
|
227
227
|
qe(),
|
|
228
|
-
|
|
229
|
-
() => d(I,
|
|
228
|
+
O(
|
|
229
|
+
() => d(I, S) ? Ie(
|
|
230
230
|
He(
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
i(I, l),
|
|
232
|
+
o
|
|
233
233
|
)
|
|
234
234
|
).pipe(
|
|
235
|
-
|
|
236
|
-
) : R(() =>
|
|
235
|
+
O((P) => n && !n(I, S) ? R(() => S) : p(P))
|
|
236
|
+
) : R(() => S)
|
|
237
237
|
)
|
|
238
238
|
);
|
|
239
239
|
})
|
|
@@ -249,14 +249,14 @@ function dt(e) {
|
|
|
249
249
|
);
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function pt(e) {
|
|
253
253
|
return e != null;
|
|
254
254
|
}
|
|
255
|
-
const
|
|
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
258
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
259
|
-
w(this, "signals", new
|
|
259
|
+
w(this, "signals", new F(/* @__PURE__ */ new Map()));
|
|
260
260
|
w(this, "isDestroyed", !1);
|
|
261
261
|
}
|
|
262
262
|
getOrCreateSignal(t) {
|
|
@@ -272,8 +272,7 @@ class G {
|
|
|
272
272
|
}), this.signals.value.clear(), this.signals.complete(), this.isDestroyed = !0;
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
|
-
const fe = X(void 0)
|
|
276
|
-
Z(
|
|
275
|
+
const fe = X(void 0), St = Z(
|
|
277
276
|
({ children: e }) => {
|
|
278
277
|
const t = _(() => new G());
|
|
279
278
|
t.current.isDestroyed && (t.current = new G());
|
|
@@ -282,9 +281,8 @@ Z(
|
|
|
282
281
|
t.current.destroy();
|
|
283
282
|
}, [t]), /* @__PURE__ */ ce(fe.Provider, { value: r, children: e });
|
|
284
283
|
}
|
|
285
|
-
)
|
|
286
|
-
const
|
|
287
|
-
const t = H();
|
|
284
|
+
), ye = () => B(fe), ze = (e) => {
|
|
285
|
+
const t = ye();
|
|
288
286
|
if (!t) {
|
|
289
287
|
if (e)
|
|
290
288
|
throw new Error(
|
|
@@ -295,7 +293,7 @@ const H = () => B(fe), ye = (e) => {
|
|
|
295
293
|
const r = t.signals;
|
|
296
294
|
return k(
|
|
297
295
|
() => r.pipe(
|
|
298
|
-
|
|
296
|
+
N(
|
|
299
297
|
() => e ? t.getOrCreateSignal(e) : void 0
|
|
300
298
|
)
|
|
301
299
|
),
|
|
@@ -305,44 +303,40 @@ const H = () => B(fe), ye = (e) => {
|
|
|
305
303
|
[r]
|
|
306
304
|
);
|
|
307
305
|
};
|
|
308
|
-
function
|
|
309
|
-
const
|
|
310
|
-
if (e instanceof
|
|
306
|
+
function H(e) {
|
|
307
|
+
const t = ye();
|
|
308
|
+
if (e instanceof A && !t)
|
|
311
309
|
throw new Error(
|
|
312
310
|
"useSignalValue must be used within a SignalContextProvider"
|
|
313
311
|
);
|
|
314
|
-
|
|
315
|
-
e instanceof
|
|
312
|
+
return ze(
|
|
313
|
+
e instanceof A ? e : void 0
|
|
316
314
|
) ?? e;
|
|
315
|
+
}
|
|
316
|
+
function Le(e, t) {
|
|
317
|
+
const r = v(t), n = H(e);
|
|
317
318
|
return k(
|
|
318
319
|
() => {
|
|
319
|
-
const
|
|
320
|
-
return
|
|
321
|
-
|
|
320
|
+
const s = r.current ?? ((u) => u);
|
|
321
|
+
return n.pipe(
|
|
322
|
+
N(s),
|
|
322
323
|
te()
|
|
323
324
|
);
|
|
324
325
|
},
|
|
325
326
|
{
|
|
326
|
-
defaultValue: t ? t == null ? void 0 : t(
|
|
327
|
+
defaultValue: t ? t == null ? void 0 : t(n.value) : n.value
|
|
327
328
|
},
|
|
328
|
-
[
|
|
329
|
+
[n]
|
|
329
330
|
);
|
|
330
331
|
}
|
|
331
|
-
function
|
|
332
|
-
|
|
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;
|
|
332
|
+
function Je(e) {
|
|
333
|
+
return H(e).update;
|
|
340
334
|
}
|
|
341
|
-
function
|
|
342
|
-
const t =
|
|
343
|
-
return [
|
|
335
|
+
function vt(e) {
|
|
336
|
+
const t = H(e), r = Le(e), n = Je(e);
|
|
337
|
+
return [r, n, t];
|
|
344
338
|
}
|
|
345
|
-
const
|
|
339
|
+
const bt = (e) => ({
|
|
346
340
|
getItem: async (t) => {
|
|
347
341
|
const r = await e.getItem(t);
|
|
348
342
|
if (r)
|
|
@@ -355,10 +349,10 @@ const vt = (e) => ({
|
|
|
355
349
|
},
|
|
356
350
|
clear: async () => {
|
|
357
351
|
}
|
|
358
|
-
}),
|
|
352
|
+
}), q = (e) => {
|
|
359
353
|
if (!(!e || typeof e != "object"))
|
|
360
354
|
return e;
|
|
361
|
-
},
|
|
355
|
+
}, Ye = ({
|
|
362
356
|
adapter: e,
|
|
363
357
|
key: t
|
|
364
358
|
}) => ({
|
|
@@ -366,23 +360,23 @@ const vt = (e) => ({
|
|
|
366
360
|
removeItem: async (r) => {
|
|
367
361
|
const n = await e.getItem(t), { [r]: s, ...c } = (
|
|
368
362
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
369
|
-
|
|
363
|
+
q(n) ?? {}
|
|
370
364
|
);
|
|
371
365
|
await e.setItem(t, c);
|
|
372
366
|
},
|
|
373
367
|
getItem: async (r) => {
|
|
374
|
-
const n = await e.getItem(t), s =
|
|
368
|
+
const n = await e.getItem(t), s = q(n) ?? {};
|
|
375
369
|
if (r in s)
|
|
376
370
|
return s[r];
|
|
377
371
|
},
|
|
378
372
|
setItem: async (r, n) => {
|
|
379
|
-
const s = await e.getItem(t), c =
|
|
373
|
+
const s = await e.getItem(t), c = q(s) ?? {};
|
|
380
374
|
await e.setItem(t, { ...c, [r]: n });
|
|
381
375
|
}
|
|
382
|
-
}),
|
|
376
|
+
}), Ue = ({
|
|
383
377
|
key: e
|
|
384
|
-
} = {}) => e ?
|
|
385
|
-
adapter:
|
|
378
|
+
} = {}) => e ? Ye({
|
|
379
|
+
adapter: Ue(),
|
|
386
380
|
key: e
|
|
387
381
|
}) : {
|
|
388
382
|
clear: async () => {
|
|
@@ -400,7 +394,7 @@ const vt = (e) => ({
|
|
|
400
394
|
localStorage.setItem(t, JSON.stringify(r));
|
|
401
395
|
}
|
|
402
396
|
};
|
|
403
|
-
function
|
|
397
|
+
function Ge(e, t) {
|
|
404
398
|
if (e == null || t === void 0 || typeof e != "object" || typeof t != "object")
|
|
405
399
|
return e === t;
|
|
406
400
|
if (e.constructor !== (t == null ? void 0 : t.constructor))
|
|
@@ -413,10 +407,10 @@ function Ue(e, t) {
|
|
|
413
407
|
return !1;
|
|
414
408
|
return !0;
|
|
415
409
|
}
|
|
416
|
-
const V = "__reactjrx",
|
|
410
|
+
const V = "__reactjrx", We = (e) => {
|
|
417
411
|
if (typeof e == "object" && e !== null && V in e && e[V] === V)
|
|
418
412
|
return e;
|
|
419
|
-
},
|
|
413
|
+
}, Xe = ({
|
|
420
414
|
adapter: e,
|
|
421
415
|
config: t
|
|
422
416
|
}) => {
|
|
@@ -431,58 +425,58 @@ const V = "__reactjrx", Ge = (e) => {
|
|
|
431
425
|
c,
|
|
432
426
|
`for signal ${r.config.key}`
|
|
433
427
|
), x(e.setItem(r.config.key, c)).pipe(
|
|
434
|
-
|
|
428
|
+
$((u) => (console.error(u), p(null)))
|
|
435
429
|
);
|
|
436
430
|
};
|
|
437
|
-
function
|
|
431
|
+
function Ze({
|
|
438
432
|
adapter: e,
|
|
439
433
|
config: t
|
|
440
434
|
}) {
|
|
441
435
|
const { hydrate: r = ({ value: c }) => c, signal: n, version: s } = t;
|
|
442
436
|
return x(e.getItem(n.config.key)).pipe(
|
|
443
|
-
|
|
444
|
-
const u =
|
|
437
|
+
C((c) => {
|
|
438
|
+
const u = We(c);
|
|
445
439
|
if (!u) return p(c);
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
440
|
+
const l = typeof u.migrationVersion != "number", a = u.migrationVersion !== void 0 && s > u.migrationVersion;
|
|
441
|
+
if (l || a || u.value === void 0)
|
|
448
442
|
return p(c);
|
|
449
|
-
const
|
|
443
|
+
const o = u.value;
|
|
450
444
|
return process.env.NODE_ENV === "development" && console.log(
|
|
451
445
|
"[reactjrx][state][persistance]:",
|
|
452
446
|
"Hydrate value",
|
|
453
447
|
u,
|
|
454
448
|
`for signal ${n.config.key}`
|
|
455
|
-
), n.setValue(r({ value:
|
|
449
|
+
), n.setValue(r({ value: o, version: s })), p(c);
|
|
456
450
|
})
|
|
457
451
|
);
|
|
458
452
|
}
|
|
459
|
-
function
|
|
453
|
+
function Be({
|
|
460
454
|
entries: e = [],
|
|
461
455
|
onHydrated: t,
|
|
462
456
|
adapter: r
|
|
463
457
|
}) {
|
|
464
458
|
const s = (e.length === 0 ? p([]) : we(
|
|
465
459
|
...e.map(
|
|
466
|
-
(u) =>
|
|
460
|
+
(u) => Ze({
|
|
467
461
|
adapter: r,
|
|
468
462
|
config: u
|
|
469
463
|
})
|
|
470
464
|
)
|
|
471
465
|
)).pipe(
|
|
472
466
|
re(t),
|
|
473
|
-
|
|
467
|
+
$((u) => (console.error("Unable to hydrate", u), T)),
|
|
474
468
|
ne()
|
|
475
469
|
), c = s.pipe(
|
|
476
|
-
|
|
477
|
-
() =>
|
|
470
|
+
C(
|
|
471
|
+
() => M(
|
|
478
472
|
...e.map(
|
|
479
473
|
(u) => u.signal.pipe(
|
|
480
474
|
Ee(500, Ve, {
|
|
481
475
|
trailing: !0
|
|
482
476
|
}),
|
|
483
|
-
|
|
477
|
+
C(
|
|
484
478
|
() => x(
|
|
485
|
-
|
|
479
|
+
Xe({
|
|
486
480
|
adapter: r,
|
|
487
481
|
config: u
|
|
488
482
|
})
|
|
@@ -493,53 +487,53 @@ function Ze({
|
|
|
493
487
|
)
|
|
494
488
|
)
|
|
495
489
|
);
|
|
496
|
-
return
|
|
490
|
+
return M(
|
|
497
491
|
s.pipe(
|
|
498
|
-
|
|
492
|
+
N(() => ({
|
|
499
493
|
type: "hydrated"
|
|
500
494
|
}))
|
|
501
495
|
),
|
|
502
496
|
c.pipe(
|
|
503
|
-
|
|
497
|
+
N(() => ({
|
|
504
498
|
type: "persisted"
|
|
505
499
|
}))
|
|
506
500
|
)
|
|
507
501
|
);
|
|
508
502
|
}
|
|
509
|
-
function
|
|
503
|
+
function It({
|
|
510
504
|
entries: e = [],
|
|
511
505
|
onHydrated: t,
|
|
512
506
|
adapter: r
|
|
513
507
|
}) {
|
|
514
|
-
const n =
|
|
508
|
+
const n = v(t), s = U(r), c = U(e);
|
|
515
509
|
return k(
|
|
516
510
|
() => s.pipe(
|
|
517
|
-
|
|
511
|
+
C((l) => l ? M(
|
|
518
512
|
p({ type: "reset" }),
|
|
519
513
|
c.pipe(
|
|
520
514
|
xe(
|
|
521
|
-
(
|
|
522
|
-
adapter:
|
|
523
|
-
entries:
|
|
515
|
+
(a) => Be({
|
|
516
|
+
adapter: l,
|
|
517
|
+
entries: a,
|
|
524
518
|
onHydrated: () => {
|
|
525
|
-
var
|
|
526
|
-
(
|
|
519
|
+
var o;
|
|
520
|
+
(o = n.current) == null || o.call(n);
|
|
527
521
|
}
|
|
528
522
|
})
|
|
529
523
|
)
|
|
530
524
|
)
|
|
531
525
|
) : p({ type: "reset" }))
|
|
532
526
|
).pipe(
|
|
533
|
-
|
|
534
|
-
(
|
|
527
|
+
Fe(
|
|
528
|
+
(l, a) => a.type === "reset" ? { isHydrated: !1 } : a.type === "hydrated" ? { isHydrated: !0 } : l,
|
|
535
529
|
{ isHydrated: !1 }
|
|
536
530
|
)
|
|
537
531
|
),
|
|
538
|
-
{ defaultValue: { isHydrated: !1 }, compareFn:
|
|
532
|
+
{ defaultValue: { isHydrated: !1 }, compareFn: Ge },
|
|
539
533
|
[s, c]
|
|
540
534
|
);
|
|
541
535
|
}
|
|
542
|
-
class
|
|
536
|
+
class et {
|
|
543
537
|
constructor() {
|
|
544
538
|
w(this, "queryMap", /* @__PURE__ */ new Map());
|
|
545
539
|
}
|
|
@@ -547,14 +541,14 @@ class Be {
|
|
|
547
541
|
return this.queryMap.get(t);
|
|
548
542
|
}
|
|
549
543
|
setQuery(t, r, n) {
|
|
550
|
-
const s =
|
|
544
|
+
const s = ae(t), c = r.pipe(
|
|
551
545
|
/**
|
|
552
546
|
* abort signal is triggered on:
|
|
553
547
|
* - manual cancellation from user
|
|
554
548
|
* - unmounting the component
|
|
555
549
|
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-cancellation
|
|
556
550
|
*/
|
|
557
|
-
se(
|
|
551
|
+
se(Ce(n, "abort")),
|
|
558
552
|
ne()
|
|
559
553
|
), u = {
|
|
560
554
|
query$: c,
|
|
@@ -564,16 +558,16 @@ class Be {
|
|
|
564
558
|
lastData: void 0
|
|
565
559
|
};
|
|
566
560
|
this.queryMap.set(s, u);
|
|
567
|
-
const
|
|
568
|
-
next: (
|
|
569
|
-
const
|
|
570
|
-
|
|
561
|
+
const l = c.subscribe({
|
|
562
|
+
next: (a) => {
|
|
563
|
+
const o = this.queryMap.get(s);
|
|
564
|
+
o && (o.lastData = { value: a });
|
|
571
565
|
},
|
|
572
566
|
complete: () => {
|
|
573
567
|
this.deleteQuery(s);
|
|
574
568
|
}
|
|
575
569
|
});
|
|
576
|
-
return u.sub =
|
|
570
|
+
return u.sub = l, u;
|
|
577
571
|
}
|
|
578
572
|
deleteQuery(t) {
|
|
579
573
|
const r = this.queryMap.get(t);
|
|
@@ -585,17 +579,17 @@ class Be {
|
|
|
585
579
|
});
|
|
586
580
|
}
|
|
587
581
|
}
|
|
588
|
-
const de = X(void 0),
|
|
582
|
+
const de = X(void 0), wt = Z(
|
|
589
583
|
({
|
|
590
584
|
children: e,
|
|
591
585
|
client: t
|
|
592
586
|
}) => {
|
|
593
|
-
const [r] =
|
|
587
|
+
const [r] = Se(() => t ?? new et());
|
|
594
588
|
return b(() => () => {
|
|
595
589
|
r.destroy();
|
|
596
590
|
}, [r]), /* @__PURE__ */ ce(de.Provider, { value: r, children: e });
|
|
597
591
|
}
|
|
598
|
-
),
|
|
592
|
+
), tt = () => {
|
|
599
593
|
const e = B(de);
|
|
600
594
|
if (!e)
|
|
601
595
|
throw new Error(
|
|
@@ -603,16 +597,16 @@ const de = X(void 0), bt = Z(
|
|
|
603
597
|
);
|
|
604
598
|
return e;
|
|
605
599
|
};
|
|
606
|
-
function
|
|
607
|
-
const r =
|
|
600
|
+
function Et(e, t) {
|
|
601
|
+
const r = oe(t), n = tt();
|
|
608
602
|
return Qe(
|
|
609
603
|
{
|
|
610
604
|
...e,
|
|
611
|
-
queryFn: (u) => new Promise((
|
|
612
|
-
const
|
|
605
|
+
queryFn: (u) => new Promise((l, a) => {
|
|
606
|
+
const o = () => Q(
|
|
613
607
|
() => typeof e.queryFn == "function" ? e.queryFn(u) : e.queryFn
|
|
614
|
-
), f =
|
|
615
|
-
|
|
608
|
+
), f = ae(u.queryKey), i = n.getQuery(f) ?? n.setQuery(u.queryKey, o(), u.signal);
|
|
609
|
+
i.query$.pipe(
|
|
616
610
|
ue(1),
|
|
617
611
|
/**
|
|
618
612
|
* If several values are emitted during this delay, we will only
|
|
@@ -621,17 +615,17 @@ function It(e, t) {
|
|
|
621
615
|
*/
|
|
622
616
|
$e(1)
|
|
623
617
|
).subscribe({
|
|
624
|
-
error: (g) =>
|
|
618
|
+
error: (g) => a(g),
|
|
625
619
|
complete: () => {
|
|
626
|
-
if ((
|
|
627
|
-
return
|
|
620
|
+
if ((i == null ? void 0 : i.lastData) === void 0)
|
|
621
|
+
return i.signal.aborted || (console.log(
|
|
628
622
|
`cancelled due to stream completing without data for query ${f}`,
|
|
629
|
-
|
|
623
|
+
i == null ? void 0 : i.lastData
|
|
630
624
|
), r.cancelQueries({
|
|
631
625
|
queryKey: u.queryKey,
|
|
632
626
|
exact: !0
|
|
633
|
-
})),
|
|
634
|
-
i
|
|
627
|
+
})), l(void 0);
|
|
628
|
+
l(i.lastData.value), (i == null ? void 0 : i.isCompleted) === !1 && setTimeout(() => {
|
|
635
629
|
r == null || r.refetchQueries({
|
|
636
630
|
queryKey: u.queryKey,
|
|
637
631
|
exact: !0
|
|
@@ -654,10 +648,10 @@ function me(e, t) {
|
|
|
654
648
|
}), n = Te(
|
|
655
649
|
{
|
|
656
650
|
...e,
|
|
657
|
-
mutationFn: (
|
|
651
|
+
mutationFn: (o) => {
|
|
658
652
|
let f;
|
|
659
|
-
return new Promise((
|
|
660
|
-
(typeof e.mutationFn == "function" ? e.mutationFn(
|
|
653
|
+
return new Promise((i, m) => {
|
|
654
|
+
(typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(ue(1)).subscribe({
|
|
661
655
|
next: (d) => {
|
|
662
656
|
f = { value: d };
|
|
663
657
|
},
|
|
@@ -667,128 +661,133 @@ function me(e, t) {
|
|
|
667
661
|
complete: () => {
|
|
668
662
|
if (f === void 0)
|
|
669
663
|
return m(new Error("Stream completed without any data"));
|
|
670
|
-
|
|
664
|
+
i(f.value);
|
|
671
665
|
}
|
|
672
666
|
});
|
|
673
667
|
});
|
|
674
668
|
}
|
|
675
669
|
},
|
|
676
670
|
t
|
|
677
|
-
), { status: s, isPending: c, isError: u, isSuccess:
|
|
671
|
+
), { status: s, isPending: c, isError: u, isSuccess: l, isIdle: a } = n;
|
|
678
672
|
return b(() => {
|
|
679
673
|
r.next({
|
|
680
674
|
status: s,
|
|
681
675
|
isPending: c,
|
|
682
676
|
isError: u,
|
|
683
|
-
isSuccess:
|
|
684
|
-
isIdle:
|
|
677
|
+
isSuccess: l,
|
|
678
|
+
isIdle: a
|
|
685
679
|
});
|
|
686
|
-
}, [s, c, u,
|
|
680
|
+
}, [s, c, u, l, a, r]), { ...n, state$: r };
|
|
687
681
|
}
|
|
688
|
-
function
|
|
682
|
+
function Vt(e, t) {
|
|
689
683
|
const [r, n] = ke(), { mutate: s, mutateAsync: c, ...u } = me(
|
|
690
684
|
{
|
|
691
685
|
...e,
|
|
692
|
-
mutationFn: (
|
|
686
|
+
mutationFn: (o) => (typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(se(r), Me(null))
|
|
693
687
|
},
|
|
694
688
|
t
|
|
695
|
-
),
|
|
696
|
-
(
|
|
689
|
+
), l = h(
|
|
690
|
+
(o) => (n(), s(o)),
|
|
697
691
|
[s, n]
|
|
698
|
-
),
|
|
699
|
-
(
|
|
692
|
+
), a = h(
|
|
693
|
+
(o) => (n(), c(o)),
|
|
700
694
|
[c, n]
|
|
701
695
|
);
|
|
702
|
-
return { ...u, mutate:
|
|
696
|
+
return { ...u, mutate: l, mutateAsync: a };
|
|
703
697
|
}
|
|
704
|
-
function
|
|
705
|
-
const r =
|
|
698
|
+
function xt(e, t) {
|
|
699
|
+
const r = oe(t), n = e.mutationKey, { mutateAsync: s, ...c } = me(
|
|
706
700
|
{
|
|
707
701
|
...e,
|
|
708
|
-
onMutate({ variables:
|
|
709
|
-
var
|
|
710
|
-
return (
|
|
702
|
+
onMutate({ variables: a }) {
|
|
703
|
+
var o;
|
|
704
|
+
return (o = e.onMutate) == null ? void 0 : o.call(e, a);
|
|
711
705
|
},
|
|
712
|
-
onSuccess(
|
|
713
|
-
var
|
|
714
|
-
return (
|
|
706
|
+
onSuccess(a, o, f) {
|
|
707
|
+
var i;
|
|
708
|
+
return (i = e.onSuccess) == null ? void 0 : i.call(e, a, o.variables, f);
|
|
715
709
|
},
|
|
716
|
-
onError(
|
|
717
|
-
var
|
|
718
|
-
return (
|
|
710
|
+
onError(a, o, f) {
|
|
711
|
+
var i;
|
|
712
|
+
return (i = e.onError) == null ? void 0 : i.call(e, a, o.variables, f);
|
|
719
713
|
},
|
|
720
|
-
onSettled(
|
|
714
|
+
onSettled(a, o, f, i) {
|
|
721
715
|
var m;
|
|
722
|
-
return (m = e.onSettled) == null ? void 0 : m.call(e,
|
|
716
|
+
return (m = e.onSettled) == null ? void 0 : m.call(e, a, o, f.variables, i);
|
|
723
717
|
},
|
|
724
|
-
mutationFn: ({ ready$:
|
|
725
|
-
const f = typeof e.mutationFn == "function" ? e.mutationFn(
|
|
726
|
-
return
|
|
727
|
-
Ne((
|
|
718
|
+
mutationFn: ({ ready$: a, variables: o }) => {
|
|
719
|
+
const f = typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn;
|
|
720
|
+
return a.pipe(
|
|
721
|
+
Ne((i) => i),
|
|
728
722
|
Pe(),
|
|
729
|
-
|
|
723
|
+
C(() => f)
|
|
730
724
|
);
|
|
731
725
|
}
|
|
732
726
|
},
|
|
733
727
|
t
|
|
734
728
|
), u = h(
|
|
735
|
-
async (
|
|
736
|
-
const
|
|
729
|
+
async (a) => {
|
|
730
|
+
const o = r.getMutationCache().findAll({
|
|
737
731
|
mutationKey: n,
|
|
738
732
|
exact: !0
|
|
739
|
-
}), f = new
|
|
733
|
+
}), f = new F(!1), i = s({ variables: a, ready$: f });
|
|
740
734
|
return await Promise.all(
|
|
741
|
-
|
|
742
|
-
), f.next(!0), await
|
|
735
|
+
o.map((m) => m.continue().catch(L))
|
|
736
|
+
), f.next(!0), await i.finally(() => {
|
|
743
737
|
f.complete();
|
|
744
738
|
});
|
|
745
739
|
},
|
|
746
740
|
[s, r, n]
|
|
747
|
-
),
|
|
748
|
-
(
|
|
749
|
-
u(
|
|
741
|
+
), l = h(
|
|
742
|
+
(a) => {
|
|
743
|
+
u(a).catch(L);
|
|
750
744
|
},
|
|
751
745
|
[u]
|
|
752
746
|
);
|
|
753
|
-
return { ...c, mutate:
|
|
747
|
+
return { ...c, mutate: l, mutateAsync: u };
|
|
754
748
|
}
|
|
755
749
|
export {
|
|
756
750
|
de as Context,
|
|
757
|
-
|
|
758
|
-
|
|
751
|
+
et as QueryClient$,
|
|
752
|
+
wt as QueryClientProvider$,
|
|
759
753
|
_e as SIGNAL_RESET,
|
|
760
754
|
le as Signal,
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
755
|
+
St as SignalContextProvider,
|
|
756
|
+
fe as SignalReactContext,
|
|
757
|
+
A as VirtualSignal,
|
|
758
|
+
gt as arrayEqual,
|
|
759
|
+
Ue as createLocalStorageAdapter,
|
|
760
|
+
bt as createLocalforageAdapter,
|
|
765
761
|
Ke as exponentialBackoffDelay,
|
|
766
762
|
He as getDelay,
|
|
767
|
-
|
|
763
|
+
pt as isDefined,
|
|
768
764
|
Y as isPromiseLike,
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
765
|
+
ht as isServer,
|
|
766
|
+
mt as retryBackoff,
|
|
767
|
+
lt as signal,
|
|
772
768
|
j as useBehaviorSubject,
|
|
773
|
-
|
|
769
|
+
xt as useContactMutation$,
|
|
774
770
|
je as useEffectOnce,
|
|
775
771
|
U as useLiveBehaviorSubject,
|
|
776
|
-
|
|
777
|
-
|
|
772
|
+
v as useLiveRef,
|
|
773
|
+
ze as useMakeOrRetrieveSignal,
|
|
774
|
+
dt as useMount,
|
|
778
775
|
me as useMutation$,
|
|
779
776
|
ke as useObservableCallback,
|
|
780
777
|
ot as useObservableState,
|
|
781
778
|
k as useObserve,
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
779
|
+
It as usePersistSignals,
|
|
780
|
+
Et as useQuery$,
|
|
781
|
+
tt as useQueryClient$,
|
|
782
|
+
Je as useSetSignal,
|
|
783
|
+
vt as useSignal,
|
|
784
|
+
ye as useSignalContext,
|
|
785
|
+
Le as useSignalValue,
|
|
787
786
|
ie as useSubject,
|
|
788
787
|
De as useSubscribe,
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
788
|
+
it as useSubscribeEffect,
|
|
789
|
+
Vt as useSwitchMutation$,
|
|
790
|
+
yt as useUnmountObservable,
|
|
791
|
+
ft as virtualSignal
|
|
793
792
|
};
|
|
794
793
|
//# sourceMappingURL=index.js.map
|