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