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