reactjrx 1.127.0 → 1.128.2
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.js +58 -58
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -64,10 +64,10 @@ function ye(e, t, r) {
|
|
|
64
64
|
defaultValue: void 0,
|
|
65
65
|
unsubscribeOnUnmount: !0,
|
|
66
66
|
compareFn: void 0
|
|
67
|
-
}, u = !r && Array.isArray(t) ? t : typeof e == "function" ? r ?? [] : [e], c = q(void 0), o = v(e),
|
|
67
|
+
}, u = !r && Array.isArray(t) ? t : typeof e == "function" ? r ?? [] : [e], c = q(void 0), o = v(e), l = v(n), s = typeof e != "function" && Array.isArray(t) ? JSON.stringify(t) : void 0, i = v(
|
|
68
68
|
typeof e != "function" && Array.isArray(t) ? t : void 0
|
|
69
69
|
), a = Z(() => {
|
|
70
|
-
const p =
|
|
70
|
+
const p = i.current, f = l.current.compareFn, m = f || (p ? fe : void 0);
|
|
71
71
|
return {
|
|
72
72
|
observable: j(o.current)().pipe(
|
|
73
73
|
// Maybe selector
|
|
@@ -79,7 +79,7 @@ function ye(e, t, r) {
|
|
|
79
79
|
subscribed: !1,
|
|
80
80
|
snapshotSub: void 0
|
|
81
81
|
};
|
|
82
|
-
}, [...u, s,
|
|
82
|
+
}, [...u, s, i, o, l]), y = S(() => {
|
|
83
83
|
if (!a.subscribed) {
|
|
84
84
|
a.subscribed = !0;
|
|
85
85
|
const p = a.observable.subscribe((f) => {
|
|
@@ -87,19 +87,19 @@ function ye(e, t, r) {
|
|
|
87
87
|
});
|
|
88
88
|
a.snapshotSub = p;
|
|
89
89
|
}
|
|
90
|
-
return c.current === void 0 ?
|
|
91
|
-
}, [a,
|
|
90
|
+
return c.current === void 0 ? l.current.defaultValue : c.current?.value;
|
|
91
|
+
}, [a, l]), d = S(
|
|
92
92
|
(p) => {
|
|
93
93
|
a.subscribed = !0;
|
|
94
94
|
const f = a.observable.pipe(
|
|
95
|
-
|
|
95
|
+
l.current.defaultValue ? Ie(l.current.defaultValue) : ne,
|
|
96
96
|
k((m) => {
|
|
97
97
|
c.current = { value: m };
|
|
98
98
|
}),
|
|
99
99
|
F((m) => (console.error(m), H))
|
|
100
100
|
).subscribe(p);
|
|
101
101
|
return a.snapshotSub?.unsubscribe(), () => {
|
|
102
|
-
|
|
102
|
+
l.current.unsubscribeOnUnmount !== !1 && f.unsubscribe();
|
|
103
103
|
};
|
|
104
104
|
},
|
|
105
105
|
[a]
|
|
@@ -122,7 +122,7 @@ function at(e, t, r = []) {
|
|
|
122
122
|
n.onError ?? ((s) => {
|
|
123
123
|
console.error(s);
|
|
124
124
|
})
|
|
125
|
-
), o = S(() => j(e)(), r),
|
|
125
|
+
), o = S(() => j(e)(), r), l = S(
|
|
126
126
|
() => o().pipe(
|
|
127
127
|
F((s) => {
|
|
128
128
|
throw c.current(s), s;
|
|
@@ -131,7 +131,7 @@ function at(e, t, r = []) {
|
|
|
131
131
|
),
|
|
132
132
|
[o, u, c]
|
|
133
133
|
);
|
|
134
|
-
He(
|
|
134
|
+
He(l, r);
|
|
135
135
|
}
|
|
136
136
|
class Ke {
|
|
137
137
|
queryMap = /* @__PURE__ */ new Map();
|
|
@@ -156,16 +156,16 @@ class Ke {
|
|
|
156
156
|
lastData: void 0
|
|
157
157
|
};
|
|
158
158
|
this.queryMap.set(u, o);
|
|
159
|
-
const
|
|
159
|
+
const l = c.subscribe({
|
|
160
160
|
next: (s) => {
|
|
161
|
-
const
|
|
162
|
-
|
|
161
|
+
const i = this.queryMap.get(u);
|
|
162
|
+
i && (i.lastData = { value: s });
|
|
163
163
|
},
|
|
164
164
|
complete: () => {
|
|
165
165
|
this.deleteQuery(u);
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
|
-
return o.sub =
|
|
168
|
+
return o.sub = l, o;
|
|
169
169
|
}
|
|
170
170
|
deleteQuery(t) {
|
|
171
171
|
const r = this.queryMap.get(t);
|
|
@@ -207,10 +207,10 @@ function me(e, t) {
|
|
|
207
207
|
), n = Pe(
|
|
208
208
|
{
|
|
209
209
|
...e,
|
|
210
|
-
mutationFn: (
|
|
210
|
+
mutationFn: (i) => {
|
|
211
211
|
let a;
|
|
212
212
|
return new Promise((y, d) => {
|
|
213
|
-
(typeof e.mutationFn == "function" ? e.mutationFn(
|
|
213
|
+
(typeof e.mutationFn == "function" ? e.mutationFn(i) : e.mutationFn).pipe(oe(1)).subscribe({
|
|
214
214
|
next: (p) => {
|
|
215
215
|
a = { value: p };
|
|
216
216
|
},
|
|
@@ -227,35 +227,35 @@ function me(e, t) {
|
|
|
227
227
|
}
|
|
228
228
|
},
|
|
229
229
|
t
|
|
230
|
-
), { status: u, isPending: c, isError: o, isSuccess:
|
|
230
|
+
), { status: u, isPending: c, isError: o, isSuccess: l, isIdle: s } = n;
|
|
231
231
|
return I(() => {
|
|
232
232
|
r.next({
|
|
233
233
|
status: u,
|
|
234
234
|
isPending: c,
|
|
235
235
|
isError: o,
|
|
236
|
-
isSuccess:
|
|
236
|
+
isSuccess: l,
|
|
237
237
|
isIdle: s
|
|
238
238
|
});
|
|
239
|
-
}, [u, c, o,
|
|
239
|
+
}, [u, c, o, l, s, r]), { ...n, state$: r };
|
|
240
240
|
}
|
|
241
241
|
function lt(e, t) {
|
|
242
242
|
const r = le(t), n = e.mutationKey, { mutateAsync: u, ...c } = me(
|
|
243
243
|
{
|
|
244
244
|
...e,
|
|
245
|
-
onMutate({ variables: s }) {
|
|
246
|
-
return e.onMutate?.(s);
|
|
245
|
+
onMutate({ variables: s }, ...i) {
|
|
246
|
+
return e.onMutate?.(s, ...i);
|
|
247
247
|
},
|
|
248
|
-
onSuccess(s,
|
|
249
|
-
return e.onSuccess?.(s,
|
|
248
|
+
onSuccess(s, { variables: i }, ...a) {
|
|
249
|
+
return e.onSuccess?.(s, i, ...a);
|
|
250
250
|
},
|
|
251
|
-
onError(s,
|
|
252
|
-
return e.onError?.(s,
|
|
251
|
+
onError(s, { variables: i }, ...a) {
|
|
252
|
+
return e.onError?.(s, i, ...a);
|
|
253
253
|
},
|
|
254
|
-
onSettled(s,
|
|
255
|
-
return e.onSettled?.(s,
|
|
254
|
+
onSettled(s, i, { variables: a }, ...y) {
|
|
255
|
+
return e.onSettled?.(s, i, a, ...y);
|
|
256
256
|
},
|
|
257
|
-
mutationFn: ({ ready$: s, variables:
|
|
258
|
-
const a = typeof e.mutationFn == "function" ? e.mutationFn(
|
|
257
|
+
mutationFn: ({ ready$: s, variables: i }) => {
|
|
258
|
+
const a = typeof e.mutationFn == "function" ? e.mutationFn(i) : e.mutationFn;
|
|
259
259
|
return s.pipe(
|
|
260
260
|
Ce((y) => y),
|
|
261
261
|
ce(),
|
|
@@ -266,34 +266,34 @@ function lt(e, t) {
|
|
|
266
266
|
t
|
|
267
267
|
), o = S(
|
|
268
268
|
async (s) => {
|
|
269
|
-
const
|
|
269
|
+
const i = r.getMutationCache().findAll({
|
|
270
270
|
mutationKey: n,
|
|
271
271
|
exact: !0
|
|
272
272
|
}), a = new E(!1), y = u({ variables: s, ready$: a });
|
|
273
273
|
return await Promise.all(
|
|
274
|
-
|
|
274
|
+
i.map((d) => d.continue().catch(L))
|
|
275
275
|
), a.next(!0), await y.finally(() => {
|
|
276
276
|
a.complete();
|
|
277
277
|
});
|
|
278
278
|
},
|
|
279
279
|
[u, r, n]
|
|
280
|
-
),
|
|
280
|
+
), l = S(
|
|
281
281
|
(s) => {
|
|
282
282
|
o(s).catch(L);
|
|
283
283
|
},
|
|
284
284
|
[o]
|
|
285
285
|
);
|
|
286
|
-
return { ...c, mutate:
|
|
286
|
+
return { ...c, mutate: l, mutateAsync: o };
|
|
287
287
|
}
|
|
288
288
|
function ft(e, t) {
|
|
289
289
|
const r = le(t), n = je();
|
|
290
290
|
return Oe(
|
|
291
291
|
{
|
|
292
292
|
...e,
|
|
293
|
-
queryFn: (o) => new Promise((
|
|
294
|
-
const
|
|
293
|
+
queryFn: (o) => new Promise((l, s) => {
|
|
294
|
+
const i = () => D(
|
|
295
295
|
() => typeof e.queryFn == "function" ? e.queryFn(o) : e.queryFn
|
|
296
|
-
), a = ie(o.queryKey), y = n.getQuery(a), d = y ?? n.setQuery(o.queryKey,
|
|
296
|
+
), a = ie(o.queryKey), y = n.getQuery(a), d = y ?? n.setQuery(o.queryKey, i(), o.signal), g = () => {
|
|
297
297
|
d?.isCompleted === !1 && setTimeout(() => {
|
|
298
298
|
r?.refetchQueries({
|
|
299
299
|
queryKey: o.queryKey,
|
|
@@ -302,7 +302,7 @@ function ft(e, t) {
|
|
|
302
302
|
});
|
|
303
303
|
};
|
|
304
304
|
if (!y && d.lastData !== void 0) {
|
|
305
|
-
|
|
305
|
+
l(d.lastData.value), g();
|
|
306
306
|
return;
|
|
307
307
|
}
|
|
308
308
|
d.query$.pipe(
|
|
@@ -323,8 +323,8 @@ function ft(e, t) {
|
|
|
323
323
|
), r.cancelQueries({
|
|
324
324
|
queryKey: o.queryKey,
|
|
325
325
|
exact: !0
|
|
326
|
-
})),
|
|
327
|
-
|
|
326
|
+
})), l(void 0);
|
|
327
|
+
l(d.lastData.value), g();
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
330
|
})
|
|
@@ -341,13 +341,13 @@ function yt(e, t) {
|
|
|
341
341
|
const r = q(new AbortController()), { mutate: n, mutateAsync: u, ...c } = me(
|
|
342
342
|
{
|
|
343
343
|
...e,
|
|
344
|
-
mutationFn: ({ variables: s, abort:
|
|
345
|
-
if (
|
|
344
|
+
mutationFn: ({ variables: s, abort: i }) => {
|
|
345
|
+
if (i.aborted)
|
|
346
346
|
throw new X();
|
|
347
347
|
const a = typeof e.mutationFn == "function" ? e.mutationFn(s) : e.mutationFn;
|
|
348
348
|
return V(
|
|
349
349
|
a,
|
|
350
|
-
se(
|
|
350
|
+
se(i, "abort").pipe(
|
|
351
351
|
k(() => {
|
|
352
352
|
throw new X();
|
|
353
353
|
}),
|
|
@@ -355,10 +355,10 @@ function yt(e, t) {
|
|
|
355
355
|
)
|
|
356
356
|
).pipe(ce(), Ve(null));
|
|
357
357
|
},
|
|
358
|
-
onMutate: ({ variables: s }) => e.onMutate?.(s),
|
|
359
|
-
onSuccess: (s, { variables:
|
|
360
|
-
onError: (s, { variables:
|
|
361
|
-
onSettled: (s,
|
|
358
|
+
onMutate: ({ variables: s }, ...i) => e.onMutate?.(s, ...i),
|
|
359
|
+
onSuccess: (s, { variables: i }, ...a) => e.onSuccess?.(s, i, ...a),
|
|
360
|
+
onError: (s, { variables: i }, ...a) => e.onError?.(s, i, ...a),
|
|
361
|
+
onSettled: (s, i, { variables: a }, ...y) => e.onSettled?.(s, i, a, ...y)
|
|
362
362
|
},
|
|
363
363
|
t
|
|
364
364
|
), o = S(
|
|
@@ -367,14 +367,14 @@ function yt(e, t) {
|
|
|
367
367
|
abort: r.current.signal
|
|
368
368
|
})),
|
|
369
369
|
[n]
|
|
370
|
-
),
|
|
370
|
+
), l = S(
|
|
371
371
|
(s) => (r.current.abort(), r.current = new AbortController(), u({
|
|
372
372
|
variables: s,
|
|
373
373
|
abort: r.current.signal
|
|
374
374
|
})),
|
|
375
375
|
[u]
|
|
376
376
|
);
|
|
377
|
-
return { ...c, mutate: o, mutateAsync:
|
|
377
|
+
return { ...c, mutate: o, mutateAsync: l };
|
|
378
378
|
}
|
|
379
379
|
const ze = Symbol("SIGNAL_RESET"), dt = (e) => ({
|
|
380
380
|
getItem: async (t) => {
|
|
@@ -544,16 +544,16 @@ function We({
|
|
|
544
544
|
M((c) => {
|
|
545
545
|
const o = Ue(c);
|
|
546
546
|
if (!o) return b(c);
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
547
|
+
const l = typeof o.migrationVersion != "number", s = o.migrationVersion !== void 0 && u > o.migrationVersion;
|
|
548
|
+
if (l || s || o.value === void 0)
|
|
549
549
|
return b(c);
|
|
550
|
-
const
|
|
550
|
+
const i = o.value;
|
|
551
551
|
return process.env.NODE_ENV === "development" && console.log(
|
|
552
552
|
"[reactjrx][state][persistance]:",
|
|
553
553
|
"Hydrate value",
|
|
554
554
|
o,
|
|
555
555
|
`for signal ${n.config.key}`
|
|
556
|
-
), n.setValue(r({ value:
|
|
556
|
+
), n.setValue(r({ value: i, version: u })), b(c);
|
|
557
557
|
})
|
|
558
558
|
);
|
|
559
559
|
}
|
|
@@ -615,12 +615,12 @@ function gt({
|
|
|
615
615
|
const n = v(t), u = G(r), c = G(e);
|
|
616
616
|
return ye(
|
|
617
617
|
() => u.pipe(
|
|
618
|
-
M((
|
|
618
|
+
M((l) => l ? V(
|
|
619
619
|
b({ type: "reset" }),
|
|
620
620
|
c.pipe(
|
|
621
621
|
Ne(
|
|
622
622
|
(s) => Xe({
|
|
623
|
-
adapter:
|
|
623
|
+
adapter: l,
|
|
624
624
|
entries: s,
|
|
625
625
|
onHydrated: () => {
|
|
626
626
|
n.current?.();
|
|
@@ -631,7 +631,7 @@ function gt({
|
|
|
631
631
|
) : b({ type: "reset" }))
|
|
632
632
|
).pipe(
|
|
633
633
|
Re(
|
|
634
|
-
(
|
|
634
|
+
(l, s) => s.type === "reset" ? { isHydrated: !1 } : s.type === "hydrated" ? { isHydrated: !0 } : l,
|
|
635
635
|
{ isHydrated: !1 }
|
|
636
636
|
)
|
|
637
637
|
),
|
|
@@ -672,10 +672,10 @@ function It(e) {
|
|
|
672
672
|
} = e, c = typeof t != "function" ? t === !1 ? 0 : t === !0 ? Number.POSITIVE_INFINITY : t ?? Number.POSITIVE_INFINITY : Number.POSITIVE_INFINITY, o = typeof t == "function" ? (
|
|
673
673
|
// ? (attempt: number, error: TError) => of(retry(attempt, error))
|
|
674
674
|
t
|
|
675
|
-
) : () => !0,
|
|
675
|
+
) : () => !0, l = typeof r == "number" ? r : 100, s = {
|
|
676
676
|
...e
|
|
677
677
|
}, {
|
|
678
|
-
maxInterval:
|
|
678
|
+
maxInterval: i = Number.POSITIVE_INFINITY,
|
|
679
679
|
resetOnSuccess: a = !1,
|
|
680
680
|
backoffDelay: y = et
|
|
681
681
|
} = s;
|
|
@@ -704,8 +704,8 @@ function It(e) {
|
|
|
704
704
|
P(
|
|
705
705
|
() => p(w, m) ? Ae(
|
|
706
706
|
Be(
|
|
707
|
-
y(w,
|
|
708
|
-
|
|
707
|
+
y(w, l),
|
|
708
|
+
i
|
|
709
709
|
)
|
|
710
710
|
).pipe(
|
|
711
711
|
P((h) => n && !n(w, m) ? A(() => m) : b(h))
|