@but212/atom-effect-jquery 0.21.2 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +267 -50
- package/dist/index.mjs +1304 -1078
- 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 dt = {
|
|
|
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 dt = {
|
|
|
33
33
|
MIN_FLUSH_ITERATIONS: 10,
|
|
34
34
|
// Memory management
|
|
35
35
|
BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
|
|
36
|
-
},
|
|
36
|
+
}, Le = {
|
|
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, we = typeof process < "u" && process.env && !1 || !1, ke = 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 xe = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), Pe = /* @__PURE__ */ Symbol("AtomEffect.Type"), Ut = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), yt = {
|
|
63
63
|
// Dev mode flag
|
|
64
|
-
enabled:
|
|
65
|
-
warnInfiniteLoop:
|
|
64
|
+
enabled: we,
|
|
65
|
+
warnInfiniteLoop: Le.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?.[xe],
|
|
75
|
+
getDebugType: (e) => e?.[Pe]
|
|
76
76
|
};
|
|
77
|
-
let
|
|
78
|
-
const
|
|
79
|
-
function
|
|
77
|
+
let Me = 1;
|
|
78
|
+
const $e = () => Me++;
|
|
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 wt(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 wt(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)) : (Dt.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 = $e() & 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 wt(
|
|
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
193
|
let Lt = 0;
|
|
213
|
-
const
|
|
214
|
-
let
|
|
215
|
-
const
|
|
216
|
-
function
|
|
217
|
-
return
|
|
218
|
-
}
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
},
|
|
222
|
-
class
|
|
194
|
+
const jt = () => (Lt = Lt + 1 & It || 1, Lt), $t = (e) => e + 1 & It;
|
|
195
|
+
let zt = 0, pt = !1, pe = 0;
|
|
196
|
+
const Fe = () => pe;
|
|
197
|
+
function se() {
|
|
198
|
+
return pt ? !1 : (pt = !0, pe = jt(), zt = 0, !0);
|
|
199
|
+
}
|
|
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 Ne {
|
|
|
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 > Q.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 Ne {
|
|
|
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 Ne {
|
|
|
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"), me = /* @__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 lt = new Ne(), $t = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ie = /
|
|
|
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 we extends ne {
|
|
|
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 Ue {
|
|
|
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 Ue {
|
|
|
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 Ue {
|
|
|
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" && me in e;
|
|
481
460
|
}
|
|
482
|
-
function
|
|
461
|
+
function ge(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._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 &
|
|
513
|
-
if (this._defaultValue !==
|
|
514
|
-
throw new
|
|
489
|
+
if (t & wt)
|
|
490
|
+
throw new z(y.COMPUTED_DISPOSED);
|
|
491
|
+
if (t & st) {
|
|
492
|
+
if (this._defaultValue !== Ut) return this._defaultValue;
|
|
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,223 @@ class Fe extends ne {
|
|
|
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 & Et) 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 ke;
|
|
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
|
-
H.release(t), this._links = R;
|
|
584
|
-
}
|
|
585
|
-
this._subscribers.length = 0, this.flags = Nt | tt | _t, 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 = me, 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, ge(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 (
|
|
584
|
+
(n) => {
|
|
585
|
+
if (s === this._promiseId) {
|
|
626
586
|
if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion)
|
|
627
587
|
return this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(
|
|
628
|
-
new
|
|
588
|
+
new z(
|
|
629
589
|
`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`
|
|
630
590
|
),
|
|
631
|
-
|
|
591
|
+
y.COMPUTED_ASYNC_COMPUTATION_FAILED
|
|
632
592
|
);
|
|
633
|
-
this._finalizeResolution(
|
|
593
|
+
this._finalizeResolution(n), this._notifySubscribers(n, void 0);
|
|
634
594
|
}
|
|
635
595
|
},
|
|
636
|
-
(
|
|
596
|
+
(n) => s === this._promiseId && this._handleError(n, y.COMPUTED_ASYNC_COMPUTATION_FAILED)
|
|
637
597
|
);
|
|
638
598
|
}
|
|
639
599
|
_captureVersionSnapshot() {
|
|
640
600
|
let t = 0;
|
|
641
|
-
const
|
|
642
|
-
for (let
|
|
643
|
-
t = (t << 5) - t + n
|
|
601
|
+
const s = this._links;
|
|
602
|
+
for (let n = 0, i = s.length; n < i; n++)
|
|
603
|
+
t = (t << 5) - t + s[n].node.version | 0;
|
|
644
604
|
return t;
|
|
645
605
|
}
|
|
646
|
-
_handleError(t,
|
|
647
|
-
const i =
|
|
648
|
-
if (!
|
|
606
|
+
_handleError(t, s, n = !1) {
|
|
607
|
+
const i = Z(t, z, s);
|
|
608
|
+
if (!n && !(this.flags & nt) && (this.version = $t(this.version)), this._error = i, this.flags = this.flags & -121 | nt | ft, this._onError)
|
|
649
609
|
try {
|
|
650
610
|
this._onError(i);
|
|
651
|
-
} catch (
|
|
652
|
-
console.error(
|
|
611
|
+
} catch (r) {
|
|
612
|
+
console.error(y.CALLBACK_ERROR_IN_ERROR_HANDLER, r);
|
|
653
613
|
}
|
|
654
|
-
if (
|
|
614
|
+
if (n) throw i;
|
|
655
615
|
this._notifySubscribers(void 0, void 0);
|
|
656
616
|
}
|
|
657
617
|
_finalizeResolution(t) {
|
|
658
|
-
(!(this.flags &
|
|
618
|
+
(!(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
619
|
}
|
|
660
620
|
execute() {
|
|
661
621
|
this._markDirty();
|
|
662
622
|
}
|
|
663
623
|
/** @internal */
|
|
664
624
|
_markDirty() {
|
|
665
|
-
this.flags & (
|
|
625
|
+
this.flags & (st | K) || (this.flags |= K, this._notifySubscribers(void 0, void 0));
|
|
666
626
|
}
|
|
667
627
|
}
|
|
668
|
-
function
|
|
669
|
-
return new
|
|
628
|
+
function Ct(e, t = {}) {
|
|
629
|
+
return new Qe(e, t);
|
|
670
630
|
}
|
|
671
|
-
var
|
|
672
|
-
class
|
|
673
|
-
constructor(t,
|
|
674
|
-
super(), this[
|
|
631
|
+
var ce;
|
|
632
|
+
class Ke extends _e {
|
|
633
|
+
constructor(t, s = {}) {
|
|
634
|
+
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
635
|
}
|
|
676
636
|
run() {
|
|
677
|
-
if (this.flags &
|
|
678
|
-
throw new
|
|
637
|
+
if (this.flags & L.DISPOSED)
|
|
638
|
+
throw new J(y.EFFECT_DISPOSED);
|
|
679
639
|
this.execute(!0);
|
|
680
640
|
}
|
|
681
641
|
dispose() {
|
|
682
|
-
this.flags &
|
|
642
|
+
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
643
|
}
|
|
684
|
-
[(
|
|
644
|
+
[(ce = Ge, Symbol.dispose)]() {
|
|
685
645
|
this.dispose();
|
|
686
646
|
}
|
|
687
647
|
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
|
-
}
|
|
648
|
+
if (!(this.flags & L.EXECUTING)) return;
|
|
649
|
+
const s = this._currentEpoch;
|
|
650
|
+
if (t._lastSeenEpoch === s) return;
|
|
651
|
+
t._lastSeenEpoch = s;
|
|
652
|
+
const n = this._nextLinks, i = this._prevLinks, r = i.findIndex((o) => o && o.node === t && o.unsub);
|
|
653
|
+
if (r !== -1) {
|
|
654
|
+
const o = i[r];
|
|
655
|
+
o.version = t.version, n.push(o), i[r] = null;
|
|
656
|
+
return;
|
|
699
657
|
}
|
|
700
658
|
try {
|
|
701
659
|
const o = t.subscribe(this._notifyCallback);
|
|
702
|
-
|
|
660
|
+
n.push(new Pt(t, t.version, o));
|
|
703
661
|
} catch (o) {
|
|
704
|
-
const
|
|
705
|
-
if (console.error(
|
|
662
|
+
const l = Z(o, J, y.EFFECT_EXECUTION_FAILED);
|
|
663
|
+
if (console.error(l), this._onError)
|
|
706
664
|
try {
|
|
707
|
-
this._onError(
|
|
665
|
+
this._onError(l);
|
|
708
666
|
} catch {
|
|
709
667
|
}
|
|
710
|
-
|
|
668
|
+
n.push(new Pt(t, t.version, void 0));
|
|
711
669
|
}
|
|
712
670
|
}
|
|
713
671
|
/**
|
|
714
672
|
* Executes effect with tracking.
|
|
715
673
|
*/
|
|
716
674
|
execute(t = !1) {
|
|
717
|
-
if (this.flags & (
|
|
718
|
-
this._checkInfiniteLoops(), this.flags |=
|
|
719
|
-
const
|
|
720
|
-
this._nextLinks =
|
|
721
|
-
let
|
|
675
|
+
if (this.flags & (L.DISPOSED | L.EXECUTING) || !t && this._links.length > 0 && !this._isDirty()) return;
|
|
676
|
+
this._checkInfiniteLoops(), this.flags |= L.EXECUTING, this._execCleanup(), this._prevLinks = this._links;
|
|
677
|
+
const s = B.acquire();
|
|
678
|
+
this._nextLinks = s, this._currentEpoch = jt();
|
|
679
|
+
let n = !1;
|
|
722
680
|
try {
|
|
723
|
-
const i =
|
|
724
|
-
this._links =
|
|
681
|
+
const i = k.run(this, this._fn);
|
|
682
|
+
this._links = s, n = !0, ge(i) ? this._handleAsyncResult(i) : this._cleanup = typeof i == "function" ? i : null;
|
|
725
683
|
} catch (i) {
|
|
726
|
-
this._links =
|
|
684
|
+
this._links = s, n = !0, this._handleExecutionError(i), this._cleanup = null;
|
|
727
685
|
} finally {
|
|
728
|
-
this._finalizeDependencies(
|
|
686
|
+
this._finalizeDependencies(n, this._prevLinks, s), this.flags &= -9;
|
|
729
687
|
}
|
|
730
688
|
}
|
|
731
689
|
_handleAsyncResult(t) {
|
|
732
|
-
const
|
|
690
|
+
const s = ++this._execId;
|
|
733
691
|
t.then(
|
|
734
|
-
(
|
|
735
|
-
if (
|
|
736
|
-
if (typeof
|
|
692
|
+
(n) => {
|
|
693
|
+
if (s !== this._execId || this.flags & L.DISPOSED) {
|
|
694
|
+
if (typeof n == "function")
|
|
737
695
|
try {
|
|
738
|
-
|
|
696
|
+
n();
|
|
739
697
|
} catch (i) {
|
|
740
|
-
this._handleExecutionError(i,
|
|
698
|
+
this._handleExecutionError(i, y.EFFECT_CLEANUP_FAILED);
|
|
741
699
|
}
|
|
742
700
|
return;
|
|
743
701
|
}
|
|
744
|
-
typeof
|
|
702
|
+
typeof n == "function" && (this._cleanup = n);
|
|
745
703
|
},
|
|
746
|
-
(
|
|
704
|
+
(n) => s === this._execId && this._handleExecutionError(n)
|
|
747
705
|
);
|
|
748
706
|
}
|
|
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 !== R && H.release(n);
|
|
756
|
-
} else
|
|
757
|
-
this._unsubLinks(s), H.release(s);
|
|
707
|
+
_finalizeDependencies(t, s, n) {
|
|
708
|
+
this._nextLinks = null, this._prevLinks = O, t ? (s.forEach((i) => i?.unsub?.()), s !== O && B.release(s)) : (this._unsubLinks(n), B.release(n));
|
|
758
709
|
}
|
|
759
710
|
_unsubLinks(t) {
|
|
760
|
-
|
|
761
|
-
t[n]?.unsub?.();
|
|
711
|
+
t.forEach((s) => s?.unsub?.());
|
|
762
712
|
}
|
|
763
713
|
_isDirty() {
|
|
764
|
-
const t = this._links,
|
|
765
|
-
|
|
714
|
+
const t = this._links, s = k.current;
|
|
715
|
+
k.current = null;
|
|
766
716
|
try {
|
|
767
|
-
|
|
768
|
-
const
|
|
769
|
-
if (
|
|
717
|
+
return t.some((n) => {
|
|
718
|
+
const i = n.node;
|
|
719
|
+
if (i.flags & fe.IS_COMPUTED)
|
|
770
720
|
try {
|
|
771
|
-
|
|
721
|
+
i.value;
|
|
772
722
|
} catch {
|
|
773
723
|
return !0;
|
|
774
724
|
}
|
|
775
|
-
|
|
776
|
-
}
|
|
777
|
-
return !1;
|
|
725
|
+
return i.version !== n.version;
|
|
726
|
+
});
|
|
778
727
|
} finally {
|
|
779
|
-
|
|
728
|
+
k.current = s;
|
|
780
729
|
}
|
|
781
730
|
}
|
|
782
731
|
_execCleanup() {
|
|
@@ -784,90 +733,116 @@ class Me extends ee {
|
|
|
784
733
|
try {
|
|
785
734
|
this._cleanup();
|
|
786
735
|
} catch (t) {
|
|
787
|
-
this._handleExecutionError(t,
|
|
736
|
+
this._handleExecutionError(t, y.EFFECT_CLEANUP_FAILED);
|
|
788
737
|
}
|
|
789
738
|
this._cleanup = null;
|
|
790
739
|
}
|
|
791
740
|
}
|
|
792
741
|
_checkInfiniteLoops() {
|
|
793
|
-
const t =
|
|
794
|
-
this._lastFlushEpoch !== t && (this._lastFlushEpoch = t, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
742
|
+
const t = Fe();
|
|
743
|
+
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
744
|
}
|
|
796
745
|
get isDisposed() {
|
|
797
|
-
return (this.flags &
|
|
746
|
+
return (this.flags & L.DISPOSED) !== 0;
|
|
798
747
|
}
|
|
799
748
|
get executionCount() {
|
|
800
749
|
return this._executionCount;
|
|
801
750
|
}
|
|
802
751
|
get isExecuting() {
|
|
803
|
-
return (this.flags &
|
|
752
|
+
return (this.flags & L.EXECUTING) !== 0;
|
|
804
753
|
}
|
|
805
754
|
_throwInfiniteLoopError(t) {
|
|
806
|
-
const
|
|
807
|
-
`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${
|
|
755
|
+
const s = new J(
|
|
756
|
+
`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${zt}`
|
|
808
757
|
);
|
|
809
|
-
throw this.dispose(), console.error(
|
|
758
|
+
throw this.dispose(), console.error(s), s;
|
|
810
759
|
}
|
|
811
|
-
_handleExecutionError(t,
|
|
812
|
-
const
|
|
813
|
-
if (console.error(
|
|
760
|
+
_handleExecutionError(t, s = y.EFFECT_EXECUTION_FAILED) {
|
|
761
|
+
const n = Z(t, J, s);
|
|
762
|
+
if (console.error(n), this._onError)
|
|
814
763
|
try {
|
|
815
|
-
this._onError(
|
|
764
|
+
this._onError(n);
|
|
816
765
|
} catch (i) {
|
|
817
|
-
console.error(
|
|
766
|
+
console.error(Z(i, J, y.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
818
767
|
}
|
|
819
768
|
}
|
|
820
769
|
}
|
|
821
|
-
function
|
|
770
|
+
function X(e, t = {}) {
|
|
822
771
|
if (typeof e != "function")
|
|
823
|
-
throw new
|
|
824
|
-
const
|
|
825
|
-
return
|
|
772
|
+
throw new J(y.EFFECT_MUST_BE_FUNCTION);
|
|
773
|
+
const s = new Ke(e, t);
|
|
774
|
+
return s.execute(), s;
|
|
826
775
|
}
|
|
827
|
-
function
|
|
776
|
+
function Ie(e) {
|
|
828
777
|
if (typeof e != "function")
|
|
829
778
|
throw new TypeError("Batch callback must be a function");
|
|
830
|
-
|
|
779
|
+
rt.startBatch();
|
|
831
780
|
try {
|
|
832
781
|
return e();
|
|
833
782
|
} finally {
|
|
834
|
-
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
function le(e) {
|
|
838
|
-
return re(e) || ce(e);
|
|
839
|
-
}
|
|
840
|
-
function Ot(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;
|
|
783
|
+
rt.endBatch();
|
|
854
784
|
}
|
|
855
|
-
return s;
|
|
856
785
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
786
|
+
const d = {
|
|
787
|
+
/** Used by the SPA router ($.route). */
|
|
788
|
+
ROUTE: "[atom-route]",
|
|
789
|
+
/** Used by all reactive binding helpers (bindText, bindCss, bindAttr, …). */
|
|
790
|
+
BINDING: "[atom-binding]",
|
|
791
|
+
/** Used by atomList reactive list rendering. */
|
|
792
|
+
LIST: "[atom-list]",
|
|
793
|
+
/** Used by mount/unmount lifecycle helpers. */
|
|
794
|
+
MOUNT: "[atom-mount]"
|
|
795
|
+
}, dt = Object.freeze({
|
|
796
|
+
mode: "hash",
|
|
797
|
+
basePath: "",
|
|
798
|
+
autoBindLinks: !1,
|
|
799
|
+
activeClass: "active"
|
|
800
|
+
}), Ye = {
|
|
801
|
+
EVENT: "input"
|
|
802
|
+
}, We = /* @__PURE__ */ new Set(["input", "select", "textarea"]), Je = /* @__PURE__ */ new Set([
|
|
803
|
+
"innerHTML",
|
|
804
|
+
"outerHTML",
|
|
805
|
+
"srcdoc",
|
|
806
|
+
"__proto__",
|
|
807
|
+
"constructor",
|
|
808
|
+
"prototype"
|
|
809
|
+
]), S = {
|
|
810
|
+
ROUTE_NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
|
|
811
|
+
TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
|
|
812
|
+
TARGET_NOT_FOUND: (e) => `Target element "${e}" not found`,
|
|
813
|
+
MALFORMED_URI: (e) => `Malformed URI component: ${e}`,
|
|
814
|
+
/** Emitted when sanitizeHtml modifies the input. Prefixed at call site with LOG_PREFIXES.BINDING or LIST to identify the originating subsystem. */
|
|
815
|
+
UNSAFE_CONTENT: () => "Unsafe content neutralized during sanitization.",
|
|
816
|
+
/** Emitted by bindCss when a CSS style property value contains a dangerous protocol. */
|
|
817
|
+
BLOCKED_DANGEROUS_CSS_VALUE: (e) => `Blocked dangerous value in CSS style property "${e}".`,
|
|
818
|
+
BLOCKED_EVENT_HANDLER: (e) => `Blocked setting dangerous event handler attribute "${e}".`,
|
|
819
|
+
BLOCKED_PROTOCOL: (e) => `Blocked dangerous protocol in "${e}" attribute.`,
|
|
820
|
+
BLOCKED_DANGEROUS_PROP: (e) => `Blocked setting dangerous property "${e}". Use html binding for sanitized HTML.`,
|
|
821
|
+
INVALID_INPUT_ELEMENT: (e) => `Val binding used on non-input element <${e}>.`,
|
|
822
|
+
MISSING_SOURCE: (e) => `[${e}] source is required when prop/name is a string.`,
|
|
823
|
+
MISSING_CONDITION: (e) => `[${e}] condition is required when className is a string.`,
|
|
824
|
+
DUPLICATE_KEY: (e, t) => `Duplicate key "${e}" at index ${t}.`,
|
|
825
|
+
UPDATER_ERROR: (e) => `Updater threw in binding "${e}"`,
|
|
826
|
+
EFFECT_DISPOSE_ERROR: () => "Effect dispose error",
|
|
827
|
+
BINDING_CLEANUP_ERROR: () => "Binding cleanup error",
|
|
828
|
+
PARSE_ERROR: () => "parse() threw during DOM→Atom sync",
|
|
829
|
+
MOUNT_ERROR: () => "Mount error",
|
|
830
|
+
MOUNT_CLEANUP_ERROR: () => "Cleanup error"
|
|
831
|
+
};
|
|
832
|
+
function ye(e) {
|
|
833
|
+
return qt(e);
|
|
834
|
+
}
|
|
835
|
+
function Xt(e) {
|
|
836
|
+
const t = e.tagName.toLowerCase();
|
|
837
|
+
if (e.id) return `${t}#${e.id}`;
|
|
838
|
+
const s = e.classList, n = s.length;
|
|
839
|
+
if (n === 0) return t;
|
|
840
|
+
let i = t;
|
|
841
|
+
for (let r = 0; r < n; r++)
|
|
842
|
+
i += `.${s[r]}`;
|
|
843
|
+
return i;
|
|
869
844
|
}
|
|
870
|
-
const
|
|
845
|
+
const Ze = /* @__PURE__ */ new Set([
|
|
871
846
|
"href",
|
|
872
847
|
"src",
|
|
873
848
|
"action",
|
|
@@ -883,167 +858,208 @@ const $e = /* @__PURE__ */ new Set([
|
|
|
883
858
|
"usemap",
|
|
884
859
|
"classid",
|
|
885
860
|
"codebase"
|
|
886
|
-
]),
|
|
887
|
-
|
|
888
|
-
|
|
861
|
+
]), ts = Object.prototype.hasOwnProperty, es = /^\s*(?:javascript|vbscript)\s*:/i, ss = (
|
|
862
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: Intentionally matching control characters for XSS sanitization
|
|
863
|
+
/(?: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
|
|
864
|
+
), 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");
|
|
865
|
+
function Bt(e) {
|
|
866
|
+
let t = String(e ?? "");
|
|
867
|
+
t = t.replace(is, ""), t = t.replace(rs, "");
|
|
868
|
+
let s;
|
|
869
|
+
do
|
|
870
|
+
s = t, t = t.replace(os, "");
|
|
871
|
+
while (t !== s);
|
|
872
|
+
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;
|
|
873
|
+
}
|
|
874
|
+
function ls(e, t) {
|
|
875
|
+
return Ze.has(e.toLowerCase()) ? es.test(t) : !1;
|
|
889
876
|
}
|
|
890
|
-
function
|
|
891
|
-
return e.toLowerCase().includes("url(") ?
|
|
877
|
+
function fs(e) {
|
|
878
|
+
return e.toLowerCase().includes("url(") ? ns.test(e) : !1;
|
|
892
879
|
}
|
|
893
|
-
function
|
|
880
|
+
function ds(e, t) {
|
|
894
881
|
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 (
|
|
882
|
+
if (e === null || t === null || typeof e != "object" || typeof t != "object") return !1;
|
|
883
|
+
const s = Object.keys(e), n = Object.keys(t);
|
|
884
|
+
if (s.length !== n.length) return !1;
|
|
885
|
+
const i = e, r = t;
|
|
886
|
+
for (let o = 0; o < s.length; o++) {
|
|
887
|
+
const l = s[o];
|
|
888
|
+
if (!ts.call(r, l) || i[l] !== r[l])
|
|
889
|
+
return !1;
|
|
902
890
|
}
|
|
903
891
|
return !0;
|
|
904
892
|
}
|
|
905
|
-
function
|
|
893
|
+
function _s(e) {
|
|
906
894
|
const t = e.length;
|
|
907
895
|
if (t === 0) return new Int32Array(0);
|
|
908
|
-
const
|
|
896
|
+
const s = new Int32Array(t).fill(-1), n = new Int32Array(t);
|
|
909
897
|
let i = 0;
|
|
910
|
-
for (let
|
|
911
|
-
const
|
|
912
|
-
if (
|
|
913
|
-
const
|
|
914
|
-
if (i === 0 ||
|
|
915
|
-
|
|
898
|
+
for (let o = 0; o < t; o++) {
|
|
899
|
+
const l = e[o];
|
|
900
|
+
if (l === void 0 || l === -1) continue;
|
|
901
|
+
const p = i > 0 ? n[i - 1] : void 0;
|
|
902
|
+
if (i === 0 || p !== void 0 && (e[p] ?? -1) < l) {
|
|
903
|
+
s[o] = p ?? -1, n[i++] = o;
|
|
916
904
|
continue;
|
|
917
905
|
}
|
|
918
|
-
let
|
|
919
|
-
for (;
|
|
920
|
-
const
|
|
921
|
-
|
|
906
|
+
let C = 0, b = i - 1;
|
|
907
|
+
for (; C < b; ) {
|
|
908
|
+
const E = C + b >>> 1, m = n[E];
|
|
909
|
+
m !== void 0 && (e[m] ?? -1) < l ? C = E + 1 : b = E;
|
|
922
910
|
}
|
|
923
|
-
const
|
|
924
|
-
|
|
911
|
+
const N = n[C];
|
|
912
|
+
N !== void 0 && l < (e[N] ?? Number.MAX_SAFE_INTEGER) && (C > 0 && (s[o] = n[C - 1] ?? -1), n[C] = o);
|
|
925
913
|
}
|
|
926
|
-
const
|
|
914
|
+
const r = new Int32Array(i);
|
|
927
915
|
if (i > 0) {
|
|
928
|
-
let
|
|
929
|
-
for (let
|
|
930
|
-
|
|
916
|
+
let o = n[i - 1];
|
|
917
|
+
for (let l = i - 1; l >= 0 && o !== void 0 && o !== -1; l--)
|
|
918
|
+
r[l] = o, o = s[o];
|
|
931
919
|
}
|
|
932
|
-
return
|
|
920
|
+
return r;
|
|
933
921
|
}
|
|
934
|
-
|
|
922
|
+
const Es = {}, Ce = 600, ps = `${Ce / 1e3}s`;
|
|
923
|
+
function ms() {
|
|
935
924
|
if (typeof window < "u") {
|
|
936
925
|
const e = window.__ATOM_DEBUG__;
|
|
937
926
|
if (typeof e == "boolean") return e;
|
|
938
927
|
}
|
|
939
|
-
return
|
|
928
|
+
return Es?.VITE_ATOM_DEBUG === "true";
|
|
940
929
|
}
|
|
941
|
-
let
|
|
942
|
-
const
|
|
930
|
+
let Y = ms();
|
|
931
|
+
const f = {
|
|
943
932
|
get enabled() {
|
|
944
|
-
return
|
|
933
|
+
return Y;
|
|
945
934
|
},
|
|
946
935
|
set enabled(e) {
|
|
947
|
-
|
|
936
|
+
Y = e;
|
|
948
937
|
},
|
|
938
|
+
/**
|
|
939
|
+
* Logs a message only when debug mode is active.
|
|
940
|
+
*/
|
|
949
941
|
log(e, ...t) {
|
|
950
|
-
|
|
942
|
+
Y && console.log(`${d.MOUNT} ${e}:`, ...t);
|
|
951
943
|
},
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
944
|
+
/**
|
|
945
|
+
* Logs an atom value change only when debug mode is active.
|
|
946
|
+
*/
|
|
947
|
+
atomChanged(e, t, s) {
|
|
948
|
+
Y && console.log(
|
|
949
|
+
`${d.MOUNT} Atom "${e ?? "anonymous"}" changed:`,
|
|
955
950
|
t,
|
|
956
951
|
"→",
|
|
957
|
-
|
|
952
|
+
s
|
|
958
953
|
);
|
|
959
954
|
},
|
|
960
955
|
/**
|
|
961
|
-
* Logs DOM
|
|
956
|
+
* Logs a DOM update and triggers a visual highlight flash.
|
|
957
|
+
* Only active when debug mode is enabled.
|
|
958
|
+
*
|
|
959
|
+
* @param target - The element or jQuery wrapper that was updated.
|
|
960
|
+
* @param type - The binding type (e.g. 'text', 'checked', 'attr.href').
|
|
961
|
+
* @param value - The new value that was applied.
|
|
962
962
|
*/
|
|
963
|
-
domUpdated(e, t,
|
|
964
|
-
|
|
963
|
+
domUpdated(e, t, s) {
|
|
964
|
+
if (!Y) return;
|
|
965
|
+
const n = e instanceof Element ? e : e[0];
|
|
966
|
+
n instanceof HTMLElement && (console.log(`${d.MOUNT} DOM updated: ${Xt(n)}.${t} =`, s), ys(n));
|
|
965
967
|
},
|
|
968
|
+
/**
|
|
969
|
+
* Logs a cleanup event only when debug mode is active.
|
|
970
|
+
*/
|
|
966
971
|
cleanup(e) {
|
|
967
|
-
|
|
972
|
+
Y && console.log(`${d.MOUNT} Cleanup: ${e}`);
|
|
973
|
+
},
|
|
974
|
+
/**
|
|
975
|
+
* Unconditional warning for runtime errors and unexpected states.
|
|
976
|
+
* Not gated by debugEnabled — these are always surfaced regardless of
|
|
977
|
+
* debug mode because they indicate real problems (e.g. dispose failures,
|
|
978
|
+
* missing route targets, pushState security errors).
|
|
979
|
+
*
|
|
980
|
+
* `prefix` is the subsystem tag (e.g. `LOG_PREFIXES.ROUTE`) so that the
|
|
981
|
+
* originating subsystem appears in the log rather than the generic MOUNT tag.
|
|
982
|
+
* Pass an empty string to emit a prefix-free message.
|
|
983
|
+
*/
|
|
984
|
+
warn(e, t, ...s) {
|
|
985
|
+
console.warn(`${e} ${t}`, ...s);
|
|
968
986
|
},
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
987
|
+
/**
|
|
988
|
+
* Unconditional error for binding failures.
|
|
989
|
+
* Not gated by debugEnabled — binding errors are always surfaced because
|
|
990
|
+
* they indicate a broken updater that silently stopped applying values.
|
|
991
|
+
*/
|
|
992
|
+
error(e, t, s) {
|
|
993
|
+
console.error(`${e} ${t}`, s);
|
|
994
|
+
}
|
|
995
|
+
}, Ht = "atom-debug-highlight", gs = "data-atom-debug";
|
|
996
|
+
let ae;
|
|
997
|
+
function Is() {
|
|
998
|
+
if (ae?.deref()?.isConnected) return;
|
|
977
999
|
const e = document.createElement("style");
|
|
978
|
-
e.textContent = `.${
|
|
979
|
-
}
|
|
980
|
-
const kt = /* @__PURE__ */ new WeakMap();
|
|
981
|
-
function Ge(e) {
|
|
982
|
-
const t = "jquery" in e ? e[0] : e;
|
|
983
|
-
if (!t || !t.isConnected) return;
|
|
984
|
-
Xe();
|
|
985
|
-
const n = kt.get(t);
|
|
986
|
-
n && clearTimeout(n), t.classList.add(xt), kt.set(
|
|
987
|
-
t,
|
|
988
|
-
setTimeout(() => {
|
|
989
|
-
t.classList.remove(xt), kt.delete(t);
|
|
990
|
-
}, 600)
|
|
991
|
-
);
|
|
1000
|
+
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
1001
|
}
|
|
993
|
-
|
|
994
|
-
|
|
1002
|
+
const kt = /* @__PURE__ */ new WeakMap(), xt = /* @__PURE__ */ new WeakMap();
|
|
1003
|
+
function ys(e) {
|
|
1004
|
+
if (!e.isConnected) return;
|
|
1005
|
+
Is();
|
|
1006
|
+
const t = xt.get(e);
|
|
1007
|
+
t !== void 0 && cancelAnimationFrame(t);
|
|
1008
|
+
const s = kt.get(e);
|
|
1009
|
+
s !== void 0 && clearTimeout(s);
|
|
1010
|
+
const n = requestAnimationFrame(() => {
|
|
1011
|
+
xt.delete(e), e.classList.add(Ht), kt.set(
|
|
1012
|
+
e,
|
|
1013
|
+
setTimeout(() => {
|
|
1014
|
+
e.classList.remove(Ht), kt.delete(e);
|
|
1015
|
+
}, Ce)
|
|
1016
|
+
);
|
|
1017
|
+
});
|
|
1018
|
+
xt.set(e, n);
|
|
995
1019
|
}
|
|
996
|
-
|
|
1020
|
+
function be(e, t) {
|
|
1021
|
+
return Ft(e, t);
|
|
1022
|
+
}
|
|
1023
|
+
Object.defineProperty(be, "debug", {
|
|
1024
|
+
enumerable: !0,
|
|
1025
|
+
// configurable: true allows tests and advanced consumers to redefine or
|
|
1026
|
+
// delete the accessor if needed. The default (false) would permanently lock
|
|
1027
|
+
// the property on the function object.
|
|
1028
|
+
configurable: !0,
|
|
997
1029
|
get() {
|
|
998
|
-
return
|
|
1030
|
+
return f.enabled;
|
|
999
1031
|
},
|
|
1000
1032
|
set(e) {
|
|
1001
|
-
|
|
1033
|
+
f.enabled = e;
|
|
1002
1034
|
}
|
|
1003
1035
|
});
|
|
1004
|
-
function
|
|
1036
|
+
function Cs() {
|
|
1005
1037
|
return new Promise((e) => setTimeout(e, 0));
|
|
1006
1038
|
}
|
|
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
|
-
}, Ye = {
|
|
1028
|
-
EVENT: "input"
|
|
1029
|
-
}, We = ["innerHTML", "outerHTML"], it = {
|
|
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
|
-
}, gt = Qe;
|
|
1042
|
-
class Je {
|
|
1039
|
+
const bs = {
|
|
1040
|
+
// `atom` carries a runtime `debug` accessor added via Object.defineProperty.
|
|
1041
|
+
// TypeScript cannot see it through the declared function type, so the double
|
|
1042
|
+
// cast is unavoidable. The NamespaceExtensions annotation still verifies all
|
|
1043
|
+
// other fields; only `atom`'s shape escapes static checking here.
|
|
1044
|
+
atom: be,
|
|
1045
|
+
computed: Ct,
|
|
1046
|
+
effect: X,
|
|
1047
|
+
batch: Ie,
|
|
1048
|
+
untracked: H,
|
|
1049
|
+
isAtom: qt,
|
|
1050
|
+
isComputed: Ve,
|
|
1051
|
+
isReactive: ye,
|
|
1052
|
+
nextTick: Cs
|
|
1053
|
+
};
|
|
1054
|
+
c.extend(bs);
|
|
1055
|
+
const W = "_aes-bound";
|
|
1056
|
+
class Ss {
|
|
1043
1057
|
constructor() {
|
|
1044
|
-
this.records = /* @__PURE__ */ new WeakMap(), this.
|
|
1058
|
+
this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1045
1059
|
}
|
|
1046
|
-
//
|
|
1060
|
+
// --------------------------------------------------------------------------
|
|
1061
|
+
// Lifecycle flags
|
|
1062
|
+
// --------------------------------------------------------------------------
|
|
1047
1063
|
keep(t) {
|
|
1048
1064
|
this.preservedNodes.add(t);
|
|
1049
1065
|
}
|
|
@@ -1056,735 +1072,945 @@ class Je {
|
|
|
1056
1072
|
isIgnored(t) {
|
|
1057
1073
|
return this.ignoredNodes.has(t);
|
|
1058
1074
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1075
|
+
// --------------------------------------------------------------------------
|
|
1076
|
+
// Tracking
|
|
1077
|
+
// --------------------------------------------------------------------------
|
|
1078
|
+
getOrCreateRecord(t) {
|
|
1079
|
+
let s = this.records.get(t);
|
|
1080
|
+
return s || (s = {}, this.records.set(t, s), t.classList.add(W)), s;
|
|
1081
|
+
}
|
|
1082
|
+
trackEffect(t, s) {
|
|
1083
|
+
const n = this.getOrCreateRecord(t);
|
|
1084
|
+
n.effects ??= [], n.effects.push(s);
|
|
1062
1085
|
}
|
|
1063
|
-
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1086
|
+
trackCleanup(t, s) {
|
|
1087
|
+
const n = this.getOrCreateRecord(t);
|
|
1088
|
+
n.cleanups ??= [], n.cleanups.push(s);
|
|
1066
1089
|
}
|
|
1067
|
-
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1090
|
+
setComponentCleanup(t, s) {
|
|
1091
|
+
const n = this.getOrCreateRecord(t);
|
|
1092
|
+
n.componentCleanup = s;
|
|
1070
1093
|
}
|
|
1071
1094
|
hasBind(t) {
|
|
1072
|
-
return this.
|
|
1095
|
+
return this.records.has(t);
|
|
1073
1096
|
}
|
|
1097
|
+
// --------------------------------------------------------------------------
|
|
1098
|
+
// Cleanup
|
|
1099
|
+
// --------------------------------------------------------------------------
|
|
1074
1100
|
cleanup(t) {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
if (s)
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1101
|
+
const s = this.records.get(t);
|
|
1102
|
+
if (!s) {
|
|
1103
|
+
t.isConnected && t.classList.remove(W), this.preservedNodes.delete(t), this.ignoredNodes.delete(t);
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
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)
|
|
1107
|
+
try {
|
|
1108
|
+
s.componentCleanup();
|
|
1109
|
+
} catch (n) {
|
|
1110
|
+
f.error(d.MOUNT, S.MOUNT_CLEANUP_ERROR(), n);
|
|
1111
|
+
}
|
|
1112
|
+
s.effects?.forEach((n) => {
|
|
1113
|
+
try {
|
|
1114
|
+
n.dispose();
|
|
1115
|
+
} catch (i) {
|
|
1116
|
+
f.error(d.BINDING, S.EFFECT_DISPOSE_ERROR(), i);
|
|
1117
|
+
}
|
|
1118
|
+
}), s.cleanups?.forEach((n) => {
|
|
1119
|
+
try {
|
|
1120
|
+
n();
|
|
1121
|
+
} catch (i) {
|
|
1122
|
+
f.error(d.BINDING, S.BINDING_CLEANUP_ERROR(), i);
|
|
1123
|
+
}
|
|
1124
|
+
});
|
|
1095
1125
|
}
|
|
1096
1126
|
cleanupDescendants(t) {
|
|
1097
|
-
const
|
|
1098
|
-
for (
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1127
|
+
const s = t.querySelectorAll(`.${W}`);
|
|
1128
|
+
for (const n of s)
|
|
1129
|
+
this.records.has(n) ? this.cleanup(n) : (n.classList.remove(W), f.warn(
|
|
1130
|
+
d.BINDING,
|
|
1131
|
+
`${W} class found on unregistered element:`,
|
|
1132
|
+
n
|
|
1133
|
+
));
|
|
1102
1134
|
}
|
|
1103
1135
|
cleanupTree(t) {
|
|
1104
1136
|
this.cleanupDescendants(t), this.cleanup(t);
|
|
1105
1137
|
}
|
|
1106
1138
|
}
|
|
1107
|
-
const
|
|
1108
|
-
let
|
|
1109
|
-
function
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1139
|
+
const g = new Ss();
|
|
1140
|
+
let it = null, Et = null;
|
|
1141
|
+
function Ts(e) {
|
|
1142
|
+
if (it !== null) {
|
|
1143
|
+
Et !== e && f.warn(
|
|
1144
|
+
d.BINDING,
|
|
1145
|
+
"enableAutoCleanup() called with a different root while already active. Observation was NOT switched — call disableAutoCleanup() first.",
|
|
1146
|
+
{ current: Et, requested: e }
|
|
1147
|
+
);
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
Et = e, it = new MutationObserver((t) => {
|
|
1151
|
+
for (const s of t)
|
|
1152
|
+
for (const n of s.removedNodes)
|
|
1153
|
+
n.nodeType === 1 && (n.isConnected || g.isKept(n) || g.isIgnored(n) || g.cleanupTree(n));
|
|
1154
|
+
}), it.observe(e, { childList: !0, subtree: !0 });
|
|
1155
|
+
}
|
|
1156
|
+
function Gs() {
|
|
1157
|
+
it?.disconnect(), it = null, Et = null;
|
|
1158
|
+
}
|
|
1159
|
+
function Q(e, t, s, n) {
|
|
1160
|
+
if (ye(t)) {
|
|
1161
|
+
const i = t;
|
|
1162
|
+
g.trackEffect(
|
|
1163
|
+
e,
|
|
1164
|
+
X(() => {
|
|
1165
|
+
const r = i.value;
|
|
1166
|
+
H(() => {
|
|
1167
|
+
try {
|
|
1168
|
+
s(r);
|
|
1169
|
+
} catch (o) {
|
|
1170
|
+
f.error(d.BINDING, `${S.UPDATER_ERROR(n)}:`, o);
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
f.enabled && f.domUpdated(e, n, r);
|
|
1174
|
+
});
|
|
1175
|
+
})
|
|
1176
|
+
);
|
|
1177
|
+
} else {
|
|
1178
|
+
try {
|
|
1179
|
+
s(t);
|
|
1180
|
+
} catch (i) {
|
|
1181
|
+
f.error(d.BINDING, `${S.UPDATER_ERROR(n)} (static):`, i);
|
|
1182
|
+
return;
|
|
1120
1183
|
}
|
|
1121
|
-
|
|
1122
|
-
}
|
|
1123
|
-
function un() {
|
|
1124
|
-
ut?.disconnect(), ut = null;
|
|
1125
|
-
}
|
|
1126
|
-
function V(e, t, n, s) {
|
|
1127
|
-
le(t) ? y.trackEffect(
|
|
1128
|
-
e,
|
|
1129
|
-
Y(() => {
|
|
1130
|
-
const i = t.value;
|
|
1131
|
-
n(i), m.domUpdated(l(e), s, i);
|
|
1132
|
-
})
|
|
1133
|
-
) : (n(t), m.enabled && m.domUpdated(l(e), s, t));
|
|
1134
|
-
}
|
|
1135
|
-
var O = /* @__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))(O || {});
|
|
1136
|
-
function fe() {
|
|
1137
|
-
return {
|
|
1138
|
-
timeoutId: null,
|
|
1139
|
-
flags: 0
|
|
1140
|
-
/* None */
|
|
1141
|
-
};
|
|
1184
|
+
f.enabled && f.domUpdated(e, n, t);
|
|
1185
|
+
}
|
|
1142
1186
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1187
|
+
const F = /* @__PURE__ */ Symbol("atom-effect-internal"), mt = /* @__PURE__ */ new WeakMap();
|
|
1188
|
+
let w = null;
|
|
1189
|
+
const Se = (e) => {
|
|
1190
|
+
if (e[F]) return e;
|
|
1191
|
+
let t = mt.get(e);
|
|
1192
|
+
return t || (t = function(...s) {
|
|
1193
|
+
return Ie(() => e.apply(this, s));
|
|
1194
|
+
}, t[F] = !0, mt.set(e, t)), t;
|
|
1195
|
+
};
|
|
1196
|
+
function Rs(e) {
|
|
1197
|
+
const t = {};
|
|
1198
|
+
return Object.keys(e).forEach((s) => {
|
|
1199
|
+
const n = e[s];
|
|
1200
|
+
n && (t[s] = Se(n));
|
|
1201
|
+
}), t;
|
|
1202
|
+
}
|
|
1203
|
+
function Os(e) {
|
|
1204
|
+
const t = {};
|
|
1205
|
+
return Object.keys(e).forEach((s) => {
|
|
1206
|
+
const n = e[s];
|
|
1207
|
+
t[s] = n ? mt.get(n) ?? n : void 0;
|
|
1208
|
+
}), t;
|
|
1209
|
+
}
|
|
1210
|
+
function Ns() {
|
|
1211
|
+
if (w !== null) return;
|
|
1212
|
+
w = {
|
|
1213
|
+
on: c.fn.on,
|
|
1214
|
+
off: c.fn.off,
|
|
1215
|
+
remove: c.fn.remove,
|
|
1216
|
+
empty: c.fn.empty,
|
|
1217
|
+
detach: c.fn.detach
|
|
1218
|
+
};
|
|
1219
|
+
const e = w;
|
|
1220
|
+
c.fn.remove = function(t) {
|
|
1221
|
+
const s = t ? this.filter(t) : this;
|
|
1222
|
+
for (let n = 0, i = s.length; n < i; n++) {
|
|
1223
|
+
const r = s[n];
|
|
1224
|
+
r && (g.markIgnored(r), g.cleanupTree(r));
|
|
1159
1225
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1226
|
+
return e.remove.call(this, t);
|
|
1227
|
+
}, c.fn.empty = function() {
|
|
1228
|
+
for (let t = 0, s = this.length; t < s; t++) {
|
|
1229
|
+
const n = this[t];
|
|
1230
|
+
n && g.cleanupDescendants(n);
|
|
1231
|
+
}
|
|
1232
|
+
return e.empty.call(this);
|
|
1233
|
+
}, c.fn.detach = function(t) {
|
|
1234
|
+
const s = t ? this.filter(t) : this;
|
|
1235
|
+
for (let n = 0, i = s.length; n < i; n++) {
|
|
1236
|
+
const r = s[n];
|
|
1237
|
+
r && g.keep(r);
|
|
1238
|
+
}
|
|
1239
|
+
return e.detach.call(this, t);
|
|
1240
|
+
}, c.fn.on = function(...t) {
|
|
1241
|
+
const s = t[0];
|
|
1242
|
+
if (s && typeof s == "object")
|
|
1243
|
+
t[0] = Rs(s);
|
|
1244
|
+
else
|
|
1245
|
+
for (let n = t.length - 1; n >= 0; n--)
|
|
1246
|
+
if (typeof t[n] == "function") {
|
|
1247
|
+
t[n] = Se(t[n]);
|
|
1248
|
+
break;
|
|
1249
|
+
}
|
|
1250
|
+
return e.on.apply(this, t);
|
|
1251
|
+
}, c.fn.off = function(...t) {
|
|
1252
|
+
const s = t[0];
|
|
1253
|
+
if (s && typeof s == "object")
|
|
1254
|
+
t[0] = Os(s);
|
|
1255
|
+
else
|
|
1256
|
+
for (let n = t.length - 1; n >= 0; n--)
|
|
1257
|
+
if (typeof t[n] == "function") {
|
|
1258
|
+
const i = t[n];
|
|
1259
|
+
t[n] = mt.get(i) ?? i;
|
|
1260
|
+
break;
|
|
1261
|
+
}
|
|
1262
|
+
return e.off.apply(this, t);
|
|
1179
1263
|
};
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1264
|
+
}
|
|
1265
|
+
function js() {
|
|
1266
|
+
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);
|
|
1267
|
+
}
|
|
1268
|
+
var R = /* @__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))(R || {});
|
|
1269
|
+
let vs = 0;
|
|
1270
|
+
class Ds {
|
|
1271
|
+
constructor(t, s, n) {
|
|
1272
|
+
this.flags = 0, this.timeoutId = void 0, this.ns = `.atomBind-${++vs}`, this.handleCompositionStart = () => {
|
|
1273
|
+
this.flags |= R.Composing;
|
|
1274
|
+
}, this.handleCompositionEnd = () => {
|
|
1275
|
+
this.flags &= ~R.Composing, this.handleInput();
|
|
1276
|
+
}, this.handleFocus = () => {
|
|
1277
|
+
this.flags |= R.Focused;
|
|
1278
|
+
}, this.handleBlur = () => {
|
|
1279
|
+
this.flags &= ~R.Focused, this.timeoutId !== void 0 && (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom());
|
|
1280
|
+
const r = this.options.format(this.atom.peek());
|
|
1281
|
+
this.el.value !== r && (this.el.value = r);
|
|
1282
|
+
}, this.syncDomFromAtom = () => {
|
|
1283
|
+
const r = this.atom.value;
|
|
1284
|
+
H(() => {
|
|
1285
|
+
const o = this.options.format(r), l = this.el.value;
|
|
1286
|
+
if (l === o) return;
|
|
1287
|
+
const p = !!(this.flags & R.Focused);
|
|
1288
|
+
if (p)
|
|
1289
|
+
try {
|
|
1290
|
+
if (this.options.equal(this.options.parse(l), r)) return;
|
|
1291
|
+
} catch {
|
|
1292
|
+
}
|
|
1293
|
+
this.flags |= R.SyncingToDom;
|
|
1294
|
+
try {
|
|
1295
|
+
if (p && (this.el instanceof HTMLInputElement || this.el instanceof HTMLTextAreaElement)) {
|
|
1296
|
+
const C = this.el.selectionStart, b = this.el.selectionEnd;
|
|
1297
|
+
this.el.value = o;
|
|
1298
|
+
const N = o.length;
|
|
1299
|
+
C !== null && b !== null && this.el.setSelectionRange(Math.min(C, N), Math.min(b, N));
|
|
1300
|
+
} else
|
|
1301
|
+
this.el.value = o;
|
|
1302
|
+
f.domUpdated(this.$el, "val", o);
|
|
1303
|
+
} finally {
|
|
1304
|
+
this.flags &= ~R.SyncingToDom;
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
}, this.cleanup = () => {
|
|
1308
|
+
this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
|
|
1309
|
+
}, this.$el = t, this.el = t[0], this.atom = s;
|
|
1310
|
+
const i = n.debounce ?? 0;
|
|
1311
|
+
this.options = {
|
|
1312
|
+
debounce: i,
|
|
1313
|
+
event: n.event ?? Ye.EVENT,
|
|
1314
|
+
parse: n.parse ?? ((r) => r),
|
|
1315
|
+
format: n.format ?? ((r) => String(r ?? "")),
|
|
1316
|
+
equal: n.equal ?? Object.is
|
|
1317
|
+
}, i > 0 ? this.handleInput = () => {
|
|
1318
|
+
this.flags & R.Composing || (clearTimeout(this.timeoutId), this.timeoutId = setTimeout(() => this.syncAtomFromDom(), i));
|
|
1319
|
+
} : this.handleInput = () => {
|
|
1320
|
+
this.flags & R.Composing || this.syncAtomFromDom();
|
|
1321
|
+
}, this.handleFocus[F] = !0, this.handleBlur[F] = !0, this.handleCompositionStart[F] = !0, this.handleCompositionEnd[F] = !0, this.handleInput[F] = !0, this.bindEvents();
|
|
1322
|
+
}
|
|
1323
|
+
// --- Sync Logic ---
|
|
1324
|
+
syncAtomFromDom() {
|
|
1325
|
+
if (!(this.flags & R.Busy)) {
|
|
1326
|
+
this.flags |= R.SyncingToAtom;
|
|
1184
1327
|
try {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
h.setSelectionRange(Math.min(J ?? 0, B), Math.min(ot ?? 0, B));
|
|
1190
|
-
} else
|
|
1191
|
-
h.value = C;
|
|
1192
|
-
m.domUpdated(e, "val", C);
|
|
1328
|
+
const t = this.options.parse(this.el.value);
|
|
1329
|
+
this.options.equal(this.atom.peek(), t) || (this.atom.value = t);
|
|
1330
|
+
} catch (t) {
|
|
1331
|
+
f.warn(d.BINDING, `${S.PARSE_ERROR()}:`, t);
|
|
1193
1332
|
} finally {
|
|
1194
|
-
|
|
1333
|
+
this.flags &= ~R.SyncingToAtom;
|
|
1195
1334
|
}
|
|
1196
1335
|
}
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1336
|
+
}
|
|
1337
|
+
bindEvents() {
|
|
1338
|
+
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);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
function As(e, t, s) {
|
|
1342
|
+
const n = new Ds(e, t, s);
|
|
1343
|
+
return { fx: X(n.syncDomFromAtom), cleanup: n.cleanup };
|
|
1200
1344
|
}
|
|
1201
|
-
const
|
|
1202
|
-
function
|
|
1203
|
-
let t =
|
|
1204
|
-
return t || (t = e.includes("-") ? e.replace(/-./g, (
|
|
1345
|
+
const he = /* @__PURE__ */ new Map();
|
|
1346
|
+
function Us(e) {
|
|
1347
|
+
let t = he.get(e);
|
|
1348
|
+
return t !== void 0 || (t = e.includes("-") ? e.replace(/-./g, (s) => s[1].toUpperCase()) : e, he.set(e, t)), t;
|
|
1205
1349
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1350
|
+
const ue = /* @__PURE__ */ new WeakMap();
|
|
1351
|
+
function Ls(e) {
|
|
1352
|
+
let t = ue.get(e);
|
|
1353
|
+
return t || (t = Ct(() => Bt(e.value)), ue.set(e, t)), t;
|
|
1354
|
+
}
|
|
1355
|
+
function D(e) {
|
|
1208
1356
|
return {
|
|
1209
|
-
|
|
1210
|
-
return t || (t = l(e)), t;
|
|
1211
|
-
},
|
|
1357
|
+
$el: c(e),
|
|
1212
1358
|
el: e,
|
|
1213
|
-
trackCleanup: (
|
|
1359
|
+
trackCleanup: (t) => g.trackCleanup(e, t)
|
|
1214
1360
|
};
|
|
1215
1361
|
}
|
|
1216
|
-
function
|
|
1362
|
+
function Te(e, t, s) {
|
|
1217
1363
|
const n = e.el;
|
|
1218
|
-
|
|
1364
|
+
Q(
|
|
1219
1365
|
n,
|
|
1220
1366
|
t,
|
|
1221
|
-
(
|
|
1222
|
-
const
|
|
1223
|
-
n.textContent !==
|
|
1367
|
+
(i) => {
|
|
1368
|
+
const r = s ? s(i) : typeof i == "string" ? i : String(i ?? "");
|
|
1369
|
+
n.textContent !== r && (n.textContent = r);
|
|
1224
1370
|
},
|
|
1225
1371
|
"text"
|
|
1226
1372
|
);
|
|
1227
1373
|
}
|
|
1228
|
-
function
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1374
|
+
function Re(e, t) {
|
|
1375
|
+
const s = e.el, n = qt(t) ? Ls(t) : t;
|
|
1376
|
+
Q(
|
|
1377
|
+
s,
|
|
1231
1378
|
n,
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
const i = String(s ?? ""), o = bt(i);
|
|
1235
|
-
o !== i && console.warn(`${W.BIND} ${it.UNSAFE_CONTENT}`), n.innerHTML !== o && (n.innerHTML = o);
|
|
1379
|
+
(i) => {
|
|
1380
|
+
s.innerHTML !== i && (g.cleanupDescendants(s), s.innerHTML = i);
|
|
1236
1381
|
},
|
|
1237
1382
|
"html"
|
|
1238
1383
|
);
|
|
1239
1384
|
}
|
|
1240
|
-
function
|
|
1241
|
-
|
|
1242
|
-
|
|
1385
|
+
function Oe(e, t) {
|
|
1386
|
+
Object.entries(t).forEach(([s, n]) => {
|
|
1387
|
+
Q(
|
|
1243
1388
|
e.el,
|
|
1244
|
-
|
|
1245
|
-
(
|
|
1246
|
-
e.el.classList.toggle(
|
|
1389
|
+
n,
|
|
1390
|
+
(i) => {
|
|
1391
|
+
e.el.classList.toggle(s, !!i);
|
|
1247
1392
|
},
|
|
1248
|
-
`class.${
|
|
1393
|
+
`class.${s}`
|
|
1249
1394
|
);
|
|
1395
|
+
});
|
|
1250
1396
|
}
|
|
1251
|
-
function
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1254
|
-
const o =
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
const S = h ? `${E}${h}` : String(E);
|
|
1262
|
-
if (He(S)) {
|
|
1263
|
-
console.warn(`${W.BIND} ${it.BLOCKED_DANGEROUS_VALUE(i)}`);
|
|
1264
|
-
return;
|
|
1265
|
-
}
|
|
1266
|
-
s[r] = S;
|
|
1397
|
+
function Ne(e, t) {
|
|
1398
|
+
const s = e.el, n = s.style;
|
|
1399
|
+
Object.entries(t).forEach(([i, r]) => {
|
|
1400
|
+
const o = Us(i), [l, p] = Array.isArray(r) ? r : [r, ""];
|
|
1401
|
+
Q(
|
|
1402
|
+
s,
|
|
1403
|
+
l,
|
|
1404
|
+
(C) => {
|
|
1405
|
+
const b = p ? `${C}${p}` : String(C);
|
|
1406
|
+
fs(b) || (n[o] = b);
|
|
1267
1407
|
},
|
|
1268
1408
|
`css.${i}`
|
|
1269
1409
|
);
|
|
1270
|
-
}
|
|
1410
|
+
});
|
|
1271
1411
|
}
|
|
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 (je(s, r)) {
|
|
1290
|
-
console.warn(`${W.BIND} ${it.BLOCKED_PROTOCOL(s)}`);
|
|
1412
|
+
function ve(e, t) {
|
|
1413
|
+
const s = e.el;
|
|
1414
|
+
Object.keys(t).forEach((n) => {
|
|
1415
|
+
n.toLowerCase().startsWith("on") || Q(
|
|
1416
|
+
s,
|
|
1417
|
+
t[n],
|
|
1418
|
+
(i) => {
|
|
1419
|
+
if (i == null || i === !1) {
|
|
1420
|
+
s.removeAttribute(n);
|
|
1291
1421
|
return;
|
|
1292
1422
|
}
|
|
1293
|
-
|
|
1423
|
+
const r = i === !0 ? n : String(i);
|
|
1424
|
+
ls(n, r) || s.getAttribute(n) !== r && s.setAttribute(n, r);
|
|
1294
1425
|
},
|
|
1295
|
-
`attr.${
|
|
1426
|
+
`attr.${n}`
|
|
1296
1427
|
);
|
|
1297
|
-
}
|
|
1428
|
+
});
|
|
1298
1429
|
}
|
|
1299
|
-
function
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
console.warn(`${W.BIND} ${it.BLOCKED_DANGEROUS_PROP(s)}`);
|
|
1304
|
-
continue;
|
|
1305
|
-
}
|
|
1306
|
-
V(
|
|
1430
|
+
function De(e, t) {
|
|
1431
|
+
const s = e.el;
|
|
1432
|
+
Object.keys(t).forEach((n) => {
|
|
1433
|
+
Je.has(n) || Q(
|
|
1307
1434
|
e.el,
|
|
1308
|
-
t[
|
|
1435
|
+
t[n],
|
|
1309
1436
|
(i) => {
|
|
1310
|
-
n
|
|
1437
|
+
s[n] !== i && (s[n] = i);
|
|
1311
1438
|
},
|
|
1312
|
-
`prop.${
|
|
1439
|
+
`prop.${n}`
|
|
1313
1440
|
);
|
|
1314
|
-
}
|
|
1441
|
+
});
|
|
1315
1442
|
}
|
|
1316
|
-
function
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
|
|
1443
|
+
function gt(e, t, s) {
|
|
1444
|
+
const n = e.el;
|
|
1445
|
+
Q(
|
|
1446
|
+
n,
|
|
1320
1447
|
t,
|
|
1321
|
-
(
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1448
|
+
(r) => {
|
|
1449
|
+
const o = s !== !!r;
|
|
1450
|
+
n.style.display = o ? "" : "none";
|
|
1324
1451
|
},
|
|
1325
|
-
s
|
|
1452
|
+
s ? "hide" : "show"
|
|
1326
1453
|
);
|
|
1327
1454
|
}
|
|
1328
|
-
function
|
|
1455
|
+
function Gt(e, t, s = {}) {
|
|
1329
1456
|
const n = e.el.tagName.toLowerCase();
|
|
1330
|
-
if (n
|
|
1331
|
-
console.warn(
|
|
1457
|
+
if (!We.has(n)) {
|
|
1458
|
+
console.warn(`${d.BINDING} ${S.INVALID_INPUT_ELEMENT(n)}`);
|
|
1332
1459
|
return;
|
|
1333
1460
|
}
|
|
1334
|
-
const
|
|
1335
|
-
|
|
1336
|
-
s ? t[0] : t,
|
|
1337
|
-
s ? t[1] : {}
|
|
1338
|
-
);
|
|
1339
|
-
y.trackEffect(e.el, Y(i)), e.trackCleanup(o);
|
|
1461
|
+
const { fx: i, cleanup: r } = As(e.$el, t, s);
|
|
1462
|
+
g.trackEffect(e.el, i), e.trackCleanup(r);
|
|
1340
1463
|
}
|
|
1341
|
-
function
|
|
1342
|
-
const
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
t.value !== c && (t.value = c);
|
|
1464
|
+
function Ae(e, t) {
|
|
1465
|
+
const s = e.el, n = e.$el, i = () => {
|
|
1466
|
+
const o = s.checked;
|
|
1467
|
+
t.value !== o && (t.value = o);
|
|
1346
1468
|
};
|
|
1347
|
-
|
|
1348
|
-
const r =
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1469
|
+
i[F] = !0, n.on("change", i), e.trackCleanup(() => n.off("change", i));
|
|
1470
|
+
const r = X(() => {
|
|
1471
|
+
const o = !!t.value;
|
|
1472
|
+
H(() => {
|
|
1473
|
+
s.checked !== o && (s.checked = o, f.domUpdated(n, "checked", o));
|
|
1474
|
+
});
|
|
1352
1475
|
});
|
|
1353
|
-
|
|
1354
|
-
}
|
|
1355
|
-
function
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
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
|
-
}
|
|
1476
|
+
g.trackEffect(s, r);
|
|
1477
|
+
}
|
|
1478
|
+
function ws(e, t) {
|
|
1479
|
+
const s = e.$el;
|
|
1480
|
+
s.on(t), e.trackCleanup(() => s.off(t));
|
|
1481
|
+
}
|
|
1482
|
+
function ks(e, t, s) {
|
|
1483
|
+
const n = e.$el;
|
|
1484
|
+
n.on(t, s), e.trackCleanup(() => n.off(t, s));
|
|
1369
1485
|
}
|
|
1370
|
-
|
|
1486
|
+
function Ue(e) {
|
|
1487
|
+
g.cleanupTree(e);
|
|
1488
|
+
}
|
|
1489
|
+
c.fn.atomText = function(e, t) {
|
|
1371
1490
|
return this.each(function() {
|
|
1372
|
-
|
|
1373
|
-
e.text !== void 0 && nn(t, e.text), e.html !== void 0 && de(t, e.html), e.class && _e(t, e.class), e.css && Ee(t, e.css), e.attr && pe(t, e.attr), e.prop && ge(t, e.prop), e.show !== void 0 && Ct(t, e.show, !1, "show"), e.hide !== void 0 && Ct(t, e.hide, !0, "hide"), e.val !== void 0 && me(t, e.val), e.checked !== void 0 && ye(t, e.checked), e.on && sn(t, e.on);
|
|
1491
|
+
Te(D(this), e, t);
|
|
1374
1492
|
});
|
|
1375
1493
|
};
|
|
1376
|
-
|
|
1494
|
+
c.fn.atomHtml = function(e) {
|
|
1377
1495
|
return this.each(function() {
|
|
1378
|
-
|
|
1379
|
-
V(this, e, t ? (i) => n.text(t(i)) : (i) => n.text(String(i ?? "")), "text");
|
|
1496
|
+
Re(D(this), e);
|
|
1380
1497
|
});
|
|
1381
1498
|
};
|
|
1382
|
-
|
|
1499
|
+
c.fn.atomClass = function(e, t) {
|
|
1500
|
+
if (typeof e == "string" && t === void 0)
|
|
1501
|
+
return console.warn(`${d.BINDING} ${S.MISSING_CONDITION("atomClass")}`), this;
|
|
1502
|
+
const s = typeof e == "string" ? { [e]: t } : e;
|
|
1383
1503
|
return this.each(function() {
|
|
1384
|
-
|
|
1504
|
+
Oe(D(this), s);
|
|
1385
1505
|
});
|
|
1386
1506
|
};
|
|
1387
|
-
|
|
1507
|
+
c.fn.atomCss = function(e, t, s) {
|
|
1508
|
+
if (typeof e == "string" && t === void 0)
|
|
1509
|
+
return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomCss")}`), this;
|
|
1510
|
+
const n = typeof e == "string" ? { [e]: s ? [t, s] : t } : e;
|
|
1388
1511
|
return this.each(function() {
|
|
1389
|
-
|
|
1512
|
+
Ne(D(this), n);
|
|
1390
1513
|
});
|
|
1391
1514
|
};
|
|
1392
|
-
|
|
1515
|
+
c.fn.atomAttr = function(e, t) {
|
|
1516
|
+
if (typeof e == "string" && t === void 0)
|
|
1517
|
+
return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomAttr")}`), this;
|
|
1518
|
+
const s = typeof e == "string" ? { [e]: t } : e;
|
|
1393
1519
|
return this.each(function() {
|
|
1394
|
-
|
|
1520
|
+
ve(D(this), s);
|
|
1395
1521
|
});
|
|
1396
1522
|
};
|
|
1397
|
-
|
|
1523
|
+
c.fn.atomProp = function(e, t) {
|
|
1524
|
+
if (typeof e == "string" && t === void 0)
|
|
1525
|
+
return console.warn(`${d.BINDING} ${S.MISSING_SOURCE("atomProp")}`), this;
|
|
1526
|
+
const s = typeof e == "string" ? { [e]: t } : e;
|
|
1398
1527
|
return this.each(function() {
|
|
1399
|
-
|
|
1528
|
+
De(D(this), s);
|
|
1400
1529
|
});
|
|
1401
1530
|
};
|
|
1402
|
-
|
|
1531
|
+
c.fn.atomShow = function(e) {
|
|
1403
1532
|
return this.each(function() {
|
|
1404
|
-
|
|
1533
|
+
gt(D(this), e, !1);
|
|
1405
1534
|
});
|
|
1406
1535
|
};
|
|
1407
|
-
|
|
1536
|
+
c.fn.atomHide = function(e) {
|
|
1408
1537
|
return this.each(function() {
|
|
1409
|
-
|
|
1538
|
+
gt(D(this), e, !0);
|
|
1410
1539
|
});
|
|
1411
1540
|
};
|
|
1412
|
-
|
|
1541
|
+
c.fn.atomVal = function(e, t = {}) {
|
|
1413
1542
|
return this.each(function() {
|
|
1414
|
-
|
|
1543
|
+
Gt(D(this), e, t);
|
|
1415
1544
|
});
|
|
1416
1545
|
};
|
|
1417
|
-
|
|
1546
|
+
c.fn.atomChecked = function(e) {
|
|
1418
1547
|
return this.each(function() {
|
|
1419
|
-
|
|
1420
|
-
M(this),
|
|
1421
|
-
t && Object.keys(t).length > 0 ? [e, t] : e
|
|
1422
|
-
);
|
|
1548
|
+
Ae(D(this), e);
|
|
1423
1549
|
});
|
|
1424
1550
|
};
|
|
1425
|
-
|
|
1551
|
+
c.fn.atomOn = function(e, t) {
|
|
1426
1552
|
return this.each(function() {
|
|
1427
|
-
|
|
1553
|
+
ks(D(this), e, t);
|
|
1428
1554
|
});
|
|
1429
1555
|
};
|
|
1430
|
-
|
|
1556
|
+
c.fn.atomBind = function(e) {
|
|
1431
1557
|
return this.each(function() {
|
|
1432
|
-
const
|
|
1433
|
-
|
|
1558
|
+
const t = D(this);
|
|
1559
|
+
if (e.text !== void 0 && Te(t, e.text), e.html !== void 0 && Re(t, e.html), e.class !== void 0 && Oe(t, e.class), e.css !== void 0 && Ne(t, e.css), e.attr !== void 0 && ve(t, e.attr), e.prop !== void 0 && De(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)
|
|
1560
|
+
if (Array.isArray(e.val)) {
|
|
1561
|
+
const [s, n] = e.val;
|
|
1562
|
+
Gt(t, s, n);
|
|
1563
|
+
} else
|
|
1564
|
+
Gt(t, e.val);
|
|
1565
|
+
e.checked !== void 0 && Ae(t, e.checked), e.on !== void 0 && ws(t, e.on);
|
|
1434
1566
|
});
|
|
1435
1567
|
};
|
|
1436
|
-
|
|
1568
|
+
c.fn.atomUnbind = function() {
|
|
1437
1569
|
return this.each(function() {
|
|
1438
|
-
|
|
1570
|
+
Ue(this);
|
|
1439
1571
|
});
|
|
1440
1572
|
};
|
|
1441
|
-
|
|
1442
|
-
|
|
1573
|
+
function xs(e, t, s) {
|
|
1574
|
+
t?.isConnected ? e.insertBefore(t) : e.appendTo(s);
|
|
1575
|
+
}
|
|
1576
|
+
c.fn.atomList = function(e, t) {
|
|
1577
|
+
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
1578
|
return this.each(function() {
|
|
1444
|
-
const
|
|
1445
|
-
let
|
|
1446
|
-
const
|
|
1447
|
-
const
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1579
|
+
const b = c(this), N = Xt(this), E = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Set();
|
|
1580
|
+
let P = [], U = null;
|
|
1581
|
+
const G = (v, T) => {
|
|
1582
|
+
const j = () => {
|
|
1583
|
+
bt?.isDisposed || (T.$el.remove(), m.delete(v), f.log("list", `${N} removed item:`, v));
|
|
1584
|
+
};
|
|
1585
|
+
if (l) {
|
|
1586
|
+
const M = l(T.$el);
|
|
1587
|
+
M instanceof Promise ? M.then(j, j) : j();
|
|
1588
|
+
} else
|
|
1589
|
+
j();
|
|
1590
|
+
}, Qt = (v, T) => {
|
|
1591
|
+
E.delete(v), m.add(v), G(v, T);
|
|
1592
|
+
};
|
|
1593
|
+
let bt;
|
|
1594
|
+
bt = X(() => {
|
|
1595
|
+
const v = e.value, T = v.length;
|
|
1596
|
+
H(() => {
|
|
1597
|
+
if (U && T > 0 && (U.remove(), U = null), T === 0) {
|
|
1598
|
+
if (p && !U) {
|
|
1599
|
+
const a = typeof p == "string" ? Bt(p) : p;
|
|
1600
|
+
U = c(a).appendTo(b);
|
|
1601
|
+
}
|
|
1602
|
+
E.forEach((a, h) => {
|
|
1603
|
+
m.has(h) || Qt(h, a);
|
|
1604
|
+
}), P = [];
|
|
1605
|
+
return;
|
|
1452
1606
|
}
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
if (rt.has(d) || A.has(d)) continue;
|
|
1470
|
-
const g = () => {
|
|
1471
|
-
U.$el.remove(), U.$el[0] && y.cleanup(U.$el[0]), A.delete(d), m.log("list", `${S} removed item:`, d);
|
|
1472
|
-
};
|
|
1473
|
-
if (b.delete(d), A.add(d), c) {
|
|
1474
|
-
const T = c(U.$el);
|
|
1475
|
-
T instanceof Promise ? T.then(g) : g();
|
|
1607
|
+
f.log("list", `${N} updating with ${T} items`);
|
|
1608
|
+
const j = /* @__PURE__ */ new Map();
|
|
1609
|
+
for (let a = 0; a < P.length; a++)
|
|
1610
|
+
j.set(P[a], a);
|
|
1611
|
+
const M = new Array(T), St = /* @__PURE__ */ new Set(), ot = new Int32Array(T), ct = [], Tt = [], Rt = [];
|
|
1612
|
+
for (let a = 0; a < T; a++) {
|
|
1613
|
+
const h = v[a], _ = C(h, a);
|
|
1614
|
+
if (M[a] = _, St.has(_)) {
|
|
1615
|
+
f.warn(d.LIST, S.DUPLICATE_KEY(_, a)), ot[a] = -1;
|
|
1616
|
+
continue;
|
|
1617
|
+
}
|
|
1618
|
+
St.add(_);
|
|
1619
|
+
const I = E.get(_);
|
|
1620
|
+
if (I) {
|
|
1621
|
+
const u = I.item;
|
|
1622
|
+
!r && u !== h && !ds(u, h) && (ct.push(_), Tt.push(h), Rt.push(a)), ot[a] = m.has(_) ? -1 : j.get(_) ?? -1;
|
|
1476
1623
|
} else
|
|
1477
|
-
|
|
1624
|
+
ct.push(_), Tt.push(h), Rt.push(a), ot[a] = -1;
|
|
1478
1625
|
}
|
|
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
|
-
|
|
1626
|
+
const Kt = "<!--sep-->", at = ct.length, Yt = new Array(
|
|
1627
|
+
at
|
|
1628
|
+
), Ot = [];
|
|
1629
|
+
for (let a = 0; a < at; a++) {
|
|
1630
|
+
const h = n(Tt[a], Rt[a]);
|
|
1631
|
+
Yt[a] = h, typeof h == "string" && Ot.push(h);
|
|
1632
|
+
}
|
|
1633
|
+
let ht = null;
|
|
1634
|
+
if (Ot.length > 0) {
|
|
1635
|
+
const a = Ot.join(Kt);
|
|
1636
|
+
ht = Bt(a).split(Kt);
|
|
1637
|
+
}
|
|
1638
|
+
let Wt = 0;
|
|
1639
|
+
for (let a = 0; a < at; a++) {
|
|
1640
|
+
const h = Yt[a], _ = typeof h == "string" ? c(ht[Wt++]) : c(h), I = ct[a], u = E.get(I);
|
|
1641
|
+
if (u) {
|
|
1642
|
+
const A = u.$el[0];
|
|
1643
|
+
A && g.cleanupTree(A), u.$el.replaceWith(_), u.$el = _, u.state = "replaced";
|
|
1644
|
+
} else
|
|
1645
|
+
E.set(I, { $el: _, item: null, state: "new" });
|
|
1646
|
+
}
|
|
1647
|
+
for (const [a, h] of E)
|
|
1648
|
+
!St.has(a) && !m.has(a) && Qt(a, h);
|
|
1649
|
+
const Jt = _s(ot);
|
|
1650
|
+
let Nt = Jt.length - 1, Zt = null;
|
|
1651
|
+
const vt = P.length === 0;
|
|
1652
|
+
if (vt && ht !== null && Wt === at && !i && !o && !l && m.size === 0) {
|
|
1653
|
+
this.innerHTML = ht.join("");
|
|
1654
|
+
let a = 0;
|
|
1655
|
+
for (let h = 0; h < T; h++) {
|
|
1656
|
+
const _ = M[h], I = v[h], u = E.get(_);
|
|
1657
|
+
if (!u) continue;
|
|
1658
|
+
const A = this.children[a++];
|
|
1659
|
+
A && (u.$el = c(A), u.item = I, u.state = void 0, m.delete(_), f.domUpdated(u.$el, "list.add", I));
|
|
1503
1660
|
}
|
|
1504
|
-
w = T.$el[0] || null;
|
|
1505
1661
|
} else {
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1662
|
+
const a = vt ? document.createDocumentFragment() : null;
|
|
1663
|
+
if (vt && a) {
|
|
1664
|
+
for (let h = T - 1; h >= 0; h--) {
|
|
1665
|
+
const _ = M[h], I = v[h], u = E.get(_);
|
|
1666
|
+
if (!u) continue;
|
|
1667
|
+
const A = u.state, x = A === "new", et = A === "replaced";
|
|
1668
|
+
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));
|
|
1669
|
+
for (let Dt = u.$el.length - 1; Dt >= 0; Dt--)
|
|
1670
|
+
a.insertBefore(u.$el[Dt], a.firstChild);
|
|
1671
|
+
o && x && o(u.$el), x && (m.delete(_), f.domUpdated(u.$el, "list.add", I));
|
|
1672
|
+
}
|
|
1673
|
+
this.appendChild(a);
|
|
1674
|
+
} else
|
|
1675
|
+
for (let h = T - 1; h >= 0; h--) {
|
|
1676
|
+
const _ = M[h], I = v[h], u = E.get(_);
|
|
1677
|
+
if (!u) continue;
|
|
1678
|
+
const A = u.state, x = A === "new", et = A === "replaced";
|
|
1679
|
+
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));
|
|
1680
|
+
}
|
|
1508
1681
|
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
})
|
|
1512
|
-
|
|
1513
|
-
b.clear(), A.clear(), L = [], N?.remove();
|
|
1682
|
+
P = M;
|
|
1683
|
+
});
|
|
1684
|
+
}), g.trackEffect(this, bt), g.trackCleanup(this, () => {
|
|
1685
|
+
E.clear(), m.clear(), P = [], U?.remove();
|
|
1514
1686
|
});
|
|
1515
1687
|
});
|
|
1516
1688
|
};
|
|
1517
|
-
const
|
|
1518
|
-
|
|
1689
|
+
const Ps = Object.freeze({});
|
|
1690
|
+
c.fn.atomMount = function(e, t) {
|
|
1691
|
+
const s = t ?? Ps;
|
|
1519
1692
|
return this.each(function() {
|
|
1520
|
-
|
|
1521
|
-
|
|
1693
|
+
g.cleanupTree(this);
|
|
1694
|
+
const n = c(this);
|
|
1522
1695
|
let i;
|
|
1523
1696
|
try {
|
|
1524
|
-
i =
|
|
1697
|
+
i = H(() => e(n, s));
|
|
1525
1698
|
} catch (r) {
|
|
1526
|
-
|
|
1699
|
+
f.error(d.MOUNT, S.MOUNT_ERROR(), r);
|
|
1527
1700
|
return;
|
|
1528
1701
|
}
|
|
1529
|
-
|
|
1530
|
-
if (St.delete(this)) {
|
|
1531
|
-
if (m.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
|
-
y.cleanupTree(this);
|
|
1538
|
-
}
|
|
1539
|
-
};
|
|
1540
|
-
St.set(this, o), y.trackCleanup(this, o);
|
|
1702
|
+
typeof i == "function" && g.setComponentCleanup(this, i);
|
|
1541
1703
|
});
|
|
1542
1704
|
};
|
|
1543
|
-
|
|
1705
|
+
c.fn.atomUnmount = function() {
|
|
1544
1706
|
return this.each(function() {
|
|
1545
|
-
|
|
1546
|
-
e && e();
|
|
1707
|
+
Ue(this);
|
|
1547
1708
|
});
|
|
1548
1709
|
};
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1710
|
+
function le(e, t) {
|
|
1711
|
+
try {
|
|
1712
|
+
return history.pushState(e, "", t), !0;
|
|
1713
|
+
} catch (s) {
|
|
1714
|
+
return f.warn(
|
|
1715
|
+
d.ROUTE,
|
|
1716
|
+
"PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.",
|
|
1717
|
+
s
|
|
1718
|
+
), !1;
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
class Ms {
|
|
1722
|
+
constructor(t) {
|
|
1723
|
+
this.isDestroyed = !1, this.previousRoute = "", this.cleanups = [], this.templateCache = /* @__PURE__ */ new Map(), this.config = {
|
|
1724
|
+
...t,
|
|
1725
|
+
mode: t.mode ?? dt.mode,
|
|
1726
|
+
basePath: t.basePath ?? dt.basePath,
|
|
1727
|
+
autoBindLinks: t.autoBindLinks ?? dt.autoBindLinks,
|
|
1728
|
+
activeClass: t.activeClass ?? dt.activeClass
|
|
1729
|
+
}, 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();
|
|
1730
|
+
}
|
|
1731
|
+
init() {
|
|
1732
|
+
const t = this.isHistoryMode ? "popstate" : "hashchange";
|
|
1733
|
+
window.addEventListener(t, this.handleUrlChange), this.cleanups.push(() => window.removeEventListener(t, this.handleUrlChange));
|
|
1734
|
+
const s = X(() => {
|
|
1735
|
+
const n = this.currentRouteAtom.value;
|
|
1736
|
+
H(() => this.renderRoute(n));
|
|
1737
|
+
});
|
|
1738
|
+
this.cleanups.push(() => s.dispose()), this.setupAutoBindLinks(), this.$target[0] && g.trackCleanup(this.$target[0], this.destroy);
|
|
1739
|
+
}
|
|
1740
|
+
// --- Mode-abstracted internal methods ---
|
|
1741
|
+
/**
|
|
1742
|
+
* Extracts route name from current URL.
|
|
1743
|
+
* Uses `normalizedBasePath` for consistent stripping in history mode.
|
|
1744
|
+
*/
|
|
1745
|
+
getRouteName() {
|
|
1746
|
+
const { default: t } = this.config;
|
|
1747
|
+
if (this.isHistoryMode) {
|
|
1748
|
+
let r = window.location.pathname;
|
|
1749
|
+
return this.normalizedBasePath && r.startsWith(this.normalizedBasePath) && (r = r.substring(this.normalizedBasePath.length)), r.charCodeAt(0) === 47 && (r = r.slice(1)), r || t;
|
|
1568
1750
|
}
|
|
1569
|
-
const
|
|
1570
|
-
return (
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1751
|
+
const s = window.location.hash, n = s.indexOf("?");
|
|
1752
|
+
return (n === -1 ? s.substring(1) : s.substring(1, n)) || t;
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Parses query parameters from the current URL.
|
|
1756
|
+
*
|
|
1757
|
+
* Note: duplicate keys (e.g. `?a=1&a=2`) are collapsed to the last value
|
|
1758
|
+
* only (`{ a: '2' }`). This matches `URLSearchParams` → `Object.fromEntries`
|
|
1759
|
+
* behaviour. If multi-value keys are needed, access `queryParams` via
|
|
1760
|
+
* `new URLSearchParams(window.location.search).getAll('key')` directly.
|
|
1761
|
+
*/
|
|
1762
|
+
getQueryParams() {
|
|
1763
|
+
let t;
|
|
1764
|
+
if (this.isHistoryMode) {
|
|
1765
|
+
if (t = window.location.search.substring(1), !t) return {};
|
|
1575
1766
|
} else {
|
|
1576
|
-
const
|
|
1577
|
-
if (
|
|
1578
|
-
|
|
1767
|
+
const i = window.location.hash, r = i.indexOf("?");
|
|
1768
|
+
if (r === -1) return {};
|
|
1769
|
+
t = i.substring(r + 1);
|
|
1579
1770
|
}
|
|
1580
|
-
const
|
|
1581
|
-
if (
|
|
1771
|
+
const s = new URLSearchParams(t), n = Object.fromEntries(s);
|
|
1772
|
+
if (t.includes("%"))
|
|
1582
1773
|
try {
|
|
1583
|
-
decodeURIComponent(
|
|
1774
|
+
decodeURIComponent(t);
|
|
1584
1775
|
} catch {
|
|
1585
|
-
|
|
1776
|
+
f.warn(d.ROUTE, S.MALFORMED_URI(t));
|
|
1586
1777
|
}
|
|
1587
|
-
return
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1778
|
+
return n;
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1781
|
+
* Updates the browser URL to reflect a new route and keeps `previousUrl`
|
|
1782
|
+
* in sync so `handleUrlChange` does not re-process our own navigation.
|
|
1783
|
+
*/
|
|
1784
|
+
setUrl(t) {
|
|
1785
|
+
if (this.isHistoryMode) {
|
|
1786
|
+
const s = `${this.normalizedBasePath}/${t}`;
|
|
1787
|
+
le(null, s), this.previousUrl = s;
|
|
1592
1788
|
} else {
|
|
1593
|
-
const
|
|
1594
|
-
|
|
1789
|
+
const s = `#${t}`;
|
|
1790
|
+
window.location.hash = s, this.previousUrl = s;
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
/**
|
|
1794
|
+
* Restores the URL when a navigation guard blocks the transition.
|
|
1795
|
+
* Uses pushState to safely add a new history entry, avoiding "back button traps"
|
|
1796
|
+
* that occur with replaceState during popstate events.
|
|
1797
|
+
*/
|
|
1798
|
+
restoreUrl() {
|
|
1799
|
+
this.isHistoryMode ? le(null, this.previousUrl) : window.location.hash = this.previousUrl;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Returns the current full URL string for comparison purposes.
|
|
1803
|
+
*/
|
|
1804
|
+
getCurrentUrl() {
|
|
1805
|
+
return this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash;
|
|
1806
|
+
}
|
|
1807
|
+
// --- End mode-abstracted methods ---
|
|
1808
|
+
/**
|
|
1809
|
+
* Resolves route configuration, falling back to notFound route if needed.
|
|
1810
|
+
*/
|
|
1811
|
+
getRouteConfig(t) {
|
|
1812
|
+
const { routes: s, notFound: n } = this.config;
|
|
1813
|
+
let i = s[t];
|
|
1814
|
+
return !i && n && (i = s[n]), i || (f.warn(d.ROUTE, S.ROUTE_NOT_FOUND(t)), null);
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Appends cloned template content into the target container.
|
|
1818
|
+
* Always appends — callers are responsible for calling `$target.empty()`
|
|
1819
|
+
* before invoking this method if a clean slate is needed.
|
|
1820
|
+
*/
|
|
1821
|
+
renderTemplate(t) {
|
|
1822
|
+
let s = this.templateCache.get(t);
|
|
1823
|
+
if (!s) {
|
|
1824
|
+
const i = document.querySelector(t);
|
|
1825
|
+
if (!i || !(i instanceof HTMLTemplateElement))
|
|
1826
|
+
return f.warn(d.ROUTE, S.TEMPLATE_NOT_FOUND(t)), !1;
|
|
1827
|
+
s = i, this.templateCache.set(t, s);
|
|
1595
1828
|
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1829
|
+
const n = s.content.cloneNode(!0);
|
|
1830
|
+
return this.$target.append(n), !0;
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Renders the specified route, including lifecycle hooks and content.
|
|
1834
|
+
*
|
|
1835
|
+
* Called from within a reactive effect, so DOM mutations here run
|
|
1836
|
+
* synchronously inside the effect body. `registry.cleanupDescendants` is
|
|
1837
|
+
* called before `$target.empty()` to ensure any reactive bindings on
|
|
1838
|
+
* outgoing content are disposed before the nodes are removed — preventing
|
|
1839
|
+
* the MutationObserver auto-cleanup path from firing a redundant cleanup.
|
|
1840
|
+
*
|
|
1841
|
+
* If `beforeTransition` throws, the render is aborted and the outgoing
|
|
1842
|
+
* content remains in the DOM. This is intentional — a throwing hook signals
|
|
1843
|
+
* that the transition should not proceed.
|
|
1844
|
+
*/
|
|
1845
|
+
renderRoute(t) {
|
|
1846
|
+
if (this.isDestroyed) return;
|
|
1847
|
+
const s = this.$target[0];
|
|
1848
|
+
if (!s) {
|
|
1849
|
+
f.warn(d.ROUTE, S.TARGET_NOT_FOUND(this.config.target));
|
|
1612
1850
|
return;
|
|
1613
1851
|
}
|
|
1614
|
-
const
|
|
1615
|
-
if (!
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1618
|
-
let
|
|
1619
|
-
if (
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1852
|
+
const n = this.getRouteConfig(t);
|
|
1853
|
+
if (!n) return;
|
|
1854
|
+
const i = this.getQueryParams(), r = this.previousRoute;
|
|
1855
|
+
this.config.beforeTransition && this.config.beforeTransition(r, t), this.$target.empty();
|
|
1856
|
+
let o = i;
|
|
1857
|
+
if (n.onEnter) {
|
|
1858
|
+
const l = n.onEnter(i);
|
|
1859
|
+
l !== void 0 && (o = { ...i, ...l });
|
|
1622
1860
|
}
|
|
1623
|
-
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
const f = s[p];
|
|
1638
|
-
if (f?.onLeave && f.onLeave() === !1) {
|
|
1639
|
-
B();
|
|
1861
|
+
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;
|
|
1862
|
+
}
|
|
1863
|
+
/**
|
|
1864
|
+
* Handles browser URL change events (hashchange or popstate).
|
|
1865
|
+
*/
|
|
1866
|
+
handleUrlChange() {
|
|
1867
|
+
if (this.isDestroyed) return;
|
|
1868
|
+
const t = this.getCurrentUrl();
|
|
1869
|
+
if (t === this.previousUrl) return;
|
|
1870
|
+
const s = this.getRouteName(), n = this.currentRouteAtom.peek(), i = this.getQueryParams();
|
|
1871
|
+
if (n !== s) {
|
|
1872
|
+
const r = this.config.routes[n];
|
|
1873
|
+
if (r?.onLeave && r.onLeave() === !1) {
|
|
1874
|
+
this.restoreUrl();
|
|
1640
1875
|
return;
|
|
1641
1876
|
}
|
|
1642
|
-
|
|
1643
|
-
} else
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1877
|
+
this.currentRouteAtom.value = s, this.queryParamsAtom.value = i;
|
|
1878
|
+
} else {
|
|
1879
|
+
this.queryParamsAtom.value = i;
|
|
1880
|
+
const r = this.config.routes[n];
|
|
1881
|
+
r?.onParamsChange ? r.onParamsChange(i) : this.renderRoute(s);
|
|
1882
|
+
}
|
|
1883
|
+
this.previousUrl = t;
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* Sets up automatic binding for navigation links with data-route attribute.
|
|
1887
|
+
*
|
|
1888
|
+
* Event delegation is attached to `document` (not `$target`) so that
|
|
1889
|
+
* `[data-route]` links anywhere in the page — including outside the router's
|
|
1890
|
+
* target container — can trigger navigation. This is intentional: nav links
|
|
1891
|
+
* typically live in headers or sidebars, not inside the routed content area.
|
|
1892
|
+
*
|
|
1893
|
+
* Active-link management uses a reactive effect that re-runs only when
|
|
1894
|
+
* `currentRoute` changes — more efficient than a persistent MutationObserver.
|
|
1895
|
+
*/
|
|
1896
|
+
setupAutoBindLinks() {
|
|
1897
|
+
if (!this.config.autoBindLinks) return;
|
|
1898
|
+
const t = (i) => {
|
|
1899
|
+
i.preventDefault();
|
|
1900
|
+
const r = i.currentTarget.dataset.route;
|
|
1901
|
+
r != null && this.navigate(r);
|
|
1652
1902
|
};
|
|
1653
|
-
|
|
1654
|
-
|
|
1903
|
+
c(document).on("click", "[data-route]", t), this.cleanups.push(() => {
|
|
1904
|
+
c(document).off("click", "[data-route]", t);
|
|
1655
1905
|
});
|
|
1656
|
-
const
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
y.trackEffect(f, z), y.trackCleanup(f, () => {
|
|
1665
|
-
I.delete(f);
|
|
1906
|
+
const { activeClass: s } = this.config, n = X(() => {
|
|
1907
|
+
const i = this.currentRouteAtom.value;
|
|
1908
|
+
H(() => {
|
|
1909
|
+
const r = document.querySelectorAll("[data-route]");
|
|
1910
|
+
for (const o of r) {
|
|
1911
|
+
const l = o.dataset.route, p = i === l;
|
|
1912
|
+
o.classList.toggle(s, p), p ? o.setAttribute("aria-current", "page") : o.removeAttribute("aria-current");
|
|
1913
|
+
}
|
|
1666
1914
|
});
|
|
1667
|
-
};
|
|
1668
|
-
for (const f of document.querySelectorAll("[data-route]"))
|
|
1669
|
-
_(f);
|
|
1670
|
-
const p = new MutationObserver((f) => {
|
|
1671
|
-
for (const v of f)
|
|
1672
|
-
v.type === "childList" && v.addedNodes.forEach((z) => {
|
|
1673
|
-
if (z.nodeType === 1) {
|
|
1674
|
-
const q = z;
|
|
1675
|
-
q.matches?.("[data-route]") && _(q), q.querySelectorAll && q.querySelectorAll("[data-route]").forEach(
|
|
1676
|
-
(be) => _(be)
|
|
1677
|
-
);
|
|
1678
|
-
}
|
|
1679
|
-
});
|
|
1680
1915
|
});
|
|
1681
|
-
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
return s ? s(h) : h;
|
|
1704
|
-
},
|
|
1705
|
-
{ defaultValue: n, lazy: !1 }
|
|
1706
|
-
);
|
|
1707
|
-
}
|
|
1708
|
-
l.extend({ atomFetch: rn });
|
|
1709
|
-
const Tt = /* @__PURE__ */ new WeakMap();
|
|
1710
|
-
let Wt = !1;
|
|
1711
|
-
const Jt = (e) => {
|
|
1712
|
-
let t = Tt.get(e);
|
|
1713
|
-
return t || (t = function(...n) {
|
|
1714
|
-
return Bt(() => e.apply(this, n));
|
|
1715
|
-
}, Tt.set(e, t)), t;
|
|
1716
|
-
};
|
|
1717
|
-
function cn() {
|
|
1718
|
-
if (Wt) return;
|
|
1719
|
-
Wt = !0;
|
|
1720
|
-
const e = l.fn.on, t = l.fn.off, n = l.fn.remove, s = l.fn.empty, i = l.fn.detach;
|
|
1721
|
-
l.fn.remove = function(o) {
|
|
1722
|
-
const r = o ? this.filter(o) : this;
|
|
1723
|
-
for (let c = 0, a = r.length; c < a; c++) {
|
|
1724
|
-
const h = r[c];
|
|
1725
|
-
h && (y.cleanupTree(h), y.markIgnored(h));
|
|
1726
|
-
}
|
|
1727
|
-
return n.call(this, o);
|
|
1728
|
-
}, l.fn.empty = function() {
|
|
1729
|
-
for (let o = 0, r = this.length; o < r; o++) {
|
|
1730
|
-
const c = this[o];
|
|
1731
|
-
c && y.cleanupDescendants(c);
|
|
1732
|
-
}
|
|
1733
|
-
return s.call(this);
|
|
1734
|
-
}, l.fn.detach = function(o) {
|
|
1735
|
-
const r = o ? this.filter(o) : this;
|
|
1736
|
-
for (let c = 0, a = r.length; c < a; c++) {
|
|
1737
|
-
const h = r[c];
|
|
1738
|
-
h && y.keep(h);
|
|
1916
|
+
this.cleanups.push(() => n.dispose());
|
|
1917
|
+
}
|
|
1918
|
+
/**
|
|
1919
|
+
* Navigates to the specified route programmatically.
|
|
1920
|
+
*
|
|
1921
|
+
* If `routeName` resolves to an empty string after falling back to
|
|
1922
|
+
* `config.default`, `setUrl` will be called with an empty string, producing
|
|
1923
|
+
* a URL of `${basePath}/` in history mode. Callers should ensure
|
|
1924
|
+
* `config.default` is always a non-empty route name.
|
|
1925
|
+
*/
|
|
1926
|
+
navigate(t) {
|
|
1927
|
+
if (this.isDestroyed) return;
|
|
1928
|
+
const s = this.currentRouteAtom.peek(), n = this.config.routes[s];
|
|
1929
|
+
if (n?.onLeave && n.onLeave() === !1)
|
|
1930
|
+
return;
|
|
1931
|
+
const i = t || this.config.default;
|
|
1932
|
+
if (!i) {
|
|
1933
|
+
f.warn(
|
|
1934
|
+
d.ROUTE,
|
|
1935
|
+
"navigate() called with empty routeName and no default configured."
|
|
1936
|
+
);
|
|
1937
|
+
return;
|
|
1739
1938
|
}
|
|
1740
|
-
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
o[c] = Jt(o[c]);
|
|
1754
|
-
break;
|
|
1755
|
-
}
|
|
1756
|
-
return e.apply(this, o);
|
|
1757
|
-
}, l.fn.off = function(...o) {
|
|
1758
|
-
const r = o[0];
|
|
1759
|
-
if (r && typeof r == "object") {
|
|
1760
|
-
const c = r, a = {};
|
|
1761
|
-
for (const h in c) {
|
|
1762
|
-
const E = c[h];
|
|
1763
|
-
E && (a[h] = Tt.get(E) || E);
|
|
1939
|
+
this.setUrl(i), this.queryParamsAtom.value = {}, this.currentRouteAtom.value = i;
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* Cleans up all event listeners and effects, and releases the template cache.
|
|
1943
|
+
* Each cleanup function is called in a try/catch so that a single failing
|
|
1944
|
+
* cleanup does not prevent the remaining ones from running.
|
|
1945
|
+
*/
|
|
1946
|
+
destroy() {
|
|
1947
|
+
this.isDestroyed || (this.isDestroyed = !0, this.cleanups.forEach((t) => {
|
|
1948
|
+
try {
|
|
1949
|
+
t();
|
|
1950
|
+
} catch (s) {
|
|
1951
|
+
f.warn(d.ROUTE, "Cleanup error during destroy:", s);
|
|
1764
1952
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
break;
|
|
1771
|
-
}
|
|
1772
|
-
return t.apply(this, o);
|
|
1773
|
-
};
|
|
1953
|
+
}), this.cleanups.length = 0, this.templateCache.clear());
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
function $s(e) {
|
|
1957
|
+
return new Ms(e);
|
|
1774
1958
|
}
|
|
1775
|
-
|
|
1776
|
-
|
|
1959
|
+
c.extend({
|
|
1960
|
+
route: $s
|
|
1961
|
+
});
|
|
1962
|
+
const Fs = new Promise(() => {
|
|
1963
|
+
});
|
|
1964
|
+
c.extend({
|
|
1965
|
+
atomFetch(e, t) {
|
|
1966
|
+
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 = {
|
|
1967
|
+
...o,
|
|
1968
|
+
...i !== void 0 && { method: i },
|
|
1969
|
+
...r !== void 0 && { headers: r }
|
|
1970
|
+
};
|
|
1971
|
+
let E = null;
|
|
1972
|
+
return Ct(
|
|
1973
|
+
async () => {
|
|
1974
|
+
E?.abort(), E = new AbortController();
|
|
1975
|
+
const m = E.signal, P = b ? { ...N, url: b } : { ...N, url: C() }, U = c.ajax(P);
|
|
1976
|
+
m.onabort = () => U.abort(), m.aborted && U.abort();
|
|
1977
|
+
try {
|
|
1978
|
+
const G = await U;
|
|
1979
|
+
return n ? n(G) : G;
|
|
1980
|
+
} catch (G) {
|
|
1981
|
+
if (m.aborted)
|
|
1982
|
+
return Fs;
|
|
1983
|
+
try {
|
|
1984
|
+
l?.(G);
|
|
1985
|
+
} catch {
|
|
1986
|
+
}
|
|
1987
|
+
throw G;
|
|
1988
|
+
} finally {
|
|
1989
|
+
m.onabort = null, E.signal === m && (E = null);
|
|
1990
|
+
}
|
|
1991
|
+
},
|
|
1992
|
+
{ defaultValue: s, lazy: !(p ?? !0) }
|
|
1993
|
+
);
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
c(() => {
|
|
1997
|
+
Ns(), Ts(document.body);
|
|
1777
1998
|
});
|
|
1778
1999
|
export {
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
2000
|
+
Ft as atom,
|
|
2001
|
+
Ie as batch,
|
|
2002
|
+
Ct as computed,
|
|
2003
|
+
qs as default,
|
|
2004
|
+
Gs as disableAutoCleanup,
|
|
2005
|
+
js as disablejQueryOverrides,
|
|
2006
|
+
X as effect,
|
|
2007
|
+
Ts as enableAutoCleanup,
|
|
2008
|
+
Ns as enablejQueryOverrides,
|
|
2009
|
+
qt as isAtom,
|
|
2010
|
+
Ve as isComputed,
|
|
2011
|
+
ye as isReactive,
|
|
2012
|
+
Cs as nextTick,
|
|
2013
|
+
g as registry,
|
|
2014
|
+
H as untracked
|
|
1789
2015
|
};
|
|
1790
2016
|
//# sourceMappingURL=index.mjs.map
|