reactjrx 1.112.0 → 1.114.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 +2 -951
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +553 -782
- package/dist/index.js.map +1 -0
- package/dist/lib/binding/useObserve.d.ts +1 -1
- package/dist/lib/binding/useSubject.d.ts +1 -1
- package/dist/lib/queries/QueryClientProvider$.d.ts +1 -1
- package/dist/lib/state/index.d.ts +1 -1
- package/dist/lib/state/persistance/adapters/createLocalStorageAdapter.d.ts +1 -1
- package/dist/lib/state/persistance/helpers.d.ts +3 -3
- package/dist/lib/state/persistance/persistSignals.d.ts +2 -2
- package/dist/lib/state/persistance/types.d.ts +1 -1
- package/dist/lib/state/react/usePersistSignals.d.ts +2 -2
- package/dist/lib/utils/operators/retryBackoff.d.ts +1 -1
- package/dist/tests/utils.d.ts +0 -5
- package/package.json +68 -69
package/dist/index.js
CHANGED
|
@@ -1,457 +1,333 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useRef, useMemo, useCallback, useSyncExternalStore, useEffect, useState, createContext, memo, useContext } from "react";
|
|
5
|
-
import { isObservable, from, of, defer, startWith, identity, distinctUntilChanged, tap, catchError
|
|
6
|
-
import { catchError as
|
|
7
|
-
import { hashKey, useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
useMemo(() => {
|
|
12
|
-
ref.current = value;
|
|
13
|
-
}, [value]);
|
|
14
|
-
return ref;
|
|
15
|
-
};
|
|
16
|
-
function isPromiseLike(value) {
|
|
17
|
-
return value instanceof Promise || value && typeof value === "object" && "then" in value && typeof value.then === "function" && "catch" in value && value.catch === "function";
|
|
1
|
+
var ce = Object.defineProperty;
|
|
2
|
+
var ae = (e, t, r) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var k = (e, t, r) => ae(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { useRef as V, useMemo as oe, useCallback as v, useSyncExternalStore as ie, useEffect as h, useState as L, createContext as le, memo as fe, useContext as ye } from "react";
|
|
5
|
+
import { isObservable as _, from as w, of as p, defer as A, startWith as me, identity as U, distinctUntilChanged as J, tap as Y, catchError as $, EMPTY as Q, Subject as j, BehaviorSubject as N, retry as de, skip as pe, first as G, map as R, switchMap as F, zip as be, share as W, merge as M, throttleTime as ve, asyncScheduler as Se, concatMap as ge, scan as he, throwError as x, timer as Ie, takeUntil as X, fromEvent as Ve, take as Z, delay as Ee, defaultIfEmpty as we, filter as Fe, noop as D } from "rxjs";
|
|
6
|
+
import { catchError as H, mergeMap as q, retryWhen as $e, concatMap as Ne, first as Me, tap as Oe } from "rxjs/operators";
|
|
7
|
+
import { hashKey as B, useQueryClient as ee, useQuery as xe, useMutation as qe } from "@tanstack/react-query";
|
|
8
|
+
import { jsx as Pe } from "react/jsx-runtime";
|
|
9
|
+
function K(e) {
|
|
10
|
+
return e instanceof Promise || e && typeof e == "object" && "then" in e && typeof e.then == "function" && "catch" in e && e.catch === "function";
|
|
18
11
|
}
|
|
19
|
-
function
|
|
20
|
-
if (
|
|
21
|
-
if (
|
|
22
|
-
if (typeof
|
|
23
|
-
const
|
|
24
|
-
return (
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
return from(result);
|
|
28
|
-
}
|
|
29
|
-
if (isObservable(result)) {
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
return of(result);
|
|
12
|
+
function C(e) {
|
|
13
|
+
if (_(e)) return () => e;
|
|
14
|
+
if (K(e)) return () => w(e);
|
|
15
|
+
if (typeof e != "function") return () => p(e);
|
|
16
|
+
const t = e;
|
|
17
|
+
return (r) => A(() => {
|
|
18
|
+
const n = t(r);
|
|
19
|
+
return K(n) ? w(n) : _(n) ? n : p(n);
|
|
33
20
|
});
|
|
34
21
|
}
|
|
35
|
-
|
|
36
|
-
const
|
|
22
|
+
const g = (e) => {
|
|
23
|
+
const t = V(e);
|
|
24
|
+
return oe(() => {
|
|
25
|
+
t.current = e;
|
|
26
|
+
}, [e]), t;
|
|
27
|
+
};
|
|
28
|
+
function te(e, t, r) {
|
|
29
|
+
const n = t != null && !Array.isArray(t) ? t : {
|
|
37
30
|
defaultValue: void 0,
|
|
38
|
-
unsubscribeOnUnmount:
|
|
31
|
+
unsubscribeOnUnmount: !0,
|
|
39
32
|
compareFn: void 0
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const optionsRef = useLiveRef(options);
|
|
47
|
-
const getSnapshot = useCallback(() => {
|
|
48
|
-
return valueRef.current;
|
|
49
|
-
}, []);
|
|
50
|
-
const subscribe = useCallback(
|
|
51
|
-
(next) => {
|
|
52
|
-
const source = sourceRef.current;
|
|
53
|
-
const sub = makeObservable(source)().pipe(
|
|
54
|
-
optionsRef.current.defaultValue ? startWith(optionsRef.current.defaultValue) : identity,
|
|
33
|
+
}, s = !r && Array.isArray(t) ? t : typeof e == "function" ? r ?? [] : [e], a = V(
|
|
34
|
+
"getValue" in e && typeof e.getValue == "function" ? e.getValue() : n.defaultValue
|
|
35
|
+
), u = g(e), i = g(n), c = v(() => a.current, []), o = v(
|
|
36
|
+
(l) => {
|
|
37
|
+
const d = u.current, b = C(d)().pipe(
|
|
38
|
+
i.current.defaultValue ? me(i.current.defaultValue) : U,
|
|
55
39
|
/**
|
|
56
40
|
* @important there is already a Object.is comparison in place from react
|
|
57
41
|
* so we only add a custom compareFn if provided
|
|
58
42
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}) : identity,
|
|
63
|
-
tap((value) => {
|
|
64
|
-
valueRef.current = value;
|
|
43
|
+
J((m, y) => i.current.compareFn ? m === void 0 || y === void 0 ? !1 : i.current.compareFn(m, y) : !1),
|
|
44
|
+
Y((m) => {
|
|
45
|
+
a.current = m;
|
|
65
46
|
}),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return EMPTY;
|
|
69
|
-
})
|
|
70
|
-
).subscribe(next);
|
|
47
|
+
$((m) => (console.error(m), Q))
|
|
48
|
+
).subscribe(l);
|
|
71
49
|
return () => {
|
|
72
|
-
|
|
73
|
-
sub.unsubscribe();
|
|
50
|
+
i.current.unsubscribeOnUnmount !== !1 && b.unsubscribe();
|
|
74
51
|
};
|
|
75
52
|
},
|
|
76
|
-
|
|
77
|
-
[...deps]
|
|
53
|
+
[...s]
|
|
78
54
|
);
|
|
79
|
-
|
|
80
|
-
return result;
|
|
55
|
+
return ie(o, c);
|
|
81
56
|
}
|
|
82
|
-
function
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
console.error(error);
|
|
88
|
-
return EMPTY;
|
|
89
|
-
})
|
|
57
|
+
function Re(e, t = []) {
|
|
58
|
+
const r = g(e);
|
|
59
|
+
h(() => {
|
|
60
|
+
const n = C(r.current)().pipe(
|
|
61
|
+
$((s) => (console.error(s), Q))
|
|
90
62
|
).subscribe();
|
|
91
63
|
return () => {
|
|
92
|
-
|
|
64
|
+
n.unsubscribe();
|
|
93
65
|
};
|
|
94
|
-
}, [
|
|
95
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
-
...deps,
|
|
97
|
-
sourceRef
|
|
98
|
-
]);
|
|
66
|
+
}, [...t, r]);
|
|
99
67
|
}
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return ref;
|
|
109
|
-
};
|
|
110
|
-
const useSubject = ({
|
|
111
|
-
onBeforeComplete,
|
|
112
|
-
completeOnUnmount = true
|
|
68
|
+
const re = (e) => {
|
|
69
|
+
const t = V(void 0);
|
|
70
|
+
return t.current || (t.current = e()), h(() => {
|
|
71
|
+
process.env.NODE_ENV;
|
|
72
|
+
}, []), t;
|
|
73
|
+
}, ne = ({
|
|
74
|
+
onBeforeComplete: e,
|
|
75
|
+
completeOnUnmount: t = !0
|
|
113
76
|
} = {}) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (completed.current) {
|
|
120
|
-
subject.current = new Subject();
|
|
121
|
-
completed.current = false;
|
|
122
|
-
}
|
|
123
|
-
return () => {
|
|
124
|
-
if (!completeOnUnmountRef.current) {
|
|
125
|
-
completed.current = true;
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (!completed.current) {
|
|
129
|
-
if (onBeforeCompleteRef.current != null) onBeforeCompleteRef.current();
|
|
130
|
-
subject.current.complete();
|
|
131
|
-
completed.current = true;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
}, [completeOnUnmountRef, onBeforeCompleteRef, subject]);
|
|
135
|
-
return subject;
|
|
136
|
-
};
|
|
137
|
-
const useObservableCallback = () => {
|
|
138
|
-
const subject = useSubject();
|
|
139
|
-
const trigger = useCallback(
|
|
140
|
-
(arg) => {
|
|
141
|
-
subject.current.next(arg);
|
|
142
|
-
},
|
|
143
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
144
|
-
[]
|
|
145
|
-
);
|
|
146
|
-
return [subject.current, trigger];
|
|
147
|
-
};
|
|
148
|
-
const useBehaviorSubject = (state) => {
|
|
149
|
-
const subject = useConstant(() => new BehaviorSubject(state));
|
|
150
|
-
const completed = useRef(false);
|
|
151
|
-
const stateRef = useRef(state);
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
if (completed.current) {
|
|
154
|
-
subject.current = new BehaviorSubject(stateRef.current);
|
|
155
|
-
completed.current = false;
|
|
77
|
+
const r = re(() => new j()), n = V(!1), s = g(e), a = g(t);
|
|
78
|
+
return h(() => (n.current && (r.current = new j(), n.current = !1), () => {
|
|
79
|
+
if (!a.current) {
|
|
80
|
+
n.current = !0;
|
|
81
|
+
return;
|
|
156
82
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
83
|
+
n.current || (s.current != null && s.current(), r.current.complete(), n.current = !0);
|
|
84
|
+
}), [a, s, r]), r;
|
|
85
|
+
}, Ae = () => {
|
|
86
|
+
const e = ne(), t = v((r) => {
|
|
87
|
+
e.current.next(r);
|
|
88
|
+
}, []);
|
|
89
|
+
return [e.current, t];
|
|
90
|
+
}, T = (e) => {
|
|
91
|
+
const t = re(() => new N(e)), r = V(!1), n = V(e);
|
|
92
|
+
return h(() => (r.current && (t.current = new N(n.current), r.current = !1), () => {
|
|
93
|
+
r.current || (t.current.complete(), r.current = !0);
|
|
94
|
+
}), [t]), t;
|
|
95
|
+
}, rt = (e) => {
|
|
96
|
+
const t = T(e), r = g(t.current.asObservable()), n = v(
|
|
97
|
+
(s) => {
|
|
98
|
+
t.current.next(s);
|
|
172
99
|
},
|
|
173
|
-
|
|
174
|
-
[subject.current]
|
|
100
|
+
[t.current]
|
|
175
101
|
);
|
|
176
|
-
return [
|
|
177
|
-
}
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}, [state, subject]);
|
|
183
|
-
return subject;
|
|
102
|
+
return [r.current, n, t.current.getValue()];
|
|
103
|
+
}, z = (e) => {
|
|
104
|
+
const t = T(e);
|
|
105
|
+
return h(() => {
|
|
106
|
+
t.current.next(e);
|
|
107
|
+
}, [e, t]), t;
|
|
184
108
|
};
|
|
185
|
-
function
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
options.onError ?? ((error) => {
|
|
190
|
-
console.error(error);
|
|
109
|
+
function nt(e, t, r = []) {
|
|
110
|
+
const n = t != null && !Array.isArray(t) ? t : {}, s = n.retry ?? !0, a = g(
|
|
111
|
+
n.onError ?? ((c) => {
|
|
112
|
+
console.error(c);
|
|
191
113
|
})
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
catchError((error) => {
|
|
197
|
-
onErrorRef.current(error);
|
|
198
|
-
throw error;
|
|
114
|
+
), u = v(() => C(e)(), r), i = v(
|
|
115
|
+
() => u().pipe(
|
|
116
|
+
$((c) => {
|
|
117
|
+
throw a.current(c), c;
|
|
199
118
|
}),
|
|
200
|
-
|
|
119
|
+
s ? de() : U
|
|
201
120
|
),
|
|
202
|
-
[
|
|
121
|
+
[u, s, a]
|
|
203
122
|
);
|
|
204
|
-
|
|
123
|
+
Re(i, r);
|
|
205
124
|
}
|
|
206
|
-
const
|
|
207
|
-
function
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
subject.next(value);
|
|
125
|
+
const Qe = Symbol("SIGNAL_RESET");
|
|
126
|
+
function Ce(e = {}) {
|
|
127
|
+
const t = {
|
|
128
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
129
|
+
default: e.default,
|
|
130
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
131
|
+
key: e.key
|
|
132
|
+
}, { default: r } = t, n = new N(r), s = (u) => {
|
|
133
|
+
const i = (c) => {
|
|
134
|
+
"key" in e && console.log(
|
|
135
|
+
"[reactjrx][state][signal]:",
|
|
136
|
+
`Value update for signal ${e.key}`,
|
|
137
|
+
{
|
|
138
|
+
prev: n.getValue(),
|
|
139
|
+
curr: c
|
|
140
|
+
}
|
|
141
|
+
), n.next(c);
|
|
224
142
|
};
|
|
225
|
-
if (typeof
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
return update(change);
|
|
229
|
-
}
|
|
230
|
-
if (arg === SIGNAL_RESET) {
|
|
231
|
-
if (defaultValue === subject.getValue()) return;
|
|
232
|
-
return update(defaultValue ?? void 0);
|
|
143
|
+
if (typeof u == "function") {
|
|
144
|
+
const c = u(n.getValue());
|
|
145
|
+
return c === n.getValue() ? void 0 : i(c);
|
|
233
146
|
}
|
|
234
|
-
if (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return {
|
|
250
|
-
getValue,
|
|
251
|
-
config,
|
|
252
|
-
subject
|
|
147
|
+
if (u === Qe)
|
|
148
|
+
return r === n.getValue() ? void 0 : i(r ?? void 0);
|
|
149
|
+
if (u !== n.getValue())
|
|
150
|
+
return i(u);
|
|
151
|
+
}, a = () => n.getValue();
|
|
152
|
+
if ("get" in e) {
|
|
153
|
+
const u = (c) => (c.subject.pipe(pe(1), G()).subscribe(() => {
|
|
154
|
+
var f;
|
|
155
|
+
const o = (f = e.get) == null ? void 0 : f.call(e, u);
|
|
156
|
+
s(o);
|
|
157
|
+
}), c.getValue()), i = e.get(u);
|
|
158
|
+
return s(i), {
|
|
159
|
+
getValue: a,
|
|
160
|
+
config: e,
|
|
161
|
+
subject: n
|
|
253
162
|
};
|
|
254
163
|
}
|
|
255
164
|
return {
|
|
256
|
-
setValue,
|
|
257
|
-
getValue,
|
|
258
|
-
|
|
259
|
-
|
|
165
|
+
setValue: s,
|
|
166
|
+
getValue: a,
|
|
167
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
168
|
+
config: t,
|
|
169
|
+
subject: n
|
|
260
170
|
};
|
|
261
171
|
}
|
|
262
|
-
function
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const selectedValue = selectorOrDefault(value);
|
|
270
|
-
return selectedValue;
|
|
271
|
-
}),
|
|
272
|
-
distinctUntilChanged()
|
|
273
|
-
);
|
|
274
|
-
return observed$;
|
|
275
|
-
},
|
|
172
|
+
function Te(e, t) {
|
|
173
|
+
const n = t ?? (() => e.getValue());
|
|
174
|
+
return te(
|
|
175
|
+
() => e.subject.pipe(
|
|
176
|
+
R((a) => n(a)),
|
|
177
|
+
J()
|
|
178
|
+
),
|
|
276
179
|
{
|
|
277
|
-
defaultValue:
|
|
180
|
+
defaultValue: n(e.getValue())
|
|
278
181
|
},
|
|
279
182
|
[]
|
|
280
183
|
);
|
|
281
184
|
}
|
|
282
|
-
const
|
|
283
|
-
const [
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
if (!serializedValue) return void 0;
|
|
291
|
-
return JSON.parse(serializedValue);
|
|
185
|
+
const ut = (e) => {
|
|
186
|
+
const [t] = L(() => Ce(e));
|
|
187
|
+
return [Te(t), t];
|
|
188
|
+
}, st = (e) => ({
|
|
189
|
+
getItem: async (t) => {
|
|
190
|
+
const r = await e.getItem(t);
|
|
191
|
+
if (r)
|
|
192
|
+
return JSON.parse(r);
|
|
292
193
|
},
|
|
293
|
-
setItem: async (
|
|
294
|
-
await
|
|
194
|
+
setItem: async (t, r) => {
|
|
195
|
+
await e.setItem(t, JSON.stringify(r));
|
|
295
196
|
},
|
|
296
|
-
|
|
297
|
-
removeItem: async (_) => {
|
|
197
|
+
removeItem: async (t) => {
|
|
298
198
|
},
|
|
299
199
|
clear: async () => {
|
|
300
200
|
}
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
};
|
|
308
|
-
const createSharedStoreAdapter = ({
|
|
309
|
-
adapter,
|
|
310
|
-
key
|
|
201
|
+
}), P = (e) => {
|
|
202
|
+
if (!(!e || typeof e != "object"))
|
|
203
|
+
return e;
|
|
204
|
+
}, ke = ({
|
|
205
|
+
adapter: e,
|
|
206
|
+
key: t
|
|
311
207
|
}) => ({
|
|
208
|
+
clear: async () => await e.removeItem(t),
|
|
209
|
+
removeItem: async (r) => {
|
|
210
|
+
const n = await e.getItem(t), { [r]: s, ...a } = (
|
|
211
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
212
|
+
P(n) ?? {}
|
|
213
|
+
);
|
|
214
|
+
await e.setItem(t, a);
|
|
215
|
+
},
|
|
216
|
+
getItem: async (r) => {
|
|
217
|
+
const n = await e.getItem(t), s = P(n) ?? {};
|
|
218
|
+
if (r in s)
|
|
219
|
+
return s[r];
|
|
220
|
+
},
|
|
221
|
+
setItem: async (r, n) => {
|
|
222
|
+
const s = await e.getItem(t), a = P(s) ?? {};
|
|
223
|
+
await e.setItem(t, { ...a, [r]: n });
|
|
224
|
+
}
|
|
225
|
+
}), _e = ({
|
|
226
|
+
key: e
|
|
227
|
+
} = {}) => e ? ke({
|
|
228
|
+
adapter: _e(),
|
|
229
|
+
key: e
|
|
230
|
+
}) : {
|
|
312
231
|
clear: async () => {
|
|
313
|
-
|
|
232
|
+
localStorage.clear();
|
|
314
233
|
},
|
|
315
|
-
removeItem: async (
|
|
316
|
-
|
|
317
|
-
const { [keyToDelete]: toRemove, ...rest } = normalizeStore(unsafeStore) ?? {};
|
|
318
|
-
await adapter.setItem(key, rest);
|
|
234
|
+
removeItem: async (t) => {
|
|
235
|
+
localStorage.removeItem(t);
|
|
319
236
|
},
|
|
320
|
-
getItem: async (
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return store[itemKey];
|
|
325
|
-
}
|
|
326
|
-
return void 0;
|
|
237
|
+
getItem: async (t) => {
|
|
238
|
+
const r = localStorage.getItem(t);
|
|
239
|
+
if (r)
|
|
240
|
+
return JSON.parse(r);
|
|
327
241
|
},
|
|
328
|
-
setItem: async (
|
|
329
|
-
|
|
330
|
-
const store = normalizeStore(unsafeStore) ?? {};
|
|
331
|
-
await adapter.setItem(key, { ...store, [itemKey]: value });
|
|
242
|
+
setItem: async (t, r) => {
|
|
243
|
+
localStorage.setItem(t, JSON.stringify(r));
|
|
332
244
|
}
|
|
333
|
-
});
|
|
334
|
-
const createLocalStorageAdapter = ({
|
|
335
|
-
key
|
|
336
|
-
} = {}) => {
|
|
337
|
-
if (key) {
|
|
338
|
-
return createSharedStoreAdapter({
|
|
339
|
-
adapter: createLocalStorageAdapter(),
|
|
340
|
-
key
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
return {
|
|
344
|
-
clear: async () => {
|
|
345
|
-
localStorage.clear();
|
|
346
|
-
},
|
|
347
|
-
removeItem: async (key2) => {
|
|
348
|
-
localStorage.removeItem(key2);
|
|
349
|
-
},
|
|
350
|
-
getItem: async (key2) => {
|
|
351
|
-
const serializedValue = localStorage.getItem(key2);
|
|
352
|
-
if (!serializedValue) return void 0;
|
|
353
|
-
return JSON.parse(serializedValue);
|
|
354
|
-
},
|
|
355
|
-
setItem: async (key2, value) => {
|
|
356
|
-
localStorage.setItem(key2, JSON.stringify(value));
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
};
|
|
360
|
-
const IDENTIFIER_PERSISTANCE_KEY = "__reactjrx";
|
|
361
|
-
const getNormalizedPersistanceValue = (unknownValue) => {
|
|
362
|
-
if (typeof unknownValue === "object" && unknownValue !== null && IDENTIFIER_PERSISTANCE_KEY in unknownValue && unknownValue[IDENTIFIER_PERSISTANCE_KEY] === IDENTIFIER_PERSISTANCE_KEY) {
|
|
363
|
-
return unknownValue;
|
|
364
|
-
}
|
|
365
|
-
return void 0;
|
|
366
245
|
};
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
246
|
+
function je(e, t) {
|
|
247
|
+
if (e == null || t === void 0 || typeof e != "object" || typeof t != "object")
|
|
248
|
+
return e === t;
|
|
249
|
+
if (e.constructor !== (t == null ? void 0 : t.constructor))
|
|
250
|
+
return !1;
|
|
251
|
+
const r = Object.keys(e), n = Object.keys(t);
|
|
252
|
+
if (r.length !== n.length)
|
|
253
|
+
return !1;
|
|
254
|
+
for (const s of r)
|
|
255
|
+
if (!t.hasOwnProperty(s) || e[s] !== t[s])
|
|
256
|
+
return !1;
|
|
257
|
+
return !0;
|
|
258
|
+
}
|
|
259
|
+
const E = "__reactjrx", De = (e) => {
|
|
260
|
+
if (typeof e == "object" && e !== null && E in e && e[E] === E)
|
|
261
|
+
return e;
|
|
262
|
+
}, He = ({
|
|
263
|
+
adapter: e,
|
|
264
|
+
config: t
|
|
370
265
|
}) => {
|
|
371
|
-
const { signal:
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
[IDENTIFIER_PERSISTANCE_KEY]: IDENTIFIER_PERSISTANCE_KEY,
|
|
376
|
-
migrationVersion: version
|
|
266
|
+
const { signal: r, version: n } = t, a = {
|
|
267
|
+
value: r.getValue(),
|
|
268
|
+
[E]: E,
|
|
269
|
+
migrationVersion: n
|
|
377
270
|
};
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
)
|
|
385
|
-
}
|
|
386
|
-
return from(adapter.setItem(signal2.config.key, value)).pipe(
|
|
387
|
-
catchError((e) => {
|
|
388
|
-
console.error(e);
|
|
389
|
-
return of(null);
|
|
390
|
-
})
|
|
271
|
+
return process.env.NODE_ENV === "development" && console.log(
|
|
272
|
+
"[reactjrx][state][persistance]:",
|
|
273
|
+
"Persist value",
|
|
274
|
+
a,
|
|
275
|
+
`for signal ${r.config.key}`
|
|
276
|
+
), w(e.setItem(r.config.key, a)).pipe(
|
|
277
|
+
$((u) => (console.error(u), p(null)))
|
|
391
278
|
);
|
|
392
279
|
};
|
|
393
|
-
function
|
|
394
|
-
adapter,
|
|
395
|
-
config
|
|
280
|
+
function Ke({
|
|
281
|
+
adapter: e,
|
|
282
|
+
config: t
|
|
396
283
|
}) {
|
|
397
|
-
const { hydrate = ({ value }) =>
|
|
398
|
-
return
|
|
399
|
-
|
|
400
|
-
const
|
|
401
|
-
if (!
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
normalizedValue,
|
|
413
|
-
`for signal ${signal2.config.key}`
|
|
414
|
-
);
|
|
415
|
-
}
|
|
416
|
-
signal2.setValue(hydrate({ value: correctVersionValue, version }));
|
|
417
|
-
return of(value);
|
|
284
|
+
const { hydrate: r = ({ value: a }) => a, signal: n, version: s } = t;
|
|
285
|
+
return w(e.getItem(n.config.key)).pipe(
|
|
286
|
+
F((a) => {
|
|
287
|
+
const u = De(a);
|
|
288
|
+
if (!u) return p(a);
|
|
289
|
+
const i = typeof u.migrationVersion != "number", c = u.migrationVersion !== void 0 && s > u.migrationVersion;
|
|
290
|
+
if (i || c || u.value === void 0)
|
|
291
|
+
return p(a);
|
|
292
|
+
const o = u.value;
|
|
293
|
+
return process.env.NODE_ENV === "development" && console.log(
|
|
294
|
+
"[reactjrx][state][persistance]:",
|
|
295
|
+
"Hydrate value",
|
|
296
|
+
u,
|
|
297
|
+
`for signal ${n.config.key}`
|
|
298
|
+
), n.setValue(r({ value: o, version: s })), p(a);
|
|
418
299
|
})
|
|
419
300
|
);
|
|
420
301
|
}
|
|
421
|
-
function
|
|
422
|
-
entries = [],
|
|
423
|
-
onHydrated,
|
|
424
|
-
adapter
|
|
302
|
+
function ze({
|
|
303
|
+
entries: e = [],
|
|
304
|
+
onHydrated: t,
|
|
305
|
+
adapter: r
|
|
425
306
|
}) {
|
|
426
|
-
const
|
|
427
|
-
...
|
|
428
|
-
(
|
|
429
|
-
adapter,
|
|
430
|
-
config
|
|
307
|
+
const s = (e.length === 0 ? p([]) : be(
|
|
308
|
+
...e.map(
|
|
309
|
+
(u) => Ke({
|
|
310
|
+
adapter: r,
|
|
311
|
+
config: u
|
|
431
312
|
})
|
|
432
313
|
)
|
|
433
|
-
)
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
() => merge(
|
|
445
|
-
...entries.map(
|
|
446
|
-
(config) => config.signal.subject.pipe(
|
|
447
|
-
throttleTime(500, asyncScheduler, {
|
|
448
|
-
trailing: true
|
|
314
|
+
)).pipe(
|
|
315
|
+
Y(t),
|
|
316
|
+
$((u) => (console.error("Unable to hydrate", u), Q)),
|
|
317
|
+
W()
|
|
318
|
+
), a = s.pipe(
|
|
319
|
+
F(
|
|
320
|
+
() => M(
|
|
321
|
+
...e.map(
|
|
322
|
+
(u) => u.signal.subject.pipe(
|
|
323
|
+
ve(500, Se, {
|
|
324
|
+
trailing: !0
|
|
449
325
|
}),
|
|
450
|
-
|
|
451
|
-
() =>
|
|
452
|
-
|
|
453
|
-
adapter,
|
|
454
|
-
config
|
|
326
|
+
F(
|
|
327
|
+
() => w(
|
|
328
|
+
He({
|
|
329
|
+
adapter: r,
|
|
330
|
+
config: u
|
|
455
331
|
})
|
|
456
332
|
)
|
|
457
333
|
)
|
|
@@ -460,492 +336,387 @@ function persistSignals({
|
|
|
460
336
|
)
|
|
461
337
|
)
|
|
462
338
|
);
|
|
463
|
-
return
|
|
464
|
-
|
|
465
|
-
|
|
339
|
+
return M(
|
|
340
|
+
s.pipe(
|
|
341
|
+
R(() => ({
|
|
466
342
|
type: "hydrated"
|
|
467
343
|
}))
|
|
468
344
|
),
|
|
469
|
-
|
|
470
|
-
|
|
345
|
+
a.pipe(
|
|
346
|
+
R(() => ({
|
|
471
347
|
type: "persisted"
|
|
472
348
|
}))
|
|
473
349
|
)
|
|
474
350
|
);
|
|
475
351
|
}
|
|
476
|
-
function
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
if (typeof objA !== "object" || typeof objB !== "object") {
|
|
481
|
-
return objA === objB;
|
|
482
|
-
}
|
|
483
|
-
if (objA.constructor !== (objB == null ? void 0 : objB.constructor)) {
|
|
484
|
-
return false;
|
|
485
|
-
}
|
|
486
|
-
const keysA = Object.keys(objA);
|
|
487
|
-
const keysB = Object.keys(objB);
|
|
488
|
-
if (keysA.length !== keysB.length) {
|
|
489
|
-
return false;
|
|
490
|
-
}
|
|
491
|
-
for (const key of keysA) {
|
|
492
|
-
if (!objB.hasOwnProperty(key) || objA[key] !== objB[key]) {
|
|
493
|
-
return false;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
return true;
|
|
497
|
-
}
|
|
498
|
-
function usePersistSignals({
|
|
499
|
-
entries = [],
|
|
500
|
-
onHydrated,
|
|
501
|
-
adapter
|
|
352
|
+
function ct({
|
|
353
|
+
entries: e = [],
|
|
354
|
+
onHydrated: t,
|
|
355
|
+
adapter: r
|
|
502
356
|
}) {
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
var _a;
|
|
520
|
-
(_a = onHydratedRef.current) == null ? void 0 : _a.call(onHydratedRef);
|
|
521
|
-
}
|
|
522
|
-
})
|
|
523
|
-
)
|
|
524
|
-
)
|
|
525
|
-
);
|
|
526
|
-
})
|
|
527
|
-
);
|
|
528
|
-
return persistence$.pipe(
|
|
529
|
-
scan(
|
|
530
|
-
(acc, event) => {
|
|
531
|
-
if (event.type === "reset") return { isHydrated: false };
|
|
532
|
-
if (event.type === "hydrated") return { isHydrated: true };
|
|
533
|
-
return acc;
|
|
534
|
-
},
|
|
535
|
-
{ isHydrated: false }
|
|
357
|
+
const n = g(t), s = z(r), a = z(e);
|
|
358
|
+
return te(
|
|
359
|
+
() => s.current.pipe(
|
|
360
|
+
F((i) => i ? M(
|
|
361
|
+
p({ type: "reset" }),
|
|
362
|
+
a.current.pipe(
|
|
363
|
+
ge(
|
|
364
|
+
(c) => ze({
|
|
365
|
+
adapter: i,
|
|
366
|
+
entries: c,
|
|
367
|
+
onHydrated: () => {
|
|
368
|
+
var o;
|
|
369
|
+
(o = n.current) == null || o.call(n);
|
|
370
|
+
}
|
|
371
|
+
})
|
|
372
|
+
)
|
|
536
373
|
)
|
|
537
|
-
)
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
374
|
+
) : p({ type: "reset" }))
|
|
375
|
+
).pipe(
|
|
376
|
+
he(
|
|
377
|
+
(i, c) => c.type === "reset" ? { isHydrated: !1 } : c.type === "hydrated" ? { isHydrated: !0 } : i,
|
|
378
|
+
{ isHydrated: !1 }
|
|
379
|
+
)
|
|
380
|
+
),
|
|
381
|
+
{ defaultValue: { isHydrated: !1 }, compareFn: je },
|
|
382
|
+
[s, a]
|
|
541
383
|
);
|
|
542
384
|
}
|
|
543
|
-
const
|
|
544
|
-
const
|
|
385
|
+
const at = () => {
|
|
386
|
+
const e = ne({
|
|
545
387
|
onBeforeComplete: () => {
|
|
546
|
-
|
|
388
|
+
e.current.next();
|
|
547
389
|
}
|
|
548
390
|
});
|
|
549
|
-
return
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
useEffectOnce(() => {
|
|
556
|
-
fn();
|
|
391
|
+
return e;
|
|
392
|
+
}, Le = (e) => {
|
|
393
|
+
h(e, []);
|
|
394
|
+
}, ot = (e) => {
|
|
395
|
+
Le(() => {
|
|
396
|
+
e();
|
|
557
397
|
});
|
|
558
398
|
};
|
|
559
|
-
function
|
|
560
|
-
return Math.min(
|
|
399
|
+
function Ue(e, t) {
|
|
400
|
+
return Math.min(e, t);
|
|
561
401
|
}
|
|
562
|
-
function
|
|
563
|
-
return
|
|
402
|
+
function Je(e, t) {
|
|
403
|
+
return 2 ** e * t;
|
|
564
404
|
}
|
|
565
|
-
function
|
|
405
|
+
function it(e) {
|
|
566
406
|
const {
|
|
567
|
-
retry:
|
|
568
|
-
retryDelay,
|
|
569
|
-
retryAfterDelay,
|
|
570
|
-
retryAfter = () =>
|
|
571
|
-
} =
|
|
572
|
-
const maxRetries = typeof retry2 !== "function" ? retry2 === false ? 0 : retry2 === true ? Infinity : retry2 ?? Infinity : Infinity;
|
|
573
|
-
const shouldRetry = typeof retry2 === "function" ? (
|
|
407
|
+
retry: t,
|
|
408
|
+
retryDelay: r,
|
|
409
|
+
retryAfterDelay: n,
|
|
410
|
+
retryAfter: s = () => p(!0)
|
|
411
|
+
} = e, a = typeof t != "function" ? t === !1 ? 0 : t === !0 ? Number.POSITIVE_INFINITY : t ?? Number.POSITIVE_INFINITY : Number.POSITIVE_INFINITY, u = typeof t == "function" ? (
|
|
574
412
|
// ? (attempt: number, error: TError) => of(retry(attempt, error))
|
|
575
|
-
|
|
576
|
-
) : () =>
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
mergeMap(
|
|
599
|
-
(source2) => merge(
|
|
600
|
-
of(source2),
|
|
601
|
-
throwError(() => error)
|
|
413
|
+
t
|
|
414
|
+
) : () => !0, i = typeof r == "number" ? r : 100, c = {
|
|
415
|
+
shouldRetry: u,
|
|
416
|
+
...e
|
|
417
|
+
}, {
|
|
418
|
+
maxInterval: o = Number.POSITIVE_INFINITY,
|
|
419
|
+
resetOnSuccess: f = !1,
|
|
420
|
+
backoffDelay: l = Je
|
|
421
|
+
} = c;
|
|
422
|
+
return (d) => A(() => {
|
|
423
|
+
let b = 0;
|
|
424
|
+
const m = (y, S) => y < a ? u(y, S) : !1;
|
|
425
|
+
return d.pipe(
|
|
426
|
+
H((y) => {
|
|
427
|
+
var I;
|
|
428
|
+
if (b++, !m(b - 1, y)) throw y;
|
|
429
|
+
const S = (I = e.caughtError) == null ? void 0 : I.call(e, b, y);
|
|
430
|
+
if (!S) throw y;
|
|
431
|
+
return S.pipe(
|
|
432
|
+
q(
|
|
433
|
+
(O) => M(
|
|
434
|
+
p(O),
|
|
435
|
+
x(() => y)
|
|
602
436
|
)
|
|
603
437
|
)
|
|
604
438
|
);
|
|
605
439
|
}),
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
(
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
)
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
);
|
|
629
|
-
}),
|
|
630
|
-
catchError$1((e) => {
|
|
631
|
-
if (config.catchError) {
|
|
632
|
-
return config.catchError(caughtErrors, e);
|
|
633
|
-
}
|
|
634
|
-
throw e;
|
|
440
|
+
$e((y) => y.pipe(
|
|
441
|
+
Ne((S) => {
|
|
442
|
+
const I = b - 1;
|
|
443
|
+
return s().pipe(
|
|
444
|
+
Me(),
|
|
445
|
+
q(
|
|
446
|
+
() => m(I, S) ? Ie(
|
|
447
|
+
Ue(
|
|
448
|
+
l(I, i),
|
|
449
|
+
o
|
|
450
|
+
)
|
|
451
|
+
).pipe(
|
|
452
|
+
q((O) => n && !n(I, S) ? x(() => S) : p(O))
|
|
453
|
+
) : x(() => S)
|
|
454
|
+
)
|
|
455
|
+
);
|
|
456
|
+
})
|
|
457
|
+
)),
|
|
458
|
+
H((y) => {
|
|
459
|
+
if (e.catchError)
|
|
460
|
+
return e.catchError(b, y);
|
|
461
|
+
throw y;
|
|
635
462
|
}),
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
caughtErrors = 0;
|
|
639
|
-
}
|
|
463
|
+
Oe(() => {
|
|
464
|
+
f && (b = 0);
|
|
640
465
|
})
|
|
641
466
|
);
|
|
642
467
|
});
|
|
643
468
|
}
|
|
644
|
-
function
|
|
645
|
-
return
|
|
469
|
+
function lt(e) {
|
|
470
|
+
return e != null;
|
|
646
471
|
}
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
class QueryClient$ {
|
|
472
|
+
const ft = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]), yt = typeof window > "u" || "Deno" in window;
|
|
473
|
+
class Ye {
|
|
650
474
|
constructor() {
|
|
651
|
-
|
|
475
|
+
k(this, "queryMap", /* @__PURE__ */ new Map());
|
|
652
476
|
}
|
|
653
|
-
getQuery(
|
|
654
|
-
return this.queryMap.get(
|
|
477
|
+
getQuery(t) {
|
|
478
|
+
return this.queryMap.get(t);
|
|
655
479
|
}
|
|
656
|
-
setQuery(
|
|
657
|
-
const
|
|
658
|
-
const sharedQuery$ = query$.pipe(
|
|
480
|
+
setQuery(t, r, n) {
|
|
481
|
+
const s = B(t), a = r.pipe(
|
|
659
482
|
/**
|
|
660
483
|
* abort signal is triggered on:
|
|
661
484
|
* - manual cancellation from user
|
|
662
485
|
* - unmounting the component
|
|
663
486
|
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-cancellation
|
|
664
487
|
*/
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
)
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
signal: signal2,
|
|
488
|
+
X(Ve(n, "abort")),
|
|
489
|
+
W()
|
|
490
|
+
), u = {
|
|
491
|
+
query$: a,
|
|
492
|
+
signal: n,
|
|
671
493
|
sub: void 0,
|
|
672
|
-
isCompleted:
|
|
494
|
+
isCompleted: !1,
|
|
673
495
|
lastData: void 0
|
|
674
496
|
};
|
|
675
|
-
this.queryMap.set(
|
|
676
|
-
const
|
|
677
|
-
next: (
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
entry.lastData = { value: data };
|
|
681
|
-
}
|
|
497
|
+
this.queryMap.set(s, u);
|
|
498
|
+
const i = a.subscribe({
|
|
499
|
+
next: (c) => {
|
|
500
|
+
const o = this.queryMap.get(s);
|
|
501
|
+
o && (o.lastData = { value: c });
|
|
682
502
|
},
|
|
683
503
|
complete: () => {
|
|
684
|
-
this.deleteQuery(
|
|
504
|
+
this.deleteQuery(s);
|
|
685
505
|
}
|
|
686
506
|
});
|
|
687
|
-
|
|
688
|
-
return cacheEntry;
|
|
507
|
+
return u.sub = i, u;
|
|
689
508
|
}
|
|
690
|
-
deleteQuery(
|
|
691
|
-
const
|
|
692
|
-
|
|
693
|
-
if (entry.sub) {
|
|
694
|
-
entry.sub.unsubscribe();
|
|
695
|
-
entry.sub = void 0;
|
|
696
|
-
}
|
|
697
|
-
entry.isCompleted = true;
|
|
698
|
-
this.queryMap.delete(queryHash);
|
|
509
|
+
deleteQuery(t) {
|
|
510
|
+
const r = this.queryMap.get(t);
|
|
511
|
+
r && (r.sub && (r.sub.unsubscribe(), r.sub = void 0), r.isCompleted = !0, this.queryMap.delete(t));
|
|
699
512
|
}
|
|
700
513
|
destroy() {
|
|
701
|
-
this.queryMap.forEach((
|
|
702
|
-
this.deleteQuery(
|
|
514
|
+
this.queryMap.forEach((t, r) => {
|
|
515
|
+
this.deleteQuery(r);
|
|
703
516
|
});
|
|
704
517
|
}
|
|
705
518
|
}
|
|
706
|
-
const
|
|
707
|
-
const QueryClientProvider$ = memo(
|
|
519
|
+
const ue = le(void 0), mt = fe(
|
|
708
520
|
({
|
|
709
|
-
children,
|
|
710
|
-
client:
|
|
521
|
+
children: e,
|
|
522
|
+
client: t
|
|
711
523
|
}) => {
|
|
712
|
-
const [
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
};
|
|
717
|
-
}, [client]);
|
|
718
|
-
return /* @__PURE__ */ jsx(Context.Provider, { value: client, children });
|
|
524
|
+
const [r] = L(() => t ?? new Ye());
|
|
525
|
+
return h(() => () => {
|
|
526
|
+
r.destroy();
|
|
527
|
+
}, [r]), /* @__PURE__ */ Pe(ue.Provider, { value: r, children: e });
|
|
719
528
|
}
|
|
720
|
-
)
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
if (!client) {
|
|
529
|
+
), Ge = () => {
|
|
530
|
+
const e = ye(ue);
|
|
531
|
+
if (!e)
|
|
724
532
|
throw new Error(
|
|
725
533
|
"useReactJrxQueryClient must be used within a ReactJrxQueryProvider"
|
|
726
534
|
);
|
|
727
|
-
|
|
728
|
-
return client;
|
|
535
|
+
return e;
|
|
729
536
|
};
|
|
730
|
-
function
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
_queryClient.cancelQueries({
|
|
763
|
-
queryKey: context.queryKey,
|
|
764
|
-
exact: true
|
|
765
|
-
});
|
|
766
|
-
return resolve(void 0);
|
|
767
|
-
}
|
|
768
|
-
resolve(queryCacheEntry.lastData.value);
|
|
769
|
-
if ((queryCacheEntry == null ? void 0 : queryCacheEntry.isCompleted) === false) {
|
|
770
|
-
setTimeout(() => {
|
|
771
|
-
_queryClient == null ? void 0 : _queryClient.refetchQueries({
|
|
772
|
-
queryKey: context.queryKey,
|
|
773
|
-
exact: true
|
|
537
|
+
function dt(e, t) {
|
|
538
|
+
const r = ee(t), n = Ge();
|
|
539
|
+
return xe(
|
|
540
|
+
{
|
|
541
|
+
...e,
|
|
542
|
+
queryFn: (u) => new Promise((i, c) => {
|
|
543
|
+
const o = () => A(
|
|
544
|
+
() => typeof e.queryFn == "function" ? e.queryFn(u) : e.queryFn
|
|
545
|
+
), f = B(u.queryKey), l = n.getQuery(f) ?? n.setQuery(u.queryKey, o(), u.signal);
|
|
546
|
+
l.query$.pipe(
|
|
547
|
+
Z(1),
|
|
548
|
+
/**
|
|
549
|
+
* If several values are emitted during this delay, we will only
|
|
550
|
+
* keep the last value. This is unfortunate but it's the best we can do
|
|
551
|
+
* for now.
|
|
552
|
+
*/
|
|
553
|
+
Ee(1)
|
|
554
|
+
).subscribe({
|
|
555
|
+
error: (b) => c(b),
|
|
556
|
+
complete: () => {
|
|
557
|
+
if ((l == null ? void 0 : l.lastData) === void 0)
|
|
558
|
+
return l.signal.aborted || (console.log(
|
|
559
|
+
`cancelled due to stream completing without data for query ${f}`,
|
|
560
|
+
l == null ? void 0 : l.lastData
|
|
561
|
+
), r.cancelQueries({
|
|
562
|
+
queryKey: u.queryKey,
|
|
563
|
+
exact: !0
|
|
564
|
+
})), i(void 0);
|
|
565
|
+
i(l.lastData.value), (l == null ? void 0 : l.isCompleted) === !1 && setTimeout(() => {
|
|
566
|
+
r == null || r.refetchQueries({
|
|
567
|
+
queryKey: u.queryKey,
|
|
568
|
+
exact: !0
|
|
774
569
|
});
|
|
775
570
|
});
|
|
776
571
|
}
|
|
777
|
-
}
|
|
778
|
-
})
|
|
779
|
-
});
|
|
780
|
-
};
|
|
781
|
-
const result = useQuery(
|
|
782
|
-
{
|
|
783
|
-
...options,
|
|
784
|
-
queryFn: queryFnAsync
|
|
572
|
+
});
|
|
573
|
+
})
|
|
785
574
|
},
|
|
786
|
-
|
|
575
|
+
t
|
|
787
576
|
);
|
|
788
|
-
return result;
|
|
789
577
|
}
|
|
790
|
-
function
|
|
791
|
-
const
|
|
578
|
+
function se(e, t) {
|
|
579
|
+
const r = T({
|
|
792
580
|
status: "idle",
|
|
793
|
-
isPending:
|
|
794
|
-
isError:
|
|
795
|
-
isSuccess:
|
|
796
|
-
isIdle:
|
|
797
|
-
})
|
|
798
|
-
const result = useMutation(
|
|
581
|
+
isPending: !1,
|
|
582
|
+
isError: !1,
|
|
583
|
+
isSuccess: !1,
|
|
584
|
+
isIdle: !0
|
|
585
|
+
}), n = qe(
|
|
799
586
|
{
|
|
800
|
-
...
|
|
801
|
-
mutationFn: (
|
|
802
|
-
let
|
|
803
|
-
return new Promise((
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
lastData = { value: data };
|
|
587
|
+
...e,
|
|
588
|
+
mutationFn: (o) => {
|
|
589
|
+
let f;
|
|
590
|
+
return new Promise((l, d) => {
|
|
591
|
+
(typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(Z(1)).subscribe({
|
|
592
|
+
next: (m) => {
|
|
593
|
+
f = { value: m };
|
|
808
594
|
},
|
|
809
|
-
error: (
|
|
810
|
-
|
|
595
|
+
error: (m) => {
|
|
596
|
+
d(m);
|
|
811
597
|
},
|
|
812
598
|
complete: () => {
|
|
813
|
-
if (
|
|
814
|
-
return
|
|
815
|
-
|
|
599
|
+
if (f === void 0)
|
|
600
|
+
return d(new Error("Stream completed without any data"));
|
|
601
|
+
l(f.value);
|
|
816
602
|
}
|
|
817
603
|
});
|
|
818
604
|
});
|
|
819
605
|
}
|
|
820
606
|
},
|
|
821
|
-
|
|
822
|
-
);
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
607
|
+
t
|
|
608
|
+
), { status: s, isPending: a, isError: u, isSuccess: i, isIdle: c } = n;
|
|
609
|
+
return h(() => {
|
|
610
|
+
r.current.next({
|
|
611
|
+
status: s,
|
|
612
|
+
isPending: a,
|
|
613
|
+
isError: u,
|
|
614
|
+
isSuccess: i,
|
|
615
|
+
isIdle: c
|
|
616
|
+
});
|
|
617
|
+
}, [s, a, u, i, c, r]), { ...n, state$: r.current };
|
|
828
618
|
}
|
|
829
|
-
function
|
|
830
|
-
const [
|
|
831
|
-
const { mutate, mutateAsync, ...rest } = useMutation$(
|
|
619
|
+
function pt(e, t) {
|
|
620
|
+
const [r, n] = Ae(), { mutate: s, mutateAsync: a, ...u } = se(
|
|
832
621
|
{
|
|
833
|
-
...
|
|
834
|
-
mutationFn: (
|
|
835
|
-
const source = typeof options.mutationFn === "function" ? options.mutationFn(variables) : options.mutationFn;
|
|
836
|
-
return source.pipe(takeUntil(cancel$), defaultIfEmpty(null));
|
|
837
|
-
}
|
|
622
|
+
...e,
|
|
623
|
+
mutationFn: (o) => (typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(X(r), we(null))
|
|
838
624
|
},
|
|
839
|
-
|
|
625
|
+
t
|
|
626
|
+
), i = v(
|
|
627
|
+
(o) => (n(), s(o)),
|
|
628
|
+
[s, n]
|
|
629
|
+
), c = v(
|
|
630
|
+
(o) => (n(), a(o)),
|
|
631
|
+
[a, n]
|
|
840
632
|
);
|
|
841
|
-
|
|
842
|
-
(variables) => {
|
|
843
|
-
cancel();
|
|
844
|
-
return mutate(variables);
|
|
845
|
-
},
|
|
846
|
-
[mutate, cancel]
|
|
847
|
-
);
|
|
848
|
-
const mutateAsyncSwitch = useCallback(
|
|
849
|
-
(variables) => {
|
|
850
|
-
cancel();
|
|
851
|
-
return mutateAsync(variables);
|
|
852
|
-
},
|
|
853
|
-
[mutateAsync, cancel]
|
|
854
|
-
);
|
|
855
|
-
return { ...rest, mutate: mutateSwitch, mutateAsync: mutateAsyncSwitch };
|
|
633
|
+
return { ...u, mutate: i, mutateAsync: c };
|
|
856
634
|
}
|
|
857
|
-
function
|
|
858
|
-
const
|
|
859
|
-
const mutationKey = options.mutationKey;
|
|
860
|
-
const { mutateAsync, ...rest } = useMutation$(
|
|
635
|
+
function bt(e, t) {
|
|
636
|
+
const r = ee(t), n = e.mutationKey, { mutateAsync: s, ...a } = se(
|
|
861
637
|
{
|
|
862
|
-
...
|
|
863
|
-
onMutate({ variables }) {
|
|
864
|
-
var
|
|
865
|
-
return (
|
|
638
|
+
...e,
|
|
639
|
+
onMutate({ variables: c }) {
|
|
640
|
+
var o;
|
|
641
|
+
return (o = e.onMutate) == null ? void 0 : o.call(e, c);
|
|
866
642
|
},
|
|
867
|
-
onSuccess(
|
|
868
|
-
var
|
|
869
|
-
return (
|
|
643
|
+
onSuccess(c, o, f) {
|
|
644
|
+
var l;
|
|
645
|
+
return (l = e.onSuccess) == null ? void 0 : l.call(e, c, o.variables, f);
|
|
870
646
|
},
|
|
871
|
-
onError(
|
|
872
|
-
var
|
|
873
|
-
return (
|
|
647
|
+
onError(c, o, f) {
|
|
648
|
+
var l;
|
|
649
|
+
return (l = e.onError) == null ? void 0 : l.call(e, c, o.variables, f);
|
|
874
650
|
},
|
|
875
|
-
onSettled(
|
|
876
|
-
var
|
|
877
|
-
return (
|
|
651
|
+
onSettled(c, o, f, l) {
|
|
652
|
+
var d;
|
|
653
|
+
return (d = e.onSettled) == null ? void 0 : d.call(e, c, o, f.variables, l);
|
|
878
654
|
},
|
|
879
|
-
mutationFn: ({ ready
|
|
880
|
-
const
|
|
881
|
-
return
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
655
|
+
mutationFn: ({ ready$: c, variables: o }) => {
|
|
656
|
+
const f = typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn;
|
|
657
|
+
return c.pipe(
|
|
658
|
+
Fe((l) => l),
|
|
659
|
+
G(),
|
|
660
|
+
F(() => f)
|
|
885
661
|
);
|
|
886
662
|
}
|
|
887
663
|
},
|
|
888
|
-
|
|
889
|
-
)
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
mutations.map((mutation) => mutation.continue().catch(noop))
|
|
900
|
-
);
|
|
901
|
-
subject.next(true);
|
|
902
|
-
return await result.finally(() => {
|
|
903
|
-
subject.complete();
|
|
664
|
+
t
|
|
665
|
+
), u = v(
|
|
666
|
+
async (c) => {
|
|
667
|
+
const o = r.getMutationCache().findAll({
|
|
668
|
+
mutationKey: n,
|
|
669
|
+
exact: !0
|
|
670
|
+
}), f = new N(!1), l = s({ variables: c, ready$: f });
|
|
671
|
+
return await Promise.all(
|
|
672
|
+
o.map((d) => d.continue().catch(D))
|
|
673
|
+
), f.next(!0), await l.finally(() => {
|
|
674
|
+
f.complete();
|
|
904
675
|
});
|
|
905
676
|
},
|
|
906
|
-
[
|
|
907
|
-
)
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
mutateAsyncConcat(variables).catch(noop);
|
|
677
|
+
[s, r, n]
|
|
678
|
+
), i = v(
|
|
679
|
+
(c) => {
|
|
680
|
+
u(c).catch(D);
|
|
911
681
|
},
|
|
912
|
-
[
|
|
682
|
+
[u]
|
|
913
683
|
);
|
|
914
|
-
return { ...
|
|
684
|
+
return { ...a, mutate: i, mutateAsync: u };
|
|
915
685
|
}
|
|
916
686
|
export {
|
|
917
|
-
Context,
|
|
918
|
-
QueryClient$,
|
|
919
|
-
QueryClientProvider$,
|
|
920
|
-
SIGNAL_RESET,
|
|
921
|
-
arrayEqual,
|
|
922
|
-
createLocalStorageAdapter,
|
|
923
|
-
createLocalforageAdapter,
|
|
924
|
-
exponentialBackoffDelay,
|
|
925
|
-
getDelay,
|
|
926
|
-
isDefined,
|
|
927
|
-
isPromiseLike,
|
|
928
|
-
isServer,
|
|
929
|
-
retryBackoff,
|
|
930
|
-
signal,
|
|
931
|
-
useBehaviorSubject,
|
|
932
|
-
useContactMutation$,
|
|
933
|
-
useEffectOnce,
|
|
934
|
-
useLiveBehaviorSubject,
|
|
935
|
-
useLiveRef,
|
|
936
|
-
useMount,
|
|
937
|
-
useMutation$,
|
|
938
|
-
useObservableCallback,
|
|
939
|
-
useObservableState,
|
|
940
|
-
useObserve,
|
|
941
|
-
usePersistSignals,
|
|
942
|
-
useQuery$,
|
|
943
|
-
useQueryClient$,
|
|
944
|
-
useSignal,
|
|
945
|
-
useSignalValue,
|
|
946
|
-
useSubject,
|
|
947
|
-
useSubscribe,
|
|
948
|
-
useSubscribeEffect,
|
|
949
|
-
useSwitchMutation$,
|
|
950
|
-
useUnmountObservable
|
|
687
|
+
ue as Context,
|
|
688
|
+
Ye as QueryClient$,
|
|
689
|
+
mt as QueryClientProvider$,
|
|
690
|
+
Qe as SIGNAL_RESET,
|
|
691
|
+
ft as arrayEqual,
|
|
692
|
+
_e as createLocalStorageAdapter,
|
|
693
|
+
st as createLocalforageAdapter,
|
|
694
|
+
Je as exponentialBackoffDelay,
|
|
695
|
+
Ue as getDelay,
|
|
696
|
+
lt as isDefined,
|
|
697
|
+
K as isPromiseLike,
|
|
698
|
+
yt as isServer,
|
|
699
|
+
it as retryBackoff,
|
|
700
|
+
Ce as signal,
|
|
701
|
+
T as useBehaviorSubject,
|
|
702
|
+
bt as useContactMutation$,
|
|
703
|
+
Le as useEffectOnce,
|
|
704
|
+
z as useLiveBehaviorSubject,
|
|
705
|
+
g as useLiveRef,
|
|
706
|
+
ot as useMount,
|
|
707
|
+
se as useMutation$,
|
|
708
|
+
Ae as useObservableCallback,
|
|
709
|
+
rt as useObservableState,
|
|
710
|
+
te as useObserve,
|
|
711
|
+
ct as usePersistSignals,
|
|
712
|
+
dt as useQuery$,
|
|
713
|
+
Ge as useQueryClient$,
|
|
714
|
+
ut as useSignal,
|
|
715
|
+
Te as useSignalValue,
|
|
716
|
+
ne as useSubject,
|
|
717
|
+
Re as useSubscribe,
|
|
718
|
+
nt as useSubscribeEffect,
|
|
719
|
+
pt as useSwitchMutation$,
|
|
720
|
+
at as useUnmountObservable
|
|
951
721
|
};
|
|
722
|
+
//# sourceMappingURL=index.js.map
|