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