@but212/atom-effect-jquery 0.28.0 → 0.29.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/README.md +1 -1
- package/dist/atom-effect-jquery.min.js +2 -2
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.mjs +747 -753
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -33,48 +33,28 @@ var t = {
|
|
|
33
33
|
}, o = {
|
|
34
34
|
WARN_INFINITE_LOOP: !0,
|
|
35
35
|
EFFECT_FREQUENCY_WINDOW: 1e3
|
|
36
|
-
}, s = {
|
|
37
|
-
MAX_ASYNC_RETRIES: 3,
|
|
38
|
-
MAX_PROMISE_ID: 2 ** 53 - 1 - 1
|
|
39
|
-
}, c = {
|
|
36
|
+
}, s = { MAX_PROMISE_ID: 2 ** 53 - 1 - 1 }, c = {
|
|
40
37
|
UNINITIALIZED: -1,
|
|
41
38
|
MIN: 1
|
|
42
|
-
}, l = 1073741823
|
|
39
|
+
}, l = 1073741823;
|
|
43
40
|
typeof process < "u" && process.env;
|
|
44
|
-
var
|
|
45
|
-
constructor(e, t, n = void 0) {
|
|
46
|
-
this.node = e, this.version = t, this.unsub = n;
|
|
47
|
-
}
|
|
48
|
-
}, p = class {
|
|
49
|
-
constructor(e, t) {
|
|
50
|
-
this.fn = e, this.sub = t;
|
|
51
|
-
}
|
|
52
|
-
notify(e, t) {
|
|
53
|
-
let n = this.fn;
|
|
54
|
-
if (n !== void 0) {
|
|
55
|
-
n(e, t);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
let r = this.sub;
|
|
59
|
-
r !== void 0 && r.execute();
|
|
60
|
-
}
|
|
61
|
-
}, m = class extends Error {
|
|
41
|
+
var u = Object.freeze([]), d = class extends Error {
|
|
62
42
|
constructor(e, t = null, n = !0) {
|
|
63
43
|
super(e), this.cause = t, this.recoverable = n, this.name = "AtomError";
|
|
64
44
|
}
|
|
65
|
-
},
|
|
45
|
+
}, f = class extends d {
|
|
66
46
|
constructor(e, t = null) {
|
|
67
47
|
super(e, t, !0), this.name = "ComputedError";
|
|
68
48
|
}
|
|
69
|
-
},
|
|
49
|
+
}, p = class extends d {
|
|
70
50
|
constructor(e, t = null) {
|
|
71
51
|
super(e, t, !1), this.name = "EffectError";
|
|
72
52
|
}
|
|
73
|
-
},
|
|
53
|
+
}, m = class extends d {
|
|
74
54
|
constructor(e, t = null) {
|
|
75
55
|
super(e, t, !1), this.name = "SchedulerError";
|
|
76
56
|
}
|
|
77
|
-
},
|
|
57
|
+
}, h = {
|
|
78
58
|
COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
|
|
79
59
|
COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
|
|
80
60
|
COMPUTED_COMPUTATION_FAILED: "Computation execution failed",
|
|
@@ -93,7 +73,23 @@ var d = Object.freeze([]), f = class {
|
|
|
93
73
|
SCHEDULER_CALLBACK_MUST_BE_FUNCTION: "Scheduler callback must be a function",
|
|
94
74
|
SCHEDULER_END_BATCH_WITHOUT_START: "endBatch() called without matching startBatch(). Ignoring.",
|
|
95
75
|
BATCH_CALLBACK_MUST_BE_FUNCTION: "Batch callback must be a function"
|
|
96
|
-
}
|
|
76
|
+
};
|
|
77
|
+
function g(e, t, n) {
|
|
78
|
+
return e instanceof d ? e : e instanceof Error ? new t(`${e.name || e.constructor.name || "Error"} (${n}): ${e.message}`, e) : new t(`Unexpected error (${n}): ${String(e)}`);
|
|
79
|
+
}
|
|
80
|
+
var ee = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), _ = /* @__PURE__ */ Symbol("AtomEffect.Type"), v = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), y = new class {
|
|
81
|
+
constructor() {
|
|
82
|
+
this.enabled = !1, this.warnInfiniteLoop = o.WARN_INFINITE_LOOP;
|
|
83
|
+
}
|
|
84
|
+
warn(e, t) {}
|
|
85
|
+
attachDebugInfo(e, t, n) {}
|
|
86
|
+
getDebugName(e) {
|
|
87
|
+
if (e != null) return e[ee];
|
|
88
|
+
}
|
|
89
|
+
getDebugType(e) {
|
|
90
|
+
if (e != null) return e[_];
|
|
91
|
+
}
|
|
92
|
+
}(), b = 1, x = () => b++ | 0, S = class {
|
|
97
93
|
constructor() {
|
|
98
94
|
this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow = null, this._freeIndices = null;
|
|
99
95
|
}
|
|
@@ -269,25 +265,179 @@ var d = Object.freeze([]), f = class {
|
|
|
269
265
|
dispose() {
|
|
270
266
|
this.clear();
|
|
271
267
|
}
|
|
272
|
-
},
|
|
268
|
+
}, C = class extends S {
|
|
269
|
+
constructor(...e) {
|
|
270
|
+
super(...e), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1;
|
|
271
|
+
}
|
|
272
|
+
prepareTracking() {
|
|
273
|
+
this.hasComputeds = !1;
|
|
274
|
+
}
|
|
275
|
+
_onItemRemoved(e) {
|
|
276
|
+
let t = e.unsub;
|
|
277
|
+
t && t();
|
|
278
|
+
}
|
|
279
|
+
claimExisting(e, t) {
|
|
280
|
+
let n = this._count;
|
|
281
|
+
if (t >= n) return !1;
|
|
282
|
+
let r = n - t;
|
|
283
|
+
if (this._map !== null || r > this._SCAN_THRESHOLD) return this._claimViaMap(e, t);
|
|
284
|
+
if (t < 4) switch (t) {
|
|
285
|
+
case 0: {
|
|
286
|
+
let t = this._s0;
|
|
287
|
+
if (t && t.node === e && t.unsub) return t.version = e.version, !0;
|
|
288
|
+
}
|
|
289
|
+
case 1: if (n > 1) {
|
|
290
|
+
let n = this._s1;
|
|
291
|
+
if (n && n.node === e && n.unsub) return n.version = e.version, t !== 1 && (this._s1 = this._s0, this._s0 = n), !0;
|
|
292
|
+
}
|
|
293
|
+
case 2: if (n > 2) {
|
|
294
|
+
let n = this._s2;
|
|
295
|
+
if (n && n.node === e && n.unsub) {
|
|
296
|
+
if (n.version = e.version, t !== 2) {
|
|
297
|
+
let e = t === 0 ? this._s0 : this._s1;
|
|
298
|
+
t === 0 ? this._s0 = n : this._s1 = n, this._s2 = e;
|
|
299
|
+
}
|
|
300
|
+
return !0;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
case 3: if (n > 3) {
|
|
304
|
+
let n = this._s3;
|
|
305
|
+
if (n && n.node === e && n.unsub) {
|
|
306
|
+
if (n.version = e.version, t !== 3) {
|
|
307
|
+
let e;
|
|
308
|
+
t === 0 ? (e = this._s0, this._s0 = n) : t === 1 ? (e = this._s1, this._s1 = n) : (e = this._s2, this._s2 = n), this._s3 = e;
|
|
309
|
+
}
|
|
310
|
+
return !0;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
let i = this._overflow;
|
|
315
|
+
if (i) {
|
|
316
|
+
let n = e.version, r = t > 4 ? t : 4, a = i.length;
|
|
317
|
+
for (let o = r - 4; o < a; o++) {
|
|
318
|
+
let r = i[o];
|
|
319
|
+
if (r && r.node === e && r.unsub) return r.version = n, this._swapGeneral(o + 4, t, r), !0;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return !1;
|
|
323
|
+
}
|
|
324
|
+
_claimViaMap(e, t) {
|
|
325
|
+
let n = this._map;
|
|
326
|
+
if (n === null) {
|
|
327
|
+
n = this._map = /* @__PURE__ */ new Map();
|
|
328
|
+
let e = this._count;
|
|
329
|
+
if (t < 4) {
|
|
330
|
+
let e = this._s0;
|
|
331
|
+
t <= 0 && e?.unsub && n.set(e.node, 0);
|
|
332
|
+
let r = this._s1;
|
|
333
|
+
t <= 1 && r?.unsub && n.set(r.node, 1);
|
|
334
|
+
let i = this._s2;
|
|
335
|
+
t <= 2 && i?.unsub && n.set(i.node, 2);
|
|
336
|
+
let a = this._s3;
|
|
337
|
+
t <= 3 && a?.unsub && n.set(a.node, 3);
|
|
338
|
+
}
|
|
339
|
+
let r = this._overflow;
|
|
340
|
+
if (r && e > 4) {
|
|
341
|
+
let e = t > 4 ? t : 4, i = r.length;
|
|
342
|
+
for (let t = e - 4; t < i; t++) {
|
|
343
|
+
let e = r[t];
|
|
344
|
+
e?.unsub && n.set(e.node, t + 4);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
let r = n.get(e);
|
|
349
|
+
if (r === void 0 || r < t) return !1;
|
|
350
|
+
let i = this.getAt(r);
|
|
351
|
+
if (i == null || !i.unsub) return !1;
|
|
352
|
+
if (i.version = e.version, r !== t) {
|
|
353
|
+
let a;
|
|
354
|
+
a = t === 0 ? this._s0 : t === 1 ? this._s1 : t === 2 ? this._s2 : t === 3 ? this._s3 : this._overflow[t - 4] ?? null, this.setAt(t, i), this.setAt(r, a), a?.unsub && n.set(a.node, r), n.set(e, t);
|
|
355
|
+
}
|
|
356
|
+
return !0;
|
|
357
|
+
}
|
|
358
|
+
_swapGeneral(e, t, n) {
|
|
359
|
+
if (e === t) return;
|
|
360
|
+
let r;
|
|
361
|
+
if (r = t === 0 ? this._s0 : t === 1 ? this._s1 : t === 2 ? this._s2 : t === 3 ? this._s3 : this._overflow[t - 4] ?? null, this.setAt(t, n), e === 0) this._s0 = r;
|
|
362
|
+
else if (e === 1) this._s1 = r;
|
|
363
|
+
else if (e === 2) this._s2 = r;
|
|
364
|
+
else if (e === 3) this._s3 = r;
|
|
365
|
+
else {
|
|
366
|
+
let t = this._overflow;
|
|
367
|
+
t[e - 4] = r;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
insertNew(e, t) {
|
|
371
|
+
let n = this._count;
|
|
372
|
+
if (e < n) {
|
|
373
|
+
let t;
|
|
374
|
+
t = e === 0 ? this._s0 : e === 1 ? this._s1 : e === 2 ? this._s2 : e === 3 ? this._s3 : this._overflow[e - 4] ?? null, t != null && (this._addToOverflow(t), this._map !== null && t.unsub && this._map.set(t.node, this._count - 1));
|
|
375
|
+
}
|
|
376
|
+
if (e === 0) this._s0 = t;
|
|
377
|
+
else if (e === 1) this._s1 = t;
|
|
378
|
+
else if (e === 2) this._s2 = t;
|
|
379
|
+
else if (e === 3) this._s3 = t;
|
|
380
|
+
else {
|
|
381
|
+
let n = this._overflow;
|
|
382
|
+
n || (n = [], this._overflow = n), n[e - 4] = t;
|
|
383
|
+
}
|
|
384
|
+
e >= n && (this._count = e + 1);
|
|
385
|
+
}
|
|
386
|
+
truncateFrom(e) {
|
|
387
|
+
e >= this._count || (super.truncateFrom(e), this._map !== null && (this._map.clear(), this._map = null));
|
|
388
|
+
}
|
|
389
|
+
disposeAll() {
|
|
390
|
+
this._count > 0 && this.truncateFrom(0), this.hasComputeds = !1;
|
|
391
|
+
}
|
|
392
|
+
remove(e) {
|
|
393
|
+
throw Error("remove() is strictly prohibited in DepSlotBuffer to preserve sequential cache paths.");
|
|
394
|
+
}
|
|
395
|
+
compact() {}
|
|
396
|
+
}, w = class {
|
|
397
|
+
constructor(e, t, n = void 0) {
|
|
398
|
+
this.node = e, this.version = t, this.unsub = n;
|
|
399
|
+
}
|
|
400
|
+
}, te = class {
|
|
401
|
+
constructor(e, t) {
|
|
402
|
+
this.fn = e, this.sub = t;
|
|
403
|
+
}
|
|
404
|
+
notify(e, t) {
|
|
405
|
+
let n = this.fn;
|
|
406
|
+
if (n !== void 0) {
|
|
407
|
+
n(e, t);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
let r = this.sub;
|
|
411
|
+
r !== void 0 && r.execute();
|
|
412
|
+
}
|
|
413
|
+
}, T = new class {
|
|
273
414
|
constructor() {
|
|
274
|
-
this.
|
|
415
|
+
this.current = null;
|
|
275
416
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
417
|
+
run(e, t) {
|
|
418
|
+
if (this.current === e) return t();
|
|
419
|
+
let n = this.current;
|
|
420
|
+
this.current = e;
|
|
421
|
+
try {
|
|
422
|
+
return t();
|
|
423
|
+
} finally {
|
|
424
|
+
this.current = n;
|
|
425
|
+
}
|
|
280
426
|
}
|
|
281
|
-
|
|
282
|
-
|
|
427
|
+
}();
|
|
428
|
+
function E(e) {
|
|
429
|
+
let t = T, n = t.current;
|
|
430
|
+
if (n === null) return e();
|
|
431
|
+
t.current = null;
|
|
432
|
+
try {
|
|
433
|
+
return e();
|
|
434
|
+
} finally {
|
|
435
|
+
t.current = n;
|
|
283
436
|
}
|
|
284
|
-
}(), w = 1, T = () => w++ | 0;
|
|
285
|
-
function E(e, t, n) {
|
|
286
|
-
return e instanceof m ? e : e instanceof Error ? new t(`${e.name || e.constructor.name || "Error"} (${n}): ${e.message}`, e) : new t(`Unexpected error (${n}): ${String(e)}`);
|
|
287
437
|
}
|
|
288
|
-
var
|
|
438
|
+
var ne = class {
|
|
289
439
|
constructor() {
|
|
290
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch = c.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id =
|
|
440
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = c.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = x() & l;
|
|
291
441
|
}
|
|
292
442
|
get isDisposed() {
|
|
293
443
|
return (this.flags & r.DISPOSED) !== 0;
|
|
@@ -300,9 +450,9 @@ var ee = class {
|
|
|
300
450
|
}
|
|
301
451
|
subscribe(e) {
|
|
302
452
|
let t = typeof e == "function";
|
|
303
|
-
if (!t && (!e || typeof e.execute != "function")) throw
|
|
453
|
+
if (!t && (!e || typeof e.execute != "function")) throw g(/* @__PURE__ */ TypeError("Invalid subscriber"), d, h.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
|
|
304
454
|
let n = this._slots;
|
|
305
|
-
n || (n = new
|
|
455
|
+
n || (n = new S(), this._slots = n);
|
|
306
456
|
let r = !1;
|
|
307
457
|
if (n._s0 != null && (t ? n._s0.fn === e : n._s0.sub === e)) r = !0;
|
|
308
458
|
else if (n._s1 != null && (t ? n._s1.fn === e : n._s1.sub === e)) r = !0;
|
|
@@ -319,7 +469,7 @@ var ee = class {
|
|
|
319
469
|
}
|
|
320
470
|
}
|
|
321
471
|
if (r) return () => {};
|
|
322
|
-
let i = new
|
|
472
|
+
let i = new te(t ? e : void 0, t ? void 0 : e);
|
|
323
473
|
return n.add(i), () => this._unsubscribe(i);
|
|
324
474
|
}
|
|
325
475
|
_unsubscribe(e) {
|
|
@@ -371,7 +521,7 @@ var ee = class {
|
|
|
371
521
|
}
|
|
372
522
|
}
|
|
373
523
|
_logNotifyError(e) {
|
|
374
|
-
console.error(
|
|
524
|
+
console.error(g(e, d, h.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
|
|
375
525
|
}
|
|
376
526
|
_isDirty() {
|
|
377
527
|
let e = this._deps;
|
|
@@ -381,30 +531,30 @@ var ee = class {
|
|
|
381
531
|
let n = e.getAt(t);
|
|
382
532
|
if (n != null && n.node.version !== n.version) return !0;
|
|
383
533
|
}
|
|
384
|
-
return
|
|
534
|
+
return this._deepDirtyCheck();
|
|
385
535
|
}
|
|
386
|
-
},
|
|
387
|
-
function
|
|
388
|
-
let e =
|
|
389
|
-
return
|
|
536
|
+
}, re = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ie = /* @__PURE__ */ Symbol.for("atom-effect/computed"), ae = /* @__PURE__ */ Symbol.for("atom-effect/effect"), oe = /* @__PURE__ */ Symbol.for("atom-effect/writable"), se = 0;
|
|
537
|
+
function ce() {
|
|
538
|
+
let e = se + 1 & l;
|
|
539
|
+
return se = e === 0 ? 1 : e, se;
|
|
390
540
|
}
|
|
391
|
-
function
|
|
541
|
+
function le(e) {
|
|
392
542
|
let t = e + 1 & l;
|
|
393
543
|
return t === 0 ? 1 : t;
|
|
394
544
|
}
|
|
395
|
-
var
|
|
396
|
-
function
|
|
397
|
-
return
|
|
545
|
+
var ue = 0, de = !1, fe = 0;
|
|
546
|
+
function pe() {
|
|
547
|
+
return fe;
|
|
398
548
|
}
|
|
399
|
-
function
|
|
400
|
-
return
|
|
549
|
+
function me() {
|
|
550
|
+
return de ? !1 : (de = !0, fe = ce(), ue = 0, !0);
|
|
401
551
|
}
|
|
402
|
-
function
|
|
403
|
-
|
|
552
|
+
function he() {
|
|
553
|
+
de = !1;
|
|
404
554
|
}
|
|
405
|
-
function
|
|
406
|
-
if (!
|
|
407
|
-
let e = ++
|
|
555
|
+
function ge() {
|
|
556
|
+
if (!de) return 0;
|
|
557
|
+
let e = ++ue;
|
|
408
558
|
if (e <= a.MAX_EXECUTIONS_PER_FLUSH) return e;
|
|
409
559
|
throw Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${a.MAX_EXECUTIONS_PER_FLUSH}`);
|
|
410
560
|
}
|
|
@@ -434,19 +584,19 @@ var D = new class {
|
|
|
434
584
|
_runLoop() {
|
|
435
585
|
try {
|
|
436
586
|
if (this._size === 0) return;
|
|
437
|
-
let e =
|
|
438
|
-
this._drainQueue(), e &&
|
|
587
|
+
let e = me();
|
|
588
|
+
this._drainQueue(), e && he();
|
|
439
589
|
} finally {
|
|
440
590
|
this._isProcessing = !1, this._size > 0 && this._batchDepth === 0 && this._flush();
|
|
441
591
|
}
|
|
442
592
|
}
|
|
443
593
|
_flushSync() {
|
|
444
594
|
this._isFlushingSync = !0;
|
|
445
|
-
let e =
|
|
595
|
+
let e = me();
|
|
446
596
|
try {
|
|
447
597
|
this._mergeBatchQueue(), this._drainQueue();
|
|
448
598
|
} finally {
|
|
449
|
-
this._isFlushingSync = !1, e &&
|
|
599
|
+
this._isFlushingSync = !1, e && he();
|
|
450
600
|
}
|
|
451
601
|
}
|
|
452
602
|
_mergeBatchQueue() {
|
|
@@ -477,14 +627,14 @@ var D = new class {
|
|
|
477
627
|
try {
|
|
478
628
|
typeof n == "function" ? n() : n.execute();
|
|
479
629
|
} catch (e) {
|
|
480
|
-
console.error(new
|
|
630
|
+
console.error(new m("Error occurred during scheduler execution", e));
|
|
481
631
|
}
|
|
482
632
|
}
|
|
483
633
|
t.length = 0;
|
|
484
634
|
}
|
|
485
635
|
_handleFlushOverflow() {
|
|
486
636
|
let e = this._size + this._batchQueueSize, t = this._maxFlushIterations;
|
|
487
|
-
console.error(new
|
|
637
|
+
console.error(new m(h.SCHEDULER_FLUSH_OVERFLOW(t, e))), this._size = 0;
|
|
488
638
|
let n = this._bufferIndex;
|
|
489
639
|
this._queueBuffer[n].length = 0, this._batchQueueSize = 0;
|
|
490
640
|
let r = this.onOverflow;
|
|
@@ -499,37 +649,23 @@ var D = new class {
|
|
|
499
649
|
this._batchDepth !== 0 && --this._batchDepth === 0 && this._flushSync();
|
|
500
650
|
}
|
|
501
651
|
setMaxFlushIterations(e) {
|
|
502
|
-
if (e < a.MIN_FLUSH_ITERATIONS) throw new
|
|
652
|
+
if (e < a.MIN_FLUSH_ITERATIONS) throw new m(`Max flush iterations must be at least ${a.MIN_FLUSH_ITERATIONS}`);
|
|
503
653
|
this._maxFlushIterations = e;
|
|
504
654
|
}
|
|
505
|
-
}(), de = /* @__PURE__ */ Symbol.for("atom-effect/atom"), fe = /* @__PURE__ */ Symbol.for("atom-effect/computed"), pe = /* @__PURE__ */ Symbol.for("atom-effect/effect"), me = /* @__PURE__ */ Symbol.for("atom-effect/writable"), O = new class {
|
|
506
|
-
constructor() {
|
|
507
|
-
this.current = null;
|
|
508
|
-
}
|
|
509
|
-
run(e, t) {
|
|
510
|
-
if (this.current === e) return t();
|
|
511
|
-
let n = this.current;
|
|
512
|
-
this.current = e;
|
|
513
|
-
try {
|
|
514
|
-
return t();
|
|
515
|
-
} finally {
|
|
516
|
-
this.current = n;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
655
|
}();
|
|
520
|
-
function
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
t.
|
|
656
|
+
function _e(e) {
|
|
657
|
+
if (typeof e != "function") throw TypeError(h.BATCH_CALLBACK_MUST_BE_FUNCTION);
|
|
658
|
+
let t = D;
|
|
659
|
+
t.startBatch();
|
|
524
660
|
try {
|
|
525
661
|
return e();
|
|
526
662
|
} finally {
|
|
527
|
-
t.
|
|
663
|
+
t.endBatch();
|
|
528
664
|
}
|
|
529
665
|
}
|
|
530
|
-
var
|
|
666
|
+
var ve = class extends ne {
|
|
531
667
|
constructor(e, t) {
|
|
532
|
-
super(), this[
|
|
668
|
+
super(), this[re] = !0, this[oe] = !0, this._value = e, t && (this.flags |= i.SYNC), y.attachDebugInfo(this, "atom", this.id);
|
|
533
669
|
}
|
|
534
670
|
get isNotificationScheduled() {
|
|
535
671
|
return (this.flags & i.NOTIFICATION_SCHEDULED) !== 0;
|
|
@@ -538,12 +674,12 @@ var he = class extends ee {
|
|
|
538
674
|
return (this.flags & i.SYNC) !== 0;
|
|
539
675
|
}
|
|
540
676
|
get value() {
|
|
541
|
-
return
|
|
677
|
+
return T.current?.addDependency(this), this._value;
|
|
542
678
|
}
|
|
543
679
|
set value(e) {
|
|
544
680
|
let t = this._value;
|
|
545
681
|
if (Object.is(t, e)) return;
|
|
546
|
-
this._value = e, this.version =
|
|
682
|
+
this._value = e, this.version = le(this.version);
|
|
547
683
|
let n = this.flags;
|
|
548
684
|
if ((n & i.NOTIFICATION_SCHEDULED) !== 0) return;
|
|
549
685
|
let r = this._slots;
|
|
@@ -572,227 +708,60 @@ var he = class extends ee {
|
|
|
572
708
|
this.dispose();
|
|
573
709
|
}
|
|
574
710
|
};
|
|
575
|
-
function
|
|
576
|
-
return new
|
|
711
|
+
function O(e, t = {}) {
|
|
712
|
+
return new ve(e, t.sync ?? !1);
|
|
577
713
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
super(...e), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1, this._depsHash = 0;
|
|
581
|
-
}
|
|
582
|
-
prepareTracking() {
|
|
583
|
-
this.hasComputeds = !1;
|
|
584
|
-
}
|
|
585
|
-
_onItemRemoved(e) {
|
|
586
|
-
let t = e.unsub;
|
|
587
|
-
t && t();
|
|
588
|
-
}
|
|
589
|
-
claimExisting(e, t) {
|
|
590
|
-
let n = this._count;
|
|
591
|
-
if (t >= n) return !1;
|
|
592
|
-
let r = n - t;
|
|
593
|
-
if (this._map !== null || r > this._SCAN_THRESHOLD) return this._claimViaMap(e, t);
|
|
594
|
-
if (t < 4) switch (t) {
|
|
595
|
-
case 0: {
|
|
596
|
-
let t = this._s0;
|
|
597
|
-
if (t && t.node === e && t.unsub) return t.version = e.version, !0;
|
|
598
|
-
}
|
|
599
|
-
case 1: if (n > 1) {
|
|
600
|
-
let n = this._s1;
|
|
601
|
-
if (n && n.node === e && n.unsub) return n.version = e.version, t !== 1 && (this._s1 = this._s0, this._s0 = n), !0;
|
|
602
|
-
}
|
|
603
|
-
case 2: if (n > 2) {
|
|
604
|
-
let n = this._s2;
|
|
605
|
-
if (n && n.node === e && n.unsub) {
|
|
606
|
-
if (n.version = e.version, t !== 2) {
|
|
607
|
-
let e = t === 0 ? this._s0 : this._s1;
|
|
608
|
-
t === 0 ? this._s0 = n : this._s1 = n, this._s2 = e;
|
|
609
|
-
}
|
|
610
|
-
return !0;
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
case 3: if (n > 3) {
|
|
614
|
-
let n = this._s3;
|
|
615
|
-
if (n && n.node === e && n.unsub) {
|
|
616
|
-
if (n.version = e.version, t !== 3) {
|
|
617
|
-
let e;
|
|
618
|
-
t === 0 ? (e = this._s0, this._s0 = n) : t === 1 ? (e = this._s1, this._s1 = n) : (e = this._s2, this._s2 = n), this._s3 = e;
|
|
619
|
-
}
|
|
620
|
-
return !0;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
let i = this._overflow;
|
|
625
|
-
if (i) {
|
|
626
|
-
let n = e.version, r = t > 4 ? t : 4, a = i.length;
|
|
627
|
-
for (let o = r - 4; o < a; o++) {
|
|
628
|
-
let r = i[o];
|
|
629
|
-
if (r && r.node === e && r.unsub) return r.version = n, this._swapGeneral(o + 4, t, r), !0;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
return !1;
|
|
633
|
-
}
|
|
634
|
-
_claimViaMap(e, t) {
|
|
635
|
-
let n = this._map;
|
|
636
|
-
if (n === null) {
|
|
637
|
-
n = this._map = /* @__PURE__ */ new Map();
|
|
638
|
-
let e = this._count;
|
|
639
|
-
if (t < 4) {
|
|
640
|
-
let e = this._s0;
|
|
641
|
-
t <= 0 && e?.unsub && n.set(e.node, 0);
|
|
642
|
-
let r = this._s1;
|
|
643
|
-
t <= 1 && r?.unsub && n.set(r.node, 1);
|
|
644
|
-
let i = this._s2;
|
|
645
|
-
t <= 2 && i?.unsub && n.set(i.node, 2);
|
|
646
|
-
let a = this._s3;
|
|
647
|
-
t <= 3 && a?.unsub && n.set(a.node, 3);
|
|
648
|
-
}
|
|
649
|
-
let r = this._overflow;
|
|
650
|
-
if (r && e > 4) {
|
|
651
|
-
let e = t > 4 ? t : 4, i = r.length;
|
|
652
|
-
for (let t = e - 4; t < i; t++) {
|
|
653
|
-
let e = r[t];
|
|
654
|
-
e?.unsub && n.set(e.node, t + 4);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
let r = n.get(e);
|
|
659
|
-
if (r === void 0 || r < t) return !1;
|
|
660
|
-
let i = this.getAt(r);
|
|
661
|
-
if (i == null || !i.unsub) return !1;
|
|
662
|
-
if (i.version = e.version, r !== t) {
|
|
663
|
-
let a;
|
|
664
|
-
a = t === 0 ? this._s0 : t === 1 ? this._s1 : t === 2 ? this._s2 : t === 3 ? this._s3 : this._overflow[t - 4] ?? null, this.setAt(t, i), this.setAt(r, a), a?.unsub && n.set(a.node, r), n.set(e, t);
|
|
665
|
-
}
|
|
666
|
-
return !0;
|
|
667
|
-
}
|
|
668
|
-
_swapGeneral(e, t, n) {
|
|
669
|
-
if (e === t) return;
|
|
670
|
-
let r;
|
|
671
|
-
if (r = t === 0 ? this._s0 : t === 1 ? this._s1 : t === 2 ? this._s2 : t === 3 ? this._s3 : this._overflow[t - 4] ?? null, this.setAt(t, n), e === 0) this._s0 = r;
|
|
672
|
-
else if (e === 1) this._s1 = r;
|
|
673
|
-
else if (e === 2) this._s2 = r;
|
|
674
|
-
else if (e === 3) this._s3 = r;
|
|
675
|
-
else {
|
|
676
|
-
let t = this._overflow;
|
|
677
|
-
t[e - 4] = r;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
insertNew(e, t) {
|
|
681
|
-
let n = this._count;
|
|
682
|
-
if (e < n) {
|
|
683
|
-
let t;
|
|
684
|
-
t = e === 0 ? this._s0 : e === 1 ? this._s1 : e === 2 ? this._s2 : e === 3 ? this._s3 : this._overflow[e - 4] ?? null, t != null && (this._addToOverflow(t), this._map !== null && t.unsub && this._map.set(t.node, this._count - 1));
|
|
685
|
-
}
|
|
686
|
-
if (e === 0) this._s0 = t;
|
|
687
|
-
else if (e === 1) this._s1 = t;
|
|
688
|
-
else if (e === 2) this._s2 = t;
|
|
689
|
-
else if (e === 3) this._s3 = t;
|
|
690
|
-
else {
|
|
691
|
-
let n = this._overflow;
|
|
692
|
-
n || (n = [], this._overflow = n), n[e - 4] = t;
|
|
693
|
-
}
|
|
694
|
-
e >= n && (this._count = e + 1);
|
|
695
|
-
}
|
|
696
|
-
truncateFrom(e) {
|
|
697
|
-
e >= this._count || (super.truncateFrom(e), this._map !== null && (this._map.clear(), this._map = null));
|
|
698
|
-
}
|
|
699
|
-
seal() {
|
|
700
|
-
this._depsHash = this._calculateHash(!1);
|
|
701
|
-
}
|
|
702
|
-
isDirtyFast() {
|
|
703
|
-
return this._calculateHash(!0) !== this._depsHash;
|
|
704
|
-
}
|
|
705
|
-
_calculateHash(e) {
|
|
706
|
-
let t = this._count;
|
|
707
|
-
if (t === 0) return 0;
|
|
708
|
-
let n = u.VERSION_BITS, r = 0, i = this._s0;
|
|
709
|
-
if (i != null) {
|
|
710
|
-
let a = i.node, o = e ? a.version : i.version;
|
|
711
|
-
r = r + (o << n) + a.id | 0;
|
|
712
|
-
let s = this._s1;
|
|
713
|
-
if (t > 1 && s != null) {
|
|
714
|
-
let i = s.node, a = e ? i.version : s.version;
|
|
715
|
-
r = r + (a << n) + i.id | 0;
|
|
716
|
-
let o = this._s2;
|
|
717
|
-
if (t > 2 && o != null) {
|
|
718
|
-
let i = o.node, a = e ? i.version : o.version;
|
|
719
|
-
r = r + (a << n) + i.id | 0;
|
|
720
|
-
let s = this._s3;
|
|
721
|
-
if (t > 3 && s != null) {
|
|
722
|
-
let t = s.node, i = e ? t.version : s.version;
|
|
723
|
-
r = r + (i << n) + t.id | 0;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
if (t > 4) {
|
|
729
|
-
let t = this._overflow;
|
|
730
|
-
for (let i = 0, a = t.length; i < a; i++) {
|
|
731
|
-
let a = t[i], o = a.node, s = e ? o.version : a.version;
|
|
732
|
-
r = r + (s << n) + o.id | 0;
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
return r;
|
|
736
|
-
}
|
|
737
|
-
disposeAll() {
|
|
738
|
-
this._count > 0 && this.truncateFrom(0), this.hasComputeds = !1;
|
|
739
|
-
}
|
|
740
|
-
remove(e) {
|
|
741
|
-
throw Error("remove() is strictly prohibited in DepSlotBuffer to preserve sequential cache paths.");
|
|
742
|
-
}
|
|
743
|
-
compact() {}
|
|
744
|
-
};
|
|
745
|
-
function _e(e) {
|
|
746
|
-
return typeof e == "object" && !!e && de in e;
|
|
714
|
+
function ye(e) {
|
|
715
|
+
return typeof e == "object" && !!e && re in e;
|
|
747
716
|
}
|
|
748
|
-
function
|
|
749
|
-
return typeof e == "object" && !!e &&
|
|
717
|
+
function be(e) {
|
|
718
|
+
return typeof e == "object" && !!e && ie in e;
|
|
750
719
|
}
|
|
751
|
-
function
|
|
720
|
+
function xe(e) {
|
|
752
721
|
return typeof e == "object" && !!e && typeof e.then == "function";
|
|
753
722
|
}
|
|
754
|
-
var { IDLE:
|
|
723
|
+
var { IDLE: k, DIRTY: A, PENDING: j, RESOLVED: M, REJECTED: N, HAS_ERROR: Se, RECOMPUTING: P, DISPOSED: Ce, IS_COMPUTED: we, FORCE_COMPUTE: Te } = r, Ee = class extends ne {
|
|
755
724
|
constructor(e, t = {}) {
|
|
756
|
-
if (typeof e != "function") throw new h
|
|
757
|
-
if (super(), this[
|
|
725
|
+
if (typeof e != "function") throw new f(h.COMPUTED_MUST_BE_FUNCTION);
|
|
726
|
+
if (super(), this[re] = !0, this[ie] = !0, this._error = null, this._promiseId = 0, this._deps = new C(), this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = we | A | k, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : v, this._onError = t.onError ?? null, y.attachDebugInfo(this, "computed", this.id), t.lazy === !1) try {
|
|
758
727
|
this._recompute();
|
|
759
728
|
} catch {}
|
|
760
729
|
}
|
|
761
730
|
get isDirty() {
|
|
762
|
-
return (this.flags &
|
|
731
|
+
return (this.flags & A) !== 0;
|
|
763
732
|
}
|
|
764
733
|
get isRejected() {
|
|
765
|
-
return (this.flags &
|
|
734
|
+
return (this.flags & N) !== 0;
|
|
766
735
|
}
|
|
767
736
|
get isRecomputing() {
|
|
768
|
-
return (this.flags &
|
|
737
|
+
return (this.flags & P) !== 0;
|
|
769
738
|
}
|
|
770
739
|
get _hasErrorInternal() {
|
|
771
|
-
return (this.flags &
|
|
740
|
+
return (this.flags & Se) !== 0;
|
|
772
741
|
}
|
|
773
742
|
_track() {
|
|
774
|
-
|
|
743
|
+
T.current?.addDependency(this);
|
|
775
744
|
}
|
|
776
745
|
get value() {
|
|
777
|
-
|
|
746
|
+
T.current?.addDependency(this);
|
|
778
747
|
let e = this.flags;
|
|
779
|
-
if ((e & (
|
|
780
|
-
if ((e &
|
|
781
|
-
if ((e &
|
|
748
|
+
if ((e & (M | A | k)) === M) return this._value;
|
|
749
|
+
if ((e & Ce) !== 0) throw new f(h.COMPUTED_DISPOSED);
|
|
750
|
+
if ((e & P) !== 0) {
|
|
782
751
|
let e = this._defaultValue;
|
|
783
|
-
if (e !==
|
|
784
|
-
throw new h
|
|
752
|
+
if (e !== v) return e;
|
|
753
|
+
throw new f(h.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
785
754
|
}
|
|
786
|
-
if ((e & (
|
|
755
|
+
if ((e & (A | k)) !== 0) {
|
|
787
756
|
let t = this._deps;
|
|
788
|
-
if ((e &
|
|
757
|
+
if ((e & k) === 0 && (e & Te) === 0 && t.size > 0 && !this._isDirty() ? e = this.flags &= ~A : (this._recompute(), e = this.flags), (e & M) !== 0) return this._value;
|
|
789
758
|
}
|
|
790
|
-
let t = this._defaultValue, n = t !==
|
|
791
|
-
if ((e &
|
|
759
|
+
let t = this._defaultValue, n = t !== v;
|
|
760
|
+
if ((e & j) !== 0) {
|
|
792
761
|
if (n) return t;
|
|
793
|
-
throw new h
|
|
762
|
+
throw new f(h.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
794
763
|
}
|
|
795
|
-
if ((e &
|
|
764
|
+
if ((e & N) !== 0) {
|
|
796
765
|
if (n) return t;
|
|
797
766
|
throw this._error;
|
|
798
767
|
}
|
|
@@ -802,12 +771,12 @@ var { IDLE: j, DIRTY: M, PENDING: N, RESOLVED: P, REJECTED: F, HAS_ERROR: be, RE
|
|
|
802
771
|
return this._value;
|
|
803
772
|
}
|
|
804
773
|
get state() {
|
|
805
|
-
|
|
774
|
+
T.current?.addDependency(this);
|
|
806
775
|
let e = this.flags;
|
|
807
|
-
return (e &
|
|
776
|
+
return (e & M) === 0 ? (e & j) === 0 ? (e & N) === 0 ? t.IDLE : t.REJECTED : t.PENDING : t.RESOLVED;
|
|
808
777
|
}
|
|
809
778
|
get hasError() {
|
|
810
|
-
if (
|
|
779
|
+
if (T.current?.addDependency(this), (this.flags & (N | Se)) !== 0) return !0;
|
|
811
780
|
let e = this._deps;
|
|
812
781
|
if (!e.hasComputeds) return !1;
|
|
813
782
|
let t = e.size;
|
|
@@ -818,9 +787,9 @@ var { IDLE: j, DIRTY: M, PENDING: N, RESOLVED: P, REJECTED: F, HAS_ERROR: be, RE
|
|
|
818
787
|
return !this.hasError;
|
|
819
788
|
}
|
|
820
789
|
get errors() {
|
|
821
|
-
|
|
790
|
+
T.current?.addDependency(this);
|
|
822
791
|
let e = this._error, t = this._deps;
|
|
823
|
-
if (!t.hasComputeds) return e == null ?
|
|
792
|
+
if (!t.hasComputeds) return e == null ? u : Object.freeze([e]);
|
|
824
793
|
let n = [];
|
|
825
794
|
e != null && n.push(e);
|
|
826
795
|
let r = t.size;
|
|
@@ -828,9 +797,9 @@ var { IDLE: j, DIRTY: M, PENDING: N, RESOLVED: P, REJECTED: F, HAS_ERROR: be, RE
|
|
|
828
797
|
let r = t.getAt(e);
|
|
829
798
|
if (r == null) continue;
|
|
830
799
|
let i = r.node;
|
|
831
|
-
(i.flags &
|
|
800
|
+
(i.flags & we) !== 0 && i.hasError && this._collectErrorsFromDep(i, n);
|
|
832
801
|
}
|
|
833
|
-
return n.length === 0 ?
|
|
802
|
+
return n.length === 0 ? u : Object.freeze(n);
|
|
834
803
|
}
|
|
835
804
|
_collectErrorsFromDep(e, t) {
|
|
836
805
|
let n = e.errors, r = n.length;
|
|
@@ -840,19 +809,19 @@ var { IDLE: j, DIRTY: M, PENDING: N, RESOLVED: P, REJECTED: F, HAS_ERROR: be, RE
|
|
|
840
809
|
}
|
|
841
810
|
}
|
|
842
811
|
get lastError() {
|
|
843
|
-
return
|
|
812
|
+
return T.current?.addDependency(this), this._error;
|
|
844
813
|
}
|
|
845
814
|
get isPending() {
|
|
846
|
-
return
|
|
815
|
+
return T.current?.addDependency(this), (this.flags & j) !== 0;
|
|
847
816
|
}
|
|
848
817
|
get isResolved() {
|
|
849
|
-
return
|
|
818
|
+
return T.current?.addDependency(this), (this.flags & M) !== 0;
|
|
850
819
|
}
|
|
851
820
|
invalidate() {
|
|
852
|
-
this.flags |=
|
|
821
|
+
this.flags |= Te, this._markDirty();
|
|
853
822
|
}
|
|
854
823
|
dispose() {
|
|
855
|
-
(this.flags &
|
|
824
|
+
(this.flags & Ce) === 0 && (this._deps.disposeAll(), this._slots != null && this._slots.clear(), this.flags = Ce | A | k, this._error = null, this._value = void 0, this._hotIndex = -1);
|
|
856
825
|
}
|
|
857
826
|
[Symbol.dispose]() {
|
|
858
827
|
this.dispose();
|
|
@@ -864,94 +833,87 @@ var { IDLE: j, DIRTY: M, PENDING: N, RESOLVED: P, REJECTED: F, HAS_ERROR: be, RE
|
|
|
864
833
|
let n = this._trackCount++, r = this._deps, i = r.getAt(n);
|
|
865
834
|
if (i != null && i.node === e) i.version = e.version;
|
|
866
835
|
else if (!r.claimExisting(e, n)) {
|
|
867
|
-
let t = new
|
|
836
|
+
let t = new w(e, e.version, e.subscribe(this));
|
|
868
837
|
r.insertNew(n, t);
|
|
869
838
|
}
|
|
870
|
-
(e.flags &
|
|
839
|
+
(e.flags & we) !== 0 && (r.hasComputeds = !0);
|
|
871
840
|
}
|
|
872
841
|
_recompute() {
|
|
873
842
|
if (this.isRecomputing) return;
|
|
874
|
-
this.flags = (this.flags |
|
|
843
|
+
this.flags = (this.flags | P) & ~Te, this._trackEpoch = ce(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
|
|
875
844
|
let e = !1;
|
|
876
845
|
try {
|
|
877
|
-
let t =
|
|
878
|
-
this._deps.truncateFrom(this._trackCount),
|
|
846
|
+
let t = T.run(this, this._fn);
|
|
847
|
+
this._deps.truncateFrom(this._trackCount), e = !0, xe(t) ? this._handleAsyncComputation(t) : this._finalizeResolution(t);
|
|
879
848
|
} catch (t) {
|
|
880
849
|
if (!e) try {
|
|
881
850
|
this._deps.truncateFrom(this._trackCount);
|
|
882
851
|
} catch {}
|
|
883
|
-
this._handleError(t,
|
|
852
|
+
this._handleError(t, h.COMPUTED_COMPUTATION_FAILED, !0);
|
|
884
853
|
} finally {
|
|
885
|
-
this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this.flags &= ~
|
|
854
|
+
this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this.flags &= ~P;
|
|
886
855
|
}
|
|
887
856
|
}
|
|
888
857
|
_handleAsyncComputation(e) {
|
|
889
|
-
this.flags = (this.flags |
|
|
858
|
+
this.flags = (this.flags | j) & ~(k | A | M | N), this._notifySubscribers(void 0, void 0), this._promiseId = (this._promiseId + 1) % s.MAX_PROMISE_ID;
|
|
890
859
|
let t = this._promiseId;
|
|
891
860
|
e.then((e) => {
|
|
892
861
|
if (t === this._promiseId) {
|
|
893
|
-
if (this._isDirty())
|
|
894
|
-
let e = se();
|
|
895
|
-
return this._lastDriftEpoch !== e && (this._lastDriftEpoch = e, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(new h(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`), v.COMPUTED_ASYNC_COMPUTATION_FAILED);
|
|
896
|
-
}
|
|
862
|
+
if (this._isDirty()) return this._markDirty();
|
|
897
863
|
this._finalizeResolution(e), this._notifySubscribers(e, void 0);
|
|
898
864
|
}
|
|
899
|
-
}, (e) => t === this._promiseId && this._handleError(e,
|
|
865
|
+
}, (e) => t === this._promiseId && this._handleError(e, h.COMPUTED_ASYNC_COMPUTATION_FAILED));
|
|
900
866
|
}
|
|
901
867
|
_handleError(e, t, n = !1) {
|
|
902
|
-
let r =
|
|
903
|
-
if (!n && !this.isRejected && (this.version =
|
|
868
|
+
let r = g(e, f, t);
|
|
869
|
+
if (!n && !this.isRejected && (this.version = le(this.version)), this._error = r, this.flags = this.flags & ~(k | A | j | M) | N | Se, this._onError) try {
|
|
904
870
|
this._onError(r);
|
|
905
871
|
} catch (e) {
|
|
906
|
-
console.error(
|
|
872
|
+
console.error(h.CALLBACK_ERROR_IN_ERROR_HANDLER, e);
|
|
907
873
|
}
|
|
908
874
|
if (n) throw r;
|
|
909
875
|
this._notifySubscribers(void 0, void 0);
|
|
910
876
|
}
|
|
911
877
|
_finalizeResolution(e) {
|
|
912
878
|
let t = this.flags;
|
|
913
|
-
((t &
|
|
879
|
+
((t & M) === 0 || !this._equal(this._value, e)) && (this.version = le(this.version)), this._value = e, this._error = null, this.flags = (t | M) & ~(k | A | j | N | Se);
|
|
914
880
|
}
|
|
915
881
|
execute() {
|
|
916
882
|
this._markDirty();
|
|
917
883
|
}
|
|
918
884
|
_markDirty() {
|
|
919
885
|
let e = this.flags;
|
|
920
|
-
(e & (
|
|
921
|
-
}
|
|
922
|
-
_isDirty() {
|
|
923
|
-
let e = this._deps;
|
|
924
|
-
return e.hasComputeds ? this._deepDirtyCheck() : e.isDirtyFast();
|
|
886
|
+
(e & (P | A)) === 0 && (this.flags = e | A, this._notifySubscribers(void 0, void 0));
|
|
925
887
|
}
|
|
926
888
|
_deepDirtyCheck() {
|
|
927
|
-
let e = this._deps, t =
|
|
928
|
-
|
|
889
|
+
let e = this._deps, t = T.current;
|
|
890
|
+
T.current = null;
|
|
929
891
|
try {
|
|
930
892
|
let t = e.size;
|
|
931
893
|
for (let n = 0; n < t; n++) {
|
|
932
894
|
let t = e.getAt(n);
|
|
933
895
|
if (t == null) continue;
|
|
934
896
|
let r = t.node;
|
|
935
|
-
if ((r.flags &
|
|
897
|
+
if ((r.flags & we) !== 0) try {
|
|
936
898
|
r.value;
|
|
937
899
|
} catch {}
|
|
938
900
|
if (r.version !== t.version) return this._hotIndex = n, !0;
|
|
939
901
|
}
|
|
940
902
|
return this._hotIndex = -1, !1;
|
|
941
903
|
} finally {
|
|
942
|
-
|
|
904
|
+
T.current = t;
|
|
943
905
|
}
|
|
944
906
|
}
|
|
945
907
|
};
|
|
946
|
-
function
|
|
947
|
-
return new
|
|
908
|
+
function F(e, t = {}) {
|
|
909
|
+
return new Ee(e, t);
|
|
948
910
|
}
|
|
949
|
-
var
|
|
911
|
+
var De = class extends ne {
|
|
950
912
|
constructor(e, t = {}) {
|
|
951
|
-
super(), this[
|
|
913
|
+
super(), this[ae] = !0, this._cleanup = null, this._deps = new C(), this._currentEpoch = c.UNINITIALIZED, this._lastFlushEpoch = c.UNINITIALIZED, this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? a.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? a.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 = () => D.schedule(this), y.attachDebugInfo(this, "effect", this.id);
|
|
952
914
|
}
|
|
953
915
|
run() {
|
|
954
|
-
if (this.isDisposed) throw new
|
|
916
|
+
if (this.isDisposed) throw new p(h.EFFECT_DISPOSED);
|
|
955
917
|
this.execute(!0);
|
|
956
918
|
}
|
|
957
919
|
dispose() {
|
|
@@ -987,13 +949,13 @@ var Te = class extends ee {
|
|
|
987
949
|
let n;
|
|
988
950
|
try {
|
|
989
951
|
let t = e.subscribe(this._notifyCallback);
|
|
990
|
-
n = new
|
|
952
|
+
n = new w(e, e.version, t);
|
|
991
953
|
} catch (t) {
|
|
992
|
-
let r =
|
|
954
|
+
let r = g(t, p, h.EFFECT_EXECUTION_FAILED);
|
|
993
955
|
if (console.error(r), this._onError) try {
|
|
994
956
|
this._onError(r);
|
|
995
957
|
} catch {}
|
|
996
|
-
n = new
|
|
958
|
+
n = new w(e, e.version, void 0);
|
|
997
959
|
}
|
|
998
960
|
this._deps.insertNew(t, n);
|
|
999
961
|
}
|
|
@@ -1002,11 +964,11 @@ var Te = class extends ee {
|
|
|
1002
964
|
if ((t & (n.DISPOSED | n.EXECUTING)) !== 0) return;
|
|
1003
965
|
let r = this._deps;
|
|
1004
966
|
if (!e && r.size > 0 && !this._isDirty()) return;
|
|
1005
|
-
this._checkInfiniteLoops(), this.flags = t | n.EXECUTING, this._execCleanup(), this._currentEpoch =
|
|
967
|
+
this._checkInfiniteLoops(), this.flags = t | n.EXECUTING, this._execCleanup(), this._currentEpoch = ce(), this._trackCount = 0, r.prepareTracking(), this._hotIndex = -1;
|
|
1006
968
|
let i = !1;
|
|
1007
969
|
try {
|
|
1008
|
-
let e =
|
|
1009
|
-
r.truncateFrom(this._trackCount),
|
|
970
|
+
let e = T.run(this, this._fn);
|
|
971
|
+
r.truncateFrom(this._trackCount), i = !0, xe(e) ? this._handleAsyncResult(e) : this._cleanup = typeof e == "function" ? e : null;
|
|
1010
972
|
} catch (e) {
|
|
1011
973
|
if (!i) try {
|
|
1012
974
|
r.truncateFrom(this._trackCount);
|
|
@@ -1016,10 +978,6 @@ var Te = class extends ee {
|
|
|
1016
978
|
this.flags &= ~n.EXECUTING;
|
|
1017
979
|
}
|
|
1018
980
|
}
|
|
1019
|
-
_isDirty() {
|
|
1020
|
-
let e = this._deps;
|
|
1021
|
-
return e.hasComputeds ? this._deepDirtyCheck() : e.isDirtyFast();
|
|
1022
|
-
}
|
|
1023
981
|
_handleAsyncResult(e) {
|
|
1024
982
|
let t = ++this._execId;
|
|
1025
983
|
e.then((e) => {
|
|
@@ -1027,7 +985,7 @@ var Te = class extends ee {
|
|
|
1027
985
|
if (typeof e == "function") try {
|
|
1028
986
|
e();
|
|
1029
987
|
} catch (e) {
|
|
1030
|
-
this._handleExecutionError(e,
|
|
988
|
+
this._handleExecutionError(e, h.EFFECT_CLEANUP_FAILED);
|
|
1031
989
|
}
|
|
1032
990
|
return;
|
|
1033
991
|
}
|
|
@@ -1035,8 +993,8 @@ var Te = class extends ee {
|
|
|
1035
993
|
}, (e) => t === this._execId && this._handleExecutionError(e));
|
|
1036
994
|
}
|
|
1037
995
|
_deepDirtyCheck() {
|
|
1038
|
-
let e =
|
|
1039
|
-
|
|
996
|
+
let e = T.current;
|
|
997
|
+
T.current = null;
|
|
1040
998
|
let t = this._deps;
|
|
1041
999
|
try {
|
|
1042
1000
|
let e = t.size;
|
|
@@ -1048,7 +1006,7 @@ var Te = class extends ee {
|
|
|
1048
1006
|
}
|
|
1049
1007
|
return !1;
|
|
1050
1008
|
} finally {
|
|
1051
|
-
|
|
1009
|
+
T.current = e;
|
|
1052
1010
|
}
|
|
1053
1011
|
}
|
|
1054
1012
|
_tryPullComputed(e) {
|
|
@@ -1063,13 +1021,13 @@ var Te = class extends ee {
|
|
|
1063
1021
|
try {
|
|
1064
1022
|
e();
|
|
1065
1023
|
} catch (e) {
|
|
1066
|
-
this._handleExecutionError(e,
|
|
1024
|
+
this._handleExecutionError(e, h.EFFECT_CLEANUP_FAILED);
|
|
1067
1025
|
}
|
|
1068
1026
|
}
|
|
1069
1027
|
}
|
|
1070
1028
|
_checkInfiniteLoops() {
|
|
1071
|
-
let e =
|
|
1072
|
-
this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
1029
|
+
let e = pe();
|
|
1030
|
+
this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), ge() > a.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
|
|
1073
1031
|
}
|
|
1074
1032
|
_checkFrequencyLimit() {
|
|
1075
1033
|
if (!Number.isFinite(this._maxExecutions)) return;
|
|
@@ -1079,7 +1037,7 @@ var Te = class extends ee {
|
|
|
1079
1037
|
return;
|
|
1080
1038
|
}
|
|
1081
1039
|
if (++this._windowCount > this._maxExecutions) {
|
|
1082
|
-
let e = new
|
|
1040
|
+
let e = new p(h.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
|
|
1083
1041
|
throw this.dispose(), this._handleExecutionError(e), e;
|
|
1084
1042
|
}
|
|
1085
1043
|
}
|
|
@@ -1090,27 +1048,27 @@ var Te = class extends ee {
|
|
|
1090
1048
|
return (this.flags & n.EXECUTING) !== 0;
|
|
1091
1049
|
}
|
|
1092
1050
|
_throwInfiniteLoopError(e) {
|
|
1093
|
-
let t = new
|
|
1051
|
+
let t = new p(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${ue}`);
|
|
1094
1052
|
throw this.dispose(), console.error(t), t;
|
|
1095
1053
|
}
|
|
1096
|
-
_handleExecutionError(e, t =
|
|
1097
|
-
let n =
|
|
1054
|
+
_handleExecutionError(e, t = h.EFFECT_EXECUTION_FAILED) {
|
|
1055
|
+
let n = g(e, p, t);
|
|
1098
1056
|
if (console.error(n), this._onError) try {
|
|
1099
1057
|
this._onError(n);
|
|
1100
1058
|
} catch (e) {
|
|
1101
|
-
console.error(
|
|
1059
|
+
console.error(g(e, p, h.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
1102
1060
|
}
|
|
1103
1061
|
}
|
|
1104
1062
|
};
|
|
1105
|
-
function
|
|
1106
|
-
if (typeof e != "function") throw new
|
|
1107
|
-
let n = new
|
|
1063
|
+
function I(e, t = {}) {
|
|
1064
|
+
if (typeof e != "function") throw new p(h.EFFECT_MUST_BE_FUNCTION);
|
|
1065
|
+
let n = new De(e, t);
|
|
1108
1066
|
return n.execute(), n;
|
|
1109
1067
|
}
|
|
1110
|
-
var
|
|
1111
|
-
function
|
|
1068
|
+
var Oe = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ke = /* @__PURE__ */ Symbol.for("atom-effect/writable");
|
|
1069
|
+
function Ae(e, t, n, r) {
|
|
1112
1070
|
if (n === t.length) return r;
|
|
1113
|
-
let i = t[n], a = typeof e == "object" && e ? e : {}, o = a[i], s =
|
|
1071
|
+
let i = t[n], a = typeof e == "object" && e ? e : {}, o = a[i], s = Ae(o, t, n + 1, r);
|
|
1114
1072
|
if (Object.is(o, s)) return e;
|
|
1115
1073
|
if (Array.isArray(a)) {
|
|
1116
1074
|
let e = a.slice(), t = Number.parseInt(i, 10);
|
|
@@ -1121,7 +1079,7 @@ function Oe(e, t, n, r) {
|
|
|
1121
1079
|
[i]: s
|
|
1122
1080
|
};
|
|
1123
1081
|
}
|
|
1124
|
-
function
|
|
1082
|
+
function L(e, t) {
|
|
1125
1083
|
let n = e, r = t.length;
|
|
1126
1084
|
for (let e = 0; e < r; e++) {
|
|
1127
1085
|
if (n == null) return;
|
|
@@ -1129,22 +1087,22 @@ function z(e, t) {
|
|
|
1129
1087
|
}
|
|
1130
1088
|
return n;
|
|
1131
1089
|
}
|
|
1132
|
-
function
|
|
1090
|
+
function je(e, t) {
|
|
1133
1091
|
let n = t.includes(".") ? t.split(".") : [t], r = /* @__PURE__ */ new Set(), i = () => {
|
|
1134
1092
|
r.forEach((e) => e()), r.clear();
|
|
1135
1093
|
};
|
|
1136
1094
|
return {
|
|
1137
1095
|
get value() {
|
|
1138
|
-
return
|
|
1096
|
+
return L(e.value, n);
|
|
1139
1097
|
},
|
|
1140
1098
|
set value(t) {
|
|
1141
|
-
let r = e.peek(), i =
|
|
1099
|
+
let r = e.peek(), i = Ae(r, n, 0, t);
|
|
1142
1100
|
i !== r && (e.value = i);
|
|
1143
1101
|
},
|
|
1144
|
-
peek: () =>
|
|
1102
|
+
peek: () => L(e.peek(), n),
|
|
1145
1103
|
subscribe(t) {
|
|
1146
1104
|
let i = e.subscribe((e, r) => {
|
|
1147
|
-
let i =
|
|
1105
|
+
let i = L(e, n), a = L(r, n);
|
|
1148
1106
|
Object.is(i, a) || t(i, a);
|
|
1149
1107
|
});
|
|
1150
1108
|
return r.add(i), () => {
|
|
@@ -1154,25 +1112,12 @@ function ke(e, t) {
|
|
|
1154
1112
|
subscriberCount: () => r.size,
|
|
1155
1113
|
dispose: i,
|
|
1156
1114
|
[Symbol.dispose]: i,
|
|
1157
|
-
[
|
|
1158
|
-
[
|
|
1115
|
+
[Oe]: !0,
|
|
1116
|
+
[ke]: !0
|
|
1159
1117
|
};
|
|
1160
1118
|
}
|
|
1161
|
-
var
|
|
1162
|
-
function
|
|
1163
|
-
if (typeof e != "function") throw TypeError(v.BATCH_CALLBACK_MUST_BE_FUNCTION);
|
|
1164
|
-
let t = D;
|
|
1165
|
-
t.startBatch();
|
|
1166
|
-
try {
|
|
1167
|
-
return e();
|
|
1168
|
-
} finally {
|
|
1169
|
-
t.endBatch();
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
//#endregion
|
|
1173
|
-
//#region src/utils/index.ts
|
|
1174
|
-
var B = (e) => _e(e), Ne = (e) => typeof e == "object" && !!e && typeof e.then == "function";
|
|
1175
|
-
function Pe(e) {
|
|
1119
|
+
var Me = (e, t) => je(e, t), Ne = (e) => (t) => je(e, t), R = (e) => ye(e), Pe = (e) => typeof e == "object" && !!e && typeof e.then == "function";
|
|
1120
|
+
function Fe(e) {
|
|
1176
1121
|
let t = e.localName, n = e.id;
|
|
1177
1122
|
if (n) return `${t}#${n}`;
|
|
1178
1123
|
let r = e.className;
|
|
@@ -1182,46 +1127,46 @@ function Pe(e) {
|
|
|
1182
1127
|
}
|
|
1183
1128
|
return t;
|
|
1184
1129
|
}
|
|
1185
|
-
var
|
|
1186
|
-
function
|
|
1130
|
+
var z = Object.prototype.hasOwnProperty;
|
|
1131
|
+
function Ie(e, t) {
|
|
1187
1132
|
if (e === t) return !0;
|
|
1188
1133
|
if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
|
|
1189
1134
|
let n = e, r = t, i = 0;
|
|
1190
|
-
for (let e in n) if (
|
|
1191
|
-
if (!
|
|
1135
|
+
for (let e in n) if (z.call(n, e)) {
|
|
1136
|
+
if (!z.call(r, e) || n[e] !== r[e]) return !1;
|
|
1192
1137
|
i++;
|
|
1193
1138
|
}
|
|
1194
1139
|
let a = 0;
|
|
1195
|
-
for (let e in r)
|
|
1140
|
+
for (let e in r) z.call(r, e) && a++;
|
|
1196
1141
|
return i === a;
|
|
1197
1142
|
}
|
|
1198
1143
|
//#endregion
|
|
1199
1144
|
//#region src/constants.ts
|
|
1200
|
-
var
|
|
1145
|
+
var B = {
|
|
1201
1146
|
ROUTE: "[atom-route]",
|
|
1202
1147
|
BINDING: "[atom-binding]",
|
|
1203
1148
|
LIST: "[atom-list]",
|
|
1204
1149
|
MOUNT: "[atom-mount]"
|
|
1205
|
-
},
|
|
1150
|
+
}, Le = Object.freeze({
|
|
1206
1151
|
mode: "hash",
|
|
1207
1152
|
basePath: "",
|
|
1208
1153
|
autoBindLinks: !1,
|
|
1209
1154
|
activeClass: "active"
|
|
1210
|
-
}),
|
|
1155
|
+
}), Re = {
|
|
1211
1156
|
EVENT: "input",
|
|
1212
1157
|
DEBOUNCE: 0
|
|
1213
|
-
},
|
|
1158
|
+
}, ze = { HIGHLIGHT_DURATION_MS: 500 }, Be = new Set([
|
|
1214
1159
|
"input",
|
|
1215
1160
|
"select",
|
|
1216
1161
|
"textarea"
|
|
1217
|
-
]),
|
|
1162
|
+
]), Ve = new Set([
|
|
1218
1163
|
"innerHTML",
|
|
1219
1164
|
"outerHTML",
|
|
1220
1165
|
"srcdoc",
|
|
1221
1166
|
"__proto__",
|
|
1222
1167
|
"constructor",
|
|
1223
1168
|
"prototype"
|
|
1224
|
-
]),
|
|
1169
|
+
]), V = {
|
|
1225
1170
|
ROUTE: {
|
|
1226
1171
|
NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
|
|
1227
1172
|
TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
|
|
@@ -1249,18 +1194,18 @@ var H = {
|
|
|
1249
1194
|
CLEANUP_ERROR: (e) => `Cleanup error${e ? ` in component <${e}>` : ""}`
|
|
1250
1195
|
},
|
|
1251
1196
|
CORE: { EFFECT_DISPOSE_ERROR: (e) => `Effect dispose error${e ? `: ${e}` : ""}` }
|
|
1252
|
-
},
|
|
1253
|
-
function
|
|
1197
|
+
}, He = typeof window < "u", Ue = `${ze.HIGHLIGHT_DURATION_MS / 1e3}s`;
|
|
1198
|
+
function We() {
|
|
1254
1199
|
let e = globalThis;
|
|
1255
|
-
if (
|
|
1200
|
+
if (He && e.window?.__ATOM_DEBUG__ === !0) return !0;
|
|
1256
1201
|
try {
|
|
1257
1202
|
if (e.process?.env?.VITE_ATOM_DEBUG === "true") return !0;
|
|
1258
1203
|
} catch {}
|
|
1259
1204
|
return !1;
|
|
1260
1205
|
}
|
|
1261
|
-
var
|
|
1206
|
+
var H = new class {
|
|
1262
1207
|
constructor() {
|
|
1263
|
-
this._enabled = !1, this._lastState = !1, this.log = () => {}, this.atomChanged = () => {}, this.domUpdated = () => {}, this.cleanup = () => {}, this._enabled =
|
|
1208
|
+
this._enabled = !1, this._lastState = !1, this.log = () => {}, this.atomChanged = () => {}, this.domUpdated = () => {}, this.cleanup = () => {}, this._enabled = We(), this._lastState = this._enabled, this._applyMethods(this._enabled);
|
|
1264
1209
|
}
|
|
1265
1210
|
get enabled() {
|
|
1266
1211
|
return this._enabled;
|
|
@@ -1277,61 +1222,61 @@ var G = new class {
|
|
|
1277
1222
|
_applyMethods(e) {
|
|
1278
1223
|
e ? (this.log = (e, ...t) => console.log(e, ...t), this.atomChanged = (e, t, n, r) => console.log(`${e} Atom "${t ?? "anonymous"}" changed:`, n, "→", r), this.domUpdated = (e, t, n, r) => {
|
|
1279
1224
|
let i = t instanceof Element ? t : t[0];
|
|
1280
|
-
i?.isConnected && (console.log(`${e} DOM updated: ${
|
|
1225
|
+
i?.isConnected && (console.log(`${e} DOM updated: ${Fe(i)}.${n} =`, r), this._highlightElement(i));
|
|
1281
1226
|
}, this.cleanup = (e, t) => console.log(`${e} Cleanup: ${t}`)) : (this.log = () => {}, this.atomChanged = () => {}, this.domUpdated = () => {}, this.cleanup = () => {});
|
|
1282
1227
|
}
|
|
1283
1228
|
_highlightElement(e) {
|
|
1284
1229
|
if (!e.isConnected) return;
|
|
1285
|
-
|
|
1286
|
-
let t =
|
|
1287
|
-
t !== void 0 && cancelAnimationFrame(t), n !== void 0 && (clearTimeout(n),
|
|
1288
|
-
|
|
1289
|
-
e.isConnected && e.classList.remove(
|
|
1290
|
-
},
|
|
1230
|
+
Je();
|
|
1231
|
+
let t = Xe.get(e), n = Ye.get(e);
|
|
1232
|
+
t !== void 0 && cancelAnimationFrame(t), n !== void 0 && (clearTimeout(n), Ye.delete(e)), Xe.set(e, requestAnimationFrame(() => {
|
|
1233
|
+
Xe.delete(e), e.isConnected && (e.classList.add(Ge), Ye.set(e, setTimeout(() => {
|
|
1234
|
+
e.isConnected && e.classList.remove(Ge), Ye.delete(e);
|
|
1235
|
+
}, ze.HIGHLIGHT_DURATION_MS)));
|
|
1291
1236
|
}));
|
|
1292
1237
|
}
|
|
1293
|
-
}(),
|
|
1294
|
-
function
|
|
1295
|
-
if (
|
|
1296
|
-
if (document.querySelector(`style[${
|
|
1297
|
-
|
|
1238
|
+
}(), Ge = "atom-debug-highlight", Ke = "data-atom-debug", qe = !1;
|
|
1239
|
+
function Je() {
|
|
1240
|
+
if (qe || !He) return;
|
|
1241
|
+
if (document.querySelector(`style[${Ke}]`)) {
|
|
1242
|
+
qe = !0;
|
|
1298
1243
|
return;
|
|
1299
1244
|
}
|
|
1300
|
-
let e = Object.assign(document.createElement("style"), { textContent: `.${
|
|
1301
|
-
e.setAttribute(
|
|
1245
|
+
let e = Object.assign(document.createElement("style"), { textContent: `.${Ge}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${Ue} ease-out}` });
|
|
1246
|
+
e.setAttribute(Ke, ""), document.head.appendChild(e), qe = !0;
|
|
1302
1247
|
}
|
|
1303
|
-
var
|
|
1248
|
+
var Ye = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap();
|
|
1304
1249
|
//#endregion
|
|
1305
1250
|
//#region src/core/namespace.ts
|
|
1306
|
-
function
|
|
1307
|
-
return
|
|
1251
|
+
function Ze(e, t) {
|
|
1252
|
+
return O(e, t);
|
|
1308
1253
|
}
|
|
1309
|
-
Object.defineProperty(
|
|
1254
|
+
Object.defineProperty(Ze, "debug", {
|
|
1310
1255
|
enumerable: !0,
|
|
1311
1256
|
configurable: !0,
|
|
1312
|
-
get: () =>
|
|
1257
|
+
get: () => H.enabled,
|
|
1313
1258
|
set: (e) => {
|
|
1314
|
-
|
|
1259
|
+
H.enabled = e;
|
|
1315
1260
|
}
|
|
1316
1261
|
});
|
|
1317
|
-
var
|
|
1262
|
+
var Qe = () => Promise.resolve();
|
|
1318
1263
|
e.extend({
|
|
1319
|
-
atom:
|
|
1320
|
-
computed:
|
|
1321
|
-
effect:
|
|
1322
|
-
batch:
|
|
1323
|
-
untracked:
|
|
1324
|
-
isAtom:
|
|
1325
|
-
isComputed:
|
|
1326
|
-
isReactive:
|
|
1327
|
-
nextTick:
|
|
1328
|
-
atomLens:
|
|
1329
|
-
composeLens:
|
|
1330
|
-
lensFor:
|
|
1264
|
+
atom: Ze,
|
|
1265
|
+
computed: F,
|
|
1266
|
+
effect: I,
|
|
1267
|
+
batch: _e,
|
|
1268
|
+
untracked: E,
|
|
1269
|
+
isAtom: ye,
|
|
1270
|
+
isComputed: be,
|
|
1271
|
+
isReactive: R,
|
|
1272
|
+
nextTick: Qe,
|
|
1273
|
+
atomLens: je,
|
|
1274
|
+
composeLens: Me,
|
|
1275
|
+
lensFor: Ne
|
|
1331
1276
|
});
|
|
1332
1277
|
//#endregion
|
|
1333
|
-
//#region src/utils/
|
|
1334
|
-
var
|
|
1278
|
+
//#region src/utils/pool.ts
|
|
1279
|
+
var $e = class {
|
|
1335
1280
|
constructor(e = 50, t = 256) {
|
|
1336
1281
|
this.limit = e, this.capacity = t, this.pool = [];
|
|
1337
1282
|
}
|
|
@@ -1344,7 +1289,7 @@ var Ze = class {
|
|
|
1344
1289
|
reset() {
|
|
1345
1290
|
this.pool.length = 0;
|
|
1346
1291
|
}
|
|
1347
|
-
},
|
|
1292
|
+
}, et = class {
|
|
1348
1293
|
constructor(e, t, n = 64) {
|
|
1349
1294
|
this.factory = e, this.reset = t, this.limit = n, this.pool = [];
|
|
1350
1295
|
}
|
|
@@ -1360,17 +1305,17 @@ var Ze = class {
|
|
|
1360
1305
|
get size() {
|
|
1361
1306
|
return this.pool.length;
|
|
1362
1307
|
}
|
|
1363
|
-
},
|
|
1308
|
+
}, tt = new $e(), nt = new $e(), rt = new et(() => ({
|
|
1364
1309
|
effects: void 0,
|
|
1365
1310
|
cleanups: void 0,
|
|
1366
1311
|
componentCleanup: void 0
|
|
1367
1312
|
}), (e) => {
|
|
1368
1313
|
e.effects = void 0, e.cleanups = void 0, e.componentCleanup = void 0;
|
|
1369
|
-
}, 128),
|
|
1370
|
-
function
|
|
1371
|
-
|
|
1314
|
+
}, 128), it = !1;
|
|
1315
|
+
function at() {
|
|
1316
|
+
it || (it = !0, typeof document < "u" && document.body && ot(document.body));
|
|
1372
1317
|
}
|
|
1373
|
-
var
|
|
1318
|
+
var U = "_aes-bound", W = new class {
|
|
1374
1319
|
constructor() {
|
|
1375
1320
|
this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1376
1321
|
}
|
|
@@ -1387,17 +1332,17 @@ var K = "_aes-bound", q = new class {
|
|
|
1387
1332
|
return this.ignoredNodes.has(e);
|
|
1388
1333
|
}
|
|
1389
1334
|
getOrCreateRecord(e) {
|
|
1390
|
-
|
|
1335
|
+
at();
|
|
1391
1336
|
let t = this.records.get(e);
|
|
1392
|
-
return t || (t =
|
|
1337
|
+
return t || (t = rt.acquire(), this.records.set(e, t), e.classList.add(U)), t;
|
|
1393
1338
|
}
|
|
1394
1339
|
trackEffect(e, t) {
|
|
1395
1340
|
let n = this.getOrCreateRecord(e);
|
|
1396
|
-
n.effects ||=
|
|
1341
|
+
n.effects ||= tt.acquire(), n.effects.push(t);
|
|
1397
1342
|
}
|
|
1398
1343
|
trackCleanup(e, t) {
|
|
1399
1344
|
let n = this.getOrCreateRecord(e);
|
|
1400
|
-
n.cleanups ||=
|
|
1345
|
+
n.cleanups ||= nt.acquire(), n.cleanups.push(t);
|
|
1401
1346
|
}
|
|
1402
1347
|
setComponentCleanup(e, t) {
|
|
1403
1348
|
this.getOrCreateRecord(e).componentCleanup = t;
|
|
@@ -1408,52 +1353,52 @@ var K = "_aes-bound", q = new class {
|
|
|
1408
1353
|
cleanup(e) {
|
|
1409
1354
|
let t = e.nodeType === 1, n = this.records.get(e);
|
|
1410
1355
|
if (this.preservedNodes.delete(e), this.ignoredNodes.delete(e), !n) {
|
|
1411
|
-
t && e.classList.remove(
|
|
1356
|
+
t && e.classList.remove(U);
|
|
1412
1357
|
return;
|
|
1413
1358
|
}
|
|
1414
|
-
this.records.delete(e), t && e.classList.remove(
|
|
1415
|
-
let r = t ?
|
|
1416
|
-
if (
|
|
1359
|
+
this.records.delete(e), t && e.classList.remove(U);
|
|
1360
|
+
let r = t ? Fe(e) : e.nodeName || "Node";
|
|
1361
|
+
if (H.cleanup(B.BINDING, r), n.componentCleanup) try {
|
|
1417
1362
|
n.componentCleanup();
|
|
1418
1363
|
} catch (e) {
|
|
1419
|
-
|
|
1364
|
+
H.error(B.MOUNT, V.MOUNT.CLEANUP_ERROR(r), e);
|
|
1420
1365
|
}
|
|
1421
1366
|
if (n.effects) {
|
|
1422
1367
|
for (let e of n.effects) try {
|
|
1423
1368
|
e.dispose();
|
|
1424
1369
|
} catch (e) {
|
|
1425
|
-
|
|
1370
|
+
H.error(B.BINDING, V.CORE.EFFECT_DISPOSE_ERROR(r), e);
|
|
1426
1371
|
}
|
|
1427
|
-
|
|
1372
|
+
tt.release(n.effects), n.effects = void 0;
|
|
1428
1373
|
}
|
|
1429
1374
|
if (n.cleanups) {
|
|
1430
1375
|
for (let e of n.cleanups) try {
|
|
1431
1376
|
e();
|
|
1432
1377
|
} catch (e) {
|
|
1433
|
-
|
|
1378
|
+
H.error(B.BINDING, V.BINDING.CLEANUP_ERROR(r), e);
|
|
1434
1379
|
}
|
|
1435
|
-
|
|
1380
|
+
nt.release(n.cleanups), n.cleanups = void 0;
|
|
1436
1381
|
}
|
|
1437
|
-
|
|
1382
|
+
rt.release(n);
|
|
1438
1383
|
}
|
|
1439
1384
|
cleanupDescendants(e) {
|
|
1440
|
-
let t = e.getElementsByClassName ? e.getElementsByClassName(
|
|
1385
|
+
let t = e.getElementsByClassName ? e.getElementsByClassName(U) : e.querySelectorAll(`.${U}`), n = t.length;
|
|
1441
1386
|
if (n === 0) return;
|
|
1442
1387
|
let r = Array(n);
|
|
1443
1388
|
for (let e = 0; e < n; e++) r[e] = t[e];
|
|
1444
1389
|
for (let e = n - 1; e >= 0; e--) {
|
|
1445
1390
|
let t = r[e];
|
|
1446
|
-
this.records.has(t) ? this.cleanup(t) : t.classList.remove(
|
|
1391
|
+
this.records.has(t) ? this.cleanup(t) : t.classList.remove(U);
|
|
1447
1392
|
}
|
|
1448
1393
|
}
|
|
1449
1394
|
cleanupTree(e) {
|
|
1450
1395
|
(e.nodeType === 1 || e.nodeType === 11) && this.cleanupDescendants(e), this.cleanup(e);
|
|
1451
1396
|
}
|
|
1452
|
-
}(),
|
|
1453
|
-
function
|
|
1454
|
-
if (
|
|
1397
|
+
}(), G = /* @__PURE__ */ new Map();
|
|
1398
|
+
function ot(e) {
|
|
1399
|
+
if (G.has(e)) return;
|
|
1455
1400
|
let t = new MutationObserver((e) => {
|
|
1456
|
-
let t =
|
|
1401
|
+
let t = W;
|
|
1457
1402
|
for (let n = 0, r = e.length; n < r; n++) {
|
|
1458
1403
|
let r = e[n].removedNodes;
|
|
1459
1404
|
for (let e = 0, n = r.length; e < n; e++) {
|
|
@@ -1467,34 +1412,34 @@ function at(e) {
|
|
|
1467
1412
|
t.observe(e, {
|
|
1468
1413
|
childList: !0,
|
|
1469
1414
|
subtree: !0
|
|
1470
|
-
}),
|
|
1415
|
+
}), G.set(e, t);
|
|
1471
1416
|
}
|
|
1472
|
-
function
|
|
1473
|
-
|
|
1417
|
+
function st() {
|
|
1418
|
+
G.forEach((e) => e.disconnect()), G.clear();
|
|
1474
1419
|
}
|
|
1475
1420
|
//#endregion
|
|
1476
1421
|
//#region src/core/jquery-patch.ts
|
|
1477
|
-
var
|
|
1478
|
-
if (e[
|
|
1479
|
-
let t =
|
|
1422
|
+
var K = Symbol("atom-effect-internal"), q = /* @__PURE__ */ new WeakMap(), J = null, ct = (e) => {
|
|
1423
|
+
if (e[K]) return e;
|
|
1424
|
+
let t = q.get(e);
|
|
1480
1425
|
return t || (t = function(...t) {
|
|
1481
|
-
return
|
|
1482
|
-
}, t[
|
|
1426
|
+
return _e(() => e.apply(this, t));
|
|
1427
|
+
}, t[K] = !0, q.set(e, t)), t;
|
|
1483
1428
|
};
|
|
1484
|
-
function
|
|
1429
|
+
function lt(e) {
|
|
1485
1430
|
let t = {};
|
|
1486
|
-
for (let n in e) e[n] && (t[n] =
|
|
1431
|
+
for (let n in e) e[n] && (t[n] = ct(e[n]));
|
|
1487
1432
|
return t;
|
|
1488
1433
|
}
|
|
1489
|
-
function
|
|
1434
|
+
function ut(e) {
|
|
1490
1435
|
let t = {};
|
|
1491
1436
|
for (let n in e) {
|
|
1492
1437
|
let r = e[n];
|
|
1493
|
-
t[n] = r ?
|
|
1438
|
+
t[n] = r ? q.get(r) ?? r : void 0;
|
|
1494
1439
|
}
|
|
1495
1440
|
return t;
|
|
1496
1441
|
}
|
|
1497
|
-
function
|
|
1442
|
+
function dt() {
|
|
1498
1443
|
if (J !== null) return;
|
|
1499
1444
|
J = {
|
|
1500
1445
|
on: e.fn.on,
|
|
@@ -1508,56 +1453,56 @@ function ft() {
|
|
|
1508
1453
|
let n = e ? this.filter(e) : this, r = n.length;
|
|
1509
1454
|
for (let e = 0; e < r; e++) {
|
|
1510
1455
|
let t = n[e];
|
|
1511
|
-
t && (
|
|
1456
|
+
t && (W.markIgnored(t), W.cleanupTree(t));
|
|
1512
1457
|
}
|
|
1513
1458
|
return t.remove.call(this, e) ?? this;
|
|
1514
1459
|
}, e.fn.empty = function() {
|
|
1515
1460
|
let e = this.length;
|
|
1516
1461
|
for (let t = 0; t < e; t++) {
|
|
1517
1462
|
let e = this[t];
|
|
1518
|
-
e?.hasChildNodes() &&
|
|
1463
|
+
e?.hasChildNodes() && W.cleanupDescendants(e);
|
|
1519
1464
|
}
|
|
1520
1465
|
return t.empty.call(this) ?? this;
|
|
1521
1466
|
}, e.fn.detach = function(e) {
|
|
1522
1467
|
let n = e ? this.filter(e) : this, r = n.length;
|
|
1523
1468
|
for (let e = 0; e < r; e++) {
|
|
1524
1469
|
let t = n[e];
|
|
1525
|
-
t &&
|
|
1470
|
+
t && W.keep(t);
|
|
1526
1471
|
}
|
|
1527
1472
|
return t.detach.call(this, e) ?? this;
|
|
1528
1473
|
}, e.fn.on = function(...e) {
|
|
1529
1474
|
let n = e[0];
|
|
1530
|
-
if (n && typeof n == "object") e[0] =
|
|
1475
|
+
if (n && typeof n == "object") e[0] = lt(n);
|
|
1531
1476
|
else {
|
|
1532
1477
|
let t = e.length - 1;
|
|
1533
|
-
t >= 0 && typeof e[t] == "function" && (e[t] =
|
|
1478
|
+
t >= 0 && typeof e[t] == "function" && (e[t] = ct(e[t]));
|
|
1534
1479
|
}
|
|
1535
1480
|
return t.on.apply(this, e) ?? this;
|
|
1536
1481
|
}, e.fn.off = function(...e) {
|
|
1537
1482
|
let n = e[0];
|
|
1538
|
-
if (n && typeof n == "object") e[0] =
|
|
1483
|
+
if (n && typeof n == "object") e[0] = ut(n);
|
|
1539
1484
|
else {
|
|
1540
1485
|
let t = e.length - 1;
|
|
1541
1486
|
if (t >= 0 && typeof e[t] == "function") {
|
|
1542
1487
|
let n = e[t];
|
|
1543
|
-
e[t] =
|
|
1488
|
+
e[t] = q.get(n) ?? n;
|
|
1544
1489
|
}
|
|
1545
1490
|
}
|
|
1546
1491
|
return t.off.apply(this, e) ?? this;
|
|
1547
1492
|
};
|
|
1548
1493
|
}
|
|
1549
|
-
function
|
|
1494
|
+
function ft() {
|
|
1550
1495
|
J !== null && (e.fn.on = J.on, e.fn.off = J.off, e.fn.remove = J.remove, e.fn.empty = J.empty, e.fn.detach = J.detach, J = null);
|
|
1551
1496
|
}
|
|
1552
1497
|
//#endregion
|
|
1553
1498
|
//#region src/types.ts
|
|
1554
1499
|
var Y = /* @__PURE__ */ function(e) {
|
|
1555
1500
|
return e[e.None = 0] = "None", e[e.Focused = 1] = "Focused", e[e.Composing = 2] = "Composing", e[e.SyncingToAtom = 4] = "SyncingToAtom", e[e.SyncingToDom = 8] = "SyncingToDom", e[e.Busy = 14] = "Busy", e;
|
|
1556
|
-
}({}),
|
|
1557
|
-
function
|
|
1558
|
-
e[
|
|
1501
|
+
}({}), pt = 0;
|
|
1502
|
+
function mt(e) {
|
|
1503
|
+
e[K] = !0;
|
|
1559
1504
|
}
|
|
1560
|
-
var
|
|
1505
|
+
var ht = class {
|
|
1561
1506
|
constructor(e, t, n) {
|
|
1562
1507
|
this.flags = 0, this.timeoutId = void 0, this.handleCompositionStart = () => {
|
|
1563
1508
|
this.flags |= Y.Composing;
|
|
@@ -1571,7 +1516,7 @@ var gt = class {
|
|
|
1571
1516
|
this.flags &= ~Y.Composing, this.flushPendingDebounce(), e && this.timeoutId === void 0 && this.syncAtomFromDom(), this.normalizeDomValue();
|
|
1572
1517
|
}, this.syncDomFromAtom = () => {
|
|
1573
1518
|
let e = this.atom.value;
|
|
1574
|
-
|
|
1519
|
+
E(() => {
|
|
1575
1520
|
let t = this.format(e), n = this.getRawDom();
|
|
1576
1521
|
if (this.isMultipleSelect) {
|
|
1577
1522
|
if (this.equal(n, e)) return;
|
|
@@ -1581,7 +1526,7 @@ var gt = class {
|
|
|
1581
1526
|
} catch {}
|
|
1582
1527
|
this.flags |= Y.SyncingToDom;
|
|
1583
1528
|
try {
|
|
1584
|
-
this.writeDom(e, t),
|
|
1529
|
+
this.writeDom(e, t), H.domUpdated(B.BINDING, this.$el, "val", t);
|
|
1585
1530
|
} finally {
|
|
1586
1531
|
this.flags &= ~Y.SyncingToDom;
|
|
1587
1532
|
}
|
|
@@ -1590,7 +1535,7 @@ var gt = class {
|
|
|
1590
1535
|
this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
|
|
1591
1536
|
}, this.$el = e, this.el = e[0], this.atom = t;
|
|
1592
1537
|
let r = this.el.tagName, i = r === "SELECT" && this.el.multiple;
|
|
1593
|
-
this.isMultipleSelect = i, this.isTextControl = r === "INPUT" || r === "TEXTAREA", this.ns = `.atomBind-${++
|
|
1538
|
+
this.isMultipleSelect = i, this.isTextControl = r === "INPUT" || r === "TEXTAREA", this.ns = `.atomBind-${++pt}`;
|
|
1594
1539
|
let a = n.debounce ?? 0;
|
|
1595
1540
|
this.parse = n.parse ?? ((e) => e), i ? (this.format = n.format ?? ((e) => (Array.isArray(e) ? e : e ? [String(e)] : []).join(",")), this.getRawDom = () => this.$el.val() || [], this.readDom = () => this.getRawDom(), this.writeDom = (e) => {
|
|
1596
1541
|
this.$el.val(e);
|
|
@@ -1627,7 +1572,7 @@ var gt = class {
|
|
|
1627
1572
|
this.handleCompositionStart,
|
|
1628
1573
|
this.handleCompositionEnd,
|
|
1629
1574
|
this.handleInput
|
|
1630
|
-
].forEach(
|
|
1575
|
+
].forEach(mt), this.bindEvents(n.event ?? Re.EVENT);
|
|
1631
1576
|
}
|
|
1632
1577
|
flushPendingDebounce() {
|
|
1633
1578
|
this.timeoutId !== void 0 && (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom());
|
|
@@ -1643,7 +1588,7 @@ var gt = class {
|
|
|
1643
1588
|
let e = this.readDom();
|
|
1644
1589
|
this.equal(this.atom.peek(), e) || (this.atom.value = e);
|
|
1645
1590
|
} catch (e) {
|
|
1646
|
-
|
|
1591
|
+
H.warn(B.BINDING, V.BINDING.PARSE_ERROR(e instanceof Error ? e.message : String(e)), e);
|
|
1647
1592
|
} finally {
|
|
1648
1593
|
this.flags &= ~Y.SyncingToAtom;
|
|
1649
1594
|
}
|
|
@@ -1654,10 +1599,10 @@ var gt = class {
|
|
|
1654
1599
|
this.$el.on(`focus${t}`, this.handleFocus).on(`blur${t}`, this.handleBlur).on(`compositionstart${t}`, this.handleCompositionStart).on(`compositionend${t}`, this.handleCompositionEnd).on(n, this.handleInput);
|
|
1655
1600
|
}
|
|
1656
1601
|
};
|
|
1657
|
-
function
|
|
1658
|
-
let r = new
|
|
1602
|
+
function gt(e, t, n) {
|
|
1603
|
+
let r = new ht(e, t, n);
|
|
1659
1604
|
return {
|
|
1660
|
-
fx:
|
|
1605
|
+
fx: I(r.syncDomFromAtom),
|
|
1661
1606
|
cleanup: () => {
|
|
1662
1607
|
r &&= (r.cleanup(), null);
|
|
1663
1608
|
}
|
|
@@ -1665,45 +1610,45 @@ function _t(e, t, n) {
|
|
|
1665
1610
|
}
|
|
1666
1611
|
//#endregion
|
|
1667
1612
|
//#region src/core/effect-factory.ts
|
|
1668
|
-
function
|
|
1613
|
+
function _t(e, t, n, r) {
|
|
1669
1614
|
let i = null, a = (t) => {
|
|
1670
|
-
if (!
|
|
1615
|
+
if (!Pe(t)) {
|
|
1671
1616
|
i = null;
|
|
1672
1617
|
try {
|
|
1673
|
-
n(t),
|
|
1618
|
+
n(t), H.domUpdated(B.BINDING, e, r, t);
|
|
1674
1619
|
} catch (e) {
|
|
1675
|
-
|
|
1620
|
+
H.error(B.BINDING, V.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1676
1621
|
}
|
|
1677
1622
|
return;
|
|
1678
1623
|
}
|
|
1679
1624
|
i = t, t.then((a) => {
|
|
1680
|
-
i === t &&
|
|
1625
|
+
i === t && E(() => {
|
|
1681
1626
|
try {
|
|
1682
|
-
n(a),
|
|
1627
|
+
n(a), H.domUpdated(B.BINDING, e, `${r} (async)`, a);
|
|
1683
1628
|
} catch (e) {
|
|
1684
|
-
|
|
1629
|
+
H.error(B.BINDING, V.BINDING.UPDATER_ERROR(r), e);
|
|
1685
1630
|
}
|
|
1686
1631
|
});
|
|
1687
1632
|
}).catch((e) => {
|
|
1688
|
-
i === t &&
|
|
1633
|
+
i === t && H.error(B.BINDING, V.BINDING.UPDATER_ERROR(r), e);
|
|
1689
1634
|
});
|
|
1690
|
-
}, o =
|
|
1691
|
-
o || typeof t == "function" ?
|
|
1635
|
+
}, o = R(t);
|
|
1636
|
+
o || typeof t == "function" ? W.trackEffect(e, I(() => {
|
|
1692
1637
|
let e = o ? t.value : t();
|
|
1693
|
-
|
|
1694
|
-
}, { name: r })) :
|
|
1638
|
+
E(() => a(e));
|
|
1639
|
+
}, { name: r })) : E(() => a(t));
|
|
1695
1640
|
}
|
|
1696
|
-
function
|
|
1641
|
+
function X(e, t, n, r) {
|
|
1697
1642
|
let i = Object.keys(t), a = [], o = [], s = [], c = {};
|
|
1698
1643
|
for (let e = 0, n = i.length; e < n; e++) {
|
|
1699
|
-
let n = i[e], r = t[n], l =
|
|
1644
|
+
let n = i[e], r = t[n], l = R(r);
|
|
1700
1645
|
l || typeof r == "function" ? (a.push(n), o.push(r), s.push(l)) : c[n] = r;
|
|
1701
1646
|
}
|
|
1702
1647
|
let l = 0, u = (t) => {
|
|
1703
1648
|
let a = [], o = {}, s = i.length;
|
|
1704
1649
|
for (let e = 0; e < s; e++) {
|
|
1705
1650
|
let n = i[e], r = t[n];
|
|
1706
|
-
|
|
1651
|
+
Pe(r) ? a.push(r.then((e) => ({
|
|
1707
1652
|
key: n,
|
|
1708
1653
|
val: e
|
|
1709
1654
|
}))) : o[n] = r;
|
|
@@ -1717,11 +1662,11 @@ function yt(e, t, n, r) {
|
|
|
1717
1662
|
let t = i[e];
|
|
1718
1663
|
o[t.key] = t.val;
|
|
1719
1664
|
}
|
|
1720
|
-
|
|
1665
|
+
E(() => {
|
|
1721
1666
|
try {
|
|
1722
|
-
n(o),
|
|
1667
|
+
n(o), H.domUpdated(B.BINDING, e, `${r} (async)`, o);
|
|
1723
1668
|
} catch (e) {
|
|
1724
|
-
|
|
1669
|
+
H.error(B.BINDING, V.BINDING.UPDATER_ERROR(r), e);
|
|
1725
1670
|
}
|
|
1726
1671
|
});
|
|
1727
1672
|
}
|
|
@@ -1729,24 +1674,24 @@ function yt(e, t, n, r) {
|
|
|
1729
1674
|
} else {
|
|
1730
1675
|
l++;
|
|
1731
1676
|
try {
|
|
1732
|
-
n(o),
|
|
1677
|
+
n(o), H.domUpdated(B.BINDING, e, r, o);
|
|
1733
1678
|
} catch (e) {
|
|
1734
|
-
|
|
1679
|
+
H.error(B.BINDING, V.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1735
1680
|
}
|
|
1736
1681
|
}
|
|
1737
1682
|
};
|
|
1738
|
-
a.length > 0 ?
|
|
1683
|
+
a.length > 0 ? W.trackEffect(e, I(() => {
|
|
1739
1684
|
let e = { ...c };
|
|
1740
1685
|
for (let t = 0, n = a.length; t < n; t++) {
|
|
1741
1686
|
let n = o[t];
|
|
1742
1687
|
e[a[t]] = s[t] ? n.value : n();
|
|
1743
1688
|
}
|
|
1744
|
-
|
|
1745
|
-
}, { name: r })) :
|
|
1689
|
+
E(() => u(e));
|
|
1690
|
+
}, { name: r })) : E(() => u(c));
|
|
1746
1691
|
}
|
|
1747
1692
|
//#endregion
|
|
1748
1693
|
//#region src/utils/sanitize.ts
|
|
1749
|
-
var
|
|
1694
|
+
var vt = new Set([
|
|
1750
1695
|
"href",
|
|
1751
1696
|
"src",
|
|
1752
1697
|
"action",
|
|
@@ -1761,12 +1706,12 @@ var bt = new Set([
|
|
|
1761
1706
|
"usemap",
|
|
1762
1707
|
"classid",
|
|
1763
1708
|
"codebase"
|
|
1764
|
-
]),
|
|
1709
|
+
]), yt = /^\s*(?:javascript|vbscript)\s*:/i, bt = /(?:expression\s*\(|behavior\s*:|-moz-binding\s*:|(?:\\[0-9a-f]{1,6}\s*|[\s\x00-\x20/'"])*(?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t|d\s*a\s*t\s*a)\s*:(?!image\/))/i, xt = /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i, St = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, Ct = /&#x([0-9a-f]+);?|&#([0-9]+);?/gi, wt = {
|
|
1765
1710
|
colon: ":",
|
|
1766
1711
|
Tab: " ",
|
|
1767
1712
|
NewLine: "\n"
|
|
1768
|
-
},
|
|
1769
|
-
function
|
|
1713
|
+
}, Tt = /&(colon|Tab|NewLine);/g, Et = /<\?[\s\S]*?\?>/g, Dt = /(<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*\/?>)/gi, Ot = /(j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t)\s*:/gi, kt = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, At = /\bon\w+\s*=/gim, jt = new RegExp(bt.source, "gim");
|
|
1714
|
+
function Mt(e) {
|
|
1770
1715
|
let t = e.length;
|
|
1771
1716
|
for (let n = 0; n < t; n++) {
|
|
1772
1717
|
let t = e.charCodeAt(n);
|
|
@@ -1780,96 +1725,96 @@ function Pt(e) {
|
|
|
1780
1725
|
}
|
|
1781
1726
|
return !1;
|
|
1782
1727
|
}
|
|
1783
|
-
function
|
|
1728
|
+
function Z(e) {
|
|
1784
1729
|
if (!e) return "";
|
|
1785
1730
|
let t = String(e);
|
|
1786
|
-
if (!
|
|
1787
|
-
let n = t.replace(
|
|
1731
|
+
if (!Mt(t)) return t;
|
|
1732
|
+
let n = t.replace(St, "").replace(Ct, (e, t, n) => String.fromCodePoint(t ? parseInt(t, 16) : parseInt(n, 10))).replace(Tt, (e, t) => wt[t] ?? "");
|
|
1788
1733
|
if (n.indexOf("<") !== -1) {
|
|
1789
|
-
n = n.replace(
|
|
1734
|
+
n = n.replace(Et, "");
|
|
1790
1735
|
let e;
|
|
1791
1736
|
do
|
|
1792
|
-
e = n, n = n.replace(
|
|
1737
|
+
e = n, n = n.replace(Dt, "");
|
|
1793
1738
|
while (n !== e);
|
|
1794
1739
|
}
|
|
1795
|
-
return n.replace(
|
|
1740
|
+
return n.replace(Ot, "data-unsafe-protocol:").replace(kt, "data-unsafe-protocol:").replace(At, "data-unsafe-attr=").replace(jt, "data-unsafe-css:");
|
|
1741
|
+
}
|
|
1742
|
+
var Nt = (e) => e.length < 15 ? !1 : e.toLowerCase().includes("url(") && xt.test(e), Pt = /* @__PURE__ */ new Map();
|
|
1743
|
+
function Ft(e) {
|
|
1744
|
+
let t = Pt.get(e);
|
|
1745
|
+
return t === void 0 ? (t = e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e, Pt.set(e, t), t) : t;
|
|
1796
1746
|
}
|
|
1797
|
-
var
|
|
1747
|
+
var It = /* @__PURE__ */ new WeakMap();
|
|
1798
1748
|
function Lt(e) {
|
|
1799
1749
|
let t = It.get(e);
|
|
1800
|
-
return t
|
|
1801
|
-
}
|
|
1802
|
-
var Rt = /* @__PURE__ */ new WeakMap();
|
|
1803
|
-
function zt(e) {
|
|
1804
|
-
let t = Rt.get(e);
|
|
1805
|
-
return t || (t = L(() => {
|
|
1750
|
+
return t || (t = F(() => {
|
|
1806
1751
|
let t = e.value;
|
|
1807
|
-
return
|
|
1808
|
-
}),
|
|
1752
|
+
return Pe(t) ? t.then((e) => Z(e)) : Z(t);
|
|
1753
|
+
}), It.set(e, t)), t;
|
|
1809
1754
|
}
|
|
1810
|
-
function
|
|
1755
|
+
function Rt(e) {
|
|
1811
1756
|
return {
|
|
1812
1757
|
el: e,
|
|
1813
|
-
trackCleanup: (t) =>
|
|
1758
|
+
trackCleanup: (t) => W.trackCleanup(e, t)
|
|
1814
1759
|
};
|
|
1815
1760
|
}
|
|
1816
|
-
function
|
|
1817
|
-
|
|
1761
|
+
function zt({ el: e }, t, n) {
|
|
1762
|
+
_t(e, t, (t) => {
|
|
1818
1763
|
let r = n ? n(t) : String(t ?? "");
|
|
1819
1764
|
e.textContent !== r && (e.textContent = r);
|
|
1820
1765
|
}, "text");
|
|
1821
1766
|
}
|
|
1822
|
-
function
|
|
1823
|
-
let n =
|
|
1824
|
-
|
|
1825
|
-
let i = n === t ?
|
|
1826
|
-
e.innerHTML !== i && (
|
|
1767
|
+
function Bt({ el: e }, t) {
|
|
1768
|
+
let n = ye(t) ? Lt(t) : t;
|
|
1769
|
+
_t(e, n, (r) => {
|
|
1770
|
+
let i = n === t ? Z(r) : r;
|
|
1771
|
+
e.innerHTML !== i && (W.cleanupDescendants(e), e.innerHTML = i);
|
|
1827
1772
|
}, "html");
|
|
1828
1773
|
}
|
|
1829
|
-
function
|
|
1774
|
+
function Vt({ el: e }, t) {
|
|
1830
1775
|
let n = {};
|
|
1831
|
-
for (let e in t) if (
|
|
1776
|
+
for (let e in t) if (z.call(t, e)) {
|
|
1832
1777
|
let t = e.trim();
|
|
1833
1778
|
n[e] = t.indexOf(" ") === -1 ? [t] : t.split(/\s+/).filter(Boolean);
|
|
1834
1779
|
}
|
|
1835
|
-
|
|
1780
|
+
X(e, t, (t) => {
|
|
1836
1781
|
for (let r in t) {
|
|
1837
1782
|
let i = n[r];
|
|
1838
1783
|
t[r] ? e.classList.add(...i) : e.classList.remove(...i);
|
|
1839
1784
|
}
|
|
1840
1785
|
}, "class");
|
|
1841
1786
|
}
|
|
1842
|
-
function
|
|
1787
|
+
function Ht({ el: e }, t) {
|
|
1843
1788
|
let n = e.style, r = {}, i = {};
|
|
1844
|
-
for (let e in t) if (
|
|
1789
|
+
for (let e in t) if (z.call(t, e)) {
|
|
1845
1790
|
let n = t[e], [a, o] = Array.isArray(n) ? n : [n, ""];
|
|
1846
1791
|
r[e] = a, i[e] = {
|
|
1847
|
-
camel:
|
|
1792
|
+
camel: Ft(e),
|
|
1848
1793
|
unit: o
|
|
1849
1794
|
};
|
|
1850
1795
|
}
|
|
1851
|
-
|
|
1796
|
+
X(e, r, (e) => {
|
|
1852
1797
|
for (let t in e) {
|
|
1853
1798
|
let r = i[t], a = e[t], o = r.unit ? `${a}${r.unit}` : String(a), s = r.camel;
|
|
1854
|
-
!
|
|
1799
|
+
!Nt(o) && n[s] !== o && (n[s] = o);
|
|
1855
1800
|
}
|
|
1856
1801
|
}, "css");
|
|
1857
1802
|
}
|
|
1858
|
-
function
|
|
1803
|
+
function Ut({ el: e }, t) {
|
|
1859
1804
|
let n = {}, r = {}, i = {};
|
|
1860
1805
|
for (let a in t) {
|
|
1861
|
-
if (!
|
|
1806
|
+
if (!z.call(t, a)) continue;
|
|
1862
1807
|
let o = a.toLowerCase();
|
|
1863
1808
|
if (o.startsWith("on")) {
|
|
1864
|
-
console.warn(`${
|
|
1809
|
+
console.warn(`${B.BINDING} ${V.SECURITY.BLOCKED_EVENT_HANDLER(a)}`);
|
|
1865
1810
|
continue;
|
|
1866
1811
|
}
|
|
1867
1812
|
n[a] = t[a], r[a] = {
|
|
1868
1813
|
isAria: o.startsWith("aria-"),
|
|
1869
|
-
isUrl:
|
|
1814
|
+
isUrl: vt.has(o)
|
|
1870
1815
|
}, i[a] = e.getAttribute(a);
|
|
1871
1816
|
}
|
|
1872
|
-
|
|
1817
|
+
X(e, n, (t) => {
|
|
1873
1818
|
for (let n in t) {
|
|
1874
1819
|
let a = r[n], o = t[n];
|
|
1875
1820
|
if (o == null || o === !1 && !a.isAria) {
|
|
@@ -1877,212 +1822,261 @@ function Gt({ el: e }, t) {
|
|
|
1877
1822
|
continue;
|
|
1878
1823
|
}
|
|
1879
1824
|
let s = o === !0 ? a.isAria ? "true" : n : String(o);
|
|
1880
|
-
if (a.isUrl &&
|
|
1881
|
-
console.warn(`${
|
|
1825
|
+
if (a.isUrl && yt.test(s)) {
|
|
1826
|
+
console.warn(`${B.BINDING} ${V.SECURITY.BLOCKED_PROTOCOL(n)}`);
|
|
1882
1827
|
continue;
|
|
1883
1828
|
}
|
|
1884
1829
|
i[n] !== s && (e.setAttribute(n, s), i[n] = s);
|
|
1885
1830
|
}
|
|
1886
1831
|
}, "attr");
|
|
1887
1832
|
}
|
|
1888
|
-
function
|
|
1833
|
+
function Wt(e, t) {
|
|
1889
1834
|
let n = e.el, r = {}, i = {};
|
|
1890
1835
|
for (let e in t) {
|
|
1891
|
-
if (!
|
|
1836
|
+
if (!z.call(t, e)) continue;
|
|
1892
1837
|
let n = e.toLowerCase();
|
|
1893
|
-
if (n.startsWith("on") ||
|
|
1894
|
-
console.warn(`${
|
|
1838
|
+
if (n.startsWith("on") || Ve.has(e)) {
|
|
1839
|
+
console.warn(`${B.BINDING} ${n.startsWith("on") ? V.SECURITY.BLOCKED_EVENT_HANDLER(e) : V.SECURITY.BLOCKED_PROP(e)}`);
|
|
1895
1840
|
continue;
|
|
1896
1841
|
}
|
|
1897
|
-
r[e] = t[e], i[e] = { isUrl:
|
|
1842
|
+
r[e] = t[e], i[e] = { isUrl: vt.has(n) };
|
|
1898
1843
|
}
|
|
1899
|
-
|
|
1844
|
+
X(e.el, r, (e) => {
|
|
1900
1845
|
for (let t in e) {
|
|
1901
1846
|
let r = e[t];
|
|
1902
|
-
if (i[t].isUrl && typeof r == "string" &&
|
|
1903
|
-
console.warn(`${
|
|
1847
|
+
if (i[t].isUrl && typeof r == "string" && yt.test(r)) {
|
|
1848
|
+
console.warn(`${B.BINDING} ${V.SECURITY.BLOCKED_PROTOCOL(t)}`);
|
|
1904
1849
|
continue;
|
|
1905
1850
|
}
|
|
1906
1851
|
n[t] !== r && (n[t] = r);
|
|
1907
1852
|
}
|
|
1908
1853
|
}, "prop");
|
|
1909
1854
|
}
|
|
1910
|
-
function
|
|
1855
|
+
function Gt({ el: e }, t, n) {
|
|
1911
1856
|
let r = e.style.display === "none" ? "" : e.style.display;
|
|
1912
|
-
|
|
1857
|
+
_t(e, t, (t) => {
|
|
1913
1858
|
let i = n === !!t ? "none" : r;
|
|
1914
1859
|
e.style.display !== i && (e.style.display = i);
|
|
1915
1860
|
}, n ? "hide" : "show");
|
|
1916
1861
|
}
|
|
1917
|
-
function
|
|
1862
|
+
function Kt(t, n, r = {}) {
|
|
1918
1863
|
let i = t.el.tagName.toLowerCase();
|
|
1919
|
-
if (!
|
|
1920
|
-
console.warn(`${
|
|
1864
|
+
if (!Be.has(i)) {
|
|
1865
|
+
console.warn(`${B.BINDING} ${V.BINDING.INVALID_INPUT_ELEMENT(i)}`);
|
|
1921
1866
|
return;
|
|
1922
1867
|
}
|
|
1923
|
-
let { fx: a, cleanup: o } =
|
|
1924
|
-
|
|
1868
|
+
let { fx: a, cleanup: o } = gt(e(t.el), n, r);
|
|
1869
|
+
W.trackEffect(t.el, a), t.trackCleanup(o);
|
|
1925
1870
|
}
|
|
1926
|
-
function
|
|
1871
|
+
function qt(t, n) {
|
|
1927
1872
|
let r = t.el, i = e(r), a = () => {
|
|
1928
1873
|
n.peek() !== r.checked && (n.value = r.checked, r.type === "radio" && r.checked && r.name && (r.form ? e(r.form) : e(document)).find(`input[type="radio"][name="${r.name.replace(/"/g, "\\\"")}"]`).not(r).trigger("change.atomRadioSync"));
|
|
1929
1874
|
};
|
|
1930
|
-
a[
|
|
1875
|
+
a[K] = !0, i.on("change change.atomRadioSync", a), t.trackCleanup(() => i.off("change change.atomRadioSync", a)), W.trackEffect(r, I(() => {
|
|
1931
1876
|
let e = !!n.value;
|
|
1932
|
-
|
|
1933
|
-
r.checked !== e && (r.checked = e,
|
|
1877
|
+
E(() => {
|
|
1878
|
+
r.checked !== e && (r.checked = e, H.domUpdated(B.BINDING, r, "checked", e));
|
|
1934
1879
|
});
|
|
1935
1880
|
}));
|
|
1936
1881
|
}
|
|
1937
|
-
function
|
|
1882
|
+
function Jt(t, n) {
|
|
1938
1883
|
let r = e(t.el);
|
|
1939
1884
|
r.on(n), t.trackCleanup(() => r.off(n));
|
|
1940
1885
|
}
|
|
1941
|
-
function
|
|
1886
|
+
function Yt({ el: t, trackCleanup: n }, r, i) {
|
|
1942
1887
|
let a = e(t);
|
|
1943
1888
|
a.on(r, i), n(() => a.off(r, i));
|
|
1944
1889
|
}
|
|
1945
|
-
function
|
|
1946
|
-
|
|
1890
|
+
function Xt(e) {
|
|
1891
|
+
W.cleanupTree(e);
|
|
1947
1892
|
}
|
|
1948
1893
|
//#endregion
|
|
1949
1894
|
//#region src/bindings/form.ts
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1895
|
+
var Zt = "input, select, textarea", Qt = class {
|
|
1896
|
+
constructor(e, t, n = {}) {
|
|
1897
|
+
this.form = e, this.atom = t, this.options = n, this.fieldMap = /* @__PURE__ */ new Map(), this.fields = [], this.elementNames = /* @__PURE__ */ new WeakMap(), this.isSyncingFromLeaf = !1, this.init();
|
|
1898
|
+
}
|
|
1899
|
+
init() {
|
|
1900
|
+
let e = I(() => {
|
|
1901
|
+
let e = this.atom.value;
|
|
1902
|
+
this.isSyncingFromLeaf || !this.fields.length || _e(() => {
|
|
1903
|
+
E(() => {
|
|
1904
|
+
for (let t = 0; t < this.fields.length; t++) {
|
|
1905
|
+
let n = this.fields[t], r = L(e, n.parts);
|
|
1906
|
+
Object.is(n.atom.peek(), r) || (n.atom.value = r);
|
|
1907
|
+
}
|
|
1908
|
+
});
|
|
1909
|
+
});
|
|
1958
1910
|
});
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
let
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1911
|
+
W.trackEffect(this.form, e), this.bindElement(this.form), this.setupObserver();
|
|
1912
|
+
}
|
|
1913
|
+
bindElement(e) {
|
|
1914
|
+
let t = e.matches?.(Zt) ? [e] : e.querySelectorAll?.(Zt) || [];
|
|
1915
|
+
for (let e = 0, n = t.length; e < n; e++) this.bindControl(t[e]);
|
|
1916
|
+
}
|
|
1917
|
+
bindControl(e) {
|
|
1918
|
+
if (!(e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement)) return;
|
|
1919
|
+
let t = e, n = t.name;
|
|
1920
|
+
if (!n) return;
|
|
1921
|
+
let r = this.elementNames.get(t);
|
|
1922
|
+
if (r !== void 0 && r !== n && W.cleanup(t), this.elementNames.has(t) && r === n) return;
|
|
1923
|
+
let i = this.acquireField(n);
|
|
1924
|
+
this.elementNames.set(t, n);
|
|
1925
|
+
let a = Rt(t);
|
|
1926
|
+
a.trackCleanup(() => this.releaseField(t, n)), t instanceof HTMLInputElement && (t.type === "radio" || t.type === "checkbox") ? this.bindToggle(a, i.atom, t.value, t.type === "checkbox") : Kt(a, i.atom, this.options);
|
|
1927
|
+
}
|
|
1928
|
+
bindToggle(t, n, r, i) {
|
|
1929
|
+
let a = t.el, o = () => {
|
|
1930
|
+
let e = n.peek();
|
|
1931
|
+
if (i && Array.isArray(e)) {
|
|
1932
|
+
let t = new Set(e.map(String));
|
|
1933
|
+
a.checked ? t.add(r) : t.delete(r), n.value = Array.from(t);
|
|
1934
|
+
} else n.value = i ? a.checked : r;
|
|
1935
|
+
};
|
|
1936
|
+
o[K] = !0, e(a).on("change", o), t.trackCleanup(() => e(a).off("change", o)), W.trackEffect(a, I(() => {
|
|
1937
|
+
let e = n.value, t = i ? Array.isArray(e) ? e.some((e) => String(e) === r) : !!e : String(e) === r;
|
|
1938
|
+
a.checked !== t && (a.checked = t);
|
|
1939
|
+
}));
|
|
1940
|
+
}
|
|
1941
|
+
acquireField(e) {
|
|
1942
|
+
let t = this.fieldMap.get(e);
|
|
1943
|
+
if (t) return t.refCount++, t;
|
|
1944
|
+
let n = e.replace(/\[(\w+)\]/g, ".$1").split(".").filter(Boolean), r = O(L(this.atom.peek(), n));
|
|
1945
|
+
return t = {
|
|
1946
|
+
atom: r,
|
|
1947
|
+
parts: n,
|
|
1948
|
+
name: e,
|
|
1949
|
+
refCount: 1,
|
|
1950
|
+
effect: null
|
|
1951
|
+
}, t.effect = I(() => {
|
|
1952
|
+
let t = r.value;
|
|
1953
|
+
this.options.transform && (t = this.options.transform(e, t));
|
|
1954
|
+
let i = this.atom.peek(), a = Ae(i, n, 0, t);
|
|
1955
|
+
if (a !== i) {
|
|
1956
|
+
this.isSyncingFromLeaf = !0;
|
|
1957
|
+
try {
|
|
1958
|
+
this.atom.value = a, this.options.onChange && E(() => this.options.onChange(e, t));
|
|
1959
|
+
} finally {
|
|
1960
|
+
this.isSyncingFromLeaf = !1;
|
|
1992
1961
|
}
|
|
1993
1962
|
}
|
|
1994
|
-
|
|
1963
|
+
}), this.fieldMap.set(e, t), this.fields.push(t), t;
|
|
1964
|
+
}
|
|
1965
|
+
releaseField(e, t) {
|
|
1966
|
+
let n = this.fieldMap.get(t);
|
|
1967
|
+
if (n && --n.refCount <= 0) {
|
|
1968
|
+
let e = this.fields.indexOf(n);
|
|
1969
|
+
e !== -1 && this.fields.splice(e, 1), n.effect?.dispose(), this.fieldMap.delete(t);
|
|
1995
1970
|
}
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
1971
|
+
W.cleanup(e);
|
|
1972
|
+
}
|
|
1973
|
+
setupObserver() {
|
|
1974
|
+
let e = new MutationObserver((e) => {
|
|
1975
|
+
for (let t = 0, n = e.length; t < n; t++) {
|
|
1976
|
+
let n = e[t];
|
|
1977
|
+
if (n.type === "childList") for (let e = 0; e < n.addedNodes.length; e++) {
|
|
1978
|
+
let t = n.addedNodes[e];
|
|
1979
|
+
t.nodeType === 1 && this.bindElement(t);
|
|
1980
|
+
}
|
|
1981
|
+
else n.attributeName === "name" && this.bindElement(n.target);
|
|
1982
|
+
}
|
|
1983
|
+
});
|
|
1984
|
+
e.observe(this.form, {
|
|
1985
|
+
childList: !0,
|
|
1986
|
+
subtree: !0,
|
|
1987
|
+
attributes: !0,
|
|
1988
|
+
attributeFilter: ["name"]
|
|
1989
|
+
}), W.trackCleanup(this.form, () => e.disconnect());
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
function $t(e, t, n = {}) {
|
|
1993
|
+
new Qt(e, t, n);
|
|
2003
1994
|
}
|
|
2004
1995
|
//#endregion
|
|
2005
1996
|
//#region src/bindings/chainable.ts
|
|
2006
|
-
function
|
|
1997
|
+
function Q(e, t) {
|
|
2007
1998
|
let n = e.length;
|
|
2008
1999
|
for (let r = 0; r < n; r++) {
|
|
2009
2000
|
let n = e[r];
|
|
2010
2001
|
if (n?.nodeType === 1) {
|
|
2011
2002
|
let e = n;
|
|
2012
|
-
t(
|
|
2013
|
-
} else n &&
|
|
2003
|
+
t(Rt(e), e);
|
|
2004
|
+
} else n && H.log(B.BINDING, `Skipping non-Element node (nodeType=${n.nodeType})`);
|
|
2014
2005
|
}
|
|
2015
2006
|
return e;
|
|
2016
2007
|
}
|
|
2017
2008
|
e.fn.atomText = function(e, t) {
|
|
2018
|
-
return
|
|
2009
|
+
return Q(this, (n) => zt(n, e, t));
|
|
2019
2010
|
}, e.fn.atomHtml = function(e) {
|
|
2020
|
-
return
|
|
2011
|
+
return Q(this, (t) => Bt(t, e));
|
|
2021
2012
|
}, e.fn.atomClass = function(e, t) {
|
|
2022
2013
|
if (typeof e == "string") {
|
|
2023
|
-
if (t === void 0) return console.warn(`${
|
|
2014
|
+
if (t === void 0) return console.warn(`${B.BINDING} ${V.BINDING.MISSING_CONDITION("atomClass")}`), this;
|
|
2024
2015
|
let n = { [e]: t };
|
|
2025
|
-
return
|
|
2016
|
+
return Q(this, (e) => Vt(e, n));
|
|
2026
2017
|
}
|
|
2027
|
-
return
|
|
2018
|
+
return Q(this, (t) => Vt(t, e));
|
|
2028
2019
|
}, e.fn.atomCss = function(e, t, n) {
|
|
2029
2020
|
if (typeof e == "string") {
|
|
2030
|
-
if (t === void 0) return console.warn(`${
|
|
2021
|
+
if (t === void 0) return console.warn(`${B.BINDING} ${V.BINDING.MISSING_SOURCE("atomCss")}`), this;
|
|
2031
2022
|
let r = { [e]: n ? [t, n] : t };
|
|
2032
|
-
return
|
|
2023
|
+
return Q(this, (e) => Ht(e, r));
|
|
2033
2024
|
}
|
|
2034
|
-
return
|
|
2025
|
+
return Q(this, (t) => Ht(t, e));
|
|
2035
2026
|
}, e.fn.atomAttr = function(e, t) {
|
|
2036
2027
|
if (typeof e == "string") {
|
|
2037
|
-
if (t === void 0) return console.warn(`${
|
|
2028
|
+
if (t === void 0) return console.warn(`${B.BINDING} ${V.BINDING.MISSING_SOURCE("atomAttr")}`), this;
|
|
2038
2029
|
let n = { [e]: t };
|
|
2039
|
-
return
|
|
2030
|
+
return Q(this, (e) => Ut(e, n));
|
|
2040
2031
|
}
|
|
2041
|
-
return
|
|
2032
|
+
return Q(this, (t) => Ut(t, e));
|
|
2042
2033
|
}, e.fn.atomProp = function(e, t) {
|
|
2043
2034
|
if (typeof e == "string") {
|
|
2044
|
-
if (t === void 0) return console.warn(`${
|
|
2035
|
+
if (t === void 0) return console.warn(`${B.BINDING} ${V.BINDING.MISSING_SOURCE("atomProp")}`), this;
|
|
2045
2036
|
let n = { [e]: t };
|
|
2046
|
-
return
|
|
2037
|
+
return Q(this, (e) => Wt(e, n));
|
|
2047
2038
|
}
|
|
2048
|
-
return
|
|
2039
|
+
return Q(this, (t) => Wt(t, e));
|
|
2049
2040
|
}, e.fn.atomShow = function(e) {
|
|
2050
|
-
return
|
|
2041
|
+
return Q(this, (t) => Gt(t, e, !1));
|
|
2051
2042
|
}, e.fn.atomHide = function(e) {
|
|
2052
|
-
return
|
|
2043
|
+
return Q(this, (t) => Gt(t, e, !0));
|
|
2053
2044
|
}, e.fn.atomVal = function(e, t = {}) {
|
|
2054
|
-
return
|
|
2045
|
+
return Q(this, (n) => Kt(n, e, t));
|
|
2055
2046
|
}, e.fn.atomChecked = function(e) {
|
|
2056
|
-
return
|
|
2047
|
+
return Q(this, (t) => qt(t, e));
|
|
2057
2048
|
}, e.fn.atomForm = function(e, t = {}) {
|
|
2058
|
-
return
|
|
2049
|
+
return Q(this, (n, r) => {
|
|
2059
2050
|
r instanceof HTMLFormElement && $t(r, e, t);
|
|
2060
2051
|
});
|
|
2061
2052
|
}, e.fn.atomOn = function(e, t) {
|
|
2062
|
-
return
|
|
2053
|
+
return Q(this, (n) => Yt(n, e, t));
|
|
2063
2054
|
};
|
|
2064
2055
|
var en = [
|
|
2065
|
-
(e, t) =>
|
|
2066
|
-
(e, t) =>
|
|
2067
|
-
(e, t) =>
|
|
2068
|
-
(e, t) =>
|
|
2069
|
-
(e, t) =>
|
|
2070
|
-
(e, t) =>
|
|
2071
|
-
(e, t) =>
|
|
2072
|
-
(e, t) =>
|
|
2056
|
+
(e, t) => zt(e, t.text),
|
|
2057
|
+
(e, t) => Bt(e, t.html),
|
|
2058
|
+
(e, t) => Vt(e, t.class),
|
|
2059
|
+
(e, t) => Ht(e, t.css),
|
|
2060
|
+
(e, t) => Ut(e, t.attr),
|
|
2061
|
+
(e, t) => Wt(e, t.prop),
|
|
2062
|
+
(e, t) => Gt(e, t.show, !1),
|
|
2063
|
+
(e, t) => Gt(e, t.hide, !0),
|
|
2073
2064
|
(e, t) => {
|
|
2074
2065
|
let n = t.val;
|
|
2075
|
-
Array.isArray(n) ?
|
|
2066
|
+
Array.isArray(n) ? Kt(e, n[0], n[1]) : Kt(e, n);
|
|
2076
2067
|
},
|
|
2077
|
-
(e, t) =>
|
|
2068
|
+
(e, t) => qt(e, t.checked),
|
|
2078
2069
|
(e, t) => {
|
|
2079
|
-
e.el instanceof HTMLFormElement
|
|
2070
|
+
if (e.el instanceof HTMLFormElement) {
|
|
2071
|
+
let n = t.form;
|
|
2072
|
+
Array.isArray(n) ? $t(e.el, n[0], n[1]) : $t(e.el, n);
|
|
2073
|
+
}
|
|
2080
2074
|
},
|
|
2081
|
-
(e, t) =>
|
|
2075
|
+
(e, t) => Jt(e, t.on)
|
|
2082
2076
|
];
|
|
2083
2077
|
e.fn.atomBind = function(e) {
|
|
2084
2078
|
let t = 0;
|
|
2085
|
-
return e.text !== void 0 && (t |= 1), e.html !== void 0 && (t |= 2), e.class !== void 0 && (t |= 4), e.css !== void 0 && (t |= 8), e.attr !== void 0 && (t |= 16), e.prop !== void 0 && (t |= 32), e.show !== void 0 && (t |= 64), e.hide !== void 0 && (t |= 128), e.val !== void 0 && (t |= 256), e.checked !== void 0 && (t |= 512), e.form !== void 0 && (t |= 1024), e.on !== void 0 && (t |= 2048), t === 0 ? this :
|
|
2079
|
+
return e.text !== void 0 && (t |= 1), e.html !== void 0 && (t |= 2), e.class !== void 0 && (t |= 4), e.css !== void 0 && (t |= 8), e.attr !== void 0 && (t |= 16), e.prop !== void 0 && (t |= 32), e.show !== void 0 && (t |= 64), e.hide !== void 0 && (t |= 128), e.val !== void 0 && (t |= 256), e.checked !== void 0 && (t |= 512), e.form !== void 0 && (t |= 1024), e.on !== void 0 && (t |= 2048), t === 0 ? this : Q(this, (n) => {
|
|
2086
2080
|
let r = t;
|
|
2087
2081
|
for (; r > 0;) {
|
|
2088
2082
|
let t = r & -r;
|
|
@@ -2093,13 +2087,13 @@ e.fn.atomBind = function(e) {
|
|
|
2093
2087
|
let e = this.length;
|
|
2094
2088
|
for (let t = 0; t < e; t++) {
|
|
2095
2089
|
let e = this[t];
|
|
2096
|
-
e?.nodeType === 1 &&
|
|
2090
|
+
e?.nodeType === 1 && Xt(e);
|
|
2097
2091
|
}
|
|
2098
2092
|
return this;
|
|
2099
2093
|
};
|
|
2100
2094
|
//#endregion
|
|
2101
2095
|
//#region src/bindings/list.ts
|
|
2102
|
-
var tn = /* @__PURE__ */ new WeakMap(), nn = 0, rn = new
|
|
2096
|
+
var tn = /* @__PURE__ */ new WeakMap(), nn = 0, rn = new et(() => /* @__PURE__ */ new Map(), (e) => e.clear()), an = new et(() => /* @__PURE__ */ new Set(), (e) => e.clear()), $ = new $e(100, 1024);
|
|
2103
2097
|
function on(e, t, n) {
|
|
2104
2098
|
if (e instanceof Element) {
|
|
2105
2099
|
n.insertBefore(e, t);
|
|
@@ -2111,16 +2105,16 @@ function on(e, t, n) {
|
|
|
2111
2105
|
r && n.insertBefore(r, t);
|
|
2112
2106
|
}
|
|
2113
2107
|
}
|
|
2114
|
-
function
|
|
2108
|
+
function sn(t) {
|
|
2115
2109
|
return t instanceof Element ? e(t) : t;
|
|
2116
2110
|
}
|
|
2117
|
-
var
|
|
2111
|
+
var cn = class {
|
|
2118
2112
|
constructor(e, t, n) {
|
|
2119
2113
|
this.$container = e, this.containerSelector = t, this.onRemove = n, this.oldKeys = [], this.oldItems = [], this.oldNodes = [], this.removingKeys = /* @__PURE__ */ new Set(), this.$emptyEl = null, this.keyToIndex = /* @__PURE__ */ new Map(), this.statesBuffer = new Uint8Array(256), this.indicesBuffer = new Int32Array(256);
|
|
2120
2114
|
}
|
|
2121
2115
|
scheduleRemoval(e, t) {
|
|
2122
2116
|
let n = () => {
|
|
2123
|
-
this.fx?.isDisposed || (t[0]?.isConnected && t.remove(), this.removingKeys.delete(e),
|
|
2117
|
+
this.fx?.isDisposed || (t[0]?.isConnected && t.remove(), this.removingKeys.delete(e), H.log(B.LIST, `${this.containerSelector} removed item:`, e));
|
|
2124
2118
|
}, r = this.onRemove?.(t);
|
|
2125
2119
|
r instanceof Promise ? r.then(n, n) : n();
|
|
2126
2120
|
}
|
|
@@ -2135,21 +2129,21 @@ var sn = class {
|
|
|
2135
2129
|
this.statesBuffer.length < e && (this.statesBuffer = new Uint8Array(Math.max(e, this.statesBuffer.length * 2))), this.indicesBuffer.length < e && (this.indicesBuffer = new Int32Array(Math.max(e, this.indicesBuffer.length * 2)));
|
|
2136
2130
|
}
|
|
2137
2131
|
};
|
|
2138
|
-
function
|
|
2132
|
+
function ln(t, n, r, i) {
|
|
2139
2133
|
if (t.$emptyEl && n > 0 && (t.$emptyEl.remove(), t.$emptyEl = null), n !== 0) return;
|
|
2140
2134
|
let { oldKeys: a, oldNodes: o, onRemove: s } = t;
|
|
2141
2135
|
if (s) for (let e = 0, n = a.length; e < n; e++) {
|
|
2142
2136
|
let n = a[e];
|
|
2143
|
-
o[e] && t.removeItem(n,
|
|
2137
|
+
o[e] && t.removeItem(n, sn(o[e]));
|
|
2144
2138
|
}
|
|
2145
2139
|
else {
|
|
2146
2140
|
for (let e = 0, n = a.length; e < n; e++) t.removingKeys.delete(a[e]);
|
|
2147
2141
|
r.empty();
|
|
2148
2142
|
}
|
|
2149
|
-
i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ?
|
|
2143
|
+
i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ? Z(i) : i), t.$emptyEl.appendTo(r)), $.release(t.oldKeys), $.release(t.oldItems), $.release(t.oldNodes), t.oldKeys = [], t.oldItems = [], t.oldNodes = [];
|
|
2150
2144
|
}
|
|
2151
|
-
function
|
|
2152
|
-
let { oldKeys: o, oldItems: s, oldNodes: c, removingKeys: l, keyToIndex: u } = e, d = o.length, f = 0, p = d - 1, m = n - 1, h = a ||
|
|
2145
|
+
function un(e, t, n, r, i, a) {
|
|
2146
|
+
let { oldKeys: o, oldItems: s, oldNodes: c, removingKeys: l, keyToIndex: u } = e, d = o.length, f = 0, p = d - 1, m = n - 1, h = a || Ie;
|
|
2153
2147
|
for (; f <= p && f <= m;) {
|
|
2154
2148
|
let e = t[f], n = r(e, f);
|
|
2155
2149
|
if (o[f] !== n || !h(s[f], e)) break;
|
|
@@ -2162,58 +2156,58 @@ function ln(e, t, n, r, i, a) {
|
|
|
2162
2156
|
}
|
|
2163
2157
|
let g = rn.acquire();
|
|
2164
2158
|
for (let e = f; e <= p; e++) g.set(o[e], e);
|
|
2165
|
-
let
|
|
2159
|
+
let ee = an.acquire();
|
|
2166
2160
|
e.ensureBuffers(n);
|
|
2167
|
-
let
|
|
2161
|
+
let _ = $.acquire();
|
|
2162
|
+
_.length = n;
|
|
2163
|
+
let v = $.acquire();
|
|
2168
2164
|
v.length = n;
|
|
2169
|
-
let y =
|
|
2165
|
+
let y = $.acquire();
|
|
2170
2166
|
y.length = n;
|
|
2171
|
-
let b =
|
|
2172
|
-
b
|
|
2173
|
-
let
|
|
2174
|
-
for (let e = 0; e < f; e++) v[e] = o[e], y[e] = t[e], b[e] = c[e], x[e] = 3, S[e] = e;
|
|
2175
|
-
for (let e = d - 1, r = n - 1; r > m; r--, e--) v[r] = o[e], y[r] = t[r], b[r] = c[e], x[r] = 3, S[r] = e;
|
|
2167
|
+
let b = e.statesBuffer, x = e.indicesBuffer, S = $.acquire(), C = $.acquire(), w = $.acquire();
|
|
2168
|
+
for (let e = 0; e < f; e++) _[e] = o[e], v[e] = t[e], y[e] = c[e], b[e] = 3, x[e] = e;
|
|
2169
|
+
for (let e = d - 1, r = n - 1; r > m; r--, e--) _[r] = o[e], v[r] = t[r], y[r] = c[e], b[r] = 3, x[r] = e;
|
|
2176
2170
|
for (let n = f; n <= m; n++) {
|
|
2177
2171
|
let o = t[n], d = r(o, n);
|
|
2178
|
-
if (
|
|
2179
|
-
|
|
2172
|
+
if (_[n] = d, v[n] = o, u.set(d, n), ee.has(d)) {
|
|
2173
|
+
H.warn(B.LIST, V.LIST.DUPLICATE_KEY(d, n, e.containerSelector)), x[n] = -1;
|
|
2180
2174
|
continue;
|
|
2181
2175
|
}
|
|
2182
|
-
|
|
2176
|
+
ee.add(d);
|
|
2183
2177
|
let f = g.get(d);
|
|
2184
2178
|
if (f === void 0) {
|
|
2185
|
-
|
|
2179
|
+
S.push(d), C.push(o), w.push(n), x[n] = -1, b[n] = 1;
|
|
2186
2180
|
continue;
|
|
2187
2181
|
}
|
|
2188
2182
|
let p = s[f];
|
|
2189
|
-
|
|
2183
|
+
y[n] = c[f], !i && p !== o && !(a ? a(p, o) : Ie(p, o)) ? (S.push(d), C.push(o), w.push(n), b[n] = 2) : b[n] = 0, x[n] = l.has(d) ? -1 : f;
|
|
2190
2184
|
}
|
|
2191
2185
|
return rn.release(g), {
|
|
2192
|
-
newKeys:
|
|
2193
|
-
newKeySet:
|
|
2194
|
-
newItems:
|
|
2195
|
-
newNodes:
|
|
2196
|
-
newStates:
|
|
2197
|
-
newIndices:
|
|
2198
|
-
trKeys:
|
|
2199
|
-
trItems:
|
|
2200
|
-
trIdxs:
|
|
2186
|
+
newKeys: _,
|
|
2187
|
+
newKeySet: ee,
|
|
2188
|
+
newItems: v,
|
|
2189
|
+
newNodes: y,
|
|
2190
|
+
newStates: b,
|
|
2191
|
+
newIndices: x,
|
|
2192
|
+
trKeys: S,
|
|
2193
|
+
trItems: C,
|
|
2194
|
+
trIdxs: w,
|
|
2201
2195
|
startIndex: f,
|
|
2202
2196
|
oldEndIndex: p,
|
|
2203
2197
|
newEndIndex: m
|
|
2204
2198
|
};
|
|
2205
2199
|
}
|
|
2206
|
-
function
|
|
2200
|
+
function dn(t, n, r) {
|
|
2207
2201
|
let { trKeys: i, trItems: a, trIdxs: o, newNodes: s, newStates: c } = t, l = i.length, u = Array(l), d = [], f = 0;
|
|
2208
2202
|
for (let e = 0; e < l; e++) {
|
|
2209
2203
|
let t = n.render(a[e], o[e]);
|
|
2210
2204
|
u[e] = t, typeof t == "string" && (d.push(t), f++);
|
|
2211
2205
|
}
|
|
2212
2206
|
let p = null;
|
|
2213
|
-
if (d.length > 0) if (d.length === 1) p = [
|
|
2207
|
+
if (d.length > 0) if (d.length === 1) p = [Z(d[0])];
|
|
2214
2208
|
else {
|
|
2215
2209
|
let e = `<template data-atom-sep="${(nn++).toString(36)}"></template>`;
|
|
2216
|
-
p =
|
|
2210
|
+
p = Z(d.join(e)).split(e);
|
|
2217
2211
|
}
|
|
2218
2212
|
if (r && p && f === l && !n.bind && !n.onAdd && !n.onRemove && !n.events) return p;
|
|
2219
2213
|
let m = 0;
|
|
@@ -2225,30 +2219,30 @@ function un(t, n, r) {
|
|
|
2225
2219
|
}
|
|
2226
2220
|
if (c[a] === 2 && s[a]) {
|
|
2227
2221
|
let e = s[a];
|
|
2228
|
-
if (e instanceof Element)
|
|
2222
|
+
if (e instanceof Element) W.cleanupTree(e);
|
|
2229
2223
|
else for (let t = 0, n = e.length; t < n; t++) {
|
|
2230
2224
|
let n = e[t];
|
|
2231
|
-
n instanceof Element &&
|
|
2225
|
+
n instanceof Element && W.cleanupTree(n);
|
|
2232
2226
|
}
|
|
2233
|
-
|
|
2227
|
+
sn(e).replaceWith(r);
|
|
2234
2228
|
}
|
|
2235
2229
|
s[a] = r.length === 1 ? r[0] : r;
|
|
2236
2230
|
}
|
|
2237
2231
|
return null;
|
|
2238
2232
|
}
|
|
2239
|
-
function
|
|
2233
|
+
function fn(e, t) {
|
|
2240
2234
|
let { startIndex: n, oldEndIndex: r, newKeySet: i } = t;
|
|
2241
2235
|
for (let t = n; t <= r; t++) {
|
|
2242
2236
|
let n = e.oldKeys[t];
|
|
2243
|
-
!i.has(n) && e.oldNodes[t] && e.removeItem(n,
|
|
2237
|
+
!i.has(n) && e.oldNodes[t] && e.removeItem(n, sn(e.oldNodes[t]));
|
|
2244
2238
|
}
|
|
2245
2239
|
}
|
|
2246
|
-
function
|
|
2240
|
+
function pn(t, n, r, i, a) {
|
|
2247
2241
|
let { newKeys: o, newItems: s, newNodes: c, newStates: l, newIndices: u } = n, d = o.length;
|
|
2248
2242
|
if (a !== null) {
|
|
2249
2243
|
r.innerHTML = a.join("");
|
|
2250
2244
|
let n = r.firstElementChild;
|
|
2251
|
-
for (let r = 0; r < d && n; r++) n.setAttribute("data-atom-key", String(o[r])), c[r] = n, l[r] = 0, t.removingKeys.delete(o[r]),
|
|
2245
|
+
for (let r = 0; r < d && n; r++) n.setAttribute("data-atom-key", String(o[r])), c[r] = n, l[r] = 0, t.removingKeys.delete(o[r]), H.domUpdated(B.LIST, e(n), "list.add", s[r]), n = n.nextElementSibling;
|
|
2252
2246
|
return;
|
|
2253
2247
|
}
|
|
2254
2248
|
if (t.oldKeys.length === 0) {
|
|
@@ -2271,8 +2265,8 @@ function fn(t, n, r, i, a) {
|
|
|
2271
2265
|
for (let e = 0; e < d; e++) {
|
|
2272
2266
|
let n = l[e];
|
|
2273
2267
|
if (n !== 3) {
|
|
2274
|
-
let r =
|
|
2275
|
-
n === 0 ? i.update?.(r, a, e) : i.bind?.(r, a, e), n === 1 && (i.onAdd?.(r), t.removingKeys.delete(o[e]),
|
|
2268
|
+
let r = sn(c[e]), a = s[e];
|
|
2269
|
+
n === 0 ? i.update?.(r, a, e) : i.bind?.(r, a, e), n === 1 && (i.onAdd?.(r), t.removingKeys.delete(o[e]), H.domUpdated(B.LIST, r, "list.add", a));
|
|
2276
2270
|
}
|
|
2277
2271
|
}
|
|
2278
2272
|
}
|
|
@@ -2289,18 +2283,18 @@ e.fn.atomList = function(t, n) {
|
|
|
2289
2283
|
s.off(".atomList");
|
|
2290
2284
|
let c = tn.get(o);
|
|
2291
2285
|
c && (c.fx.dispose(), c.ctx.dispose());
|
|
2292
|
-
let l = new
|
|
2286
|
+
let l = new cn(s, Fe(o), n.onRemove), u = I(() => {
|
|
2293
2287
|
let e = t.value, a = e.length;
|
|
2294
|
-
|
|
2295
|
-
if (
|
|
2296
|
-
|
|
2297
|
-
let t =
|
|
2298
|
-
if (
|
|
2299
|
-
|
|
2288
|
+
E(() => {
|
|
2289
|
+
if (ln(l, a, s, n.empty), a === 0) return;
|
|
2290
|
+
H.log(B.LIST, `${l.containerSelector} updating with ${a} items`);
|
|
2291
|
+
let t = un(l, e, a, r, n.update, n.isEqual), c = dn(t, n, l.oldKeys.length === 0);
|
|
2292
|
+
if (fn(l, t), pn(l, t, o, i, c), n.events) for (let e = t.startIndex; e <= t.oldEndIndex; e++) t.newKeySet.has(l.oldKeys[e]) || l.keyToIndex.delete(l.oldKeys[e]);
|
|
2293
|
+
$.release(l.oldKeys), $.release(l.oldItems), $.release(l.oldNodes), l.oldKeys = t.newKeys, l.oldItems = t.newItems, l.oldNodes = t.newNodes, an.release(t.newKeySet), $.release(t.trKeys), $.release(t.trItems), $.release(t.trIdxs);
|
|
2300
2294
|
});
|
|
2301
2295
|
});
|
|
2302
2296
|
if (l.fx = u, n.events) for (let e in n.events) {
|
|
2303
|
-
if (!
|
|
2297
|
+
if (!z.call(n.events, e)) continue;
|
|
2304
2298
|
let t = e.indexOf(" "), r = t === -1 ? e : e.slice(0, t), i = t === -1 ? "> *" : e.slice(t + 1).trim(), a = n.events[e];
|
|
2305
2299
|
s.on(`${r}.atomList`, i, function(e) {
|
|
2306
2300
|
let t = e.target.closest?.("[data-atom-key]"), n = t?.getAttribute("data-atom-key");
|
|
@@ -2314,10 +2308,10 @@ e.fn.atomList = function(t, n) {
|
|
|
2314
2308
|
i !== void 0 && a.call(t, l.oldItems[i], i, e);
|
|
2315
2309
|
});
|
|
2316
2310
|
}
|
|
2317
|
-
|
|
2311
|
+
W.trackEffect(o, u), tn.set(o, {
|
|
2318
2312
|
fx: u,
|
|
2319
2313
|
ctx: l
|
|
2320
|
-
}),
|
|
2314
|
+
}), W.trackCleanup(o, () => {
|
|
2321
2315
|
l.dispose(), tn.delete(o);
|
|
2322
2316
|
});
|
|
2323
2317
|
}
|
|
@@ -2325,18 +2319,18 @@ e.fn.atomList = function(t, n) {
|
|
|
2325
2319
|
};
|
|
2326
2320
|
//#endregion
|
|
2327
2321
|
//#region src/bindings/mount.ts
|
|
2328
|
-
var
|
|
2322
|
+
var mn = Object.freeze({});
|
|
2329
2323
|
e.fn.atomMount = function(t, n) {
|
|
2330
|
-
let r = n ??
|
|
2324
|
+
let r = n ?? mn, i = t.name || "Component";
|
|
2331
2325
|
for (let n = 0, a = this.length; n < a; n++) {
|
|
2332
2326
|
let a = this[n];
|
|
2333
2327
|
if (a) {
|
|
2334
|
-
|
|
2328
|
+
W.cleanupTree(a);
|
|
2335
2329
|
try {
|
|
2336
|
-
let n =
|
|
2337
|
-
typeof n == "function" &&
|
|
2330
|
+
let n = E(() => t(e(a), r));
|
|
2331
|
+
typeof n == "function" && W.setComponentCleanup(a, n);
|
|
2338
2332
|
} catch (e) {
|
|
2339
|
-
|
|
2333
|
+
H.error(B.MOUNT, V.MOUNT.ERROR(i), e);
|
|
2340
2334
|
}
|
|
2341
2335
|
}
|
|
2342
2336
|
}
|
|
@@ -2344,42 +2338,42 @@ e.fn.atomMount = function(t, n) {
|
|
|
2344
2338
|
}, e.fn.atomUnmount = function() {
|
|
2345
2339
|
for (let e = 0, t = this.length; e < t; e++) {
|
|
2346
2340
|
let t = this[e];
|
|
2347
|
-
t &&
|
|
2341
|
+
t && Xt(t);
|
|
2348
2342
|
}
|
|
2349
2343
|
return this;
|
|
2350
2344
|
};
|
|
2351
2345
|
//#endregion
|
|
2352
2346
|
//#region src/features/route.ts
|
|
2353
|
-
function
|
|
2347
|
+
function hn(e, t) {
|
|
2354
2348
|
try {
|
|
2355
2349
|
history.pushState(e, "", t);
|
|
2356
2350
|
} catch (e) {
|
|
2357
|
-
|
|
2351
|
+
H.warn(B.ROUTE, "PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.", e);
|
|
2358
2352
|
}
|
|
2359
2353
|
}
|
|
2360
|
-
var
|
|
2354
|
+
var gn = class {
|
|
2361
2355
|
constructor(t) {
|
|
2362
2356
|
this.isDestroyed = !1, this.previousRoute = "", this.cleanups = [], this.templateCache = /* @__PURE__ */ new Map(), this.routeCleanups = [], this.lastRawQuery = "", this.cachedParams = {}, this.config = {
|
|
2363
|
-
mode:
|
|
2364
|
-
basePath:
|
|
2365
|
-
autoBindLinks:
|
|
2366
|
-
activeClass:
|
|
2357
|
+
mode: Le.mode,
|
|
2358
|
+
basePath: Le.basePath,
|
|
2359
|
+
autoBindLinks: Le.autoBindLinks,
|
|
2360
|
+
activeClass: Le.activeClass,
|
|
2367
2361
|
...t
|
|
2368
|
-
}, this.isHistoryMode = this.config.mode === "history", this.basePath = this.config.basePath.replace(/\/$/, ""), this.activeClass = this.config.activeClass, this.$target = e(this.config.target), this.previousUrl = this.isHistoryMode ? location.pathname + location.search : location.hash, this.currentRouteAtom =
|
|
2362
|
+
}, this.isHistoryMode = this.config.mode === "history", this.basePath = this.config.basePath.replace(/\/$/, ""), this.activeClass = this.config.activeClass, this.$target = e(this.config.target), this.previousUrl = this.isHistoryMode ? location.pathname + location.search : location.hash, this.currentRouteAtom = O(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = O(this.getQueryParams()), this.queryParams = F(() => this.queryParamsAtom.value), this.init();
|
|
2369
2363
|
}
|
|
2370
2364
|
init() {
|
|
2371
2365
|
let e = this.isHistoryMode ? "popstate" : "hashchange", t = this.handleUrlChange.bind(this);
|
|
2372
2366
|
window.addEventListener(e, t), this.cleanups.push(() => window.removeEventListener(e, t));
|
|
2373
|
-
let n =
|
|
2367
|
+
let n = I(() => {
|
|
2374
2368
|
let e = this.currentRouteAtom.value;
|
|
2375
|
-
|
|
2369
|
+
E(() => {
|
|
2376
2370
|
for (let e of this.routeCleanups) try {
|
|
2377
2371
|
e();
|
|
2378
2372
|
} catch {}
|
|
2379
2373
|
this.routeCleanups.length = 0;
|
|
2380
2374
|
}), this.renderRoute(e);
|
|
2381
2375
|
});
|
|
2382
|
-
this.cleanups.push(() => n.dispose()), this.setupAutoBindLinks(), this.$target[0] &&
|
|
2376
|
+
this.cleanups.push(() => n.dispose()), this.setupAutoBindLinks(), this.$target[0] && W.trackCleanup(this.$target[0], () => this.destroy());
|
|
2383
2377
|
}
|
|
2384
2378
|
getRouteName() {
|
|
2385
2379
|
let { default: e } = this.config;
|
|
@@ -2410,23 +2404,23 @@ var hn = class {
|
|
|
2410
2404
|
}
|
|
2411
2405
|
setUrl(e) {
|
|
2412
2406
|
let t = this.isHistoryMode ? `${this.basePath}/${e}` : `#${e}`;
|
|
2413
|
-
this.isHistoryMode ?
|
|
2407
|
+
this.isHistoryMode ? hn(null, t) : location.hash = t, this.previousUrl = this.isHistoryMode ? t : location.hash;
|
|
2414
2408
|
}
|
|
2415
2409
|
restoreUrl() {
|
|
2416
|
-
this.isHistoryMode ?
|
|
2410
|
+
this.isHistoryMode ? hn(null, this.previousUrl) : location.hash = this.previousUrl;
|
|
2417
2411
|
}
|
|
2418
2412
|
renderRoute(e) {
|
|
2419
2413
|
if (this.isDestroyed || !this.$target[0]) return;
|
|
2420
2414
|
let { routes: t, notFound: n, beforeTransition: r, afterTransition: i } = this.config, a = t[e] ?? (n ? t[n] : void 0);
|
|
2421
2415
|
if (!a) {
|
|
2422
|
-
|
|
2416
|
+
H.warn(B.ROUTE, V.ROUTE.NOT_FOUND(e));
|
|
2423
2417
|
return;
|
|
2424
2418
|
}
|
|
2425
2419
|
let o = this.getQueryParams(), s = this.previousRoute;
|
|
2426
|
-
r &&
|
|
2420
|
+
r && E(() => r(s, e)), this.$target.empty();
|
|
2427
2421
|
let c = o;
|
|
2428
2422
|
if (a.onEnter) {
|
|
2429
|
-
let e =
|
|
2423
|
+
let e = E(() => a.onEnter(o, this));
|
|
2430
2424
|
e && (c = {
|
|
2431
2425
|
...o,
|
|
2432
2426
|
...e
|
|
@@ -2440,13 +2434,13 @@ var hn = class {
|
|
|
2440
2434
|
let t = document.querySelector(a.template);
|
|
2441
2435
|
if (t instanceof HTMLTemplateElement) e = t, this.templateCache.set(a.template, e);
|
|
2442
2436
|
else {
|
|
2443
|
-
|
|
2437
|
+
H.warn(B.ROUTE, V.ROUTE.TEMPLATE_NOT_FOUND(a.template));
|
|
2444
2438
|
return;
|
|
2445
2439
|
}
|
|
2446
2440
|
}
|
|
2447
2441
|
this.$target.append(e.content.cloneNode(!0)), a.onMount && a.onMount(this.$target.children(), l, this);
|
|
2448
2442
|
}
|
|
2449
|
-
i &&
|
|
2443
|
+
i && E(() => i(s, e)), this.previousRoute = e;
|
|
2450
2444
|
}
|
|
2451
2445
|
handleUrlChange() {
|
|
2452
2446
|
if (this.isDestroyed) return;
|
|
@@ -2454,7 +2448,7 @@ var hn = class {
|
|
|
2454
2448
|
if (e === this.previousUrl) return;
|
|
2455
2449
|
let t = this.getRouteName(), n = this.currentRouteAtom.peek();
|
|
2456
2450
|
if (n !== t) {
|
|
2457
|
-
if (
|
|
2451
|
+
if (E(() => this.config.routes[n]?.onLeave?.(this)) === !1) {
|
|
2458
2452
|
this.restoreUrl();
|
|
2459
2453
|
return;
|
|
2460
2454
|
}
|
|
@@ -2470,9 +2464,9 @@ var hn = class {
|
|
|
2470
2464
|
t != null && this.navigate(t);
|
|
2471
2465
|
};
|
|
2472
2466
|
e(document).on("click", "[data-route]", t), this.cleanups.push(() => e(document).off("click", "[data-route]", t));
|
|
2473
|
-
let n = [], r =
|
|
2467
|
+
let n = [], r = I(() => {
|
|
2474
2468
|
let e = this.currentRouteAtom.value, t = this.activeClass;
|
|
2475
|
-
|
|
2469
|
+
E(() => {
|
|
2476
2470
|
let r = n.length;
|
|
2477
2471
|
for (let e = 0; e < r; e++) {
|
|
2478
2472
|
let r = n[e];
|
|
@@ -2509,13 +2503,13 @@ var hn = class {
|
|
|
2509
2503
|
}
|
|
2510
2504
|
}
|
|
2511
2505
|
};
|
|
2512
|
-
function
|
|
2513
|
-
return new
|
|
2506
|
+
function _n(e) {
|
|
2507
|
+
return new gn(e);
|
|
2514
2508
|
}
|
|
2515
|
-
e.extend({ route:
|
|
2509
|
+
e.extend({ route: _n });
|
|
2516
2510
|
//#endregion
|
|
2517
2511
|
//#region src/features/fetch.ts
|
|
2518
|
-
var
|
|
2512
|
+
var vn = class {
|
|
2519
2513
|
constructor(t, n) {
|
|
2520
2514
|
this.abortController = null, this.execute = async () => {
|
|
2521
2515
|
this.abortController?.abort(), this.abortController = new AbortController();
|
|
@@ -2575,16 +2569,16 @@ var _n = class {
|
|
|
2575
2569
|
//#endregion
|
|
2576
2570
|
//#region src/index.ts
|
|
2577
2571
|
e.extend({ atomFetch(e, t) {
|
|
2578
|
-
let n = new
|
|
2572
|
+
let n = new vn(e, t), r = F(n.execute, {
|
|
2579
2573
|
defaultValue: t.defaultValue,
|
|
2580
2574
|
lazy: t.eager === !1
|
|
2581
2575
|
});
|
|
2582
2576
|
return Object.assign(r, { abort: () => n.abort() });
|
|
2583
2577
|
} }), e(() => {
|
|
2584
|
-
|
|
2578
|
+
dt(), ot(document.body);
|
|
2585
2579
|
});
|
|
2586
|
-
var
|
|
2580
|
+
var yn = e;
|
|
2587
2581
|
//#endregion
|
|
2588
|
-
export {
|
|
2582
|
+
export { yn as default, st as disableAutoCleanup, ft as disablejQueryOverrides, ot as enableAutoCleanup, dt as enablejQueryOverrides, R as isReactive, Qe as nextTick, W as registry };
|
|
2589
2583
|
|
|
2590
2584
|
//# sourceMappingURL=index.mjs.map
|