@but212/atom-effect-jquery 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -1
- package/dist/atom-effect-jquery.min.js +1 -1
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +25 -5
- package/dist/index.mjs +651 -553
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { default as
|
|
1
|
+
import u from "jquery";
|
|
2
|
+
import { default as Vt } from "jquery";
|
|
3
3
|
const Je = {
|
|
4
4
|
ONE_SECOND_MS: 1e3
|
|
5
|
-
},
|
|
5
|
+
}, Ee = {
|
|
6
6
|
IDLE: "idle",
|
|
7
7
|
PENDING: "pending",
|
|
8
8
|
RESOLVED: "resolved",
|
|
9
9
|
REJECTED: "rejected"
|
|
10
|
-
},
|
|
10
|
+
}, ve = {
|
|
11
11
|
DISPOSED: 1
|
|
12
12
|
}, P = {
|
|
13
|
-
...
|
|
13
|
+
...ve,
|
|
14
14
|
EXECUTING: 8
|
|
15
15
|
}, d = {
|
|
16
|
-
...
|
|
16
|
+
...ve,
|
|
17
17
|
DIRTY: 8,
|
|
18
18
|
IDLE: 16,
|
|
19
19
|
PENDING: 32,
|
|
@@ -22,7 +22,7 @@ const Je = {
|
|
|
22
22
|
RECOMPUTING: 256,
|
|
23
23
|
HAS_ERROR: 512
|
|
24
24
|
}, H = {
|
|
25
|
-
...
|
|
25
|
+
...ve,
|
|
26
26
|
SYNC: 8,
|
|
27
27
|
NOTIFICATION_SCHEDULED: 16
|
|
28
28
|
}, q = {
|
|
@@ -34,75 +34,73 @@ const Je = {
|
|
|
34
34
|
MAX_FLUSH_ITERATIONS: 1e3,
|
|
35
35
|
MIN_FLUSH_ITERATIONS: 10,
|
|
36
36
|
BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
|
|
37
|
-
},
|
|
38
|
-
MAX_DEPENDENCIES: 1e3,
|
|
37
|
+
}, Ze = {
|
|
39
38
|
WARN_INFINITE_LOOP: !0
|
|
40
|
-
},
|
|
41
|
-
class
|
|
39
|
+
}, ie = 1073741823, A = typeof process < "u" && process.env && process.env.NODE_ENV !== "production" || typeof __DEV__ < "u" && !!__DEV__, et = Object.freeze([]);
|
|
40
|
+
class ee extends Error {
|
|
42
41
|
constructor(e, t = null, s = !0) {
|
|
43
42
|
super(e), this.cause = t, this.recoverable = s, this.timestamp = /* @__PURE__ */ new Date(), this.name = "AtomError";
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
class z extends
|
|
45
|
+
class z extends ee {
|
|
47
46
|
constructor(e, t = null) {
|
|
48
47
|
super(e, t, !0), this.name = "ComputedError";
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
|
-
class
|
|
50
|
+
class G extends ee {
|
|
52
51
|
constructor(e, t = null) {
|
|
53
52
|
super(e, t, !1), this.name = "EffectError";
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
|
-
class
|
|
55
|
+
class ae extends ee {
|
|
57
56
|
constructor(e, t = null) {
|
|
58
57
|
super(e, t, !1), this.name = "SchedulerError";
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
|
-
const
|
|
62
|
-
function
|
|
60
|
+
const Ne = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), tt = /* @__PURE__ */ Symbol("AtomEffect.Id"), Re = /* @__PURE__ */ Symbol("AtomEffect.Type"), ye = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), nt = (n) => "dependencies" in n && Array.isArray(n.dependencies);
|
|
61
|
+
function Me(n, e, t) {
|
|
63
62
|
if (n === e)
|
|
64
63
|
throw new z(
|
|
65
64
|
"Circular dependency detected: The computation refers to itself explicitly or implicitly."
|
|
66
65
|
);
|
|
67
|
-
if (!t.has(n.id) && (t.add(n.id),
|
|
66
|
+
if (!t.has(n.id) && (t.add(n.id), nt(n))) {
|
|
68
67
|
const s = n.dependencies;
|
|
69
68
|
for (let i = 0; i < s.length; i++) {
|
|
70
69
|
const o = s[i];
|
|
71
|
-
o &&
|
|
70
|
+
o && Me(o, e, t);
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
const Y = {
|
|
76
75
|
// Dev mode flag
|
|
77
|
-
enabled:
|
|
78
|
-
|
|
79
|
-
warnInfiniteLoop: Ne.WARN_INFINITE_LOOP,
|
|
76
|
+
enabled: A,
|
|
77
|
+
warnInfiniteLoop: Ze.WARN_INFINITE_LOOP,
|
|
80
78
|
warn(n, e) {
|
|
81
|
-
|
|
79
|
+
A && this.enabled && n && console.warn(`[Atom Effect] ${e}`);
|
|
82
80
|
},
|
|
83
81
|
checkCircular(n, e) {
|
|
84
82
|
if (n === e)
|
|
85
83
|
throw new z("Direct circular dependency detected");
|
|
86
|
-
|
|
84
|
+
A && this.enabled && Me(n, e, /* @__PURE__ */ new Set());
|
|
87
85
|
},
|
|
88
86
|
attachDebugInfo(n, e, t) {
|
|
89
|
-
if (!
|
|
87
|
+
if (!A || !this.enabled) return;
|
|
90
88
|
const s = n;
|
|
91
|
-
s[
|
|
89
|
+
s[Ne] = `${e}_${t}`, s[tt] = t, s[Re] = e;
|
|
92
90
|
},
|
|
93
|
-
getDebugName: (n) => n?.[
|
|
94
|
-
getDebugType: (n) => n?.[
|
|
91
|
+
getDebugName: (n) => n?.[Ne],
|
|
92
|
+
getDebugType: (n) => n?.[Re]
|
|
95
93
|
};
|
|
96
|
-
let
|
|
97
|
-
const
|
|
98
|
-
function
|
|
94
|
+
let st = 1;
|
|
95
|
+
const it = () => st++;
|
|
96
|
+
function Be(n, e, t) {
|
|
99
97
|
if (typeof e == "function") {
|
|
100
98
|
const i = e;
|
|
101
99
|
for (let o = 0, r = t.length; o < r; o++) {
|
|
102
100
|
const c = t[o];
|
|
103
101
|
if (c && c.fn === i) return;
|
|
104
102
|
}
|
|
105
|
-
t.push(new
|
|
103
|
+
t.push(new Ce(i, void 0));
|
|
106
104
|
return;
|
|
107
105
|
}
|
|
108
106
|
if ("addDependency" in e) {
|
|
@@ -114,9 +112,9 @@ function je(n, e, t) {
|
|
|
114
112
|
const r = t[i];
|
|
115
113
|
if (r && r.sub === s) return;
|
|
116
114
|
}
|
|
117
|
-
t.push(new
|
|
115
|
+
t.push(new Ce(void 0, s));
|
|
118
116
|
}
|
|
119
|
-
function
|
|
117
|
+
function ot(n, e, t) {
|
|
120
118
|
for (let s = 0, i = e.length; s < i; s++) {
|
|
121
119
|
const o = e[s];
|
|
122
120
|
o && (o.node._tempUnsub = o.unsub);
|
|
@@ -135,17 +133,17 @@ function it(n, e, t) {
|
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
135
|
}
|
|
138
|
-
class
|
|
136
|
+
class he {
|
|
139
137
|
constructor(e, t, s = void 0) {
|
|
140
138
|
this.node = e, this.version = t, this.unsub = s;
|
|
141
139
|
}
|
|
142
140
|
}
|
|
143
|
-
class
|
|
141
|
+
class Ce {
|
|
144
142
|
constructor(e, t) {
|
|
145
143
|
this.fn = e, this.sub = t;
|
|
146
144
|
}
|
|
147
145
|
}
|
|
148
|
-
const
|
|
146
|
+
const D = {
|
|
149
147
|
// Computed Errors
|
|
150
148
|
COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
|
|
151
149
|
COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
|
|
@@ -161,10 +159,15 @@ const v = {
|
|
|
161
159
|
EFFECT_EXECUTION_FAILED: "Effect execution failed",
|
|
162
160
|
EFFECT_CLEANUP_FAILED: "Effect cleanup failed",
|
|
163
161
|
EFFECT_DISPOSED: "Attempted to run disposed effect",
|
|
164
|
-
|
|
162
|
+
// Scheduler Errors
|
|
163
|
+
SCHEDULER_FLUSH_OVERFLOW: (n, e) => `Maximum flush iterations (${n}) exceeded. ${e} jobs dropped. Possible infinite loop.`,
|
|
164
|
+
// System / Debug
|
|
165
|
+
CALLBACK_ERROR_IN_ERROR_HANDLER: "Exception encountered in onError handler",
|
|
166
|
+
// Effect frequency
|
|
167
|
+
EFFECT_FREQUENCY_LIMIT_EXCEEDED: "Effect executed too frequently within 1 second. Suspected infinite loop."
|
|
165
168
|
};
|
|
166
|
-
function
|
|
167
|
-
if (n instanceof
|
|
169
|
+
function Z(n, e, t) {
|
|
170
|
+
if (n instanceof ee)
|
|
168
171
|
return n;
|
|
169
172
|
const s = n instanceof Error, i = s ? n.message : String(n), o = s ? n : void 0;
|
|
170
173
|
let r = "Unexpected error";
|
|
@@ -172,31 +175,31 @@ function ee(n, e, t) {
|
|
|
172
175
|
const c = `${r} (${t}): ${i}`;
|
|
173
176
|
return new e(c, o);
|
|
174
177
|
}
|
|
175
|
-
class
|
|
178
|
+
class je {
|
|
176
179
|
constructor() {
|
|
177
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this._modifiedAtEpoch = -1, this.id =
|
|
180
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this._modifiedAtEpoch = -1, this.id = it() & ie, this._tempUnsub = void 0;
|
|
178
181
|
}
|
|
179
182
|
}
|
|
180
|
-
class
|
|
183
|
+
class Ve extends je {
|
|
181
184
|
/**
|
|
182
185
|
* Adds subscriber.
|
|
183
186
|
*/
|
|
184
187
|
subscribe(e) {
|
|
185
188
|
const t = typeof e == "function";
|
|
186
189
|
if (!t && (!e || typeof e.execute != "function"))
|
|
187
|
-
throw
|
|
190
|
+
throw Z(
|
|
188
191
|
new TypeError("Invalid subscriber"),
|
|
189
|
-
|
|
190
|
-
|
|
192
|
+
ee,
|
|
193
|
+
D.ATOM_SUBSCRIBER_MUST_BE_FUNCTION
|
|
191
194
|
);
|
|
192
195
|
const s = this._subscribers;
|
|
193
196
|
for (let o = 0, r = s.length; o < r; o++) {
|
|
194
197
|
const c = s[o];
|
|
195
198
|
if (c && (t ? c.fn === e : c.sub === e))
|
|
196
|
-
return
|
|
199
|
+
return A && console.warn("Duplicate subscription ignored."), () => {
|
|
197
200
|
};
|
|
198
201
|
}
|
|
199
|
-
const i = new
|
|
202
|
+
const i = new Ce(
|
|
200
203
|
t ? e : void 0,
|
|
201
204
|
t ? void 0 : e
|
|
202
205
|
);
|
|
@@ -213,7 +216,7 @@ class He extends Ve {
|
|
|
213
216
|
}
|
|
214
217
|
_notifySubscribers(e, t) {
|
|
215
218
|
if (this._subscribers.length === 0) return;
|
|
216
|
-
const s =
|
|
219
|
+
const s = this._subscribers.slice(0), i = s.length;
|
|
217
220
|
for (let o = 0; o < i; o++) {
|
|
218
221
|
const r = s[o];
|
|
219
222
|
if (r)
|
|
@@ -225,18 +228,18 @@ class He extends Ve {
|
|
|
225
228
|
}
|
|
226
229
|
}
|
|
227
230
|
_handleNotifyError(e) {
|
|
228
|
-
console.error(
|
|
231
|
+
console.error(Z(e, ee, D.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
|
-
let
|
|
232
|
-
const
|
|
233
|
-
let
|
|
234
|
-
function
|
|
235
|
-
return
|
|
234
|
+
let fe = 0;
|
|
235
|
+
const He = () => (fe = fe + 1 & ie || 1, fe), rt = () => fe, Ie = (n) => n + 1 & ie;
|
|
236
|
+
let Se = 0, Te = 0, _e = !1;
|
|
237
|
+
function xe() {
|
|
238
|
+
return _e ? (A && console.warn("startFlush() called during flush - ignored"), !1) : (_e = !0, Se = Se + 1 & ie || 1, Te = 0, !0);
|
|
236
239
|
}
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
},
|
|
240
|
+
const Ae = () => {
|
|
241
|
+
_e = !1;
|
|
242
|
+
}, ct = () => _e ? ++Te : 0, $ = {
|
|
240
243
|
/** Queue buffer */
|
|
241
244
|
_queueBuffer: [[], []],
|
|
242
245
|
_bufferIndex: 0,
|
|
@@ -266,8 +269,8 @@ const xe = () => {
|
|
|
266
269
|
* Schedules job.
|
|
267
270
|
*/
|
|
268
271
|
schedule(n) {
|
|
269
|
-
if (
|
|
270
|
-
throw new
|
|
272
|
+
if (A && typeof n != "function")
|
|
273
|
+
throw new ae("Scheduler callback must be a function");
|
|
271
274
|
if (n._nextEpoch !== this._epoch) {
|
|
272
275
|
if (n._nextEpoch = this._epoch, this._isBatching || this._isFlushingSync) {
|
|
273
276
|
this._batchQueue[this._batchQueueSize++] = n;
|
|
@@ -287,20 +290,20 @@ const xe = () => {
|
|
|
287
290
|
*/
|
|
288
291
|
_runLoop: () => {
|
|
289
292
|
try {
|
|
290
|
-
if (
|
|
291
|
-
const n =
|
|
292
|
-
|
|
293
|
+
if ($._size === 0) return;
|
|
294
|
+
const n = xe();
|
|
295
|
+
$._drainQueue(), n && Ae();
|
|
293
296
|
} finally {
|
|
294
|
-
|
|
297
|
+
$._isProcessing = !1, $._size > 0 && !$._isBatching && $._flush();
|
|
295
298
|
}
|
|
296
299
|
},
|
|
297
300
|
_flushSync() {
|
|
298
301
|
this._isFlushingSync = !0;
|
|
299
|
-
const n =
|
|
302
|
+
const n = xe();
|
|
300
303
|
try {
|
|
301
304
|
this._mergeBatchQueue(), this._drainQueue();
|
|
302
305
|
} finally {
|
|
303
|
-
this._isFlushingSync = !1, n &&
|
|
306
|
+
this._isFlushingSync = !1, n && Ae();
|
|
304
307
|
}
|
|
305
308
|
},
|
|
306
309
|
_mergeBatchQueue() {
|
|
@@ -330,35 +333,42 @@ const xe = () => {
|
|
|
330
333
|
try {
|
|
331
334
|
e[s]();
|
|
332
335
|
} catch (i) {
|
|
333
|
-
console.error(new
|
|
336
|
+
console.error(new ae("Error occurred during scheduler execution", i));
|
|
334
337
|
}
|
|
335
338
|
e.length = 0;
|
|
336
339
|
},
|
|
340
|
+
/** Overflow callback */
|
|
341
|
+
onOverflow: null,
|
|
337
342
|
_handleFlushOverflow() {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
343
|
+
const n = this._size + this._batchQueueSize;
|
|
344
|
+
if (console.error(
|
|
345
|
+
new ae(
|
|
346
|
+
D.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, n)
|
|
341
347
|
)
|
|
342
|
-
), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0
|
|
348
|
+
), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0, this.onOverflow)
|
|
349
|
+
try {
|
|
350
|
+
this.onOverflow(n);
|
|
351
|
+
} catch {
|
|
352
|
+
}
|
|
343
353
|
},
|
|
344
354
|
startBatch() {
|
|
345
355
|
this._batchDepth++, this._isBatching = !0;
|
|
346
356
|
},
|
|
347
357
|
endBatch() {
|
|
348
358
|
if (this._batchDepth === 0) {
|
|
349
|
-
|
|
359
|
+
A && console.warn("endBatch() called without matching startBatch(). Ignoring.");
|
|
350
360
|
return;
|
|
351
361
|
}
|
|
352
362
|
--this._batchDepth === 0 && (this._flushSync(), this._isBatching = !1);
|
|
353
363
|
},
|
|
354
364
|
setMaxFlushIterations(n) {
|
|
355
365
|
if (n < q.MIN_FLUSH_ITERATIONS)
|
|
356
|
-
throw new
|
|
366
|
+
throw new ae(
|
|
357
367
|
`Max flush iterations must be at least ${q.MIN_FLUSH_ITERATIONS}`
|
|
358
368
|
);
|
|
359
369
|
this._maxFlushIterations = n;
|
|
360
370
|
}
|
|
361
|
-
},
|
|
371
|
+
}, B = {
|
|
362
372
|
/** Active listener. */
|
|
363
373
|
current: null,
|
|
364
374
|
/**
|
|
@@ -378,35 +388,35 @@ const xe = () => {
|
|
|
378
388
|
}
|
|
379
389
|
}
|
|
380
390
|
};
|
|
381
|
-
function
|
|
382
|
-
const e =
|
|
391
|
+
function at(n) {
|
|
392
|
+
const e = B.current;
|
|
383
393
|
if (e === null) return n();
|
|
384
|
-
|
|
394
|
+
B.current = null;
|
|
385
395
|
try {
|
|
386
396
|
return n();
|
|
387
397
|
} finally {
|
|
388
|
-
|
|
398
|
+
B.current = e;
|
|
389
399
|
}
|
|
390
400
|
}
|
|
391
|
-
class ut extends
|
|
401
|
+
class ut extends Ve {
|
|
392
402
|
constructor(e, t) {
|
|
393
403
|
super(), this._pendingOldValue = void 0, this._notifyTask = void 0, this._subscribers = [], this._value = e, t && (this.flags |= H.SYNC), Y.attachDebugInfo(this, "atom", this.id);
|
|
394
404
|
}
|
|
395
405
|
get value() {
|
|
396
|
-
const e =
|
|
397
|
-
return e &&
|
|
406
|
+
const e = B.current;
|
|
407
|
+
return e && Be(this, e, this._subscribers), this._value;
|
|
398
408
|
}
|
|
399
409
|
set value(e) {
|
|
400
410
|
const t = this._value;
|
|
401
411
|
if (Object.is(t, e)) return;
|
|
402
|
-
this._value = e, this.version = this.version
|
|
412
|
+
this._value = e, this.version = Ie(this.version);
|
|
403
413
|
const s = this.flags;
|
|
404
414
|
if (!(this._subscribers.length === 0 || s & H.NOTIFICATION_SCHEDULED)) {
|
|
405
|
-
if (this._pendingOldValue = t, this.flags = s | H.NOTIFICATION_SCHEDULED, s & H.SYNC &&
|
|
415
|
+
if (this._pendingOldValue = t, this.flags = s | H.NOTIFICATION_SCHEDULED, s & H.SYNC && !$.isBatching) {
|
|
406
416
|
this._flushNotifications();
|
|
407
417
|
return;
|
|
408
418
|
}
|
|
409
|
-
this._notifyTask || (this._notifyTask = () => this._flushNotifications()),
|
|
419
|
+
this._notifyTask || (this._notifyTask = () => this._flushNotifications()), $.schedule(this._notifyTask);
|
|
410
420
|
}
|
|
411
421
|
}
|
|
412
422
|
/**
|
|
@@ -426,16 +436,17 @@ class ut extends He {
|
|
|
426
436
|
this.flags & H.DISPOSED || (this._subscribers.length = 0, this.flags |= H.DISPOSED, this._value = void 0, this._pendingOldValue = void 0, this._notifyTask = void 0);
|
|
427
437
|
}
|
|
428
438
|
}
|
|
429
|
-
function
|
|
439
|
+
function ze(n, e = {}) {
|
|
430
440
|
return new ut(n, e.sync ?? !1);
|
|
431
441
|
}
|
|
432
442
|
class lt {
|
|
433
443
|
/**
|
|
434
444
|
* @param limit - Max unique arrays to hold (default: 50). Prevents the pool itself from consuming too much memory.
|
|
435
445
|
* @param capacity - Max length of an array to accept (default: 256).
|
|
446
|
+
* @param enableStats - Force-enable stats even in production (default: false).
|
|
436
447
|
*/
|
|
437
|
-
constructor(e = 50, t = 256) {
|
|
438
|
-
this.limit = e, this.capacity = t, this.pool = [], this.stats =
|
|
448
|
+
constructor(e = 50, t = 256, s = !1) {
|
|
449
|
+
this.limit = e, this.capacity = t, this.pool = [], this.stats = null, this.stats = A || s ? {
|
|
439
450
|
acquired: 0,
|
|
440
451
|
released: 0,
|
|
441
452
|
rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
|
|
@@ -445,7 +456,7 @@ class lt {
|
|
|
445
456
|
* Acquires array.
|
|
446
457
|
*/
|
|
447
458
|
acquire() {
|
|
448
|
-
return
|
|
459
|
+
return this.stats && this.stats.acquired++, this.pool.pop() ?? [];
|
|
449
460
|
}
|
|
450
461
|
/**
|
|
451
462
|
* Releases array.
|
|
@@ -456,25 +467,25 @@ class lt {
|
|
|
456
467
|
release(e, t) {
|
|
457
468
|
if (!(t && e === t)) {
|
|
458
469
|
if (e.length > this.capacity) {
|
|
459
|
-
|
|
470
|
+
this.stats && this.stats.rejected.tooLarge++;
|
|
460
471
|
return;
|
|
461
472
|
}
|
|
462
473
|
if (this.pool.length >= this.limit) {
|
|
463
|
-
|
|
474
|
+
this.stats && this.stats.rejected.poolFull++;
|
|
464
475
|
return;
|
|
465
476
|
}
|
|
466
477
|
if (Object.isFrozen(e)) {
|
|
467
|
-
|
|
478
|
+
this.stats && this.stats.rejected.frozen++;
|
|
468
479
|
return;
|
|
469
480
|
}
|
|
470
|
-
e.length = 0, this.pool.push(e),
|
|
481
|
+
e.length = 0, this.pool.push(e), this.stats && this.stats.released++;
|
|
471
482
|
}
|
|
472
483
|
}
|
|
473
484
|
/**
|
|
474
485
|
* Pool stats.
|
|
475
486
|
*/
|
|
476
487
|
getStats() {
|
|
477
|
-
if (!
|
|
488
|
+
if (!this.stats) return null;
|
|
478
489
|
const { acquired: e, released: t, rejected: s } = this.stats, i = e - t - (s.frozen + s.tooLarge + s.poolFull);
|
|
479
490
|
return {
|
|
480
491
|
acquired: e,
|
|
@@ -488,7 +499,7 @@ class lt {
|
|
|
488
499
|
* Resets pool.
|
|
489
500
|
*/
|
|
490
501
|
reset() {
|
|
491
|
-
this.pool.length = 0,
|
|
502
|
+
this.pool.length = 0, this.stats && (this.stats = {
|
|
492
503
|
acquired: 0,
|
|
493
504
|
released: 0,
|
|
494
505
|
rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
|
|
@@ -500,33 +511,35 @@ oe([]);
|
|
|
500
511
|
oe([]);
|
|
501
512
|
oe([]);
|
|
502
513
|
oe([]);
|
|
503
|
-
const
|
|
504
|
-
function
|
|
514
|
+
const U = oe([]), X = new lt();
|
|
515
|
+
function De(n) {
|
|
505
516
|
return n !== null && typeof n == "object" && "value" in n && typeof n.subscribe == "function";
|
|
506
517
|
}
|
|
507
518
|
function Le(n) {
|
|
508
|
-
return
|
|
519
|
+
return De(n) && typeof n.invalidate == "function";
|
|
509
520
|
}
|
|
510
|
-
function
|
|
521
|
+
function qe(n) {
|
|
511
522
|
return n !== null && typeof n == "object" && typeof n.then == "function";
|
|
512
523
|
}
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
class Qe extends
|
|
524
|
+
const Xe = d.RESOLVED | d.PENDING | d.REJECTED, ge = Array(Xe + 1).fill(Ee.IDLE);
|
|
525
|
+
ge[d.RESOLVED] = Ee.RESOLVED;
|
|
526
|
+
ge[d.PENDING] = Ee.PENDING;
|
|
527
|
+
ge[d.REJECTED] = Ee.REJECTED;
|
|
528
|
+
const ht = 3, Ue = Number.MAX_SAFE_INTEGER - 1, ft = d.REJECTED | d.HAS_ERROR;
|
|
529
|
+
class Qe extends Ve {
|
|
519
530
|
constructor(e, t = {}) {
|
|
520
|
-
if (typeof e != "function") throw new z(
|
|
521
|
-
|
|
531
|
+
if (typeof e != "function") throw new z(D.COMPUTED_MUST_BE_FUNCTION);
|
|
532
|
+
super(), this._error = null, this._promiseId = 0, this._subscribers = [], this._links = U, this._cachedErrors = null, this._errorCacheEpoch = -1, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._errorDepCount = 0, this._trackEpoch = -1, this._trackLinks = U, this._trackCount = 0, this._value = void 0, this.flags = d.DIRTY | d.IDLE, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : ye, this._onError = t.onError ?? null;
|
|
533
|
+
const s = t.maxAsyncRetries;
|
|
534
|
+
if (this._maxAsyncRetries = s != null && s >= 0 ? s : ht, Y.attachDebugInfo(this, "computed", this.id), t.lazy === !1)
|
|
522
535
|
try {
|
|
523
536
|
this._recompute();
|
|
524
537
|
} catch {
|
|
525
538
|
}
|
|
526
539
|
}
|
|
527
540
|
_track() {
|
|
528
|
-
const e =
|
|
529
|
-
e &&
|
|
541
|
+
const e = B.current;
|
|
542
|
+
e && Be(this, e, this._subscribers);
|
|
530
543
|
}
|
|
531
544
|
get value() {
|
|
532
545
|
this._track();
|
|
@@ -534,17 +547,17 @@ class Qe extends He {
|
|
|
534
547
|
if ((e & (d.RESOLVED | d.DIRTY | d.IDLE)) === d.RESOLVED)
|
|
535
548
|
return this._value;
|
|
536
549
|
if (e & d.DISPOSED)
|
|
537
|
-
throw new z(
|
|
550
|
+
throw new z(D.COMPUTED_DISPOSED);
|
|
538
551
|
if (e & d.RECOMPUTING) {
|
|
539
|
-
if (this._defaultValue !==
|
|
540
|
-
throw new z(
|
|
552
|
+
if (this._defaultValue !== ye) return this._defaultValue;
|
|
553
|
+
throw new z(D.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
541
554
|
}
|
|
542
555
|
if (e & (d.DIRTY | d.IDLE) && (this._recompute(), this.flags & d.RESOLVED))
|
|
543
556
|
return this._value;
|
|
544
|
-
const t = this._defaultValue, s = t !==
|
|
557
|
+
const t = this._defaultValue, s = t !== ye;
|
|
545
558
|
if (this.flags & d.PENDING) {
|
|
546
559
|
if (s) return t;
|
|
547
|
-
throw new z(
|
|
560
|
+
throw new z(D.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
548
561
|
}
|
|
549
562
|
if (this.flags & d.REJECTED) {
|
|
550
563
|
if (this._error?.recoverable && s) return t;
|
|
@@ -556,10 +569,10 @@ class Qe extends He {
|
|
|
556
569
|
return this._value;
|
|
557
570
|
}
|
|
558
571
|
get state() {
|
|
559
|
-
return this._track(),
|
|
572
|
+
return this._track(), ge[this.flags & Xe];
|
|
560
573
|
}
|
|
561
574
|
get hasError() {
|
|
562
|
-
if (this._track(), this.flags & (d.REJECTED | d.HAS_ERROR)) return !0;
|
|
575
|
+
if (this._track(), this.flags & (d.REJECTED | d.HAS_ERROR) || this._errorDepCount > 0) return !0;
|
|
563
576
|
const e = this._links;
|
|
564
577
|
for (let t = 0, s = e.length; t < s; t++) {
|
|
565
578
|
const i = e[t]?.node;
|
|
@@ -572,8 +585,8 @@ class Qe extends He {
|
|
|
572
585
|
return !this.hasError;
|
|
573
586
|
}
|
|
574
587
|
get errors() {
|
|
575
|
-
if (this._track(), !this.hasError) return
|
|
576
|
-
const e =
|
|
588
|
+
if (this._track(), !this.hasError) return et;
|
|
589
|
+
const e = rt();
|
|
577
590
|
if (this._errorCacheEpoch === e && this._cachedErrors) return this._cachedErrors;
|
|
578
591
|
const t = [];
|
|
579
592
|
this._error && t.push(this._error);
|
|
@@ -581,12 +594,12 @@ class Qe extends He {
|
|
|
581
594
|
for (let o = 0, r = s.length; o < r; o++) {
|
|
582
595
|
const c = s[o].node;
|
|
583
596
|
if (c.flags & d.HAS_ERROR) {
|
|
584
|
-
const
|
|
585
|
-
if (
|
|
586
|
-
const
|
|
587
|
-
for (let
|
|
588
|
-
const
|
|
589
|
-
|
|
597
|
+
const l = c;
|
|
598
|
+
if (l.errors) {
|
|
599
|
+
const _ = l.errors;
|
|
600
|
+
for (let g = 0; g < _.length; g++) {
|
|
601
|
+
const v = _[g];
|
|
602
|
+
v && t.indexOf(v) === -1 && t.push(v);
|
|
590
603
|
}
|
|
591
604
|
}
|
|
592
605
|
}
|
|
@@ -609,12 +622,12 @@ class Qe extends He {
|
|
|
609
622
|
dispose() {
|
|
610
623
|
if (this.flags & d.DISPOSED) return;
|
|
611
624
|
const e = this._links;
|
|
612
|
-
if (e !==
|
|
625
|
+
if (e !== U) {
|
|
613
626
|
for (let t = 0, s = e.length; t < s; t++)
|
|
614
627
|
e[t].unsub?.();
|
|
615
|
-
X.release(e), this._links =
|
|
628
|
+
X.release(e), this._links = U;
|
|
616
629
|
}
|
|
617
|
-
this._subscribers.length = 0, this.flags = d.DISPOSED | d.DIRTY | d.IDLE, this._error = null, this._value = void 0, this._promiseId = (this._promiseId + 1) %
|
|
630
|
+
this._subscribers.length = 0, this.flags = d.DISPOSED | d.DIRTY | d.IDLE, this._error = null, this._value = void 0, this._promiseId = (this._promiseId + 1) % Ue, this._cachedErrors = null, this._errorCacheEpoch = -1;
|
|
618
631
|
}
|
|
619
632
|
addDependency(e) {
|
|
620
633
|
if (e._lastSeenEpoch !== this._trackEpoch) {
|
|
@@ -622,70 +635,82 @@ class Qe extends He {
|
|
|
622
635
|
const t = this._trackLinks[this._trackCount];
|
|
623
636
|
t.node = e, t.version = e.version;
|
|
624
637
|
} else
|
|
625
|
-
this._trackLinks.push(new
|
|
638
|
+
this._trackLinks.push(new he(e, e.version));
|
|
626
639
|
this._trackCount++;
|
|
627
640
|
}
|
|
628
641
|
}
|
|
629
642
|
_commitDeps(e) {
|
|
630
|
-
this._trackLinks.length = this._trackCount,
|
|
643
|
+
this._trackLinks.length = this._trackCount, ot(this._trackLinks, e, this), this._links = this._trackLinks;
|
|
644
|
+
}
|
|
645
|
+
_updateErrorDepCount() {
|
|
646
|
+
let e = 0;
|
|
647
|
+
const t = this._links;
|
|
648
|
+
for (let s = 0, i = t.length; s < i; s++) {
|
|
649
|
+
const o = t[s]?.node;
|
|
650
|
+
o && o.flags & d.HAS_ERROR && e++;
|
|
651
|
+
}
|
|
652
|
+
this._errorDepCount = e;
|
|
631
653
|
}
|
|
632
654
|
_recompute() {
|
|
633
655
|
if (this.flags & d.RECOMPUTING) return;
|
|
634
656
|
this.flags |= d.RECOMPUTING;
|
|
635
657
|
const e = this._links;
|
|
636
|
-
this._trackEpoch =
|
|
658
|
+
this._trackEpoch = He(), this._trackLinks = X.acquire(), this._trackCount = 0;
|
|
637
659
|
let t = !1;
|
|
638
660
|
try {
|
|
639
|
-
const s =
|
|
640
|
-
this._commitDeps(e), t = !0,
|
|
661
|
+
const s = B.run(this, this._fn);
|
|
662
|
+
this._commitDeps(e), t = !0, this._updateErrorDepCount(), qe(s) ? this._handleAsyncComputation(s) : this._finalizeResolution(s);
|
|
641
663
|
} catch (s) {
|
|
642
664
|
if (!t)
|
|
643
665
|
try {
|
|
644
|
-
this._commitDeps(e), t = !0;
|
|
645
|
-
} catch {
|
|
666
|
+
this._commitDeps(e), t = !0, this._updateErrorDepCount();
|
|
667
|
+
} catch (i) {
|
|
668
|
+
A && console.warn("[atom-effect] _commitDeps failed during error recovery:", i);
|
|
646
669
|
}
|
|
647
|
-
this._handleError(s,
|
|
670
|
+
this._handleError(s, D.COMPUTED_COMPUTATION_FAILED, !0);
|
|
648
671
|
} finally {
|
|
649
|
-
t && e !==
|
|
672
|
+
t && e !== U ? X.release(e) : t || X.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = U, this._trackCount = 0, this.flags &= -257;
|
|
650
673
|
}
|
|
651
674
|
}
|
|
652
675
|
_handleAsyncComputation(e) {
|
|
653
|
-
this.flags = (this.flags | d.PENDING) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) %
|
|
676
|
+
this.flags = (this.flags | d.PENDING) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % Ue;
|
|
654
677
|
const t = this._promiseId;
|
|
655
678
|
e.then(
|
|
656
679
|
(s) => {
|
|
657
680
|
if (t === this._promiseId) {
|
|
658
681
|
if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion)
|
|
659
|
-
return this._asyncRetryCount++ <
|
|
660
|
-
new z(
|
|
661
|
-
|
|
682
|
+
return this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(
|
|
683
|
+
new z(
|
|
684
|
+
`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`
|
|
685
|
+
),
|
|
686
|
+
D.COMPUTED_ASYNC_COMPUTATION_FAILED
|
|
662
687
|
);
|
|
663
688
|
this._finalizeResolution(s), this._notifySubscribers(s, void 0);
|
|
664
689
|
}
|
|
665
690
|
},
|
|
666
|
-
(s) => t === this._promiseId && this._handleError(s,
|
|
691
|
+
(s) => t === this._promiseId && this._handleError(s, D.COMPUTED_ASYNC_COMPUTATION_FAILED)
|
|
667
692
|
);
|
|
668
693
|
}
|
|
669
694
|
_captureVersionSnapshot() {
|
|
670
695
|
let e = 0;
|
|
671
696
|
const t = this._links;
|
|
672
697
|
for (let s = 0, i = t.length; s < i; s++)
|
|
673
|
-
e = ((e << 5) - e | 0) + t[s].node.version &
|
|
698
|
+
e = ((e << 5) - e | 0) + t[s].node.version & ie;
|
|
674
699
|
return e;
|
|
675
700
|
}
|
|
676
701
|
_handleError(e, t, s = !1) {
|
|
677
|
-
const i =
|
|
678
|
-
if (!s && !(this.flags & d.REJECTED) && (this.version = this.version
|
|
702
|
+
const i = Z(e, z, t);
|
|
703
|
+
if (!s && !(this.flags & d.REJECTED) && (this.version = Ie(this.version)), this._error = i, this.flags = this.flags & -121 | ft, this._onError)
|
|
679
704
|
try {
|
|
680
705
|
this._onError(i);
|
|
681
706
|
} catch (o) {
|
|
682
|
-
console.error(
|
|
707
|
+
console.error(D.CALLBACK_ERROR_IN_ERROR_HANDLER, o);
|
|
683
708
|
}
|
|
684
709
|
if (s) throw i;
|
|
685
710
|
this._notifySubscribers(void 0, void 0);
|
|
686
711
|
}
|
|
687
712
|
_finalizeResolution(e) {
|
|
688
|
-
(!(this.flags & d.RESOLVED) || !this._equal(this._value, e)) && (this.version = this.version
|
|
713
|
+
(!(this.flags & d.RESOLVED) || !this._equal(this._value, e)) && (this.version = Ie(this.version)), this._value = e, this._error = null, this.flags = (this.flags | d.RESOLVED) & -697, this._cachedErrors = null, this._errorCacheEpoch = -1;
|
|
689
714
|
}
|
|
690
715
|
execute() {
|
|
691
716
|
this._markDirty();
|
|
@@ -696,39 +721,45 @@ class Qe extends He {
|
|
|
696
721
|
}
|
|
697
722
|
}
|
|
698
723
|
Object.freeze(Qe.prototype);
|
|
699
|
-
function
|
|
724
|
+
function dt(n, e = {}) {
|
|
700
725
|
return new Qe(n, e);
|
|
701
726
|
}
|
|
702
|
-
class
|
|
727
|
+
class _t extends je {
|
|
703
728
|
constructor(e, t = {}) {
|
|
704
|
-
super(), this._cleanup = null, this._links =
|
|
729
|
+
super(), this._cleanup = null, this._links = U, this._nextLinks = null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._historyPtr = 0, this._execId = 0, this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? q.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? q.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = t.trackModifications ?? !1;
|
|
705
730
|
const s = Number.isFinite(this._maxExecutions), i = s ? Math.min(this._maxExecutions + 1, q.MAX_EXECUTIONS_PER_SECOND + 1) : 0;
|
|
706
|
-
this._historyCapacity = i, this._history =
|
|
731
|
+
this._historyCapacity = i, this._history = A && s && i > 0 ? new Array(i).fill(0) : null, Y.attachDebugInfo(this, "effect", this.id);
|
|
707
732
|
}
|
|
708
733
|
run() {
|
|
709
734
|
if (this.flags & P.DISPOSED)
|
|
710
|
-
throw new
|
|
735
|
+
throw new G(D.EFFECT_DISPOSED);
|
|
711
736
|
this.execute(!0);
|
|
712
737
|
}
|
|
713
738
|
dispose() {
|
|
714
|
-
this.flags & P.DISPOSED || (this.flags |= P.DISPOSED, this._execCleanup(), this._releaseLinks(this._links), this._links =
|
|
739
|
+
this.flags & P.DISPOSED || (this.flags |= P.DISPOSED, this._execCleanup(), this._releaseLinks(this._links), this._links = U, this._executeTask = void 0);
|
|
715
740
|
}
|
|
716
741
|
addDependency(e) {
|
|
717
742
|
if (!(this.flags & P.EXECUTING) || e._lastSeenEpoch === this._currentEpoch) return;
|
|
718
743
|
e._lastSeenEpoch = this._currentEpoch;
|
|
719
744
|
const t = this._nextLinks;
|
|
720
745
|
if (e._tempUnsub) {
|
|
721
|
-
t.push(new
|
|
746
|
+
t.push(new he(e, e.version, e._tempUnsub)), e._tempUnsub = void 0;
|
|
722
747
|
return;
|
|
723
748
|
}
|
|
724
749
|
try {
|
|
725
750
|
const s = e.subscribe(() => {
|
|
726
751
|
if (this._trackModifications && this.flags & P.EXECUTING && (e._modifiedAtEpoch = this._currentEpoch), this._sync) return this.execute();
|
|
727
|
-
this._executeTask || (this._executeTask = () => this.execute()),
|
|
752
|
+
this._executeTask || (this._executeTask = () => this.execute()), $.schedule(this._executeTask);
|
|
728
753
|
});
|
|
729
|
-
t.push(new
|
|
754
|
+
t.push(new he(e, e.version, s));
|
|
730
755
|
} catch (s) {
|
|
731
|
-
|
|
756
|
+
const i = Z(s, G, D.EFFECT_EXECUTION_FAILED);
|
|
757
|
+
if (console.error(i), this._onError)
|
|
758
|
+
try {
|
|
759
|
+
this._onError(i);
|
|
760
|
+
} catch {
|
|
761
|
+
}
|
|
762
|
+
t.push(new he(e, e.version, void 0));
|
|
732
763
|
}
|
|
733
764
|
}
|
|
734
765
|
/**
|
|
@@ -738,17 +769,17 @@ class ht extends Ve {
|
|
|
738
769
|
if (this.flags & (P.DISPOSED | P.EXECUTING) || !e && this._links.length > 0 && !this._isDirty()) return;
|
|
739
770
|
this._checkInfiniteLoops(), this.flags |= P.EXECUTING, this._execCleanup();
|
|
740
771
|
const t = this._links;
|
|
741
|
-
if (t !==
|
|
772
|
+
if (t !== U)
|
|
742
773
|
for (let o = 0, r = t.length; o < r; o++) {
|
|
743
774
|
const c = t[o];
|
|
744
775
|
c && (c.node._tempUnsub = c.unsub);
|
|
745
776
|
}
|
|
746
777
|
const s = X.acquire();
|
|
747
|
-
this._nextLinks = s, this._currentEpoch =
|
|
778
|
+
this._nextLinks = s, this._currentEpoch = He();
|
|
748
779
|
let i = !1;
|
|
749
780
|
try {
|
|
750
|
-
const o =
|
|
751
|
-
this._links = s, i = !0, this._checkLoopWarnings(),
|
|
781
|
+
const o = B.run(this, this._fn);
|
|
782
|
+
this._links = s, i = !0, this._checkLoopWarnings(), qe(o) ? this._handleAsyncResult(o) : this._cleanup = typeof o == "function" ? o : null;
|
|
752
783
|
} catch (o) {
|
|
753
784
|
i = !0, this._handleExecutionError(o), this._cleanup = null;
|
|
754
785
|
} finally {
|
|
@@ -764,7 +795,7 @@ class ht extends Ve {
|
|
|
764
795
|
try {
|
|
765
796
|
s();
|
|
766
797
|
} catch (i) {
|
|
767
|
-
this._handleExecutionError(i,
|
|
798
|
+
this._handleExecutionError(i, D.EFFECT_CLEANUP_FAILED);
|
|
768
799
|
}
|
|
769
800
|
return;
|
|
770
801
|
}
|
|
@@ -775,43 +806,41 @@ class ht extends Ve {
|
|
|
775
806
|
}
|
|
776
807
|
_finalizeDependencies(e, t, s) {
|
|
777
808
|
if (this._nextLinks = null, e) {
|
|
778
|
-
if (t !==
|
|
809
|
+
if (t !== U) {
|
|
779
810
|
for (let i = 0, o = t.length; i < o; i++) {
|
|
780
811
|
const r = t[i], c = r?.node._tempUnsub;
|
|
781
812
|
c && (c(), r && (r.node._tempUnsub = void 0));
|
|
782
813
|
}
|
|
783
814
|
X.release(t);
|
|
784
815
|
}
|
|
785
|
-
} else if (this._releaseLinks(s), X.release(s), t !==
|
|
816
|
+
} else if (this._releaseLinks(s), X.release(s), t !== U)
|
|
786
817
|
for (let i = 0, o = t.length; i < o; i++)
|
|
787
818
|
t[i] && (t[i].node._tempUnsub = void 0);
|
|
788
819
|
}
|
|
789
820
|
_releaseLinks(e) {
|
|
790
|
-
if (e !==
|
|
821
|
+
if (e !== U) {
|
|
791
822
|
for (let t = 0, s = e.length; t < s; t++)
|
|
792
823
|
e[t]?.unsub?.();
|
|
793
824
|
X.release(e);
|
|
794
825
|
}
|
|
795
826
|
}
|
|
796
827
|
_isDirty() {
|
|
797
|
-
const e = this._links, t =
|
|
798
|
-
|
|
828
|
+
const e = this._links, t = B.current;
|
|
829
|
+
B.current = null;
|
|
799
830
|
try {
|
|
800
831
|
for (let s = 0, i = e.length; s < i; s++) {
|
|
801
832
|
const o = e[s], r = o.node;
|
|
802
|
-
if (
|
|
803
|
-
if ("value" in r) {
|
|
833
|
+
if ("value" in r)
|
|
804
834
|
try {
|
|
805
835
|
r.value;
|
|
806
836
|
} catch {
|
|
807
|
-
return !0;
|
|
837
|
+
return A && console.warn(`[atom-effect] Dependency #${r.id} threw during dirty check`), !0;
|
|
808
838
|
}
|
|
809
|
-
|
|
810
|
-
}
|
|
839
|
+
if (r.version !== o.version) return !0;
|
|
811
840
|
}
|
|
812
841
|
return !1;
|
|
813
842
|
} finally {
|
|
814
|
-
|
|
843
|
+
B.current = t;
|
|
815
844
|
}
|
|
816
845
|
}
|
|
817
846
|
_execCleanup() {
|
|
@@ -819,22 +848,20 @@ class ht extends Ve {
|
|
|
819
848
|
try {
|
|
820
849
|
this._cleanup();
|
|
821
850
|
} catch (e) {
|
|
822
|
-
this._handleExecutionError(e,
|
|
851
|
+
this._handleExecutionError(e, D.EFFECT_CLEANUP_FAILED);
|
|
823
852
|
}
|
|
824
853
|
this._cleanup = null;
|
|
825
854
|
}
|
|
826
855
|
}
|
|
827
856
|
_checkInfiniteLoops() {
|
|
828
|
-
const e =
|
|
829
|
-
if (this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
857
|
+
const e = Se;
|
|
858
|
+
if (this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), ct() > q.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, this._history) {
|
|
830
859
|
const t = Date.now();
|
|
831
860
|
this._history[this._historyPtr] = t, this._historyPtr = (this._historyPtr + 1) % this._historyCapacity;
|
|
832
861
|
const s = this._history[this._historyPtr] || 0;
|
|
833
862
|
if (s > 0 && t - s < Je.ONE_SECOND_MS) {
|
|
834
|
-
const i = new
|
|
835
|
-
|
|
836
|
-
);
|
|
837
|
-
if (this.dispose(), this._handleExecutionError(i), T) throw i;
|
|
863
|
+
const i = new G(D.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
|
|
864
|
+
if (this.dispose(), this._handleExecutionError(i), A) throw i;
|
|
838
865
|
}
|
|
839
866
|
}
|
|
840
867
|
}
|
|
@@ -848,18 +875,18 @@ class ht extends Ve {
|
|
|
848
875
|
return (this.flags & P.EXECUTING) !== 0;
|
|
849
876
|
}
|
|
850
877
|
_throwInfiniteLoopError(e) {
|
|
851
|
-
const t = new
|
|
878
|
+
const t = new G(
|
|
852
879
|
`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Te}`
|
|
853
880
|
);
|
|
854
881
|
throw this.dispose(), console.error(t), t;
|
|
855
882
|
}
|
|
856
|
-
_handleExecutionError(e, t =
|
|
857
|
-
const s =
|
|
883
|
+
_handleExecutionError(e, t = D.EFFECT_EXECUTION_FAILED) {
|
|
884
|
+
const s = Z(e, G, t);
|
|
858
885
|
if (console.error(s), this._onError)
|
|
859
886
|
try {
|
|
860
887
|
this._onError(s);
|
|
861
888
|
} catch (i) {
|
|
862
|
-
console.error(
|
|
889
|
+
console.error(Z(i, G, D.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
863
890
|
}
|
|
864
891
|
}
|
|
865
892
|
_checkLoopWarnings() {
|
|
@@ -875,26 +902,26 @@ class ht extends Ve {
|
|
|
875
902
|
}
|
|
876
903
|
}
|
|
877
904
|
}
|
|
878
|
-
function
|
|
905
|
+
function V(n, e = {}) {
|
|
879
906
|
if (typeof n != "function")
|
|
880
|
-
throw new
|
|
881
|
-
const t = new
|
|
907
|
+
throw new G(D.EFFECT_MUST_BE_FUNCTION);
|
|
908
|
+
const t = new _t(n, e);
|
|
882
909
|
return t.execute(), t;
|
|
883
910
|
}
|
|
884
|
-
function
|
|
911
|
+
function Oe(n) {
|
|
885
912
|
if (typeof n != "function")
|
|
886
913
|
throw new TypeError("Batch callback must be a function");
|
|
887
|
-
|
|
914
|
+
$.startBatch();
|
|
888
915
|
try {
|
|
889
916
|
return n();
|
|
890
917
|
} finally {
|
|
891
|
-
|
|
918
|
+
$.endBatch();
|
|
892
919
|
}
|
|
893
920
|
}
|
|
894
|
-
function
|
|
921
|
+
function pt(n) {
|
|
895
922
|
return n !== null && typeof n == "object" && "value" in n && "subscribe" in n;
|
|
896
923
|
}
|
|
897
|
-
function
|
|
924
|
+
function me(n) {
|
|
898
925
|
if (!n) return "unknown";
|
|
899
926
|
const e = "jquery" in n ? n[0] : n;
|
|
900
927
|
if (!e) return "unknown";
|
|
@@ -904,14 +931,38 @@ function pe(n) {
|
|
|
904
931
|
if (i && i.length > 0) {
|
|
905
932
|
let o = s;
|
|
906
933
|
for (let r = 0, c = i.length; r < c; r++) {
|
|
907
|
-
const
|
|
908
|
-
|
|
934
|
+
const l = i[r];
|
|
935
|
+
l && (o += `.${l}`);
|
|
909
936
|
}
|
|
910
937
|
return o;
|
|
911
938
|
}
|
|
912
939
|
return s;
|
|
913
940
|
}
|
|
914
|
-
function
|
|
941
|
+
function Ge(n) {
|
|
942
|
+
let e = String(n ?? "");
|
|
943
|
+
if (e = e.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, ""), e = e.replace(/<\?[\s\S]*?\?>/g, "").replace(
|
|
944
|
+
/<(script|iframe|object|embed|base|meta|form|applet|link|style|template|noscript|title)\b[^>]*>([\s\S]*?)<\/\1>/gim,
|
|
945
|
+
""
|
|
946
|
+
).replace(
|
|
947
|
+
/<(script|iframe|object|embed|base|meta|form|applet|link|style|template|noscript|title)\b[^>]*\/?>/gim,
|
|
948
|
+
""
|
|
949
|
+
), ((o) => o.replace(/&#x([0-9a-f]+);?/gi, (r, c) => String.fromCharCode(parseInt(c, 16))).replace(/&#([0-9]+);?/gi, (r, c) => String.fromCharCode(parseInt(c, 10))))(e).match(/(?:java|vb)script:|data:/i)) {
|
|
950
|
+
const o = (r) => new RegExp(
|
|
951
|
+
`${r.split("").map((c) => {
|
|
952
|
+
const l = c.charCodeAt(0);
|
|
953
|
+
return `(?:${c}|�*${l};?|�*${l.toString(16)};?)`;
|
|
954
|
+
}).join("\\s*")}\\s*(?::|:|&#x?0*((58)|(3a));?|%3a)`,
|
|
955
|
+
"gi"
|
|
956
|
+
);
|
|
957
|
+
e = e.replace(o("javascript"), "data-unsafe-protocol:").replace(o("vbscript"), "data-unsafe-protocol:");
|
|
958
|
+
} else {
|
|
959
|
+
const o = /((?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t)\s*(?::|:|&#x?0*((58)|(3a));?|%3a))/gim;
|
|
960
|
+
e = e.replace(o, "data-unsafe-protocol:");
|
|
961
|
+
}
|
|
962
|
+
const i = /data\s*:\s*(?:text\/html|application\/javascript|text\/javascript|text\/vbscript)/gim;
|
|
963
|
+
return e = e.replace(i, "data-unsafe-protocol:"), e = e.replace(/\bon\w+\s*=/gim, "data-unsafe-attr="), e = e.replace(/expression\s*\(/gim, "data-unsafe-css(").replace(/behavior\s*:/gim, "data-unsafe-css:"), e;
|
|
964
|
+
}
|
|
965
|
+
function Et(n) {
|
|
915
966
|
const e = n.length;
|
|
916
967
|
if (e === 0) return new Int32Array(0);
|
|
917
968
|
const t = new Int32Array(e), s = new Int32Array(e);
|
|
@@ -919,18 +970,18 @@ function dt(n) {
|
|
|
919
970
|
for (let r = 0; r < e; r++) {
|
|
920
971
|
const c = n[r];
|
|
921
972
|
if (c === void 0 || c === -1) continue;
|
|
922
|
-
const
|
|
923
|
-
if (i === 0 ||
|
|
924
|
-
t[r] =
|
|
973
|
+
const l = i > 0 ? s[i - 1] : void 0;
|
|
974
|
+
if (i === 0 || l !== void 0 && (n[l] ?? -1) < c) {
|
|
975
|
+
t[r] = l ?? -1, s[i++] = r;
|
|
925
976
|
continue;
|
|
926
977
|
}
|
|
927
|
-
let
|
|
928
|
-
for (;
|
|
929
|
-
const
|
|
930
|
-
|
|
978
|
+
let _ = 0, g = i - 1;
|
|
979
|
+
for (; _ < g; ) {
|
|
980
|
+
const C = _ + g >>> 1, k = s[C];
|
|
981
|
+
k !== void 0 && (n[k] ?? -1) < c ? _ = C + 1 : g = C;
|
|
931
982
|
}
|
|
932
|
-
const
|
|
933
|
-
|
|
983
|
+
const v = s[_];
|
|
984
|
+
v !== void 0 && c < (n[v] ?? Number.MAX_SAFE_INTEGER) && (_ > 0 && (t[r] = s[_ - 1] ?? -1), s[_] = r);
|
|
934
985
|
}
|
|
935
986
|
const o = new Int32Array(i);
|
|
936
987
|
if (i > 0) {
|
|
@@ -940,7 +991,7 @@ function dt(n) {
|
|
|
940
991
|
}
|
|
941
992
|
return o;
|
|
942
993
|
}
|
|
943
|
-
function
|
|
994
|
+
function gt() {
|
|
944
995
|
if (typeof window < "u") {
|
|
945
996
|
const n = window.__ATOM_DEBUG__;
|
|
946
997
|
if (typeof n == "boolean") return n;
|
|
@@ -951,19 +1002,19 @@ function _t() {
|
|
|
951
1002
|
}
|
|
952
1003
|
return !1;
|
|
953
1004
|
}
|
|
954
|
-
let
|
|
955
|
-
const
|
|
1005
|
+
let Q = gt();
|
|
1006
|
+
const b = {
|
|
956
1007
|
get enabled() {
|
|
957
|
-
return
|
|
1008
|
+
return Q;
|
|
958
1009
|
},
|
|
959
1010
|
set enabled(n) {
|
|
960
|
-
|
|
1011
|
+
Q = n;
|
|
961
1012
|
},
|
|
962
1013
|
log(n, ...e) {
|
|
963
|
-
|
|
1014
|
+
Q && console.log(`[atom-effect-jquery] ${n}:`, ...e);
|
|
964
1015
|
},
|
|
965
1016
|
atomChanged(n, e, t) {
|
|
966
|
-
|
|
1017
|
+
Q && console.log(
|
|
967
1018
|
`[atom-effect-jquery] Atom "${n ?? "anonymous"}" changed:`,
|
|
968
1019
|
e,
|
|
969
1020
|
"→",
|
|
@@ -974,20 +1025,20 @@ const m = {
|
|
|
974
1025
|
* Logs DOM updates and triggers visual highlight.
|
|
975
1026
|
*/
|
|
976
1027
|
domUpdated(n, e, t) {
|
|
977
|
-
|
|
1028
|
+
Q && (console.log(`[atom-effect-jquery] DOM updated: ${me(n)}.${e} =`, t), mt(n));
|
|
978
1029
|
},
|
|
979
1030
|
cleanup(n) {
|
|
980
|
-
|
|
1031
|
+
Q && console.log(`[atom-effect-jquery] Cleanup: ${n}`);
|
|
981
1032
|
},
|
|
982
1033
|
warn(...n) {
|
|
983
|
-
|
|
1034
|
+
Q && console.warn("[atom-effect-jquery]", ...n);
|
|
984
1035
|
}
|
|
985
|
-
},
|
|
986
|
-
function
|
|
1036
|
+
}, be = /* @__PURE__ */ new WeakMap();
|
|
1037
|
+
function mt(n) {
|
|
987
1038
|
const e = "jquery" in n ? n[0] : n;
|
|
988
1039
|
if (!e || !e.isConnected) return;
|
|
989
|
-
let t =
|
|
990
|
-
if (t || (t = {},
|
|
1040
|
+
let t = be.get(e);
|
|
1041
|
+
if (t || (t = {}, be.set(e, t)), t.timer && clearTimeout(t.timer), t.cleanupTimer && clearTimeout(t.cleanupTimer), !t.orgStyle) {
|
|
991
1042
|
const i = e.style;
|
|
992
1043
|
t.orgStyle = {
|
|
993
1044
|
outline: i.outline,
|
|
@@ -1001,40 +1052,40 @@ function Et(n) {
|
|
|
1001
1052
|
if (!e.isConnected) return;
|
|
1002
1053
|
const i = t?.orgStyle;
|
|
1003
1054
|
i && (s.outline = i.outline, s.outlineOffset = i.outlineOffset), t.cleanupTimer = setTimeout(() => {
|
|
1004
|
-
e.isConnected && t?.orgStyle && (s.transition = t.orgStyle.transition),
|
|
1055
|
+
e.isConnected && t?.orgStyle && (s.transition = t.orgStyle.transition), be.delete(e);
|
|
1005
1056
|
}, 500);
|
|
1006
1057
|
}));
|
|
1007
1058
|
}, 100);
|
|
1008
1059
|
}
|
|
1009
|
-
const
|
|
1060
|
+
const yt = /* @__PURE__ */ new WeakMap();
|
|
1010
1061
|
function Ye(n, e = {}) {
|
|
1011
|
-
const t =
|
|
1012
|
-
return e.name &&
|
|
1062
|
+
const t = ze(n, e);
|
|
1063
|
+
return e.name && yt.set(t, { name: e.name }), t;
|
|
1013
1064
|
}
|
|
1014
1065
|
Object.defineProperty(Ye, "debug", {
|
|
1015
1066
|
get() {
|
|
1016
|
-
return
|
|
1067
|
+
return b.enabled;
|
|
1017
1068
|
},
|
|
1018
1069
|
set(n) {
|
|
1019
|
-
|
|
1070
|
+
b.enabled = n;
|
|
1020
1071
|
}
|
|
1021
1072
|
});
|
|
1022
|
-
function
|
|
1073
|
+
function bt() {
|
|
1023
1074
|
return new Promise((n) => setTimeout(n, 0));
|
|
1024
1075
|
}
|
|
1025
|
-
|
|
1076
|
+
u.extend({
|
|
1026
1077
|
atom: Ye,
|
|
1027
|
-
computed:
|
|
1028
|
-
effect:
|
|
1029
|
-
batch:
|
|
1030
|
-
untracked:
|
|
1031
|
-
isAtom:
|
|
1078
|
+
computed: dt,
|
|
1079
|
+
effect: V,
|
|
1080
|
+
batch: Oe,
|
|
1081
|
+
untracked: at,
|
|
1082
|
+
isAtom: De,
|
|
1032
1083
|
isComputed: Le,
|
|
1033
|
-
isReactive: (n) =>
|
|
1034
|
-
nextTick:
|
|
1084
|
+
isReactive: (n) => De(n) || Le(n),
|
|
1085
|
+
nextTick: bt
|
|
1035
1086
|
});
|
|
1036
|
-
const
|
|
1037
|
-
class
|
|
1087
|
+
const ue = "_aes-bound";
|
|
1088
|
+
class Ct {
|
|
1038
1089
|
records = /* @__PURE__ */ new WeakMap();
|
|
1039
1090
|
boundElements = /* @__PURE__ */ new WeakSet();
|
|
1040
1091
|
preservedNodes = /* @__PURE__ */ new WeakSet();
|
|
@@ -1054,7 +1105,7 @@ class mt {
|
|
|
1054
1105
|
}
|
|
1055
1106
|
_getOrCreateRecord(e) {
|
|
1056
1107
|
let t = this.records.get(e);
|
|
1057
|
-
return t || (t = {}, this.records.set(e, t), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(
|
|
1108
|
+
return t || (t = {}, this.records.set(e, t), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(ue))), t;
|
|
1058
1109
|
}
|
|
1059
1110
|
trackEffect(e, t) {
|
|
1060
1111
|
const s = this._getOrCreateRecord(e);
|
|
@@ -1071,14 +1122,14 @@ class mt {
|
|
|
1071
1122
|
if (!this.boundElements.delete(e)) return;
|
|
1072
1123
|
const t = this.records.get(e);
|
|
1073
1124
|
if (!t) return;
|
|
1074
|
-
this.records.delete(e), this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.classList.remove(
|
|
1125
|
+
this.records.delete(e), this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.classList.remove(ue), b.enabled && b.cleanup(me(e));
|
|
1075
1126
|
const s = t.effects;
|
|
1076
1127
|
if (s)
|
|
1077
1128
|
for (let o = 0, r = s.length; o < r; o++)
|
|
1078
1129
|
try {
|
|
1079
1130
|
s[o]?.dispose();
|
|
1080
1131
|
} catch (c) {
|
|
1081
|
-
|
|
1132
|
+
b.warn("Effect dispose error:", c);
|
|
1082
1133
|
}
|
|
1083
1134
|
const i = t.cleanups;
|
|
1084
1135
|
if (i)
|
|
@@ -1086,24 +1137,24 @@ class mt {
|
|
|
1086
1137
|
try {
|
|
1087
1138
|
i[o]?.();
|
|
1088
1139
|
} catch (c) {
|
|
1089
|
-
|
|
1140
|
+
b.warn("Cleanup error:", c);
|
|
1090
1141
|
}
|
|
1091
1142
|
}
|
|
1092
1143
|
cleanupDescendants(e) {
|
|
1093
|
-
const t = e.querySelectorAll(`.${
|
|
1144
|
+
const t = e.querySelectorAll(`.${ue}`);
|
|
1094
1145
|
for (let s = 0, i = t.length; s < i; s++) {
|
|
1095
1146
|
const o = t[s];
|
|
1096
|
-
o && this.boundElements.has(o) ? this.cleanup(o) : o && o.classList.remove(
|
|
1147
|
+
o && this.boundElements.has(o) ? this.cleanup(o) : o && o.classList.remove(ue);
|
|
1097
1148
|
}
|
|
1098
1149
|
}
|
|
1099
1150
|
cleanupTree(e) {
|
|
1100
1151
|
this.cleanupDescendants(e), this.cleanup(e);
|
|
1101
1152
|
}
|
|
1102
1153
|
}
|
|
1103
|
-
const y = new
|
|
1104
|
-
let
|
|
1105
|
-
function
|
|
1106
|
-
|
|
1154
|
+
const y = new Ct();
|
|
1155
|
+
let se = null;
|
|
1156
|
+
function It(n = document.body) {
|
|
1157
|
+
se || (se = new MutationObserver((e) => {
|
|
1107
1158
|
for (let t = 0, s = e.length; t < s; t++) {
|
|
1108
1159
|
const i = e[t]?.removedNodes;
|
|
1109
1160
|
if (!i) continue;
|
|
@@ -1114,19 +1165,19 @@ function yt(n = document.body) {
|
|
|
1114
1165
|
c.nodeType === 1 && (c.isConnected || y.isKept(c) || y.isIgnored(c) || y.cleanupTree(c));
|
|
1115
1166
|
}
|
|
1116
1167
|
}
|
|
1117
|
-
}),
|
|
1168
|
+
}), se.observe(n, { childList: !0, subtree: !0 }));
|
|
1118
1169
|
}
|
|
1119
|
-
function
|
|
1120
|
-
|
|
1170
|
+
function $t() {
|
|
1171
|
+
se?.disconnect(), se = null;
|
|
1121
1172
|
}
|
|
1122
|
-
function
|
|
1123
|
-
|
|
1173
|
+
function O(n, e, t, s) {
|
|
1174
|
+
pt(e) ? y.trackEffect(
|
|
1124
1175
|
n,
|
|
1125
|
-
|
|
1176
|
+
V(() => {
|
|
1126
1177
|
const i = e.value;
|
|
1127
|
-
t(i),
|
|
1178
|
+
t(i), b.domUpdated(u(n), s, i);
|
|
1128
1179
|
})
|
|
1129
|
-
) : (t(e),
|
|
1180
|
+
) : (t(e), b.domUpdated(u(n), s, e));
|
|
1130
1181
|
}
|
|
1131
1182
|
var S = /* @__PURE__ */ ((n) => (n[n.None = 0] = "None", n[n.Focused = 1] = "Focused", n[n.Composing = 2] = "Composing", n[n.SyncingToAtom = 4] = "SyncingToAtom", n[n.SyncingToDom = 8] = "SyncingToDom", n[n.Busy = 14] = "Busy", n))(S || {});
|
|
1132
1183
|
function ke() {
|
|
@@ -1140,76 +1191,84 @@ function We(n, e, t = {}) {
|
|
|
1140
1191
|
const {
|
|
1141
1192
|
debounce: s,
|
|
1142
1193
|
event: i = "input",
|
|
1143
|
-
parse: o = (
|
|
1144
|
-
format: r = (
|
|
1194
|
+
parse: o = (w) => w,
|
|
1195
|
+
format: r = (w) => String(w ?? ""),
|
|
1145
1196
|
equal: c = Object.is
|
|
1146
|
-
} = t,
|
|
1147
|
-
if (!(
|
|
1148
|
-
|
|
1197
|
+
} = t, l = ke(), _ = n[0], g = () => {
|
|
1198
|
+
if (!(l.flags & S.Busy)) {
|
|
1199
|
+
l.flags |= S.SyncingToAtom;
|
|
1149
1200
|
try {
|
|
1150
|
-
const
|
|
1151
|
-
c(e.value,
|
|
1201
|
+
const w = _.value, N = o(w);
|
|
1202
|
+
c(e.value, N) || (e.value = N);
|
|
1152
1203
|
} finally {
|
|
1153
|
-
|
|
1204
|
+
l.flags &= ~S.SyncingToAtom;
|
|
1154
1205
|
}
|
|
1155
1206
|
}
|
|
1156
|
-
},
|
|
1157
|
-
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1160
|
-
},
|
|
1161
|
-
|
|
1162
|
-
},
|
|
1207
|
+
}, v = () => {
|
|
1208
|
+
l.timeoutId && (clearTimeout(l.timeoutId), l.timeoutId = null, g()), l.flags &= ~S.Focused;
|
|
1209
|
+
const w = r(e.value);
|
|
1210
|
+
_.value !== w && (_.value = w);
|
|
1211
|
+
}, C = () => {
|
|
1212
|
+
l.flags & S.Busy || (s ? (l.timeoutId && clearTimeout(l.timeoutId), l.timeoutId = setTimeout(g, s)) : g());
|
|
1213
|
+
}, k = {
|
|
1163
1214
|
compositionstart: () => {
|
|
1164
|
-
|
|
1215
|
+
l.flags |= S.Composing;
|
|
1165
1216
|
},
|
|
1166
1217
|
compositionend: () => {
|
|
1167
|
-
|
|
1218
|
+
l.flags &= ~S.Composing, g();
|
|
1168
1219
|
},
|
|
1169
1220
|
focus: () => {
|
|
1170
|
-
|
|
1221
|
+
l.flags |= S.Focused;
|
|
1171
1222
|
},
|
|
1172
|
-
blur:
|
|
1173
|
-
[i]:
|
|
1174
|
-
change:
|
|
1223
|
+
blur: v,
|
|
1224
|
+
[i]: C,
|
|
1225
|
+
change: C
|
|
1175
1226
|
};
|
|
1176
|
-
return n.on(
|
|
1177
|
-
const
|
|
1178
|
-
if (
|
|
1179
|
-
|
|
1227
|
+
return n.on(k), { effect: () => {
|
|
1228
|
+
const w = e.value, N = r(w), x = _.value;
|
|
1229
|
+
if (x !== N && !(l.flags & S.Focused && c(o(x), w))) {
|
|
1230
|
+
l.flags |= S.SyncingToDom;
|
|
1180
1231
|
try {
|
|
1181
|
-
if (
|
|
1182
|
-
const { selectionStart:
|
|
1183
|
-
|
|
1184
|
-
const
|
|
1185
|
-
|
|
1232
|
+
if (l.flags & S.Focused) {
|
|
1233
|
+
const { selectionStart: L, selectionEnd: W } = _;
|
|
1234
|
+
_.value = N;
|
|
1235
|
+
const F = N.length;
|
|
1236
|
+
_.setSelectionRange(Math.min(L ?? F, F), Math.min(W ?? F, F));
|
|
1186
1237
|
} else
|
|
1187
|
-
|
|
1188
|
-
|
|
1238
|
+
_.value = N;
|
|
1239
|
+
b.domUpdated(n, "val", N);
|
|
1189
1240
|
} finally {
|
|
1190
|
-
|
|
1241
|
+
l.flags &= ~S.SyncingToDom;
|
|
1191
1242
|
}
|
|
1192
1243
|
}
|
|
1193
1244
|
}, cleanup: () => {
|
|
1194
|
-
n.off(
|
|
1245
|
+
n.off(k), l.timeoutId && clearTimeout(l.timeoutId);
|
|
1195
1246
|
} };
|
|
1196
1247
|
}
|
|
1197
|
-
|
|
1248
|
+
u.fn.atomText = function(n, e) {
|
|
1198
1249
|
return this.each(function() {
|
|
1199
|
-
const t =
|
|
1200
|
-
|
|
1250
|
+
const t = u(this);
|
|
1251
|
+
O(this, n, e ? (i) => t.text(e(i)) : (i) => t.text(String(i ?? "")), "text");
|
|
1201
1252
|
});
|
|
1202
1253
|
};
|
|
1203
|
-
|
|
1254
|
+
u.fn.atomHtml = function(n) {
|
|
1204
1255
|
return this.each(function() {
|
|
1205
|
-
const e =
|
|
1206
|
-
|
|
1256
|
+
const e = u(this);
|
|
1257
|
+
O(
|
|
1258
|
+
this,
|
|
1259
|
+
n,
|
|
1260
|
+
(t) => {
|
|
1261
|
+
const s = String(t ?? ""), i = Ge(s);
|
|
1262
|
+
i !== s && console.warn("[atomHtml] Unsafe content neutralized during sanitization."), e.html(i);
|
|
1263
|
+
},
|
|
1264
|
+
"html"
|
|
1265
|
+
);
|
|
1207
1266
|
});
|
|
1208
1267
|
};
|
|
1209
|
-
|
|
1268
|
+
u.fn.atomClass = function(n, e) {
|
|
1210
1269
|
return this.each(function() {
|
|
1211
|
-
const t =
|
|
1212
|
-
|
|
1270
|
+
const t = u(this);
|
|
1271
|
+
O(
|
|
1213
1272
|
this,
|
|
1214
1273
|
e,
|
|
1215
1274
|
(s) => t.toggleClass(n, !!s),
|
|
@@ -1217,16 +1276,16 @@ l.fn.atomClass = function(n, e) {
|
|
|
1217
1276
|
);
|
|
1218
1277
|
});
|
|
1219
1278
|
};
|
|
1220
|
-
|
|
1279
|
+
u.fn.atomCss = function(n, e, t) {
|
|
1221
1280
|
return this.each(function() {
|
|
1222
|
-
const s =
|
|
1223
|
-
|
|
1281
|
+
const s = u(this);
|
|
1282
|
+
O(this, e, t ? (o) => s.css(n, `${o}${t}`) : (o) => s.css(n, o), `css.${n}`);
|
|
1224
1283
|
});
|
|
1225
1284
|
};
|
|
1226
|
-
|
|
1285
|
+
u.fn.atomAttr = function(n, e) {
|
|
1227
1286
|
return this.each(function() {
|
|
1228
|
-
const t =
|
|
1229
|
-
|
|
1287
|
+
const t = u(this);
|
|
1288
|
+
O(
|
|
1230
1289
|
this,
|
|
1231
1290
|
e,
|
|
1232
1291
|
(s) => {
|
|
@@ -1240,65 +1299,70 @@ l.fn.atomAttr = function(n, e) {
|
|
|
1240
1299
|
);
|
|
1241
1300
|
});
|
|
1242
1301
|
};
|
|
1243
|
-
|
|
1302
|
+
u.fn.atomProp = function(n, e) {
|
|
1244
1303
|
return this.each(function() {
|
|
1245
|
-
const t =
|
|
1246
|
-
|
|
1304
|
+
const t = u(this);
|
|
1305
|
+
O(this, e, (s) => t.prop(n, s), `prop.${n}`);
|
|
1247
1306
|
});
|
|
1248
1307
|
};
|
|
1249
|
-
|
|
1308
|
+
u.fn.atomShow = function(n) {
|
|
1250
1309
|
return this.each(function() {
|
|
1251
|
-
const e =
|
|
1252
|
-
|
|
1310
|
+
const e = u(this);
|
|
1311
|
+
O(this, n, (t) => e.toggle(!!t), "show");
|
|
1253
1312
|
});
|
|
1254
1313
|
};
|
|
1255
|
-
|
|
1314
|
+
u.fn.atomHide = function(n) {
|
|
1256
1315
|
return this.each(function() {
|
|
1257
|
-
const e =
|
|
1258
|
-
|
|
1316
|
+
const e = u(this);
|
|
1317
|
+
O(this, n, (t) => e.toggle(!t), "hide");
|
|
1259
1318
|
});
|
|
1260
1319
|
};
|
|
1261
|
-
|
|
1320
|
+
u.fn.atomVal = function(n, e = {}) {
|
|
1262
1321
|
return this.each(function() {
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1322
|
+
const t = this.tagName.toLowerCase();
|
|
1323
|
+
if (!["input", "select", "textarea"].includes(t)) {
|
|
1324
|
+
console.warn(`[atomVal] Element <${t}> is not a valid input element.`);
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
const { effect: s, cleanup: i } = We(u(this), n, e);
|
|
1328
|
+
y.trackEffect(this, V(s)), y.trackCleanup(this, i);
|
|
1265
1329
|
});
|
|
1266
1330
|
};
|
|
1267
|
-
|
|
1331
|
+
u.fn.atomChecked = function(n) {
|
|
1268
1332
|
return this.each(function() {
|
|
1269
|
-
const e =
|
|
1333
|
+
const e = u(this), t = this, s = ke(), i = () => {
|
|
1270
1334
|
if (s.flags & S.Busy) return;
|
|
1271
1335
|
const r = t.checked;
|
|
1272
1336
|
n.value !== r && (n.value = r);
|
|
1273
1337
|
};
|
|
1274
1338
|
e.on("change", i), y.trackCleanup(this, () => e.off("change", i));
|
|
1275
|
-
const o =
|
|
1339
|
+
const o = V(() => {
|
|
1276
1340
|
s.flags |= S.SyncingToDom;
|
|
1277
1341
|
const r = !!n.value;
|
|
1278
|
-
t.checked !== r && (t.checked = r,
|
|
1342
|
+
t.checked !== r && (t.checked = r, b.domUpdated(e, "checked", r)), s.flags &= ~S.SyncingToDom;
|
|
1279
1343
|
});
|
|
1280
1344
|
y.trackEffect(this, o);
|
|
1281
1345
|
});
|
|
1282
1346
|
};
|
|
1283
|
-
|
|
1347
|
+
u.fn.atomOn = function(n, e) {
|
|
1284
1348
|
return this.each(function() {
|
|
1285
|
-
const t =
|
|
1349
|
+
const t = u(this);
|
|
1286
1350
|
t.on(n, e), y.trackCleanup(this, () => t.off(n, e));
|
|
1287
1351
|
});
|
|
1288
1352
|
};
|
|
1289
|
-
|
|
1353
|
+
u.fn.atomUnbind = function() {
|
|
1290
1354
|
return this.each(function() {
|
|
1291
1355
|
y.cleanupTree(this);
|
|
1292
1356
|
});
|
|
1293
1357
|
};
|
|
1294
1358
|
const Fe = /* @__PURE__ */ Object.create(null);
|
|
1295
|
-
function
|
|
1359
|
+
function St(n) {
|
|
1296
1360
|
let e = Fe[n];
|
|
1297
1361
|
return e || (e = n.includes("-") ? n.replace(/-./g, (t) => t[1].toUpperCase()) : n, Fe[n] = e, e);
|
|
1298
1362
|
}
|
|
1299
|
-
function
|
|
1363
|
+
function Dt(n, e) {
|
|
1300
1364
|
const t = n.el;
|
|
1301
|
-
|
|
1365
|
+
O(
|
|
1302
1366
|
t,
|
|
1303
1367
|
e,
|
|
1304
1368
|
(s) => {
|
|
@@ -1308,21 +1372,23 @@ function It(n, e) {
|
|
|
1308
1372
|
"text"
|
|
1309
1373
|
);
|
|
1310
1374
|
}
|
|
1311
|
-
function
|
|
1375
|
+
function vt(n, e) {
|
|
1312
1376
|
const t = n.el;
|
|
1313
|
-
|
|
1377
|
+
O(
|
|
1314
1378
|
t,
|
|
1315
1379
|
e,
|
|
1316
1380
|
(s) => {
|
|
1317
|
-
const i = String(s ?? "");
|
|
1318
|
-
|
|
1381
|
+
const i = String(s ?? ""), o = Ge(i);
|
|
1382
|
+
o !== i && console.warn("[atomBind] Unsafe content neutralized during sanitization.");
|
|
1383
|
+
const r = o;
|
|
1384
|
+
t.innerHTML !== r && (t.innerHTML = r);
|
|
1319
1385
|
},
|
|
1320
1386
|
"html"
|
|
1321
1387
|
);
|
|
1322
1388
|
}
|
|
1323
|
-
function
|
|
1389
|
+
function Tt(n, e) {
|
|
1324
1390
|
for (const t in e)
|
|
1325
|
-
|
|
1391
|
+
O(
|
|
1326
1392
|
n.el,
|
|
1327
1393
|
e[t],
|
|
1328
1394
|
(s) => {
|
|
@@ -1331,20 +1397,20 @@ function St(n, e) {
|
|
|
1331
1397
|
`class.${t}`
|
|
1332
1398
|
);
|
|
1333
1399
|
}
|
|
1334
|
-
function
|
|
1400
|
+
function Ot(n, e) {
|
|
1335
1401
|
const t = n.el, s = t.style;
|
|
1336
1402
|
for (const i in e) {
|
|
1337
1403
|
const o = e[i];
|
|
1338
1404
|
if (o === void 0) continue;
|
|
1339
|
-
const r =
|
|
1340
|
-
Array.isArray(o) ?
|
|
1405
|
+
const r = St(i);
|
|
1406
|
+
Array.isArray(o) ? O(
|
|
1341
1407
|
t,
|
|
1342
1408
|
o[0],
|
|
1343
1409
|
(c) => {
|
|
1344
1410
|
s[r] = `${c}${o[1]}`;
|
|
1345
1411
|
},
|
|
1346
1412
|
`css.${i}`
|
|
1347
|
-
) :
|
|
1413
|
+
) : O(
|
|
1348
1414
|
t,
|
|
1349
1415
|
o,
|
|
1350
1416
|
(c) => {
|
|
@@ -1354,10 +1420,10 @@ function Dt(n, e) {
|
|
|
1354
1420
|
);
|
|
1355
1421
|
}
|
|
1356
1422
|
}
|
|
1357
|
-
function
|
|
1423
|
+
function kt(n, e) {
|
|
1358
1424
|
const t = n.el;
|
|
1359
1425
|
for (const s in e)
|
|
1360
|
-
|
|
1426
|
+
O(
|
|
1361
1427
|
t,
|
|
1362
1428
|
e[s],
|
|
1363
1429
|
(i) => {
|
|
@@ -1371,10 +1437,10 @@ function Tt(n, e) {
|
|
|
1371
1437
|
`attr.${s}`
|
|
1372
1438
|
);
|
|
1373
1439
|
}
|
|
1374
|
-
function
|
|
1440
|
+
function wt(n, e) {
|
|
1375
1441
|
const t = n.el;
|
|
1376
1442
|
for (const s in e)
|
|
1377
|
-
|
|
1443
|
+
O(
|
|
1378
1444
|
n.el,
|
|
1379
1445
|
e[s],
|
|
1380
1446
|
(i) => {
|
|
@@ -1383,35 +1449,40 @@ function vt(n, e) {
|
|
|
1383
1449
|
`prop.${s}`
|
|
1384
1450
|
);
|
|
1385
1451
|
}
|
|
1386
|
-
function
|
|
1452
|
+
function Nt(n, e) {
|
|
1387
1453
|
const t = n.el;
|
|
1388
|
-
|
|
1454
|
+
O(
|
|
1389
1455
|
t,
|
|
1390
1456
|
e,
|
|
1391
1457
|
(s) => {
|
|
1392
|
-
t.style.display = s ? "" : "none",
|
|
1458
|
+
t.style.display = s ? "" : "none", b.enabled && b.domUpdated(t, "show", s);
|
|
1393
1459
|
},
|
|
1394
1460
|
"show"
|
|
1395
1461
|
);
|
|
1396
1462
|
}
|
|
1397
|
-
function
|
|
1463
|
+
function Rt(n, e) {
|
|
1398
1464
|
const t = n.el;
|
|
1399
|
-
|
|
1465
|
+
O(
|
|
1400
1466
|
t,
|
|
1401
1467
|
e,
|
|
1402
1468
|
(s) => {
|
|
1403
|
-
t.style.display = s ? "none" : "",
|
|
1469
|
+
t.style.display = s ? "none" : "", b.enabled && b.domUpdated(t, "hide", s);
|
|
1404
1470
|
},
|
|
1405
1471
|
"hide"
|
|
1406
1472
|
);
|
|
1407
1473
|
}
|
|
1408
|
-
function
|
|
1409
|
-
const t =
|
|
1474
|
+
function xt(n, e) {
|
|
1475
|
+
const t = n.el.tagName.toLowerCase();
|
|
1476
|
+
if (!["input", "select", "textarea"].includes(t)) {
|
|
1477
|
+
console.warn(`[atomBind] Val binding used on non-input element <${t}>.`);
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
const s = Array.isArray(e), { effect: i, cleanup: o } = We(
|
|
1410
1481
|
n.$el,
|
|
1411
|
-
|
|
1412
|
-
|
|
1482
|
+
s ? e[0] : e,
|
|
1483
|
+
s ? e[1] : {}
|
|
1413
1484
|
);
|
|
1414
|
-
y.trackEffect(n.el,
|
|
1485
|
+
y.trackEffect(n.el, V(i)), n.trackCleanup(o);
|
|
1415
1486
|
}
|
|
1416
1487
|
function At(n, e) {
|
|
1417
1488
|
const t = n.el, s = ke(), i = () => {
|
|
@@ -1420,151 +1491,151 @@ function At(n, e) {
|
|
|
1420
1491
|
e.value !== r && (e.value = r);
|
|
1421
1492
|
};
|
|
1422
1493
|
t.addEventListener("change", i), n.trackCleanup(() => t.removeEventListener("change", i));
|
|
1423
|
-
const o =
|
|
1494
|
+
const o = V(() => {
|
|
1424
1495
|
s.flags |= S.SyncingToDom;
|
|
1425
1496
|
const r = !!e.value;
|
|
1426
|
-
t.checked !== r && (t.checked = r,
|
|
1497
|
+
t.checked !== r && (t.checked = r, b.enabled && b.domUpdated(t, "checked", r)), s.flags &= ~S.SyncingToDom;
|
|
1427
1498
|
});
|
|
1428
1499
|
y.trackEffect(t, o);
|
|
1429
1500
|
}
|
|
1430
|
-
function
|
|
1501
|
+
function Lt(n, e) {
|
|
1431
1502
|
for (const t in e) {
|
|
1432
1503
|
const s = e[t];
|
|
1433
1504
|
if (typeof s != "function") continue;
|
|
1434
1505
|
const i = (o) => {
|
|
1435
|
-
|
|
1506
|
+
Oe(
|
|
1436
1507
|
() => s.call(
|
|
1437
1508
|
n.el,
|
|
1438
|
-
|
|
1509
|
+
u.Event(o.type, { originalEvent: o })
|
|
1439
1510
|
)
|
|
1440
1511
|
);
|
|
1441
1512
|
};
|
|
1442
1513
|
n.el.addEventListener(t, i), n.trackCleanup(() => n.el.removeEventListener(t, i));
|
|
1443
1514
|
}
|
|
1444
1515
|
}
|
|
1445
|
-
|
|
1516
|
+
u.fn.atomBind = function(n) {
|
|
1446
1517
|
return this.each(function() {
|
|
1447
1518
|
const e = this;
|
|
1448
1519
|
let t = null;
|
|
1449
1520
|
const s = {
|
|
1450
1521
|
get $el() {
|
|
1451
|
-
return t || (t =
|
|
1522
|
+
return t || (t = u(e)), t;
|
|
1452
1523
|
},
|
|
1453
1524
|
el: e,
|
|
1454
1525
|
trackCleanup: (i) => y.trackCleanup(e, i)
|
|
1455
1526
|
};
|
|
1456
|
-
n.text !== void 0 &&
|
|
1527
|
+
n.text !== void 0 && Dt(s, n.text), n.html !== void 0 && vt(s, n.html), n.class && Tt(s, n.class), n.css && Ot(s, n.css), n.attr && kt(s, n.attr), n.prop && wt(s, n.prop), n.show !== void 0 && Nt(s, n.show), n.hide !== void 0 && Rt(s, n.hide), n.val !== void 0 && xt(s, n.val), n.checked !== void 0 && At(s, n.checked), n.on && Lt(s, n.on);
|
|
1457
1528
|
});
|
|
1458
1529
|
};
|
|
1459
|
-
|
|
1460
|
-
const { key: t, render: s, bind: i, update: o, onAdd: r, onRemove: c, empty:
|
|
1530
|
+
u.fn.atomList = function(n, e) {
|
|
1531
|
+
const { key: t, render: s, bind: i, update: o, onAdd: r, onRemove: c, empty: l } = e, _ = typeof t == "function" ? t : (g, v) => g[t];
|
|
1461
1532
|
return this.each(function() {
|
|
1462
|
-
const
|
|
1463
|
-
let
|
|
1464
|
-
const
|
|
1465
|
-
const
|
|
1466
|
-
if (
|
|
1467
|
-
|
|
1533
|
+
const g = u(this), v = me(this), C = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
|
|
1534
|
+
let R = [], M = null;
|
|
1535
|
+
const w = V(() => {
|
|
1536
|
+
const N = n.value, x = N.length;
|
|
1537
|
+
if (x === 0 ? l && !M && (M = u(l).appendTo(g)) : M && (M.remove(), M = null), x === 0 && C.size === 0) {
|
|
1538
|
+
R = [];
|
|
1468
1539
|
return;
|
|
1469
1540
|
}
|
|
1470
|
-
|
|
1471
|
-
const
|
|
1472
|
-
for (let
|
|
1473
|
-
|
|
1474
|
-
const
|
|
1475
|
-
for (let
|
|
1476
|
-
const E =
|
|
1477
|
-
|
|
1541
|
+
b.log("list", `${v} updating with ${x} items`);
|
|
1542
|
+
const L = /* @__PURE__ */ new Map(), W = R.length;
|
|
1543
|
+
for (let a = 0; a < W; a++)
|
|
1544
|
+
L.set(R[a], a);
|
|
1545
|
+
const F = new Array(x), K = /* @__PURE__ */ new Set(), re = new Int32Array(x);
|
|
1546
|
+
for (let a = 0; a < x; a++) {
|
|
1547
|
+
const E = N[a], f = _(E, a);
|
|
1548
|
+
K.has(f) && console.warn(`[atomList] Duplicate key "${f}" at index ${a}.`), F[a] = f, K.add(f), re[a] = L.get(f) ?? -1;
|
|
1478
1549
|
}
|
|
1479
|
-
if (
|
|
1480
|
-
for (const [
|
|
1481
|
-
if (
|
|
1482
|
-
const
|
|
1483
|
-
E.$el.remove(), E.$el[0] && y.cleanup(E.$el[0]),
|
|
1550
|
+
if (C.size > 0)
|
|
1551
|
+
for (const [a, E] of C) {
|
|
1552
|
+
if (K.has(a) || k.has(a)) continue;
|
|
1553
|
+
const f = () => {
|
|
1554
|
+
E.$el.remove(), E.$el[0] && y.cleanup(E.$el[0]), k.delete(a), b.log("list", `${v} removed item:`, a);
|
|
1484
1555
|
};
|
|
1485
|
-
if (
|
|
1486
|
-
const
|
|
1487
|
-
|
|
1556
|
+
if (C.delete(a), k.add(a), c) {
|
|
1557
|
+
const p = c(E.$el);
|
|
1558
|
+
p instanceof Promise ? p.then(f) : f();
|
|
1488
1559
|
} else
|
|
1489
|
-
|
|
1560
|
+
f();
|
|
1490
1561
|
}
|
|
1491
|
-
if (
|
|
1492
|
-
|
|
1562
|
+
if (x === 0) {
|
|
1563
|
+
R = [];
|
|
1493
1564
|
return;
|
|
1494
1565
|
}
|
|
1495
|
-
const
|
|
1496
|
-
let
|
|
1497
|
-
for (let
|
|
1498
|
-
const E =
|
|
1499
|
-
if (
|
|
1500
|
-
const
|
|
1501
|
-
|
|
1502
|
-
const
|
|
1503
|
-
if (!
|
|
1566
|
+
const te = Et(re);
|
|
1567
|
+
let ne = te.length - 1, h = null;
|
|
1568
|
+
for (let a = x - 1; a >= 0; a--) {
|
|
1569
|
+
const E = F[a], f = N[a], p = C.get(E);
|
|
1570
|
+
if (p) {
|
|
1571
|
+
const T = p.item;
|
|
1572
|
+
p.item = f;
|
|
1573
|
+
const m = p.$el[0];
|
|
1574
|
+
if (!m) continue;
|
|
1504
1575
|
if (o)
|
|
1505
|
-
o(
|
|
1506
|
-
else if (
|
|
1507
|
-
let
|
|
1508
|
-
if (typeof
|
|
1509
|
-
|
|
1510
|
-
let
|
|
1511
|
-
const ce =
|
|
1512
|
-
for (const
|
|
1513
|
-
if (ce[
|
|
1514
|
-
|
|
1576
|
+
o(p.$el, f, a), b.domUpdated(p.$el, "list.update", f);
|
|
1577
|
+
else if (T !== f) {
|
|
1578
|
+
let I = !0;
|
|
1579
|
+
if (typeof T == "object" && T !== null && typeof f == "object" && f !== null) {
|
|
1580
|
+
I = !1;
|
|
1581
|
+
let j = 0;
|
|
1582
|
+
const ce = T, we = f;
|
|
1583
|
+
for (const J in ce) {
|
|
1584
|
+
if (ce[J] !== we[J]) {
|
|
1585
|
+
I = !0;
|
|
1515
1586
|
break;
|
|
1516
1587
|
}
|
|
1517
|
-
|
|
1588
|
+
j++;
|
|
1518
1589
|
}
|
|
1519
|
-
if (!
|
|
1520
|
-
let
|
|
1521
|
-
for (const
|
|
1522
|
-
if (
|
|
1523
|
-
|
|
1590
|
+
if (!I) {
|
|
1591
|
+
let J = 0;
|
|
1592
|
+
for (const Ft in we)
|
|
1593
|
+
if (J++, J > j) {
|
|
1594
|
+
I = !0;
|
|
1524
1595
|
break;
|
|
1525
1596
|
}
|
|
1526
|
-
|
|
1597
|
+
j !== J && (I = !0);
|
|
1527
1598
|
}
|
|
1528
1599
|
}
|
|
1529
|
-
if (
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1600
|
+
if (I) {
|
|
1601
|
+
const j = u(s(f, a)), ce = h === m;
|
|
1602
|
+
p.$el.replaceWith(j), p.$el = j, i && i(j, f, a), b.domUpdated(j, "list.render", f), ce && (h = j[0] || null);
|
|
1532
1603
|
}
|
|
1533
1604
|
}
|
|
1534
|
-
if (
|
|
1535
|
-
|
|
1605
|
+
if (ne >= 0 && te[ne] === a)
|
|
1606
|
+
ne--;
|
|
1536
1607
|
else {
|
|
1537
|
-
const
|
|
1538
|
-
h?.isConnected ? h !==
|
|
1608
|
+
const I = p.$el[0];
|
|
1609
|
+
h?.isConnected ? h !== I && p.$el.insertBefore(h) : p.$el.appendTo(g);
|
|
1539
1610
|
}
|
|
1540
|
-
h =
|
|
1611
|
+
h = p.$el[0] || null;
|
|
1541
1612
|
} else {
|
|
1542
|
-
const
|
|
1543
|
-
|
|
1613
|
+
const T = s(f, a), m = u(T);
|
|
1614
|
+
C.set(E, { $el: m, item: f }), h?.isConnected ? m.insertBefore(h) : m.appendTo(g), i && i(m, f, a), r && r(m), b.domUpdated(m, "list.add", f), h = m[0] || null;
|
|
1544
1615
|
}
|
|
1545
1616
|
}
|
|
1546
|
-
|
|
1617
|
+
R = F;
|
|
1547
1618
|
});
|
|
1548
|
-
y.trackEffect(this,
|
|
1549
|
-
|
|
1619
|
+
y.trackEffect(this, w), y.trackCleanup(this, () => {
|
|
1620
|
+
C.clear(), k.clear(), R = [], M?.remove();
|
|
1550
1621
|
});
|
|
1551
1622
|
});
|
|
1552
1623
|
};
|
|
1553
|
-
const
|
|
1554
|
-
|
|
1624
|
+
const de = /* @__PURE__ */ new WeakMap();
|
|
1625
|
+
u.fn.atomMount = function(n, e = {}) {
|
|
1555
1626
|
return this.each(function() {
|
|
1556
|
-
const t =
|
|
1557
|
-
i && (t &&
|
|
1627
|
+
const t = b.enabled, s = t ? me(this) : "", i = de.get(this);
|
|
1628
|
+
i && (t && b.log("mount", `${s} unmounting existing component`), i()), t && b.log("mount", `${s} mounting component`);
|
|
1558
1629
|
let o;
|
|
1559
1630
|
try {
|
|
1560
|
-
o = n(
|
|
1631
|
+
o = n(u(this), e);
|
|
1561
1632
|
} catch (c) {
|
|
1562
1633
|
console.error("[atom-effect-jquery] Mount error:", c);
|
|
1563
1634
|
return;
|
|
1564
1635
|
}
|
|
1565
1636
|
const r = () => {
|
|
1566
|
-
if (
|
|
1567
|
-
if (t &&
|
|
1637
|
+
if (de.delete(this)) {
|
|
1638
|
+
if (t && b.log("mount", `${s} full cleanup`), typeof o == "function")
|
|
1568
1639
|
try {
|
|
1569
1640
|
o();
|
|
1570
1641
|
} catch (c) {
|
|
@@ -1573,17 +1644,17 @@ l.fn.atomMount = function(n, e = {}) {
|
|
|
1573
1644
|
y.cleanupTree(this);
|
|
1574
1645
|
}
|
|
1575
1646
|
};
|
|
1576
|
-
|
|
1647
|
+
de.set(this, r), y.trackCleanup(this, r);
|
|
1577
1648
|
});
|
|
1578
1649
|
};
|
|
1579
|
-
|
|
1650
|
+
u.fn.atomUnmount = function() {
|
|
1580
1651
|
return this.each(function() {
|
|
1581
|
-
const n =
|
|
1652
|
+
const n = de.get(this);
|
|
1582
1653
|
n && n();
|
|
1583
1654
|
});
|
|
1584
1655
|
};
|
|
1585
|
-
const
|
|
1586
|
-
function
|
|
1656
|
+
const le = "[$.route]";
|
|
1657
|
+
function Ut(n) {
|
|
1587
1658
|
const {
|
|
1588
1659
|
target: e,
|
|
1589
1660
|
default: t,
|
|
@@ -1592,188 +1663,215 @@ function Rt(n) {
|
|
|
1592
1663
|
autoBindLinks: o = !1,
|
|
1593
1664
|
activeClass: r = "active",
|
|
1594
1665
|
beforeTransition: c,
|
|
1595
|
-
afterTransition:
|
|
1666
|
+
afterTransition: l
|
|
1596
1667
|
} = n;
|
|
1597
|
-
let
|
|
1598
|
-
const
|
|
1599
|
-
const h = window.location.hash,
|
|
1600
|
-
return (
|
|
1601
|
-
},
|
|
1602
|
-
const
|
|
1603
|
-
if (
|
|
1604
|
-
const E = {},
|
|
1605
|
-
let
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1668
|
+
let _ = !1, g = null, v = window.location.hash;
|
|
1669
|
+
const C = [], k = /* @__PURE__ */ new Set(), R = u(e), M = () => {
|
|
1670
|
+
const h = window.location.hash, a = h.indexOf("?");
|
|
1671
|
+
return (a === -1 ? h.substring(1) : h.substring(1, a)) || t;
|
|
1672
|
+
}, w = (h) => {
|
|
1673
|
+
const a = h.indexOf("?");
|
|
1674
|
+
if (a === -1) return {};
|
|
1675
|
+
const E = {}, f = h.length;
|
|
1676
|
+
let p = a + 1;
|
|
1677
|
+
const T = (m) => {
|
|
1678
|
+
try {
|
|
1679
|
+
return decodeURIComponent(m);
|
|
1680
|
+
} catch {
|
|
1681
|
+
return console.warn(`${le} Malformed URI component: ${m}`), m;
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
for (; p < f; ) {
|
|
1685
|
+
let m = h.indexOf("&", p);
|
|
1686
|
+
if (m === -1 && (m = f), m > p) {
|
|
1687
|
+
const I = h.indexOf("=", p);
|
|
1688
|
+
I !== -1 && I < m ? E[T(h.substring(p, I))] = T(
|
|
1689
|
+
h.substring(I + 1, m)
|
|
1690
|
+
) : E[T(h.substring(p, m))] = "";
|
|
1613
1691
|
}
|
|
1614
|
-
|
|
1692
|
+
p = m + 1;
|
|
1615
1693
|
}
|
|
1616
1694
|
return E;
|
|
1617
|
-
},
|
|
1618
|
-
let
|
|
1619
|
-
return !
|
|
1620
|
-
},
|
|
1621
|
-
const
|
|
1622
|
-
if (!
|
|
1623
|
-
return console.warn(`${
|
|
1624
|
-
const E =
|
|
1625
|
-
return
|
|
1626
|
-
},
|
|
1627
|
-
if (
|
|
1628
|
-
const
|
|
1629
|
-
if (!
|
|
1630
|
-
console.warn(`${
|
|
1695
|
+
}, N = (h) => {
|
|
1696
|
+
let a = s[h];
|
|
1697
|
+
return !a && i && (a = s[i]), a || (console.warn(`${le} Route "${h}" not found and no notFound route configured`), null);
|
|
1698
|
+
}, x = (h) => {
|
|
1699
|
+
const a = document.querySelector(h);
|
|
1700
|
+
if (!a?.content)
|
|
1701
|
+
return console.warn(`${le} Template "${h}" not found`), !1;
|
|
1702
|
+
const E = a.content.cloneNode(!0);
|
|
1703
|
+
return R.append(E), !0;
|
|
1704
|
+
}, L = ze(M()), W = (h) => {
|
|
1705
|
+
if (_) return;
|
|
1706
|
+
const a = R[0];
|
|
1707
|
+
if (!a) {
|
|
1708
|
+
console.warn(`${le} Target element "${e}" not found`);
|
|
1631
1709
|
return;
|
|
1632
1710
|
}
|
|
1633
|
-
const E =
|
|
1711
|
+
const E = N(h);
|
|
1634
1712
|
if (!E) return;
|
|
1635
|
-
const
|
|
1636
|
-
c && c(
|
|
1637
|
-
let
|
|
1713
|
+
const f = w(window.location.hash);
|
|
1714
|
+
c && c(g || h, h), R.empty();
|
|
1715
|
+
let p = f;
|
|
1638
1716
|
if (E.onEnter) {
|
|
1639
|
-
const
|
|
1640
|
-
|
|
1717
|
+
const T = E.onEnter(f);
|
|
1718
|
+
T !== void 0 && (p = { ...f, ...T });
|
|
1641
1719
|
}
|
|
1642
|
-
E.render ? E.render(
|
|
1643
|
-
},
|
|
1644
|
-
if (
|
|
1645
|
-
const
|
|
1646
|
-
E?.onLeave && E.onLeave() === !1 || (
|
|
1647
|
-
},
|
|
1648
|
-
if (
|
|
1720
|
+
E.render ? E.render(a, h, p) : E.template && x(E.template), l && l(g || h, h), g = h;
|
|
1721
|
+
}, F = (h) => {
|
|
1722
|
+
if (_) return;
|
|
1723
|
+
const a = L.value, E = s[a];
|
|
1724
|
+
E?.onLeave && E.onLeave() === !1 || (v = `#${h}`, window.location.hash = v, L.value = h);
|
|
1725
|
+
}, K = () => {
|
|
1726
|
+
if (_) return;
|
|
1649
1727
|
const h = window.location.hash;
|
|
1650
|
-
if (h ===
|
|
1651
|
-
const
|
|
1652
|
-
if (E !==
|
|
1653
|
-
const
|
|
1654
|
-
if (
|
|
1655
|
-
window.location.hash =
|
|
1728
|
+
if (h === v) return;
|
|
1729
|
+
const a = M(), E = L.value;
|
|
1730
|
+
if (E !== a) {
|
|
1731
|
+
const f = s[E];
|
|
1732
|
+
if (f?.onLeave && f.onLeave() === !1) {
|
|
1733
|
+
window.location.hash = v;
|
|
1656
1734
|
return;
|
|
1657
1735
|
}
|
|
1658
|
-
|
|
1736
|
+
L.value = a;
|
|
1659
1737
|
} else
|
|
1660
|
-
|
|
1661
|
-
|
|
1738
|
+
W(a);
|
|
1739
|
+
v = h;
|
|
1662
1740
|
}, re = () => {
|
|
1663
1741
|
if (!o) return;
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1742
|
+
const h = (f) => {
|
|
1743
|
+
f.preventDefault();
|
|
1744
|
+
const p = u(f.currentTarget).data("route");
|
|
1745
|
+
F(p);
|
|
1746
|
+
};
|
|
1747
|
+
u(document).on("click", "[data-route]", h), C.push(() => {
|
|
1748
|
+
u(document).off("click", "[data-route]", h);
|
|
1749
|
+
});
|
|
1750
|
+
const a = (f) => {
|
|
1751
|
+
if (k.has(f)) return;
|
|
1752
|
+
const p = u(f), T = p.data("route");
|
|
1753
|
+
k.add(f);
|
|
1754
|
+
const m = V(() => {
|
|
1755
|
+
const I = L.value === T;
|
|
1756
|
+
p.toggleClass(r, I), I ? p.attr("aria-current", "page") : p.removeAttr("aria-current");
|
|
1672
1757
|
});
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
E.toggleClass(r, b), b ? E.attr("aria-current", "page") : E.removeAttr("aria-current");
|
|
1758
|
+
y.trackEffect(f, m), y.trackCleanup(f, () => {
|
|
1759
|
+
k.delete(f);
|
|
1676
1760
|
});
|
|
1677
|
-
|
|
1761
|
+
};
|
|
1762
|
+
u("[data-route]").each(function() {
|
|
1763
|
+
a(this);
|
|
1678
1764
|
});
|
|
1679
|
-
|
|
1680
|
-
|
|
1765
|
+
const E = new MutationObserver((f) => {
|
|
1766
|
+
for (const p of f)
|
|
1767
|
+
p.type === "childList" && p.addedNodes.forEach((T) => {
|
|
1768
|
+
if (T.nodeType === 1) {
|
|
1769
|
+
const m = T;
|
|
1770
|
+
m.matches?.("[data-route]") && a(m), m.querySelectorAll && m.querySelectorAll("[data-route]").forEach(
|
|
1771
|
+
(I) => a(I)
|
|
1772
|
+
);
|
|
1773
|
+
}
|
|
1774
|
+
});
|
|
1775
|
+
});
|
|
1776
|
+
E.observe(document.body, { childList: !0, subtree: !0 }), C.push(() => E.disconnect());
|
|
1777
|
+
}, te = () => {
|
|
1778
|
+
_ || (_ = !0, C.forEach((h) => h()), C.length = 0, k.forEach((h) => y.cleanup(h)), k.clear());
|
|
1681
1779
|
};
|
|
1682
|
-
window.addEventListener("hashchange",
|
|
1683
|
-
const
|
|
1684
|
-
|
|
1780
|
+
window.addEventListener("hashchange", K), C.push(() => window.removeEventListener("hashchange", K));
|
|
1781
|
+
const ne = V(() => {
|
|
1782
|
+
W(L.value);
|
|
1685
1783
|
});
|
|
1686
|
-
return
|
|
1687
|
-
currentRoute:
|
|
1688
|
-
navigate:
|
|
1689
|
-
destroy:
|
|
1784
|
+
return C.push(() => ne.dispose()), re(), R[0] && y.trackCleanup(R[0], te), {
|
|
1785
|
+
currentRoute: L,
|
|
1786
|
+
navigate: F,
|
|
1787
|
+
destroy: te
|
|
1690
1788
|
};
|
|
1691
1789
|
}
|
|
1692
|
-
|
|
1693
|
-
route:
|
|
1790
|
+
u.extend({
|
|
1791
|
+
route: Ut
|
|
1694
1792
|
});
|
|
1695
|
-
const
|
|
1696
|
-
let
|
|
1697
|
-
const
|
|
1698
|
-
let e =
|
|
1793
|
+
const pe = /* @__PURE__ */ new WeakMap();
|
|
1794
|
+
let Pe = !1;
|
|
1795
|
+
const $e = (n) => {
|
|
1796
|
+
let e = pe.get(n);
|
|
1699
1797
|
return e || (e = function(...t) {
|
|
1700
|
-
return
|
|
1701
|
-
},
|
|
1798
|
+
return Oe(() => n.apply(this, t));
|
|
1799
|
+
}, pe.set(n, e)), e;
|
|
1702
1800
|
};
|
|
1703
1801
|
function Ke() {
|
|
1704
|
-
if (
|
|
1705
|
-
|
|
1706
|
-
const n =
|
|
1707
|
-
|
|
1802
|
+
if (Pe) return;
|
|
1803
|
+
Pe = !0;
|
|
1804
|
+
const n = u.fn.on, e = u.fn.off, t = u.fn.remove, s = u.fn.empty, i = u.fn.detach;
|
|
1805
|
+
u.fn.remove = function(o) {
|
|
1708
1806
|
const r = o ? this.filter(o) : this;
|
|
1709
|
-
for (let c = 0,
|
|
1710
|
-
const
|
|
1711
|
-
|
|
1807
|
+
for (let c = 0, l = r.length; c < l; c++) {
|
|
1808
|
+
const _ = r[c];
|
|
1809
|
+
_ && (y.cleanupTree(_), y.markIgnored(_));
|
|
1712
1810
|
}
|
|
1713
1811
|
return t.call(this, o);
|
|
1714
|
-
},
|
|
1812
|
+
}, u.fn.empty = function() {
|
|
1715
1813
|
for (let o = 0, r = this.length; o < r; o++) {
|
|
1716
1814
|
const c = this[o];
|
|
1717
1815
|
c && y.cleanupDescendants(c);
|
|
1718
1816
|
}
|
|
1719
1817
|
return s.call(this);
|
|
1720
|
-
},
|
|
1818
|
+
}, u.fn.detach = function(o) {
|
|
1721
1819
|
const r = o ? this.filter(o) : this;
|
|
1722
|
-
for (let c = 0,
|
|
1723
|
-
const
|
|
1724
|
-
|
|
1820
|
+
for (let c = 0, l = r.length; c < l; c++) {
|
|
1821
|
+
const _ = r[c];
|
|
1822
|
+
_ && y.keep(_);
|
|
1725
1823
|
}
|
|
1726
1824
|
return i.call(this, o);
|
|
1727
|
-
},
|
|
1825
|
+
}, u.fn.on = function(...o) {
|
|
1728
1826
|
const r = o[0];
|
|
1729
1827
|
if (r && typeof r == "object") {
|
|
1730
|
-
const c = r,
|
|
1731
|
-
for (const
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1828
|
+
const c = r, l = {};
|
|
1829
|
+
for (const _ in c) {
|
|
1830
|
+
const g = c[_];
|
|
1831
|
+
g && (l[_] = $e(g));
|
|
1734
1832
|
}
|
|
1735
|
-
o[0] =
|
|
1833
|
+
o[0] = l;
|
|
1736
1834
|
} else
|
|
1737
1835
|
for (let c = o.length - 1; c >= 0; c--)
|
|
1738
1836
|
if (typeof o[c] == "function") {
|
|
1739
|
-
o[c] =
|
|
1837
|
+
o[c] = $e(o[c]);
|
|
1740
1838
|
break;
|
|
1741
1839
|
}
|
|
1742
1840
|
return n.apply(this, o);
|
|
1743
|
-
},
|
|
1841
|
+
}, u.fn.off = function(...o) {
|
|
1744
1842
|
const r = o[0];
|
|
1745
1843
|
if (r && typeof r == "object") {
|
|
1746
|
-
const c = r,
|
|
1747
|
-
for (const
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1844
|
+
const c = r, l = {};
|
|
1845
|
+
for (const _ in c) {
|
|
1846
|
+
const g = c[_];
|
|
1847
|
+
g && (l[_] = pe.get(g) || g);
|
|
1750
1848
|
}
|
|
1751
|
-
o[0] =
|
|
1849
|
+
o[0] = l;
|
|
1752
1850
|
} else
|
|
1753
1851
|
for (let c = o.length - 1; c >= 0; c--)
|
|
1754
1852
|
if (typeof o[c] == "function") {
|
|
1755
|
-
o[c] =
|
|
1853
|
+
o[c] = pe.get(o[c]) || o[c];
|
|
1756
1854
|
break;
|
|
1757
1855
|
}
|
|
1758
1856
|
return e.apply(this, o);
|
|
1759
1857
|
};
|
|
1760
1858
|
}
|
|
1761
|
-
const
|
|
1859
|
+
const Mt = Ke;
|
|
1762
1860
|
Ke();
|
|
1763
|
-
|
|
1764
|
-
|
|
1861
|
+
u(() => {
|
|
1862
|
+
It(document.body);
|
|
1765
1863
|
});
|
|
1766
1864
|
export {
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1865
|
+
ze as atom,
|
|
1866
|
+
Oe as batch,
|
|
1867
|
+
dt as computed,
|
|
1868
|
+
Vt as default,
|
|
1869
|
+
$t as disableAutoCleanup,
|
|
1870
|
+
V as effect,
|
|
1871
|
+
It as enableAutoCleanup,
|
|
1872
|
+
Mt as enablejQueryBatching,
|
|
1775
1873
|
Ke as enablejQueryOverrides,
|
|
1776
1874
|
y as registry,
|
|
1777
|
-
|
|
1875
|
+
at as untracked
|
|
1778
1876
|
};
|
|
1779
1877
|
//# sourceMappingURL=index.mjs.map
|