@but212/atom-effect-jquery 0.25.0 → 0.27.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 +2 -2
- 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 +71 -122
- package/dist/index.mjs +1286 -1218
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -50,7 +50,13 @@ var d = Object.freeze([]), f = class {
|
|
|
50
50
|
this.fn = e, this.sub = t;
|
|
51
51
|
}
|
|
52
52
|
notify(e, t) {
|
|
53
|
-
|
|
53
|
+
let n = this.fn;
|
|
54
|
+
if (n !== void 0) {
|
|
55
|
+
n(e, t);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let r = this.sub;
|
|
59
|
+
r !== void 0 && r.execute();
|
|
54
60
|
}
|
|
55
61
|
}, m = class extends Error {
|
|
56
62
|
constructor(e, t = null, n = !0) {
|
|
@@ -89,26 +95,24 @@ var d = Object.freeze([]), f = class {
|
|
|
89
95
|
BATCH_CALLBACK_MUST_BE_FUNCTION: "Batch callback must be a function"
|
|
90
96
|
}, y = class {
|
|
91
97
|
constructor() {
|
|
92
|
-
this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow = null;
|
|
98
|
+
this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow = null, this._freeIndices = null;
|
|
93
99
|
}
|
|
94
100
|
get size() {
|
|
95
101
|
return this._count;
|
|
96
102
|
}
|
|
97
103
|
getAt(e) {
|
|
98
|
-
switch (e) {
|
|
104
|
+
if (e < 4) switch (e) {
|
|
99
105
|
case 0: return this._s0;
|
|
100
106
|
case 1: return this._s1;
|
|
101
107
|
case 2: return this._s2;
|
|
102
108
|
case 3: return this._s3;
|
|
103
|
-
default: {
|
|
104
|
-
let t = this._overflow;
|
|
105
|
-
if (t !== null && e >= 4) {
|
|
106
|
-
let n = e - 4;
|
|
107
|
-
if (n < t.length) return t[n] ?? null;
|
|
108
|
-
}
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
109
|
}
|
|
110
|
+
let t = this._overflow;
|
|
111
|
+
if (t !== null) {
|
|
112
|
+
let n = t[e - 4];
|
|
113
|
+
return n === void 0 ? null : n;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
112
116
|
}
|
|
113
117
|
setAt(e, t) {
|
|
114
118
|
switch (e) {
|
|
@@ -124,31 +128,27 @@ var d = Object.freeze([]), f = class {
|
|
|
124
128
|
case 3:
|
|
125
129
|
this._s3 = t;
|
|
126
130
|
break;
|
|
127
|
-
default:
|
|
128
|
-
this._overflow ??= [];
|
|
129
|
-
let n = this._overflow;
|
|
130
|
-
n[e - 4] = t;
|
|
131
|
-
}
|
|
131
|
+
default: this._overflow ??= [], this._overflow[e - 4] = t;
|
|
132
132
|
}
|
|
133
133
|
e >= this._count && (this._count = e + 1);
|
|
134
134
|
}
|
|
135
135
|
truncateFrom(e) {
|
|
136
136
|
let t = this._count;
|
|
137
137
|
if (e >= t) return;
|
|
138
|
-
if (e <= 3)
|
|
139
|
-
|
|
138
|
+
if (e <= 3) {
|
|
139
|
+
if (e <= 0) {
|
|
140
140
|
let e = this._s0;
|
|
141
141
|
e != null && (this._onItemRemoved(e), this._s0 = null);
|
|
142
142
|
}
|
|
143
|
-
|
|
143
|
+
if (e <= 1) {
|
|
144
144
|
let e = this._s1;
|
|
145
145
|
e != null && (this._onItemRemoved(e), this._s1 = null);
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
if (e <= 2) {
|
|
148
148
|
let e = this._s2;
|
|
149
149
|
e != null && (this._onItemRemoved(e), this._s2 = null);
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
if (e <= 3) {
|
|
152
152
|
let e = this._s3;
|
|
153
153
|
e != null && (this._onItemRemoved(e), this._s3 = null);
|
|
154
154
|
}
|
|
@@ -162,7 +162,7 @@ var d = Object.freeze([]), f = class {
|
|
|
162
162
|
}
|
|
163
163
|
e <= 4 ? (n.length = 0, this._overflow = null) : n.length = e - 4;
|
|
164
164
|
}
|
|
165
|
-
this._count = e;
|
|
165
|
+
this._freeIndices !== null && (this._freeIndices = null), this._count = e;
|
|
166
166
|
}
|
|
167
167
|
_onItemRemoved(e) {}
|
|
168
168
|
add(e) {
|
|
@@ -182,14 +182,14 @@ var d = Object.freeze([]), f = class {
|
|
|
182
182
|
this._s3 = e, this._count++;
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
this._addToOverflow(e);
|
|
186
|
+
}
|
|
187
|
+
_addToOverflow(e) {
|
|
188
|
+
let t = this._overflow;
|
|
189
|
+
if (t === null) this._overflow = [e];
|
|
186
190
|
else {
|
|
187
|
-
let
|
|
188
|
-
|
|
189
|
-
t[n] = e, this._count++;
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
t.push(e);
|
|
191
|
+
let n = this._freeIndices;
|
|
192
|
+
n !== null && n.length > 0 ? t[n.pop()] = e : t.push(e);
|
|
193
193
|
}
|
|
194
194
|
this._count++;
|
|
195
195
|
}
|
|
@@ -200,179 +200,233 @@ var d = Object.freeze([]), f = class {
|
|
|
200
200
|
if (this._s3 === e) return this._s3 = null, this._count--, !0;
|
|
201
201
|
let t = this._overflow;
|
|
202
202
|
if (t == null) return !1;
|
|
203
|
-
for (let n = 0, r = t.length; n < r; n++) if (t[n] === e)
|
|
203
|
+
for (let n = 0, r = t.length; n < r; n++) if (t[n] === e) {
|
|
204
|
+
t[n] = null, this._count--;
|
|
205
|
+
let e = this._freeIndices;
|
|
206
|
+
return e === null && (e = this._freeIndices = []), e.push(n), !0;
|
|
207
|
+
}
|
|
204
208
|
return !1;
|
|
205
209
|
}
|
|
206
210
|
has(e) {
|
|
207
|
-
|
|
208
|
-
if (t === 0) return !1;
|
|
211
|
+
if (this._count === 0) return !1;
|
|
209
212
|
if (this._s0 === e || this._s1 === e || this._s2 === e || this._s3 === e) return !0;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
let r = 0;
|
|
214
|
-
this._s0 != null && r++, this._s1 != null && r++, this._s2 != null && r++, this._s3 != null && r++;
|
|
215
|
-
for (let i = 0, a = n.length; i < a; i++) {
|
|
216
|
-
let a = n[i];
|
|
217
|
-
if (a != null) {
|
|
218
|
-
if (a === e) return !0;
|
|
219
|
-
if (++r === t) break;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
213
|
+
let t = this._overflow;
|
|
214
|
+
if (t != null) {
|
|
215
|
+
for (let n = 0, r = t.length; n < r; n++) if (t[n] === e) return !0;
|
|
222
216
|
}
|
|
223
217
|
return !1;
|
|
224
218
|
}
|
|
225
219
|
forEach(e) {
|
|
226
220
|
let t = this._count;
|
|
227
221
|
if (t === 0) return;
|
|
228
|
-
let n = this._s0;
|
|
229
|
-
|
|
230
|
-
let
|
|
231
|
-
|
|
232
|
-
let
|
|
233
|
-
|
|
234
|
-
let
|
|
235
|
-
if (
|
|
236
|
-
let
|
|
237
|
-
if (
|
|
238
|
-
let
|
|
239
|
-
|
|
240
|
-
for (let n = 0, r = o.length; n < r; n++) {
|
|
241
|
-
let r = o[n];
|
|
242
|
-
if (r != null && (e(r), ++s === t)) return;
|
|
243
|
-
}
|
|
222
|
+
let n = 0, r = this._s0;
|
|
223
|
+
if (r != null && (e(r), ++n === t)) return;
|
|
224
|
+
let i = this._s1;
|
|
225
|
+
if (i != null && (e(i), ++n === t)) return;
|
|
226
|
+
let a = this._s2;
|
|
227
|
+
if (a != null && (e(a), ++n === t)) return;
|
|
228
|
+
let o = this._s3;
|
|
229
|
+
if (o != null && (e(o), ++n === t)) return;
|
|
230
|
+
let s = this._overflow;
|
|
231
|
+
if (s != null) for (let r = 0, i = s.length; r < i; r++) {
|
|
232
|
+
let i = s[r];
|
|
233
|
+
if (i != null && (e(i), ++n === t)) return;
|
|
244
234
|
}
|
|
245
235
|
}
|
|
246
236
|
forEachIndexed(e) {
|
|
247
237
|
let t = this._count;
|
|
248
238
|
if (t === 0) return 0;
|
|
249
239
|
let n = 0, r = this._s0;
|
|
250
|
-
r != null && (e(r), n
|
|
240
|
+
if (r != null && (e(r), ++n === t)) return n;
|
|
251
241
|
let i = this._s1;
|
|
252
|
-
i != null && (e(i), n
|
|
242
|
+
if (i != null && (e(i), ++n === t)) return n;
|
|
253
243
|
let a = this._s2;
|
|
254
|
-
a != null && (e(a), n
|
|
244
|
+
if (a != null && (e(a), ++n === t)) return n;
|
|
255
245
|
let o = this._s3;
|
|
256
|
-
if (o != null && (e(o),
|
|
246
|
+
if (o != null && (e(o), ++n === t)) return n;
|
|
257
247
|
let s = this._overflow;
|
|
258
248
|
if (s != null) for (let r = 0, i = s.length; r < i; r++) {
|
|
259
249
|
let i = s[r];
|
|
260
|
-
if (i != null && (e(i), ++n === t))
|
|
250
|
+
if (i != null && (e(i), ++n === t)) return n;
|
|
261
251
|
}
|
|
262
252
|
return n;
|
|
263
253
|
}
|
|
264
254
|
compact() {
|
|
265
255
|
let e = this._overflow;
|
|
266
|
-
if (e === null
|
|
267
|
-
let t =
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
256
|
+
if (e === null) return;
|
|
257
|
+
let t = e.length;
|
|
258
|
+
if (t === 0) return;
|
|
259
|
+
let n = 0;
|
|
260
|
+
for (; n < t;) if (e[n] === null) {
|
|
261
|
+
for (; t > n && e[t - 1] === null;) e.pop(), t--;
|
|
262
|
+
t > n && (e[n] = e.pop(), t--, n++);
|
|
263
|
+
} else n++;
|
|
264
|
+
this._freeIndices = null, t === 0 && (this._overflow = null);
|
|
273
265
|
}
|
|
274
266
|
clear() {
|
|
275
|
-
this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow !== null && (this._overflow.length = 0, this._overflow = null);
|
|
267
|
+
this._s0 = null, this._s1 = null, this._s2 = null, this._s3 = null, this._count = 0, this._overflow !== null && (this._overflow.length = 0, this._overflow = null), this._freeIndices = null;
|
|
276
268
|
}
|
|
277
269
|
dispose() {
|
|
278
270
|
this.clear();
|
|
279
271
|
}
|
|
280
|
-
}, b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symbol("AtomEffect.Type"), S = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), C = {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
272
|
+
}, b = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), x = /* @__PURE__ */ Symbol("AtomEffect.Type"), S = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), C = new class {
|
|
273
|
+
constructor() {
|
|
274
|
+
this.enabled = !1, this.warnInfiniteLoop = o.WARN_INFINITE_LOOP;
|
|
275
|
+
}
|
|
276
|
+
warn(e, t) {}
|
|
277
|
+
attachDebugInfo(e, t, n) {}
|
|
278
|
+
getDebugName(e) {
|
|
279
|
+
if (e != null) return e[b];
|
|
280
|
+
}
|
|
281
|
+
getDebugType(e) {
|
|
282
|
+
if (e != null) return e[x];
|
|
283
|
+
}
|
|
284
|
+
}(), ee = 1, w = () => ee++ | 0;
|
|
285
|
+
function T(e, t, n) {
|
|
286
|
+
return e instanceof m ? e : e instanceof Error ? new t(`${e.name || e.constructor.name || "Error"} (${n}): ${e.message}`, e) : new t(`Unexpected error (${n}): ${String(e)}`);
|
|
292
287
|
}
|
|
293
|
-
var
|
|
288
|
+
var te = class {
|
|
294
289
|
constructor() {
|
|
295
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch = c.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id =
|
|
290
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = c.UNINITIALIZED, this._notifying = 0, this._hotIndex = -1, this._slots = null, this._deps = null, this.id = w() & l;
|
|
291
|
+
}
|
|
292
|
+
get isDisposed() {
|
|
293
|
+
return (this.flags & r.DISPOSED) !== 0;
|
|
294
|
+
}
|
|
295
|
+
get isComputed() {
|
|
296
|
+
return (this.flags & r.IS_COMPUTED) !== 0;
|
|
297
|
+
}
|
|
298
|
+
get hasError() {
|
|
299
|
+
return !1;
|
|
296
300
|
}
|
|
297
301
|
subscribe(e) {
|
|
298
302
|
let t = typeof e == "function";
|
|
299
|
-
if (!t && (!e || typeof e.execute != "function")) throw
|
|
303
|
+
if (!t && (!e || typeof e.execute != "function")) throw T(/* @__PURE__ */ TypeError("Invalid subscriber"), m, v.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);
|
|
300
304
|
let n = this._slots;
|
|
301
305
|
n || (n = new y(), this._slots = n);
|
|
302
306
|
let r = !1;
|
|
303
|
-
if (n.
|
|
304
|
-
|
|
305
|
-
|
|
307
|
+
if (n._s0 != null && (t ? n._s0.fn === e : n._s0.sub === e)) r = !0;
|
|
308
|
+
else if (n._s1 != null && (t ? n._s1.fn === e : n._s1.sub === e)) r = !0;
|
|
309
|
+
else if (n._s2 != null && (t ? n._s2.fn === e : n._s2.sub === e)) r = !0;
|
|
310
|
+
else if (n._s3 != null && (t ? n._s3.fn === e : n._s3.sub === e)) r = !0;
|
|
311
|
+
else {
|
|
312
|
+
let i = n._overflow;
|
|
313
|
+
if (i != null) for (let n = 0, a = i.length; n < a; n++) {
|
|
314
|
+
let a = i[n];
|
|
315
|
+
if (a != null && (t ? a.fn === e : a.sub === e)) {
|
|
316
|
+
r = !0;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (r) return () => {};
|
|
306
322
|
let i = new p(t ? e : void 0, t ? void 0 : e);
|
|
307
323
|
return n.add(i), () => this._unsubscribe(i);
|
|
308
324
|
}
|
|
309
325
|
_unsubscribe(e) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this._slots.remove(e);
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
this._slots.remove(e), this._slots.compact();
|
|
316
|
-
}
|
|
326
|
+
let t = this._slots;
|
|
327
|
+
t && (t.remove(e), this._notifying === 0 && t.compact());
|
|
317
328
|
}
|
|
318
329
|
subscriberCount() {
|
|
319
|
-
|
|
330
|
+
let e = this._slots;
|
|
331
|
+
return e === null ? 0 : e.size;
|
|
320
332
|
}
|
|
321
333
|
_notifySubscribers(e, t) {
|
|
322
334
|
let n = this._slots;
|
|
323
|
-
if (!(
|
|
335
|
+
if (!(n === null || n.size === 0)) {
|
|
324
336
|
this._notifying++;
|
|
325
337
|
try {
|
|
326
|
-
n.
|
|
327
|
-
|
|
328
|
-
|
|
338
|
+
let r = n._s0;
|
|
339
|
+
if (r != null) try {
|
|
340
|
+
r.notify(e, t);
|
|
341
|
+
} catch (e) {
|
|
342
|
+
this._logNotifyError(e);
|
|
343
|
+
}
|
|
344
|
+
if (r = n._s1, r != null) try {
|
|
345
|
+
r.notify(e, t);
|
|
346
|
+
} catch (e) {
|
|
347
|
+
this._logNotifyError(e);
|
|
348
|
+
}
|
|
349
|
+
if (r = n._s2, r != null) try {
|
|
350
|
+
r.notify(e, t);
|
|
351
|
+
} catch (e) {
|
|
352
|
+
this._logNotifyError(e);
|
|
353
|
+
}
|
|
354
|
+
if (r = n._s3, r != null) try {
|
|
355
|
+
r.notify(e, t);
|
|
356
|
+
} catch (e) {
|
|
357
|
+
this._logNotifyError(e);
|
|
358
|
+
}
|
|
359
|
+
let i = n._overflow;
|
|
360
|
+
if (i != null) for (let n = 0, r = i.length; n < r; n++) {
|
|
361
|
+
let r = i[n];
|
|
362
|
+
if (r != null) try {
|
|
363
|
+
r.notify(e, t);
|
|
329
364
|
} catch (e) {
|
|
330
|
-
|
|
365
|
+
this._logNotifyError(e);
|
|
331
366
|
}
|
|
332
|
-
}
|
|
367
|
+
}
|
|
333
368
|
} finally {
|
|
334
|
-
this._notifying
|
|
369
|
+
--this._notifying === 0 && n.compact();
|
|
335
370
|
}
|
|
336
371
|
}
|
|
337
372
|
}
|
|
373
|
+
_logNotifyError(e) {
|
|
374
|
+
console.error(T(e, m, v.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
|
|
375
|
+
}
|
|
338
376
|
_isDirty() {
|
|
339
377
|
let e = this._deps;
|
|
340
|
-
if (
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
378
|
+
if (e === null || e.size === 0) return !1;
|
|
379
|
+
let t = this._hotIndex;
|
|
380
|
+
if (t !== -1) {
|
|
381
|
+
let n = e.getAt(t);
|
|
382
|
+
if (n != null && n.node.version !== n.version) return !0;
|
|
344
383
|
}
|
|
345
384
|
return !e.hasComputeds && !e.isDirtyFast() ? !1 : this._deepDirtyCheck();
|
|
346
385
|
}
|
|
347
|
-
},
|
|
386
|
+
}, ne = 0;
|
|
387
|
+
function re() {
|
|
388
|
+
let e = ne + 1 & l;
|
|
389
|
+
return ne = e === 0 ? 1 : e, ne;
|
|
390
|
+
}
|
|
391
|
+
function ie(e) {
|
|
392
|
+
let t = e + 1 & l;
|
|
393
|
+
return t === 0 ? 1 : t;
|
|
394
|
+
}
|
|
395
|
+
var ae = 0, E = !1, oe = 0;
|
|
396
|
+
function se() {
|
|
397
|
+
return oe;
|
|
398
|
+
}
|
|
399
|
+
function ce() {
|
|
400
|
+
return E ? !1 : (E = !0, oe = re(), ae = 0, !0);
|
|
401
|
+
}
|
|
402
|
+
function le() {
|
|
403
|
+
E = !1;
|
|
404
|
+
}
|
|
348
405
|
function ue() {
|
|
349
|
-
|
|
406
|
+
if (!E) return 0;
|
|
407
|
+
let e = ++ae;
|
|
408
|
+
if (e <= a.MAX_EXECUTIONS_PER_FLUSH) return e;
|
|
409
|
+
throw Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${a.MAX_EXECUTIONS_PER_FLUSH}`);
|
|
350
410
|
}
|
|
351
|
-
var de =
|
|
352
|
-
se = !1;
|
|
353
|
-
}, fe = () => se ? ++oe : 0, pe = /* @__PURE__ */ (function(e) {
|
|
354
|
-
return e[e.IDLE = 0] = "IDLE", e[e.BATCHING = 1] = "BATCHING", e[e.FLUSHING = 2] = "FLUSHING", e;
|
|
355
|
-
})({}), T = new class {
|
|
411
|
+
var de = new class {
|
|
356
412
|
constructor() {
|
|
357
|
-
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this.
|
|
358
|
-
}
|
|
359
|
-
get phase() {
|
|
360
|
-
return this._isProcessing || this._isFlushingSync ? pe.FLUSHING : this._isBatching ? pe.BATCHING : pe.IDLE;
|
|
413
|
+
this._queueBuffer = [[], []], this._bufferIndex = 0, this._size = 0, this._epoch = 0, this._isProcessing = !1, this._isFlushingSync = !1, this._batchDepth = 0, this._batchQueue = [], this._batchQueueSize = 0, this._maxFlushIterations = a.MAX_FLUSH_ITERATIONS, this.onOverflow = null, this._boundRunLoop = this._runLoop.bind(this);
|
|
361
414
|
}
|
|
362
415
|
get queueSize() {
|
|
363
416
|
return this._size;
|
|
364
417
|
}
|
|
365
418
|
get isBatching() {
|
|
366
|
-
return this.
|
|
419
|
+
return this._batchDepth > 0;
|
|
367
420
|
}
|
|
368
421
|
schedule(e) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
this._queueBuffer[this._bufferIndex][this._size++] = e, this._isProcessing || this._flush();
|
|
422
|
+
let t = this._epoch;
|
|
423
|
+
if (e._nextEpoch === t) return;
|
|
424
|
+
if (e._nextEpoch = t, this._batchDepth > 0 || this._isFlushingSync) {
|
|
425
|
+
this._batchQueue[this._batchQueueSize++] = e;
|
|
426
|
+
return;
|
|
375
427
|
}
|
|
428
|
+
let n = this._bufferIndex, r = this._queueBuffer[n];
|
|
429
|
+
r[this._size++] = e, this._isProcessing || this._flush();
|
|
376
430
|
}
|
|
377
431
|
_flush() {
|
|
378
432
|
this._isProcessing || this._size === 0 || (this._isProcessing = !0, queueMicrotask(this._boundRunLoop));
|
|
@@ -380,29 +434,30 @@ var de = () => {
|
|
|
380
434
|
_runLoop() {
|
|
381
435
|
try {
|
|
382
436
|
if (this._size === 0) return;
|
|
383
|
-
let e =
|
|
384
|
-
this._drainQueue(), e &&
|
|
437
|
+
let e = ce();
|
|
438
|
+
this._drainQueue(), e && le();
|
|
385
439
|
} finally {
|
|
386
|
-
this._isProcessing = !1, this._size > 0 &&
|
|
440
|
+
this._isProcessing = !1, this._size > 0 && this._batchDepth === 0 && this._flush();
|
|
387
441
|
}
|
|
388
442
|
}
|
|
389
443
|
_flushSync() {
|
|
390
444
|
this._isFlushingSync = !0;
|
|
391
|
-
let e =
|
|
445
|
+
let e = ce();
|
|
392
446
|
try {
|
|
393
447
|
this._mergeBatchQueue(), this._drainQueue();
|
|
394
448
|
} finally {
|
|
395
|
-
this._isFlushingSync = !1, e &&
|
|
449
|
+
this._isFlushingSync = !1, e && le();
|
|
396
450
|
}
|
|
397
451
|
}
|
|
398
452
|
_mergeBatchQueue() {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
453
|
+
let e = this._batchQueueSize;
|
|
454
|
+
if (e === 0) return;
|
|
455
|
+
let t = ++this._epoch, n = this._batchQueue, r = this._bufferIndex, i = this._queueBuffer[r], a = this._size;
|
|
456
|
+
for (let r = 0; r < e; r++) {
|
|
457
|
+
let e = n[r];
|
|
458
|
+
e._nextEpoch !== t && (e._nextEpoch = t, i[a++] = e);
|
|
404
459
|
}
|
|
405
|
-
this._size =
|
|
460
|
+
this._size = a, this._batchQueueSize = 0, n.length = 0;
|
|
406
461
|
}
|
|
407
462
|
_drainQueue() {
|
|
408
463
|
let e = 0;
|
|
@@ -416,33 +471,41 @@ var de = () => {
|
|
|
416
471
|
}
|
|
417
472
|
_processQueue() {
|
|
418
473
|
let e = this._bufferIndex, t = this._queueBuffer[e], n = this._size;
|
|
419
|
-
this._bufferIndex = e ^ 1, this._size = 0, this._epoch
|
|
420
|
-
for (let e = 0; e < n; e++)
|
|
474
|
+
this._bufferIndex = e ^ 1, this._size = 0, this._epoch = this._epoch + 1 | 0;
|
|
475
|
+
for (let e = 0; e < n; e++) {
|
|
421
476
|
let n = t[e];
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
477
|
+
try {
|
|
478
|
+
typeof n == "function" ? n() : n.execute();
|
|
479
|
+
} catch (e) {
|
|
480
|
+
console.error(new _("Error occurred during scheduler execution", e));
|
|
481
|
+
}
|
|
425
482
|
}
|
|
426
483
|
t.length = 0;
|
|
427
484
|
}
|
|
428
485
|
_handleFlushOverflow() {
|
|
429
|
-
let e = this._size + this._batchQueueSize;
|
|
430
|
-
|
|
431
|
-
|
|
486
|
+
let e = this._size + this._batchQueueSize, t = this._maxFlushIterations;
|
|
487
|
+
console.error(new _(v.SCHEDULER_FLUSH_OVERFLOW(t, e))), this._size = 0;
|
|
488
|
+
let n = this._bufferIndex;
|
|
489
|
+
this._queueBuffer[n].length = 0, this._batchQueueSize = 0;
|
|
490
|
+
let r = this.onOverflow;
|
|
491
|
+
if (r) try {
|
|
492
|
+
r(e);
|
|
432
493
|
} catch {}
|
|
433
494
|
}
|
|
434
495
|
startBatch() {
|
|
435
|
-
this._batchDepth
|
|
496
|
+
this._batchDepth++;
|
|
436
497
|
}
|
|
437
498
|
endBatch() {
|
|
438
|
-
this._batchDepth !== 0 && --this._batchDepth === 0 &&
|
|
499
|
+
this._batchDepth !== 0 && --this._batchDepth === 0 && this._flushSync();
|
|
439
500
|
}
|
|
440
501
|
setMaxFlushIterations(e) {
|
|
441
502
|
if (e < a.MIN_FLUSH_ITERATIONS) throw new _(`Max flush iterations must be at least ${a.MIN_FLUSH_ITERATIONS}`);
|
|
442
503
|
this._maxFlushIterations = e;
|
|
443
504
|
}
|
|
444
|
-
}(),
|
|
445
|
-
|
|
505
|
+
}(), fe = /* @__PURE__ */ Symbol.for("atom-effect/atom"), pe = /* @__PURE__ */ Symbol.for("atom-effect/computed"), me = /* @__PURE__ */ Symbol.for("atom-effect/effect"), he = /* @__PURE__ */ Symbol.for("atom-effect/writable"), D = new class {
|
|
506
|
+
constructor() {
|
|
507
|
+
this.current = null;
|
|
508
|
+
}
|
|
446
509
|
run(e, t) {
|
|
447
510
|
let n = this.current;
|
|
448
511
|
this.current = e;
|
|
@@ -452,52 +515,54 @@ var de = () => {
|
|
|
452
515
|
this.current = n;
|
|
453
516
|
}
|
|
454
517
|
}
|
|
455
|
-
};
|
|
456
|
-
function
|
|
457
|
-
let t =
|
|
458
|
-
if (
|
|
459
|
-
|
|
518
|
+
}();
|
|
519
|
+
function O(e) {
|
|
520
|
+
let t = D, n = t.current;
|
|
521
|
+
if (n === null) return e();
|
|
522
|
+
t.current = null;
|
|
460
523
|
try {
|
|
461
524
|
return e();
|
|
462
525
|
} finally {
|
|
463
|
-
|
|
526
|
+
t.current = n;
|
|
464
527
|
}
|
|
465
528
|
}
|
|
466
|
-
var
|
|
529
|
+
var ge = class extends te {
|
|
467
530
|
constructor(e, t) {
|
|
468
|
-
super(), this[
|
|
531
|
+
super(), this[fe] = !0, this[he] = !0, this._value = e, t && (this.flags |= i.SYNC), C.attachDebugInfo(this, "atom", this.id);
|
|
532
|
+
}
|
|
533
|
+
get isNotificationScheduled() {
|
|
534
|
+
return (this.flags & i.NOTIFICATION_SCHEDULED) !== 0;
|
|
535
|
+
}
|
|
536
|
+
get isSync() {
|
|
537
|
+
return (this.flags & i.SYNC) !== 0;
|
|
469
538
|
}
|
|
470
539
|
get value() {
|
|
471
|
-
return
|
|
540
|
+
return D.current?.addDependency(this), this._value;
|
|
472
541
|
}
|
|
473
542
|
set value(e) {
|
|
474
543
|
let t = this._value;
|
|
475
544
|
if (Object.is(t, e)) return;
|
|
476
|
-
this._value = e, this.version =
|
|
477
|
-
let n = this.
|
|
478
|
-
if (n
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
if (this.flags = a, (a & i.SYNC) !== 0 && !T.isBatching) {
|
|
482
|
-
this._flushNotifications();
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
T.schedule(this);
|
|
545
|
+
this._value = e, this.version = ie(this.version);
|
|
546
|
+
let n = this.flags;
|
|
547
|
+
if ((n & i.NOTIFICATION_SCHEDULED) !== 0) return;
|
|
548
|
+
let r = this._slots;
|
|
549
|
+
r == null || r.size === 0 || (this._pendingOldValue = t, this.flags = n | i.NOTIFICATION_SCHEDULED, (n & i.SYNC) !== 0 && !de.isBatching ? this._flushNotifications() : de.schedule(this));
|
|
486
550
|
}
|
|
487
551
|
execute() {
|
|
488
552
|
this._flushNotifications();
|
|
489
553
|
}
|
|
490
554
|
_flushNotifications() {
|
|
491
555
|
let e = this.flags;
|
|
492
|
-
if (
|
|
556
|
+
if ((e & (i.NOTIFICATION_SCHEDULED | i.DISPOSED)) !== i.NOTIFICATION_SCHEDULED) return;
|
|
493
557
|
let t = this._pendingOldValue;
|
|
494
|
-
this._pendingOldValue = void 0, this.flags
|
|
558
|
+
this._pendingOldValue = void 0, this.flags = e & ~i.NOTIFICATION_SCHEDULED, this._notifySubscribers(this._value, t);
|
|
495
559
|
}
|
|
496
560
|
peek() {
|
|
497
561
|
return this._value;
|
|
498
562
|
}
|
|
499
563
|
dispose() {
|
|
500
|
-
|
|
564
|
+
let e = this.flags;
|
|
565
|
+
(e & i.DISPOSED) === 0 && (this._slots?.clear(), this.flags = e | i.DISPOSED, this._value = void 0, this._pendingOldValue = void 0);
|
|
501
566
|
}
|
|
502
567
|
_deepDirtyCheck() {
|
|
503
568
|
return !1;
|
|
@@ -506,12 +571,12 @@ var ve = class extends ne {
|
|
|
506
571
|
this.dispose();
|
|
507
572
|
}
|
|
508
573
|
};
|
|
509
|
-
function
|
|
510
|
-
return new
|
|
574
|
+
function k(e, t = {}) {
|
|
575
|
+
return new ge(e, t.sync ?? !1);
|
|
511
576
|
}
|
|
512
|
-
var
|
|
513
|
-
constructor() {
|
|
514
|
-
super(), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1, this._depsHash = 0
|
|
577
|
+
var _e = class extends y {
|
|
578
|
+
constructor(...e) {
|
|
579
|
+
super(...e), this._map = null, this._SCAN_THRESHOLD = 32, this.hasComputeds = !1, this._depsHash = 0;
|
|
515
580
|
}
|
|
516
581
|
prepareTracking() {
|
|
517
582
|
this.hasComputeds = !1;
|
|
@@ -555,45 +620,54 @@ var be = class extends y {
|
|
|
555
620
|
}
|
|
556
621
|
}
|
|
557
622
|
}
|
|
558
|
-
let i =
|
|
559
|
-
if (
|
|
560
|
-
let r = a
|
|
561
|
-
|
|
623
|
+
let i = this._overflow;
|
|
624
|
+
if (i) {
|
|
625
|
+
let n = e.version, r = t > 4 ? t : 4, a = i.length;
|
|
626
|
+
for (let o = r - 4; o < a; o++) {
|
|
627
|
+
let r = i[o];
|
|
628
|
+
if (r && r.node === e && r.unsub) return r.version = n, this._swapGeneral(o + 4, t, r), !0;
|
|
629
|
+
}
|
|
562
630
|
}
|
|
563
631
|
return !1;
|
|
564
632
|
}
|
|
565
633
|
_claimViaMap(e, t) {
|
|
566
|
-
|
|
567
|
-
|
|
634
|
+
let n = this._map;
|
|
635
|
+
if (n === null) {
|
|
636
|
+
n = this._map = /* @__PURE__ */ new Map();
|
|
568
637
|
let e = this._count;
|
|
569
|
-
t < 4
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
let
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
638
|
+
if (t < 4) {
|
|
639
|
+
let e = this._s0;
|
|
640
|
+
t <= 0 && e?.unsub && n.set(e.node, 0);
|
|
641
|
+
let r = this._s1;
|
|
642
|
+
t <= 1 && r?.unsub && n.set(r.node, 1);
|
|
643
|
+
let i = this._s2;
|
|
644
|
+
t <= 2 && i?.unsub && n.set(i.node, 2);
|
|
645
|
+
let a = this._s3;
|
|
646
|
+
t <= 3 && a?.unsub && n.set(a.node, 3);
|
|
647
|
+
}
|
|
648
|
+
let r = this._overflow;
|
|
649
|
+
if (r && e > 4) {
|
|
650
|
+
let e = t > 4 ? t : 4, i = r.length;
|
|
651
|
+
for (let t = e - 4; t < i; t++) {
|
|
652
|
+
let e = r[t];
|
|
653
|
+
e?.unsub && n.set(e.node, t + 4);
|
|
576
654
|
}
|
|
577
655
|
}
|
|
578
656
|
}
|
|
579
|
-
let
|
|
580
|
-
if (
|
|
581
|
-
let
|
|
582
|
-
if (
|
|
583
|
-
if (
|
|
584
|
-
let
|
|
585
|
-
this.setAt(t,
|
|
657
|
+
let r = n.get(e);
|
|
658
|
+
if (r === void 0 || r < t) return !1;
|
|
659
|
+
let i = this.getAt(r);
|
|
660
|
+
if (i == null || !i.unsub) return !1;
|
|
661
|
+
if (i.version = e.version, r !== t) {
|
|
662
|
+
let a;
|
|
663
|
+
a = t === 0 ? this._s0 : t === 1 ? this._s1 : t === 2 ? this._s2 : t === 3 ? this._s3 : this._overflow[t - 4] ?? null, this.setAt(t, i), this.setAt(r, a), a?.unsub && n.set(a.node, r), n.set(e, t);
|
|
586
664
|
}
|
|
587
665
|
return !0;
|
|
588
666
|
}
|
|
589
|
-
_swapInline(e, t, n) {
|
|
590
|
-
let r = this.getAt(t);
|
|
591
|
-
this.setAt(t, n), this.setAt(e, r);
|
|
592
|
-
}
|
|
593
667
|
_swapGeneral(e, t, n) {
|
|
594
668
|
if (e === t) return;
|
|
595
|
-
let r
|
|
596
|
-
if (this.setAt(t, n), e === 0) this._s0 = r;
|
|
669
|
+
let r;
|
|
670
|
+
if (r = t === 0 ? this._s0 : t === 1 ? this._s1 : t === 2 ? this._s2 : t === 3 ? this._s3 : this._overflow[t - 4] ?? null, this.setAt(t, n), e === 0) this._s0 = r;
|
|
597
671
|
else if (e === 1) this._s1 = r;
|
|
598
672
|
else if (e === 2) this._s2 = r;
|
|
599
673
|
else if (e === 3) this._s3 = r;
|
|
@@ -605,8 +679,8 @@ var be = class extends y {
|
|
|
605
679
|
insertNew(e, t) {
|
|
606
680
|
let n = this._count;
|
|
607
681
|
if (e < n) {
|
|
608
|
-
let t
|
|
609
|
-
t != null && (this.
|
|
682
|
+
let t;
|
|
683
|
+
t = e === 0 ? this._s0 : e === 1 ? this._s1 : e === 2 ? this._s2 : e === 3 ? this._s3 : this._overflow[e - 4] ?? null, t != null && (this._addToOverflow(t), this._map !== null && t.unsub && this._map.set(t.node, this._count - 1));
|
|
610
684
|
}
|
|
611
685
|
if (e === 0) this._s0 = t;
|
|
612
686
|
else if (e === 1) this._s1 = t;
|
|
@@ -622,114 +696,102 @@ var be = class extends y {
|
|
|
622
696
|
e >= this._count || (super.truncateFrom(e), this._map !== null && (this._map.clear(), this._map = null));
|
|
623
697
|
}
|
|
624
698
|
seal() {
|
|
625
|
-
|
|
626
|
-
switch (e) {
|
|
627
|
-
case 0:
|
|
628
|
-
this._depsHash = 0;
|
|
629
|
-
return;
|
|
630
|
-
case 1: {
|
|
631
|
-
let e = this._s0;
|
|
632
|
-
n = n + (e.version << t) + e.node.id | 0;
|
|
633
|
-
break;
|
|
634
|
-
}
|
|
635
|
-
case 2: {
|
|
636
|
-
let e = this._s0, r = this._s1;
|
|
637
|
-
n = n + (e.version << t) + e.node.id | 0, n = n + (r.version << t) + r.node.id | 0;
|
|
638
|
-
break;
|
|
639
|
-
}
|
|
640
|
-
case 3: {
|
|
641
|
-
let e = this._s0, r = this._s1, i = this._s2;
|
|
642
|
-
n = n + (e.version << t) + e.node.id | 0, n = n + (r.version << t) + r.node.id | 0, n = n + (i.version << t) + i.node.id | 0;
|
|
643
|
-
break;
|
|
644
|
-
}
|
|
645
|
-
default: {
|
|
646
|
-
let r = this._s0, i = this._s1, a = this._s2, o = this._s3;
|
|
647
|
-
if (n = n + (r.version << t) + r.node.id | 0, n = n + (i.version << t) + i.node.id | 0, n = n + (a.version << t) + a.node.id | 0, n = n + (o.version << t) + o.node.id | 0, e > 4) {
|
|
648
|
-
let e = this._overflow;
|
|
649
|
-
for (let r = 0, i = e.length; r < i; r++) {
|
|
650
|
-
let i = e[r];
|
|
651
|
-
n = n + (i.version << t) + i.node.id | 0;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
this._depsHash = n;
|
|
699
|
+
this._depsHash = this._calculateHash(!1);
|
|
657
700
|
}
|
|
658
701
|
isDirtyFast() {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
let e = this._overflow;
|
|
681
|
-
for (let r = 0, i = e.length; r < i; r++) {
|
|
682
|
-
let i = e[r].node;
|
|
683
|
-
n = n + (i.version << t) + i.id | 0;
|
|
702
|
+
return this._calculateHash(!0) !== this._depsHash;
|
|
703
|
+
}
|
|
704
|
+
_calculateHash(e) {
|
|
705
|
+
let t = this._count;
|
|
706
|
+
if (t === 0) return 0;
|
|
707
|
+
let n = u.VERSION_BITS, r = 0, i = this._s0;
|
|
708
|
+
if (i != null) {
|
|
709
|
+
let a = i.node, o = e ? a.version : i.version;
|
|
710
|
+
r = r + (o << n) + a.id | 0;
|
|
711
|
+
let s = this._s1;
|
|
712
|
+
if (t > 1 && s != null) {
|
|
713
|
+
let i = s.node, a = e ? i.version : s.version;
|
|
714
|
+
r = r + (a << n) + i.id | 0;
|
|
715
|
+
let o = this._s2;
|
|
716
|
+
if (t > 2 && o != null) {
|
|
717
|
+
let i = o.node, a = e ? i.version : o.version;
|
|
718
|
+
r = r + (a << n) + i.id | 0;
|
|
719
|
+
let s = this._s3;
|
|
720
|
+
if (t > 3 && s != null) {
|
|
721
|
+
let t = s.node, i = e ? t.version : s.version;
|
|
722
|
+
r = r + (i << n) + t.id | 0;
|
|
684
723
|
}
|
|
685
724
|
}
|
|
686
725
|
}
|
|
687
726
|
}
|
|
688
|
-
|
|
727
|
+
if (t > 4) {
|
|
728
|
+
let t = this._overflow;
|
|
729
|
+
for (let i = 0, a = t.length; i < a; i++) {
|
|
730
|
+
let a = t[i], o = a.node, s = e ? o.version : a.version;
|
|
731
|
+
r = r + (s << n) + o.id | 0;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
return r;
|
|
689
735
|
}
|
|
690
736
|
disposeAll() {
|
|
691
|
-
this._count > 0 && this.truncateFrom(0), this.hasComputeds = !1
|
|
737
|
+
this._count > 0 && this.truncateFrom(0), this.hasComputeds = !1;
|
|
692
738
|
}
|
|
693
739
|
remove(e) {
|
|
694
740
|
throw Error("remove() is strictly prohibited in DepSlotBuffer to preserve sequential cache paths.");
|
|
695
741
|
}
|
|
696
742
|
compact() {}
|
|
697
743
|
};
|
|
698
|
-
function
|
|
699
|
-
return typeof e == "object" && !!e &&
|
|
744
|
+
function ve(e) {
|
|
745
|
+
return typeof e == "object" && !!e && fe in e;
|
|
700
746
|
}
|
|
701
|
-
function
|
|
702
|
-
return typeof e == "object" && !!e &&
|
|
747
|
+
function ye(e) {
|
|
748
|
+
return typeof e == "object" && !!e && pe in e;
|
|
703
749
|
}
|
|
704
|
-
function
|
|
750
|
+
function be(e) {
|
|
705
751
|
return typeof e == "object" && !!e && typeof e.then == "function";
|
|
706
752
|
}
|
|
707
|
-
var { IDLE:
|
|
753
|
+
var { IDLE: A, DIRTY: j, PENDING: M, RESOLVED: N, REJECTED: P, HAS_ERROR: xe, RECOMPUTING: F, DISPOSED: Se, IS_COMPUTED: I, FORCE_COMPUTE: Ce } = r, we = class extends te {
|
|
708
754
|
constructor(e, t = {}) {
|
|
709
755
|
if (typeof e != "function") throw new h(v.COMPUTED_MUST_BE_FUNCTION);
|
|
710
|
-
if (super(), this[
|
|
756
|
+
if (super(), this[fe] = !0, this[pe] = !0, this._error = null, this._promiseId = 0, this._deps = new _e(), this._asyncRetryCount = 0, this._lastDriftEpoch = c.UNINITIALIZED, this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = I | j | A, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : S, this._onError = t.onError ?? null, this._maxAsyncRetries = (t.maxAsyncRetries ?? s.MAX_ASYNC_RETRIES) & l, C.attachDebugInfo(this, "computed", this.id), t.lazy === !1) try {
|
|
711
757
|
this._recompute();
|
|
712
758
|
} catch {}
|
|
713
759
|
}
|
|
760
|
+
get isDirty() {
|
|
761
|
+
return (this.flags & j) !== 0;
|
|
762
|
+
}
|
|
763
|
+
get isRejected() {
|
|
764
|
+
return (this.flags & P) !== 0;
|
|
765
|
+
}
|
|
766
|
+
get isRecomputing() {
|
|
767
|
+
return (this.flags & F) !== 0;
|
|
768
|
+
}
|
|
769
|
+
get _hasErrorInternal() {
|
|
770
|
+
return (this.flags & xe) !== 0;
|
|
771
|
+
}
|
|
714
772
|
_track() {
|
|
715
|
-
|
|
773
|
+
D.current?.addDependency(this);
|
|
716
774
|
}
|
|
717
775
|
get value() {
|
|
718
|
-
|
|
776
|
+
D.current?.addDependency(this);
|
|
719
777
|
let e = this.flags;
|
|
720
|
-
if ((e & (
|
|
721
|
-
if (e &
|
|
722
|
-
if (e &
|
|
723
|
-
|
|
778
|
+
if ((e & (N | j | A)) === N) return this._value;
|
|
779
|
+
if ((e & Se) !== 0) throw new h(v.COMPUTED_DISPOSED);
|
|
780
|
+
if ((e & F) !== 0) {
|
|
781
|
+
let e = this._defaultValue;
|
|
782
|
+
if (e !== S) return e;
|
|
724
783
|
throw new h(v.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
725
784
|
}
|
|
726
|
-
if (e & (
|
|
785
|
+
if ((e & (j | A)) !== 0) {
|
|
786
|
+
let t = this._deps;
|
|
787
|
+
if ((e & A) === 0 && (e & Ce) === 0 && t.size > 0 && !this._isDirty() ? e = this.flags &= ~j : (this._recompute(), e = this.flags), (e & N) !== 0) return this._value;
|
|
788
|
+
}
|
|
727
789
|
let t = this._defaultValue, n = t !== S;
|
|
728
|
-
if (
|
|
790
|
+
if ((e & M) !== 0) {
|
|
729
791
|
if (n) return t;
|
|
730
792
|
throw new h(v.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
731
793
|
}
|
|
732
|
-
if (
|
|
794
|
+
if ((e & P) !== 0) {
|
|
733
795
|
if (n) return t;
|
|
734
796
|
throw this._error;
|
|
735
797
|
}
|
|
@@ -739,38 +801,35 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
|
|
|
739
801
|
return this._value;
|
|
740
802
|
}
|
|
741
803
|
get state() {
|
|
742
|
-
|
|
804
|
+
D.current?.addDependency(this);
|
|
743
805
|
let e = this.flags;
|
|
744
|
-
return e &
|
|
806
|
+
return (e & N) === 0 ? (e & M) === 0 ? (e & P) === 0 ? t.IDLE : t.REJECTED : t.PENDING : t.RESOLVED;
|
|
745
807
|
}
|
|
746
808
|
get hasError() {
|
|
747
|
-
if (
|
|
809
|
+
if (D.current?.addDependency(this), (this.flags & (P | xe)) !== 0) return !0;
|
|
748
810
|
let e = this._deps;
|
|
749
811
|
if (!e.hasComputeds) return !1;
|
|
750
812
|
let t = e.size;
|
|
751
|
-
for (let n = 0; n < t; n++)
|
|
752
|
-
let t = e.getAt(n);
|
|
753
|
-
if (t != null && t.node.flags & N) return !0;
|
|
754
|
-
}
|
|
813
|
+
for (let n = 0; n < t; n++) if (e.getAt(n)?.node.hasError) return !0;
|
|
755
814
|
return !1;
|
|
756
815
|
}
|
|
757
816
|
get isValid() {
|
|
758
817
|
return !this.hasError;
|
|
759
818
|
}
|
|
760
819
|
get errors() {
|
|
761
|
-
|
|
762
|
-
let e =
|
|
763
|
-
|
|
764
|
-
let
|
|
765
|
-
|
|
766
|
-
let
|
|
767
|
-
for (let
|
|
768
|
-
let
|
|
769
|
-
if (
|
|
770
|
-
let i =
|
|
771
|
-
i.flags &
|
|
820
|
+
D.current?.addDependency(this);
|
|
821
|
+
let e = this._error, t = this._deps;
|
|
822
|
+
if (!t.hasComputeds) return e == null ? d : Object.freeze([e]);
|
|
823
|
+
let n = [];
|
|
824
|
+
e != null && n.push(e);
|
|
825
|
+
let r = t.size;
|
|
826
|
+
for (let e = 0; e < r; e++) {
|
|
827
|
+
let r = t.getAt(e);
|
|
828
|
+
if (r == null) continue;
|
|
829
|
+
let i = r.node;
|
|
830
|
+
(i.flags & I) !== 0 && i.hasError && this._collectErrorsFromDep(i, n);
|
|
772
831
|
}
|
|
773
|
-
return
|
|
832
|
+
return n.length === 0 ? d : Object.freeze(n);
|
|
774
833
|
}
|
|
775
834
|
_collectErrorsFromDep(e, t) {
|
|
776
835
|
let n = e.errors, r = n.length;
|
|
@@ -780,57 +839,58 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
|
|
|
780
839
|
}
|
|
781
840
|
}
|
|
782
841
|
get lastError() {
|
|
783
|
-
return
|
|
842
|
+
return D.current?.addDependency(this), this._error;
|
|
784
843
|
}
|
|
785
844
|
get isPending() {
|
|
786
|
-
return
|
|
845
|
+
return D.current?.addDependency(this), (this.flags & M) !== 0;
|
|
787
846
|
}
|
|
788
847
|
get isResolved() {
|
|
789
|
-
return
|
|
848
|
+
return D.current?.addDependency(this), (this.flags & N) !== 0;
|
|
790
849
|
}
|
|
791
850
|
invalidate() {
|
|
792
|
-
this.flags |=
|
|
851
|
+
this.flags |= Ce, this._markDirty();
|
|
793
852
|
}
|
|
794
853
|
dispose() {
|
|
795
|
-
this.flags &
|
|
854
|
+
(this.flags & Se) === 0 && (this._deps.disposeAll(), this._slots != null && this._slots.clear(), this.flags = Se | j | A, this._error = null, this._value = void 0, this._hotIndex = -1);
|
|
796
855
|
}
|
|
797
856
|
[Symbol.dispose]() {
|
|
798
857
|
this.dispose();
|
|
799
858
|
}
|
|
800
859
|
addDependency(e) {
|
|
801
|
-
|
|
802
|
-
e._lastSeenEpoch
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
860
|
+
let t = this._trackEpoch;
|
|
861
|
+
if (e._lastSeenEpoch === t) return;
|
|
862
|
+
e._lastSeenEpoch = t;
|
|
863
|
+
let n = this._trackCount++, r = this._deps, i = r.getAt(n);
|
|
864
|
+
if (i != null && i.node === e) i.version = e.version;
|
|
865
|
+
else if (!r.claimExisting(e, n)) {
|
|
866
|
+
let t = new f(e, e.version, e.subscribe(this));
|
|
867
|
+
r.insertNew(n, t);
|
|
808
868
|
}
|
|
809
|
-
e.flags &
|
|
869
|
+
(e.flags & I) !== 0 && (r.hasComputeds = !0);
|
|
810
870
|
}
|
|
811
871
|
_recompute() {
|
|
812
|
-
if (this.
|
|
813
|
-
this.flags = (this.flags |
|
|
872
|
+
if (this.isRecomputing) return;
|
|
873
|
+
this.flags = (this.flags | F) & ~Ce, this._trackEpoch = re(), this._trackCount = 0, this._deps.prepareTracking(), this._hotIndex = -1;
|
|
814
874
|
let e = !1;
|
|
815
875
|
try {
|
|
816
|
-
let t =
|
|
817
|
-
this._deps.truncateFrom(this._trackCount), this._deps.seal(), e = !0,
|
|
876
|
+
let t = D.run(this, this._fn);
|
|
877
|
+
this._deps.truncateFrom(this._trackCount), this._deps.seal(), e = !0, be(t) ? this._handleAsyncComputation(t) : this._finalizeResolution(t);
|
|
818
878
|
} catch (t) {
|
|
819
879
|
if (!e) try {
|
|
820
880
|
this._deps.truncateFrom(this._trackCount);
|
|
821
881
|
} catch {}
|
|
822
882
|
this._handleError(t, v.COMPUTED_COMPUTATION_FAILED, !0);
|
|
823
883
|
} finally {
|
|
824
|
-
this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this.flags &= ~
|
|
884
|
+
this._trackEpoch = c.UNINITIALIZED, this._trackCount = 0, this.flags &= ~F;
|
|
825
885
|
}
|
|
826
886
|
}
|
|
827
887
|
_handleAsyncComputation(e) {
|
|
828
|
-
this.flags = (this.flags |
|
|
888
|
+
this.flags = (this.flags | M) & ~(A | j | N | P), this._notifySubscribers(void 0, void 0), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % s.MAX_PROMISE_ID;
|
|
829
889
|
let t = this._promiseId;
|
|
830
890
|
e.then((e) => {
|
|
831
891
|
if (t === this._promiseId) {
|
|
832
892
|
if (this._isDirty()) {
|
|
833
|
-
let e =
|
|
893
|
+
let e = se();
|
|
834
894
|
return this._lastDriftEpoch !== e && (this._lastDriftEpoch = e, this._asyncRetryCount = 0), this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(new h(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`), v.COMPUTED_ASYNC_COMPUTATION_FAILED);
|
|
835
895
|
}
|
|
836
896
|
this._finalizeResolution(e), this._notifySubscribers(e, void 0);
|
|
@@ -838,8 +898,8 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
|
|
|
838
898
|
}, (e) => t === this._promiseId && this._handleError(e, v.COMPUTED_ASYNC_COMPUTATION_FAILED));
|
|
839
899
|
}
|
|
840
900
|
_handleError(e, t, n = !1) {
|
|
841
|
-
let r =
|
|
842
|
-
if (!n && !
|
|
901
|
+
let r = T(e, h, t);
|
|
902
|
+
if (!n && !this.isRejected && (this.version = ie(this.version)), this._error = r, this.flags = this.flags & ~(A | j | M | N) | P | xe, this._onError) try {
|
|
843
903
|
this._onError(r);
|
|
844
904
|
} catch (e) {
|
|
845
905
|
console.error(v.CALLBACK_ERROR_IN_ERROR_HANDLER, e);
|
|
@@ -848,62 +908,79 @@ var { IDLE: O, DIRTY: k, PENDING: A, RESOLVED: j, REJECTED: M, HAS_ERROR: N, REC
|
|
|
848
908
|
this._notifySubscribers(void 0, void 0);
|
|
849
909
|
}
|
|
850
910
|
_finalizeResolution(e) {
|
|
851
|
-
|
|
911
|
+
let t = this.flags;
|
|
912
|
+
((t & N) === 0 || !this._equal(this._value, e)) && (this.version = ie(this.version)), this._value = e, this._error = null, this.flags = (t | N) & ~(A | j | M | P | xe);
|
|
852
913
|
}
|
|
853
914
|
execute() {
|
|
854
915
|
this._markDirty();
|
|
855
916
|
}
|
|
856
917
|
_markDirty() {
|
|
857
|
-
|
|
918
|
+
let e = this.flags;
|
|
919
|
+
(e & (F | j)) === 0 && (this.flags = e | j, this._notifySubscribers(void 0, void 0));
|
|
858
920
|
}
|
|
859
921
|
_isDirty() {
|
|
860
922
|
let e = this._deps;
|
|
861
923
|
return e.hasComputeds ? this._deepDirtyCheck() : e.isDirtyFast();
|
|
862
924
|
}
|
|
863
925
|
_deepDirtyCheck() {
|
|
864
|
-
let e = this._deps, t =
|
|
865
|
-
|
|
926
|
+
let e = this._deps, t = D.current;
|
|
927
|
+
D.current = null;
|
|
866
928
|
try {
|
|
867
929
|
let t = e.size;
|
|
868
930
|
for (let n = 0; n < t; n++) {
|
|
869
931
|
let t = e.getAt(n);
|
|
870
932
|
if (t == null) continue;
|
|
871
933
|
let r = t.node;
|
|
872
|
-
if (r.flags &
|
|
934
|
+
if ((r.flags & I) !== 0) try {
|
|
873
935
|
r.value;
|
|
874
936
|
} catch {}
|
|
875
937
|
if (r.version !== t.version) return this._hotIndex = n, !0;
|
|
876
938
|
}
|
|
877
939
|
return this._hotIndex = -1, !1;
|
|
878
940
|
} finally {
|
|
879
|
-
|
|
941
|
+
D.current = t;
|
|
880
942
|
}
|
|
881
943
|
}
|
|
882
944
|
};
|
|
883
|
-
function
|
|
884
|
-
return new
|
|
945
|
+
function L(e, t = {}) {
|
|
946
|
+
return new we(e, t);
|
|
885
947
|
}
|
|
886
|
-
var
|
|
948
|
+
var Te = class extends te {
|
|
887
949
|
constructor(e, t = {}) {
|
|
888
|
-
super(), this[
|
|
950
|
+
super(), this[me] = !0, this._cleanup = null, this._deps = new _e(), this._currentEpoch = c.UNINITIALIZED, this._lastFlushEpoch = c.UNINITIALIZED, this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? a.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? a.MAX_EXECUTIONS_PER_EFFECT, this._executionsInEpoch = 0, this._executionCount = 0, this._windowStart = 0, this._windowCount = 0, this._execId = 0, this._trackCount = 0, this._sync ? this._notifyCallback = () => this.execute() : this._notifyCallback = () => de.schedule(this), C.attachDebugInfo(this, "effect", this.id);
|
|
889
951
|
}
|
|
890
952
|
run() {
|
|
891
|
-
if (this.
|
|
953
|
+
if (this.isDisposed) throw new g(v.EFFECT_DISPOSED);
|
|
892
954
|
this.execute(!0);
|
|
893
955
|
}
|
|
894
956
|
dispose() {
|
|
895
|
-
this.
|
|
957
|
+
this.isDisposed || (this.flags |= n.DISPOSED, this._execCleanup(), this._deps?.disposeAll());
|
|
896
958
|
}
|
|
897
959
|
[Symbol.dispose]() {
|
|
898
960
|
this.dispose();
|
|
899
961
|
}
|
|
900
962
|
addDependency(e) {
|
|
901
|
-
if (
|
|
963
|
+
if ((this.flags & n.EXECUTING) === 0) return;
|
|
902
964
|
let t = this._currentEpoch;
|
|
903
965
|
if (e._lastSeenEpoch === t) return;
|
|
904
966
|
e._lastSeenEpoch = t;
|
|
905
|
-
let
|
|
906
|
-
|
|
967
|
+
let r = this._trackCount++, i = this._deps, a;
|
|
968
|
+
switch (r) {
|
|
969
|
+
case 0:
|
|
970
|
+
a = i._s0;
|
|
971
|
+
break;
|
|
972
|
+
case 1:
|
|
973
|
+
a = i._s1;
|
|
974
|
+
break;
|
|
975
|
+
case 2:
|
|
976
|
+
a = i._s2;
|
|
977
|
+
break;
|
|
978
|
+
case 3:
|
|
979
|
+
a = i._s3;
|
|
980
|
+
break;
|
|
981
|
+
default: a = i.getAt(r);
|
|
982
|
+
}
|
|
983
|
+
a != null && a.node === e ? a.version = e.version : i.claimExisting(e, r) || this._insertNewDependency(e, r), e.isComputed && (i.hasComputeds = !0);
|
|
907
984
|
}
|
|
908
985
|
_insertNewDependency(e, t) {
|
|
909
986
|
let n;
|
|
@@ -911,7 +988,7 @@ var Oe = class extends ne {
|
|
|
911
988
|
let t = e.subscribe(this._notifyCallback);
|
|
912
989
|
n = new f(e, e.version, t);
|
|
913
990
|
} catch (t) {
|
|
914
|
-
let r =
|
|
991
|
+
let r = T(t, g, v.EFFECT_EXECUTION_FAILED);
|
|
915
992
|
if (console.error(r), this._onError) try {
|
|
916
993
|
this._onError(r);
|
|
917
994
|
} catch {}
|
|
@@ -920,17 +997,18 @@ var Oe = class extends ne {
|
|
|
920
997
|
this._deps.insertNew(t, n);
|
|
921
998
|
}
|
|
922
999
|
execute(e = !1) {
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
1000
|
+
let t = this.flags;
|
|
1001
|
+
if ((t & (n.DISPOSED | n.EXECUTING)) !== 0) return;
|
|
1002
|
+
let r = this._deps;
|
|
1003
|
+
if (!e && r.size > 0 && !this._isDirty()) return;
|
|
1004
|
+
this._checkInfiniteLoops(), this.flags = t | n.EXECUTING, this._execCleanup(), this._currentEpoch = re(), this._trackCount = 0, r.prepareTracking(), this._hotIndex = -1;
|
|
1005
|
+
let i = !1;
|
|
928
1006
|
try {
|
|
929
|
-
let e =
|
|
930
|
-
|
|
1007
|
+
let e = D.run(this, this._fn);
|
|
1008
|
+
r.truncateFrom(this._trackCount), r.seal(), i = !0, be(e) ? this._handleAsyncResult(e) : this._cleanup = typeof e == "function" ? e : null;
|
|
931
1009
|
} catch (e) {
|
|
932
|
-
if (!
|
|
933
|
-
|
|
1010
|
+
if (!i) try {
|
|
1011
|
+
r.truncateFrom(this._trackCount);
|
|
934
1012
|
} catch {}
|
|
935
1013
|
this._handleExecutionError(e), this._cleanup = null;
|
|
936
1014
|
} finally {
|
|
@@ -944,7 +1022,7 @@ var Oe = class extends ne {
|
|
|
944
1022
|
_handleAsyncResult(e) {
|
|
945
1023
|
let t = ++this._execId;
|
|
946
1024
|
e.then((e) => {
|
|
947
|
-
if (t !== this._execId || this.
|
|
1025
|
+
if (t !== this._execId || this.isDisposed) {
|
|
948
1026
|
if (typeof e == "function") try {
|
|
949
1027
|
e();
|
|
950
1028
|
} catch (e) {
|
|
@@ -956,20 +1034,20 @@ var Oe = class extends ne {
|
|
|
956
1034
|
}, (e) => t === this._execId && this._handleExecutionError(e));
|
|
957
1035
|
}
|
|
958
1036
|
_deepDirtyCheck() {
|
|
959
|
-
let e =
|
|
960
|
-
|
|
1037
|
+
let e = D.current;
|
|
1038
|
+
D.current = null;
|
|
961
1039
|
let t = this._deps;
|
|
962
1040
|
try {
|
|
963
1041
|
let e = t.size;
|
|
964
1042
|
for (let n = 0; n < e; n++) {
|
|
965
1043
|
let e = t.getAt(n);
|
|
966
1044
|
if (e == null) continue;
|
|
967
|
-
let
|
|
968
|
-
if (
|
|
1045
|
+
let r = e.node;
|
|
1046
|
+
if (r.isComputed && this._tryPullComputed(r), r.version !== e.version) return this._hotIndex = n, !0;
|
|
969
1047
|
}
|
|
970
1048
|
return !1;
|
|
971
1049
|
} finally {
|
|
972
|
-
|
|
1050
|
+
D.current = e;
|
|
973
1051
|
}
|
|
974
1052
|
}
|
|
975
1053
|
_tryPullComputed(e) {
|
|
@@ -978,18 +1056,19 @@ var Oe = class extends ne {
|
|
|
978
1056
|
} catch {}
|
|
979
1057
|
}
|
|
980
1058
|
_execCleanup() {
|
|
981
|
-
|
|
1059
|
+
let e = this._cleanup;
|
|
1060
|
+
if (e != null) {
|
|
1061
|
+
this._cleanup = null;
|
|
982
1062
|
try {
|
|
983
|
-
|
|
1063
|
+
e();
|
|
984
1064
|
} catch (e) {
|
|
985
1065
|
this._handleExecutionError(e, v.EFFECT_CLEANUP_FAILED);
|
|
986
1066
|
}
|
|
987
|
-
this._cleanup = null;
|
|
988
1067
|
}
|
|
989
1068
|
}
|
|
990
1069
|
_checkInfiniteLoops() {
|
|
991
|
-
let e =
|
|
992
|
-
this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"),
|
|
1070
|
+
let e = se();
|
|
1071
|
+
this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), ue() > a.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++;
|
|
993
1072
|
}
|
|
994
1073
|
_checkFrequencyLimit() {
|
|
995
1074
|
if (!Number.isFinite(this._maxExecutions)) return;
|
|
@@ -1003,9 +1082,6 @@ var Oe = class extends ne {
|
|
|
1003
1082
|
throw this.dispose(), this._handleExecutionError(e), e;
|
|
1004
1083
|
}
|
|
1005
1084
|
}
|
|
1006
|
-
get isDisposed() {
|
|
1007
|
-
return (this.flags & n.DISPOSED) !== 0;
|
|
1008
|
-
}
|
|
1009
1085
|
get executionCount() {
|
|
1010
1086
|
return this._executionCount;
|
|
1011
1087
|
}
|
|
@@ -1013,89 +1089,86 @@ var Oe = class extends ne {
|
|
|
1013
1089
|
return (this.flags & n.EXECUTING) !== 0;
|
|
1014
1090
|
}
|
|
1015
1091
|
_throwInfiniteLoopError(e) {
|
|
1016
|
-
let t = new g(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${
|
|
1092
|
+
let t = new g(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${ae}`);
|
|
1017
1093
|
throw this.dispose(), console.error(t), t;
|
|
1018
1094
|
}
|
|
1019
1095
|
_handleExecutionError(e, t = v.EFFECT_EXECUTION_FAILED) {
|
|
1020
|
-
let n =
|
|
1096
|
+
let n = T(e, g, t);
|
|
1021
1097
|
if (console.error(n), this._onError) try {
|
|
1022
1098
|
this._onError(n);
|
|
1023
1099
|
} catch (e) {
|
|
1024
|
-
console.error(
|
|
1100
|
+
console.error(T(e, g, v.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
1025
1101
|
}
|
|
1026
1102
|
}
|
|
1027
1103
|
};
|
|
1028
|
-
function
|
|
1104
|
+
function R(e, t = {}) {
|
|
1029
1105
|
if (typeof e != "function") throw new g(v.EFFECT_MUST_BE_FUNCTION);
|
|
1030
|
-
let n = new
|
|
1106
|
+
let n = new Te(e, t);
|
|
1031
1107
|
return n.execute(), n;
|
|
1032
1108
|
}
|
|
1033
|
-
function
|
|
1109
|
+
function Ee(e) {
|
|
1034
1110
|
if (typeof e != "function") throw TypeError(v.BATCH_CALLBACK_MUST_BE_FUNCTION);
|
|
1035
|
-
|
|
1111
|
+
let t = de;
|
|
1112
|
+
t.startBatch();
|
|
1036
1113
|
try {
|
|
1037
1114
|
return e();
|
|
1038
1115
|
} finally {
|
|
1039
|
-
|
|
1116
|
+
t.endBatch();
|
|
1040
1117
|
}
|
|
1041
1118
|
}
|
|
1042
1119
|
//#endregion
|
|
1043
1120
|
//#region src/utils/index.ts
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
if (r === 0) return t;
|
|
1055
|
-
let i = t;
|
|
1056
|
-
for (let e = 0; e < r; e++) i += `.${n[e]}`;
|
|
1057
|
-
return i;
|
|
1121
|
+
var z = (e) => ve(e), De = (e) => typeof e == "object" && !!e && typeof e.then == "function";
|
|
1122
|
+
function B(e) {
|
|
1123
|
+
let t = e.localName, n = e.id;
|
|
1124
|
+
if (n) return `${t}#${n}`;
|
|
1125
|
+
let r = e.className;
|
|
1126
|
+
if (typeof r == "string") {
|
|
1127
|
+
let e = r.trim();
|
|
1128
|
+
if (e) return `${t}.${e.replace(/\s+/g, ".")}`;
|
|
1129
|
+
}
|
|
1130
|
+
return t;
|
|
1058
1131
|
}
|
|
1059
|
-
var
|
|
1060
|
-
function
|
|
1132
|
+
var V = Object.prototype.hasOwnProperty;
|
|
1133
|
+
function Oe(e, t) {
|
|
1061
1134
|
if (e === t) return !0;
|
|
1062
|
-
if (e
|
|
1063
|
-
let n =
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
return
|
|
1135
|
+
if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
|
|
1136
|
+
let n = e, r = t, i = 0;
|
|
1137
|
+
for (let e in n) if (V.call(n, e)) {
|
|
1138
|
+
if (!V.call(r, e) || n[e] !== r[e]) return !1;
|
|
1139
|
+
i++;
|
|
1140
|
+
}
|
|
1141
|
+
let a = 0;
|
|
1142
|
+
for (let e in r) V.call(r, e) && a++;
|
|
1143
|
+
return i === a;
|
|
1071
1144
|
}
|
|
1072
1145
|
//#endregion
|
|
1073
1146
|
//#region src/constants.ts
|
|
1074
|
-
var
|
|
1147
|
+
var H = {
|
|
1075
1148
|
ROUTE: "[atom-route]",
|
|
1076
1149
|
BINDING: "[atom-binding]",
|
|
1077
1150
|
LIST: "[atom-list]",
|
|
1078
1151
|
MOUNT: "[atom-mount]"
|
|
1079
|
-
},
|
|
1152
|
+
}, U = Object.freeze({
|
|
1080
1153
|
mode: "hash",
|
|
1081
1154
|
basePath: "",
|
|
1082
1155
|
autoBindLinks: !1,
|
|
1083
1156
|
activeClass: "active"
|
|
1084
|
-
}),
|
|
1157
|
+
}), ke = {
|
|
1085
1158
|
EVENT: "input",
|
|
1086
1159
|
DEBOUNCE: 0
|
|
1087
|
-
},
|
|
1160
|
+
}, Ae = { HIGHLIGHT_DURATION_MS: 500 }, je = new Set([
|
|
1088
1161
|
"input",
|
|
1089
1162
|
"select",
|
|
1090
1163
|
"textarea"
|
|
1091
|
-
]),
|
|
1164
|
+
]), Me = new Set([
|
|
1092
1165
|
"innerHTML",
|
|
1093
1166
|
"outerHTML",
|
|
1094
1167
|
"srcdoc",
|
|
1095
1168
|
"__proto__",
|
|
1096
1169
|
"constructor",
|
|
1097
1170
|
"prototype"
|
|
1098
|
-
]),
|
|
1171
|
+
]), W = {
|
|
1099
1172
|
ROUTE: {
|
|
1100
1173
|
NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
|
|
1101
1174
|
TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
|
|
@@ -1123,102 +1196,147 @@ var B = {
|
|
|
1123
1196
|
CLEANUP_ERROR: (e) => `Cleanup error${e ? ` in component <${e}>` : ""}`
|
|
1124
1197
|
},
|
|
1125
1198
|
CORE: { EFFECT_DISPOSE_ERROR: (e) => `Effect dispose error${e ? `: ${e}` : ""}` }
|
|
1126
|
-
},
|
|
1127
|
-
function
|
|
1128
|
-
if (
|
|
1129
|
-
let e = window.__ATOM_DEBUG__;
|
|
1130
|
-
if (typeof e == "boolean") return e;
|
|
1131
|
-
}
|
|
1199
|
+
}, Ne = typeof window < "u", Pe = `${Ae.HIGHLIGHT_DURATION_MS / 1e3}s`;
|
|
1200
|
+
function Fe() {
|
|
1201
|
+
if (Ne && window.__ATOM_DEBUG__ === !0) return !0;
|
|
1132
1202
|
try {
|
|
1133
1203
|
if (globalThis.process?.env?.VITE_ATOM_DEBUG === "true") return !0;
|
|
1134
1204
|
} catch {}
|
|
1135
1205
|
return !1;
|
|
1136
1206
|
}
|
|
1137
|
-
var
|
|
1207
|
+
var Ie = Fe(), G = new class {
|
|
1138
1208
|
get enabled() {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
if (typeof e == "boolean") return e;
|
|
1142
|
-
}
|
|
1143
|
-
return Re;
|
|
1144
|
-
},
|
|
1209
|
+
return Ne && window.__ATOM_DEBUG__ === !0 || Ie;
|
|
1210
|
+
}
|
|
1145
1211
|
set enabled(e) {
|
|
1146
|
-
|
|
1147
|
-
}
|
|
1212
|
+
Ie = e;
|
|
1213
|
+
}
|
|
1148
1214
|
log(e, ...t) {
|
|
1149
|
-
this.enabled && console.log(
|
|
1150
|
-
}
|
|
1215
|
+
this.enabled && console.log(e, ...t);
|
|
1216
|
+
}
|
|
1151
1217
|
atomChanged(e, t, n, r) {
|
|
1152
1218
|
this.enabled && console.log(`${e} Atom "${t ?? "anonymous"}" changed:`, n, "→", r);
|
|
1153
|
-
}
|
|
1219
|
+
}
|
|
1154
1220
|
domUpdated(e, t, n, r) {
|
|
1155
1221
|
if (!this.enabled) return;
|
|
1156
1222
|
let i = t instanceof Element ? t : t[0];
|
|
1157
|
-
i && (console.log(`${e} DOM updated: ${
|
|
1158
|
-
}
|
|
1223
|
+
i?.isConnected && (console.log(`${e} DOM updated: ${B(i)}.${n} =`, r), Ue(i));
|
|
1224
|
+
}
|
|
1159
1225
|
cleanup(e, t) {
|
|
1160
1226
|
this.enabled && console.log(`${e} Cleanup: ${t}`);
|
|
1161
|
-
}
|
|
1227
|
+
}
|
|
1162
1228
|
warn(e, t, ...n) {
|
|
1163
1229
|
console.warn(`${e} ${t}`, ...n);
|
|
1164
|
-
}
|
|
1230
|
+
}
|
|
1165
1231
|
error(e, t, n) {
|
|
1166
1232
|
console.error(`${e} ${t}`, n);
|
|
1167
1233
|
}
|
|
1168
|
-
},
|
|
1169
|
-
function
|
|
1170
|
-
if (
|
|
1171
|
-
|
|
1172
|
-
|
|
1234
|
+
}(), Le = "atom-debug-highlight", Re = "data-atom-debug", ze = !1;
|
|
1235
|
+
function Be() {
|
|
1236
|
+
if (ze || !Ne) return;
|
|
1237
|
+
if (document.querySelector(`style[${Re}]`)) {
|
|
1238
|
+
ze = !0;
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
let e = Object.assign(document.createElement("style"), { textContent: `.${Le}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${Pe} ease-out}` });
|
|
1242
|
+
e.setAttribute(Re, ""), document.head.appendChild(e), ze = !0;
|
|
1173
1243
|
}
|
|
1174
|
-
var
|
|
1175
|
-
function
|
|
1176
|
-
if (!
|
|
1177
|
-
|
|
1178
|
-
let t =
|
|
1179
|
-
t !== void 0 && cancelAnimationFrame(t)
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
e.isConnected && e.classList.remove(ze), He.delete(e);
|
|
1185
|
-
}, Ne.HIGHLIGHT_DURATION_MS)));
|
|
1186
|
-
});
|
|
1187
|
-
Ue.set(e, r);
|
|
1244
|
+
var Ve = /* @__PURE__ */ new WeakMap(), He = /* @__PURE__ */ new WeakMap();
|
|
1245
|
+
function Ue(e) {
|
|
1246
|
+
if (!G.enabled || !e.isConnected) return;
|
|
1247
|
+
Be();
|
|
1248
|
+
let t = He.get(e), n = Ve.get(e);
|
|
1249
|
+
t !== void 0 && cancelAnimationFrame(t), n !== void 0 && (clearTimeout(n), Ve.delete(e)), He.set(e, requestAnimationFrame(() => {
|
|
1250
|
+
He.delete(e), e.isConnected && (e.classList.add(Le), Ve.set(e, setTimeout(() => {
|
|
1251
|
+
e.isConnected && e.classList.remove(Le), Ve.delete(e);
|
|
1252
|
+
}, Ae.HIGHLIGHT_DURATION_MS)));
|
|
1253
|
+
}));
|
|
1188
1254
|
}
|
|
1189
1255
|
//#endregion
|
|
1256
|
+
//#region src/core/lens.ts
|
|
1257
|
+
var We = Symbol.for("atom-effect/atom"), Ge = Symbol.for("atom-effect/writable");
|
|
1258
|
+
function Ke(e, t, n, r) {
|
|
1259
|
+
if (n === t.length) return r;
|
|
1260
|
+
let i = t[n], a = typeof e == "object" && e ? e : {}, o = a[i], s = Ke(o, t, n + 1, r);
|
|
1261
|
+
if (Object.is(o, s)) return e;
|
|
1262
|
+
if (Array.isArray(a)) {
|
|
1263
|
+
let e = a.slice(), t = Number.parseInt(i, 10);
|
|
1264
|
+
return Number.isNaN(t) ? e[i] = s : e[t] = s, e;
|
|
1265
|
+
}
|
|
1266
|
+
return {
|
|
1267
|
+
...a,
|
|
1268
|
+
[i]: s
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
function K(e, t) {
|
|
1272
|
+
let n = e, r = t.length;
|
|
1273
|
+
for (let e = 0; e < r; e++) {
|
|
1274
|
+
if (n == null) return;
|
|
1275
|
+
n = n[t[e]];
|
|
1276
|
+
}
|
|
1277
|
+
return n;
|
|
1278
|
+
}
|
|
1279
|
+
function qe(e, t) {
|
|
1280
|
+
let n = t.includes(".") ? t.split(".") : [t], r = /* @__PURE__ */ new Set(), i = () => {
|
|
1281
|
+
r.forEach((e) => e()), r.clear();
|
|
1282
|
+
};
|
|
1283
|
+
return {
|
|
1284
|
+
get value() {
|
|
1285
|
+
return K(e.value, n);
|
|
1286
|
+
},
|
|
1287
|
+
set value(t) {
|
|
1288
|
+
let r = e.peek(), i = Ke(r, n, 0, t);
|
|
1289
|
+
i !== r && (e.value = i);
|
|
1290
|
+
},
|
|
1291
|
+
peek: () => K(e.peek(), n),
|
|
1292
|
+
subscribe(t) {
|
|
1293
|
+
let i = e.subscribe((e, r) => {
|
|
1294
|
+
let i = K(e, n), a = K(r, n);
|
|
1295
|
+
Object.is(i, a) || t(i, a);
|
|
1296
|
+
});
|
|
1297
|
+
return r.add(i), () => {
|
|
1298
|
+
i(), r.delete(i);
|
|
1299
|
+
};
|
|
1300
|
+
},
|
|
1301
|
+
subscriberCount: () => r.size,
|
|
1302
|
+
dispose: i,
|
|
1303
|
+
[Symbol.dispose]: i,
|
|
1304
|
+
[We]: !0,
|
|
1305
|
+
[Ge]: !0
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
var Je = (e, t) => qe(e, t), Ye = (e) => (t) => qe(e, t);
|
|
1309
|
+
//#endregion
|
|
1190
1310
|
//#region src/core/namespace.ts
|
|
1191
|
-
function
|
|
1192
|
-
return
|
|
1311
|
+
function Xe(e, t) {
|
|
1312
|
+
return k(e, t);
|
|
1193
1313
|
}
|
|
1194
|
-
Object.defineProperty(
|
|
1314
|
+
Object.defineProperty(Xe, "debug", {
|
|
1195
1315
|
enumerable: !0,
|
|
1196
1316
|
configurable: !0,
|
|
1197
|
-
get()
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
set(e) {
|
|
1201
|
-
U.enabled = e;
|
|
1317
|
+
get: () => G.enabled,
|
|
1318
|
+
set: (e) => {
|
|
1319
|
+
G.enabled = e;
|
|
1202
1320
|
}
|
|
1203
1321
|
});
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1322
|
+
var Ze = () => Promise.resolve();
|
|
1323
|
+
e.extend({
|
|
1324
|
+
atom: Xe,
|
|
1325
|
+
computed: L,
|
|
1326
|
+
effect: R,
|
|
1327
|
+
batch: Ee,
|
|
1328
|
+
untracked: O,
|
|
1329
|
+
isAtom: ve,
|
|
1330
|
+
isComputed: ye,
|
|
1331
|
+
isReactive: z,
|
|
1332
|
+
nextTick: Ze,
|
|
1333
|
+
atomLens: qe,
|
|
1334
|
+
composeLens: Je,
|
|
1335
|
+
lensFor: Ye
|
|
1336
|
+
});
|
|
1219
1337
|
//#endregion
|
|
1220
1338
|
//#region src/utils/array-pool.ts
|
|
1221
|
-
var
|
|
1339
|
+
var Qe = class {
|
|
1222
1340
|
constructor(e = 50, t = 256) {
|
|
1223
1341
|
this.limit = e, this.capacity = t, this.pool = [];
|
|
1224
1342
|
}
|
|
@@ -1231,7 +1349,7 @@ var Je = class {
|
|
|
1231
1349
|
reset() {
|
|
1232
1350
|
this.pool.length = 0;
|
|
1233
1351
|
}
|
|
1234
|
-
},
|
|
1352
|
+
}, $e = class {
|
|
1235
1353
|
constructor(e, t, n = 64) {
|
|
1236
1354
|
this.factory = e, this.reset = t, this.limit = n, this.pool = [];
|
|
1237
1355
|
}
|
|
@@ -1239,21 +1357,25 @@ var Je = class {
|
|
|
1239
1357
|
return this.pool.pop() ?? this.factory();
|
|
1240
1358
|
}
|
|
1241
1359
|
release(e) {
|
|
1242
|
-
this.pool.length
|
|
1360
|
+
this.pool.length < this.limit && (this.reset(e), this.pool.push(e));
|
|
1243
1361
|
}
|
|
1244
1362
|
drain() {
|
|
1245
|
-
this.pool.length = 0;
|
|
1363
|
+
this.pool.length > 0 && (this.pool.length = 0);
|
|
1246
1364
|
}
|
|
1247
1365
|
get size() {
|
|
1248
1366
|
return this.pool.length;
|
|
1249
1367
|
}
|
|
1250
|
-
},
|
|
1368
|
+
}, et = new Qe(), tt = new Qe(), nt = new $e(() => ({
|
|
1251
1369
|
effects: void 0,
|
|
1252
1370
|
cleanups: void 0,
|
|
1253
1371
|
componentCleanup: void 0
|
|
1254
1372
|
}), (e) => {
|
|
1255
1373
|
e.effects = void 0, e.cleanups = void 0, e.componentCleanup = void 0;
|
|
1256
|
-
}, 128),
|
|
1374
|
+
}, 128), rt = !1;
|
|
1375
|
+
function it() {
|
|
1376
|
+
rt || (rt = !0, typeof document < "u" && document.body && ot(document.body));
|
|
1377
|
+
}
|
|
1378
|
+
var q = "_aes-bound", J = new class {
|
|
1257
1379
|
constructor() {
|
|
1258
1380
|
this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1259
1381
|
}
|
|
@@ -1270,257 +1392,264 @@ var Je = class {
|
|
|
1270
1392
|
return this.ignoredNodes.has(e);
|
|
1271
1393
|
}
|
|
1272
1394
|
getOrCreateRecord(e) {
|
|
1395
|
+
it();
|
|
1273
1396
|
let t = this.records.get(e);
|
|
1274
|
-
return t || (t =
|
|
1397
|
+
return t || (t = nt.acquire(), this.records.set(e, t), e.classList.add(q)), t;
|
|
1275
1398
|
}
|
|
1276
1399
|
trackEffect(e, t) {
|
|
1277
1400
|
let n = this.getOrCreateRecord(e);
|
|
1278
|
-
n.effects
|
|
1401
|
+
n.effects ||= et.acquire(), n.effects.push(t);
|
|
1279
1402
|
}
|
|
1280
1403
|
trackCleanup(e, t) {
|
|
1281
1404
|
let n = this.getOrCreateRecord(e);
|
|
1282
|
-
n.cleanups
|
|
1405
|
+
n.cleanups ||= tt.acquire(), n.cleanups.push(t);
|
|
1283
1406
|
}
|
|
1284
1407
|
setComponentCleanup(e, t) {
|
|
1285
|
-
|
|
1286
|
-
n.componentCleanup = t;
|
|
1408
|
+
this.getOrCreateRecord(e).componentCleanup = t;
|
|
1287
1409
|
}
|
|
1288
1410
|
hasBind(e) {
|
|
1289
1411
|
return this.records.has(e);
|
|
1290
1412
|
}
|
|
1291
1413
|
cleanup(e) {
|
|
1292
|
-
let t = this.records.get(e);
|
|
1293
|
-
if (!
|
|
1294
|
-
|
|
1414
|
+
let t = e.nodeType === 1, n = this.records.get(e);
|
|
1415
|
+
if (this.preservedNodes.delete(e), this.ignoredNodes.delete(e), !n) {
|
|
1416
|
+
t && e.classList.remove(q);
|
|
1295
1417
|
return;
|
|
1296
1418
|
}
|
|
1297
|
-
if (this.records.delete(e),
|
|
1298
|
-
let
|
|
1299
|
-
|
|
1419
|
+
if (this.records.delete(e), t && e.classList.remove(q), G.enabled) {
|
|
1420
|
+
let n = t ? B(e) : e.nodeName || "Node";
|
|
1421
|
+
G.cleanup(H.BINDING, n);
|
|
1300
1422
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
}
|
|
1307
|
-
if (
|
|
1308
|
-
let
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
let n = e.nodeType === 1 ? R(e) : "Node";
|
|
1313
|
-
U.error(B.BINDING, H.CORE.EFFECT_DISPOSE_ERROR(n), t);
|
|
1423
|
+
let r = t ? B(e) : "Node";
|
|
1424
|
+
if (n.componentCleanup) try {
|
|
1425
|
+
n.componentCleanup();
|
|
1426
|
+
} catch (e) {
|
|
1427
|
+
G.error(H.MOUNT, W.MOUNT.CLEANUP_ERROR(r), e);
|
|
1428
|
+
}
|
|
1429
|
+
if (n.effects) {
|
|
1430
|
+
for (let e of n.effects) try {
|
|
1431
|
+
e.dispose();
|
|
1432
|
+
} catch (e) {
|
|
1433
|
+
G.error(H.BINDING, W.CORE.EFFECT_DISPOSE_ERROR(r), e);
|
|
1314
1434
|
}
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1317
|
-
if (
|
|
1318
|
-
let
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
let n = e.nodeType === 1 ? R(e) : "Node";
|
|
1323
|
-
U.error(B.BINDING, H.BINDING.CLEANUP_ERROR(n), t);
|
|
1435
|
+
et.release(n.effects), n.effects = void 0;
|
|
1436
|
+
}
|
|
1437
|
+
if (n.cleanups) {
|
|
1438
|
+
for (let e of n.cleanups) try {
|
|
1439
|
+
e();
|
|
1440
|
+
} catch (e) {
|
|
1441
|
+
G.error(H.BINDING, W.BINDING.CLEANUP_ERROR(r), e);
|
|
1324
1442
|
}
|
|
1325
|
-
|
|
1443
|
+
tt.release(n.cleanups), n.cleanups = void 0;
|
|
1326
1444
|
}
|
|
1327
|
-
|
|
1445
|
+
nt.release(n);
|
|
1328
1446
|
}
|
|
1329
1447
|
cleanupDescendants(e) {
|
|
1330
|
-
let t =
|
|
1331
|
-
for (let e =
|
|
1448
|
+
let t = e.getElementsByClassName ? e.getElementsByClassName(q) : e.querySelectorAll(`.${q}`), n = t.length;
|
|
1449
|
+
if (n !== 0) for (let e = n - 1; e >= 0; e--) {
|
|
1332
1450
|
let n = t[e];
|
|
1333
|
-
|
|
1451
|
+
this.records.has(n) ? this.cleanup(n) : n.classList.remove(q);
|
|
1334
1452
|
}
|
|
1335
1453
|
}
|
|
1336
1454
|
cleanupTree(e) {
|
|
1337
1455
|
(e.nodeType === 1 || e.nodeType === 11) && this.cleanupDescendants(e), this.cleanup(e);
|
|
1338
1456
|
}
|
|
1339
|
-
}(),
|
|
1340
|
-
function
|
|
1341
|
-
if (
|
|
1457
|
+
}(), at = /* @__PURE__ */ new Map();
|
|
1458
|
+
function ot(e) {
|
|
1459
|
+
if (at.has(e)) return;
|
|
1342
1460
|
let t = new MutationObserver((e) => {
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1461
|
+
let t = J;
|
|
1462
|
+
for (let n = 0, r = e.length; n < r; n++) {
|
|
1463
|
+
let r = e[n].removedNodes;
|
|
1464
|
+
for (let e = 0, n = r.length; e < n; e++) {
|
|
1465
|
+
let n = r[e];
|
|
1466
|
+
if (n.nodeType !== 1) continue;
|
|
1467
|
+
let i = n;
|
|
1468
|
+
i.isConnected || t.isKept(i) || t.isIgnored(i) || t.cleanupTree(i);
|
|
1348
1469
|
}
|
|
1349
1470
|
}
|
|
1350
1471
|
});
|
|
1351
1472
|
t.observe(e, {
|
|
1352
1473
|
childList: !0,
|
|
1353
1474
|
subtree: !0
|
|
1354
|
-
}),
|
|
1475
|
+
}), at.set(e, t);
|
|
1355
1476
|
}
|
|
1356
|
-
function
|
|
1357
|
-
|
|
1477
|
+
function st() {
|
|
1478
|
+
at.forEach((e) => e.disconnect()), at.clear();
|
|
1358
1479
|
}
|
|
1359
1480
|
//#endregion
|
|
1360
1481
|
//#region src/core/jquery-patch.ts
|
|
1361
|
-
var
|
|
1362
|
-
if (e[
|
|
1363
|
-
let t =
|
|
1482
|
+
var ct = Symbol("atom-effect-internal"), lt = /* @__PURE__ */ new WeakMap(), Y = null, ut = (e) => {
|
|
1483
|
+
if (e[ct]) return e;
|
|
1484
|
+
let t = lt.get(e);
|
|
1364
1485
|
return t || (t = function(...t) {
|
|
1365
|
-
return
|
|
1366
|
-
}, t[
|
|
1486
|
+
return Ee(() => e.apply(this, t));
|
|
1487
|
+
}, t[ct] = !0, lt.set(e, t)), t;
|
|
1367
1488
|
};
|
|
1368
|
-
function
|
|
1369
|
-
let t = {}
|
|
1370
|
-
for (let
|
|
1371
|
-
let r = n[e], i = r[0], a = r[1];
|
|
1372
|
-
a && (t[i] = it(a));
|
|
1373
|
-
}
|
|
1489
|
+
function dt(e) {
|
|
1490
|
+
let t = {};
|
|
1491
|
+
for (let n in e) e[n] && (t[n] = ut(e[n]));
|
|
1374
1492
|
return t;
|
|
1375
1493
|
}
|
|
1376
|
-
function
|
|
1377
|
-
let t = {}
|
|
1378
|
-
for (let
|
|
1379
|
-
let r =
|
|
1380
|
-
t[
|
|
1494
|
+
function ft(e) {
|
|
1495
|
+
let t = {};
|
|
1496
|
+
for (let n in e) {
|
|
1497
|
+
let r = e[n];
|
|
1498
|
+
t[n] = r ? lt.get(r) ?? r : void 0;
|
|
1381
1499
|
}
|
|
1382
1500
|
return t;
|
|
1383
1501
|
}
|
|
1384
|
-
function
|
|
1385
|
-
if (
|
|
1386
|
-
|
|
1502
|
+
function pt() {
|
|
1503
|
+
if (Y !== null) return;
|
|
1504
|
+
Y = {
|
|
1387
1505
|
on: e.fn.on,
|
|
1388
1506
|
off: e.fn.off,
|
|
1389
1507
|
remove: e.fn.remove,
|
|
1390
1508
|
empty: e.fn.empty,
|
|
1391
1509
|
detach: e.fn.detach
|
|
1392
1510
|
};
|
|
1393
|
-
let t =
|
|
1511
|
+
let t = Y;
|
|
1394
1512
|
e.fn.remove = function(e) {
|
|
1395
|
-
let n = e ? this.filter(e) : this;
|
|
1396
|
-
for (let e = 0
|
|
1513
|
+
let n = e ? this.filter(e) : this, r = n.length;
|
|
1514
|
+
for (let e = 0; e < r; e++) {
|
|
1397
1515
|
let t = n[e];
|
|
1398
|
-
t && (
|
|
1516
|
+
t && (J.markIgnored(t), J.cleanupTree(t));
|
|
1399
1517
|
}
|
|
1400
|
-
|
|
1401
|
-
return r === void 0 ? this : r;
|
|
1518
|
+
return t.remove.call(this, e) ?? this;
|
|
1402
1519
|
}, e.fn.empty = function() {
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1520
|
+
let e = this.length;
|
|
1521
|
+
for (let t = 0; t < e; t++) {
|
|
1522
|
+
let e = this[t];
|
|
1523
|
+
e?.hasChildNodes() && J.cleanupDescendants(e);
|
|
1406
1524
|
}
|
|
1407
|
-
|
|
1408
|
-
return e === void 0 ? this : e;
|
|
1525
|
+
return t.empty.call(this) ?? this;
|
|
1409
1526
|
}, e.fn.detach = function(e) {
|
|
1410
|
-
let n = e ? this.filter(e) : this;
|
|
1411
|
-
for (let e = 0
|
|
1527
|
+
let n = e ? this.filter(e) : this, r = n.length;
|
|
1528
|
+
for (let e = 0; e < r; e++) {
|
|
1412
1529
|
let t = n[e];
|
|
1413
|
-
t &&
|
|
1530
|
+
t && J.keep(t);
|
|
1414
1531
|
}
|
|
1415
|
-
|
|
1416
|
-
return r === void 0 ? this : r;
|
|
1532
|
+
return t.detach.call(this, e) ?? this;
|
|
1417
1533
|
}, e.fn.on = function(...e) {
|
|
1418
1534
|
let n = e[0];
|
|
1419
|
-
if (n && typeof n == "object") e[0] =
|
|
1535
|
+
if (n && typeof n == "object") e[0] = dt(n);
|
|
1420
1536
|
else {
|
|
1421
1537
|
let t = e.length - 1;
|
|
1422
|
-
t >= 0 && typeof e[t] == "function" && (e[t] =
|
|
1538
|
+
t >= 0 && typeof e[t] == "function" && (e[t] = ut(e[t]));
|
|
1423
1539
|
}
|
|
1424
|
-
|
|
1425
|
-
return r === void 0 ? this : r;
|
|
1540
|
+
return t.on.apply(this, e) ?? this;
|
|
1426
1541
|
}, e.fn.off = function(...e) {
|
|
1427
1542
|
let n = e[0];
|
|
1428
|
-
if (n && typeof n == "object") e[0] =
|
|
1543
|
+
if (n && typeof n == "object") e[0] = ft(n);
|
|
1429
1544
|
else {
|
|
1430
1545
|
let t = e.length - 1;
|
|
1431
1546
|
if (t >= 0 && typeof e[t] == "function") {
|
|
1432
1547
|
let n = e[t];
|
|
1433
|
-
e[t] =
|
|
1548
|
+
e[t] = lt.get(n) ?? n;
|
|
1434
1549
|
}
|
|
1435
1550
|
}
|
|
1436
|
-
|
|
1437
|
-
return r === void 0 ? this : r;
|
|
1551
|
+
return t.off.apply(this, e) ?? this;
|
|
1438
1552
|
};
|
|
1439
1553
|
}
|
|
1440
|
-
function
|
|
1441
|
-
|
|
1554
|
+
function mt() {
|
|
1555
|
+
Y !== null && (e.fn.on = Y.on, e.fn.off = Y.off, e.fn.remove = Y.remove, e.fn.empty = Y.empty, e.fn.detach = Y.detach, Y = null);
|
|
1442
1556
|
}
|
|
1443
1557
|
//#endregion
|
|
1444
1558
|
//#region src/types.ts
|
|
1445
|
-
var
|
|
1559
|
+
var X = /* @__PURE__ */ function(e) {
|
|
1446
1560
|
return e[e.None = 0] = "None", e[e.Focused = 1] = "Focused", e[e.Composing = 2] = "Composing", e[e.SyncingToAtom = 4] = "SyncingToAtom", e[e.SyncingToDom = 8] = "SyncingToDom", e[e.Busy = 14] = "Busy", e;
|
|
1447
|
-
}({}),
|
|
1448
|
-
function
|
|
1449
|
-
e[
|
|
1561
|
+
}({}), ht = 0;
|
|
1562
|
+
function gt(e) {
|
|
1563
|
+
e[ct] = !0;
|
|
1450
1564
|
}
|
|
1451
|
-
var
|
|
1565
|
+
var _t = class {
|
|
1452
1566
|
constructor(e, t, n) {
|
|
1453
1567
|
this.flags = 0, this.timeoutId = void 0, this.handleCompositionStart = () => {
|
|
1454
|
-
this.flags |=
|
|
1568
|
+
this.flags |= X.Composing;
|
|
1455
1569
|
}, this.handleCompositionEnd = () => {
|
|
1456
|
-
this.flags &= ~
|
|
1570
|
+
this.flags &= ~X.Composing, this.handleInput();
|
|
1457
1571
|
}, this.handleFocus = () => {
|
|
1458
|
-
this.flags |=
|
|
1572
|
+
this.flags |= X.Focused;
|
|
1459
1573
|
}, this.handleBlur = () => {
|
|
1460
|
-
this.flags &= ~
|
|
1461
|
-
let e = !!(this.flags &
|
|
1462
|
-
this.flags &= ~
|
|
1574
|
+
this.flags &= ~X.Focused;
|
|
1575
|
+
let e = !!(this.flags & X.Composing);
|
|
1576
|
+
this.flags &= ~X.Composing, this.flushPendingDebounce(), e && this.timeoutId === void 0 && this.syncAtomFromDom(), this.normalizeDomValue();
|
|
1463
1577
|
}, this.syncDomFromAtom = () => {
|
|
1464
1578
|
let e = this.atom.value;
|
|
1465
|
-
|
|
1466
|
-
let t = this.format(e),
|
|
1467
|
-
if (
|
|
1468
|
-
let
|
|
1469
|
-
if (
|
|
1470
|
-
let
|
|
1471
|
-
if (this.equal(
|
|
1579
|
+
O(() => {
|
|
1580
|
+
let t = this.isMultipleSelect, n = this.format(e), r = t ? this.$el.val() || [] : this.el.value;
|
|
1581
|
+
if (this.equal(r, e)) return;
|
|
1582
|
+
let i = !!(this.flags & X.Focused);
|
|
1583
|
+
if (i) try {
|
|
1584
|
+
let n = t ? r : this.parse(this.el.value);
|
|
1585
|
+
if (this.equal(n, e)) return;
|
|
1472
1586
|
} catch {}
|
|
1473
|
-
this.flags |=
|
|
1587
|
+
this.flags |= X.SyncingToDom;
|
|
1474
1588
|
try {
|
|
1475
|
-
if (
|
|
1476
|
-
else if (
|
|
1477
|
-
let e = this.el.selectionStart,
|
|
1478
|
-
|
|
1479
|
-
let
|
|
1480
|
-
|
|
1589
|
+
if (t) this.$el.val(e);
|
|
1590
|
+
else if (i && this.isTextControl) try {
|
|
1591
|
+
let e = this.el, t = e.selectionStart, r = e.selectionEnd;
|
|
1592
|
+
e.value = n;
|
|
1593
|
+
let i = n.length;
|
|
1594
|
+
t !== null && r !== null && e.setSelectionRange(t < i ? t : i, r < i ? r : i);
|
|
1481
1595
|
} catch {
|
|
1482
|
-
this.el.value =
|
|
1596
|
+
this.el.value = n;
|
|
1483
1597
|
}
|
|
1484
|
-
else this.el.value =
|
|
1485
|
-
|
|
1598
|
+
else this.el.value = n;
|
|
1599
|
+
G.enabled && G.domUpdated(H.BINDING, this.$el, "val", n);
|
|
1486
1600
|
} finally {
|
|
1487
|
-
this.flags &= ~
|
|
1601
|
+
this.flags &= ~X.SyncingToDom;
|
|
1488
1602
|
}
|
|
1489
1603
|
});
|
|
1490
1604
|
}, this.cleanup = () => {
|
|
1491
1605
|
this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
|
|
1492
|
-
}, this.$el = e, this.el = e[0], this.atom = t
|
|
1493
|
-
let r =
|
|
1494
|
-
this.
|
|
1495
|
-
let a = n.
|
|
1496
|
-
this.
|
|
1497
|
-
|
|
1606
|
+
}, this.$el = e, this.el = e[0], this.atom = t;
|
|
1607
|
+
let r = this.el.tagName, i = r === "SELECT" && this.el.multiple;
|
|
1608
|
+
this.isMultipleSelect = i, this.isTextControl = r === "INPUT" || r === "TEXTAREA", this.ns = `.atomBind-${++ht}`;
|
|
1609
|
+
let a = n.debounce ?? 0;
|
|
1610
|
+
this.parse = n.parse ?? ((e) => e), i ? this.format = n.format ?? ((e) => (Array.isArray(e) ? e : e ? [String(e)] : []).join(",")) : this.format = n.format ?? ((e) => String(e ?? ""));
|
|
1611
|
+
let o = n.equal ?? Object.is;
|
|
1612
|
+
i ? this.equal = (e, t) => {
|
|
1613
|
+
if (o(e, t)) return !0;
|
|
1614
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
1615
|
+
let n = e.length;
|
|
1616
|
+
if (n !== t.length) return !1;
|
|
1617
|
+
for (let r = 0; r < n; r++) if (!Object.is(e[r], t[r])) return !1;
|
|
1618
|
+
return !0;
|
|
1619
|
+
}
|
|
1620
|
+
return !1;
|
|
1621
|
+
} : this.equal = o, a > 0 ? this.handleInput = () => {
|
|
1622
|
+
this.flags & X.Composing || (clearTimeout(this.timeoutId), this.timeoutId = setTimeout(() => this.syncAtomFromDom(), a));
|
|
1498
1623
|
} : this.handleInput = () => {
|
|
1499
|
-
this.flags &
|
|
1500
|
-
},
|
|
1624
|
+
this.flags & X.Composing || this.syncAtomFromDom();
|
|
1625
|
+
}, [
|
|
1626
|
+
this.handleFocus,
|
|
1627
|
+
this.handleBlur,
|
|
1628
|
+
this.handleCompositionStart,
|
|
1629
|
+
this.handleCompositionEnd,
|
|
1630
|
+
this.handleInput
|
|
1631
|
+
].forEach(gt), this.bindEvents(n.event ?? ke.EVENT);
|
|
1501
1632
|
}
|
|
1502
1633
|
flushPendingDebounce() {
|
|
1503
1634
|
this.timeoutId !== void 0 && (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom());
|
|
1504
1635
|
}
|
|
1505
1636
|
normalizeDomValue() {
|
|
1506
|
-
let e = this.
|
|
1637
|
+
let e = this.atom.peek(), t = this.format(e);
|
|
1507
1638
|
if (this.isMultipleSelect) {
|
|
1508
|
-
let
|
|
1509
|
-
this.equal(
|
|
1510
|
-
} else this.el.value !==
|
|
1639
|
+
let t = this.$el.val() || [], n = Array.isArray(e) ? e : [];
|
|
1640
|
+
this.equal(t, n) || this.$el.val(n);
|
|
1641
|
+
} else this.el.value !== t && (this.el.value = t);
|
|
1511
1642
|
}
|
|
1512
1643
|
syncAtomFromDom() {
|
|
1513
|
-
if (!(this.flags &
|
|
1514
|
-
this.flags |=
|
|
1644
|
+
if (!(this.flags & X.Busy)) {
|
|
1645
|
+
this.flags |= X.SyncingToAtom;
|
|
1515
1646
|
try {
|
|
1516
|
-
let e;
|
|
1517
|
-
|
|
1518
|
-
let t = this.parse(e);
|
|
1519
|
-
this.equal(this.atom.peek(), t) || (this.atom.value = t);
|
|
1647
|
+
let e = this.isMultipleSelect, t = e ? this.$el.val() || [] : this.el.value, n = e ? t : this.parse(t);
|
|
1648
|
+
this.equal(this.atom.peek(), n) || (this.atom.value = n);
|
|
1520
1649
|
} catch (e) {
|
|
1521
|
-
|
|
1650
|
+
G.warn(H.BINDING, W.BINDING.PARSE_ERROR(e instanceof Error ? e.message : String(e)), e);
|
|
1522
1651
|
} finally {
|
|
1523
|
-
this.flags &= ~
|
|
1652
|
+
this.flags &= ~X.SyncingToAtom;
|
|
1524
1653
|
}
|
|
1525
1654
|
}
|
|
1526
1655
|
}
|
|
@@ -1529,75 +1658,74 @@ var ut = class {
|
|
|
1529
1658
|
this.$el.on(`focus${t}`, this.handleFocus).on(`blur${t}`, this.handleBlur).on(`compositionstart${t}`, this.handleCompositionStart).on(`compositionend${t}`, this.handleCompositionEnd).on(n, this.handleInput);
|
|
1530
1659
|
}
|
|
1531
1660
|
};
|
|
1532
|
-
function
|
|
1533
|
-
let r = new
|
|
1661
|
+
function vt(e, t, n) {
|
|
1662
|
+
let r = new _t(e, t, n);
|
|
1534
1663
|
return {
|
|
1535
|
-
fx:
|
|
1536
|
-
cleanup:
|
|
1664
|
+
fx: R(r.syncDomFromAtom),
|
|
1665
|
+
cleanup: () => {
|
|
1666
|
+
r &&= (r.cleanup(), null);
|
|
1667
|
+
}
|
|
1537
1668
|
};
|
|
1538
1669
|
}
|
|
1539
1670
|
//#endregion
|
|
1540
1671
|
//#region src/core/effect-factory.ts
|
|
1541
|
-
function
|
|
1672
|
+
function yt(e, t, n, r) {
|
|
1542
1673
|
let i = null, a = (t) => {
|
|
1543
|
-
if (
|
|
1544
|
-
let a = t;
|
|
1545
|
-
i = a, a.then((t) => {
|
|
1546
|
-
i === a && D(() => {
|
|
1547
|
-
try {
|
|
1548
|
-
n(t), U.enabled && U.domUpdated(B.BINDING, e, `${r} (async)`, t);
|
|
1549
|
-
} catch (e) {
|
|
1550
|
-
U.error(B.BINDING, H.BINDING.UPDATER_ERROR(r), e);
|
|
1551
|
-
}
|
|
1552
|
-
});
|
|
1553
|
-
}).catch((e) => {
|
|
1554
|
-
i === a && U.error(B.BINDING, H.BINDING.UPDATER_ERROR(r), e);
|
|
1555
|
-
});
|
|
1556
|
-
} else {
|
|
1674
|
+
if (!De(t)) {
|
|
1557
1675
|
i = null;
|
|
1558
1676
|
try {
|
|
1559
|
-
n(t),
|
|
1677
|
+
n(t), G.enabled && G.domUpdated(H.BINDING, e, r, t);
|
|
1560
1678
|
} catch (e) {
|
|
1561
|
-
|
|
1679
|
+
G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1562
1680
|
}
|
|
1681
|
+
return;
|
|
1563
1682
|
}
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1683
|
+
i = t, t.then((a) => {
|
|
1684
|
+
i === t && O(() => {
|
|
1685
|
+
try {
|
|
1686
|
+
n(a), G.enabled && G.domUpdated(H.BINDING, e, `${r} (async)`, a);
|
|
1687
|
+
} catch (e) {
|
|
1688
|
+
G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r), e);
|
|
1689
|
+
}
|
|
1690
|
+
});
|
|
1691
|
+
}).catch((e) => {
|
|
1692
|
+
i === t && G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r), e);
|
|
1693
|
+
});
|
|
1694
|
+
}, o = z(t);
|
|
1695
|
+
o || typeof t == "function" ? J.trackEffect(e, R(() => {
|
|
1696
|
+
let e = o ? t.value : t();
|
|
1697
|
+
O(() => a(e));
|
|
1698
|
+
}, { name: r })) : O(() => a(t));
|
|
1572
1699
|
}
|
|
1573
|
-
function
|
|
1700
|
+
function bt(e, t, n, r) {
|
|
1574
1701
|
let i = Object.keys(t), a = [], o = {};
|
|
1575
|
-
for (let e = 0
|
|
1702
|
+
for (let e = 0, n = i.length; e < n; e++) {
|
|
1576
1703
|
let n = i[e], r = t[n];
|
|
1577
|
-
|
|
1704
|
+
z(r) || typeof r == "function" ? a.push(n) : o[n] = r;
|
|
1578
1705
|
}
|
|
1579
1706
|
let s = 0, c = (t) => {
|
|
1580
|
-
let
|
|
1581
|
-
for (let e = 0; e <
|
|
1707
|
+
let a = [], o = {}, c = i.length;
|
|
1708
|
+
for (let e = 0; e < c; e++) {
|
|
1582
1709
|
let n = i[e], r = t[n];
|
|
1583
|
-
|
|
1710
|
+
De(r) ? a.push(r.then((e) => ({
|
|
1584
1711
|
key: n,
|
|
1585
1712
|
val: e
|
|
1586
1713
|
}))) : o[n] = r;
|
|
1587
1714
|
}
|
|
1588
|
-
|
|
1715
|
+
let l = a.length;
|
|
1716
|
+
if (l > 0) {
|
|
1589
1717
|
let t = ++s;
|
|
1590
1718
|
Promise.all(a).then((i) => {
|
|
1591
1719
|
if (t === s) {
|
|
1592
|
-
for (let e = 0; e <
|
|
1593
|
-
let
|
|
1594
|
-
o[t] =
|
|
1720
|
+
for (let e = 0; e < l; e++) {
|
|
1721
|
+
let t = i[e];
|
|
1722
|
+
o[t.key] = t.val;
|
|
1595
1723
|
}
|
|
1596
|
-
|
|
1724
|
+
O(() => {
|
|
1597
1725
|
try {
|
|
1598
|
-
n(o),
|
|
1726
|
+
n(o), G.enabled && G.domUpdated(H.BINDING, e, `${r} (async)`, o);
|
|
1599
1727
|
} catch (e) {
|
|
1600
|
-
|
|
1728
|
+
G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r), e);
|
|
1601
1729
|
}
|
|
1602
1730
|
});
|
|
1603
1731
|
}
|
|
@@ -1605,24 +1733,24 @@ function pt(e, t, n, r) {
|
|
|
1605
1733
|
} else {
|
|
1606
1734
|
s++;
|
|
1607
1735
|
try {
|
|
1608
|
-
n(o),
|
|
1736
|
+
n(o), G.enabled && G.domUpdated(H.BINDING, e, r, o);
|
|
1609
1737
|
} catch (e) {
|
|
1610
|
-
|
|
1738
|
+
G.error(H.BINDING, W.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1611
1739
|
}
|
|
1612
1740
|
}
|
|
1613
1741
|
};
|
|
1614
|
-
a.length > 0 ?
|
|
1742
|
+
a.length > 0 ? J.trackEffect(e, R(() => {
|
|
1615
1743
|
let e = { ...o };
|
|
1616
|
-
for (let n = 0
|
|
1744
|
+
for (let n = 0, r = a.length; n < r; n++) {
|
|
1617
1745
|
let r = a[n], i = t[r];
|
|
1618
|
-
e[r] =
|
|
1746
|
+
e[r] = z(i) ? i.value : i();
|
|
1619
1747
|
}
|
|
1620
|
-
|
|
1621
|
-
}, { name: r })) :
|
|
1748
|
+
O(() => c(e));
|
|
1749
|
+
}, { name: r })) : O(() => c(o));
|
|
1622
1750
|
}
|
|
1623
1751
|
//#endregion
|
|
1624
1752
|
//#region src/utils/sanitize.ts
|
|
1625
|
-
var
|
|
1753
|
+
var xt = new Set([
|
|
1626
1754
|
"href",
|
|
1627
1755
|
"src",
|
|
1628
1756
|
"action",
|
|
@@ -1637,731 +1765,672 @@ var mt = new Set([
|
|
|
1637
1765
|
"usemap",
|
|
1638
1766
|
"classid",
|
|
1639
1767
|
"codebase"
|
|
1640
|
-
]),
|
|
1768
|
+
]), St = /^\s*(?:javascript|vbscript)\s*:/i, Ct = /(?: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, wt = /url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i, Tt = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, Et = /&#x([0-9a-f]+);?|&#([0-9]+);?/gi, Dt = {
|
|
1641
1769
|
colon: ":",
|
|
1642
1770
|
Tab: " ",
|
|
1643
1771
|
NewLine: "\n"
|
|
1644
|
-
},
|
|
1645
|
-
function
|
|
1646
|
-
|
|
1647
|
-
t =
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1772
|
+
}, Ot = /&(colon|Tab|NewLine);/g, kt = /<\?[\s\S]*?\?>/g, At = /(<(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, jt = /(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, Mt = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, Nt = /\bon\w+\s*=/gim, Pt = new RegExp(Ct.source, "gim");
|
|
1773
|
+
function Z(e) {
|
|
1774
|
+
if (!e) return "";
|
|
1775
|
+
let t = String(e).replace(Tt, "").replace(Et, (e, t, n) => String.fromCodePoint(t ? parseInt(t, 16) : parseInt(n, 10))).replace(Ot, (e, t) => Dt[t] ?? "");
|
|
1776
|
+
if (t.indexOf("<") !== -1) {
|
|
1777
|
+
t = t.replace(kt, "");
|
|
1778
|
+
let e;
|
|
1779
|
+
do
|
|
1780
|
+
e = t, t = t.replace(At, "");
|
|
1781
|
+
while (t !== e);
|
|
1782
|
+
}
|
|
1783
|
+
return t.replace(jt, "data-unsafe-protocol:").replace(Mt, "data-unsafe-protocol:").replace(Nt, "data-unsafe-attr=").replace(Pt, "data-unsafe-css:");
|
|
1653
1784
|
}
|
|
1654
|
-
|
|
1655
|
-
|
|
1785
|
+
var Ft = (e) => e.length < 15 ? !1 : e.toLowerCase().includes("url(") && wt.test(e), It = /* @__PURE__ */ new Map();
|
|
1786
|
+
function Lt(e) {
|
|
1787
|
+
let t = It.get(e);
|
|
1788
|
+
return t === void 0 ? (t = e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e, It.set(e, t), t) : t;
|
|
1656
1789
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
let t = kt.get(e);
|
|
1662
|
-
return t === void 0 ? (t = e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e, kt.set(e, t), t) : t;
|
|
1663
|
-
}
|
|
1664
|
-
var jt = /* @__PURE__ */ new WeakMap();
|
|
1665
|
-
function Mt(e) {
|
|
1666
|
-
let t = jt.get(e);
|
|
1667
|
-
return t || (t = F(() => {
|
|
1790
|
+
var Rt = /* @__PURE__ */ new WeakMap();
|
|
1791
|
+
function zt(e) {
|
|
1792
|
+
let t = Rt.get(e);
|
|
1793
|
+
return t || (t = L(() => {
|
|
1668
1794
|
let t = e.value;
|
|
1669
|
-
return
|
|
1670
|
-
}),
|
|
1795
|
+
return De(t) ? t.then((e) => Z(e)) : Z(t);
|
|
1796
|
+
}), Rt.set(e, t)), t;
|
|
1671
1797
|
}
|
|
1672
|
-
function
|
|
1798
|
+
function Bt(e) {
|
|
1673
1799
|
return {
|
|
1674
1800
|
el: e,
|
|
1675
|
-
trackCleanup: (t) =>
|
|
1801
|
+
trackCleanup: (t) => J.trackCleanup(e, t)
|
|
1676
1802
|
};
|
|
1677
1803
|
}
|
|
1678
|
-
function
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
r.textContent !== t && (r.textContent = t);
|
|
1804
|
+
function Vt({ el: e }, t, n) {
|
|
1805
|
+
yt(e, t, (t) => {
|
|
1806
|
+
let r = n ? n(t) : String(t ?? "");
|
|
1807
|
+
e.textContent !== r && (e.textContent = r);
|
|
1683
1808
|
}, "text");
|
|
1684
1809
|
}
|
|
1685
|
-
function
|
|
1686
|
-
let n =
|
|
1687
|
-
|
|
1688
|
-
let i =
|
|
1689
|
-
|
|
1810
|
+
function Ht({ el: e }, t) {
|
|
1811
|
+
let n = ve(t) ? zt(t) : t;
|
|
1812
|
+
yt(e, n, (r) => {
|
|
1813
|
+
let i = n === t ? Z(r) : r;
|
|
1814
|
+
e.innerHTML !== i && (J.cleanupDescendants(e), e.innerHTML = i);
|
|
1690
1815
|
}, "html");
|
|
1691
1816
|
}
|
|
1692
|
-
function
|
|
1693
|
-
let n =
|
|
1694
|
-
for (let e in t)
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1817
|
+
function Ut({ el: e }, t) {
|
|
1818
|
+
let n = {};
|
|
1819
|
+
for (let e in t) if (V.call(t, e)) {
|
|
1820
|
+
let t = e.trim();
|
|
1821
|
+
n[e] = t.indexOf(" ") === -1 ? [t] : t.split(/\s+/).filter(Boolean);
|
|
1822
|
+
}
|
|
1823
|
+
bt(e, t, (t) => {
|
|
1824
|
+
for (let r in t) {
|
|
1825
|
+
let i = n[r];
|
|
1826
|
+
t[r] ? e.classList.add(...i) : e.classList.remove(...i);
|
|
1699
1827
|
}
|
|
1700
1828
|
}, "class");
|
|
1701
1829
|
}
|
|
1702
|
-
function
|
|
1703
|
-
let n = e.
|
|
1704
|
-
for (let e in t) if (
|
|
1705
|
-
let n = t[e], [
|
|
1706
|
-
|
|
1707
|
-
camel:
|
|
1830
|
+
function Wt({ el: e }, t) {
|
|
1831
|
+
let n = e.style, r = {}, i = {};
|
|
1832
|
+
for (let e in t) if (V.call(t, e)) {
|
|
1833
|
+
let n = t[e], [a, o] = Array.isArray(n) ? n : [n, ""];
|
|
1834
|
+
r[e] = a, i[e] = {
|
|
1835
|
+
camel: Lt(e),
|
|
1708
1836
|
unit: o
|
|
1709
1837
|
};
|
|
1710
1838
|
}
|
|
1711
|
-
|
|
1839
|
+
bt(e, r, (e) => {
|
|
1712
1840
|
for (let t in e) {
|
|
1713
|
-
let
|
|
1714
|
-
|
|
1841
|
+
let r = i[t], a = e[t], o = r.unit ? `${a}${r.unit}` : String(a), s = r.camel;
|
|
1842
|
+
!Ft(o) && n[s] !== o && (n[s] = o);
|
|
1715
1843
|
}
|
|
1716
1844
|
}, "css");
|
|
1717
1845
|
}
|
|
1718
|
-
function
|
|
1719
|
-
let n =
|
|
1720
|
-
for (let
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1846
|
+
function Gt({ el: e }, t) {
|
|
1847
|
+
let n = {}, r = {}, i = {};
|
|
1848
|
+
for (let a in t) {
|
|
1849
|
+
if (!V.call(t, a)) continue;
|
|
1850
|
+
let o = a.toLowerCase();
|
|
1851
|
+
if (o.startsWith("on")) {
|
|
1852
|
+
console.warn(`${H.BINDING} ${W.SECURITY.BLOCKED_EVENT_HANDLER(a)}`);
|
|
1724
1853
|
continue;
|
|
1725
1854
|
}
|
|
1726
|
-
|
|
1727
|
-
isAria:
|
|
1728
|
-
isUrl:
|
|
1729
|
-
};
|
|
1855
|
+
n[a] = t[a], r[a] = {
|
|
1856
|
+
isAria: o.startsWith("aria-"),
|
|
1857
|
+
isUrl: xt.has(o)
|
|
1858
|
+
}, i[a] = e.getAttribute(a);
|
|
1730
1859
|
}
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
if (r == null || r === !1 && !s) {
|
|
1737
|
-
a[t] !== null && (n.removeAttribute(t), a[t] = null);
|
|
1860
|
+
bt(e, n, (t) => {
|
|
1861
|
+
for (let n in t) {
|
|
1862
|
+
let a = r[n], o = t[n];
|
|
1863
|
+
if (o == null || o === !1 && !a.isAria) {
|
|
1864
|
+
i[n] !== null && e.removeAttribute(n), i[n] = null;
|
|
1738
1865
|
continue;
|
|
1739
1866
|
}
|
|
1740
|
-
let
|
|
1741
|
-
if (
|
|
1742
|
-
console.warn(`${
|
|
1867
|
+
let s = o === !0 ? a.isAria ? "true" : n : String(o);
|
|
1868
|
+
if (a.isUrl && St.test(s)) {
|
|
1869
|
+
console.warn(`${H.BINDING} ${W.SECURITY.BLOCKED_PROTOCOL(n)}`);
|
|
1743
1870
|
continue;
|
|
1744
1871
|
}
|
|
1745
|
-
|
|
1872
|
+
i[n] !== s && (e.setAttribute(n, s), i[n] = s);
|
|
1746
1873
|
}
|
|
1747
1874
|
}, "attr");
|
|
1748
1875
|
}
|
|
1749
|
-
function
|
|
1876
|
+
function Kt(e, t) {
|
|
1750
1877
|
let n = e.el, r = {}, i = {};
|
|
1751
|
-
for (let e in t)
|
|
1878
|
+
for (let e in t) {
|
|
1879
|
+
if (!V.call(t, e)) continue;
|
|
1752
1880
|
let n = e.toLowerCase();
|
|
1753
|
-
if (n.startsWith("on")) {
|
|
1754
|
-
console.warn(`${
|
|
1755
|
-
continue;
|
|
1756
|
-
}
|
|
1757
|
-
if (Fe.has(e)) {
|
|
1758
|
-
console.warn(`${B.BINDING} ${H.SECURITY.BLOCKED_PROP(e)}`);
|
|
1881
|
+
if (n.startsWith("on") || Me.has(e)) {
|
|
1882
|
+
console.warn(`${H.BINDING} ${n.startsWith("on") ? W.SECURITY.BLOCKED_EVENT_HANDLER(e) : W.SECURITY.BLOCKED_PROP(e)}`);
|
|
1759
1883
|
continue;
|
|
1760
1884
|
}
|
|
1761
|
-
r[e] = t[e], i[e] = { isUrl:
|
|
1885
|
+
r[e] = t[e], i[e] = { isUrl: xt.has(n) };
|
|
1762
1886
|
}
|
|
1763
|
-
|
|
1887
|
+
bt(e.el, r, (e) => {
|
|
1764
1888
|
for (let t in e) {
|
|
1765
1889
|
let r = e[t];
|
|
1766
|
-
if (i[t].isUrl && typeof r == "string" &&
|
|
1767
|
-
console.warn(`${
|
|
1890
|
+
if (i[t].isUrl && typeof r == "string" && St.test(r)) {
|
|
1891
|
+
console.warn(`${H.BINDING} ${W.SECURITY.BLOCKED_PROTOCOL(t)}`);
|
|
1768
1892
|
continue;
|
|
1769
1893
|
}
|
|
1770
1894
|
n[t] !== r && (n[t] = r);
|
|
1771
1895
|
}
|
|
1772
1896
|
}, "prop");
|
|
1773
1897
|
}
|
|
1774
|
-
function
|
|
1775
|
-
let r = e.
|
|
1776
|
-
|
|
1777
|
-
let
|
|
1778
|
-
|
|
1779
|
-
},
|
|
1898
|
+
function qt({ el: e }, t, n) {
|
|
1899
|
+
let r = e.style.display === "none" ? "" : e.style.display;
|
|
1900
|
+
yt(e, t, (t) => {
|
|
1901
|
+
let i = n === !!t ? "none" : r;
|
|
1902
|
+
e.style.display !== i && (e.style.display = i);
|
|
1903
|
+
}, n ? "hide" : "show");
|
|
1780
1904
|
}
|
|
1781
|
-
function
|
|
1905
|
+
function Jt(t, n, r = {}) {
|
|
1782
1906
|
let i = t.el.tagName.toLowerCase();
|
|
1783
|
-
if (!
|
|
1784
|
-
console.warn(`${
|
|
1907
|
+
if (!je.has(i)) {
|
|
1908
|
+
console.warn(`${H.BINDING} ${W.BINDING.INVALID_INPUT_ELEMENT(i)}`);
|
|
1785
1909
|
return;
|
|
1786
1910
|
}
|
|
1787
|
-
let { fx: a, cleanup: o } =
|
|
1788
|
-
|
|
1911
|
+
let { fx: a, cleanup: o } = vt(e(t.el), n, r);
|
|
1912
|
+
J.trackEffect(t.el, a), t.trackCleanup(o);
|
|
1789
1913
|
}
|
|
1790
|
-
function
|
|
1791
|
-
let r = t.el, i = e(r), a =
|
|
1792
|
-
|
|
1793
|
-
if (n.peek() !== t && (n.value = t, a && t && r.name)) {
|
|
1794
|
-
let t = r.name.replace(/"/g, "\\\"");
|
|
1795
|
-
(r.form ? e(r.form) : e(document)).find(`input[type="radio"][name="${t}"]`).not(r).trigger("change.atomRadioSync");
|
|
1796
|
-
}
|
|
1914
|
+
function Yt(t, n) {
|
|
1915
|
+
let r = t.el, i = e(r), a = () => {
|
|
1916
|
+
n.peek() !== r.checked && (n.value = r.checked, r.type === "radio" && r.checked && r.name && (r.form ? e(r.form) : e(document)).find(`input[type="radio"][name="${r.name.replace(/"/g, "\\\"")}"]`).not(r).trigger("change.atomRadioSync"));
|
|
1797
1917
|
};
|
|
1798
|
-
|
|
1799
|
-
let s = I(() => {
|
|
1918
|
+
a[ct] = !0, i.on("change change.atomRadioSync", a), t.trackCleanup(() => i.off("change change.atomRadioSync", a)), J.trackEffect(r, R(() => {
|
|
1800
1919
|
let e = !!n.value;
|
|
1801
|
-
|
|
1802
|
-
r.checked !== e && (r.checked = e,
|
|
1920
|
+
O(() => {
|
|
1921
|
+
r.checked !== e && (r.checked = e, G.enabled && G.domUpdated(H.BINDING, r, "checked", e));
|
|
1803
1922
|
});
|
|
1804
|
-
});
|
|
1805
|
-
K.trackEffect(r, s);
|
|
1923
|
+
}));
|
|
1806
1924
|
}
|
|
1807
|
-
function
|
|
1925
|
+
function Xt(t, n) {
|
|
1808
1926
|
let r = e(t.el);
|
|
1809
1927
|
r.on(n), t.trackCleanup(() => r.off(n));
|
|
1810
1928
|
}
|
|
1811
|
-
function
|
|
1812
|
-
let
|
|
1813
|
-
|
|
1929
|
+
function Zt({ el: t, trackCleanup: n }, r, i) {
|
|
1930
|
+
let a = e(t);
|
|
1931
|
+
a.on(r, i), n(() => a.off(r, i));
|
|
1814
1932
|
}
|
|
1815
|
-
function
|
|
1816
|
-
|
|
1933
|
+
function Qt(e) {
|
|
1934
|
+
J.cleanupTree(e);
|
|
1817
1935
|
}
|
|
1818
1936
|
//#endregion
|
|
1819
1937
|
//#region src/bindings/form.ts
|
|
1820
|
-
function
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
subscribe(t) {
|
|
1846
|
-
return e.subscribe(t);
|
|
1847
|
-
},
|
|
1848
|
-
subscriberCount() {
|
|
1849
|
-
return e.subscriberCount();
|
|
1850
|
-
},
|
|
1851
|
-
dispose() {},
|
|
1852
|
-
[Symbol.dispose]() {},
|
|
1853
|
-
[n]: !0,
|
|
1854
|
-
[r]: !0
|
|
1855
|
-
};
|
|
1856
|
-
}
|
|
1857
|
-
function Jt(e, t, n = {}) {
|
|
1858
|
-
let r = e.elements, i = (e) => {
|
|
1938
|
+
function $t(e, t, n = {}) {
|
|
1939
|
+
let r = /* @__PURE__ */ new Map(), i = [], a = R(() => {
|
|
1940
|
+
let e = t.value, n = i.length;
|
|
1941
|
+
n !== 0 && O(() => {
|
|
1942
|
+
for (let t = 0; t < n; t++) {
|
|
1943
|
+
let n = i[t], r = K(e, n.parts);
|
|
1944
|
+
Object.is(n.atom.peek(), r) || (n.atom.value = r);
|
|
1945
|
+
}
|
|
1946
|
+
});
|
|
1947
|
+
});
|
|
1948
|
+
J.trackEffect(e, a);
|
|
1949
|
+
let o = (n) => {
|
|
1950
|
+
let a = r.get(n);
|
|
1951
|
+
if (!a) {
|
|
1952
|
+
let o = n.includes(".") ? n.split(".") : [n];
|
|
1953
|
+
a = k(K(t.peek(), o)), i.push({
|
|
1954
|
+
atom: a,
|
|
1955
|
+
parts: o
|
|
1956
|
+
}), J.trackEffect(e, R(() => {
|
|
1957
|
+
let e = a.value, n = t.peek(), r = Ke(n, o, 0, e);
|
|
1958
|
+
r !== n && (t.value = r);
|
|
1959
|
+
})), r.set(n, a);
|
|
1960
|
+
}
|
|
1961
|
+
return a;
|
|
1962
|
+
}, s = (e) => {
|
|
1859
1963
|
if (!(e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement)) return;
|
|
1860
|
-
let
|
|
1861
|
-
if (!
|
|
1862
|
-
let
|
|
1863
|
-
e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ?
|
|
1964
|
+
let t = e.name;
|
|
1965
|
+
if (!t || J.hasBind(e)) return;
|
|
1966
|
+
let r = o(t), i = Bt(e);
|
|
1967
|
+
e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? Yt(i, r) : Jt(i, r, n);
|
|
1864
1968
|
};
|
|
1865
|
-
for (let
|
|
1866
|
-
let
|
|
1969
|
+
for (let t = 0, n = e.elements.length; t < n; t++) s(e.elements[t]);
|
|
1970
|
+
let c = new MutationObserver((e) => {
|
|
1867
1971
|
for (let t = 0, n = e.length; t < n; t++) {
|
|
1868
1972
|
let n = e[t];
|
|
1869
|
-
if (n.type === "childList") {
|
|
1870
|
-
let
|
|
1871
|
-
|
|
1872
|
-
let
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
let t = e.querySelectorAll("input, select, textarea");
|
|
1877
|
-
for (let e = 0, n = t.length; e < n; e++) i(t[e]);
|
|
1878
|
-
}
|
|
1973
|
+
if (n.type === "childList") for (let e = 0, t = n.addedNodes.length; e < t; e++) {
|
|
1974
|
+
let t = n.addedNodes[e];
|
|
1975
|
+
if (t.nodeType === 1) {
|
|
1976
|
+
let e = t;
|
|
1977
|
+
s(e);
|
|
1978
|
+
let n = e.matches?.("input, select, textarea") ? [e] : e.querySelectorAll("input, select, textarea");
|
|
1979
|
+
for (let e = 0, t = n.length; e < t; e++) s(n[e]);
|
|
1879
1980
|
}
|
|
1880
|
-
}
|
|
1981
|
+
}
|
|
1982
|
+
else n.type === "attributes" && n.attributeName === "name" && s(n.target);
|
|
1881
1983
|
}
|
|
1882
1984
|
});
|
|
1883
|
-
|
|
1985
|
+
c.observe(e, {
|
|
1884
1986
|
childList: !0,
|
|
1885
1987
|
subtree: !0,
|
|
1886
1988
|
attributes: !0,
|
|
1887
1989
|
attributeFilter: ["name"]
|
|
1888
|
-
}),
|
|
1990
|
+
}), J.trackCleanup(e, () => c.disconnect());
|
|
1889
1991
|
}
|
|
1890
1992
|
//#endregion
|
|
1891
1993
|
//#region src/bindings/chainable.ts
|
|
1892
|
-
function
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1994
|
+
function Q(e, t) {
|
|
1995
|
+
let n = e.length;
|
|
1996
|
+
for (let r = 0; r < n; r++) {
|
|
1997
|
+
let n = e[r];
|
|
1998
|
+
if (n?.nodeType === 1) {
|
|
1999
|
+
let e = n;
|
|
2000
|
+
t(Bt(e), e);
|
|
2001
|
+
} else G.enabled && n && G.log(H.BINDING, `Skipping non-Element node (nodeType=${n.nodeType})`);
|
|
1896
2002
|
}
|
|
1897
2003
|
return e;
|
|
1898
2004
|
}
|
|
1899
2005
|
e.fn.atomText = function(e, t) {
|
|
1900
|
-
return
|
|
2006
|
+
return Q(this, (n) => Vt(n, e, t));
|
|
1901
2007
|
}, e.fn.atomHtml = function(e) {
|
|
1902
|
-
return
|
|
2008
|
+
return Q(this, (t) => Ht(t, e));
|
|
1903
2009
|
}, e.fn.atomClass = function(e, t) {
|
|
1904
|
-
if (typeof e == "string"
|
|
1905
|
-
|
|
1906
|
-
|
|
2010
|
+
if (typeof e == "string") {
|
|
2011
|
+
if (t === void 0) return console.warn(`${H.BINDING} ${W.BINDING.MISSING_CONDITION("atomClass")}`), this;
|
|
2012
|
+
let n = { [e]: t };
|
|
2013
|
+
return Q(this, (e) => Ut(e, n));
|
|
2014
|
+
}
|
|
2015
|
+
return Q(this, (t) => Ut(t, e));
|
|
1907
2016
|
}, e.fn.atomCss = function(e, t, n) {
|
|
1908
|
-
if (typeof e == "string"
|
|
1909
|
-
|
|
1910
|
-
|
|
2017
|
+
if (typeof e == "string") {
|
|
2018
|
+
if (t === void 0) return console.warn(`${H.BINDING} ${W.BINDING.MISSING_SOURCE("atomCss")}`), this;
|
|
2019
|
+
let r = { [e]: n ? [t, n] : t };
|
|
2020
|
+
return Q(this, (e) => Wt(e, r));
|
|
2021
|
+
}
|
|
2022
|
+
return Q(this, (t) => Wt(t, e));
|
|
1911
2023
|
}, e.fn.atomAttr = function(e, t) {
|
|
1912
|
-
if (typeof e == "string"
|
|
1913
|
-
|
|
1914
|
-
|
|
2024
|
+
if (typeof e == "string") {
|
|
2025
|
+
if (t === void 0) return console.warn(`${H.BINDING} ${W.BINDING.MISSING_SOURCE("atomAttr")}`), this;
|
|
2026
|
+
let n = { [e]: t };
|
|
2027
|
+
return Q(this, (e) => Gt(e, n));
|
|
2028
|
+
}
|
|
2029
|
+
return Q(this, (t) => Gt(t, e));
|
|
1915
2030
|
}, e.fn.atomProp = function(e, t) {
|
|
1916
|
-
if (typeof e == "string"
|
|
1917
|
-
|
|
1918
|
-
|
|
2031
|
+
if (typeof e == "string") {
|
|
2032
|
+
if (t === void 0) return console.warn(`${H.BINDING} ${W.BINDING.MISSING_SOURCE("atomProp")}`), this;
|
|
2033
|
+
let n = { [e]: t };
|
|
2034
|
+
return Q(this, (e) => Kt(e, n));
|
|
2035
|
+
}
|
|
2036
|
+
return Q(this, (t) => Kt(t, e));
|
|
1919
2037
|
}, e.fn.atomShow = function(e) {
|
|
1920
|
-
return
|
|
2038
|
+
return Q(this, (t) => qt(t, e, !1));
|
|
1921
2039
|
}, e.fn.atomHide = function(e) {
|
|
1922
|
-
return
|
|
2040
|
+
return Q(this, (t) => qt(t, e, !0));
|
|
1923
2041
|
}, e.fn.atomVal = function(e, t = {}) {
|
|
1924
|
-
return
|
|
2042
|
+
return Q(this, (n) => Jt(n, e, t));
|
|
1925
2043
|
}, e.fn.atomChecked = function(e) {
|
|
1926
|
-
return
|
|
2044
|
+
return Q(this, (t) => Yt(t, e));
|
|
1927
2045
|
}, e.fn.atomForm = function(e, t = {}) {
|
|
1928
|
-
return
|
|
1929
|
-
r instanceof HTMLFormElement &&
|
|
2046
|
+
return Q(this, (n, r) => {
|
|
2047
|
+
r instanceof HTMLFormElement && $t(r, e, t);
|
|
1930
2048
|
});
|
|
1931
2049
|
}, e.fn.atomOn = function(e, t) {
|
|
1932
|
-
return
|
|
2050
|
+
return Q(this, (n) => Zt(n, e, t));
|
|
1933
2051
|
}, e.fn.atomBind = function(e) {
|
|
1934
2052
|
let { text: t, html: n, class: r, css: i, attr: a, prop: o, show: s, hide: c, val: l, checked: u, form: d, on: f } = e, p = l === void 0 ? null : Array.isArray(l) ? {
|
|
1935
2053
|
atom: l[0],
|
|
1936
|
-
|
|
2054
|
+
options: l[1]
|
|
1937
2055
|
} : {
|
|
1938
2056
|
atom: l,
|
|
1939
|
-
|
|
2057
|
+
options: void 0
|
|
1940
2058
|
};
|
|
1941
|
-
return
|
|
1942
|
-
t !== void 0 &&
|
|
2059
|
+
return Q(this, (e) => {
|
|
2060
|
+
t !== void 0 && Vt(e, t), n !== void 0 && Ht(e, n), r !== void 0 && Ut(e, r), i !== void 0 && Wt(e, i), a !== void 0 && Gt(e, a), o !== void 0 && Kt(e, o), s !== void 0 && qt(e, s, !1), c !== void 0 && qt(e, c, !0), p && Jt(e, p.atom, p.options), u !== void 0 && Yt(e, u), d !== void 0 && e.el instanceof HTMLFormElement && $t(e.el, d), f !== void 0 && Xt(e, f);
|
|
1943
2061
|
});
|
|
1944
2062
|
}, e.fn.atomUnbind = function() {
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2063
|
+
let e = this.length;
|
|
2064
|
+
for (let t = 0; t < e; t++) {
|
|
2065
|
+
let e = this[t];
|
|
2066
|
+
e?.nodeType === 1 && Qt(e);
|
|
1948
2067
|
}
|
|
1949
2068
|
return this;
|
|
1950
2069
|
};
|
|
1951
2070
|
//#endregion
|
|
1952
2071
|
//#region src/bindings/list.ts
|
|
1953
|
-
var
|
|
1954
|
-
function
|
|
1955
|
-
|
|
2072
|
+
var en = /* @__PURE__ */ new WeakMap(), tn = 0, nn = new $e(() => /* @__PURE__ */ new Map(), (e) => e.clear()), rn = new $e(() => /* @__PURE__ */ new Set(), (e) => e.clear()), $ = new Qe(100, 1024);
|
|
2073
|
+
function an(e, t, n) {
|
|
2074
|
+
if (e instanceof Element) {
|
|
2075
|
+
n.insertBefore(e, t);
|
|
2076
|
+
return;
|
|
2077
|
+
}
|
|
2078
|
+
let r = e.length;
|
|
2079
|
+
for (let i = 0; i < r; i++) {
|
|
2080
|
+
let r = e[i];
|
|
2081
|
+
r && n.insertBefore(r, t);
|
|
2082
|
+
}
|
|
1956
2083
|
}
|
|
1957
|
-
function
|
|
2084
|
+
function on(t) {
|
|
1958
2085
|
return t instanceof Element ? e(t) : t;
|
|
1959
2086
|
}
|
|
1960
|
-
var
|
|
2087
|
+
var sn = class {
|
|
1961
2088
|
constructor(e, t, n) {
|
|
1962
2089
|
this.$container = e, this.containerSelector = t, this.onRemove = n, this.oldKeys = [], this.oldItems = [], this.oldNodes = [], this.removingKeys = /* @__PURE__ */ new Set(), this.$emptyEl = null, this.keyToIndex = /* @__PURE__ */ new Map(), this.statesBuffer = new Uint8Array(256), this.indicesBuffer = new Int32Array(256);
|
|
1963
2090
|
}
|
|
1964
2091
|
scheduleRemoval(e, t) {
|
|
1965
2092
|
let n = () => {
|
|
1966
|
-
this.fx?.isDisposed || (t.remove(), this.removingKeys.delete(e),
|
|
1967
|
-
};
|
|
1968
|
-
if (!this.onRemove) {
|
|
1969
|
-
n();
|
|
1970
|
-
return;
|
|
1971
|
-
}
|
|
1972
|
-
let r = this.onRemove(t);
|
|
2093
|
+
this.fx?.isDisposed || (t[0]?.isConnected && t.remove(), this.removingKeys.delete(e), G.enabled && G.log(H.LIST, `${this.containerSelector} removed item:`, e));
|
|
2094
|
+
}, r = this.onRemove?.(t);
|
|
1973
2095
|
r instanceof Promise ? r.then(n, n) : n();
|
|
1974
2096
|
}
|
|
1975
2097
|
removeItem(e, t) {
|
|
1976
|
-
for (let e = 0; e < t.length; e++)
|
|
1977
|
-
let n = t[e];
|
|
1978
|
-
n instanceof Element && n.removeAttribute("data-atom-key");
|
|
1979
|
-
}
|
|
2098
|
+
for (let e = 0; e < t.length; e++) t[e] instanceof Element && t[e].removeAttribute("data-atom-key");
|
|
1980
2099
|
this.removingKeys.add(e), this.scheduleRemoval(e, t);
|
|
1981
2100
|
}
|
|
1982
2101
|
dispose() {
|
|
1983
|
-
this.removingKeys.clear(), this.oldKeys.length = 0, this.oldItems.length = 0, this.oldNodes.length = 0, this.keyToIndex.clear(), this.$emptyEl?.remove(), this.$container.off(".atomList");
|
|
1984
|
-
let e = new Uint8Array(), t = new Int32Array();
|
|
1985
|
-
this.statesBuffer = e, this.indicesBuffer = t;
|
|
2102
|
+
this.removingKeys.clear(), this.oldKeys.length = 0, this.oldItems.length = 0, this.oldNodes.length = 0, this.keyToIndex.clear(), this.$emptyEl?.remove(), this.$container.off(".atomList"), this.statesBuffer = new Uint8Array(), this.indicesBuffer = new Int32Array();
|
|
1986
2103
|
}
|
|
1987
2104
|
ensureBuffers(e) {
|
|
1988
2105
|
this.statesBuffer.length < e && (this.statesBuffer = new Uint8Array(Math.max(e, this.statesBuffer.length * 2))), this.indicesBuffer.length < e && (this.indicesBuffer = new Int32Array(Math.max(e, this.indicesBuffer.length * 2)));
|
|
1989
2106
|
}
|
|
1990
2107
|
};
|
|
1991
|
-
function
|
|
2108
|
+
function cn(t, n, r, i) {
|
|
1992
2109
|
if (t.$emptyEl && n > 0 && (t.$emptyEl.remove(), t.$emptyEl = null), n !== 0) return;
|
|
1993
2110
|
let { oldKeys: a, oldNodes: o, onRemove: s } = t;
|
|
1994
2111
|
if (s) for (let e = 0, n = a.length; e < n; e++) {
|
|
1995
|
-
let n = a[e]
|
|
1996
|
-
|
|
2112
|
+
let n = a[e];
|
|
2113
|
+
o[e] && t.removeItem(n, on(o[e]));
|
|
1997
2114
|
}
|
|
1998
2115
|
else {
|
|
1999
2116
|
for (let e = 0, n = a.length; e < n; e++) t.removingKeys.delete(a[e]);
|
|
2000
2117
|
r.empty();
|
|
2001
2118
|
}
|
|
2002
|
-
i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ?
|
|
2119
|
+
i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ? Z(i) : i), t.$emptyEl.appendTo(r)), $.release(t.oldKeys), $.release(t.oldItems), $.release(t.oldNodes), t.oldKeys = [], t.oldItems = [], t.oldNodes = [];
|
|
2003
2120
|
}
|
|
2004
|
-
function
|
|
2005
|
-
let { oldKeys: o, oldItems: s, oldNodes: c, removingKeys: l, keyToIndex: u } = e, d = o.length, f = 0, p = d - 1, m = n - 1;
|
|
2121
|
+
function ln(e, t, n, r, i, a) {
|
|
2122
|
+
let { oldKeys: o, oldItems: s, oldNodes: c, removingKeys: l, keyToIndex: u } = e, d = o.length, f = 0, p = d - 1, m = n - 1, h = a || Oe;
|
|
2006
2123
|
for (; f <= p && f <= m;) {
|
|
2007
2124
|
let e = t[f], n = r(e, f);
|
|
2008
|
-
if (o[f] !== n) break;
|
|
2009
|
-
|
|
2010
|
-
if (!(a ? a(i, e) : je(i, e))) break;
|
|
2011
|
-
u.set(n, f), f++;
|
|
2125
|
+
if (o[f] !== n || !h(s[f], e)) break;
|
|
2126
|
+
u.set(n, f++);
|
|
2012
2127
|
}
|
|
2013
2128
|
for (; p >= f && m >= f;) {
|
|
2014
2129
|
let e = t[m], n = r(e, m);
|
|
2015
|
-
if (o[p] !== n) break;
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
let
|
|
2021
|
-
for (let e = f; e <= p; e++) h.set(o[e], e);
|
|
2022
|
-
let g = Q.acquire();
|
|
2023
|
-
g.length = n;
|
|
2024
|
-
let _ = Qt.acquire();
|
|
2130
|
+
if (o[p] !== n || !h(s[p], e)) break;
|
|
2131
|
+
u.set(n, m--), p--;
|
|
2132
|
+
}
|
|
2133
|
+
let g = nn.acquire();
|
|
2134
|
+
for (let e = f; e <= p; e++) g.set(o[e], e);
|
|
2135
|
+
let _ = rn.acquire();
|
|
2025
2136
|
e.ensureBuffers(n);
|
|
2026
|
-
let v =
|
|
2137
|
+
let v = $.acquire();
|
|
2027
2138
|
v.length = n;
|
|
2028
|
-
let y =
|
|
2139
|
+
let y = $.acquire();
|
|
2029
2140
|
y.length = n;
|
|
2030
|
-
let b =
|
|
2031
|
-
|
|
2032
|
-
|
|
2141
|
+
let b = $.acquire();
|
|
2142
|
+
b.length = n;
|
|
2143
|
+
let x = e.statesBuffer, S = e.indicesBuffer, C = $.acquire(), ee = $.acquire(), w = $.acquire();
|
|
2144
|
+
for (let e = 0; e < f; e++) v[e] = o[e], y[e] = t[e], b[e] = c[e], x[e] = 3, S[e] = e;
|
|
2145
|
+
for (let e = d - 1, r = n - 1; r > m; r--, e--) v[r] = o[e], y[r] = t[r], b[r] = c[e], x[r] = 3, S[r] = e;
|
|
2033
2146
|
for (let n = f; n <= m; n++) {
|
|
2034
2147
|
let o = t[n], d = r(o, n);
|
|
2035
|
-
if (
|
|
2036
|
-
|
|
2148
|
+
if (v[n] = d, y[n] = o, u.set(d, n), _.has(d)) {
|
|
2149
|
+
G.warn(H.LIST, W.LIST.DUPLICATE_KEY(d, n, e.containerSelector)), S[n] = -1;
|
|
2037
2150
|
continue;
|
|
2038
2151
|
}
|
|
2039
2152
|
_.add(d);
|
|
2040
|
-
let f =
|
|
2153
|
+
let f = g.get(d);
|
|
2041
2154
|
if (f === void 0) {
|
|
2042
|
-
|
|
2155
|
+
C.push(d), ee.push(o), w.push(n), S[n] = -1, x[n] = 1;
|
|
2043
2156
|
continue;
|
|
2044
2157
|
}
|
|
2045
2158
|
let p = s[f];
|
|
2046
|
-
|
|
2047
|
-
let m = a ? a(p, o) : je(p, o);
|
|
2048
|
-
!i && p !== o && !m ? (S.push(d), C.push(o), ee.push(n), b[n] = 2) : b[n] = 0, x[n] = l.has(d) ? -1 : f;
|
|
2159
|
+
b[n] = c[f], !i && p !== o && !(a ? a(p, o) : Oe(p, o)) ? (C.push(d), ee.push(o), w.push(n), x[n] = 2) : x[n] = 0, S[n] = l.has(d) ? -1 : f;
|
|
2049
2160
|
}
|
|
2050
|
-
return
|
|
2051
|
-
newKeys:
|
|
2161
|
+
return nn.release(g), {
|
|
2162
|
+
newKeys: v,
|
|
2052
2163
|
newKeySet: _,
|
|
2053
|
-
newItems:
|
|
2054
|
-
newNodes:
|
|
2055
|
-
newStates:
|
|
2056
|
-
newIndices:
|
|
2057
|
-
trKeys:
|
|
2058
|
-
trItems:
|
|
2059
|
-
trIdxs:
|
|
2164
|
+
newItems: y,
|
|
2165
|
+
newNodes: b,
|
|
2166
|
+
newStates: x,
|
|
2167
|
+
newIndices: S,
|
|
2168
|
+
trKeys: C,
|
|
2169
|
+
trItems: ee,
|
|
2170
|
+
trIdxs: w,
|
|
2060
2171
|
startIndex: f,
|
|
2061
2172
|
oldEndIndex: p,
|
|
2062
2173
|
newEndIndex: m
|
|
2063
2174
|
};
|
|
2064
2175
|
}
|
|
2065
|
-
function
|
|
2066
|
-
let { trKeys: i, trItems: a, trIdxs: o, newNodes: s, newStates: c } = t, l = i.length, u =
|
|
2176
|
+
function un(t, n, r) {
|
|
2177
|
+
let { trKeys: i, trItems: a, trIdxs: o, newNodes: s, newStates: c } = t, l = i.length, u = Array(l), d = [], f = 0;
|
|
2067
2178
|
for (let e = 0; e < l; e++) {
|
|
2068
|
-
let t =
|
|
2069
|
-
|
|
2179
|
+
let t = n.render(a[e], o[e]);
|
|
2180
|
+
u[e] = t, typeof t == "string" && (d.push(t), f++);
|
|
2070
2181
|
}
|
|
2071
|
-
let
|
|
2072
|
-
if (
|
|
2182
|
+
let p = null;
|
|
2183
|
+
if (d.length > 0) if (d.length === 1) p = [Z(d[0])];
|
|
2073
2184
|
else {
|
|
2074
|
-
let e = `<template data-atom-sep="${(
|
|
2075
|
-
|
|
2185
|
+
let e = `<template data-atom-sep="${(tn++).toString(36)}"></template>`;
|
|
2186
|
+
p = Z(d.join(e)).split(e);
|
|
2076
2187
|
}
|
|
2077
|
-
if (r &&
|
|
2078
|
-
let
|
|
2188
|
+
if (r && p && f === l && !n.bind && !n.onAdd && !n.onRemove && !n.events) return p;
|
|
2189
|
+
let m = 0;
|
|
2079
2190
|
for (let t = 0; t < l; t++) {
|
|
2080
|
-
let n =
|
|
2191
|
+
let n = u[t], r = e(typeof n == "string" ? p[m++] : n), a = o[t], l = String(i[t]);
|
|
2081
2192
|
for (let e = 0, t = r.length; e < t; e++) {
|
|
2082
2193
|
let t = r[e];
|
|
2083
|
-
t instanceof Element && t.setAttribute("data-atom-key",
|
|
2194
|
+
t instanceof Element && t.setAttribute("data-atom-key", l);
|
|
2084
2195
|
}
|
|
2085
|
-
if (
|
|
2196
|
+
if (c[a] === 2 && s[a]) {
|
|
2086
2197
|
let e = s[a];
|
|
2087
|
-
if (e)
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
n && K.cleanupTree(n);
|
|
2092
|
-
}
|
|
2093
|
-
t.replaceWith(r);
|
|
2198
|
+
if (e instanceof Element) J.cleanupTree(e);
|
|
2199
|
+
else for (let t = 0, n = e.length; t < n; t++) {
|
|
2200
|
+
let n = e[t];
|
|
2201
|
+
n instanceof Element && J.cleanupTree(n);
|
|
2094
2202
|
}
|
|
2203
|
+
on(e).replaceWith(r);
|
|
2095
2204
|
}
|
|
2096
2205
|
s[a] = r.length === 1 ? r[0] : r;
|
|
2097
2206
|
}
|
|
2098
2207
|
return null;
|
|
2099
2208
|
}
|
|
2100
|
-
function
|
|
2101
|
-
let { startIndex: n, oldEndIndex: r, newKeySet: i } = t
|
|
2209
|
+
function dn(e, t) {
|
|
2210
|
+
let { startIndex: n, oldEndIndex: r, newKeySet: i } = t;
|
|
2102
2211
|
for (let t = n; t <= r; t++) {
|
|
2103
|
-
let n =
|
|
2104
|
-
|
|
2105
|
-
let r = o[t];
|
|
2106
|
-
r && e.removeItem(n, $(r));
|
|
2212
|
+
let n = e.oldKeys[t];
|
|
2213
|
+
!i.has(n) && e.oldNodes[t] && e.removeItem(n, on(e.oldNodes[t]));
|
|
2107
2214
|
}
|
|
2108
2215
|
}
|
|
2109
|
-
function
|
|
2110
|
-
let {
|
|
2111
|
-
if (
|
|
2112
|
-
r.innerHTML =
|
|
2216
|
+
function fn(t, n, r, i, a) {
|
|
2217
|
+
let { newKeys: o, newItems: s, newNodes: c, newStates: l, newIndices: u } = n, d = o.length;
|
|
2218
|
+
if (a !== null) {
|
|
2219
|
+
r.innerHTML = a.join("");
|
|
2113
2220
|
let n = r.firstElementChild;
|
|
2114
|
-
for (let r = 0; r <
|
|
2115
|
-
let i = u[r];
|
|
2116
|
-
n.setAttribute("data-atom-key", String(i)), f[r] = n, p[r] = 0, t.removingKeys.delete(i), U.enabled && U.domUpdated(B.LIST, e(n), "list.add", d[r]), n = n.nextElementSibling;
|
|
2117
|
-
}
|
|
2221
|
+
for (let r = 0; r < d && n; r++) n.setAttribute("data-atom-key", String(o[r])), c[r] = n, l[r] = 0, t.removingKeys.delete(o[r]), G.enabled && G.domUpdated(H.LIST, e(n), "list.add", s[r]), n = n.nextElementSibling;
|
|
2118
2222
|
return;
|
|
2119
2223
|
}
|
|
2120
|
-
if (
|
|
2224
|
+
if (t.oldKeys.length === 0) {
|
|
2121
2225
|
let e = document.createDocumentFragment();
|
|
2122
|
-
for (let t = 0; t <
|
|
2123
|
-
let n =
|
|
2226
|
+
for (let t = 0; t < d; t++) {
|
|
2227
|
+
let n = c[t];
|
|
2124
2228
|
if (n instanceof Element) e.appendChild(n);
|
|
2125
2229
|
else for (let t = 0; t < n.length; t++) e.appendChild(n[t]);
|
|
2126
2230
|
}
|
|
2127
2231
|
r.appendChild(e);
|
|
2128
2232
|
} else {
|
|
2129
2233
|
let e = null, t = 2147483647;
|
|
2130
|
-
for (let n =
|
|
2131
|
-
let
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
t.removingKeys.delete(n), U.enabled && U.domUpdated(B.LIST, i, "list.add", d[e]);
|
|
2143
|
-
}
|
|
2234
|
+
for (let n = d - 1; n >= 0; n--) {
|
|
2235
|
+
let i = u[n];
|
|
2236
|
+
i !== -1 && i < t ? t = i : an(c[n], e, r);
|
|
2237
|
+
let a = c[n];
|
|
2238
|
+
e = a instanceof Element ? a : a[0] ?? null;
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
for (let e = 0; e < d; e++) {
|
|
2242
|
+
let n = l[e];
|
|
2243
|
+
if (n !== 3) {
|
|
2244
|
+
let r = on(c[e]), a = s[e];
|
|
2245
|
+
n === 0 ? i.update?.(r, a, e) : i.bind?.(r, a, e), n === 1 && (i.onAdd?.(r), t.removingKeys.delete(o[e]), G.enabled && G.domUpdated(H.LIST, r, "list.add", a));
|
|
2144
2246
|
}
|
|
2145
2247
|
}
|
|
2146
2248
|
}
|
|
2147
2249
|
e.fn.atomList = function(t, n) {
|
|
2148
|
-
let
|
|
2149
|
-
bind:
|
|
2150
|
-
update:
|
|
2151
|
-
onAdd:
|
|
2152
|
-
onRemove:
|
|
2153
|
-
events:
|
|
2250
|
+
let r = typeof n.key == "function" ? n.key : (e) => e[n.key], i = {
|
|
2251
|
+
bind: n.bind,
|
|
2252
|
+
update: n.update,
|
|
2253
|
+
onAdd: n.onAdd,
|
|
2254
|
+
onRemove: n.onRemove,
|
|
2255
|
+
events: n.events
|
|
2154
2256
|
};
|
|
2155
|
-
for (let
|
|
2156
|
-
let
|
|
2157
|
-
|
|
2158
|
-
let
|
|
2159
|
-
|
|
2160
|
-
let
|
|
2161
|
-
let e = t.value,
|
|
2162
|
-
|
|
2163
|
-
if (
|
|
2164
|
-
|
|
2165
|
-
let t =
|
|
2166
|
-
if (
|
|
2167
|
-
|
|
2168
|
-
for (let t = e; t <= n; t++) {
|
|
2169
|
-
let e = h.oldKeys[t];
|
|
2170
|
-
r.has(e) || h.keyToIndex.delete(e);
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
Q.release(h.oldKeys), Q.release(h.oldItems), Q.release(h.oldNodes), h.oldKeys = t.newKeys, h.oldItems = t.newItems, h.oldNodes = t.newNodes, Qt.release(t.newKeySet), Q.release(t.trKeys), Q.release(t.trItems), Q.release(t.trIdxs);
|
|
2257
|
+
for (let a = 0, o = this.length; a < o; a++) {
|
|
2258
|
+
let o = this[a], s = e(o);
|
|
2259
|
+
s.off(".atomList");
|
|
2260
|
+
let c = en.get(o);
|
|
2261
|
+
c && (c.fx.dispose(), c.ctx.dispose());
|
|
2262
|
+
let l = new sn(s, B(o), n.onRemove), u = R(() => {
|
|
2263
|
+
let e = t.value, a = e.length;
|
|
2264
|
+
O(() => {
|
|
2265
|
+
if (cn(l, a, s, n.empty), a === 0) return;
|
|
2266
|
+
G.enabled && G.log(H.LIST, `${l.containerSelector} updating with ${a} items`);
|
|
2267
|
+
let t = ln(l, e, a, r, n.update, n.isEqual), c = un(t, n, l.oldKeys.length === 0);
|
|
2268
|
+
if (dn(l, t), fn(l, t, o, i, c), n.events) for (let e = t.startIndex; e <= t.oldEndIndex; e++) t.newKeySet.has(l.oldKeys[e]) || l.keyToIndex.delete(l.oldKeys[e]);
|
|
2269
|
+
$.release(l.oldKeys), $.release(l.oldItems), $.release(l.oldNodes), l.oldKeys = t.newKeys, l.oldItems = t.newItems, l.oldNodes = t.newNodes, rn.release(t.newKeySet), $.release(t.trKeys), $.release(t.trItems), $.release(t.trIdxs);
|
|
2174
2270
|
});
|
|
2175
2271
|
});
|
|
2176
|
-
if (
|
|
2177
|
-
if (!
|
|
2178
|
-
let t =
|
|
2179
|
-
|
|
2180
|
-
let
|
|
2181
|
-
if (
|
|
2182
|
-
let r = n
|
|
2183
|
-
if (
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
let e = Number(r);
|
|
2187
|
-
!Number.isNaN(e) && h.keyToIndex.has(e) && (i = e);
|
|
2272
|
+
if (l.fx = u, n.events) for (let e in n.events) {
|
|
2273
|
+
if (!V.call(n.events, e)) continue;
|
|
2274
|
+
let t = e.indexOf(" "), r = t === -1 ? e : e.slice(0, t), i = t === -1 ? "> *" : e.slice(t + 1).trim(), a = n.events[e];
|
|
2275
|
+
s.on(`${r}.atomList`, i, function(e) {
|
|
2276
|
+
let t = e.target.closest?.("[data-atom-key]"), n = t?.getAttribute("data-atom-key");
|
|
2277
|
+
if (n == null) return;
|
|
2278
|
+
let r = n;
|
|
2279
|
+
if (!l.keyToIndex.has(n)) {
|
|
2280
|
+
let e = Number(n);
|
|
2281
|
+
!Number.isNaN(e) && l.keyToIndex.has(e) && (r = e);
|
|
2188
2282
|
}
|
|
2189
|
-
let
|
|
2190
|
-
|
|
2283
|
+
let i = l.keyToIndex.get(r);
|
|
2284
|
+
i !== void 0 && a.call(t, l.oldItems[i], i, e);
|
|
2191
2285
|
});
|
|
2192
2286
|
}
|
|
2193
|
-
|
|
2194
|
-
fx:
|
|
2195
|
-
ctx:
|
|
2196
|
-
}),
|
|
2197
|
-
|
|
2287
|
+
J.trackEffect(o, u), en.set(o, {
|
|
2288
|
+
fx: u,
|
|
2289
|
+
ctx: l
|
|
2290
|
+
}), J.trackCleanup(o, () => {
|
|
2291
|
+
l.dispose(), en.delete(o);
|
|
2198
2292
|
});
|
|
2199
2293
|
}
|
|
2200
2294
|
return this;
|
|
2201
2295
|
};
|
|
2202
2296
|
//#endregion
|
|
2203
2297
|
//#region src/bindings/mount.ts
|
|
2204
|
-
var
|
|
2298
|
+
var pn = Object.freeze({});
|
|
2205
2299
|
e.fn.atomMount = function(t, n) {
|
|
2206
|
-
let r = n ??
|
|
2207
|
-
for (let n = 0,
|
|
2208
|
-
let
|
|
2209
|
-
if (
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2300
|
+
let r = n ?? pn, i = t.name || "Component";
|
|
2301
|
+
for (let n = 0, a = this.length; n < a; n++) {
|
|
2302
|
+
let a = this[n];
|
|
2303
|
+
if (a) {
|
|
2304
|
+
J.cleanupTree(a);
|
|
2305
|
+
try {
|
|
2306
|
+
let n = O(() => t(e(a), r));
|
|
2307
|
+
typeof n == "function" && J.setComponentCleanup(a, n);
|
|
2308
|
+
} catch (e) {
|
|
2309
|
+
G.error(H.MOUNT, W.MOUNT.ERROR(i), e);
|
|
2310
|
+
}
|
|
2217
2311
|
}
|
|
2218
|
-
typeof o == "function" && K.setComponentCleanup(i, o);
|
|
2219
2312
|
}
|
|
2220
2313
|
return this;
|
|
2221
2314
|
}, e.fn.atomUnmount = function() {
|
|
2222
2315
|
for (let e = 0, t = this.length; e < t; e++) {
|
|
2223
2316
|
let t = this[e];
|
|
2224
|
-
t &&
|
|
2317
|
+
t && Qt(t);
|
|
2225
2318
|
}
|
|
2226
2319
|
return this;
|
|
2227
2320
|
};
|
|
2228
2321
|
//#endregion
|
|
2229
2322
|
//#region src/features/route.ts
|
|
2230
|
-
function
|
|
2323
|
+
function mn(e, t) {
|
|
2231
2324
|
try {
|
|
2232
|
-
|
|
2325
|
+
history.pushState(e, "", t);
|
|
2233
2326
|
} catch (e) {
|
|
2234
|
-
|
|
2327
|
+
G.warn(H.ROUTE, "PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.", e);
|
|
2235
2328
|
}
|
|
2236
2329
|
}
|
|
2237
|
-
var
|
|
2330
|
+
var hn = class {
|
|
2238
2331
|
constructor(t) {
|
|
2239
2332
|
this.isDestroyed = !1, this.previousRoute = "", this.cleanups = [], this.templateCache = /* @__PURE__ */ new Map(), this.routeCleanups = [], this.lastRawQuery = "", this.cachedParams = {}, this.config = {
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
}, this.isHistoryMode = this.config.mode === "history", this
|
|
2333
|
+
mode: U.mode,
|
|
2334
|
+
basePath: U.basePath,
|
|
2335
|
+
autoBindLinks: U.autoBindLinks,
|
|
2336
|
+
activeClass: U.activeClass,
|
|
2337
|
+
...t
|
|
2338
|
+
}, this.isHistoryMode = this.config.mode === "history", this.basePath = this.config.basePath.replace(/\/$/, ""), this.activeClass = this.config.activeClass, this.$target = e(this.config.target), this.previousUrl = this.isHistoryMode ? location.pathname + location.search : location.hash, this.currentRouteAtom = k(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = k(this.getQueryParams()), this.queryParams = L(() => this.queryParamsAtom.value), this.init();
|
|
2246
2339
|
}
|
|
2247
2340
|
init() {
|
|
2248
|
-
let e = this.isHistoryMode ? "popstate" : "hashchange";
|
|
2249
|
-
window.addEventListener(e,
|
|
2250
|
-
let
|
|
2341
|
+
let e = this.isHistoryMode ? "popstate" : "hashchange", t = this.handleUrlChange.bind(this);
|
|
2342
|
+
window.addEventListener(e, t), this.cleanups.push(() => window.removeEventListener(e, t));
|
|
2343
|
+
let n = R(() => {
|
|
2251
2344
|
let e = this.currentRouteAtom.value;
|
|
2252
|
-
|
|
2253
|
-
let e
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
U.warn(B.ROUTE, "Cleanup error during route transition:", e);
|
|
2258
|
-
}
|
|
2259
|
-
e.length = 0;
|
|
2345
|
+
O(() => {
|
|
2346
|
+
for (let e of this.routeCleanups) try {
|
|
2347
|
+
e();
|
|
2348
|
+
} catch {}
|
|
2349
|
+
this.routeCleanups.length = 0;
|
|
2260
2350
|
}), this.renderRoute(e);
|
|
2261
2351
|
});
|
|
2262
|
-
this.cleanups.push(() =>
|
|
2352
|
+
this.cleanups.push(() => n.dispose()), this.setupAutoBindLinks(), this.$target[0] && J.trackCleanup(this.$target[0], () => this.destroy());
|
|
2263
2353
|
}
|
|
2264
2354
|
getRouteName() {
|
|
2265
|
-
let e = this.config
|
|
2355
|
+
let { default: e } = this.config;
|
|
2266
2356
|
if (this.isHistoryMode) {
|
|
2267
|
-
let t =
|
|
2268
|
-
return
|
|
2357
|
+
let t = this.basePath, n = location.pathname;
|
|
2358
|
+
return t && n.startsWith(t) && (n = n.substring(t.length)), n.replace(/^\//, "") || e;
|
|
2269
2359
|
}
|
|
2270
|
-
|
|
2271
|
-
if (t.length <= 1) return e;
|
|
2272
|
-
let n = t.indexOf("?");
|
|
2273
|
-
return (n === -1 ? t.substring(1) : t.substring(1, n)) || e;
|
|
2360
|
+
return location.hash.split("?")[0].substring(1) || e;
|
|
2274
2361
|
}
|
|
2275
2362
|
getQueryParams() {
|
|
2276
|
-
let e = "";
|
|
2277
|
-
if (this.
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
if (e === this.lastRawQuery) return this.cachedParams;
|
|
2283
|
-
let t = {};
|
|
2284
|
-
e && new URLSearchParams(e).forEach((e, n) => {
|
|
2285
|
-
t[n] = e;
|
|
2363
|
+
let e = location.hash, t = e.indexOf("?"), n = this.isHistoryMode ? location.search.substring(1) : t === -1 ? "" : e.substring(t + 1);
|
|
2364
|
+
if (n === this.lastRawQuery) return this.cachedParams;
|
|
2365
|
+
this.lastRawQuery = n;
|
|
2366
|
+
let r = {}, i = 0;
|
|
2367
|
+
n && new URLSearchParams(n).forEach((e, t) => {
|
|
2368
|
+
r[t] = e, i++;
|
|
2286
2369
|
});
|
|
2287
|
-
let
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
if (r[
|
|
2292
|
-
|
|
2370
|
+
let a = 0;
|
|
2371
|
+
for (let e in this.cachedParams) a++;
|
|
2372
|
+
let o = i !== a;
|
|
2373
|
+
if (!o) {
|
|
2374
|
+
for (let e in r) if (r[e] !== this.cachedParams[e]) {
|
|
2375
|
+
o = !0;
|
|
2293
2376
|
break;
|
|
2294
2377
|
}
|
|
2295
2378
|
}
|
|
2296
|
-
return
|
|
2379
|
+
return o && (n.indexOf("%"), this.cachedParams = r), this.cachedParams;
|
|
2297
2380
|
}
|
|
2298
2381
|
setUrl(e) {
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
cn(null, t), this.previousUrl = t;
|
|
2302
|
-
} else {
|
|
2303
|
-
let t = `#${e}`;
|
|
2304
|
-
window.location.hash = t, this.previousUrl = t;
|
|
2305
|
-
}
|
|
2382
|
+
let t = this.isHistoryMode ? `${this.basePath}/${e}` : `#${e}`;
|
|
2383
|
+
this.isHistoryMode ? mn(null, t) : location.hash = t, this.previousUrl = this.isHistoryMode ? t : location.hash;
|
|
2306
2384
|
}
|
|
2307
2385
|
restoreUrl() {
|
|
2308
|
-
this.isHistoryMode ?
|
|
2309
|
-
}
|
|
2310
|
-
getCurrentUrl() {
|
|
2311
|
-
return this.isHistoryMode ? window.location.pathname + window.location.search : window.location.hash;
|
|
2312
|
-
}
|
|
2313
|
-
getRouteConfig(e) {
|
|
2314
|
-
let { routes: t, notFound: n } = this.config, r = t[e];
|
|
2315
|
-
return !r && n && (r = t[n]), r || (U.warn(B.ROUTE, H.ROUTE.NOT_FOUND(e)), null);
|
|
2316
|
-
}
|
|
2317
|
-
renderTemplate(e) {
|
|
2318
|
-
let t = this.templateCache.get(e);
|
|
2319
|
-
if (!t) {
|
|
2320
|
-
let n = document.querySelector(e);
|
|
2321
|
-
if (!n || !(n instanceof HTMLTemplateElement)) return U.warn(B.ROUTE, H.ROUTE.TEMPLATE_NOT_FOUND(e)), !1;
|
|
2322
|
-
t = n, this.templateCache.set(e, t);
|
|
2323
|
-
}
|
|
2324
|
-
let n = t.content.cloneNode(!0);
|
|
2325
|
-
return this.$target.append(n), !0;
|
|
2386
|
+
this.isHistoryMode ? mn(null, this.previousUrl) : location.hash = this.previousUrl;
|
|
2326
2387
|
}
|
|
2327
2388
|
renderRoute(e) {
|
|
2328
|
-
if (this.isDestroyed) return;
|
|
2329
|
-
let t = this
|
|
2330
|
-
if (!
|
|
2331
|
-
|
|
2389
|
+
if (this.isDestroyed || !this.$target[0]) return;
|
|
2390
|
+
let { routes: t, notFound: n, beforeTransition: r, afterTransition: i } = this.config, a = t[e] ?? (n ? t[n] : void 0);
|
|
2391
|
+
if (!a) {
|
|
2392
|
+
G.warn(H.ROUTE, W.ROUTE.NOT_FOUND(e));
|
|
2332
2393
|
return;
|
|
2333
2394
|
}
|
|
2334
|
-
let
|
|
2335
|
-
|
|
2336
|
-
let
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
e !== void 0 && (s = {
|
|
2342
|
-
...r,
|
|
2395
|
+
let o = this.getQueryParams(), s = this.previousRoute;
|
|
2396
|
+
r && O(() => r(s, e)), this.$target.empty();
|
|
2397
|
+
let c = o;
|
|
2398
|
+
if (a.onEnter) {
|
|
2399
|
+
let e = O(() => a.onEnter(o, this));
|
|
2400
|
+
e && (c = {
|
|
2401
|
+
...o,
|
|
2343
2402
|
...e
|
|
2344
2403
|
});
|
|
2345
2404
|
}
|
|
2346
|
-
let l = (e) =>
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2405
|
+
let l = (e) => this.routeCleanups.push(e);
|
|
2406
|
+
if (a.render) a.render(this.$target[0], e, c, l, this);
|
|
2407
|
+
else if (a.template) {
|
|
2408
|
+
let e = this.templateCache.get(a.template);
|
|
2409
|
+
if (!e) {
|
|
2410
|
+
let t = document.querySelector(a.template);
|
|
2411
|
+
if (t instanceof HTMLTemplateElement) e = t, this.templateCache.set(a.template, e);
|
|
2412
|
+
else {
|
|
2413
|
+
G.warn(H.ROUTE, W.ROUTE.TEMPLATE_NOT_FOUND(a.template));
|
|
2414
|
+
return;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
this.$target.append(e.content.cloneNode(!0)), a.onMount && a.onMount(this.$target.children(), l, this);
|
|
2418
|
+
}
|
|
2419
|
+
i && O(() => i(s, e)), this.previousRoute = e;
|
|
2350
2420
|
}
|
|
2351
2421
|
handleUrlChange() {
|
|
2352
2422
|
if (this.isDestroyed) return;
|
|
2353
|
-
let e = this.
|
|
2423
|
+
let e = this.isHistoryMode ? location.pathname + location.search : location.hash;
|
|
2354
2424
|
if (e === this.previousUrl) return;
|
|
2355
|
-
let t = this.getRouteName(), n = this.currentRouteAtom.peek()
|
|
2425
|
+
let t = this.getRouteName(), n = this.currentRouteAtom.peek();
|
|
2356
2426
|
if (n !== t) {
|
|
2357
|
-
|
|
2358
|
-
if (e?.onLeave && D(() => e.onLeave(this)) === !1) {
|
|
2427
|
+
if (O(() => this.config.routes[n]?.onLeave?.(this)) === !1) {
|
|
2359
2428
|
this.restoreUrl();
|
|
2360
2429
|
return;
|
|
2361
2430
|
}
|
|
2362
|
-
this.currentRouteAtom.value = t
|
|
2363
|
-
}
|
|
2364
|
-
this.previousUrl = e;
|
|
2431
|
+
this.currentRouteAtom.value = t;
|
|
2432
|
+
}
|
|
2433
|
+
this.queryParamsAtom.value = this.getQueryParams(), this.previousUrl = e;
|
|
2365
2434
|
}
|
|
2366
2435
|
setupAutoBindLinks() {
|
|
2367
2436
|
if (!this.config.autoBindLinks) return;
|
|
@@ -2370,123 +2439,122 @@ var ln = class {
|
|
|
2370
2439
|
let t = e.currentTarget.dataset.route;
|
|
2371
2440
|
t != null && this.navigate(t);
|
|
2372
2441
|
};
|
|
2373
|
-
e(document).on("click", "[data-route]", t), this.cleanups.push(() =>
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
t.classList.remove(n), t.removeAttribute("aria-current");
|
|
2442
|
+
e(document).on("click", "[data-route]", t), this.cleanups.push(() => e(document).off("click", "[data-route]", t));
|
|
2443
|
+
let n = [], r = R(() => {
|
|
2444
|
+
let e = this.currentRouteAtom.value, t = this.activeClass;
|
|
2445
|
+
O(() => {
|
|
2446
|
+
let r = n.length;
|
|
2447
|
+
for (let e = 0; e < r; e++) {
|
|
2448
|
+
let r = n[e];
|
|
2449
|
+
r.classList.remove(t), r.removeAttribute("aria-current");
|
|
2382
2450
|
}
|
|
2383
2451
|
try {
|
|
2384
|
-
let
|
|
2452
|
+
let r = `[data-route="${e.replace(/"/g, "\\\"")}"]`, i = Array.from(document.querySelectorAll(r)), a = i.length;
|
|
2385
2453
|
for (let e = 0; e < a; e++) {
|
|
2386
|
-
let
|
|
2387
|
-
|
|
2454
|
+
let n = i[e];
|
|
2455
|
+
n.classList.add(t), n.setAttribute("aria-current", "page");
|
|
2388
2456
|
}
|
|
2389
|
-
|
|
2457
|
+
n = i;
|
|
2390
2458
|
} catch {
|
|
2391
|
-
|
|
2459
|
+
n = [];
|
|
2392
2460
|
}
|
|
2393
2461
|
});
|
|
2394
2462
|
});
|
|
2395
|
-
this.cleanups.push(() =>
|
|
2463
|
+
this.cleanups.push(() => r.dispose());
|
|
2396
2464
|
}
|
|
2397
2465
|
navigate(e) {
|
|
2398
2466
|
if (this.isDestroyed) return;
|
|
2399
|
-
let t = this.currentRouteAtom.peek()
|
|
2400
|
-
if (
|
|
2401
|
-
let
|
|
2402
|
-
|
|
2403
|
-
U.warn(B.ROUTE, "navigate() called with empty routeName and no default configured.");
|
|
2404
|
-
return;
|
|
2405
|
-
}
|
|
2406
|
-
this.setUrl(r), this.queryParamsAtom.value = {}, this.currentRouteAtom.value = r;
|
|
2467
|
+
let t = this.currentRouteAtom.peek();
|
|
2468
|
+
if (this.config.routes[t]?.onLeave?.(this) === !1) return;
|
|
2469
|
+
let n = e || this.config.default;
|
|
2470
|
+
n && (this.setUrl(n), this.queryParamsAtom.value = {}, this.currentRouteAtom.value = n);
|
|
2407
2471
|
}
|
|
2408
2472
|
destroy() {
|
|
2409
|
-
if (this.isDestroyed)
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
} catch (e) {
|
|
2416
|
-
U.warn(B.ROUTE, "Cleanup error during destroy:", e);
|
|
2473
|
+
if (!this.isDestroyed) {
|
|
2474
|
+
this.isDestroyed = !0;
|
|
2475
|
+
for (let e of this.cleanups) try {
|
|
2476
|
+
e();
|
|
2477
|
+
} catch {}
|
|
2478
|
+
this.templateCache.clear();
|
|
2417
2479
|
}
|
|
2418
|
-
this.templateCache.clear();
|
|
2419
2480
|
}
|
|
2420
2481
|
};
|
|
2421
|
-
function
|
|
2422
|
-
return new
|
|
2482
|
+
function gn(e) {
|
|
2483
|
+
return new hn(e);
|
|
2423
2484
|
}
|
|
2424
|
-
e.extend({ route:
|
|
2485
|
+
e.extend({ route: gn });
|
|
2425
2486
|
//#endregion
|
|
2426
2487
|
//#region src/features/fetch.ts
|
|
2427
|
-
var
|
|
2428
|
-
constructor(
|
|
2429
|
-
this.abortController = null, this.
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2488
|
+
var _n = class {
|
|
2489
|
+
constructor(t, n) {
|
|
2490
|
+
this.abortController = null, this.execute = async () => {
|
|
2491
|
+
this.abortController?.abort(), this.abortController = new AbortController();
|
|
2492
|
+
let { signal: t } = this.abortController, n = this.ajaxOptionsFn?.() ?? {}, r = {
|
|
2493
|
+
...this.staticOptions,
|
|
2494
|
+
...n,
|
|
2495
|
+
headers: {
|
|
2496
|
+
...this.staticOptions.headers,
|
|
2497
|
+
...n.headers
|
|
2498
|
+
},
|
|
2499
|
+
url: this.isStaticUrl ? this.staticUrl : this.getUrl(),
|
|
2500
|
+
success: void 0,
|
|
2501
|
+
error: void 0,
|
|
2502
|
+
complete: void 0
|
|
2503
|
+
}, i = e.ajax(r);
|
|
2504
|
+
t.onabort = () => i.abort(), t.aborted && i.abort();
|
|
2505
|
+
try {
|
|
2506
|
+
let e = await i;
|
|
2507
|
+
return this.transformFn ? this.transformFn(e) : e;
|
|
2508
|
+
} catch (e) {
|
|
2509
|
+
if (t.aborted) {
|
|
2510
|
+
let e = /* @__PURE__ */ Error("AbortError");
|
|
2511
|
+
throw e.name = "AbortError", e;
|
|
2512
|
+
}
|
|
2513
|
+
return this.handleError(e);
|
|
2514
|
+
} finally {
|
|
2515
|
+
t.onabort = null, this.abortController?.signal === t && (this.abortController = null);
|
|
2516
|
+
}
|
|
2517
|
+
};
|
|
2518
|
+
let r = typeof t == "string";
|
|
2519
|
+
this.isStaticUrl = r, r ? (this.staticUrl = t, this.getUrl = () => this.staticUrl) : this.getUrl = t, this.ajaxOptionsFn = typeof n.ajaxOptions == "function" ? n.ajaxOptions : void 0;
|
|
2520
|
+
let i = typeof n.ajaxOptions == "object" ? n.ajaxOptions : {};
|
|
2521
|
+
this.staticOptions = {
|
|
2522
|
+
...i,
|
|
2523
|
+
method: n.method,
|
|
2524
|
+
headers: {
|
|
2525
|
+
...i?.headers,
|
|
2526
|
+
...n.headers
|
|
2527
|
+
}
|
|
2528
|
+
}, this.transformFn = n.transform, this.onErrorFn = n.onError;
|
|
2433
2529
|
}
|
|
2434
2530
|
abort() {
|
|
2435
2531
|
this.abortController?.abort();
|
|
2436
2532
|
}
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
t
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
if (t.aborted) {
|
|
2448
|
-
let e = /* @__PURE__ */ Error("AbortError");
|
|
2449
|
-
throw e.name = "AbortError", e;
|
|
2450
|
-
}
|
|
2451
|
-
let n;
|
|
2452
|
-
if (e && e.readyState !== void 0) {
|
|
2453
|
-
let t = e;
|
|
2454
|
-
n = /* @__PURE__ */ Error(`Network Error: ${t.statusText || "Unknown"} (${t.status})`), n.jqXHR = t;
|
|
2455
|
-
} else n = e instanceof Error ? e : Error(String(e ?? "Unknown network error"));
|
|
2456
|
-
let r = this.onErrorFn;
|
|
2457
|
-
if (r) try {
|
|
2458
|
-
r(n);
|
|
2459
|
-
} catch {}
|
|
2460
|
-
throw n;
|
|
2461
|
-
} finally {
|
|
2462
|
-
t.onabort = null, this.abortController?.signal === t && (this.abortController = null);
|
|
2463
|
-
}
|
|
2464
|
-
let o = this.transformFn;
|
|
2465
|
-
if (o) try {
|
|
2466
|
-
return o(a);
|
|
2467
|
-
} catch (e) {
|
|
2468
|
-
let t = this.onErrorFn;
|
|
2469
|
-
if (t) try {
|
|
2470
|
-
t(e);
|
|
2471
|
-
} catch {}
|
|
2472
|
-
throw e;
|
|
2473
|
-
}
|
|
2474
|
-
return a;
|
|
2533
|
+
handleError(e) {
|
|
2534
|
+
let t;
|
|
2535
|
+
if (e && e.readyState !== void 0) {
|
|
2536
|
+
let n = e;
|
|
2537
|
+
t = /* @__PURE__ */ Error(`Network Error: ${n.statusText || "Unknown"} (${n.status})`), t.jqXHR = n;
|
|
2538
|
+
} else t = e instanceof Error ? e : Error(String(e ?? "Unknown error"));
|
|
2539
|
+
if (this.onErrorFn) try {
|
|
2540
|
+
this.onErrorFn(t);
|
|
2541
|
+
} catch {}
|
|
2542
|
+
throw t;
|
|
2475
2543
|
}
|
|
2476
2544
|
};
|
|
2477
2545
|
//#endregion
|
|
2478
2546
|
//#region src/index.ts
|
|
2479
2547
|
e.extend({ atomFetch(e, t) {
|
|
2480
|
-
let n = new
|
|
2548
|
+
let n = new _n(e, t), r = L(n.execute, {
|
|
2481
2549
|
defaultValue: t.defaultValue,
|
|
2482
|
-
lazy:
|
|
2550
|
+
lazy: t.eager === !1
|
|
2483
2551
|
});
|
|
2484
|
-
return Object.assign(
|
|
2552
|
+
return Object.assign(r, { abort: () => n.abort() });
|
|
2485
2553
|
} }), e(() => {
|
|
2486
|
-
|
|
2554
|
+
pt(), ot(document.body);
|
|
2487
2555
|
});
|
|
2488
|
-
var
|
|
2556
|
+
var vn = e;
|
|
2489
2557
|
//#endregion
|
|
2490
|
-
export {
|
|
2558
|
+
export { k as atom, qe as atomLens, Ee as batch, Je as composeLens, L as computed, vn as default, st as disableAutoCleanup, mt as disablejQueryOverrides, R as effect, ot as enableAutoCleanup, pt as enablejQueryOverrides, ve as isAtom, ye as isComputed, z as isReactive, Ye as lensFor, Ze as nextTick, J as registry, O as untracked };
|
|
2491
2559
|
|
|
2492
2560
|
//# sourceMappingURL=index.mjs.map
|