@but212/atom-effect-jquery 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/atom-effect-jquery.min.js +1 -1
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +407 -386
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var we = Object.defineProperty;
|
|
2
|
+
var ke = (e, t, n) => t in e ? we(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var ct = (e, t, n) => ke(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import h from "jquery";
|
|
5
|
+
import { default as mn } from "jquery";
|
|
3
6
|
const _t = {
|
|
4
7
|
IDLE: "idle",
|
|
5
8
|
PENDING: "pending",
|
|
@@ -8,7 +11,7 @@ const _t = {
|
|
|
8
11
|
}, F = {
|
|
9
12
|
DISPOSED: 1,
|
|
10
13
|
EXECUTING: 8
|
|
11
|
-
},
|
|
14
|
+
}, ne = {
|
|
12
15
|
DISPOSED: 1,
|
|
13
16
|
/** Marker bit: identifies this node as a computed. */
|
|
14
17
|
IS_COMPUTED: 2,
|
|
@@ -19,11 +22,11 @@ const _t = {
|
|
|
19
22
|
REJECTED: 128,
|
|
20
23
|
RECOMPUTING: 256,
|
|
21
24
|
HAS_ERROR: 512
|
|
22
|
-
},
|
|
25
|
+
}, z = {
|
|
23
26
|
DISPOSED: 1,
|
|
24
27
|
SYNC: 8,
|
|
25
28
|
NOTIFICATION_SCHEDULED: 16
|
|
26
|
-
},
|
|
29
|
+
}, K = {
|
|
27
30
|
// Infinite loop protection
|
|
28
31
|
MAX_EXECUTIONS_PER_SECOND: 1e3,
|
|
29
32
|
MAX_EXECUTIONS_PER_EFFECT: 100,
|
|
@@ -32,20 +35,20 @@ const _t = {
|
|
|
32
35
|
MAX_FLUSH_ITERATIONS: 1e3,
|
|
33
36
|
MIN_FLUSH_ITERATIONS: 10,
|
|
34
37
|
BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
|
|
35
|
-
},
|
|
38
|
+
}, De = {
|
|
36
39
|
WARN_INFINITE_LOOP: !0
|
|
37
|
-
}, Ut = 1073741823, R = typeof process < "u" && process.env && process.env.NODE_ENV !== "production" || typeof __DEV__ < "u" && !!__DEV__,
|
|
40
|
+
}, Ut = 1073741823, R = typeof process < "u" && process.env && process.env.NODE_ENV !== "production" || typeof __DEV__ < "u" && !!__DEV__, Te = Object.freeze([]);
|
|
38
41
|
class it extends Error {
|
|
39
42
|
constructor(t, n = null, s = !0) {
|
|
40
43
|
super(t), this.cause = n, this.recoverable = s, this.name = "AtomError";
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
|
-
class
|
|
46
|
+
class H extends it {
|
|
44
47
|
constructor(t, n = null) {
|
|
45
48
|
super(t, n, !0), this.name = "ComputedError";
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
|
-
class
|
|
51
|
+
class W extends it {
|
|
49
52
|
constructor(t, n = null) {
|
|
50
53
|
super(t, n, !1), this.name = "EffectError";
|
|
51
54
|
}
|
|
@@ -55,43 +58,43 @@ class pt extends it {
|
|
|
55
58
|
super(t, n, !1), this.name = "SchedulerError";
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
|
-
const Bt = /* @__PURE__ */ Symbol("AtomEffect.DebugName"),
|
|
59
|
-
function
|
|
61
|
+
const Bt = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), Oe = /* @__PURE__ */ Symbol("AtomEffect.Id"), jt = /* @__PURE__ */ Symbol("AtomEffect.Type"), Tt = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), Ae = (e) => "dependencies" in e && Array.isArray(e.dependencies);
|
|
62
|
+
function se(e, t, n) {
|
|
60
63
|
if (e === t)
|
|
61
|
-
throw new
|
|
64
|
+
throw new H(
|
|
62
65
|
"Circular dependency detected: The computation refers to itself explicitly or implicitly."
|
|
63
66
|
);
|
|
64
|
-
if (!n.has(e.id) && (n.add(e.id),
|
|
67
|
+
if (!n.has(e.id) && (n.add(e.id), Ae(e))) {
|
|
65
68
|
const s = e.dependencies;
|
|
66
69
|
for (let i = 0; i < s.length; i++) {
|
|
67
70
|
const o = s[i];
|
|
68
|
-
o &&
|
|
71
|
+
o && se(o, t, n);
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
|
-
const
|
|
75
|
+
const J = {
|
|
73
76
|
// Dev mode flag
|
|
74
77
|
enabled: R,
|
|
75
|
-
warnInfiniteLoop:
|
|
78
|
+
warnInfiniteLoop: De.WARN_INFINITE_LOOP,
|
|
76
79
|
warn(e, t) {
|
|
77
80
|
R && this.enabled && e && console.warn(`[Atom Effect] ${t}`);
|
|
78
81
|
},
|
|
79
82
|
checkCircular(e, t) {
|
|
80
83
|
if (e === t)
|
|
81
|
-
throw new
|
|
82
|
-
R && this.enabled &&
|
|
84
|
+
throw new H("Direct circular dependency detected");
|
|
85
|
+
R && this.enabled && se(e, t, /* @__PURE__ */ new Set());
|
|
83
86
|
},
|
|
84
87
|
attachDebugInfo(e, t, n) {
|
|
85
88
|
if (!R || !this.enabled) return;
|
|
86
89
|
const s = e;
|
|
87
|
-
s[Bt] = `${t}_${n}`, s[
|
|
90
|
+
s[Bt] = `${t}_${n}`, s[Oe] = n, s[jt] = t;
|
|
88
91
|
},
|
|
89
92
|
getDebugName: (e) => e?.[Bt],
|
|
90
93
|
getDebugType: (e) => e?.[jt]
|
|
91
94
|
};
|
|
92
|
-
let
|
|
93
|
-
const
|
|
94
|
-
function
|
|
95
|
+
let Le = 1;
|
|
96
|
+
const xe = () => Le++;
|
|
97
|
+
function ie(e, t, n) {
|
|
95
98
|
if (typeof t == "function") {
|
|
96
99
|
const i = t;
|
|
97
100
|
for (let o = 0, r = n.length; o < r; o++) {
|
|
@@ -112,7 +115,7 @@ function Kt(e, t, n) {
|
|
|
112
115
|
}
|
|
113
116
|
n.push(new xt(void 0, s));
|
|
114
117
|
}
|
|
115
|
-
function
|
|
118
|
+
function zt(e, t, n) {
|
|
116
119
|
const s = /* @__PURE__ */ new Map();
|
|
117
120
|
for (let i = 0, o = t.length; i < o; i++) {
|
|
118
121
|
const r = t[i];
|
|
@@ -122,7 +125,7 @@ function Ht(e, t, n) {
|
|
|
122
125
|
const r = e[i];
|
|
123
126
|
if (!r) continue;
|
|
124
127
|
const c = r.node, a = s.get(c);
|
|
125
|
-
a !== void 0 ? (r.unsub = a, s.delete(c)) : (
|
|
128
|
+
a !== void 0 ? (r.unsub = a, s.delete(c)) : (J.checkCircular(c, n), r.unsub = c.subscribe(n));
|
|
126
129
|
}
|
|
127
130
|
for (const i of s.values())
|
|
128
131
|
i();
|
|
@@ -166,12 +169,12 @@ function st(e, t, n) {
|
|
|
166
169
|
const s = e instanceof Error, i = s ? e.message : String(e), o = s ? e : void 0, r = `${s ? e.constructor.name : "Unexpected error"} (${n}): ${i}`;
|
|
167
170
|
return new t(r, o);
|
|
168
171
|
}
|
|
169
|
-
class
|
|
172
|
+
class oe {
|
|
170
173
|
constructor() {
|
|
171
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id =
|
|
174
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id = xe() & Ut;
|
|
172
175
|
}
|
|
173
176
|
}
|
|
174
|
-
class
|
|
177
|
+
class re extends oe {
|
|
175
178
|
/**
|
|
176
179
|
* Adds subscriber.
|
|
177
180
|
*/
|
|
@@ -224,17 +227,17 @@ class Zt extends Jt {
|
|
|
224
227
|
}
|
|
225
228
|
let Ot = 0;
|
|
226
229
|
const Ft = () => (Ot = Ot + 1 & Ut || 1, Ot), Nt = (e) => e + 1 & Ut;
|
|
227
|
-
let Pt = 0, vt = !1,
|
|
228
|
-
const
|
|
229
|
-
function
|
|
230
|
-
return vt ? (R && console.warn("startFlush() called during flush - ignored"), !1) : (vt = !0,
|
|
230
|
+
let Pt = 0, vt = !1, ce = 0;
|
|
231
|
+
const Ne = () => ce;
|
|
232
|
+
function Ht() {
|
|
233
|
+
return vt ? (R && console.warn("startFlush() called during flush - ignored"), !1) : (vt = !0, ce = Ft(), Pt = 0, !0);
|
|
231
234
|
}
|
|
232
235
|
const Vt = () => {
|
|
233
236
|
vt = !1;
|
|
234
|
-
},
|
|
235
|
-
class
|
|
237
|
+
}, Re = () => vt ? ++Pt : 0;
|
|
238
|
+
class Ue {
|
|
236
239
|
constructor() {
|
|
237
|
-
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isBatching = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations =
|
|
240
|
+
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isBatching = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = K.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
|
|
238
241
|
}
|
|
239
242
|
get phase() {
|
|
240
243
|
return this._isProcessing || this._isFlushingSync ? 2 : this._isBatching ? 1 : 0;
|
|
@@ -271,7 +274,7 @@ class Ie {
|
|
|
271
274
|
_runLoop() {
|
|
272
275
|
try {
|
|
273
276
|
if (this._size === 0) return;
|
|
274
|
-
const t =
|
|
277
|
+
const t = Ht();
|
|
275
278
|
this._drainQueue(), t && Vt();
|
|
276
279
|
} finally {
|
|
277
280
|
this._isProcessing = !1, this._size > 0 && !this._isBatching && this._flush();
|
|
@@ -279,7 +282,7 @@ class Ie {
|
|
|
279
282
|
}
|
|
280
283
|
_flushSync() {
|
|
281
284
|
this._isFlushingSync = !0;
|
|
282
|
-
const t =
|
|
285
|
+
const t = Ht();
|
|
283
286
|
try {
|
|
284
287
|
this._mergeBatchQueue(), this._drainQueue();
|
|
285
288
|
} finally {
|
|
@@ -294,7 +297,7 @@ class Ie {
|
|
|
294
297
|
const r = n[o];
|
|
295
298
|
r._nextEpoch !== t && (r._nextEpoch = t, s[i++] = r);
|
|
296
299
|
}
|
|
297
|
-
this._size = i, this._batchQueueSize = 0, n.length >
|
|
300
|
+
this._size = i, this._batchQueueSize = 0, n.length > K.BATCH_QUEUE_SHRINK_THRESHOLD && (n.length = 0);
|
|
298
301
|
}
|
|
299
302
|
_drainQueue() {
|
|
300
303
|
let t = 0;
|
|
@@ -340,14 +343,14 @@ class Ie {
|
|
|
340
343
|
--this._batchDepth === 0 && (this._flushSync(), this._isBatching = !1);
|
|
341
344
|
}
|
|
342
345
|
setMaxFlushIterations(t) {
|
|
343
|
-
if (t <
|
|
346
|
+
if (t < K.MIN_FLUSH_ITERATIONS)
|
|
344
347
|
throw new pt(
|
|
345
|
-
`Max flush iterations must be at least ${
|
|
348
|
+
`Max flush iterations must be at least ${K.MIN_FLUSH_ITERATIONS}`
|
|
346
349
|
);
|
|
347
350
|
this._maxFlushIterations = t;
|
|
348
351
|
}
|
|
349
352
|
}
|
|
350
|
-
const
|
|
353
|
+
const ht = new Ue(), Mt = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ae = /* @__PURE__ */ Symbol.for("atom-effect/computed"), Fe = /* @__PURE__ */ Symbol.for("atom-effect/effect"), M = {
|
|
351
354
|
/** Active listener. */
|
|
352
355
|
current: null,
|
|
353
356
|
/**
|
|
@@ -367,7 +370,7 @@ const lt = new Ie(), M = {
|
|
|
367
370
|
}
|
|
368
371
|
}
|
|
369
372
|
};
|
|
370
|
-
function
|
|
373
|
+
function Pe(e) {
|
|
371
374
|
const t = M.current;
|
|
372
375
|
if (t === null) return e();
|
|
373
376
|
M.current = null;
|
|
@@ -377,25 +380,26 @@ function Se(e) {
|
|
|
377
380
|
M.current = t;
|
|
378
381
|
}
|
|
379
382
|
}
|
|
380
|
-
|
|
383
|
+
var qt, Xt;
|
|
384
|
+
class Me extends (Xt = re, qt = Mt, Xt) {
|
|
381
385
|
constructor(t, n) {
|
|
382
|
-
super(), this._pendingOldValue = void 0, this._notifyTask = void 0, this._subscribers = [], this._value = t, n && (this.flags |=
|
|
386
|
+
super(), this._pendingOldValue = void 0, this._notifyTask = void 0, this._subscribers = [], this[qt] = !0, this._value = t, n && (this.flags |= z.SYNC), J.attachDebugInfo(this, "atom", this.id);
|
|
383
387
|
}
|
|
384
388
|
get value() {
|
|
385
389
|
const t = M.current;
|
|
386
|
-
return t &&
|
|
390
|
+
return t && ie(this, t, this._subscribers), this._value;
|
|
387
391
|
}
|
|
388
392
|
set value(t) {
|
|
389
393
|
const n = this._value;
|
|
390
394
|
if (Object.is(n, t)) return;
|
|
391
395
|
this._value = t, this.version = Nt(this.version);
|
|
392
396
|
const s = this.flags;
|
|
393
|
-
if (!(this._subscribers.length === 0 || s &
|
|
394
|
-
if (this._pendingOldValue = n, this.flags = s |
|
|
397
|
+
if (!(this._subscribers.length === 0 || s & z.NOTIFICATION_SCHEDULED)) {
|
|
398
|
+
if (this._pendingOldValue = n, this.flags = s | z.NOTIFICATION_SCHEDULED, s & z.SYNC && !ht.isBatching) {
|
|
395
399
|
this._flushNotifications();
|
|
396
400
|
return;
|
|
397
401
|
}
|
|
398
|
-
this._notifyTask || (this._notifyTask = () => this._flushNotifications()),
|
|
402
|
+
this._notifyTask || (this._notifyTask = () => this._flushNotifications()), ht.schedule(this._notifyTask);
|
|
399
403
|
}
|
|
400
404
|
}
|
|
401
405
|
/**
|
|
@@ -403,7 +407,7 @@ class ve extends Zt {
|
|
|
403
407
|
*/
|
|
404
408
|
_flushNotifications() {
|
|
405
409
|
const t = this.flags;
|
|
406
|
-
if (!(t &
|
|
410
|
+
if (!(t & z.NOTIFICATION_SCHEDULED) || t & z.DISPOSED)
|
|
407
411
|
return;
|
|
408
412
|
const n = this._pendingOldValue;
|
|
409
413
|
this._pendingOldValue = void 0, this.flags &= -17, this._notifySubscribers(this._value, n);
|
|
@@ -412,13 +416,13 @@ class ve extends Zt {
|
|
|
412
416
|
return this._value;
|
|
413
417
|
}
|
|
414
418
|
dispose() {
|
|
415
|
-
this.flags &
|
|
419
|
+
this.flags & z.DISPOSED || (this._subscribers.length = 0, this.flags |= z.DISPOSED, this._value = void 0, this._pendingOldValue = void 0, this._notifyTask = void 0);
|
|
416
420
|
}
|
|
417
421
|
}
|
|
418
|
-
function
|
|
419
|
-
return new
|
|
422
|
+
function ue(e, t = {}) {
|
|
423
|
+
return new Me(e, t.sync ?? !1);
|
|
420
424
|
}
|
|
421
|
-
class
|
|
425
|
+
class $e {
|
|
422
426
|
/**
|
|
423
427
|
* @param limit - Max unique arrays to hold (default: 50). Prevents the pool itself from consuming too much memory.
|
|
424
428
|
* @param capacity - Max length of an array to accept (default: 256).
|
|
@@ -487,26 +491,27 @@ class we {
|
|
|
487
491
|
}
|
|
488
492
|
const P = Object.freeze(
|
|
489
493
|
[]
|
|
490
|
-
), V = new
|
|
491
|
-
function
|
|
492
|
-
return e !== null && typeof e == "object" &&
|
|
494
|
+
), V = new $e();
|
|
495
|
+
function le(e) {
|
|
496
|
+
return e !== null && typeof e == "object" && Mt in e;
|
|
493
497
|
}
|
|
494
|
-
function
|
|
495
|
-
return
|
|
498
|
+
function he(e) {
|
|
499
|
+
return e !== null && typeof e == "object" && ae in e;
|
|
496
500
|
}
|
|
497
|
-
function
|
|
501
|
+
function fe(e) {
|
|
498
502
|
return e !== null && typeof e == "object" && typeof e.then == "function";
|
|
499
503
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
504
|
+
var Qt, Gt, Wt;
|
|
505
|
+
const Be = 3, je = Number.MAX_SAFE_INTEGER - 1, { IDLE: Et, DIRTY: nt, PENDING: Ct, RESOLVED: Y, REJECTED: ut, HAS_ERROR: gt, RECOMPUTING: at, DISPOSED: At, IS_COMPUTED: ze } = ne;
|
|
506
|
+
function He(e) {
|
|
507
|
+
return e & Y ? _t.RESOLVED : e & Ct ? _t.PENDING : e & ut ? _t.REJECTED : _t.IDLE;
|
|
503
508
|
}
|
|
504
|
-
class
|
|
509
|
+
class Ve extends (Wt = re, Gt = Mt, Qt = ae, Wt) {
|
|
505
510
|
constructor(t, n = {}) {
|
|
506
|
-
if (typeof t != "function") throw new
|
|
507
|
-
super(), this._error = null, this._promiseId = 0, this._subscribers = [], this._links = P, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._trackEpoch = -1, this._trackLinks = P, this._trackCount = 0, this._value = void 0, this.flags =
|
|
511
|
+
if (typeof t != "function") throw new H(S.COMPUTED_MUST_BE_FUNCTION);
|
|
512
|
+
super(), this[Gt] = !0, this[Qt] = !0, this._error = null, this._promiseId = 0, this._subscribers = [], this._links = P, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._trackEpoch = -1, this._trackLinks = P, this._trackCount = 0, this._value = void 0, this.flags = ze | nt | Et, this._equal = n.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in n ? n.defaultValue : Tt, this._onError = n.onError ?? null;
|
|
508
513
|
const s = n.maxAsyncRetries;
|
|
509
|
-
if (this._maxAsyncRetries = s != null && s >= 0 ? s :
|
|
514
|
+
if (this._maxAsyncRetries = s != null && s >= 0 ? s : Be, J.attachDebugInfo(this, "computed", this.id), n.lazy === !1)
|
|
510
515
|
try {
|
|
511
516
|
this._recompute();
|
|
512
517
|
} catch {
|
|
@@ -514,27 +519,27 @@ class Ae extends Zt {
|
|
|
514
519
|
}
|
|
515
520
|
_track() {
|
|
516
521
|
const t = M.current;
|
|
517
|
-
t &&
|
|
522
|
+
t && ie(this, t, this._subscribers);
|
|
518
523
|
}
|
|
519
524
|
get value() {
|
|
520
525
|
this._track();
|
|
521
526
|
const t = this.flags;
|
|
522
|
-
if ((t & (
|
|
527
|
+
if ((t & (Y | nt | Et)) === Y)
|
|
523
528
|
return this._value;
|
|
524
529
|
if (t & At)
|
|
525
|
-
throw new
|
|
526
|
-
if (t &
|
|
530
|
+
throw new H(S.COMPUTED_DISPOSED);
|
|
531
|
+
if (t & at) {
|
|
527
532
|
if (this._defaultValue !== Tt) return this._defaultValue;
|
|
528
|
-
throw new
|
|
533
|
+
throw new H(S.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
529
534
|
}
|
|
530
|
-
if (t & (nt | Et) && (this._recompute(), this.flags &
|
|
535
|
+
if (t & (nt | Et) && (this._recompute(), this.flags & Y))
|
|
531
536
|
return this._value;
|
|
532
537
|
const n = this._defaultValue, s = n !== Tt;
|
|
533
538
|
if (this.flags & Ct) {
|
|
534
539
|
if (s) return n;
|
|
535
|
-
throw new
|
|
540
|
+
throw new H(S.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
536
541
|
}
|
|
537
|
-
if (this.flags &
|
|
542
|
+
if (this.flags & ut) {
|
|
538
543
|
if (this._error?.recoverable && s) return n;
|
|
539
544
|
throw this._error;
|
|
540
545
|
}
|
|
@@ -544,10 +549,10 @@ class Ae extends Zt {
|
|
|
544
549
|
return this._value;
|
|
545
550
|
}
|
|
546
551
|
get state() {
|
|
547
|
-
return this._track(),
|
|
552
|
+
return this._track(), He(this.flags);
|
|
548
553
|
}
|
|
549
554
|
get hasError() {
|
|
550
|
-
if (this._track(), this.flags & (
|
|
555
|
+
if (this._track(), this.flags & (ut | gt)) return !0;
|
|
551
556
|
const t = this._links;
|
|
552
557
|
for (let n = 0, s = t.length; n < s; n++) {
|
|
553
558
|
const i = t[n]?.node;
|
|
@@ -559,7 +564,7 @@ class Ae extends Zt {
|
|
|
559
564
|
return !this.hasError;
|
|
560
565
|
}
|
|
561
566
|
get errors() {
|
|
562
|
-
if (this._track(), !this.hasError) return
|
|
567
|
+
if (this._track(), !this.hasError) return Te;
|
|
563
568
|
const t = [];
|
|
564
569
|
this._error && t.push(this._error);
|
|
565
570
|
const n = this._links;
|
|
@@ -570,8 +575,8 @@ class Ae extends Zt {
|
|
|
570
575
|
if (r.errors) {
|
|
571
576
|
const c = r.errors;
|
|
572
577
|
for (let a = 0; a < c.length; a++) {
|
|
573
|
-
const
|
|
574
|
-
|
|
578
|
+
const l = c[a];
|
|
579
|
+
l && t.indexOf(l) === -1 && t.push(l);
|
|
575
580
|
}
|
|
576
581
|
}
|
|
577
582
|
}
|
|
@@ -585,7 +590,7 @@ class Ae extends Zt {
|
|
|
585
590
|
return this._track(), (this.flags & Ct) !== 0;
|
|
586
591
|
}
|
|
587
592
|
get isResolved() {
|
|
588
|
-
return this._track(), (this.flags &
|
|
593
|
+
return this._track(), (this.flags & Y) !== 0;
|
|
589
594
|
}
|
|
590
595
|
invalidate() {
|
|
591
596
|
this._markDirty();
|
|
@@ -611,35 +616,35 @@ class Ae extends Zt {
|
|
|
611
616
|
}
|
|
612
617
|
}
|
|
613
618
|
_recompute() {
|
|
614
|
-
if (this.flags &
|
|
615
|
-
this.flags |=
|
|
619
|
+
if (this.flags & at) return;
|
|
620
|
+
this.flags |= at;
|
|
616
621
|
const t = this._links;
|
|
617
622
|
this._trackEpoch = Ft(), this._trackLinks = V.acquire(), this._trackCount = 0;
|
|
618
623
|
let n = !1;
|
|
619
624
|
try {
|
|
620
625
|
const s = M.run(this, this._fn);
|
|
621
|
-
this._trackLinks.length = this._trackCount,
|
|
626
|
+
this._trackLinks.length = this._trackCount, zt(this._trackLinks, t, this), this._links = this._trackLinks, n = !0, fe(s) ? this._handleAsyncComputation(s) : this._finalizeResolution(s);
|
|
622
627
|
} catch (s) {
|
|
623
628
|
if (!n)
|
|
624
629
|
try {
|
|
625
|
-
this._trackLinks.length = this._trackCount,
|
|
630
|
+
this._trackLinks.length = this._trackCount, zt(this._trackLinks, t, this), this._links = this._trackLinks, n = !0;
|
|
626
631
|
} catch (i) {
|
|
627
632
|
R && console.warn("[atom-effect] _commitDeps failed during error recovery:", i);
|
|
628
633
|
}
|
|
629
634
|
this._handleError(s, S.COMPUTED_COMPUTATION_FAILED, !0);
|
|
630
635
|
} finally {
|
|
631
|
-
n && t !== P ? V.release(t) : n || V.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = P, this._trackCount = 0, this.flags &= ~
|
|
636
|
+
n && t !== P ? V.release(t) : n || V.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = P, this._trackCount = 0, this.flags &= ~at;
|
|
632
637
|
}
|
|
633
638
|
}
|
|
634
639
|
_handleAsyncComputation(t) {
|
|
635
|
-
this.flags = (this.flags | Ct) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) %
|
|
640
|
+
this.flags = (this.flags | Ct) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % je;
|
|
636
641
|
const n = this._promiseId;
|
|
637
642
|
t.then(
|
|
638
643
|
(s) => {
|
|
639
644
|
if (n === this._promiseId) {
|
|
640
645
|
if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion)
|
|
641
646
|
return this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(
|
|
642
|
-
new
|
|
647
|
+
new H(
|
|
643
648
|
`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`
|
|
644
649
|
),
|
|
645
650
|
S.COMPUTED_ASYNC_COMPUTATION_FAILED
|
|
@@ -654,12 +659,12 @@ class Ae extends Zt {
|
|
|
654
659
|
let t = 0;
|
|
655
660
|
const n = this._links;
|
|
656
661
|
for (let s = 0, i = n.length; s < i; s++)
|
|
657
|
-
t
|
|
662
|
+
t = (t << 5) - t + n[s].node.version | 0;
|
|
658
663
|
return t;
|
|
659
664
|
}
|
|
660
665
|
_handleError(t, n, s = !1) {
|
|
661
|
-
const i = st(t,
|
|
662
|
-
if (!s && !(this.flags &
|
|
666
|
+
const i = st(t, H, n);
|
|
667
|
+
if (!s && !(this.flags & ut) && (this.version = Nt(this.version)), this._error = i, this.flags = this.flags & -121 | ut | gt, this._onError)
|
|
663
668
|
try {
|
|
664
669
|
this._onError(i);
|
|
665
670
|
} catch (o) {
|
|
@@ -669,26 +674,27 @@ class Ae extends Zt {
|
|
|
669
674
|
this._notifySubscribers(void 0, void 0);
|
|
670
675
|
}
|
|
671
676
|
_finalizeResolution(t) {
|
|
672
|
-
(!(this.flags &
|
|
677
|
+
(!(this.flags & Y) || !this._equal(this._value, t)) && (this.version = Nt(this.version)), this._value = t, this._error = null, this.flags = (this.flags | Y) & -697;
|
|
673
678
|
}
|
|
674
679
|
execute() {
|
|
675
680
|
this._markDirty();
|
|
676
681
|
}
|
|
677
682
|
/** @internal */
|
|
678
683
|
_markDirty() {
|
|
679
|
-
this.flags & (
|
|
684
|
+
this.flags & (at | nt) || (this.flags |= nt, this._notifySubscribers(void 0, void 0));
|
|
680
685
|
}
|
|
681
686
|
}
|
|
682
|
-
function
|
|
683
|
-
return new
|
|
687
|
+
function de(e, t = {}) {
|
|
688
|
+
return new Ve(e, t);
|
|
684
689
|
}
|
|
685
|
-
|
|
690
|
+
var Yt, Kt;
|
|
691
|
+
class qe extends (Kt = oe, Yt = Fe, Kt) {
|
|
686
692
|
constructor(t, n = {}) {
|
|
687
|
-
super(), this._cleanup = null, this._links = P, this._nextLinks = null, this._prevLinks = null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._fn = t, this._onError = n.onError ?? null, this._sync = n.sync ?? !1, this._maxExecutions = n.maxExecutionsPerSecond ??
|
|
693
|
+
super(), this[Yt] = !0, this._cleanup = null, this._links = P, this._nextLinks = null, this._prevLinks = null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._fn = t, this._onError = n.onError ?? null, this._sync = n.sync ?? !1, this._maxExecutions = n.maxExecutionsPerSecond ?? K.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = n.maxExecutionsPerFlush ?? K.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = n.trackModifications ?? !1, J.attachDebugInfo(this, "effect", this.id);
|
|
688
694
|
}
|
|
689
695
|
run() {
|
|
690
696
|
if (this.flags & F.DISPOSED)
|
|
691
|
-
throw new
|
|
697
|
+
throw new W(S.EFFECT_DISPOSED);
|
|
692
698
|
this.execute(!0);
|
|
693
699
|
}
|
|
694
700
|
dispose() {
|
|
@@ -709,11 +715,11 @@ class xe extends Jt {
|
|
|
709
715
|
try {
|
|
710
716
|
const i = t.subscribe(() => {
|
|
711
717
|
if (this._trackModifications && this.flags & F.EXECUTING && (t._modifiedAtEpoch = this._currentEpoch), this._sync) return this.execute();
|
|
712
|
-
this._executeTask
|
|
718
|
+
this._executeTask ??= () => this.execute(), ht.schedule(this._executeTask);
|
|
713
719
|
});
|
|
714
720
|
n.push(new bt(t, t.version, i));
|
|
715
721
|
} catch (i) {
|
|
716
|
-
const o = st(i,
|
|
722
|
+
const o = st(i, W, S.EFFECT_EXECUTION_FAILED);
|
|
717
723
|
if (console.error(o), this._onError)
|
|
718
724
|
try {
|
|
719
725
|
this._onError(o);
|
|
@@ -735,17 +741,17 @@ class xe extends Jt {
|
|
|
735
741
|
let i = !1;
|
|
736
742
|
try {
|
|
737
743
|
const o = M.run(this, this._fn);
|
|
738
|
-
if (this._links = s, i = !0, this._trackModifications &&
|
|
744
|
+
if (this._links = s, i = !0, this._trackModifications && J.enabled) {
|
|
739
745
|
const r = this._currentEpoch;
|
|
740
746
|
for (let c = 0, a = s.length; c < a; c++) {
|
|
741
|
-
const
|
|
742
|
-
|
|
747
|
+
const l = s[c].node;
|
|
748
|
+
l._modifiedAtEpoch === r && J.warn(
|
|
743
749
|
!0,
|
|
744
|
-
`Effect is reading a dependency (${
|
|
750
|
+
`Effect is reading a dependency (${J.getDebugName(l) || "unknown"}) that it just modified. Infinite loop may occur`
|
|
745
751
|
);
|
|
746
752
|
}
|
|
747
753
|
}
|
|
748
|
-
|
|
754
|
+
fe(o) ? this._handleAsyncResult(o) : this._cleanup = typeof o == "function" ? o : null;
|
|
749
755
|
} catch (o) {
|
|
750
756
|
i = !0, this._handleExecutionError(o), this._cleanup = null;
|
|
751
757
|
} finally {
|
|
@@ -791,7 +797,7 @@ class xe extends Jt {
|
|
|
791
797
|
try {
|
|
792
798
|
for (let s = 0, i = t.length; s < i; s++) {
|
|
793
799
|
const o = t[s], r = o.node;
|
|
794
|
-
if (r.flags &
|
|
800
|
+
if (r.flags & ne.IS_COMPUTED)
|
|
795
801
|
try {
|
|
796
802
|
r.value;
|
|
797
803
|
} catch {
|
|
@@ -815,13 +821,13 @@ class xe extends Jt {
|
|
|
815
821
|
}
|
|
816
822
|
}
|
|
817
823
|
_checkInfiniteLoops() {
|
|
818
|
-
const t =
|
|
819
|
-
if (this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
824
|
+
const t = Ne();
|
|
825
|
+
if (this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), Re() > K.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, R && Number.isFinite(this._maxExecutions)) {
|
|
820
826
|
const n = Date.now();
|
|
821
827
|
if (n - this._windowStart >= 1e3)
|
|
822
828
|
this._windowStart = n, this._windowCount = 1;
|
|
823
829
|
else if (++this._windowCount > this._maxExecutions) {
|
|
824
|
-
const s = new
|
|
830
|
+
const s = new W(S.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
|
|
825
831
|
throw this.dispose(), this._handleExecutionError(s), s;
|
|
826
832
|
}
|
|
827
833
|
}
|
|
@@ -836,39 +842,39 @@ class xe extends Jt {
|
|
|
836
842
|
return (this.flags & F.EXECUTING) !== 0;
|
|
837
843
|
}
|
|
838
844
|
_throwInfiniteLoopError(t) {
|
|
839
|
-
const n = new
|
|
845
|
+
const n = new W(
|
|
840
846
|
`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Pt}`
|
|
841
847
|
);
|
|
842
848
|
throw this.dispose(), console.error(n), n;
|
|
843
849
|
}
|
|
844
850
|
_handleExecutionError(t, n = S.EFFECT_EXECUTION_FAILED) {
|
|
845
|
-
const s = st(t,
|
|
851
|
+
const s = st(t, W, n);
|
|
846
852
|
if (console.error(s), this._onError)
|
|
847
853
|
try {
|
|
848
854
|
this._onError(s);
|
|
849
855
|
} catch (i) {
|
|
850
|
-
console.error(st(i,
|
|
856
|
+
console.error(st(i, W, S.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
851
857
|
}
|
|
852
858
|
}
|
|
853
859
|
}
|
|
854
|
-
function
|
|
860
|
+
function Z(e, t = {}) {
|
|
855
861
|
if (typeof e != "function")
|
|
856
|
-
throw new
|
|
857
|
-
const n = new
|
|
862
|
+
throw new W(S.EFFECT_MUST_BE_FUNCTION);
|
|
863
|
+
const n = new qe(e, t);
|
|
858
864
|
return n.execute(), n;
|
|
859
865
|
}
|
|
860
866
|
function $t(e) {
|
|
861
867
|
if (typeof e != "function")
|
|
862
868
|
throw new TypeError("Batch callback must be a function");
|
|
863
|
-
|
|
869
|
+
ht.startBatch();
|
|
864
870
|
try {
|
|
865
871
|
return e();
|
|
866
872
|
} finally {
|
|
867
|
-
|
|
873
|
+
ht.endBatch();
|
|
868
874
|
}
|
|
869
875
|
}
|
|
870
|
-
function
|
|
871
|
-
return
|
|
876
|
+
function _e(e) {
|
|
877
|
+
return le(e) || he(e);
|
|
872
878
|
}
|
|
873
879
|
function Dt(e) {
|
|
874
880
|
if (!e) return "unknown";
|
|
@@ -900,7 +906,7 @@ function It(e) {
|
|
|
900
906
|
const o = /data\s*:\s*(?:text\/html|application\/javascript|text\/javascript|text\/vbscript|text\/xml|application\/xhtml\+xml)/gim;
|
|
901
907
|
return t = t.replace(o, "data-unsafe-protocol:"), t = t.replace(/\bon\w+\s*=/gim, "data-unsafe-attr="), t = t.replace(/expression\s*\(/gim, "data-unsafe-css(").replace(/behavior\s*:/gim, "data-unsafe-css:"), t;
|
|
902
908
|
}
|
|
903
|
-
const
|
|
909
|
+
const Xe = /* @__PURE__ */ new Set([
|
|
904
910
|
"href",
|
|
905
911
|
"src",
|
|
906
912
|
"action",
|
|
@@ -916,14 +922,14 @@ const Ne = /* @__PURE__ */ new Set([
|
|
|
916
922
|
"usemap",
|
|
917
923
|
"classid",
|
|
918
924
|
"codebase"
|
|
919
|
-
]),
|
|
920
|
-
function
|
|
921
|
-
return
|
|
925
|
+
]), Qe = /^\s*(?:javascript|vbscript)\s*:/i;
|
|
926
|
+
function Ge(e, t) {
|
|
927
|
+
return Xe.has(e.toLowerCase()) ? Qe.test(t) : !1;
|
|
922
928
|
}
|
|
923
|
-
function
|
|
929
|
+
function We(e) {
|
|
924
930
|
return e.toLowerCase().includes("url(") ? /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i.test(e) : !1;
|
|
925
931
|
}
|
|
926
|
-
function
|
|
932
|
+
function Ye(e, t) {
|
|
927
933
|
if (e === t) return !0;
|
|
928
934
|
if (typeof e != "object" || e === null || typeof t != "object" || t === null) return !1;
|
|
929
935
|
const n = Object.keys(e), s = Object.keys(t);
|
|
@@ -935,7 +941,7 @@ function Pe(e, t) {
|
|
|
935
941
|
}
|
|
936
942
|
return !0;
|
|
937
943
|
}
|
|
938
|
-
function
|
|
944
|
+
function Ke(e) {
|
|
939
945
|
const t = e.length;
|
|
940
946
|
if (t === 0) return new Int32Array(0);
|
|
941
947
|
const n = new Int32Array(t), s = new Int32Array(t);
|
|
@@ -948,13 +954,13 @@ function Me(e) {
|
|
|
948
954
|
n[r] = a ?? -1, s[i++] = r;
|
|
949
955
|
continue;
|
|
950
956
|
}
|
|
951
|
-
let
|
|
952
|
-
for (;
|
|
953
|
-
const b =
|
|
954
|
-
T !== void 0 && (e[T] ?? -1) < c ?
|
|
957
|
+
let l = 0, p = i - 1;
|
|
958
|
+
for (; l < p; ) {
|
|
959
|
+
const b = l + p >>> 1, T = s[b];
|
|
960
|
+
T !== void 0 && (e[T] ?? -1) < c ? l = b + 1 : p = b;
|
|
955
961
|
}
|
|
956
|
-
const C = s[
|
|
957
|
-
C !== void 0 && c < (e[C] ?? Number.MAX_SAFE_INTEGER) && (
|
|
962
|
+
const C = s[l];
|
|
963
|
+
C !== void 0 && c < (e[C] ?? Number.MAX_SAFE_INTEGER) && (l > 0 && (n[r] = s[l - 1] ?? -1), s[l] = r);
|
|
958
964
|
}
|
|
959
965
|
const o = new Int32Array(i);
|
|
960
966
|
if (i > 0) {
|
|
@@ -964,26 +970,26 @@ function Me(e) {
|
|
|
964
970
|
}
|
|
965
971
|
return o;
|
|
966
972
|
}
|
|
967
|
-
function
|
|
973
|
+
function Je() {
|
|
968
974
|
if (typeof window < "u") {
|
|
969
975
|
const e = window.__ATOM_DEBUG__;
|
|
970
976
|
if (typeof e == "boolean") return e;
|
|
971
977
|
}
|
|
972
978
|
return !1;
|
|
973
979
|
}
|
|
974
|
-
let
|
|
980
|
+
let G = Je();
|
|
975
981
|
const m = {
|
|
976
982
|
get enabled() {
|
|
977
|
-
return
|
|
983
|
+
return G;
|
|
978
984
|
},
|
|
979
985
|
set enabled(e) {
|
|
980
|
-
|
|
986
|
+
G = e;
|
|
981
987
|
},
|
|
982
988
|
log(e, ...t) {
|
|
983
|
-
|
|
989
|
+
G && console.log(`[atom-effect-jquery] ${e}:`, ...t);
|
|
984
990
|
},
|
|
985
991
|
atomChanged(e, t, n) {
|
|
986
|
-
|
|
992
|
+
G && console.log(
|
|
987
993
|
`[atom-effect-jquery] Atom "${e ?? "anonymous"}" changed:`,
|
|
988
994
|
t,
|
|
989
995
|
"→",
|
|
@@ -994,27 +1000,27 @@ const m = {
|
|
|
994
1000
|
* Logs DOM updates and triggers visual highlight.
|
|
995
1001
|
*/
|
|
996
1002
|
domUpdated(e, t, n) {
|
|
997
|
-
|
|
1003
|
+
G && (console.log(`[atom-effect-jquery] DOM updated: ${Dt(e)}.${t} =`, n), tn(e));
|
|
998
1004
|
},
|
|
999
1005
|
cleanup(e) {
|
|
1000
|
-
|
|
1006
|
+
G && console.log(`[atom-effect-jquery] Cleanup: ${e}`);
|
|
1001
1007
|
},
|
|
1002
1008
|
warn(...e) {
|
|
1003
|
-
|
|
1009
|
+
G && console.warn("[atom-effect-jquery]", ...e);
|
|
1004
1010
|
}
|
|
1005
1011
|
}, Rt = "atom-debug-highlight";
|
|
1006
|
-
let
|
|
1007
|
-
function
|
|
1008
|
-
if (
|
|
1009
|
-
|
|
1012
|
+
let Jt = !1;
|
|
1013
|
+
function Ze() {
|
|
1014
|
+
if (Jt) return;
|
|
1015
|
+
Jt = !0;
|
|
1010
1016
|
const e = document.createElement("style");
|
|
1011
1017
|
e.textContent = `.${Rt}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline 0.5s ease-out}`, document.head.appendChild(e);
|
|
1012
1018
|
}
|
|
1013
1019
|
const Lt = /* @__PURE__ */ new WeakMap();
|
|
1014
|
-
function
|
|
1020
|
+
function tn(e) {
|
|
1015
1021
|
const t = "jquery" in e ? e[0] : e;
|
|
1016
1022
|
if (!t || !t.isConnected) return;
|
|
1017
|
-
|
|
1023
|
+
Ze();
|
|
1018
1024
|
const n = Lt.get(t);
|
|
1019
1025
|
n && clearTimeout(n), t.classList.add(Rt), Lt.set(
|
|
1020
1026
|
t,
|
|
@@ -1023,10 +1029,10 @@ function je(e) {
|
|
|
1023
1029
|
}, 600)
|
|
1024
1030
|
);
|
|
1025
1031
|
}
|
|
1026
|
-
function
|
|
1027
|
-
return
|
|
1032
|
+
function pe(e, t = {}) {
|
|
1033
|
+
return ue(e, t);
|
|
1028
1034
|
}
|
|
1029
|
-
Object.defineProperty(
|
|
1035
|
+
Object.defineProperty(pe, "debug", {
|
|
1030
1036
|
get() {
|
|
1031
1037
|
return m.enabled;
|
|
1032
1038
|
},
|
|
@@ -1034,26 +1040,28 @@ Object.defineProperty(oe, "debug", {
|
|
|
1034
1040
|
m.enabled = e;
|
|
1035
1041
|
}
|
|
1036
1042
|
});
|
|
1037
|
-
function
|
|
1043
|
+
function en() {
|
|
1038
1044
|
return new Promise((e) => setTimeout(e, 0));
|
|
1039
1045
|
}
|
|
1040
|
-
|
|
1041
|
-
atom:
|
|
1042
|
-
computed:
|
|
1043
|
-
effect:
|
|
1046
|
+
h.extend({
|
|
1047
|
+
atom: pe,
|
|
1048
|
+
computed: de,
|
|
1049
|
+
effect: Z,
|
|
1044
1050
|
batch: $t,
|
|
1045
|
-
untracked:
|
|
1046
|
-
isAtom:
|
|
1047
|
-
isComputed:
|
|
1048
|
-
isReactive:
|
|
1049
|
-
nextTick:
|
|
1051
|
+
untracked: Pe,
|
|
1052
|
+
isAtom: le,
|
|
1053
|
+
isComputed: he,
|
|
1054
|
+
isReactive: _e,
|
|
1055
|
+
nextTick: en
|
|
1050
1056
|
});
|
|
1051
1057
|
const mt = "_aes-bound";
|
|
1052
|
-
class
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1058
|
+
class nn {
|
|
1059
|
+
constructor() {
|
|
1060
|
+
ct(this, "records", /* @__PURE__ */ new WeakMap());
|
|
1061
|
+
ct(this, "boundElements", /* @__PURE__ */ new WeakSet());
|
|
1062
|
+
ct(this, "preservedNodes", /* @__PURE__ */ new WeakSet());
|
|
1063
|
+
ct(this, "ignoredNodes", /* @__PURE__ */ new WeakSet());
|
|
1064
|
+
}
|
|
1057
1065
|
// Prevent redundant cleanup
|
|
1058
1066
|
keep(t) {
|
|
1059
1067
|
this.preservedNodes.add(t);
|
|
@@ -1073,11 +1081,11 @@ class ze {
|
|
|
1073
1081
|
}
|
|
1074
1082
|
trackEffect(t, n) {
|
|
1075
1083
|
const s = this._getOrCreateRecord(t);
|
|
1076
|
-
s.effects
|
|
1084
|
+
s.effects ??= [], s.effects.push(n);
|
|
1077
1085
|
}
|
|
1078
1086
|
trackCleanup(t, n) {
|
|
1079
1087
|
const s = this._getOrCreateRecord(t);
|
|
1080
|
-
s.cleanups
|
|
1088
|
+
s.cleanups ??= [], s.cleanups.push(n);
|
|
1081
1089
|
}
|
|
1082
1090
|
hasBind(t) {
|
|
1083
1091
|
return this.boundElements.has(t);
|
|
@@ -1115,10 +1123,10 @@ class ze {
|
|
|
1115
1123
|
this.cleanupDescendants(t), this.cleanup(t);
|
|
1116
1124
|
}
|
|
1117
1125
|
}
|
|
1118
|
-
const y = new
|
|
1119
|
-
let
|
|
1120
|
-
function
|
|
1121
|
-
|
|
1126
|
+
const y = new nn();
|
|
1127
|
+
let lt = null;
|
|
1128
|
+
function sn(e = document.body) {
|
|
1129
|
+
lt || (lt = new MutationObserver((t) => {
|
|
1122
1130
|
for (let n = 0, s = t.length; n < s; n++) {
|
|
1123
1131
|
const i = t[n]?.removedNodes;
|
|
1124
1132
|
if (!i) continue;
|
|
@@ -1129,102 +1137,102 @@ function Ve(e = document.body) {
|
|
|
1129
1137
|
c.nodeType === 1 && (c.isConnected || y.isKept(c) || y.isIgnored(c) || y.cleanupTree(c));
|
|
1130
1138
|
}
|
|
1131
1139
|
}
|
|
1132
|
-
}),
|
|
1140
|
+
}), lt.observe(e, { childList: !0, subtree: !0 }));
|
|
1133
1141
|
}
|
|
1134
|
-
function
|
|
1135
|
-
|
|
1142
|
+
function pn() {
|
|
1143
|
+
lt?.disconnect(), lt = null;
|
|
1136
1144
|
}
|
|
1137
1145
|
function q(e, t, n, s) {
|
|
1138
|
-
|
|
1146
|
+
_e(t) ? y.trackEffect(
|
|
1139
1147
|
e,
|
|
1140
|
-
|
|
1148
|
+
Z(() => {
|
|
1141
1149
|
const i = t.value;
|
|
1142
|
-
n(i), m.domUpdated(
|
|
1150
|
+
n(i), m.domUpdated(h(e), s, i);
|
|
1143
1151
|
})
|
|
1144
|
-
) : (n(t), m.enabled && m.domUpdated(
|
|
1152
|
+
) : (n(t), m.enabled && m.domUpdated(h(e), s, t));
|
|
1145
1153
|
}
|
|
1146
|
-
var
|
|
1147
|
-
function
|
|
1154
|
+
var k = /* @__PURE__ */ ((e) => (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))(k || {});
|
|
1155
|
+
function Ee() {
|
|
1148
1156
|
return {
|
|
1149
1157
|
timeoutId: null,
|
|
1150
1158
|
flags: 0
|
|
1151
1159
|
/* None */
|
|
1152
1160
|
};
|
|
1153
1161
|
}
|
|
1154
|
-
function
|
|
1162
|
+
function on(e, t, n = {}) {
|
|
1155
1163
|
const {
|
|
1156
1164
|
debounce: s,
|
|
1157
1165
|
event: i = "input",
|
|
1158
1166
|
parse: o = (I) => I,
|
|
1159
1167
|
format: r = (I) => String(I ?? ""),
|
|
1160
1168
|
equal: c = Object.is
|
|
1161
|
-
} = n, a =
|
|
1162
|
-
if (!(a.flags &
|
|
1163
|
-
a.flags |=
|
|
1169
|
+
} = n, a = Ee(), l = e[0], p = () => {
|
|
1170
|
+
if (!(a.flags & k.Busy)) {
|
|
1171
|
+
a.flags |= k.SyncingToAtom;
|
|
1164
1172
|
try {
|
|
1165
|
-
const I =
|
|
1173
|
+
const I = l.value, v = o(I);
|
|
1166
1174
|
c(t.value, v) || (t.value = v);
|
|
1167
1175
|
} finally {
|
|
1168
|
-
a.flags &= ~
|
|
1176
|
+
a.flags &= ~k.SyncingToAtom;
|
|
1169
1177
|
}
|
|
1170
1178
|
}
|
|
1171
1179
|
}, C = () => {
|
|
1172
|
-
a.timeoutId && (clearTimeout(a.timeoutId), a.timeoutId = null, p()), a.flags &= ~
|
|
1180
|
+
a.timeoutId && (clearTimeout(a.timeoutId), a.timeoutId = null, p()), a.flags &= ~k.Focused;
|
|
1173
1181
|
const I = r(t.value);
|
|
1174
|
-
|
|
1182
|
+
l.value !== I && (l.value = I);
|
|
1175
1183
|
}, b = () => {
|
|
1176
|
-
a.flags &
|
|
1184
|
+
a.flags & k.Busy || (s ? (a.timeoutId && clearTimeout(a.timeoutId), a.timeoutId = setTimeout(p, s)) : p());
|
|
1177
1185
|
}, T = {
|
|
1178
1186
|
compositionstart: () => {
|
|
1179
|
-
a.flags |=
|
|
1187
|
+
a.flags |= k.Composing;
|
|
1180
1188
|
},
|
|
1181
1189
|
compositionend: () => {
|
|
1182
|
-
a.flags &= ~
|
|
1190
|
+
a.flags &= ~k.Composing, p();
|
|
1183
1191
|
},
|
|
1184
1192
|
focus: () => {
|
|
1185
|
-
a.flags |=
|
|
1193
|
+
a.flags |= k.Focused;
|
|
1186
1194
|
},
|
|
1187
1195
|
blur: C,
|
|
1188
1196
|
[i]: b,
|
|
1189
1197
|
change: b
|
|
1190
1198
|
};
|
|
1191
1199
|
return e.on(T), { effect: () => {
|
|
1192
|
-
const I = t.value, v = r(I), L =
|
|
1193
|
-
if (L !== v && !(a.flags &
|
|
1194
|
-
a.flags |=
|
|
1200
|
+
const I = t.value, v = r(I), L = l.value;
|
|
1201
|
+
if (L !== v && !(a.flags & k.Focused && c(o(L), I))) {
|
|
1202
|
+
a.flags |= k.SyncingToDom;
|
|
1195
1203
|
try {
|
|
1196
|
-
if (a.flags &
|
|
1197
|
-
const { selectionStart:
|
|
1198
|
-
|
|
1204
|
+
if (a.flags & k.Focused) {
|
|
1205
|
+
const { selectionStart: tt, selectionEnd: ot } = l;
|
|
1206
|
+
l.value = v;
|
|
1199
1207
|
const j = v.length;
|
|
1200
|
-
|
|
1208
|
+
l.setSelectionRange(Math.min(tt ?? 0, j), Math.min(ot ?? 0, j));
|
|
1201
1209
|
} else
|
|
1202
|
-
|
|
1210
|
+
l.value = v;
|
|
1203
1211
|
m.domUpdated(e, "val", v);
|
|
1204
1212
|
} finally {
|
|
1205
|
-
a.flags &= ~
|
|
1213
|
+
a.flags &= ~k.SyncingToDom;
|
|
1206
1214
|
}
|
|
1207
1215
|
}
|
|
1208
1216
|
}, cleanup: () => {
|
|
1209
1217
|
e.off(T), a.timeoutId && clearTimeout(a.timeoutId);
|
|
1210
1218
|
} };
|
|
1211
1219
|
}
|
|
1212
|
-
const
|
|
1213
|
-
function
|
|
1214
|
-
let t =
|
|
1215
|
-
return t || (t = e.includes("-") ? e.replace(/-./g, (n) => n[1].toUpperCase()) : e,
|
|
1220
|
+
const Zt = /* @__PURE__ */ Object.create(null);
|
|
1221
|
+
function rn(e) {
|
|
1222
|
+
let t = Zt[e];
|
|
1223
|
+
return t || (t = e.includes("-") ? e.replace(/-./g, (n) => n[1].toUpperCase()) : e, Zt[e] = t, t);
|
|
1216
1224
|
}
|
|
1217
1225
|
function $(e) {
|
|
1218
1226
|
let t = null;
|
|
1219
1227
|
return {
|
|
1220
1228
|
get $el() {
|
|
1221
|
-
return t || (t =
|
|
1229
|
+
return t || (t = h(e)), t;
|
|
1222
1230
|
},
|
|
1223
1231
|
el: e,
|
|
1224
1232
|
trackCleanup: (n) => y.trackCleanup(e, n)
|
|
1225
1233
|
};
|
|
1226
1234
|
}
|
|
1227
|
-
function
|
|
1235
|
+
function cn(e, t) {
|
|
1228
1236
|
const n = e.el;
|
|
1229
1237
|
q(
|
|
1230
1238
|
n,
|
|
@@ -1236,7 +1244,7 @@ function Qe(e, t) {
|
|
|
1236
1244
|
"text"
|
|
1237
1245
|
);
|
|
1238
1246
|
}
|
|
1239
|
-
function
|
|
1247
|
+
function ge(e, t) {
|
|
1240
1248
|
const n = e.el;
|
|
1241
1249
|
q(
|
|
1242
1250
|
n,
|
|
@@ -1248,7 +1256,7 @@ function ce(e, t) {
|
|
|
1248
1256
|
"html"
|
|
1249
1257
|
);
|
|
1250
1258
|
}
|
|
1251
|
-
function
|
|
1259
|
+
function me(e, t) {
|
|
1252
1260
|
for (const n in t)
|
|
1253
1261
|
q(
|
|
1254
1262
|
e.el,
|
|
@@ -1259,18 +1267,18 @@ function ae(e, t) {
|
|
|
1259
1267
|
`class.${n}`
|
|
1260
1268
|
);
|
|
1261
1269
|
}
|
|
1262
|
-
function
|
|
1270
|
+
function ye(e, t) {
|
|
1263
1271
|
const n = e.el, s = n.style;
|
|
1264
1272
|
for (const i in t) {
|
|
1265
1273
|
const o = t[i];
|
|
1266
1274
|
if (o === void 0) continue;
|
|
1267
|
-
const r =
|
|
1275
|
+
const r = rn(i), c = Array.isArray(o), a = c ? o[0] : o, l = c ? o[1] : "";
|
|
1268
1276
|
q(
|
|
1269
1277
|
n,
|
|
1270
1278
|
a,
|
|
1271
1279
|
(p) => {
|
|
1272
|
-
const C =
|
|
1273
|
-
if (
|
|
1280
|
+
const C = l ? `${p}${l}` : String(p);
|
|
1281
|
+
if (We(C)) {
|
|
1274
1282
|
console.warn(`[atomBind] Blocked dangerous value in "${i}" property.`);
|
|
1275
1283
|
return;
|
|
1276
1284
|
}
|
|
@@ -1280,7 +1288,7 @@ function ue(e, t) {
|
|
|
1280
1288
|
);
|
|
1281
1289
|
}
|
|
1282
1290
|
}
|
|
1283
|
-
function
|
|
1291
|
+
function be(e, t) {
|
|
1284
1292
|
const n = e.el;
|
|
1285
1293
|
for (const s in t) {
|
|
1286
1294
|
const i = s.charCodeAt(0);
|
|
@@ -1297,7 +1305,7 @@ function le(e, t) {
|
|
|
1297
1305
|
return;
|
|
1298
1306
|
}
|
|
1299
1307
|
const r = o === !0 ? s : String(o);
|
|
1300
|
-
if (
|
|
1308
|
+
if (Ge(s, r)) {
|
|
1301
1309
|
console.warn(`[atomBind] Blocked dangerous protocol in "${s}" attribute.`);
|
|
1302
1310
|
return;
|
|
1303
1311
|
}
|
|
@@ -1307,11 +1315,11 @@ function le(e, t) {
|
|
|
1307
1315
|
);
|
|
1308
1316
|
}
|
|
1309
1317
|
}
|
|
1310
|
-
const
|
|
1311
|
-
function
|
|
1318
|
+
const an = ["innerHTML", "outerHTML"];
|
|
1319
|
+
function Ce(e, t) {
|
|
1312
1320
|
const n = e.el;
|
|
1313
1321
|
for (const s in t) {
|
|
1314
|
-
if (
|
|
1322
|
+
if (an.includes(s)) {
|
|
1315
1323
|
console.warn(
|
|
1316
1324
|
`[atomBind] Blocked setting dangerous property "${s}". Use html binding for sanitized HTML.`
|
|
1317
1325
|
);
|
|
@@ -1339,34 +1347,34 @@ function wt(e, t, n, s) {
|
|
|
1339
1347
|
s
|
|
1340
1348
|
);
|
|
1341
1349
|
}
|
|
1342
|
-
function
|
|
1350
|
+
function Ie(e, t) {
|
|
1343
1351
|
const n = e.el.tagName.toLowerCase();
|
|
1344
1352
|
if (n !== "input" && n !== "select" && n !== "textarea") {
|
|
1345
1353
|
console.warn(`[atomBind] Val binding used on non-input element <${n}>.`);
|
|
1346
1354
|
return;
|
|
1347
1355
|
}
|
|
1348
|
-
const s = Array.isArray(t), { effect: i, cleanup: o } =
|
|
1356
|
+
const s = Array.isArray(t), { effect: i, cleanup: o } = on(
|
|
1349
1357
|
e.$el,
|
|
1350
1358
|
s ? t[0] : t,
|
|
1351
1359
|
s ? t[1] : {}
|
|
1352
1360
|
);
|
|
1353
|
-
y.trackEffect(e.el,
|
|
1361
|
+
y.trackEffect(e.el, Z(i)), e.trackCleanup(o);
|
|
1354
1362
|
}
|
|
1355
|
-
function
|
|
1356
|
-
const n = e.el, s = e.$el, i =
|
|
1357
|
-
if (i.flags &
|
|
1363
|
+
function Se(e, t) {
|
|
1364
|
+
const n = e.el, s = e.$el, i = Ee(), o = () => {
|
|
1365
|
+
if (i.flags & k.Busy) return;
|
|
1358
1366
|
const c = n.checked;
|
|
1359
1367
|
t.value !== c && (t.value = c);
|
|
1360
1368
|
};
|
|
1361
1369
|
s.on("change", o), e.trackCleanup(() => s.off("change", o));
|
|
1362
|
-
const r =
|
|
1363
|
-
i.flags |=
|
|
1370
|
+
const r = Z(() => {
|
|
1371
|
+
i.flags |= k.SyncingToDom;
|
|
1364
1372
|
const c = !!t.value;
|
|
1365
|
-
n.checked !== c && (n.checked = c, m.enabled && m.domUpdated(s, "checked", c)), i.flags &= ~
|
|
1373
|
+
n.checked !== c && (n.checked = c, m.enabled && m.domUpdated(s, "checked", c)), i.flags &= ~k.SyncingToDom;
|
|
1366
1374
|
});
|
|
1367
1375
|
y.trackEffect(n, r);
|
|
1368
1376
|
}
|
|
1369
|
-
function
|
|
1377
|
+
function un(e, t) {
|
|
1370
1378
|
for (const n in t) {
|
|
1371
1379
|
const s = t[n];
|
|
1372
1380
|
if (typeof s != "function") continue;
|
|
@@ -1374,95 +1382,95 @@ function We(e, t) {
|
|
|
1374
1382
|
$t(
|
|
1375
1383
|
() => s.call(
|
|
1376
1384
|
e.el,
|
|
1377
|
-
|
|
1385
|
+
h.Event(o.type, { originalEvent: o })
|
|
1378
1386
|
)
|
|
1379
1387
|
);
|
|
1380
1388
|
};
|
|
1381
1389
|
e.el.addEventListener(n, i), e.trackCleanup(() => e.el.removeEventListener(n, i));
|
|
1382
1390
|
}
|
|
1383
1391
|
}
|
|
1384
|
-
|
|
1392
|
+
h.fn.atomBind = function(e) {
|
|
1385
1393
|
return this.each(function() {
|
|
1386
1394
|
const t = $(this);
|
|
1387
|
-
e.text !== void 0 &&
|
|
1395
|
+
e.text !== void 0 && cn(t, e.text), e.html !== void 0 && ge(t, e.html), e.class && me(t, e.class), e.css && ye(t, e.css), e.attr && be(t, e.attr), e.prop && Ce(t, e.prop), e.show !== void 0 && wt(t, e.show, !1, "show"), e.hide !== void 0 && wt(t, e.hide, !0, "hide"), e.val !== void 0 && Ie(t, e.val), e.checked !== void 0 && Se(t, e.checked), e.on && un(t, e.on);
|
|
1388
1396
|
});
|
|
1389
1397
|
};
|
|
1390
|
-
|
|
1398
|
+
h.fn.atomText = function(e, t) {
|
|
1391
1399
|
return this.each(function() {
|
|
1392
|
-
const n =
|
|
1400
|
+
const n = h(this);
|
|
1393
1401
|
q(this, e, t ? (i) => n.text(t(i)) : (i) => n.text(String(i ?? "")), "text");
|
|
1394
1402
|
});
|
|
1395
1403
|
};
|
|
1396
|
-
|
|
1404
|
+
h.fn.atomHtml = function(e) {
|
|
1397
1405
|
return this.each(function() {
|
|
1398
|
-
|
|
1406
|
+
ge($(this), e);
|
|
1399
1407
|
});
|
|
1400
1408
|
};
|
|
1401
|
-
|
|
1409
|
+
h.fn.atomClass = function(e, t) {
|
|
1402
1410
|
return this.each(function() {
|
|
1403
|
-
|
|
1411
|
+
me($(this), { [e]: t });
|
|
1404
1412
|
});
|
|
1405
1413
|
};
|
|
1406
|
-
|
|
1414
|
+
h.fn.atomCss = function(e, t, n) {
|
|
1407
1415
|
return this.each(function() {
|
|
1408
|
-
|
|
1416
|
+
ye($(this), { [e]: n ? [t, n] : t });
|
|
1409
1417
|
});
|
|
1410
1418
|
};
|
|
1411
|
-
|
|
1419
|
+
h.fn.atomAttr = function(e, t) {
|
|
1412
1420
|
return this.each(function() {
|
|
1413
|
-
|
|
1421
|
+
be($(this), { [e]: t });
|
|
1414
1422
|
});
|
|
1415
1423
|
};
|
|
1416
|
-
|
|
1424
|
+
h.fn.atomProp = function(e, t) {
|
|
1417
1425
|
return this.each(function() {
|
|
1418
|
-
|
|
1426
|
+
Ce($(this), { [e]: t });
|
|
1419
1427
|
});
|
|
1420
1428
|
};
|
|
1421
|
-
|
|
1429
|
+
h.fn.atomShow = function(e) {
|
|
1422
1430
|
return this.each(function() {
|
|
1423
1431
|
wt($(this), e, !1, "show");
|
|
1424
1432
|
});
|
|
1425
1433
|
};
|
|
1426
|
-
|
|
1434
|
+
h.fn.atomHide = function(e) {
|
|
1427
1435
|
return this.each(function() {
|
|
1428
1436
|
wt($(this), e, !0, "hide");
|
|
1429
1437
|
});
|
|
1430
1438
|
};
|
|
1431
|
-
|
|
1439
|
+
h.fn.atomVal = function(e, t = {}) {
|
|
1432
1440
|
return this.each(function() {
|
|
1433
|
-
|
|
1441
|
+
Ie(
|
|
1434
1442
|
$(this),
|
|
1435
1443
|
t && Object.keys(t).length > 0 ? [e, t] : e
|
|
1436
1444
|
);
|
|
1437
1445
|
});
|
|
1438
1446
|
};
|
|
1439
|
-
|
|
1447
|
+
h.fn.atomChecked = function(e) {
|
|
1440
1448
|
return this.each(function() {
|
|
1441
|
-
|
|
1449
|
+
Se($(this), e);
|
|
1442
1450
|
});
|
|
1443
1451
|
};
|
|
1444
|
-
|
|
1452
|
+
h.fn.atomOn = function(e, t) {
|
|
1445
1453
|
return this.each(function() {
|
|
1446
|
-
const n =
|
|
1454
|
+
const n = h(this);
|
|
1447
1455
|
n.on(e, t), y.trackCleanup(this, () => n.off(e, t));
|
|
1448
1456
|
});
|
|
1449
1457
|
};
|
|
1450
|
-
|
|
1458
|
+
h.fn.atomUnbind = function() {
|
|
1451
1459
|
return this.each(function() {
|
|
1452
1460
|
y.cleanupTree(this);
|
|
1453
1461
|
});
|
|
1454
1462
|
};
|
|
1455
|
-
|
|
1456
|
-
const { key: n, render: s, bind: i, update: o, onAdd: r, onRemove: c, empty: a } = t,
|
|
1463
|
+
h.fn.atomList = function(e, t) {
|
|
1464
|
+
const { key: n, render: s, bind: i, update: o, onAdd: r, onRemove: c, empty: a } = t, l = typeof n == "function" ? n : (p, C) => p[n];
|
|
1457
1465
|
return this.each(function() {
|
|
1458
|
-
const p =
|
|
1466
|
+
const p = h(this), C = Dt(this), b = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Set();
|
|
1459
1467
|
let O = [], A = null;
|
|
1460
|
-
const I =
|
|
1468
|
+
const I = Z(() => {
|
|
1461
1469
|
const v = e.value, L = v.length;
|
|
1462
1470
|
if (L === 0) {
|
|
1463
1471
|
if (a && !A) {
|
|
1464
|
-
const
|
|
1465
|
-
A =
|
|
1472
|
+
const d = typeof a == "string" ? It(a) : a;
|
|
1473
|
+
A = h(d).appendTo(p);
|
|
1466
1474
|
}
|
|
1467
1475
|
} else A && (A.remove(), A = null);
|
|
1468
1476
|
if (L === 0 && b.size === 0) {
|
|
@@ -1470,21 +1478,21 @@ l.fn.atomList = function(e, t) {
|
|
|
1470
1478
|
return;
|
|
1471
1479
|
}
|
|
1472
1480
|
m.log("list", `${C} updating with ${L} items`);
|
|
1473
|
-
const
|
|
1474
|
-
for (let
|
|
1475
|
-
|
|
1476
|
-
const j = new Array(L), rt = /* @__PURE__ */ new Set(),
|
|
1477
|
-
for (let
|
|
1478
|
-
const N = v[
|
|
1479
|
-
rt.has(g) && console.warn(`[atomList] Duplicate key "${g}" at index ${
|
|
1481
|
+
const tt = /* @__PURE__ */ new Map(), ot = O.length;
|
|
1482
|
+
for (let d = 0; d < ot; d++)
|
|
1483
|
+
tt.set(O[d], d);
|
|
1484
|
+
const j = new Array(L), rt = /* @__PURE__ */ new Set(), ft = new Int32Array(L);
|
|
1485
|
+
for (let d = 0; d < L; d++) {
|
|
1486
|
+
const N = v[d], g = l(N, d);
|
|
1487
|
+
rt.has(g) && console.warn(`[atomList] Duplicate key "${g}" at index ${d}.`), j[d] = g, rt.add(g), ft[d] = tt.get(g) ?? -1;
|
|
1480
1488
|
}
|
|
1481
1489
|
if (b.size > 0)
|
|
1482
|
-
for (const [
|
|
1483
|
-
if (rt.has(
|
|
1490
|
+
for (const [d, N] of b) {
|
|
1491
|
+
if (rt.has(d) || T.has(d)) continue;
|
|
1484
1492
|
const g = () => {
|
|
1485
|
-
N.$el.remove(), N.$el[0] && y.cleanup(N.$el[0]), T.delete(
|
|
1493
|
+
N.$el.remove(), N.$el[0] && y.cleanup(N.$el[0]), T.delete(d), m.log("list", `${C} removed item:`, d);
|
|
1486
1494
|
};
|
|
1487
|
-
if (b.delete(
|
|
1495
|
+
if (b.delete(d), T.add(d), c) {
|
|
1488
1496
|
const w = c(N.$el);
|
|
1489
1497
|
w instanceof Promise ? w.then(g) : g();
|
|
1490
1498
|
} else
|
|
@@ -1494,22 +1502,22 @@ l.fn.atomList = function(e, t) {
|
|
|
1494
1502
|
O = [];
|
|
1495
1503
|
return;
|
|
1496
1504
|
}
|
|
1497
|
-
const
|
|
1498
|
-
let U =
|
|
1499
|
-
for (let
|
|
1500
|
-
const N = j[
|
|
1505
|
+
const dt = Ke(ft);
|
|
1506
|
+
let U = dt.length - 1, x = null;
|
|
1507
|
+
for (let d = L - 1; d >= 0; d--) {
|
|
1508
|
+
const N = j[d], g = v[d], w = b.get(N);
|
|
1501
1509
|
if (w) {
|
|
1502
1510
|
const B = w.item;
|
|
1503
1511
|
w.item = g;
|
|
1504
|
-
const
|
|
1505
|
-
if (!
|
|
1512
|
+
const et = w.$el[0];
|
|
1513
|
+
if (!et) continue;
|
|
1506
1514
|
if (o)
|
|
1507
|
-
o(w.$el, g,
|
|
1508
|
-
else if (B !== g && !
|
|
1509
|
-
const u = s(g,
|
|
1510
|
-
w.$el.replaceWith(E), w.$el = E, i && i(E, g,
|
|
1515
|
+
o(w.$el, g, d), m.domUpdated(w.$el, "list.update", g);
|
|
1516
|
+
else if (B !== g && !Ye(B, g)) {
|
|
1517
|
+
const u = s(g, d), _ = typeof u == "string" ? It(u) : u, E = h(_), f = x === et;
|
|
1518
|
+
w.$el.replaceWith(E), w.$el = E, i && i(E, g, d), m.domUpdated(E, "list.render", g), f && (x = E[0] || null);
|
|
1511
1519
|
}
|
|
1512
|
-
if (U >= 0 &&
|
|
1520
|
+
if (U >= 0 && dt[U] === d)
|
|
1513
1521
|
U--;
|
|
1514
1522
|
else {
|
|
1515
1523
|
const u = w.$el[0];
|
|
@@ -1517,8 +1525,8 @@ l.fn.atomList = function(e, t) {
|
|
|
1517
1525
|
}
|
|
1518
1526
|
x = w.$el[0] || null;
|
|
1519
1527
|
} else {
|
|
1520
|
-
const B = s(g,
|
|
1521
|
-
b.set(N, { $el: u, item: g }), x?.isConnected ? u.insertBefore(x) : u.appendTo(p), i && i(u, g,
|
|
1528
|
+
const B = s(g, d), et = typeof B == "string" ? It(B) : B, u = h(et);
|
|
1529
|
+
b.set(N, { $el: u, item: g }), x?.isConnected ? u.insertBefore(x) : u.appendTo(p), i && i(u, g, d), r && r(u), m.domUpdated(u, "list.add", g), x = u[0] || null;
|
|
1522
1530
|
}
|
|
1523
1531
|
}
|
|
1524
1532
|
O = j;
|
|
@@ -1529,13 +1537,13 @@ l.fn.atomList = function(e, t) {
|
|
|
1529
1537
|
});
|
|
1530
1538
|
};
|
|
1531
1539
|
const St = /* @__PURE__ */ new WeakMap();
|
|
1532
|
-
|
|
1540
|
+
h.fn.atomMount = function(e, t = {}) {
|
|
1533
1541
|
return this.each(function() {
|
|
1534
1542
|
const n = Dt(this), s = St.get(this);
|
|
1535
1543
|
s && (m.log("mount", `${n} unmounting existing component`), s()), m.log("mount", `${n} mounting component`);
|
|
1536
1544
|
let i;
|
|
1537
1545
|
try {
|
|
1538
|
-
i = e(
|
|
1546
|
+
i = e(h(this), t);
|
|
1539
1547
|
} catch (r) {
|
|
1540
1548
|
console.error("[atom-effect-jquery] Mount error:", r);
|
|
1541
1549
|
return;
|
|
@@ -1554,14 +1562,14 @@ l.fn.atomMount = function(e, t = {}) {
|
|
|
1554
1562
|
St.set(this, o), y.trackCleanup(this, o);
|
|
1555
1563
|
});
|
|
1556
1564
|
};
|
|
1557
|
-
|
|
1565
|
+
h.fn.atomUnmount = function() {
|
|
1558
1566
|
return this.each(function() {
|
|
1559
1567
|
const e = St.get(this);
|
|
1560
1568
|
e && e();
|
|
1561
1569
|
});
|
|
1562
1570
|
};
|
|
1563
1571
|
const yt = "[$.route]";
|
|
1564
|
-
function
|
|
1572
|
+
function ln(e) {
|
|
1565
1573
|
const {
|
|
1566
1574
|
target: t,
|
|
1567
1575
|
default: n,
|
|
@@ -1571,27 +1579,27 @@ function Ye(e) {
|
|
|
1571
1579
|
basePath: r = "",
|
|
1572
1580
|
autoBindLinks: c = !1,
|
|
1573
1581
|
activeClass: a = "active",
|
|
1574
|
-
beforeTransition:
|
|
1582
|
+
beforeTransition: l,
|
|
1575
1583
|
afterTransition: p
|
|
1576
1584
|
} = e, C = o === "history";
|
|
1577
1585
|
let b = !1, T = null, O = C ? window.location.pathname + window.location.search : window.location.hash;
|
|
1578
|
-
const A = [], I = /* @__PURE__ */ new Set(), v =
|
|
1586
|
+
const A = [], I = /* @__PURE__ */ new Set(), v = h(t), L = () => {
|
|
1579
1587
|
if (C) {
|
|
1580
|
-
let
|
|
1581
|
-
return r &&
|
|
1588
|
+
let f = window.location.pathname;
|
|
1589
|
+
return r && f.startsWith(r) && (f = f.substring(r.length)), f.replace(/^\//, "") || n;
|
|
1582
1590
|
}
|
|
1583
|
-
const u = window.location.hash,
|
|
1584
|
-
return (
|
|
1585
|
-
},
|
|
1591
|
+
const u = window.location.hash, _ = u.indexOf("?");
|
|
1592
|
+
return (_ === -1 ? u.substring(1) : u.substring(1, _)) || n;
|
|
1593
|
+
}, tt = () => {
|
|
1586
1594
|
let u;
|
|
1587
1595
|
if (C) {
|
|
1588
1596
|
if (u = window.location.search.substring(1), !u) return {};
|
|
1589
1597
|
} else {
|
|
1590
|
-
const
|
|
1591
|
-
if (
|
|
1592
|
-
u =
|
|
1598
|
+
const f = window.location.hash, D = f.indexOf("?");
|
|
1599
|
+
if (D === -1) return {};
|
|
1600
|
+
u = f.substring(D + 1);
|
|
1593
1601
|
}
|
|
1594
|
-
const
|
|
1602
|
+
const _ = new URLSearchParams(u), E = Object.fromEntries(_);
|
|
1595
1603
|
if (u.includes("%"))
|
|
1596
1604
|
try {
|
|
1597
1605
|
decodeURIComponent(u);
|
|
@@ -1601,91 +1609,93 @@ function Ye(e) {
|
|
|
1601
1609
|
return E;
|
|
1602
1610
|
}, ot = (u) => {
|
|
1603
1611
|
if (C) {
|
|
1604
|
-
const
|
|
1605
|
-
history.pushState(null, "",
|
|
1612
|
+
const _ = `${r.replace(/\/$/, "")}/${u}`;
|
|
1613
|
+
history.pushState(null, "", _), O = _;
|
|
1606
1614
|
} else {
|
|
1607
|
-
const
|
|
1608
|
-
O =
|
|
1615
|
+
const _ = `#${u}`;
|
|
1616
|
+
O = _, window.location.hash = _;
|
|
1609
1617
|
}
|
|
1610
1618
|
}, j = () => {
|
|
1611
1619
|
C ? history.replaceState(null, "", O) : window.location.hash = O;
|
|
1612
|
-
}, rt = () => C ? window.location.pathname + window.location.search : window.location.hash,
|
|
1613
|
-
let
|
|
1614
|
-
return !
|
|
1615
|
-
},
|
|
1616
|
-
const
|
|
1617
|
-
if (!
|
|
1620
|
+
}, rt = () => C ? window.location.pathname + window.location.search : window.location.hash, ft = (u) => {
|
|
1621
|
+
let _ = s[u];
|
|
1622
|
+
return !_ && i && (_ = s[i]), _ || (console.warn(`${yt} Route "${u}" not found and no notFound route configured`), null);
|
|
1623
|
+
}, dt = (u) => {
|
|
1624
|
+
const _ = document.querySelector(u);
|
|
1625
|
+
if (!_?.content)
|
|
1618
1626
|
return console.warn(`${yt} Template "${u}" not found`), !1;
|
|
1619
|
-
const E =
|
|
1627
|
+
const E = _.content.cloneNode(!0);
|
|
1620
1628
|
return v.append(E), !0;
|
|
1621
|
-
}, U =
|
|
1629
|
+
}, U = ue(L()), x = (u) => {
|
|
1622
1630
|
if (b) return;
|
|
1623
|
-
const
|
|
1624
|
-
if (!
|
|
1631
|
+
const _ = v[0];
|
|
1632
|
+
if (!_) {
|
|
1625
1633
|
console.warn(`${yt} Target element "${t}" not found`);
|
|
1626
1634
|
return;
|
|
1627
1635
|
}
|
|
1628
|
-
const E =
|
|
1636
|
+
const E = ft(u);
|
|
1629
1637
|
if (!E) return;
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1632
|
-
let
|
|
1638
|
+
const f = tt();
|
|
1639
|
+
l && l(T || u, u), v.empty();
|
|
1640
|
+
let D = f;
|
|
1633
1641
|
if (E.onEnter) {
|
|
1634
|
-
const X = E.onEnter(
|
|
1635
|
-
X !== void 0 && (
|
|
1642
|
+
const X = E.onEnter(f);
|
|
1643
|
+
X !== void 0 && (D = { ...f, ...X });
|
|
1636
1644
|
}
|
|
1637
|
-
E.render ? E.render(
|
|
1638
|
-
},
|
|
1645
|
+
E.render ? E.render(_, u, D) : E.template && dt(E.template), p && p(T || u, u), T = u;
|
|
1646
|
+
}, d = (u) => {
|
|
1639
1647
|
if (b) return;
|
|
1640
|
-
const
|
|
1641
|
-
E?.onLeave && E.onLeave() === !1
|
|
1648
|
+
const _ = U.value, E = s[_];
|
|
1649
|
+
if (E?.onLeave && E.onLeave() === !1)
|
|
1650
|
+
return;
|
|
1651
|
+
const f = u || n;
|
|
1652
|
+
ot(f), U.value = f;
|
|
1642
1653
|
}, N = () => {
|
|
1643
1654
|
if (b) return;
|
|
1644
1655
|
const u = rt();
|
|
1645
1656
|
if (u === O) return;
|
|
1646
|
-
const
|
|
1647
|
-
if (E !==
|
|
1648
|
-
const
|
|
1649
|
-
if (
|
|
1657
|
+
const _ = L(), E = U.value;
|
|
1658
|
+
if (E !== _) {
|
|
1659
|
+
const f = s[E];
|
|
1660
|
+
if (f?.onLeave && f.onLeave() === !1) {
|
|
1650
1661
|
j();
|
|
1651
1662
|
return;
|
|
1652
1663
|
}
|
|
1653
|
-
U.value =
|
|
1664
|
+
U.value = _;
|
|
1654
1665
|
} else
|
|
1655
|
-
x(
|
|
1666
|
+
x(_);
|
|
1656
1667
|
O = u;
|
|
1657
1668
|
}, g = () => {
|
|
1658
1669
|
if (!c) return;
|
|
1659
|
-
const u = (
|
|
1660
|
-
|
|
1661
|
-
const
|
|
1662
|
-
|
|
1670
|
+
const u = (f) => {
|
|
1671
|
+
f.preventDefault();
|
|
1672
|
+
const D = f.currentTarget.dataset.route;
|
|
1673
|
+
D != null && d(D);
|
|
1663
1674
|
};
|
|
1664
|
-
|
|
1665
|
-
|
|
1675
|
+
h(document).on("click", "[data-route]", u), A.push(() => {
|
|
1676
|
+
h(document).off("click", "[data-route]", u);
|
|
1666
1677
|
});
|
|
1667
|
-
const
|
|
1668
|
-
if (I.has(
|
|
1669
|
-
const
|
|
1670
|
-
I.add(
|
|
1671
|
-
const
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1678
|
+
const _ = (f) => {
|
|
1679
|
+
if (I.has(f)) return;
|
|
1680
|
+
const D = f.dataset.route;
|
|
1681
|
+
I.add(f);
|
|
1682
|
+
const X = Z(() => {
|
|
1683
|
+
const Q = U.value === D;
|
|
1684
|
+
f.classList.toggle(a, Q), Q ? f.setAttribute("aria-current", "page") : f.removeAttribute("aria-current");
|
|
1674
1685
|
});
|
|
1675
|
-
y.trackEffect(
|
|
1676
|
-
I.delete(
|
|
1686
|
+
y.trackEffect(f, X), y.trackCleanup(f, () => {
|
|
1687
|
+
I.delete(f);
|
|
1677
1688
|
});
|
|
1678
1689
|
};
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
k.type === "childList" && k.addedNodes.forEach((X) => {
|
|
1690
|
+
for (const f of document.querySelectorAll("[data-route]"))
|
|
1691
|
+
_(f);
|
|
1692
|
+
const E = new MutationObserver((f) => {
|
|
1693
|
+
for (const D of f)
|
|
1694
|
+
D.type === "childList" && D.addedNodes.forEach((X) => {
|
|
1685
1695
|
if (X.nodeType === 1) {
|
|
1686
|
-
const
|
|
1687
|
-
|
|
1688
|
-
(
|
|
1696
|
+
const Q = X;
|
|
1697
|
+
Q.matches?.("[data-route]") && _(Q), Q.querySelectorAll && Q.querySelectorAll("[data-route]").forEach(
|
|
1698
|
+
(ve) => _(ve)
|
|
1689
1699
|
);
|
|
1690
1700
|
}
|
|
1691
1701
|
});
|
|
@@ -1695,73 +1705,84 @@ function Ye(e) {
|
|
|
1695
1705
|
b || (b = !0, A.forEach((u) => u()), A.length = 0, I.forEach((u) => y.cleanup(u)), I.clear());
|
|
1696
1706
|
}, B = C ? "popstate" : "hashchange";
|
|
1697
1707
|
window.addEventListener(B, N), A.push(() => window.removeEventListener(B, N));
|
|
1698
|
-
const
|
|
1708
|
+
const et = Z(() => {
|
|
1699
1709
|
x(U.value);
|
|
1700
1710
|
});
|
|
1701
|
-
return A.push(() =>
|
|
1711
|
+
return A.push(() => et.dispose()), g(), v[0] && y.trackCleanup(v[0], w), {
|
|
1702
1712
|
currentRoute: U,
|
|
1703
|
-
navigate:
|
|
1713
|
+
navigate: d,
|
|
1704
1714
|
destroy: w
|
|
1705
1715
|
};
|
|
1706
1716
|
}
|
|
1707
|
-
|
|
1708
|
-
route:
|
|
1717
|
+
h.extend({
|
|
1718
|
+
route: ln
|
|
1709
1719
|
});
|
|
1720
|
+
function hn(e, t) {
|
|
1721
|
+
const { defaultValue: n, transform: s, method: i, headers: o, ajaxOptions: r } = t, c = typeof e == "function" ? e : () => e;
|
|
1722
|
+
return de(
|
|
1723
|
+
async () => {
|
|
1724
|
+
const a = c(), l = await h.ajax({ ...r, url: a, method: i, headers: o });
|
|
1725
|
+
return s ? s(l) : l;
|
|
1726
|
+
},
|
|
1727
|
+
{ defaultValue: n, lazy: !1 }
|
|
1728
|
+
);
|
|
1729
|
+
}
|
|
1730
|
+
h.extend({ atomFetch: hn });
|
|
1710
1731
|
const kt = /* @__PURE__ */ new WeakMap();
|
|
1711
|
-
let
|
|
1712
|
-
const
|
|
1732
|
+
let te = !1;
|
|
1733
|
+
const ee = (e) => {
|
|
1713
1734
|
let t = kt.get(e);
|
|
1714
1735
|
return t || (t = function(...n) {
|
|
1715
1736
|
return $t(() => e.apply(this, n));
|
|
1716
1737
|
}, kt.set(e, t)), t;
|
|
1717
1738
|
};
|
|
1718
|
-
function
|
|
1719
|
-
if (
|
|
1720
|
-
|
|
1721
|
-
const e =
|
|
1722
|
-
|
|
1739
|
+
function fn() {
|
|
1740
|
+
if (te) return;
|
|
1741
|
+
te = !0;
|
|
1742
|
+
const e = h.fn.on, t = h.fn.off, n = h.fn.remove, s = h.fn.empty, i = h.fn.detach;
|
|
1743
|
+
h.fn.remove = function(o) {
|
|
1723
1744
|
const r = o ? this.filter(o) : this;
|
|
1724
1745
|
for (let c = 0, a = r.length; c < a; c++) {
|
|
1725
|
-
const
|
|
1726
|
-
|
|
1746
|
+
const l = r[c];
|
|
1747
|
+
l && (y.cleanupTree(l), y.markIgnored(l));
|
|
1727
1748
|
}
|
|
1728
1749
|
return n.call(this, o);
|
|
1729
|
-
},
|
|
1750
|
+
}, h.fn.empty = function() {
|
|
1730
1751
|
for (let o = 0, r = this.length; o < r; o++) {
|
|
1731
1752
|
const c = this[o];
|
|
1732
1753
|
c && y.cleanupDescendants(c);
|
|
1733
1754
|
}
|
|
1734
1755
|
return s.call(this);
|
|
1735
|
-
},
|
|
1756
|
+
}, h.fn.detach = function(o) {
|
|
1736
1757
|
const r = o ? this.filter(o) : this;
|
|
1737
1758
|
for (let c = 0, a = r.length; c < a; c++) {
|
|
1738
|
-
const
|
|
1739
|
-
|
|
1759
|
+
const l = r[c];
|
|
1760
|
+
l && y.keep(l);
|
|
1740
1761
|
}
|
|
1741
1762
|
return i.call(this, o);
|
|
1742
|
-
},
|
|
1763
|
+
}, h.fn.on = function(...o) {
|
|
1743
1764
|
const r = o[0];
|
|
1744
1765
|
if (r && typeof r == "object") {
|
|
1745
1766
|
const c = r, a = {};
|
|
1746
|
-
for (const
|
|
1747
|
-
const p = c[
|
|
1748
|
-
p && (a[
|
|
1767
|
+
for (const l in c) {
|
|
1768
|
+
const p = c[l];
|
|
1769
|
+
p && (a[l] = ee(p));
|
|
1749
1770
|
}
|
|
1750
1771
|
o[0] = a;
|
|
1751
1772
|
} else
|
|
1752
1773
|
for (let c = o.length - 1; c >= 0; c--)
|
|
1753
1774
|
if (typeof o[c] == "function") {
|
|
1754
|
-
o[c] =
|
|
1775
|
+
o[c] = ee(o[c]);
|
|
1755
1776
|
break;
|
|
1756
1777
|
}
|
|
1757
1778
|
return e.apply(this, o);
|
|
1758
|
-
},
|
|
1779
|
+
}, h.fn.off = function(...o) {
|
|
1759
1780
|
const r = o[0];
|
|
1760
1781
|
if (r && typeof r == "object") {
|
|
1761
1782
|
const c = r, a = {};
|
|
1762
|
-
for (const
|
|
1763
|
-
const p = c[
|
|
1764
|
-
p && (a[
|
|
1783
|
+
for (const l in c) {
|
|
1784
|
+
const p = c[l];
|
|
1785
|
+
p && (a[l] = kt.get(p) || p);
|
|
1765
1786
|
}
|
|
1766
1787
|
o[0] = a;
|
|
1767
1788
|
} else
|
|
@@ -1773,19 +1794,19 @@ function Ke() {
|
|
|
1773
1794
|
return t.apply(this, o);
|
|
1774
1795
|
};
|
|
1775
1796
|
}
|
|
1776
|
-
|
|
1777
|
-
|
|
1797
|
+
h(() => {
|
|
1798
|
+
fn(), sn(document.body);
|
|
1778
1799
|
});
|
|
1779
1800
|
export {
|
|
1780
|
-
|
|
1801
|
+
ue as atom,
|
|
1781
1802
|
$t as batch,
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1803
|
+
de as computed,
|
|
1804
|
+
mn as default,
|
|
1805
|
+
pn as disableAutoCleanup,
|
|
1806
|
+
Z as effect,
|
|
1807
|
+
sn as enableAutoCleanup,
|
|
1808
|
+
fn as enablejQueryOverrides,
|
|
1788
1809
|
y as registry,
|
|
1789
|
-
|
|
1810
|
+
Pe as untracked
|
|
1790
1811
|
};
|
|
1791
1812
|
//# sourceMappingURL=index.mjs.map
|