@but212/atom-effect 0.27.0 → 0.28.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/atom-effect.min.js +1 -1
- package/dist/atom-effect.min.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +60 -0
- package/dist/index.mjs +239 -180
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ var A = {
|
|
|
6
6
|
}, I = {
|
|
7
7
|
DISPOSED: 1,
|
|
8
8
|
EXECUTING: 8
|
|
9
|
-
},
|
|
9
|
+
}, z = {
|
|
10
10
|
DISPOSED: 1,
|
|
11
11
|
IS_COMPUTED: 2,
|
|
12
12
|
DIRTY: 8,
|
|
@@ -28,20 +28,20 @@ var A = {
|
|
|
28
28
|
MAX_FLUSH_ITERATIONS: 1e3,
|
|
29
29
|
MIN_FLUSH_ITERATIONS: 10,
|
|
30
30
|
BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
|
|
31
|
-
},
|
|
31
|
+
}, et = {
|
|
32
32
|
WARN_INFINITE_LOOP: !0,
|
|
33
33
|
EFFECT_FREQUENCY_WINDOW: 1e3
|
|
34
|
-
},
|
|
34
|
+
}, W = {
|
|
35
35
|
MAX_ASYNC_RETRIES: 3,
|
|
36
36
|
MAX_PROMISE_ID: Number.MAX_SAFE_INTEGER - 1
|
|
37
37
|
}, T = {
|
|
38
38
|
UNINITIALIZED: -1,
|
|
39
39
|
MIN: 1
|
|
40
|
-
},
|
|
40
|
+
}, U = 1073741823, Et = { VERSION_BITS: 16 }, Ot = (typeof process < "u" && process.env, !1), K = Object.freeze([]), X = class {
|
|
41
41
|
constructor(t, s, e = void 0) {
|
|
42
42
|
this.node = t, this.version = s, this.unsub = e;
|
|
43
43
|
}
|
|
44
|
-
},
|
|
44
|
+
}, dt = class {
|
|
45
45
|
constructor(t, s) {
|
|
46
46
|
this.fn = t, this.sub = s;
|
|
47
47
|
}
|
|
@@ -66,11 +66,11 @@ var A = {
|
|
|
66
66
|
constructor(t, s = null) {
|
|
67
67
|
super(t, s, !1), this.name = "EffectError";
|
|
68
68
|
}
|
|
69
|
-
},
|
|
69
|
+
}, P = class extends N {
|
|
70
70
|
constructor(t, s = null) {
|
|
71
71
|
super(t, s, !1), this.name = "SchedulerError";
|
|
72
72
|
}
|
|
73
|
-
},
|
|
73
|
+
}, _ = {
|
|
74
74
|
COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
|
|
75
75
|
COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
|
|
76
76
|
COMPUTED_COMPUTATION_FAILED: "Computation execution failed",
|
|
@@ -89,7 +89,7 @@ var A = {
|
|
|
89
89
|
SCHEDULER_CALLBACK_MUST_BE_FUNCTION: "Scheduler callback must be a function",
|
|
90
90
|
SCHEDULER_END_BATCH_WITHOUT_START: "endBatch() called without matching startBatch(). Ignoring.",
|
|
91
91
|
BATCH_CALLBACK_MUST_BE_FUNCTION: "Batch callback must be a function"
|
|
92
|
-
},
|
|
92
|
+
}, it = class {
|
|
93
93
|
constructor() {
|
|
94
94
|
this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow = null, this._freeIndices = null;
|
|
95
95
|
}
|
|
@@ -239,9 +239,9 @@ var A = {
|
|
|
239
239
|
if (o != null && (t(o), ++e === s))
|
|
240
240
|
return;
|
|
241
241
|
const u = this._overflow;
|
|
242
|
-
if (u != null) for (let
|
|
243
|
-
const
|
|
244
|
-
if (
|
|
242
|
+
if (u != null) for (let l = 0, h = u.length; l < h; l++) {
|
|
243
|
+
const c = u[l];
|
|
244
|
+
if (c != null && (t(c), ++e === s))
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
247
|
}
|
|
@@ -262,9 +262,9 @@ var A = {
|
|
|
262
262
|
if (o != null && (t(o), ++e === s))
|
|
263
263
|
return e;
|
|
264
264
|
const u = this._overflow;
|
|
265
|
-
if (u != null) for (let
|
|
266
|
-
const
|
|
267
|
-
if (
|
|
265
|
+
if (u != null) for (let l = 0, h = u.length; l < h; l++) {
|
|
266
|
+
const c = u[l];
|
|
267
|
+
if (c != null && (t(c), ++e === s))
|
|
268
268
|
return e;
|
|
269
269
|
}
|
|
270
270
|
return e;
|
|
@@ -288,9 +288,9 @@ var A = {
|
|
|
288
288
|
dispose() {
|
|
289
289
|
this.clear();
|
|
290
290
|
}
|
|
291
|
-
},
|
|
291
|
+
}, Z = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), pt = /* @__PURE__ */ Symbol("AtomEffect.Id"), J = /* @__PURE__ */ Symbol("AtomEffect.Type"), M = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), Ct = class {
|
|
292
292
|
constructor() {
|
|
293
|
-
this.enabled = !1, this.warnInfiniteLoop =
|
|
293
|
+
this.enabled = !1, this.warnInfiniteLoop = et.WARN_INFINITE_LOOP;
|
|
294
294
|
}
|
|
295
295
|
warn(t, s) {
|
|
296
296
|
}
|
|
@@ -298,34 +298,34 @@ var A = {
|
|
|
298
298
|
}
|
|
299
299
|
getDebugName(t) {
|
|
300
300
|
if (t != null)
|
|
301
|
-
return t[
|
|
301
|
+
return t[Z];
|
|
302
302
|
}
|
|
303
303
|
getDebugType(t) {
|
|
304
304
|
if (t != null)
|
|
305
|
-
return t[
|
|
305
|
+
return t[J];
|
|
306
306
|
}
|
|
307
|
-
},
|
|
307
|
+
}, Q = new Ct(), It = 1, Dt = () => It++ | 0;
|
|
308
308
|
function m(t, s, e) {
|
|
309
309
|
return t instanceof N ? t : t instanceof Error ? new s(`${t.name || t.constructor.name || "Error"} (${e}): ${t.message}`, t) : new s(`Unexpected error (${e}): ${String(t)}`);
|
|
310
310
|
}
|
|
311
|
-
var
|
|
311
|
+
var Y = class {
|
|
312
312
|
constructor() {
|
|
313
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch = T.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id =
|
|
313
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = T.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = Dt() & U;
|
|
314
314
|
}
|
|
315
315
|
get isDisposed() {
|
|
316
|
-
return (this.flags &
|
|
316
|
+
return (this.flags & z.DISPOSED) !== 0;
|
|
317
317
|
}
|
|
318
318
|
get isComputed() {
|
|
319
|
-
return (this.flags &
|
|
319
|
+
return (this.flags & z.IS_COMPUTED) !== 0;
|
|
320
320
|
}
|
|
321
321
|
get hasError() {
|
|
322
322
|
return !1;
|
|
323
323
|
}
|
|
324
324
|
subscribe(t) {
|
|
325
325
|
const s = typeof t == "function";
|
|
326
|
-
if (!s && (!t || typeof t.execute != "function")) throw m(/* @__PURE__ */ new TypeError("Invalid subscriber"), N,
|
|
326
|
+
if (!s && (!t || typeof t.execute != "function")) throw m(/* @__PURE__ */ new TypeError("Invalid subscriber"), N, _.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
|
|
327
327
|
let e = this._slots;
|
|
328
|
-
e || (e = new
|
|
328
|
+
e || (e = new it(), this._slots = e);
|
|
329
329
|
let i = !1;
|
|
330
330
|
if (e._s0 != null && (s ? e._s0.fn === t : e._s0.sub === t)) i = !0;
|
|
331
331
|
else if (e._s1 != null && (s ? e._s1.fn === t : e._s1.sub === t)) i = !0;
|
|
@@ -334,8 +334,8 @@ var Q = class {
|
|
|
334
334
|
else {
|
|
335
335
|
const n = e._overflow;
|
|
336
336
|
if (n != null) for (let o = 0, u = n.length; o < u; o++) {
|
|
337
|
-
const
|
|
338
|
-
if (
|
|
337
|
+
const l = n[o];
|
|
338
|
+
if (l != null && (s ? l.fn === t : l.sub === t)) {
|
|
339
339
|
i = !0;
|
|
340
340
|
break;
|
|
341
341
|
}
|
|
@@ -344,7 +344,7 @@ var Q = class {
|
|
|
344
344
|
if (i)
|
|
345
345
|
return () => {
|
|
346
346
|
};
|
|
347
|
-
const r = new
|
|
347
|
+
const r = new dt(s ? t : void 0, s ? void 0 : t);
|
|
348
348
|
return e.add(r), () => this._unsubscribe(r);
|
|
349
349
|
}
|
|
350
350
|
_unsubscribe(t) {
|
|
@@ -386,8 +386,8 @@ var Q = class {
|
|
|
386
386
|
const u = r[n];
|
|
387
387
|
if (u != null) try {
|
|
388
388
|
u.notify(t, s);
|
|
389
|
-
} catch (
|
|
390
|
-
this._logNotifyError(
|
|
389
|
+
} catch (l) {
|
|
390
|
+
this._logNotifyError(l);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
} finally {
|
|
@@ -396,7 +396,7 @@ var Q = class {
|
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
_logNotifyError(t) {
|
|
399
|
-
console.error(m(t, N,
|
|
399
|
+
console.error(m(t, N, _.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
|
|
400
400
|
}
|
|
401
401
|
_isDirty() {
|
|
402
402
|
const t = this._deps;
|
|
@@ -408,32 +408,32 @@ var Q = class {
|
|
|
408
408
|
}
|
|
409
409
|
return !t.hasComputeds && !t.isDirtyFast() ? !1 : this._deepDirtyCheck();
|
|
410
410
|
}
|
|
411
|
-
},
|
|
412
|
-
function
|
|
413
|
-
const t =
|
|
414
|
-
return
|
|
411
|
+
}, x = 0;
|
|
412
|
+
function k() {
|
|
413
|
+
const t = x + 1 & U;
|
|
414
|
+
return x = t === 0 ? 1 : t, x;
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
const s = t + 1 &
|
|
416
|
+
function G(t) {
|
|
417
|
+
const s = t + 1 & U;
|
|
418
418
|
return s === 0 ? 1 : s;
|
|
419
419
|
}
|
|
420
|
-
var
|
|
421
|
-
function
|
|
422
|
-
return
|
|
423
|
-
}
|
|
424
|
-
function J() {
|
|
425
|
-
return R ? !1 : (R = !0, it = Y(), k = 0, !0);
|
|
420
|
+
var V = 0, F = !1, nt = 0;
|
|
421
|
+
function rt() {
|
|
422
|
+
return nt;
|
|
426
423
|
}
|
|
427
424
|
function tt() {
|
|
428
|
-
|
|
425
|
+
return F ? !1 : (F = !0, nt = k(), V = 0, !0);
|
|
426
|
+
}
|
|
427
|
+
function st() {
|
|
428
|
+
F = !1;
|
|
429
429
|
}
|
|
430
|
-
function
|
|
431
|
-
if (!
|
|
432
|
-
const t = ++
|
|
430
|
+
function vt() {
|
|
431
|
+
if (!F) return 0;
|
|
432
|
+
const t = ++V;
|
|
433
433
|
if (t <= C.MAX_EXECUTIONS_PER_FLUSH) return t;
|
|
434
434
|
throw new Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${C.MAX_EXECUTIONS_PER_FLUSH}`);
|
|
435
435
|
}
|
|
436
|
-
var
|
|
436
|
+
var St = class {
|
|
437
437
|
constructor() {
|
|
438
438
|
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = C.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
|
|
439
439
|
}
|
|
@@ -459,19 +459,19 @@ var It = class {
|
|
|
459
459
|
_runLoop() {
|
|
460
460
|
try {
|
|
461
461
|
if (this._size === 0) return;
|
|
462
|
-
const t =
|
|
463
|
-
this._drainQueue(), t &&
|
|
462
|
+
const t = tt();
|
|
463
|
+
this._drainQueue(), t && st();
|
|
464
464
|
} finally {
|
|
465
465
|
this._isProcessing = !1, this._size > 0 && this._batchDepth === 0 && this._flush();
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
468
|
_flushSync() {
|
|
469
469
|
this._isFlushingSync = !0;
|
|
470
|
-
const t =
|
|
470
|
+
const t = tt();
|
|
471
471
|
try {
|
|
472
472
|
this._mergeBatchQueue(), this._drainQueue();
|
|
473
473
|
} finally {
|
|
474
|
-
this._isFlushingSync = !1, t &&
|
|
474
|
+
this._isFlushingSync = !1, t && st();
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
_mergeBatchQueue() {
|
|
@@ -503,14 +503,14 @@ var It = class {
|
|
|
503
503
|
try {
|
|
504
504
|
typeof r == "function" ? r() : r.execute();
|
|
505
505
|
} catch (n) {
|
|
506
|
-
console.error(new
|
|
506
|
+
console.error(new P("Error occurred during scheduler execution", n));
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
s.length = 0;
|
|
510
510
|
}
|
|
511
511
|
_handleFlushOverflow() {
|
|
512
512
|
const t = this._size + this._batchQueueSize, s = this._maxFlushIterations;
|
|
513
|
-
console.error(new
|
|
513
|
+
console.error(new P(_.SCHEDULER_FLUSH_OVERFLOW(s, t))), this._size = 0;
|
|
514
514
|
const e = this._bufferIndex;
|
|
515
515
|
this._queueBuffer[e].length = 0, this._batchQueueSize = 0;
|
|
516
516
|
const i = this.onOverflow;
|
|
@@ -526,14 +526,15 @@ var It = class {
|
|
|
526
526
|
this._batchDepth !== 0 && --this._batchDepth === 0 && this._flushSync();
|
|
527
527
|
}
|
|
528
528
|
setMaxFlushIterations(t) {
|
|
529
|
-
if (t < C.MIN_FLUSH_ITERATIONS) throw new
|
|
529
|
+
if (t < C.MIN_FLUSH_ITERATIONS) throw new P(`Max flush iterations must be at least ${C.MIN_FLUSH_ITERATIONS}`);
|
|
530
530
|
this._maxFlushIterations = t;
|
|
531
531
|
}
|
|
532
|
-
},
|
|
532
|
+
}, w = new St(), $ = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ot = /* @__PURE__ */ Symbol.for("atom-effect/computed"), ut = /* @__PURE__ */ Symbol.for("atom-effect/effect"), gt = /* @__PURE__ */ Symbol.for("atom-effect/writable"), Tt = class {
|
|
533
533
|
constructor() {
|
|
534
534
|
this.current = null;
|
|
535
535
|
}
|
|
536
536
|
run(t, s) {
|
|
537
|
+
if (this.current === t) return s();
|
|
537
538
|
const e = this.current;
|
|
538
539
|
this.current = t;
|
|
539
540
|
try {
|
|
@@ -542,9 +543,9 @@ var It = class {
|
|
|
542
543
|
this.current = e;
|
|
543
544
|
}
|
|
544
545
|
}
|
|
545
|
-
},
|
|
546
|
-
function
|
|
547
|
-
const s =
|
|
546
|
+
}, f = new Tt();
|
|
547
|
+
function Rt(t) {
|
|
548
|
+
const s = f, e = s.current;
|
|
548
549
|
if (e === null) return t();
|
|
549
550
|
s.current = null;
|
|
550
551
|
try {
|
|
@@ -553,9 +554,9 @@ function Nt(t) {
|
|
|
553
554
|
s.current = e;
|
|
554
555
|
}
|
|
555
556
|
}
|
|
556
|
-
var
|
|
557
|
+
var mt = class extends Y {
|
|
557
558
|
constructor(t, s) {
|
|
558
|
-
super(), this[
|
|
559
|
+
super(), this[$] = !0, this[gt] = !0, this._value = t, s && (this.flags |= a.SYNC), Q.attachDebugInfo(this, "atom", this.id);
|
|
559
560
|
}
|
|
560
561
|
get isNotificationScheduled() {
|
|
561
562
|
return (this.flags & a.NOTIFICATION_SCHEDULED) !== 0;
|
|
@@ -564,17 +565,17 @@ var St = class extends Q {
|
|
|
564
565
|
return (this.flags & a.SYNC) !== 0;
|
|
565
566
|
}
|
|
566
567
|
get value() {
|
|
567
|
-
const t =
|
|
568
|
+
const t = f.current;
|
|
568
569
|
return t?.addDependency(this), this._value;
|
|
569
570
|
}
|
|
570
571
|
set value(t) {
|
|
571
572
|
const s = this._value;
|
|
572
573
|
if (Object.is(s, t)) return;
|
|
573
|
-
this._value = t, this.version =
|
|
574
|
+
this._value = t, this.version = G(this.version);
|
|
574
575
|
const e = this.flags;
|
|
575
576
|
if ((e & a.NOTIFICATION_SCHEDULED) !== 0) return;
|
|
576
577
|
const i = this._slots;
|
|
577
|
-
i == null || i.size === 0 || (this._pendingOldValue = s, this.flags = e | a.NOTIFICATION_SCHEDULED, (e & a.SYNC) !== 0 && !
|
|
578
|
+
i == null || i.size === 0 || (this._pendingOldValue = s, this.flags = e | a.NOTIFICATION_SCHEDULED, (e & a.SYNC) !== 0 && !w.isBatching ? this._flushNotifications() : w.schedule(this));
|
|
578
579
|
}
|
|
579
580
|
execute() {
|
|
580
581
|
this._flushNotifications();
|
|
@@ -599,10 +600,10 @@ var St = class extends Q {
|
|
|
599
600
|
this.dispose();
|
|
600
601
|
}
|
|
601
602
|
};
|
|
602
|
-
function
|
|
603
|
-
return new
|
|
603
|
+
function Ft(t, s = {}) {
|
|
604
|
+
return new mt(t, s.sync ?? !1);
|
|
604
605
|
}
|
|
605
|
-
var
|
|
606
|
+
var lt = class extends it {
|
|
606
607
|
constructor(...t) {
|
|
607
608
|
super(...t), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1, this._depsHash = 0;
|
|
608
609
|
}
|
|
@@ -656,10 +657,10 @@ var ut = class extends et {
|
|
|
656
657
|
const r = this._overflow;
|
|
657
658
|
if (r) {
|
|
658
659
|
const n = t.version, o = s > 4 ? s : 4, u = r.length;
|
|
659
|
-
for (let
|
|
660
|
-
const
|
|
661
|
-
if (
|
|
662
|
-
return
|
|
660
|
+
for (let l = o - 4; l < u; l++) {
|
|
661
|
+
const h = r[l];
|
|
662
|
+
if (h && h.node === t && h.unsub)
|
|
663
|
+
return h.version = n, this._swapGeneral(l + 4, s, h), !0;
|
|
663
664
|
}
|
|
664
665
|
}
|
|
665
666
|
return !1;
|
|
@@ -672,19 +673,19 @@ var ut = class extends et {
|
|
|
672
673
|
if (s < 4) {
|
|
673
674
|
const u = this._s0;
|
|
674
675
|
s <= 0 && u?.unsub && e.set(u.node, 0);
|
|
675
|
-
const
|
|
676
|
-
s <= 1 &&
|
|
677
|
-
const
|
|
678
|
-
s <= 2 &&
|
|
679
|
-
const
|
|
680
|
-
s <= 3 &&
|
|
676
|
+
const l = this._s1;
|
|
677
|
+
s <= 1 && l?.unsub && e.set(l.node, 1);
|
|
678
|
+
const h = this._s2;
|
|
679
|
+
s <= 2 && h?.unsub && e.set(h.node, 2);
|
|
680
|
+
const c = this._s3;
|
|
681
|
+
s <= 3 && c?.unsub && e.set(c.node, 3);
|
|
681
682
|
}
|
|
682
683
|
const o = this._overflow;
|
|
683
684
|
if (o && n > 4) {
|
|
684
|
-
const u = s > 4 ? s : 4,
|
|
685
|
-
for (let
|
|
686
|
-
const
|
|
687
|
-
|
|
685
|
+
const u = s > 4 ? s : 4, l = o.length;
|
|
686
|
+
for (let h = u - 4; h < l; h++) {
|
|
687
|
+
const c = o[h];
|
|
688
|
+
c?.unsub && e.set(c.node, h + 4);
|
|
688
689
|
}
|
|
689
690
|
}
|
|
690
691
|
}
|
|
@@ -738,7 +739,7 @@ var ut = class extends et {
|
|
|
738
739
|
_calculateHash(t) {
|
|
739
740
|
const s = this._count;
|
|
740
741
|
if (s === 0) return 0;
|
|
741
|
-
const e =
|
|
742
|
+
const e = Et.VERSION_BITS;
|
|
742
743
|
let i = 0;
|
|
743
744
|
const r = this._s0;
|
|
744
745
|
if (r != null) {
|
|
@@ -746,16 +747,16 @@ var ut = class extends et {
|
|
|
746
747
|
i = i + (o << e) + n.id | 0;
|
|
747
748
|
const u = this._s1;
|
|
748
749
|
if (s > 1 && u != null) {
|
|
749
|
-
const
|
|
750
|
-
i = i + (
|
|
751
|
-
const
|
|
752
|
-
if (s > 2 &&
|
|
753
|
-
const
|
|
754
|
-
i = i + (
|
|
755
|
-
const
|
|
756
|
-
if (s > 3 &&
|
|
757
|
-
const
|
|
758
|
-
i = i + (
|
|
750
|
+
const l = u.node, h = t ? l.version : u.version;
|
|
751
|
+
i = i + (h << e) + l.id | 0;
|
|
752
|
+
const c = this._s2;
|
|
753
|
+
if (s > 2 && c != null) {
|
|
754
|
+
const q = c.node, ft = t ? q.version : c.version;
|
|
755
|
+
i = i + (ft << e) + q.id | 0;
|
|
756
|
+
const L = this._s3;
|
|
757
|
+
if (s > 3 && L != null) {
|
|
758
|
+
const j = L.node, at = t ? j.version : L.version;
|
|
759
|
+
i = i + (at << e) + j.id | 0;
|
|
759
760
|
}
|
|
760
761
|
}
|
|
761
762
|
}
|
|
@@ -763,8 +764,8 @@ var ut = class extends et {
|
|
|
763
764
|
if (s > 4) {
|
|
764
765
|
const n = this._overflow;
|
|
765
766
|
for (let o = 0, u = n.length; o < u; o++) {
|
|
766
|
-
const
|
|
767
|
-
i = i + (
|
|
767
|
+
const l = n[o], h = l.node, c = t ? h.version : l.version;
|
|
768
|
+
i = i + (c << e) + h.id | 0;
|
|
768
769
|
}
|
|
769
770
|
}
|
|
770
771
|
return i;
|
|
@@ -778,22 +779,22 @@ var ut = class extends et {
|
|
|
778
779
|
compact() {
|
|
779
780
|
}
|
|
780
781
|
};
|
|
781
|
-
function
|
|
782
|
-
return typeof t == "object" && t !== null &&
|
|
783
|
-
}
|
|
784
|
-
function Ot(t) {
|
|
785
|
-
return typeof t == "object" && t !== null && rt in t;
|
|
782
|
+
function wt(t) {
|
|
783
|
+
return typeof t == "object" && t !== null && $ in t;
|
|
786
784
|
}
|
|
787
|
-
function
|
|
785
|
+
function Ut(t) {
|
|
788
786
|
return typeof t == "object" && t !== null && ot in t;
|
|
789
787
|
}
|
|
788
|
+
function Lt(t) {
|
|
789
|
+
return typeof t == "object" && t !== null && ut in t;
|
|
790
|
+
}
|
|
790
791
|
function ht(t) {
|
|
791
792
|
return typeof t == "object" && t !== null && typeof t.then == "function";
|
|
792
793
|
}
|
|
793
|
-
var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR:
|
|
794
|
+
var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR: b, RECOMPUTING: y, DISPOSED: B, IS_COMPUTED: O, FORCE_COMPUTE: H } = z, Nt = class extends Y {
|
|
794
795
|
constructor(t, s = {}) {
|
|
795
|
-
if (typeof t != "function") throw new S(
|
|
796
|
-
if (super(), this[
|
|
796
|
+
if (typeof t != "function") throw new S(_.COMPUTED_MUST_BE_FUNCTION);
|
|
797
|
+
if (super(), this[$] = !0, this[ot] = !0, this._error = null, this._promiseId = 0, this._deps = new lt(), this._asyncRetryCount = 0, this._lastDriftEpoch = T.UNINITIALIZED, this._trackEpoch = T.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = O | E | p, this._equal = s.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in s ? s.defaultValue : M, this._onError = s.onError ?? null, this._maxAsyncRetries = (s.maxAsyncRetries ?? W.MAX_ASYNC_RETRIES) & U, Q.attachDebugInfo(this, "computed", this.id), s.lazy === !1) try {
|
|
797
798
|
this._recompute();
|
|
798
799
|
} catch {
|
|
799
800
|
}
|
|
@@ -808,30 +809,30 @@ var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR: O, REC
|
|
|
808
809
|
return (this.flags & y) !== 0;
|
|
809
810
|
}
|
|
810
811
|
get _hasErrorInternal() {
|
|
811
|
-
return (this.flags &
|
|
812
|
+
return (this.flags & b) !== 0;
|
|
812
813
|
}
|
|
813
814
|
_track() {
|
|
814
|
-
|
|
815
|
+
f.current?.addDependency(this);
|
|
815
816
|
}
|
|
816
817
|
get value() {
|
|
817
|
-
const t =
|
|
818
|
+
const t = f.current;
|
|
818
819
|
t?.addDependency(this);
|
|
819
820
|
let s = this.flags;
|
|
820
821
|
if ((s & (d | E | p)) === d) return this._value;
|
|
821
|
-
if ((s &
|
|
822
|
+
if ((s & B) !== 0) throw new S(_.COMPUTED_DISPOSED);
|
|
822
823
|
if ((s & y) !== 0) {
|
|
823
824
|
const r = this._defaultValue;
|
|
824
|
-
if (r !==
|
|
825
|
-
throw new S(
|
|
825
|
+
if (r !== M) return r;
|
|
826
|
+
throw new S(_.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
826
827
|
}
|
|
827
828
|
if ((s & (E | p)) !== 0) {
|
|
828
829
|
const r = this._deps;
|
|
829
|
-
if ((s & p) === 0 && (s &
|
|
830
|
+
if ((s & p) === 0 && (s & H) === 0 && r.size > 0 && !this._isDirty() ? s = this.flags &= ~E : (this._recompute(), s = this.flags), (s & d) !== 0) return this._value;
|
|
830
831
|
}
|
|
831
|
-
const e = this._defaultValue, i = e !==
|
|
832
|
+
const e = this._defaultValue, i = e !== M;
|
|
832
833
|
if ((s & g) !== 0) {
|
|
833
834
|
if (i) return e;
|
|
834
|
-
throw new S(
|
|
835
|
+
throw new S(_.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
835
836
|
}
|
|
836
837
|
if ((s & D) !== 0) {
|
|
837
838
|
if (i) return e;
|
|
@@ -843,14 +844,14 @@ var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR: O, REC
|
|
|
843
844
|
return this._value;
|
|
844
845
|
}
|
|
845
846
|
get state() {
|
|
846
|
-
const t =
|
|
847
|
+
const t = f.current;
|
|
847
848
|
t?.addDependency(this);
|
|
848
849
|
const s = this.flags;
|
|
849
850
|
return (s & d) !== 0 ? A.RESOLVED : (s & g) !== 0 ? A.PENDING : (s & D) !== 0 ? A.REJECTED : A.IDLE;
|
|
850
851
|
}
|
|
851
852
|
get hasError() {
|
|
852
|
-
const t =
|
|
853
|
-
if (t?.addDependency(this), (this.flags & (D |
|
|
853
|
+
const t = f.current;
|
|
854
|
+
if (t?.addDependency(this), (this.flags & (D | b)) !== 0) return !0;
|
|
854
855
|
const s = this._deps;
|
|
855
856
|
if (!s.hasComputeds) return !1;
|
|
856
857
|
const e = s.size;
|
|
@@ -861,11 +862,11 @@ var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR: O, REC
|
|
|
861
862
|
return !this.hasError;
|
|
862
863
|
}
|
|
863
864
|
get errors() {
|
|
864
|
-
const t =
|
|
865
|
+
const t = f.current;
|
|
865
866
|
t?.addDependency(this);
|
|
866
867
|
const s = this._error, e = this._deps;
|
|
867
868
|
if (!e.hasComputeds)
|
|
868
|
-
return s == null ?
|
|
869
|
+
return s == null ? K : Object.freeze([s]);
|
|
869
870
|
const i = [];
|
|
870
871
|
s != null && i.push(s);
|
|
871
872
|
const r = e.size;
|
|
@@ -873,9 +874,9 @@ var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR: O, REC
|
|
|
873
874
|
const o = e.getAt(n);
|
|
874
875
|
if (o == null) continue;
|
|
875
876
|
const u = o.node;
|
|
876
|
-
(u.flags &
|
|
877
|
+
(u.flags & O) !== 0 && u.hasError && this._collectErrorsFromDep(u, i);
|
|
877
878
|
}
|
|
878
|
-
return i.length === 0 ?
|
|
879
|
+
return i.length === 0 ? K : Object.freeze(i);
|
|
879
880
|
}
|
|
880
881
|
_collectErrorsFromDep(t, s) {
|
|
881
882
|
const e = t.errors, i = e.length;
|
|
@@ -885,22 +886,22 @@ var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR: O, REC
|
|
|
885
886
|
}
|
|
886
887
|
}
|
|
887
888
|
get lastError() {
|
|
888
|
-
const t =
|
|
889
|
+
const t = f.current;
|
|
889
890
|
return t?.addDependency(this), this._error;
|
|
890
891
|
}
|
|
891
892
|
get isPending() {
|
|
892
|
-
const t =
|
|
893
|
+
const t = f.current;
|
|
893
894
|
return t?.addDependency(this), (this.flags & g) !== 0;
|
|
894
895
|
}
|
|
895
896
|
get isResolved() {
|
|
896
|
-
const t =
|
|
897
|
+
const t = f.current;
|
|
897
898
|
return t?.addDependency(this), (this.flags & d) !== 0;
|
|
898
899
|
}
|
|
899
900
|
invalidate() {
|
|
900
|
-
this.flags |=
|
|
901
|
+
this.flags |= H, this._markDirty();
|
|
901
902
|
}
|
|
902
903
|
dispose() {
|
|
903
|
-
(this.flags &
|
|
904
|
+
(this.flags & B) === 0 && (this._deps.disposeAll(), this._slots != null && this._slots.clear(), this.flags = B | E | p, this._error = null, this._value = void 0, this._hotIndex = -1);
|
|
904
905
|
}
|
|
905
906
|
[Symbol.dispose]() {
|
|
906
907
|
this.dispose();
|
|
@@ -912,54 +913,54 @@ var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR: O, REC
|
|
|
912
913
|
const e = this._trackCount++, i = this._deps, r = i.getAt(e);
|
|
913
914
|
if (r != null && r.node === t) r.version = t.version;
|
|
914
915
|
else if (!i.claimExisting(t, e)) {
|
|
915
|
-
const n = new
|
|
916
|
+
const n = new X(t, t.version, t.subscribe(this));
|
|
916
917
|
i.insertNew(e, n);
|
|
917
918
|
}
|
|
918
|
-
(t.flags &
|
|
919
|
+
(t.flags & O) !== 0 && (i.hasComputeds = !0);
|
|
919
920
|
}
|
|
920
921
|
_recompute() {
|
|
921
922
|
if (this.isRecomputing) return;
|
|
922
|
-
this.flags = (this.flags | y) & ~
|
|
923
|
+
this.flags = (this.flags | y) & ~H, this._trackEpoch = k(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
|
|
923
924
|
let t = !1;
|
|
924
925
|
try {
|
|
925
|
-
const s =
|
|
926
|
+
const s = f.run(this, this._fn);
|
|
926
927
|
this._deps.truncateFrom(this._trackCount), this._deps.seal(), t = !0, ht(s) ? this._handleAsyncComputation(s) : this._finalizeResolution(s);
|
|
927
928
|
} catch (s) {
|
|
928
929
|
if (!t) try {
|
|
929
930
|
this._deps.truncateFrom(this._trackCount);
|
|
930
931
|
} catch {
|
|
931
932
|
}
|
|
932
|
-
this._handleError(s,
|
|
933
|
+
this._handleError(s, _.COMPUTED_COMPUTATION_FAILED, !0);
|
|
933
934
|
} finally {
|
|
934
935
|
this._trackEpoch = T.UNINITIALIZED, this._trackCount = 0, this.flags &= ~y;
|
|
935
936
|
}
|
|
936
937
|
}
|
|
937
938
|
_handleAsyncComputation(t) {
|
|
938
|
-
this.flags = (this.flags | g) & ~(p | E | d | D), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) %
|
|
939
|
+
this.flags = (this.flags | g) & ~(p | E | d | D), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % W.MAX_PROMISE_ID;
|
|
939
940
|
const s = this._promiseId;
|
|
940
941
|
t.then((e) => {
|
|
941
942
|
if (s === this._promiseId) {
|
|
942
943
|
if (this._isDirty()) {
|
|
943
|
-
const i =
|
|
944
|
-
return this._lastDriftEpoch !== i && (this._lastDriftEpoch = i, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(new S(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`),
|
|
944
|
+
const i = rt();
|
|
945
|
+
return this._lastDriftEpoch !== i && (this._lastDriftEpoch = i, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(new S(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`), _.COMPUTED_ASYNC_COMPUTATION_FAILED);
|
|
945
946
|
}
|
|
946
947
|
this._finalizeResolution(e), this._notifySubscribers(e, void 0);
|
|
947
948
|
}
|
|
948
|
-
}, (e) => s === this._promiseId && this._handleError(e,
|
|
949
|
+
}, (e) => s === this._promiseId && this._handleError(e, _.COMPUTED_ASYNC_COMPUTATION_FAILED));
|
|
949
950
|
}
|
|
950
951
|
_handleError(t, s, e = !1) {
|
|
951
952
|
const i = m(t, S, s);
|
|
952
|
-
if (!e && !this.isRejected && (this.version =
|
|
953
|
+
if (!e && !this.isRejected && (this.version = G(this.version)), this._error = i, this.flags = this.flags & ~(p | E | g | d) | D | b, this._onError) try {
|
|
953
954
|
this._onError(i);
|
|
954
955
|
} catch (r) {
|
|
955
|
-
console.error(
|
|
956
|
+
console.error(_.CALLBACK_ERROR_IN_ERROR_HANDLER, r);
|
|
956
957
|
}
|
|
957
958
|
if (e) throw i;
|
|
958
959
|
this._notifySubscribers(void 0, void 0);
|
|
959
960
|
}
|
|
960
961
|
_finalizeResolution(t) {
|
|
961
962
|
const s = this.flags;
|
|
962
|
-
((s & d) === 0 || !this._equal(this._value, t)) && (this.version =
|
|
963
|
+
((s & d) === 0 || !this._equal(this._value, t)) && (this.version = G(this.version)), this._value = t, this._error = null, this.flags = (s | d) & ~(p | E | g | D | b);
|
|
963
964
|
}
|
|
964
965
|
execute() {
|
|
965
966
|
this._markDirty();
|
|
@@ -973,15 +974,15 @@ var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR: O, REC
|
|
|
973
974
|
return t.hasComputeds ? this._deepDirtyCheck() : t.isDirtyFast();
|
|
974
975
|
}
|
|
975
976
|
_deepDirtyCheck() {
|
|
976
|
-
const t = this._deps, s =
|
|
977
|
-
|
|
977
|
+
const t = this._deps, s = f.current;
|
|
978
|
+
f.current = null;
|
|
978
979
|
try {
|
|
979
980
|
const e = t.size;
|
|
980
981
|
for (let i = 0; i < e; i++) {
|
|
981
982
|
const r = t.getAt(i);
|
|
982
983
|
if (r == null) continue;
|
|
983
984
|
const n = r.node;
|
|
984
|
-
if ((n.flags &
|
|
985
|
+
if ((n.flags & O) !== 0) try {
|
|
985
986
|
n.value;
|
|
986
987
|
} catch {
|
|
987
988
|
}
|
|
@@ -990,19 +991,19 @@ var { IDLE: p, DIRTY: E, PENDING: g, RESOLVED: d, REJECTED: D, HAS_ERROR: O, REC
|
|
|
990
991
|
}
|
|
991
992
|
return this._hotIndex = -1, !1;
|
|
992
993
|
} finally {
|
|
993
|
-
|
|
994
|
+
f.current = s;
|
|
994
995
|
}
|
|
995
996
|
}
|
|
996
997
|
};
|
|
997
|
-
function
|
|
998
|
-
return new
|
|
998
|
+
function Pt(t, s = {}) {
|
|
999
|
+
return new Nt(t, s);
|
|
999
1000
|
}
|
|
1000
|
-
var
|
|
1001
|
+
var yt = class extends Y {
|
|
1001
1002
|
constructor(t, s = {}) {
|
|
1002
|
-
super(), this[
|
|
1003
|
+
super(), this[ut] = !0, this._cleanup = null, this._deps = new lt(), this._currentEpoch = T.UNINITIALIZED, this._lastFlushEpoch = T.UNINITIALIZED, this._fn = t, this._onError = s.onError ?? null, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? C.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? C.MAX_EXECUTIONS_PER_EFFECT, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => w.schedule(this), Q.attachDebugInfo(this, "effect", this.id);
|
|
1003
1004
|
}
|
|
1004
1005
|
run() {
|
|
1005
|
-
if (this.isDisposed) throw new v(
|
|
1006
|
+
if (this.isDisposed) throw new v(_.EFFECT_DISPOSED);
|
|
1006
1007
|
this.execute(!0);
|
|
1007
1008
|
}
|
|
1008
1009
|
dispose() {
|
|
@@ -1040,14 +1041,14 @@ var Tt = class extends Q {
|
|
|
1040
1041
|
let e;
|
|
1041
1042
|
try {
|
|
1042
1043
|
const i = t.subscribe(this._notifyCallback);
|
|
1043
|
-
e = new
|
|
1044
|
+
e = new X(t, t.version, i);
|
|
1044
1045
|
} catch (i) {
|
|
1045
|
-
const r = m(i, v,
|
|
1046
|
+
const r = m(i, v, _.EFFECT_EXECUTION_FAILED);
|
|
1046
1047
|
if (console.error(r), this._onError) try {
|
|
1047
1048
|
this._onError(r);
|
|
1048
1049
|
} catch {
|
|
1049
1050
|
}
|
|
1050
|
-
e = new
|
|
1051
|
+
e = new X(t, t.version, void 0);
|
|
1051
1052
|
}
|
|
1052
1053
|
this._deps.insertNew(s, e);
|
|
1053
1054
|
}
|
|
@@ -1056,10 +1057,10 @@ var Tt = class extends Q {
|
|
|
1056
1057
|
if ((s & (I.DISPOSED | I.EXECUTING)) !== 0) return;
|
|
1057
1058
|
const e = this._deps;
|
|
1058
1059
|
if (!t && e.size > 0 && !this._isDirty()) return;
|
|
1059
|
-
this._checkInfiniteLoops(), this.flags = s | I.EXECUTING, this._execCleanup(), this._currentEpoch =
|
|
1060
|
+
this._checkInfiniteLoops(), this.flags = s | I.EXECUTING, this._execCleanup(), this._currentEpoch = k(), this._trackCount = 0, e.prepareTracking(), this._hotIndex = -1;
|
|
1060
1061
|
let i = !1;
|
|
1061
1062
|
try {
|
|
1062
|
-
const r =
|
|
1063
|
+
const r = f.run(this, this._fn);
|
|
1063
1064
|
e.truncateFrom(this._trackCount), e.seal(), i = !0, ht(r) ? this._handleAsyncResult(r) : this._cleanup = typeof r == "function" ? r : null;
|
|
1064
1065
|
} catch (r) {
|
|
1065
1066
|
if (!i) try {
|
|
@@ -1082,7 +1083,7 @@ var Tt = class extends Q {
|
|
|
1082
1083
|
if (typeof e == "function") try {
|
|
1083
1084
|
e();
|
|
1084
1085
|
} catch (i) {
|
|
1085
|
-
this._handleExecutionError(i,
|
|
1086
|
+
this._handleExecutionError(i, _.EFFECT_CLEANUP_FAILED);
|
|
1086
1087
|
}
|
|
1087
1088
|
return;
|
|
1088
1089
|
}
|
|
@@ -1090,8 +1091,8 @@ var Tt = class extends Q {
|
|
|
1090
1091
|
}, (e) => s === this._execId && this._handleExecutionError(e));
|
|
1091
1092
|
}
|
|
1092
1093
|
_deepDirtyCheck() {
|
|
1093
|
-
const t =
|
|
1094
|
-
|
|
1094
|
+
const t = f.current;
|
|
1095
|
+
f.current = null;
|
|
1095
1096
|
const s = this._deps;
|
|
1096
1097
|
try {
|
|
1097
1098
|
const e = s.size;
|
|
@@ -1104,7 +1105,7 @@ var Tt = class extends Q {
|
|
|
1104
1105
|
}
|
|
1105
1106
|
return !1;
|
|
1106
1107
|
} finally {
|
|
1107
|
-
|
|
1108
|
+
f.current = t;
|
|
1108
1109
|
}
|
|
1109
1110
|
}
|
|
1110
1111
|
_tryPullComputed(t) {
|
|
@@ -1120,23 +1121,23 @@ var Tt = class extends Q {
|
|
|
1120
1121
|
try {
|
|
1121
1122
|
t();
|
|
1122
1123
|
} catch (s) {
|
|
1123
|
-
this._handleExecutionError(s,
|
|
1124
|
+
this._handleExecutionError(s, _.EFFECT_CLEANUP_FAILED);
|
|
1124
1125
|
}
|
|
1125
1126
|
}
|
|
1126
1127
|
}
|
|
1127
1128
|
_checkInfiniteLoops() {
|
|
1128
|
-
const t =
|
|
1129
|
-
this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
1129
|
+
const t = rt();
|
|
1130
|
+
this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), vt() > C.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
|
|
1130
1131
|
}
|
|
1131
1132
|
_checkFrequencyLimit() {
|
|
1132
1133
|
if (!Number.isFinite(this._maxExecutions)) return;
|
|
1133
1134
|
const t = Date.now();
|
|
1134
|
-
if (t - this._windowStart >=
|
|
1135
|
+
if (t - this._windowStart >= et.EFFECT_FREQUENCY_WINDOW) {
|
|
1135
1136
|
this._windowStart = t, this._windowCount = 1;
|
|
1136
1137
|
return;
|
|
1137
1138
|
}
|
|
1138
1139
|
if (++this._windowCount > this._maxExecutions) {
|
|
1139
|
-
const s = new v(
|
|
1140
|
+
const s = new v(_.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
|
|
1140
1141
|
throw this.dispose(), this._handleExecutionError(s), s;
|
|
1141
1142
|
}
|
|
1142
1143
|
}
|
|
@@ -1147,26 +1148,79 @@ var Tt = class extends Q {
|
|
|
1147
1148
|
return (this.flags & I.EXECUTING) !== 0;
|
|
1148
1149
|
}
|
|
1149
1150
|
_throwInfiniteLoopError(t) {
|
|
1150
|
-
const s = new v(`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${
|
|
1151
|
+
const s = new v(`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${V}`);
|
|
1151
1152
|
throw this.dispose(), console.error(s), s;
|
|
1152
1153
|
}
|
|
1153
|
-
_handleExecutionError(t, s =
|
|
1154
|
+
_handleExecutionError(t, s = _.EFFECT_EXECUTION_FAILED) {
|
|
1154
1155
|
const e = m(t, v, s);
|
|
1155
1156
|
if (console.error(e), this._onError) try {
|
|
1156
1157
|
this._onError(e);
|
|
1157
1158
|
} catch (i) {
|
|
1158
|
-
console.error(m(i, v,
|
|
1159
|
+
console.error(m(i, v, _.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
1159
1160
|
}
|
|
1160
1161
|
}
|
|
1161
1162
|
};
|
|
1162
|
-
function
|
|
1163
|
-
if (typeof t != "function") throw new v(
|
|
1164
|
-
const e = new
|
|
1163
|
+
function Mt(t, s = {}) {
|
|
1164
|
+
if (typeof t != "function") throw new v(_.EFFECT_MUST_BE_FUNCTION);
|
|
1165
|
+
const e = new yt(t, s);
|
|
1165
1166
|
return e.execute(), e;
|
|
1166
1167
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1168
|
+
var At = /* @__PURE__ */ Symbol.for("atom-effect/atom"), bt = /* @__PURE__ */ Symbol.for("atom-effect/writable");
|
|
1169
|
+
function ct(t, s, e, i) {
|
|
1170
|
+
if (e === s.length) return i;
|
|
1171
|
+
const r = s[e], n = t != null && typeof t == "object" ? t : {}, o = n[r], u = ct(o, s, e + 1, i);
|
|
1172
|
+
if (Object.is(o, u)) return t;
|
|
1173
|
+
if (Array.isArray(n)) {
|
|
1174
|
+
const l = n.slice(), h = Number.parseInt(r, 10);
|
|
1175
|
+
return Number.isNaN(h) ? l[r] = u : l[h] = u, l;
|
|
1176
|
+
}
|
|
1177
|
+
return {
|
|
1178
|
+
...n,
|
|
1179
|
+
[r]: u
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
function R(t, s) {
|
|
1183
|
+
let e = t;
|
|
1184
|
+
const i = s.length;
|
|
1185
|
+
for (let r = 0; r < i; r++) {
|
|
1186
|
+
if (e == null) return;
|
|
1187
|
+
e = e[s[r]];
|
|
1188
|
+
}
|
|
1189
|
+
return e;
|
|
1190
|
+
}
|
|
1191
|
+
function _t(t, s) {
|
|
1192
|
+
const e = s.includes(".") ? s.split(".") : [s], i = /* @__PURE__ */ new Set(), r = () => {
|
|
1193
|
+
i.forEach((n) => n()), i.clear();
|
|
1194
|
+
};
|
|
1195
|
+
return {
|
|
1196
|
+
get value() {
|
|
1197
|
+
return R(t.value, e);
|
|
1198
|
+
},
|
|
1199
|
+
set value(n) {
|
|
1200
|
+
const o = t.peek(), u = ct(o, e, 0, n);
|
|
1201
|
+
u !== o && (t.value = u);
|
|
1202
|
+
},
|
|
1203
|
+
peek: () => R(t.peek(), e),
|
|
1204
|
+
subscribe(n) {
|
|
1205
|
+
const o = t.subscribe((u, l) => {
|
|
1206
|
+
const h = R(u, e), c = R(l, e);
|
|
1207
|
+
Object.is(h, c) || n(h, c);
|
|
1208
|
+
});
|
|
1209
|
+
return i.add(o), () => {
|
|
1210
|
+
o(), i.delete(o);
|
|
1211
|
+
};
|
|
1212
|
+
},
|
|
1213
|
+
subscriberCount: () => i.size,
|
|
1214
|
+
dispose: r,
|
|
1215
|
+
[Symbol.dispose]: r,
|
|
1216
|
+
[At]: !0,
|
|
1217
|
+
[bt]: !0
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
var xt = (t, s) => _t(t, s), Bt = (t) => (s) => _t(t, s);
|
|
1221
|
+
function Ht(t) {
|
|
1222
|
+
if (typeof t != "function") throw new TypeError(_.BATCH_CALLBACK_MUST_BE_FUNCTION);
|
|
1223
|
+
const s = w;
|
|
1170
1224
|
s.startBatch();
|
|
1171
1225
|
try {
|
|
1172
1226
|
return t();
|
|
@@ -1178,20 +1232,25 @@ export {
|
|
|
1178
1232
|
A as AsyncState,
|
|
1179
1233
|
N as AtomError,
|
|
1180
1234
|
S as ComputedError,
|
|
1181
|
-
|
|
1182
|
-
|
|
1235
|
+
et as DEBUG_CONFIG,
|
|
1236
|
+
Q as DEBUG_RUNTIME,
|
|
1183
1237
|
v as EffectError,
|
|
1184
1238
|
C as SCHEDULER_CONFIG,
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1239
|
+
P as SchedulerError,
|
|
1240
|
+
Ft as atom,
|
|
1241
|
+
_t as atomLens,
|
|
1242
|
+
Ht as batch,
|
|
1243
|
+
xt as composeLens,
|
|
1244
|
+
Pt as computed,
|
|
1245
|
+
Mt as effect,
|
|
1246
|
+
R as getPathValue,
|
|
1247
|
+
wt as isAtom,
|
|
1248
|
+
Ut as isComputed,
|
|
1249
|
+
Lt as isEffect,
|
|
1250
|
+
Bt as lensFor,
|
|
1251
|
+
w as scheduler,
|
|
1252
|
+
ct as setDeepValue,
|
|
1253
|
+
Rt as untracked
|
|
1195
1254
|
};
|
|
1196
1255
|
|
|
1197
1256
|
//# sourceMappingURL=index.mjs.map
|