@but212/atom-effect 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ const k = {
6
6
  }, l = {
7
7
  DISPOSED: 1,
8
8
  EXECUTING: 8
9
- }, q = {
9
+ }, st = {
10
10
  DISPOSED: 1,
11
11
  /** Marker bit: identifies this node as a computed. */
12
12
  IS_COMPUTED: 2,
@@ -21,7 +21,7 @@ const k = {
21
21
  DISPOSED: 1,
22
22
  SYNC: 8,
23
23
  NOTIFICATION_SCHEDULED: 16
24
- }, St = {
24
+ }, kt = {
25
25
  MAX_SIZE: 1e3,
26
26
  WARMUP_SIZE: 100,
27
27
  ENABLE_STATS: !1
@@ -36,9 +36,9 @@ const k = {
36
36
  // Memory management
37
37
  CLEANUP_THRESHOLD: 1e3,
38
38
  BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
39
- }, et = {
39
+ }, _t = {
40
40
  WARN_INFINITE_LOOP: !0
41
- }, z = 1073741823, u = typeof process < "u" && process.env && process.env.NODE_ENV !== "production" || typeof __DEV__ < "u" && !!__DEV__, st = Object.freeze([]);
41
+ }, z = 1073741823, u = typeof process < "u" && process.env && process.env.NODE_ENV !== "production" || typeof __DEV__ < "u" && !!__DEV__, at = Object.freeze([]);
42
42
  class O extends Error {
43
43
  constructor(t, e = null, s = !0) {
44
44
  super(t), this.cause = e, this.recoverable = s, this.name = "AtomError";
@@ -54,48 +54,48 @@ class I extends O {
54
54
  super(t, e, !1), this.name = "EffectError";
55
55
  }
56
56
  }
57
- class L extends O {
57
+ class m extends O {
58
58
  constructor(t, e = null) {
59
59
  super(t, e, !1), this.name = "SchedulerError";
60
60
  }
61
61
  }
62
- const X = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), it = /* @__PURE__ */ Symbol("AtomEffect.Id"), G = /* @__PURE__ */ Symbol("AtomEffect.Type"), v = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), nt = (i) => "dependencies" in i && Array.isArray(i.dependencies);
63
- function $(i, t, e) {
62
+ const G = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), ft = /* @__PURE__ */ Symbol("AtomEffect.Id"), Q = /* @__PURE__ */ Symbol("AtomEffect.Type"), v = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), Et = (i) => "dependencies" in i && Array.isArray(i.dependencies);
63
+ function it(i, t, e) {
64
64
  if (i === t)
65
65
  throw new d(
66
66
  "Circular dependency detected: The computation refers to itself explicitly or implicitly."
67
67
  );
68
- if (!e.has(i.id) && (e.add(i.id), nt(i))) {
68
+ if (!e.has(i.id) && (e.add(i.id), Et(i))) {
69
69
  const s = i.dependencies;
70
70
  for (let n = 0; n < s.length; n++) {
71
71
  const r = s[n];
72
- r && $(r, t, e);
72
+ r && it(r, t, e);
73
73
  }
74
74
  }
75
75
  }
76
76
  const D = {
77
77
  // Dev mode flag
78
78
  enabled: u,
79
- warnInfiniteLoop: et.WARN_INFINITE_LOOP,
79
+ warnInfiniteLoop: _t.WARN_INFINITE_LOOP,
80
80
  warn(i, t) {
81
81
  u && this.enabled && i && console.warn(`[Atom Effect] ${t}`);
82
82
  },
83
83
  checkCircular(i, t) {
84
84
  if (i === t)
85
85
  throw new d("Direct circular dependency detected");
86
- u && this.enabled && $(i, t, /* @__PURE__ */ new Set());
86
+ u && this.enabled && it(i, t, /* @__PURE__ */ new Set());
87
87
  },
88
88
  attachDebugInfo(i, t, e) {
89
89
  if (!u || !this.enabled) return;
90
90
  const s = i;
91
- s[X] = `${t}_${e}`, s[it] = e, s[G] = t;
91
+ s[G] = `${t}_${e}`, s[ft] = e, s[Q] = t;
92
92
  },
93
- getDebugName: (i) => i?.[X],
94
- getDebugType: (i) => i?.[G]
93
+ getDebugName: (i) => i?.[G],
94
+ getDebugType: (i) => i?.[Q]
95
95
  };
96
- let rt = 1;
97
- const ot = () => rt++;
98
- function K(i, t, e) {
96
+ let dt = 1;
97
+ const pt = () => dt++;
98
+ function nt(i, t, e) {
99
99
  if (typeof t == "function") {
100
100
  const n = t;
101
101
  for (let r = 0, o = e.length; r < o; r++) {
@@ -116,7 +116,7 @@ function K(i, t, e) {
116
116
  }
117
117
  e.push(new M(void 0, s));
118
118
  }
119
- function Q(i, t, e) {
119
+ function j(i, t, e) {
120
120
  const s = /* @__PURE__ */ new Map();
121
121
  for (let n = 0, r = t.length; n < r; n++) {
122
122
  const o = t[n];
@@ -131,7 +131,7 @@ function Q(i, t, e) {
131
131
  for (const n of s.values())
132
132
  n();
133
133
  }
134
- class x {
134
+ class R {
135
135
  constructor(t, e, s = void 0) {
136
136
  this.node = t, this.version = e, this.unsub = s;
137
137
  }
@@ -164,25 +164,25 @@ const c = {
164
164
  // Effect frequency
165
165
  EFFECT_FREQUENCY_LIMIT_EXCEEDED: "Effect executed too frequently within 1 second. Suspected infinite loop."
166
166
  };
167
- function b(i, t, e) {
167
+ function T(i, t, e) {
168
168
  if (i instanceof O)
169
169
  return i;
170
170
  const s = i instanceof Error, n = s ? i.message : String(i), r = s ? i : void 0, h = `${s ? i.constructor.name : "Unexpected error"} (${e}): ${n}`;
171
171
  return new t(h, r);
172
172
  }
173
- class W {
173
+ class rt {
174
174
  constructor() {
175
- this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id = ot() & z;
175
+ this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id = pt() & z;
176
176
  }
177
177
  }
178
- class J extends W {
178
+ class ot extends rt {
179
179
  /**
180
180
  * Adds subscriber.
181
181
  */
182
182
  subscribe(t) {
183
183
  const e = typeof t == "function";
184
184
  if (!e && (!t || typeof t.execute != "function"))
185
- throw b(
185
+ throw T(
186
186
  new TypeError("Invalid subscriber"),
187
187
  O,
188
188
  c.ATOM_SUBSCRIBER_MUST_BE_FUNCTION
@@ -223,20 +223,20 @@ class J extends W {
223
223
  }
224
224
  }
225
225
  _handleNotifyError(t) {
226
- console.error(b(t, O, c.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
226
+ console.error(T(t, O, c.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
227
227
  }
228
228
  }
229
229
  let w = 0;
230
230
  const V = () => (w = w + 1 & z || 1, w), B = (i) => i + 1 & z;
231
- let H = 0, U = !1, Z = 0;
232
- const ht = () => Z;
231
+ let H = 0, U = !1, ht = 0;
232
+ const It = () => ht;
233
233
  function Y() {
234
- return U ? (u && console.warn("startFlush() called during flush - ignored"), !1) : (U = !0, Z = V(), H = 0, !0);
234
+ return U ? (u && console.warn("startFlush() called during flush - ignored"), !1) : (U = !0, ht = V(), H = 0, !0);
235
235
  }
236
- const j = () => {
236
+ const $ = () => {
237
237
  U = !1;
238
- }, ct = () => U ? ++H : 0;
239
- class ut {
238
+ }, gt = () => U ? ++H : 0;
239
+ class St {
240
240
  constructor() {
241
241
  this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isBatching = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = S.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
242
242
  }
@@ -254,7 +254,7 @@ class ut {
254
254
  */
255
255
  schedule(t) {
256
256
  if (u && typeof t != "function")
257
- throw new L("Scheduler callback must be a function");
257
+ throw new m("Scheduler callback must be a function");
258
258
  if (t._nextEpoch !== this._epoch) {
259
259
  if (t._nextEpoch = this._epoch, this._isBatching || this._isFlushingSync) {
260
260
  this._batchQueue[this._batchQueueSize++] = t;
@@ -276,7 +276,7 @@ class ut {
276
276
  try {
277
277
  if (this._size === 0) return;
278
278
  const t = Y();
279
- this._drainQueue(), t && j();
279
+ this._drainQueue(), t && $();
280
280
  } finally {
281
281
  this._isProcessing = !1, this._size > 0 && !this._isBatching && this._flush();
282
282
  }
@@ -287,7 +287,7 @@ class ut {
287
287
  try {
288
288
  this._mergeBatchQueue(), this._drainQueue();
289
289
  } finally {
290
- this._isFlushingSync = !1, t && j();
290
+ this._isFlushingSync = !1, t && $();
291
291
  }
292
292
  }
293
293
  _mergeBatchQueue() {
@@ -317,14 +317,14 @@ class ut {
317
317
  try {
318
318
  e[n]();
319
319
  } catch (r) {
320
- console.error(new L("Error occurred during scheduler execution", r));
320
+ console.error(new m("Error occurred during scheduler execution", r));
321
321
  }
322
322
  e.length = 0;
323
323
  }
324
324
  _handleFlushOverflow() {
325
325
  const t = this._size + this._batchQueueSize;
326
326
  if (console.error(
327
- new L(
327
+ new m(
328
328
  c.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, t)
329
329
  )
330
330
  ), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0, this.onOverflow)
@@ -345,13 +345,13 @@ class ut {
345
345
  }
346
346
  setMaxFlushIterations(t) {
347
347
  if (t < S.MIN_FLUSH_ITERATIONS)
348
- throw new L(
348
+ throw new m(
349
349
  `Max flush iterations must be at least ${S.MIN_FLUSH_ITERATIONS}`
350
350
  );
351
351
  this._maxFlushIterations = t;
352
352
  }
353
353
  }
354
- const N = new ut(), a = {
354
+ const N = new St(), X = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ct = /* @__PURE__ */ Symbol.for("atom-effect/computed"), ut = /* @__PURE__ */ Symbol.for("atom-effect/effect"), a = {
355
355
  /** Active listener. */
356
356
  current: null,
357
357
  /**
@@ -371,7 +371,7 @@ const N = new ut(), a = {
371
371
  }
372
372
  }
373
373
  };
374
- function Dt(i) {
374
+ function mt(i) {
375
375
  const t = a.current;
376
376
  if (t === null) return i();
377
377
  a.current = null;
@@ -381,13 +381,14 @@ function Dt(i) {
381
381
  a.current = t;
382
382
  }
383
383
  }
384
- class lt extends J {
384
+ var q, K;
385
+ class Dt extends (K = ot, q = X, K) {
385
386
  constructor(t, e) {
386
- super(), this._pendingOldValue = void 0, this._notifyTask = void 0, this._subscribers = [], this._value = t, e && (this.flags |= E.SYNC), D.attachDebugInfo(this, "atom", this.id);
387
+ super(), this._pendingOldValue = void 0, this._notifyTask = void 0, this._subscribers = [], this[q] = !0, this._value = t, e && (this.flags |= E.SYNC), D.attachDebugInfo(this, "atom", this.id);
387
388
  }
388
389
  get value() {
389
390
  const t = a.current;
390
- return t && K(this, t, this._subscribers), this._value;
391
+ return t && nt(this, t, this._subscribers), this._value;
391
392
  }
392
393
  set value(t) {
393
394
  const e = this._value;
@@ -419,10 +420,10 @@ class lt extends J {
419
420
  this.flags & E.DISPOSED || (this._subscribers.length = 0, this.flags |= E.DISPOSED, this._value = void 0, this._pendingOldValue = void 0, this._notifyTask = void 0);
420
421
  }
421
422
  }
422
- function Ct(i, t = {}) {
423
- return new lt(i, t.sync ?? !1);
423
+ function Lt(i, t = {}) {
424
+ return new Dt(i, t.sync ?? !1);
424
425
  }
425
- class _t {
426
+ class Ct {
426
427
  /**
427
428
  * @param limit - Max unique arrays to hold (default: 50). Prevents the pool itself from consuming too much memory.
428
429
  * @param capacity - Max length of an array to accept (default: 256).
@@ -491,29 +492,30 @@ class _t {
491
492
  }
492
493
  const _ = Object.freeze(
493
494
  []
494
- ), p = new _t();
495
- function at(i) {
496
- return i !== null && typeof i == "object" && "value" in i && typeof i.subscribe == "function";
495
+ ), p = new Ct();
496
+ function Ft(i) {
497
+ return i !== null && typeof i == "object" && X in i;
497
498
  }
498
- function Tt(i) {
499
- return at(i) && typeof i.invalidate == "function";
499
+ function Rt(i) {
500
+ return i !== null && typeof i == "object" && ct in i;
500
501
  }
501
- function bt(i) {
502
- return i !== null && typeof i == "object" && typeof i.dispose == "function" && typeof i.run == "function";
502
+ function xt(i) {
503
+ return i !== null && typeof i == "object" && ut in i;
503
504
  }
504
- function tt(i) {
505
+ function lt(i) {
505
506
  return i !== null && typeof i == "object" && typeof i.then == "function";
506
507
  }
507
- const ft = 3, Et = Number.MAX_SAFE_INTEGER - 1, { IDLE: F, DIRTY: T, PENDING: R, RESOLVED: g, REJECTED: A, HAS_ERROR: m, RECOMPUTING: y, DISPOSED: P, IS_COMPUTED: dt } = q;
508
- function pt(i) {
509
- return i & g ? k.RESOLVED : i & R ? k.PENDING : i & A ? k.REJECTED : k.IDLE;
508
+ var W, J, Z;
509
+ const bt = 3, Tt = Number.MAX_SAFE_INTEGER - 1, { IDLE: L, DIRTY: b, PENDING: x, RESOLVED: g, REJECTED: A, HAS_ERROR: F, RECOMPUTING: y, DISPOSED: P, IS_COMPUTED: Ot } = st;
510
+ function yt(i) {
511
+ return i & g ? k.RESOLVED : i & x ? k.PENDING : i & A ? k.REJECTED : k.IDLE;
510
512
  }
511
- class It extends J {
513
+ class At extends (Z = ot, J = X, W = ct, Z) {
512
514
  constructor(t, e = {}) {
513
515
  if (typeof t != "function") throw new d(c.COMPUTED_MUST_BE_FUNCTION);
514
- super(), this._error = null, this._promiseId = 0, this._subscribers = [], this._links = _, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._trackEpoch = -1, this._trackLinks = _, this._trackCount = 0, this._value = void 0, this.flags = dt | T | F, this._equal = e.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in e ? e.defaultValue : v, this._onError = e.onError ?? null;
516
+ super(), this[J] = !0, this[W] = !0, this._error = null, this._promiseId = 0, this._subscribers = [], this._links = _, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._trackEpoch = -1, this._trackLinks = _, this._trackCount = 0, this._value = void 0, this.flags = Ot | b | L, this._equal = e.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in e ? e.defaultValue : v, this._onError = e.onError ?? null;
515
517
  const s = e.maxAsyncRetries;
516
- if (this._maxAsyncRetries = s != null && s >= 0 ? s : ft, D.attachDebugInfo(this, "computed", this.id), e.lazy === !1)
518
+ if (this._maxAsyncRetries = s != null && s >= 0 ? s : bt, D.attachDebugInfo(this, "computed", this.id), e.lazy === !1)
517
519
  try {
518
520
  this._recompute();
519
521
  } catch {
@@ -521,12 +523,12 @@ class It extends J {
521
523
  }
522
524
  _track() {
523
525
  const t = a.current;
524
- t && K(this, t, this._subscribers);
526
+ t && nt(this, t, this._subscribers);
525
527
  }
526
528
  get value() {
527
529
  this._track();
528
530
  const t = this.flags;
529
- if ((t & (g | T | F)) === g)
531
+ if ((t & (g | b | L)) === g)
530
532
  return this._value;
531
533
  if (t & P)
532
534
  throw new d(c.COMPUTED_DISPOSED);
@@ -534,10 +536,10 @@ class It extends J {
534
536
  if (this._defaultValue !== v) return this._defaultValue;
535
537
  throw new d(c.COMPUTED_CIRCULAR_DEPENDENCY);
536
538
  }
537
- if (t & (T | F) && (this._recompute(), this.flags & g))
539
+ if (t & (b | L) && (this._recompute(), this.flags & g))
538
540
  return this._value;
539
541
  const e = this._defaultValue, s = e !== v;
540
- if (this.flags & R) {
542
+ if (this.flags & x) {
541
543
  if (s) return e;
542
544
  throw new d(c.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
543
545
  }
@@ -551,14 +553,14 @@ class It extends J {
551
553
  return this._value;
552
554
  }
553
555
  get state() {
554
- return this._track(), pt(this.flags);
556
+ return this._track(), yt(this.flags);
555
557
  }
556
558
  get hasError() {
557
- if (this._track(), this.flags & (A | m)) return !0;
559
+ if (this._track(), this.flags & (A | F)) return !0;
558
560
  const t = this._links;
559
561
  for (let e = 0, s = t.length; e < s; e++) {
560
562
  const n = t[e]?.node;
561
- if (n && n.flags & m) return !0;
563
+ if (n && n.flags & F) return !0;
562
564
  }
563
565
  return !1;
564
566
  }
@@ -566,13 +568,13 @@ class It extends J {
566
568
  return !this.hasError;
567
569
  }
568
570
  get errors() {
569
- if (this._track(), !this.hasError) return st;
571
+ if (this._track(), !this.hasError) return at;
570
572
  const t = [];
571
573
  this._error && t.push(this._error);
572
574
  const e = this._links;
573
575
  for (let s = 0, n = e.length; s < n; s++) {
574
576
  const r = e[s].node;
575
- if (r.flags & m) {
577
+ if (r.flags & F) {
576
578
  const o = r;
577
579
  if (o.errors) {
578
580
  const h = o.errors;
@@ -589,7 +591,7 @@ class It extends J {
589
591
  return this._track(), this._error;
590
592
  }
591
593
  get isPending() {
592
- return this._track(), (this.flags & R) !== 0;
594
+ return this._track(), (this.flags & x) !== 0;
593
595
  }
594
596
  get isResolved() {
595
597
  return this._track(), (this.flags & g) !== 0;
@@ -605,7 +607,7 @@ class It extends J {
605
607
  t[e].unsub?.();
606
608
  p.release(t), this._links = _;
607
609
  }
608
- this._subscribers.length = 0, this.flags = P | T | F, this._error = null, this._value = void 0;
610
+ this._subscribers.length = 0, this.flags = P | b | L, this._error = null, this._value = void 0;
609
611
  }
610
612
  addDependency(t) {
611
613
  if (t._lastSeenEpoch !== this._trackEpoch) {
@@ -613,7 +615,7 @@ class It extends J {
613
615
  const e = this._trackLinks[this._trackCount];
614
616
  e.node = t, e.version = t.version;
615
617
  } else
616
- this._trackLinks.push(new x(t, t.version));
618
+ this._trackLinks.push(new R(t, t.version));
617
619
  this._trackCount++;
618
620
  }
619
621
  }
@@ -625,11 +627,11 @@ class It extends J {
625
627
  let e = !1;
626
628
  try {
627
629
  const s = a.run(this, this._fn);
628
- this._trackLinks.length = this._trackCount, Q(this._trackLinks, t, this), this._links = this._trackLinks, e = !0, tt(s) ? this._handleAsyncComputation(s) : this._finalizeResolution(s);
630
+ this._trackLinks.length = this._trackCount, j(this._trackLinks, t, this), this._links = this._trackLinks, e = !0, lt(s) ? this._handleAsyncComputation(s) : this._finalizeResolution(s);
629
631
  } catch (s) {
630
632
  if (!e)
631
633
  try {
632
- this._trackLinks.length = this._trackCount, Q(this._trackLinks, t, this), this._links = this._trackLinks, e = !0;
634
+ this._trackLinks.length = this._trackCount, j(this._trackLinks, t, this), this._links = this._trackLinks, e = !0;
633
635
  } catch (n) {
634
636
  u && console.warn("[atom-effect] _commitDeps failed during error recovery:", n);
635
637
  }
@@ -639,7 +641,7 @@ class It extends J {
639
641
  }
640
642
  }
641
643
  _handleAsyncComputation(t) {
642
- this.flags = (this.flags | R) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % Et;
644
+ this.flags = (this.flags | x) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % Tt;
643
645
  const e = this._promiseId;
644
646
  t.then(
645
647
  (s) => {
@@ -661,12 +663,12 @@ class It extends J {
661
663
  let t = 0;
662
664
  const e = this._links;
663
665
  for (let s = 0, n = e.length; s < n; s++)
664
- t += e[s].node.version;
666
+ t = (t << 5) - t + e[s].node.version | 0;
665
667
  return t;
666
668
  }
667
669
  _handleError(t, e, s = !1) {
668
- const n = b(t, d, e);
669
- if (!s && !(this.flags & A) && (this.version = B(this.version)), this._error = n, this.flags = this.flags & -121 | A | m, this._onError)
670
+ const n = T(t, d, e);
671
+ if (!s && !(this.flags & A) && (this.version = B(this.version)), this._error = n, this.flags = this.flags & -121 | A | F, this._onError)
670
672
  try {
671
673
  this._onError(n);
672
674
  } catch (r) {
@@ -683,15 +685,16 @@ class It extends J {
683
685
  }
684
686
  /** @internal */
685
687
  _markDirty() {
686
- this.flags & (y | T) || (this.flags |= T, this._notifySubscribers(void 0, void 0));
688
+ this.flags & (y | b) || (this.flags |= b, this._notifySubscribers(void 0, void 0));
687
689
  }
688
690
  }
689
- function Ot(i, t = {}) {
690
- return new It(i, t);
691
+ function Ut(i, t = {}) {
692
+ return new At(i, t);
691
693
  }
692
- class gt extends W {
694
+ var tt, et;
695
+ class Nt extends (et = rt, tt = ut, et) {
693
696
  constructor(t, e = {}) {
694
- super(), this._cleanup = null, this._links = _, this._nextLinks = null, this._prevLinks = null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._fn = t, this._onError = e.onError ?? null, this._sync = e.sync ?? !1, this._maxExecutions = e.maxExecutionsPerSecond ?? S.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = e.maxExecutionsPerFlush ?? S.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = e.trackModifications ?? !1, D.attachDebugInfo(this, "effect", this.id);
697
+ super(), this[tt] = !0, this._cleanup = null, this._links = _, this._nextLinks = null, this._prevLinks = null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._fn = t, this._onError = e.onError ?? null, this._sync = e.sync ?? !1, this._maxExecutions = e.maxExecutionsPerSecond ?? S.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = e.maxExecutionsPerFlush ?? S.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = e.trackModifications ?? !1, D.attachDebugInfo(this, "effect", this.id);
695
698
  }
696
699
  run() {
697
700
  if (this.flags & l.DISPOSED)
@@ -709,24 +712,24 @@ class gt extends W {
709
712
  for (let n = 0, r = s.length; n < r; n++) {
710
713
  const o = s[n];
711
714
  if (o && o.node === t && o.unsub) {
712
- e.push(new x(t, t.version, o.unsub)), o.unsub = void 0;
715
+ e.push(new R(t, t.version, o.unsub)), o.unsub = void 0;
713
716
  return;
714
717
  }
715
718
  }
716
719
  try {
717
720
  const n = t.subscribe(() => {
718
721
  if (this._trackModifications && this.flags & l.EXECUTING && (t._modifiedAtEpoch = this._currentEpoch), this._sync) return this.execute();
719
- this._executeTask || (this._executeTask = () => this.execute()), N.schedule(this._executeTask);
722
+ this._executeTask ??= () => this.execute(), N.schedule(this._executeTask);
720
723
  });
721
- e.push(new x(t, t.version, n));
724
+ e.push(new R(t, t.version, n));
722
725
  } catch (n) {
723
- const r = b(n, I, c.EFFECT_EXECUTION_FAILED);
726
+ const r = T(n, I, c.EFFECT_EXECUTION_FAILED);
724
727
  if (console.error(r), this._onError)
725
728
  try {
726
729
  this._onError(r);
727
730
  } catch {
728
731
  }
729
- e.push(new x(t, t.version, void 0));
732
+ e.push(new R(t, t.version, void 0));
730
733
  }
731
734
  }
732
735
  /**
@@ -752,7 +755,7 @@ class gt extends W {
752
755
  );
753
756
  }
754
757
  }
755
- tt(r) ? this._handleAsyncResult(r) : this._cleanup = typeof r == "function" ? r : null;
758
+ lt(r) ? this._handleAsyncResult(r) : this._cleanup = typeof r == "function" ? r : null;
756
759
  } catch (r) {
757
760
  n = !0, this._handleExecutionError(r), this._cleanup = null;
758
761
  } finally {
@@ -798,7 +801,7 @@ class gt extends W {
798
801
  try {
799
802
  for (let s = 0, n = t.length; s < n; s++) {
800
803
  const r = t[s], o = r.node;
801
- if (o.flags & q.IS_COMPUTED)
804
+ if (o.flags & st.IS_COMPUTED)
802
805
  try {
803
806
  o.value;
804
807
  } catch {
@@ -822,8 +825,8 @@ class gt extends W {
822
825
  }
823
826
  }
824
827
  _checkInfiniteLoops() {
825
- const t = ht();
826
- if (this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), ct() > S.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, u && Number.isFinite(this._maxExecutions)) {
828
+ const t = It();
829
+ if (this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), gt() > S.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, u && Number.isFinite(this._maxExecutions)) {
827
830
  const e = Date.now();
828
831
  if (e - this._windowStart >= 1e3)
829
832
  this._windowStart = e, this._windowCount = 1;
@@ -849,22 +852,22 @@ class gt extends W {
849
852
  throw this.dispose(), console.error(e), e;
850
853
  }
851
854
  _handleExecutionError(t, e = c.EFFECT_EXECUTION_FAILED) {
852
- const s = b(t, I, e);
855
+ const s = T(t, I, e);
853
856
  if (console.error(s), this._onError)
854
857
  try {
855
858
  this._onError(s);
856
859
  } catch (n) {
857
- console.error(b(n, I, c.CALLBACK_ERROR_IN_ERROR_HANDLER));
860
+ console.error(T(n, I, c.CALLBACK_ERROR_IN_ERROR_HANDLER));
858
861
  }
859
862
  }
860
863
  }
861
- function yt(i, t = {}) {
864
+ function vt(i, t = {}) {
862
865
  if (typeof i != "function")
863
866
  throw new I(c.EFFECT_MUST_BE_FUNCTION);
864
- const e = new gt(i, t);
867
+ const e = new Nt(i, t);
865
868
  return e.execute(), e;
866
869
  }
867
- function At(i) {
870
+ function wt(i) {
868
871
  if (typeof i != "function")
869
872
  throw new TypeError("Batch callback must be a function");
870
873
  N.startBatch();
@@ -875,23 +878,26 @@ function At(i) {
875
878
  }
876
879
  }
877
880
  export {
881
+ X as ATOM_BRAND,
878
882
  k as AsyncState,
879
883
  O as AtomError,
884
+ ct as COMPUTED_BRAND,
880
885
  d as ComputedError,
881
- et as DEBUG_CONFIG,
886
+ _t as DEBUG_CONFIG,
882
887
  D as DEBUG_RUNTIME,
888
+ ut as EFFECT_BRAND,
883
889
  I as EffectError,
884
- St as POOL_CONFIG,
890
+ kt as POOL_CONFIG,
885
891
  S as SCHEDULER_CONFIG,
886
- L as SchedulerError,
887
- Ct as atom,
888
- At as batch,
889
- Ot as computed,
890
- yt as effect,
891
- at as isAtom,
892
- Tt as isComputed,
893
- bt as isEffect,
892
+ m as SchedulerError,
893
+ Lt as atom,
894
+ wt as batch,
895
+ Ut as computed,
896
+ vt as effect,
897
+ Ft as isAtom,
898
+ Rt as isComputed,
899
+ xt as isEffect,
894
900
  N as scheduler,
895
- Dt as untracked
901
+ mt as untracked
896
902
  };
897
903
  //# sourceMappingURL=index.mjs.map