@but212/atom-effect-jquery 0.15.2 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atom-effect-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 +437 -410
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import h from "jquery";
|
|
2
|
-
import { default as
|
|
3
|
-
const
|
|
2
|
+
import { default as Pt } from "jquery";
|
|
3
|
+
const Ye = {
|
|
4
4
|
/** One second in milliseconds */
|
|
5
5
|
ONE_SECOND_MS: 1e3
|
|
6
|
-
},
|
|
6
|
+
}, de = {
|
|
7
7
|
IDLE: "idle",
|
|
8
8
|
PENDING: "pending",
|
|
9
9
|
RESOLVED: "resolved",
|
|
10
10
|
REJECTED: "rejected"
|
|
11
|
-
},
|
|
11
|
+
}, U = {
|
|
12
12
|
DISPOSED: 1,
|
|
13
13
|
HAS_FN_SUBS: 2,
|
|
14
14
|
HAS_OBJ_SUBS: 4
|
|
15
|
-
},
|
|
16
|
-
...
|
|
15
|
+
}, v = {
|
|
16
|
+
...U,
|
|
17
17
|
EXECUTING: 8
|
|
18
18
|
}, l = {
|
|
19
|
-
...
|
|
19
|
+
...U,
|
|
20
20
|
DIRTY: 8,
|
|
21
21
|
IDLE: 16,
|
|
22
22
|
PENDING: 32,
|
|
@@ -24,11 +24,11 @@ const ze = {
|
|
|
24
24
|
REJECTED: 128,
|
|
25
25
|
RECOMPUTING: 256,
|
|
26
26
|
HAS_ERROR: 512
|
|
27
|
-
},
|
|
28
|
-
...
|
|
27
|
+
}, w = {
|
|
28
|
+
...U,
|
|
29
29
|
SYNC: 8,
|
|
30
30
|
NOTIFICATION_SCHEDULED: 16
|
|
31
|
-
},
|
|
31
|
+
}, $ = {
|
|
32
32
|
/** Maximum effect executions per second to detect infinite loops (Legacy/Fallback) */
|
|
33
33
|
MAX_EXECUTIONS_PER_SECOND: 1e3,
|
|
34
34
|
/**
|
|
@@ -47,13 +47,13 @@ const ze = {
|
|
|
47
47
|
MIN_FLUSH_ITERATIONS: 10,
|
|
48
48
|
/** Threshold for shrinking the batch queue to assist GC */
|
|
49
49
|
BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
|
|
50
|
-
},
|
|
50
|
+
}, Re = {
|
|
51
51
|
/** Maximum dependencies before warning about large dependency graphs */
|
|
52
52
|
MAX_DEPENDENCIES: 1e3,
|
|
53
53
|
/** Enable infinite loop detection warnings */
|
|
54
54
|
WARN_INFINITE_LOOP: !0
|
|
55
|
-
},
|
|
56
|
-
class
|
|
55
|
+
}, X = 1073741823, N = typeof process < "u" && process.env && process.env.NODE_ENV !== "production", Qe = Object.freeze([]);
|
|
56
|
+
class M extends Error {
|
|
57
57
|
/**
|
|
58
58
|
* Creates a new AtomError
|
|
59
59
|
* @param message - Error message describing what went wrong
|
|
@@ -64,7 +64,7 @@ class P extends Error {
|
|
|
64
64
|
super(e), this.name = "AtomError", this.cause = s, this.recoverable = n, this.timestamp = /* @__PURE__ */ new Date();
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class P extends M {
|
|
68
68
|
/**
|
|
69
69
|
* Creates a new ComputedError
|
|
70
70
|
* @param message - Error message
|
|
@@ -74,7 +74,7 @@ class V extends P {
|
|
|
74
74
|
super(e, s, !0), this.name = "ComputedError";
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
class
|
|
77
|
+
class K extends M {
|
|
78
78
|
/**
|
|
79
79
|
* Creates a new EffectError
|
|
80
80
|
* @param message - Error message
|
|
@@ -84,7 +84,7 @@ class J extends P {
|
|
|
84
84
|
super(e, s, !1), this.name = "EffectError";
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
class
|
|
87
|
+
class ae extends M {
|
|
88
88
|
/**
|
|
89
89
|
* Creates a new SchedulerError
|
|
90
90
|
* @param message - Error message
|
|
@@ -94,7 +94,7 @@ class ce extends P {
|
|
|
94
94
|
super(e, s, !1), this.name = "SchedulerError";
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
const
|
|
97
|
+
const b = {
|
|
98
98
|
// ─────────────────────────────────────────────────────────────────
|
|
99
99
|
// Computed errors
|
|
100
100
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -126,6 +126,10 @@ const E = {
|
|
|
126
126
|
* Error thrown when subscribing to a dependency fails.
|
|
127
127
|
*/
|
|
128
128
|
COMPUTED_DEPENDENCY_SUBSCRIPTION_FAILED: "Failed to subscribe to dependency",
|
|
129
|
+
/**
|
|
130
|
+
* Error thrown when accessing a disposed computed value.
|
|
131
|
+
*/
|
|
132
|
+
COMPUTED_DISPOSED: "Cannot access a disposed computed",
|
|
129
133
|
// ─────────────────────────────────────────────────────────────────
|
|
130
134
|
// Atom errors
|
|
131
135
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -186,28 +190,28 @@ const E = {
|
|
|
186
190
|
* @remarks This prevents cascading failures from masking the original error.
|
|
187
191
|
*/
|
|
188
192
|
CALLBACK_ERROR_IN_ERROR_HANDLER: "Error occurred during onError callback execution"
|
|
189
|
-
},
|
|
190
|
-
function
|
|
193
|
+
}, me = /* @__PURE__ */ Symbol("debugName"), Je = /* @__PURE__ */ Symbol("id"), Se = /* @__PURE__ */ Symbol("type"), Ae = /* @__PURE__ */ Symbol("noDefaultValue");
|
|
194
|
+
function Ke(t) {
|
|
191
195
|
return "dependencies" in t && Array.isArray(t.dependencies);
|
|
192
196
|
}
|
|
193
|
-
let
|
|
194
|
-
function
|
|
197
|
+
let ve = 0;
|
|
198
|
+
function ke(t, e, s) {
|
|
195
199
|
if (t._visitedEpoch !== s) {
|
|
196
200
|
if (t._visitedEpoch = s, t === e)
|
|
197
|
-
throw new
|
|
198
|
-
if (
|
|
201
|
+
throw new P("Indirect circular dependency detected");
|
|
202
|
+
if (Ke(t)) {
|
|
199
203
|
const n = t.dependencies;
|
|
200
204
|
for (let i = 0; i < n.length; i++) {
|
|
201
205
|
const o = n[i];
|
|
202
|
-
o &&
|
|
206
|
+
o && ke(o, e, s);
|
|
203
207
|
}
|
|
204
208
|
}
|
|
205
209
|
}
|
|
206
210
|
}
|
|
207
|
-
const
|
|
211
|
+
const L = {
|
|
208
212
|
enabled: typeof process < "u" && process.env?.NODE_ENV === "development",
|
|
209
|
-
maxDependencies:
|
|
210
|
-
warnInfiniteLoop:
|
|
213
|
+
maxDependencies: Re.MAX_DEPENDENCIES,
|
|
214
|
+
warnInfiniteLoop: Re.WARN_INFINITE_LOOP,
|
|
211
215
|
warn(t, e) {
|
|
212
216
|
this.enabled && t && console.warn(`[Atom Effect] ${e}`);
|
|
213
217
|
},
|
|
@@ -218,38 +222,38 @@ const w = {
|
|
|
218
222
|
*/
|
|
219
223
|
checkCircular(t, e) {
|
|
220
224
|
if (t === e)
|
|
221
|
-
throw new
|
|
222
|
-
this.enabled && (
|
|
225
|
+
throw new P("Direct circular dependency detected");
|
|
226
|
+
this.enabled && (ve++, ke(t, e, ve));
|
|
223
227
|
},
|
|
224
228
|
attachDebugInfo(t, e, s) {
|
|
225
229
|
if (!this.enabled)
|
|
226
230
|
return;
|
|
227
231
|
const n = t;
|
|
228
|
-
n[
|
|
232
|
+
n[me] = `${e}_${s}`, n[Je] = s, n[Se] = e;
|
|
229
233
|
},
|
|
230
234
|
getDebugName(t) {
|
|
231
|
-
if (t != null &&
|
|
232
|
-
return t[
|
|
235
|
+
if (t != null && me in t)
|
|
236
|
+
return t[me];
|
|
233
237
|
},
|
|
234
238
|
getDebugType(t) {
|
|
235
|
-
if (t != null &&
|
|
236
|
-
return t[
|
|
239
|
+
if (t != null && Se in t)
|
|
240
|
+
return t[Se];
|
|
237
241
|
}
|
|
238
242
|
};
|
|
239
|
-
let
|
|
240
|
-
const
|
|
241
|
-
class
|
|
243
|
+
let We = 1;
|
|
244
|
+
const Ze = () => We++;
|
|
245
|
+
class Me {
|
|
242
246
|
constructor() {
|
|
243
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this._modifiedAtEpoch = -1, this._visitedEpoch = -1, this.id =
|
|
247
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this._modifiedAtEpoch = -1, this._visitedEpoch = -1, this.id = Ze() & X, this._tempUnsub = void 0;
|
|
244
248
|
}
|
|
245
249
|
/**
|
|
246
250
|
* Calculates the logical distance (shift) between current and cached version.
|
|
247
251
|
*/
|
|
248
252
|
getShift(e) {
|
|
249
|
-
return this.version - e &
|
|
253
|
+
return this.version - e & X;
|
|
250
254
|
}
|
|
251
255
|
}
|
|
252
|
-
class
|
|
256
|
+
class Be extends Me {
|
|
253
257
|
/**
|
|
254
258
|
* Subscribes a listener function or Subscriber object to value changes.
|
|
255
259
|
*/
|
|
@@ -258,11 +262,11 @@ class Fe extends Le {
|
|
|
258
262
|
return this._addSubscriber(
|
|
259
263
|
this._fnSubs,
|
|
260
264
|
e,
|
|
261
|
-
|
|
265
|
+
U.HAS_FN_SUBS
|
|
262
266
|
);
|
|
263
267
|
if (e !== null && typeof e == "object" && "execute" in e)
|
|
264
|
-
return this._addSubscriber(this._objSubs, e,
|
|
265
|
-
throw new
|
|
268
|
+
return this._addSubscriber(this._objSubs, e, U.HAS_OBJ_SUBS);
|
|
269
|
+
throw new M(b.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
|
|
266
270
|
}
|
|
267
271
|
/**
|
|
268
272
|
* Gets the total number of active subscribers.
|
|
@@ -296,9 +300,9 @@ class Fe extends Le {
|
|
|
296
300
|
* Notifies all subscribers of a change.
|
|
297
301
|
*/
|
|
298
302
|
_notifySubscribers(e, s) {
|
|
299
|
-
const n = this.flags, i =
|
|
303
|
+
const n = this.flags, i = U.HAS_FN_SUBS | U.HAS_OBJ_SUBS;
|
|
300
304
|
if (n & i) {
|
|
301
|
-
if (n &
|
|
305
|
+
if (n & U.HAS_FN_SUBS) {
|
|
302
306
|
const o = this._fnSubs;
|
|
303
307
|
for (let r = 0, c = o.length; r < c; r++) {
|
|
304
308
|
const u = o[r];
|
|
@@ -307,12 +311,12 @@ class Fe extends Le {
|
|
|
307
311
|
u(e, s);
|
|
308
312
|
} catch (a) {
|
|
309
313
|
console.error(
|
|
310
|
-
new
|
|
314
|
+
new M(b.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED, a)
|
|
311
315
|
);
|
|
312
316
|
}
|
|
313
317
|
}
|
|
314
318
|
}
|
|
315
|
-
if (n &
|
|
319
|
+
if (n & U.HAS_OBJ_SUBS) {
|
|
316
320
|
const o = this._objSubs;
|
|
317
321
|
for (let r = 0, c = o.length; r < c; r++) {
|
|
318
322
|
const u = o[r];
|
|
@@ -321,7 +325,7 @@ class Fe extends Le {
|
|
|
321
325
|
u.execute();
|
|
322
326
|
} catch (a) {
|
|
323
327
|
console.error(
|
|
324
|
-
new
|
|
328
|
+
new M(b.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED, a)
|
|
325
329
|
);
|
|
326
330
|
}
|
|
327
331
|
}
|
|
@@ -329,19 +333,19 @@ class Fe extends Le {
|
|
|
329
333
|
}
|
|
330
334
|
}
|
|
331
335
|
}
|
|
332
|
-
class
|
|
336
|
+
class et {
|
|
333
337
|
constructor() {
|
|
334
|
-
this.acquired = 0, this.released = 0, this.rejected = new
|
|
338
|
+
this.acquired = 0, this.released = 0, this.rejected = new tt();
|
|
335
339
|
}
|
|
336
340
|
}
|
|
337
|
-
class
|
|
341
|
+
class tt {
|
|
338
342
|
constructor() {
|
|
339
343
|
this.frozen = 0, this.tooLarge = 0, this.poolFull = 0;
|
|
340
344
|
}
|
|
341
345
|
}
|
|
342
|
-
class
|
|
346
|
+
class De {
|
|
343
347
|
constructor() {
|
|
344
|
-
this.pool = [], this.maxPoolSize = 50, this.maxReusableCapacity = 256, this.stats = N ? new
|
|
348
|
+
this.pool = [], this.maxPoolSize = 50, this.maxReusableCapacity = 256, this.stats = N ? new et() : null;
|
|
345
349
|
}
|
|
346
350
|
/** Acquires an array from the pool or creates a new one if the pool is empty. */
|
|
347
351
|
acquire() {
|
|
@@ -392,8 +396,8 @@ class me {
|
|
|
392
396
|
N && e && (e.acquired = 0, e.released = 0, e.rejected.frozen = 0, e.rejected.tooLarge = 0, e.rejected.poolFull = 0);
|
|
393
397
|
}
|
|
394
398
|
}
|
|
395
|
-
const T = Object.freeze([]), H = Object.freeze([]),
|
|
396
|
-
function
|
|
399
|
+
const T = Object.freeze([]), H = Object.freeze([]), x = Object.freeze([]), z = new De(), W = new De(), k = new De();
|
|
400
|
+
function j(t, e, s, n) {
|
|
397
401
|
if (e != null) {
|
|
398
402
|
if ((typeof e == "object" || typeof e == "function") && typeof e.addDependency == "function") {
|
|
399
403
|
e.addDependency(t);
|
|
@@ -401,26 +405,26 @@ function B(t, e, s, n) {
|
|
|
401
405
|
}
|
|
402
406
|
if (typeof e == "function") {
|
|
403
407
|
const i = e;
|
|
404
|
-
s.indexOf(i) === -1 && (s.push(i), t.flags |=
|
|
408
|
+
s.indexOf(i) === -1 && (s.push(i), t.flags |= U.HAS_FN_SUBS);
|
|
405
409
|
return;
|
|
406
410
|
}
|
|
407
|
-
typeof e == "object" && typeof e.execute == "function" && n.indexOf(e) === -1 && (n.push(e), t.flags |=
|
|
411
|
+
typeof e == "object" && typeof e.execute == "function" && n.indexOf(e) === -1 && (n.push(e), t.flags |= U.HAS_OBJ_SUBS);
|
|
408
412
|
}
|
|
409
413
|
}
|
|
410
|
-
function
|
|
414
|
+
function Ue(t, e, s, n) {
|
|
411
415
|
const i = t.length, o = e.length, r = e !== T && o > 0;
|
|
412
416
|
if (r)
|
|
413
417
|
for (let u = 0; u < o; u++) {
|
|
414
418
|
const a = e[u];
|
|
415
419
|
a && (a._tempUnsub = s[u]);
|
|
416
420
|
}
|
|
417
|
-
const c =
|
|
421
|
+
const c = W.acquire();
|
|
418
422
|
c.length = i;
|
|
419
423
|
for (let u = 0; u < i; u++) {
|
|
420
424
|
const a = t[u];
|
|
421
425
|
if (!a) continue;
|
|
422
426
|
const _ = a._tempUnsub;
|
|
423
|
-
_ ? (c[u] = _, a._tempUnsub = void 0) : (
|
|
427
|
+
_ ? (c[u] = _, a._tempUnsub = void 0) : (L.checkCircular(a, n), c[u] = a.subscribe(n));
|
|
424
428
|
}
|
|
425
429
|
if (r)
|
|
426
430
|
for (let u = 0; u < o; u++) {
|
|
@@ -430,30 +434,30 @@ function Re(t, e, s, n) {
|
|
|
430
434
|
_ && (_(), a._tempUnsub = void 0);
|
|
431
435
|
}
|
|
432
436
|
}
|
|
433
|
-
return s !== H &&
|
|
437
|
+
return s !== H && W.release(s), c;
|
|
434
438
|
}
|
|
435
|
-
let
|
|
436
|
-
function
|
|
437
|
-
return
|
|
439
|
+
let le = 0;
|
|
440
|
+
function Ve() {
|
|
441
|
+
return le = le + 1 & X || 1, le;
|
|
438
442
|
}
|
|
439
|
-
function
|
|
440
|
-
return
|
|
443
|
+
function st() {
|
|
444
|
+
return le;
|
|
441
445
|
}
|
|
442
|
-
let
|
|
443
|
-
function
|
|
444
|
-
return
|
|
446
|
+
let ye = 0, Ce = 0, _e = !1;
|
|
447
|
+
function we() {
|
|
448
|
+
return _e ? (N && console.warn(
|
|
445
449
|
"Warning: startFlush() called during flush - ignored to prevent infinite loop detection bypass"
|
|
446
|
-
), !1) : (
|
|
450
|
+
), !1) : (_e = !0, ye = ye + 1 & X || 1, Ce = 0, !0);
|
|
447
451
|
}
|
|
448
|
-
function
|
|
449
|
-
|
|
452
|
+
function Le() {
|
|
453
|
+
_e = !1;
|
|
450
454
|
}
|
|
451
|
-
function
|
|
452
|
-
return
|
|
455
|
+
function nt() {
|
|
456
|
+
return _e ? ++Ce : 0;
|
|
453
457
|
}
|
|
454
|
-
class
|
|
458
|
+
class it {
|
|
455
459
|
constructor() {
|
|
456
|
-
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this.isProcessing = !1, this._isBatching = !1, this.batchDepth = 0, this.batchQueue = [], this.batchQueueSize = 0, this.isFlushingSync = !1, this.maxFlushIterations =
|
|
460
|
+
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this.isProcessing = !1, this._isBatching = !1, this.batchDepth = 0, this.batchQueue = [], this.batchQueueSize = 0, this.isFlushingSync = !1, this.maxFlushIterations = $.MAX_FLUSH_ITERATIONS;
|
|
457
461
|
}
|
|
458
462
|
/**
|
|
459
463
|
* Returns the current operational phase of the scheduler.
|
|
@@ -476,7 +480,7 @@ class et {
|
|
|
476
480
|
*/
|
|
477
481
|
schedule(e) {
|
|
478
482
|
if (N && typeof e != "function")
|
|
479
|
-
throw new
|
|
483
|
+
throw new ae("Scheduler callback must be a function");
|
|
480
484
|
const s = this._epoch;
|
|
481
485
|
if (e._nextEpoch !== s) {
|
|
482
486
|
if (e._nextEpoch = s, this._isBatching || this.isFlushingSync) {
|
|
@@ -494,8 +498,8 @@ class et {
|
|
|
494
498
|
this.isProcessing || this._size === 0 || (this.isProcessing = !0, queueMicrotask(() => {
|
|
495
499
|
try {
|
|
496
500
|
if (this._size === 0) return;
|
|
497
|
-
const e =
|
|
498
|
-
this._drainQueue(), e &&
|
|
501
|
+
const e = we();
|
|
502
|
+
this._drainQueue(), e && Le();
|
|
499
503
|
} finally {
|
|
500
504
|
this.isProcessing = !1, this._size > 0 && !this._isBatching && this.flush();
|
|
501
505
|
}
|
|
@@ -507,11 +511,11 @@ class et {
|
|
|
507
511
|
*/
|
|
508
512
|
flushSync() {
|
|
509
513
|
this.isFlushingSync = !0;
|
|
510
|
-
const e =
|
|
514
|
+
const e = we();
|
|
511
515
|
try {
|
|
512
516
|
this._mergeBatchQueue(), this._drainQueue();
|
|
513
517
|
} finally {
|
|
514
|
-
this.isFlushingSync = !1, e &&
|
|
518
|
+
this.isFlushingSync = !1, e && Le();
|
|
515
519
|
}
|
|
516
520
|
}
|
|
517
521
|
/**
|
|
@@ -527,7 +531,7 @@ class et {
|
|
|
527
531
|
const c = n[r];
|
|
528
532
|
c._nextEpoch !== s && (c._nextEpoch = s, i[o++] = c);
|
|
529
533
|
}
|
|
530
|
-
this._size = o, this.batchQueueSize = 0, n.length >
|
|
534
|
+
this._size = o, this.batchQueueSize = 0, n.length > $.BATCH_QUEUE_SHRINK_THRESHOLD && (n.length = 0);
|
|
531
535
|
}
|
|
532
536
|
_drainQueue() {
|
|
533
537
|
let e = 0;
|
|
@@ -546,7 +550,7 @@ class et {
|
|
|
546
550
|
}
|
|
547
551
|
_handleFlushOverflow() {
|
|
548
552
|
console.error(
|
|
549
|
-
new
|
|
553
|
+
new ae(
|
|
550
554
|
`Maximum flush iterations (${this.maxFlushIterations}) exceeded. Possible infinite loop.`
|
|
551
555
|
)
|
|
552
556
|
), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this.batchQueueSize = 0;
|
|
@@ -557,7 +561,7 @@ class et {
|
|
|
557
561
|
e[n]();
|
|
558
562
|
} catch (i) {
|
|
559
563
|
console.error(
|
|
560
|
-
new
|
|
564
|
+
new ae("Error occurred during scheduler execution", i)
|
|
561
565
|
);
|
|
562
566
|
}
|
|
563
567
|
e.length = 0;
|
|
@@ -573,15 +577,15 @@ class et {
|
|
|
573
577
|
this.batchDepth--, this.batchDepth === 0 && (this.flushSync(), this._isBatching = !1);
|
|
574
578
|
}
|
|
575
579
|
setMaxFlushIterations(e) {
|
|
576
|
-
if (e <
|
|
577
|
-
throw new
|
|
578
|
-
`Max flush iterations must be at least ${
|
|
580
|
+
if (e < $.MIN_FLUSH_ITERATIONS)
|
|
581
|
+
throw new ae(
|
|
582
|
+
`Max flush iterations must be at least ${$.MIN_FLUSH_ITERATIONS}`
|
|
579
583
|
);
|
|
580
584
|
this.maxFlushIterations = e;
|
|
581
585
|
}
|
|
582
586
|
}
|
|
583
|
-
const
|
|
584
|
-
class
|
|
587
|
+
const re = new it();
|
|
588
|
+
class ot {
|
|
585
589
|
constructor() {
|
|
586
590
|
this.current = null;
|
|
587
591
|
}
|
|
@@ -608,10 +612,10 @@ class tt {
|
|
|
608
612
|
return this.current;
|
|
609
613
|
}
|
|
610
614
|
}
|
|
611
|
-
const C = new
|
|
612
|
-
function
|
|
615
|
+
const C = new ot();
|
|
616
|
+
function je(t) {
|
|
613
617
|
if (typeof t != "function")
|
|
614
|
-
throw new
|
|
618
|
+
throw new M("Untracked callback must be a function");
|
|
615
619
|
const e = C.current;
|
|
616
620
|
C.current = null;
|
|
617
621
|
try {
|
|
@@ -620,16 +624,16 @@ function ke(t) {
|
|
|
620
624
|
C.current = e;
|
|
621
625
|
}
|
|
622
626
|
}
|
|
623
|
-
class
|
|
627
|
+
class rt extends Be {
|
|
624
628
|
constructor(e, s) {
|
|
625
|
-
super(), this._value = e, this._pendingOldValue = void 0, this._notifyTask = void 0, this._fnSubs = [], this._objSubs = [], s && (this.flags |=
|
|
629
|
+
super(), this._value = e, this._pendingOldValue = void 0, this._notifyTask = void 0, this._fnSubs = [], this._objSubs = [], s && (this.flags |= w.SYNC), L.attachDebugInfo(this, "atom", this.id);
|
|
626
630
|
}
|
|
627
631
|
/**
|
|
628
632
|
* Returns the current value and registers the atom as a dependency if in a tracking context.
|
|
629
633
|
*/
|
|
630
634
|
get value() {
|
|
631
635
|
const e = C.current;
|
|
632
|
-
return e &&
|
|
636
|
+
return e && j(this, e, this._fnSubs, this._objSubs), this._value;
|
|
633
637
|
}
|
|
634
638
|
/**
|
|
635
639
|
* Sets a new value and schedules notifications if the value has changed.
|
|
@@ -637,8 +641,8 @@ class st extends Fe {
|
|
|
637
641
|
set value(e) {
|
|
638
642
|
const s = this._value;
|
|
639
643
|
if (Object.is(s, e)) return;
|
|
640
|
-
this._value = e, this.version = this.version + 1 &
|
|
641
|
-
const n = this.flags, i =
|
|
644
|
+
this._value = e, this.version = this.version + 1 & X;
|
|
645
|
+
const n = this.flags, i = w.HAS_FN_SUBS | w.HAS_OBJ_SUBS;
|
|
642
646
|
n & i && this._scheduleNotification(s);
|
|
643
647
|
}
|
|
644
648
|
/**
|
|
@@ -646,19 +650,19 @@ class st extends Fe {
|
|
|
646
650
|
*/
|
|
647
651
|
_scheduleNotification(e) {
|
|
648
652
|
let s = this.flags;
|
|
649
|
-
if (s &
|
|
653
|
+
if (s & w.NOTIFICATION_SCHEDULED || (this._pendingOldValue = e, this.flags = s |= w.NOTIFICATION_SCHEDULED), s & w.SYNC && !re.isBatching) {
|
|
650
654
|
this._flushNotifications();
|
|
651
655
|
return;
|
|
652
656
|
}
|
|
653
657
|
let n = this._notifyTask;
|
|
654
|
-
n || (n = this._notifyTask = () => this._flushNotifications()),
|
|
658
|
+
n || (n = this._notifyTask = () => this._flushNotifications()), re.schedule(n);
|
|
655
659
|
}
|
|
656
660
|
/**
|
|
657
661
|
* Flushes scheduled notifications and resets state for the next cycle.
|
|
658
662
|
*/
|
|
659
663
|
_flushNotifications() {
|
|
660
664
|
const e = this.flags;
|
|
661
|
-
if (!(e &
|
|
665
|
+
if (!(e & w.NOTIFICATION_SCHEDULED) || e & w.DISPOSED)
|
|
662
666
|
return;
|
|
663
667
|
const s = this._pendingOldValue, n = this._value;
|
|
664
668
|
this._pendingOldValue = void 0, this.flags &= -17, this._notifySubscribers(n, s);
|
|
@@ -673,43 +677,43 @@ class st extends Fe {
|
|
|
673
677
|
* Disposes of the atom and releases all subscribers and tasks.
|
|
674
678
|
*/
|
|
675
679
|
dispose() {
|
|
676
|
-
this.flags &
|
|
680
|
+
this.flags & w.DISPOSED || (this._fnSubs = [], this._objSubs = [], this.flags |= w.DISPOSED, this._value = void 0, this._pendingOldValue = void 0, this._notifyTask = void 0);
|
|
677
681
|
}
|
|
678
682
|
}
|
|
679
|
-
function
|
|
680
|
-
return new
|
|
683
|
+
function ct(t, e = {}) {
|
|
684
|
+
return new rt(t, e.sync ?? !1);
|
|
681
685
|
}
|
|
682
|
-
function
|
|
686
|
+
function ie(t, e, s) {
|
|
683
687
|
if (t instanceof TypeError)
|
|
684
688
|
return new e(`Type error (${s}): ${t.message}`, t);
|
|
685
689
|
if (t instanceof ReferenceError)
|
|
686
690
|
return new e(`Reference error (${s}): ${t.message}`, t);
|
|
687
|
-
if (t instanceof
|
|
691
|
+
if (t instanceof M)
|
|
688
692
|
return t;
|
|
689
693
|
const n = t instanceof Error ? t.message : String(t), i = t instanceof Error ? t : null;
|
|
690
694
|
return new e(`Unexpected error (${s}): ${n}`, i);
|
|
691
695
|
}
|
|
692
|
-
function
|
|
696
|
+
function Ie(t) {
|
|
693
697
|
return t !== null && typeof t == "object" && "value" in t && "subscribe" in t && typeof t.subscribe == "function";
|
|
694
698
|
}
|
|
695
|
-
function
|
|
696
|
-
if (
|
|
697
|
-
const e =
|
|
699
|
+
function Fe(t) {
|
|
700
|
+
if (L.enabled && t != null && typeof t == "object") {
|
|
701
|
+
const e = L.getDebugType(t);
|
|
698
702
|
if (e)
|
|
699
703
|
return e === "computed";
|
|
700
704
|
}
|
|
701
|
-
return
|
|
705
|
+
return Ie(t) && "invalidate" in t && typeof t.invalidate == "function";
|
|
702
706
|
}
|
|
703
|
-
function
|
|
707
|
+
function $e(t) {
|
|
704
708
|
return t != null && typeof t.then == "function";
|
|
705
709
|
}
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
class
|
|
710
|
+
const He = l.RESOLVED | l.PENDING | l.REJECTED, pe = Array(He + 1).fill(de.IDLE);
|
|
711
|
+
pe[l.RESOLVED] = de.RESOLVED;
|
|
712
|
+
pe[l.PENDING] = de.PENDING;
|
|
713
|
+
pe[l.REJECTED] = de.REJECTED;
|
|
714
|
+
class ut {
|
|
711
715
|
constructor(e) {
|
|
712
|
-
this._owner = e, this._epoch = -1, this._nextDeps = T, this._nextVersions =
|
|
716
|
+
this._owner = e, this._epoch = -1, this._nextDeps = T, this._nextVersions = x, this._depCount = 0;
|
|
713
717
|
}
|
|
714
718
|
execute() {
|
|
715
719
|
this._owner._markDirty();
|
|
@@ -722,14 +726,14 @@ class it {
|
|
|
722
726
|
s < n.length ? (n[s] = e, i[s] = e.version) : (n.push(e), i.push(e.version)), this._depCount = s + 1;
|
|
723
727
|
}
|
|
724
728
|
reset() {
|
|
725
|
-
this._epoch = -1, this._nextDeps = T, this._nextVersions =
|
|
729
|
+
this._epoch = -1, this._nextDeps = T, this._nextVersions = x, this._depCount = 0;
|
|
726
730
|
}
|
|
727
731
|
}
|
|
728
|
-
class
|
|
732
|
+
class ze extends Be {
|
|
729
733
|
constructor(e, s = {}) {
|
|
730
734
|
if (typeof e != "function")
|
|
731
|
-
throw new
|
|
732
|
-
if (super(), this.MAX_ASYNC_RETRIES = 3, this._value = void 0, this.flags = l.DIRTY | l.IDLE, this._error = null, this._promiseId = 0, this._equal = s.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in s ? s.defaultValue :
|
|
735
|
+
throw new P(b.COMPUTED_MUST_BE_FUNCTION);
|
|
736
|
+
if (super(), this.MAX_ASYNC_RETRIES = 3, this._value = void 0, this.flags = l.DIRTY | l.IDLE, this._error = null, this._promiseId = 0, this._equal = s.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in s ? s.defaultValue : Ae, this._hasDefaultValue = this._defaultValue !== Ae, this._onError = s.onError ?? null, this.MAX_PROMISE_ID = Number.MAX_SAFE_INTEGER - 1, this._fnSubs = [], this._objSubs = [], this._dependencies = T, this._dependencyVersions = x, this._unsubscribes = H, this._cachedErrors = null, this._errorCacheEpoch = -1, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._trackable = new ut(this), L.attachDebugInfo(this, "computed", this.id), L.enabled) {
|
|
733
737
|
const n = this;
|
|
734
738
|
n.subscriberCount = this.subscriberCount.bind(this), n.isDirty = () => (this.flags & l.DIRTY) !== 0, n.dependencies = this._dependencies, n.stateFlags = "";
|
|
735
739
|
}
|
|
@@ -741,11 +745,13 @@ class Ve extends Fe {
|
|
|
741
745
|
}
|
|
742
746
|
get value() {
|
|
743
747
|
const e = C.current;
|
|
744
|
-
e &&
|
|
748
|
+
e && j(this, e, this._fnSubs, this._objSubs);
|
|
745
749
|
const s = this.flags;
|
|
750
|
+
if (s & l.DISPOSED)
|
|
751
|
+
throw new P(b.COMPUTED_DISPOSED);
|
|
746
752
|
if (s & l.RECOMPUTING) {
|
|
747
753
|
if (this._hasDefaultValue) return this._defaultValue;
|
|
748
|
-
throw new
|
|
754
|
+
throw new P(b.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
749
755
|
}
|
|
750
756
|
s & (l.DIRTY | l.IDLE) && this._recompute();
|
|
751
757
|
const n = this.flags;
|
|
@@ -756,11 +762,11 @@ class Ve extends Fe {
|
|
|
756
762
|
}
|
|
757
763
|
get state() {
|
|
758
764
|
const e = C.current;
|
|
759
|
-
return e &&
|
|
765
|
+
return e && j(this, e, this._fnSubs, this._objSubs), pe[this.flags & He];
|
|
760
766
|
}
|
|
761
767
|
get hasError() {
|
|
762
768
|
const e = C.current;
|
|
763
|
-
if (e &&
|
|
769
|
+
if (e && j(this, e, this._fnSubs, this._objSubs), this.flags & (l.REJECTED | l.HAS_ERROR)) return !0;
|
|
764
770
|
const s = this._dependencies;
|
|
765
771
|
for (let n = 0, i = s.length; n < i; n++) {
|
|
766
772
|
const o = s[n];
|
|
@@ -773,8 +779,8 @@ class Ve extends Fe {
|
|
|
773
779
|
}
|
|
774
780
|
get errors() {
|
|
775
781
|
const e = C.current;
|
|
776
|
-
if (e &&
|
|
777
|
-
const s =
|
|
782
|
+
if (e && j(this, e, this._fnSubs, this._objSubs), !this.hasError) return Qe;
|
|
783
|
+
const s = st();
|
|
778
784
|
if (this._errorCacheEpoch === s && this._cachedErrors !== null)
|
|
779
785
|
return this._cachedErrors;
|
|
780
786
|
const n = /* @__PURE__ */ new Set();
|
|
@@ -784,9 +790,9 @@ class Ve extends Fe {
|
|
|
784
790
|
const u = i[r];
|
|
785
791
|
if (u && "errors" in u) {
|
|
786
792
|
const a = u.errors;
|
|
787
|
-
for (let _ = 0,
|
|
788
|
-
const
|
|
789
|
-
|
|
793
|
+
for (let _ = 0, B = a.length; _ < B; _++) {
|
|
794
|
+
const D = a[_];
|
|
795
|
+
D && n.add(D);
|
|
790
796
|
}
|
|
791
797
|
}
|
|
792
798
|
}
|
|
@@ -795,20 +801,20 @@ class Ve extends Fe {
|
|
|
795
801
|
}
|
|
796
802
|
get lastError() {
|
|
797
803
|
const e = C.current;
|
|
798
|
-
return e &&
|
|
804
|
+
return e && j(this, e, this._fnSubs, this._objSubs), this._error;
|
|
799
805
|
}
|
|
800
806
|
get isPending() {
|
|
801
807
|
const e = C.current;
|
|
802
|
-
return e &&
|
|
808
|
+
return e && j(this, e, this._fnSubs, this._objSubs), (this.flags & l.PENDING) !== 0;
|
|
803
809
|
}
|
|
804
810
|
get isResolved() {
|
|
805
811
|
const e = C.current;
|
|
806
|
-
return e &&
|
|
812
|
+
return e && j(this, e, this._fnSubs, this._objSubs), (this.flags & l.RESOLVED) !== 0;
|
|
807
813
|
}
|
|
808
814
|
invalidate() {
|
|
809
815
|
this._markDirty();
|
|
810
816
|
const e = this._dependencyVersions;
|
|
811
|
-
e !==
|
|
817
|
+
e !== x && (k.release(e), this._dependencyVersions = x), this._errorCacheEpoch = -1, this._cachedErrors = null;
|
|
812
818
|
}
|
|
813
819
|
dispose() {
|
|
814
820
|
const e = this._unsubscribes;
|
|
@@ -817,12 +823,12 @@ class Ve extends Fe {
|
|
|
817
823
|
const r = e[i];
|
|
818
824
|
r && r();
|
|
819
825
|
}
|
|
820
|
-
|
|
826
|
+
W.release(e), this._unsubscribes = H;
|
|
821
827
|
}
|
|
822
828
|
const s = this._dependencies;
|
|
823
|
-
s !== T && (
|
|
829
|
+
s !== T && (z.release(s), this._dependencies = T);
|
|
824
830
|
const n = this._dependencyVersions;
|
|
825
|
-
n !==
|
|
831
|
+
n !== x && (k.release(n), this._dependencyVersions = x), this._fnSubs = [], this._objSubs = [], this.flags = l.DISPOSED | l.DIRTY | l.IDLE, this._error = null, this._value = void 0, this._promiseId = (this._promiseId + 1) % this.MAX_PROMISE_ID, this._cachedErrors = null, this._errorCacheEpoch = -1;
|
|
826
832
|
}
|
|
827
833
|
_clearDirty() {
|
|
828
834
|
this.flags &= -9;
|
|
@@ -851,23 +857,23 @@ class Ve extends Fe {
|
|
|
851
857
|
return;
|
|
852
858
|
this._setRecomputing(!0);
|
|
853
859
|
const e = this._trackable, s = this._dependencies, n = this._dependencyVersions;
|
|
854
|
-
e._epoch =
|
|
860
|
+
e._epoch = Ve(), e._nextDeps = z.acquire(), e._nextVersions = k.acquire(), e._depCount = 0;
|
|
855
861
|
let i = !1;
|
|
856
862
|
try {
|
|
857
863
|
const o = C.run(e, this._fn), r = e._nextDeps, c = e._nextVersions, u = e._depCount;
|
|
858
|
-
r.length = u, c.length = u, this._unsubscribes =
|
|
864
|
+
r.length = u, c.length = u, this._unsubscribes = Ue(r, s, this._unsubscribes, this), this._dependencies = r, this._dependencyVersions = c, i = !0, $e(o) ? this._handleAsyncComputation(o) : this._finalizeResolution(o);
|
|
859
865
|
} catch (o) {
|
|
860
866
|
let r = o;
|
|
861
867
|
if (!i)
|
|
862
868
|
try {
|
|
863
869
|
const c = e._nextDeps, u = e._nextVersions, a = e._depCount;
|
|
864
|
-
c.length = a, u.length = a, this._unsubscribes =
|
|
870
|
+
c.length = a, u.length = a, this._unsubscribes = Ue(c, s, this._unsubscribes, this), this._dependencies = c, this._dependencyVersions = u, i = !0;
|
|
865
871
|
} catch (c) {
|
|
866
872
|
r = c;
|
|
867
873
|
}
|
|
868
874
|
this._handleComputationError(r);
|
|
869
875
|
} finally {
|
|
870
|
-
i ? (s !== T &&
|
|
876
|
+
i ? (s !== T && z.release(s), n !== x && k.release(n)) : (z.release(e._nextDeps), k.release(e._nextVersions)), e.reset(), this._setRecomputing(!1);
|
|
871
877
|
}
|
|
872
878
|
}
|
|
873
879
|
_handleAsyncComputation(e) {
|
|
@@ -880,7 +886,7 @@ class Ve extends Fe {
|
|
|
880
886
|
this._asyncRetryCount++, this._markDirty();
|
|
881
887
|
return;
|
|
882
888
|
}
|
|
883
|
-
const i = new
|
|
889
|
+
const i = new P(
|
|
884
890
|
`Async drift exceeded threshold after ${this.MAX_ASYNC_RETRIES} retries.`
|
|
885
891
|
);
|
|
886
892
|
this._handleAsyncRejection(i);
|
|
@@ -899,42 +905,42 @@ class Ve extends Fe {
|
|
|
899
905
|
const o = s[n];
|
|
900
906
|
if (o) {
|
|
901
907
|
const r = o.version;
|
|
902
|
-
e = ((e << 5) - e | 0) + r &
|
|
908
|
+
e = ((e << 5) - e | 0) + r & X;
|
|
903
909
|
}
|
|
904
910
|
}
|
|
905
911
|
return e;
|
|
906
912
|
}
|
|
907
913
|
_handleAsyncRejection(e) {
|
|
908
|
-
const s =
|
|
909
|
-
this.flags & l.REJECTED || (this.version = this.version + 1 &
|
|
914
|
+
const s = ie(e, P, b.COMPUTED_ASYNC_COMPUTATION_FAILED);
|
|
915
|
+
this.flags & l.REJECTED || (this.version = this.version + 1 & X), this._error = s, this._setRejected(), this._clearDirty();
|
|
910
916
|
const n = this._onError;
|
|
911
917
|
if (n)
|
|
912
918
|
try {
|
|
913
919
|
n(s);
|
|
914
920
|
} catch (i) {
|
|
915
|
-
console.error(
|
|
921
|
+
console.error(b.CALLBACK_ERROR_IN_ERROR_HANDLER, i);
|
|
916
922
|
}
|
|
917
923
|
this._notifySubscribers(void 0, void 0);
|
|
918
924
|
}
|
|
919
925
|
_finalizeResolution(e) {
|
|
920
|
-
(!(this.flags & l.RESOLVED) || !this._equal(this._value, e)) && (this.version = this.version + 1 &
|
|
926
|
+
(!(this.flags & l.RESOLVED) || !this._equal(this._value, e)) && (this.version = this.version + 1 & X), this._value = e, this._clearDirty(), this._setResolved(), this._error = null, this._setRecomputing(!1), this._cachedErrors = null, this._errorCacheEpoch = -1;
|
|
921
927
|
}
|
|
922
928
|
_handleComputationError(e) {
|
|
923
|
-
const s =
|
|
929
|
+
const s = ie(e, P, b.COMPUTED_COMPUTATION_FAILED);
|
|
924
930
|
this._error = s, this._setRejected(), this._clearDirty(), this._setRecomputing(!1);
|
|
925
931
|
const n = this._onError;
|
|
926
932
|
if (n)
|
|
927
933
|
try {
|
|
928
934
|
n(s);
|
|
929
935
|
} catch (i) {
|
|
930
|
-
console.error(
|
|
936
|
+
console.error(b.CALLBACK_ERROR_IN_ERROR_HANDLER, i);
|
|
931
937
|
}
|
|
932
938
|
throw s;
|
|
933
939
|
}
|
|
934
940
|
_handlePending() {
|
|
935
941
|
if (this._hasDefaultValue)
|
|
936
942
|
return this._defaultValue;
|
|
937
|
-
throw new
|
|
943
|
+
throw new P(b.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
938
944
|
}
|
|
939
945
|
_handleRejected() {
|
|
940
946
|
const e = this._error;
|
|
@@ -951,40 +957,40 @@ class Ve extends Fe {
|
|
|
951
957
|
e & (l.RECOMPUTING | l.DIRTY) || (this.flags = e | l.DIRTY, this._notifySubscribers(void 0, void 0));
|
|
952
958
|
}
|
|
953
959
|
}
|
|
954
|
-
Object.freeze(
|
|
955
|
-
function
|
|
956
|
-
return new
|
|
960
|
+
Object.freeze(ze.prototype);
|
|
961
|
+
function ht(t, e = {}) {
|
|
962
|
+
return new ze(t, e);
|
|
957
963
|
}
|
|
958
|
-
class
|
|
964
|
+
class at extends Me {
|
|
959
965
|
constructor(e, s = {}) {
|
|
960
|
-
super(), this._cleanup = null, this._dependencies = T, this._dependencyVersions =
|
|
961
|
-
const n = Number.isFinite(this._maxExecutions), i = n ? Math.min(this._maxExecutions + 1,
|
|
962
|
-
this._historyCapacity = i, this._history = N && n && i > 0 ? new Array(i).fill(0) : null, this._execId = 0,
|
|
966
|
+
super(), this._cleanup = null, this._dependencies = T, this._dependencyVersions = x, this._unsubscribes = H, this._nextDeps = null, this._nextVersions = null, this._nextUnsubs = null, this._executeTask = void 0, this._onError = s.onError ?? null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._fn = e, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? $.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? $.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = s.trackModifications ?? !1, this._executionCount = 0, this._historyPtr = 0;
|
|
967
|
+
const n = Number.isFinite(this._maxExecutions), i = n ? Math.min(this._maxExecutions + 1, $.MAX_EXECUTIONS_PER_SECOND + 1) : 0;
|
|
968
|
+
this._historyCapacity = i, this._history = N && n && i > 0 ? new Array(i).fill(0) : null, this._execId = 0, L.attachDebugInfo(this, "effect", this.id);
|
|
963
969
|
}
|
|
964
970
|
run() {
|
|
965
|
-
if (this.flags &
|
|
966
|
-
throw new
|
|
971
|
+
if (this.flags & v.DISPOSED)
|
|
972
|
+
throw new K(b.EFFECT_DISPOSED);
|
|
967
973
|
this.execute(!0);
|
|
968
974
|
}
|
|
969
975
|
dispose() {
|
|
970
976
|
const e = this.flags;
|
|
971
|
-
if (e &
|
|
972
|
-
this.flags = e |
|
|
977
|
+
if (e & v.DISPOSED) return;
|
|
978
|
+
this.flags = e | v.DISPOSED, this._safeCleanup();
|
|
973
979
|
const s = this._unsubscribes;
|
|
974
980
|
if (s !== H) {
|
|
975
981
|
for (let o = 0, r = s.length; o < r; o++) {
|
|
976
982
|
const c = s[o];
|
|
977
983
|
c && c();
|
|
978
984
|
}
|
|
979
|
-
|
|
985
|
+
W.release(s), this._unsubscribes = H;
|
|
980
986
|
}
|
|
981
987
|
const n = this._dependencies;
|
|
982
|
-
n !== T && (
|
|
988
|
+
n !== T && (z.release(n), this._dependencies = T);
|
|
983
989
|
const i = this._dependencyVersions;
|
|
984
|
-
i !==
|
|
990
|
+
i !== x && (k.release(i), this._dependencyVersions = x), this._executeTask = void 0;
|
|
985
991
|
}
|
|
986
992
|
addDependency(e) {
|
|
987
|
-
if (!(this.flags &
|
|
993
|
+
if (!(this.flags & v.EXECUTING)) return;
|
|
988
994
|
const s = this._currentEpoch;
|
|
989
995
|
if (e._lastSeenEpoch === s) return;
|
|
990
996
|
e._lastSeenEpoch = s;
|
|
@@ -995,7 +1001,7 @@ class rt extends Le {
|
|
|
995
1001
|
r ? (o.push(r), e._tempUnsub = void 0) : this._subscribeTo(e);
|
|
996
1002
|
}
|
|
997
1003
|
execute(e = !1) {
|
|
998
|
-
if (this.flags & (
|
|
1004
|
+
if (this.flags & (v.DISPOSED | v.EXECUTING) || !e && !this._shouldExecute()) return;
|
|
999
1005
|
this._checkInfiniteLoop(), this._setExecuting(!0), this._safeCleanup();
|
|
1000
1006
|
const s = this._prepareEffectExecutionContext();
|
|
1001
1007
|
let n = !1;
|
|
@@ -1003,14 +1009,14 @@ class rt extends Le {
|
|
|
1003
1009
|
const i = C.run(this, this._fn), o = s.nextDeps.length;
|
|
1004
1010
|
s.nextDeps.length = o, s.nextVersions.length = o, this._dependencies = s.nextDeps, this._dependencyVersions = s.nextVersions, this._unsubscribes = s.nextUnsubs, n = !0, this._checkLoopWarnings();
|
|
1005
1011
|
const r = ++this._execId;
|
|
1006
|
-
|
|
1007
|
-
const u = r !== this._execId, a = this.flags &
|
|
1012
|
+
$e(i) ? i.then((c) => {
|
|
1013
|
+
const u = r !== this._execId, a = this.flags & v.DISPOSED;
|
|
1008
1014
|
if (u || a) {
|
|
1009
1015
|
if (typeof c == "function")
|
|
1010
1016
|
try {
|
|
1011
1017
|
c();
|
|
1012
1018
|
} catch (_) {
|
|
1013
|
-
this._handleExecutionError(_,
|
|
1019
|
+
this._handleExecutionError(_, b.EFFECT_CLEANUP_FAILED);
|
|
1014
1020
|
}
|
|
1015
1021
|
return;
|
|
1016
1022
|
}
|
|
@@ -1025,7 +1031,7 @@ class rt extends Le {
|
|
|
1025
1031
|
}
|
|
1026
1032
|
}
|
|
1027
1033
|
_prepareEffectExecutionContext() {
|
|
1028
|
-
const e = this._dependencies, s = this._dependencyVersions, n = this._unsubscribes, i =
|
|
1034
|
+
const e = this._dependencies, s = this._dependencyVersions, n = this._unsubscribes, i = z.acquire(), o = k.acquire(), r = W.acquire(), c = Ve();
|
|
1029
1035
|
if (e !== T)
|
|
1030
1036
|
for (let u = 0, a = e.length; u < a; u++) {
|
|
1031
1037
|
const _ = e[u];
|
|
@@ -1042,15 +1048,15 @@ class rt extends Le {
|
|
|
1042
1048
|
const r = n[i], c = r ? r._tempUnsub : void 0;
|
|
1043
1049
|
c && (c(), r && (r._tempUnsub = void 0));
|
|
1044
1050
|
}
|
|
1045
|
-
|
|
1051
|
+
z.release(n);
|
|
1046
1052
|
}
|
|
1047
|
-
e.prevUnsubs !== H &&
|
|
1053
|
+
e.prevUnsubs !== H && W.release(e.prevUnsubs), e.prevVersions !== x && k.release(e.prevVersions);
|
|
1048
1054
|
} else {
|
|
1049
|
-
|
|
1055
|
+
z.release(e.nextDeps), k.release(e.nextVersions);
|
|
1050
1056
|
const i = e.nextUnsubs;
|
|
1051
1057
|
for (let o = 0, r = i.length; o < r; o++)
|
|
1052
1058
|
i[o]?.();
|
|
1053
|
-
if (
|
|
1059
|
+
if (W.release(i), n !== T)
|
|
1054
1060
|
for (let o = 0, r = n.length; o < r; o++) {
|
|
1055
1061
|
const c = n[o];
|
|
1056
1062
|
c && (c._tempUnsub = void 0);
|
|
@@ -1060,32 +1066,32 @@ class rt extends Le {
|
|
|
1060
1066
|
_subscribeTo(e) {
|
|
1061
1067
|
try {
|
|
1062
1068
|
const s = e.subscribe(() => {
|
|
1063
|
-
if (this._trackModifications && this.flags &
|
|
1069
|
+
if (this._trackModifications && this.flags & v.EXECUTING && (e._modifiedAtEpoch = this._currentEpoch), this._sync) {
|
|
1064
1070
|
this.execute();
|
|
1065
1071
|
return;
|
|
1066
1072
|
}
|
|
1067
1073
|
let i = this._executeTask;
|
|
1068
|
-
i || (i = this._executeTask = () => this.execute()),
|
|
1074
|
+
i || (i = this._executeTask = () => this.execute()), re.schedule(i);
|
|
1069
1075
|
}), n = this._nextUnsubs;
|
|
1070
1076
|
n && n.push(s);
|
|
1071
1077
|
} catch (s) {
|
|
1072
|
-
console.error(
|
|
1078
|
+
console.error(ie(s, K, b.EFFECT_EXECUTION_FAILED));
|
|
1073
1079
|
const n = this._nextUnsubs;
|
|
1074
1080
|
n && n.push(() => {
|
|
1075
1081
|
});
|
|
1076
1082
|
}
|
|
1077
1083
|
}
|
|
1078
1084
|
get isDisposed() {
|
|
1079
|
-
return (this.flags &
|
|
1085
|
+
return (this.flags & v.DISPOSED) !== 0;
|
|
1080
1086
|
}
|
|
1081
1087
|
get executionCount() {
|
|
1082
1088
|
return this._executionCount;
|
|
1083
1089
|
}
|
|
1084
1090
|
get isExecuting() {
|
|
1085
|
-
return (this.flags &
|
|
1091
|
+
return (this.flags & v.EXECUTING) !== 0;
|
|
1086
1092
|
}
|
|
1087
1093
|
_setExecuting(e) {
|
|
1088
|
-
const s =
|
|
1094
|
+
const s = v.EXECUTING;
|
|
1089
1095
|
this.flags = this.flags & ~s | (e ? -1 : 0) & s;
|
|
1090
1096
|
}
|
|
1091
1097
|
_safeCleanup() {
|
|
@@ -1094,14 +1100,14 @@ class rt extends Le {
|
|
|
1094
1100
|
try {
|
|
1095
1101
|
e();
|
|
1096
1102
|
} catch (s) {
|
|
1097
|
-
this._handleExecutionError(s,
|
|
1103
|
+
this._handleExecutionError(s, b.EFFECT_CLEANUP_FAILED);
|
|
1098
1104
|
}
|
|
1099
1105
|
this._cleanup = null;
|
|
1100
1106
|
}
|
|
1101
1107
|
}
|
|
1102
1108
|
_checkInfiniteLoop() {
|
|
1103
|
-
const e =
|
|
1104
|
-
this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
1109
|
+
const e = ye;
|
|
1110
|
+
this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), nt() > $.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
|
|
1105
1111
|
const s = this._history;
|
|
1106
1112
|
if (s) {
|
|
1107
1113
|
const n = Date.now(), i = this._historyPtr, o = this._historyCapacity;
|
|
@@ -1109,8 +1115,8 @@ class rt extends Le {
|
|
|
1109
1115
|
const r = (i + 1) % o;
|
|
1110
1116
|
this._historyPtr = r;
|
|
1111
1117
|
const c = s[r] ?? 0;
|
|
1112
|
-
if (c > 0 && n - c <
|
|
1113
|
-
const u = new
|
|
1118
|
+
if (c > 0 && n - c < Ye.ONE_SECOND_MS) {
|
|
1119
|
+
const u = new K(
|
|
1114
1120
|
`Effect executed ${o} times within 1 second. Infinite loop suspected`
|
|
1115
1121
|
);
|
|
1116
1122
|
if (this.dispose(), console.error(u), this._onError && this._onError(u), N) throw u;
|
|
@@ -1119,8 +1125,8 @@ class rt extends Le {
|
|
|
1119
1125
|
}
|
|
1120
1126
|
}
|
|
1121
1127
|
_throwInfiniteLoopError(e) {
|
|
1122
|
-
const s = new
|
|
1123
|
-
`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${
|
|
1128
|
+
const s = new K(
|
|
1129
|
+
`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Ce}`
|
|
1124
1130
|
);
|
|
1125
1131
|
throw this.dispose(), console.error(s), s;
|
|
1126
1132
|
}
|
|
@@ -1134,7 +1140,7 @@ class rt extends Le {
|
|
|
1134
1140
|
if (o.version !== s[n]) return !0;
|
|
1135
1141
|
if ("value" in o)
|
|
1136
1142
|
try {
|
|
1137
|
-
|
|
1143
|
+
if (je(() => o.value), o.version !== s[n]) return !0;
|
|
1138
1144
|
} catch {
|
|
1139
1145
|
return !0;
|
|
1140
1146
|
}
|
|
@@ -1142,50 +1148,50 @@ class rt extends Le {
|
|
|
1142
1148
|
}
|
|
1143
1149
|
return !1;
|
|
1144
1150
|
}
|
|
1145
|
-
_handleExecutionError(e, s =
|
|
1146
|
-
const n =
|
|
1151
|
+
_handleExecutionError(e, s = b.EFFECT_EXECUTION_FAILED) {
|
|
1152
|
+
const n = ie(e, K, s);
|
|
1147
1153
|
console.error(n);
|
|
1148
1154
|
const i = this._onError;
|
|
1149
1155
|
if (i)
|
|
1150
1156
|
try {
|
|
1151
1157
|
i(n);
|
|
1152
1158
|
} catch (o) {
|
|
1153
|
-
console.error(
|
|
1159
|
+
console.error(ie(o, K, b.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
1154
1160
|
}
|
|
1155
1161
|
}
|
|
1156
1162
|
_checkLoopWarnings() {
|
|
1157
|
-
if (this._trackModifications &&
|
|
1163
|
+
if (this._trackModifications && L.enabled) {
|
|
1158
1164
|
const e = this._dependencies, s = this._currentEpoch;
|
|
1159
1165
|
for (let n = 0, i = e.length; n < i; n++) {
|
|
1160
1166
|
const o = e[n];
|
|
1161
|
-
o && o._modifiedAtEpoch === s &&
|
|
1167
|
+
o && o._modifiedAtEpoch === s && L.warn(
|
|
1162
1168
|
!0,
|
|
1163
|
-
`Effect is reading a dependency (${
|
|
1169
|
+
`Effect is reading a dependency (${L.getDebugName(o) || "unknown"}) that it just modified. Infinite loop may occur`
|
|
1164
1170
|
);
|
|
1165
1171
|
}
|
|
1166
1172
|
}
|
|
1167
1173
|
}
|
|
1168
1174
|
}
|
|
1169
|
-
function
|
|
1175
|
+
function Z(t, e = {}) {
|
|
1170
1176
|
if (typeof t != "function")
|
|
1171
|
-
throw new
|
|
1172
|
-
const s = new
|
|
1177
|
+
throw new K(b.EFFECT_MUST_BE_FUNCTION);
|
|
1178
|
+
const s = new at(t, e);
|
|
1173
1179
|
return s.execute(), s;
|
|
1174
1180
|
}
|
|
1175
|
-
function
|
|
1181
|
+
function Ne(t) {
|
|
1176
1182
|
if (typeof t != "function")
|
|
1177
|
-
throw new
|
|
1178
|
-
|
|
1183
|
+
throw new M("Batch callback must be a function");
|
|
1184
|
+
re.startBatch();
|
|
1179
1185
|
try {
|
|
1180
1186
|
return t();
|
|
1181
1187
|
} finally {
|
|
1182
|
-
|
|
1188
|
+
re.endBatch();
|
|
1183
1189
|
}
|
|
1184
1190
|
}
|
|
1185
|
-
function
|
|
1191
|
+
function lt(t) {
|
|
1186
1192
|
return t !== null && typeof t == "object" && "value" in t && "subscribe" in t;
|
|
1187
1193
|
}
|
|
1188
|
-
function
|
|
1194
|
+
function Ee(t) {
|
|
1189
1195
|
if (!t) return "unknown";
|
|
1190
1196
|
const e = "jquery" in t ? t[0] : t;
|
|
1191
1197
|
if (!e) return "unknown";
|
|
@@ -1196,7 +1202,7 @@ function _e(t) {
|
|
|
1196
1202
|
}
|
|
1197
1203
|
return e.tagName.toLowerCase();
|
|
1198
1204
|
}
|
|
1199
|
-
function
|
|
1205
|
+
function ft(t) {
|
|
1200
1206
|
const e = t.length;
|
|
1201
1207
|
if (e === 0) return new Int32Array(0);
|
|
1202
1208
|
const s = new Int32Array(e), n = new Int32Array(e);
|
|
@@ -1220,7 +1226,7 @@ function ut(t) {
|
|
|
1220
1226
|
o[r] = c, c = s[c];
|
|
1221
1227
|
return o;
|
|
1222
1228
|
}
|
|
1223
|
-
function
|
|
1229
|
+
function _t() {
|
|
1224
1230
|
if (typeof window < "u") {
|
|
1225
1231
|
const t = window.__ATOM_DEBUG__;
|
|
1226
1232
|
if (typeof t == "boolean")
|
|
@@ -1233,36 +1239,36 @@ function ht() {
|
|
|
1233
1239
|
}
|
|
1234
1240
|
return !1;
|
|
1235
1241
|
}
|
|
1236
|
-
let
|
|
1237
|
-
const
|
|
1242
|
+
let J = _t();
|
|
1243
|
+
const m = {
|
|
1238
1244
|
get enabled() {
|
|
1239
|
-
return
|
|
1245
|
+
return J;
|
|
1240
1246
|
},
|
|
1241
1247
|
set enabled(t) {
|
|
1242
|
-
|
|
1248
|
+
J = t;
|
|
1243
1249
|
},
|
|
1244
1250
|
log(t, ...e) {
|
|
1245
|
-
|
|
1251
|
+
J && console.log(`[atom-effect-jquery] ${t}:`, ...e);
|
|
1246
1252
|
},
|
|
1247
1253
|
atomChanged(t, e, s) {
|
|
1248
|
-
|
|
1254
|
+
J && console.log(`[atom-effect-jquery] Atom "${t || "anonymous"}" changed:`, e, "→", s);
|
|
1249
1255
|
},
|
|
1250
1256
|
/**
|
|
1251
1257
|
* Logs DOM updates and triggers visual highlight.
|
|
1252
1258
|
*/
|
|
1253
1259
|
domUpdated(t, e, s) {
|
|
1254
|
-
if (!
|
|
1255
|
-
const n =
|
|
1256
|
-
console.log(`[atom-effect-jquery] DOM updated: ${n}.${e} =`, s),
|
|
1260
|
+
if (!J) return;
|
|
1261
|
+
const n = Ee(t);
|
|
1262
|
+
console.log(`[atom-effect-jquery] DOM updated: ${n}.${e} =`, s), dt(t);
|
|
1257
1263
|
},
|
|
1258
1264
|
cleanup(t) {
|
|
1259
|
-
|
|
1265
|
+
J && console.log(`[atom-effect-jquery] Cleanup: ${t}`);
|
|
1260
1266
|
},
|
|
1261
1267
|
warn(...t) {
|
|
1262
|
-
|
|
1268
|
+
J && console.warn("[atom-effect-jquery]", ...t);
|
|
1263
1269
|
}
|
|
1264
1270
|
};
|
|
1265
|
-
function
|
|
1271
|
+
function dt(t) {
|
|
1266
1272
|
const e = t[0];
|
|
1267
1273
|
if (!e || !document.contains(e)) return;
|
|
1268
1274
|
const s = "atom_debug_timer", n = "atom_debug_cleanup_timer", i = "atom_debug_org_style";
|
|
@@ -1291,35 +1297,35 @@ function at(t) {
|
|
|
1291
1297
|
}, 100);
|
|
1292
1298
|
t.data(s, o);
|
|
1293
1299
|
}
|
|
1294
|
-
const
|
|
1295
|
-
function
|
|
1296
|
-
const s =
|
|
1297
|
-
return e.name &&
|
|
1300
|
+
const pt = /* @__PURE__ */ new WeakMap();
|
|
1301
|
+
function Xe(t, e = {}) {
|
|
1302
|
+
const s = ct(t, e);
|
|
1303
|
+
return e.name && pt.set(s, { name: e.name }), s;
|
|
1298
1304
|
}
|
|
1299
|
-
Object.defineProperty(
|
|
1305
|
+
Object.defineProperty(Xe, "debug", {
|
|
1300
1306
|
get() {
|
|
1301
|
-
return
|
|
1307
|
+
return m.enabled;
|
|
1302
1308
|
},
|
|
1303
1309
|
set(t) {
|
|
1304
|
-
|
|
1310
|
+
m.enabled = t;
|
|
1305
1311
|
}
|
|
1306
1312
|
});
|
|
1307
|
-
function
|
|
1313
|
+
function Et() {
|
|
1308
1314
|
return new Promise((t) => setTimeout(t, 0));
|
|
1309
1315
|
}
|
|
1310
1316
|
h.extend({
|
|
1311
|
-
atom:
|
|
1312
|
-
computed:
|
|
1313
|
-
effect:
|
|
1314
|
-
batch:
|
|
1315
|
-
untracked:
|
|
1316
|
-
isAtom:
|
|
1317
|
-
isComputed:
|
|
1318
|
-
isReactive: (t) =>
|
|
1319
|
-
nextTick:
|
|
1317
|
+
atom: Xe,
|
|
1318
|
+
computed: ht,
|
|
1319
|
+
effect: Z,
|
|
1320
|
+
batch: Ne,
|
|
1321
|
+
untracked: je,
|
|
1322
|
+
isAtom: Ie,
|
|
1323
|
+
isComputed: Fe,
|
|
1324
|
+
isReactive: (t) => Ie(t) || Fe(t),
|
|
1325
|
+
nextTick: Et
|
|
1320
1326
|
});
|
|
1321
|
-
const
|
|
1322
|
-
class
|
|
1327
|
+
const se = "_aes-bound";
|
|
1328
|
+
class gt {
|
|
1323
1329
|
effects = /* @__PURE__ */ new WeakMap();
|
|
1324
1330
|
cleanups = /* @__PURE__ */ new WeakMap();
|
|
1325
1331
|
boundElements = /* @__PURE__ */ new WeakSet();
|
|
@@ -1340,18 +1346,18 @@ class _t {
|
|
|
1340
1346
|
}
|
|
1341
1347
|
trackEffect(e, s) {
|
|
1342
1348
|
let n = this.effects.get(e);
|
|
1343
|
-
n || (n = [], this.effects.set(e, n), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(
|
|
1349
|
+
n || (n = [], this.effects.set(e, n), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(se))), n.push(s);
|
|
1344
1350
|
}
|
|
1345
1351
|
trackCleanup(e, s) {
|
|
1346
1352
|
let n = this.cleanups.get(e);
|
|
1347
|
-
n || (n = [], this.cleanups.set(e, n), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(
|
|
1353
|
+
n || (n = [], this.cleanups.set(e, n), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(se))), n.push(s);
|
|
1348
1354
|
}
|
|
1349
1355
|
hasBind(e) {
|
|
1350
1356
|
return this.boundElements.has(e);
|
|
1351
1357
|
}
|
|
1352
1358
|
cleanup(e) {
|
|
1353
1359
|
if (!this.boundElements.delete(e)) return;
|
|
1354
|
-
this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.classList.remove(
|
|
1360
|
+
this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.classList.remove(se), m.cleanup(Ee(e));
|
|
1355
1361
|
const s = this.effects.get(e);
|
|
1356
1362
|
if (s) {
|
|
1357
1363
|
this.effects.delete(e);
|
|
@@ -1361,7 +1367,7 @@ class _t {
|
|
|
1361
1367
|
try {
|
|
1362
1368
|
r.dispose();
|
|
1363
1369
|
} catch (c) {
|
|
1364
|
-
|
|
1370
|
+
m.warn("Effect dispose error:", c);
|
|
1365
1371
|
}
|
|
1366
1372
|
}
|
|
1367
1373
|
}
|
|
@@ -1374,26 +1380,26 @@ class _t {
|
|
|
1374
1380
|
try {
|
|
1375
1381
|
r();
|
|
1376
1382
|
} catch (c) {
|
|
1377
|
-
|
|
1383
|
+
m.warn("Cleanup error:", c);
|
|
1378
1384
|
}
|
|
1379
1385
|
}
|
|
1380
1386
|
}
|
|
1381
1387
|
}
|
|
1382
1388
|
cleanupDescendants(e) {
|
|
1383
|
-
const s = e.querySelectorAll(`.${
|
|
1389
|
+
const s = e.querySelectorAll(`.${se}`);
|
|
1384
1390
|
for (let n = 0, i = s.length; n < i; n++) {
|
|
1385
1391
|
const o = s[n];
|
|
1386
|
-
o && (this.boundElements.has(o) ? this.cleanup(o) : o.classList.remove(
|
|
1392
|
+
o && (this.boundElements.has(o) ? this.cleanup(o) : o.classList.remove(se));
|
|
1387
1393
|
}
|
|
1388
1394
|
}
|
|
1389
1395
|
cleanupTree(e) {
|
|
1390
1396
|
this.cleanupDescendants(e), this.cleanup(e);
|
|
1391
1397
|
}
|
|
1392
1398
|
}
|
|
1393
|
-
const d = new
|
|
1394
|
-
let
|
|
1395
|
-
function
|
|
1396
|
-
|
|
1399
|
+
const d = new gt();
|
|
1400
|
+
let oe = null;
|
|
1401
|
+
function bt(t = document.body) {
|
|
1402
|
+
oe || (oe = new MutationObserver((e) => {
|
|
1397
1403
|
for (let s = 0, n = e.length; s < n; s++) {
|
|
1398
1404
|
const i = e[s];
|
|
1399
1405
|
if (!i) continue;
|
|
@@ -1403,92 +1409,92 @@ function dt(t = document.body) {
|
|
|
1403
1409
|
u && (d.isKept(u) || d.isIgnored(u) || u.isConnected || u.nodeType === 1 && d.cleanupTree(u));
|
|
1404
1410
|
}
|
|
1405
1411
|
}
|
|
1406
|
-
}),
|
|
1412
|
+
}), oe.observe(t, { childList: !0, subtree: !0 }));
|
|
1407
1413
|
}
|
|
1408
|
-
function
|
|
1409
|
-
|
|
1414
|
+
function Ut() {
|
|
1415
|
+
oe?.disconnect(), oe = null;
|
|
1410
1416
|
}
|
|
1411
|
-
function
|
|
1417
|
+
function S(t, e, s, n) {
|
|
1412
1418
|
const i = h(t);
|
|
1413
|
-
if (
|
|
1414
|
-
const o =
|
|
1419
|
+
if (lt(e)) {
|
|
1420
|
+
const o = Z(() => {
|
|
1415
1421
|
const r = e.value;
|
|
1416
|
-
s(r),
|
|
1422
|
+
s(r), m.domUpdated(i, n, r);
|
|
1417
1423
|
});
|
|
1418
1424
|
d.trackEffect(t, o);
|
|
1419
1425
|
} else
|
|
1420
|
-
s(e),
|
|
1426
|
+
s(e), m.domUpdated(i, n, e);
|
|
1421
1427
|
}
|
|
1422
|
-
var
|
|
1423
|
-
function
|
|
1428
|
+
var E = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.Focused = 1] = "Focused", t[t.Composing = 2] = "Composing", t[t.SyncingToAtom = 4] = "SyncingToAtom", t[t.SyncingToDom = 8] = "SyncingToDom", t[t.Busy = 14] = "Busy", t))(E || {});
|
|
1429
|
+
function Te() {
|
|
1424
1430
|
return {
|
|
1425
1431
|
timeoutId: null,
|
|
1426
1432
|
flags: 0
|
|
1427
1433
|
/* None */
|
|
1428
1434
|
};
|
|
1429
1435
|
}
|
|
1430
|
-
function
|
|
1436
|
+
function qe(t, e, s = {}) {
|
|
1431
1437
|
const {
|
|
1432
1438
|
debounce: n,
|
|
1433
1439
|
event: i = "input",
|
|
1434
|
-
parse: o = (
|
|
1435
|
-
format: r = (
|
|
1440
|
+
parse: o = (y) => y,
|
|
1441
|
+
format: r = (y) => String(y ?? ""),
|
|
1436
1442
|
equal: c = Object.is
|
|
1437
|
-
} = s, u =
|
|
1438
|
-
u.flags |=
|
|
1443
|
+
} = s, u = Te(), a = () => {
|
|
1444
|
+
u.flags |= E.Composing;
|
|
1439
1445
|
}, _ = () => {
|
|
1440
|
-
u.flags &= ~
|
|
1446
|
+
u.flags &= ~E.Composing, D();
|
|
1441
1447
|
};
|
|
1442
1448
|
t.on("compositionstart", a), t.on("compositionend", _);
|
|
1443
|
-
const
|
|
1444
|
-
u.flags |=
|
|
1445
|
-
},
|
|
1446
|
-
if (!(u.flags &
|
|
1447
|
-
u.flags |=
|
|
1449
|
+
const B = () => {
|
|
1450
|
+
u.flags |= E.Focused;
|
|
1451
|
+
}, D = () => {
|
|
1452
|
+
if (!(u.flags & E.Busy)) {
|
|
1453
|
+
u.flags |= E.SyncingToAtom;
|
|
1448
1454
|
try {
|
|
1449
1455
|
e.value = o(t.val());
|
|
1450
1456
|
} finally {
|
|
1451
|
-
u.flags &= ~
|
|
1457
|
+
u.flags &= ~E.SyncingToAtom;
|
|
1452
1458
|
}
|
|
1453
1459
|
}
|
|
1454
|
-
},
|
|
1455
|
-
u.timeoutId && (clearTimeout(u.timeoutId), u.timeoutId = null,
|
|
1456
|
-
const
|
|
1457
|
-
t.val() !==
|
|
1460
|
+
}, q = () => {
|
|
1461
|
+
u.timeoutId && (clearTimeout(u.timeoutId), u.timeoutId = null, D()), u.flags &= ~E.Focused;
|
|
1462
|
+
const y = r(e.value);
|
|
1463
|
+
t.val() !== y && t.val(y);
|
|
1458
1464
|
};
|
|
1459
|
-
t.on("focus",
|
|
1460
|
-
const
|
|
1461
|
-
u.flags &
|
|
1465
|
+
t.on("focus", B), t.on("blur", q);
|
|
1466
|
+
const R = () => {
|
|
1467
|
+
u.flags & E.Busy || (n ? (u.timeoutId && clearTimeout(u.timeoutId), u.timeoutId = window.setTimeout(D, n)) : D());
|
|
1462
1468
|
};
|
|
1463
|
-
return t.on(i,
|
|
1464
|
-
const
|
|
1465
|
-
if (
|
|
1466
|
-
if (u.flags &
|
|
1469
|
+
return t.on(i, R), t.on("change", R), { effect: () => {
|
|
1470
|
+
const y = r(e.value), O = t.val();
|
|
1471
|
+
if (O !== y) {
|
|
1472
|
+
if (u.flags & E.Focused && c(o(O), e.value))
|
|
1467
1473
|
return;
|
|
1468
|
-
u.flags |=
|
|
1474
|
+
u.flags |= E.SyncingToDom;
|
|
1469
1475
|
try {
|
|
1470
|
-
if (u.flags &
|
|
1471
|
-
const
|
|
1472
|
-
t.val(
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
Math.min(
|
|
1476
|
-
Math.min(
|
|
1476
|
+
if (u.flags & E.Focused) {
|
|
1477
|
+
const V = t[0], te = V.selectionStart, ce = V.selectionEnd;
|
|
1478
|
+
t.val(y);
|
|
1479
|
+
const Y = y.length;
|
|
1480
|
+
V.setSelectionRange(
|
|
1481
|
+
Math.min(te ?? Y, Y),
|
|
1482
|
+
Math.min(ce ?? Y, Y)
|
|
1477
1483
|
);
|
|
1478
1484
|
} else
|
|
1479
|
-
t.val(
|
|
1480
|
-
|
|
1485
|
+
t.val(y);
|
|
1486
|
+
m.domUpdated(t, "val", y);
|
|
1481
1487
|
} finally {
|
|
1482
|
-
u.flags &= ~
|
|
1488
|
+
u.flags &= ~E.SyncingToDom;
|
|
1483
1489
|
}
|
|
1484
1490
|
}
|
|
1485
1491
|
}, cleanup: () => {
|
|
1486
|
-
t.off(i,
|
|
1492
|
+
t.off(i, R), t.off("change", R), t.off("compositionstart", a), t.off("compositionend", _), t.off("focus", B), t.off("blur", q), u.timeoutId && clearTimeout(u.timeoutId);
|
|
1487
1493
|
} };
|
|
1488
1494
|
}
|
|
1489
1495
|
h.fn.atomText = function(t, e) {
|
|
1490
1496
|
return this.each(function() {
|
|
1491
|
-
|
|
1497
|
+
S(
|
|
1492
1498
|
this,
|
|
1493
1499
|
t,
|
|
1494
1500
|
(s) => {
|
|
@@ -1501,12 +1507,12 @@ h.fn.atomText = function(t, e) {
|
|
|
1501
1507
|
};
|
|
1502
1508
|
h.fn.atomHtml = function(t) {
|
|
1503
1509
|
return this.each(function() {
|
|
1504
|
-
|
|
1510
|
+
S(this, t, (e) => h(this).html(String(e ?? "")), "html");
|
|
1505
1511
|
});
|
|
1506
1512
|
};
|
|
1507
1513
|
h.fn.atomClass = function(t, e) {
|
|
1508
1514
|
return this.each(function() {
|
|
1509
|
-
|
|
1515
|
+
S(
|
|
1510
1516
|
this,
|
|
1511
1517
|
e,
|
|
1512
1518
|
(s) => h(this).toggleClass(t, !!s),
|
|
@@ -1516,7 +1522,7 @@ h.fn.atomClass = function(t, e) {
|
|
|
1516
1522
|
};
|
|
1517
1523
|
h.fn.atomCss = function(t, e, s) {
|
|
1518
1524
|
return this.each(function() {
|
|
1519
|
-
|
|
1525
|
+
S(
|
|
1520
1526
|
this,
|
|
1521
1527
|
e,
|
|
1522
1528
|
(n) => {
|
|
@@ -1529,7 +1535,7 @@ h.fn.atomCss = function(t, e, s) {
|
|
|
1529
1535
|
};
|
|
1530
1536
|
h.fn.atomAttr = function(t, e) {
|
|
1531
1537
|
return this.each(function() {
|
|
1532
|
-
|
|
1538
|
+
S(
|
|
1533
1539
|
this,
|
|
1534
1540
|
e,
|
|
1535
1541
|
(s) => {
|
|
@@ -1542,35 +1548,35 @@ h.fn.atomAttr = function(t, e) {
|
|
|
1542
1548
|
};
|
|
1543
1549
|
h.fn.atomProp = function(t, e) {
|
|
1544
1550
|
return this.each(function() {
|
|
1545
|
-
|
|
1551
|
+
S(this, e, (s) => h(this).prop(t, s), `prop.${t}`);
|
|
1546
1552
|
});
|
|
1547
1553
|
};
|
|
1548
1554
|
h.fn.atomShow = function(t) {
|
|
1549
1555
|
return this.each(function() {
|
|
1550
|
-
|
|
1556
|
+
S(this, t, (e) => h(this).toggle(!!e), "show");
|
|
1551
1557
|
});
|
|
1552
1558
|
};
|
|
1553
1559
|
h.fn.atomHide = function(t) {
|
|
1554
1560
|
return this.each(function() {
|
|
1555
|
-
|
|
1561
|
+
S(this, t, (e) => h(this).toggle(!e), "hide");
|
|
1556
1562
|
});
|
|
1557
1563
|
};
|
|
1558
1564
|
h.fn.atomVal = function(t, e = {}) {
|
|
1559
1565
|
return this.each(function() {
|
|
1560
|
-
const s = h(this), { effect: n, cleanup: i } =
|
|
1566
|
+
const s = h(this), { effect: n, cleanup: i } = qe(s, t, e), o = Z(n);
|
|
1561
1567
|
d.trackEffect(this, o), d.trackCleanup(this, i);
|
|
1562
1568
|
});
|
|
1563
1569
|
};
|
|
1564
1570
|
h.fn.atomChecked = function(t) {
|
|
1565
1571
|
return this.each(function() {
|
|
1566
|
-
const e = h(this), s =
|
|
1567
|
-
s.flags &
|
|
1572
|
+
const e = h(this), s = Te(), n = () => {
|
|
1573
|
+
s.flags & E.Busy || (t.value = !!e.prop("checked"));
|
|
1568
1574
|
};
|
|
1569
1575
|
e.on("change", n), d.trackCleanup(this, () => e.off("change", n));
|
|
1570
|
-
const i =
|
|
1571
|
-
s.flags |=
|
|
1576
|
+
const i = Z(() => {
|
|
1577
|
+
s.flags |= E.SyncingToDom;
|
|
1572
1578
|
const o = !!t.value;
|
|
1573
|
-
e.prop("checked", o),
|
|
1579
|
+
e.prop("checked", o), m.domUpdated(e, "checked", o), s.flags &= ~E.SyncingToDom;
|
|
1574
1580
|
});
|
|
1575
1581
|
d.trackEffect(this, i);
|
|
1576
1582
|
});
|
|
@@ -1586,8 +1592,8 @@ h.fn.atomUnbind = function() {
|
|
|
1586
1592
|
d.cleanupTree(this);
|
|
1587
1593
|
});
|
|
1588
1594
|
};
|
|
1589
|
-
function
|
|
1590
|
-
|
|
1595
|
+
function mt(t, e) {
|
|
1596
|
+
S(
|
|
1591
1597
|
t.el,
|
|
1592
1598
|
e,
|
|
1593
1599
|
(s) => {
|
|
@@ -1596,8 +1602,8 @@ function pt(t, e) {
|
|
|
1596
1602
|
"text"
|
|
1597
1603
|
);
|
|
1598
1604
|
}
|
|
1599
|
-
function
|
|
1600
|
-
|
|
1605
|
+
function St(t, e) {
|
|
1606
|
+
S(
|
|
1601
1607
|
t.el,
|
|
1602
1608
|
e,
|
|
1603
1609
|
(s) => {
|
|
@@ -1606,9 +1612,9 @@ function Et(t, e) {
|
|
|
1606
1612
|
"html"
|
|
1607
1613
|
);
|
|
1608
1614
|
}
|
|
1609
|
-
function
|
|
1615
|
+
function yt(t, e) {
|
|
1610
1616
|
for (const s in e)
|
|
1611
|
-
|
|
1617
|
+
S(
|
|
1612
1618
|
t.el,
|
|
1613
1619
|
e[s],
|
|
1614
1620
|
(n) => {
|
|
@@ -1617,7 +1623,7 @@ function gt(t, e) {
|
|
|
1617
1623
|
`class.${s}`
|
|
1618
1624
|
);
|
|
1619
1625
|
}
|
|
1620
|
-
function
|
|
1626
|
+
function It(t, e) {
|
|
1621
1627
|
const s = t.el.style;
|
|
1622
1628
|
for (const n in e) {
|
|
1623
1629
|
const i = e[n];
|
|
@@ -1625,7 +1631,7 @@ function bt(t, e) {
|
|
|
1625
1631
|
const o = n.includes("-") ? n.replace(/-./g, (r) => r.charAt(1).toUpperCase()) : n;
|
|
1626
1632
|
if (Array.isArray(i)) {
|
|
1627
1633
|
const [r, c] = i;
|
|
1628
|
-
|
|
1634
|
+
S(
|
|
1629
1635
|
t.el,
|
|
1630
1636
|
r,
|
|
1631
1637
|
(u) => {
|
|
@@ -1634,7 +1640,7 @@ function bt(t, e) {
|
|
|
1634
1640
|
`css.${n}`
|
|
1635
1641
|
);
|
|
1636
1642
|
} else
|
|
1637
|
-
|
|
1643
|
+
S(
|
|
1638
1644
|
t.el,
|
|
1639
1645
|
i,
|
|
1640
1646
|
(r) => {
|
|
@@ -1644,11 +1650,11 @@ function bt(t, e) {
|
|
|
1644
1650
|
);
|
|
1645
1651
|
}
|
|
1646
1652
|
}
|
|
1647
|
-
function
|
|
1653
|
+
function Dt(t, e) {
|
|
1648
1654
|
const s = t.el;
|
|
1649
1655
|
for (const n in e) {
|
|
1650
1656
|
const i = e[n];
|
|
1651
|
-
|
|
1657
|
+
S(
|
|
1652
1658
|
s,
|
|
1653
1659
|
i,
|
|
1654
1660
|
(o) => {
|
|
@@ -1662,10 +1668,10 @@ function mt(t, e) {
|
|
|
1662
1668
|
);
|
|
1663
1669
|
}
|
|
1664
1670
|
}
|
|
1665
|
-
function
|
|
1671
|
+
function Ct(t, e) {
|
|
1666
1672
|
const s = t.el;
|
|
1667
1673
|
for (const n in e)
|
|
1668
|
-
|
|
1674
|
+
S(
|
|
1669
1675
|
s,
|
|
1670
1676
|
e[n],
|
|
1671
1677
|
(i) => {
|
|
@@ -1674,8 +1680,8 @@ function St(t, e) {
|
|
|
1674
1680
|
`prop.${n}`
|
|
1675
1681
|
);
|
|
1676
1682
|
}
|
|
1677
|
-
function
|
|
1678
|
-
|
|
1683
|
+
function Nt(t, e) {
|
|
1684
|
+
S(
|
|
1679
1685
|
t.el,
|
|
1680
1686
|
e,
|
|
1681
1687
|
(s) => {
|
|
@@ -1684,8 +1690,8 @@ function yt(t, e) {
|
|
|
1684
1690
|
"show"
|
|
1685
1691
|
);
|
|
1686
1692
|
}
|
|
1687
|
-
function
|
|
1688
|
-
|
|
1693
|
+
function Tt(t, e) {
|
|
1694
|
+
S(
|
|
1689
1695
|
t.el,
|
|
1690
1696
|
e,
|
|
1691
1697
|
(s) => {
|
|
@@ -1694,30 +1700,30 @@ function It(t, e) {
|
|
|
1694
1700
|
"hide"
|
|
1695
1701
|
);
|
|
1696
1702
|
}
|
|
1697
|
-
function
|
|
1698
|
-
const s = Array.isArray(e) ? e[0] : e, n = Array.isArray(e) ? e[1] : {}, { effect: i, cleanup: o } =
|
|
1703
|
+
function Ot(t, e) {
|
|
1704
|
+
const s = Array.isArray(e) ? e[0] : e, n = Array.isArray(e) ? e[1] : {}, { effect: i, cleanup: o } = qe(t.$el, s, n), r = Z(i);
|
|
1699
1705
|
d.trackEffect(t.el, r), t.trackCleanup(o);
|
|
1700
1706
|
}
|
|
1701
|
-
function
|
|
1702
|
-
const s =
|
|
1703
|
-
s.flags &
|
|
1707
|
+
function xt(t, e) {
|
|
1708
|
+
const s = Te(), n = () => {
|
|
1709
|
+
s.flags & E.Busy || (e.value = t.$el.prop("checked"));
|
|
1704
1710
|
};
|
|
1705
1711
|
t.$el.on("change", n), t.trackCleanup(() => t.$el.off("change", n));
|
|
1706
|
-
const i =
|
|
1707
|
-
s.flags |=
|
|
1712
|
+
const i = Z(() => {
|
|
1713
|
+
s.flags |= E.SyncingToDom;
|
|
1708
1714
|
const o = !!e.value;
|
|
1709
|
-
t.$el.prop("checked", o),
|
|
1715
|
+
t.$el.prop("checked", o), m.domUpdated(t.$el, "checked", o), s.flags &= ~E.SyncingToDom;
|
|
1710
1716
|
});
|
|
1711
1717
|
d.trackEffect(t.el, i);
|
|
1712
1718
|
}
|
|
1713
|
-
function
|
|
1719
|
+
function Rt(t, e) {
|
|
1714
1720
|
const s = t.el;
|
|
1715
1721
|
for (const n in e) {
|
|
1716
1722
|
const i = e[n];
|
|
1717
1723
|
if (typeof i != "function") continue;
|
|
1718
1724
|
const o = i, r = (c) => {
|
|
1719
1725
|
const u = h.Event(c.type, { originalEvent: c });
|
|
1720
|
-
|
|
1726
|
+
Ne(() => o.call(s, u));
|
|
1721
1727
|
};
|
|
1722
1728
|
s.addEventListener(n, r), t.trackCleanup(() => s.removeEventListener(n, r));
|
|
1723
1729
|
}
|
|
@@ -1729,81 +1735,102 @@ h.fn.atomBind = function(t) {
|
|
|
1729
1735
|
el: this,
|
|
1730
1736
|
trackCleanup: (n) => d.trackCleanup(this, n)
|
|
1731
1737
|
};
|
|
1732
|
-
t.text !== void 0 &&
|
|
1738
|
+
t.text !== void 0 && mt(s, t.text), t.html !== void 0 && St(s, t.html), t.class && yt(s, t.class), t.css && It(s, t.css), t.attr && Dt(s, t.attr), t.prop && Ct(s, t.prop), t.show !== void 0 && Nt(s, t.show), t.hide !== void 0 && Tt(s, t.hide), t.val !== void 0 && Ot(s, t.val), t.checked !== void 0 && xt(s, t.checked), t.on && Rt(s, t.on);
|
|
1733
1739
|
});
|
|
1734
1740
|
};
|
|
1735
1741
|
h.fn.atomList = function(t, e) {
|
|
1736
1742
|
const { key: s, render: n, bind: i, update: o, onAdd: r, onRemove: c, empty: u } = e, a = typeof s == "function" ? s : (_) => _[s];
|
|
1737
1743
|
return this.each(function() {
|
|
1738
|
-
const _ = h(this),
|
|
1739
|
-
let
|
|
1740
|
-
const
|
|
1741
|
-
const
|
|
1742
|
-
if (
|
|
1743
|
-
|
|
1744
|
+
const _ = h(this), B = Ee(this), D = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Set();
|
|
1745
|
+
let R = [], G = null;
|
|
1746
|
+
const Oe = Z(() => {
|
|
1747
|
+
const y = t.value, O = y.length;
|
|
1748
|
+
if (O === 0 ? u && !G && (G = h(u).appendTo(_)) : G && (G.remove(), G = null), O === 0 && D.size === 0) {
|
|
1749
|
+
R = [];
|
|
1744
1750
|
return;
|
|
1745
1751
|
}
|
|
1746
|
-
|
|
1747
|
-
const
|
|
1748
|
-
for (let f = 0; f <
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1751
|
-
`[atomList] Duplicate key "${
|
|
1752
|
-
),
|
|
1752
|
+
m.log("list", `${B} updating with ${O} items`);
|
|
1753
|
+
const V = new Array(O), te = /* @__PURE__ */ new Set();
|
|
1754
|
+
for (let f = 0; f < O; f++) {
|
|
1755
|
+
const I = y[f], p = a(I, f);
|
|
1756
|
+
m.enabled && te.has(p) && console.warn(
|
|
1757
|
+
`[atomList] Duplicate key "${p}" at index ${f}. Items with duplicate keys may cause unexpected behavior.`
|
|
1758
|
+
), V[f] = p, te.add(p);
|
|
1753
1759
|
}
|
|
1754
|
-
for (const [f,
|
|
1755
|
-
if (
|
|
1756
|
-
const
|
|
1757
|
-
|
|
1758
|
-
const
|
|
1759
|
-
|
|
1760
|
+
for (const [f, I] of D) {
|
|
1761
|
+
if (te.has(f) || q.has(f)) continue;
|
|
1762
|
+
const p = () => {
|
|
1763
|
+
I.$el.remove();
|
|
1764
|
+
const g = I.$el[0];
|
|
1765
|
+
g && d.cleanup(g), q.delete(f), m.log("list", `${B} removed item:`, f);
|
|
1760
1766
|
};
|
|
1761
|
-
if (
|
|
1762
|
-
const
|
|
1763
|
-
|
|
1767
|
+
if (D.delete(f), q.add(f), c) {
|
|
1768
|
+
const g = c(I.$el);
|
|
1769
|
+
g instanceof Promise ? g.then(p) : p();
|
|
1764
1770
|
} else
|
|
1765
|
-
|
|
1771
|
+
p();
|
|
1766
1772
|
}
|
|
1767
|
-
if (
|
|
1768
|
-
|
|
1773
|
+
if (O === 0) {
|
|
1774
|
+
R = [];
|
|
1769
1775
|
return;
|
|
1770
1776
|
}
|
|
1771
|
-
const
|
|
1772
|
-
for (let f = 0; f <
|
|
1773
|
-
const
|
|
1774
|
-
|
|
1777
|
+
const ce = /* @__PURE__ */ new Map();
|
|
1778
|
+
for (let f = 0; f < R.length; f++) {
|
|
1779
|
+
const I = R[f];
|
|
1780
|
+
I !== void 0 && ce.set(I, f);
|
|
1775
1781
|
}
|
|
1776
|
-
const
|
|
1777
|
-
for (let f = 0; f <
|
|
1778
|
-
const
|
|
1779
|
-
|
|
1782
|
+
const Y = new Int32Array(O);
|
|
1783
|
+
for (let f = 0; f < O; f++) {
|
|
1784
|
+
const I = V[f];
|
|
1785
|
+
Y[f] = I !== void 0 ? ce.get(I) ?? -1 : -1;
|
|
1780
1786
|
}
|
|
1781
|
-
const
|
|
1782
|
-
let
|
|
1783
|
-
for (let f =
|
|
1784
|
-
const
|
|
1785
|
-
if (
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1787
|
+
const xe = ft(Y);
|
|
1788
|
+
let ge = xe.length - 1, A = null;
|
|
1789
|
+
for (let f = O - 1; f >= 0; f--) {
|
|
1790
|
+
const I = V[f], p = y[f], g = D.get(I);
|
|
1791
|
+
if (g) {
|
|
1792
|
+
const Q = g.item;
|
|
1793
|
+
g.item = p;
|
|
1794
|
+
const F = g.$el[0];
|
|
1795
|
+
if (!F) continue;
|
|
1796
|
+
if (o)
|
|
1797
|
+
o(g.$el, p, f);
|
|
1798
|
+
else if (Q !== p) {
|
|
1799
|
+
let be = !0;
|
|
1800
|
+
if (typeof Q == "object" && Q !== null && typeof p == "object" && p !== null) {
|
|
1801
|
+
const ue = Object.keys(Q), ee = Object.keys(p);
|
|
1802
|
+
if (ue.length === ee.length) {
|
|
1803
|
+
be = !1;
|
|
1804
|
+
for (const he of ue)
|
|
1805
|
+
if (Q[he] !== p[he]) {
|
|
1806
|
+
be = !0;
|
|
1807
|
+
break;
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
if (be) {
|
|
1812
|
+
const ue = n(p, f), ee = h(ue), he = A === F;
|
|
1813
|
+
g.$el.replaceWith(ee), g.$el = ee, i && i(ee, p, f), he && (A = ee[0] || null);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
ge >= 0 && xe[ge] === f ? ge-- : A ? A.isConnected && A !== g.$el[0] ? g.$el.insertBefore(A) : A.isConnected || g.$el.appendTo(_) : g.$el.appendTo(_), A = g.$el[0] || null;
|
|
1790
1817
|
} else {
|
|
1791
|
-
const
|
|
1792
|
-
|
|
1818
|
+
const Q = n(p, f), F = h(Q);
|
|
1819
|
+
D.set(I, { $el: F, item: p }), A?.isConnected ? F.insertBefore(A) : F.appendTo(_), i && i(F, p, f), r && r(F), m.log("list", `${B} added item:`, I), A = F[0] || null;
|
|
1793
1820
|
}
|
|
1794
1821
|
}
|
|
1795
|
-
|
|
1822
|
+
R = V;
|
|
1796
1823
|
});
|
|
1797
|
-
d.trackEffect(this,
|
|
1798
|
-
|
|
1824
|
+
d.trackEffect(this, Oe), d.trackCleanup(this, () => {
|
|
1825
|
+
D.clear(), q.clear(), R = [], G?.remove();
|
|
1799
1826
|
});
|
|
1800
1827
|
});
|
|
1801
1828
|
};
|
|
1802
|
-
const
|
|
1829
|
+
const fe = /* @__PURE__ */ new WeakMap();
|
|
1803
1830
|
h.fn.atomMount = function(t, e = {}) {
|
|
1804
1831
|
return this.each(function() {
|
|
1805
|
-
const s = h(this), n =
|
|
1806
|
-
i && (
|
|
1832
|
+
const s = h(this), n = Ee(this), i = fe.get(this);
|
|
1833
|
+
i && (m.log("mount", `${n} unmounting existing component`), i()), m.log("mount", `${n} mounting component`);
|
|
1807
1834
|
let o;
|
|
1808
1835
|
try {
|
|
1809
1836
|
o = t(s, e);
|
|
@@ -1814,28 +1841,28 @@ h.fn.atomMount = function(t, e = {}) {
|
|
|
1814
1841
|
let r = !1;
|
|
1815
1842
|
const c = () => {
|
|
1816
1843
|
if (!r) {
|
|
1817
|
-
if (r = !0,
|
|
1844
|
+
if (r = !0, m.log("mount", `${n} full cleanup`), typeof o == "function")
|
|
1818
1845
|
try {
|
|
1819
1846
|
o();
|
|
1820
1847
|
} catch (u) {
|
|
1821
1848
|
console.error("[atom-effect-jquery] Cleanup error:", u);
|
|
1822
1849
|
}
|
|
1823
|
-
d.cleanupTree(this),
|
|
1850
|
+
d.cleanupTree(this), fe.delete(this);
|
|
1824
1851
|
}
|
|
1825
1852
|
};
|
|
1826
|
-
|
|
1853
|
+
fe.set(this, c), d.trackCleanup(this, c);
|
|
1827
1854
|
});
|
|
1828
1855
|
};
|
|
1829
1856
|
h.fn.atomUnmount = function() {
|
|
1830
1857
|
return this.each(function() {
|
|
1831
|
-
|
|
1858
|
+
fe.get(this)?.();
|
|
1832
1859
|
});
|
|
1833
1860
|
};
|
|
1834
|
-
const
|
|
1835
|
-
let
|
|
1836
|
-
function
|
|
1837
|
-
if (
|
|
1838
|
-
|
|
1861
|
+
const ne = /* @__PURE__ */ new WeakMap();
|
|
1862
|
+
let Pe = !1;
|
|
1863
|
+
function Ge() {
|
|
1864
|
+
if (Pe) return;
|
|
1865
|
+
Pe = !0;
|
|
1839
1866
|
const t = h.fn.on, e = h.fn.off, s = h.fn.remove, n = h.fn.empty, i = h.fn.detach;
|
|
1840
1867
|
h.fn.remove = function(o) {
|
|
1841
1868
|
return (o ? this.filter(o) : this).each(function() {
|
|
@@ -1859,9 +1886,9 @@ function $e() {
|
|
|
1859
1886
|
if (r !== -1) {
|
|
1860
1887
|
const c = o[r];
|
|
1861
1888
|
let u;
|
|
1862
|
-
|
|
1863
|
-
return
|
|
1864
|
-
},
|
|
1889
|
+
ne.has(c) ? u = ne.get(c) : (u = function(a, ..._) {
|
|
1890
|
+
return Ne(() => c.call(this, a, ..._));
|
|
1891
|
+
}, ne.set(c, u)), o[r] = u;
|
|
1865
1892
|
}
|
|
1866
1893
|
return t.apply(this, o);
|
|
1867
1894
|
}, h.fn.off = function(...o) {
|
|
@@ -1873,27 +1900,27 @@ function $e() {
|
|
|
1873
1900
|
}
|
|
1874
1901
|
if (r !== -1) {
|
|
1875
1902
|
const c = o[r];
|
|
1876
|
-
|
|
1903
|
+
ne.has(c) && (o[r] = ne.get(c));
|
|
1877
1904
|
}
|
|
1878
1905
|
return e.apply(this, o);
|
|
1879
1906
|
};
|
|
1880
1907
|
}
|
|
1881
|
-
const
|
|
1882
|
-
|
|
1908
|
+
const wt = Ge;
|
|
1909
|
+
Ge();
|
|
1883
1910
|
h(() => {
|
|
1884
|
-
|
|
1911
|
+
bt(document.body);
|
|
1885
1912
|
});
|
|
1886
1913
|
export {
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1914
|
+
ct as atom,
|
|
1915
|
+
Ne as batch,
|
|
1916
|
+
ht as computed,
|
|
1917
|
+
Pt as default,
|
|
1918
|
+
Ut as disableAutoCleanup,
|
|
1919
|
+
Z as effect,
|
|
1920
|
+
bt as enableAutoCleanup,
|
|
1921
|
+
wt as enablejQueryBatching,
|
|
1922
|
+
Ge as enablejQueryOverrides,
|
|
1896
1923
|
d as registry,
|
|
1897
|
-
|
|
1924
|
+
je as untracked
|
|
1898
1925
|
};
|
|
1899
1926
|
//# sourceMappingURL=index.mjs.map
|