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