@but212/atom-effect-jquery 0.21.3 → 0.22.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 +1 -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 +264 -53
- package/dist/index.mjs +1306 -1101
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { default as
|
|
3
|
-
const
|
|
1
|
+
import c from "jquery";
|
|
2
|
+
import { default as qs } from "jquery";
|
|
3
|
+
const ut = {
|
|
4
4
|
IDLE: "idle",
|
|
5
5
|
PENDING: "pending",
|
|
6
6
|
RESOLVED: "resolved",
|
|
7
7
|
REJECTED: "rejected"
|
|
8
|
-
},
|
|
8
|
+
}, L = {
|
|
9
9
|
DISPOSED: 1,
|
|
10
10
|
EXECUTING: 8
|
|
11
|
-
},
|
|
11
|
+
}, fe = {
|
|
12
12
|
DISPOSED: 1,
|
|
13
13
|
/** Marker bit: identifies this node as a computed. */
|
|
14
14
|
IS_COMPUTED: 2,
|
|
@@ -19,11 +19,11 @@ const bt = {
|
|
|
19
19
|
REJECTED: 128,
|
|
20
20
|
RECOMPUTING: 256,
|
|
21
21
|
HAS_ERROR: 512
|
|
22
|
-
},
|
|
22
|
+
}, $ = {
|
|
23
23
|
DISPOSED: 1,
|
|
24
24
|
SYNC: 8,
|
|
25
25
|
NOTIFICATION_SCHEDULED: 16
|
|
26
|
-
},
|
|
26
|
+
}, q = {
|
|
27
27
|
// Infinite loop protection
|
|
28
28
|
MAX_EXECUTIONS_PER_SECOND: 1e3,
|
|
29
29
|
MAX_EXECUTIONS_PER_EFFECT: 100,
|
|
@@ -33,96 +33,84 @@ const bt = {
|
|
|
33
33
|
MIN_FLUSH_ITERATIONS: 10,
|
|
34
34
|
// Memory management
|
|
35
35
|
BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
|
|
36
|
-
},
|
|
36
|
+
}, we = {
|
|
37
37
|
WARN_INFINITE_LOOP: !0
|
|
38
|
-
},
|
|
38
|
+
}, te = {
|
|
39
39
|
MAX_ASYNC_RETRIES: 3,
|
|
40
40
|
MAX_PROMISE_ID: Number.MAX_SAFE_INTEGER - 1
|
|
41
|
-
},
|
|
42
|
-
class
|
|
43
|
-
constructor(t,
|
|
44
|
-
super(t), this.cause =
|
|
41
|
+
}, It = 1073741823, ke = typeof process < "u" && process.env && !1 || !1, xe = Object.freeze([]);
|
|
42
|
+
class tt extends Error {
|
|
43
|
+
constructor(t, s = null, n = !0) {
|
|
44
|
+
super(t), this.cause = s, this.recoverable = n, this.name = "AtomError";
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
class
|
|
48
|
-
constructor(t,
|
|
49
|
-
super(t,
|
|
47
|
+
class z extends tt {
|
|
48
|
+
constructor(t, s = null) {
|
|
49
|
+
super(t, s, !0), this.name = "ComputedError";
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
class
|
|
53
|
-
constructor(t,
|
|
54
|
-
super(t,
|
|
52
|
+
class J extends tt {
|
|
53
|
+
constructor(t, s = null) {
|
|
54
|
+
super(t, s, !1), this.name = "EffectError";
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
class
|
|
58
|
-
constructor(t,
|
|
59
|
-
super(t,
|
|
57
|
+
class At extends tt {
|
|
58
|
+
constructor(t, s = null) {
|
|
59
|
+
super(t, s, !1), this.name = "SchedulerError";
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
const
|
|
62
|
+
const Pe = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), Me = /* @__PURE__ */ Symbol("AtomEffect.Type"), Ut = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), yt = {
|
|
63
63
|
// Dev mode flag
|
|
64
|
-
enabled:
|
|
65
|
-
warnInfiniteLoop:
|
|
64
|
+
enabled: ke,
|
|
65
|
+
warnInfiniteLoop: we.WARN_INFINITE_LOOP,
|
|
66
66
|
warn(e, t) {
|
|
67
67
|
},
|
|
68
68
|
checkCircular(e, t) {
|
|
69
69
|
if (e === t)
|
|
70
|
-
throw new
|
|
70
|
+
throw new z("Direct circular dependency detected");
|
|
71
71
|
},
|
|
72
|
-
attachDebugInfo(e, t,
|
|
72
|
+
attachDebugInfo(e, t, s) {
|
|
73
73
|
},
|
|
74
|
-
getDebugName: (e) => e?.[
|
|
75
|
-
getDebugType: (e) => e?.[
|
|
74
|
+
getDebugName: (e) => e?.[Pe],
|
|
75
|
+
getDebugType: (e) => e?.[Me]
|
|
76
76
|
};
|
|
77
|
-
let
|
|
78
|
-
const
|
|
79
|
-
function
|
|
77
|
+
let $e = 1;
|
|
78
|
+
const Fe = () => $e++;
|
|
79
|
+
function de(e, t, s) {
|
|
80
80
|
if (typeof t == "function") {
|
|
81
81
|
const i = t;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (c && c.fn === i) return;
|
|
85
|
-
}
|
|
86
|
-
n.push(new $t(i, void 0));
|
|
82
|
+
if (s.some((r) => r && r.fn === i)) return;
|
|
83
|
+
s.push(new Mt(i, void 0));
|
|
87
84
|
return;
|
|
88
85
|
}
|
|
89
86
|
if ("addDependency" in t) {
|
|
90
87
|
t.addDependency(e);
|
|
91
88
|
return;
|
|
92
89
|
}
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
const r = n[i];
|
|
96
|
-
if (r && r.sub === s) return;
|
|
97
|
-
}
|
|
98
|
-
n.push(new $t(void 0, s));
|
|
90
|
+
const n = t;
|
|
91
|
+
s.some((i) => i && i.sub === n) || s.push(new Mt(void 0, n));
|
|
99
92
|
}
|
|
100
|
-
function
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const c = r.node, a = s.get(c);
|
|
110
|
-
a !== void 0 ? (r.unsub = a, s.delete(c)) : (kt.checkCircular(c, n), r.unsub = c.subscribe(n));
|
|
111
|
-
}
|
|
112
|
-
for (const i of s.values())
|
|
113
|
-
i();
|
|
93
|
+
function ee(e, t, s) {
|
|
94
|
+
const n = /* @__PURE__ */ new Map();
|
|
95
|
+
t.forEach((i) => {
|
|
96
|
+
i?.unsub && n.set(i.node, i.unsub);
|
|
97
|
+
}), e.forEach((i) => {
|
|
98
|
+
if (!i) return;
|
|
99
|
+
const r = i.node, o = n.get(r);
|
|
100
|
+
o !== void 0 ? (i.unsub = o, n.delete(r)) : (yt.checkCircular(r, s), i.unsub = r.subscribe(s));
|
|
101
|
+
}), n.forEach((i) => i());
|
|
114
102
|
}
|
|
115
|
-
class
|
|
116
|
-
constructor(t,
|
|
117
|
-
this.node = t, this.version =
|
|
103
|
+
class Pt {
|
|
104
|
+
constructor(t, s, n = void 0) {
|
|
105
|
+
this.node = t, this.version = s, this.unsub = n;
|
|
118
106
|
}
|
|
119
107
|
}
|
|
120
|
-
class
|
|
121
|
-
constructor(t,
|
|
122
|
-
this.fn = t, this.sub =
|
|
108
|
+
class Mt {
|
|
109
|
+
constructor(t, s) {
|
|
110
|
+
this.fn = t, this.sub = s;
|
|
123
111
|
}
|
|
124
112
|
}
|
|
125
|
-
const
|
|
113
|
+
const y = {
|
|
126
114
|
// Computed Errors
|
|
127
115
|
COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
|
|
128
116
|
COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
|
|
@@ -147,81 +135,74 @@ const D = {
|
|
|
147
135
|
SCHEDULER_CALLBACK_MUST_BE_FUNCTION: "Scheduler callback must be a function",
|
|
148
136
|
SCHEDULER_END_BATCH_WITHOUT_START: "endBatch() called without matching startBatch(). Ignoring."
|
|
149
137
|
};
|
|
150
|
-
function
|
|
151
|
-
if (e instanceof
|
|
138
|
+
function Z(e, t, s) {
|
|
139
|
+
if (e instanceof tt)
|
|
152
140
|
return e;
|
|
153
|
-
const
|
|
154
|
-
return new t(
|
|
141
|
+
const n = e instanceof Error, i = n ? e.message : String(e), r = n ? e : void 0, o = `${n ? e.constructor.name : "Unexpected error"} (${s}): ${i}`;
|
|
142
|
+
return new t(o, r);
|
|
155
143
|
}
|
|
156
|
-
class
|
|
144
|
+
class _e {
|
|
157
145
|
constructor() {
|
|
158
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id =
|
|
146
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this.id = Fe() & It;
|
|
159
147
|
}
|
|
160
148
|
}
|
|
161
|
-
class
|
|
149
|
+
class Ee extends _e {
|
|
162
150
|
/**
|
|
163
151
|
* Adds subscriber.
|
|
164
152
|
*/
|
|
165
153
|
subscribe(t) {
|
|
166
|
-
const
|
|
167
|
-
if (!
|
|
168
|
-
throw
|
|
154
|
+
const s = typeof t == "function";
|
|
155
|
+
if (!s && (!t || typeof t.execute != "function"))
|
|
156
|
+
throw Z(
|
|
169
157
|
new TypeError("Invalid subscriber"),
|
|
170
|
-
|
|
171
|
-
|
|
158
|
+
tt,
|
|
159
|
+
y.ATOM_SUBSCRIBER_MUST_BE_FUNCTION
|
|
172
160
|
);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
const i = new $t(
|
|
181
|
-
n ? t : void 0,
|
|
182
|
-
n ? void 0 : t
|
|
161
|
+
if (this._subscribers.some((i) => i ? s ? i.fn === t : i.sub === t : !1))
|
|
162
|
+
return () => {
|
|
163
|
+
};
|
|
164
|
+
const n = new Mt(
|
|
165
|
+
s ? t : void 0,
|
|
166
|
+
s ? void 0 : t
|
|
183
167
|
);
|
|
184
|
-
return
|
|
168
|
+
return this._subscribers.push(n), () => this._unsubscribe(n);
|
|
185
169
|
}
|
|
186
170
|
_unsubscribe(t) {
|
|
187
|
-
const
|
|
188
|
-
if (
|
|
189
|
-
const i =
|
|
190
|
-
|
|
171
|
+
const s = this._subscribers, n = s.indexOf(t);
|
|
172
|
+
if (n === -1) return;
|
|
173
|
+
const i = s.pop();
|
|
174
|
+
n < s.length && i && (s[n] = i);
|
|
191
175
|
}
|
|
192
176
|
subscriberCount() {
|
|
193
177
|
return this._subscribers.length;
|
|
194
178
|
}
|
|
195
|
-
_notifySubscribers(t,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
for (let o = 0; o < i; o++) {
|
|
199
|
-
const r = s[o];
|
|
200
|
-
if (r)
|
|
179
|
+
_notifySubscribers(t, s) {
|
|
180
|
+
this._subscribers.length !== 0 && this._subscribers.slice(0).forEach((n) => {
|
|
181
|
+
if (n)
|
|
201
182
|
try {
|
|
202
|
-
|
|
203
|
-
} catch (
|
|
204
|
-
this._handleNotifyError(
|
|
183
|
+
n.fn ? n.fn(t, s) : n.sub && n.sub.execute();
|
|
184
|
+
} catch (i) {
|
|
185
|
+
this._handleNotifyError(i);
|
|
205
186
|
}
|
|
206
|
-
}
|
|
187
|
+
});
|
|
207
188
|
}
|
|
208
189
|
_handleNotifyError(t) {
|
|
209
|
-
console.error(
|
|
190
|
+
console.error(Z(t, tt, y.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
|
|
210
191
|
}
|
|
211
192
|
}
|
|
212
|
-
let
|
|
213
|
-
const
|
|
214
|
-
let
|
|
215
|
-
const
|
|
216
|
-
function
|
|
217
|
-
return
|
|
193
|
+
let Lt = 0;
|
|
194
|
+
const jt = () => (Lt = Lt + 1 & It || 1, Lt), $t = (e) => e + 1 & It;
|
|
195
|
+
let zt = 0, pt = !1, pe = 0;
|
|
196
|
+
const me = () => pe;
|
|
197
|
+
function se() {
|
|
198
|
+
return pt ? !1 : (pt = !0, pe = jt(), zt = 0, !0);
|
|
218
199
|
}
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
},
|
|
222
|
-
class
|
|
200
|
+
const ne = () => {
|
|
201
|
+
pt = !1;
|
|
202
|
+
}, Be = () => pt ? ++zt : 0;
|
|
203
|
+
class He {
|
|
223
204
|
constructor() {
|
|
224
|
-
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isBatching = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations =
|
|
205
|
+
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isBatching = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = q.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
|
|
225
206
|
}
|
|
226
207
|
get phase() {
|
|
227
208
|
return this._isProcessing || this._isFlushingSync ? 2 : this._isBatching ? 1 : 0;
|
|
@@ -256,30 +237,28 @@ class Pe {
|
|
|
256
237
|
_runLoop() {
|
|
257
238
|
try {
|
|
258
239
|
if (this._size === 0) return;
|
|
259
|
-
const t =
|
|
260
|
-
this._drainQueue(), t &&
|
|
240
|
+
const t = se();
|
|
241
|
+
this._drainQueue(), t && ne();
|
|
261
242
|
} finally {
|
|
262
243
|
this._isProcessing = !1, this._size > 0 && !this._isBatching && this._flush();
|
|
263
244
|
}
|
|
264
245
|
}
|
|
265
246
|
_flushSync() {
|
|
266
247
|
this._isFlushingSync = !0;
|
|
267
|
-
const t =
|
|
248
|
+
const t = se();
|
|
268
249
|
try {
|
|
269
250
|
this._mergeBatchQueue(), this._drainQueue();
|
|
270
251
|
} finally {
|
|
271
|
-
this._isFlushingSync = !1, t &&
|
|
252
|
+
this._isFlushingSync = !1, t && ne();
|
|
272
253
|
}
|
|
273
254
|
}
|
|
274
255
|
_mergeBatchQueue() {
|
|
275
256
|
if (this._batchQueueSize === 0) return;
|
|
276
|
-
const t = ++this._epoch,
|
|
257
|
+
const t = ++this._epoch, s = this._batchQueue, n = this._queueBuffer[this._bufferIndex];
|
|
277
258
|
let i = this._size;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
this._size = i, this._batchQueueSize = 0, n.length > W.BATCH_QUEUE_SHRINK_THRESHOLD && (n.length = 0);
|
|
259
|
+
s.slice(0, this._batchQueueSize).forEach((r) => {
|
|
260
|
+
r._nextEpoch !== t && (r._nextEpoch = t, n[i++] = r);
|
|
261
|
+
}), this._size = i, this._batchQueueSize = 0, s.length > q.BATCH_QUEUE_SHRINK_THRESHOLD && (s.length = 0);
|
|
283
262
|
}
|
|
284
263
|
_drainQueue() {
|
|
285
264
|
let t = 0;
|
|
@@ -292,21 +271,21 @@ class Pe {
|
|
|
292
271
|
}
|
|
293
272
|
}
|
|
294
273
|
_processQueue() {
|
|
295
|
-
const t = this._bufferIndex,
|
|
274
|
+
const t = this._bufferIndex, s = this._queueBuffer[t], n = this._size;
|
|
296
275
|
this._bufferIndex = t ^ 1, this._size = 0, this._epoch++;
|
|
297
|
-
for (let i = 0; i <
|
|
276
|
+
for (let i = 0; i < n; i++)
|
|
298
277
|
try {
|
|
299
|
-
|
|
300
|
-
} catch (
|
|
301
|
-
console.error(new
|
|
278
|
+
s[i]();
|
|
279
|
+
} catch (r) {
|
|
280
|
+
console.error(new At("Error occurred during scheduler execution", r));
|
|
302
281
|
}
|
|
303
|
-
|
|
282
|
+
s.length = 0;
|
|
304
283
|
}
|
|
305
284
|
_handleFlushOverflow() {
|
|
306
285
|
const t = this._size + this._batchQueueSize;
|
|
307
286
|
if (console.error(
|
|
308
|
-
new
|
|
309
|
-
|
|
287
|
+
new At(
|
|
288
|
+
y.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, t)
|
|
310
289
|
)
|
|
311
290
|
), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0, this.onOverflow)
|
|
312
291
|
try {
|
|
@@ -321,14 +300,14 @@ class Pe {
|
|
|
321
300
|
this._batchDepth !== 0 && --this._batchDepth === 0 && (this._flushSync(), this._isBatching = !1);
|
|
322
301
|
}
|
|
323
302
|
setMaxFlushIterations(t) {
|
|
324
|
-
if (t <
|
|
325
|
-
throw new
|
|
326
|
-
`Max flush iterations must be at least ${
|
|
303
|
+
if (t < q.MIN_FLUSH_ITERATIONS)
|
|
304
|
+
throw new At(
|
|
305
|
+
`Max flush iterations must be at least ${q.MIN_FLUSH_ITERATIONS}`
|
|
327
306
|
);
|
|
328
307
|
this._maxFlushIterations = t;
|
|
329
308
|
}
|
|
330
309
|
}
|
|
331
|
-
const
|
|
310
|
+
const rt = new He(), Vt = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ge = /* @__PURE__ */ Symbol.for("atom-effect/computed"), Ge = /* @__PURE__ */ Symbol.for("atom-effect/effect"), k = {
|
|
332
311
|
/** Active listener. */
|
|
333
312
|
current: null,
|
|
334
313
|
/**
|
|
@@ -339,45 +318,45 @@ const _t = new Pe(), Xt = /* @__PURE__ */ Symbol.for("atom-effect/atom"), fe = /
|
|
|
339
318
|
* @returns The result of `fn`.
|
|
340
319
|
*/
|
|
341
320
|
run(e, t) {
|
|
342
|
-
const
|
|
321
|
+
const s = this.current;
|
|
343
322
|
this.current = e;
|
|
344
323
|
try {
|
|
345
324
|
return t();
|
|
346
325
|
} finally {
|
|
347
|
-
this.current =
|
|
326
|
+
this.current = s;
|
|
348
327
|
}
|
|
349
328
|
}
|
|
350
329
|
};
|
|
351
|
-
function
|
|
352
|
-
const t =
|
|
330
|
+
function H(e) {
|
|
331
|
+
const t = k.current;
|
|
353
332
|
if (t === null) return e();
|
|
354
|
-
|
|
333
|
+
k.current = null;
|
|
355
334
|
try {
|
|
356
335
|
return e();
|
|
357
336
|
} finally {
|
|
358
|
-
|
|
337
|
+
k.current = t;
|
|
359
338
|
}
|
|
360
339
|
}
|
|
361
|
-
var
|
|
362
|
-
class
|
|
363
|
-
constructor(t,
|
|
364
|
-
super(), this._pendingOldValue = void 0, this._notifyTask = () => this._flushNotifications(), this._subscribers = [], this[
|
|
340
|
+
var ie;
|
|
341
|
+
class je extends Ee {
|
|
342
|
+
constructor(t, s) {
|
|
343
|
+
super(), this._pendingOldValue = void 0, this._notifyTask = () => this._flushNotifications(), this._subscribers = [], this[ie] = !0, this._value = t, s && (this.flags |= $.SYNC), yt.attachDebugInfo(this, "atom", this.id);
|
|
365
344
|
}
|
|
366
345
|
get value() {
|
|
367
|
-
const t =
|
|
368
|
-
return t &&
|
|
346
|
+
const t = k.current;
|
|
347
|
+
return t && de(this, t, this._subscribers), this._value;
|
|
369
348
|
}
|
|
370
349
|
set value(t) {
|
|
371
|
-
const
|
|
372
|
-
if (Object.is(
|
|
373
|
-
this._value = t, this.version =
|
|
374
|
-
const
|
|
375
|
-
if (!(this._subscribers.length === 0 ||
|
|
376
|
-
if (this._pendingOldValue =
|
|
350
|
+
const s = this._value;
|
|
351
|
+
if (Object.is(s, t)) return;
|
|
352
|
+
this._value = t, this.version = $t(this.version);
|
|
353
|
+
const n = this.flags;
|
|
354
|
+
if (!(this._subscribers.length === 0 || n & $.NOTIFICATION_SCHEDULED)) {
|
|
355
|
+
if (this._pendingOldValue = s, this.flags = n | $.NOTIFICATION_SCHEDULED, n & $.SYNC && !rt.isBatching) {
|
|
377
356
|
this._flushNotifications();
|
|
378
357
|
return;
|
|
379
358
|
}
|
|
380
|
-
|
|
359
|
+
rt.schedule(this._notifyTask);
|
|
381
360
|
}
|
|
382
361
|
}
|
|
383
362
|
/**
|
|
@@ -385,32 +364,32 @@ class $e extends le {
|
|
|
385
364
|
*/
|
|
386
365
|
_flushNotifications() {
|
|
387
366
|
const t = this.flags;
|
|
388
|
-
if (!(t &
|
|
367
|
+
if (!(t & $.NOTIFICATION_SCHEDULED) || t & $.DISPOSED)
|
|
389
368
|
return;
|
|
390
|
-
const
|
|
391
|
-
this._pendingOldValue = void 0, this.flags &= -17, this._notifySubscribers(this._value,
|
|
369
|
+
const s = this._pendingOldValue;
|
|
370
|
+
this._pendingOldValue = void 0, this.flags &= -17, this._notifySubscribers(this._value, s);
|
|
392
371
|
}
|
|
393
372
|
peek() {
|
|
394
373
|
return this._value;
|
|
395
374
|
}
|
|
396
375
|
dispose() {
|
|
397
|
-
this.flags &
|
|
376
|
+
this.flags & $.DISPOSED || (this._subscribers.length = 0, this.flags |= $.DISPOSED, this._value = void 0, this._pendingOldValue = void 0);
|
|
398
377
|
}
|
|
399
|
-
[(
|
|
378
|
+
[(ie = Vt, Symbol.dispose)]() {
|
|
400
379
|
this.dispose();
|
|
401
380
|
}
|
|
402
381
|
}
|
|
403
|
-
function
|
|
404
|
-
return new
|
|
382
|
+
function Ft(e, t = {}) {
|
|
383
|
+
return new je(e, t.sync ?? !1);
|
|
405
384
|
}
|
|
406
|
-
class
|
|
385
|
+
class ze {
|
|
407
386
|
/**
|
|
408
387
|
* @param limit - Max unique arrays to hold (default: 50). Prevents the pool itself from consuming too much memory.
|
|
409
388
|
* @param capacity - Max length of an array to accept (default: 256).
|
|
410
389
|
* @param enableStats - Force-enable stats even in production (default: false).
|
|
411
390
|
*/
|
|
412
|
-
constructor(t = 50,
|
|
413
|
-
this.limit = t, this.capacity =
|
|
391
|
+
constructor(t = 50, s = 256, n = !1) {
|
|
392
|
+
this.limit = t, this.capacity = s, this.pool = [], this.stats = null, this.stats = n ? {
|
|
414
393
|
acquired: 0,
|
|
415
394
|
released: 0,
|
|
416
395
|
rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
|
|
@@ -428,8 +407,8 @@ class Be {
|
|
|
428
407
|
* @param arr - Array to release.
|
|
429
408
|
* @param emptyConst - Optional empty constant.
|
|
430
409
|
*/
|
|
431
|
-
release(t,
|
|
432
|
-
if (!(
|
|
410
|
+
release(t, s) {
|
|
411
|
+
if (!(s && t === s)) {
|
|
433
412
|
if (t.length > this.capacity) {
|
|
434
413
|
this.stats && this.stats.rejected.tooLarge++;
|
|
435
414
|
return;
|
|
@@ -450,11 +429,11 @@ class Be {
|
|
|
450
429
|
*/
|
|
451
430
|
getStats() {
|
|
452
431
|
if (!this.stats) return null;
|
|
453
|
-
const { acquired: t, released:
|
|
432
|
+
const { acquired: t, released: s, rejected: n } = this.stats, i = t - s - (n.frozen + n.tooLarge + n.poolFull);
|
|
454
433
|
return {
|
|
455
434
|
acquired: t,
|
|
456
|
-
released:
|
|
457
|
-
rejected: { ...
|
|
435
|
+
released: s,
|
|
436
|
+
rejected: { ...n },
|
|
458
437
|
leaked: i,
|
|
459
438
|
poolSize: this.pool.length
|
|
460
439
|
};
|
|
@@ -470,58 +449,58 @@ class Be {
|
|
|
470
449
|
});
|
|
471
450
|
}
|
|
472
451
|
}
|
|
473
|
-
const
|
|
452
|
+
const O = Object.freeze(
|
|
474
453
|
[]
|
|
475
|
-
),
|
|
476
|
-
function
|
|
477
|
-
return e !== null && typeof e == "object" &&
|
|
454
|
+
), B = new ze();
|
|
455
|
+
function qt(e) {
|
|
456
|
+
return e !== null && typeof e == "object" && Vt in e;
|
|
478
457
|
}
|
|
479
|
-
function
|
|
480
|
-
return e !== null && typeof e == "object" &&
|
|
458
|
+
function Ve(e) {
|
|
459
|
+
return e !== null && typeof e == "object" && ge in e;
|
|
481
460
|
}
|
|
482
|
-
function
|
|
461
|
+
function Ie(e) {
|
|
483
462
|
return e !== null && typeof e == "object" && typeof e.then == "function";
|
|
484
463
|
}
|
|
485
|
-
var
|
|
486
|
-
const { IDLE:
|
|
487
|
-
function
|
|
488
|
-
return e &
|
|
489
|
-
}
|
|
490
|
-
class
|
|
491
|
-
constructor(t,
|
|
492
|
-
if (typeof t != "function") throw new
|
|
493
|
-
super(), this[
|
|
494
|
-
const
|
|
495
|
-
if (this._maxAsyncRetries =
|
|
464
|
+
var re, oe;
|
|
465
|
+
const { IDLE: lt, DIRTY: K, PENDING: _t, RESOLVED: V, REJECTED: nt, HAS_ERROR: ft, RECOMPUTING: st, DISPOSED: wt, IS_COMPUTED: qe } = fe;
|
|
466
|
+
function Xe(e) {
|
|
467
|
+
return e & V ? ut.RESOLVED : e & _t ? ut.PENDING : e & nt ? ut.REJECTED : ut.IDLE;
|
|
468
|
+
}
|
|
469
|
+
class Qe extends Ee {
|
|
470
|
+
constructor(t, s = {}) {
|
|
471
|
+
if (typeof t != "function") throw new z(y.COMPUTED_MUST_BE_FUNCTION);
|
|
472
|
+
super(), this[oe] = !0, this[re] = !0, this._error = null, this._promiseId = 0, this._subscribers = [], this._links = O, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._lastDriftEpoch = -1, this._trackEpoch = -1, this._trackLinks = O, this._trackCount = 0, this._value = void 0, this.flags = qe | K | lt, this._equal = s.equal ?? Object.is, this._fn = t, this._defaultValue = "defaultValue" in s ? s.defaultValue : Ut, this._onError = s.onError ?? null;
|
|
473
|
+
const n = s.maxAsyncRetries;
|
|
474
|
+
if (this._maxAsyncRetries = (n ?? te.MAX_ASYNC_RETRIES) & It, yt.attachDebugInfo(this, "computed", this.id), s.lazy === !1)
|
|
496
475
|
try {
|
|
497
476
|
this._recompute();
|
|
498
477
|
} catch {
|
|
499
478
|
}
|
|
500
479
|
}
|
|
501
480
|
_track() {
|
|
502
|
-
const t =
|
|
503
|
-
t &&
|
|
481
|
+
const t = k.current;
|
|
482
|
+
t && de(this, t, this._subscribers);
|
|
504
483
|
}
|
|
505
484
|
get value() {
|
|
506
485
|
this._track();
|
|
507
486
|
const t = this.flags;
|
|
508
|
-
if ((t & (
|
|
487
|
+
if ((t & (V | K | lt)) === V)
|
|
509
488
|
return this._value;
|
|
510
|
-
if (t &
|
|
511
|
-
throw new
|
|
512
|
-
if (t &
|
|
489
|
+
if (t & wt)
|
|
490
|
+
throw new z(y.COMPUTED_DISPOSED);
|
|
491
|
+
if (t & st) {
|
|
513
492
|
if (this._defaultValue !== Ut) return this._defaultValue;
|
|
514
|
-
throw new
|
|
493
|
+
throw new z(y.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
515
494
|
}
|
|
516
|
-
if (t & (
|
|
495
|
+
if (t & (K | lt) && (this._recompute(), this.flags & V))
|
|
517
496
|
return this._value;
|
|
518
|
-
const
|
|
519
|
-
if (this.flags &
|
|
520
|
-
if (
|
|
521
|
-
throw new
|
|
497
|
+
const s = this._defaultValue, n = s !== Ut;
|
|
498
|
+
if (this.flags & _t) {
|
|
499
|
+
if (n) return s;
|
|
500
|
+
throw new z(y.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
522
501
|
}
|
|
523
|
-
if (this.flags &
|
|
524
|
-
if (
|
|
502
|
+
if (this.flags & nt) {
|
|
503
|
+
if (n) return s;
|
|
525
504
|
throw this._error;
|
|
526
505
|
}
|
|
527
506
|
return this._value;
|
|
@@ -530,253 +509,225 @@ class Ve extends le {
|
|
|
530
509
|
return this._value;
|
|
531
510
|
}
|
|
532
511
|
get state() {
|
|
533
|
-
return this._track(),
|
|
512
|
+
return this._track(), Xe(this.flags);
|
|
534
513
|
}
|
|
535
514
|
get hasError() {
|
|
536
|
-
|
|
537
|
-
const t = this._links;
|
|
538
|
-
for (let n = 0, s = t.length; n < s; n++) {
|
|
539
|
-
const i = t[n]?.node;
|
|
540
|
-
if (i && i.flags & It) return !0;
|
|
541
|
-
}
|
|
542
|
-
return !1;
|
|
515
|
+
return this._track(), this.flags & (nt | ft) ? !0 : this._links.some((t) => t?.node?.flags & ft);
|
|
543
516
|
}
|
|
544
517
|
get isValid() {
|
|
545
518
|
return !this.hasError;
|
|
546
519
|
}
|
|
547
520
|
get errors() {
|
|
548
|
-
if (this._track(), !this.hasError) return
|
|
521
|
+
if (this._track(), !this.hasError) return xe;
|
|
549
522
|
const t = [];
|
|
550
|
-
this._error && t.push(this._error)
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
if (r.length > 0)
|
|
557
|
-
for (let c = 0; c < r.length; c++) {
|
|
558
|
-
const a = r[c];
|
|
559
|
-
a && t.indexOf(a) === -1 && t.push(a);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
return Object.freeze(t);
|
|
523
|
+
return this._error && t.push(this._error), this._links.forEach((s) => {
|
|
524
|
+
const n = s.node;
|
|
525
|
+
n.flags & ft && n.errors.forEach((i) => {
|
|
526
|
+
i && !t.includes(i) && t.push(i);
|
|
527
|
+
});
|
|
528
|
+
}), Object.freeze(t);
|
|
564
529
|
}
|
|
565
530
|
get lastError() {
|
|
566
531
|
return this._track(), this._error;
|
|
567
532
|
}
|
|
568
533
|
get isPending() {
|
|
569
|
-
return this._track(), (this.flags &
|
|
534
|
+
return this._track(), (this.flags & _t) !== 0;
|
|
570
535
|
}
|
|
571
536
|
get isResolved() {
|
|
572
|
-
return this._track(), (this.flags &
|
|
537
|
+
return this._track(), (this.flags & V) !== 0;
|
|
573
538
|
}
|
|
574
539
|
invalidate() {
|
|
575
540
|
this._markDirty();
|
|
576
541
|
}
|
|
577
542
|
dispose() {
|
|
578
|
-
if (this.flags &
|
|
543
|
+
if (this.flags & wt) return;
|
|
579
544
|
const t = this._links;
|
|
580
|
-
|
|
581
|
-
for (let n = 0, s = t.length; n < s; n++)
|
|
582
|
-
t[n].unsub?.();
|
|
583
|
-
q.release(t), this._links = x;
|
|
584
|
-
}
|
|
585
|
-
this._subscribers.length = 0, this.flags = Pt | et | St, this._error = null, this._value = void 0;
|
|
545
|
+
t !== O && (t.forEach((s) => s.unsub?.()), B.release(t), this._links = O), this._subscribers.length = 0, this.flags = wt | K | lt, this._error = null, this._value = void 0;
|
|
586
546
|
}
|
|
587
|
-
[(
|
|
547
|
+
[(oe = Vt, re = ge, Symbol.dispose)]() {
|
|
588
548
|
this.dispose();
|
|
589
549
|
}
|
|
590
550
|
addDependency(t) {
|
|
591
551
|
if (t._lastSeenEpoch !== this._trackEpoch) {
|
|
592
552
|
if (t._lastSeenEpoch = this._trackEpoch, this._trackCount < this._trackLinks.length) {
|
|
593
|
-
const
|
|
594
|
-
|
|
553
|
+
const s = this._trackLinks[this._trackCount];
|
|
554
|
+
s.node = t, s.version = t.version;
|
|
595
555
|
} else
|
|
596
|
-
this._trackLinks.push(new
|
|
556
|
+
this._trackLinks.push(new Pt(t, t.version));
|
|
597
557
|
this._trackCount++;
|
|
598
558
|
}
|
|
599
559
|
}
|
|
600
560
|
_recompute() {
|
|
601
|
-
if (this.flags &
|
|
602
|
-
this.flags |=
|
|
561
|
+
if (this.flags & st) return;
|
|
562
|
+
this.flags |= st;
|
|
603
563
|
const t = this._links;
|
|
604
|
-
this._trackEpoch =
|
|
605
|
-
let
|
|
564
|
+
this._trackEpoch = jt(), this._trackLinks = B.acquire(), this._trackCount = 0;
|
|
565
|
+
let s = !1;
|
|
606
566
|
try {
|
|
607
|
-
const
|
|
608
|
-
this._trackLinks.length = this._trackCount,
|
|
609
|
-
} catch (
|
|
610
|
-
if (!
|
|
567
|
+
const n = k.run(this, this._fn);
|
|
568
|
+
this._trackLinks.length = this._trackCount, ee(this._trackLinks, t, this), this._links = this._trackLinks, s = !0, Ie(n) ? this._handleAsyncComputation(n) : this._finalizeResolution(n);
|
|
569
|
+
} catch (n) {
|
|
570
|
+
if (!s)
|
|
611
571
|
try {
|
|
612
|
-
this._trackLinks.length = this._trackCount,
|
|
572
|
+
this._trackLinks.length = this._trackCount, ee(this._trackLinks, t, this), this._links = this._trackLinks, s = !0;
|
|
613
573
|
} catch {
|
|
614
574
|
}
|
|
615
|
-
this._handleError(
|
|
575
|
+
this._handleError(n, y.COMPUTED_COMPUTATION_FAILED, !0);
|
|
616
576
|
} finally {
|
|
617
|
-
|
|
577
|
+
s && t !== O ? B.release(t) : s || B.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = O, this._trackCount = 0, this.flags &= ~st;
|
|
618
578
|
}
|
|
619
579
|
}
|
|
620
580
|
_handleAsyncComputation(t) {
|
|
621
|
-
this.flags = (this.flags |
|
|
622
|
-
const
|
|
581
|
+
this.flags = (this.flags | _t) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % te.MAX_PROMISE_ID;
|
|
582
|
+
const s = this._promiseId;
|
|
623
583
|
t.then(
|
|
624
|
-
(
|
|
625
|
-
if (
|
|
626
|
-
if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion)
|
|
627
|
-
|
|
628
|
-
|
|
584
|
+
(n) => {
|
|
585
|
+
if (s === this._promiseId) {
|
|
586
|
+
if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion) {
|
|
587
|
+
const i = me();
|
|
588
|
+
return this._lastDriftEpoch !== i && (this._lastDriftEpoch = i, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(
|
|
589
|
+
new z(
|
|
629
590
|
`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`
|
|
630
591
|
),
|
|
631
|
-
|
|
592
|
+
y.COMPUTED_ASYNC_COMPUTATION_FAILED
|
|
632
593
|
);
|
|
633
|
-
|
|
594
|
+
}
|
|
595
|
+
this._finalizeResolution(n), this._notifySubscribers(n, void 0);
|
|
634
596
|
}
|
|
635
597
|
},
|
|
636
|
-
(
|
|
598
|
+
(n) => s === this._promiseId && this._handleError(n, y.COMPUTED_ASYNC_COMPUTATION_FAILED)
|
|
637
599
|
);
|
|
638
600
|
}
|
|
639
601
|
_captureVersionSnapshot() {
|
|
640
602
|
let t = 0;
|
|
641
|
-
const
|
|
642
|
-
for (let
|
|
643
|
-
t = (t << 5) - t + n
|
|
603
|
+
const s = this._links;
|
|
604
|
+
for (let n = 0, i = s.length; n < i; n++)
|
|
605
|
+
t = (t << 5) - t + s[n].node.version | 0;
|
|
644
606
|
return t;
|
|
645
607
|
}
|
|
646
|
-
_handleError(t,
|
|
647
|
-
const i =
|
|
648
|
-
if (!
|
|
608
|
+
_handleError(t, s, n = !1) {
|
|
609
|
+
const i = Z(t, z, s);
|
|
610
|
+
if (!n && !(this.flags & nt) && (this.version = $t(this.version)), this._error = i, this.flags = this.flags & -121 | nt | ft, this._onError)
|
|
649
611
|
try {
|
|
650
612
|
this._onError(i);
|
|
651
|
-
} catch (
|
|
652
|
-
console.error(
|
|
613
|
+
} catch (r) {
|
|
614
|
+
console.error(y.CALLBACK_ERROR_IN_ERROR_HANDLER, r);
|
|
653
615
|
}
|
|
654
|
-
if (
|
|
616
|
+
if (n) throw i;
|
|
655
617
|
this._notifySubscribers(void 0, void 0);
|
|
656
618
|
}
|
|
657
619
|
_finalizeResolution(t) {
|
|
658
|
-
(!(this.flags &
|
|
620
|
+
(!(this.flags & V) || !this._equal(this._value, t)) && (this.version = $t(this.version)), this._value = t, this._error = null, this.flags = (this.flags | V) & -697;
|
|
659
621
|
}
|
|
660
622
|
execute() {
|
|
661
623
|
this._markDirty();
|
|
662
624
|
}
|
|
663
625
|
/** @internal */
|
|
664
626
|
_markDirty() {
|
|
665
|
-
this.flags & (
|
|
627
|
+
this.flags & (st | K) || (this.flags |= K, this._notifySubscribers(void 0, void 0));
|
|
666
628
|
}
|
|
667
629
|
}
|
|
668
|
-
function
|
|
669
|
-
return new
|
|
630
|
+
function Ct(e, t = {}) {
|
|
631
|
+
return new Qe(e, t);
|
|
670
632
|
}
|
|
671
|
-
var
|
|
672
|
-
class
|
|
673
|
-
constructor(t,
|
|
674
|
-
super(), this[
|
|
633
|
+
var ce;
|
|
634
|
+
class Ke extends _e {
|
|
635
|
+
constructor(t, s = {}) {
|
|
636
|
+
super(), this[ce] = !0, this._cleanup = null, this._links = O, this._nextLinks = null, this._prevLinks = O, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._fn = t, this._onError = s.onError ?? null, this._sync = s.sync ?? !1, this._maxExecutions = s.maxExecutionsPerSecond ?? q.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = s.maxExecutionsPerFlush ?? q.MAX_EXECUTIONS_PER_EFFECT, this._sync ? (this._executeTask = void 0, this._notifyCallback = () => this.execute()) : (this._executeTask = () => this.execute(), this._notifyCallback = () => rt.schedule(this._executeTask)), yt.attachDebugInfo(this, "effect", this.id);
|
|
675
637
|
}
|
|
676
638
|
run() {
|
|
677
|
-
if (this.flags &
|
|
678
|
-
throw new
|
|
639
|
+
if (this.flags & L.DISPOSED)
|
|
640
|
+
throw new J(y.EFFECT_DISPOSED);
|
|
679
641
|
this.execute(!0);
|
|
680
642
|
}
|
|
681
643
|
dispose() {
|
|
682
|
-
this.flags &
|
|
644
|
+
this.flags & L.DISPOSED || (this.flags |= L.DISPOSED, this._execCleanup(), this._unsubLinks(this._links), this._links !== O && B.release(this._links), this._links = O, this._prevLinks = O);
|
|
683
645
|
}
|
|
684
|
-
[(
|
|
646
|
+
[(ce = Ge, Symbol.dispose)]() {
|
|
685
647
|
this.dispose();
|
|
686
648
|
}
|
|
687
649
|
addDependency(t) {
|
|
688
|
-
if (!(this.flags &
|
|
689
|
-
const
|
|
690
|
-
if (t._lastSeenEpoch ===
|
|
691
|
-
t._lastSeenEpoch =
|
|
692
|
-
const
|
|
693
|
-
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
return;
|
|
698
|
-
}
|
|
650
|
+
if (!(this.flags & L.EXECUTING)) return;
|
|
651
|
+
const s = this._currentEpoch;
|
|
652
|
+
if (t._lastSeenEpoch === s) return;
|
|
653
|
+
t._lastSeenEpoch = s;
|
|
654
|
+
const n = this._nextLinks, i = this._prevLinks, r = i.findIndex((o) => o && o.node === t && o.unsub);
|
|
655
|
+
if (r !== -1) {
|
|
656
|
+
const o = i[r];
|
|
657
|
+
o.version = t.version, n.push(o), i[r] = null;
|
|
658
|
+
return;
|
|
699
659
|
}
|
|
700
660
|
try {
|
|
701
661
|
const o = t.subscribe(this._notifyCallback);
|
|
702
|
-
|
|
662
|
+
n.push(new Pt(t, t.version, o));
|
|
703
663
|
} catch (o) {
|
|
704
|
-
const
|
|
705
|
-
if (console.error(
|
|
664
|
+
const l = Z(o, J, y.EFFECT_EXECUTION_FAILED);
|
|
665
|
+
if (console.error(l), this._onError)
|
|
706
666
|
try {
|
|
707
|
-
this._onError(
|
|
667
|
+
this._onError(l);
|
|
708
668
|
} catch {
|
|
709
669
|
}
|
|
710
|
-
|
|
670
|
+
n.push(new Pt(t, t.version, void 0));
|
|
711
671
|
}
|
|
712
672
|
}
|
|
713
673
|
/**
|
|
714
674
|
* Executes effect with tracking.
|
|
715
675
|
*/
|
|
716
676
|
execute(t = !1) {
|
|
717
|
-
if (this.flags & (
|
|
718
|
-
this._checkInfiniteLoops(), this.flags |=
|
|
719
|
-
const
|
|
720
|
-
this._nextLinks =
|
|
721
|
-
let
|
|
677
|
+
if (this.flags & (L.DISPOSED | L.EXECUTING) || !t && this._links.length > 0 && !this._isDirty()) return;
|
|
678
|
+
this._checkInfiniteLoops(), this.flags |= L.EXECUTING, this._execCleanup(), this._prevLinks = this._links;
|
|
679
|
+
const s = B.acquire();
|
|
680
|
+
this._nextLinks = s, this._currentEpoch = jt();
|
|
681
|
+
let n = !1;
|
|
722
682
|
try {
|
|
723
|
-
const i =
|
|
724
|
-
this._links =
|
|
683
|
+
const i = k.run(this, this._fn);
|
|
684
|
+
this._links = s, n = !0, Ie(i) ? this._handleAsyncResult(i) : this._cleanup = typeof i == "function" ? i : null;
|
|
725
685
|
} catch (i) {
|
|
726
|
-
this._links =
|
|
686
|
+
this._links = s, n = !0, this._handleExecutionError(i), this._cleanup = null;
|
|
727
687
|
} finally {
|
|
728
|
-
this._finalizeDependencies(
|
|
688
|
+
this._finalizeDependencies(n, this._prevLinks, s), this.flags &= -9;
|
|
729
689
|
}
|
|
730
690
|
}
|
|
731
691
|
_handleAsyncResult(t) {
|
|
732
|
-
const
|
|
692
|
+
const s = ++this._execId;
|
|
733
693
|
t.then(
|
|
734
|
-
(
|
|
735
|
-
if (
|
|
736
|
-
if (typeof
|
|
694
|
+
(n) => {
|
|
695
|
+
if (s !== this._execId || this.flags & L.DISPOSED) {
|
|
696
|
+
if (typeof n == "function")
|
|
737
697
|
try {
|
|
738
|
-
|
|
698
|
+
n();
|
|
739
699
|
} catch (i) {
|
|
740
|
-
this._handleExecutionError(i,
|
|
700
|
+
this._handleExecutionError(i, y.EFFECT_CLEANUP_FAILED);
|
|
741
701
|
}
|
|
742
702
|
return;
|
|
743
703
|
}
|
|
744
|
-
typeof
|
|
704
|
+
typeof n == "function" && (this._cleanup = n);
|
|
745
705
|
},
|
|
746
|
-
(
|
|
706
|
+
(n) => s === this._execId && this._handleExecutionError(n)
|
|
747
707
|
);
|
|
748
708
|
}
|
|
749
|
-
_finalizeDependencies(t,
|
|
750
|
-
|
|
751
|
-
for (let i = 0, o = n.length; i < o; i++) {
|
|
752
|
-
const r = n[i];
|
|
753
|
-
r && r.unsub?.();
|
|
754
|
-
}
|
|
755
|
-
n !== x && q.release(n);
|
|
756
|
-
} else
|
|
757
|
-
this._unsubLinks(s), q.release(s);
|
|
709
|
+
_finalizeDependencies(t, s, n) {
|
|
710
|
+
this._nextLinks = null, this._prevLinks = O, t ? (s.forEach((i) => i?.unsub?.()), s !== O && B.release(s)) : (this._unsubLinks(n), B.release(n));
|
|
758
711
|
}
|
|
759
712
|
_unsubLinks(t) {
|
|
760
|
-
|
|
761
|
-
t[n]?.unsub?.();
|
|
713
|
+
t.forEach((s) => s?.unsub?.());
|
|
762
714
|
}
|
|
763
715
|
_isDirty() {
|
|
764
|
-
const t = this._links,
|
|
765
|
-
|
|
716
|
+
const t = this._links, s = k.current;
|
|
717
|
+
k.current = null;
|
|
766
718
|
try {
|
|
767
|
-
|
|
768
|
-
const
|
|
769
|
-
if (
|
|
719
|
+
return t.some((n) => {
|
|
720
|
+
const i = n.node;
|
|
721
|
+
if (i.flags & fe.IS_COMPUTED)
|
|
770
722
|
try {
|
|
771
|
-
|
|
723
|
+
i.value;
|
|
772
724
|
} catch {
|
|
773
725
|
return !0;
|
|
774
726
|
}
|
|
775
|
-
|
|
776
|
-
}
|
|
777
|
-
return !1;
|
|
727
|
+
return i.version !== n.version;
|
|
728
|
+
});
|
|
778
729
|
} finally {
|
|
779
|
-
|
|
730
|
+
k.current = s;
|
|
780
731
|
}
|
|
781
732
|
}
|
|
782
733
|
_execCleanup() {
|
|
@@ -784,90 +735,116 @@ class ze extends ue {
|
|
|
784
735
|
try {
|
|
785
736
|
this._cleanup();
|
|
786
737
|
} catch (t) {
|
|
787
|
-
this._handleExecutionError(t,
|
|
738
|
+
this._handleExecutionError(t, y.EFFECT_CLEANUP_FAILED);
|
|
788
739
|
}
|
|
789
740
|
this._cleanup = null;
|
|
790
741
|
}
|
|
791
742
|
}
|
|
792
743
|
_checkInfiniteLoops() {
|
|
793
|
-
const t =
|
|
794
|
-
this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
744
|
+
const t = me();
|
|
745
|
+
this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), Be() > q.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
|
|
795
746
|
}
|
|
796
747
|
get isDisposed() {
|
|
797
|
-
return (this.flags &
|
|
748
|
+
return (this.flags & L.DISPOSED) !== 0;
|
|
798
749
|
}
|
|
799
750
|
get executionCount() {
|
|
800
751
|
return this._executionCount;
|
|
801
752
|
}
|
|
802
753
|
get isExecuting() {
|
|
803
|
-
return (this.flags &
|
|
754
|
+
return (this.flags & L.EXECUTING) !== 0;
|
|
804
755
|
}
|
|
805
756
|
_throwInfiniteLoopError(t) {
|
|
806
|
-
const
|
|
807
|
-
`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${
|
|
757
|
+
const s = new J(
|
|
758
|
+
`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${zt}`
|
|
808
759
|
);
|
|
809
|
-
throw this.dispose(), console.error(
|
|
760
|
+
throw this.dispose(), console.error(s), s;
|
|
810
761
|
}
|
|
811
|
-
_handleExecutionError(t,
|
|
812
|
-
const
|
|
813
|
-
if (console.error(
|
|
762
|
+
_handleExecutionError(t, s = y.EFFECT_EXECUTION_FAILED) {
|
|
763
|
+
const n = Z(t, J, s);
|
|
764
|
+
if (console.error(n), this._onError)
|
|
814
765
|
try {
|
|
815
|
-
this._onError(
|
|
766
|
+
this._onError(n);
|
|
816
767
|
} catch (i) {
|
|
817
|
-
console.error(
|
|
768
|
+
console.error(Z(i, J, y.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
818
769
|
}
|
|
819
770
|
}
|
|
820
771
|
}
|
|
821
|
-
function
|
|
772
|
+
function X(e, t = {}) {
|
|
822
773
|
if (typeof e != "function")
|
|
823
|
-
throw new
|
|
824
|
-
const
|
|
825
|
-
return
|
|
774
|
+
throw new J(y.EFFECT_MUST_BE_FUNCTION);
|
|
775
|
+
const s = new Ke(e, t);
|
|
776
|
+
return s.execute(), s;
|
|
826
777
|
}
|
|
827
|
-
function
|
|
778
|
+
function ye(e) {
|
|
828
779
|
if (typeof e != "function")
|
|
829
780
|
throw new TypeError("Batch callback must be a function");
|
|
830
|
-
|
|
781
|
+
rt.startBatch();
|
|
831
782
|
try {
|
|
832
783
|
return e();
|
|
833
784
|
} finally {
|
|
834
|
-
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
function pe(e) {
|
|
838
|
-
return de(e) || _e(e);
|
|
839
|
-
}
|
|
840
|
-
function Rt(e) {
|
|
841
|
-
if (!e) return "unknown";
|
|
842
|
-
const t = "jquery" in e ? e[0] : e;
|
|
843
|
-
if (!t) return "unknown";
|
|
844
|
-
const n = t.id;
|
|
845
|
-
if (n && typeof n == "string") return `#${n}`;
|
|
846
|
-
const s = t.tagName.toLowerCase(), i = t.classList;
|
|
847
|
-
if (i && i.length > 0) {
|
|
848
|
-
let o = s;
|
|
849
|
-
for (let r = 0, c = i.length; r < c; r++) {
|
|
850
|
-
const a = i[r];
|
|
851
|
-
a && (o += `.${a}`);
|
|
852
|
-
}
|
|
853
|
-
return o;
|
|
785
|
+
rt.endBatch();
|
|
854
786
|
}
|
|
855
|
-
return s;
|
|
856
787
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
788
|
+
const d = {
|
|
789
|
+
/** Used by the SPA router ($.route). */
|
|
790
|
+
ROUTE: "[atom-route]",
|
|
791
|
+
/** Used by all reactive binding helpers (bindText, bindCss, bindAttr, …). */
|
|
792
|
+
BINDING: "[atom-binding]",
|
|
793
|
+
/** Used by atomList reactive list rendering. */
|
|
794
|
+
LIST: "[atom-list]",
|
|
795
|
+
/** Used by mount/unmount lifecycle helpers. */
|
|
796
|
+
MOUNT: "[atom-mount]"
|
|
797
|
+
}, dt = Object.freeze({
|
|
798
|
+
mode: "hash",
|
|
799
|
+
basePath: "",
|
|
800
|
+
autoBindLinks: !1,
|
|
801
|
+
activeClass: "active"
|
|
802
|
+
}), Ye = {
|
|
803
|
+
EVENT: "input"
|
|
804
|
+
}, We = /* @__PURE__ */ new Set(["input", "select", "textarea"]), Je = /* @__PURE__ */ new Set([
|
|
805
|
+
"innerHTML",
|
|
806
|
+
"outerHTML",
|
|
807
|
+
"srcdoc",
|
|
808
|
+
"__proto__",
|
|
809
|
+
"constructor",
|
|
810
|
+
"prototype"
|
|
811
|
+
]), S = {
|
|
812
|
+
ROUTE_NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
|
|
813
|
+
TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
|
|
814
|
+
TARGET_NOT_FOUND: (e) => `Target element "${e}" not found`,
|
|
815
|
+
MALFORMED_URI: (e) => `Malformed URI component: ${e}`,
|
|
816
|
+
/** Emitted when sanitizeHtml modifies the input. Prefixed at call site with LOG_PREFIXES.BINDING or LIST to identify the originating subsystem. */
|
|
817
|
+
UNSAFE_CONTENT: () => "Unsafe content neutralized during sanitization.",
|
|
818
|
+
/** Emitted by bindCss when a CSS style property value contains a dangerous protocol. */
|
|
819
|
+
BLOCKED_DANGEROUS_CSS_VALUE: (e) => `Blocked dangerous value in CSS style property "${e}".`,
|
|
820
|
+
BLOCKED_EVENT_HANDLER: (e) => `Blocked setting dangerous event handler attribute "${e}".`,
|
|
821
|
+
BLOCKED_PROTOCOL: (e) => `Blocked dangerous protocol in "${e}" attribute.`,
|
|
822
|
+
BLOCKED_DANGEROUS_PROP: (e) => `Blocked setting dangerous property "${e}". Use html binding for sanitized HTML.`,
|
|
823
|
+
INVALID_INPUT_ELEMENT: (e) => `Val binding used on non-input element <${e}>.`,
|
|
824
|
+
MISSING_SOURCE: (e) => `[${e}] source is required when prop/name is a string.`,
|
|
825
|
+
MISSING_CONDITION: (e) => `[${e}] condition is required when className is a string.`,
|
|
826
|
+
DUPLICATE_KEY: (e, t) => `Duplicate key "${e}" at index ${t}.`,
|
|
827
|
+
UPDATER_ERROR: (e) => `Updater threw in binding "${e}"`,
|
|
828
|
+
EFFECT_DISPOSE_ERROR: () => "Effect dispose error",
|
|
829
|
+
BINDING_CLEANUP_ERROR: () => "Binding cleanup error",
|
|
830
|
+
PARSE_ERROR: () => "parse() threw during DOM→Atom sync",
|
|
831
|
+
MOUNT_ERROR: () => "Mount error",
|
|
832
|
+
MOUNT_CLEANUP_ERROR: () => "Cleanup error"
|
|
833
|
+
};
|
|
834
|
+
function Ce(e) {
|
|
835
|
+
return qt(e);
|
|
836
|
+
}
|
|
837
|
+
function Xt(e) {
|
|
838
|
+
const t = e.tagName.toLowerCase();
|
|
839
|
+
if (e.id) return `${t}#${e.id}`;
|
|
840
|
+
const s = e.classList, n = s.length;
|
|
841
|
+
if (n === 0) return t;
|
|
842
|
+
let i = t;
|
|
843
|
+
for (let r = 0; r < n; r++)
|
|
844
|
+
i += `.${s[r]}`;
|
|
845
|
+
return i;
|
|
869
846
|
}
|
|
870
|
-
const
|
|
847
|
+
const Ze = /* @__PURE__ */ new Set([
|
|
871
848
|
"href",
|
|
872
849
|
"src",
|
|
873
850
|
"action",
|
|
@@ -883,167 +860,208 @@ const qe = /* @__PURE__ */ new Set([
|
|
|
883
860
|
"usemap",
|
|
884
861
|
"classid",
|
|
885
862
|
"codebase"
|
|
886
|
-
]),
|
|
887
|
-
|
|
888
|
-
|
|
863
|
+
]), ts = Object.prototype.hasOwnProperty, es = /^\s*(?:javascript|vbscript)\s*:/i, ss = (
|
|
864
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: Intentionally matching control characters for XSS sanitization
|
|
865
|
+
/(?:expression\s*\(|behavior\s*:|(?:\\[0-9a-f]{1,6}\s*|[\s\x00-\x20/'"])*(?: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|d\s*a\s*t\s*a)\s*:(?!image\/))/i
|
|
866
|
+
), ns = /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i, is = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, rs = /<\?[\s\S]*?\?>/g, os = /(<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*\/?>)/gi, cs = /(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*:/gi, as = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, hs = /\bon\w+\s*=/gim, us = new RegExp(ss.source, "gim");
|
|
867
|
+
function Bt(e) {
|
|
868
|
+
let t = String(e ?? "");
|
|
869
|
+
t = t.replace(is, ""), t = t.replace(rs, "");
|
|
870
|
+
let s;
|
|
871
|
+
do
|
|
872
|
+
s = t, t = t.replace(os, "");
|
|
873
|
+
while (t !== s);
|
|
874
|
+
return t = t.replace(cs, "data-unsafe-protocol:"), t = t.replace(as, "data-unsafe-protocol:"), t = t.replace(hs, "data-unsafe-attr="), t = t.replace(us, "data-unsafe-css:"), t;
|
|
875
|
+
}
|
|
876
|
+
function ls(e, t) {
|
|
877
|
+
return Ze.has(e.toLowerCase()) ? es.test(t) : !1;
|
|
889
878
|
}
|
|
890
|
-
function
|
|
891
|
-
return e.toLowerCase().includes("url(") ?
|
|
879
|
+
function fs(e) {
|
|
880
|
+
return e.toLowerCase().includes("url(") ? ns.test(e) : !1;
|
|
892
881
|
}
|
|
893
|
-
function
|
|
882
|
+
function ds(e, t) {
|
|
894
883
|
if (e === t) return !0;
|
|
895
|
-
if (
|
|
896
|
-
const
|
|
897
|
-
if (
|
|
898
|
-
const i = t;
|
|
899
|
-
for (let o = 0; o <
|
|
900
|
-
const
|
|
901
|
-
if (
|
|
884
|
+
if (e === null || t === null || typeof e != "object" || typeof t != "object") return !1;
|
|
885
|
+
const s = Object.keys(e), n = Object.keys(t);
|
|
886
|
+
if (s.length !== n.length) return !1;
|
|
887
|
+
const i = e, r = t;
|
|
888
|
+
for (let o = 0; o < s.length; o++) {
|
|
889
|
+
const l = s[o];
|
|
890
|
+
if (!ts.call(r, l) || i[l] !== r[l])
|
|
891
|
+
return !1;
|
|
902
892
|
}
|
|
903
893
|
return !0;
|
|
904
894
|
}
|
|
905
|
-
function
|
|
895
|
+
function _s(e) {
|
|
906
896
|
const t = e.length;
|
|
907
897
|
if (t === 0) return new Int32Array(0);
|
|
908
|
-
const
|
|
898
|
+
const s = new Int32Array(t).fill(-1), n = new Int32Array(t);
|
|
909
899
|
let i = 0;
|
|
910
|
-
for (let
|
|
911
|
-
const
|
|
912
|
-
if (
|
|
913
|
-
const
|
|
914
|
-
if (i === 0 ||
|
|
915
|
-
|
|
900
|
+
for (let o = 0; o < t; o++) {
|
|
901
|
+
const l = e[o];
|
|
902
|
+
if (l === void 0 || l === -1) continue;
|
|
903
|
+
const p = i > 0 ? n[i - 1] : void 0;
|
|
904
|
+
if (i === 0 || p !== void 0 && (e[p] ?? -1) < l) {
|
|
905
|
+
s[o] = p ?? -1, n[i++] = o;
|
|
916
906
|
continue;
|
|
917
907
|
}
|
|
918
|
-
let
|
|
919
|
-
for (;
|
|
920
|
-
const
|
|
921
|
-
|
|
908
|
+
let C = 0, b = i - 1;
|
|
909
|
+
for (; C < b; ) {
|
|
910
|
+
const E = C + b >>> 1, m = n[E];
|
|
911
|
+
m !== void 0 && (e[m] ?? -1) < l ? C = E + 1 : b = E;
|
|
922
912
|
}
|
|
923
|
-
const
|
|
924
|
-
|
|
913
|
+
const N = n[C];
|
|
914
|
+
N !== void 0 && l < (e[N] ?? Number.MAX_SAFE_INTEGER) && (C > 0 && (s[o] = n[C - 1] ?? -1), n[C] = o);
|
|
925
915
|
}
|
|
926
|
-
const
|
|
916
|
+
const r = new Int32Array(i);
|
|
927
917
|
if (i > 0) {
|
|
928
|
-
let
|
|
929
|
-
for (let
|
|
930
|
-
|
|
918
|
+
let o = n[i - 1];
|
|
919
|
+
for (let l = i - 1; l >= 0 && o !== void 0 && o !== -1; l--)
|
|
920
|
+
r[l] = o, o = s[o];
|
|
931
921
|
}
|
|
932
|
-
return
|
|
922
|
+
return r;
|
|
933
923
|
}
|
|
934
|
-
|
|
924
|
+
const Es = {}, be = 600, ps = `${be / 1e3}s`;
|
|
925
|
+
function ms() {
|
|
935
926
|
if (typeof window < "u") {
|
|
936
927
|
const e = window.__ATOM_DEBUG__;
|
|
937
928
|
if (typeof e == "boolean") return e;
|
|
938
929
|
}
|
|
939
|
-
return
|
|
930
|
+
return Es?.VITE_ATOM_DEBUG === "true";
|
|
940
931
|
}
|
|
941
|
-
let
|
|
942
|
-
const
|
|
932
|
+
let Y = ms();
|
|
933
|
+
const f = {
|
|
943
934
|
get enabled() {
|
|
944
|
-
return
|
|
935
|
+
return Y;
|
|
945
936
|
},
|
|
946
937
|
set enabled(e) {
|
|
947
|
-
|
|
938
|
+
Y = e;
|
|
948
939
|
},
|
|
940
|
+
/**
|
|
941
|
+
* Logs a message only when debug mode is active.
|
|
942
|
+
*/
|
|
949
943
|
log(e, ...t) {
|
|
950
|
-
|
|
944
|
+
Y && console.log(`${d.MOUNT} ${e}:`, ...t);
|
|
951
945
|
},
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
946
|
+
/**
|
|
947
|
+
* Logs an atom value change only when debug mode is active.
|
|
948
|
+
*/
|
|
949
|
+
atomChanged(e, t, s) {
|
|
950
|
+
Y && console.log(
|
|
951
|
+
`${d.MOUNT} Atom "${e ?? "anonymous"}" changed:`,
|
|
955
952
|
t,
|
|
956
953
|
"→",
|
|
957
|
-
|
|
954
|
+
s
|
|
958
955
|
);
|
|
959
956
|
},
|
|
960
957
|
/**
|
|
961
|
-
* Logs DOM
|
|
958
|
+
* Logs a DOM update and triggers a visual highlight flash.
|
|
959
|
+
* Only active when debug mode is enabled.
|
|
960
|
+
*
|
|
961
|
+
* @param target - The element or jQuery wrapper that was updated.
|
|
962
|
+
* @param type - The binding type (e.g. 'text', 'checked', 'attr.href').
|
|
963
|
+
* @param value - The new value that was applied.
|
|
962
964
|
*/
|
|
963
|
-
domUpdated(e, t,
|
|
964
|
-
|
|
965
|
+
domUpdated(e, t, s) {
|
|
966
|
+
if (!Y) return;
|
|
967
|
+
const n = e instanceof Element ? e : e[0];
|
|
968
|
+
n instanceof HTMLElement && (console.log(`${d.MOUNT} DOM updated: ${Xt(n)}.${t} =`, s), ys(n));
|
|
965
969
|
},
|
|
970
|
+
/**
|
|
971
|
+
* Logs a cleanup event only when debug mode is active.
|
|
972
|
+
*/
|
|
966
973
|
cleanup(e) {
|
|
967
|
-
|
|
974
|
+
Y && console.log(`${d.MOUNT} Cleanup: ${e}`);
|
|
975
|
+
},
|
|
976
|
+
/**
|
|
977
|
+
* Unconditional warning for runtime errors and unexpected states.
|
|
978
|
+
* Not gated by debugEnabled — these are always surfaced regardless of
|
|
979
|
+
* debug mode because they indicate real problems (e.g. dispose failures,
|
|
980
|
+
* missing route targets, pushState security errors).
|
|
981
|
+
*
|
|
982
|
+
* `prefix` is the subsystem tag (e.g. `LOG_PREFIXES.ROUTE`) so that the
|
|
983
|
+
* originating subsystem appears in the log rather than the generic MOUNT tag.
|
|
984
|
+
* Pass an empty string to emit a prefix-free message.
|
|
985
|
+
*/
|
|
986
|
+
warn(e, t, ...s) {
|
|
987
|
+
console.warn(`${e} ${t}`, ...s);
|
|
968
988
|
},
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
989
|
+
/**
|
|
990
|
+
* Unconditional error for binding failures.
|
|
991
|
+
* Not gated by debugEnabled — binding errors are always surfaced because
|
|
992
|
+
* they indicate a broken updater that silently stopped applying values.
|
|
993
|
+
*/
|
|
994
|
+
error(e, t, s) {
|
|
995
|
+
console.error(`${e} ${t}`, s);
|
|
996
|
+
}
|
|
997
|
+
}, Ht = "atom-debug-highlight", gs = "data-atom-debug";
|
|
998
|
+
let ae;
|
|
999
|
+
function Is() {
|
|
1000
|
+
if (ae?.deref()?.isConnected) return;
|
|
977
1001
|
const e = document.createElement("style");
|
|
978
|
-
e.textContent = `.${Ht}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline
|
|
979
|
-
}
|
|
980
|
-
const Ft = /* @__PURE__ */ new WeakMap();
|
|
981
|
-
function Ze(e) {
|
|
982
|
-
const t = "jquery" in e ? e[0] : e;
|
|
983
|
-
if (!t || !t.isConnected) return;
|
|
984
|
-
Je();
|
|
985
|
-
const n = Ft.get(t);
|
|
986
|
-
n && clearTimeout(n), t.classList.add(Ht), Ft.set(
|
|
987
|
-
t,
|
|
988
|
-
setTimeout(() => {
|
|
989
|
-
t.classList.remove(Ht), Ft.delete(t);
|
|
990
|
-
}, 600)
|
|
991
|
-
);
|
|
1002
|
+
e.setAttribute(gs, ""), e.textContent = `.${Ht}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${ps} ease-out}`, document.head.appendChild(e), ae = new WeakRef(e);
|
|
992
1003
|
}
|
|
993
|
-
|
|
994
|
-
|
|
1004
|
+
const kt = /* @__PURE__ */ new WeakMap(), xt = /* @__PURE__ */ new WeakMap();
|
|
1005
|
+
function ys(e) {
|
|
1006
|
+
if (!e.isConnected) return;
|
|
1007
|
+
Is();
|
|
1008
|
+
const t = xt.get(e);
|
|
1009
|
+
t !== void 0 && cancelAnimationFrame(t);
|
|
1010
|
+
const s = kt.get(e);
|
|
1011
|
+
s !== void 0 && clearTimeout(s);
|
|
1012
|
+
const n = requestAnimationFrame(() => {
|
|
1013
|
+
xt.delete(e), e.classList.add(Ht), kt.set(
|
|
1014
|
+
e,
|
|
1015
|
+
setTimeout(() => {
|
|
1016
|
+
e.classList.remove(Ht), kt.delete(e);
|
|
1017
|
+
}, be)
|
|
1018
|
+
);
|
|
1019
|
+
});
|
|
1020
|
+
xt.set(e, n);
|
|
995
1021
|
}
|
|
996
|
-
|
|
1022
|
+
function Se(e, t) {
|
|
1023
|
+
return Ft(e, t);
|
|
1024
|
+
}
|
|
1025
|
+
Object.defineProperty(Se, "debug", {
|
|
1026
|
+
enumerable: !0,
|
|
1027
|
+
// configurable: true allows tests and advanced consumers to redefine or
|
|
1028
|
+
// delete the accessor if needed. The default (false) would permanently lock
|
|
1029
|
+
// the property on the function object.
|
|
1030
|
+
configurable: !0,
|
|
997
1031
|
get() {
|
|
998
|
-
return
|
|
1032
|
+
return f.enabled;
|
|
999
1033
|
},
|
|
1000
1034
|
set(e) {
|
|
1001
|
-
|
|
1035
|
+
f.enabled = e;
|
|
1002
1036
|
}
|
|
1003
1037
|
});
|
|
1004
|
-
function
|
|
1038
|
+
function Cs() {
|
|
1005
1039
|
return new Promise((e) => setTimeout(e, 0));
|
|
1006
1040
|
}
|
|
1007
|
-
|
|
1008
|
-
atom
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
BASE_PATH: "",
|
|
1026
|
-
AUTO_BIND_LINKS: !1
|
|
1027
|
-
}, nn = {
|
|
1028
|
-
EVENT: "input"
|
|
1029
|
-
}, sn = ["innerHTML", "outerHTML"], rt = {
|
|
1030
|
-
ROUTE_NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
|
|
1031
|
-
TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
|
|
1032
|
-
TARGET_NOT_FOUND: (e) => `Target element "${e}" not found`,
|
|
1033
|
-
MALFORMED_URI: (e) => `Malformed URI component: ${e}`,
|
|
1034
|
-
UNSAFE_CONTENT: "Unsafe content neutralized during sanitization.",
|
|
1035
|
-
BLOCKED_DANGEROUS_VALUE: (e) => `Blocked dangerous value in "${e}" property.`,
|
|
1036
|
-
BLOCKED_EVENT_HANDLER: (e) => `Blocked setting dangerous event handler attribute "${e}".`,
|
|
1037
|
-
BLOCKED_PROTOCOL: (e) => `Blocked dangerous protocol in "${e}" attribute.`,
|
|
1038
|
-
BLOCKED_DANGEROUS_PROP: (e) => `Blocked setting dangerous property "${e}". Use html binding for sanitized HTML.`,
|
|
1039
|
-
INVALID_INPUT_ELEMENT: (e) => `Val binding used on non-input element <${e}>.`,
|
|
1040
|
-
DUPLICATE_KEY: (e, t) => `Duplicate key "${e}" at index ${t}.`
|
|
1041
|
-
}, Tt = en;
|
|
1042
|
-
class on {
|
|
1041
|
+
const bs = {
|
|
1042
|
+
// `atom` carries a runtime `debug` accessor added via Object.defineProperty.
|
|
1043
|
+
// TypeScript cannot see it through the declared function type, so the double
|
|
1044
|
+
// cast is unavoidable. The NamespaceExtensions annotation still verifies all
|
|
1045
|
+
// other fields; only `atom`'s shape escapes static checking here.
|
|
1046
|
+
atom: Se,
|
|
1047
|
+
computed: Ct,
|
|
1048
|
+
effect: X,
|
|
1049
|
+
batch: ye,
|
|
1050
|
+
untracked: H,
|
|
1051
|
+
isAtom: qt,
|
|
1052
|
+
isComputed: Ve,
|
|
1053
|
+
isReactive: Ce,
|
|
1054
|
+
nextTick: Cs
|
|
1055
|
+
};
|
|
1056
|
+
c.extend(bs);
|
|
1057
|
+
const W = "_aes-bound";
|
|
1058
|
+
class Ss {
|
|
1043
1059
|
constructor() {
|
|
1044
|
-
this.records = /* @__PURE__ */ new WeakMap(), this.
|
|
1060
|
+
this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1045
1061
|
}
|
|
1046
|
-
//
|
|
1062
|
+
// --------------------------------------------------------------------------
|
|
1063
|
+
// Lifecycle flags
|
|
1064
|
+
// --------------------------------------------------------------------------
|
|
1047
1065
|
keep(t) {
|
|
1048
1066
|
this.preservedNodes.add(t);
|
|
1049
1067
|
}
|
|
@@ -1056,758 +1074,945 @@ class on {
|
|
|
1056
1074
|
isIgnored(t) {
|
|
1057
1075
|
return this.ignoredNodes.has(t);
|
|
1058
1076
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1077
|
+
// --------------------------------------------------------------------------
|
|
1078
|
+
// Tracking
|
|
1079
|
+
// --------------------------------------------------------------------------
|
|
1080
|
+
getOrCreateRecord(t) {
|
|
1081
|
+
let s = this.records.get(t);
|
|
1082
|
+
return s || (s = {}, this.records.set(t, s), t.classList.add(W)), s;
|
|
1083
|
+
}
|
|
1084
|
+
trackEffect(t, s) {
|
|
1085
|
+
const n = this.getOrCreateRecord(t);
|
|
1086
|
+
n.effects ??= [], n.effects.push(s);
|
|
1062
1087
|
}
|
|
1063
|
-
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1088
|
+
trackCleanup(t, s) {
|
|
1089
|
+
const n = this.getOrCreateRecord(t);
|
|
1090
|
+
n.cleanups ??= [], n.cleanups.push(s);
|
|
1066
1091
|
}
|
|
1067
|
-
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1092
|
+
setComponentCleanup(t, s) {
|
|
1093
|
+
const n = this.getOrCreateRecord(t);
|
|
1094
|
+
n.componentCleanup = s;
|
|
1070
1095
|
}
|
|
1071
1096
|
hasBind(t) {
|
|
1072
|
-
return this.
|
|
1097
|
+
return this.records.has(t);
|
|
1073
1098
|
}
|
|
1099
|
+
// --------------------------------------------------------------------------
|
|
1100
|
+
// Cleanup
|
|
1101
|
+
// --------------------------------------------------------------------------
|
|
1074
1102
|
cleanup(t) {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
if (s)
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1103
|
+
const s = this.records.get(t);
|
|
1104
|
+
if (!s) {
|
|
1105
|
+
t.isConnected && t.classList.remove(W), this.preservedNodes.delete(t), this.ignoredNodes.delete(t);
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
if (this.records.delete(t), this.preservedNodes.delete(t), this.ignoredNodes.delete(t), t.isConnected && t.classList.remove(W), f.enabled && f.cleanup(Xt(t)), s.componentCleanup)
|
|
1109
|
+
try {
|
|
1110
|
+
s.componentCleanup();
|
|
1111
|
+
} catch (n) {
|
|
1112
|
+
f.error(d.MOUNT, S.MOUNT_CLEANUP_ERROR(), n);
|
|
1113
|
+
}
|
|
1114
|
+
s.effects?.forEach((n) => {
|
|
1115
|
+
try {
|
|
1116
|
+
n.dispose();
|
|
1117
|
+
} catch (i) {
|
|
1118
|
+
f.error(d.BINDING, S.EFFECT_DISPOSE_ERROR(), i);
|
|
1119
|
+
}
|
|
1120
|
+
}), s.cleanups?.forEach((n) => {
|
|
1121
|
+
try {
|
|
1122
|
+
n();
|
|
1123
|
+
} catch (i) {
|
|
1124
|
+
f.error(d.BINDING, S.BINDING_CLEANUP_ERROR(), i);
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1095
1127
|
}
|
|
1096
1128
|
cleanupDescendants(t) {
|
|
1097
|
-
const
|
|
1098
|
-
for (
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1129
|
+
const s = t.querySelectorAll(`.${W}`);
|
|
1130
|
+
for (const n of s)
|
|
1131
|
+
this.records.has(n) ? this.cleanup(n) : (n.classList.remove(W), f.warn(
|
|
1132
|
+
d.BINDING,
|
|
1133
|
+
`${W} class found on unregistered element:`,
|
|
1134
|
+
n
|
|
1135
|
+
));
|
|
1102
1136
|
}
|
|
1103
1137
|
cleanupTree(t) {
|
|
1104
1138
|
this.cleanupDescendants(t), this.cleanup(t);
|
|
1105
1139
|
}
|
|
1106
1140
|
}
|
|
1107
|
-
const
|
|
1108
|
-
let
|
|
1109
|
-
function
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1141
|
+
const g = new Ss();
|
|
1142
|
+
let it = null, Et = null;
|
|
1143
|
+
function Rs(e) {
|
|
1144
|
+
if (it !== null) {
|
|
1145
|
+
Et !== e && f.warn(
|
|
1146
|
+
d.BINDING,
|
|
1147
|
+
"enableAutoCleanup() called with a different root while already active. Observation was NOT switched — call disableAutoCleanup() first.",
|
|
1148
|
+
{ current: Et, requested: e }
|
|
1149
|
+
);
|
|
1150
|
+
return;
|
|
1151
|
+
}
|
|
1152
|
+
Et = e, it = new MutationObserver((t) => {
|
|
1153
|
+
for (const s of t)
|
|
1154
|
+
for (const n of s.removedNodes)
|
|
1155
|
+
n.nodeType === 1 && (n.isConnected || g.isKept(n) || g.isIgnored(n) || g.cleanupTree(n));
|
|
1156
|
+
}), it.observe(e, { childList: !0, subtree: !0 });
|
|
1157
|
+
}
|
|
1158
|
+
function Gs() {
|
|
1159
|
+
it?.disconnect(), it = null, Et = null;
|
|
1160
|
+
}
|
|
1161
|
+
function Q(e, t, s, n) {
|
|
1162
|
+
if (Ce(t)) {
|
|
1163
|
+
const i = t;
|
|
1164
|
+
g.trackEffect(
|
|
1165
|
+
e,
|
|
1166
|
+
X(() => {
|
|
1167
|
+
const r = i.value;
|
|
1168
|
+
H(() => {
|
|
1169
|
+
try {
|
|
1170
|
+
s(r);
|
|
1171
|
+
} catch (o) {
|
|
1172
|
+
f.error(d.BINDING, `${S.UPDATER_ERROR(n)}:`, o);
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
f.enabled && f.domUpdated(e, n, r);
|
|
1176
|
+
});
|
|
1177
|
+
})
|
|
1178
|
+
);
|
|
1179
|
+
} else {
|
|
1180
|
+
try {
|
|
1181
|
+
s(t);
|
|
1182
|
+
} catch (i) {
|
|
1183
|
+
f.error(d.BINDING, `${S.UPDATER_ERROR(n)} (static):`, i);
|
|
1184
|
+
return;
|
|
1120
1185
|
}
|
|
1121
|
-
|
|
1122
|
-
}
|
|
1123
|
-
function En() {
|
|
1124
|
-
dt?.disconnect(), dt = null;
|
|
1125
|
-
}
|
|
1126
|
-
function X(e, t, n, s) {
|
|
1127
|
-
pe(t) ? b.trackEffect(
|
|
1128
|
-
e,
|
|
1129
|
-
J(() => {
|
|
1130
|
-
const i = t.value;
|
|
1131
|
-
n(i), E.domUpdated(l(e), s, i);
|
|
1132
|
-
})
|
|
1133
|
-
) : (n(t), E.enabled && E.domUpdated(l(e), s, t));
|
|
1134
|
-
}
|
|
1135
|
-
var L = /* @__PURE__ */ ((e) => (e[e.None = 0] = "None", e[e.Focused = 1] = "Focused", e[e.Composing = 2] = "Composing", e[e.SyncingToAtom = 4] = "SyncingToAtom", e[e.SyncingToDom = 8] = "SyncingToDom", e[e.Busy = 14] = "Busy", e))(L || {});
|
|
1136
|
-
function me() {
|
|
1137
|
-
return {
|
|
1138
|
-
timeoutId: null,
|
|
1139
|
-
flags: 0
|
|
1140
|
-
/* None */
|
|
1141
|
-
};
|
|
1186
|
+
f.enabled && f.domUpdated(e, n, t);
|
|
1187
|
+
}
|
|
1142
1188
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1189
|
+
const F = /* @__PURE__ */ Symbol("atom-effect-internal"), mt = /* @__PURE__ */ new WeakMap();
|
|
1190
|
+
let w = null;
|
|
1191
|
+
const Re = (e) => {
|
|
1192
|
+
if (e[F]) return e;
|
|
1193
|
+
let t = mt.get(e);
|
|
1194
|
+
return t || (t = function(...s) {
|
|
1195
|
+
return ye(() => e.apply(this, s));
|
|
1196
|
+
}, t[F] = !0, mt.set(e, t)), t;
|
|
1197
|
+
};
|
|
1198
|
+
function Ts(e) {
|
|
1199
|
+
const t = {};
|
|
1200
|
+
return Object.keys(e).forEach((s) => {
|
|
1201
|
+
const n = e[s];
|
|
1202
|
+
n && (t[s] = Re(n));
|
|
1203
|
+
}), t;
|
|
1204
|
+
}
|
|
1205
|
+
function Os(e) {
|
|
1206
|
+
const t = {};
|
|
1207
|
+
return Object.keys(e).forEach((s) => {
|
|
1208
|
+
const n = e[s];
|
|
1209
|
+
t[s] = n ? mt.get(n) ?? n : void 0;
|
|
1210
|
+
}), t;
|
|
1211
|
+
}
|
|
1212
|
+
function Ns() {
|
|
1213
|
+
if (w !== null) return;
|
|
1214
|
+
w = {
|
|
1215
|
+
on: c.fn.on,
|
|
1216
|
+
off: c.fn.off,
|
|
1217
|
+
remove: c.fn.remove,
|
|
1218
|
+
empty: c.fn.empty,
|
|
1219
|
+
detach: c.fn.detach
|
|
1220
|
+
};
|
|
1221
|
+
const e = w;
|
|
1222
|
+
c.fn.remove = function(t) {
|
|
1223
|
+
const s = t ? this.filter(t) : this;
|
|
1224
|
+
for (let n = 0, i = s.length; n < i; n++) {
|
|
1225
|
+
const r = s[n];
|
|
1226
|
+
r && (g.markIgnored(r), g.cleanupTree(r));
|
|
1159
1227
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1228
|
+
return e.remove.call(this, t);
|
|
1229
|
+
}, c.fn.empty = function() {
|
|
1230
|
+
for (let t = 0, s = this.length; t < s; t++) {
|
|
1231
|
+
const n = this[t];
|
|
1232
|
+
n && g.cleanupDescendants(n);
|
|
1233
|
+
}
|
|
1234
|
+
return e.empty.call(this);
|
|
1235
|
+
}, c.fn.detach = function(t) {
|
|
1236
|
+
const s = t ? this.filter(t) : this;
|
|
1237
|
+
for (let n = 0, i = s.length; n < i; n++) {
|
|
1238
|
+
const r = s[n];
|
|
1239
|
+
r && g.keep(r);
|
|
1240
|
+
}
|
|
1241
|
+
return e.detach.call(this, t);
|
|
1242
|
+
}, c.fn.on = function(...t) {
|
|
1243
|
+
const s = t[0];
|
|
1244
|
+
if (s && typeof s == "object")
|
|
1245
|
+
t[0] = Ts(s);
|
|
1246
|
+
else
|
|
1247
|
+
for (let n = t.length - 1; n >= 0; n--)
|
|
1248
|
+
if (typeof t[n] == "function") {
|
|
1249
|
+
t[n] = Re(t[n]);
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
return e.on.apply(this, t);
|
|
1253
|
+
}, c.fn.off = function(...t) {
|
|
1254
|
+
const s = t[0];
|
|
1255
|
+
if (s && typeof s == "object")
|
|
1256
|
+
t[0] = Os(s);
|
|
1257
|
+
else
|
|
1258
|
+
for (let n = t.length - 1; n >= 0; n--)
|
|
1259
|
+
if (typeof t[n] == "function") {
|
|
1260
|
+
const i = t[n];
|
|
1261
|
+
t[n] = mt.get(i) ?? i;
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
return e.off.apply(this, t);
|
|
1179
1265
|
};
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1266
|
+
}
|
|
1267
|
+
function js() {
|
|
1268
|
+
w !== null && (c.fn.on = w.on, c.fn.off = w.off, c.fn.remove = w.remove, c.fn.empty = w.empty, c.fn.detach = w.detach, w = null);
|
|
1269
|
+
}
|
|
1270
|
+
var T = /* @__PURE__ */ ((e) => (e[e.None = 0] = "None", e[e.Focused = 1] = "Focused", e[e.Composing = 2] = "Composing", e[e.SyncingToAtom = 4] = "SyncingToAtom", e[e.SyncingToDom = 8] = "SyncingToDom", e[e.Busy = 14] = "Busy", e))(T || {});
|
|
1271
|
+
let vs = 0;
|
|
1272
|
+
class Ds {
|
|
1273
|
+
constructor(t, s, n) {
|
|
1274
|
+
this.flags = 0, this.timeoutId = void 0, this.ns = `.atomBind-${++vs}`, this.handleCompositionStart = () => {
|
|
1275
|
+
this.flags |= T.Composing;
|
|
1276
|
+
}, this.handleCompositionEnd = () => {
|
|
1277
|
+
this.flags &= ~T.Composing, this.handleInput();
|
|
1278
|
+
}, this.handleFocus = () => {
|
|
1279
|
+
this.flags |= T.Focused;
|
|
1280
|
+
}, this.handleBlur = () => {
|
|
1281
|
+
this.flags &= ~T.Focused, this.timeoutId !== void 0 && (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom());
|
|
1282
|
+
const r = this.options.format(this.atom.peek());
|
|
1283
|
+
this.el.value !== r && (this.el.value = r);
|
|
1284
|
+
}, this.syncDomFromAtom = () => {
|
|
1285
|
+
const r = this.atom.value;
|
|
1286
|
+
H(() => {
|
|
1287
|
+
const o = this.options.format(r), l = this.el.value;
|
|
1288
|
+
if (l === o) return;
|
|
1289
|
+
const p = !!(this.flags & T.Focused);
|
|
1290
|
+
if (p)
|
|
1291
|
+
try {
|
|
1292
|
+
if (this.options.equal(this.options.parse(l), r)) return;
|
|
1293
|
+
} catch {
|
|
1294
|
+
}
|
|
1295
|
+
this.flags |= T.SyncingToDom;
|
|
1296
|
+
try {
|
|
1297
|
+
if (p && (this.el instanceof HTMLInputElement || this.el instanceof HTMLTextAreaElement)) {
|
|
1298
|
+
const C = this.el.selectionStart, b = this.el.selectionEnd;
|
|
1299
|
+
this.el.value = o;
|
|
1300
|
+
const N = o.length;
|
|
1301
|
+
C !== null && b !== null && this.el.setSelectionRange(Math.min(C, N), Math.min(b, N));
|
|
1302
|
+
} else
|
|
1303
|
+
this.el.value = o;
|
|
1304
|
+
f.domUpdated(this.$el, "val", o);
|
|
1305
|
+
} finally {
|
|
1306
|
+
this.flags &= ~T.SyncingToDom;
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
}, this.cleanup = () => {
|
|
1310
|
+
this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
|
|
1311
|
+
}, this.$el = t, this.el = t[0], this.atom = s;
|
|
1312
|
+
const i = n.debounce ?? 0;
|
|
1313
|
+
this.options = {
|
|
1314
|
+
debounce: i,
|
|
1315
|
+
event: n.event ?? Ye.EVENT,
|
|
1316
|
+
parse: n.parse ?? ((r) => r),
|
|
1317
|
+
format: n.format ?? ((r) => String(r ?? "")),
|
|
1318
|
+
equal: n.equal ?? Object.is
|
|
1319
|
+
}, i > 0 ? this.handleInput = () => {
|
|
1320
|
+
this.flags & T.Composing || (clearTimeout(this.timeoutId), this.timeoutId = setTimeout(() => this.syncAtomFromDom(), i));
|
|
1321
|
+
} : this.handleInput = () => {
|
|
1322
|
+
this.flags & T.Composing || this.syncAtomFromDom();
|
|
1323
|
+
}, this.handleFocus[F] = !0, this.handleBlur[F] = !0, this.handleCompositionStart[F] = !0, this.handleCompositionEnd[F] = !0, this.handleInput[F] = !0, this.bindEvents();
|
|
1324
|
+
}
|
|
1325
|
+
// --- Sync Logic ---
|
|
1326
|
+
syncAtomFromDom() {
|
|
1327
|
+
if (!(this.flags & T.Busy)) {
|
|
1328
|
+
this.flags |= T.SyncingToAtom;
|
|
1184
1329
|
try {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
f.setSelectionRange(Math.min(H ?? 0, V), Math.min(ct ?? 0, V));
|
|
1190
|
-
} else
|
|
1191
|
-
f.value = C;
|
|
1192
|
-
E.domUpdated(e, "val", C);
|
|
1330
|
+
const t = this.options.parse(this.el.value);
|
|
1331
|
+
this.options.equal(this.atom.peek(), t) || (this.atom.value = t);
|
|
1332
|
+
} catch (t) {
|
|
1333
|
+
f.warn(d.BINDING, `${S.PARSE_ERROR()}:`, t);
|
|
1193
1334
|
} finally {
|
|
1194
|
-
|
|
1335
|
+
this.flags &= ~T.SyncingToAtom;
|
|
1195
1336
|
}
|
|
1196
1337
|
}
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1338
|
+
}
|
|
1339
|
+
bindEvents() {
|
|
1340
|
+
this.$el.on(`focus${this.ns}`, this.handleFocus).on(`blur${this.ns}`, this.handleBlur).on(`compositionstart${this.ns}`, this.handleCompositionStart).on(`compositionend${this.ns}`, this.handleCompositionEnd).on(`${this.options.event}${this.ns}`, this.handleInput);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
function As(e, t, s) {
|
|
1344
|
+
const n = new Ds(e, t, s);
|
|
1345
|
+
return { fx: X(n.syncDomFromAtom), cleanup: n.cleanup };
|
|
1200
1346
|
}
|
|
1201
|
-
const
|
|
1202
|
-
function
|
|
1203
|
-
let t =
|
|
1204
|
-
return t || (t = e.includes("-") ? e.replace(/-./g, (
|
|
1347
|
+
const he = /* @__PURE__ */ new Map();
|
|
1348
|
+
function Us(e) {
|
|
1349
|
+
let t = he.get(e);
|
|
1350
|
+
return t !== void 0 || (t = e.includes("-") ? e.replace(/-./g, (s) => s[1].toUpperCase()) : e, he.set(e, t)), t;
|
|
1205
1351
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1352
|
+
const ue = /* @__PURE__ */ new WeakMap();
|
|
1353
|
+
function Ls(e) {
|
|
1354
|
+
let t = ue.get(e);
|
|
1355
|
+
return t || (t = Ct(() => Bt(e.value)), ue.set(e, t)), t;
|
|
1356
|
+
}
|
|
1357
|
+
function D(e) {
|
|
1208
1358
|
return {
|
|
1209
|
-
|
|
1210
|
-
return t || (t = l(e)), t;
|
|
1211
|
-
},
|
|
1359
|
+
$el: c(e),
|
|
1212
1360
|
el: e,
|
|
1213
|
-
trackCleanup: (
|
|
1361
|
+
trackCleanup: (t) => g.trackCleanup(e, t)
|
|
1214
1362
|
};
|
|
1215
1363
|
}
|
|
1216
|
-
function
|
|
1364
|
+
function Te(e, t, s) {
|
|
1217
1365
|
const n = e.el;
|
|
1218
|
-
|
|
1366
|
+
Q(
|
|
1219
1367
|
n,
|
|
1220
1368
|
t,
|
|
1221
|
-
(
|
|
1222
|
-
const
|
|
1223
|
-
n.textContent !==
|
|
1369
|
+
(i) => {
|
|
1370
|
+
const r = s ? s(i) : typeof i == "string" ? i : String(i ?? "");
|
|
1371
|
+
n.textContent !== r && (n.textContent = r);
|
|
1224
1372
|
},
|
|
1225
1373
|
"text"
|
|
1226
1374
|
);
|
|
1227
1375
|
}
|
|
1228
|
-
function
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1376
|
+
function Oe(e, t) {
|
|
1377
|
+
const s = e.el, n = qt(t) ? Ls(t) : t;
|
|
1378
|
+
Q(
|
|
1379
|
+
s,
|
|
1231
1380
|
n,
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
const i = String(s ?? ""), o = Ot(i);
|
|
1235
|
-
o !== i && console.warn(`${Z.BIND} ${rt.UNSAFE_CONTENT}`), n.innerHTML !== o && (n.innerHTML = o);
|
|
1381
|
+
(i) => {
|
|
1382
|
+
s.innerHTML !== i && (g.cleanupDescendants(s), s.innerHTML = i);
|
|
1236
1383
|
},
|
|
1237
1384
|
"html"
|
|
1238
1385
|
);
|
|
1239
1386
|
}
|
|
1240
|
-
function
|
|
1241
|
-
|
|
1242
|
-
|
|
1387
|
+
function Ne(e, t) {
|
|
1388
|
+
Object.entries(t).forEach(([s, n]) => {
|
|
1389
|
+
Q(
|
|
1243
1390
|
e.el,
|
|
1244
|
-
|
|
1245
|
-
(
|
|
1246
|
-
e.el.classList.toggle(
|
|
1391
|
+
n,
|
|
1392
|
+
(i) => {
|
|
1393
|
+
e.el.classList.toggle(s, !!i);
|
|
1247
1394
|
},
|
|
1248
|
-
`class.${
|
|
1395
|
+
`class.${s}`
|
|
1249
1396
|
);
|
|
1397
|
+
});
|
|
1250
1398
|
}
|
|
1251
|
-
function
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1254
|
-
const o =
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
const S = f ? `${p}${f}` : String(p);
|
|
1262
|
-
if (Ke(S)) {
|
|
1263
|
-
console.warn(`${Z.BIND} ${rt.BLOCKED_DANGEROUS_VALUE(i)}`);
|
|
1264
|
-
return;
|
|
1265
|
-
}
|
|
1266
|
-
s[r] = S;
|
|
1399
|
+
function ve(e, t) {
|
|
1400
|
+
const s = e.el, n = s.style;
|
|
1401
|
+
Object.entries(t).forEach(([i, r]) => {
|
|
1402
|
+
const o = Us(i), [l, p] = Array.isArray(r) ? r : [r, ""];
|
|
1403
|
+
Q(
|
|
1404
|
+
s,
|
|
1405
|
+
l,
|
|
1406
|
+
(C) => {
|
|
1407
|
+
const b = p ? `${C}${p}` : String(C);
|
|
1408
|
+
fs(b) || (n[o] = b);
|
|
1267
1409
|
},
|
|
1268
1410
|
`css.${i}`
|
|
1269
1411
|
);
|
|
1270
|
-
}
|
|
1412
|
+
});
|
|
1271
1413
|
}
|
|
1272
|
-
function
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
n,
|
|
1282
|
-
t[s],
|
|
1283
|
-
(o) => {
|
|
1284
|
-
if (o == null || o === !1) {
|
|
1285
|
-
n.removeAttribute(s);
|
|
1286
|
-
return;
|
|
1287
|
-
}
|
|
1288
|
-
const r = o === !0 ? s : String(o);
|
|
1289
|
-
if (Ge(s, r)) {
|
|
1290
|
-
console.warn(`${Z.BIND} ${rt.BLOCKED_PROTOCOL(s)}`);
|
|
1414
|
+
function De(e, t) {
|
|
1415
|
+
const s = e.el;
|
|
1416
|
+
Object.keys(t).forEach((n) => {
|
|
1417
|
+
n.toLowerCase().startsWith("on") || Q(
|
|
1418
|
+
s,
|
|
1419
|
+
t[n],
|
|
1420
|
+
(i) => {
|
|
1421
|
+
if (i == null || i === !1) {
|
|
1422
|
+
s.removeAttribute(n);
|
|
1291
1423
|
return;
|
|
1292
1424
|
}
|
|
1293
|
-
|
|
1425
|
+
const r = i === !0 ? n : String(i);
|
|
1426
|
+
ls(n, r) || s.getAttribute(n) !== r && s.setAttribute(n, r);
|
|
1294
1427
|
},
|
|
1295
|
-
`attr.${
|
|
1428
|
+
`attr.${n}`
|
|
1296
1429
|
);
|
|
1297
|
-
}
|
|
1430
|
+
});
|
|
1298
1431
|
}
|
|
1299
|
-
function
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
console.warn(`${Z.BIND} ${rt.BLOCKED_DANGEROUS_PROP(s)}`);
|
|
1304
|
-
continue;
|
|
1305
|
-
}
|
|
1306
|
-
X(
|
|
1432
|
+
function Ae(e, t) {
|
|
1433
|
+
const s = e.el;
|
|
1434
|
+
Object.keys(t).forEach((n) => {
|
|
1435
|
+
Je.has(n) || Q(
|
|
1307
1436
|
e.el,
|
|
1308
|
-
t[
|
|
1437
|
+
t[n],
|
|
1309
1438
|
(i) => {
|
|
1310
|
-
n
|
|
1439
|
+
s[n] !== i && (s[n] = i);
|
|
1311
1440
|
},
|
|
1312
|
-
`prop.${
|
|
1441
|
+
`prop.${n}`
|
|
1313
1442
|
);
|
|
1314
|
-
}
|
|
1443
|
+
});
|
|
1315
1444
|
}
|
|
1316
|
-
function
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
|
|
1445
|
+
function gt(e, t, s) {
|
|
1446
|
+
const n = e.el;
|
|
1447
|
+
Q(
|
|
1448
|
+
n,
|
|
1320
1449
|
t,
|
|
1321
|
-
(
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1450
|
+
(r) => {
|
|
1451
|
+
const o = s !== !!r;
|
|
1452
|
+
n.style.display = o ? "" : "none";
|
|
1324
1453
|
},
|
|
1325
|
-
s
|
|
1454
|
+
s ? "hide" : "show"
|
|
1326
1455
|
);
|
|
1327
1456
|
}
|
|
1328
|
-
function
|
|
1457
|
+
function Gt(e, t, s = {}) {
|
|
1329
1458
|
const n = e.el.tagName.toLowerCase();
|
|
1330
|
-
if (n
|
|
1331
|
-
console.warn(
|
|
1459
|
+
if (!We.has(n)) {
|
|
1460
|
+
console.warn(`${d.BINDING} ${S.INVALID_INPUT_ELEMENT(n)}`);
|
|
1332
1461
|
return;
|
|
1333
1462
|
}
|
|
1334
|
-
const
|
|
1335
|
-
|
|
1336
|
-
s ? t[0] : t,
|
|
1337
|
-
s ? t[1] : {}
|
|
1338
|
-
);
|
|
1339
|
-
b.trackEffect(e.el, J(i)), e.trackCleanup(o);
|
|
1463
|
+
const { fx: i, cleanup: r } = As(e.$el, t, s);
|
|
1464
|
+
g.trackEffect(e.el, i), e.trackCleanup(r);
|
|
1340
1465
|
}
|
|
1341
|
-
function
|
|
1342
|
-
const
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
t.value !== c && (t.value = c);
|
|
1466
|
+
function Ue(e, t) {
|
|
1467
|
+
const s = e.el, n = e.$el, i = () => {
|
|
1468
|
+
const o = s.checked;
|
|
1469
|
+
t.value !== o && (t.value = o);
|
|
1346
1470
|
};
|
|
1347
|
-
|
|
1348
|
-
const r =
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1471
|
+
i[F] = !0, n.on("change", i), e.trackCleanup(() => n.off("change", i));
|
|
1472
|
+
const r = X(() => {
|
|
1473
|
+
const o = !!t.value;
|
|
1474
|
+
H(() => {
|
|
1475
|
+
s.checked !== o && (s.checked = o, f.domUpdated(n, "checked", o));
|
|
1476
|
+
});
|
|
1352
1477
|
});
|
|
1353
|
-
|
|
1354
|
-
}
|
|
1355
|
-
function ln(e, t) {
|
|
1356
|
-
for (const n in t) {
|
|
1357
|
-
const s = t[n];
|
|
1358
|
-
if (typeof s != "function") continue;
|
|
1359
|
-
const i = (o) => {
|
|
1360
|
-
Kt(
|
|
1361
|
-
() => s.call(
|
|
1362
|
-
e.el,
|
|
1363
|
-
l.Event(o.type, { originalEvent: o })
|
|
1364
|
-
)
|
|
1365
|
-
);
|
|
1366
|
-
};
|
|
1367
|
-
e.el.addEventListener(n, i), e.trackCleanup(() => e.el.removeEventListener(n, i));
|
|
1368
|
-
}
|
|
1478
|
+
g.trackEffect(s, r);
|
|
1369
1479
|
}
|
|
1370
|
-
|
|
1480
|
+
function ws(e, t) {
|
|
1481
|
+
const s = e.$el;
|
|
1482
|
+
s.on(t), e.trackCleanup(() => s.off(t));
|
|
1483
|
+
}
|
|
1484
|
+
function ks(e, t, s) {
|
|
1485
|
+
const n = e.$el;
|
|
1486
|
+
n.on(t, s), e.trackCleanup(() => n.off(t, s));
|
|
1487
|
+
}
|
|
1488
|
+
function Le(e) {
|
|
1489
|
+
g.cleanupTree(e);
|
|
1490
|
+
}
|
|
1491
|
+
c.fn.atomText = function(e, t) {
|
|
1371
1492
|
return this.each(function() {
|
|
1372
|
-
|
|
1373
|
-
e.text !== void 0 && un(t, e.text), e.html !== void 0 && ye(t, e.html), e.class && be(t, e.class), e.css && Se(t, e.css), e.attr && Ie(t, e.attr), e.prop && Ce(t, e.prop), e.show !== void 0 && At(t, e.show, !1, "show"), e.hide !== void 0 && At(t, e.hide, !0, "hide"), e.val !== void 0 && Te(t, e.val), e.checked !== void 0 && De(t, e.checked), e.on && ln(t, e.on);
|
|
1493
|
+
Te(D(this), e, t);
|
|
1374
1494
|
});
|
|
1375
1495
|
};
|
|
1376
|
-
|
|
1496
|
+
c.fn.atomHtml = function(e) {
|
|
1377
1497
|
return this.each(function() {
|
|
1378
|
-
|
|
1379
|
-
X(this, e, t ? (i) => n.text(t(i)) : (i) => n.text(String(i ?? "")), "text");
|
|
1498
|
+
Oe(D(this), e);
|
|
1380
1499
|
});
|
|
1381
1500
|
};
|
|
1382
|
-
|
|
1501
|
+
c.fn.atomClass = function(e, t) {
|
|
1502
|
+
if (typeof e == "string" && t === void 0)
|
|
1503
|
+
return console.warn(`${d.BINDING} ${S.MISSING_CONDITION("atomClass")}`), this;
|
|
1504
|
+
const s = typeof e == "string" ? { [e]: t } : e;
|
|
1383
1505
|
return this.each(function() {
|
|
1384
|
-
|
|
1506
|
+
Ne(D(this), s);
|
|
1385
1507
|
});
|
|
1386
1508
|
};
|
|
1387
|
-
|
|
1509
|
+
c.fn.atomCss = function(e, t, s) {
|
|
1510
|
+
if (typeof e == "string" && t === void 0)
|
|
1511
|
+
return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomCss")}`), this;
|
|
1512
|
+
const n = typeof e == "string" ? { [e]: s ? [t, s] : t } : e;
|
|
1388
1513
|
return this.each(function() {
|
|
1389
|
-
|
|
1514
|
+
ve(D(this), n);
|
|
1390
1515
|
});
|
|
1391
1516
|
};
|
|
1392
|
-
|
|
1517
|
+
c.fn.atomAttr = function(e, t) {
|
|
1518
|
+
if (typeof e == "string" && t === void 0)
|
|
1519
|
+
return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomAttr")}`), this;
|
|
1520
|
+
const s = typeof e == "string" ? { [e]: t } : e;
|
|
1393
1521
|
return this.each(function() {
|
|
1394
|
-
|
|
1522
|
+
De(D(this), s);
|
|
1395
1523
|
});
|
|
1396
1524
|
};
|
|
1397
|
-
|
|
1525
|
+
c.fn.atomProp = function(e, t) {
|
|
1526
|
+
if (typeof e == "string" && t === void 0)
|
|
1527
|
+
return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomProp")}`), this;
|
|
1528
|
+
const s = typeof e == "string" ? { [e]: t } : e;
|
|
1398
1529
|
return this.each(function() {
|
|
1399
|
-
|
|
1530
|
+
Ae(D(this), s);
|
|
1400
1531
|
});
|
|
1401
1532
|
};
|
|
1402
|
-
|
|
1533
|
+
c.fn.atomShow = function(e) {
|
|
1403
1534
|
return this.each(function() {
|
|
1404
|
-
|
|
1535
|
+
gt(D(this), e, !1);
|
|
1405
1536
|
});
|
|
1406
1537
|
};
|
|
1407
|
-
|
|
1538
|
+
c.fn.atomHide = function(e) {
|
|
1408
1539
|
return this.each(function() {
|
|
1409
|
-
|
|
1540
|
+
gt(D(this), e, !0);
|
|
1410
1541
|
});
|
|
1411
1542
|
};
|
|
1412
|
-
|
|
1543
|
+
c.fn.atomVal = function(e, t = {}) {
|
|
1413
1544
|
return this.each(function() {
|
|
1414
|
-
|
|
1545
|
+
Gt(D(this), e, t);
|
|
1415
1546
|
});
|
|
1416
1547
|
};
|
|
1417
|
-
|
|
1548
|
+
c.fn.atomChecked = function(e) {
|
|
1418
1549
|
return this.each(function() {
|
|
1419
|
-
|
|
1420
|
-
B(this),
|
|
1421
|
-
t && Object.keys(t).length > 0 ? [e, t] : e
|
|
1422
|
-
);
|
|
1550
|
+
Ue(D(this), e);
|
|
1423
1551
|
});
|
|
1424
1552
|
};
|
|
1425
|
-
|
|
1553
|
+
c.fn.atomOn = function(e, t) {
|
|
1426
1554
|
return this.each(function() {
|
|
1427
|
-
|
|
1555
|
+
ks(D(this), e, t);
|
|
1428
1556
|
});
|
|
1429
1557
|
};
|
|
1430
|
-
|
|
1558
|
+
c.fn.atomBind = function(e) {
|
|
1431
1559
|
return this.each(function() {
|
|
1432
|
-
const
|
|
1433
|
-
|
|
1560
|
+
const t = D(this);
|
|
1561
|
+
if (e.text !== void 0 && Te(t, e.text), e.html !== void 0 && Oe(t, e.html), e.class !== void 0 && Ne(t, e.class), e.css !== void 0 && ve(t, e.css), e.attr !== void 0 && De(t, e.attr), e.prop !== void 0 && Ae(t, e.prop), e.show !== void 0 && gt(t, e.show, !1), e.hide !== void 0 && gt(t, e.hide, !0), e.val !== void 0)
|
|
1562
|
+
if (Array.isArray(e.val)) {
|
|
1563
|
+
const [s, n] = e.val;
|
|
1564
|
+
Gt(t, s, n);
|
|
1565
|
+
} else
|
|
1566
|
+
Gt(t, e.val);
|
|
1567
|
+
e.checked !== void 0 && Ue(t, e.checked), e.on !== void 0 && ws(t, e.on);
|
|
1434
1568
|
});
|
|
1435
1569
|
};
|
|
1436
|
-
|
|
1570
|
+
c.fn.atomUnbind = function() {
|
|
1437
1571
|
return this.each(function() {
|
|
1438
|
-
|
|
1572
|
+
Le(this);
|
|
1439
1573
|
});
|
|
1440
1574
|
};
|
|
1441
|
-
|
|
1442
|
-
|
|
1575
|
+
function xs(e, t, s) {
|
|
1576
|
+
t?.isConnected ? e.insertBefore(t) : e.appendTo(s);
|
|
1577
|
+
}
|
|
1578
|
+
c.fn.atomList = function(e, t) {
|
|
1579
|
+
const { key: s, render: n, bind: i, update: r, onAdd: o, onRemove: l, empty: p } = t, C = typeof s == "function" ? s : (b, N) => b[s];
|
|
1443
1580
|
return this.each(function() {
|
|
1444
|
-
const
|
|
1445
|
-
let
|
|
1446
|
-
const
|
|
1447
|
-
const
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1581
|
+
const b = c(this), N = Xt(this), E = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Set();
|
|
1582
|
+
let P = [], U = null;
|
|
1583
|
+
const G = (v, R) => {
|
|
1584
|
+
const j = () => {
|
|
1585
|
+
bt?.isDisposed || (R.$el.remove(), m.delete(v), f.log("list", `${N} removed item:`, v));
|
|
1586
|
+
};
|
|
1587
|
+
if (l) {
|
|
1588
|
+
const M = l(R.$el);
|
|
1589
|
+
M instanceof Promise ? M.then(j, j) : j();
|
|
1590
|
+
} else
|
|
1591
|
+
j();
|
|
1592
|
+
}, Qt = (v, R) => {
|
|
1593
|
+
E.delete(v), m.add(v), G(v, R);
|
|
1594
|
+
};
|
|
1595
|
+
let bt;
|
|
1596
|
+
bt = X(() => {
|
|
1597
|
+
const v = e.value, R = v.length;
|
|
1598
|
+
H(() => {
|
|
1599
|
+
if (U && R > 0 && (U.remove(), U = null), R === 0) {
|
|
1600
|
+
if (p && !U) {
|
|
1601
|
+
const a = typeof p == "string" ? Bt(p) : p;
|
|
1602
|
+
U = c(a).appendTo(b);
|
|
1603
|
+
}
|
|
1604
|
+
E.forEach((a, h) => {
|
|
1605
|
+
m.has(h) || Qt(h, a);
|
|
1606
|
+
}), P = [];
|
|
1607
|
+
return;
|
|
1452
1608
|
}
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
if (at.has(h) || k.has(h)) continue;
|
|
1470
|
-
const g = () => {
|
|
1471
|
-
U.$el.remove(), U.$el[0] && b.cleanup(U.$el[0]), k.delete(h), E.log("list", `${S} removed item:`, h);
|
|
1472
|
-
};
|
|
1473
|
-
if (y.delete(h), k.add(h), c) {
|
|
1474
|
-
const T = c(U.$el);
|
|
1475
|
-
T instanceof Promise ? T.then(g) : g();
|
|
1609
|
+
f.log("list", `${N} updating with ${R} items`);
|
|
1610
|
+
const j = /* @__PURE__ */ new Map();
|
|
1611
|
+
for (let a = 0; a < P.length; a++)
|
|
1612
|
+
j.set(P[a], a);
|
|
1613
|
+
const M = new Array(R), St = /* @__PURE__ */ new Set(), ot = new Int32Array(R), ct = [], Rt = [], Tt = [];
|
|
1614
|
+
for (let a = 0; a < R; a++) {
|
|
1615
|
+
const h = v[a], _ = C(h, a);
|
|
1616
|
+
if (M[a] = _, St.has(_)) {
|
|
1617
|
+
f.warn(d.LIST, S.DUPLICATE_KEY(_, a)), ot[a] = -1;
|
|
1618
|
+
continue;
|
|
1619
|
+
}
|
|
1620
|
+
St.add(_);
|
|
1621
|
+
const I = E.get(_);
|
|
1622
|
+
if (I) {
|
|
1623
|
+
const u = I.item;
|
|
1624
|
+
!r && u !== h && !ds(u, h) && (ct.push(_), Rt.push(h), Tt.push(a)), ot[a] = m.has(_) ? -1 : j.get(_) ?? -1;
|
|
1476
1625
|
} else
|
|
1477
|
-
|
|
1626
|
+
ct.push(_), Rt.push(h), Tt.push(a), ot[a] = -1;
|
|
1478
1627
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
if (
|
|
1488
|
-
const
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
const
|
|
1496
|
-
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1628
|
+
const Kt = "<!--sep-->", at = ct.length, Yt = new Array(
|
|
1629
|
+
at
|
|
1630
|
+
), Ot = [];
|
|
1631
|
+
for (let a = 0; a < at; a++) {
|
|
1632
|
+
const h = n(Rt[a], Tt[a]);
|
|
1633
|
+
Yt[a] = h, typeof h == "string" && Ot.push(h);
|
|
1634
|
+
}
|
|
1635
|
+
let ht = null;
|
|
1636
|
+
if (Ot.length > 0) {
|
|
1637
|
+
const a = Ot.join(Kt);
|
|
1638
|
+
ht = Bt(a).split(Kt);
|
|
1639
|
+
}
|
|
1640
|
+
let Wt = 0;
|
|
1641
|
+
for (let a = 0; a < at; a++) {
|
|
1642
|
+
const h = Yt[a], _ = typeof h == "string" ? c(ht[Wt++]) : c(h), I = ct[a], u = E.get(I);
|
|
1643
|
+
if (u) {
|
|
1644
|
+
const A = u.$el[0];
|
|
1645
|
+
A && g.cleanupTree(A), u.$el.replaceWith(_), u.$el = _, u.state = "replaced";
|
|
1646
|
+
} else
|
|
1647
|
+
E.set(I, { $el: _, item: null, state: "new" });
|
|
1648
|
+
}
|
|
1649
|
+
for (const [a, h] of E)
|
|
1650
|
+
!St.has(a) && !m.has(a) && Qt(a, h);
|
|
1651
|
+
const Jt = _s(ot);
|
|
1652
|
+
let Nt = Jt.length - 1, Zt = null;
|
|
1653
|
+
const vt = P.length === 0;
|
|
1654
|
+
if (vt && ht !== null && Wt === at && !i && !o && !l && m.size === 0) {
|
|
1655
|
+
this.innerHTML = ht.join("");
|
|
1656
|
+
let a = 0;
|
|
1657
|
+
for (let h = 0; h < R; h++) {
|
|
1658
|
+
const _ = M[h], I = v[h], u = E.get(_);
|
|
1659
|
+
if (!u) continue;
|
|
1660
|
+
const A = this.children[a++];
|
|
1661
|
+
A && (u.$el = c(A), u.item = I, u.state = void 0, m.delete(_), f.domUpdated(u.$el, "list.add", I));
|
|
1503
1662
|
}
|
|
1504
|
-
P = T.$el[0] || null;
|
|
1505
1663
|
} else {
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1664
|
+
const a = vt ? document.createDocumentFragment() : null;
|
|
1665
|
+
if (vt && a) {
|
|
1666
|
+
for (let h = R - 1; h >= 0; h--) {
|
|
1667
|
+
const _ = M[h], I = v[h], u = E.get(_);
|
|
1668
|
+
if (!u) continue;
|
|
1669
|
+
const A = u.state, x = A === "new", et = A === "replaced";
|
|
1670
|
+
u.item = I, u.state = void 0, u.$el[0] && (!x && !et && r ? r(u.$el, I, h) : (x || et) && i && i(u.$el, I, h));
|
|
1671
|
+
for (let Dt = u.$el.length - 1; Dt >= 0; Dt--)
|
|
1672
|
+
a.insertBefore(u.$el[Dt], a.firstChild);
|
|
1673
|
+
o && x && o(u.$el), x && (m.delete(_), f.domUpdated(u.$el, "list.add", I));
|
|
1674
|
+
}
|
|
1675
|
+
this.appendChild(a);
|
|
1676
|
+
} else
|
|
1677
|
+
for (let h = R - 1; h >= 0; h--) {
|
|
1678
|
+
const _ = M[h], I = v[h], u = E.get(_);
|
|
1679
|
+
if (!u) continue;
|
|
1680
|
+
const A = u.state, x = A === "new", et = A === "replaced";
|
|
1681
|
+
u.item = I, u.state = void 0, u.$el[0] && (!x && !et && r ? r(u.$el, I, h) : (x || et) && i && i(u.$el, I, h)), Nt >= 0 && Jt[Nt] === h ? Nt-- : xs(u.$el, Zt, b), o && x && o(u.$el), Zt = u.$el[0] ?? null, x && (m.delete(_), f.domUpdated(u.$el, "list.add", I));
|
|
1682
|
+
}
|
|
1508
1683
|
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
})
|
|
1512
|
-
|
|
1513
|
-
y.clear(), k.clear(), R = [], A?.remove();
|
|
1684
|
+
P = M;
|
|
1685
|
+
});
|
|
1686
|
+
}), g.trackEffect(this, bt), g.trackCleanup(this, () => {
|
|
1687
|
+
E.clear(), m.clear(), P = [], U?.remove();
|
|
1514
1688
|
});
|
|
1515
1689
|
});
|
|
1516
1690
|
};
|
|
1517
|
-
const
|
|
1518
|
-
|
|
1691
|
+
const Ps = Object.freeze({});
|
|
1692
|
+
c.fn.atomMount = function(e, t) {
|
|
1693
|
+
const s = t ?? Ps;
|
|
1519
1694
|
return this.each(function() {
|
|
1520
|
-
|
|
1521
|
-
|
|
1695
|
+
g.cleanupTree(this);
|
|
1696
|
+
const n = c(this);
|
|
1522
1697
|
let i;
|
|
1523
1698
|
try {
|
|
1524
|
-
i =
|
|
1699
|
+
i = H(() => e(n, s));
|
|
1525
1700
|
} catch (r) {
|
|
1526
|
-
|
|
1701
|
+
f.error(d.MOUNT, S.MOUNT_ERROR(), r);
|
|
1527
1702
|
return;
|
|
1528
1703
|
}
|
|
1529
|
-
|
|
1530
|
-
if (vt.delete(this)) {
|
|
1531
|
-
if (E.log("mount", `${n} full cleanup`), typeof i == "function")
|
|
1532
|
-
try {
|
|
1533
|
-
i();
|
|
1534
|
-
} catch (r) {
|
|
1535
|
-
console.error("[atom-effect-jquery] Cleanup error:", r);
|
|
1536
|
-
}
|
|
1537
|
-
b.cleanupTree(this);
|
|
1538
|
-
}
|
|
1539
|
-
};
|
|
1540
|
-
vt.set(this, o), b.trackCleanup(this, o);
|
|
1704
|
+
typeof i == "function" && g.setComponentCleanup(this, i);
|
|
1541
1705
|
});
|
|
1542
1706
|
};
|
|
1543
|
-
|
|
1707
|
+
c.fn.atomUnmount = function() {
|
|
1544
1708
|
return this.each(function() {
|
|
1545
|
-
|
|
1546
|
-
e && e();
|
|
1709
|
+
Le(this);
|
|
1547
1710
|
});
|
|
1548
1711
|
};
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1712
|
+
function le(e, t) {
|
|
1713
|
+
try {
|
|
1714
|
+
return history.pushState(e, "", t), !0;
|
|
1715
|
+
} catch (s) {
|
|
1716
|
+
return f.warn(
|
|
1717
|
+
d.ROUTE,
|
|
1718
|
+
"PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.",
|
|
1719
|
+
s
|
|
1720
|
+
), !1;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
class Ms {
|
|
1724
|
+
constructor(t) {
|
|
1725
|
+
this.isDestroyed = !1, this.previousRoute = "", this.cleanups = [], this.templateCache = /* @__PURE__ */ new Map(), this.config = {
|
|
1726
|
+
...t,
|
|
1727
|
+
mode: t.mode ?? dt.mode,
|
|
1728
|
+
basePath: t.basePath ?? dt.basePath,
|
|
1729
|
+
autoBindLinks: t.autoBindLinks ?? dt.autoBindLinks,
|
|
1730
|
+
activeClass: t.activeClass ?? dt.activeClass
|
|
1731
|
+
}, this.isHistoryMode = this.config.mode === "history", this.$target = c(this.config.target), this.normalizedBasePath = this.config.basePath?.replace(/\/$/, "") || "", this.previousUrl = this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash, this.currentRouteAtom = Ft(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = Ft(this.getQueryParams()), this.queryParams = Ct(() => this.queryParamsAtom.value), this.handleUrlChange = this.handleUrlChange.bind(this), this.destroy = this.destroy.bind(this), this.init();
|
|
1732
|
+
}
|
|
1733
|
+
init() {
|
|
1734
|
+
const t = this.isHistoryMode ? "popstate" : "hashchange";
|
|
1735
|
+
window.addEventListener(t, this.handleUrlChange), this.cleanups.push(() => window.removeEventListener(t, this.handleUrlChange));
|
|
1736
|
+
const s = X(() => {
|
|
1737
|
+
const n = this.currentRouteAtom.value;
|
|
1738
|
+
H(() => this.renderRoute(n));
|
|
1739
|
+
});
|
|
1740
|
+
this.cleanups.push(() => s.dispose()), this.setupAutoBindLinks(), this.$target[0] && g.trackCleanup(this.$target[0], this.destroy);
|
|
1741
|
+
}
|
|
1742
|
+
// --- Mode-abstracted internal methods ---
|
|
1743
|
+
/**
|
|
1744
|
+
* Extracts route name from current URL.
|
|
1745
|
+
* Uses `normalizedBasePath` for consistent stripping in history mode.
|
|
1746
|
+
*/
|
|
1747
|
+
getRouteName() {
|
|
1748
|
+
const { default: t } = this.config;
|
|
1749
|
+
if (this.isHistoryMode) {
|
|
1750
|
+
let r = window.location.pathname;
|
|
1751
|
+
return this.normalizedBasePath && r.startsWith(this.normalizedBasePath) && (r = r.substring(this.normalizedBasePath.length)), r.charCodeAt(0) === 47 && (r = r.slice(1)), r || t;
|
|
1568
1752
|
}
|
|
1569
|
-
const
|
|
1570
|
-
return (
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1753
|
+
const s = window.location.hash, n = s.indexOf("?");
|
|
1754
|
+
return (n === -1 ? s.substring(1) : s.substring(1, n)) || t;
|
|
1755
|
+
}
|
|
1756
|
+
/**
|
|
1757
|
+
* Parses query parameters from the current URL.
|
|
1758
|
+
*
|
|
1759
|
+
* Note: duplicate keys (e.g. `?a=1&a=2`) are collapsed to the last value
|
|
1760
|
+
* only (`{ a: '2' }`). This matches `URLSearchParams` → `Object.fromEntries`
|
|
1761
|
+
* behaviour. If multi-value keys are needed, access `queryParams` via
|
|
1762
|
+
* `new URLSearchParams(window.location.search).getAll('key')` directly.
|
|
1763
|
+
*/
|
|
1764
|
+
getQueryParams() {
|
|
1765
|
+
let t;
|
|
1766
|
+
if (this.isHistoryMode) {
|
|
1767
|
+
if (t = window.location.search.substring(1), !t) return {};
|
|
1575
1768
|
} else {
|
|
1576
|
-
const
|
|
1577
|
-
if (
|
|
1578
|
-
|
|
1769
|
+
const i = window.location.hash, r = i.indexOf("?");
|
|
1770
|
+
if (r === -1) return {};
|
|
1771
|
+
t = i.substring(r + 1);
|
|
1579
1772
|
}
|
|
1580
|
-
const
|
|
1581
|
-
if (
|
|
1773
|
+
const s = new URLSearchParams(t), n = Object.fromEntries(s);
|
|
1774
|
+
if (t.includes("%"))
|
|
1582
1775
|
try {
|
|
1583
|
-
decodeURIComponent(
|
|
1776
|
+
decodeURIComponent(t);
|
|
1584
1777
|
} catch {
|
|
1585
|
-
|
|
1778
|
+
f.warn(d.ROUTE, S.MALFORMED_URI(t));
|
|
1586
1779
|
}
|
|
1587
|
-
return
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
}, V = (u, d, _) => {
|
|
1598
|
-
try {
|
|
1599
|
-
return history.replaceState(u, d, _), !0;
|
|
1600
|
-
} catch (m) {
|
|
1601
|
-
return E.warn(`${nt} ReplaceState failed.`, m), !1;
|
|
1602
|
-
}
|
|
1603
|
-
}, at = (u) => {
|
|
1604
|
-
if (S) {
|
|
1605
|
-
const d = `${r.replace(/\/$/, "")}/${u}`;
|
|
1606
|
-
ct(null, "", d), R = d;
|
|
1780
|
+
return n;
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Updates the browser URL to reflect a new route and keeps `previousUrl`
|
|
1784
|
+
* in sync so `handleUrlChange` does not re-process our own navigation.
|
|
1785
|
+
*/
|
|
1786
|
+
setUrl(t) {
|
|
1787
|
+
if (this.isHistoryMode) {
|
|
1788
|
+
const s = `${this.normalizedBasePath}/${t}`;
|
|
1789
|
+
le(null, s), this.previousUrl = s;
|
|
1607
1790
|
} else {
|
|
1608
|
-
const
|
|
1609
|
-
|
|
1791
|
+
const s = `#${t}`;
|
|
1792
|
+
window.location.hash = s, this.previousUrl = s;
|
|
1610
1793
|
}
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* Restores the URL when a navigation guard blocks the transition.
|
|
1797
|
+
* Uses pushState to safely add a new history entry, avoiding "back button traps"
|
|
1798
|
+
* that occur with replaceState during popstate events.
|
|
1799
|
+
*/
|
|
1800
|
+
restoreUrl() {
|
|
1801
|
+
this.isHistoryMode ? le(null, this.previousUrl) : window.location.hash = this.previousUrl;
|
|
1802
|
+
}
|
|
1803
|
+
/**
|
|
1804
|
+
* Returns the current full URL string for comparison purposes.
|
|
1805
|
+
*/
|
|
1806
|
+
getCurrentUrl() {
|
|
1807
|
+
return this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash;
|
|
1808
|
+
}
|
|
1809
|
+
// --- End mode-abstracted methods ---
|
|
1810
|
+
/**
|
|
1811
|
+
* Resolves route configuration, falling back to notFound route if needed.
|
|
1812
|
+
*/
|
|
1813
|
+
getRouteConfig(t) {
|
|
1814
|
+
const { routes: s, notFound: n } = this.config;
|
|
1815
|
+
let i = s[t];
|
|
1816
|
+
return !i && n && (i = s[n]), i || (f.warn(d.ROUTE, S.ROUTE_NOT_FOUND(t)), null);
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Appends cloned template content into the target container.
|
|
1820
|
+
* Always appends — callers are responsible for calling `$target.empty()`
|
|
1821
|
+
* before invoking this method if a clean slate is needed.
|
|
1822
|
+
*/
|
|
1823
|
+
renderTemplate(t) {
|
|
1824
|
+
let s = this.templateCache.get(t);
|
|
1825
|
+
if (!s) {
|
|
1826
|
+
const i = document.querySelector(t);
|
|
1827
|
+
if (!i || !(i instanceof HTMLTemplateElement))
|
|
1828
|
+
return f.warn(d.ROUTE, S.TEMPLATE_NOT_FOUND(t)), !1;
|
|
1829
|
+
s = i, this.templateCache.set(t, s);
|
|
1830
|
+
}
|
|
1831
|
+
const n = s.content.cloneNode(!0);
|
|
1832
|
+
return this.$target.append(n), !0;
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Renders the specified route, including lifecycle hooks and content.
|
|
1836
|
+
*
|
|
1837
|
+
* Called from within a reactive effect, so DOM mutations here run
|
|
1838
|
+
* synchronously inside the effect body. `registry.cleanupDescendants` is
|
|
1839
|
+
* called before `$target.empty()` to ensure any reactive bindings on
|
|
1840
|
+
* outgoing content are disposed before the nodes are removed — preventing
|
|
1841
|
+
* the MutationObserver auto-cleanup path from firing a redundant cleanup.
|
|
1842
|
+
*
|
|
1843
|
+
* If `beforeTransition` throws, the render is aborted and the outgoing
|
|
1844
|
+
* content remains in the DOM. This is intentional — a throwing hook signals
|
|
1845
|
+
* that the transition should not proceed.
|
|
1846
|
+
*/
|
|
1847
|
+
renderRoute(t) {
|
|
1848
|
+
if (this.isDestroyed) return;
|
|
1849
|
+
const s = this.$target[0];
|
|
1850
|
+
if (!s) {
|
|
1851
|
+
f.warn(d.ROUTE, S.TARGET_NOT_FOUND(this.config.target));
|
|
1627
1852
|
return;
|
|
1628
1853
|
}
|
|
1629
|
-
const
|
|
1630
|
-
if (!
|
|
1631
|
-
const
|
|
1632
|
-
|
|
1633
|
-
let
|
|
1634
|
-
if (
|
|
1635
|
-
const
|
|
1636
|
-
|
|
1854
|
+
const n = this.getRouteConfig(t);
|
|
1855
|
+
if (!n) return;
|
|
1856
|
+
const i = this.getQueryParams(), r = this.previousRoute;
|
|
1857
|
+
this.config.beforeTransition && this.config.beforeTransition(r, t), this.$target.empty();
|
|
1858
|
+
let o = i;
|
|
1859
|
+
if (n.onEnter) {
|
|
1860
|
+
const l = n.onEnter(i);
|
|
1861
|
+
l !== void 0 && (o = { ...i, ...l });
|
|
1637
1862
|
}
|
|
1638
|
-
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
const v = s[_];
|
|
1653
|
-
if (v?.onLeave && v.onLeave() === !1) {
|
|
1654
|
-
Et();
|
|
1863
|
+
n.render ? n.render(s, t, o) : n.template && this.renderTemplate(n.template) && n.onMount && n.onMount(this.$target.children()), this.config.afterTransition && this.config.afterTransition(r, t), this.previousRoute = t;
|
|
1864
|
+
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Handles browser URL change events (hashchange or popstate).
|
|
1867
|
+
*/
|
|
1868
|
+
handleUrlChange() {
|
|
1869
|
+
if (this.isDestroyed) return;
|
|
1870
|
+
const t = this.getCurrentUrl();
|
|
1871
|
+
if (t === this.previousUrl) return;
|
|
1872
|
+
const s = this.getRouteName(), n = this.currentRouteAtom.peek(), i = this.getQueryParams();
|
|
1873
|
+
if (n !== s) {
|
|
1874
|
+
const r = this.config.routes[n];
|
|
1875
|
+
if (r?.onLeave && r.onLeave() === !1) {
|
|
1876
|
+
this.restoreUrl();
|
|
1655
1877
|
return;
|
|
1656
1878
|
}
|
|
1657
|
-
|
|
1879
|
+
this.currentRouteAtom.value = s, this.queryParamsAtom.value = i;
|
|
1658
1880
|
} else {
|
|
1659
|
-
|
|
1660
|
-
const
|
|
1661
|
-
|
|
1881
|
+
this.queryParamsAtom.value = i;
|
|
1882
|
+
const r = this.config.routes[n];
|
|
1883
|
+
r?.onParamsChange ? r.onParamsChange(i) : this.renderRoute(s);
|
|
1662
1884
|
}
|
|
1663
|
-
|
|
1664
|
-
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1885
|
+
this.previousUrl = t;
|
|
1886
|
+
}
|
|
1887
|
+
/**
|
|
1888
|
+
* Sets up automatic binding for navigation links with data-route attribute.
|
|
1889
|
+
*
|
|
1890
|
+
* Event delegation is attached to `document` (not `$target`) so that
|
|
1891
|
+
* `[data-route]` links anywhere in the page — including outside the router's
|
|
1892
|
+
* target container — can trigger navigation. This is intentional: nav links
|
|
1893
|
+
* typically live in headers or sidebars, not inside the routed content area.
|
|
1894
|
+
*
|
|
1895
|
+
* Active-link management uses a reactive effect that re-runs only when
|
|
1896
|
+
* `currentRoute` changes — more efficient than a persistent MutationObserver.
|
|
1897
|
+
*/
|
|
1898
|
+
setupAutoBindLinks() {
|
|
1899
|
+
if (!this.config.autoBindLinks) return;
|
|
1900
|
+
const t = (i) => {
|
|
1901
|
+
i.preventDefault();
|
|
1902
|
+
const r = i.currentTarget.dataset.route;
|
|
1903
|
+
r != null && this.navigate(r);
|
|
1676
1904
|
};
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
const _ = (N) => {
|
|
1680
|
-
for (const F of I) {
|
|
1681
|
-
const mt = F.dataset.route, lt = N === mt;
|
|
1682
|
-
F.classList.toggle(a, lt), lt ? F.setAttribute("aria-current", "page") : F.removeAttribute("aria-current");
|
|
1683
|
-
}
|
|
1684
|
-
}, m = J(() => {
|
|
1685
|
-
_(h.value);
|
|
1905
|
+
c(document).on("click", "[data-route]", t), this.cleanups.push(() => {
|
|
1906
|
+
c(document).off("click", "[data-route]", t);
|
|
1686
1907
|
});
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
});
|
|
1697
|
-
}
|
|
1698
|
-
});
|
|
1699
|
-
F && _(h.value);
|
|
1908
|
+
const { activeClass: s } = this.config, n = X(() => {
|
|
1909
|
+
const i = this.currentRouteAtom.value;
|
|
1910
|
+
H(() => {
|
|
1911
|
+
const r = document.querySelectorAll("[data-route]");
|
|
1912
|
+
for (const o of r) {
|
|
1913
|
+
const l = o.dataset.route, p = i === l;
|
|
1914
|
+
o.classList.toggle(s, p), p ? o.setAttribute("aria-current", "page") : o.removeAttribute("aria-current");
|
|
1915
|
+
}
|
|
1916
|
+
});
|
|
1700
1917
|
});
|
|
1701
|
-
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
return Gt(
|
|
1724
|
-
async () => {
|
|
1725
|
-
const a = c(), f = await l.ajax({ ...r, url: a, method: i, headers: o });
|
|
1726
|
-
return s ? s(f) : f;
|
|
1727
|
-
},
|
|
1728
|
-
{ defaultValue: n, lazy: !1 }
|
|
1729
|
-
);
|
|
1730
|
-
}
|
|
1731
|
-
l.extend({ atomFetch: fn });
|
|
1732
|
-
const Nt = /* @__PURE__ */ new WeakMap();
|
|
1733
|
-
let oe = !1;
|
|
1734
|
-
const re = (e) => {
|
|
1735
|
-
let t = Nt.get(e);
|
|
1736
|
-
return t || (t = function(...n) {
|
|
1737
|
-
return Kt(() => e.apply(this, n));
|
|
1738
|
-
}, Nt.set(e, t)), t;
|
|
1739
|
-
};
|
|
1740
|
-
function dn() {
|
|
1741
|
-
if (oe) return;
|
|
1742
|
-
oe = !0;
|
|
1743
|
-
const e = l.fn.on, t = l.fn.off, n = l.fn.remove, s = l.fn.empty, i = l.fn.detach;
|
|
1744
|
-
l.fn.remove = function(o) {
|
|
1745
|
-
const r = o ? this.filter(o) : this;
|
|
1746
|
-
for (let c = 0, a = r.length; c < a; c++) {
|
|
1747
|
-
const f = r[c];
|
|
1748
|
-
f && (b.cleanupTree(f), b.markIgnored(f));
|
|
1749
|
-
}
|
|
1750
|
-
return n.call(this, o);
|
|
1751
|
-
}, l.fn.empty = function() {
|
|
1752
|
-
for (let o = 0, r = this.length; o < r; o++) {
|
|
1753
|
-
const c = this[o];
|
|
1754
|
-
c && b.cleanupDescendants(c);
|
|
1755
|
-
}
|
|
1756
|
-
return s.call(this);
|
|
1757
|
-
}, l.fn.detach = function(o) {
|
|
1758
|
-
const r = o ? this.filter(o) : this;
|
|
1759
|
-
for (let c = 0, a = r.length; c < a; c++) {
|
|
1760
|
-
const f = r[c];
|
|
1761
|
-
f && b.keep(f);
|
|
1918
|
+
this.cleanups.push(() => n.dispose());
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Navigates to the specified route programmatically.
|
|
1922
|
+
*
|
|
1923
|
+
* If `routeName` resolves to an empty string after falling back to
|
|
1924
|
+
* `config.default`, `setUrl` will be called with an empty string, producing
|
|
1925
|
+
* a URL of `${basePath}/` in history mode. Callers should ensure
|
|
1926
|
+
* `config.default` is always a non-empty route name.
|
|
1927
|
+
*/
|
|
1928
|
+
navigate(t) {
|
|
1929
|
+
if (this.isDestroyed) return;
|
|
1930
|
+
const s = this.currentRouteAtom.peek(), n = this.config.routes[s];
|
|
1931
|
+
if (n?.onLeave && n.onLeave() === !1)
|
|
1932
|
+
return;
|
|
1933
|
+
const i = t || this.config.default;
|
|
1934
|
+
if (!i) {
|
|
1935
|
+
f.warn(
|
|
1936
|
+
d.ROUTE,
|
|
1937
|
+
"navigate() called with empty routeName and no default configured."
|
|
1938
|
+
);
|
|
1939
|
+
return;
|
|
1762
1940
|
}
|
|
1763
|
-
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
o[c] = re(o[c]);
|
|
1777
|
-
break;
|
|
1778
|
-
}
|
|
1779
|
-
return e.apply(this, o);
|
|
1780
|
-
}, l.fn.off = function(...o) {
|
|
1781
|
-
const r = o[0];
|
|
1782
|
-
if (r && typeof r == "object") {
|
|
1783
|
-
const c = r, a = {};
|
|
1784
|
-
for (const f in c) {
|
|
1785
|
-
const p = c[f];
|
|
1786
|
-
p && (a[f] = Nt.get(p) || p);
|
|
1941
|
+
this.setUrl(i), this.queryParamsAtom.value = {}, this.currentRouteAtom.value = i;
|
|
1942
|
+
}
|
|
1943
|
+
/**
|
|
1944
|
+
* Cleans up all event listeners and effects, and releases the template cache.
|
|
1945
|
+
* Each cleanup function is called in a try/catch so that a single failing
|
|
1946
|
+
* cleanup does not prevent the remaining ones from running.
|
|
1947
|
+
*/
|
|
1948
|
+
destroy() {
|
|
1949
|
+
this.isDestroyed || (this.isDestroyed = !0, this.cleanups.forEach((t) => {
|
|
1950
|
+
try {
|
|
1951
|
+
t();
|
|
1952
|
+
} catch (s) {
|
|
1953
|
+
f.warn(d.ROUTE, "Cleanup error during destroy:", s);
|
|
1787
1954
|
}
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
break;
|
|
1794
|
-
}
|
|
1795
|
-
return t.apply(this, o);
|
|
1796
|
-
};
|
|
1955
|
+
}), this.cleanups.length = 0, this.templateCache.clear());
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
function $s(e) {
|
|
1959
|
+
return new Ms(e);
|
|
1797
1960
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1961
|
+
c.extend({
|
|
1962
|
+
route: $s
|
|
1963
|
+
});
|
|
1964
|
+
const Fs = new Promise(() => {
|
|
1965
|
+
});
|
|
1966
|
+
c.extend({
|
|
1967
|
+
atomFetch(e, t) {
|
|
1968
|
+
const { defaultValue: s, transform: n, method: i, headers: r, ajaxOptions: o, onError: l, eager: p } = t, C = typeof e == "function" ? e : null, b = typeof e == "string" ? e : void 0, N = {
|
|
1969
|
+
...o,
|
|
1970
|
+
...i !== void 0 && { method: i },
|
|
1971
|
+
...r !== void 0 && { headers: r }
|
|
1972
|
+
};
|
|
1973
|
+
let E = null;
|
|
1974
|
+
return Ct(
|
|
1975
|
+
async () => {
|
|
1976
|
+
E?.abort(), E = new AbortController();
|
|
1977
|
+
const m = E.signal, P = b ? { ...N, url: b } : { ...N, url: C() }, U = c.ajax(P);
|
|
1978
|
+
m.onabort = () => U.abort(), m.aborted && U.abort();
|
|
1979
|
+
try {
|
|
1980
|
+
const G = await U;
|
|
1981
|
+
return n ? n(G) : G;
|
|
1982
|
+
} catch (G) {
|
|
1983
|
+
if (m.aborted)
|
|
1984
|
+
return Fs;
|
|
1985
|
+
try {
|
|
1986
|
+
l?.(G);
|
|
1987
|
+
} catch {
|
|
1988
|
+
}
|
|
1989
|
+
throw G;
|
|
1990
|
+
} finally {
|
|
1991
|
+
m.onabort = null, E.signal === m && (E = null);
|
|
1992
|
+
}
|
|
1993
|
+
},
|
|
1994
|
+
{ defaultValue: s, lazy: !(p ?? !0) }
|
|
1995
|
+
);
|
|
1996
|
+
}
|
|
1997
|
+
});
|
|
1998
|
+
c(() => {
|
|
1999
|
+
Ns(), Rs(document.body);
|
|
1800
2000
|
});
|
|
1801
2001
|
export {
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
2002
|
+
Ft as atom,
|
|
2003
|
+
ye as batch,
|
|
2004
|
+
Ct as computed,
|
|
2005
|
+
qs as default,
|
|
2006
|
+
Gs as disableAutoCleanup,
|
|
2007
|
+
js as disablejQueryOverrides,
|
|
2008
|
+
X as effect,
|
|
2009
|
+
Rs as enableAutoCleanup,
|
|
2010
|
+
Ns as enablejQueryOverrides,
|
|
2011
|
+
qt as isAtom,
|
|
2012
|
+
Ve as isComputed,
|
|
2013
|
+
Ce as isReactive,
|
|
2014
|
+
Cs as nextTick,
|
|
2015
|
+
g as registry,
|
|
2016
|
+
H as untracked
|
|
1812
2017
|
};
|
|
1813
2018
|
//# sourceMappingURL=index.mjs.map
|