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