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