react-state-custom 1.0.9 → 1.0.10
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.d.ts +1 -0
- package/dist/index.es.js +104 -103
- package/dist/index.umd.js +4 -4
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/state-utils/createRootCtx.tsx +1 -1
- package/vite.config.ts +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Context, getContext, useDataContext, useDataSource, useDataSourceMultiple, useDataSubscribe, useDataSubscribeMultiple, useDataSubscribeMultipleWithDebounce, useDataSubscribeWithTransform } from './state-utils/ctx';
|
|
2
2
|
export { createRootCtx } from './state-utils/createRootCtx';
|
|
3
3
|
export { AutoRootCtx, createAutoCtx } from './state-utils/createAutoCtx';
|
|
4
|
+
export { useObjHash } from './state-utils/useObjectHash';
|
|
4
5
|
export { useQuickSubscribeV2 as useQuickSubscribe } from './state-utils/useQuickSubscribeV2';
|
package/dist/index.es.js
CHANGED
|
@@ -20,14 +20,14 @@ function Fe() {
|
|
|
20
20
|
function u(s) {
|
|
21
21
|
console && console.warn && console.warn(s);
|
|
22
22
|
}
|
|
23
|
-
var
|
|
23
|
+
var c = Number.isNaN || function(a) {
|
|
24
24
|
return a !== a;
|
|
25
25
|
};
|
|
26
26
|
function n() {
|
|
27
27
|
n.init.call(this);
|
|
28
28
|
}
|
|
29
29
|
Z.exports = n, Z.exports.once = N, n.EventEmitter = n, n.prototype._events = void 0, n.prototype._eventsCount = 0, n.prototype._maxListeners = void 0;
|
|
30
|
-
var
|
|
30
|
+
var f = 10;
|
|
31
31
|
function d(s) {
|
|
32
32
|
if (typeof s != "function")
|
|
33
33
|
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof s);
|
|
@@ -35,17 +35,17 @@ function Fe() {
|
|
|
35
35
|
Object.defineProperty(n, "defaultMaxListeners", {
|
|
36
36
|
enumerable: !0,
|
|
37
37
|
get: function() {
|
|
38
|
-
return
|
|
38
|
+
return f;
|
|
39
39
|
},
|
|
40
40
|
set: function(s) {
|
|
41
|
-
if (typeof s != "number" || s < 0 ||
|
|
41
|
+
if (typeof s != "number" || s < 0 || c(s))
|
|
42
42
|
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + s + ".");
|
|
43
|
-
|
|
43
|
+
f = s;
|
|
44
44
|
}
|
|
45
45
|
}), n.init = function() {
|
|
46
46
|
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
47
47
|
}, n.prototype.setMaxListeners = function(a) {
|
|
48
|
-
if (typeof a != "number" || a < 0 ||
|
|
48
|
+
if (typeof a != "number" || a < 0 || c(a))
|
|
49
49
|
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + a + ".");
|
|
50
50
|
return this._maxListeners = a, this;
|
|
51
51
|
};
|
|
@@ -227,8 +227,8 @@ function Ve(e) {
|
|
|
227
227
|
var u = !0;
|
|
228
228
|
} catch {
|
|
229
229
|
}
|
|
230
|
-
var
|
|
231
|
-
return u && (t ? e[q] = r : delete e[q]),
|
|
230
|
+
var c = He.call(e);
|
|
231
|
+
return u && (t ? e[q] = r : delete e[q]), c;
|
|
232
232
|
}
|
|
233
233
|
var qe = Object.prototype, Je = qe.toString;
|
|
234
234
|
function Xe(e) {
|
|
@@ -448,11 +448,11 @@ function le(e, t) {
|
|
|
448
448
|
if (typeof e != "function" || t != null && typeof t != "function")
|
|
449
449
|
throw new TypeError(Zt);
|
|
450
450
|
var r = function() {
|
|
451
|
-
var u = arguments,
|
|
452
|
-
if (n.has(
|
|
453
|
-
return n.get(
|
|
454
|
-
var
|
|
455
|
-
return r.cache = n.set(
|
|
451
|
+
var u = arguments, c = t ? t.apply(this, u) : u[0], n = r.cache;
|
|
452
|
+
if (n.has(c))
|
|
453
|
+
return n.get(c);
|
|
454
|
+
var f = e.apply(this, u);
|
|
455
|
+
return r.cache = n.set(c, f) || n, f;
|
|
456
456
|
};
|
|
457
457
|
return r.cache = new (le.Cache || I)(), r;
|
|
458
458
|
}
|
|
@@ -461,16 +461,16 @@ var fe = function() {
|
|
|
461
461
|
return re.Date.now();
|
|
462
462
|
}, er = "Expected a function", tr = Math.max, rr = Math.min;
|
|
463
463
|
function ae(e, t, r) {
|
|
464
|
-
var u,
|
|
464
|
+
var u, c, n, f, d, p, v = 0, g = !1, E = !1, T = !0;
|
|
465
465
|
if (typeof e != "function")
|
|
466
466
|
throw new TypeError(er);
|
|
467
467
|
t = ye(t) || 0, G(r) && (g = !!r.leading, E = "maxWait" in r, n = E ? tr(ye(r.maxWait) || 0, t) : n, T = "trailing" in r ? !!r.trailing : T);
|
|
468
468
|
function C(o) {
|
|
469
|
-
var l = u, h =
|
|
470
|
-
return u =
|
|
469
|
+
var l = u, h = c;
|
|
470
|
+
return u = c = void 0, v = o, f = e.apply(h, l), f;
|
|
471
471
|
}
|
|
472
472
|
function M(o) {
|
|
473
|
-
return v = o, d = setTimeout(N, t), g ? C(o) :
|
|
473
|
+
return v = o, d = setTimeout(N, t), g ? C(o) : f;
|
|
474
474
|
}
|
|
475
475
|
function y(o) {
|
|
476
476
|
var l = o - p, h = o - v, _ = t - l;
|
|
@@ -487,44 +487,44 @@ function ae(e, t, r) {
|
|
|
487
487
|
d = setTimeout(N, y(o));
|
|
488
488
|
}
|
|
489
489
|
function x(o) {
|
|
490
|
-
return d = void 0, T && u ? C(o) : (u =
|
|
490
|
+
return d = void 0, T && u ? C(o) : (u = c = void 0, f);
|
|
491
491
|
}
|
|
492
492
|
function D() {
|
|
493
|
-
d !== void 0 && clearTimeout(d), v = 0, u = p =
|
|
493
|
+
d !== void 0 && clearTimeout(d), v = 0, u = p = c = d = void 0;
|
|
494
494
|
}
|
|
495
495
|
function s() {
|
|
496
|
-
return d === void 0 ?
|
|
496
|
+
return d === void 0 ? f : x(fe());
|
|
497
497
|
}
|
|
498
498
|
function a() {
|
|
499
499
|
var o = fe(), l = O(o);
|
|
500
|
-
if (u = arguments,
|
|
500
|
+
if (u = arguments, c = this, p = o, l) {
|
|
501
501
|
if (d === void 0)
|
|
502
502
|
return M(p);
|
|
503
503
|
if (E)
|
|
504
504
|
return clearTimeout(d), d = setTimeout(N, t), C(p);
|
|
505
505
|
}
|
|
506
|
-
return d === void 0 && (d = setTimeout(N, t)),
|
|
506
|
+
return d === void 0 && (d = setTimeout(N, t)), f;
|
|
507
507
|
}
|
|
508
508
|
return a.cancel = D, a.flush = s, a;
|
|
509
509
|
}
|
|
510
510
|
var nr = "Expected a function";
|
|
511
511
|
function or(e, t, r) {
|
|
512
|
-
var u = !0,
|
|
512
|
+
var u = !0, c = !0;
|
|
513
513
|
if (typeof e != "function")
|
|
514
514
|
throw new TypeError(nr);
|
|
515
|
-
return G(r) && (u = "leading" in r ? !!r.leading : u,
|
|
515
|
+
return G(r) && (u = "leading" in r ? !!r.leading : u, c = "trailing" in r ? !!r.trailing : c), ae(e, t, {
|
|
516
516
|
leading: u,
|
|
517
517
|
maxWait: t,
|
|
518
|
-
trailing:
|
|
518
|
+
trailing: c
|
|
519
519
|
});
|
|
520
520
|
}
|
|
521
521
|
const we = () => Math.random().toString().slice(2), ar = (e) => {
|
|
522
522
|
const { current: { computedHash: t } } = $e({
|
|
523
523
|
get computedHash() {
|
|
524
524
|
let r = [], u = we();
|
|
525
|
-
return (
|
|
525
|
+
return (c) => {
|
|
526
526
|
let n = !1;
|
|
527
|
-
return n = n || !
|
|
527
|
+
return n = n || !c != !r, n = n || (c == null ? void 0 : c.length) != (r == null ? void 0 : r.length), n = n || c.some((f, d) => f != r[d]), r = c, n && (u = we()), u;
|
|
528
528
|
};
|
|
529
529
|
}
|
|
530
530
|
});
|
|
@@ -562,8 +562,8 @@ class ir {
|
|
|
562
562
|
* @returns Unsubscribe function.
|
|
563
563
|
*/
|
|
564
564
|
subscribe(t, r) {
|
|
565
|
-
const u = ({ value:
|
|
566
|
-
r(
|
|
565
|
+
const u = ({ value: c }) => {
|
|
566
|
+
r(c);
|
|
567
567
|
};
|
|
568
568
|
return this.event.addListener(String(t), u), t in this.data && r(this.data[t]), () => (this.event.removeListener(String(t), u), void 0);
|
|
569
569
|
}
|
|
@@ -584,32 +584,32 @@ const sr = le((e) => new ir(e)), Y = (e = "noname") => z(() => sr(e), [e]), Le =
|
|
|
584
584
|
e && e.data[t] != r && e.publish(t, r);
|
|
585
585
|
}, [t, r, e]), Le(e, t);
|
|
586
586
|
}, ur = (e, t, r = 0) => {
|
|
587
|
-
const [{ value: u },
|
|
587
|
+
const [{ value: u }, c] = U(() => {
|
|
588
588
|
var n;
|
|
589
589
|
return { value: (n = e == null ? void 0 : e.data) == null ? void 0 : n[t] };
|
|
590
590
|
});
|
|
591
591
|
return L(() => {
|
|
592
592
|
if (e) {
|
|
593
|
-
let n = r == 0 ? (d) =>
|
|
594
|
-
return u != e.data[t] &&
|
|
595
|
-
|
|
593
|
+
let n = r == 0 ? (d) => c({ value: d }) : ae((d) => c({ value: d }), r), f = e.subscribe(t, n);
|
|
594
|
+
return u != e.data[t] && c({ value: e.data[t] }), () => {
|
|
595
|
+
f();
|
|
596
596
|
};
|
|
597
597
|
}
|
|
598
598
|
}, [t, e]), e == null ? void 0 : e.data[t];
|
|
599
599
|
}, br = (e, t, r) => {
|
|
600
|
-
const [, u] = U(0),
|
|
600
|
+
const [, u] = U(0), c = z(
|
|
601
601
|
() => r(e == null ? void 0 : e.data[t]),
|
|
602
602
|
[r, e == null ? void 0 : e.data[t]]
|
|
603
603
|
);
|
|
604
604
|
return L(() => {
|
|
605
605
|
if (e) {
|
|
606
|
-
let n =
|
|
606
|
+
let n = c, f = () => {
|
|
607
607
|
let p = r(e.data[t]);
|
|
608
608
|
p != n && (n = p, u((v) => v + 1));
|
|
609
|
-
}, d = e.subscribe(t,
|
|
610
|
-
return
|
|
609
|
+
}, d = e.subscribe(t, f);
|
|
610
|
+
return f(), () => d();
|
|
611
611
|
}
|
|
612
|
-
}, [t, e]),
|
|
612
|
+
}, [t, e]), c;
|
|
613
613
|
}, Pe = (e, ...t) => {
|
|
614
614
|
L(() => {
|
|
615
615
|
if (e)
|
|
@@ -617,47 +617,47 @@ const sr = le((e) => new ir(e)), Y = (e = "noname") => z(() => sr(e), [e]), Le =
|
|
|
617
617
|
e.data[r] != u && e.publish(r, u);
|
|
618
618
|
}, [e, ar(t.flat())]), Le(e, ...t.map((r) => r[0]));
|
|
619
619
|
}, gr = (e, ...t) => {
|
|
620
|
-
const [, r] = U(0), u = t.map((
|
|
620
|
+
const [, r] = U(0), u = t.map((c) => {
|
|
621
621
|
var n;
|
|
622
|
-
return (n = e == null ? void 0 : e.data) == null ? void 0 : n[
|
|
622
|
+
return (n = e == null ? void 0 : e.data) == null ? void 0 : n[c];
|
|
623
623
|
});
|
|
624
624
|
return L(() => {
|
|
625
625
|
if (e) {
|
|
626
|
-
let
|
|
626
|
+
let c = u;
|
|
627
627
|
const n = ae(() => {
|
|
628
628
|
let p = t.map((v) => {
|
|
629
629
|
var g;
|
|
630
630
|
return (g = e == null ? void 0 : e.data) == null ? void 0 : g[v];
|
|
631
631
|
});
|
|
632
|
-
t.some((v, g) =>
|
|
632
|
+
t.some((v, g) => c[g] != p[g]) && (c = p, r((v) => v + 1));
|
|
633
633
|
}, 1);
|
|
634
|
-
let
|
|
634
|
+
let f = t.map((p) => e.subscribe(p, n)), d = setTimeout(n, 1);
|
|
635
635
|
return () => {
|
|
636
|
-
clearTimeout(d), n.cancel(),
|
|
636
|
+
clearTimeout(d), n.cancel(), f.forEach((p) => p());
|
|
637
637
|
};
|
|
638
638
|
}
|
|
639
|
-
}, [e, ...t]), Object.fromEntries(t.map((
|
|
639
|
+
}, [e, ...t]), Object.fromEntries(t.map((c, n) => [c, u[n]]));
|
|
640
640
|
}, _r = (e, t = 100, ...r) => {
|
|
641
|
-
const [, u] = U(0),
|
|
642
|
-
var
|
|
643
|
-
return (
|
|
641
|
+
const [, u] = U(0), c = r.map((n) => {
|
|
642
|
+
var f;
|
|
643
|
+
return (f = e == null ? void 0 : e.data) == null ? void 0 : f[n];
|
|
644
644
|
});
|
|
645
645
|
return L(() => {
|
|
646
646
|
if (e) {
|
|
647
|
-
let n =
|
|
648
|
-
const
|
|
647
|
+
let n = c;
|
|
648
|
+
const f = or(() => {
|
|
649
649
|
let v = r.map((g) => {
|
|
650
650
|
var E;
|
|
651
651
|
return (E = e == null ? void 0 : e.data) == null ? void 0 : E[g];
|
|
652
652
|
});
|
|
653
653
|
r.some((g, E) => n[E] != v[E]) && (n = v, u((g) => g + 1));
|
|
654
654
|
}, t);
|
|
655
|
-
let d = r.map((v) => e.subscribe(v,
|
|
655
|
+
let d = r.map((v) => e.subscribe(v, f)), p = setTimeout(f, 1);
|
|
656
656
|
return () => {
|
|
657
|
-
clearTimeout(p),
|
|
657
|
+
clearTimeout(p), f.cancel(), d.forEach((v) => v());
|
|
658
658
|
};
|
|
659
659
|
}
|
|
660
|
-
}, [e, ...r]),
|
|
660
|
+
}, [e, ...r]), c;
|
|
661
661
|
};
|
|
662
662
|
var ee = { exports: {} }, J = {};
|
|
663
663
|
/**
|
|
@@ -674,18 +674,18 @@ function cr() {
|
|
|
674
674
|
if (Te) return J;
|
|
675
675
|
Te = 1;
|
|
676
676
|
var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
677
|
-
function r(u,
|
|
678
|
-
var
|
|
679
|
-
if (n !== void 0 && (
|
|
677
|
+
function r(u, c, n) {
|
|
678
|
+
var f = null;
|
|
679
|
+
if (n !== void 0 && (f = "" + n), c.key !== void 0 && (f = "" + c.key), "key" in c) {
|
|
680
680
|
n = {};
|
|
681
|
-
for (var d in
|
|
682
|
-
d !== "key" && (n[d] =
|
|
683
|
-
} else n =
|
|
684
|
-
return
|
|
681
|
+
for (var d in c)
|
|
682
|
+
d !== "key" && (n[d] = c[d]);
|
|
683
|
+
} else n = c;
|
|
684
|
+
return c = n.ref, {
|
|
685
685
|
$$typeof: e,
|
|
686
686
|
type: u,
|
|
687
|
-
key:
|
|
688
|
-
ref:
|
|
687
|
+
key: f,
|
|
688
|
+
ref: c !== void 0 ? c : null,
|
|
689
689
|
props: n
|
|
690
690
|
};
|
|
691
691
|
}
|
|
@@ -778,14 +778,14 @@ function fr() {
|
|
|
778
778
|
return "<...>";
|
|
779
779
|
}
|
|
780
780
|
}
|
|
781
|
-
function
|
|
781
|
+
function c() {
|
|
782
782
|
var i = j.A;
|
|
783
783
|
return i === null ? null : i.getOwner();
|
|
784
784
|
}
|
|
785
785
|
function n() {
|
|
786
786
|
return Error("react-stack-top-frame");
|
|
787
787
|
}
|
|
788
|
-
function
|
|
788
|
+
function f(i) {
|
|
789
789
|
if (A.call(i, "key")) {
|
|
790
790
|
var m = Object.getOwnPropertyDescriptor(i, "key").get;
|
|
791
791
|
if (m && m.isReactWarning) return !1;
|
|
@@ -873,7 +873,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
873
873
|
S
|
|
874
874
|
), me[S + R] = !0);
|
|
875
875
|
}
|
|
876
|
-
if (S = null, w !== void 0 && (r(w), S = "" + w),
|
|
876
|
+
if (S = null, w !== void 0 && (r(w), S = "" + w), f(m) && (r(m.key), S = "" + m.key), "key" in m) {
|
|
877
877
|
w = {};
|
|
878
878
|
for (var ue in m)
|
|
879
879
|
ue !== "key" && (w[ue] = m[ue]);
|
|
@@ -886,7 +886,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
886
886
|
S,
|
|
887
887
|
P,
|
|
888
888
|
k,
|
|
889
|
-
|
|
889
|
+
c(),
|
|
890
890
|
w,
|
|
891
891
|
ie,
|
|
892
892
|
se
|
|
@@ -942,46 +942,46 @@ var W = lr();
|
|
|
942
942
|
const yr = (e, t) => {
|
|
943
943
|
const r = (n) => [
|
|
944
944
|
e,
|
|
945
|
-
...Object.entries(n ?? {}).sort((
|
|
945
|
+
...Object.entries(n ?? {}).sort((f, d) => f[0].localeCompare(d[0])).flat()
|
|
946
946
|
].join("-");
|
|
947
947
|
let u = /* @__PURE__ */ new Set();
|
|
948
|
-
const
|
|
949
|
-
const
|
|
948
|
+
const c = (n) => {
|
|
949
|
+
const f = t(n), d = r(n), p = Y(d), v = z(() => new Error().stack, []);
|
|
950
950
|
return Pe(
|
|
951
|
-
|
|
952
|
-
...Object.entries(
|
|
951
|
+
p,
|
|
952
|
+
...Object.entries(f)
|
|
953
953
|
), L(() => {
|
|
954
|
-
if (u.has(
|
|
955
|
-
const g = new Error("RootContext " +
|
|
954
|
+
if (u.has(d)) {
|
|
955
|
+
const g = new Error("RootContext " + d + " are mounted more than once");
|
|
956
956
|
throw g.stack = v, g;
|
|
957
957
|
}
|
|
958
|
-
return u.add(
|
|
959
|
-
u.delete(
|
|
958
|
+
return u.add(d), () => {
|
|
959
|
+
u.delete(d);
|
|
960
960
|
};
|
|
961
961
|
}), /* @__PURE__ */ W.jsx(W.Fragment, {});
|
|
962
962
|
};
|
|
963
|
-
return
|
|
963
|
+
return c.displayName = `State[${(t == null ? void 0 : t.name) ?? "??"}]`, {
|
|
964
964
|
resolveCtxName: r,
|
|
965
|
-
Root:
|
|
965
|
+
Root: c,
|
|
966
966
|
useCtxStateStrict: (n) => {
|
|
967
|
-
const
|
|
967
|
+
const f = r(n), d = z(() => new Error().stack, []);
|
|
968
968
|
return L(() => {
|
|
969
|
-
if (!u.has(
|
|
970
|
-
const p = new Error("RootContext [" +
|
|
969
|
+
if (!u.has(f)) {
|
|
970
|
+
const p = new Error("RootContext [" + f + "] is not mounted");
|
|
971
971
|
throw p.stack = d, p;
|
|
972
972
|
}
|
|
973
|
-
}, [
|
|
973
|
+
}, [f]), Y(f);
|
|
974
974
|
},
|
|
975
975
|
useCtxState: (n) => {
|
|
976
|
-
const
|
|
976
|
+
const f = r(n), d = z(() => new Error().stack, []);
|
|
977
977
|
return L(() => {
|
|
978
|
-
if (!u.has(
|
|
979
|
-
const p = new Error("RootContext [" +
|
|
978
|
+
if (!u.has(f)) {
|
|
979
|
+
const p = new Error("RootContext [" + f + "] is not mounted");
|
|
980
980
|
p.stack = d;
|
|
981
981
|
let v = setTimeout(() => console.error(p), 1e3);
|
|
982
982
|
return () => clearTimeout(v);
|
|
983
983
|
}
|
|
984
|
-
}, [u.has(
|
|
984
|
+
}, [u.has(f)]), Y(f);
|
|
985
985
|
}
|
|
986
986
|
};
|
|
987
987
|
}, dr = /* @__PURE__ */ function() {
|
|
@@ -993,14 +993,14 @@ const yr = (e, t) => {
|
|
|
993
993
|
}(), hr = (e) => [
|
|
994
994
|
...Object.entries(e ?? {}).sort((t, r) => t[0].localeCompare(r[0])).flat()
|
|
995
995
|
].join("-"), Er = ({ Wrapper: e = xe }) => {
|
|
996
|
-
const t = Y("auto-ctx"), [r, u] = U({}),
|
|
997
|
-
(n,
|
|
998
|
-
const d = dr(n), p = hr(
|
|
996
|
+
const t = Y("auto-ctx"), [r, u] = U({}), c = Ie(
|
|
997
|
+
(n, f) => {
|
|
998
|
+
const d = dr(n), p = hr(f);
|
|
999
999
|
return u(({
|
|
1000
1000
|
[d]: {
|
|
1001
1001
|
Component: v = n,
|
|
1002
1002
|
subState: {
|
|
1003
|
-
[p]: g = { params:
|
|
1003
|
+
[p]: g = { params: f, counter: 0 },
|
|
1004
1004
|
...E
|
|
1005
1005
|
} = {}
|
|
1006
1006
|
} = {},
|
|
@@ -1021,7 +1021,7 @@ const yr = (e, t) => {
|
|
|
1021
1021
|
[d]: {
|
|
1022
1022
|
Component: v = n,
|
|
1023
1023
|
subState: {
|
|
1024
|
-
[p]: g = { params:
|
|
1024
|
+
[p]: g = { params: f, counter: 0 },
|
|
1025
1025
|
...E
|
|
1026
1026
|
} = {}
|
|
1027
1027
|
} = {},
|
|
@@ -1046,40 +1046,40 @@ const yr = (e, t) => {
|
|
|
1046
1046
|
);
|
|
1047
1047
|
return Pe(
|
|
1048
1048
|
t,
|
|
1049
|
-
["subscribe",
|
|
1049
|
+
["subscribe", c],
|
|
1050
1050
|
["state", r]
|
|
1051
1051
|
), /* @__PURE__ */ W.jsx(W.Fragment, { children: Object.entries(r).flatMap(
|
|
1052
|
-
([n, { Component:
|
|
1052
|
+
([n, { Component: f, subState: d }]) => Object.entries(d).map(([p, { counter: v, params: g }]) => ({ key: n + p, Component: f, params: g, counter: v })).filter((p) => p.counter > 0).map(({ key: p, params: v, Component: g }) => /* @__PURE__ */ W.jsx(e, { children: /* @__PURE__ */ W.jsx(g, { ...v }) }, p))
|
|
1053
1053
|
) });
|
|
1054
1054
|
}, wr = ({ Root: e, useCtxState: t, useCtxStateStrict: r, resolveCtxName: u }) => ({
|
|
1055
|
-
useCtxState: (
|
|
1056
|
-
const n = u(
|
|
1057
|
-
return L(() =>
|
|
1055
|
+
useCtxState: (c) => {
|
|
1056
|
+
const n = u(c), f = ur(Y("auto-ctx"), "subscribe");
|
|
1057
|
+
return L(() => f == null ? void 0 : f(e, c), [f, n]), Y(n);
|
|
1058
1058
|
}
|
|
1059
1059
|
}), Tr = (e) => {
|
|
1060
|
-
const [, t] = U(0), { proxy: r, finalGetter: u, openGetter:
|
|
1060
|
+
const [, t] = U(0), { proxy: r, finalGetter: u, openGetter: c, clean: n } = z(
|
|
1061
1061
|
() => {
|
|
1062
|
-
const
|
|
1062
|
+
const f = /* @__PURE__ */ new Set(), d = {}, p = /* @__PURE__ */ new Map(), v = new Proxy(
|
|
1063
1063
|
e == null ? void 0 : e.data,
|
|
1064
1064
|
{
|
|
1065
1065
|
get(y, O) {
|
|
1066
1066
|
if (g)
|
|
1067
|
-
return
|
|
1067
|
+
return f.add(O), d[O] = y[O];
|
|
1068
1068
|
throw new Error("now allow here");
|
|
1069
1069
|
}
|
|
1070
1070
|
}
|
|
1071
1071
|
);
|
|
1072
1072
|
let g = !0, E = ae(() => {
|
|
1073
|
-
[...
|
|
1073
|
+
[...f.values()].some((y) => {
|
|
1074
1074
|
var O;
|
|
1075
1075
|
return d[y] != ((O = e == null ? void 0 : e.data) == null ? void 0 : O[y]);
|
|
1076
1076
|
}) && t((y) => y + 1);
|
|
1077
1077
|
}, 0), T = () => {
|
|
1078
|
-
g = !0,
|
|
1078
|
+
g = !0, f.clear();
|
|
1079
1079
|
}, C = () => {
|
|
1080
|
-
g = !1, [...
|
|
1080
|
+
g = !1, [...f.values()].filter((y) => !p.has(y)).forEach((y) => {
|
|
1081
1081
|
p.set(y, e == null ? void 0 : e.subscribe(y, E));
|
|
1082
|
-
}), [...p.keys()].filter((y) => !
|
|
1082
|
+
}), [...p.keys()].filter((y) => !f.has(y)).forEach((y) => {
|
|
1083
1083
|
let O = p.get(y);
|
|
1084
1084
|
O == null || O(), p.delete(y);
|
|
1085
1085
|
});
|
|
@@ -1090,7 +1090,7 @@ const yr = (e, t) => {
|
|
|
1090
1090
|
},
|
|
1091
1091
|
[e]
|
|
1092
1092
|
);
|
|
1093
|
-
return
|
|
1093
|
+
return c(), setTimeout(u, 0), L(
|
|
1094
1094
|
() => () => n(),
|
|
1095
1095
|
[n]
|
|
1096
1096
|
), r;
|
|
@@ -1108,5 +1108,6 @@ export {
|
|
|
1108
1108
|
gr as useDataSubscribeMultiple,
|
|
1109
1109
|
_r as useDataSubscribeMultipleWithDebounce,
|
|
1110
1110
|
br as useDataSubscribeWithTransform,
|
|
1111
|
+
ar as useObjHash,
|
|
1111
1112
|
Tr as useQuickSubscribe
|
|
1112
1113
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(T,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],v):(T=typeof globalThis<"u"?globalThis:T||self,v(T.RState={},T.React))})(this,function(T,v){"use strict";var mn=Object.defineProperty;var bn=(T,v,W)=>v in T?mn(T,v,{enumerable:!0,configurable:!0,writable:!0,value:W}):T[v]=W;var ae=(T,v,W)=>bn(T,typeof v!="symbol"?v+"":v,W);function W(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z={exports:{}},he;function ke(){if(he)return Z.exports;he=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(a,o,l){return Function.prototype.apply.call(a,o,l)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(a){return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a))}:n=function(a){return Object.getOwnPropertyNames(a)};function u(i){console&&console.warn&&console.warn(i)}var f=Number.isNaN||function(a){return a!==a};function r(){r.init.call(this)}Z.exports=r,Z.exports.once=A,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var c=10;function d(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(i){if(typeof i!="number"||i<0||f(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");c=i}}),r.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(a){if(typeof a!="number"||a<0||f(a))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+a+".");return this._maxListeners=a,this};function p(i){return i._maxListeners===void 0?r.defaultMaxListeners:i._maxListeners}r.prototype.getMaxListeners=function(){return p(this)},r.prototype.emit=function(a){for(var o=[],l=1;l<arguments.length;l++)o.push(arguments[l]);var h=a==="error",E=this._events;if(E!==void 0)h=h&&E.error===void 0;else if(!h)return!1;if(h){var g;if(o.length>0&&(g=o[0]),g instanceof Error)throw g;var L=new Error("Unhandled error."+(g?" ("+g.message+")":""));throw L.context=g,L}var M=E[a];if(M===void 0)return!1;if(typeof M=="function")t(M,this,o);else for(var oe=M.length,Q=F(M,oe),l=0;l<oe;++l)t(Q[l],this,o);return!0};function m(i,a,o,l){var h,E,g;if(d(o),E=i._events,E===void 0?(E=i._events=Object.create(null),i._eventsCount=0):(E.newListener!==void 0&&(i.emit("newListener",a,o.listener?o.listener:o),E=i._events),g=E[a]),g===void 0)g=E[a]=o,++i._eventsCount;else if(typeof g=="function"?g=E[a]=l?[o,g]:[g,o]:l?g.unshift(o):g.push(o),h=p(i),h>0&&g.length>h&&!g.warned){g.warned=!0;var L=new Error("Possible EventEmitter memory leak detected. "+g.length+" "+String(a)+" listeners added. Use emitter.setMaxListeners() to increase limit");L.name="MaxListenersExceededWarning",L.emitter=i,L.type=a,L.count=g.length,u(L)}return i}r.prototype.addListener=function(a,o){return m(this,a,o,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(a,o){return m(this,a,o,!0)};function _(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function S(i,a,o){var l={fired:!1,wrapFn:void 0,target:i,type:a,listener:o},h=_.bind(l);return h.listener=o,l.wrapFn=h,h}r.prototype.once=function(a,o){return d(o),this.on(a,S(this,a,o)),this},r.prototype.prependOnceListener=function(a,o){return d(o),this.prependListener(a,S(this,a,o)),this},r.prototype.removeListener=function(a,o){var l,h,E,g,L;if(d(o),h=this._events,h===void 0)return this;if(l=h[a],l===void 0)return this;if(l===o||l.listener===o)--this._eventsCount===0?this._events=Object.create(null):(delete h[a],h.removeListener&&this.emit("removeListener",a,l.listener||o));else if(typeof l!="function"){for(E=-1,g=l.length-1;g>=0;g--)if(l[g]===o||l[g].listener===o){L=l[g].listener,E=g;break}if(E<0)return this;E===0?l.shift():y(l,E),l.length===1&&(h[a]=l[0]),h.removeListener!==void 0&&this.emit("removeListener",a,L||o)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(a){var o,l,h;if(l=this._events,l===void 0)return this;if(l.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):l[a]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete l[a]),this;if(arguments.length===0){var E=Object.keys(l),g;for(h=0;h<E.length;++h)g=E[h],g!=="removeListener"&&this.removeAllListeners(g);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(o=l[a],typeof o=="function")this.removeListener(a,o);else if(o!==void 0)for(h=o.length-1;h>=0;h--)this.removeListener(a,o[h]);return this};function O(i,a,o){var l=i._events;if(l===void 0)return[];var h=l[a];return h===void 0?[]:typeof h=="function"?o?[h.listener||h]:[h]:o?R(h):F(h,h.length)}r.prototype.listeners=function(a){return O(this,a,!0)},r.prototype.rawListeners=function(a){return O(this,a,!1)},r.listenerCount=function(i,a){return typeof i.listenerCount=="function"?i.listenerCount(a):P.call(i,a)},r.prototype.listenerCount=P;function P(i){var a=this._events;if(a!==void 0){var o=a[i];if(typeof o=="function")return 1;if(o!==void 0)return o.length}return 0}r.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function F(i,a){for(var o=new Array(a),l=0;l<a;++l)o[l]=i[l];return o}function y(i,a){for(;a+1<i.length;a++)i[a]=i[a+1];i.pop()}function R(i){for(var a=new Array(i.length),o=0;o<a.length;++o)a[o]=i[o].listener||i[o];return a}function A(i,a){return new Promise(function(o,l){function h(g){i.removeListener(a,E),l(g)}function E(){typeof i.removeListener=="function"&&i.removeListener("error",h),o([].slice.call(arguments))}H(i,a,E,{once:!0}),a!=="error"&&U(i,h,{once:!0})})}function U(i,a,o){typeof i.on=="function"&&H(i,"error",a,o)}function H(i,a,o,l){if(typeof i.on=="function")l.once?i.once(a,o):i.on(a,o);else if(typeof i.addEventListener=="function")i.addEventListener(a,function h(E){l.once&&i.removeEventListener(a,h),o(E)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof i)}return Z.exports}var De=ke();const Ie=W(De);var xe=typeof global=="object"&&global&&global.Object===Object&&global,Fe=typeof self=="object"&&self&&self.Object===Object&&self,$=xe||Fe||Function("return this")(),q=$.Symbol,pe=Object.prototype,We=pe.hasOwnProperty,ze=pe.toString,J=q?q.toStringTag:void 0;function Ye(e){var t=We.call(e,J),n=e[J];try{e[J]=void 0;var u=!0}catch{}var f=ze.call(e);return u&&(t?e[J]=n:delete e[J]),f}var Ge=Object.prototype,Ue=Ge.toString;function He(e){return Ue.call(e)}var Ve="[object Null]",Je="[object Undefined]",ve=q?q.toStringTag:void 0;function me(e){return e==null?e===void 0?Je:Ve:ve&&ve in Object(e)?Ye(e):He(e)}function Xe(e){return e!=null&&typeof e=="object"}var Ke="[object Symbol]";function Be(e){return typeof e=="symbol"||Xe(e)&&me(e)==Ke}var Qe=/\s/;function Ze(e){for(var t=e.length;t--&&Qe.test(e.charAt(t)););return t}var $e=/^\s+/;function qe(e){return e&&e.slice(0,Ze(e)+1).replace($e,"")}function z(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var be=NaN,et=/^[-+]0x[0-9a-f]+$/i,tt=/^0b[01]+$/i,nt=/^0o[0-7]+$/i,rt=parseInt;function ge(e){if(typeof e=="number")return e;if(Be(e))return be;if(z(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=z(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=qe(e);var n=tt.test(e);return n||nt.test(e)?rt(e.slice(2),n?2:8):et.test(e)?be:+e}var ot="[object AsyncFunction]",at="[object Function]",st="[object GeneratorFunction]",it="[object Proxy]";function ut(e){if(!z(e))return!1;var t=me(e);return t==at||t==st||t==ot||t==it}var se=$["__core-js_shared__"],_e=function(){var e=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ct(e){return!!_e&&_e in e}var ft=Function.prototype,lt=ft.toString;function dt(e){if(e!=null){try{return lt.call(e)}catch{}try{return e+""}catch{}}return""}var ht=/[\\^$.*+?()[\]{}|]/g,pt=/^\[object .+?Constructor\]$/,vt=Function.prototype,mt=Object.prototype,bt=vt.toString,gt=mt.hasOwnProperty,_t=RegExp("^"+bt.call(gt).replace(ht,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Et(e){if(!z(e)||ct(e))return!1;var t=ut(e)?_t:pt;return t.test(dt(e))}function yt(e,t){return e==null?void 0:e[t]}function Ee(e,t){var n=yt(e,t);return Et(n)?n:void 0}function Tt(e,t){return e===t||e!==e&&t!==t}var X=Ee(Object,"create");function St(){this.__data__=X?X(null):{},this.size=0}function wt(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ot="__lodash_hash_undefined__",Rt=Object.prototype,Ct=Rt.hasOwnProperty;function jt(e){var t=this.__data__;if(X){var n=t[e];return n===Ot?void 0:n}return Ct.call(t,e)?t[e]:void 0}var Lt=Object.prototype,Pt=Lt.hasOwnProperty;function Nt(e){var t=this.__data__;return X?t[e]!==void 0:Pt.call(t,e)}var At="__lodash_hash_undefined__";function Mt(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=X&&t===void 0?At:t,this}function D(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var u=e[t];this.set(u[0],u[1])}}D.prototype.clear=St,D.prototype.delete=wt,D.prototype.get=jt,D.prototype.has=Nt,D.prototype.set=Mt;function kt(){this.__data__=[],this.size=0}function ee(e,t){for(var n=e.length;n--;)if(Tt(e[n][0],t))return n;return-1}var Dt=Array.prototype,It=Dt.splice;function xt(e){var t=this.__data__,n=ee(t,e);if(n<0)return!1;var u=t.length-1;return n==u?t.pop():It.call(t,n,1),--this.size,!0}function Ft(e){var t=this.__data__,n=ee(t,e);return n<0?void 0:t[n][1]}function Wt(e){return ee(this.__data__,e)>-1}function zt(e,t){var n=this.__data__,u=ee(n,e);return u<0?(++this.size,n.push([e,t])):n[u][1]=t,this}function Y(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var u=e[t];this.set(u[0],u[1])}}Y.prototype.clear=kt,Y.prototype.delete=xt,Y.prototype.get=Ft,Y.prototype.has=Wt,Y.prototype.set=zt;var Yt=Ee($,"Map");function Gt(){this.size=0,this.__data__={hash:new D,map:new(Yt||Y),string:new D}}function Ut(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function te(e,t){var n=e.__data__;return Ut(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Ht(e){var t=te(this,e).delete(e);return this.size-=t?1:0,t}function Vt(e){return te(this,e).get(e)}function Jt(e){return te(this,e).has(e)}function Xt(e,t){var n=te(this,e),u=n.size;return n.set(e,t),this.size+=n.size==u?0:1,this}function I(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var u=e[t];this.set(u[0],u[1])}}I.prototype.clear=Gt,I.prototype.delete=Ht,I.prototype.get=Vt,I.prototype.has=Jt,I.prototype.set=Xt;var Kt="Expected a function";function ie(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Kt);var n=function(){var u=arguments,f=t?t.apply(this,u):u[0],r=n.cache;if(r.has(f))return r.get(f);var c=e.apply(this,u);return n.cache=r.set(f,c)||r,c};return n.cache=new(ie.Cache||I),n}ie.Cache=I;var ue=function(){return $.Date.now()},Bt="Expected a function",Qt=Math.max,Zt=Math.min;function ne(e,t,n){var u,f,r,c,d,p,m=0,_=!1,S=!1,O=!0;if(typeof e!="function")throw new TypeError(Bt);t=ge(t)||0,z(n)&&(_=!!n.leading,S="maxWait"in n,r=S?Qt(ge(n.maxWait)||0,t):r,O="trailing"in n?!!n.trailing:O);function P(o){var l=u,h=f;return u=f=void 0,m=o,c=e.apply(h,l),c}function F(o){return m=o,d=setTimeout(A,t),_?P(o):c}function y(o){var l=o-p,h=o-m,E=t-l;return S?Zt(E,r-h):E}function R(o){var l=o-p,h=o-m;return p===void 0||l>=t||l<0||S&&h>=r}function A(){var o=ue();if(R(o))return U(o);d=setTimeout(A,y(o))}function U(o){return d=void 0,O&&u?P(o):(u=f=void 0,c)}function H(){d!==void 0&&clearTimeout(d),m=0,u=p=f=d=void 0}function i(){return d===void 0?c:U(ue())}function a(){var o=ue(),l=R(o);if(u=arguments,f=this,p=o,l){if(d===void 0)return F(p);if(S)return clearTimeout(d),d=setTimeout(A,t),P(p)}return d===void 0&&(d=setTimeout(A,t)),c}return a.cancel=H,a.flush=i,a}var $t="Expected a function";function qt(e,t,n){var u=!0,f=!0;if(typeof e!="function")throw new TypeError($t);return z(n)&&(u="leading"in n?!!n.leading:u,f="trailing"in n?!!n.trailing:f),ne(e,t,{leading:u,maxWait:t,trailing:f})}const ye=()=>Math.random().toString().slice(2),en=e=>{const{current:{computedHash:t}}=v.useRef({get computedHash(){let n=[],u=ye();return f=>{let r=!1;return r=r||!f!=!n,r=r||(f==null?void 0:f.length)!=(n==null?void 0:n.length),r=r||f.some((c,d)=>c!=n[d]),n=f,r&&(u=ye()),u}}});return t(e)};class Te{constructor(t){ae(this,"event",new Ie.EventEmitter);ae(this,"data",{});ae(this,"registry",new Set);this.name=t,console.log("[CONTEXT] %s",t),this.event.setMaxListeners(100)}publish(t,n){n!=this.data[t]&&(this.data[t]=n,this.event.emit(String(t),{value:n}))}subscribe(t,n){const u=({value:f})=>{n(f)};return this.event.addListener(String(t),u),t in this.data&&n(this.data[t]),()=>(this.event.removeListener(String(t),u),void 0)}}const Se=ie(e=>new Te(e)),x=(e="noname")=>v.useMemo(()=>Se(e),[e]),we=(e,...t)=>{const n=new Error("[ctx] useRegistryChecker failed "+JSON.stringify({names:t,ctx:(e==null?void 0:e.name)??"undefined"}));v.useEffect(()=>{if(e)return t.some(u=>e.registry.has(u))&&console.error(n),t.forEach(u=>e.registry.add(u)),()=>{t.forEach(u=>e.registry.delete(u))}},[e,t.length])},tn=(e,t,n)=>{v.useEffect(()=>{e&&e.data[t]!=n&&e.publish(t,n)},[t,n,e]),we(e,t)},Oe=(e,t,n=0)=>{const[{value:u},f]=v.useState(()=>{var r;return{value:(r=e==null?void 0:e.data)==null?void 0:r[t]}});return v.useEffect(()=>{if(e){let r=n==0?d=>f({value:d}):ne(d=>f({value:d}),n),c=e.subscribe(t,r);return u!=e.data[t]&&f({value:e.data[t]}),()=>{c()}}},[t,e]),e==null?void 0:e.data[t]},nn=(e,t,n)=>{const[,u]=v.useState(0),f=v.useMemo(()=>n(e==null?void 0:e.data[t]),[n,e==null?void 0:e.data[t]]);return v.useEffect(()=>{if(e){let r=f,c=()=>{let p=n(e.data[t]);p!=r&&(r=p,u(m=>m+1))},d=e.subscribe(t,c);return c(),()=>d()}},[t,e]),f},ce=(e,...t)=>{v.useEffect(()=>{if(e)for(let[n,u]of t)e.data[n]!=u&&e.publish(n,u)},[e,en(t.flat())]),we(e,...t.map(n=>n[0]))},rn=(e,...t)=>{const[,n]=v.useState(0),u=t.map(f=>{var r;return(r=e==null?void 0:e.data)==null?void 0:r[f]});return v.useEffect(()=>{if(e){let f=u;const r=ne(()=>{let p=t.map(m=>{var _;return(_=e==null?void 0:e.data)==null?void 0:_[m]});t.some((m,_)=>f[_]!=p[_])&&(f=p,n(m=>m+1))},1);let c=t.map(p=>e.subscribe(p,r)),d=setTimeout(r,1);return()=>{clearTimeout(d),r.cancel(),c.forEach(p=>p())}}},[e,...t]),Object.fromEntries(t.map((f,r)=>[f,u[r]]))},on=(e,t=100,...n)=>{const[,u]=v.useState(0),f=n.map(r=>{var c;return(c=e==null?void 0:e.data)==null?void 0:c[r]});return v.useEffect(()=>{if(e){let r=f;const c=qt(()=>{let m=n.map(_=>{var S;return(S=e==null?void 0:e.data)==null?void 0:S[_]});n.some((_,S)=>r[S]!=m[S])&&(r=m,u(_=>_+1))},t);let d=n.map(m=>e.subscribe(m,c)),p=setTimeout(c,1);return()=>{clearTimeout(p),c.cancel(),d.forEach(m=>m())}}},[e,...n]),f};var re={exports:{}},K={};/**
|
|
1
|
+
(function(y,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],v):(y=typeof globalThis<"u"?globalThis:y||self,v(y.RState={},y.React))})(this,function(y,v){"use strict";var mn=Object.defineProperty;var bn=(y,v,W)=>v in y?mn(y,v,{enumerable:!0,configurable:!0,writable:!0,value:W}):y[v]=W;var ae=(y,v,W)=>bn(y,typeof v!="symbol"?v+"":v,W);function W(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z={exports:{}},he;function De(){if(he)return Z.exports;he=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(a,o,l){return Function.prototype.apply.call(a,o,l)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(a){return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a))}:n=function(a){return Object.getOwnPropertyNames(a)};function u(i){console&&console.warn&&console.warn(i)}var c=Number.isNaN||function(a){return a!==a};function r(){r.init.call(this)}Z.exports=r,Z.exports.once=A,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var f=10;function d(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return f},set:function(i){if(typeof i!="number"||i<0||c(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");f=i}}),r.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(a){if(typeof a!="number"||a<0||c(a))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+a+".");return this._maxListeners=a,this};function p(i){return i._maxListeners===void 0?r.defaultMaxListeners:i._maxListeners}r.prototype.getMaxListeners=function(){return p(this)},r.prototype.emit=function(a){for(var o=[],l=1;l<arguments.length;l++)o.push(arguments[l]);var h=a==="error",E=this._events;if(E!==void 0)h=h&&E.error===void 0;else if(!h)return!1;if(h){var g;if(o.length>0&&(g=o[0]),g instanceof Error)throw g;var L=new Error("Unhandled error."+(g?" ("+g.message+")":""));throw L.context=g,L}var M=E[a];if(M===void 0)return!1;if(typeof M=="function")t(M,this,o);else for(var oe=M.length,Q=F(M,oe),l=0;l<oe;++l)t(Q[l],this,o);return!0};function m(i,a,o,l){var h,E,g;if(d(o),E=i._events,E===void 0?(E=i._events=Object.create(null),i._eventsCount=0):(E.newListener!==void 0&&(i.emit("newListener",a,o.listener?o.listener:o),E=i._events),g=E[a]),g===void 0)g=E[a]=o,++i._eventsCount;else if(typeof g=="function"?g=E[a]=l?[o,g]:[g,o]:l?g.unshift(o):g.push(o),h=p(i),h>0&&g.length>h&&!g.warned){g.warned=!0;var L=new Error("Possible EventEmitter memory leak detected. "+g.length+" "+String(a)+" listeners added. Use emitter.setMaxListeners() to increase limit");L.name="MaxListenersExceededWarning",L.emitter=i,L.type=a,L.count=g.length,u(L)}return i}r.prototype.addListener=function(a,o){return m(this,a,o,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(a,o){return m(this,a,o,!0)};function _(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function S(i,a,o){var l={fired:!1,wrapFn:void 0,target:i,type:a,listener:o},h=_.bind(l);return h.listener=o,l.wrapFn=h,h}r.prototype.once=function(a,o){return d(o),this.on(a,S(this,a,o)),this},r.prototype.prependOnceListener=function(a,o){return d(o),this.prependListener(a,S(this,a,o)),this},r.prototype.removeListener=function(a,o){var l,h,E,g,L;if(d(o),h=this._events,h===void 0)return this;if(l=h[a],l===void 0)return this;if(l===o||l.listener===o)--this._eventsCount===0?this._events=Object.create(null):(delete h[a],h.removeListener&&this.emit("removeListener",a,l.listener||o));else if(typeof l!="function"){for(E=-1,g=l.length-1;g>=0;g--)if(l[g]===o||l[g].listener===o){L=l[g].listener,E=g;break}if(E<0)return this;E===0?l.shift():T(l,E),l.length===1&&(h[a]=l[0]),h.removeListener!==void 0&&this.emit("removeListener",a,L||o)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(a){var o,l,h;if(l=this._events,l===void 0)return this;if(l.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):l[a]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete l[a]),this;if(arguments.length===0){var E=Object.keys(l),g;for(h=0;h<E.length;++h)g=E[h],g!=="removeListener"&&this.removeAllListeners(g);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(o=l[a],typeof o=="function")this.removeListener(a,o);else if(o!==void 0)for(h=o.length-1;h>=0;h--)this.removeListener(a,o[h]);return this};function O(i,a,o){var l=i._events;if(l===void 0)return[];var h=l[a];return h===void 0?[]:typeof h=="function"?o?[h.listener||h]:[h]:o?R(h):F(h,h.length)}r.prototype.listeners=function(a){return O(this,a,!0)},r.prototype.rawListeners=function(a){return O(this,a,!1)},r.listenerCount=function(i,a){return typeof i.listenerCount=="function"?i.listenerCount(a):P.call(i,a)},r.prototype.listenerCount=P;function P(i){var a=this._events;if(a!==void 0){var o=a[i];if(typeof o=="function")return 1;if(o!==void 0)return o.length}return 0}r.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function F(i,a){for(var o=new Array(a),l=0;l<a;++l)o[l]=i[l];return o}function T(i,a){for(;a+1<i.length;a++)i[a]=i[a+1];i.pop()}function R(i){for(var a=new Array(i.length),o=0;o<a.length;++o)a[o]=i[o].listener||i[o];return a}function A(i,a){return new Promise(function(o,l){function h(g){i.removeListener(a,E),l(g)}function E(){typeof i.removeListener=="function"&&i.removeListener("error",h),o([].slice.call(arguments))}U(i,a,E,{once:!0}),a!=="error"&&H(i,h,{once:!0})})}function H(i,a,o){typeof i.on=="function"&&U(i,"error",a,o)}function U(i,a,o,l){if(typeof i.on=="function")l.once?i.once(a,o):i.on(a,o);else if(typeof i.addEventListener=="function")i.addEventListener(a,function h(E){l.once&&i.removeEventListener(a,h),o(E)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof i)}return Z.exports}var Ie=De();const xe=W(Ie);var Fe=typeof global=="object"&&global&&global.Object===Object&&global,We=typeof self=="object"&&self&&self.Object===Object&&self,$=Fe||We||Function("return this")(),q=$.Symbol,pe=Object.prototype,ze=pe.hasOwnProperty,Ye=pe.toString,J=q?q.toStringTag:void 0;function Ge(e){var t=ze.call(e,J),n=e[J];try{e[J]=void 0;var u=!0}catch{}var c=Ye.call(e);return u&&(t?e[J]=n:delete e[J]),c}var He=Object.prototype,Ue=He.toString;function Ve(e){return Ue.call(e)}var Je="[object Null]",Xe="[object Undefined]",ve=q?q.toStringTag:void 0;function me(e){return e==null?e===void 0?Xe:Je:ve&&ve in Object(e)?Ge(e):Ve(e)}function Ke(e){return e!=null&&typeof e=="object"}var Be="[object Symbol]";function Qe(e){return typeof e=="symbol"||Ke(e)&&me(e)==Be}var Ze=/\s/;function $e(e){for(var t=e.length;t--&&Ze.test(e.charAt(t)););return t}var qe=/^\s+/;function et(e){return e&&e.slice(0,$e(e)+1).replace(qe,"")}function z(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var be=NaN,tt=/^[-+]0x[0-9a-f]+$/i,nt=/^0b[01]+$/i,rt=/^0o[0-7]+$/i,ot=parseInt;function ge(e){if(typeof e=="number")return e;if(Qe(e))return be;if(z(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=z(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=et(e);var n=nt.test(e);return n||rt.test(e)?ot(e.slice(2),n?2:8):tt.test(e)?be:+e}var at="[object AsyncFunction]",st="[object Function]",it="[object GeneratorFunction]",ut="[object Proxy]";function ct(e){if(!z(e))return!1;var t=me(e);return t==st||t==it||t==at||t==ut}var se=$["__core-js_shared__"],_e=function(){var e=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ft(e){return!!_e&&_e in e}var lt=Function.prototype,dt=lt.toString;function ht(e){if(e!=null){try{return dt.call(e)}catch{}try{return e+""}catch{}}return""}var pt=/[\\^$.*+?()[\]{}|]/g,vt=/^\[object .+?Constructor\]$/,mt=Function.prototype,bt=Object.prototype,gt=mt.toString,_t=bt.hasOwnProperty,Et=RegExp("^"+gt.call(_t).replace(pt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function yt(e){if(!z(e)||ft(e))return!1;var t=ct(e)?Et:vt;return t.test(ht(e))}function Tt(e,t){return e==null?void 0:e[t]}function Ee(e,t){var n=Tt(e,t);return yt(n)?n:void 0}function St(e,t){return e===t||e!==e&&t!==t}var X=Ee(Object,"create");function wt(){this.__data__=X?X(null):{},this.size=0}function Ot(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Rt="__lodash_hash_undefined__",jt=Object.prototype,Ct=jt.hasOwnProperty;function Lt(e){var t=this.__data__;if(X){var n=t[e];return n===Rt?void 0:n}return Ct.call(t,e)?t[e]:void 0}var Pt=Object.prototype,Nt=Pt.hasOwnProperty;function At(e){var t=this.__data__;return X?t[e]!==void 0:Nt.call(t,e)}var Mt="__lodash_hash_undefined__";function kt(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=X&&t===void 0?Mt:t,this}function D(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var u=e[t];this.set(u[0],u[1])}}D.prototype.clear=wt,D.prototype.delete=Ot,D.prototype.get=Lt,D.prototype.has=At,D.prototype.set=kt;function Dt(){this.__data__=[],this.size=0}function ee(e,t){for(var n=e.length;n--;)if(St(e[n][0],t))return n;return-1}var It=Array.prototype,xt=It.splice;function Ft(e){var t=this.__data__,n=ee(t,e);if(n<0)return!1;var u=t.length-1;return n==u?t.pop():xt.call(t,n,1),--this.size,!0}function Wt(e){var t=this.__data__,n=ee(t,e);return n<0?void 0:t[n][1]}function zt(e){return ee(this.__data__,e)>-1}function Yt(e,t){var n=this.__data__,u=ee(n,e);return u<0?(++this.size,n.push([e,t])):n[u][1]=t,this}function Y(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var u=e[t];this.set(u[0],u[1])}}Y.prototype.clear=Dt,Y.prototype.delete=Ft,Y.prototype.get=Wt,Y.prototype.has=zt,Y.prototype.set=Yt;var Gt=Ee($,"Map");function Ht(){this.size=0,this.__data__={hash:new D,map:new(Gt||Y),string:new D}}function Ut(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function te(e,t){var n=e.__data__;return Ut(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Vt(e){var t=te(this,e).delete(e);return this.size-=t?1:0,t}function Jt(e){return te(this,e).get(e)}function Xt(e){return te(this,e).has(e)}function Kt(e,t){var n=te(this,e),u=n.size;return n.set(e,t),this.size+=n.size==u?0:1,this}function I(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var u=e[t];this.set(u[0],u[1])}}I.prototype.clear=Ht,I.prototype.delete=Vt,I.prototype.get=Jt,I.prototype.has=Xt,I.prototype.set=Kt;var Bt="Expected a function";function ie(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Bt);var n=function(){var u=arguments,c=t?t.apply(this,u):u[0],r=n.cache;if(r.has(c))return r.get(c);var f=e.apply(this,u);return n.cache=r.set(c,f)||r,f};return n.cache=new(ie.Cache||I),n}ie.Cache=I;var ue=function(){return $.Date.now()},Qt="Expected a function",Zt=Math.max,$t=Math.min;function ne(e,t,n){var u,c,r,f,d,p,m=0,_=!1,S=!1,O=!0;if(typeof e!="function")throw new TypeError(Qt);t=ge(t)||0,z(n)&&(_=!!n.leading,S="maxWait"in n,r=S?Zt(ge(n.maxWait)||0,t):r,O="trailing"in n?!!n.trailing:O);function P(o){var l=u,h=c;return u=c=void 0,m=o,f=e.apply(h,l),f}function F(o){return m=o,d=setTimeout(A,t),_?P(o):f}function T(o){var l=o-p,h=o-m,E=t-l;return S?$t(E,r-h):E}function R(o){var l=o-p,h=o-m;return p===void 0||l>=t||l<0||S&&h>=r}function A(){var o=ue();if(R(o))return H(o);d=setTimeout(A,T(o))}function H(o){return d=void 0,O&&u?P(o):(u=c=void 0,f)}function U(){d!==void 0&&clearTimeout(d),m=0,u=p=c=d=void 0}function i(){return d===void 0?f:H(ue())}function a(){var o=ue(),l=R(o);if(u=arguments,c=this,p=o,l){if(d===void 0)return F(p);if(S)return clearTimeout(d),d=setTimeout(A,t),P(p)}return d===void 0&&(d=setTimeout(A,t)),f}return a.cancel=U,a.flush=i,a}var qt="Expected a function";function en(e,t,n){var u=!0,c=!0;if(typeof e!="function")throw new TypeError(qt);return z(n)&&(u="leading"in n?!!n.leading:u,c="trailing"in n?!!n.trailing:c),ne(e,t,{leading:u,maxWait:t,trailing:c})}const ye=()=>Math.random().toString().slice(2),Te=e=>{const{current:{computedHash:t}}=v.useRef({get computedHash(){let n=[],u=ye();return c=>{let r=!1;return r=r||!c!=!n,r=r||(c==null?void 0:c.length)!=(n==null?void 0:n.length),r=r||c.some((f,d)=>f!=n[d]),n=c,r&&(u=ye()),u}}});return t(e)};class Se{constructor(t){ae(this,"event",new xe.EventEmitter);ae(this,"data",{});ae(this,"registry",new Set);this.name=t,console.log("[CONTEXT] %s",t),this.event.setMaxListeners(100)}publish(t,n){n!=this.data[t]&&(this.data[t]=n,this.event.emit(String(t),{value:n}))}subscribe(t,n){const u=({value:c})=>{n(c)};return this.event.addListener(String(t),u),t in this.data&&n(this.data[t]),()=>(this.event.removeListener(String(t),u),void 0)}}const we=ie(e=>new Se(e)),x=(e="noname")=>v.useMemo(()=>we(e),[e]),Oe=(e,...t)=>{const n=new Error("[ctx] useRegistryChecker failed "+JSON.stringify({names:t,ctx:(e==null?void 0:e.name)??"undefined"}));v.useEffect(()=>{if(e)return t.some(u=>e.registry.has(u))&&console.error(n),t.forEach(u=>e.registry.add(u)),()=>{t.forEach(u=>e.registry.delete(u))}},[e,t.length])},tn=(e,t,n)=>{v.useEffect(()=>{e&&e.data[t]!=n&&e.publish(t,n)},[t,n,e]),Oe(e,t)},Re=(e,t,n=0)=>{const[{value:u},c]=v.useState(()=>{var r;return{value:(r=e==null?void 0:e.data)==null?void 0:r[t]}});return v.useEffect(()=>{if(e){let r=n==0?d=>c({value:d}):ne(d=>c({value:d}),n),f=e.subscribe(t,r);return u!=e.data[t]&&c({value:e.data[t]}),()=>{f()}}},[t,e]),e==null?void 0:e.data[t]},nn=(e,t,n)=>{const[,u]=v.useState(0),c=v.useMemo(()=>n(e==null?void 0:e.data[t]),[n,e==null?void 0:e.data[t]]);return v.useEffect(()=>{if(e){let r=c,f=()=>{let p=n(e.data[t]);p!=r&&(r=p,u(m=>m+1))},d=e.subscribe(t,f);return f(),()=>d()}},[t,e]),c},ce=(e,...t)=>{v.useEffect(()=>{if(e)for(let[n,u]of t)e.data[n]!=u&&e.publish(n,u)},[e,Te(t.flat())]),Oe(e,...t.map(n=>n[0]))},rn=(e,...t)=>{const[,n]=v.useState(0),u=t.map(c=>{var r;return(r=e==null?void 0:e.data)==null?void 0:r[c]});return v.useEffect(()=>{if(e){let c=u;const r=ne(()=>{let p=t.map(m=>{var _;return(_=e==null?void 0:e.data)==null?void 0:_[m]});t.some((m,_)=>c[_]!=p[_])&&(c=p,n(m=>m+1))},1);let f=t.map(p=>e.subscribe(p,r)),d=setTimeout(r,1);return()=>{clearTimeout(d),r.cancel(),f.forEach(p=>p())}}},[e,...t]),Object.fromEntries(t.map((c,r)=>[c,u[r]]))},on=(e,t=100,...n)=>{const[,u]=v.useState(0),c=n.map(r=>{var f;return(f=e==null?void 0:e.data)==null?void 0:f[r]});return v.useEffect(()=>{if(e){let r=c;const f=en(()=>{let m=n.map(_=>{var S;return(S=e==null?void 0:e.data)==null?void 0:S[_]});n.some((_,S)=>r[S]!=m[S])&&(r=m,u(_=>_+1))},t);let d=n.map(m=>e.subscribe(m,f)),p=setTimeout(f,1);return()=>{clearTimeout(p),f.cancel(),d.forEach(m=>m())}}},[e,...n]),c};var re={exports:{}},K={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var je;function an(){if(je)return K;je=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(u,c,r){var f=null;if(r!==void 0&&(f=""+r),c.key!==void 0&&(f=""+c.key),"key"in c){r={};for(var d in c)d!=="key"&&(r[d]=c[d])}else r=c;return c=r.ref,{$$typeof:e,type:u,key:f,ref:c!==void 0?c:null,props:r}}return K.Fragment=t,K.jsx=n,K.jsxs=n,K}var B={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Ce;function sn(){return Ce||(Ce=1,process.env.NODE_ENV!=="production"&&function(){function e(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===g?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case
|
|
17
|
+
*/var Ce;function sn(){return Ce||(Ce=1,process.env.NODE_ENV!=="production"&&function(){function e(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===g?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case T:return"Fragment";case A:return"Profiler";case R:return"StrictMode";case a:return"Suspense";case o:return"SuspenseList";case E:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case F:return"Portal";case U:return(s.displayName||"Context")+".Provider";case H:return(s._context.displayName||"Context")+".Consumer";case i:var b=s.render;return s=s.displayName,s||(s=b.displayName||b.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case l:return b=s.displayName||null,b!==null?b:e(s.type)||"Memo";case h:b=s._payload,s=s._init;try{return e(s(b))}catch{}}return null}function t(s){return""+s}function n(s){try{t(s);var b=!1}catch{b=!0}if(b){b=console;var w=b.error,j=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return w.call(b,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",j),t(s)}}function u(s){if(s===T)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===h)return"<...>";try{var b=e(s);return b?"<"+b+">":"<...>"}catch{return"<...>"}}function c(){var s=L.A;return s===null?null:s.getOwner()}function r(){return Error("react-stack-top-frame")}function f(s){if(M.call(s,"key")){var b=Object.getOwnPropertyDescriptor(s,"key").get;if(b&&b.isReactWarning)return!1}return s.key!==void 0}function d(s,b){function w(){Pe||(Pe=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",b))}w.isReactWarning=!0,Object.defineProperty(s,"key",{get:w,configurable:!0})}function p(){var s=e(this.type);return Ne[s]||(Ne[s]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),s=this.props.ref,s!==void 0?s:null}function m(s,b,w,j,k,N,fe,le){return w=N.ref,s={$$typeof:P,type:s,key:b,props:N,_owner:k},(w!==void 0?w:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:p}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:fe}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:le}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function _(s,b,w,j,k,N,fe,le){var C=b.children;if(C!==void 0)if(j)if(oe(C)){for(j=0;j<C.length;j++)S(C[j]);Object.freeze&&Object.freeze(C)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else S(C);if(M.call(b,"key")){C=e(s);var V=Object.keys(b).filter(function(vn){return vn!=="key"});j=0<V.length?"{key: someKey, "+V.join(": ..., ")+": ...}":"{key: someKey}",ke[C+j]||(V=0<V.length?"{"+V.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,C,
|
|
22
|
+
<%s key={someKey} {...props} />`,j,C,V,C),ke[C+j]=!0)}if(C=null,w!==void 0&&(n(w),C=""+w),f(b)&&(n(b.key),C=""+b.key),"key"in b){w={};for(var de in b)de!=="key"&&(w[de]=b[de])}else w=b;return C&&d(w,typeof s=="function"?s.displayName||s.name||"Unknown":s),m(s,C,N,k,c(),w,fe,le)}function S(s){typeof s=="object"&&s!==null&&s.$$typeof===P&&s._store&&(s._store.validated=1)}var O=v,P=Symbol.for("react.transitional.element"),F=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),U=Symbol.for("react.context"),i=Symbol.for("react.forward_ref"),a=Symbol.for("react.suspense"),o=Symbol.for("react.suspense_list"),l=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),g=Symbol.for("react.client.reference"),L=O.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=Object.prototype.hasOwnProperty,oe=Array.isArray,Q=console.createTask?console.createTask:function(){return null};O={"react-stack-bottom-frame":function(s){return s()}};var Pe,Ne={},Ae=O["react-stack-bottom-frame"].bind(O,r)(),Me=Q(u(r)),ke={};B.Fragment=T,B.jsx=function(s,b,w,j,k){var N=1e4>L.recentlyCreatedOwnerStacks++;return _(s,b,w,!1,j,k,N?Error("react-stack-top-frame"):Ae,N?Q(u(s)):Me)},B.jsxs=function(s,b,w,j,k){var N=1e4>L.recentlyCreatedOwnerStacks++;return _(s,b,w,!0,j,k,N?Error("react-stack-top-frame"):Ae,N?Q(u(s)):Me)}}()),B}var Le;function un(){return Le||(Le=1,process.env.NODE_ENV==="production"?re.exports=an():re.exports=sn()),re.exports}var G=un();const cn=(e,t)=>{const n=r=>[e,...Object.entries(r??{}).sort((f,d)=>f[0].localeCompare(d[0])).flat()].join("-");let u=new Set;const c=r=>{const f=t(r),d=n(r),p=x(d),m=v.useMemo(()=>new Error().stack,[]);return ce(p,...Object.entries(f)),v.useEffect(()=>{if(u.has(d)){const _=new Error("RootContext "+d+" are mounted more than once");throw _.stack=m,_}return u.add(d),()=>{u.delete(d)}}),G.jsx(G.Fragment,{})};return c.displayName=`State[${(t==null?void 0:t.name)??"??"}]`,{resolveCtxName:n,Root:c,useCtxStateStrict:r=>{const f=n(r),d=v.useMemo(()=>new Error().stack,[]);return v.useEffect(()=>{if(!u.has(f)){const p=new Error("RootContext ["+f+"] is not mounted");throw p.stack=d,p}},[f]),x(f)},useCtxState:r=>{const f=n(r),d=v.useMemo(()=>new Error().stack,[]);return v.useEffect(()=>{if(!u.has(f)){const p=new Error("RootContext ["+f+"] is not mounted");p.stack=d;let m=setTimeout(()=>console.error(p),1e3);return()=>clearTimeout(m)}},[u.has(f)]),x(f)}}},fn=function(){const e=new WeakMap;return t=>{let n=e.get(t);return n||e.set(t,n=((t==null?void 0:t.name)??"")+Math.random().toString()),n}}(),ln=e=>[...Object.entries(e??{}).sort((t,n)=>t[0].localeCompare(n[0])).flat()].join("-"),dn=({Wrapper:e=v.Fragment})=>{const t=x("auto-ctx"),[n,u]=v.useState({}),c=v.useCallback((r,f)=>{const d=fn(r),p=ln(f);return u(({[d]:{Component:m=r,subState:{[p]:_={params:f,counter:0},...S}={}}={},...O})=>({...O,[d]:{Component:m,subState:{...S,[p]:{..._,counter:_.counter+1}}}})),()=>u(({[d]:{Component:m=r,subState:{[p]:_={params:f,counter:0},...S}={}}={},...O})=>({...O,[d]:{Component:m,subState:{...S,..._.counter>1?{[p]:{..._,counter:_.counter-1}}:{}}}}))},[]);return ce(t,["subscribe",c],["state",n]),G.jsx(G.Fragment,{children:Object.entries(n).flatMap(([r,{Component:f,subState:d}])=>Object.entries(d).map(([p,{counter:m,params:_}])=>({key:r+p,Component:f,params:_,counter:m})).filter(p=>p.counter>0).map(({key:p,params:m,Component:_})=>G.jsx(e,{children:G.jsx(_,{...m})},p)))})},hn=({Root:e,useCtxState:t,useCtxStateStrict:n,resolveCtxName:u})=>({useCtxState:c=>{const r=u(c),f=Re(x("auto-ctx"),"subscribe");return v.useEffect(()=>f==null?void 0:f(e,c),[f,r]),x(r)}}),pn=e=>{const[,t]=v.useState(0),{proxy:n,finalGetter:u,openGetter:c,clean:r}=v.useMemo(()=>{const f=new Set,d={},p=new Map,m=new Proxy(e==null?void 0:e.data,{get(T,R){if(_)return f.add(R),d[R]=T[R];throw new Error("now allow here")}});let _=!0,S=ne(()=>{[...f.values()].some(T=>{var R;return d[T]!=((R=e==null?void 0:e.data)==null?void 0:R[T])})&&t(T=>T+1)},0),O=()=>{_=!0,f.clear()},P=()=>{_=!1,[...f.values()].filter(T=>!p.has(T)).forEach(T=>{p.set(T,e==null?void 0:e.subscribe(T,S))}),[...p.keys()].filter(T=>!f.has(T)).forEach(T=>{let R=p.get(T);R==null||R(),p.delete(T)})};return{proxy:m,finalGetter:P,openGetter:O,clean:()=>{O(),P(),t(T=>T+1)}}},[e]);return c(),setTimeout(u,0),v.useEffect(()=>()=>r(),[r]),n};y.AutoRootCtx=dn,y.Context=Se,y.createAutoCtx=hn,y.createRootCtx=cn,y.getContext=we,y.useDataContext=x,y.useDataSource=tn,y.useDataSourceMultiple=ce,y.useDataSubscribe=Re,y.useDataSubscribeMultiple=rn,y.useDataSubscribeMultipleWithDebounce=on,y.useDataSubscribeWithTransform=nn,y.useObjHash=Te,y.useQuickSubscribe=pn,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-state-custom",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "A React library built with Vite and TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.umd.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"events": "^3.3.0",
|
|
19
19
|
"lodash-es": "^4.17.21",
|
|
20
|
-
"
|
|
20
|
+
"vite-bundle-analyzer": "^1.1.0",
|
|
21
21
|
"vite-plugin-dts": "^4.5.4"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export {
|
|
|
14
14
|
|
|
15
15
|
export { createRootCtx } from "./state-utils/createRootCtx"
|
|
16
16
|
export { AutoRootCtx, createAutoCtx } from "./state-utils/createAutoCtx"
|
|
17
|
+
export { useObjHash } from "./state-utils/useObjectHash"
|
|
17
18
|
|
|
18
19
|
export { useQuickSubscribeV2 as useQuickSubscribe } from "./state-utils/useQuickSubscribeV2"
|
|
19
20
|
|
|
@@ -17,9 +17,9 @@ export const createRootCtx = <U extends object, V extends object>(name: string,
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
const RootState: React.FC<U> = (e: U) => {
|
|
20
|
+
const state = useFn(e)
|
|
20
21
|
const ctxName = resolveCtxName(e)
|
|
21
22
|
const ctx = useDataContext<V>(ctxName)
|
|
22
|
-
const state = useFn(e)
|
|
23
23
|
const stack = useMemo(() => new Error().stack, [])
|
|
24
24
|
|
|
25
25
|
useDataSourceMultiple(
|
package/vite.config.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
3
|
import dts from 'vite-plugin-dts'
|
|
4
|
+
import { analyzer } from 'vite-bundle-analyzer'
|
|
4
5
|
|
|
5
6
|
export default defineConfig({
|
|
6
7
|
plugins: [
|
|
7
8
|
react(),
|
|
8
9
|
dts({
|
|
9
10
|
include: ['src'],
|
|
10
|
-
})
|
|
11
|
+
}),
|
|
12
|
+
analyzer({
|
|
13
|
+
analyzerMode: "server",
|
|
14
|
+
openAnalyzer: true
|
|
15
|
+
}),
|
|
11
16
|
],
|
|
12
17
|
build: {
|
|
13
18
|
lib: {
|