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