@but212/atom-effect-jquery 0.9.2 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- 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 +4 -30
- package/dist/index.mjs +561 -581
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import u from "jquery";
|
|
2
|
-
import { default as
|
|
3
|
-
const
|
|
2
|
+
import { default as Ot } from "jquery";
|
|
3
|
+
const Ve = {
|
|
4
4
|
/** One second in milliseconds */
|
|
5
5
|
ONE_SECOND_MS: 1e3
|
|
6
|
-
},
|
|
6
|
+
}, ue = {
|
|
7
7
|
IDLE: "idle",
|
|
8
8
|
PENDING: "pending",
|
|
9
9
|
RESOLVED: "resolved",
|
|
10
10
|
REJECTED: "rejected"
|
|
11
|
-
},
|
|
11
|
+
}, te = {
|
|
12
12
|
DISPOSED: 1,
|
|
13
13
|
// 0001 - Effect has been disposed
|
|
14
14
|
EXECUTING: 2
|
|
@@ -28,7 +28,10 @@ const Le = {
|
|
|
28
28
|
// 100000 - Currently recomputing
|
|
29
29
|
HAS_ERROR: 64
|
|
30
30
|
// 1000000 - Has error state
|
|
31
|
-
},
|
|
31
|
+
}, Y = {
|
|
32
|
+
SYNC: 1,
|
|
33
|
+
NOTIFICATION_SCHEDULED: 2
|
|
34
|
+
}, B = {
|
|
32
35
|
/** Maximum effect executions per second to detect infinite loops (Legacy/Fallback) */
|
|
33
36
|
MAX_EXECUTIONS_PER_SECOND: 1e3,
|
|
34
37
|
/**
|
|
@@ -45,13 +48,13 @@ const Le = {
|
|
|
45
48
|
MAX_FLUSH_ITERATIONS: 1e3,
|
|
46
49
|
/** Minimum allowed value for max flush iterations */
|
|
47
50
|
MIN_FLUSH_ITERATIONS: 10
|
|
48
|
-
},
|
|
51
|
+
}, ye = {
|
|
49
52
|
/** Maximum dependencies before warning about large dependency graphs */
|
|
50
53
|
MAX_DEPENDENCIES: 1e3,
|
|
51
54
|
/** Enable infinite loop detection warnings */
|
|
52
55
|
WARN_INFINITE_LOOP: !0
|
|
53
|
-
},
|
|
54
|
-
class
|
|
56
|
+
}, z = 1073741823, v = typeof process < "u" && process.env && process.env.NODE_ENV !== "production", Be = Object.freeze([]);
|
|
57
|
+
class w extends Error {
|
|
55
58
|
/**
|
|
56
59
|
* Creates a new AtomError
|
|
57
60
|
* @param message - Error message describing what went wrong
|
|
@@ -62,7 +65,7 @@ class k extends Error {
|
|
|
62
65
|
super(e), this.name = "AtomError", this.cause = s, this.recoverable = n, this.timestamp = /* @__PURE__ */ new Date();
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
|
-
class
|
|
68
|
+
class Q extends w {
|
|
66
69
|
/**
|
|
67
70
|
* Creates a new ComputedError
|
|
68
71
|
* @param message - Error message
|
|
@@ -72,7 +75,7 @@ class X extends k {
|
|
|
72
75
|
super(e, s, !0), this.name = "ComputedError";
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
|
-
class V extends
|
|
78
|
+
class V extends w {
|
|
76
79
|
/**
|
|
77
80
|
* Creates a new EffectError
|
|
78
81
|
* @param message - Error message
|
|
@@ -82,7 +85,7 @@ class V extends k {
|
|
|
82
85
|
super(e, s, !1), this.name = "EffectError";
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
|
-
class
|
|
88
|
+
class se extends w {
|
|
86
89
|
/**
|
|
87
90
|
* Creates a new SchedulerError
|
|
88
91
|
* @param message - Error message
|
|
@@ -92,7 +95,7 @@ class ee extends k {
|
|
|
92
95
|
super(e, s, !1), this.name = "SchedulerError";
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
|
-
const
|
|
98
|
+
const g = {
|
|
96
99
|
// ─────────────────────────────────────────────────────────────────
|
|
97
100
|
// Computed errors
|
|
98
101
|
// ─────────────────────────────────────────────────────────────────
|
|
@@ -144,28 +147,28 @@ const y = {
|
|
|
144
147
|
* @remarks This prevents cascading failures from masking the original error.
|
|
145
148
|
*/
|
|
146
149
|
CALLBACK_ERROR_IN_ERROR_HANDLER: "Error occurred during onError callback execution"
|
|
147
|
-
},
|
|
148
|
-
function
|
|
150
|
+
}, fe = /* @__PURE__ */ Symbol("debugName"), qe = /* @__PURE__ */ Symbol("id"), de = /* @__PURE__ */ Symbol("type"), De = /* @__PURE__ */ Symbol("noDefaultValue");
|
|
151
|
+
function ze(t) {
|
|
149
152
|
return "dependencies" in t && Array.isArray(t.dependencies);
|
|
150
153
|
}
|
|
151
|
-
let
|
|
152
|
-
function
|
|
154
|
+
let Ie = 0;
|
|
155
|
+
function xe(t, e, s) {
|
|
153
156
|
if (t._visitedEpoch !== s) {
|
|
154
157
|
if (t._visitedEpoch = s, t === e)
|
|
155
|
-
throw new
|
|
156
|
-
if (
|
|
158
|
+
throw new Q("Indirect circular dependency detected");
|
|
159
|
+
if (ze(t)) {
|
|
157
160
|
const n = t.dependencies;
|
|
158
161
|
for (let i = 0; i < n.length; i++) {
|
|
159
162
|
const r = n[i];
|
|
160
|
-
r &&
|
|
163
|
+
r && xe(r, e, s);
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
167
|
}
|
|
165
|
-
const
|
|
168
|
+
const R = {
|
|
166
169
|
enabled: typeof process < "u" && process.env?.NODE_ENV === "development",
|
|
167
|
-
maxDependencies:
|
|
168
|
-
warnInfiniteLoop:
|
|
170
|
+
maxDependencies: ye.MAX_DEPENDENCIES,
|
|
171
|
+
warnInfiniteLoop: ye.WARN_INFINITE_LOOP,
|
|
169
172
|
warn(t, e) {
|
|
170
173
|
this.enabled && t && console.warn(`[Atom Effect] ${e}`);
|
|
171
174
|
},
|
|
@@ -176,32 +179,32 @@ const w = {
|
|
|
176
179
|
*/
|
|
177
180
|
checkCircular(t, e) {
|
|
178
181
|
if (t === e)
|
|
179
|
-
throw new
|
|
180
|
-
this.enabled && (
|
|
182
|
+
throw new Q("Direct circular dependency detected");
|
|
183
|
+
this.enabled && (Ie++, xe(t, e, Ie));
|
|
181
184
|
},
|
|
182
185
|
attachDebugInfo(t, e, s) {
|
|
183
186
|
if (!this.enabled)
|
|
184
187
|
return;
|
|
185
188
|
const n = t;
|
|
186
|
-
n[
|
|
189
|
+
n[fe] = `${e}_${s}`, n[qe] = s, n[de] = e;
|
|
187
190
|
},
|
|
188
191
|
getDebugName(t) {
|
|
189
|
-
if (t != null &&
|
|
190
|
-
return t[
|
|
192
|
+
if (t != null && fe in t)
|
|
193
|
+
return t[fe];
|
|
191
194
|
},
|
|
192
195
|
getDebugType(t) {
|
|
193
|
-
if (t != null &&
|
|
194
|
-
return t[
|
|
196
|
+
if (t != null && de in t)
|
|
197
|
+
return t[de];
|
|
195
198
|
}
|
|
196
199
|
};
|
|
197
|
-
let
|
|
198
|
-
const
|
|
199
|
-
class
|
|
200
|
+
let Xe = 1;
|
|
201
|
+
const Ge = () => Xe++;
|
|
202
|
+
class Re {
|
|
200
203
|
constructor() {
|
|
201
|
-
this.id =
|
|
204
|
+
this.id = Ge() & z, this.flags = 0;
|
|
202
205
|
}
|
|
203
206
|
}
|
|
204
|
-
class
|
|
207
|
+
class Ae extends Re {
|
|
205
208
|
constructor() {
|
|
206
209
|
super(), this.version = 0, this._lastSeenEpoch = -1;
|
|
207
210
|
}
|
|
@@ -216,7 +219,7 @@ class Ne extends ve {
|
|
|
216
219
|
if (typeof e == "object" && e !== null && "execute" in e)
|
|
217
220
|
return this._objectSubscribers.add(e);
|
|
218
221
|
if (typeof e != "function")
|
|
219
|
-
throw new
|
|
222
|
+
throw new w(g.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
|
|
220
223
|
return this._functionSubscribers.add(e);
|
|
221
224
|
}
|
|
222
225
|
/**
|
|
@@ -234,35 +237,35 @@ class Ne extends ve {
|
|
|
234
237
|
_notifySubscribers(e, s) {
|
|
235
238
|
this._functionSubscribers.forEachSafe(
|
|
236
239
|
(n) => n(e, s),
|
|
237
|
-
(n) => console.error(new
|
|
240
|
+
(n) => console.error(new w(g.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED, n))
|
|
238
241
|
), this._objectSubscribers.forEachSafe(
|
|
239
242
|
(n) => n.execute(),
|
|
240
|
-
(n) => console.error(new
|
|
243
|
+
(n) => console.error(new w(g.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED, n))
|
|
241
244
|
);
|
|
242
245
|
}
|
|
243
246
|
}
|
|
244
|
-
let
|
|
245
|
-
function
|
|
246
|
-
return
|
|
247
|
+
let ne = 0;
|
|
248
|
+
function Oe() {
|
|
249
|
+
return ne = ne + 1 & z || 1, ne;
|
|
247
250
|
}
|
|
248
|
-
function
|
|
249
|
-
return
|
|
251
|
+
function He() {
|
|
252
|
+
return ne;
|
|
250
253
|
}
|
|
251
|
-
let
|
|
252
|
-
function
|
|
253
|
-
return
|
|
254
|
+
let re = 0, pe = 0, oe = !1;
|
|
255
|
+
function Ce() {
|
|
256
|
+
return oe ? (v && console.warn(
|
|
254
257
|
"Warning: startFlush() called during flush - ignored to prevent infinite loop detection bypass"
|
|
255
|
-
), !1) : (
|
|
258
|
+
), !1) : (oe = !0, re = re + 1 & z, pe = 0, !0);
|
|
256
259
|
}
|
|
257
|
-
function
|
|
258
|
-
|
|
260
|
+
function ve() {
|
|
261
|
+
oe = !1;
|
|
259
262
|
}
|
|
260
263
|
function Qe() {
|
|
261
|
-
return
|
|
264
|
+
return oe ? ++pe : 0;
|
|
262
265
|
}
|
|
263
|
-
class
|
|
266
|
+
class Ye {
|
|
264
267
|
constructor() {
|
|
265
|
-
this.queueA = [], this.queueB = [], this.queue = this.queueA, this.queueSize = 0, this._epoch = 0, this.isProcessing = !1, this.isBatching = !1, this.batchDepth = 0, this.batchQueue = [], this.batchQueueSize = 0, this.isFlushingSync = !1, this.maxFlushIterations =
|
|
268
|
+
this.queueA = [], this.queueB = [], this.queue = this.queueA, this.queueSize = 0, this._epoch = 0, this.isProcessing = !1, this.isBatching = !1, this.batchDepth = 0, this.batchQueue = [], this.batchQueueSize = 0, this.isFlushingSync = !1, this.maxFlushIterations = B.MAX_FLUSH_ITERATIONS;
|
|
266
269
|
}
|
|
267
270
|
get phase() {
|
|
268
271
|
return this.isProcessing || this.isFlushingSync ? 2 : this.isBatching ? 1 : 0;
|
|
@@ -275,15 +278,15 @@ class He {
|
|
|
275
278
|
*/
|
|
276
279
|
schedule(e) {
|
|
277
280
|
if (typeof e != "function")
|
|
278
|
-
throw new
|
|
281
|
+
throw new se("Scheduler callback must be a function");
|
|
279
282
|
e._nextEpoch !== this._epoch && (e._nextEpoch = this._epoch, this.isBatching || this.isFlushingSync ? this.batchQueue[this.batchQueueSize++] = e : (this.queue[this.queueSize++] = e, this.isProcessing || this.flush()));
|
|
280
283
|
}
|
|
281
284
|
flush() {
|
|
282
285
|
this.isProcessing || this.queueSize === 0 || (this.isProcessing = !0, queueMicrotask(() => {
|
|
283
286
|
try {
|
|
284
287
|
if (this.queueSize === 0) return;
|
|
285
|
-
const e =
|
|
286
|
-
this._drainQueue(), e &&
|
|
288
|
+
const e = Ce();
|
|
289
|
+
this._drainQueue(), e && ve();
|
|
287
290
|
} finally {
|
|
288
291
|
this.isProcessing = !1, this.queueSize > 0 && !this.isBatching && this.flush();
|
|
289
292
|
}
|
|
@@ -291,11 +294,11 @@ class He {
|
|
|
291
294
|
}
|
|
292
295
|
flushSync() {
|
|
293
296
|
this.isFlushingSync = !0;
|
|
294
|
-
const e =
|
|
297
|
+
const e = Ce();
|
|
295
298
|
try {
|
|
296
299
|
this._mergeBatchQueue(), this._drainQueue();
|
|
297
300
|
} finally {
|
|
298
|
-
this.isFlushingSync = !1, e &&
|
|
301
|
+
this.isFlushingSync = !1, e && ve();
|
|
299
302
|
}
|
|
300
303
|
}
|
|
301
304
|
_mergeBatchQueue() {
|
|
@@ -323,7 +326,7 @@ class He {
|
|
|
323
326
|
}
|
|
324
327
|
_handleFlushOverflow() {
|
|
325
328
|
console.error(
|
|
326
|
-
new
|
|
329
|
+
new se(
|
|
327
330
|
`Maximum flush iterations (${this.maxFlushIterations}) exceeded. Possible infinite loop.`
|
|
328
331
|
)
|
|
329
332
|
), this.queueSize = 0, this.queue.length = 0, this.batchQueueSize = 0;
|
|
@@ -334,7 +337,7 @@ class He {
|
|
|
334
337
|
e[n]?.();
|
|
335
338
|
} catch (i) {
|
|
336
339
|
console.error(
|
|
337
|
-
new
|
|
340
|
+
new se("Error occurred during scheduler execution", i)
|
|
338
341
|
);
|
|
339
342
|
}
|
|
340
343
|
e.length = 0;
|
|
@@ -355,51 +358,64 @@ class He {
|
|
|
355
358
|
* @param max - Maximum iterations count.
|
|
356
359
|
*/
|
|
357
360
|
setMaxFlushIterations(e) {
|
|
358
|
-
if (e <
|
|
359
|
-
throw new
|
|
360
|
-
`Max flush iterations must be at least ${
|
|
361
|
+
if (e < B.MIN_FLUSH_ITERATIONS)
|
|
362
|
+
throw new se(
|
|
363
|
+
`Max flush iterations must be at least ${B.MIN_FLUSH_ITERATIONS}`
|
|
361
364
|
);
|
|
362
365
|
this.maxFlushIterations = e;
|
|
363
366
|
}
|
|
364
367
|
}
|
|
365
|
-
const
|
|
366
|
-
function
|
|
368
|
+
const Z = new Ye();
|
|
369
|
+
function Je(t) {
|
|
367
370
|
if (typeof t != "function")
|
|
368
|
-
throw new
|
|
369
|
-
|
|
371
|
+
throw new w("Batch callback must be a function");
|
|
372
|
+
Z.startBatch();
|
|
370
373
|
try {
|
|
371
374
|
return t();
|
|
372
375
|
} finally {
|
|
373
|
-
|
|
376
|
+
Z.endBatch();
|
|
374
377
|
}
|
|
375
378
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
379
|
+
class Ke {
|
|
380
|
+
constructor() {
|
|
381
|
+
this.current = null;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Runs the provided function within the context of the given listener.
|
|
385
|
+
* Restores the previous context after the function completes or throws.
|
|
386
|
+
*
|
|
387
|
+
* @param listener - The tracking listener to associate with the current execution.
|
|
388
|
+
* @param fn - The function to execute.
|
|
389
|
+
*/
|
|
390
|
+
run(e, s) {
|
|
391
|
+
const n = this.current;
|
|
392
|
+
this.current = e;
|
|
381
393
|
try {
|
|
382
|
-
return
|
|
394
|
+
return s();
|
|
383
395
|
} finally {
|
|
384
|
-
this.current =
|
|
396
|
+
this.current = n;
|
|
385
397
|
}
|
|
386
|
-
}
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Retrieves the listener currently associated with the tracking context.
|
|
401
|
+
*/
|
|
387
402
|
getCurrent() {
|
|
388
403
|
return this.current;
|
|
389
404
|
}
|
|
390
|
-
}
|
|
391
|
-
|
|
405
|
+
}
|
|
406
|
+
const X = new Ke();
|
|
407
|
+
function Ue(t) {
|
|
392
408
|
if (typeof t != "function")
|
|
393
|
-
throw new
|
|
394
|
-
const e =
|
|
395
|
-
|
|
409
|
+
throw new w("Untracked callback must be a function");
|
|
410
|
+
const e = X.current;
|
|
411
|
+
X.current = null;
|
|
396
412
|
try {
|
|
397
413
|
return t();
|
|
398
414
|
} finally {
|
|
399
|
-
|
|
415
|
+
X.current = e;
|
|
400
416
|
}
|
|
401
417
|
}
|
|
402
|
-
class
|
|
418
|
+
class ce {
|
|
403
419
|
constructor() {
|
|
404
420
|
this.subscribers = null;
|
|
405
421
|
}
|
|
@@ -455,9 +471,9 @@ class re {
|
|
|
455
471
|
return this.subscribers ? [...this.subscribers] : [];
|
|
456
472
|
}
|
|
457
473
|
}
|
|
458
|
-
class
|
|
474
|
+
class be {
|
|
459
475
|
constructor() {
|
|
460
|
-
this.pool = [], this.maxPoolSize = 50, this.maxReusableCapacity = 256, this.stats =
|
|
476
|
+
this.pool = [], this.maxPoolSize = 50, this.maxReusableCapacity = 256, this.stats = v ? {
|
|
461
477
|
acquired: 0,
|
|
462
478
|
released: 0,
|
|
463
479
|
rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
|
|
@@ -465,7 +481,7 @@ class de {
|
|
|
465
481
|
}
|
|
466
482
|
/** Acquires an array from the pool or creates a new one if the pool is empty. */
|
|
467
483
|
acquire() {
|
|
468
|
-
return
|
|
484
|
+
return v && this.stats && this.stats.acquired++, this.pool.pop() ?? [];
|
|
469
485
|
}
|
|
470
486
|
/**
|
|
471
487
|
* Releases an array back to the pool.
|
|
@@ -476,23 +492,23 @@ class de {
|
|
|
476
492
|
release(e, s) {
|
|
477
493
|
if (!(s && e === s)) {
|
|
478
494
|
if (Object.isFrozen(e)) {
|
|
479
|
-
|
|
495
|
+
v && this.stats && this.stats.rejected.frozen++;
|
|
480
496
|
return;
|
|
481
497
|
}
|
|
482
498
|
if (e.length > this.maxReusableCapacity) {
|
|
483
|
-
|
|
499
|
+
v && this.stats && this.stats.rejected.tooLarge++;
|
|
484
500
|
return;
|
|
485
501
|
}
|
|
486
502
|
if (this.pool.length >= this.maxPoolSize) {
|
|
487
|
-
|
|
503
|
+
v && this.stats && this.stats.rejected.poolFull++;
|
|
488
504
|
return;
|
|
489
505
|
}
|
|
490
|
-
e.length = 0, this.pool.push(e),
|
|
506
|
+
e.length = 0, this.pool.push(e), v && this.stats && this.stats.released++;
|
|
491
507
|
}
|
|
492
508
|
}
|
|
493
509
|
/** Returns current stats for the pool (dev mode only). */
|
|
494
510
|
getStats() {
|
|
495
|
-
if (!
|
|
511
|
+
if (!v || !this.stats) return null;
|
|
496
512
|
const { acquired: e, released: s, rejected: n } = this.stats, i = n.frozen + n.tooLarge + n.poolFull;
|
|
497
513
|
return {
|
|
498
514
|
acquired: e,
|
|
@@ -504,142 +520,145 @@ class de {
|
|
|
504
520
|
}
|
|
505
521
|
/** Resets the pool and its stats. */
|
|
506
522
|
reset() {
|
|
507
|
-
this.pool.length = 0,
|
|
523
|
+
this.pool.length = 0, v && this.stats && (this.stats.acquired = 0, this.stats.released = 0, this.stats.rejected = { frozen: 0, tooLarge: 0, poolFull: 0 });
|
|
508
524
|
}
|
|
509
525
|
}
|
|
510
|
-
const S = Object.freeze([]),
|
|
511
|
-
function
|
|
526
|
+
const S = Object.freeze([]), T = Object.freeze([]), y = Object.freeze([]), F = new be(), q = new be(), x = new be();
|
|
527
|
+
function _e(t) {
|
|
512
528
|
return t !== null && typeof t == "object" && "value" in t && "subscribe" in t && typeof t.subscribe == "function";
|
|
513
529
|
}
|
|
514
|
-
function
|
|
515
|
-
if (
|
|
516
|
-
const e =
|
|
530
|
+
function Ne(t) {
|
|
531
|
+
if (R.enabled && (t == null || typeof t == "object")) {
|
|
532
|
+
const e = R.getDebugType(t);
|
|
517
533
|
if (e)
|
|
518
534
|
return e === "computed";
|
|
519
535
|
}
|
|
520
|
-
return
|
|
536
|
+
return _e(t) && "invalidate" in t && typeof t.invalidate == "function";
|
|
521
537
|
}
|
|
522
|
-
function
|
|
538
|
+
function we(t) {
|
|
523
539
|
return t != null && typeof t.then == "function";
|
|
524
540
|
}
|
|
525
|
-
function
|
|
541
|
+
function We(t) {
|
|
526
542
|
return typeof t == "object" && t !== null;
|
|
527
543
|
}
|
|
528
|
-
function
|
|
544
|
+
function Ze(t) {
|
|
529
545
|
return (typeof t == "object" || typeof t == "function") && t !== null && typeof t.addDependency == "function";
|
|
530
546
|
}
|
|
531
|
-
function
|
|
547
|
+
function et(t) {
|
|
532
548
|
return typeof t == "function" && typeof t.addDependency != "function";
|
|
533
549
|
}
|
|
534
|
-
function
|
|
535
|
-
return
|
|
550
|
+
function tt(t) {
|
|
551
|
+
return We(t) && typeof t.execute == "function";
|
|
536
552
|
}
|
|
537
|
-
function
|
|
553
|
+
function ke(t, e, s, n) {
|
|
538
554
|
if (e) {
|
|
539
|
-
if (
|
|
555
|
+
if (Ze(e)) {
|
|
540
556
|
e.addDependency(t);
|
|
541
557
|
return;
|
|
542
558
|
}
|
|
543
|
-
if (
|
|
559
|
+
if (et(e)) {
|
|
544
560
|
s.add(e);
|
|
545
561
|
return;
|
|
546
562
|
}
|
|
547
|
-
|
|
563
|
+
tt(e) && n.add(e);
|
|
548
564
|
}
|
|
549
565
|
}
|
|
550
|
-
function
|
|
551
|
-
if (e !== S && s !==
|
|
566
|
+
function st(t, e, s, n) {
|
|
567
|
+
if (e !== S && s !== T)
|
|
552
568
|
for (let r = 0; r < e.length; r++) {
|
|
553
569
|
const o = e[r];
|
|
554
570
|
o && (o._tempUnsub = s[r]);
|
|
555
571
|
}
|
|
556
|
-
const i =
|
|
572
|
+
const i = q.acquire();
|
|
557
573
|
i.length = t.length;
|
|
558
574
|
for (let r = 0; r < t.length; r++) {
|
|
559
575
|
const o = t[r];
|
|
560
|
-
o && (o._tempUnsub ? (i[r] = o._tempUnsub, o._tempUnsub = void 0) : (
|
|
576
|
+
o && (o._tempUnsub ? (i[r] = o._tempUnsub, o._tempUnsub = void 0) : (R.checkCircular(o, n), i[r] = o.subscribe(n)));
|
|
561
577
|
}
|
|
562
578
|
if (e !== S)
|
|
563
579
|
for (let r = 0; r < e.length; r++) {
|
|
564
580
|
const o = e[r];
|
|
565
581
|
o?._tempUnsub && (o._tempUnsub(), o._tempUnsub = void 0);
|
|
566
582
|
}
|
|
567
|
-
return s !==
|
|
583
|
+
return s !== T && q.release(s), i;
|
|
568
584
|
}
|
|
569
|
-
class
|
|
585
|
+
class nt extends Ae {
|
|
570
586
|
constructor(e, s) {
|
|
571
|
-
super(), this.
|
|
587
|
+
super(), this._functionSubscribersStore = null, this._objectSubscribersStore = null, this._value = e, s && (this.flags |= Y.SYNC), R.attachDebugInfo(this, "atom", this.id);
|
|
572
588
|
}
|
|
573
|
-
/** Gets the manager for function-based subscribers. */
|
|
574
589
|
get _functionSubscribers() {
|
|
575
|
-
return this._functionSubscribersStore;
|
|
590
|
+
return this._functionSubscribersStore || (this._functionSubscribersStore = new ce()), this._functionSubscribersStore;
|
|
576
591
|
}
|
|
577
|
-
/** Gets the manager for object-based subscribers. */
|
|
578
592
|
get _objectSubscribers() {
|
|
579
|
-
return this._objectSubscribersStore;
|
|
593
|
+
return this._objectSubscribersStore || (this._objectSubscribersStore = new ce()), this._objectSubscribersStore;
|
|
580
594
|
}
|
|
581
595
|
/**
|
|
582
|
-
* Returns the current value and registers the atom as a dependency in
|
|
596
|
+
* Returns the current value and registers the atom as a dependency if in a tracking context.
|
|
583
597
|
*/
|
|
584
598
|
get value() {
|
|
585
|
-
const e =
|
|
586
|
-
return e && this.
|
|
599
|
+
const e = X.current;
|
|
600
|
+
return e && ke(this, e, this._functionSubscribers, this._objectSubscribers), this._value;
|
|
587
601
|
}
|
|
588
602
|
/**
|
|
589
603
|
* Sets a new value and schedules notifications if the value has changed.
|
|
590
|
-
* Uses `Object.is` for comparison.
|
|
591
604
|
*/
|
|
592
605
|
set value(e) {
|
|
593
606
|
if (Object.is(this._value, e)) return;
|
|
594
607
|
const s = this._value;
|
|
595
|
-
this.
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
Ue(this, e, this._functionSubscribersStore, this._objectSubscribersStore);
|
|
608
|
+
this._value = e, this.version = this.version + 1 & z;
|
|
609
|
+
const n = this._functionSubscribersStore?.hasSubscribers, i = this._objectSubscribersStore?.hasSubscribers;
|
|
610
|
+
(n || i) && this._scheduleNotification(s);
|
|
599
611
|
}
|
|
612
|
+
/**
|
|
613
|
+
* Schedules or flushes notifications based on sync mode and batching state.
|
|
614
|
+
*/
|
|
600
615
|
_scheduleNotification(e) {
|
|
601
|
-
this.
|
|
616
|
+
if (this.flags & Y.NOTIFICATION_SCHEDULED || (this._pendingOldValue = e, this.flags |= Y.NOTIFICATION_SCHEDULED), this.flags & Y.SYNC && !Z.isBatching) {
|
|
617
|
+
this._flushNotifications();
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
this._notifyTask || (this._notifyTask = () => this._flushNotifications()), Z.schedule(this._notifyTask);
|
|
602
621
|
}
|
|
603
622
|
_flushNotifications() {
|
|
604
|
-
if (!this.
|
|
623
|
+
if (!(this.flags & Y.NOTIFICATION_SCHEDULED)) return;
|
|
605
624
|
const e = this._pendingOldValue, s = this._value;
|
|
606
|
-
this._pendingOldValue = void 0, this.
|
|
625
|
+
this._pendingOldValue = void 0, this.flags &= -3, this._notifySubscribers(s, e);
|
|
607
626
|
}
|
|
608
627
|
/**
|
|
609
|
-
*
|
|
628
|
+
* Overridden to avoid unnecessary manager creation during notification loop.
|
|
610
629
|
*/
|
|
630
|
+
_notifySubscribers(e, s) {
|
|
631
|
+
this._functionSubscribersStore && this._functionSubscribersStore.forEachSafe((n) => n(e, s)), this._objectSubscribersStore && this._objectSubscribersStore.forEachSafe((n) => n.execute());
|
|
632
|
+
}
|
|
611
633
|
peek() {
|
|
612
634
|
return this._value;
|
|
613
635
|
}
|
|
614
|
-
/**
|
|
615
|
-
* Disposes of the atom, clearing all subscribers and resetting the value.
|
|
616
|
-
*/
|
|
617
636
|
dispose() {
|
|
618
|
-
this._functionSubscribersStore
|
|
637
|
+
this._functionSubscribersStore?.clear(), this._objectSubscribersStore?.clear(), this._value = void 0, this._notifyTask = void 0;
|
|
619
638
|
}
|
|
620
639
|
}
|
|
621
|
-
function
|
|
622
|
-
return new
|
|
640
|
+
function it(t, e = {}) {
|
|
641
|
+
return new nt(t, e.sync ?? !1);
|
|
623
642
|
}
|
|
624
|
-
function
|
|
643
|
+
function K(t, e, s) {
|
|
625
644
|
if (t instanceof TypeError)
|
|
626
645
|
return new e(`Type error (${s}): ${t.message}`, t);
|
|
627
646
|
if (t instanceof ReferenceError)
|
|
628
647
|
return new e(`Reference error (${s}): ${t.message}`, t);
|
|
629
|
-
if (t instanceof
|
|
648
|
+
if (t instanceof w)
|
|
630
649
|
return t;
|
|
631
650
|
const n = t instanceof Error ? t.message : String(t), i = t instanceof Error ? t : null;
|
|
632
651
|
return new e(`Unexpected error (${s}): ${n}`, i);
|
|
633
652
|
}
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
class
|
|
653
|
+
const Fe = d.RESOLVED | d.PENDING | d.REJECTED, he = Array(Fe + 1).fill(ue.IDLE);
|
|
654
|
+
he[d.RESOLVED] = ue.RESOLVED;
|
|
655
|
+
he[d.PENDING] = ue.PENDING;
|
|
656
|
+
he[d.REJECTED] = ue.REJECTED;
|
|
657
|
+
class Me extends Ae {
|
|
639
658
|
constructor(e, s = {}) {
|
|
640
659
|
if (typeof e != "function")
|
|
641
|
-
throw new
|
|
642
|
-
if (super(), this._cachedErrors = null, this._errorCacheEpoch = -1, this._value = void 0, this.flags = d.DIRTY | d.IDLE, this._error = null, this._promiseId = 0, this._equal = s.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in s ? s.defaultValue :
|
|
660
|
+
throw new Q(g.COMPUTED_MUST_BE_FUNCTION);
|
|
661
|
+
if (super(), this._cachedErrors = null, this._errorCacheEpoch = -1, this._value = void 0, this.flags = d.DIRTY | d.IDLE, this._error = null, this._promiseId = 0, this._equal = s.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in s ? s.defaultValue : De, this._hasDefaultValue = this._defaultValue !== De, this._onError = s.onError ?? null, this.MAX_PROMISE_ID = Number.MAX_SAFE_INTEGER - 1, this._functionSubscribersStore = new ce(), this._objectSubscribersStore = new ce(), this._dependencies = S, this._dependencyVersions = y, this._unsubscribes = T, this._notifyJob = () => {
|
|
643
662
|
this._functionSubscribersStore.forEachSafe(
|
|
644
663
|
(n) => n(),
|
|
645
664
|
(n) => console.error(n)
|
|
@@ -650,7 +669,7 @@ class Ae extends Ne {
|
|
|
650
669
|
}, this._trackable = Object.assign(() => this._markDirty(), {
|
|
651
670
|
addDependency: (n) => {
|
|
652
671
|
}
|
|
653
|
-
}),
|
|
672
|
+
}), R.attachDebugInfo(this, "computed", this.id), R.enabled) {
|
|
654
673
|
const n = this;
|
|
655
674
|
n.subscriberCount = () => this._functionSubscribersStore.size + this._objectSubscribersStore.size, n.isDirty = () => this._isDirty(), n.dependencies = this._dependencies, n.stateFlags = this._getFlagsAsString();
|
|
656
675
|
}
|
|
@@ -690,8 +709,8 @@ class Ae extends Ne {
|
|
|
690
709
|
}
|
|
691
710
|
get errors() {
|
|
692
711
|
if (this._registerTracking(), !this.hasError)
|
|
693
|
-
return
|
|
694
|
-
const e =
|
|
712
|
+
return Be;
|
|
713
|
+
const e = He();
|
|
695
714
|
if (this._errorCacheEpoch === e && this._cachedErrors !== null)
|
|
696
715
|
return this._cachedErrors;
|
|
697
716
|
const s = /* @__PURE__ */ new Set();
|
|
@@ -718,17 +737,17 @@ class Ae extends Ne {
|
|
|
718
737
|
return this._registerTracking(), this._isResolved();
|
|
719
738
|
}
|
|
720
739
|
invalidate() {
|
|
721
|
-
this._markDirty(), this._dependencyVersions !==
|
|
740
|
+
this._markDirty(), this._dependencyVersions !== y && (x.release(this._dependencyVersions), this._dependencyVersions = y), this._errorCacheEpoch = -1, this._cachedErrors = null;
|
|
722
741
|
}
|
|
723
742
|
dispose() {
|
|
724
|
-
if (this._unsubscribes !==
|
|
743
|
+
if (this._unsubscribes !== T) {
|
|
725
744
|
for (let e = 0; e < this._unsubscribes.length; e++) {
|
|
726
745
|
const s = this._unsubscribes[e];
|
|
727
746
|
s && s();
|
|
728
747
|
}
|
|
729
|
-
|
|
748
|
+
q.release(this._unsubscribes), this._unsubscribes = T;
|
|
730
749
|
}
|
|
731
|
-
this._dependencies !== S && (
|
|
750
|
+
this._dependencies !== S && (F.release(this._dependencies), this._dependencies = S), this._dependencyVersions !== y && (x.release(this._dependencyVersions), this._dependencyVersions = y), this._functionSubscribersStore.clear(), this._objectSubscribersStore.clear(), this.flags = d.DIRTY | d.IDLE, this._error = null, this._value = void 0, this._promiseId = (this._promiseId + 1) % this.MAX_PROMISE_ID, this._cachedErrors = null, this._errorCacheEpoch = -1;
|
|
732
751
|
}
|
|
733
752
|
// State flag operations
|
|
734
753
|
_isDirty() {
|
|
@@ -772,7 +791,7 @@ class Ae extends Ne {
|
|
|
772
791
|
this.flags = this.flags & ~s | -Number(e) & s;
|
|
773
792
|
}
|
|
774
793
|
_getAsyncState() {
|
|
775
|
-
return
|
|
794
|
+
return he[this.flags & Fe];
|
|
776
795
|
}
|
|
777
796
|
_getFlagsAsString() {
|
|
778
797
|
const e = [];
|
|
@@ -787,8 +806,8 @@ class Ae extends Ne {
|
|
|
787
806
|
const e = this._prepareComputationContext();
|
|
788
807
|
let s = !1;
|
|
789
808
|
try {
|
|
790
|
-
const n =
|
|
791
|
-
this._commitDependencies(e), s = !0,
|
|
809
|
+
const n = X.run(this._trackable, this._fn);
|
|
810
|
+
this._commitDependencies(e), s = !0, we(n) ? this._handleAsyncComputation(n) : this._handleSyncResult(n);
|
|
792
811
|
} catch (n) {
|
|
793
812
|
if (!s)
|
|
794
813
|
try {
|
|
@@ -802,21 +821,21 @@ class Ae extends Ne {
|
|
|
802
821
|
}
|
|
803
822
|
}
|
|
804
823
|
_prepareComputationContext() {
|
|
805
|
-
const e = this._dependencies, s = this._dependencyVersions, n =
|
|
824
|
+
const e = this._dependencies, s = this._dependencyVersions, n = F.acquire(), i = x.acquire(), r = Oe(), o = { depCount: 0 }, c = (_) => {
|
|
806
825
|
_._lastSeenEpoch !== r && (_._lastSeenEpoch = r, o.depCount < n.length ? (n[o.depCount] = _, i[o.depCount] = _.version) : (n.push(_), i.push(_.version)), o.depCount++);
|
|
807
|
-
},
|
|
808
|
-
return this._trackable.addDependency = c, { prevDeps: e, prevVersions: s, nextDeps: n, nextVersions: i, originalAdd:
|
|
826
|
+
}, h = this._trackable.addDependency;
|
|
827
|
+
return this._trackable.addDependency = c, { prevDeps: e, prevVersions: s, nextDeps: n, nextVersions: i, originalAdd: h, state: o };
|
|
809
828
|
}
|
|
810
829
|
_commitDependencies(e) {
|
|
811
830
|
const { nextDeps: s, nextVersions: n, state: i, prevDeps: r } = e;
|
|
812
|
-
s.length = i.depCount, n.length = i.depCount, this._unsubscribes =
|
|
831
|
+
s.length = i.depCount, n.length = i.depCount, this._unsubscribes = st(s, r, this._unsubscribes, this), this._dependencies = s, this._dependencyVersions = n;
|
|
813
832
|
}
|
|
814
833
|
_cleanupContext(e, s) {
|
|
815
|
-
this._trackable.addDependency = e.originalAdd, s ? (e.prevDeps !== S &&
|
|
834
|
+
this._trackable.addDependency = e.originalAdd, s ? (e.prevDeps !== S && F.release(e.prevDeps), e.prevVersions !== y && x.release(e.prevVersions)) : (F.release(e.nextDeps), x.release(e.nextVersions));
|
|
816
835
|
}
|
|
817
836
|
_handleSyncResult(e) {
|
|
818
837
|
const s = !this._isResolved() || !this._equal(this._value, e);
|
|
819
|
-
this.version = this.version + Number(s) &
|
|
838
|
+
this.version = this.version + Number(s) & z, this._value = e, this._clearDirty(), this._setResolved(), this._error = null, this._setRecomputing(!1), this._cachedErrors = null, this._errorCacheEpoch = -1;
|
|
820
839
|
}
|
|
821
840
|
_handleAsyncComputation(e) {
|
|
822
841
|
this._setPending(), this._clearDirty(), this._notifyJob(), this._promiseId = this._promiseId >= this.MAX_PROMISE_ID ? 1 : this._promiseId + 1;
|
|
@@ -829,32 +848,32 @@ class Ae extends Ne {
|
|
|
829
848
|
}
|
|
830
849
|
_handleAsyncResolution(e) {
|
|
831
850
|
const s = !this._isResolved() || !this._equal(this._value, e);
|
|
832
|
-
this.version = this.version + Number(s) &
|
|
851
|
+
this.version = this.version + Number(s) & z, this._value = e, this._clearDirty(), this._setResolved(), this._error = null, this._setRecomputing(!1), this._cachedErrors = null, this._errorCacheEpoch = -1, this._notifyJob();
|
|
833
852
|
}
|
|
834
853
|
_handleAsyncRejection(e) {
|
|
835
|
-
const s =
|
|
836
|
-
if (this.version = this.version + Number(n) &
|
|
854
|
+
const s = K(e, Q, g.COMPUTED_ASYNC_COMPUTATION_FAILED), n = !this._isRejected();
|
|
855
|
+
if (this.version = this.version + Number(n) & z, this._error = s, this._setRejected(), this._clearDirty(), this._setRecomputing(!1), this._onError)
|
|
837
856
|
try {
|
|
838
857
|
this._onError(s);
|
|
839
858
|
} catch (i) {
|
|
840
|
-
console.error(
|
|
859
|
+
console.error(g.CALLBACK_ERROR_IN_ERROR_HANDLER, i);
|
|
841
860
|
}
|
|
842
861
|
this._notifyJob();
|
|
843
862
|
}
|
|
844
863
|
_handleComputationError(e) {
|
|
845
|
-
const s =
|
|
864
|
+
const s = K(e, Q, g.COMPUTED_COMPUTATION_FAILED);
|
|
846
865
|
if (this._error = s, this._setRejected(), this._clearDirty(), this._setRecomputing(!1), this._onError)
|
|
847
866
|
try {
|
|
848
867
|
this._onError(s);
|
|
849
868
|
} catch (n) {
|
|
850
|
-
console.error(
|
|
869
|
+
console.error(g.CALLBACK_ERROR_IN_ERROR_HANDLER, n);
|
|
851
870
|
}
|
|
852
871
|
throw s;
|
|
853
872
|
}
|
|
854
873
|
_handlePending() {
|
|
855
874
|
if (this._hasDefaultValue)
|
|
856
875
|
return this._defaultValue;
|
|
857
|
-
throw new
|
|
876
|
+
throw new Q(g.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
858
877
|
}
|
|
859
878
|
_handleRejected() {
|
|
860
879
|
if (this._error?.recoverable && this._hasDefaultValue)
|
|
@@ -869,19 +888,19 @@ class Ae extends Ne {
|
|
|
869
888
|
this._isRecomputing() || this._isDirty() || (this._setDirty(), this._notifyJob());
|
|
870
889
|
}
|
|
871
890
|
_registerTracking() {
|
|
872
|
-
|
|
891
|
+
ke(
|
|
873
892
|
this,
|
|
874
|
-
|
|
893
|
+
X.getCurrent(),
|
|
875
894
|
this._functionSubscribersStore,
|
|
876
895
|
this._objectSubscribersStore
|
|
877
896
|
);
|
|
878
897
|
}
|
|
879
898
|
}
|
|
880
|
-
Object.freeze(
|
|
881
|
-
function
|
|
882
|
-
return new
|
|
899
|
+
Object.freeze(Me.prototype);
|
|
900
|
+
function rt(t, e = {}) {
|
|
901
|
+
return new Me(t, e);
|
|
883
902
|
}
|
|
884
|
-
class
|
|
903
|
+
class ot extends Re {
|
|
885
904
|
/**
|
|
886
905
|
* Creates a new EffectImpl instance.
|
|
887
906
|
* @param fn - The effect function to run.
|
|
@@ -890,18 +909,18 @@ class nt extends ve {
|
|
|
890
909
|
constructor(e, s = {}) {
|
|
891
910
|
super(), this.run = () => {
|
|
892
911
|
if (this.isDisposed)
|
|
893
|
-
throw new V(
|
|
894
|
-
this._dependencyVersions !==
|
|
912
|
+
throw new V(g.EFFECT_MUST_BE_FUNCTION);
|
|
913
|
+
this._dependencyVersions !== y && (x.release(this._dependencyVersions), this._dependencyVersions = y), this.execute();
|
|
895
914
|
}, this.dispose = () => {
|
|
896
915
|
if (!this.isDisposed) {
|
|
897
|
-
if (this._setDisposed(), this._safeCleanup(), this._unsubscribes !==
|
|
916
|
+
if (this._setDisposed(), this._safeCleanup(), this._unsubscribes !== T) {
|
|
898
917
|
for (let i = 0; i < this._unsubscribes.length; i++) {
|
|
899
918
|
const r = this._unsubscribes[i];
|
|
900
919
|
r && r();
|
|
901
920
|
}
|
|
902
|
-
|
|
921
|
+
q.release(this._unsubscribes), this._unsubscribes = T;
|
|
903
922
|
}
|
|
904
|
-
this._dependencies !== S && (
|
|
923
|
+
this._dependencies !== S && (F.release(this._dependencies), this._dependencies = S), this._dependencyVersions !== y && (x.release(this._dependencyVersions), this._dependencyVersions = y);
|
|
905
924
|
}
|
|
906
925
|
}, this.addDependency = (i) => {
|
|
907
926
|
if (this.isExecuting && this._nextDeps && this._nextUnsubs && this._nextVersions) {
|
|
@@ -915,8 +934,8 @@ class nt extends ve {
|
|
|
915
934
|
const i = this._prepareEffectContext();
|
|
916
935
|
let r = !1;
|
|
917
936
|
try {
|
|
918
|
-
const o =
|
|
919
|
-
this._commitEffect(i), r = !0, this._checkLoopWarnings(),
|
|
937
|
+
const o = X.run(this, this._fn);
|
|
938
|
+
this._commitEffect(i), r = !0, this._checkLoopWarnings(), we(o) ? o.then((c) => {
|
|
920
939
|
!this.isDisposed && typeof c == "function" && (this._cleanup = c);
|
|
921
940
|
}).catch((c) => {
|
|
922
941
|
this._handleExecutionError(c);
|
|
@@ -926,20 +945,20 @@ class nt extends ve {
|
|
|
926
945
|
} finally {
|
|
927
946
|
this._cleanupEffect(i, r), this._setExecuting(!1);
|
|
928
947
|
}
|
|
929
|
-
}, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._fn = e, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ??
|
|
948
|
+
}, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._fn = e, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? B.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? B.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = s.trackModifications ?? !1, this._cleanup = null, this._dependencies = S, this._dependencyVersions = y, this._unsubscribes = T, this._nextDeps = null, this._nextVersions = null, this._nextUnsubs = null, this._onError = s.onError ?? null, this._historyPtr = 0;
|
|
930
949
|
const n = Number.isFinite(this._maxExecutions);
|
|
931
|
-
this._historyCapacity = n ? Math.min(this._maxExecutions + 1,
|
|
950
|
+
this._historyCapacity = n ? Math.min(this._maxExecutions + 1, B.MAX_EXECUTIONS_PER_SECOND + 1) : 0, this._history = v && n && this._historyCapacity > 0 ? new Array(this._historyCapacity).fill(0) : null, this._executionCount = 0, R.attachDebugInfo(this, "effect", this.id);
|
|
932
951
|
}
|
|
933
952
|
/**
|
|
934
953
|
* Prepares the execution context by acquiring pools and setting up epoch.
|
|
935
954
|
* @returns The prepared EffectContext.
|
|
936
955
|
*/
|
|
937
956
|
_prepareEffectContext() {
|
|
938
|
-
const e = this._dependencies, s = this._dependencyVersions, n = this._unsubscribes, i =
|
|
939
|
-
if (e !== S && n !==
|
|
940
|
-
for (let
|
|
941
|
-
const _ = e[
|
|
942
|
-
_ && (_._tempUnsub = n[
|
|
957
|
+
const e = this._dependencies, s = this._dependencyVersions, n = this._unsubscribes, i = F.acquire(), r = x.acquire(), o = q.acquire(), c = Oe();
|
|
958
|
+
if (e !== S && n !== T)
|
|
959
|
+
for (let h = 0; h < e.length; h++) {
|
|
960
|
+
const _ = e[h];
|
|
961
|
+
_ && (_._tempUnsub = n[h]);
|
|
943
962
|
}
|
|
944
963
|
return this._nextDeps = i, this._nextVersions = r, this._nextUnsubs = o, this._currentEpoch = c, { prevDeps: e, prevVersions: s, prevUnsubs: n, nextDeps: i, nextVersions: r, nextUnsubs: o };
|
|
945
964
|
}
|
|
@@ -963,14 +982,14 @@ class nt extends ve {
|
|
|
963
982
|
const i = e.prevDeps[n];
|
|
964
983
|
i?._tempUnsub && (i._tempUnsub(), i._tempUnsub = void 0);
|
|
965
984
|
}
|
|
966
|
-
|
|
985
|
+
F.release(e.prevDeps);
|
|
967
986
|
}
|
|
968
|
-
e.prevUnsubs !==
|
|
987
|
+
e.prevUnsubs !== T && q.release(e.prevUnsubs), e.prevVersions !== y && x.release(e.prevVersions);
|
|
969
988
|
} else {
|
|
970
|
-
|
|
989
|
+
F.release(e.nextDeps), x.release(e.nextVersions);
|
|
971
990
|
for (let n = 0; n < e.nextUnsubs.length; n++)
|
|
972
991
|
e.nextUnsubs[n]?.();
|
|
973
|
-
if (
|
|
992
|
+
if (q.release(e.nextUnsubs), e.prevDeps !== S)
|
|
974
993
|
for (let n = 0; n < e.prevDeps.length; n++) {
|
|
975
994
|
const i = e.prevDeps[n];
|
|
976
995
|
i && (i._tempUnsub = void 0);
|
|
@@ -984,11 +1003,11 @@ class nt extends ve {
|
|
|
984
1003
|
_subscribeTo(e) {
|
|
985
1004
|
try {
|
|
986
1005
|
const s = e.subscribe(() => {
|
|
987
|
-
this._trackModifications && this.isExecuting && (e._modifiedAtEpoch = this._currentEpoch), this._sync ? this.execute() :
|
|
1006
|
+
this._trackModifications && this.isExecuting && (e._modifiedAtEpoch = this._currentEpoch), this._sync ? this.execute() : Z.schedule(this.execute);
|
|
988
1007
|
});
|
|
989
1008
|
this._nextUnsubs && this._nextUnsubs.push(s);
|
|
990
1009
|
} catch (s) {
|
|
991
|
-
console.error(
|
|
1010
|
+
console.error(K(s, V, g.EFFECT_EXECUTION_FAILED)), this._nextUnsubs && this._nextUnsubs.push(() => {
|
|
992
1011
|
});
|
|
993
1012
|
}
|
|
994
1013
|
}
|
|
@@ -996,7 +1015,7 @@ class nt extends ve {
|
|
|
996
1015
|
* Whether the effect has been disposed.
|
|
997
1016
|
*/
|
|
998
1017
|
get isDisposed() {
|
|
999
|
-
return (this.flags &
|
|
1018
|
+
return (this.flags & te.DISPOSED) !== 0;
|
|
1000
1019
|
}
|
|
1001
1020
|
/**
|
|
1002
1021
|
* Total number of times this effect has executed.
|
|
@@ -1008,13 +1027,13 @@ class nt extends ve {
|
|
|
1008
1027
|
* Whether the effect is currently executing.
|
|
1009
1028
|
*/
|
|
1010
1029
|
get isExecuting() {
|
|
1011
|
-
return (this.flags &
|
|
1030
|
+
return (this.flags & te.EXECUTING) !== 0;
|
|
1012
1031
|
}
|
|
1013
1032
|
_setDisposed() {
|
|
1014
|
-
this.flags |=
|
|
1033
|
+
this.flags |= te.DISPOSED;
|
|
1015
1034
|
}
|
|
1016
1035
|
_setExecuting(e) {
|
|
1017
|
-
const s =
|
|
1036
|
+
const s = te.EXECUTING;
|
|
1018
1037
|
this.flags = this.flags & ~s | -Number(e) & s;
|
|
1019
1038
|
}
|
|
1020
1039
|
/**
|
|
@@ -1025,7 +1044,7 @@ class nt extends ve {
|
|
|
1025
1044
|
try {
|
|
1026
1045
|
this._cleanup();
|
|
1027
1046
|
} catch (e) {
|
|
1028
|
-
console.error(
|
|
1047
|
+
console.error(K(e, V, g.EFFECT_CLEANUP_FAILED));
|
|
1029
1048
|
}
|
|
1030
1049
|
this._cleanup = null;
|
|
1031
1050
|
}
|
|
@@ -1035,22 +1054,22 @@ class nt extends ve {
|
|
|
1035
1054
|
* @throws {EffectError} If an infinite loop is detected.
|
|
1036
1055
|
*/
|
|
1037
1056
|
_checkInfiniteLoop() {
|
|
1038
|
-
if (this._lastFlushEpoch !==
|
|
1057
|
+
if (this._lastFlushEpoch !== re && (this._lastFlushEpoch = re, this._executionsInEpoch = 0), this._executionsInEpoch++, this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), Qe() > B.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, this._history && this._maxExecutions > 0) {
|
|
1039
1058
|
const e = Date.now(), s = this._historyPtr, n = this._historyCapacity;
|
|
1040
1059
|
this._history[s] = e;
|
|
1041
1060
|
const i = (s + 1) % n, r = this._history[i] ?? 0;
|
|
1042
|
-
if (this._historyPtr = i, r > 0 && e - r <
|
|
1061
|
+
if (this._historyPtr = i, r > 0 && e - r < Ve.ONE_SECOND_MS) {
|
|
1043
1062
|
const o = new V(
|
|
1044
1063
|
`Effect executed ${n} times within 1 second. Infinite loop suspected`
|
|
1045
1064
|
);
|
|
1046
|
-
if (this.dispose(), console.error(o), this._onError && this._onError(o),
|
|
1065
|
+
if (this.dispose(), console.error(o), this._onError && this._onError(o), v)
|
|
1047
1066
|
throw o;
|
|
1048
1067
|
}
|
|
1049
1068
|
}
|
|
1050
1069
|
}
|
|
1051
1070
|
_throwInfiniteLoopError(e) {
|
|
1052
1071
|
const s = new V(
|
|
1053
|
-
`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${
|
|
1072
|
+
`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${pe}`
|
|
1054
1073
|
);
|
|
1055
1074
|
throw this.dispose(), console.error(s), s;
|
|
1056
1075
|
}
|
|
@@ -1059,14 +1078,14 @@ class nt extends ve {
|
|
|
1059
1078
|
* @returns true if any dependency has changed or if it's the first run.
|
|
1060
1079
|
*/
|
|
1061
1080
|
_shouldExecute() {
|
|
1062
|
-
if (this._dependencies === S || this._dependencyVersions ===
|
|
1081
|
+
if (this._dependencies === S || this._dependencyVersions === y)
|
|
1063
1082
|
return !0;
|
|
1064
1083
|
for (let e = 0; e < this._dependencies.length; e++) {
|
|
1065
1084
|
const s = this._dependencies[e];
|
|
1066
1085
|
if (s) {
|
|
1067
1086
|
if ("value" in s)
|
|
1068
1087
|
try {
|
|
1069
|
-
|
|
1088
|
+
Ue(() => s.value);
|
|
1070
1089
|
} catch {
|
|
1071
1090
|
return !0;
|
|
1072
1091
|
}
|
|
@@ -1081,7 +1100,7 @@ class nt extends ve {
|
|
|
1081
1100
|
* Wraps the error, logs it to console, and calls onError callback if provided.
|
|
1082
1101
|
*/
|
|
1083
1102
|
_handleExecutionError(e) {
|
|
1084
|
-
const s =
|
|
1103
|
+
const s = K(e, V, g.EFFECT_EXECUTION_FAILED);
|
|
1085
1104
|
console.error(s), this._onError && this._onError(s);
|
|
1086
1105
|
}
|
|
1087
1106
|
/**
|
|
@@ -1089,32 +1108,33 @@ class nt extends ve {
|
|
|
1089
1108
|
* Only active if trackModifications is enabled and debug is on.
|
|
1090
1109
|
*/
|
|
1091
1110
|
_checkLoopWarnings() {
|
|
1092
|
-
if (this._trackModifications &&
|
|
1111
|
+
if (this._trackModifications && R.enabled) {
|
|
1093
1112
|
const e = this._dependencies;
|
|
1094
1113
|
for (let s = 0; s < e.length; s++) {
|
|
1095
1114
|
const n = e[s];
|
|
1096
|
-
n && n._modifiedAtEpoch === this._currentEpoch &&
|
|
1115
|
+
n && n._modifiedAtEpoch === this._currentEpoch && R.warn(
|
|
1097
1116
|
!0,
|
|
1098
|
-
`Effect is reading a dependency (${
|
|
1117
|
+
`Effect is reading a dependency (${R.getDebugName(n) || "unknown"}) that it just modified. Infinite loop may occur`
|
|
1099
1118
|
);
|
|
1100
1119
|
}
|
|
1101
1120
|
}
|
|
1102
1121
|
}
|
|
1103
1122
|
}
|
|
1104
|
-
function
|
|
1123
|
+
function D(t, e = {}) {
|
|
1105
1124
|
if (typeof t != "function")
|
|
1106
|
-
throw new V(
|
|
1107
|
-
const s = new
|
|
1125
|
+
throw new V(g.EFFECT_MUST_BE_FUNCTION);
|
|
1126
|
+
const s = new ot(t, e);
|
|
1108
1127
|
return s.execute(), s;
|
|
1109
1128
|
}
|
|
1110
|
-
function
|
|
1129
|
+
function p(t) {
|
|
1111
1130
|
return t !== null && typeof t == "object" && "value" in t && "subscribe" in t;
|
|
1112
1131
|
}
|
|
1113
|
-
function
|
|
1114
|
-
return
|
|
1132
|
+
function k(t) {
|
|
1133
|
+
return p(t) ? t.value : t;
|
|
1115
1134
|
}
|
|
1116
|
-
function
|
|
1117
|
-
|
|
1135
|
+
function ae(t) {
|
|
1136
|
+
if (!t) return "unknown";
|
|
1137
|
+
const e = "jquery" in t ? t[0] : t;
|
|
1118
1138
|
if (!e) return "unknown";
|
|
1119
1139
|
if (e.id) return `#${e.id}`;
|
|
1120
1140
|
if (e.className) {
|
|
@@ -1123,7 +1143,7 @@ function ue(t) {
|
|
|
1123
1143
|
}
|
|
1124
1144
|
return e.tagName.toLowerCase();
|
|
1125
1145
|
}
|
|
1126
|
-
function
|
|
1146
|
+
function ct() {
|
|
1127
1147
|
if (typeof window < "u") {
|
|
1128
1148
|
const t = window.__ATOM_DEBUG__;
|
|
1129
1149
|
if (typeof t == "boolean")
|
|
@@ -1136,8 +1156,8 @@ function it() {
|
|
|
1136
1156
|
}
|
|
1137
1157
|
return !1;
|
|
1138
1158
|
}
|
|
1139
|
-
let P =
|
|
1140
|
-
const
|
|
1159
|
+
let P = ct();
|
|
1160
|
+
const l = {
|
|
1141
1161
|
get enabled() {
|
|
1142
1162
|
return P;
|
|
1143
1163
|
},
|
|
@@ -1155,8 +1175,8 @@ const h = {
|
|
|
1155
1175
|
*/
|
|
1156
1176
|
domUpdated(t, e, s) {
|
|
1157
1177
|
if (!P) return;
|
|
1158
|
-
const n =
|
|
1159
|
-
console.log(`[atom-effect-jquery] DOM updated: ${n}.${e} =`, s),
|
|
1178
|
+
const n = ae(t);
|
|
1179
|
+
console.log(`[atom-effect-jquery] DOM updated: ${n}.${e} =`, s), ut(t);
|
|
1160
1180
|
},
|
|
1161
1181
|
cleanup(t) {
|
|
1162
1182
|
P && console.log(`[atom-effect-jquery] Cleanup: ${t}`);
|
|
@@ -1165,7 +1185,7 @@ const h = {
|
|
|
1165
1185
|
P && console.warn("[atom-effect-jquery]", ...t);
|
|
1166
1186
|
}
|
|
1167
1187
|
};
|
|
1168
|
-
function
|
|
1188
|
+
function ut(t) {
|
|
1169
1189
|
const e = t[0];
|
|
1170
1190
|
if (!e || !document.contains(e)) return;
|
|
1171
1191
|
const s = "atom_debug_timer", n = "atom_debug_cleanup_timer", i = "atom_debug_org_style";
|
|
@@ -1194,85 +1214,76 @@ function rt(t) {
|
|
|
1194
1214
|
}, 100);
|
|
1195
1215
|
t.data(s, r);
|
|
1196
1216
|
}
|
|
1197
|
-
const
|
|
1198
|
-
function
|
|
1199
|
-
const s =
|
|
1200
|
-
return e.name &&
|
|
1217
|
+
const ht = /* @__PURE__ */ new WeakMap();
|
|
1218
|
+
function $e(t, e = {}) {
|
|
1219
|
+
const s = it(t, e);
|
|
1220
|
+
return e.name && ht.set(s, { name: e.name }), s;
|
|
1201
1221
|
}
|
|
1202
|
-
Object.defineProperty(
|
|
1222
|
+
Object.defineProperty($e, "debug", {
|
|
1203
1223
|
get() {
|
|
1204
|
-
return
|
|
1224
|
+
return l.enabled;
|
|
1205
1225
|
},
|
|
1206
1226
|
set(t) {
|
|
1207
|
-
|
|
1227
|
+
l.enabled = t;
|
|
1208
1228
|
}
|
|
1209
1229
|
});
|
|
1210
|
-
function
|
|
1230
|
+
function at() {
|
|
1211
1231
|
return new Promise((t) => setTimeout(t, 0));
|
|
1212
1232
|
}
|
|
1213
1233
|
u.extend({
|
|
1214
|
-
atom:
|
|
1215
|
-
computed:
|
|
1216
|
-
effect:
|
|
1217
|
-
batch:
|
|
1218
|
-
untracked:
|
|
1219
|
-
isAtom:
|
|
1220
|
-
isComputed:
|
|
1221
|
-
isReactive: (t) =>
|
|
1222
|
-
nextTick:
|
|
1234
|
+
atom: $e,
|
|
1235
|
+
computed: rt,
|
|
1236
|
+
effect: D,
|
|
1237
|
+
batch: Je,
|
|
1238
|
+
untracked: Ue,
|
|
1239
|
+
isAtom: _e,
|
|
1240
|
+
isComputed: Ne,
|
|
1241
|
+
isReactive: (t) => _e(t) || Ne(t),
|
|
1242
|
+
nextTick: at
|
|
1223
1243
|
});
|
|
1224
|
-
function
|
|
1244
|
+
function Le() {
|
|
1225
1245
|
return { timeoutId: null, phase: "idle", hasFocus: !1 };
|
|
1226
1246
|
}
|
|
1227
|
-
function
|
|
1247
|
+
function je(t, e, s = {}) {
|
|
1228
1248
|
const {
|
|
1229
1249
|
debounce: n,
|
|
1230
1250
|
event: i = "input",
|
|
1231
|
-
parse: r = (
|
|
1232
|
-
format: o = (
|
|
1233
|
-
} = s, c =
|
|
1251
|
+
parse: r = (I) => I,
|
|
1252
|
+
format: o = (I) => String(I ?? "")
|
|
1253
|
+
} = s, c = Le(), h = () => {
|
|
1234
1254
|
c.phase = "composing";
|
|
1235
1255
|
}, _ = () => {
|
|
1236
|
-
c.phase = "idle",
|
|
1256
|
+
c.phase = "idle", N();
|
|
1237
1257
|
};
|
|
1238
|
-
t.on("compositionstart",
|
|
1239
|
-
const
|
|
1258
|
+
t.on("compositionstart", h), t.on("compositionend", _);
|
|
1259
|
+
const m = () => {
|
|
1240
1260
|
c.hasFocus = !0;
|
|
1241
|
-
},
|
|
1261
|
+
}, G = () => {
|
|
1242
1262
|
c.hasFocus = !1;
|
|
1243
|
-
const
|
|
1244
|
-
t.val() !==
|
|
1263
|
+
const I = o(e.value);
|
|
1264
|
+
t.val() !== I && t.val(I);
|
|
1245
1265
|
};
|
|
1246
|
-
t.on("focus",
|
|
1247
|
-
const
|
|
1248
|
-
c.phase === "idle" && (c.phase = "syncing-to-atom",
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
}, v = () => {
|
|
1252
|
-
c.phase === "idle" && (n ? (c.timeoutId && clearTimeout(c.timeoutId), c.timeoutId = window.setTimeout(F, n)) : F());
|
|
1266
|
+
t.on("focus", m), t.on("blur", G);
|
|
1267
|
+
const N = () => {
|
|
1268
|
+
c.phase === "idle" && (c.phase = "syncing-to-atom", e.value = r(t.val()), c.phase = "idle");
|
|
1269
|
+
}, A = () => {
|
|
1270
|
+
c.phase === "idle" && (n ? (c.timeoutId && clearTimeout(c.timeoutId), c.timeoutId = window.setTimeout(N, n)) : N());
|
|
1253
1271
|
};
|
|
1254
|
-
return t.on(i,
|
|
1255
|
-
const
|
|
1256
|
-
if (
|
|
1257
|
-
if (c.hasFocus && r(
|
|
1272
|
+
return t.on(i, A), t.on("change", A), { effect: () => {
|
|
1273
|
+
const I = o(e.value), H = t.val();
|
|
1274
|
+
if (H !== I) {
|
|
1275
|
+
if (c.hasFocus && r(H) === e.value)
|
|
1258
1276
|
return;
|
|
1259
|
-
c.phase = "syncing-to-dom", t.val(
|
|
1277
|
+
c.phase = "syncing-to-dom", t.val(I), l.domUpdated(t, "val", I), c.phase = "idle";
|
|
1260
1278
|
}
|
|
1261
1279
|
}, cleanup: () => {
|
|
1262
|
-
t.off(i,
|
|
1280
|
+
t.off(i, A), t.off("change", A), t.off("compositionstart", h), t.off("compositionend", _), t.off("focus", m), t.off("blur", G), c.timeoutId && clearTimeout(c.timeoutId);
|
|
1263
1281
|
} };
|
|
1264
1282
|
}
|
|
1265
|
-
class
|
|
1266
|
-
// DOM Element -> Effect Array (for disposal)
|
|
1283
|
+
class lt {
|
|
1267
1284
|
effects = /* @__PURE__ */ new WeakMap();
|
|
1268
|
-
// DOM Element -> Custom Cleanup Function Array
|
|
1269
1285
|
cleanups = /* @__PURE__ */ new WeakMap();
|
|
1270
|
-
// Track bound elements (Performance optimization)
|
|
1271
1286
|
boundElements = /* @__PURE__ */ new WeakSet();
|
|
1272
|
-
/**
|
|
1273
|
-
* Tracks elements that are temporarily detached (e.g. via .detach())
|
|
1274
|
-
* so they are NOT cleaned up by the MutationObserver.
|
|
1275
|
-
*/
|
|
1276
1287
|
preservedNodes = /* @__PURE__ */ new WeakSet();
|
|
1277
1288
|
keep(e) {
|
|
1278
1289
|
this.preservedNodes.add(e);
|
|
@@ -1280,183 +1291,156 @@ class ut {
|
|
|
1280
1291
|
isKept(e) {
|
|
1281
1292
|
return this.preservedNodes.has(e);
|
|
1282
1293
|
}
|
|
1283
|
-
/**
|
|
1284
|
-
* Registers an Effect to be disposed later.
|
|
1285
|
-
*/
|
|
1286
1294
|
trackEffect(e, s) {
|
|
1287
|
-
|
|
1288
|
-
n
|
|
1295
|
+
let n = this.effects.get(e);
|
|
1296
|
+
n || (n = [], this.effects.set(e, n), this.boundElements.add(e)), n.push(s);
|
|
1289
1297
|
}
|
|
1290
|
-
/**
|
|
1291
|
-
* Registers a custom cleanup function (e.g., event listener removal).
|
|
1292
|
-
*/
|
|
1293
1298
|
trackCleanup(e, s) {
|
|
1294
|
-
|
|
1295
|
-
n
|
|
1299
|
+
let n = this.cleanups.get(e);
|
|
1300
|
+
n || (n = [], this.cleanups.set(e, n), this.boundElements.add(e)), n.push(s);
|
|
1296
1301
|
}
|
|
1297
|
-
/**
|
|
1298
|
-
* Checks if an element has bindings (Fast check).
|
|
1299
|
-
*/
|
|
1300
1302
|
hasBind(e) {
|
|
1301
1303
|
return this.boundElements.has(e);
|
|
1302
1304
|
}
|
|
1303
|
-
/**
|
|
1304
|
-
* Cleans up a single element.
|
|
1305
|
-
* - Disposes all Effects (severs connection with Atom).
|
|
1306
|
-
* - Executes all custom cleanups.
|
|
1307
|
-
*/
|
|
1308
1305
|
cleanup(e) {
|
|
1309
|
-
if (!this.boundElements.
|
|
1310
|
-
|
|
1306
|
+
if (!this.boundElements.delete(e)) return;
|
|
1307
|
+
l.cleanup(ae(e));
|
|
1311
1308
|
const s = this.effects.get(e);
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1309
|
+
if (s) {
|
|
1310
|
+
this.effects.delete(e);
|
|
1311
|
+
for (let i = 0, r = s.length; i < r; i++) {
|
|
1312
|
+
const o = s[i];
|
|
1313
|
+
if (o)
|
|
1314
|
+
try {
|
|
1315
|
+
o.dispose();
|
|
1316
|
+
} catch (c) {
|
|
1317
|
+
l.warn("Effect dispose error:", c);
|
|
1318
|
+
}
|
|
1317
1319
|
}
|
|
1318
|
-
}
|
|
1320
|
+
}
|
|
1319
1321
|
const n = this.cleanups.get(e);
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1322
|
+
if (n) {
|
|
1323
|
+
this.cleanups.delete(e);
|
|
1324
|
+
for (let i = 0, r = n.length; i < r; i++) {
|
|
1325
|
+
const o = n[i];
|
|
1326
|
+
if (o)
|
|
1327
|
+
try {
|
|
1328
|
+
o();
|
|
1329
|
+
} catch (c) {
|
|
1330
|
+
l.warn("Cleanup error:", c);
|
|
1331
|
+
}
|
|
1325
1332
|
}
|
|
1326
|
-
}
|
|
1333
|
+
}
|
|
1327
1334
|
}
|
|
1328
|
-
/**
|
|
1329
|
-
* Cleans up the element and all its descendants (Recursive).
|
|
1330
|
-
* - Essential for deep removal (empty(), remove(), etc.).
|
|
1331
|
-
*/
|
|
1332
1335
|
cleanupTree(e) {
|
|
1333
|
-
e.querySelectorAll("*")
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
+
const s = e.querySelectorAll("*");
|
|
1337
|
+
for (let n = 0, i = s.length; n < i; n++) {
|
|
1338
|
+
const r = s[n];
|
|
1339
|
+
r && this.boundElements.has(r) && this.cleanup(r);
|
|
1340
|
+
}
|
|
1341
|
+
this.cleanup(e);
|
|
1336
1342
|
}
|
|
1337
1343
|
}
|
|
1338
|
-
const
|
|
1339
|
-
let
|
|
1340
|
-
function
|
|
1341
|
-
|
|
1342
|
-
for (
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1344
|
+
const f = new lt();
|
|
1345
|
+
let W = null;
|
|
1346
|
+
function ft(t = document.body) {
|
|
1347
|
+
W || (W = new MutationObserver((e) => {
|
|
1348
|
+
for (let s = 0, n = e.length; s < n; s++) {
|
|
1349
|
+
const i = e[s];
|
|
1350
|
+
if (!i) continue;
|
|
1351
|
+
const r = i.removedNodes;
|
|
1352
|
+
for (let o = 0, c = r.length; o < c; o++) {
|
|
1353
|
+
const h = r[o];
|
|
1354
|
+
h && (f.isKept(h) || h.isConnected || h.nodeType === 1 && f.cleanupTree(h));
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
}), W.observe(t, { childList: !0, subtree: !0 }));
|
|
1347
1358
|
}
|
|
1348
|
-
function
|
|
1349
|
-
|
|
1359
|
+
function Tt() {
|
|
1360
|
+
W?.disconnect(), W = null;
|
|
1350
1361
|
}
|
|
1351
1362
|
u.fn.atomText = function(t, e) {
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
s.text(r), h.domUpdated(s, "text", r);
|
|
1363
|
+
if (p(t))
|
|
1364
|
+
return this.each(function() {
|
|
1365
|
+
const n = u(this), i = D(() => {
|
|
1366
|
+
const r = t.value, o = e ? e(r) : String(r ?? "");
|
|
1367
|
+
n.text(o), l.domUpdated(n, "text", o);
|
|
1358
1368
|
});
|
|
1359
|
-
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
}
|
|
1364
|
-
});
|
|
1369
|
+
f.trackEffect(this, i);
|
|
1370
|
+
});
|
|
1371
|
+
const s = e ? e(t) : String(t ?? "");
|
|
1372
|
+
return this.text(s);
|
|
1365
1373
|
};
|
|
1366
1374
|
u.fn.atomHtml = function(t) {
|
|
1367
|
-
return this.each(function() {
|
|
1368
|
-
const e = u(this)
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
l.trackEffect(this, s);
|
|
1375
|
-
} else
|
|
1376
|
-
e.html(String(t ?? ""));
|
|
1377
|
-
});
|
|
1375
|
+
return p(t) ? this.each(function() {
|
|
1376
|
+
const e = u(this), s = D(() => {
|
|
1377
|
+
const n = String(t.value ?? "");
|
|
1378
|
+
e.html(n), l.domUpdated(e, "html", n);
|
|
1379
|
+
});
|
|
1380
|
+
f.trackEffect(this, s);
|
|
1381
|
+
}) : this.html(String(t ?? ""));
|
|
1378
1382
|
};
|
|
1379
1383
|
u.fn.atomClass = function(t, e) {
|
|
1380
|
-
return this.each(function() {
|
|
1381
|
-
const s = u(this)
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
l.trackEffect(this, n);
|
|
1388
|
-
} else
|
|
1389
|
-
s.toggleClass(t, !!e);
|
|
1390
|
-
});
|
|
1384
|
+
return p(e) ? this.each(function() {
|
|
1385
|
+
const s = u(this), n = D(() => {
|
|
1386
|
+
const i = !!e.value;
|
|
1387
|
+
s.toggleClass(t, i), l.domUpdated(s, `class.${t}`, i);
|
|
1388
|
+
});
|
|
1389
|
+
f.trackEffect(this, n);
|
|
1390
|
+
}) : this.toggleClass(t, !!e);
|
|
1391
1391
|
};
|
|
1392
1392
|
u.fn.atomCss = function(t, e, s) {
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
n.css(t, o), h.domUpdated(n, `css.${t}`, o);
|
|
1393
|
+
if (p(e))
|
|
1394
|
+
return this.each(function() {
|
|
1395
|
+
const i = u(this), r = D(() => {
|
|
1396
|
+
const o = e.value, c = s ? `${o}${s}` : o;
|
|
1397
|
+
i.css(t, c), l.domUpdated(i, `css.${t}`, c);
|
|
1399
1398
|
});
|
|
1400
|
-
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1399
|
+
f.trackEffect(this, r);
|
|
1400
|
+
});
|
|
1401
|
+
const n = s ? `${e}${s}` : e;
|
|
1402
|
+
return this.css(t, n);
|
|
1404
1403
|
};
|
|
1405
1404
|
u.fn.atomAttr = function(t, e) {
|
|
1406
|
-
return this.each(function() {
|
|
1407
|
-
const s = u(this), n = (
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
} else
|
|
1414
|
-
n(e);
|
|
1415
|
-
});
|
|
1405
|
+
return p(e) ? this.each(function() {
|
|
1406
|
+
const s = u(this), n = D(() => {
|
|
1407
|
+
const i = e.value;
|
|
1408
|
+
i == null || i === !1 ? s.removeAttr(t) : i === !0 ? s.attr(t, t) : s.attr(t, String(i)), l.domUpdated(s, `attr.${t}`, i);
|
|
1409
|
+
});
|
|
1410
|
+
f.trackEffect(this, n);
|
|
1411
|
+
}) : e == null || e === !1 ? this.removeAttr(t) : e === !0 ? this.attr(t, t) : this.attr(t, String(e));
|
|
1416
1412
|
};
|
|
1417
1413
|
u.fn.atomProp = function(t, e) {
|
|
1418
|
-
return this.each(function() {
|
|
1419
|
-
const s = u(this)
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
l.trackEffect(this, n);
|
|
1426
|
-
} else
|
|
1427
|
-
s.prop(t, e);
|
|
1428
|
-
});
|
|
1414
|
+
return p(e) ? this.each(function() {
|
|
1415
|
+
const s = u(this), n = D(() => {
|
|
1416
|
+
const i = e.value;
|
|
1417
|
+
s.prop(t, i), l.domUpdated(s, `prop.${t}`, i);
|
|
1418
|
+
});
|
|
1419
|
+
f.trackEffect(this, n);
|
|
1420
|
+
}) : this.prop(t, e);
|
|
1429
1421
|
};
|
|
1430
1422
|
u.fn.atomShow = function(t) {
|
|
1431
|
-
return this.each(function() {
|
|
1432
|
-
const e = u(this)
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
l.trackEffect(this, s);
|
|
1439
|
-
} else
|
|
1440
|
-
e.toggle(!!t);
|
|
1441
|
-
});
|
|
1423
|
+
return p(t) ? this.each(function() {
|
|
1424
|
+
const e = u(this), s = D(() => {
|
|
1425
|
+
const n = !!t.value;
|
|
1426
|
+
e.toggle(n), l.domUpdated(e, "show", n);
|
|
1427
|
+
});
|
|
1428
|
+
f.trackEffect(this, s);
|
|
1429
|
+
}) : this.toggle(!!t);
|
|
1442
1430
|
};
|
|
1443
1431
|
u.fn.atomHide = function(t) {
|
|
1444
|
-
return this.each(function() {
|
|
1445
|
-
const e = u(this)
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
l.trackEffect(this, s);
|
|
1452
|
-
} else
|
|
1453
|
-
e.toggle(!t);
|
|
1454
|
-
});
|
|
1432
|
+
return p(t) ? this.each(function() {
|
|
1433
|
+
const e = u(this), s = D(() => {
|
|
1434
|
+
const n = !t.value;
|
|
1435
|
+
e.toggle(n), l.domUpdated(e, "hide", !n);
|
|
1436
|
+
});
|
|
1437
|
+
f.trackEffect(this, s);
|
|
1438
|
+
}) : this.toggle(!t);
|
|
1455
1439
|
};
|
|
1456
1440
|
u.fn.atomVal = function(t, e = {}) {
|
|
1457
1441
|
return this.each(function() {
|
|
1458
|
-
const { effect:
|
|
1459
|
-
|
|
1442
|
+
const s = u(this), { effect: n, cleanup: i } = je(s, t, e), r = D(n);
|
|
1443
|
+
f.trackEffect(this, r), f.trackCleanup(this, i);
|
|
1460
1444
|
});
|
|
1461
1445
|
};
|
|
1462
1446
|
u.fn.atomChecked = function(t) {
|
|
@@ -1464,107 +1448,103 @@ u.fn.atomChecked = function(t) {
|
|
|
1464
1448
|
const e = u(this);
|
|
1465
1449
|
let s = !1;
|
|
1466
1450
|
const n = () => {
|
|
1467
|
-
s ||
|
|
1468
|
-
t.value = e.prop("checked");
|
|
1469
|
-
});
|
|
1451
|
+
s || (t.value = !!e.prop("checked"));
|
|
1470
1452
|
};
|
|
1471
|
-
e.on("change", n),
|
|
1472
|
-
const i =
|
|
1473
|
-
s = !0
|
|
1453
|
+
e.on("change", n), f.trackCleanup(this, () => e.off("change", n));
|
|
1454
|
+
const i = D(() => {
|
|
1455
|
+
s = !0;
|
|
1456
|
+
const r = !!t.value;
|
|
1457
|
+
e.prop("checked", r), l.domUpdated(e, "checked", r), s = !1;
|
|
1474
1458
|
});
|
|
1475
|
-
|
|
1459
|
+
f.trackEffect(this, i);
|
|
1476
1460
|
});
|
|
1477
1461
|
};
|
|
1478
1462
|
u.fn.atomOn = function(t, e) {
|
|
1479
1463
|
return this.each(function() {
|
|
1480
|
-
const s = u(this)
|
|
1481
|
-
|
|
1482
|
-
};
|
|
1483
|
-
s.on(t, n), l.trackCleanup(this, () => s.off(t, n));
|
|
1464
|
+
const s = u(this);
|
|
1465
|
+
s.on(t, e), f.trackCleanup(this, () => s.off(t, e));
|
|
1484
1466
|
});
|
|
1485
1467
|
};
|
|
1486
1468
|
u.fn.atomUnbind = function() {
|
|
1487
1469
|
return this.each(function() {
|
|
1488
|
-
|
|
1470
|
+
f.cleanupTree(this);
|
|
1489
1471
|
});
|
|
1490
1472
|
};
|
|
1491
|
-
function
|
|
1492
|
-
|
|
1493
|
-
const s = String(
|
|
1494
|
-
t.$el.text(s),
|
|
1473
|
+
function dt(t, e) {
|
|
1474
|
+
p(e) ? t.effects.push(() => {
|
|
1475
|
+
const s = String(k(e) ?? "");
|
|
1476
|
+
t.$el.text(s), l.domUpdated(t.$el, "text", s);
|
|
1495
1477
|
}) : t.$el.text(String(e ?? ""));
|
|
1496
1478
|
}
|
|
1497
|
-
function
|
|
1498
|
-
|
|
1499
|
-
const s = String(
|
|
1500
|
-
t.$el.html(s),
|
|
1479
|
+
function _t(t, e) {
|
|
1480
|
+
p(e) ? t.effects.push(() => {
|
|
1481
|
+
const s = String(k(e) ?? "");
|
|
1482
|
+
t.$el.html(s), l.domUpdated(t.$el, "html", s);
|
|
1501
1483
|
}) : t.$el.html(String(e ?? ""));
|
|
1502
1484
|
}
|
|
1503
|
-
function
|
|
1485
|
+
function pt(t, e) {
|
|
1504
1486
|
for (const [s, n] of Object.entries(e))
|
|
1505
|
-
|
|
1506
|
-
const i = !!
|
|
1507
|
-
t.$el.toggleClass(s, i),
|
|
1487
|
+
p(n) ? t.effects.push(() => {
|
|
1488
|
+
const i = !!k(n);
|
|
1489
|
+
t.$el.toggleClass(s, i), l.domUpdated(t.$el, `class.${s}`, i);
|
|
1508
1490
|
}) : t.$el.toggleClass(s, !!n);
|
|
1509
1491
|
}
|
|
1510
|
-
function
|
|
1492
|
+
function bt(t, e) {
|
|
1511
1493
|
for (const [s, n] of Object.entries(e))
|
|
1512
1494
|
if (Array.isArray(n)) {
|
|
1513
1495
|
const [i, r] = n;
|
|
1514
|
-
|
|
1515
|
-
const o = `${
|
|
1516
|
-
t.$el.css(s, o),
|
|
1496
|
+
p(i) ? t.effects.push(() => {
|
|
1497
|
+
const o = `${k(i)}${r}`;
|
|
1498
|
+
t.$el.css(s, o), l.domUpdated(t.$el, `css.${s}`, o);
|
|
1517
1499
|
}) : t.$el.css(s, `${i}${r}`);
|
|
1518
|
-
} else
|
|
1519
|
-
const i =
|
|
1520
|
-
t.$el.css(s, i),
|
|
1500
|
+
} else p(n) ? t.effects.push(() => {
|
|
1501
|
+
const i = k(n);
|
|
1502
|
+
t.$el.css(s, i), l.domUpdated(t.$el, `css.${s}`, i);
|
|
1521
1503
|
}) : t.$el.css(s, n);
|
|
1522
1504
|
}
|
|
1523
|
-
function
|
|
1505
|
+
function Et(t, e) {
|
|
1524
1506
|
for (const [s, n] of Object.entries(e)) {
|
|
1525
1507
|
const i = (r) => {
|
|
1526
|
-
r == null || r === !1 ? t.$el.removeAttr(s) : r === !0 ? t.$el.attr(s, s) : t.$el.attr(s, String(r)),
|
|
1508
|
+
r == null || r === !1 ? t.$el.removeAttr(s) : r === !0 ? t.$el.attr(s, s) : t.$el.attr(s, String(r)), l.domUpdated(t.$el, `attr.${s}`, r);
|
|
1527
1509
|
};
|
|
1528
|
-
|
|
1510
|
+
p(n) ? t.effects.push(() => i(k(n))) : i(n);
|
|
1529
1511
|
}
|
|
1530
1512
|
}
|
|
1531
|
-
function
|
|
1513
|
+
function gt(t, e) {
|
|
1532
1514
|
for (const [s, n] of Object.entries(e))
|
|
1533
|
-
|
|
1534
|
-
const i =
|
|
1535
|
-
t.$el.prop(s, i),
|
|
1515
|
+
p(n) ? t.effects.push(() => {
|
|
1516
|
+
const i = k(n);
|
|
1517
|
+
t.$el.prop(s, i), l.domUpdated(t.$el, `prop.${s}`, i);
|
|
1536
1518
|
}) : t.$el.prop(s, n);
|
|
1537
1519
|
}
|
|
1538
|
-
function
|
|
1539
|
-
|
|
1540
|
-
const s = !!
|
|
1541
|
-
t.$el.toggle(s),
|
|
1520
|
+
function mt(t, e) {
|
|
1521
|
+
p(e) ? t.effects.push(() => {
|
|
1522
|
+
const s = !!k(e);
|
|
1523
|
+
t.$el.toggle(s), l.domUpdated(t.$el, "show", s);
|
|
1542
1524
|
}) : t.$el.toggle(!!e);
|
|
1543
1525
|
}
|
|
1544
|
-
function
|
|
1545
|
-
|
|
1546
|
-
const s = !
|
|
1547
|
-
t.$el.toggle(s),
|
|
1526
|
+
function St(t, e) {
|
|
1527
|
+
p(e) ? t.effects.push(() => {
|
|
1528
|
+
const s = !k(e);
|
|
1529
|
+
t.$el.toggle(s), l.domUpdated(t.$el, "hide", !s);
|
|
1548
1530
|
}) : t.$el.toggle(!e);
|
|
1549
1531
|
}
|
|
1550
|
-
function
|
|
1551
|
-
const s = Array.isArray(e) ? e[0] : e, n = Array.isArray(e) ? e[1] : {}, { effect: i, cleanup: r } =
|
|
1532
|
+
function yt(t, e) {
|
|
1533
|
+
const s = Array.isArray(e) ? e[0] : e, n = Array.isArray(e) ? e[1] : {}, { effect: i, cleanup: r } = je(t.$el, s, n);
|
|
1552
1534
|
t.effects.push(i), t.trackCleanup(r);
|
|
1553
1535
|
}
|
|
1554
|
-
function
|
|
1555
|
-
const s =
|
|
1556
|
-
s.phase === "idle" &&
|
|
1557
|
-
e.value = t.$el.prop("checked");
|
|
1558
|
-
});
|
|
1536
|
+
function Dt(t, e) {
|
|
1537
|
+
const s = Le(), n = () => {
|
|
1538
|
+
s.phase === "idle" && (e.value = t.$el.prop("checked"));
|
|
1559
1539
|
};
|
|
1560
1540
|
t.$el.on("change", n), t.trackCleanup(() => t.$el.off("change", n)), t.effects.push(() => {
|
|
1561
|
-
s.phase = "syncing-to-dom", t.$el.prop("checked", e.value),
|
|
1541
|
+
s.phase = "syncing-to-dom", t.$el.prop("checked", e.value), l.domUpdated(t.$el, "checked", e.value), s.phase = "idle";
|
|
1562
1542
|
});
|
|
1563
1543
|
}
|
|
1564
|
-
function
|
|
1544
|
+
function It(t, e) {
|
|
1565
1545
|
for (const [s, n] of Object.entries(e)) {
|
|
1566
1546
|
const i = function(r) {
|
|
1567
|
-
|
|
1547
|
+
n.call(this, r);
|
|
1568
1548
|
};
|
|
1569
1549
|
t.$el.on(s, i), t.trackCleanup(() => t.$el.off(s, i));
|
|
1570
1550
|
}
|
|
@@ -1575,148 +1555,151 @@ u.fn.atomBind = function(t) {
|
|
|
1575
1555
|
$el: e,
|
|
1576
1556
|
el: this,
|
|
1577
1557
|
effects: s,
|
|
1578
|
-
trackCleanup: (i) =>
|
|
1558
|
+
trackCleanup: (i) => f.trackCleanup(this, i)
|
|
1579
1559
|
};
|
|
1580
|
-
t.text !== void 0 &&
|
|
1581
|
-
const r =
|
|
1582
|
-
|
|
1560
|
+
t.text !== void 0 && dt(n, t.text), t.html !== void 0 && _t(n, t.html), t.class && pt(n, t.class), t.css && bt(n, t.css), t.attr && Et(n, t.attr), t.prop && gt(n, t.prop), t.show !== void 0 && mt(n, t.show), t.hide !== void 0 && St(n, t.hide), t.val !== void 0 && yt(n, t.val), t.checked !== void 0 && Dt(n, t.checked), t.on && It(n, t.on), s.forEach((i) => {
|
|
1561
|
+
const r = D(i);
|
|
1562
|
+
f.trackEffect(this, r);
|
|
1583
1563
|
});
|
|
1584
1564
|
});
|
|
1585
1565
|
};
|
|
1586
|
-
function
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
for (
|
|
1592
|
-
const
|
|
1593
|
-
if (
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1566
|
+
function Ct(t) {
|
|
1567
|
+
const e = t.length;
|
|
1568
|
+
if (e === 0) return new Int32Array(0);
|
|
1569
|
+
const s = new Int32Array(e), n = new Int32Array(e);
|
|
1570
|
+
let i = 0;
|
|
1571
|
+
for (let o = 0; o < e; o++) {
|
|
1572
|
+
const c = t[o];
|
|
1573
|
+
if (c === -1) continue;
|
|
1574
|
+
if (i === 0 || t[n[i - 1]] < c) {
|
|
1575
|
+
s[o] = i > 0 ? n[i - 1] : -1, n[i++] = o;
|
|
1576
|
+
continue;
|
|
1577
|
+
}
|
|
1578
|
+
let h = 0, _ = i - 1;
|
|
1579
|
+
for (; h < _; ) {
|
|
1580
|
+
const m = h + _ >>> 1;
|
|
1581
|
+
t[n[m]] < c ? h = m + 1 : _ = m;
|
|
1602
1582
|
}
|
|
1583
|
+
c < t[n[h]] && (h > 0 && (s[o] = n[h - 1]), n[h] = o);
|
|
1603
1584
|
}
|
|
1604
|
-
|
|
1605
|
-
for (;
|
|
1606
|
-
|
|
1607
|
-
return
|
|
1585
|
+
const r = new Int32Array(i);
|
|
1586
|
+
for (let o = i - 1, c = n[i - 1]; o >= 0; o--)
|
|
1587
|
+
r[o] = c, c = s[c];
|
|
1588
|
+
return r;
|
|
1608
1589
|
}
|
|
1609
1590
|
u.fn.atomList = function(t, e) {
|
|
1591
|
+
const { key: s, render: n, bind: i, update: r, onAdd: o, onRemove: c, empty: h } = e, _ = typeof s == "function" ? s : (m) => m[s];
|
|
1610
1592
|
return this.each(function() {
|
|
1611
|
-
const
|
|
1612
|
-
let
|
|
1613
|
-
const
|
|
1614
|
-
const
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1593
|
+
const m = u(this), G = ae(this), N = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Set();
|
|
1594
|
+
let M = [], $ = null;
|
|
1595
|
+
const I = D(() => {
|
|
1596
|
+
const H = t.value, O = H.length;
|
|
1597
|
+
if (O === 0 ? h && !$ && ($ = u(h).appendTo(m)) : $ && ($.remove(), $ = null), O === 0 && N.size === 0) {
|
|
1598
|
+
M = [];
|
|
1599
|
+
return;
|
|
1618
1600
|
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1601
|
+
l.log("list", `${G} updating with ${O} items`);
|
|
1602
|
+
const ee = new Array(O), Ee = /* @__PURE__ */ new Set();
|
|
1603
|
+
for (let a = 0; a < O; a++) {
|
|
1604
|
+
const b = H[a], C = _(b, a);
|
|
1605
|
+
ee[a] = C, Ee.add(C);
|
|
1606
|
+
}
|
|
1607
|
+
for (const [a, b] of N) {
|
|
1608
|
+
if (Ee.has(a) || A.has(a)) continue;
|
|
1609
|
+
const C = () => {
|
|
1610
|
+
b.$el.remove();
|
|
1611
|
+
const E = b.$el[0];
|
|
1612
|
+
E && f.cleanup(E), A.delete(a), l.log("list", `${G} removed item:`, a);
|
|
1613
|
+
};
|
|
1614
|
+
if (N.delete(a), A.add(a), c) {
|
|
1615
|
+
const E = c(b.$el);
|
|
1616
|
+
E instanceof Promise ? E.then(C) : C();
|
|
1617
|
+
} else
|
|
1618
|
+
C();
|
|
1619
|
+
}
|
|
1620
|
+
if (O === 0) {
|
|
1621
|
+
M = [];
|
|
1627
1622
|
return;
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
const
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
N.item = x;
|
|
1649
|
-
const U = N.$el[0];
|
|
1650
|
-
if (!U) continue;
|
|
1651
|
-
if (e.update && e.update(N.$el, x, a), !W)
|
|
1652
|
-
R ? N.$el.insertBefore(R) : N.$el.appendTo(s);
|
|
1653
|
-
else {
|
|
1654
|
-
const G = U.nextSibling;
|
|
1655
|
-
R && G !== R ? N.$el.insertBefore(R) : !R && G && N.$el.appendTo(s);
|
|
1656
|
-
}
|
|
1657
|
-
R = U;
|
|
1623
|
+
}
|
|
1624
|
+
const ge = /* @__PURE__ */ new Map();
|
|
1625
|
+
for (let a = 0; a < M.length; a++) {
|
|
1626
|
+
const b = M[a];
|
|
1627
|
+
b !== void 0 && ge.set(b, a);
|
|
1628
|
+
}
|
|
1629
|
+
const me = new Int32Array(O);
|
|
1630
|
+
for (let a = 0; a < O; a++) {
|
|
1631
|
+
const b = ee[a];
|
|
1632
|
+
me[a] = b !== void 0 ? ge.get(b) ?? -1 : -1;
|
|
1633
|
+
}
|
|
1634
|
+
const Se = Ct(me);
|
|
1635
|
+
let le = Se.length - 1, U = null;
|
|
1636
|
+
for (let a = O - 1; a >= 0; a--) {
|
|
1637
|
+
const b = ee[a], C = H[a], E = N.get(b);
|
|
1638
|
+
if (E) {
|
|
1639
|
+
E.item = C;
|
|
1640
|
+
const L = E.$el[0];
|
|
1641
|
+
if (!L) continue;
|
|
1642
|
+
r && r(E.$el, C, a), le >= 0 && Se[le] === a ? (le--, L.nextSibling !== U && (U ? E.$el.insertBefore(U) : E.$el.appendTo(m))) : U ? E.$el.insertBefore(U) : E.$el.appendTo(m), U = L;
|
|
1658
1643
|
} else {
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1661
|
-
const G = U[0];
|
|
1662
|
-
G && (R = G);
|
|
1644
|
+
const L = n(C, a), j = L instanceof Element ? u(L) : u(L);
|
|
1645
|
+
N.set(b, { $el: j, item: C }), U ? j.insertBefore(U) : j.appendTo(m), i && i(j, C, a), o && o(j), l.log("list", `${G} added item:`, b), U = j[0] || null;
|
|
1663
1646
|
}
|
|
1664
1647
|
}
|
|
1665
|
-
|
|
1648
|
+
M = ee;
|
|
1666
1649
|
});
|
|
1667
|
-
|
|
1668
|
-
|
|
1650
|
+
f.trackEffect(this, I), f.trackCleanup(this, () => {
|
|
1651
|
+
N.clear(), A.clear(), M = [], $?.remove();
|
|
1669
1652
|
});
|
|
1670
1653
|
});
|
|
1671
1654
|
};
|
|
1672
|
-
const
|
|
1655
|
+
const ie = /* @__PURE__ */ new WeakMap();
|
|
1673
1656
|
u.fn.atomMount = function(t, e = {}) {
|
|
1674
1657
|
return this.each(function() {
|
|
1675
|
-
const s = u(this), n =
|
|
1676
|
-
i && (
|
|
1658
|
+
const s = u(this), n = ae(this), i = ie.get(this);
|
|
1659
|
+
i && (l.log("mount", `${n} unmounting existing component`), i()), l.log("mount", `${n} mounting component`);
|
|
1677
1660
|
let r;
|
|
1678
1661
|
try {
|
|
1679
1662
|
r = t(s, e);
|
|
1680
|
-
} catch (
|
|
1681
|
-
console.error("[atom-effect-jquery] Mount error:",
|
|
1663
|
+
} catch (h) {
|
|
1664
|
+
console.error("[atom-effect-jquery] Mount error:", h);
|
|
1682
1665
|
return;
|
|
1683
1666
|
}
|
|
1684
1667
|
let o = !1;
|
|
1685
1668
|
const c = () => {
|
|
1686
1669
|
if (!o) {
|
|
1687
|
-
if (o = !0,
|
|
1670
|
+
if (o = !0, l.log("mount", `${n} full cleanup`), typeof r == "function")
|
|
1688
1671
|
try {
|
|
1689
1672
|
r();
|
|
1690
1673
|
} catch {
|
|
1691
1674
|
}
|
|
1692
|
-
|
|
1675
|
+
f.cleanupTree(this), ie.delete(this);
|
|
1693
1676
|
}
|
|
1694
1677
|
};
|
|
1695
|
-
|
|
1678
|
+
ie.set(this, c), f.trackCleanup(this, c);
|
|
1696
1679
|
});
|
|
1697
1680
|
};
|
|
1698
1681
|
u.fn.atomUnmount = function() {
|
|
1699
1682
|
return this.each(function() {
|
|
1700
|
-
|
|
1683
|
+
ie.get(this)?.();
|
|
1701
1684
|
});
|
|
1702
1685
|
};
|
|
1703
|
-
const
|
|
1704
|
-
let
|
|
1705
|
-
function
|
|
1706
|
-
if (
|
|
1707
|
-
|
|
1686
|
+
const J = /* @__PURE__ */ new WeakMap();
|
|
1687
|
+
let Te = !1;
|
|
1688
|
+
function Pe() {
|
|
1689
|
+
if (Te) return;
|
|
1690
|
+
Te = !0;
|
|
1708
1691
|
const t = u.fn.on, e = u.fn.off, s = u.fn.remove, n = u.fn.empty, i = u.fn.detach;
|
|
1709
1692
|
u.fn.remove = function(r) {
|
|
1710
1693
|
return (r ? this.filter(r) : this).each(function() {
|
|
1711
|
-
|
|
1694
|
+
f.cleanupTree(this);
|
|
1712
1695
|
}), s.call(this, r);
|
|
1713
1696
|
}, u.fn.empty = function() {
|
|
1714
1697
|
return this.each(function() {
|
|
1715
|
-
this.querySelectorAll("*").forEach((o) =>
|
|
1698
|
+
this.querySelectorAll("*").forEach((o) => f.cleanup(o));
|
|
1716
1699
|
}), n.call(this);
|
|
1717
1700
|
}, u.fn.detach = function(r) {
|
|
1718
1701
|
return (r ? this.filter(r) : this).each(function() {
|
|
1719
|
-
|
|
1702
|
+
f.keep(this);
|
|
1720
1703
|
}), i.call(this, r);
|
|
1721
1704
|
}, u.fn.on = function(...r) {
|
|
1722
1705
|
let o = -1;
|
|
@@ -1727,13 +1710,10 @@ function Me() {
|
|
|
1727
1710
|
}
|
|
1728
1711
|
if (o !== -1) {
|
|
1729
1712
|
const c = r[o];
|
|
1730
|
-
let
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
C = c.apply(this, _);
|
|
1735
|
-
}), C;
|
|
1736
|
-
}, Q.set(c, f)), r[o] = f;
|
|
1713
|
+
let h;
|
|
1714
|
+
J.has(c) ? h = J.get(c) : (h = function(..._) {
|
|
1715
|
+
return c.apply(this, _);
|
|
1716
|
+
}, J.set(c, h)), r[o] = h;
|
|
1737
1717
|
}
|
|
1738
1718
|
return t.apply(this, r);
|
|
1739
1719
|
}, u.fn.off = function(...r) {
|
|
@@ -1745,27 +1725,27 @@ function Me() {
|
|
|
1745
1725
|
}
|
|
1746
1726
|
if (o !== -1) {
|
|
1747
1727
|
const c = r[o];
|
|
1748
|
-
|
|
1728
|
+
J.has(c) && (r[o] = J.get(c));
|
|
1749
1729
|
}
|
|
1750
1730
|
return e.apply(this, r);
|
|
1751
1731
|
};
|
|
1752
1732
|
}
|
|
1753
|
-
const
|
|
1754
|
-
|
|
1733
|
+
const xt = Pe;
|
|
1734
|
+
Pe();
|
|
1755
1735
|
u(() => {
|
|
1756
|
-
|
|
1736
|
+
ft(document.body);
|
|
1757
1737
|
});
|
|
1758
1738
|
export {
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1739
|
+
it as atom,
|
|
1740
|
+
Je as batch,
|
|
1741
|
+
rt as computed,
|
|
1742
|
+
Ot as default,
|
|
1743
|
+
Tt as disableAutoCleanup,
|
|
1744
|
+
D as effect,
|
|
1745
|
+
ft as enableAutoCleanup,
|
|
1746
|
+
xt as enablejQueryBatching,
|
|
1747
|
+
Pe as enablejQueryOverrides,
|
|
1748
|
+
f as registry,
|
|
1749
|
+
Ue as untracked
|
|
1770
1750
|
};
|
|
1771
1751
|
//# sourceMappingURL=index.mjs.map
|