reactjrx 1.128.2 → 1.129.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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +277 -256
- package/dist/index.js.map +1 -1
- package/dist/lib/utils/index.d.ts +1 -5
- package/dist/lib/utils/react/index.d.ts +9 -0
- package/dist/lib/utils/react/useDebounced.d.ts +8 -0
- package/dist/lib/utils/react/useMemoCompare.d.ts +1 -0
- package/dist/lib/utils/react/useUnmount.d.ts +1 -0
- package/package.json +1 -1
- /package/dist/lib/{utils/react → binding}/useUnmountObservable.d.ts +0 -0
- /package/dist/lib/{utils/react → binding}/useUnmountObservable.test.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { BehaviorSubject as
|
|
1
|
+
import { useRef as w, useEffect as I, useMemo as _, useCallback as S, useSyncExternalStore as ve, useState as D, createContext as B, memo as ee, useContext as te } from "react";
|
|
2
|
+
import { BehaviorSubject as C, isObservable as L, from as M, of as b, defer as k, map as $, distinctUntilChanged as re, shareReplay as Ie, startWith as we, identity as ne, tap as H, catchError as R, EMPTY as K, retry as Ee, ReplaySubject as Y, takeUntil as Ce, fromEvent as se, share as ue, take as oe, noop as U, filter as xe, first as ce, switchMap as V, delay as Me, merge as F, ignoreElements as Ve, defaultIfEmpty as Fe, zip as Re, throttleTime as $e, asyncScheduler as qe, concatMap as Ne, scan as Ae, throwError as A, timer as Pe } from "rxjs";
|
|
3
3
|
import { jsx as ae } from "react/jsx-runtime";
|
|
4
|
-
import { hashKey as ie, useMutation as
|
|
5
|
-
import { catchError as
|
|
6
|
-
const
|
|
7
|
-
const t =
|
|
4
|
+
import { hashKey as ie, useMutation as Oe, useQueryClient as le, useQuery as Te } from "@tanstack/react-query";
|
|
5
|
+
import { catchError as G, mergeMap as P, retryWhen as Qe, concatMap as _e, first as De, tap as ke } from "rxjs/operators";
|
|
6
|
+
const j = (e) => {
|
|
7
|
+
const t = w(void 0);
|
|
8
8
|
return t.current || (t.current = e()), I(() => {
|
|
9
9
|
process.env.NODE_ENV;
|
|
10
10
|
}, []), t;
|
|
11
|
-
},
|
|
12
|
-
const t =
|
|
11
|
+
}, q = (e) => j(e).current, W = (e) => {
|
|
12
|
+
const t = q(() => new C(e));
|
|
13
13
|
return I(() => {
|
|
14
14
|
t.next(e);
|
|
15
15
|
}, [e, t]), t;
|
|
16
16
|
}, v = (e) => {
|
|
17
|
-
const t =
|
|
18
|
-
return
|
|
17
|
+
const t = w(e);
|
|
18
|
+
return _(() => {
|
|
19
19
|
t.current = e;
|
|
20
20
|
}, [e]), t;
|
|
21
|
-
},
|
|
22
|
-
const t =
|
|
23
|
-
(
|
|
24
|
-
t.next(
|
|
21
|
+
}, at = (e) => {
|
|
22
|
+
const t = q(() => new C(e)), r = v(t), n = S(
|
|
23
|
+
(s) => {
|
|
24
|
+
t.next(s);
|
|
25
25
|
},
|
|
26
26
|
[t]
|
|
27
27
|
);
|
|
28
28
|
return [r.current, n, t.getValue()];
|
|
29
29
|
};
|
|
30
|
-
function
|
|
30
|
+
function He(e, t) {
|
|
31
31
|
return t.reduce(
|
|
32
32
|
(r, n) => n in e ? { ...r, [n]: e[n] } : r,
|
|
33
33
|
{}
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function X(e) {
|
|
37
37
|
return e instanceof Promise || e && typeof e == "object" && "then" in e && typeof e.then == "function" && "catch" in e && e.catch === "function";
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
if (
|
|
41
|
-
if (
|
|
39
|
+
function z(e) {
|
|
40
|
+
if (L(e)) return () => e;
|
|
41
|
+
if (X(e)) return () => M(e);
|
|
42
42
|
if (typeof e != "function") return () => b(e);
|
|
43
43
|
const t = e;
|
|
44
|
-
return (r) =>
|
|
44
|
+
return (r) => k(() => {
|
|
45
45
|
const n = t(r);
|
|
46
|
-
return
|
|
46
|
+
return X(n) ? M(n) : L(n) ? n : b(n);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
function fe(e, t) {
|
|
@@ -54,8 +54,8 @@ function fe(e, t) {
|
|
|
54
54
|
const r = Object.keys(e), n = Object.keys(t);
|
|
55
55
|
if (r.length !== n.length)
|
|
56
56
|
return !1;
|
|
57
|
-
for (const
|
|
58
|
-
if (!t.hasOwnProperty(
|
|
57
|
+
for (const s of r)
|
|
58
|
+
if (!t.hasOwnProperty(s) || e[s] !== t[s])
|
|
59
59
|
return !1;
|
|
60
60
|
return !0;
|
|
61
61
|
}
|
|
@@ -64,22 +64,22 @@ function ye(e, t, r) {
|
|
|
64
64
|
defaultValue: void 0,
|
|
65
65
|
unsubscribeOnUnmount: !0,
|
|
66
66
|
compareFn: void 0
|
|
67
|
-
},
|
|
67
|
+
}, s = !r && Array.isArray(t) ? t : typeof e == "function" ? r ?? [] : [e], c = w(void 0), o = v(e), l = v(n), u = typeof e != "function" && Array.isArray(t) ? JSON.stringify(t) : void 0, i = v(
|
|
68
68
|
typeof e != "function" && Array.isArray(t) ? t : void 0
|
|
69
|
-
), a =
|
|
69
|
+
), a = _(() => {
|
|
70
70
|
const p = i.current, f = l.current.compareFn, m = f || (p ? fe : void 0);
|
|
71
71
|
return {
|
|
72
|
-
observable:
|
|
72
|
+
observable: z(o.current)().pipe(
|
|
73
73
|
// Maybe selector
|
|
74
|
-
$((h) => p && typeof h == "object" && h !== null ?
|
|
74
|
+
$((h) => p && typeof h == "object" && h !== null ? He(h, p) : h),
|
|
75
75
|
// Maybe compareFn
|
|
76
|
-
re((h,
|
|
77
|
-
|
|
76
|
+
re((h, N) => h === void 0 || N === void 0 ? !1 : m ? m(h, N) : h === N),
|
|
77
|
+
Ie({ refCount: !0, bufferSize: 1 })
|
|
78
78
|
),
|
|
79
79
|
subscribed: !1,
|
|
80
80
|
snapshotSub: void 0
|
|
81
81
|
};
|
|
82
|
-
}, [...
|
|
82
|
+
}, [...s, u, i, o, l]), y = S(() => {
|
|
83
83
|
if (!a.subscribed) {
|
|
84
84
|
a.subscribed = !0;
|
|
85
85
|
const p = a.observable.subscribe((f) => {
|
|
@@ -92,11 +92,11 @@ function ye(e, t, r) {
|
|
|
92
92
|
(p) => {
|
|
93
93
|
a.subscribed = !0;
|
|
94
94
|
const f = a.observable.pipe(
|
|
95
|
-
l.current.defaultValue ?
|
|
96
|
-
|
|
95
|
+
l.current.defaultValue ? we(l.current.defaultValue) : ne,
|
|
96
|
+
H((m) => {
|
|
97
97
|
c.current = { value: m };
|
|
98
98
|
}),
|
|
99
|
-
|
|
99
|
+
R((m) => (console.error(m), K))
|
|
100
100
|
).subscribe(p);
|
|
101
101
|
return a.snapshotSub?.unsubscribe(), () => {
|
|
102
102
|
l.current.unsubscribeOnUnmount !== !1 && f.unsubscribe();
|
|
@@ -104,49 +104,55 @@ function ye(e, t, r) {
|
|
|
104
104
|
},
|
|
105
105
|
[a]
|
|
106
106
|
);
|
|
107
|
-
return
|
|
107
|
+
return ve(d, y, y);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function Ke(e, t = []) {
|
|
110
110
|
const r = v(e);
|
|
111
111
|
I(() => {
|
|
112
|
-
const n =
|
|
113
|
-
|
|
112
|
+
const n = z(r.current)().pipe(
|
|
113
|
+
R((s) => (console.error(s), K))
|
|
114
114
|
).subscribe();
|
|
115
115
|
return () => {
|
|
116
116
|
n.unsubscribe();
|
|
117
117
|
};
|
|
118
118
|
}, [...t, r]);
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
const n = t != null && !Array.isArray(t) ? t : {},
|
|
122
|
-
n.onError ?? ((
|
|
123
|
-
console.error(
|
|
120
|
+
function it(e, t, r = []) {
|
|
121
|
+
const n = t != null && !Array.isArray(t) ? t : {}, s = n.retry ?? !0, c = v(
|
|
122
|
+
n.onError ?? ((u) => {
|
|
123
|
+
console.error(u);
|
|
124
124
|
})
|
|
125
|
-
), o = S(() =>
|
|
125
|
+
), o = S(() => z(e)(), r), l = S(
|
|
126
126
|
() => o().pipe(
|
|
127
|
-
|
|
128
|
-
throw c.current(
|
|
127
|
+
R((u) => {
|
|
128
|
+
throw c.current(u), u;
|
|
129
129
|
}),
|
|
130
|
-
|
|
130
|
+
s ? Ee() : ne
|
|
131
131
|
),
|
|
132
|
-
[o,
|
|
132
|
+
[o, s, c]
|
|
133
133
|
);
|
|
134
|
-
|
|
134
|
+
Ke(l, r);
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
const lt = () => {
|
|
137
|
+
const e = j(() => new Y(1)), [t, r] = D(!1);
|
|
138
|
+
return t && (e.current = new Y(1), r(!1)), I(() => () => {
|
|
139
|
+
e.current.next(void 0), r(!0);
|
|
140
|
+
}, [e]), e.current;
|
|
141
|
+
};
|
|
142
|
+
class je {
|
|
137
143
|
queryMap = /* @__PURE__ */ new Map();
|
|
138
144
|
getQuery(t) {
|
|
139
145
|
return this.queryMap.get(t);
|
|
140
146
|
}
|
|
141
147
|
setQuery(t, r, n) {
|
|
142
|
-
const
|
|
148
|
+
const s = ie(t), c = r.pipe(
|
|
143
149
|
/**
|
|
144
150
|
* abort signal is triggered on:
|
|
145
151
|
* - manual cancellation from user
|
|
146
152
|
* - unmounting the component
|
|
147
153
|
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-cancellation
|
|
148
154
|
*/
|
|
149
|
-
|
|
155
|
+
Ce(se(n, "abort")),
|
|
150
156
|
ue()
|
|
151
157
|
), o = {
|
|
152
158
|
query$: c,
|
|
@@ -155,14 +161,14 @@ class Ke {
|
|
|
155
161
|
isCompleted: !1,
|
|
156
162
|
lastData: void 0
|
|
157
163
|
};
|
|
158
|
-
this.queryMap.set(
|
|
164
|
+
this.queryMap.set(s, o);
|
|
159
165
|
const l = c.subscribe({
|
|
160
|
-
next: (
|
|
161
|
-
const i = this.queryMap.get(
|
|
162
|
-
i && (i.lastData = { value:
|
|
166
|
+
next: (u) => {
|
|
167
|
+
const i = this.queryMap.get(s);
|
|
168
|
+
i && (i.lastData = { value: u });
|
|
163
169
|
},
|
|
164
170
|
complete: () => {
|
|
165
|
-
this.deleteQuery(
|
|
171
|
+
this.deleteQuery(s);
|
|
166
172
|
}
|
|
167
173
|
});
|
|
168
174
|
return o.sub = l, o;
|
|
@@ -177,17 +183,17 @@ class Ke {
|
|
|
177
183
|
});
|
|
178
184
|
}
|
|
179
185
|
}
|
|
180
|
-
const de = B(void 0),
|
|
186
|
+
const de = B(void 0), ft = ee(
|
|
181
187
|
({
|
|
182
188
|
children: e,
|
|
183
189
|
client: t
|
|
184
190
|
}) => {
|
|
185
|
-
const [r] =
|
|
191
|
+
const [r] = D(() => t ?? new je());
|
|
186
192
|
return I(() => () => {
|
|
187
193
|
r.destroy();
|
|
188
194
|
}, [r]), /* @__PURE__ */ ae(de.Provider, { value: r, children: e });
|
|
189
195
|
}
|
|
190
|
-
),
|
|
196
|
+
), ze = () => {
|
|
191
197
|
const e = te(de);
|
|
192
198
|
if (!e)
|
|
193
199
|
throw new Error(
|
|
@@ -196,15 +202,15 @@ const de = B(void 0), it = ee(
|
|
|
196
202
|
return e;
|
|
197
203
|
};
|
|
198
204
|
function me(e, t) {
|
|
199
|
-
const r =
|
|
200
|
-
() => new
|
|
205
|
+
const r = q(
|
|
206
|
+
() => new C({
|
|
201
207
|
status: "idle",
|
|
202
208
|
isPending: !1,
|
|
203
209
|
isError: !1,
|
|
204
210
|
isSuccess: !1,
|
|
205
211
|
isIdle: !0
|
|
206
212
|
})
|
|
207
|
-
), n =
|
|
213
|
+
), n = Oe(
|
|
208
214
|
{
|
|
209
215
|
...e,
|
|
210
216
|
mutationFn: (i) => {
|
|
@@ -227,71 +233,71 @@ function me(e, t) {
|
|
|
227
233
|
}
|
|
228
234
|
},
|
|
229
235
|
t
|
|
230
|
-
), { status:
|
|
236
|
+
), { status: s, isPending: c, isError: o, isSuccess: l, isIdle: u } = n;
|
|
231
237
|
return I(() => {
|
|
232
238
|
r.next({
|
|
233
|
-
status:
|
|
239
|
+
status: s,
|
|
234
240
|
isPending: c,
|
|
235
241
|
isError: o,
|
|
236
242
|
isSuccess: l,
|
|
237
|
-
isIdle:
|
|
243
|
+
isIdle: u
|
|
238
244
|
});
|
|
239
|
-
}, [
|
|
245
|
+
}, [s, c, o, l, u, r]), { ...n, state$: r };
|
|
240
246
|
}
|
|
241
|
-
function
|
|
242
|
-
const r = le(t), n = e.mutationKey, { mutateAsync:
|
|
247
|
+
function yt(e, t) {
|
|
248
|
+
const r = le(t), n = e.mutationKey, { mutateAsync: s, ...c } = me(
|
|
243
249
|
{
|
|
244
250
|
...e,
|
|
245
|
-
onMutate({ variables:
|
|
246
|
-
return e.onMutate?.(
|
|
251
|
+
onMutate({ variables: u }, ...i) {
|
|
252
|
+
return e.onMutate?.(u, ...i);
|
|
247
253
|
},
|
|
248
|
-
onSuccess(
|
|
249
|
-
return e.onSuccess?.(
|
|
254
|
+
onSuccess(u, { variables: i }, ...a) {
|
|
255
|
+
return e.onSuccess?.(u, i, ...a);
|
|
250
256
|
},
|
|
251
|
-
onError(
|
|
252
|
-
return e.onError?.(
|
|
257
|
+
onError(u, { variables: i }, ...a) {
|
|
258
|
+
return e.onError?.(u, i, ...a);
|
|
253
259
|
},
|
|
254
|
-
onSettled(
|
|
255
|
-
return e.onSettled?.(
|
|
260
|
+
onSettled(u, i, { variables: a }, ...y) {
|
|
261
|
+
return e.onSettled?.(u, i, a, ...y);
|
|
256
262
|
},
|
|
257
|
-
mutationFn: ({ ready$:
|
|
263
|
+
mutationFn: ({ ready$: u, variables: i }) => {
|
|
258
264
|
const a = typeof e.mutationFn == "function" ? e.mutationFn(i) : e.mutationFn;
|
|
259
|
-
return
|
|
260
|
-
|
|
265
|
+
return u.pipe(
|
|
266
|
+
xe((y) => y),
|
|
261
267
|
ce(),
|
|
262
|
-
|
|
268
|
+
V(() => a)
|
|
263
269
|
);
|
|
264
270
|
}
|
|
265
271
|
},
|
|
266
272
|
t
|
|
267
273
|
), o = S(
|
|
268
|
-
async (
|
|
274
|
+
async (u) => {
|
|
269
275
|
const i = r.getMutationCache().findAll({
|
|
270
276
|
mutationKey: n,
|
|
271
277
|
exact: !0
|
|
272
|
-
}), a = new
|
|
278
|
+
}), a = new C(!1), y = s({ variables: u, ready$: a });
|
|
273
279
|
return await Promise.all(
|
|
274
|
-
i.map((d) => d.continue().catch(
|
|
280
|
+
i.map((d) => d.continue().catch(U))
|
|
275
281
|
), a.next(!0), await y.finally(() => {
|
|
276
282
|
a.complete();
|
|
277
283
|
});
|
|
278
284
|
},
|
|
279
|
-
[
|
|
285
|
+
[s, r, n]
|
|
280
286
|
), l = S(
|
|
281
|
-
(
|
|
282
|
-
o(
|
|
287
|
+
(u) => {
|
|
288
|
+
o(u).catch(U);
|
|
283
289
|
},
|
|
284
290
|
[o]
|
|
285
291
|
);
|
|
286
292
|
return { ...c, mutate: l, mutateAsync: o };
|
|
287
293
|
}
|
|
288
|
-
function
|
|
289
|
-
const r = le(t), n =
|
|
290
|
-
return
|
|
294
|
+
function dt(e, t) {
|
|
295
|
+
const r = le(t), n = ze();
|
|
296
|
+
return Te(
|
|
291
297
|
{
|
|
292
298
|
...e,
|
|
293
|
-
queryFn: (o) => new Promise((l,
|
|
294
|
-
const i = () =>
|
|
299
|
+
queryFn: (o) => new Promise((l, u) => {
|
|
300
|
+
const i = () => k(
|
|
295
301
|
() => typeof e.queryFn == "function" ? e.queryFn(o) : e.queryFn
|
|
296
302
|
), a = ie(o.queryKey), y = n.getQuery(a), d = y ?? n.setQuery(o.queryKey, i(), o.signal), g = () => {
|
|
297
303
|
d?.isCompleted === !1 && setTimeout(() => {
|
|
@@ -312,9 +318,9 @@ function ft(e, t) {
|
|
|
312
318
|
* keep the last value. This is unfortunate but it's the best we can do
|
|
313
319
|
* for now.
|
|
314
320
|
*/
|
|
315
|
-
|
|
321
|
+
Me(1)
|
|
316
322
|
).subscribe({
|
|
317
|
-
error: (f) =>
|
|
323
|
+
error: (f) => u(f),
|
|
318
324
|
complete: () => {
|
|
319
325
|
if (d?.lastData === void 0)
|
|
320
326
|
return d.signal.aborted || (console.log(
|
|
@@ -332,51 +338,51 @@ function ft(e, t) {
|
|
|
332
338
|
t
|
|
333
339
|
);
|
|
334
340
|
}
|
|
335
|
-
class
|
|
341
|
+
class Z extends Error {
|
|
336
342
|
constructor(t = "Mutation canceled") {
|
|
337
343
|
super(t), this.name = "SwitchMutationCancelError";
|
|
338
344
|
}
|
|
339
345
|
}
|
|
340
|
-
function
|
|
341
|
-
const r =
|
|
346
|
+
function mt(e, t) {
|
|
347
|
+
const r = w(new AbortController()), { mutate: n, mutateAsync: s, ...c } = me(
|
|
342
348
|
{
|
|
343
349
|
...e,
|
|
344
|
-
mutationFn: ({ variables:
|
|
350
|
+
mutationFn: ({ variables: u, abort: i }) => {
|
|
345
351
|
if (i.aborted)
|
|
346
|
-
throw new
|
|
347
|
-
const a = typeof e.mutationFn == "function" ? e.mutationFn(
|
|
348
|
-
return
|
|
352
|
+
throw new Z();
|
|
353
|
+
const a = typeof e.mutationFn == "function" ? e.mutationFn(u) : e.mutationFn;
|
|
354
|
+
return F(
|
|
349
355
|
a,
|
|
350
356
|
se(i, "abort").pipe(
|
|
351
|
-
|
|
352
|
-
throw new
|
|
357
|
+
H(() => {
|
|
358
|
+
throw new Z();
|
|
353
359
|
}),
|
|
354
|
-
|
|
360
|
+
Ve()
|
|
355
361
|
)
|
|
356
|
-
).pipe(ce(),
|
|
362
|
+
).pipe(ce(), Fe(null));
|
|
357
363
|
},
|
|
358
|
-
onMutate: ({ variables:
|
|
359
|
-
onSuccess: (
|
|
360
|
-
onError: (
|
|
361
|
-
onSettled: (
|
|
364
|
+
onMutate: ({ variables: u }, ...i) => e.onMutate?.(u, ...i),
|
|
365
|
+
onSuccess: (u, { variables: i }, ...a) => e.onSuccess?.(u, i, ...a),
|
|
366
|
+
onError: (u, { variables: i }, ...a) => e.onError?.(u, i, ...a),
|
|
367
|
+
onSettled: (u, i, { variables: a }, ...y) => e.onSettled?.(u, i, a, ...y)
|
|
362
368
|
},
|
|
363
369
|
t
|
|
364
370
|
), o = S(
|
|
365
|
-
(
|
|
366
|
-
variables:
|
|
371
|
+
(u) => (r.current.abort(), r.current = new AbortController(), n({
|
|
372
|
+
variables: u,
|
|
367
373
|
abort: r.current.signal
|
|
368
374
|
})),
|
|
369
375
|
[n]
|
|
370
376
|
), l = S(
|
|
371
|
-
(
|
|
372
|
-
variables:
|
|
377
|
+
(u) => (r.current.abort(), r.current = new AbortController(), s({
|
|
378
|
+
variables: u,
|
|
373
379
|
abort: r.current.signal
|
|
374
380
|
})),
|
|
375
|
-
[
|
|
381
|
+
[s]
|
|
376
382
|
);
|
|
377
383
|
return { ...c, mutate: o, mutateAsync: l };
|
|
378
384
|
}
|
|
379
|
-
const
|
|
385
|
+
const Je = Symbol("SIGNAL_RESET"), pt = (e) => ({
|
|
380
386
|
getItem: async (t) => {
|
|
381
387
|
const r = await e.getItem(t);
|
|
382
388
|
if (r)
|
|
@@ -392,31 +398,31 @@ const ze = Symbol("SIGNAL_RESET"), dt = (e) => ({
|
|
|
392
398
|
}), O = (e) => {
|
|
393
399
|
if (!(!e || typeof e != "object"))
|
|
394
400
|
return e;
|
|
395
|
-
},
|
|
401
|
+
}, Le = ({
|
|
396
402
|
adapter: e,
|
|
397
403
|
key: t
|
|
398
404
|
}) => ({
|
|
399
405
|
clear: async () => await e.removeItem(t),
|
|
400
406
|
removeItem: async (r) => {
|
|
401
|
-
const n = await e.getItem(t), { [r]:
|
|
407
|
+
const n = await e.getItem(t), { [r]: s, ...c } = (
|
|
402
408
|
// biome-ignore lint/suspicious/noExplicitAny: TODO
|
|
403
409
|
O(n) ?? {}
|
|
404
410
|
);
|
|
405
411
|
await e.setItem(t, c);
|
|
406
412
|
},
|
|
407
413
|
getItem: async (r) => {
|
|
408
|
-
const n = await e.getItem(t),
|
|
409
|
-
if (r in
|
|
410
|
-
return
|
|
414
|
+
const n = await e.getItem(t), s = O(n) ?? {};
|
|
415
|
+
if (r in s)
|
|
416
|
+
return s[r];
|
|
411
417
|
},
|
|
412
418
|
setItem: async (r, n) => {
|
|
413
|
-
const
|
|
419
|
+
const s = await e.getItem(t), c = O(s) ?? {};
|
|
414
420
|
await e.setItem(t, { ...c, [r]: n });
|
|
415
421
|
}
|
|
416
|
-
}),
|
|
422
|
+
}), Ye = ({
|
|
417
423
|
key: e
|
|
418
|
-
} = {}) => e ?
|
|
419
|
-
adapter:
|
|
424
|
+
} = {}) => e ? Le({
|
|
425
|
+
adapter: Ye(),
|
|
420
426
|
key: e
|
|
421
427
|
}) : {
|
|
422
428
|
clear: async () => {
|
|
@@ -434,12 +440,12 @@ const ze = Symbol("SIGNAL_RESET"), dt = (e) => ({
|
|
|
434
440
|
localStorage.setItem(t, JSON.stringify(r));
|
|
435
441
|
}
|
|
436
442
|
};
|
|
437
|
-
class pe extends
|
|
443
|
+
class pe extends C {
|
|
438
444
|
constructor(t) {
|
|
439
445
|
super(t.default), this.config = t;
|
|
440
446
|
}
|
|
441
447
|
update = (t) => {
|
|
442
|
-
if (t ===
|
|
448
|
+
if (t === Je)
|
|
443
449
|
super.next(this.config.default);
|
|
444
450
|
else if (typeof t == "function") {
|
|
445
451
|
const r = t;
|
|
@@ -461,29 +467,29 @@ class pe extends E {
|
|
|
461
467
|
return this.config.key;
|
|
462
468
|
}
|
|
463
469
|
}
|
|
464
|
-
class
|
|
470
|
+
class T {
|
|
465
471
|
constructor(t) {
|
|
466
472
|
this.config = t;
|
|
467
473
|
}
|
|
468
474
|
}
|
|
469
|
-
function
|
|
475
|
+
function bt(e = {}) {
|
|
470
476
|
return new pe({
|
|
471
477
|
key: void 0,
|
|
472
478
|
...e,
|
|
473
479
|
default: e.default ?? void 0
|
|
474
480
|
});
|
|
475
481
|
}
|
|
476
|
-
function
|
|
477
|
-
return new
|
|
482
|
+
function gt(e) {
|
|
483
|
+
return new T(e);
|
|
478
484
|
}
|
|
479
|
-
class
|
|
485
|
+
class Q {
|
|
480
486
|
/**
|
|
481
487
|
* items only get added as they are created. The only time we should cleanup
|
|
482
488
|
* are on context destroy. This is to ensure later re-use of virtual signals
|
|
483
489
|
* return the same persisted state.
|
|
484
490
|
*/
|
|
485
491
|
// biome-ignore lint/suspicious/noExplicitAny: TODO
|
|
486
|
-
signals = new
|
|
492
|
+
signals = new C(/* @__PURE__ */ new Map());
|
|
487
493
|
isDestroyed = !1;
|
|
488
494
|
getOrCreateSignal(t) {
|
|
489
495
|
const r = this.signals.value.get(t);
|
|
@@ -499,31 +505,31 @@ class T {
|
|
|
499
505
|
}
|
|
500
506
|
}
|
|
501
507
|
const be = B(
|
|
502
|
-
new
|
|
503
|
-
),
|
|
508
|
+
new Q()
|
|
509
|
+
), ht = ee(
|
|
504
510
|
({ children: e }) => {
|
|
505
|
-
const t =
|
|
506
|
-
() => new
|
|
507
|
-
), r = t.current, [n,
|
|
508
|
-
n && (t.current = new
|
|
511
|
+
const t = j(
|
|
512
|
+
() => new Q()
|
|
513
|
+
), r = t.current, [n, s] = D(!1);
|
|
514
|
+
n && (t.current = new Q(), s(!1));
|
|
509
515
|
const c = r;
|
|
510
516
|
return I(() => () => {
|
|
511
|
-
t.current?.destroy(),
|
|
517
|
+
t.current?.destroy(), s(!0);
|
|
512
518
|
}, [t]), /* @__PURE__ */ ae(be.Provider, { value: c, children: e });
|
|
513
519
|
}
|
|
514
|
-
), ge = () => te(be),
|
|
520
|
+
), ge = () => te(be), Ue = (e) => {
|
|
515
521
|
const t = ge();
|
|
516
522
|
return e ? t.getOrCreateSignal(e) : void 0;
|
|
517
|
-
},
|
|
518
|
-
if (typeof e == "object" && e !== null &&
|
|
523
|
+
}, x = "__reactjrx", Ge = (e) => {
|
|
524
|
+
if (typeof e == "object" && e !== null && x in e && e[x] === x)
|
|
519
525
|
return e;
|
|
520
|
-
},
|
|
526
|
+
}, We = ({
|
|
521
527
|
adapter: e,
|
|
522
528
|
config: t
|
|
523
529
|
}) => {
|
|
524
530
|
const { signal: r, version: n } = t, c = {
|
|
525
531
|
value: r.getValue(),
|
|
526
|
-
[
|
|
532
|
+
[x]: x,
|
|
527
533
|
migrationVersion: n
|
|
528
534
|
};
|
|
529
535
|
return process.env.NODE_ENV === "development" && console.log(
|
|
@@ -531,21 +537,21 @@ const be = B(
|
|
|
531
537
|
"Persist value",
|
|
532
538
|
c,
|
|
533
539
|
`for signal ${r.config.key}`
|
|
534
|
-
),
|
|
535
|
-
|
|
540
|
+
), M(e.setItem(r.config.key, c)).pipe(
|
|
541
|
+
R((o) => (console.error(o), b(null)))
|
|
536
542
|
);
|
|
537
543
|
};
|
|
538
|
-
function
|
|
544
|
+
function Xe({
|
|
539
545
|
adapter: e,
|
|
540
546
|
config: t
|
|
541
547
|
}) {
|
|
542
|
-
const { hydrate: r = ({ value: c }) => c, signal: n, version:
|
|
543
|
-
return
|
|
544
|
-
|
|
545
|
-
const o =
|
|
548
|
+
const { hydrate: r = ({ value: c }) => c, signal: n, version: s } = t;
|
|
549
|
+
return M(e.getItem(n.config.key)).pipe(
|
|
550
|
+
V((c) => {
|
|
551
|
+
const o = Ge(c);
|
|
546
552
|
if (!o) return b(c);
|
|
547
|
-
const l = typeof o.migrationVersion != "number",
|
|
548
|
-
if (l ||
|
|
553
|
+
const l = typeof o.migrationVersion != "number", u = o.migrationVersion !== void 0 && s > o.migrationVersion;
|
|
554
|
+
if (l || u || o.value === void 0)
|
|
549
555
|
return b(c);
|
|
550
556
|
const i = o.value;
|
|
551
557
|
return process.env.NODE_ENV === "development" && console.log(
|
|
@@ -553,37 +559,37 @@ function We({
|
|
|
553
559
|
"Hydrate value",
|
|
554
560
|
o,
|
|
555
561
|
`for signal ${n.config.key}`
|
|
556
|
-
), n.setValue(r({ value: i, version:
|
|
562
|
+
), n.setValue(r({ value: i, version: s })), b(c);
|
|
557
563
|
})
|
|
558
564
|
);
|
|
559
565
|
}
|
|
560
|
-
function
|
|
566
|
+
function Ze({
|
|
561
567
|
entries: e = [],
|
|
562
568
|
onHydrated: t,
|
|
563
569
|
adapter: r
|
|
564
570
|
}) {
|
|
565
|
-
const
|
|
571
|
+
const s = (e.length === 0 ? b([]) : Re(
|
|
566
572
|
...e.map(
|
|
567
|
-
(o) =>
|
|
573
|
+
(o) => Xe({
|
|
568
574
|
adapter: r,
|
|
569
575
|
config: o
|
|
570
576
|
})
|
|
571
577
|
)
|
|
572
578
|
)).pipe(
|
|
573
|
-
|
|
574
|
-
|
|
579
|
+
H(t),
|
|
580
|
+
R((o) => (console.error("Unable to hydrate", o), K)),
|
|
575
581
|
ue()
|
|
576
|
-
), c =
|
|
577
|
-
|
|
578
|
-
() =>
|
|
582
|
+
), c = s.pipe(
|
|
583
|
+
V(
|
|
584
|
+
() => F(
|
|
579
585
|
...e.map(
|
|
580
586
|
(o) => o.signal.pipe(
|
|
581
587
|
$e(500, qe, {
|
|
582
588
|
trailing: !0
|
|
583
589
|
}),
|
|
584
|
-
|
|
585
|
-
() =>
|
|
586
|
-
|
|
590
|
+
V(
|
|
591
|
+
() => M(
|
|
592
|
+
We({
|
|
587
593
|
adapter: r,
|
|
588
594
|
config: o
|
|
589
595
|
})
|
|
@@ -594,8 +600,8 @@ function Xe({
|
|
|
594
600
|
)
|
|
595
601
|
)
|
|
596
602
|
);
|
|
597
|
-
return
|
|
598
|
-
|
|
603
|
+
return F(
|
|
604
|
+
s.pipe(
|
|
599
605
|
$(() => ({
|
|
600
606
|
type: "hydrated"
|
|
601
607
|
}))
|
|
@@ -607,21 +613,21 @@ function Xe({
|
|
|
607
613
|
)
|
|
608
614
|
);
|
|
609
615
|
}
|
|
610
|
-
function
|
|
616
|
+
function St({
|
|
611
617
|
entries: e = [],
|
|
612
618
|
onHydrated: t,
|
|
613
619
|
adapter: r
|
|
614
620
|
}) {
|
|
615
|
-
const n = v(t),
|
|
621
|
+
const n = v(t), s = W(r), c = W(e);
|
|
616
622
|
return ye(
|
|
617
|
-
() =>
|
|
618
|
-
|
|
623
|
+
() => s.pipe(
|
|
624
|
+
V((l) => l ? F(
|
|
619
625
|
b({ type: "reset" }),
|
|
620
626
|
c.pipe(
|
|
621
627
|
Ne(
|
|
622
|
-
(
|
|
628
|
+
(u) => Ze({
|
|
623
629
|
adapter: l,
|
|
624
|
-
entries:
|
|
630
|
+
entries: u,
|
|
625
631
|
onHydrated: () => {
|
|
626
632
|
n.current?.();
|
|
627
633
|
}
|
|
@@ -630,120 +636,131 @@ function gt({
|
|
|
630
636
|
)
|
|
631
637
|
) : b({ type: "reset" }))
|
|
632
638
|
).pipe(
|
|
633
|
-
|
|
634
|
-
(l,
|
|
639
|
+
Ae(
|
|
640
|
+
(l, u) => u.type === "reset" ? { isHydrated: !1 } : u.type === "hydrated" ? { isHydrated: !0 } : l,
|
|
635
641
|
{ isHydrated: !1 }
|
|
636
642
|
)
|
|
637
643
|
),
|
|
638
644
|
{ defaultValue: { isHydrated: !1 }, compareFn: fe },
|
|
639
|
-
[
|
|
645
|
+
[s, c]
|
|
640
646
|
);
|
|
641
647
|
}
|
|
642
|
-
function
|
|
648
|
+
function J(e) {
|
|
643
649
|
const t = ge();
|
|
644
|
-
if (e instanceof
|
|
650
|
+
if (e instanceof T && !t)
|
|
645
651
|
throw new Error(
|
|
646
652
|
"useSignalValue must be used within a SignalContextProvider"
|
|
647
653
|
);
|
|
648
|
-
return
|
|
649
|
-
e instanceof
|
|
654
|
+
return Ue(
|
|
655
|
+
e instanceof T ? e : void 0
|
|
650
656
|
) ?? e;
|
|
651
657
|
}
|
|
652
|
-
function
|
|
653
|
-
return
|
|
658
|
+
function Be(e) {
|
|
659
|
+
return J(e).update;
|
|
654
660
|
}
|
|
655
|
-
const
|
|
656
|
-
function
|
|
661
|
+
const vt = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]);
|
|
662
|
+
function It(e) {
|
|
657
663
|
return e != null;
|
|
658
664
|
}
|
|
659
|
-
const
|
|
660
|
-
function
|
|
665
|
+
const wt = typeof window > "u" || "Deno" in window;
|
|
666
|
+
function et(e, t) {
|
|
661
667
|
return Math.min(e, t);
|
|
662
668
|
}
|
|
663
|
-
function
|
|
669
|
+
function tt(e, t) {
|
|
664
670
|
return 2 ** e * t;
|
|
665
671
|
}
|
|
666
|
-
function
|
|
672
|
+
function Et(e) {
|
|
667
673
|
const {
|
|
668
674
|
retry: t,
|
|
669
675
|
retryDelay: r,
|
|
670
676
|
retryAfterDelay: n,
|
|
671
|
-
retryAfter:
|
|
677
|
+
retryAfter: s = () => b(!0)
|
|
672
678
|
} = e, c = typeof t != "function" ? t === !1 ? 0 : t === !0 ? Number.POSITIVE_INFINITY : t ?? Number.POSITIVE_INFINITY : Number.POSITIVE_INFINITY, o = typeof t == "function" ? (
|
|
673
679
|
// ? (attempt: number, error: TError) => of(retry(attempt, error))
|
|
674
680
|
t
|
|
675
|
-
) : () => !0, l = typeof r == "number" ? r : 100,
|
|
681
|
+
) : () => !0, l = typeof r == "number" ? r : 100, u = {
|
|
676
682
|
...e
|
|
677
683
|
}, {
|
|
678
684
|
maxInterval: i = Number.POSITIVE_INFINITY,
|
|
679
685
|
resetOnSuccess: a = !1,
|
|
680
|
-
backoffDelay: y =
|
|
681
|
-
} =
|
|
682
|
-
return (d) =>
|
|
686
|
+
backoffDelay: y = tt
|
|
687
|
+
} = u;
|
|
688
|
+
return (d) => k(() => {
|
|
683
689
|
let g = 0;
|
|
684
690
|
const p = (f, m) => f < c ? o(f, m) : !1;
|
|
685
691
|
return d.pipe(
|
|
686
|
-
|
|
692
|
+
G((f) => {
|
|
687
693
|
if (g++, !p(g - 1, f)) throw f;
|
|
688
694
|
const m = e.caughtError?.(g, f);
|
|
689
695
|
if (!m) throw f;
|
|
690
696
|
return m.pipe(
|
|
691
697
|
P(
|
|
692
|
-
(
|
|
693
|
-
b(
|
|
698
|
+
(E) => F(
|
|
699
|
+
b(E),
|
|
694
700
|
A(() => f)
|
|
695
701
|
)
|
|
696
702
|
)
|
|
697
703
|
);
|
|
698
704
|
}),
|
|
699
705
|
Qe((f) => f.pipe(
|
|
700
|
-
|
|
701
|
-
const
|
|
702
|
-
return
|
|
703
|
-
|
|
706
|
+
_e((m) => {
|
|
707
|
+
const E = g - 1;
|
|
708
|
+
return s().pipe(
|
|
709
|
+
De(),
|
|
704
710
|
P(
|
|
705
|
-
() => p(
|
|
706
|
-
|
|
707
|
-
y(
|
|
711
|
+
() => p(E, m) ? Pe(
|
|
712
|
+
et(
|
|
713
|
+
y(E, l),
|
|
708
714
|
i
|
|
709
715
|
)
|
|
710
716
|
).pipe(
|
|
711
|
-
P((h) => n && !n(
|
|
717
|
+
P((h) => n && !n(E, m) ? A(() => m) : b(h))
|
|
712
718
|
) : A(() => m)
|
|
713
719
|
)
|
|
714
720
|
);
|
|
715
721
|
})
|
|
716
722
|
)),
|
|
717
|
-
|
|
723
|
+
G((f) => {
|
|
718
724
|
if (e.catchError)
|
|
719
725
|
return e.catchError(g, f);
|
|
720
726
|
throw f;
|
|
721
727
|
}),
|
|
722
|
-
|
|
728
|
+
ke(() => {
|
|
723
729
|
a && (g = 0);
|
|
724
730
|
})
|
|
725
731
|
);
|
|
726
732
|
});
|
|
727
733
|
}
|
|
728
|
-
const
|
|
734
|
+
const he = (e) => {
|
|
729
735
|
I(e, []);
|
|
730
|
-
},
|
|
731
|
-
|
|
736
|
+
}, rt = (e) => {
|
|
737
|
+
const t = w(e);
|
|
738
|
+
t.current = e, he(() => () => t.current());
|
|
739
|
+
}, Ct = (e, t, r = {}) => {
|
|
740
|
+
const { cancelOnUnmount: n = !1 } = r, s = w(null), c = S(
|
|
741
|
+
(o) => {
|
|
742
|
+
s.current !== null && clearTimeout(s.current), s.current = setTimeout(() => e(o), t);
|
|
743
|
+
},
|
|
744
|
+
[e, t]
|
|
745
|
+
);
|
|
746
|
+
return rt(() => {
|
|
747
|
+
n && s.current && clearTimeout(s.current);
|
|
748
|
+
}), c;
|
|
749
|
+
}, xt = (e, t) => {
|
|
750
|
+
const r = w({ value: e });
|
|
751
|
+
return _(() => t(e, r.current.value) ? r.current.value : (r.current = { value: e }, e), [e, t]);
|
|
752
|
+
}, Mt = (e) => {
|
|
753
|
+
he(() => {
|
|
732
754
|
e();
|
|
733
755
|
});
|
|
734
|
-
}, Et = () => {
|
|
735
|
-
const e = K(() => new Y(1)), [t, r] = _(!1);
|
|
736
|
-
return t && (e.current = new Y(1), r(!1)), I(() => () => {
|
|
737
|
-
e.current.next(void 0), r(!0);
|
|
738
|
-
}, [e]), e.current;
|
|
739
756
|
};
|
|
740
|
-
function
|
|
741
|
-
const r = v(t), n =
|
|
757
|
+
function Se(e, t) {
|
|
758
|
+
const r = v(t), n = J(e);
|
|
742
759
|
return ye(
|
|
743
760
|
() => {
|
|
744
|
-
const
|
|
761
|
+
const s = r.current ?? ((o) => o);
|
|
745
762
|
return n.pipe(
|
|
746
|
-
$(
|
|
763
|
+
$(s),
|
|
747
764
|
re()
|
|
748
765
|
);
|
|
749
766
|
},
|
|
@@ -753,56 +770,60 @@ function he(e, t) {
|
|
|
753
770
|
[n]
|
|
754
771
|
);
|
|
755
772
|
}
|
|
756
|
-
function
|
|
757
|
-
const t =
|
|
773
|
+
function Vt(e) {
|
|
774
|
+
const t = J(e), r = Se(e), n = Be(e);
|
|
758
775
|
return [r, n, t];
|
|
759
776
|
}
|
|
760
|
-
const
|
|
761
|
-
const t =
|
|
762
|
-
return [
|
|
777
|
+
const Ft = (e) => {
|
|
778
|
+
const t = q(e);
|
|
779
|
+
return [Se(t), t];
|
|
763
780
|
};
|
|
764
781
|
export {
|
|
765
782
|
de as Context,
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
783
|
+
je as QueryClient$,
|
|
784
|
+
ft as QueryClientProvider$,
|
|
785
|
+
Je as SIGNAL_RESET,
|
|
769
786
|
pe as Signal,
|
|
770
|
-
|
|
787
|
+
ht as SignalContextProvider,
|
|
771
788
|
be as SignalReactContext,
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
789
|
+
Z as SwitchMutationCancelError,
|
|
790
|
+
T as VirtualSignal,
|
|
791
|
+
vt as arrayEqual,
|
|
792
|
+
Ye as createLocalStorageAdapter,
|
|
793
|
+
pt as createLocalforageAdapter,
|
|
794
|
+
tt as exponentialBackoffDelay,
|
|
795
|
+
et as getDelay,
|
|
796
|
+
It as isDefined,
|
|
797
|
+
X as isPromiseLike,
|
|
798
|
+
wt as isServer,
|
|
799
|
+
Et as retryBackoff,
|
|
800
|
+
bt as signal,
|
|
801
|
+
q as useConstant,
|
|
802
|
+
yt as useContactMutation$,
|
|
803
|
+
Ct as useDebounced,
|
|
804
|
+
he as useEffectOnce,
|
|
805
|
+
W as useLiveBehaviorSubject,
|
|
788
806
|
v as useLiveRef,
|
|
789
|
-
|
|
790
|
-
|
|
807
|
+
Ue as useMakeOrRetrieveSignal,
|
|
808
|
+
xt as useMemoCompare,
|
|
809
|
+
Mt as useMount,
|
|
791
810
|
me as useMutation$,
|
|
792
|
-
|
|
811
|
+
at as useObservableState,
|
|
793
812
|
ye as useObserve,
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
813
|
+
St as usePersistSignals,
|
|
814
|
+
dt as useQuery$,
|
|
815
|
+
ze as useQueryClient$,
|
|
816
|
+
j as useRefOnce,
|
|
817
|
+
Be as useSetSignal,
|
|
818
|
+
Vt as useSignal,
|
|
799
819
|
ge as useSignalContext,
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
820
|
+
Ft as useSignalState,
|
|
821
|
+
Se as useSignalValue,
|
|
822
|
+
Ke as useSubscribe,
|
|
823
|
+
it as useSubscribeEffect,
|
|
824
|
+
mt as useSwitchMutation$,
|
|
825
|
+
rt as useUnmount,
|
|
826
|
+
lt as useUnmountObservable,
|
|
827
|
+
gt as virtualSignal
|
|
807
828
|
};
|
|
808
829
|
//# sourceMappingURL=index.js.map
|