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