@but212/atom-effect-jquery 0.22.2 → 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 -2
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +53 -147
- package/dist/index.mjs +1412 -1034
- 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,
|
|
@@ -23,7 +23,7 @@ const ut = {
|
|
|
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,81 +33,61 @@ 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);
|
|
50
|
+
}
|
|
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));
|
|
45
56
|
}
|
|
57
|
+
for (const i of s.values())
|
|
58
|
+
i();
|
|
46
59
|
}
|
|
47
|
-
class
|
|
48
|
-
constructor(t, e =
|
|
49
|
-
|
|
60
|
+
class ht {
|
|
61
|
+
constructor(t, e, s = void 0) {
|
|
62
|
+
this.node = t, this.version = e, this.unsub = s;
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
|
-
class
|
|
53
|
-
constructor(t, e
|
|
54
|
-
|
|
65
|
+
class Ne {
|
|
66
|
+
constructor(t, e) {
|
|
67
|
+
this.fn = t, this.sub = e;
|
|
55
68
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
constructor(t, e = null) {
|
|
59
|
-
super(t, e, !1), this.name = "SchedulerError";
|
|
69
|
+
notify(t, e) {
|
|
70
|
+
this.fn ? this.fn(t, e) : this.sub && this.sub.execute();
|
|
60
71
|
}
|
|
61
72
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
warnInfiniteLoop: ke.WARN_INFINITE_LOOP,
|
|
66
|
-
warn(s, t) {
|
|
67
|
-
},
|
|
68
|
-
checkCircular(s, t) {
|
|
69
|
-
if (s === t)
|
|
70
|
-
throw new j("Direct circular dependency detected");
|
|
71
|
-
},
|
|
72
|
-
attachDebugInfo(s, t, e) {
|
|
73
|
-
},
|
|
74
|
-
getDebugName: (s) => s?.[$e],
|
|
75
|
-
getDebugType: (s) => s?.[Me]
|
|
76
|
-
};
|
|
77
|
-
let Fe = 1;
|
|
78
|
-
const Be = () => Fe++;
|
|
79
|
-
function fe(s, t, e) {
|
|
80
|
-
if (typeof t == "function") {
|
|
81
|
-
const i = t;
|
|
82
|
-
if (e.some((o) => o && o.fn === i)) return;
|
|
83
|
-
e.push(new Mt(i, void 0));
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if ("addDependency" in t) {
|
|
87
|
-
t.addDependency(s);
|
|
88
|
-
return;
|
|
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
|
-
e.some((i) => i && i.sub === n) || e.push(new Mt(void 0, n));
|
|
92
77
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}), s.forEach((i) => {
|
|
98
|
-
if (!i) return;
|
|
99
|
-
const o = i.node, r = n.get(o);
|
|
100
|
-
r !== void 0 ? (i.unsub = r, n.delete(o)) : (Ct.checkCircular(o, e), i.unsub = o.subscribe(e));
|
|
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, e
|
|
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, e) {
|
|
110
|
-
|
|
88
|
+
class yt extends W {
|
|
89
|
+
constructor(t, e = null) {
|
|
90
|
+
super(t, e, !1), this.name = "SchedulerError";
|
|
111
91
|
}
|
|
112
92
|
}
|
|
113
93
|
const b = {
|
|
@@ -127,82 +107,140 @@ const b = {
|
|
|
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
|
-
|
|
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}`;
|
|
142
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
150
|
const e = typeof t == "function";
|
|
155
151
|
if (!e && (!t || typeof t.execute != "function"))
|
|
156
|
-
throw
|
|
152
|
+
throw Q(
|
|
157
153
|
new TypeError("Invalid subscriber"),
|
|
158
|
-
|
|
154
|
+
W,
|
|
159
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
|
|
169
|
+
const r = new Ne(
|
|
165
170
|
e ? t : void 0,
|
|
166
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 e = this._subscribers
|
|
172
|
-
|
|
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
|
+
}
|
|
173
188
|
const i = e.pop();
|
|
174
|
-
|
|
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
198
|
_notifySubscribers(t, e) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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 Ge {
|
|
|
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, e = this._batchQueue,
|
|
295
|
+
const t = ++this._epoch, e = this._batchQueue, s = this._queueBuffer[this._bufferIndex];
|
|
258
296
|
let i = this._size;
|
|
259
297
|
e.slice(0, this._batchQueueSize).forEach((o) => {
|
|
260
|
-
o._nextEpoch !== t && (o._nextEpoch = t,
|
|
261
|
-
}), this._size = i, this._batchQueueSize = 0, e.length >
|
|
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,20 +309,21 @@ class Ge {
|
|
|
271
309
|
}
|
|
272
310
|
}
|
|
273
311
|
_processQueue() {
|
|
274
|
-
const t = this._bufferIndex, e = this._queueBuffer[t],
|
|
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
|
-
e[i]
|
|
316
|
+
const o = e[i];
|
|
317
|
+
typeof o == "function" ? o() : o.execute();
|
|
279
318
|
} catch (o) {
|
|
280
|
-
console.error(new
|
|
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
|
|
326
|
+
new yt(
|
|
288
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)
|
|
@@ -300,14 +339,14 @@ class Ge {
|
|
|
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 ot = new
|
|
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,9 +356,9 @@ const ot = new Ge(), 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(
|
|
359
|
+
run(n, t) {
|
|
321
360
|
const e = this.current;
|
|
322
|
-
this.current =
|
|
361
|
+
this.current = n;
|
|
323
362
|
try {
|
|
324
363
|
return t();
|
|
325
364
|
} finally {
|
|
@@ -327,38 +366,44 @@ const ot = new Ge(), Vt = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ge = /
|
|
|
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
|
|
379
|
+
var Bt, Gt;
|
|
380
|
+
class Ue extends Zt {
|
|
342
381
|
constructor(t, e) {
|
|
343
|
-
super(), this._pendingOldValue = void 0, this.
|
|
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 && fe(this, t, this._subscribers), this._value;
|
|
385
|
+
return $.current?.addDependency(this), this._value;
|
|
348
386
|
}
|
|
349
387
|
set value(t) {
|
|
350
388
|
const e = this._value;
|
|
351
389
|
if (Object.is(e, t)) return;
|
|
352
|
-
this._value = t, this.version =
|
|
353
|
-
const
|
|
354
|
-
if (!(this._subscribers.length === 0 ||
|
|
355
|
-
if (this._pendingOldValue = e, this.flags =
|
|
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
|
-
ot.schedule(this
|
|
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
|
*/
|
|
@@ -375,21 +420,21 @@ class je extends _e {
|
|
|
375
420
|
dispose() {
|
|
376
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, e = 256,
|
|
392
|
-
this.limit = t, this.capacity = e, this.pool = [], this.stats = null, this.stats =
|
|
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 }
|
|
@@ -429,11 +474,11 @@ class Ve {
|
|
|
429
474
|
*/
|
|
430
475
|
getStats() {
|
|
431
476
|
if (!this.stats) return null;
|
|
432
|
-
const { acquired: t, released: e, rejected:
|
|
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
480
|
released: e,
|
|
436
|
-
rejected: { ...
|
|
481
|
+
rejected: { ...s },
|
|
437
482
|
leaked: i,
|
|
438
483
|
poolSize: this.pool.length
|
|
439
484
|
};
|
|
@@ -449,58 +494,57 @@ class Ve {
|
|
|
449
494
|
});
|
|
450
495
|
}
|
|
451
496
|
}
|
|
452
|
-
const
|
|
497
|
+
const L = Object.freeze(
|
|
453
498
|
[]
|
|
454
|
-
),
|
|
455
|
-
function
|
|
456
|
-
return
|
|
499
|
+
), F = new we();
|
|
500
|
+
function wt(n) {
|
|
501
|
+
return n !== null && typeof n == "object" && Ut in n;
|
|
457
502
|
}
|
|
458
|
-
function
|
|
459
|
-
return
|
|
503
|
+
function xe(n) {
|
|
504
|
+
return n !== null && typeof n == "object" && ee in n;
|
|
460
505
|
}
|
|
461
|
-
function
|
|
462
|
-
return
|
|
506
|
+
function se(n) {
|
|
507
|
+
return n !== null && typeof n == "object" && typeof n.then == "function";
|
|
463
508
|
}
|
|
464
|
-
var
|
|
465
|
-
const { IDLE:
|
|
466
|
-
function
|
|
467
|
-
return
|
|
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;
|
|
468
513
|
}
|
|
469
|
-
class
|
|
514
|
+
class Me extends Zt {
|
|
470
515
|
constructor(t, e = {}) {
|
|
471
|
-
if (typeof t != "function") throw new
|
|
472
|
-
super(), this[
|
|
473
|
-
const
|
|
474
|
-
if (this._maxAsyncRetries = (
|
|
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 && fe(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
|
|
491
|
-
if (t &
|
|
492
|
-
if (this._defaultValue !==
|
|
493
|
-
throw new
|
|
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 e = this._defaultValue,
|
|
498
|
-
if (this.flags &
|
|
499
|
-
if (
|
|
500
|
-
throw new
|
|
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 Ye extends _e {
|
|
|
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
567
|
return this._error && t.push(this._error), this._links.forEach((e) => {
|
|
524
|
-
const
|
|
525
|
-
|
|
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 Ye extends _e {
|
|
|
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 =
|
|
613
|
+
this._trackEpoch = kt(), this._trackLinks = t, this._trackCount = 0;
|
|
565
614
|
let e = !1;
|
|
566
615
|
try {
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
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) {
|
|
570
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
|
-
e && t !==
|
|
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 |
|
|
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;
|
|
582
646
|
const e = this._promiseId;
|
|
583
647
|
t.then(
|
|
584
|
-
(
|
|
648
|
+
(s) => {
|
|
585
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
|
-
new
|
|
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
667
|
const e = this._links;
|
|
604
|
-
for (let
|
|
605
|
-
t = (t << 5) - t + e[
|
|
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, e,
|
|
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
677
|
} catch (o) {
|
|
614
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
|
|
697
|
+
var Vt;
|
|
698
|
+
class Fe extends Wt {
|
|
635
699
|
constructor(t, e = {}) {
|
|
636
|
-
super(), this[
|
|
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 &
|
|
714
|
+
if (!(this.flags & w.EXECUTING)) return;
|
|
651
715
|
const e = this._currentEpoch;
|
|
652
716
|
if (t._lastSeenEpoch === e) return;
|
|
653
717
|
t._lastSeenEpoch = e;
|
|
654
|
-
const
|
|
655
|
-
if (
|
|
656
|
-
|
|
657
|
-
r.version = t.version, n.push(r), i[o] = null;
|
|
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 r =
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
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;
|
|
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
|
+
}
|
|
671
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 = e, this._currentEpoch = zt();
|
|
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
790
|
const e = ++this._execId;
|
|
693
791
|
t.then(
|
|
694
|
-
(
|
|
695
|
-
if (e !== this._execId || this.flags &
|
|
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
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, e,
|
|
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
811
|
t.forEach((e) => e?.unsub?.());
|
|
714
812
|
}
|
|
715
813
|
_isDirty() {
|
|
716
|
-
const t = this._links, e =
|
|
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() {
|
|
@@ -741,51 +839,51 @@ class Ke extends de {
|
|
|
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 e = new
|
|
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
858
|
throw this.dispose(), console.error(e), e;
|
|
761
859
|
}
|
|
762
860
|
_handleExecutionError(t, e = b.EFFECT_EXECUTION_FAILED) {
|
|
763
|
-
const
|
|
764
|
-
if (console.error(
|
|
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 e = new
|
|
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);
|
|
776
874
|
return e.execute(), e;
|
|
777
875
|
}
|
|
778
|
-
function
|
|
779
|
-
if (typeof
|
|
780
|
-
throw new TypeError(
|
|
876
|
+
function ne(n) {
|
|
877
|
+
if (typeof n != "function")
|
|
878
|
+
throw new TypeError(b.BATCH_CALLBACK_MUST_BE_FUNCTION);
|
|
781
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,276 +892,258 @@ const g = {
|
|
|
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
|
-
]), T = {
|
|
812
|
-
ROUTE_NOT_FOUND: (s) => `Route "${s}" not found and no notFound route configured`,
|
|
813
|
-
TEMPLATE_NOT_FOUND: (s) => `Template "${s}" not found`,
|
|
814
|
-
TARGET_NOT_FOUND: (s) => `Target element "${s}" not found`,
|
|
815
|
-
MALFORMED_URI: (s) => `Malformed URI component: ${s}`,
|
|
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: (s) => `Blocked dangerous value in CSS style property "${s}".`,
|
|
820
|
-
BLOCKED_EVENT_HANDLER: (s) => `Blocked setting dangerous event handler attribute "${s}".`,
|
|
821
|
-
BLOCKED_PROTOCOL: (s) => `Blocked dangerous protocol in "${s}" attribute.`,
|
|
822
|
-
BLOCKED_DANGEROUS_PROP: (s) => `Blocked setting dangerous property "${s}". Use html binding for sanitized HTML.`,
|
|
823
|
-
INVALID_INPUT_ELEMENT: (s) => `Val binding used on non-input element <${s}>.`,
|
|
824
|
-
MISSING_SOURCE: (s) => `[${s}] source is required when prop/name is a string.`,
|
|
825
|
-
MISSING_CONDITION: (s) => `[${s}] condition is required when className is a string.`,
|
|
826
|
-
DUPLICATE_KEY: (s, t) => `Duplicate key "${s}" at index ${t}.`,
|
|
827
|
-
UPDATER_ERROR: (s) => `Updater threw in binding "${s}"`,
|
|
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 ye(s) {
|
|
835
|
-
return qt(s);
|
|
836
|
-
}
|
|
837
|
-
function Xt(s) {
|
|
838
|
-
const t = s.tagName.toLowerCase();
|
|
839
|
-
if (s.id) return `${t}#${s.id}`;
|
|
840
|
-
const e = s.classList, n = e.length;
|
|
841
|
-
if (n === 0) return t;
|
|
842
|
-
let i = t;
|
|
843
|
-
for (let o = 0; o < n; o++)
|
|
844
|
-
i += `.${e[o]}`;
|
|
845
|
-
return i;
|
|
846
|
-
}
|
|
847
|
-
const ts = /* @__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
|
-
(n
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
|
|
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;
|
|
889
975
|
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
if (
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
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;
|
|
896
983
|
for (let r = 0; r < e.length; r++) {
|
|
897
984
|
const c = e[r];
|
|
898
|
-
if (!
|
|
985
|
+
if (!Z.call(o, c) || i[c] !== o[c])
|
|
899
986
|
return !1;
|
|
900
987
|
}
|
|
901
988
|
return !0;
|
|
902
989
|
}
|
|
903
|
-
function
|
|
904
|
-
const t =
|
|
990
|
+
function ze(n) {
|
|
991
|
+
const t = n.length;
|
|
905
992
|
if (t === 0) return new Int32Array(0);
|
|
906
|
-
const e = new Int32Array(t).fill(-1),
|
|
993
|
+
const e = new Int32Array(t).fill(-1), s = new Int32Array(t);
|
|
907
994
|
let i = 0;
|
|
908
995
|
for (let r = 0; r < t; r++) {
|
|
909
|
-
const c =
|
|
996
|
+
const c = n[r];
|
|
910
997
|
if (c === void 0 || c === -1) continue;
|
|
911
|
-
const
|
|
912
|
-
if (i === 0 ||
|
|
913
|
-
e[r] =
|
|
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;
|
|
914
1001
|
continue;
|
|
915
1002
|
}
|
|
916
|
-
let
|
|
917
|
-
for (;
|
|
918
|
-
const
|
|
919
|
-
|
|
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;
|
|
920
1007
|
}
|
|
921
|
-
const
|
|
922
|
-
|
|
1008
|
+
const _ = s[l];
|
|
1009
|
+
_ !== void 0 && c < (n[_] ?? Number.MAX_SAFE_INTEGER) && (l > 0 && (e[r] = s[l - 1] ?? -1), s[l] = r);
|
|
923
1010
|
}
|
|
924
1011
|
const o = new Int32Array(i);
|
|
925
1012
|
if (i > 0) {
|
|
926
|
-
let r =
|
|
1013
|
+
let r = s[i - 1];
|
|
927
1014
|
for (let c = i - 1; c >= 0 && r !== void 0 && r !== -1; c--)
|
|
928
1015
|
o[c] = r, r = e[r];
|
|
929
1016
|
}
|
|
930
1017
|
return o;
|
|
931
1018
|
}
|
|
932
|
-
const
|
|
933
|
-
function
|
|
1019
|
+
const Ke = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, qe = `${ie.HIGHLIGHT_DURATION_MS / 1e3}s`;
|
|
1020
|
+
function Xe() {
|
|
934
1021
|
if (typeof window < "u") {
|
|
935
|
-
const
|
|
936
|
-
if (typeof
|
|
1022
|
+
const n = window.__ATOM_DEBUG__;
|
|
1023
|
+
if (typeof n == "boolean") return n;
|
|
937
1024
|
}
|
|
938
|
-
|
|
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 {
|
|
1033
|
+
}
|
|
1034
|
+
return !1;
|
|
939
1035
|
}
|
|
940
|
-
let
|
|
941
|
-
const
|
|
1036
|
+
let zt = Xe();
|
|
1037
|
+
const d = {
|
|
942
1038
|
get enabled() {
|
|
943
|
-
|
|
1039
|
+
if (typeof window < "u") {
|
|
1040
|
+
const n = window.__ATOM_DEBUG__;
|
|
1041
|
+
if (typeof n == "boolean") return n;
|
|
1042
|
+
}
|
|
1043
|
+
return zt;
|
|
944
1044
|
},
|
|
945
|
-
set enabled(
|
|
946
|
-
|
|
1045
|
+
set enabled(n) {
|
|
1046
|
+
zt = n;
|
|
947
1047
|
},
|
|
948
1048
|
/**
|
|
949
1049
|
* Logs a message only when debug mode is active.
|
|
950
1050
|
*/
|
|
951
|
-
log(
|
|
952
|
-
|
|
1051
|
+
log(n, ...t) {
|
|
1052
|
+
this.enabled && console.log(`${n}`, ...t);
|
|
953
1053
|
},
|
|
954
1054
|
/**
|
|
955
1055
|
* Logs an atom value change only when debug mode is active.
|
|
956
1056
|
*/
|
|
957
|
-
atomChanged(
|
|
958
|
-
|
|
959
|
-
`${g.MOUNT} Atom "${s ?? "anonymous"}" changed:`,
|
|
960
|
-
t,
|
|
961
|
-
"→",
|
|
962
|
-
e
|
|
963
|
-
);
|
|
1057
|
+
atomChanged(n, t, e, s) {
|
|
1058
|
+
this.enabled && console.log(`${n} Atom "${t ?? "anonymous"}" changed:`, e, "→", s);
|
|
964
1059
|
},
|
|
965
1060
|
/**
|
|
966
1061
|
* Logs a DOM update and triggers a visual highlight flash.
|
|
967
|
-
* Only active when debug mode is enabled.
|
|
968
|
-
*
|
|
969
|
-
* @param target - The element or jQuery wrapper that was updated.
|
|
970
|
-
* @param type - The binding type (e.g. 'text', 'checked', 'attr.href').
|
|
971
|
-
* @param value - The new value that was applied.
|
|
972
1062
|
*/
|
|
973
|
-
domUpdated(
|
|
974
|
-
if (!
|
|
975
|
-
const
|
|
976
|
-
|
|
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));
|
|
977
1067
|
},
|
|
978
1068
|
/**
|
|
979
1069
|
* Logs a cleanup event only when debug mode is active.
|
|
980
1070
|
*/
|
|
981
|
-
cleanup(
|
|
982
|
-
|
|
1071
|
+
cleanup(n, t) {
|
|
1072
|
+
this.enabled && console.log(`${n} Cleanup: ${t}`);
|
|
983
1073
|
},
|
|
984
1074
|
/**
|
|
985
|
-
* Unconditional warning for runtime errors
|
|
986
|
-
* Not gated by debugEnabled — these are always surfaced regardless of
|
|
987
|
-
* debug mode because they indicate real problems (e.g. dispose failures,
|
|
988
|
-
* missing route targets, pushState security errors).
|
|
989
|
-
*
|
|
990
|
-
* `prefix` is the subsystem tag (e.g. `LOG_PREFIXES.ROUTE`) so that the
|
|
991
|
-
* originating subsystem appears in the log rather than the generic MOUNT tag.
|
|
992
|
-
* Pass an empty string to emit a prefix-free message.
|
|
1075
|
+
* Unconditional warning for runtime errors.
|
|
993
1076
|
*/
|
|
994
|
-
warn(
|
|
995
|
-
console.warn(`${
|
|
1077
|
+
warn(n, t, ...e) {
|
|
1078
|
+
console.warn(`${n} ${t}`, ...e);
|
|
996
1079
|
},
|
|
997
1080
|
/**
|
|
998
1081
|
* Unconditional error for binding failures.
|
|
999
|
-
* Not gated by debugEnabled — binding errors are always surfaced because
|
|
1000
|
-
* they indicate a broken updater that silently stopped applying values.
|
|
1001
1082
|
*/
|
|
1002
|
-
error(
|
|
1003
|
-
console.error(`${
|
|
1004
|
-
}
|
|
1005
|
-
},
|
|
1006
|
-
let
|
|
1007
|
-
function
|
|
1008
|
-
if (
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1011
|
-
}
|
|
1012
|
-
const
|
|
1013
|
-
function
|
|
1014
|
-
if (!
|
|
1015
|
-
|
|
1016
|
-
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);
|
|
1017
1098
|
t !== void 0 && cancelAnimationFrame(t);
|
|
1018
|
-
const e =
|
|
1099
|
+
const e = Nt.get(n);
|
|
1019
1100
|
e !== void 0 && clearTimeout(e);
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
|
|
1101
|
+
const s = requestAnimationFrame(() => {
|
|
1102
|
+
bt.delete(n), n.isConnected && (n.classList.add(Ot), Nt.set(
|
|
1103
|
+
n,
|
|
1023
1104
|
setTimeout(() => {
|
|
1024
|
-
|
|
1025
|
-
},
|
|
1026
|
-
);
|
|
1105
|
+
n.isConnected && n.classList.remove(Ot), Nt.delete(n);
|
|
1106
|
+
}, ie.HIGHLIGHT_DURATION_MS)
|
|
1107
|
+
));
|
|
1027
1108
|
});
|
|
1028
|
-
|
|
1109
|
+
bt.set(n, s);
|
|
1029
1110
|
}
|
|
1030
|
-
function
|
|
1031
|
-
return
|
|
1111
|
+
function re(n, t) {
|
|
1112
|
+
return Dt(n, t);
|
|
1032
1113
|
}
|
|
1033
|
-
Object.defineProperty(
|
|
1114
|
+
Object.defineProperty(re, "debug", {
|
|
1034
1115
|
enumerable: !0,
|
|
1035
1116
|
// configurable: true allows tests and advanced consumers to redefine or
|
|
1036
1117
|
// delete the accessor if needed. The default (false) would permanently lock
|
|
1037
1118
|
// the property on the function object.
|
|
1038
1119
|
configurable: !0,
|
|
1039
1120
|
get() {
|
|
1040
|
-
return
|
|
1121
|
+
return d.enabled;
|
|
1041
1122
|
},
|
|
1042
|
-
set(
|
|
1043
|
-
|
|
1123
|
+
set(n) {
|
|
1124
|
+
d.enabled = n;
|
|
1044
1125
|
}
|
|
1045
1126
|
});
|
|
1046
|
-
function
|
|
1047
|
-
return new Promise((
|
|
1048
|
-
}
|
|
1049
|
-
const
|
|
1050
|
-
// `atom`
|
|
1051
|
-
//
|
|
1052
|
-
//
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
nextTick: Ts
|
|
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
|
|
1063
1143
|
};
|
|
1064
|
-
|
|
1065
|
-
const
|
|
1066
|
-
class
|
|
1144
|
+
h.extend(Ze);
|
|
1145
|
+
const G = "_aes-bound";
|
|
1146
|
+
class Je {
|
|
1067
1147
|
constructor() {
|
|
1068
1148
|
this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1069
1149
|
}
|
|
@@ -1087,19 +1167,19 @@ class Ns {
|
|
|
1087
1167
|
// --------------------------------------------------------------------------
|
|
1088
1168
|
getOrCreateRecord(t) {
|
|
1089
1169
|
let e = this.records.get(t);
|
|
1090
|
-
return e || (e = {}, this.records.set(t, e), t.classList.add(
|
|
1170
|
+
return e || (e = { effects: void 0, cleanups: void 0, componentCleanup: void 0 }, this.records.set(t, e), t.classList.add(G)), e;
|
|
1091
1171
|
}
|
|
1092
1172
|
trackEffect(t, e) {
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1173
|
+
const s = this.getOrCreateRecord(t);
|
|
1174
|
+
s.effects ??= [], s.effects.push(e);
|
|
1095
1175
|
}
|
|
1096
1176
|
trackCleanup(t, e) {
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1177
|
+
const s = this.getOrCreateRecord(t);
|
|
1178
|
+
s.cleanups ??= [], s.cleanups.push(e);
|
|
1099
1179
|
}
|
|
1100
1180
|
setComponentCleanup(t, e) {
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1181
|
+
const s = this.getOrCreateRecord(t);
|
|
1182
|
+
s.componentCleanup = e;
|
|
1103
1183
|
}
|
|
1104
1184
|
hasBind(t) {
|
|
1105
1185
|
return this.records.has(t);
|
|
@@ -1110,667 +1190,921 @@ class Ns {
|
|
|
1110
1190
|
cleanup(t) {
|
|
1111
1191
|
const e = this.records.get(t);
|
|
1112
1192
|
if (!e) {
|
|
1113
|
-
t.
|
|
1193
|
+
t.nodeType === 1 && t.classList.remove(G), this.preservedNodes.delete(t), this.ignoredNodes.delete(t);
|
|
1114
1194
|
return;
|
|
1115
1195
|
}
|
|
1116
|
-
if (this.records.delete(t), this.preservedNodes.delete(t), this.ignoredNodes.delete(t), t.
|
|
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)
|
|
1117
1201
|
try {
|
|
1118
1202
|
e.componentCleanup();
|
|
1119
|
-
} catch (
|
|
1120
|
-
|
|
1203
|
+
} catch (s) {
|
|
1204
|
+
const i = t.nodeType === 1 ? X(t) : "Node";
|
|
1205
|
+
d.error(E.MOUNT, S.MOUNT.CLEANUP_ERROR(i), s);
|
|
1121
1206
|
}
|
|
1122
1207
|
if (e.effects) {
|
|
1123
|
-
const
|
|
1124
|
-
for (let i = 0, o =
|
|
1208
|
+
const s = e.effects;
|
|
1209
|
+
for (let i = 0, o = s.length; i < o; i++)
|
|
1125
1210
|
try {
|
|
1126
|
-
|
|
1211
|
+
s[i].dispose();
|
|
1127
1212
|
} catch (r) {
|
|
1128
|
-
|
|
1213
|
+
const c = t.nodeType === 1 ? X(t) : "Node";
|
|
1214
|
+
d.error(E.BINDING, S.CORE.EFFECT_DISPOSE_ERROR(c), r);
|
|
1129
1215
|
}
|
|
1130
1216
|
}
|
|
1131
1217
|
if (e.cleanups) {
|
|
1132
|
-
const
|
|
1133
|
-
for (let i = 0, o =
|
|
1218
|
+
const s = e.cleanups;
|
|
1219
|
+
for (let i = 0, o = s.length; i < o; i++)
|
|
1134
1220
|
try {
|
|
1135
|
-
|
|
1221
|
+
s[i]();
|
|
1136
1222
|
} catch (r) {
|
|
1137
|
-
|
|
1223
|
+
const c = t.nodeType === 1 ? X(t) : "Node";
|
|
1224
|
+
d.error(E.BINDING, S.BINDING.CLEANUP_ERROR(c), r);
|
|
1138
1225
|
}
|
|
1139
1226
|
}
|
|
1140
1227
|
}
|
|
1141
1228
|
cleanupDescendants(t) {
|
|
1142
|
-
const e = t.getElementsByClassName(
|
|
1143
|
-
for (let
|
|
1144
|
-
const i = e[
|
|
1145
|
-
i && (this.records.has(i) ? this.cleanup(i) : (i.classList.remove(
|
|
1146
|
-
|
|
1147
|
-
`${
|
|
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:`,
|
|
1148
1235
|
i
|
|
1149
1236
|
)));
|
|
1150
1237
|
}
|
|
1151
1238
|
}
|
|
1152
1239
|
cleanupTree(t) {
|
|
1153
|
-
this.cleanupDescendants(t), this.cleanup(t);
|
|
1240
|
+
(t.nodeType === 1 || t.nodeType === 11) && this.cleanupDescendants(t), this.cleanup(t);
|
|
1154
1241
|
}
|
|
1155
1242
|
}
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
if (it !== null) {
|
|
1160
|
-
pt !== s && f.warn(
|
|
1161
|
-
g.BINDING,
|
|
1162
|
-
"enableAutoCleanup() called with a different root while already active. Observation was NOT switched — call disableAutoCleanup() first.",
|
|
1163
|
-
{ current: pt, requested: s }
|
|
1164
|
-
);
|
|
1243
|
+
const R = new Je(), ft = /* @__PURE__ */ new Map();
|
|
1244
|
+
function ts(n) {
|
|
1245
|
+
if (ft.has(n))
|
|
1165
1246
|
return;
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
c.nodeType === 1 && (c.isConnected || y.isKept(c) || y.isIgnored(c) || y.cleanupTree(c));
|
|
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));
|
|
1173
1253
|
}
|
|
1174
1254
|
}
|
|
1175
|
-
})
|
|
1255
|
+
});
|
|
1256
|
+
t.observe(n, { childList: !0, subtree: !0 }), ft.set(n, t);
|
|
1176
1257
|
}
|
|
1177
|
-
function
|
|
1178
|
-
|
|
1258
|
+
function Gs() {
|
|
1259
|
+
ft.forEach((n) => n.disconnect()), ft.clear();
|
|
1179
1260
|
}
|
|
1180
|
-
function
|
|
1181
|
-
if (
|
|
1261
|
+
function B(n, t, e, s) {
|
|
1262
|
+
if (oe(t)) {
|
|
1182
1263
|
const i = t;
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
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
|
+
)
|
|
1197
1281
|
);
|
|
1198
|
-
} else
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
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
|
+
});
|
|
1207
1292
|
}
|
|
1208
|
-
const
|
|
1293
|
+
const dt = /* @__PURE__ */ Symbol("atom-effect-internal"), _t = /* @__PURE__ */ new WeakMap();
|
|
1209
1294
|
let x = null;
|
|
1210
|
-
const
|
|
1211
|
-
if (
|
|
1212
|
-
let t =
|
|
1295
|
+
const ce = (n) => {
|
|
1296
|
+
if (n[dt]) return n;
|
|
1297
|
+
let t = _t.get(n);
|
|
1213
1298
|
return t || (t = function(...e) {
|
|
1214
|
-
return
|
|
1215
|
-
}, t[
|
|
1299
|
+
return ne(() => n.apply(this, e));
|
|
1300
|
+
}, t[dt] = !0, _t.set(n, t)), t;
|
|
1216
1301
|
};
|
|
1217
|
-
function
|
|
1218
|
-
const t = {};
|
|
1219
|
-
|
|
1220
|
-
const
|
|
1221
|
-
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
}
|
|
1231
|
-
|
|
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() {
|
|
1232
1319
|
if (x !== null) return;
|
|
1233
1320
|
x = {
|
|
1234
|
-
on:
|
|
1235
|
-
off:
|
|
1236
|
-
remove:
|
|
1237
|
-
empty:
|
|
1238
|
-
detach:
|
|
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
|
|
1239
1326
|
};
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1327
|
+
const n = x;
|
|
1328
|
+
h.fn.remove = function(t) {
|
|
1242
1329
|
const e = t ? this.filter(t) : this;
|
|
1243
|
-
for (let
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1330
|
+
for (let i = 0, o = e.length; i < o; i++) {
|
|
1331
|
+
const r = e[i];
|
|
1332
|
+
r && (R.markIgnored(r), R.cleanupTree(r));
|
|
1246
1333
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
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);
|
|
1252
1340
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1341
|
+
const t = n.empty.call(this);
|
|
1342
|
+
return t !== void 0 ? t : this;
|
|
1343
|
+
}, h.fn.detach = function(t) {
|
|
1255
1344
|
const e = t ? this.filter(t) : this;
|
|
1256
|
-
for (let
|
|
1257
|
-
const
|
|
1258
|
-
|
|
1345
|
+
for (let i = 0, o = e.length; i < o; i++) {
|
|
1346
|
+
const r = e[i];
|
|
1347
|
+
r && R.keep(r);
|
|
1259
1348
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1349
|
+
const s = n.detach.call(this, t);
|
|
1350
|
+
return s !== void 0 ? s : this;
|
|
1351
|
+
}, h.fn.on = function(...t) {
|
|
1262
1352
|
const e = t[0];
|
|
1263
1353
|
if (e && typeof e == "object")
|
|
1264
|
-
t[0] =
|
|
1265
|
-
else
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
}, l.fn.off = function(...t) {
|
|
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) {
|
|
1273
1362
|
const e = t[0];
|
|
1274
1363
|
if (e && typeof e == "object")
|
|
1275
|
-
t[0] =
|
|
1276
|
-
else
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
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;
|
|
1284
1374
|
};
|
|
1285
1375
|
}
|
|
1286
|
-
function
|
|
1287
|
-
x !== null && (
|
|
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);
|
|
1288
1378
|
}
|
|
1289
|
-
var
|
|
1290
|
-
let
|
|
1291
|
-
|
|
1292
|
-
|
|
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;
|
|
1383
|
+
}
|
|
1384
|
+
class os {
|
|
1385
|
+
constructor(t, e, s) {
|
|
1293
1386
|
this.flags = 0, this.timeoutId = void 0, this.handleCompositionStart = () => {
|
|
1294
|
-
this.flags |=
|
|
1387
|
+
this.flags |= O.Composing;
|
|
1295
1388
|
}, this.handleCompositionEnd = () => {
|
|
1296
|
-
this.flags &= ~
|
|
1389
|
+
this.flags &= ~O.Composing, this.handleInput();
|
|
1297
1390
|
}, this.handleFocus = () => {
|
|
1298
|
-
this.flags |=
|
|
1391
|
+
this.flags |= O.Focused;
|
|
1299
1392
|
}, this.handleBlur = () => {
|
|
1300
|
-
this.flags &= ~
|
|
1301
|
-
const
|
|
1302
|
-
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();
|
|
1303
1396
|
}, this.syncDomFromAtom = () => {
|
|
1304
|
-
const
|
|
1305
|
-
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
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)
|
|
1310
1404
|
try {
|
|
1311
|
-
|
|
1405
|
+
const _ = this.isMultipleSelect ? l : this.parse(this.el.value);
|
|
1406
|
+
if (this.equal(_, c)) return;
|
|
1312
1407
|
} catch {
|
|
1313
1408
|
}
|
|
1314
|
-
this.flags |=
|
|
1409
|
+
this.flags |= O.SyncingToDom;
|
|
1315
1410
|
try {
|
|
1316
|
-
if (
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
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);
|
|
1324
1425
|
} finally {
|
|
1325
|
-
this.flags &= ~
|
|
1426
|
+
this.flags &= ~O.SyncingToDom;
|
|
1326
1427
|
}
|
|
1327
1428
|
});
|
|
1328
1429
|
}, this.cleanup = () => {
|
|
1329
1430
|
this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
|
|
1330
|
-
}, this.$el = t, this.el = t[0], this.atom = e, this.ns = `.atomBind-${++
|
|
1331
|
-
const i =
|
|
1332
|
-
this.parse =
|
|
1333
|
-
|
|
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));
|
|
1334
1437
|
} : this.handleInput = () => {
|
|
1335
|
-
this.flags &
|
|
1336
|
-
}, 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);
|
|
1337
1461
|
}
|
|
1338
1462
|
// --- Sync Logic ---
|
|
1339
1463
|
syncAtomFromDom() {
|
|
1340
|
-
if (!(this.flags &
|
|
1341
|
-
this.flags |=
|
|
1464
|
+
if (!(this.flags & O.Busy)) {
|
|
1465
|
+
this.flags |= O.SyncingToAtom;
|
|
1342
1466
|
try {
|
|
1343
|
-
|
|
1344
|
-
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);
|
|
1345
1471
|
} catch (t) {
|
|
1346
|
-
|
|
1472
|
+
d.warn(
|
|
1473
|
+
E.BINDING,
|
|
1474
|
+
S.BINDING.PARSE_ERROR(t instanceof Error ? t.message : String(t)),
|
|
1475
|
+
t
|
|
1476
|
+
);
|
|
1347
1477
|
} finally {
|
|
1348
|
-
this.flags &= ~
|
|
1478
|
+
this.flags &= ~O.SyncingToAtom;
|
|
1349
1479
|
}
|
|
1350
1480
|
}
|
|
1351
1481
|
}
|
|
1352
1482
|
bindEvents(t) {
|
|
1353
|
-
const e = this.ns;
|
|
1354
|
-
this.$el.on(`focus${e}`, this.handleFocus).on(`blur${e}`, this.handleBlur).on(`compositionstart${e}`, this.handleCompositionStart).on(`compositionend${e}`, this.handleCompositionEnd).on(
|
|
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);
|
|
1355
1485
|
}
|
|
1356
1486
|
}
|
|
1357
|
-
function
|
|
1358
|
-
const
|
|
1359
|
-
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 };
|
|
1360
1490
|
}
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
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;
|
|
1365
1526
|
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
let t = le.get(s);
|
|
1369
|
-
return t || (t = St(() => Ht(s.value)), le.set(s, t)), t;
|
|
1527
|
+
function ae(n, t) {
|
|
1528
|
+
return cs.has(n.toLowerCase()) ? as.test(t) : !1;
|
|
1370
1529
|
}
|
|
1371
|
-
function
|
|
1530
|
+
function Cs(n) {
|
|
1531
|
+
return n.toLowerCase().includes("url(") ? hs.test(n) : !1;
|
|
1532
|
+
}
|
|
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;
|
|
1537
|
+
}
|
|
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) {
|
|
1372
1544
|
return {
|
|
1373
|
-
$el:
|
|
1374
|
-
el:
|
|
1375
|
-
trackCleanup: (t) =>
|
|
1545
|
+
$el: h(n),
|
|
1546
|
+
el: n,
|
|
1547
|
+
trackCleanup: (t) => R.trackCleanup(n, t)
|
|
1376
1548
|
};
|
|
1377
1549
|
}
|
|
1378
|
-
function
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1381
|
-
|
|
1550
|
+
function le(n, t, e) {
|
|
1551
|
+
const s = n.el;
|
|
1552
|
+
B(
|
|
1553
|
+
s,
|
|
1382
1554
|
t,
|
|
1383
1555
|
(i) => {
|
|
1384
1556
|
const o = e ? e(i) : typeof i == "string" ? i : String(i ?? "");
|
|
1385
|
-
|
|
1557
|
+
s.textContent !== o && (s.textContent = o);
|
|
1386
1558
|
},
|
|
1387
1559
|
"text"
|
|
1388
1560
|
);
|
|
1389
1561
|
}
|
|
1390
|
-
function
|
|
1391
|
-
const e =
|
|
1392
|
-
|
|
1562
|
+
function he(n, t) {
|
|
1563
|
+
const e = n.el, s = wt(t) ? Ss(t) : t;
|
|
1564
|
+
B(
|
|
1393
1565
|
e,
|
|
1394
|
-
|
|
1566
|
+
s,
|
|
1395
1567
|
(i) => {
|
|
1396
|
-
e.innerHTML !== i && (
|
|
1568
|
+
e.innerHTML !== i && (R.cleanupDescendants(e), e.innerHTML = i);
|
|
1397
1569
|
},
|
|
1398
1570
|
"html"
|
|
1399
1571
|
);
|
|
1400
1572
|
}
|
|
1401
|
-
function
|
|
1573
|
+
function ue(n, t) {
|
|
1402
1574
|
for (const e in t)
|
|
1403
|
-
if (
|
|
1404
|
-
const
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
(
|
|
1409
|
-
|
|
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);
|
|
1410
1589
|
},
|
|
1411
1590
|
`class.${e}`
|
|
1412
1591
|
);
|
|
1413
1592
|
}
|
|
1414
1593
|
}
|
|
1415
|
-
function
|
|
1416
|
-
const e =
|
|
1594
|
+
function fe(n, t) {
|
|
1595
|
+
const e = n.el, s = e.style;
|
|
1417
1596
|
for (const i in t)
|
|
1418
|
-
if (
|
|
1419
|
-
const o = t[i], r =
|
|
1420
|
-
|
|
1597
|
+
if (Z.call(t, i)) {
|
|
1598
|
+
const o = t[i], r = Ts(i), [c, a] = Array.isArray(o) ? o : [o, ""];
|
|
1599
|
+
B(
|
|
1421
1600
|
e,
|
|
1422
1601
|
c,
|
|
1423
|
-
(
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1602
|
+
(l) => {
|
|
1603
|
+
const u = a ? String(l) + a : String(l);
|
|
1604
|
+
Cs(u) || (s[r] = u);
|
|
1426
1605
|
},
|
|
1427
1606
|
`css.${i}`
|
|
1428
1607
|
);
|
|
1429
1608
|
}
|
|
1430
1609
|
}
|
|
1431
|
-
function
|
|
1432
|
-
const e =
|
|
1433
|
-
for (const
|
|
1434
|
-
if (
|
|
1435
|
-
|
|
1436
|
-
|
|
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(
|
|
1437
1623
|
e,
|
|
1438
|
-
t[
|
|
1439
|
-
(
|
|
1440
|
-
if (
|
|
1441
|
-
e.removeAttribute(
|
|
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);
|
|
1442
1632
|
return;
|
|
1443
1633
|
}
|
|
1444
|
-
const
|
|
1445
|
-
|
|
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);
|
|
1446
1642
|
},
|
|
1447
|
-
`attr.${
|
|
1643
|
+
`attr.${s}`
|
|
1448
1644
|
);
|
|
1449
1645
|
}
|
|
1450
1646
|
}
|
|
1451
|
-
function
|
|
1452
|
-
const e =
|
|
1453
|
-
for (const
|
|
1454
|
-
if (
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
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);
|
|
1461
1674
|
},
|
|
1462
|
-
`prop.${
|
|
1675
|
+
`prop.${s}`
|
|
1463
1676
|
);
|
|
1464
1677
|
}
|
|
1465
1678
|
}
|
|
1466
|
-
function
|
|
1467
|
-
const n = s.
|
|
1468
|
-
|
|
1469
|
-
|
|
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,
|
|
1470
1683
|
t,
|
|
1471
|
-
(
|
|
1472
|
-
|
|
1473
|
-
n.style.display = r ? "" : "none";
|
|
1684
|
+
(c) => {
|
|
1685
|
+
s.style.display = e !== !!c ? r : "none";
|
|
1474
1686
|
},
|
|
1475
|
-
|
|
1687
|
+
i
|
|
1476
1688
|
);
|
|
1477
1689
|
}
|
|
1478
|
-
function
|
|
1479
|
-
const
|
|
1480
|
-
if (!
|
|
1481
|
-
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
|
+
);
|
|
1482
1696
|
return;
|
|
1483
1697
|
}
|
|
1484
|
-
const { fx: i, cleanup: o } =
|
|
1485
|
-
|
|
1698
|
+
const { fx: i, cleanup: o } = rs(n.$el, t, e);
|
|
1699
|
+
R.trackEffect(n.el, i), n.trackCleanup(o);
|
|
1486
1700
|
}
|
|
1487
|
-
function
|
|
1488
|
-
const e =
|
|
1489
|
-
const
|
|
1490
|
-
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
|
+
}
|
|
1491
1708
|
};
|
|
1492
|
-
|
|
1493
|
-
const
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
e.checked !==
|
|
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));
|
|
1497
1714
|
});
|
|
1498
1715
|
});
|
|
1499
|
-
|
|
1716
|
+
R.trackEffect(e, r);
|
|
1717
|
+
}
|
|
1718
|
+
function Ns(n, t) {
|
|
1719
|
+
const e = n.$el;
|
|
1720
|
+
e.on(t), n.trackCleanup(() => e.off(t));
|
|
1500
1721
|
}
|
|
1501
|
-
function
|
|
1502
|
-
const
|
|
1503
|
-
|
|
1722
|
+
function bs(n, t, e) {
|
|
1723
|
+
const s = n.$el;
|
|
1724
|
+
s.on(t, e), n.trackCleanup(() => s.off(t, e));
|
|
1504
1725
|
}
|
|
1505
|
-
function
|
|
1506
|
-
|
|
1507
|
-
n.on(t, e), s.trackCleanup(() => n.off(t, e));
|
|
1726
|
+
function me(n) {
|
|
1727
|
+
R.cleanupTree(n);
|
|
1508
1728
|
}
|
|
1509
|
-
function
|
|
1510
|
-
|
|
1729
|
+
function k(n) {
|
|
1730
|
+
d.enabled && d.log(E.BINDING, `Skipping non-Element node (nodeType=${n})`);
|
|
1511
1731
|
}
|
|
1512
|
-
|
|
1513
|
-
for (let e = 0,
|
|
1514
|
-
|
|
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
|
+
}
|
|
1515
1737
|
return this;
|
|
1516
1738
|
};
|
|
1517
|
-
|
|
1518
|
-
for (let t = 0, e = this.length; t < e; t++)
|
|
1519
|
-
|
|
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
|
+
}
|
|
1520
1744
|
return this;
|
|
1521
1745
|
};
|
|
1522
|
-
|
|
1523
|
-
if (typeof
|
|
1524
|
-
return console.warn(
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
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
|
+
}
|
|
1528
1756
|
return this;
|
|
1529
1757
|
};
|
|
1530
|
-
|
|
1531
|
-
if (typeof
|
|
1532
|
-
return console.warn(`${
|
|
1533
|
-
const
|
|
1534
|
-
for (let i = 0, o = this.length; i < o; i++)
|
|
1535
|
-
|
|
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
|
+
}
|
|
1536
1766
|
return this;
|
|
1537
1767
|
};
|
|
1538
|
-
|
|
1539
|
-
if (typeof
|
|
1540
|
-
return console.warn(`${
|
|
1541
|
-
const e = typeof
|
|
1542
|
-
for (let
|
|
1543
|
-
|
|
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
|
+
}
|
|
1544
1776
|
return this;
|
|
1545
1777
|
};
|
|
1546
|
-
|
|
1547
|
-
if (typeof
|
|
1548
|
-
return console.warn(`${
|
|
1549
|
-
const e = typeof
|
|
1550
|
-
for (let
|
|
1551
|
-
|
|
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
|
+
}
|
|
1552
1786
|
return this;
|
|
1553
1787
|
};
|
|
1554
|
-
|
|
1555
|
-
for (let t = 0, e = this.length; t < e; t++)
|
|
1556
|
-
|
|
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
|
+
}
|
|
1557
1793
|
return this;
|
|
1558
1794
|
};
|
|
1559
|
-
|
|
1560
|
-
for (let t = 0, e = this.length; t < e; t++)
|
|
1561
|
-
|
|
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
|
+
}
|
|
1562
1800
|
return this;
|
|
1563
1801
|
};
|
|
1564
|
-
|
|
1565
|
-
for (let e = 0,
|
|
1566
|
-
|
|
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
|
+
}
|
|
1567
1811
|
return this;
|
|
1568
1812
|
};
|
|
1569
|
-
|
|
1570
|
-
for (let t = 0, e = this.length; t < e; t++)
|
|
1571
|
-
|
|
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
|
+
}
|
|
1572
1818
|
return this;
|
|
1573
1819
|
};
|
|
1574
|
-
|
|
1575
|
-
for (let e = 0,
|
|
1576
|
-
|
|
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
|
+
}
|
|
1577
1825
|
return this;
|
|
1578
1826
|
};
|
|
1579
|
-
|
|
1580
|
-
const { text: t, html: e, class:
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
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, _);
|
|
1586
1840
|
}
|
|
1587
1841
|
return this;
|
|
1588
1842
|
};
|
|
1589
|
-
|
|
1590
|
-
for (let
|
|
1591
|
-
|
|
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
|
+
}
|
|
1592
1848
|
return this;
|
|
1593
1849
|
};
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
}
|
|
1610
|
-
const $ = c(D.$el);
|
|
1611
|
-
$ instanceof Promise ? $.then(z, z) : z();
|
|
1612
|
-
}, Qt = (L, D) => {
|
|
1613
|
-
C.delete(L), I.add(L), we(L, D);
|
|
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));
|
|
1614
1865
|
};
|
|
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
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
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;
|
|
1712
2028
|
});
|
|
1713
|
-
})
|
|
1714
|
-
|
|
2029
|
+
});
|
|
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);
|
|
1715
2049
|
});
|
|
1716
2050
|
}
|
|
1717
2051
|
return this;
|
|
1718
2052
|
};
|
|
1719
|
-
const
|
|
1720
|
-
|
|
1721
|
-
const e = t ??
|
|
1722
|
-
for (let
|
|
1723
|
-
const o = this[
|
|
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];
|
|
1724
2058
|
if (!o) continue;
|
|
1725
|
-
|
|
1726
|
-
const r =
|
|
2059
|
+
R.cleanupTree(o);
|
|
2060
|
+
const r = h(o);
|
|
1727
2061
|
let c;
|
|
1728
2062
|
try {
|
|
1729
|
-
c =
|
|
1730
|
-
} catch (
|
|
1731
|
-
|
|
2063
|
+
c = P(() => n(r, e));
|
|
2064
|
+
} catch (a) {
|
|
2065
|
+
d.error(E.MOUNT, S.MOUNT.ERROR(n.name), a);
|
|
1732
2066
|
continue;
|
|
1733
2067
|
}
|
|
1734
|
-
typeof c == "function" &&
|
|
2068
|
+
typeof c == "function" && R.setComponentCleanup(o, c);
|
|
1735
2069
|
}
|
|
1736
2070
|
return this;
|
|
1737
2071
|
};
|
|
1738
|
-
|
|
1739
|
-
for (let
|
|
1740
|
-
const e = this[
|
|
1741
|
-
e &&
|
|
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);
|
|
1742
2076
|
}
|
|
1743
2077
|
return this;
|
|
1744
2078
|
};
|
|
1745
|
-
function
|
|
2079
|
+
function Yt(n, t) {
|
|
1746
2080
|
try {
|
|
1747
|
-
return history.pushState(
|
|
2081
|
+
return history.pushState(n, "", t), !0;
|
|
1748
2082
|
} catch (e) {
|
|
1749
|
-
return
|
|
1750
|
-
|
|
2083
|
+
return d.warn(
|
|
2084
|
+
E.ROUTE,
|
|
1751
2085
|
"PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.",
|
|
1752
2086
|
e
|
|
1753
2087
|
), !1;
|
|
1754
2088
|
}
|
|
1755
2089
|
}
|
|
1756
|
-
class
|
|
2090
|
+
class Ps {
|
|
1757
2091
|
constructor(t) {
|
|
1758
2092
|
this.isDestroyed = !1, this.previousRoute = "", this.cleanups = [], this.templateCache = /* @__PURE__ */ new Map(), this.config = {
|
|
1759
2093
|
...t,
|
|
1760
|
-
mode: t.mode ??
|
|
1761
|
-
basePath: t.basePath ??
|
|
1762
|
-
autoBindLinks: t.autoBindLinks ??
|
|
1763
|
-
activeClass: t.activeClass ??
|
|
1764
|
-
}, 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();
|
|
1765
2099
|
}
|
|
1766
2100
|
init() {
|
|
1767
2101
|
const t = this.isHistoryMode ? "popstate" : "hashchange";
|
|
1768
2102
|
window.addEventListener(t, this.handleUrlChange), this.cleanups.push(() => window.removeEventListener(t, this.handleUrlChange));
|
|
1769
|
-
const e =
|
|
1770
|
-
const
|
|
1771
|
-
|
|
2103
|
+
const e = V(() => {
|
|
2104
|
+
const s = this.currentRouteAtom.value;
|
|
2105
|
+
P(() => this.renderRoute(s));
|
|
1772
2106
|
});
|
|
1773
|
-
this.cleanups.push(() => e.dispose()), this.setupAutoBindLinks(), this.$target[0] &&
|
|
2107
|
+
this.cleanups.push(() => e.dispose()), this.setupAutoBindLinks(), this.$target[0] && R.trackCleanup(this.$target[0], this.destroy);
|
|
1774
2108
|
}
|
|
1775
2109
|
// --- Mode-abstracted internal methods ---
|
|
1776
2110
|
/**
|
|
@@ -1783,8 +2117,8 @@ class Bs {
|
|
|
1783
2117
|
let o = window.location.pathname;
|
|
1784
2118
|
return this.normalizedBasePath && o.startsWith(this.normalizedBasePath) && (o = o.substring(this.normalizedBasePath.length)), o.charCodeAt(0) === 47 && (o = o.slice(1)), o || t;
|
|
1785
2119
|
}
|
|
1786
|
-
const e = window.location.hash,
|
|
1787
|
-
return (
|
|
2120
|
+
const e = window.location.hash, s = e.indexOf("?");
|
|
2121
|
+
return (s === -1 ? e.substring(1) : e.substring(1, s)) || t;
|
|
1788
2122
|
}
|
|
1789
2123
|
/**
|
|
1790
2124
|
* Parses query parameters from the current URL.
|
|
@@ -1793,6 +2127,12 @@ class Bs {
|
|
|
1793
2127
|
* only (`{ a: '2' }`). This matches `URLSearchParams` → `Object.fromEntries`
|
|
1794
2128
|
* behaviour. If multi-value keys are needed, access `queryParams` via
|
|
1795
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.
|
|
1796
2136
|
*/
|
|
1797
2137
|
getQueryParams() {
|
|
1798
2138
|
let t;
|
|
@@ -1803,14 +2143,14 @@ class Bs {
|
|
|
1803
2143
|
if (o === -1) return {};
|
|
1804
2144
|
t = i.substring(o + 1);
|
|
1805
2145
|
}
|
|
1806
|
-
const e = new URLSearchParams(t),
|
|
2146
|
+
const e = new URLSearchParams(t), s = Object.fromEntries(e);
|
|
1807
2147
|
if (t.includes("%"))
|
|
1808
2148
|
try {
|
|
1809
2149
|
decodeURIComponent(t);
|
|
1810
2150
|
} catch {
|
|
1811
|
-
|
|
2151
|
+
d.warn(E.ROUTE, S.ROUTE.MALFORMED_URI(t));
|
|
1812
2152
|
}
|
|
1813
|
-
return
|
|
2153
|
+
return s;
|
|
1814
2154
|
}
|
|
1815
2155
|
/**
|
|
1816
2156
|
* Updates the browser URL to reflect a new route and keeps `previousUrl`
|
|
@@ -1819,7 +2159,7 @@ class Bs {
|
|
|
1819
2159
|
setUrl(t) {
|
|
1820
2160
|
if (this.isHistoryMode) {
|
|
1821
2161
|
const e = `${this.normalizedBasePath}/${t}`;
|
|
1822
|
-
|
|
2162
|
+
Yt(null, e), this.previousUrl = e;
|
|
1823
2163
|
} else {
|
|
1824
2164
|
const e = `#${t}`;
|
|
1825
2165
|
window.location.hash = e, this.previousUrl = e;
|
|
@@ -1831,7 +2171,7 @@ class Bs {
|
|
|
1831
2171
|
* that occur with replaceState during popstate events.
|
|
1832
2172
|
*/
|
|
1833
2173
|
restoreUrl() {
|
|
1834
|
-
this.isHistoryMode ?
|
|
2174
|
+
this.isHistoryMode ? Yt(null, this.previousUrl) : window.location.hash = this.previousUrl;
|
|
1835
2175
|
}
|
|
1836
2176
|
/**
|
|
1837
2177
|
* Returns the current full URL string for comparison purposes.
|
|
@@ -1844,9 +2184,9 @@ class Bs {
|
|
|
1844
2184
|
* Resolves route configuration, falling back to notFound route if needed.
|
|
1845
2185
|
*/
|
|
1846
2186
|
getRouteConfig(t) {
|
|
1847
|
-
const { routes: e, notFound:
|
|
2187
|
+
const { routes: e, notFound: s } = this.config;
|
|
1848
2188
|
let i = e[t];
|
|
1849
|
-
return !i &&
|
|
2189
|
+
return !i && s && (i = e[s]), i || (d.warn(E.ROUTE, S.ROUTE.NOT_FOUND(t)), null);
|
|
1850
2190
|
}
|
|
1851
2191
|
/**
|
|
1852
2192
|
* Appends cloned template content into the target container.
|
|
@@ -1858,11 +2198,11 @@ class Bs {
|
|
|
1858
2198
|
if (!e) {
|
|
1859
2199
|
const i = document.querySelector(t);
|
|
1860
2200
|
if (!i || !(i instanceof HTMLTemplateElement))
|
|
1861
|
-
return
|
|
2201
|
+
return d.warn(E.ROUTE, S.ROUTE.TEMPLATE_NOT_FOUND(t)), !1;
|
|
1862
2202
|
e = i, this.templateCache.set(t, e);
|
|
1863
2203
|
}
|
|
1864
|
-
const
|
|
1865
|
-
return this.$target.append(
|
|
2204
|
+
const s = e.content.cloneNode(!0);
|
|
2205
|
+
return this.$target.append(s), !0;
|
|
1866
2206
|
}
|
|
1867
2207
|
/**
|
|
1868
2208
|
* Renders the specified route, including lifecycle hooks and content.
|
|
@@ -1873,27 +2213,33 @@ class Bs {
|
|
|
1873
2213
|
* outgoing content are disposed before the nodes are removed — preventing
|
|
1874
2214
|
* the MutationObserver auto-cleanup path from firing a redundant cleanup.
|
|
1875
2215
|
*
|
|
1876
|
-
*
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
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.
|
|
1879
2225
|
*/
|
|
1880
2226
|
renderRoute(t) {
|
|
1881
2227
|
if (this.isDestroyed) return;
|
|
1882
2228
|
const e = this.$target[0];
|
|
1883
2229
|
if (!e) {
|
|
1884
|
-
|
|
2230
|
+
d.warn(E.ROUTE, S.ROUTE.TARGET_NOT_FOUND(this.config.target));
|
|
1885
2231
|
return;
|
|
1886
2232
|
}
|
|
1887
|
-
const
|
|
1888
|
-
if (!
|
|
2233
|
+
const s = this.getRouteConfig(t);
|
|
2234
|
+
if (!s) return;
|
|
1889
2235
|
const i = this.getQueryParams(), o = this.previousRoute;
|
|
1890
2236
|
this.config.beforeTransition && this.config.beforeTransition(o, t), this.$target.empty();
|
|
1891
2237
|
let r = i;
|
|
1892
|
-
if (
|
|
1893
|
-
const c =
|
|
2238
|
+
if (s.onEnter) {
|
|
2239
|
+
const c = s.onEnter(i);
|
|
1894
2240
|
c !== void 0 && (r = { ...i, ...c });
|
|
1895
2241
|
}
|
|
1896
|
-
|
|
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;
|
|
1897
2243
|
}
|
|
1898
2244
|
/**
|
|
1899
2245
|
* Handles browser URL change events (hashchange or popstate).
|
|
@@ -1902,9 +2248,9 @@ class Bs {
|
|
|
1902
2248
|
if (this.isDestroyed) return;
|
|
1903
2249
|
const t = this.getCurrentUrl();
|
|
1904
2250
|
if (t === this.previousUrl) return;
|
|
1905
|
-
const e = this.getRouteName(),
|
|
1906
|
-
if (
|
|
1907
|
-
const o = this.config.routes[
|
|
2251
|
+
const e = this.getRouteName(), s = this.currentRouteAtom.peek(), i = this.getQueryParams();
|
|
2252
|
+
if (s !== e) {
|
|
2253
|
+
const o = this.config.routes[s];
|
|
1908
2254
|
if (o?.onLeave && o.onLeave() === !1) {
|
|
1909
2255
|
this.restoreUrl();
|
|
1910
2256
|
return;
|
|
@@ -1912,7 +2258,7 @@ class Bs {
|
|
|
1912
2258
|
this.currentRouteAtom.value = e, this.queryParamsAtom.value = i;
|
|
1913
2259
|
} else {
|
|
1914
2260
|
this.queryParamsAtom.value = i;
|
|
1915
|
-
const o = this.config.routes[
|
|
2261
|
+
const o = this.config.routes[s];
|
|
1916
2262
|
o?.onParamsChange ? o.onParamsChange(i) : this.renderRoute(e);
|
|
1917
2263
|
}
|
|
1918
2264
|
this.previousUrl = t;
|
|
@@ -1935,20 +2281,20 @@ class Bs {
|
|
|
1935
2281
|
const o = i.currentTarget.dataset.route;
|
|
1936
2282
|
o != null && this.navigate(o);
|
|
1937
2283
|
};
|
|
1938
|
-
|
|
1939
|
-
|
|
2284
|
+
h(document).on("click", "[data-route]", t), this.cleanups.push(() => {
|
|
2285
|
+
h(document).off("click", "[data-route]", t);
|
|
1940
2286
|
});
|
|
1941
|
-
const
|
|
2287
|
+
const e = this.activeClass, s = V(() => {
|
|
1942
2288
|
const i = this.currentRouteAtom.value;
|
|
1943
|
-
|
|
2289
|
+
P(() => {
|
|
1944
2290
|
const o = document.querySelectorAll("[data-route]");
|
|
1945
2291
|
for (let r = 0, c = o.length; r < c; r++) {
|
|
1946
|
-
const
|
|
1947
|
-
|
|
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");
|
|
1948
2294
|
}
|
|
1949
2295
|
});
|
|
1950
2296
|
});
|
|
1951
|
-
this.cleanups.push(() =>
|
|
2297
|
+
this.cleanups.push(() => s.dispose());
|
|
1952
2298
|
}
|
|
1953
2299
|
/**
|
|
1954
2300
|
* Navigates to the specified route programmatically.
|
|
@@ -1960,13 +2306,13 @@ class Bs {
|
|
|
1960
2306
|
*/
|
|
1961
2307
|
navigate(t) {
|
|
1962
2308
|
if (this.isDestroyed) return;
|
|
1963
|
-
const e = this.currentRouteAtom.peek(),
|
|
1964
|
-
if (
|
|
2309
|
+
const e = this.currentRouteAtom.peek(), s = this.config.routes[e];
|
|
2310
|
+
if (s?.onLeave && s.onLeave() === !1)
|
|
1965
2311
|
return;
|
|
1966
2312
|
const i = t || this.config.default;
|
|
1967
2313
|
if (!i) {
|
|
1968
|
-
|
|
1969
|
-
|
|
2314
|
+
d.warn(
|
|
2315
|
+
E.ROUTE,
|
|
1970
2316
|
"navigate() called with empty routeName and no default configured."
|
|
1971
2317
|
);
|
|
1972
2318
|
return;
|
|
@@ -1982,72 +2328,104 @@ class Bs {
|
|
|
1982
2328
|
if (this.isDestroyed) return;
|
|
1983
2329
|
this.isDestroyed = !0;
|
|
1984
2330
|
const t = this.cleanups;
|
|
1985
|
-
|
|
2331
|
+
this.cleanups = [];
|
|
2332
|
+
for (let e = 0, s = t.length; e < s; e++)
|
|
1986
2333
|
try {
|
|
1987
2334
|
t[e]();
|
|
1988
2335
|
} catch (i) {
|
|
1989
|
-
|
|
2336
|
+
d.warn(E.ROUTE, "Cleanup error during destroy:", i);
|
|
1990
2337
|
}
|
|
1991
|
-
this.
|
|
2338
|
+
this.templateCache.clear();
|
|
1992
2339
|
}
|
|
1993
2340
|
}
|
|
1994
|
-
function
|
|
1995
|
-
return new
|
|
2341
|
+
function Ms(n) {
|
|
2342
|
+
return new Ps(n);
|
|
1996
2343
|
}
|
|
1997
|
-
|
|
1998
|
-
route:
|
|
1999
|
-
});
|
|
2000
|
-
const Gs = new Promise(() => {
|
|
2344
|
+
h.extend({
|
|
2345
|
+
route: Ms
|
|
2001
2346
|
});
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
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)
|
|
2014
2376
|
try {
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
}
|
|
2018
|
-
|
|
2019
|
-
|
|
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)
|
|
2020
2391
|
try {
|
|
2021
|
-
c
|
|
2392
|
+
a(c);
|
|
2022
2393
|
} catch {
|
|
2023
2394
|
}
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
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
|
+
});
|
|
2031
2409
|
}
|
|
2032
2410
|
});
|
|
2033
|
-
|
|
2034
|
-
|
|
2411
|
+
h(() => {
|
|
2412
|
+
ns(), ts(document.body);
|
|
2035
2413
|
});
|
|
2036
2414
|
export {
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2415
|
+
Dt as atom,
|
|
2416
|
+
ne as batch,
|
|
2417
|
+
gt as computed,
|
|
2418
|
+
zs as default,
|
|
2419
|
+
Gs as disableAutoCleanup,
|
|
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
|
|
2052
2430
|
};
|
|
2053
2431
|
//# sourceMappingURL=index.mjs.map
|