@but212/atom-effect-jquery 0.17.0 → 0.19.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 +12 -1
- package/dist/atom-effect-jquery.min.js +1 -1
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +68 -0
- package/dist/index.mjs +993 -788
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import u from "jquery";
|
|
2
|
-
import { default as
|
|
3
|
-
const
|
|
2
|
+
import { default as Vt } from "jquery";
|
|
3
|
+
const Je = {
|
|
4
4
|
ONE_SECOND_MS: 1e3
|
|
5
|
-
},
|
|
5
|
+
}, Ee = {
|
|
6
6
|
IDLE: "idle",
|
|
7
7
|
PENDING: "pending",
|
|
8
8
|
RESOLVED: "resolved",
|
|
9
9
|
REJECTED: "rejected"
|
|
10
|
-
},
|
|
11
|
-
DISPOSED: 1
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, k = {
|
|
15
|
-
...F,
|
|
10
|
+
}, ve = {
|
|
11
|
+
DISPOSED: 1
|
|
12
|
+
}, P = {
|
|
13
|
+
...ve,
|
|
16
14
|
EXECUTING: 8
|
|
17
|
-
},
|
|
18
|
-
...
|
|
15
|
+
}, d = {
|
|
16
|
+
...ve,
|
|
19
17
|
DIRTY: 8,
|
|
20
18
|
IDLE: 16,
|
|
21
19
|
PENDING: 32,
|
|
@@ -23,11 +21,11 @@ const Wt = {
|
|
|
23
21
|
REJECTED: 128,
|
|
24
22
|
RECOMPUTING: 256,
|
|
25
23
|
HAS_ERROR: 512
|
|
26
|
-
},
|
|
27
|
-
...
|
|
24
|
+
}, H = {
|
|
25
|
+
...ve,
|
|
28
26
|
SYNC: 8,
|
|
29
27
|
NOTIFICATION_SCHEDULED: 16
|
|
30
|
-
},
|
|
28
|
+
}, q = {
|
|
31
29
|
// Infinite loop protection
|
|
32
30
|
MAX_EXECUTIONS_PER_SECOND: 1e3,
|
|
33
31
|
MAX_EXECUTIONS_PER_EFFECT: 100,
|
|
@@ -36,118 +34,116 @@ const Wt = {
|
|
|
36
34
|
MAX_FLUSH_ITERATIONS: 1e3,
|
|
37
35
|
MIN_FLUSH_ITERATIONS: 10,
|
|
38
36
|
BATCH_QUEUE_SHRINK_THRESHOLD: 1e3
|
|
39
|
-
},
|
|
40
|
-
MAX_DEPENDENCIES: 1e3,
|
|
37
|
+
}, Ze = {
|
|
41
38
|
WARN_INFINITE_LOOP: !0
|
|
42
|
-
},
|
|
43
|
-
class
|
|
44
|
-
constructor(
|
|
45
|
-
super(
|
|
39
|
+
}, ie = 1073741823, A = typeof process < "u" && process.env && process.env.NODE_ENV !== "production" || typeof __DEV__ < "u" && !!__DEV__, et = Object.freeze([]);
|
|
40
|
+
class ee extends Error {
|
|
41
|
+
constructor(e, t = null, s = !0) {
|
|
42
|
+
super(e), this.cause = t, this.recoverable = s, this.timestamp = /* @__PURE__ */ new Date(), this.name = "AtomError";
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
|
-
class
|
|
49
|
-
constructor(
|
|
50
|
-
super(
|
|
45
|
+
class z extends ee {
|
|
46
|
+
constructor(e, t = null) {
|
|
47
|
+
super(e, t, !0), this.name = "ComputedError";
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
|
-
class
|
|
54
|
-
constructor(
|
|
55
|
-
super(
|
|
50
|
+
class G extends ee {
|
|
51
|
+
constructor(e, t = null) {
|
|
52
|
+
super(e, t, !1), this.name = "EffectError";
|
|
56
53
|
}
|
|
57
54
|
}
|
|
58
|
-
class
|
|
59
|
-
constructor(
|
|
60
|
-
super(
|
|
55
|
+
class ae extends ee {
|
|
56
|
+
constructor(e, t = null) {
|
|
57
|
+
super(e, t, !1), this.name = "SchedulerError";
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
|
-
const
|
|
64
|
-
function
|
|
65
|
-
if (n ===
|
|
66
|
-
throw new
|
|
60
|
+
const Ne = /* @__PURE__ */ Symbol("AtomEffect.DebugName"), tt = /* @__PURE__ */ Symbol("AtomEffect.Id"), Re = /* @__PURE__ */ Symbol("AtomEffect.Type"), ye = /* @__PURE__ */ Symbol("AtomEffect.NoDefaultValue"), nt = (n) => "dependencies" in n && Array.isArray(n.dependencies);
|
|
61
|
+
function Me(n, e, t) {
|
|
62
|
+
if (n === e)
|
|
63
|
+
throw new z(
|
|
67
64
|
"Circular dependency detected: The computation refers to itself explicitly or implicitly."
|
|
68
65
|
);
|
|
69
|
-
if (!
|
|
66
|
+
if (!t.has(n.id) && (t.add(n.id), nt(n))) {
|
|
70
67
|
const s = n.dependencies;
|
|
71
68
|
for (let i = 0; i < s.length; i++) {
|
|
72
69
|
const o = s[i];
|
|
73
|
-
o &&
|
|
70
|
+
o && Me(o, e, t);
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
|
-
const
|
|
74
|
+
const Y = {
|
|
78
75
|
// Dev mode flag
|
|
79
|
-
enabled:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
m && this.enabled && n && console.warn(`[Atom Effect] ${t}`);
|
|
76
|
+
enabled: A,
|
|
77
|
+
warnInfiniteLoop: Ze.WARN_INFINITE_LOOP,
|
|
78
|
+
warn(n, e) {
|
|
79
|
+
A && this.enabled && n && console.warn(`[Atom Effect] ${e}`);
|
|
84
80
|
},
|
|
85
|
-
checkCircular(n,
|
|
86
|
-
if (n ===
|
|
87
|
-
throw new
|
|
88
|
-
|
|
81
|
+
checkCircular(n, e) {
|
|
82
|
+
if (n === e)
|
|
83
|
+
throw new z("Direct circular dependency detected");
|
|
84
|
+
A && this.enabled && Me(n, e, /* @__PURE__ */ new Set());
|
|
89
85
|
},
|
|
90
|
-
attachDebugInfo(n,
|
|
91
|
-
if (!
|
|
86
|
+
attachDebugInfo(n, e, t) {
|
|
87
|
+
if (!A || !this.enabled) return;
|
|
92
88
|
const s = n;
|
|
93
|
-
s[
|
|
89
|
+
s[Ne] = `${e}_${t}`, s[tt] = t, s[Re] = e;
|
|
94
90
|
},
|
|
95
|
-
getDebugName: (n) => n?.[
|
|
96
|
-
getDebugType: (n) => n?.[
|
|
91
|
+
getDebugName: (n) => n?.[Ne],
|
|
92
|
+
getDebugType: (n) => n?.[Re]
|
|
97
93
|
};
|
|
98
|
-
let
|
|
99
|
-
const
|
|
100
|
-
function
|
|
101
|
-
if (typeof
|
|
102
|
-
const i =
|
|
103
|
-
for (let o = 0, r =
|
|
104
|
-
const c =
|
|
94
|
+
let st = 1;
|
|
95
|
+
const it = () => st++;
|
|
96
|
+
function Be(n, e, t) {
|
|
97
|
+
if (typeof e == "function") {
|
|
98
|
+
const i = e;
|
|
99
|
+
for (let o = 0, r = t.length; o < r; o++) {
|
|
100
|
+
const c = t[o];
|
|
105
101
|
if (c && c.fn === i) return;
|
|
106
102
|
}
|
|
107
|
-
|
|
103
|
+
t.push(new Ce(i, void 0));
|
|
108
104
|
return;
|
|
109
105
|
}
|
|
110
|
-
if ("addDependency" in
|
|
111
|
-
|
|
106
|
+
if ("addDependency" in e) {
|
|
107
|
+
e.addDependency(n);
|
|
112
108
|
return;
|
|
113
109
|
}
|
|
114
|
-
const s =
|
|
115
|
-
for (let i = 0, o =
|
|
116
|
-
const r =
|
|
110
|
+
const s = e;
|
|
111
|
+
for (let i = 0, o = t.length; i < o; i++) {
|
|
112
|
+
const r = t[i];
|
|
117
113
|
if (r && r.sub === s) return;
|
|
118
114
|
}
|
|
119
|
-
|
|
115
|
+
t.push(new Ce(void 0, s));
|
|
120
116
|
}
|
|
121
|
-
function
|
|
122
|
-
for (let s = 0, i =
|
|
123
|
-
const o =
|
|
117
|
+
function ot(n, e, t) {
|
|
118
|
+
for (let s = 0, i = e.length; s < i; s++) {
|
|
119
|
+
const o = e[s];
|
|
124
120
|
o && (o.node._tempUnsub = o.unsub);
|
|
125
121
|
}
|
|
126
122
|
for (let s = 0, i = n.length; s < i; s++) {
|
|
127
123
|
const o = n[s];
|
|
128
124
|
if (!o) continue;
|
|
129
125
|
const r = o.node;
|
|
130
|
-
r._tempUnsub !== void 0 ? (o.unsub = r._tempUnsub, r._tempUnsub = void 0) : (
|
|
126
|
+
r._tempUnsub !== void 0 ? (o.unsub = r._tempUnsub, r._tempUnsub = void 0) : (Y.checkCircular(r, t), o.unsub = r.subscribe(t));
|
|
131
127
|
}
|
|
132
|
-
for (let s = 0, i =
|
|
133
|
-
const o =
|
|
128
|
+
for (let s = 0, i = e.length; s < i; s++) {
|
|
129
|
+
const o = e[s];
|
|
134
130
|
if (o) {
|
|
135
131
|
const r = o.node;
|
|
136
132
|
r._tempUnsub !== void 0 && (r._tempUnsub(), r._tempUnsub = void 0), o.unsub = void 0;
|
|
137
133
|
}
|
|
138
134
|
}
|
|
139
135
|
}
|
|
140
|
-
class
|
|
141
|
-
constructor(
|
|
142
|
-
this.node =
|
|
136
|
+
class he {
|
|
137
|
+
constructor(e, t, s = void 0) {
|
|
138
|
+
this.node = e, this.version = t, this.unsub = s;
|
|
143
139
|
}
|
|
144
140
|
}
|
|
145
|
-
class
|
|
146
|
-
constructor(
|
|
147
|
-
this.fn =
|
|
141
|
+
class Ce {
|
|
142
|
+
constructor(e, t) {
|
|
143
|
+
this.fn = e, this.sub = t;
|
|
148
144
|
}
|
|
149
145
|
}
|
|
150
|
-
const
|
|
146
|
+
const D = {
|
|
151
147
|
// Computed Errors
|
|
152
148
|
COMPUTED_MUST_BE_FUNCTION: "Computed target must be a function",
|
|
153
149
|
COMPUTED_ASYNC_PENDING_NO_DEFAULT: "Async computation pending with no default value",
|
|
@@ -163,85 +159,87 @@ const S = {
|
|
|
163
159
|
EFFECT_EXECUTION_FAILED: "Effect execution failed",
|
|
164
160
|
EFFECT_CLEANUP_FAILED: "Effect cleanup failed",
|
|
165
161
|
EFFECT_DISPOSED: "Attempted to run disposed effect",
|
|
166
|
-
|
|
162
|
+
// Scheduler Errors
|
|
163
|
+
SCHEDULER_FLUSH_OVERFLOW: (n, e) => `Maximum flush iterations (${n}) exceeded. ${e} jobs dropped. Possible infinite loop.`,
|
|
164
|
+
// System / Debug
|
|
165
|
+
CALLBACK_ERROR_IN_ERROR_HANDLER: "Exception encountered in onError handler",
|
|
166
|
+
// Effect frequency
|
|
167
|
+
EFFECT_FREQUENCY_LIMIT_EXCEEDED: "Effect executed too frequently within 1 second. Suspected infinite loop."
|
|
167
168
|
};
|
|
168
|
-
function
|
|
169
|
-
if (n instanceof
|
|
169
|
+
function Z(n, e, t) {
|
|
170
|
+
if (n instanceof ee)
|
|
170
171
|
return n;
|
|
171
172
|
const s = n instanceof Error, i = s ? n.message : String(n), o = s ? n : void 0;
|
|
172
173
|
let r = "Unexpected error";
|
|
173
174
|
n instanceof TypeError ? r = "Type error" : n instanceof ReferenceError && (r = "Reference error");
|
|
174
|
-
const c = `${r} (${
|
|
175
|
-
return new
|
|
175
|
+
const c = `${r} (${t}): ${i}`;
|
|
176
|
+
return new e(c, o);
|
|
176
177
|
}
|
|
177
|
-
class
|
|
178
|
+
class je {
|
|
178
179
|
constructor() {
|
|
179
|
-
this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this._modifiedAtEpoch = -1, this.id =
|
|
180
|
+
this.flags = 0, this.version = 0, this._lastSeenEpoch = -1, this._modifiedAtEpoch = -1, this.id = it() & ie, this._tempUnsub = void 0;
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
|
-
class
|
|
183
|
-
constructor() {
|
|
184
|
-
super(...arguments), this._fnSubCount = 0, this._objSubCount = 0;
|
|
185
|
-
}
|
|
183
|
+
class Ve extends je {
|
|
186
184
|
/**
|
|
187
185
|
* Adds subscriber.
|
|
188
186
|
*/
|
|
189
|
-
subscribe(
|
|
190
|
-
const
|
|
191
|
-
if (!
|
|
192
|
-
throw
|
|
187
|
+
subscribe(e) {
|
|
188
|
+
const t = typeof e == "function";
|
|
189
|
+
if (!t && (!e || typeof e.execute != "function"))
|
|
190
|
+
throw Z(
|
|
193
191
|
new TypeError("Invalid subscriber"),
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
ee,
|
|
193
|
+
D.ATOM_SUBSCRIBER_MUST_BE_FUNCTION
|
|
196
194
|
);
|
|
197
195
|
const s = this._subscribers;
|
|
198
196
|
for (let o = 0, r = s.length; o < r; o++) {
|
|
199
197
|
const c = s[o];
|
|
200
|
-
if (c && (
|
|
201
|
-
return
|
|
198
|
+
if (c && (t ? c.fn === e : c.sub === e))
|
|
199
|
+
return A && console.warn("Duplicate subscription ignored."), () => {
|
|
202
200
|
};
|
|
203
201
|
}
|
|
204
|
-
const i = new
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
const i = new Ce(
|
|
203
|
+
t ? e : void 0,
|
|
204
|
+
t ? void 0 : e
|
|
207
205
|
);
|
|
208
|
-
return s.push(i),
|
|
206
|
+
return s.push(i), () => this._unsubscribe(i);
|
|
209
207
|
}
|
|
210
|
-
_unsubscribe(
|
|
211
|
-
const
|
|
208
|
+
_unsubscribe(e) {
|
|
209
|
+
const t = this._subscribers, s = t.indexOf(e);
|
|
212
210
|
if (s === -1) return;
|
|
213
|
-
const i =
|
|
214
|
-
s <
|
|
211
|
+
const i = t.pop();
|
|
212
|
+
s < t.length && i && (t[s] = i);
|
|
215
213
|
}
|
|
216
214
|
subscriberCount() {
|
|
217
215
|
return this._subscribers.length;
|
|
218
216
|
}
|
|
219
|
-
_notifySubscribers(
|
|
220
|
-
if (
|
|
221
|
-
const s = this._subscribers, i = s.length;
|
|
217
|
+
_notifySubscribers(e, t) {
|
|
218
|
+
if (this._subscribers.length === 0) return;
|
|
219
|
+
const s = this._subscribers.slice(0), i = s.length;
|
|
222
220
|
for (let o = 0; o < i; o++) {
|
|
223
221
|
const r = s[o];
|
|
224
222
|
if (r)
|
|
225
223
|
try {
|
|
226
|
-
r.fn ? r.fn(
|
|
224
|
+
r.fn ? r.fn(e, t) : r.sub && r.sub.execute();
|
|
227
225
|
} catch (c) {
|
|
228
226
|
this._handleNotifyError(c);
|
|
229
227
|
}
|
|
230
228
|
}
|
|
231
229
|
}
|
|
232
|
-
_handleNotifyError(
|
|
233
|
-
console.error(
|
|
230
|
+
_handleNotifyError(e) {
|
|
231
|
+
console.error(Z(e, ee, D.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED));
|
|
234
232
|
}
|
|
235
233
|
}
|
|
236
|
-
let
|
|
237
|
-
const
|
|
238
|
-
let
|
|
239
|
-
function
|
|
240
|
-
return
|
|
234
|
+
let fe = 0;
|
|
235
|
+
const He = () => (fe = fe + 1 & ie || 1, fe), rt = () => fe, Ie = (n) => n + 1 & ie;
|
|
236
|
+
let Se = 0, Te = 0, _e = !1;
|
|
237
|
+
function xe() {
|
|
238
|
+
return _e ? (A && console.warn("startFlush() called during flush - ignored"), !1) : (_e = !0, Se = Se + 1 & ie || 1, Te = 0, !0);
|
|
241
239
|
}
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
},
|
|
240
|
+
const Ae = () => {
|
|
241
|
+
_e = !1;
|
|
242
|
+
}, ct = () => _e ? ++Te : 0, $ = {
|
|
245
243
|
/** Queue buffer */
|
|
246
244
|
_queueBuffer: [[], []],
|
|
247
245
|
_bufferIndex: 0,
|
|
@@ -257,7 +255,7 @@ const Rt = () => {
|
|
|
257
255
|
_batchQueue: [],
|
|
258
256
|
_batchQueueSize: 0,
|
|
259
257
|
/** Config */
|
|
260
|
-
_maxFlushIterations:
|
|
258
|
+
_maxFlushIterations: q.MAX_FLUSH_ITERATIONS,
|
|
261
259
|
get phase() {
|
|
262
260
|
return this._isProcessing || this._isFlushingSync ? 2 : this._isBatching ? 1 : 0;
|
|
263
261
|
},
|
|
@@ -271,8 +269,8 @@ const Rt = () => {
|
|
|
271
269
|
* Schedules job.
|
|
272
270
|
*/
|
|
273
271
|
schedule(n) {
|
|
274
|
-
if (
|
|
275
|
-
throw new
|
|
272
|
+
if (A && typeof n != "function")
|
|
273
|
+
throw new ae("Scheduler callback must be a function");
|
|
276
274
|
if (n._nextEpoch !== this._epoch) {
|
|
277
275
|
if (n._nextEpoch = this._epoch, this._isBatching || this._isFlushingSync) {
|
|
278
276
|
this._batchQueue[this._batchQueueSize++] = n;
|
|
@@ -292,31 +290,31 @@ const Rt = () => {
|
|
|
292
290
|
*/
|
|
293
291
|
_runLoop: () => {
|
|
294
292
|
try {
|
|
295
|
-
if (
|
|
296
|
-
const n =
|
|
297
|
-
|
|
293
|
+
if ($._size === 0) return;
|
|
294
|
+
const n = xe();
|
|
295
|
+
$._drainQueue(), n && Ae();
|
|
298
296
|
} finally {
|
|
299
|
-
|
|
297
|
+
$._isProcessing = !1, $._size > 0 && !$._isBatching && $._flush();
|
|
300
298
|
}
|
|
301
299
|
},
|
|
302
300
|
_flushSync() {
|
|
303
301
|
this._isFlushingSync = !0;
|
|
304
|
-
const n =
|
|
302
|
+
const n = xe();
|
|
305
303
|
try {
|
|
306
304
|
this._mergeBatchQueue(), this._drainQueue();
|
|
307
305
|
} finally {
|
|
308
|
-
this._isFlushingSync = !1, n &&
|
|
306
|
+
this._isFlushingSync = !1, n && Ae();
|
|
309
307
|
}
|
|
310
308
|
},
|
|
311
309
|
_mergeBatchQueue() {
|
|
312
310
|
if (this._batchQueueSize === 0) return;
|
|
313
|
-
const n = ++this._epoch,
|
|
311
|
+
const n = ++this._epoch, e = this._batchQueue, t = this._queueBuffer[this._bufferIndex];
|
|
314
312
|
let s = this._size;
|
|
315
313
|
for (let i = 0; i < this._batchQueueSize; i++) {
|
|
316
|
-
const o =
|
|
317
|
-
o._nextEpoch !== n && (o._nextEpoch = n,
|
|
314
|
+
const o = e[i];
|
|
315
|
+
o._nextEpoch !== n && (o._nextEpoch = n, t[s++] = o);
|
|
318
316
|
}
|
|
319
|
-
this._size = s, this._batchQueueSize = 0,
|
|
317
|
+
this._size = s, this._batchQueueSize = 0, e.length > q.BATCH_QUEUE_SHRINK_THRESHOLD && (e.length = 0);
|
|
320
318
|
},
|
|
321
319
|
_drainQueue() {
|
|
322
320
|
let n = 0;
|
|
@@ -329,41 +327,48 @@ const Rt = () => {
|
|
|
329
327
|
}
|
|
330
328
|
},
|
|
331
329
|
_processQueue() {
|
|
332
|
-
const n = this._bufferIndex,
|
|
330
|
+
const n = this._bufferIndex, e = this._queueBuffer[n], t = this._size;
|
|
333
331
|
this._bufferIndex = n ^ 1, this._size = 0, this._epoch++;
|
|
334
|
-
for (let s = 0; s <
|
|
332
|
+
for (let s = 0; s < t; s++)
|
|
335
333
|
try {
|
|
336
|
-
|
|
334
|
+
e[s]();
|
|
337
335
|
} catch (i) {
|
|
338
|
-
console.error(new
|
|
336
|
+
console.error(new ae("Error occurred during scheduler execution", i));
|
|
339
337
|
}
|
|
340
|
-
|
|
338
|
+
e.length = 0;
|
|
341
339
|
},
|
|
340
|
+
/** Overflow callback */
|
|
341
|
+
onOverflow: null,
|
|
342
342
|
_handleFlushOverflow() {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
343
|
+
const n = this._size + this._batchQueueSize;
|
|
344
|
+
if (console.error(
|
|
345
|
+
new ae(
|
|
346
|
+
D.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations, n)
|
|
346
347
|
)
|
|
347
|
-
), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0
|
|
348
|
+
), this._size = 0, this._queueBuffer[this._bufferIndex].length = 0, this._batchQueueSize = 0, this.onOverflow)
|
|
349
|
+
try {
|
|
350
|
+
this.onOverflow(n);
|
|
351
|
+
} catch {
|
|
352
|
+
}
|
|
348
353
|
},
|
|
349
354
|
startBatch() {
|
|
350
355
|
this._batchDepth++, this._isBatching = !0;
|
|
351
356
|
},
|
|
352
357
|
endBatch() {
|
|
353
358
|
if (this._batchDepth === 0) {
|
|
354
|
-
|
|
359
|
+
A && console.warn("endBatch() called without matching startBatch(). Ignoring.");
|
|
355
360
|
return;
|
|
356
361
|
}
|
|
357
362
|
--this._batchDepth === 0 && (this._flushSync(), this._isBatching = !1);
|
|
358
363
|
},
|
|
359
364
|
setMaxFlushIterations(n) {
|
|
360
|
-
if (n <
|
|
361
|
-
throw new
|
|
362
|
-
`Max flush iterations must be at least ${
|
|
365
|
+
if (n < q.MIN_FLUSH_ITERATIONS)
|
|
366
|
+
throw new ae(
|
|
367
|
+
`Max flush iterations must be at least ${q.MIN_FLUSH_ITERATIONS}`
|
|
363
368
|
);
|
|
364
369
|
this._maxFlushIterations = n;
|
|
365
370
|
}
|
|
366
|
-
},
|
|
371
|
+
}, B = {
|
|
367
372
|
/** Active listener. */
|
|
368
373
|
current: null,
|
|
369
374
|
/**
|
|
@@ -373,75 +378,75 @@ const Rt = () => {
|
|
|
373
378
|
* @param fn - The logic to execute.
|
|
374
379
|
* @returns The result of `fn`.
|
|
375
380
|
*/
|
|
376
|
-
run(n,
|
|
377
|
-
const
|
|
381
|
+
run(n, e) {
|
|
382
|
+
const t = this.current;
|
|
378
383
|
this.current = n;
|
|
379
384
|
try {
|
|
380
|
-
return
|
|
385
|
+
return e();
|
|
381
386
|
} finally {
|
|
382
|
-
this.current =
|
|
387
|
+
this.current = t;
|
|
383
388
|
}
|
|
384
389
|
}
|
|
385
390
|
};
|
|
386
|
-
function
|
|
387
|
-
const
|
|
388
|
-
if (
|
|
389
|
-
|
|
391
|
+
function at(n) {
|
|
392
|
+
const e = B.current;
|
|
393
|
+
if (e === null) return n();
|
|
394
|
+
B.current = null;
|
|
390
395
|
try {
|
|
391
396
|
return n();
|
|
392
397
|
} finally {
|
|
393
|
-
|
|
398
|
+
B.current = e;
|
|
394
399
|
}
|
|
395
400
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
super(), this._pendingOldValue = void 0, this._notifyTask = void 0, this._subscribers = [], this._value = t, e && (this.flags |= R.SYNC), X.attachDebugInfo(this, "atom", this.id);
|
|
401
|
+
class ut extends Ve {
|
|
402
|
+
constructor(e, t) {
|
|
403
|
+
super(), this._pendingOldValue = void 0, this._notifyTask = void 0, this._subscribers = [], this._value = e, t && (this.flags |= H.SYNC), Y.attachDebugInfo(this, "atom", this.id);
|
|
400
404
|
}
|
|
401
405
|
get value() {
|
|
402
|
-
const
|
|
403
|
-
return
|
|
406
|
+
const e = B.current;
|
|
407
|
+
return e && Be(this, e, this._subscribers), this._value;
|
|
404
408
|
}
|
|
405
|
-
set value(
|
|
406
|
-
const
|
|
407
|
-
if (Object.is(
|
|
408
|
-
this._value =
|
|
409
|
+
set value(e) {
|
|
410
|
+
const t = this._value;
|
|
411
|
+
if (Object.is(t, e)) return;
|
|
412
|
+
this._value = e, this.version = Ie(this.version);
|
|
409
413
|
const s = this.flags;
|
|
410
|
-
if (!(
|
|
411
|
-
if (this._pendingOldValue =
|
|
414
|
+
if (!(this._subscribers.length === 0 || s & H.NOTIFICATION_SCHEDULED)) {
|
|
415
|
+
if (this._pendingOldValue = t, this.flags = s | H.NOTIFICATION_SCHEDULED, s & H.SYNC && !$.isBatching) {
|
|
412
416
|
this._flushNotifications();
|
|
413
417
|
return;
|
|
414
418
|
}
|
|
415
|
-
this._notifyTask || (this._notifyTask = () => this._flushNotifications()),
|
|
419
|
+
this._notifyTask || (this._notifyTask = () => this._flushNotifications()), $.schedule(this._notifyTask);
|
|
416
420
|
}
|
|
417
421
|
}
|
|
418
422
|
/**
|
|
419
423
|
* Triggers subscribers.
|
|
420
424
|
*/
|
|
421
425
|
_flushNotifications() {
|
|
422
|
-
const
|
|
423
|
-
if (!(
|
|
426
|
+
const e = this.flags;
|
|
427
|
+
if (!(e & H.NOTIFICATION_SCHEDULED) || e & H.DISPOSED)
|
|
424
428
|
return;
|
|
425
|
-
const
|
|
426
|
-
this._pendingOldValue = void 0, this.flags &= -17, this._notifySubscribers(this._value,
|
|
429
|
+
const t = this._pendingOldValue;
|
|
430
|
+
this._pendingOldValue = void 0, this.flags &= -17, this._notifySubscribers(this._value, t);
|
|
427
431
|
}
|
|
428
432
|
peek() {
|
|
429
433
|
return this._value;
|
|
430
434
|
}
|
|
431
435
|
dispose() {
|
|
432
|
-
this.flags &
|
|
436
|
+
this.flags & H.DISPOSED || (this._subscribers.length = 0, this.flags |= H.DISPOSED, this._value = void 0, this._pendingOldValue = void 0, this._notifyTask = void 0);
|
|
433
437
|
}
|
|
434
438
|
}
|
|
435
|
-
function
|
|
436
|
-
return new
|
|
439
|
+
function ze(n, e = {}) {
|
|
440
|
+
return new ut(n, e.sync ?? !1);
|
|
437
441
|
}
|
|
438
|
-
class
|
|
442
|
+
class lt {
|
|
439
443
|
/**
|
|
440
444
|
* @param limit - Max unique arrays to hold (default: 50). Prevents the pool itself from consuming too much memory.
|
|
441
445
|
* @param capacity - Max length of an array to accept (default: 256).
|
|
446
|
+
* @param enableStats - Force-enable stats even in production (default: false).
|
|
442
447
|
*/
|
|
443
|
-
constructor(
|
|
444
|
-
this.limit =
|
|
448
|
+
constructor(e = 50, t = 256, s = !1) {
|
|
449
|
+
this.limit = e, this.capacity = t, this.pool = [], this.stats = null, this.stats = A || s ? {
|
|
445
450
|
acquired: 0,
|
|
446
451
|
released: 0,
|
|
447
452
|
rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
|
|
@@ -451,7 +456,7 @@ class le {
|
|
|
451
456
|
* Acquires array.
|
|
452
457
|
*/
|
|
453
458
|
acquire() {
|
|
454
|
-
return
|
|
459
|
+
return this.stats && this.stats.acquired++, this.pool.pop() ?? [];
|
|
455
460
|
}
|
|
456
461
|
/**
|
|
457
462
|
* Releases array.
|
|
@@ -459,32 +464,32 @@ class le {
|
|
|
459
464
|
* @param arr - Array to release.
|
|
460
465
|
* @param emptyConst - Optional empty constant.
|
|
461
466
|
*/
|
|
462
|
-
release(
|
|
463
|
-
if (!(
|
|
464
|
-
if (
|
|
465
|
-
|
|
467
|
+
release(e, t) {
|
|
468
|
+
if (!(t && e === t)) {
|
|
469
|
+
if (e.length > this.capacity) {
|
|
470
|
+
this.stats && this.stats.rejected.tooLarge++;
|
|
466
471
|
return;
|
|
467
472
|
}
|
|
468
473
|
if (this.pool.length >= this.limit) {
|
|
469
|
-
|
|
474
|
+
this.stats && this.stats.rejected.poolFull++;
|
|
470
475
|
return;
|
|
471
476
|
}
|
|
472
|
-
if (Object.isFrozen(
|
|
473
|
-
|
|
477
|
+
if (Object.isFrozen(e)) {
|
|
478
|
+
this.stats && this.stats.rejected.frozen++;
|
|
474
479
|
return;
|
|
475
480
|
}
|
|
476
|
-
|
|
481
|
+
e.length = 0, this.pool.push(e), this.stats && this.stats.released++;
|
|
477
482
|
}
|
|
478
483
|
}
|
|
479
484
|
/**
|
|
480
485
|
* Pool stats.
|
|
481
486
|
*/
|
|
482
487
|
getStats() {
|
|
483
|
-
if (!
|
|
484
|
-
const { acquired:
|
|
488
|
+
if (!this.stats) return null;
|
|
489
|
+
const { acquired: e, released: t, rejected: s } = this.stats, i = e - t - (s.frozen + s.tooLarge + s.poolFull);
|
|
485
490
|
return {
|
|
486
|
-
acquired:
|
|
487
|
-
released:
|
|
491
|
+
acquired: e,
|
|
492
|
+
released: t,
|
|
488
493
|
rejected: { ...s },
|
|
489
494
|
leaked: i,
|
|
490
495
|
poolSize: this.pool.length
|
|
@@ -494,68 +499,68 @@ class le {
|
|
|
494
499
|
* Resets pool.
|
|
495
500
|
*/
|
|
496
501
|
reset() {
|
|
497
|
-
this.pool.length = 0,
|
|
502
|
+
this.pool.length = 0, this.stats && (this.stats = {
|
|
498
503
|
acquired: 0,
|
|
499
504
|
released: 0,
|
|
500
505
|
rejected: { frozen: 0, tooLarge: 0, poolFull: 0 }
|
|
501
506
|
});
|
|
502
507
|
}
|
|
503
508
|
}
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
const j = new le();
|
|
512
|
-
function yt(n) {
|
|
509
|
+
const oe = (n) => Object.freeze(n);
|
|
510
|
+
oe([]);
|
|
511
|
+
oe([]);
|
|
512
|
+
oe([]);
|
|
513
|
+
oe([]);
|
|
514
|
+
const U = oe([]), X = new lt();
|
|
515
|
+
function De(n) {
|
|
513
516
|
return n !== null && typeof n == "object" && "value" in n && typeof n.subscribe == "function";
|
|
514
517
|
}
|
|
515
|
-
function
|
|
516
|
-
return
|
|
518
|
+
function Le(n) {
|
|
519
|
+
return De(n) && typeof n.invalidate == "function";
|
|
517
520
|
}
|
|
518
|
-
function
|
|
521
|
+
function qe(n) {
|
|
519
522
|
return n !== null && typeof n == "object" && typeof n.then == "function";
|
|
520
523
|
}
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
const
|
|
526
|
-
class
|
|
527
|
-
constructor(
|
|
528
|
-
if (typeof
|
|
529
|
-
|
|
524
|
+
const Xe = d.RESOLVED | d.PENDING | d.REJECTED, ge = Array(Xe + 1).fill(Ee.IDLE);
|
|
525
|
+
ge[d.RESOLVED] = Ee.RESOLVED;
|
|
526
|
+
ge[d.PENDING] = Ee.PENDING;
|
|
527
|
+
ge[d.REJECTED] = Ee.REJECTED;
|
|
528
|
+
const ht = 3, Ue = Number.MAX_SAFE_INTEGER - 1, ft = d.REJECTED | d.HAS_ERROR;
|
|
529
|
+
class Qe extends Ve {
|
|
530
|
+
constructor(e, t = {}) {
|
|
531
|
+
if (typeof e != "function") throw new z(D.COMPUTED_MUST_BE_FUNCTION);
|
|
532
|
+
super(), this._error = null, this._promiseId = 0, this._subscribers = [], this._links = U, this._cachedErrors = null, this._errorCacheEpoch = -1, this._asyncStartAggregateVersion = 0, this._asyncRetryCount = 0, this._errorDepCount = 0, this._trackEpoch = -1, this._trackLinks = U, this._trackCount = 0, this._value = void 0, this.flags = d.DIRTY | d.IDLE, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : ye, this._onError = t.onError ?? null;
|
|
533
|
+
const s = t.maxAsyncRetries;
|
|
534
|
+
if (this._maxAsyncRetries = s != null && s >= 0 ? s : ht, Y.attachDebugInfo(this, "computed", this.id), t.lazy === !1)
|
|
530
535
|
try {
|
|
531
536
|
this._recompute();
|
|
532
537
|
} catch {
|
|
533
538
|
}
|
|
534
539
|
}
|
|
535
540
|
_track() {
|
|
536
|
-
const
|
|
537
|
-
|
|
541
|
+
const e = B.current;
|
|
542
|
+
e && Be(this, e, this._subscribers);
|
|
538
543
|
}
|
|
539
544
|
get value() {
|
|
540
545
|
this._track();
|
|
541
|
-
const
|
|
542
|
-
if ((
|
|
546
|
+
const e = this.flags;
|
|
547
|
+
if ((e & (d.RESOLVED | d.DIRTY | d.IDLE)) === d.RESOLVED)
|
|
543
548
|
return this._value;
|
|
544
|
-
if (
|
|
545
|
-
throw new
|
|
546
|
-
if (
|
|
547
|
-
if (this._defaultValue !==
|
|
548
|
-
throw new
|
|
549
|
+
if (e & d.DISPOSED)
|
|
550
|
+
throw new z(D.COMPUTED_DISPOSED);
|
|
551
|
+
if (e & d.RECOMPUTING) {
|
|
552
|
+
if (this._defaultValue !== ye) return this._defaultValue;
|
|
553
|
+
throw new z(D.COMPUTED_CIRCULAR_DEPENDENCY);
|
|
549
554
|
}
|
|
550
|
-
if (
|
|
555
|
+
if (e & (d.DIRTY | d.IDLE) && (this._recompute(), this.flags & d.RESOLVED))
|
|
551
556
|
return this._value;
|
|
552
|
-
const
|
|
553
|
-
if (this.flags &
|
|
554
|
-
if (s) return
|
|
555
|
-
throw new
|
|
557
|
+
const t = this._defaultValue, s = t !== ye;
|
|
558
|
+
if (this.flags & d.PENDING) {
|
|
559
|
+
if (s) return t;
|
|
560
|
+
throw new z(D.COMPUTED_ASYNC_PENDING_NO_DEFAULT);
|
|
556
561
|
}
|
|
557
|
-
if (this.flags &
|
|
558
|
-
if (this._error?.recoverable && s) return
|
|
562
|
+
if (this.flags & d.REJECTED) {
|
|
563
|
+
if (this._error?.recoverable && s) return t;
|
|
559
564
|
throw this._error;
|
|
560
565
|
}
|
|
561
566
|
return this._value;
|
|
@@ -564,14 +569,14 @@ class Gt extends Ht {
|
|
|
564
569
|
return this._value;
|
|
565
570
|
}
|
|
566
571
|
get state() {
|
|
567
|
-
return this._track(),
|
|
572
|
+
return this._track(), ge[this.flags & Xe];
|
|
568
573
|
}
|
|
569
574
|
get hasError() {
|
|
570
|
-
if (this._track(), this.flags & (
|
|
571
|
-
const
|
|
572
|
-
for (let
|
|
573
|
-
const i = t
|
|
574
|
-
if (i && i.flags &
|
|
575
|
+
if (this._track(), this.flags & (d.REJECTED | d.HAS_ERROR) || this._errorDepCount > 0) return !0;
|
|
576
|
+
const e = this._links;
|
|
577
|
+
for (let t = 0, s = e.length; t < s; t++) {
|
|
578
|
+
const i = e[t]?.node;
|
|
579
|
+
if (i && i.flags & d.HAS_ERROR) return !0;
|
|
575
580
|
}
|
|
576
581
|
return !1;
|
|
577
582
|
}
|
|
@@ -580,330 +585,349 @@ class Gt extends Ht {
|
|
|
580
585
|
return !this.hasError;
|
|
581
586
|
}
|
|
582
587
|
get errors() {
|
|
583
|
-
if (this._track(), !this.hasError) return
|
|
584
|
-
const
|
|
585
|
-
if (this._errorCacheEpoch ===
|
|
586
|
-
const
|
|
587
|
-
this._error &&
|
|
588
|
+
if (this._track(), !this.hasError) return et;
|
|
589
|
+
const e = rt();
|
|
590
|
+
if (this._errorCacheEpoch === e && this._cachedErrors) return this._cachedErrors;
|
|
591
|
+
const t = [];
|
|
592
|
+
this._error && t.push(this._error);
|
|
588
593
|
const s = this._links;
|
|
589
594
|
for (let o = 0, r = s.length; o < r; o++) {
|
|
590
595
|
const c = s[o].node;
|
|
591
|
-
if (c.flags &
|
|
596
|
+
if (c.flags & d.HAS_ERROR) {
|
|
592
597
|
const l = c;
|
|
593
598
|
if (l.errors) {
|
|
594
|
-
const
|
|
595
|
-
for (let
|
|
596
|
-
const
|
|
597
|
-
|
|
599
|
+
const _ = l.errors;
|
|
600
|
+
for (let g = 0; g < _.length; g++) {
|
|
601
|
+
const v = _[g];
|
|
602
|
+
v && t.indexOf(v) === -1 && t.push(v);
|
|
598
603
|
}
|
|
599
604
|
}
|
|
600
605
|
}
|
|
601
606
|
}
|
|
602
|
-
const i = Object.freeze(
|
|
603
|
-
return this._errorCacheEpoch =
|
|
607
|
+
const i = Object.freeze(t);
|
|
608
|
+
return this._errorCacheEpoch = e, this._cachedErrors = i, i;
|
|
604
609
|
}
|
|
605
610
|
get lastError() {
|
|
606
611
|
return this._track(), this._error;
|
|
607
612
|
}
|
|
608
613
|
get isPending() {
|
|
609
|
-
return this._track(), (this.flags &
|
|
614
|
+
return this._track(), (this.flags & d.PENDING) !== 0;
|
|
610
615
|
}
|
|
611
616
|
get isResolved() {
|
|
612
|
-
return this._track(), (this.flags &
|
|
617
|
+
return this._track(), (this.flags & d.RESOLVED) !== 0;
|
|
613
618
|
}
|
|
614
619
|
invalidate() {
|
|
615
620
|
this._markDirty(), this._errorCacheEpoch = -1, this._cachedErrors = null;
|
|
616
621
|
}
|
|
617
622
|
dispose() {
|
|
618
|
-
if (this.flags &
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
-
for (let
|
|
622
|
-
t
|
|
623
|
-
|
|
623
|
+
if (this.flags & d.DISPOSED) return;
|
|
624
|
+
const e = this._links;
|
|
625
|
+
if (e !== U) {
|
|
626
|
+
for (let t = 0, s = e.length; t < s; t++)
|
|
627
|
+
e[t].unsub?.();
|
|
628
|
+
X.release(e), this._links = U;
|
|
624
629
|
}
|
|
625
|
-
this._subscribers.length = 0, this.flags =
|
|
630
|
+
this._subscribers.length = 0, this.flags = d.DISPOSED | d.DIRTY | d.IDLE, this._error = null, this._value = void 0, this._promiseId = (this._promiseId + 1) % Ue, this._cachedErrors = null, this._errorCacheEpoch = -1;
|
|
626
631
|
}
|
|
627
|
-
addDependency(
|
|
628
|
-
if (
|
|
629
|
-
if (
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
+
addDependency(e) {
|
|
633
|
+
if (e._lastSeenEpoch !== this._trackEpoch) {
|
|
634
|
+
if (e._lastSeenEpoch = this._trackEpoch, this._trackCount < this._trackLinks.length) {
|
|
635
|
+
const t = this._trackLinks[this._trackCount];
|
|
636
|
+
t.node = e, t.version = e.version;
|
|
632
637
|
} else
|
|
633
|
-
this._trackLinks.push(new
|
|
638
|
+
this._trackLinks.push(new he(e, e.version));
|
|
634
639
|
this._trackCount++;
|
|
635
640
|
}
|
|
636
641
|
}
|
|
637
|
-
_commitDeps(
|
|
638
|
-
this._trackLinks.length = this._trackCount,
|
|
642
|
+
_commitDeps(e) {
|
|
643
|
+
this._trackLinks.length = this._trackCount, ot(this._trackLinks, e, this), this._links = this._trackLinks;
|
|
639
644
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
this.flags |= h.RECOMPUTING;
|
|
645
|
+
_updateErrorDepCount() {
|
|
646
|
+
let e = 0;
|
|
643
647
|
const t = this._links;
|
|
644
|
-
|
|
645
|
-
|
|
648
|
+
for (let s = 0, i = t.length; s < i; s++) {
|
|
649
|
+
const o = t[s]?.node;
|
|
650
|
+
o && o.flags & d.HAS_ERROR && e++;
|
|
651
|
+
}
|
|
652
|
+
this._errorDepCount = e;
|
|
653
|
+
}
|
|
654
|
+
_recompute() {
|
|
655
|
+
if (this.flags & d.RECOMPUTING) return;
|
|
656
|
+
this.flags |= d.RECOMPUTING;
|
|
657
|
+
const e = this._links;
|
|
658
|
+
this._trackEpoch = He(), this._trackLinks = X.acquire(), this._trackCount = 0;
|
|
659
|
+
let t = !1;
|
|
646
660
|
try {
|
|
647
|
-
const s =
|
|
648
|
-
this._commitDeps(
|
|
661
|
+
const s = B.run(this, this._fn);
|
|
662
|
+
this._commitDeps(e), t = !0, this._updateErrorDepCount(), qe(s) ? this._handleAsyncComputation(s) : this._finalizeResolution(s);
|
|
649
663
|
} catch (s) {
|
|
650
|
-
if (!
|
|
664
|
+
if (!t)
|
|
651
665
|
try {
|
|
652
|
-
this._commitDeps(
|
|
653
|
-
} catch {
|
|
666
|
+
this._commitDeps(e), t = !0, this._updateErrorDepCount();
|
|
667
|
+
} catch (i) {
|
|
668
|
+
A && console.warn("[atom-effect] _commitDeps failed during error recovery:", i);
|
|
654
669
|
}
|
|
655
|
-
this._handleError(s,
|
|
670
|
+
this._handleError(s, D.COMPUTED_COMPUTATION_FAILED, !0);
|
|
656
671
|
} finally {
|
|
657
|
-
|
|
672
|
+
t && e !== U ? X.release(e) : t || X.release(this._trackLinks), this._trackEpoch = -1, this._trackLinks = U, this._trackCount = 0, this.flags &= -257;
|
|
658
673
|
}
|
|
659
674
|
}
|
|
660
|
-
_handleAsyncComputation(
|
|
661
|
-
this.flags = (this.flags |
|
|
662
|
-
const
|
|
663
|
-
|
|
675
|
+
_handleAsyncComputation(e) {
|
|
676
|
+
this.flags = (this.flags | d.PENDING) & -217, this._notifySubscribers(void 0, void 0), this._asyncStartAggregateVersion = this._captureVersionSnapshot(), this._asyncRetryCount = 0, this._promiseId = (this._promiseId + 1) % Ue;
|
|
677
|
+
const t = this._promiseId;
|
|
678
|
+
e.then(
|
|
664
679
|
(s) => {
|
|
665
|
-
if (
|
|
680
|
+
if (t === this._promiseId) {
|
|
666
681
|
if (this._captureVersionSnapshot() !== this._asyncStartAggregateVersion)
|
|
667
|
-
return this._asyncRetryCount++ <
|
|
668
|
-
new
|
|
669
|
-
|
|
682
|
+
return this._asyncRetryCount++ < this._maxAsyncRetries ? this._markDirty() : this._handleError(
|
|
683
|
+
new z(
|
|
684
|
+
`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`
|
|
685
|
+
),
|
|
686
|
+
D.COMPUTED_ASYNC_COMPUTATION_FAILED
|
|
670
687
|
);
|
|
671
688
|
this._finalizeResolution(s), this._notifySubscribers(s, void 0);
|
|
672
689
|
}
|
|
673
690
|
},
|
|
674
|
-
(s) =>
|
|
691
|
+
(s) => t === this._promiseId && this._handleError(s, D.COMPUTED_ASYNC_COMPUTATION_FAILED)
|
|
675
692
|
);
|
|
676
693
|
}
|
|
677
694
|
_captureVersionSnapshot() {
|
|
678
|
-
let
|
|
679
|
-
const
|
|
680
|
-
for (let s = 0, i =
|
|
681
|
-
|
|
682
|
-
return
|
|
695
|
+
let e = 0;
|
|
696
|
+
const t = this._links;
|
|
697
|
+
for (let s = 0, i = t.length; s < i; s++)
|
|
698
|
+
e = ((e << 5) - e | 0) + t[s].node.version & ie;
|
|
699
|
+
return e;
|
|
683
700
|
}
|
|
684
|
-
_handleError(
|
|
685
|
-
const i =
|
|
686
|
-
if (!s && !(this.flags &
|
|
701
|
+
_handleError(e, t, s = !1) {
|
|
702
|
+
const i = Z(e, z, t);
|
|
703
|
+
if (!s && !(this.flags & d.REJECTED) && (this.version = Ie(this.version)), this._error = i, this.flags = this.flags & -121 | ft, this._onError)
|
|
687
704
|
try {
|
|
688
705
|
this._onError(i);
|
|
689
706
|
} catch (o) {
|
|
690
|
-
console.error(
|
|
707
|
+
console.error(D.CALLBACK_ERROR_IN_ERROR_HANDLER, o);
|
|
691
708
|
}
|
|
692
709
|
if (s) throw i;
|
|
693
710
|
this._notifySubscribers(void 0, void 0);
|
|
694
711
|
}
|
|
695
|
-
_finalizeResolution(
|
|
696
|
-
(!(this.flags &
|
|
712
|
+
_finalizeResolution(e) {
|
|
713
|
+
(!(this.flags & d.RESOLVED) || !this._equal(this._value, e)) && (this.version = Ie(this.version)), this._value = e, this._error = null, this.flags = (this.flags | d.RESOLVED) & -697, this._cachedErrors = null, this._errorCacheEpoch = -1;
|
|
697
714
|
}
|
|
698
715
|
execute() {
|
|
699
716
|
this._markDirty();
|
|
700
717
|
}
|
|
701
718
|
/** @internal */
|
|
702
719
|
_markDirty() {
|
|
703
|
-
this.flags & (
|
|
720
|
+
this.flags & (d.RECOMPUTING | d.DIRTY) || (this.flags |= d.DIRTY, this._notifySubscribers(void 0, void 0));
|
|
704
721
|
}
|
|
705
722
|
}
|
|
706
|
-
Object.freeze(
|
|
707
|
-
function
|
|
708
|
-
return new
|
|
723
|
+
Object.freeze(Qe.prototype);
|
|
724
|
+
function dt(n, e = {}) {
|
|
725
|
+
return new Qe(n, e);
|
|
709
726
|
}
|
|
710
|
-
class
|
|
711
|
-
constructor(
|
|
712
|
-
super(), this._cleanup = null, this._links =
|
|
713
|
-
const s = Number.isFinite(this._maxExecutions), i = s ? Math.min(this._maxExecutions + 1,
|
|
714
|
-
this._historyCapacity = i, this._history =
|
|
727
|
+
class _t extends je {
|
|
728
|
+
constructor(e, t = {}) {
|
|
729
|
+
super(), this._cleanup = null, this._links = U, this._nextLinks = null, this._currentEpoch = -1, this._lastFlushEpoch = -1, this._executionsInEpoch = 0, this._executionCount = 0, this._historyPtr = 0, this._execId = 0, this._fn = e, this._onError = t.onError ?? null, this._sync = t.sync ?? !1, this._maxExecutions = t.maxExecutionsPerSecond ?? q.MAX_EXECUTIONS_PER_SECOND, this._maxExecutionsPerFlush = t.maxExecutionsPerFlush ?? q.MAX_EXECUTIONS_PER_EFFECT, this._trackModifications = t.trackModifications ?? !1;
|
|
730
|
+
const s = Number.isFinite(this._maxExecutions), i = s ? Math.min(this._maxExecutions + 1, q.MAX_EXECUTIONS_PER_SECOND + 1) : 0;
|
|
731
|
+
this._historyCapacity = i, this._history = A && s && i > 0 ? new Array(i).fill(0) : null, Y.attachDebugInfo(this, "effect", this.id);
|
|
715
732
|
}
|
|
716
733
|
run() {
|
|
717
|
-
if (this.flags &
|
|
718
|
-
throw new
|
|
734
|
+
if (this.flags & P.DISPOSED)
|
|
735
|
+
throw new G(D.EFFECT_DISPOSED);
|
|
719
736
|
this.execute(!0);
|
|
720
737
|
}
|
|
721
738
|
dispose() {
|
|
722
|
-
this.flags &
|
|
723
|
-
}
|
|
724
|
-
addDependency(
|
|
725
|
-
if (!(this.flags &
|
|
726
|
-
|
|
727
|
-
const
|
|
728
|
-
if (
|
|
729
|
-
|
|
739
|
+
this.flags & P.DISPOSED || (this.flags |= P.DISPOSED, this._execCleanup(), this._releaseLinks(this._links), this._links = U, this._executeTask = void 0);
|
|
740
|
+
}
|
|
741
|
+
addDependency(e) {
|
|
742
|
+
if (!(this.flags & P.EXECUTING) || e._lastSeenEpoch === this._currentEpoch) return;
|
|
743
|
+
e._lastSeenEpoch = this._currentEpoch;
|
|
744
|
+
const t = this._nextLinks;
|
|
745
|
+
if (e._tempUnsub) {
|
|
746
|
+
t.push(new he(e, e.version, e._tempUnsub)), e._tempUnsub = void 0;
|
|
730
747
|
return;
|
|
731
748
|
}
|
|
732
749
|
try {
|
|
733
|
-
const s =
|
|
734
|
-
if (this._trackModifications && this.flags &
|
|
735
|
-
this._executeTask || (this._executeTask = () => this.execute()),
|
|
750
|
+
const s = e.subscribe(() => {
|
|
751
|
+
if (this._trackModifications && this.flags & P.EXECUTING && (e._modifiedAtEpoch = this._currentEpoch), this._sync) return this.execute();
|
|
752
|
+
this._executeTask || (this._executeTask = () => this.execute()), $.schedule(this._executeTask);
|
|
736
753
|
});
|
|
737
|
-
|
|
754
|
+
t.push(new he(e, e.version, s));
|
|
738
755
|
} catch (s) {
|
|
739
|
-
|
|
756
|
+
const i = Z(s, G, D.EFFECT_EXECUTION_FAILED);
|
|
757
|
+
if (console.error(i), this._onError)
|
|
758
|
+
try {
|
|
759
|
+
this._onError(i);
|
|
760
|
+
} catch {
|
|
761
|
+
}
|
|
762
|
+
t.push(new he(e, e.version, void 0));
|
|
740
763
|
}
|
|
741
764
|
}
|
|
742
765
|
/**
|
|
743
766
|
* Executes effect with tracking.
|
|
744
767
|
*/
|
|
745
|
-
execute(
|
|
746
|
-
if (this.flags & (
|
|
747
|
-
this._checkInfiniteLoops(), this.flags |=
|
|
748
|
-
const
|
|
749
|
-
if (
|
|
750
|
-
for (let o = 0, r =
|
|
751
|
-
const c =
|
|
768
|
+
execute(e = !1) {
|
|
769
|
+
if (this.flags & (P.DISPOSED | P.EXECUTING) || !e && this._links.length > 0 && !this._isDirty()) return;
|
|
770
|
+
this._checkInfiniteLoops(), this.flags |= P.EXECUTING, this._execCleanup();
|
|
771
|
+
const t = this._links;
|
|
772
|
+
if (t !== U)
|
|
773
|
+
for (let o = 0, r = t.length; o < r; o++) {
|
|
774
|
+
const c = t[o];
|
|
752
775
|
c && (c.node._tempUnsub = c.unsub);
|
|
753
776
|
}
|
|
754
|
-
const s =
|
|
755
|
-
this._nextLinks = s, this._currentEpoch =
|
|
777
|
+
const s = X.acquire();
|
|
778
|
+
this._nextLinks = s, this._currentEpoch = He();
|
|
756
779
|
let i = !1;
|
|
757
780
|
try {
|
|
758
|
-
const o =
|
|
759
|
-
this._links = s, i = !0, this._checkLoopWarnings(),
|
|
781
|
+
const o = B.run(this, this._fn);
|
|
782
|
+
this._links = s, i = !0, this._checkLoopWarnings(), qe(o) ? this._handleAsyncResult(o) : this._cleanup = typeof o == "function" ? o : null;
|
|
760
783
|
} catch (o) {
|
|
761
784
|
i = !0, this._handleExecutionError(o), this._cleanup = null;
|
|
762
785
|
} finally {
|
|
763
|
-
this._finalizeDependencies(i,
|
|
786
|
+
this._finalizeDependencies(i, t, s), this.flags &= -9;
|
|
764
787
|
}
|
|
765
788
|
}
|
|
766
|
-
_handleAsyncResult(
|
|
767
|
-
const
|
|
768
|
-
|
|
789
|
+
_handleAsyncResult(e) {
|
|
790
|
+
const t = ++this._execId;
|
|
791
|
+
e.then(
|
|
769
792
|
(s) => {
|
|
770
|
-
if (
|
|
793
|
+
if (t !== this._execId || this.flags & P.DISPOSED) {
|
|
771
794
|
if (typeof s == "function")
|
|
772
795
|
try {
|
|
773
796
|
s();
|
|
774
797
|
} catch (i) {
|
|
775
|
-
this._handleExecutionError(i,
|
|
798
|
+
this._handleExecutionError(i, D.EFFECT_CLEANUP_FAILED);
|
|
776
799
|
}
|
|
777
800
|
return;
|
|
778
801
|
}
|
|
779
802
|
typeof s == "function" && (this._cleanup = s);
|
|
780
803
|
},
|
|
781
|
-
(s) =>
|
|
804
|
+
(s) => t === this._execId && this._handleExecutionError(s)
|
|
782
805
|
);
|
|
783
806
|
}
|
|
784
|
-
_finalizeDependencies(
|
|
785
|
-
if (this._nextLinks = null,
|
|
786
|
-
if (
|
|
787
|
-
for (let i = 0, o =
|
|
788
|
-
const r =
|
|
807
|
+
_finalizeDependencies(e, t, s) {
|
|
808
|
+
if (this._nextLinks = null, e) {
|
|
809
|
+
if (t !== U) {
|
|
810
|
+
for (let i = 0, o = t.length; i < o; i++) {
|
|
811
|
+
const r = t[i], c = r?.node._tempUnsub;
|
|
789
812
|
c && (c(), r && (r.node._tempUnsub = void 0));
|
|
790
813
|
}
|
|
791
|
-
|
|
814
|
+
X.release(t);
|
|
792
815
|
}
|
|
793
|
-
} else if (this._releaseLinks(s),
|
|
794
|
-
for (let i = 0, o =
|
|
795
|
-
|
|
796
|
-
}
|
|
797
|
-
_releaseLinks(
|
|
798
|
-
if (
|
|
799
|
-
for (let
|
|
800
|
-
t
|
|
801
|
-
|
|
816
|
+
} else if (this._releaseLinks(s), X.release(s), t !== U)
|
|
817
|
+
for (let i = 0, o = t.length; i < o; i++)
|
|
818
|
+
t[i] && (t[i].node._tempUnsub = void 0);
|
|
819
|
+
}
|
|
820
|
+
_releaseLinks(e) {
|
|
821
|
+
if (e !== U) {
|
|
822
|
+
for (let t = 0, s = e.length; t < s; t++)
|
|
823
|
+
e[t]?.unsub?.();
|
|
824
|
+
X.release(e);
|
|
802
825
|
}
|
|
803
826
|
}
|
|
804
827
|
_isDirty() {
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
828
|
+
const e = this._links, t = B.current;
|
|
829
|
+
B.current = null;
|
|
830
|
+
try {
|
|
831
|
+
for (let s = 0, i = e.length; s < i; s++) {
|
|
832
|
+
const o = e[s], r = o.node;
|
|
833
|
+
if ("value" in r)
|
|
834
|
+
try {
|
|
835
|
+
r.value;
|
|
836
|
+
} catch {
|
|
837
|
+
return A && console.warn(`[atom-effect] Dependency #${r.id} threw during dirty check`), !0;
|
|
838
|
+
}
|
|
839
|
+
if (r.version !== o.version) return !0;
|
|
816
840
|
}
|
|
841
|
+
return !1;
|
|
842
|
+
} finally {
|
|
843
|
+
B.current = t;
|
|
817
844
|
}
|
|
818
|
-
return !1;
|
|
819
845
|
}
|
|
820
846
|
_execCleanup() {
|
|
821
847
|
if (this._cleanup) {
|
|
822
848
|
try {
|
|
823
849
|
this._cleanup();
|
|
824
|
-
} catch (
|
|
825
|
-
this._handleExecutionError(
|
|
850
|
+
} catch (e) {
|
|
851
|
+
this._handleExecutionError(e, D.EFFECT_CLEANUP_FAILED);
|
|
826
852
|
}
|
|
827
853
|
this._cleanup = null;
|
|
828
854
|
}
|
|
829
855
|
}
|
|
830
856
|
_checkInfiniteLoops() {
|
|
831
|
-
const
|
|
832
|
-
if (this._lastFlushEpoch !==
|
|
833
|
-
const
|
|
834
|
-
this._history[this._historyPtr] =
|
|
857
|
+
const e = Se;
|
|
858
|
+
if (this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), ct() > q.MAX_EXECUTIONS_PER_FLUSH && this._throwInfiniteLoopError("global"), this._executionCount++, this._history) {
|
|
859
|
+
const t = Date.now();
|
|
860
|
+
this._history[this._historyPtr] = t, this._historyPtr = (this._historyPtr + 1) % this._historyCapacity;
|
|
835
861
|
const s = this._history[this._historyPtr] || 0;
|
|
836
|
-
if (s > 0 &&
|
|
837
|
-
const i = new
|
|
838
|
-
|
|
839
|
-
);
|
|
840
|
-
if (this.dispose(), this._handleExecutionError(i), m) throw i;
|
|
862
|
+
if (s > 0 && t - s < Je.ONE_SECOND_MS) {
|
|
863
|
+
const i = new G(D.EFFECT_FREQUENCY_LIMIT_EXCEEDED);
|
|
864
|
+
if (this.dispose(), this._handleExecutionError(i), A) throw i;
|
|
841
865
|
}
|
|
842
866
|
}
|
|
843
867
|
}
|
|
844
868
|
get isDisposed() {
|
|
845
|
-
return (this.flags &
|
|
869
|
+
return (this.flags & P.DISPOSED) !== 0;
|
|
846
870
|
}
|
|
847
871
|
get executionCount() {
|
|
848
872
|
return this._executionCount;
|
|
849
873
|
}
|
|
850
874
|
get isExecuting() {
|
|
851
|
-
return (this.flags &
|
|
875
|
+
return (this.flags & P.EXECUTING) !== 0;
|
|
852
876
|
}
|
|
853
|
-
_throwInfiniteLoopError(
|
|
854
|
-
const
|
|
855
|
-
`Infinite loop detected (${
|
|
877
|
+
_throwInfiniteLoopError(e) {
|
|
878
|
+
const t = new G(
|
|
879
|
+
`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Te}`
|
|
856
880
|
);
|
|
857
|
-
throw this.dispose(), console.error(
|
|
881
|
+
throw this.dispose(), console.error(t), t;
|
|
858
882
|
}
|
|
859
|
-
_handleExecutionError(
|
|
860
|
-
const s =
|
|
883
|
+
_handleExecutionError(e, t = D.EFFECT_EXECUTION_FAILED) {
|
|
884
|
+
const s = Z(e, G, t);
|
|
861
885
|
if (console.error(s), this._onError)
|
|
862
886
|
try {
|
|
863
887
|
this._onError(s);
|
|
864
888
|
} catch (i) {
|
|
865
|
-
console.error(
|
|
889
|
+
console.error(Z(i, G, D.CALLBACK_ERROR_IN_ERROR_HANDLER));
|
|
866
890
|
}
|
|
867
891
|
}
|
|
868
892
|
_checkLoopWarnings() {
|
|
869
|
-
if (this._trackModifications &&
|
|
870
|
-
const
|
|
871
|
-
for (let s = 0, i =
|
|
872
|
-
const o =
|
|
873
|
-
o._modifiedAtEpoch ===
|
|
893
|
+
if (this._trackModifications && Y.enabled) {
|
|
894
|
+
const e = this._currentEpoch, t = this._links;
|
|
895
|
+
for (let s = 0, i = t.length; s < i; s++) {
|
|
896
|
+
const o = t[s].node;
|
|
897
|
+
o._modifiedAtEpoch === e && Y.warn(
|
|
874
898
|
!0,
|
|
875
|
-
`Effect is reading a dependency (${
|
|
899
|
+
`Effect is reading a dependency (${Y.getDebugName(o) || "unknown"}) that it just modified. Infinite loop may occur`
|
|
876
900
|
);
|
|
877
901
|
}
|
|
878
902
|
}
|
|
879
903
|
}
|
|
880
904
|
}
|
|
881
|
-
function
|
|
905
|
+
function V(n, e = {}) {
|
|
882
906
|
if (typeof n != "function")
|
|
883
|
-
throw new
|
|
884
|
-
const
|
|
885
|
-
return
|
|
907
|
+
throw new G(D.EFFECT_MUST_BE_FUNCTION);
|
|
908
|
+
const t = new _t(n, e);
|
|
909
|
+
return t.execute(), t;
|
|
886
910
|
}
|
|
887
|
-
function
|
|
911
|
+
function Oe(n) {
|
|
888
912
|
if (typeof n != "function")
|
|
889
913
|
throw new TypeError("Batch callback must be a function");
|
|
890
|
-
|
|
914
|
+
$.startBatch();
|
|
891
915
|
try {
|
|
892
916
|
return n();
|
|
893
917
|
} finally {
|
|
894
|
-
|
|
918
|
+
$.endBatch();
|
|
895
919
|
}
|
|
896
920
|
}
|
|
897
|
-
function
|
|
921
|
+
function pt(n) {
|
|
898
922
|
return n !== null && typeof n == "object" && "value" in n && "subscribe" in n;
|
|
899
923
|
}
|
|
900
|
-
function
|
|
924
|
+
function me(n) {
|
|
901
925
|
if (!n) return "unknown";
|
|
902
|
-
const
|
|
903
|
-
if (!
|
|
904
|
-
const
|
|
905
|
-
if (
|
|
906
|
-
const s =
|
|
926
|
+
const e = "jquery" in n ? n[0] : n;
|
|
927
|
+
if (!e) return "unknown";
|
|
928
|
+
const t = e.id;
|
|
929
|
+
if (t && typeof t == "string") return `#${t}`;
|
|
930
|
+
const s = e.tagName.toLowerCase(), i = e.classList;
|
|
907
931
|
if (i && i.length > 0) {
|
|
908
932
|
let o = s;
|
|
909
933
|
for (let r = 0, c = i.length; r < c; r++) {
|
|
@@ -914,36 +938,60 @@ function ft(n) {
|
|
|
914
938
|
}
|
|
915
939
|
return s;
|
|
916
940
|
}
|
|
917
|
-
function
|
|
918
|
-
|
|
919
|
-
if (
|
|
920
|
-
|
|
941
|
+
function Ge(n) {
|
|
942
|
+
let e = String(n ?? "");
|
|
943
|
+
if (e = e.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, ""), e = e.replace(/<\?[\s\S]*?\?>/g, "").replace(
|
|
944
|
+
/<(script|iframe|object|embed|base|meta|form|applet|link|style|template|noscript|title)\b[^>]*>([\s\S]*?)<\/\1>/gim,
|
|
945
|
+
""
|
|
946
|
+
).replace(
|
|
947
|
+
/<(script|iframe|object|embed|base|meta|form|applet|link|style|template|noscript|title)\b[^>]*\/?>/gim,
|
|
948
|
+
""
|
|
949
|
+
), ((o) => o.replace(/&#x([0-9a-f]+);?/gi, (r, c) => String.fromCharCode(parseInt(c, 16))).replace(/&#([0-9]+);?/gi, (r, c) => String.fromCharCode(parseInt(c, 10))))(e).match(/(?:java|vb)script:|data:/i)) {
|
|
950
|
+
const o = (r) => new RegExp(
|
|
951
|
+
`${r.split("").map((c) => {
|
|
952
|
+
const l = c.charCodeAt(0);
|
|
953
|
+
return `(?:${c}|�*${l};?|�*${l.toString(16)};?)`;
|
|
954
|
+
}).join("\\s*")}\\s*(?::|:|&#x?0*((58)|(3a));?|%3a)`,
|
|
955
|
+
"gi"
|
|
956
|
+
);
|
|
957
|
+
e = e.replace(o("javascript"), "data-unsafe-protocol:").replace(o("vbscript"), "data-unsafe-protocol:");
|
|
958
|
+
} else {
|
|
959
|
+
const o = /((?: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*(?::|:|&#x?0*((58)|(3a));?|%3a))/gim;
|
|
960
|
+
e = e.replace(o, "data-unsafe-protocol:");
|
|
961
|
+
}
|
|
962
|
+
const i = /data\s*:\s*(?:text\/html|application\/javascript|text\/javascript|text\/vbscript)/gim;
|
|
963
|
+
return e = e.replace(i, "data-unsafe-protocol:"), e = e.replace(/\bon\w+\s*=/gim, "data-unsafe-attr="), e = e.replace(/expression\s*\(/gim, "data-unsafe-css(").replace(/behavior\s*:/gim, "data-unsafe-css:"), e;
|
|
964
|
+
}
|
|
965
|
+
function Et(n) {
|
|
966
|
+
const e = n.length;
|
|
967
|
+
if (e === 0) return new Int32Array(0);
|
|
968
|
+
const t = new Int32Array(e), s = new Int32Array(e);
|
|
921
969
|
let i = 0;
|
|
922
|
-
for (let r = 0; r <
|
|
970
|
+
for (let r = 0; r < e; r++) {
|
|
923
971
|
const c = n[r];
|
|
924
972
|
if (c === void 0 || c === -1) continue;
|
|
925
973
|
const l = i > 0 ? s[i - 1] : void 0;
|
|
926
974
|
if (i === 0 || l !== void 0 && (n[l] ?? -1) < c) {
|
|
927
|
-
|
|
975
|
+
t[r] = l ?? -1, s[i++] = r;
|
|
928
976
|
continue;
|
|
929
977
|
}
|
|
930
|
-
let
|
|
931
|
-
for (;
|
|
932
|
-
const C =
|
|
933
|
-
|
|
978
|
+
let _ = 0, g = i - 1;
|
|
979
|
+
for (; _ < g; ) {
|
|
980
|
+
const C = _ + g >>> 1, k = s[C];
|
|
981
|
+
k !== void 0 && (n[k] ?? -1) < c ? _ = C + 1 : g = C;
|
|
934
982
|
}
|
|
935
|
-
const
|
|
936
|
-
|
|
983
|
+
const v = s[_];
|
|
984
|
+
v !== void 0 && c < (n[v] ?? Number.MAX_SAFE_INTEGER) && (_ > 0 && (t[r] = s[_ - 1] ?? -1), s[_] = r);
|
|
937
985
|
}
|
|
938
986
|
const o = new Int32Array(i);
|
|
939
987
|
if (i > 0) {
|
|
940
988
|
let r = s[i - 1];
|
|
941
989
|
for (let c = i - 1; c >= 0 && r !== void 0 && r !== -1; c--)
|
|
942
|
-
o[c] = r, r =
|
|
990
|
+
o[c] = r, r = t[r];
|
|
943
991
|
}
|
|
944
992
|
return o;
|
|
945
993
|
}
|
|
946
|
-
function
|
|
994
|
+
function gt() {
|
|
947
995
|
if (typeof window < "u") {
|
|
948
996
|
const n = window.__ATOM_DEBUG__;
|
|
949
997
|
if (typeof n == "boolean") return n;
|
|
@@ -954,401 +1002,416 @@ function de() {
|
|
|
954
1002
|
}
|
|
955
1003
|
return !1;
|
|
956
1004
|
}
|
|
957
|
-
let
|
|
958
|
-
const
|
|
1005
|
+
let Q = gt();
|
|
1006
|
+
const b = {
|
|
959
1007
|
get enabled() {
|
|
960
|
-
return
|
|
1008
|
+
return Q;
|
|
961
1009
|
},
|
|
962
1010
|
set enabled(n) {
|
|
963
|
-
|
|
1011
|
+
Q = n;
|
|
964
1012
|
},
|
|
965
|
-
log(n, ...
|
|
966
|
-
|
|
1013
|
+
log(n, ...e) {
|
|
1014
|
+
Q && console.log(`[atom-effect-jquery] ${n}:`, ...e);
|
|
967
1015
|
},
|
|
968
|
-
atomChanged(n,
|
|
969
|
-
|
|
1016
|
+
atomChanged(n, e, t) {
|
|
1017
|
+
Q && console.log(
|
|
970
1018
|
`[atom-effect-jquery] Atom "${n ?? "anonymous"}" changed:`,
|
|
971
|
-
|
|
1019
|
+
e,
|
|
972
1020
|
"→",
|
|
973
|
-
|
|
1021
|
+
t
|
|
974
1022
|
);
|
|
975
1023
|
},
|
|
976
1024
|
/**
|
|
977
1025
|
* Logs DOM updates and triggers visual highlight.
|
|
978
1026
|
*/
|
|
979
|
-
domUpdated(n,
|
|
980
|
-
|
|
1027
|
+
domUpdated(n, e, t) {
|
|
1028
|
+
Q && (console.log(`[atom-effect-jquery] DOM updated: ${me(n)}.${e} =`, t), mt(n));
|
|
981
1029
|
},
|
|
982
1030
|
cleanup(n) {
|
|
983
|
-
|
|
1031
|
+
Q && console.log(`[atom-effect-jquery] Cleanup: ${n}`);
|
|
984
1032
|
},
|
|
985
1033
|
warn(...n) {
|
|
986
|
-
|
|
987
|
-
}
|
|
988
|
-
},
|
|
989
|
-
function
|
|
990
|
-
const
|
|
991
|
-
if (!
|
|
992
|
-
let
|
|
993
|
-
if (
|
|
994
|
-
const i =
|
|
995
|
-
|
|
1034
|
+
Q && console.warn("[atom-effect-jquery]", ...n);
|
|
1035
|
+
}
|
|
1036
|
+
}, be = /* @__PURE__ */ new WeakMap();
|
|
1037
|
+
function mt(n) {
|
|
1038
|
+
const e = "jquery" in n ? n[0] : n;
|
|
1039
|
+
if (!e || !e.isConnected) return;
|
|
1040
|
+
let t = be.get(e);
|
|
1041
|
+
if (t || (t = {}, be.set(e, t)), t.timer && clearTimeout(t.timer), t.cleanupTimer && clearTimeout(t.cleanupTimer), !t.orgStyle) {
|
|
1042
|
+
const i = e.style;
|
|
1043
|
+
t.orgStyle = {
|
|
996
1044
|
outline: i.outline,
|
|
997
1045
|
outlineOffset: i.outlineOffset,
|
|
998
1046
|
transition: i.transition
|
|
999
1047
|
};
|
|
1000
1048
|
}
|
|
1001
|
-
const s =
|
|
1002
|
-
s.outline = "2px solid rgba(255, 68, 68, 0.8)", s.outlineOffset = "1px", s.transition = "none",
|
|
1003
|
-
|
|
1004
|
-
if (!
|
|
1005
|
-
const i =
|
|
1006
|
-
i && (s.outline = i.outline, s.outlineOffset = i.outlineOffset),
|
|
1007
|
-
|
|
1049
|
+
const s = e.style;
|
|
1050
|
+
s.outline = "2px solid rgba(255, 68, 68, 0.8)", s.outlineOffset = "1px", s.transition = "none", t.timer = setTimeout(() => {
|
|
1051
|
+
e.isConnected && (s.transition = "outline 0.5s ease-out", requestAnimationFrame(() => {
|
|
1052
|
+
if (!e.isConnected) return;
|
|
1053
|
+
const i = t?.orgStyle;
|
|
1054
|
+
i && (s.outline = i.outline, s.outlineOffset = i.outlineOffset), t.cleanupTimer = setTimeout(() => {
|
|
1055
|
+
e.isConnected && t?.orgStyle && (s.transition = t.orgStyle.transition), be.delete(e);
|
|
1008
1056
|
}, 500);
|
|
1009
1057
|
}));
|
|
1010
1058
|
}, 100);
|
|
1011
1059
|
}
|
|
1012
|
-
const
|
|
1013
|
-
function
|
|
1014
|
-
const
|
|
1015
|
-
return
|
|
1060
|
+
const yt = /* @__PURE__ */ new WeakMap();
|
|
1061
|
+
function Ye(n, e = {}) {
|
|
1062
|
+
const t = ze(n, e);
|
|
1063
|
+
return e.name && yt.set(t, { name: e.name }), t;
|
|
1016
1064
|
}
|
|
1017
|
-
Object.defineProperty(
|
|
1065
|
+
Object.defineProperty(Ye, "debug", {
|
|
1018
1066
|
get() {
|
|
1019
|
-
return
|
|
1067
|
+
return b.enabled;
|
|
1020
1068
|
},
|
|
1021
1069
|
set(n) {
|
|
1022
|
-
|
|
1070
|
+
b.enabled = n;
|
|
1023
1071
|
}
|
|
1024
1072
|
});
|
|
1025
|
-
function
|
|
1073
|
+
function bt() {
|
|
1026
1074
|
return new Promise((n) => setTimeout(n, 0));
|
|
1027
1075
|
}
|
|
1028
1076
|
u.extend({
|
|
1029
|
-
atom:
|
|
1030
|
-
computed:
|
|
1031
|
-
effect:
|
|
1032
|
-
batch:
|
|
1033
|
-
untracked:
|
|
1034
|
-
isAtom:
|
|
1035
|
-
isComputed:
|
|
1036
|
-
isReactive: (n) =>
|
|
1037
|
-
nextTick:
|
|
1077
|
+
atom: Ye,
|
|
1078
|
+
computed: dt,
|
|
1079
|
+
effect: V,
|
|
1080
|
+
batch: Oe,
|
|
1081
|
+
untracked: at,
|
|
1082
|
+
isAtom: De,
|
|
1083
|
+
isComputed: Le,
|
|
1084
|
+
isReactive: (n) => De(n) || Le(n),
|
|
1085
|
+
nextTick: bt
|
|
1038
1086
|
});
|
|
1039
|
-
const
|
|
1040
|
-
class
|
|
1087
|
+
const ue = "_aes-bound";
|
|
1088
|
+
class Ct {
|
|
1041
1089
|
records = /* @__PURE__ */ new WeakMap();
|
|
1042
1090
|
boundElements = /* @__PURE__ */ new WeakSet();
|
|
1043
1091
|
preservedNodes = /* @__PURE__ */ new WeakSet();
|
|
1044
1092
|
ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1045
1093
|
// Prevent redundant cleanup
|
|
1046
|
-
keep(
|
|
1047
|
-
this.preservedNodes.add(
|
|
1094
|
+
keep(e) {
|
|
1095
|
+
this.preservedNodes.add(e);
|
|
1048
1096
|
}
|
|
1049
|
-
isKept(
|
|
1050
|
-
return this.preservedNodes.has(
|
|
1097
|
+
isKept(e) {
|
|
1098
|
+
return this.preservedNodes.has(e);
|
|
1051
1099
|
}
|
|
1052
|
-
markIgnored(
|
|
1053
|
-
this.ignoredNodes.add(
|
|
1100
|
+
markIgnored(e) {
|
|
1101
|
+
this.ignoredNodes.add(e);
|
|
1054
1102
|
}
|
|
1055
|
-
isIgnored(
|
|
1056
|
-
return this.ignoredNodes.has(
|
|
1103
|
+
isIgnored(e) {
|
|
1104
|
+
return this.ignoredNodes.has(e);
|
|
1057
1105
|
}
|
|
1058
|
-
_getOrCreateRecord(
|
|
1059
|
-
let
|
|
1060
|
-
return
|
|
1106
|
+
_getOrCreateRecord(e) {
|
|
1107
|
+
let t = this.records.get(e);
|
|
1108
|
+
return t || (t = {}, this.records.set(e, t), this.boundElements.has(e) || (this.boundElements.add(e), e.classList.add(ue))), t;
|
|
1061
1109
|
}
|
|
1062
|
-
trackEffect(
|
|
1063
|
-
const s = this._getOrCreateRecord(
|
|
1064
|
-
s.effects || (s.effects = []), s.effects.push(
|
|
1110
|
+
trackEffect(e, t) {
|
|
1111
|
+
const s = this._getOrCreateRecord(e);
|
|
1112
|
+
s.effects || (s.effects = []), s.effects.push(t);
|
|
1065
1113
|
}
|
|
1066
|
-
trackCleanup(
|
|
1067
|
-
const s = this._getOrCreateRecord(
|
|
1068
|
-
s.cleanups || (s.cleanups = []), s.cleanups.push(
|
|
1114
|
+
trackCleanup(e, t) {
|
|
1115
|
+
const s = this._getOrCreateRecord(e);
|
|
1116
|
+
s.cleanups || (s.cleanups = []), s.cleanups.push(t);
|
|
1069
1117
|
}
|
|
1070
|
-
hasBind(
|
|
1071
|
-
return this.boundElements.has(
|
|
1118
|
+
hasBind(e) {
|
|
1119
|
+
return this.boundElements.has(e);
|
|
1072
1120
|
}
|
|
1073
|
-
cleanup(
|
|
1074
|
-
if (!this.boundElements.delete(
|
|
1075
|
-
const
|
|
1076
|
-
if (!
|
|
1077
|
-
this.records.delete(
|
|
1078
|
-
const s =
|
|
1121
|
+
cleanup(e) {
|
|
1122
|
+
if (!this.boundElements.delete(e)) return;
|
|
1123
|
+
const t = this.records.get(e);
|
|
1124
|
+
if (!t) return;
|
|
1125
|
+
this.records.delete(e), this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.classList.remove(ue), b.enabled && b.cleanup(me(e));
|
|
1126
|
+
const s = t.effects;
|
|
1079
1127
|
if (s)
|
|
1080
1128
|
for (let o = 0, r = s.length; o < r; o++)
|
|
1081
1129
|
try {
|
|
1082
1130
|
s[o]?.dispose();
|
|
1083
1131
|
} catch (c) {
|
|
1084
|
-
|
|
1132
|
+
b.warn("Effect dispose error:", c);
|
|
1085
1133
|
}
|
|
1086
|
-
const i =
|
|
1134
|
+
const i = t.cleanups;
|
|
1087
1135
|
if (i)
|
|
1088
1136
|
for (let o = 0, r = i.length; o < r; o++)
|
|
1089
1137
|
try {
|
|
1090
1138
|
i[o]?.();
|
|
1091
1139
|
} catch (c) {
|
|
1092
|
-
|
|
1140
|
+
b.warn("Cleanup error:", c);
|
|
1093
1141
|
}
|
|
1094
1142
|
}
|
|
1095
|
-
cleanupDescendants(
|
|
1096
|
-
const
|
|
1097
|
-
for (let s = 0, i =
|
|
1098
|
-
const o =
|
|
1099
|
-
o && this.boundElements.has(o) ? this.cleanup(o) : o && o.classList.remove(
|
|
1143
|
+
cleanupDescendants(e) {
|
|
1144
|
+
const t = e.querySelectorAll(`.${ue}`);
|
|
1145
|
+
for (let s = 0, i = t.length; s < i; s++) {
|
|
1146
|
+
const o = t[s];
|
|
1147
|
+
o && this.boundElements.has(o) ? this.cleanup(o) : o && o.classList.remove(ue);
|
|
1100
1148
|
}
|
|
1101
1149
|
}
|
|
1102
|
-
cleanupTree(
|
|
1103
|
-
this.cleanupDescendants(
|
|
1150
|
+
cleanupTree(e) {
|
|
1151
|
+
this.cleanupDescendants(e), this.cleanup(e);
|
|
1104
1152
|
}
|
|
1105
1153
|
}
|
|
1106
|
-
const
|
|
1107
|
-
let
|
|
1108
|
-
function
|
|
1109
|
-
|
|
1110
|
-
for (let
|
|
1111
|
-
const i = t
|
|
1154
|
+
const y = new Ct();
|
|
1155
|
+
let se = null;
|
|
1156
|
+
function It(n = document.body) {
|
|
1157
|
+
se || (se = new MutationObserver((e) => {
|
|
1158
|
+
for (let t = 0, s = e.length; t < s; t++) {
|
|
1159
|
+
const i = e[t]?.removedNodes;
|
|
1112
1160
|
if (!i) continue;
|
|
1113
1161
|
const o = i.length;
|
|
1114
1162
|
if (o !== 0)
|
|
1115
1163
|
for (let r = 0; r < o; r++) {
|
|
1116
1164
|
const c = i[r];
|
|
1117
|
-
c.nodeType === 1 && (c.isConnected ||
|
|
1165
|
+
c.nodeType === 1 && (c.isConnected || y.isKept(c) || y.isIgnored(c) || y.cleanupTree(c));
|
|
1118
1166
|
}
|
|
1119
1167
|
}
|
|
1120
|
-
}),
|
|
1168
|
+
}), se.observe(n, { childList: !0, subtree: !0 }));
|
|
1121
1169
|
}
|
|
1122
|
-
function
|
|
1123
|
-
|
|
1170
|
+
function $t() {
|
|
1171
|
+
se?.disconnect(), se = null;
|
|
1124
1172
|
}
|
|
1125
|
-
function
|
|
1126
|
-
|
|
1173
|
+
function O(n, e, t, s) {
|
|
1174
|
+
pt(e) ? y.trackEffect(
|
|
1127
1175
|
n,
|
|
1128
|
-
|
|
1129
|
-
const i =
|
|
1130
|
-
|
|
1176
|
+
V(() => {
|
|
1177
|
+
const i = e.value;
|
|
1178
|
+
t(i), b.domUpdated(u(n), s, i);
|
|
1131
1179
|
})
|
|
1132
|
-
) : (e
|
|
1180
|
+
) : (t(e), b.domUpdated(u(n), s, e));
|
|
1133
1181
|
}
|
|
1134
|
-
var
|
|
1135
|
-
function
|
|
1182
|
+
var S = /* @__PURE__ */ ((n) => (n[n.None = 0] = "None", n[n.Focused = 1] = "Focused", n[n.Composing = 2] = "Composing", n[n.SyncingToAtom = 4] = "SyncingToAtom", n[n.SyncingToDom = 8] = "SyncingToDom", n[n.Busy = 14] = "Busy", n))(S || {});
|
|
1183
|
+
function ke() {
|
|
1136
1184
|
return {
|
|
1137
1185
|
timeoutId: null,
|
|
1138
1186
|
flags: 0
|
|
1139
1187
|
/* None */
|
|
1140
1188
|
};
|
|
1141
1189
|
}
|
|
1142
|
-
function
|
|
1190
|
+
function We(n, e, t = {}) {
|
|
1143
1191
|
const {
|
|
1144
1192
|
debounce: s,
|
|
1145
1193
|
event: i = "input",
|
|
1146
|
-
parse: o = (
|
|
1147
|
-
format: r = (
|
|
1194
|
+
parse: o = (w) => w,
|
|
1195
|
+
format: r = (w) => String(w ?? ""),
|
|
1148
1196
|
equal: c = Object.is
|
|
1149
|
-
} =
|
|
1150
|
-
if (!(l.flags &
|
|
1151
|
-
l.flags |=
|
|
1197
|
+
} = t, l = ke(), _ = n[0], g = () => {
|
|
1198
|
+
if (!(l.flags & S.Busy)) {
|
|
1199
|
+
l.flags |= S.SyncingToAtom;
|
|
1152
1200
|
try {
|
|
1153
|
-
const
|
|
1154
|
-
c(
|
|
1201
|
+
const w = _.value, N = o(w);
|
|
1202
|
+
c(e.value, N) || (e.value = N);
|
|
1155
1203
|
} finally {
|
|
1156
|
-
l.flags &= ~
|
|
1204
|
+
l.flags &= ~S.SyncingToAtom;
|
|
1157
1205
|
}
|
|
1158
1206
|
}
|
|
1159
|
-
},
|
|
1160
|
-
l.timeoutId && (clearTimeout(l.timeoutId), l.timeoutId = null,
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1207
|
+
}, v = () => {
|
|
1208
|
+
l.timeoutId && (clearTimeout(l.timeoutId), l.timeoutId = null, g()), l.flags &= ~S.Focused;
|
|
1209
|
+
const w = r(e.value);
|
|
1210
|
+
_.value !== w && (_.value = w);
|
|
1163
1211
|
}, C = () => {
|
|
1164
|
-
l.flags &
|
|
1165
|
-
},
|
|
1212
|
+
l.flags & S.Busy || (s ? (l.timeoutId && clearTimeout(l.timeoutId), l.timeoutId = setTimeout(g, s)) : g());
|
|
1213
|
+
}, k = {
|
|
1166
1214
|
compositionstart: () => {
|
|
1167
|
-
l.flags |=
|
|
1215
|
+
l.flags |= S.Composing;
|
|
1168
1216
|
},
|
|
1169
1217
|
compositionend: () => {
|
|
1170
|
-
l.flags &= ~
|
|
1218
|
+
l.flags &= ~S.Composing, g();
|
|
1171
1219
|
},
|
|
1172
1220
|
focus: () => {
|
|
1173
|
-
l.flags |=
|
|
1221
|
+
l.flags |= S.Focused;
|
|
1174
1222
|
},
|
|
1175
|
-
blur:
|
|
1223
|
+
blur: v,
|
|
1176
1224
|
[i]: C,
|
|
1177
1225
|
change: C
|
|
1178
1226
|
};
|
|
1179
|
-
return n.on(
|
|
1180
|
-
const
|
|
1181
|
-
if (
|
|
1182
|
-
l.flags |=
|
|
1227
|
+
return n.on(k), { effect: () => {
|
|
1228
|
+
const w = e.value, N = r(w), x = _.value;
|
|
1229
|
+
if (x !== N && !(l.flags & S.Focused && c(o(x), w))) {
|
|
1230
|
+
l.flags |= S.SyncingToDom;
|
|
1183
1231
|
try {
|
|
1184
|
-
if (l.flags &
|
|
1185
|
-
const { selectionStart:
|
|
1186
|
-
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1232
|
+
if (l.flags & S.Focused) {
|
|
1233
|
+
const { selectionStart: L, selectionEnd: W } = _;
|
|
1234
|
+
_.value = N;
|
|
1235
|
+
const F = N.length;
|
|
1236
|
+
_.setSelectionRange(Math.min(L ?? F, F), Math.min(W ?? F, F));
|
|
1189
1237
|
} else
|
|
1190
|
-
|
|
1191
|
-
|
|
1238
|
+
_.value = N;
|
|
1239
|
+
b.domUpdated(n, "val", N);
|
|
1192
1240
|
} finally {
|
|
1193
|
-
l.flags &= ~
|
|
1241
|
+
l.flags &= ~S.SyncingToDom;
|
|
1194
1242
|
}
|
|
1195
1243
|
}
|
|
1196
1244
|
}, cleanup: () => {
|
|
1197
|
-
n.off(
|
|
1245
|
+
n.off(k), l.timeoutId && clearTimeout(l.timeoutId);
|
|
1198
1246
|
} };
|
|
1199
1247
|
}
|
|
1200
|
-
u.fn.atomText = function(n,
|
|
1248
|
+
u.fn.atomText = function(n, e) {
|
|
1201
1249
|
return this.each(function() {
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1250
|
+
const t = u(this);
|
|
1251
|
+
O(this, n, e ? (i) => t.text(e(i)) : (i) => t.text(String(i ?? "")), "text");
|
|
1204
1252
|
});
|
|
1205
1253
|
};
|
|
1206
1254
|
u.fn.atomHtml = function(n) {
|
|
1207
1255
|
return this.each(function() {
|
|
1208
|
-
const
|
|
1209
|
-
|
|
1256
|
+
const e = u(this);
|
|
1257
|
+
O(
|
|
1258
|
+
this,
|
|
1259
|
+
n,
|
|
1260
|
+
(t) => {
|
|
1261
|
+
const s = String(t ?? ""), i = Ge(s);
|
|
1262
|
+
i !== s && console.warn("[atomHtml] Unsafe content neutralized during sanitization."), e.html(i);
|
|
1263
|
+
},
|
|
1264
|
+
"html"
|
|
1265
|
+
);
|
|
1210
1266
|
});
|
|
1211
1267
|
};
|
|
1212
|
-
u.fn.atomClass = function(n,
|
|
1268
|
+
u.fn.atomClass = function(n, e) {
|
|
1213
1269
|
return this.each(function() {
|
|
1214
|
-
const
|
|
1215
|
-
|
|
1270
|
+
const t = u(this);
|
|
1271
|
+
O(
|
|
1216
1272
|
this,
|
|
1217
|
-
|
|
1218
|
-
(s) =>
|
|
1273
|
+
e,
|
|
1274
|
+
(s) => t.toggleClass(n, !!s),
|
|
1219
1275
|
`class.${n}`
|
|
1220
1276
|
);
|
|
1221
1277
|
});
|
|
1222
1278
|
};
|
|
1223
|
-
u.fn.atomCss = function(n,
|
|
1279
|
+
u.fn.atomCss = function(n, e, t) {
|
|
1224
1280
|
return this.each(function() {
|
|
1225
1281
|
const s = u(this);
|
|
1226
|
-
|
|
1282
|
+
O(this, e, t ? (o) => s.css(n, `${o}${t}`) : (o) => s.css(n, o), `css.${n}`);
|
|
1227
1283
|
});
|
|
1228
1284
|
};
|
|
1229
|
-
u.fn.atomAttr = function(n,
|
|
1285
|
+
u.fn.atomAttr = function(n, e) {
|
|
1230
1286
|
return this.each(function() {
|
|
1231
|
-
const
|
|
1232
|
-
|
|
1287
|
+
const t = u(this);
|
|
1288
|
+
O(
|
|
1233
1289
|
this,
|
|
1234
|
-
|
|
1290
|
+
e,
|
|
1235
1291
|
(s) => {
|
|
1236
1292
|
if (s == null || s === !1) {
|
|
1237
|
-
|
|
1293
|
+
t.removeAttr(n);
|
|
1238
1294
|
return;
|
|
1239
1295
|
}
|
|
1240
|
-
|
|
1296
|
+
t.attr(n, s === !0 ? n : String(s));
|
|
1241
1297
|
},
|
|
1242
1298
|
`attr.${n}`
|
|
1243
1299
|
);
|
|
1244
1300
|
});
|
|
1245
1301
|
};
|
|
1246
|
-
u.fn.atomProp = function(n,
|
|
1302
|
+
u.fn.atomProp = function(n, e) {
|
|
1247
1303
|
return this.each(function() {
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1304
|
+
const t = u(this);
|
|
1305
|
+
O(this, e, (s) => t.prop(n, s), `prop.${n}`);
|
|
1250
1306
|
});
|
|
1251
1307
|
};
|
|
1252
1308
|
u.fn.atomShow = function(n) {
|
|
1253
1309
|
return this.each(function() {
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1310
|
+
const e = u(this);
|
|
1311
|
+
O(this, n, (t) => e.toggle(!!t), "show");
|
|
1256
1312
|
});
|
|
1257
1313
|
};
|
|
1258
1314
|
u.fn.atomHide = function(n) {
|
|
1259
1315
|
return this.each(function() {
|
|
1260
|
-
const
|
|
1261
|
-
|
|
1316
|
+
const e = u(this);
|
|
1317
|
+
O(this, n, (t) => e.toggle(!t), "hide");
|
|
1262
1318
|
});
|
|
1263
1319
|
};
|
|
1264
|
-
u.fn.atomVal = function(n,
|
|
1320
|
+
u.fn.atomVal = function(n, e = {}) {
|
|
1265
1321
|
return this.each(function() {
|
|
1266
|
-
const
|
|
1267
|
-
|
|
1322
|
+
const t = this.tagName.toLowerCase();
|
|
1323
|
+
if (!["input", "select", "textarea"].includes(t)) {
|
|
1324
|
+
console.warn(`[atomVal] Element <${t}> is not a valid input element.`);
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
const { effect: s, cleanup: i } = We(u(this), n, e);
|
|
1328
|
+
y.trackEffect(this, V(s)), y.trackCleanup(this, i);
|
|
1268
1329
|
});
|
|
1269
1330
|
};
|
|
1270
1331
|
u.fn.atomChecked = function(n) {
|
|
1271
1332
|
return this.each(function() {
|
|
1272
|
-
const
|
|
1273
|
-
if (s.flags &
|
|
1274
|
-
const r =
|
|
1333
|
+
const e = u(this), t = this, s = ke(), i = () => {
|
|
1334
|
+
if (s.flags & S.Busy) return;
|
|
1335
|
+
const r = t.checked;
|
|
1275
1336
|
n.value !== r && (n.value = r);
|
|
1276
1337
|
};
|
|
1277
|
-
|
|
1278
|
-
const o =
|
|
1279
|
-
s.flags |=
|
|
1338
|
+
e.on("change", i), y.trackCleanup(this, () => e.off("change", i));
|
|
1339
|
+
const o = V(() => {
|
|
1340
|
+
s.flags |= S.SyncingToDom;
|
|
1280
1341
|
const r = !!n.value;
|
|
1281
|
-
|
|
1342
|
+
t.checked !== r && (t.checked = r, b.domUpdated(e, "checked", r)), s.flags &= ~S.SyncingToDom;
|
|
1282
1343
|
});
|
|
1283
|
-
|
|
1344
|
+
y.trackEffect(this, o);
|
|
1284
1345
|
});
|
|
1285
1346
|
};
|
|
1286
|
-
u.fn.atomOn = function(n,
|
|
1347
|
+
u.fn.atomOn = function(n, e) {
|
|
1287
1348
|
return this.each(function() {
|
|
1288
|
-
const
|
|
1289
|
-
|
|
1349
|
+
const t = u(this);
|
|
1350
|
+
t.on(n, e), y.trackCleanup(this, () => t.off(n, e));
|
|
1290
1351
|
});
|
|
1291
1352
|
};
|
|
1292
1353
|
u.fn.atomUnbind = function() {
|
|
1293
1354
|
return this.each(function() {
|
|
1294
|
-
|
|
1355
|
+
y.cleanupTree(this);
|
|
1295
1356
|
});
|
|
1296
1357
|
};
|
|
1297
|
-
const
|
|
1298
|
-
function
|
|
1299
|
-
let
|
|
1300
|
-
return
|
|
1358
|
+
const Fe = /* @__PURE__ */ Object.create(null);
|
|
1359
|
+
function St(n) {
|
|
1360
|
+
let e = Fe[n];
|
|
1361
|
+
return e || (e = n.includes("-") ? n.replace(/-./g, (t) => t[1].toUpperCase()) : n, Fe[n] = e, e);
|
|
1301
1362
|
}
|
|
1302
|
-
function
|
|
1303
|
-
const
|
|
1304
|
-
|
|
1305
|
-
e,
|
|
1363
|
+
function Dt(n, e) {
|
|
1364
|
+
const t = n.el;
|
|
1365
|
+
O(
|
|
1306
1366
|
t,
|
|
1367
|
+
e,
|
|
1307
1368
|
(s) => {
|
|
1308
1369
|
const i = typeof s == "string" ? s : String(s ?? "");
|
|
1309
|
-
|
|
1370
|
+
t.textContent !== i && (t.textContent = i);
|
|
1310
1371
|
},
|
|
1311
1372
|
"text"
|
|
1312
1373
|
);
|
|
1313
1374
|
}
|
|
1314
|
-
function
|
|
1315
|
-
const
|
|
1316
|
-
|
|
1317
|
-
e,
|
|
1375
|
+
function vt(n, e) {
|
|
1376
|
+
const t = n.el;
|
|
1377
|
+
O(
|
|
1318
1378
|
t,
|
|
1379
|
+
e,
|
|
1319
1380
|
(s) => {
|
|
1320
|
-
const i = String(s ?? "");
|
|
1321
|
-
|
|
1381
|
+
const i = String(s ?? ""), o = Ge(i);
|
|
1382
|
+
o !== i && console.warn("[atomBind] Unsafe content neutralized during sanitization.");
|
|
1383
|
+
const r = o;
|
|
1384
|
+
t.innerHTML !== r && (t.innerHTML = r);
|
|
1322
1385
|
},
|
|
1323
1386
|
"html"
|
|
1324
1387
|
);
|
|
1325
1388
|
}
|
|
1326
|
-
function
|
|
1327
|
-
for (const
|
|
1328
|
-
|
|
1389
|
+
function Tt(n, e) {
|
|
1390
|
+
for (const t in e)
|
|
1391
|
+
O(
|
|
1329
1392
|
n.el,
|
|
1330
|
-
t
|
|
1393
|
+
e[t],
|
|
1331
1394
|
(s) => {
|
|
1332
|
-
n.el.classList.toggle(
|
|
1395
|
+
n.el.classList.toggle(t, !!s);
|
|
1333
1396
|
},
|
|
1334
|
-
`class.${
|
|
1397
|
+
`class.${t}`
|
|
1335
1398
|
);
|
|
1336
1399
|
}
|
|
1337
|
-
function
|
|
1338
|
-
const
|
|
1339
|
-
for (const i in
|
|
1340
|
-
const o =
|
|
1400
|
+
function Ot(n, e) {
|
|
1401
|
+
const t = n.el, s = t.style;
|
|
1402
|
+
for (const i in e) {
|
|
1403
|
+
const o = e[i];
|
|
1341
1404
|
if (o === void 0) continue;
|
|
1342
|
-
const r =
|
|
1343
|
-
Array.isArray(o) ?
|
|
1344
|
-
|
|
1405
|
+
const r = St(i);
|
|
1406
|
+
Array.isArray(o) ? O(
|
|
1407
|
+
t,
|
|
1345
1408
|
o[0],
|
|
1346
1409
|
(c) => {
|
|
1347
1410
|
s[r] = `${c}${o[1]}`;
|
|
1348
1411
|
},
|
|
1349
1412
|
`css.${i}`
|
|
1350
|
-
) :
|
|
1351
|
-
|
|
1413
|
+
) : O(
|
|
1414
|
+
t,
|
|
1352
1415
|
o,
|
|
1353
1416
|
(c) => {
|
|
1354
1417
|
s[r] = c;
|
|
@@ -1357,279 +1420,421 @@ function De(n, t) {
|
|
|
1357
1420
|
);
|
|
1358
1421
|
}
|
|
1359
1422
|
}
|
|
1360
|
-
function
|
|
1361
|
-
const
|
|
1362
|
-
for (const s in
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1423
|
+
function kt(n, e) {
|
|
1424
|
+
const t = n.el;
|
|
1425
|
+
for (const s in e)
|
|
1426
|
+
O(
|
|
1427
|
+
t,
|
|
1428
|
+
e[s],
|
|
1366
1429
|
(i) => {
|
|
1367
1430
|
if (i == null || i === !1) {
|
|
1368
|
-
|
|
1431
|
+
t.removeAttribute(s);
|
|
1369
1432
|
return;
|
|
1370
1433
|
}
|
|
1371
1434
|
const o = i === !0 ? s : String(i);
|
|
1372
|
-
|
|
1435
|
+
t.getAttribute(s) !== o && t.setAttribute(s, o);
|
|
1373
1436
|
},
|
|
1374
1437
|
`attr.${s}`
|
|
1375
1438
|
);
|
|
1376
1439
|
}
|
|
1377
|
-
function
|
|
1378
|
-
const
|
|
1379
|
-
for (const s in
|
|
1380
|
-
|
|
1440
|
+
function wt(n, e) {
|
|
1441
|
+
const t = n.el;
|
|
1442
|
+
for (const s in e)
|
|
1443
|
+
O(
|
|
1381
1444
|
n.el,
|
|
1382
|
-
|
|
1445
|
+
e[s],
|
|
1383
1446
|
(i) => {
|
|
1384
|
-
|
|
1447
|
+
t[s] !== i && (t[s] = i);
|
|
1385
1448
|
},
|
|
1386
1449
|
`prop.${s}`
|
|
1387
1450
|
);
|
|
1388
1451
|
}
|
|
1389
|
-
function
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1392
|
-
e,
|
|
1452
|
+
function Nt(n, e) {
|
|
1453
|
+
const t = n.el;
|
|
1454
|
+
O(
|
|
1393
1455
|
t,
|
|
1456
|
+
e,
|
|
1394
1457
|
(s) => {
|
|
1395
|
-
|
|
1458
|
+
t.style.display = s ? "" : "none", b.enabled && b.domUpdated(t, "show", s);
|
|
1396
1459
|
},
|
|
1397
1460
|
"show"
|
|
1398
1461
|
);
|
|
1399
1462
|
}
|
|
1400
|
-
function
|
|
1401
|
-
const
|
|
1402
|
-
|
|
1403
|
-
e,
|
|
1463
|
+
function Rt(n, e) {
|
|
1464
|
+
const t = n.el;
|
|
1465
|
+
O(
|
|
1404
1466
|
t,
|
|
1467
|
+
e,
|
|
1405
1468
|
(s) => {
|
|
1406
|
-
|
|
1469
|
+
t.style.display = s ? "none" : "", b.enabled && b.domUpdated(t, "hide", s);
|
|
1407
1470
|
},
|
|
1408
1471
|
"hide"
|
|
1409
1472
|
);
|
|
1410
1473
|
}
|
|
1411
|
-
function
|
|
1412
|
-
const
|
|
1474
|
+
function xt(n, e) {
|
|
1475
|
+
const t = n.el.tagName.toLowerCase();
|
|
1476
|
+
if (!["input", "select", "textarea"].includes(t)) {
|
|
1477
|
+
console.warn(`[atomBind] Val binding used on non-input element <${t}>.`);
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
const s = Array.isArray(e), { effect: i, cleanup: o } = We(
|
|
1413
1481
|
n.$el,
|
|
1414
|
-
|
|
1415
|
-
|
|
1482
|
+
s ? e[0] : e,
|
|
1483
|
+
s ? e[1] : {}
|
|
1416
1484
|
);
|
|
1417
|
-
|
|
1485
|
+
y.trackEffect(n.el, V(i)), n.trackCleanup(o);
|
|
1418
1486
|
}
|
|
1419
|
-
function
|
|
1420
|
-
const
|
|
1421
|
-
if (s.flags &
|
|
1422
|
-
const r =
|
|
1423
|
-
|
|
1487
|
+
function At(n, e) {
|
|
1488
|
+
const t = n.el, s = ke(), i = () => {
|
|
1489
|
+
if (s.flags & S.Busy) return;
|
|
1490
|
+
const r = t.checked;
|
|
1491
|
+
e.value !== r && (e.value = r);
|
|
1424
1492
|
};
|
|
1425
|
-
|
|
1426
|
-
const o =
|
|
1427
|
-
s.flags |=
|
|
1428
|
-
const r = !!
|
|
1429
|
-
|
|
1493
|
+
t.addEventListener("change", i), n.trackCleanup(() => t.removeEventListener("change", i));
|
|
1494
|
+
const o = V(() => {
|
|
1495
|
+
s.flags |= S.SyncingToDom;
|
|
1496
|
+
const r = !!e.value;
|
|
1497
|
+
t.checked !== r && (t.checked = r, b.enabled && b.domUpdated(t, "checked", r)), s.flags &= ~S.SyncingToDom;
|
|
1430
1498
|
});
|
|
1431
|
-
|
|
1499
|
+
y.trackEffect(t, o);
|
|
1432
1500
|
}
|
|
1433
|
-
function
|
|
1434
|
-
for (const
|
|
1435
|
-
const s = t
|
|
1501
|
+
function Lt(n, e) {
|
|
1502
|
+
for (const t in e) {
|
|
1503
|
+
const s = e[t];
|
|
1436
1504
|
if (typeof s != "function") continue;
|
|
1437
1505
|
const i = (o) => {
|
|
1438
|
-
|
|
1506
|
+
Oe(
|
|
1439
1507
|
() => s.call(
|
|
1440
1508
|
n.el,
|
|
1441
1509
|
u.Event(o.type, { originalEvent: o })
|
|
1442
1510
|
)
|
|
1443
1511
|
);
|
|
1444
1512
|
};
|
|
1445
|
-
n.el.addEventListener(
|
|
1513
|
+
n.el.addEventListener(t, i), n.trackCleanup(() => n.el.removeEventListener(t, i));
|
|
1446
1514
|
}
|
|
1447
1515
|
}
|
|
1448
1516
|
u.fn.atomBind = function(n) {
|
|
1449
1517
|
return this.each(function() {
|
|
1450
|
-
const
|
|
1451
|
-
let
|
|
1518
|
+
const e = this;
|
|
1519
|
+
let t = null;
|
|
1452
1520
|
const s = {
|
|
1453
1521
|
get $el() {
|
|
1454
|
-
return
|
|
1522
|
+
return t || (t = u(e)), t;
|
|
1455
1523
|
},
|
|
1456
|
-
el:
|
|
1457
|
-
trackCleanup: (i) =>
|
|
1524
|
+
el: e,
|
|
1525
|
+
trackCleanup: (i) => y.trackCleanup(e, i)
|
|
1458
1526
|
};
|
|
1459
|
-
n.text !== void 0 &&
|
|
1527
|
+
n.text !== void 0 && Dt(s, n.text), n.html !== void 0 && vt(s, n.html), n.class && Tt(s, n.class), n.css && Ot(s, n.css), n.attr && kt(s, n.attr), n.prop && wt(s, n.prop), n.show !== void 0 && Nt(s, n.show), n.hide !== void 0 && Rt(s, n.hide), n.val !== void 0 && xt(s, n.val), n.checked !== void 0 && At(s, n.checked), n.on && Lt(s, n.on);
|
|
1460
1528
|
});
|
|
1461
1529
|
};
|
|
1462
|
-
u.fn.atomList = function(n,
|
|
1463
|
-
const { key:
|
|
1530
|
+
u.fn.atomList = function(n, e) {
|
|
1531
|
+
const { key: t, render: s, bind: i, update: o, onAdd: r, onRemove: c, empty: l } = e, _ = typeof t == "function" ? t : (g, v) => g[t];
|
|
1464
1532
|
return this.each(function() {
|
|
1465
|
-
const
|
|
1466
|
-
let
|
|
1467
|
-
const
|
|
1468
|
-
const
|
|
1469
|
-
if (
|
|
1470
|
-
|
|
1533
|
+
const g = u(this), v = me(this), C = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
|
|
1534
|
+
let R = [], M = null;
|
|
1535
|
+
const w = V(() => {
|
|
1536
|
+
const N = n.value, x = N.length;
|
|
1537
|
+
if (x === 0 ? l && !M && (M = u(l).appendTo(g)) : M && (M.remove(), M = null), x === 0 && C.size === 0) {
|
|
1538
|
+
R = [];
|
|
1471
1539
|
return;
|
|
1472
1540
|
}
|
|
1473
|
-
|
|
1474
|
-
const
|
|
1475
|
-
for (let
|
|
1476
|
-
|
|
1477
|
-
const
|
|
1478
|
-
for (let
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1541
|
+
b.log("list", `${v} updating with ${x} items`);
|
|
1542
|
+
const L = /* @__PURE__ */ new Map(), W = R.length;
|
|
1543
|
+
for (let a = 0; a < W; a++)
|
|
1544
|
+
L.set(R[a], a);
|
|
1545
|
+
const F = new Array(x), K = /* @__PURE__ */ new Set(), re = new Int32Array(x);
|
|
1546
|
+
for (let a = 0; a < x; a++) {
|
|
1547
|
+
const E = N[a], f = _(E, a);
|
|
1548
|
+
K.has(f) && console.warn(`[atomList] Duplicate key "${f}" at index ${a}.`), F[a] = f, K.add(f), re[a] = L.get(f) ?? -1;
|
|
1481
1549
|
}
|
|
1482
1550
|
if (C.size > 0)
|
|
1483
|
-
for (const [
|
|
1484
|
-
if (
|
|
1485
|
-
const
|
|
1486
|
-
|
|
1551
|
+
for (const [a, E] of C) {
|
|
1552
|
+
if (K.has(a) || k.has(a)) continue;
|
|
1553
|
+
const f = () => {
|
|
1554
|
+
E.$el.remove(), E.$el[0] && y.cleanup(E.$el[0]), k.delete(a), b.log("list", `${v} removed item:`, a);
|
|
1487
1555
|
};
|
|
1488
|
-
if (C.delete(
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1556
|
+
if (C.delete(a), k.add(a), c) {
|
|
1557
|
+
const p = c(E.$el);
|
|
1558
|
+
p instanceof Promise ? p.then(f) : f();
|
|
1491
1559
|
} else
|
|
1492
|
-
|
|
1560
|
+
f();
|
|
1493
1561
|
}
|
|
1494
|
-
if (
|
|
1495
|
-
|
|
1562
|
+
if (x === 0) {
|
|
1563
|
+
R = [];
|
|
1496
1564
|
return;
|
|
1497
1565
|
}
|
|
1498
|
-
const
|
|
1499
|
-
let
|
|
1500
|
-
for (let
|
|
1501
|
-
const
|
|
1502
|
-
if (
|
|
1503
|
-
const
|
|
1504
|
-
|
|
1505
|
-
const
|
|
1506
|
-
if (!
|
|
1566
|
+
const te = Et(re);
|
|
1567
|
+
let ne = te.length - 1, h = null;
|
|
1568
|
+
for (let a = x - 1; a >= 0; a--) {
|
|
1569
|
+
const E = F[a], f = N[a], p = C.get(E);
|
|
1570
|
+
if (p) {
|
|
1571
|
+
const T = p.item;
|
|
1572
|
+
p.item = f;
|
|
1573
|
+
const m = p.$el[0];
|
|
1574
|
+
if (!m) continue;
|
|
1507
1575
|
if (o)
|
|
1508
|
-
o(
|
|
1509
|
-
else if (
|
|
1510
|
-
let
|
|
1511
|
-
if (typeof
|
|
1512
|
-
|
|
1513
|
-
let
|
|
1514
|
-
const
|
|
1515
|
-
for (const
|
|
1516
|
-
if (
|
|
1517
|
-
|
|
1576
|
+
o(p.$el, f, a), b.domUpdated(p.$el, "list.update", f);
|
|
1577
|
+
else if (T !== f) {
|
|
1578
|
+
let I = !0;
|
|
1579
|
+
if (typeof T == "object" && T !== null && typeof f == "object" && f !== null) {
|
|
1580
|
+
I = !1;
|
|
1581
|
+
let j = 0;
|
|
1582
|
+
const ce = T, we = f;
|
|
1583
|
+
for (const J in ce) {
|
|
1584
|
+
if (ce[J] !== we[J]) {
|
|
1585
|
+
I = !0;
|
|
1518
1586
|
break;
|
|
1519
1587
|
}
|
|
1520
|
-
|
|
1588
|
+
j++;
|
|
1521
1589
|
}
|
|
1522
|
-
if (!
|
|
1523
|
-
let
|
|
1524
|
-
for (const
|
|
1525
|
-
if (
|
|
1526
|
-
|
|
1590
|
+
if (!I) {
|
|
1591
|
+
let J = 0;
|
|
1592
|
+
for (const Ft in we)
|
|
1593
|
+
if (J++, J > j) {
|
|
1594
|
+
I = !0;
|
|
1527
1595
|
break;
|
|
1528
1596
|
}
|
|
1529
|
-
|
|
1597
|
+
j !== J && (I = !0);
|
|
1530
1598
|
}
|
|
1531
1599
|
}
|
|
1532
|
-
if (
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1600
|
+
if (I) {
|
|
1601
|
+
const j = u(s(f, a)), ce = h === m;
|
|
1602
|
+
p.$el.replaceWith(j), p.$el = j, i && i(j, f, a), b.domUpdated(j, "list.render", f), ce && (h = j[0] || null);
|
|
1535
1603
|
}
|
|
1536
1604
|
}
|
|
1537
|
-
if (
|
|
1538
|
-
|
|
1605
|
+
if (ne >= 0 && te[ne] === a)
|
|
1606
|
+
ne--;
|
|
1539
1607
|
else {
|
|
1540
|
-
const
|
|
1541
|
-
|
|
1608
|
+
const I = p.$el[0];
|
|
1609
|
+
h?.isConnected ? h !== I && p.$el.insertBefore(h) : p.$el.appendTo(g);
|
|
1542
1610
|
}
|
|
1543
|
-
|
|
1611
|
+
h = p.$el[0] || null;
|
|
1544
1612
|
} else {
|
|
1545
|
-
const
|
|
1546
|
-
C.set(
|
|
1613
|
+
const T = s(f, a), m = u(T);
|
|
1614
|
+
C.set(E, { $el: m, item: f }), h?.isConnected ? m.insertBefore(h) : m.appendTo(g), i && i(m, f, a), r && r(m), b.domUpdated(m, "list.add", f), h = m[0] || null;
|
|
1547
1615
|
}
|
|
1548
1616
|
}
|
|
1549
|
-
|
|
1617
|
+
R = F;
|
|
1550
1618
|
});
|
|
1551
|
-
|
|
1552
|
-
C.clear(),
|
|
1619
|
+
y.trackEffect(this, w), y.trackCleanup(this, () => {
|
|
1620
|
+
C.clear(), k.clear(), R = [], M?.remove();
|
|
1553
1621
|
});
|
|
1554
1622
|
});
|
|
1555
1623
|
};
|
|
1556
|
-
const
|
|
1557
|
-
u.fn.atomMount = function(n,
|
|
1624
|
+
const de = /* @__PURE__ */ new WeakMap();
|
|
1625
|
+
u.fn.atomMount = function(n, e = {}) {
|
|
1558
1626
|
return this.each(function() {
|
|
1559
|
-
const
|
|
1560
|
-
i && (
|
|
1627
|
+
const t = b.enabled, s = t ? me(this) : "", i = de.get(this);
|
|
1628
|
+
i && (t && b.log("mount", `${s} unmounting existing component`), i()), t && b.log("mount", `${s} mounting component`);
|
|
1561
1629
|
let o;
|
|
1562
1630
|
try {
|
|
1563
|
-
o = n(u(this),
|
|
1631
|
+
o = n(u(this), e);
|
|
1564
1632
|
} catch (c) {
|
|
1565
1633
|
console.error("[atom-effect-jquery] Mount error:", c);
|
|
1566
1634
|
return;
|
|
1567
1635
|
}
|
|
1568
1636
|
const r = () => {
|
|
1569
|
-
if (
|
|
1570
|
-
if (
|
|
1637
|
+
if (de.delete(this)) {
|
|
1638
|
+
if (t && b.log("mount", `${s} full cleanup`), typeof o == "function")
|
|
1571
1639
|
try {
|
|
1572
1640
|
o();
|
|
1573
1641
|
} catch (c) {
|
|
1574
1642
|
console.error("[atom-effect-jquery] Cleanup error:", c);
|
|
1575
1643
|
}
|
|
1576
|
-
|
|
1644
|
+
y.cleanupTree(this);
|
|
1577
1645
|
}
|
|
1578
1646
|
};
|
|
1579
|
-
|
|
1647
|
+
de.set(this, r), y.trackCleanup(this, r);
|
|
1580
1648
|
});
|
|
1581
1649
|
};
|
|
1582
1650
|
u.fn.atomUnmount = function() {
|
|
1583
1651
|
return this.each(function() {
|
|
1584
|
-
const n =
|
|
1652
|
+
const n = de.get(this);
|
|
1585
1653
|
n && n();
|
|
1586
1654
|
});
|
|
1587
1655
|
};
|
|
1588
|
-
const
|
|
1589
|
-
|
|
1590
|
-
const
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1656
|
+
const le = "[$.route]";
|
|
1657
|
+
function Ut(n) {
|
|
1658
|
+
const {
|
|
1659
|
+
target: e,
|
|
1660
|
+
default: t,
|
|
1661
|
+
routes: s,
|
|
1662
|
+
notFound: i,
|
|
1663
|
+
autoBindLinks: o = !1,
|
|
1664
|
+
activeClass: r = "active",
|
|
1665
|
+
beforeTransition: c,
|
|
1666
|
+
afterTransition: l
|
|
1667
|
+
} = n;
|
|
1668
|
+
let _ = !1, g = null, v = window.location.hash;
|
|
1669
|
+
const C = [], k = /* @__PURE__ */ new Set(), R = u(e), M = () => {
|
|
1670
|
+
const h = window.location.hash, a = h.indexOf("?");
|
|
1671
|
+
return (a === -1 ? h.substring(1) : h.substring(1, a)) || t;
|
|
1672
|
+
}, w = (h) => {
|
|
1673
|
+
const a = h.indexOf("?");
|
|
1674
|
+
if (a === -1) return {};
|
|
1675
|
+
const E = {}, f = h.length;
|
|
1676
|
+
let p = a + 1;
|
|
1677
|
+
const T = (m) => {
|
|
1678
|
+
try {
|
|
1679
|
+
return decodeURIComponent(m);
|
|
1680
|
+
} catch {
|
|
1681
|
+
return console.warn(`${le} Malformed URI component: ${m}`), m;
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
for (; p < f; ) {
|
|
1685
|
+
let m = h.indexOf("&", p);
|
|
1686
|
+
if (m === -1 && (m = f), m > p) {
|
|
1687
|
+
const I = h.indexOf("=", p);
|
|
1688
|
+
I !== -1 && I < m ? E[T(h.substring(p, I))] = T(
|
|
1689
|
+
h.substring(I + 1, m)
|
|
1690
|
+
) : E[T(h.substring(p, m))] = "";
|
|
1691
|
+
}
|
|
1692
|
+
p = m + 1;
|
|
1693
|
+
}
|
|
1694
|
+
return E;
|
|
1695
|
+
}, N = (h) => {
|
|
1696
|
+
let a = s[h];
|
|
1697
|
+
return !a && i && (a = s[i]), a || (console.warn(`${le} Route "${h}" not found and no notFound route configured`), null);
|
|
1698
|
+
}, x = (h) => {
|
|
1699
|
+
const a = document.querySelector(h);
|
|
1700
|
+
if (!a?.content)
|
|
1701
|
+
return console.warn(`${le} Template "${h}" not found`), !1;
|
|
1702
|
+
const E = a.content.cloneNode(!0);
|
|
1703
|
+
return R.append(E), !0;
|
|
1704
|
+
}, L = ze(M()), W = (h) => {
|
|
1705
|
+
if (_) return;
|
|
1706
|
+
const a = R[0];
|
|
1707
|
+
if (!a) {
|
|
1708
|
+
console.warn(`${le} Target element "${e}" not found`);
|
|
1709
|
+
return;
|
|
1710
|
+
}
|
|
1711
|
+
const E = N(h);
|
|
1712
|
+
if (!E) return;
|
|
1713
|
+
const f = w(window.location.hash);
|
|
1714
|
+
c && c(g || h, h), R.empty();
|
|
1715
|
+
let p = f;
|
|
1716
|
+
if (E.onEnter) {
|
|
1717
|
+
const T = E.onEnter(f);
|
|
1718
|
+
T !== void 0 && (p = { ...f, ...T });
|
|
1719
|
+
}
|
|
1720
|
+
E.render ? E.render(a, h, p) : E.template && x(E.template), l && l(g || h, h), g = h;
|
|
1721
|
+
}, F = (h) => {
|
|
1722
|
+
if (_) return;
|
|
1723
|
+
const a = L.value, E = s[a];
|
|
1724
|
+
E?.onLeave && E.onLeave() === !1 || (v = `#${h}`, window.location.hash = v, L.value = h);
|
|
1725
|
+
}, K = () => {
|
|
1726
|
+
if (_) return;
|
|
1727
|
+
const h = window.location.hash;
|
|
1728
|
+
if (h === v) return;
|
|
1729
|
+
const a = M(), E = L.value;
|
|
1730
|
+
if (E !== a) {
|
|
1731
|
+
const f = s[E];
|
|
1732
|
+
if (f?.onLeave && f.onLeave() === !1) {
|
|
1733
|
+
window.location.hash = v;
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
L.value = a;
|
|
1737
|
+
} else
|
|
1738
|
+
W(a);
|
|
1739
|
+
v = h;
|
|
1740
|
+
}, re = () => {
|
|
1741
|
+
if (!o) return;
|
|
1742
|
+
const h = (f) => {
|
|
1743
|
+
f.preventDefault();
|
|
1744
|
+
const p = u(f.currentTarget).data("route");
|
|
1745
|
+
F(p);
|
|
1746
|
+
};
|
|
1747
|
+
u(document).on("click", "[data-route]", h), C.push(() => {
|
|
1748
|
+
u(document).off("click", "[data-route]", h);
|
|
1749
|
+
});
|
|
1750
|
+
const a = (f) => {
|
|
1751
|
+
if (k.has(f)) return;
|
|
1752
|
+
const p = u(f), T = p.data("route");
|
|
1753
|
+
k.add(f);
|
|
1754
|
+
const m = V(() => {
|
|
1755
|
+
const I = L.value === T;
|
|
1756
|
+
p.toggleClass(r, I), I ? p.attr("aria-current", "page") : p.removeAttr("aria-current");
|
|
1757
|
+
});
|
|
1758
|
+
y.trackEffect(f, m), y.trackCleanup(f, () => {
|
|
1759
|
+
k.delete(f);
|
|
1760
|
+
});
|
|
1761
|
+
};
|
|
1762
|
+
u("[data-route]").each(function() {
|
|
1763
|
+
a(this);
|
|
1764
|
+
});
|
|
1765
|
+
const E = new MutationObserver((f) => {
|
|
1766
|
+
for (const p of f)
|
|
1767
|
+
p.type === "childList" && p.addedNodes.forEach((T) => {
|
|
1768
|
+
if (T.nodeType === 1) {
|
|
1769
|
+
const m = T;
|
|
1770
|
+
m.matches?.("[data-route]") && a(m), m.querySelectorAll && m.querySelectorAll("[data-route]").forEach(
|
|
1771
|
+
(I) => a(I)
|
|
1772
|
+
);
|
|
1773
|
+
}
|
|
1774
|
+
});
|
|
1775
|
+
});
|
|
1776
|
+
E.observe(document.body, { childList: !0, subtree: !0 }), C.push(() => E.disconnect());
|
|
1777
|
+
}, te = () => {
|
|
1778
|
+
_ || (_ = !0, C.forEach((h) => h()), C.length = 0, k.forEach((h) => y.cleanup(h)), k.clear());
|
|
1779
|
+
};
|
|
1780
|
+
window.addEventListener("hashchange", K), C.push(() => window.removeEventListener("hashchange", K));
|
|
1781
|
+
const ne = V(() => {
|
|
1782
|
+
W(L.value);
|
|
1783
|
+
});
|
|
1784
|
+
return C.push(() => ne.dispose()), re(), R[0] && y.trackCleanup(R[0], te), {
|
|
1785
|
+
currentRoute: L,
|
|
1786
|
+
navigate: F,
|
|
1787
|
+
destroy: te
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
u.extend({
|
|
1791
|
+
route: Ut
|
|
1792
|
+
});
|
|
1793
|
+
const pe = /* @__PURE__ */ new WeakMap();
|
|
1794
|
+
let Pe = !1;
|
|
1795
|
+
const $e = (n) => {
|
|
1796
|
+
let e = pe.get(n);
|
|
1797
|
+
return e || (e = function(...t) {
|
|
1798
|
+
return Oe(() => n.apply(this, t));
|
|
1799
|
+
}, pe.set(n, e)), e;
|
|
1595
1800
|
};
|
|
1596
|
-
function
|
|
1597
|
-
if (
|
|
1598
|
-
|
|
1599
|
-
const n = u.fn.on,
|
|
1801
|
+
function Ke() {
|
|
1802
|
+
if (Pe) return;
|
|
1803
|
+
Pe = !0;
|
|
1804
|
+
const n = u.fn.on, e = u.fn.off, t = u.fn.remove, s = u.fn.empty, i = u.fn.detach;
|
|
1600
1805
|
u.fn.remove = function(o) {
|
|
1601
1806
|
const r = o ? this.filter(o) : this;
|
|
1602
1807
|
for (let c = 0, l = r.length; c < l; c++) {
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1808
|
+
const _ = r[c];
|
|
1809
|
+
_ && (y.cleanupTree(_), y.markIgnored(_));
|
|
1605
1810
|
}
|
|
1606
|
-
return
|
|
1811
|
+
return t.call(this, o);
|
|
1607
1812
|
}, u.fn.empty = function() {
|
|
1608
1813
|
for (let o = 0, r = this.length; o < r; o++) {
|
|
1609
1814
|
const c = this[o];
|
|
1610
|
-
c &&
|
|
1815
|
+
c && y.cleanupDescendants(c);
|
|
1611
1816
|
}
|
|
1612
1817
|
return s.call(this);
|
|
1613
1818
|
}, u.fn.detach = function(o) {
|
|
1614
1819
|
const r = o ? this.filter(o) : this;
|
|
1615
1820
|
for (let c = 0, l = r.length; c < l; c++) {
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1821
|
+
const _ = r[c];
|
|
1822
|
+
_ && y.keep(_);
|
|
1618
1823
|
}
|
|
1619
1824
|
return i.call(this, o);
|
|
1620
1825
|
}, u.fn.on = function(...o) {
|
|
1621
1826
|
const r = o[0];
|
|
1622
1827
|
if (r && typeof r == "object") {
|
|
1623
1828
|
const c = r, l = {};
|
|
1624
|
-
for (const
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1829
|
+
for (const _ in c) {
|
|
1830
|
+
const g = c[_];
|
|
1831
|
+
g && (l[_] = $e(g));
|
|
1627
1832
|
}
|
|
1628
1833
|
o[0] = l;
|
|
1629
1834
|
} else
|
|
1630
1835
|
for (let c = o.length - 1; c >= 0; c--)
|
|
1631
1836
|
if (typeof o[c] == "function") {
|
|
1632
|
-
o[c] =
|
|
1837
|
+
o[c] = $e(o[c]);
|
|
1633
1838
|
break;
|
|
1634
1839
|
}
|
|
1635
1840
|
return n.apply(this, o);
|
|
@@ -1637,36 +1842,36 @@ function Jt() {
|
|
|
1637
1842
|
const r = o[0];
|
|
1638
1843
|
if (r && typeof r == "object") {
|
|
1639
1844
|
const c = r, l = {};
|
|
1640
|
-
for (const
|
|
1641
|
-
const
|
|
1642
|
-
|
|
1845
|
+
for (const _ in c) {
|
|
1846
|
+
const g = c[_];
|
|
1847
|
+
g && (l[_] = pe.get(g) || g);
|
|
1643
1848
|
}
|
|
1644
1849
|
o[0] = l;
|
|
1645
1850
|
} else
|
|
1646
1851
|
for (let c = o.length - 1; c >= 0; c--)
|
|
1647
1852
|
if (typeof o[c] == "function") {
|
|
1648
|
-
o[c] =
|
|
1853
|
+
o[c] = pe.get(o[c]) || o[c];
|
|
1649
1854
|
break;
|
|
1650
1855
|
}
|
|
1651
|
-
return
|
|
1856
|
+
return e.apply(this, o);
|
|
1652
1857
|
};
|
|
1653
1858
|
}
|
|
1654
|
-
const
|
|
1655
|
-
|
|
1859
|
+
const Mt = Ke;
|
|
1860
|
+
Ke();
|
|
1656
1861
|
u(() => {
|
|
1657
|
-
|
|
1862
|
+
It(document.body);
|
|
1658
1863
|
});
|
|
1659
1864
|
export {
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1865
|
+
ze as atom,
|
|
1866
|
+
Oe as batch,
|
|
1867
|
+
dt as computed,
|
|
1868
|
+
Vt as default,
|
|
1869
|
+
$t as disableAutoCleanup,
|
|
1870
|
+
V as effect,
|
|
1871
|
+
It as enableAutoCleanup,
|
|
1872
|
+
Mt as enablejQueryBatching,
|
|
1873
|
+
Ke as enablejQueryOverrides,
|
|
1874
|
+
y as registry,
|
|
1875
|
+
at as untracked
|
|
1671
1876
|
};
|
|
1672
1877
|
//# sourceMappingURL=index.mjs.map
|