atomirx 0.0.4 → 0.0.6
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/README.md +2 -2
- package/coverage/src/core/onCreateHook.ts.html +72 -70
- package/dist/core/derived.d.ts +15 -2
- package/dist/core/effect.d.ts +6 -2
- package/dist/core/hook.d.ts +1 -1
- package/dist/core/onCreateHook.d.ts +37 -23
- package/dist/core/onErrorHook.d.ts +49 -0
- package/dist/core/onErrorHook.test.d.ts +1 -0
- package/dist/core/types.d.ts +52 -3
- package/dist/core/withReady.d.ts +46 -0
- package/dist/index-CBVj1kSj.js +1350 -0
- package/dist/index-Cxk9v0um.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12 -11
- package/dist/react/index.cjs +9 -9
- package/dist/react/index.js +76 -75
- package/package.json +5 -5
- package/src/core/atom.ts +1 -1
- package/src/core/define.test.ts +12 -11
- package/src/core/define.ts +1 -1
- package/src/core/derived.test.ts +179 -0
- package/src/core/derived.ts +51 -8
- package/src/core/effect.test.ts +395 -9
- package/src/core/effect.ts +56 -29
- package/src/core/hook.test.ts +5 -5
- package/src/core/hook.ts +1 -1
- package/src/core/onCreateHook.ts +38 -23
- package/src/core/onErrorHook.test.ts +350 -0
- package/src/core/onErrorHook.ts +52 -0
- package/src/core/types.ts +53 -3
- package/src/core/withReady.test.ts +174 -0
- package/src/core/withReady.ts +91 -27
- package/src/index.ts +10 -1
- package/dist/index-CqO6BDwj.cjs +0 -1
- package/dist/index-D8RDOTB_.js +0 -1319
package/dist/react/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var _r = Object.defineProperty;
|
|
2
2
|
var Sr = (n, a, l) => a in n ? _r(n, a, { enumerable: !0, configurable: !0, writable: !0, value: l }) : n[a] = l;
|
|
3
|
-
var
|
|
4
|
-
import Le, { useRef as
|
|
5
|
-
import { i as z, r as ae, s as Fe, t as Ie, w as Cr, a as Pr, b as We } from "../index-
|
|
6
|
-
import { A as Gr, c as
|
|
3
|
+
var Ae = (n, a, l) => Sr(n, typeof a != "symbol" ? a + "" : a, l);
|
|
4
|
+
import Le, { useRef as A, useCallback as U, useSyncExternalStore as Or, useReducer as Tr, useEffect as De, memo as jr, Suspense as xr, Component as wr } from "react";
|
|
5
|
+
import { i as z, r as ae, s as Fe, t as Ie, w as Cr, a as Pr, b as We } from "../index-CBVj1kSj.js";
|
|
6
|
+
import { A as Gr, c as Hr, e as Xr, f as Zr, g as Qr, h as et, j as rt, l as tt, k as nt, n as at, m as ot, o as it, q as st, v as ut, x as ct, d as lt, p as ft, u as dt } from "../index-CBVj1kSj.js";
|
|
7
7
|
function Ue(n, a) {
|
|
8
|
-
const l = z(n) ? ({ read: d }) => d(n) : n, b = ae(a ?? "shallow"), g =
|
|
8
|
+
const l = z(n) ? ({ read: d }) => d(n) : n, b = ae(a ?? "shallow"), g = A(l), T = A(b);
|
|
9
9
|
g.current = l, T.current = b;
|
|
10
|
-
const h =
|
|
10
|
+
const h = A(/* @__PURE__ */ new Map()), v = A(/* @__PURE__ */ new Set()), i = A({
|
|
11
11
|
value: void 0,
|
|
12
12
|
initialized: !1
|
|
13
13
|
}), S = U(() => {
|
|
@@ -21,15 +21,15 @@ function Ue(n, a) {
|
|
|
21
21
|
}, []), f = U((d) => {
|
|
22
22
|
const E = h.current, P = () => {
|
|
23
23
|
const D = v.current;
|
|
24
|
-
for (const [
|
|
25
|
-
D.has(
|
|
26
|
-
for (const
|
|
27
|
-
if (!E.has(
|
|
28
|
-
const R =
|
|
24
|
+
for (const [k, R] of E)
|
|
25
|
+
D.has(k) || (R(), E.delete(k));
|
|
26
|
+
for (const k of D)
|
|
27
|
+
if (!E.has(k)) {
|
|
28
|
+
const R = k.on(() => {
|
|
29
29
|
const j = Fe(g.current);
|
|
30
30
|
v.current = j.dependencies, P(), d();
|
|
31
31
|
});
|
|
32
|
-
E.set(
|
|
32
|
+
E.set(k, R);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
return P(), () => {
|
|
@@ -40,11 +40,11 @@ function Ue(n, a) {
|
|
|
40
40
|
}, []);
|
|
41
41
|
return Or(f, S, S);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function kr(n) {
|
|
44
44
|
return n == null ? "strict" : Array.isArray(n) ? "shallow" : n instanceof Date ? "deep" : typeof n == "object" ? "shallow" : "strict";
|
|
45
45
|
}
|
|
46
46
|
function Nr(n, a) {
|
|
47
|
-
const l =
|
|
47
|
+
const l = A({}), b = A(null);
|
|
48
48
|
b.current === null && (b.current = {});
|
|
49
49
|
const g = l.current, T = b.current;
|
|
50
50
|
for (const h of Object.keys(n)) {
|
|
@@ -59,7 +59,7 @@ function Nr(n, a) {
|
|
|
59
59
|
g[h] = { value: E }, T[h] = E;
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
|
-
const S = a == null ? void 0 : a[h], f = S ? ae(S) : ae(
|
|
62
|
+
const S = a == null ? void 0 : a[h], f = S ? ae(S) : ae(kr(v)), [d] = Ie(
|
|
63
63
|
i,
|
|
64
64
|
v,
|
|
65
65
|
f
|
|
@@ -79,7 +79,7 @@ const Ve = {
|
|
|
79
79
|
result: void 0,
|
|
80
80
|
error: void 0
|
|
81
81
|
};
|
|
82
|
-
function
|
|
82
|
+
function Ar(n, a) {
|
|
83
83
|
switch (a.type) {
|
|
84
84
|
case "START":
|
|
85
85
|
return qe;
|
|
@@ -103,9 +103,9 @@ function kr(n, a) {
|
|
|
103
103
|
}
|
|
104
104
|
function zr(n, a = {}) {
|
|
105
105
|
const { lazy: l = !0, exclusive: b = !0, deps: g = [] } = a, T = l ? Ve : qe, [h, v] = Tr(
|
|
106
|
-
|
|
106
|
+
Ar,
|
|
107
107
|
T
|
|
108
|
-
), i =
|
|
108
|
+
), i = A(null), S = A(n);
|
|
109
109
|
S.current = n;
|
|
110
110
|
const f = U(() => {
|
|
111
111
|
const R = i.current;
|
|
@@ -150,13 +150,13 @@ function zr(n, a = {}) {
|
|
|
150
150
|
}, [l, ...E, ...D]), De(() => () => {
|
|
151
151
|
b && f();
|
|
152
152
|
}, [b, f]);
|
|
153
|
-
const
|
|
153
|
+
const k = U(() => {
|
|
154
154
|
b && f(), v({ type: "RESET" });
|
|
155
155
|
}, [b, f]);
|
|
156
156
|
return Object.assign(P, {
|
|
157
157
|
...h,
|
|
158
158
|
abort: f,
|
|
159
|
-
reset:
|
|
159
|
+
reset: k
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
var oe = { exports: {} }, M = {};
|
|
@@ -196,11 +196,11 @@ var N = {};
|
|
|
196
196
|
var Ye;
|
|
197
197
|
function Fr() {
|
|
198
198
|
return Ye || (Ye = 1, process.env.NODE_ENV !== "production" && function() {
|
|
199
|
-
var n = Le, a = Symbol.for("react.element"), l = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), T = Symbol.for("react.profiler"), h = Symbol.for("react.provider"), v = Symbol.for("react.context"), i = Symbol.for("react.forward_ref"), S = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), d = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), P = Symbol.for("react.offscreen"), D = Symbol.iterator,
|
|
199
|
+
var n = Le, a = Symbol.for("react.element"), l = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), T = Symbol.for("react.profiler"), h = Symbol.for("react.provider"), v = Symbol.for("react.context"), i = Symbol.for("react.forward_ref"), S = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), d = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), P = Symbol.for("react.offscreen"), D = Symbol.iterator, k = "@@iterator";
|
|
200
200
|
function R(e) {
|
|
201
201
|
if (e === null || typeof e != "object")
|
|
202
202
|
return null;
|
|
203
|
-
var r = D && e[D] || e[
|
|
203
|
+
var r = D && e[D] || e[k];
|
|
204
204
|
return typeof r == "function" ? r : null;
|
|
205
205
|
}
|
|
206
206
|
var j = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
@@ -312,7 +312,7 @@ function Fr() {
|
|
|
312
312
|
V++;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function He() {
|
|
316
316
|
{
|
|
317
317
|
if (V--, V === 0) {
|
|
318
318
|
var e = {
|
|
@@ -347,24 +347,24 @@ function Fr() {
|
|
|
347
347
|
V < 0 && m("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
var
|
|
350
|
+
var H = j.ReactCurrentDispatcher, X;
|
|
351
351
|
function B(e, r, t) {
|
|
352
352
|
{
|
|
353
|
-
if (
|
|
353
|
+
if (X === void 0)
|
|
354
354
|
try {
|
|
355
355
|
throw Error();
|
|
356
356
|
} catch (c) {
|
|
357
357
|
var o = c.stack.trim().match(/\n( *(at )?)/);
|
|
358
|
-
|
|
358
|
+
X = o && o[1] || "";
|
|
359
359
|
}
|
|
360
360
|
return `
|
|
361
|
-
` +
|
|
361
|
+
` + X + e;
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
var Z = !1, J;
|
|
365
365
|
{
|
|
366
|
-
var
|
|
367
|
-
J = new
|
|
366
|
+
var Xe = typeof WeakMap == "function" ? WeakMap : Map;
|
|
367
|
+
J = new Xe();
|
|
368
368
|
}
|
|
369
369
|
function Ee(e, r) {
|
|
370
370
|
if (!e || Z)
|
|
@@ -379,7 +379,7 @@ function Fr() {
|
|
|
379
379
|
var c = Error.prepareStackTrace;
|
|
380
380
|
Error.prepareStackTrace = void 0;
|
|
381
381
|
var p;
|
|
382
|
-
p =
|
|
382
|
+
p = H.current, H.current = null, Ge();
|
|
383
383
|
try {
|
|
384
384
|
if (r) {
|
|
385
385
|
var u = function() {
|
|
@@ -392,37 +392,37 @@ function Fr() {
|
|
|
392
392
|
}), typeof Reflect == "object" && Reflect.construct) {
|
|
393
393
|
try {
|
|
394
394
|
Reflect.construct(u, []);
|
|
395
|
-
} catch (
|
|
396
|
-
o =
|
|
395
|
+
} catch (w) {
|
|
396
|
+
o = w;
|
|
397
397
|
}
|
|
398
398
|
Reflect.construct(e, [], u);
|
|
399
399
|
} else {
|
|
400
400
|
try {
|
|
401
401
|
u.call();
|
|
402
|
-
} catch (
|
|
403
|
-
o =
|
|
402
|
+
} catch (w) {
|
|
403
|
+
o = w;
|
|
404
404
|
}
|
|
405
405
|
e.call(u.prototype);
|
|
406
406
|
}
|
|
407
407
|
} else {
|
|
408
408
|
try {
|
|
409
409
|
throw Error();
|
|
410
|
-
} catch (
|
|
411
|
-
o =
|
|
410
|
+
} catch (w) {
|
|
411
|
+
o = w;
|
|
412
412
|
}
|
|
413
413
|
e();
|
|
414
414
|
}
|
|
415
|
-
} catch (
|
|
416
|
-
if (
|
|
417
|
-
for (var s =
|
|
418
|
-
`),
|
|
419
|
-
`), y = s.length - 1, _ =
|
|
415
|
+
} catch (w) {
|
|
416
|
+
if (w && o && typeof w.stack == "string") {
|
|
417
|
+
for (var s = w.stack.split(`
|
|
418
|
+
`), x = o.stack.split(`
|
|
419
|
+
`), y = s.length - 1, _ = x.length - 1; y >= 1 && _ >= 0 && s[y] !== x[_]; )
|
|
420
420
|
_--;
|
|
421
421
|
for (; y >= 1 && _ >= 0; y--, _--)
|
|
422
|
-
if (s[y] !==
|
|
422
|
+
if (s[y] !== x[_]) {
|
|
423
423
|
if (y !== 1 || _ !== 1)
|
|
424
424
|
do
|
|
425
|
-
if (y--, _--, _ < 0 || s[y] !==
|
|
425
|
+
if (y--, _--, _ < 0 || s[y] !== x[_]) {
|
|
426
426
|
var C = `
|
|
427
427
|
` + s[y].replace(" at new ", " at ");
|
|
428
428
|
return e.displayName && C.includes("<anonymous>") && (C = C.replace("<anonymous>", e.displayName)), typeof e == "function" && J.set(e, C), C;
|
|
@@ -432,7 +432,7 @@ function Fr() {
|
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
} finally {
|
|
435
|
-
Z = !1,
|
|
435
|
+
Z = !1, H.current = p, He(), Error.prepareStackTrace = c;
|
|
436
436
|
}
|
|
437
437
|
var L = e ? e.displayName || e.name : "", $ = L ? B(L) : "";
|
|
438
438
|
return typeof e == "function" && J.set(e, $), $;
|
|
@@ -489,8 +489,8 @@ function Fr() {
|
|
|
489
489
|
var s = void 0;
|
|
490
490
|
try {
|
|
491
491
|
if (typeof e[u] != "function") {
|
|
492
|
-
var
|
|
493
|
-
throw
|
|
492
|
+
var x = Error((o || "React class") + ": " + t + " type `" + u + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[u] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
493
|
+
throw x.name = "Invariant Violation", x;
|
|
494
494
|
}
|
|
495
495
|
s = e[u](r, u, o, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
496
496
|
} catch (y) {
|
|
@@ -602,8 +602,8 @@ function Fr() {
|
|
|
602
602
|
};
|
|
603
603
|
function fr(e, r, t, o, c) {
|
|
604
604
|
{
|
|
605
|
-
var p, u = {}, s = null,
|
|
606
|
-
t !== void 0 && (ge(t), s = "" + t), ir(r) && (ge(r.key), s = "" + r.key), or(r) && (
|
|
605
|
+
var p, u = {}, s = null, x = null;
|
|
606
|
+
t !== void 0 && (ge(t), s = "" + t), ir(r) && (ge(r.key), s = "" + r.key), or(r) && (x = r.ref, sr(r, c));
|
|
607
607
|
for (p in r)
|
|
608
608
|
q.call(r, p) && !ar.hasOwnProperty(p) && (u[p] = r[p]);
|
|
609
609
|
if (e && e.defaultProps) {
|
|
@@ -611,11 +611,11 @@ function Fr() {
|
|
|
611
611
|
for (p in y)
|
|
612
612
|
u[p] === void 0 && (u[p] = y[p]);
|
|
613
613
|
}
|
|
614
|
-
if (s ||
|
|
614
|
+
if (s || x) {
|
|
615
615
|
var _ = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
|
|
616
|
-
s && ur(u, _),
|
|
616
|
+
s && ur(u, _), x && cr(u, _);
|
|
617
617
|
}
|
|
618
|
-
return lr(e, s,
|
|
618
|
+
return lr(e, s, x, c, o, _e.current, u);
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
621
|
var ee = j.ReactCurrentOwner, Te = j.ReactDebugCurrentFrame;
|
|
@@ -646,7 +646,7 @@ Check the render method of \`` + e + "`.";
|
|
|
646
646
|
function dr(e) {
|
|
647
647
|
return "";
|
|
648
648
|
}
|
|
649
|
-
var
|
|
649
|
+
var xe = {};
|
|
650
650
|
function vr(e) {
|
|
651
651
|
{
|
|
652
652
|
var r = je();
|
|
@@ -659,15 +659,15 @@ Check the top-level render call using <` + t + ">.");
|
|
|
659
659
|
return r;
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
|
-
function
|
|
662
|
+
function we(e, r) {
|
|
663
663
|
{
|
|
664
664
|
if (!e._store || e._store.validated || e.key != null)
|
|
665
665
|
return;
|
|
666
666
|
e._store.validated = !0;
|
|
667
667
|
var t = vr(r);
|
|
668
|
-
if (
|
|
668
|
+
if (xe[t])
|
|
669
669
|
return;
|
|
670
|
-
|
|
670
|
+
xe[t] = !0;
|
|
671
671
|
var o = "";
|
|
672
672
|
e && e._owner && e._owner !== ee.current && (o = " It was passed a child from " + I(e._owner.type) + "."), Y(e), m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, o), Y(null);
|
|
673
673
|
}
|
|
@@ -679,7 +679,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
679
679
|
if (Q(e))
|
|
680
680
|
for (var t = 0; t < e.length; t++) {
|
|
681
681
|
var o = e[t];
|
|
682
|
-
te(o) &&
|
|
682
|
+
te(o) && we(o, r);
|
|
683
683
|
}
|
|
684
684
|
else if (te(e))
|
|
685
685
|
e._store && (e._store.validated = !0);
|
|
@@ -687,7 +687,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
687
687
|
var c = R(e);
|
|
688
688
|
if (typeof c == "function" && c !== e.entries)
|
|
689
689
|
for (var p = c.call(e), u; !(u = p.next()).done; )
|
|
690
|
-
te(u.value) &&
|
|
690
|
+
te(u.value) && we(u.value, r);
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
}
|
|
@@ -729,14 +729,14 @@ Check the top-level render call using <` + t + ">.");
|
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
731
|
var Pe = {};
|
|
732
|
-
function
|
|
732
|
+
function ke(e, r, t, o, c, p) {
|
|
733
733
|
{
|
|
734
734
|
var u = Je(e);
|
|
735
735
|
if (!u) {
|
|
736
736
|
var s = "";
|
|
737
737
|
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (s += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
738
|
-
var
|
|
739
|
-
|
|
738
|
+
var x = dr();
|
|
739
|
+
x ? s += x : s += je();
|
|
740
740
|
var y;
|
|
741
741
|
e === null ? y = "null" : Q(e) ? y = "array" : e !== void 0 && e.$$typeof === a ? (y = "<" + (I(e.type) || "Unknown") + " />", s = " Did you accidentally export a JSX literal instead of a component?") : y = typeof e, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", y, s);
|
|
742
742
|
}
|
|
@@ -757,11 +757,11 @@ Check the top-level render call using <` + t + ">.");
|
|
|
757
757
|
Ce(C, e);
|
|
758
758
|
}
|
|
759
759
|
if (q.call(r, "key")) {
|
|
760
|
-
var $ = I(e),
|
|
760
|
+
var $ = I(e), w = Object.keys(r).filter(function(gr) {
|
|
761
761
|
return gr !== "key";
|
|
762
|
-
}), ne =
|
|
762
|
+
}), ne = w.length > 0 ? "{key: someKey, " + w.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
763
763
|
if (!Pe[$ + ne]) {
|
|
764
|
-
var yr =
|
|
764
|
+
var yr = w.length > 0 ? "{" + w.join(": ..., ") + ": ...}" : "{}";
|
|
765
765
|
m(`A props object containing a "key" prop is being spread into JSX:
|
|
766
766
|
let props = %s;
|
|
767
767
|
<%s {...props} />
|
|
@@ -774,10 +774,10 @@ React keys must be passed directly to JSX without using spread:
|
|
|
774
774
|
}
|
|
775
775
|
}
|
|
776
776
|
function hr(e, r, t) {
|
|
777
|
-
return
|
|
777
|
+
return ke(e, r, t, !0);
|
|
778
778
|
}
|
|
779
779
|
function Er(e, r, t) {
|
|
780
|
-
return
|
|
780
|
+
return ke(e, r, t, !1);
|
|
781
781
|
}
|
|
782
782
|
var Rr = Er, mr = hr;
|
|
783
783
|
N.Fragment = b, N.jsx = Rr, N.jsxs = mr;
|
|
@@ -795,10 +795,10 @@ function Br(n, a) {
|
|
|
795
795
|
}
|
|
796
796
|
);
|
|
797
797
|
}
|
|
798
|
-
class Ir extends
|
|
798
|
+
class Ir extends wr {
|
|
799
799
|
constructor() {
|
|
800
800
|
super(...arguments);
|
|
801
|
-
|
|
801
|
+
Ae(this, "state", { error: null });
|
|
802
802
|
}
|
|
803
803
|
static getDerivedStateFromError(l) {
|
|
804
804
|
return { error: l };
|
|
@@ -822,7 +822,7 @@ function $r(n) {
|
|
|
822
822
|
return /* @__PURE__ */ O.jsx(O.Fragment, { children: n.render() });
|
|
823
823
|
}
|
|
824
824
|
function Yr(n) {
|
|
825
|
-
return n.fallback ? /* @__PURE__ */ O.jsx(
|
|
825
|
+
return n.fallback ? /* @__PURE__ */ O.jsx(xr, { fallback: /* @__PURE__ */ O.jsx($r, { render: n.fallback }), children: n.children }) : /* @__PURE__ */ O.jsx(O.Fragment, { children: n.children });
|
|
826
826
|
}
|
|
827
827
|
function Lr(n) {
|
|
828
828
|
return n.onError ? /* @__PURE__ */ O.jsx(Ir, { onError: n.onError, children: n.children }) : /* @__PURE__ */ O.jsx(O.Fragment, { children: n.children });
|
|
@@ -830,7 +830,7 @@ function Lr(n) {
|
|
|
830
830
|
const Ur = jr(
|
|
831
831
|
function(a) {
|
|
832
832
|
var v, i, S, f;
|
|
833
|
-
const l =
|
|
833
|
+
const l = A(a.selectorOrAtom);
|
|
834
834
|
l.current = a.selectorOrAtom;
|
|
835
835
|
const b = z(a.selectorOrAtom), g = (v = a.options) == null ? void 0 : v.deps, T = b ? [a.selectorOrAtom, ...g ?? []] : g ?? [{}], h = U(
|
|
836
836
|
(d) => z(l.current) ? d.read(l.current) : l.current(d),
|
|
@@ -842,8 +842,8 @@ const Ur = jr(
|
|
|
842
842
|
);
|
|
843
843
|
export {
|
|
844
844
|
Gr as AllAtomsRejectedError,
|
|
845
|
-
|
|
846
|
-
|
|
845
|
+
Hr as atom,
|
|
846
|
+
Xr as batch,
|
|
847
847
|
Zr as define,
|
|
848
848
|
Qr as derived,
|
|
849
849
|
et as effect,
|
|
@@ -855,12 +855,13 @@ export {
|
|
|
855
855
|
ot as isPending,
|
|
856
856
|
it as isRejected,
|
|
857
857
|
st as onCreateHook,
|
|
858
|
-
ut as
|
|
859
|
-
ct as
|
|
858
|
+
ut as onErrorHook,
|
|
859
|
+
ct as promisesEqual,
|
|
860
|
+
lt as readonly,
|
|
860
861
|
Br as rx,
|
|
861
862
|
Fe as select,
|
|
862
|
-
|
|
863
|
-
|
|
863
|
+
ft as trackPromise,
|
|
864
|
+
dt as unwrap,
|
|
864
865
|
zr as useAction,
|
|
865
866
|
Ue as useSelector,
|
|
866
867
|
Nr as useStable
|
package/package.json
CHANGED
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"url": "https://github.com/linq2js/atomirx"
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/linq2js/atomirx",
|
|
19
|
-
"version": "0.0.
|
|
19
|
+
"version": "0.0.6",
|
|
20
20
|
"type": "module",
|
|
21
|
-
"main": "./dist/
|
|
22
|
-
"module": "./dist/
|
|
21
|
+
"main": "./dist/index.cjs",
|
|
22
|
+
"module": "./dist/index.js",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
|
-
"import": "./dist/
|
|
27
|
-
"require": "./dist/
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.cjs",
|
|
28
28
|
"types": "./dist/index.d.ts"
|
|
29
29
|
},
|
|
30
30
|
"./react": {
|
package/src/core/atom.ts
CHANGED
package/src/core/define.test.ts
CHANGED
|
@@ -3,14 +3,12 @@ import { define } from "./define";
|
|
|
3
3
|
import { onCreateHook } from "./onCreateHook";
|
|
4
4
|
|
|
5
5
|
describe("define", () => {
|
|
6
|
-
const originalOnCreateHook = onCreateHook.current;
|
|
7
|
-
|
|
8
6
|
beforeEach(() => {
|
|
9
|
-
onCreateHook.
|
|
7
|
+
onCreateHook.reset();
|
|
10
8
|
});
|
|
11
9
|
|
|
12
10
|
afterEach(() => {
|
|
13
|
-
onCreateHook.
|
|
11
|
+
onCreateHook.reset();
|
|
14
12
|
});
|
|
15
13
|
|
|
16
14
|
describe("basic functionality", () => {
|
|
@@ -238,7 +236,7 @@ describe("define", () => {
|
|
|
238
236
|
describe("onCreateHook", () => {
|
|
239
237
|
it("should call onCreateHook when module is created", () => {
|
|
240
238
|
const hookFn = vi.fn();
|
|
241
|
-
onCreateHook.
|
|
239
|
+
onCreateHook.override(() => hookFn);
|
|
242
240
|
|
|
243
241
|
const store = define(() => ({ value: 42 }), { key: "testModule" });
|
|
244
242
|
const instance = store();
|
|
@@ -247,13 +245,14 @@ describe("define", () => {
|
|
|
247
245
|
expect(hookFn).toHaveBeenCalledWith({
|
|
248
246
|
type: "module",
|
|
249
247
|
key: "testModule",
|
|
250
|
-
|
|
248
|
+
meta: undefined,
|
|
249
|
+
instance,
|
|
251
250
|
});
|
|
252
251
|
});
|
|
253
252
|
|
|
254
253
|
it("should call onCreateHook with undefined key when not provided", () => {
|
|
255
254
|
const hookFn = vi.fn();
|
|
256
|
-
onCreateHook.
|
|
255
|
+
onCreateHook.override(() => hookFn);
|
|
257
256
|
|
|
258
257
|
const store = define(() => ({ value: 42 }));
|
|
259
258
|
store();
|
|
@@ -261,12 +260,13 @@ describe("define", () => {
|
|
|
261
260
|
expect(hookFn).toHaveBeenCalledWith({
|
|
262
261
|
type: "module",
|
|
263
262
|
key: undefined,
|
|
264
|
-
|
|
263
|
+
meta: undefined,
|
|
264
|
+
instance: expect.any(Object),
|
|
265
265
|
});
|
|
266
266
|
});
|
|
267
267
|
|
|
268
268
|
it("should not throw when onCreateHook is undefined", () => {
|
|
269
|
-
onCreateHook.
|
|
269
|
+
onCreateHook.reset();
|
|
270
270
|
|
|
271
271
|
const store = define(() => ({ value: 42 }));
|
|
272
272
|
expect(() => store()).not.toThrow();
|
|
@@ -274,7 +274,7 @@ describe("define", () => {
|
|
|
274
274
|
|
|
275
275
|
it("should call onCreateHook for overridden module", () => {
|
|
276
276
|
const hookFn = vi.fn();
|
|
277
|
-
onCreateHook.
|
|
277
|
+
onCreateHook.override(() => hookFn);
|
|
278
278
|
|
|
279
279
|
const store = define(() => ({ value: "original" }));
|
|
280
280
|
store.override(() => ({ value: "overridden" }));
|
|
@@ -283,7 +283,8 @@ describe("define", () => {
|
|
|
283
283
|
expect(hookFn).toHaveBeenCalledWith({
|
|
284
284
|
type: "module",
|
|
285
285
|
key: undefined,
|
|
286
|
-
|
|
286
|
+
meta: undefined,
|
|
287
|
+
instance,
|
|
287
288
|
});
|
|
288
289
|
});
|
|
289
290
|
});
|