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.
@@ -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 ke = (n, a, l) => Sr(n, typeof a != "symbol" ? a + "" : a, l);
4
- import Le, { useRef as k, useCallback as U, useSyncExternalStore as Or, useReducer as Tr, useEffect as De, memo as jr, Suspense as wr, Component as xr } 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-D8RDOTB_.js";
6
- import { A as Gr, c as Xr, e as Hr, 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, d as ct, p as lt, u as ft } from "../index-D8RDOTB_.js";
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 = k(l), T = k(b);
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 = k(/* @__PURE__ */ new Map()), v = k(/* @__PURE__ */ new Set()), i = k({
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 [A, R] of E)
25
- D.has(A) || (R(), E.delete(A));
26
- for (const A of D)
27
- if (!E.has(A)) {
28
- const R = A.on(() => {
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(A, R);
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 Ar(n) {
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 = k({}), b = k(null);
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(Ar(v)), [d] = Ie(
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 kr(n, a) {
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
- kr,
106
+ Ar,
107
107
  T
108
- ), i = k(null), S = k(n);
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 A = U(() => {
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: A
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, A = "@@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[A];
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 Xe() {
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 X = j.ReactCurrentDispatcher, H;
350
+ var H = j.ReactCurrentDispatcher, X;
351
351
  function B(e, r, t) {
352
352
  {
353
- if (H === void 0)
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
- H = o && o[1] || "";
358
+ X = o && o[1] || "";
359
359
  }
360
360
  return `
361
- ` + H + e;
361
+ ` + X + e;
362
362
  }
363
363
  }
364
364
  var Z = !1, J;
365
365
  {
366
- var He = typeof WeakMap == "function" ? WeakMap : Map;
367
- J = new He();
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 = X.current, X.current = null, Ge();
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 (x) {
396
- o = x;
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 (x) {
403
- o = x;
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 (x) {
411
- o = x;
410
+ } catch (w) {
411
+ o = w;
412
412
  }
413
413
  e();
414
414
  }
415
- } catch (x) {
416
- if (x && o && typeof x.stack == "string") {
417
- for (var s = x.stack.split(`
418
- `), w = o.stack.split(`
419
- `), y = s.length - 1, _ = w.length - 1; y >= 1 && _ >= 0 && s[y] !== w[_]; )
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] !== w[_]) {
422
+ if (s[y] !== x[_]) {
423
423
  if (y !== 1 || _ !== 1)
424
424
  do
425
- if (y--, _--, _ < 0 || s[y] !== w[_]) {
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, X.current = p, Xe(), Error.prepareStackTrace = c;
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 w = 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 w.name = "Invariant Violation", w;
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, w = null;
606
- t !== void 0 && (ge(t), s = "" + t), ir(r) && (ge(r.key), s = "" + r.key), or(r) && (w = r.ref, sr(r, c));
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 || w) {
614
+ if (s || x) {
615
615
  var _ = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
616
- s && ur(u, _), w && cr(u, _);
616
+ s && ur(u, _), x && cr(u, _);
617
617
  }
618
- return lr(e, s, w, c, o, _e.current, u);
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 we = {};
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 xe(e, r) {
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 (we[t])
668
+ if (xe[t])
669
669
  return;
670
- we[t] = !0;
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) && xe(o, r);
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) && xe(u.value, r);
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 Ae(e, r, t, o, c, p) {
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 w = dr();
739
- w ? s += w : s += je();
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), x = Object.keys(r).filter(function(gr) {
760
+ var $ = I(e), w = Object.keys(r).filter(function(gr) {
761
761
  return gr !== "key";
762
- }), ne = x.length > 0 ? "{key: someKey, " + x.join(": ..., ") + ": ...}" : "{key: someKey}";
762
+ }), ne = w.length > 0 ? "{key: someKey, " + w.join(": ..., ") + ": ...}" : "{key: someKey}";
763
763
  if (!Pe[$ + ne]) {
764
- var yr = x.length > 0 ? "{" + x.join(": ..., ") + ": ...}" : "{}";
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 Ae(e, r, t, !0);
777
+ return ke(e, r, t, !0);
778
778
  }
779
779
  function Er(e, r, t) {
780
- return Ae(e, r, t, !1);
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 xr {
798
+ class Ir extends wr {
799
799
  constructor() {
800
800
  super(...arguments);
801
- ke(this, "state", { error: null });
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(wr, { fallback: /* @__PURE__ */ O.jsx($r, { render: n.fallback }), children: n.children }) : /* @__PURE__ */ O.jsx(O.Fragment, { children: n.children });
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 = k(a.selectorOrAtom);
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
- Xr as atom,
846
- Hr as batch,
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 promisesEqual,
859
- ct as readonly,
858
+ ut as onErrorHook,
859
+ ct as promisesEqual,
860
+ lt as readonly,
860
861
  Br as rx,
861
862
  Fe as select,
862
- lt as trackPromise,
863
- ft as unwrap,
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.4",
19
+ "version": "0.0.6",
20
20
  "type": "module",
21
- "main": "./dist/atomirx.umd.cjs",
22
- "module": "./dist/atomirx.js",
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/atomirx.js",
27
- "require": "./dist/atomirx.umd.cjs",
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
@@ -240,7 +240,7 @@ export function atom<T>(
240
240
  type: "mutable",
241
241
  key: options.meta?.key,
242
242
  meta: options.meta,
243
- atom: a as MutableAtom<unknown>,
243
+ instance: a as MutableAtom<unknown>,
244
244
  });
245
245
 
246
246
  return a;
@@ -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.current = undefined;
7
+ onCreateHook.reset();
10
8
  });
11
9
 
12
10
  afterEach(() => {
13
- onCreateHook.current = originalOnCreateHook;
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.current = hookFn;
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
- module: instance,
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.current = hookFn;
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
- module: expect.any(Object),
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.current = undefined;
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.current = hookFn;
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
- module: instance,
286
+ meta: undefined,
287
+ instance,
287
288
  });
288
289
  });
289
290
  });
@@ -213,7 +213,7 @@ export function define<T>(
213
213
  type: "module",
214
214
  key: options?.key,
215
215
  meta: options?.meta,
216
- module: instance,
216
+ instance,
217
217
  });
218
218
  }
219
219
  return instance;