@but212/atom-effect-jquery 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -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 +1349 -1185
- 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"), w = "[Atom Effect]", T = 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(`${w} ${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
|
+
}, ee = 1, te = () => ee++ | 0, ne = 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
|
+
}, re = class extends ne {
|
|
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
|
+
}, E = /* @__PURE__ */ Symbol.for("atom-effect/brand"), D = {
|
|
384
|
+
Atom: 1,
|
|
385
|
+
Writable: 2,
|
|
386
|
+
Computed: 4,
|
|
387
|
+
Effect: 8
|
|
388
|
+
};
|
|
389
|
+
function ie(e, t) {
|
|
390
|
+
if (!e) return !1;
|
|
391
|
+
let n = typeof e;
|
|
392
|
+
return (n === "object" || n === "function") && !!((e[E] ?? 0) & t);
|
|
393
|
+
}
|
|
394
|
+
function ae(e) {
|
|
395
|
+
return ie(e, D.Atom);
|
|
396
|
+
}
|
|
397
|
+
function oe(e) {
|
|
398
|
+
return ie(e, D.Computed);
|
|
399
|
+
}
|
|
400
|
+
function se(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 ce = 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
|
+
}, le = 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
|
+
k(() => {
|
|
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
|
+
}, O = 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 && T.warn(se(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 k(e) {
|
|
439
|
+
let t = O, 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 ue = 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 = te() & 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 ne(), 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 le(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
|
+
}, de = 0;
|
|
547
|
+
function fe() {
|
|
548
|
+
let e = de + 1 & s;
|
|
549
|
+
return de = e === 0 ? 1 : e, de;
|
|
540
550
|
}
|
|
541
|
-
function
|
|
542
|
-
let t = e + 1 &
|
|
551
|
+
function pe(e) {
|
|
552
|
+
let t = e + 1 & s;
|
|
543
553
|
return t === 0 ? 1 : t;
|
|
544
554
|
}
|
|
545
|
-
var
|
|
546
|
-
function
|
|
547
|
-
return
|
|
555
|
+
var me = 0, he = !1, ge = 0;
|
|
556
|
+
function _e() {
|
|
557
|
+
return ge;
|
|
548
558
|
}
|
|
549
|
-
function
|
|
550
|
-
return
|
|
559
|
+
function ve() {
|
|
560
|
+
return he ? (f && console.warn("startFlush() called during flush - ignored"), !1) : (he = !0, ge = fe(), me = 0, !0);
|
|
551
561
|
}
|
|
552
|
-
function
|
|
553
|
-
|
|
562
|
+
function ye() {
|
|
563
|
+
he = !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 be() {
|
|
566
|
+
if (!he) return 0;
|
|
567
|
+
let e = ++me;
|
|
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 A = 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 = ve();
|
|
599
|
+
this._drainQueue(), e && ye();
|
|
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 = ve();
|
|
596
609
|
try {
|
|
597
610
|
this._mergeBatchQueue(), this._drainQueue();
|
|
598
611
|
} finally {
|
|
599
|
-
this._isFlushingSync =
|
|
612
|
+
this._isFlushingSync = e, t && ye();
|
|
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 xe(e) {
|
|
673
|
+
if (f && typeof e != "function") throw TypeError(v.BATCH_CALLBACK_MUST_BE_FUNCTION);
|
|
674
|
+
A.startBatch();
|
|
660
675
|
try {
|
|
661
676
|
return e();
|
|
662
677
|
} finally {
|
|
663
|
-
|
|
678
|
+
A.endBatch();
|
|
664
679
|
}
|
|
665
680
|
}
|
|
666
|
-
var
|
|
681
|
+
var Se = class extends ue {
|
|
667
682
|
constructor(e, t) {
|
|
668
|
-
super(), this[
|
|
683
|
+
super(), this[E] = D.Atom | D.Writable, this._value = e, this._equal = t.equal ?? Object.is, t.sync && (this.flags |= a.SYNC), T.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 O.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 = pe(this.version), T.trackUpdate(this.id, T.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 && !A.isBatching ? this._notifying === 0 && this._flushNotifications() : A.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 || A.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;
|
|
724
|
+
function Ce(e, t = {}) {
|
|
725
|
+
return new Se(e, t);
|
|
716
726
|
}
|
|
717
|
-
|
|
718
|
-
return typeof e == "object" && !!e && ie in e;
|
|
719
|
-
}
|
|
720
|
-
function xe(e) {
|
|
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: j, DIRTY: M, PENDING: N, RESOLVED: P, REJECTED: F, HAS_ERROR: we, RECOMPUTING: I, DISPOSED: Te, IS_COMPUTED: L, FORCE_COMPUTE: Ee } = i, De = class extends ue {
|
|
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[E] = D.Atom | D.Computed, this._error = null, this._promiseId = 0, this._deps = new re(), this._trackEpoch = u.UNINITIALIZED, this._trackCount = 0, this._value = void 0, this.flags = L | M | j, this._equal = t.equal ?? Object.is, this._fn = e, this._defaultValue = "defaultValue" in t ? t.defaultValue : C, this._onError = t.onError ?? null, T.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 & M) !== 0;
|
|
732
736
|
}
|
|
733
737
|
get isRejected() {
|
|
734
|
-
return (this.flags &
|
|
738
|
+
return (this.flags & F) !== 0;
|
|
735
739
|
}
|
|
736
740
|
get isRecomputing() {
|
|
737
|
-
return (this.flags &
|
|
741
|
+
return (this.flags & I) !== 0;
|
|
738
742
|
}
|
|
739
743
|
get _hasErrorInternal() {
|
|
740
|
-
return (this.flags &
|
|
744
|
+
return (this.flags & we) !== 0;
|
|
741
745
|
}
|
|
742
746
|
_track() {
|
|
743
|
-
|
|
747
|
+
O.current?.addDependency(this);
|
|
744
748
|
}
|
|
745
749
|
get value() {
|
|
746
|
-
|
|
750
|
+
O.current?.addDependency(this);
|
|
747
751
|
let e = this.flags;
|
|
748
|
-
if ((e & (
|
|
749
|
-
if ((e &
|
|
750
|
-
if ((e &
|
|
752
|
+
if ((e & (P | M | j)) === P) return this._value;
|
|
753
|
+
if ((e & Te) !== 0) throw new h(v.COMPUTED_DISPOSED);
|
|
754
|
+
if ((e & I) !== 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 & (M | j)) !== 0) {
|
|
756
760
|
let t = this._deps;
|
|
757
|
-
if ((e &
|
|
761
|
+
if ((e & j) === 0 && (e & Ee) === 0 && t.size > 0 && !this._isDirty() ? e = this.flags &= ~M : (this._recompute(), e = this.flags), (e & P) !== 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 & N) !== 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 & F) !== 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
|
+
O.current?.addDependency(this);
|
|
775
779
|
let e = this.flags;
|
|
776
|
-
return (e &
|
|
780
|
+
return (e & P) === 0 ? (e & N) === 0 ? (e & F) === 0 ? n.IDLE : n.REJECTED : n.PENDING : n.RESOLVED;
|
|
777
781
|
}
|
|
778
782
|
get hasError() {
|
|
779
|
-
if (
|
|
783
|
+
if (O.current?.addDependency(this), (this.flags & (F | we)) !== 0) return !0;
|
|
780
784
|
let e = this._deps;
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
+
return e.hasComputeds ? k(() => {
|
|
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
|
+
O.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), k(() => {
|
|
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 & L) !== 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 & L) !== 0 && this._accumulateErrors(n, t);
|
|
809
816
|
}
|
|
810
817
|
}
|
|
811
818
|
get lastError() {
|
|
812
|
-
return
|
|
819
|
+
return O.current?.addDependency(this), this._error;
|
|
813
820
|
}
|
|
814
821
|
get isPending() {
|
|
815
|
-
return
|
|
822
|
+
return O.current?.addDependency(this), (this.flags & N) !== 0;
|
|
816
823
|
}
|
|
817
824
|
get isResolved() {
|
|
818
|
-
return
|
|
825
|
+
return O.current?.addDependency(this), (this.flags & P) !== 0;
|
|
819
826
|
}
|
|
820
827
|
invalidate() {
|
|
821
|
-
this.flags |=
|
|
828
|
+
this.flags |= Ee, this._markDirty();
|
|
822
829
|
}
|
|
823
830
|
dispose() {
|
|
824
|
-
(this.flags &
|
|
831
|
+
(this.flags & Te) === 0 && (this._deps.disposeAll(), this._slots != null && this._slots.clear(), this.flags = Te | M | j, 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 ce(e, e.version, e.subscribe(this));
|
|
837
844
|
r.insertNew(n, t);
|
|
838
845
|
}
|
|
839
|
-
(e.flags &
|
|
846
|
+
(e.flags & L) !== 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 | I) & ~Ee, this._trackEpoch = fe(), 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 = O.run(this, this._fn);
|
|
854
|
+
this._deps.truncateFrom(this._trackCount), e = !0, se(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 &= ~I;
|
|
855
864
|
}
|
|
856
865
|
}
|
|
857
866
|
_handleAsyncComputation(e) {
|
|
858
|
-
this.flags = (this.flags |
|
|
867
|
+
this.flags = (this.flags | N) & ~(j | M | P | F), 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 = pe(this.version)), this._error = r, this.flags = this.flags & ~(j | M | N | P) | F | we, 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 & P) === 0 || !this._equal(this._value, e)) && (this.version = pe(this.version)), this._value = e, this._error = null, this.flags = (t | P) & ~(j | M | N | F | we);
|
|
880
888
|
}
|
|
881
889
|
execute() {
|
|
882
890
|
this._markDirty();
|
|
883
891
|
}
|
|
884
892
|
_markDirty() {
|
|
885
893
|
let e = this.flags;
|
|
886
|
-
(e & (
|
|
894
|
+
(e & (I | M)) === 0 && (this.flags = e | M, T.trackUpdate(this.id, T.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 k(() => {
|
|
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 & L) !== 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 Oe(e, t = {}) {
|
|
916
|
+
return new De(e, t);
|
|
910
917
|
}
|
|
911
|
-
var
|
|
918
|
+
var ke = class extends ue {
|
|
912
919
|
constructor(e, t = {}) {
|
|
913
|
-
super(), this[
|
|
920
|
+
super(), this[E] = D.Effect, this._cleanup = null, this._deps = new re(), 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 = () => A.schedule(this), T.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 ce(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 ce(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(), T.trackUpdate(this.id, T.getDebugName(this)), this.flags = t | r.EXECUTING, this._execCleanup(), this._currentEpoch = fe(), this._trackCount = 0, n.prepareTracking(), this._hotIndex = -1;
|
|
968
975
|
let i = !1;
|
|
969
976
|
try {
|
|
970
|
-
let e =
|
|
971
|
-
|
|
977
|
+
let e = O.run(this, this._fn);
|
|
978
|
+
n.truncateFrom(this._trackCount), i = !0, se(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 = O.current;
|
|
1006
|
+
O.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
|
+
O.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 = _e();
|
|
1041
|
+
this._lastFlushEpoch !== e && (this._lastFlushEpoch = e, this._executionsInEpoch = 0), ++this._executionsInEpoch > this._maxExecutionsPerFlush && this._throwInfiniteLoopError("per-effect"), be() > 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,27 +1056,26 @@ 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: ${me}`);
|
|
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 Oe = /* @__PURE__ */ Symbol.for("atom-effect/atom"), ke = /* @__PURE__ */ Symbol.for("atom-effect/writable");
|
|
1069
1079
|
function Ae(e, t, n, r) {
|
|
1070
1080
|
if (n === t.length) return r;
|
|
1071
1081
|
let i = t[n], a = typeof e == "object" && e ? e : {}, o = a[i], s = Ae(o, t, n + 1, r);
|
|
@@ -1079,7 +1089,7 @@ function Ae(e, t, n, r) {
|
|
|
1079
1089
|
[i]: s
|
|
1080
1090
|
};
|
|
1081
1091
|
}
|
|
1082
|
-
function
|
|
1092
|
+
function z(e, t) {
|
|
1083
1093
|
let n = e, r = t.length;
|
|
1084
1094
|
for (let e = 0; e < r; e++) {
|
|
1085
1095
|
if (n == null) return;
|
|
@@ -1093,16 +1103,16 @@ function je(e, t) {
|
|
|
1093
1103
|
};
|
|
1094
1104
|
return {
|
|
1095
1105
|
get value() {
|
|
1096
|
-
return
|
|
1106
|
+
return z(e.value, n);
|
|
1097
1107
|
},
|
|
1098
1108
|
set value(t) {
|
|
1099
1109
|
let r = e.peek(), i = Ae(r, n, 0, t);
|
|
1100
1110
|
i !== r && (e.value = i);
|
|
1101
1111
|
},
|
|
1102
|
-
peek: () =>
|
|
1112
|
+
peek: () => z(e.peek(), n),
|
|
1103
1113
|
subscribe(t) {
|
|
1104
1114
|
let i = e.subscribe((e, r) => {
|
|
1105
|
-
let i =
|
|
1115
|
+
let i = z(e, n), a = z(r, n);
|
|
1106
1116
|
Object.is(i, a) || t(i, a);
|
|
1107
1117
|
});
|
|
1108
1118
|
return r.add(i), () => {
|
|
@@ -1112,61 +1122,57 @@ function je(e, t) {
|
|
|
1112
1122
|
subscriberCount: () => r.size,
|
|
1113
1123
|
dispose: i,
|
|
1114
1124
|
[Symbol.dispose]: i,
|
|
1115
|
-
[
|
|
1116
|
-
[ke]: !0
|
|
1125
|
+
[E]: D.Atom | D.Writable
|
|
1117
1126
|
};
|
|
1118
1127
|
}
|
|
1119
|
-
var Me = (e, t) => je(e, t), Ne = (e) => (t) => je(e, t),
|
|
1120
|
-
function
|
|
1121
|
-
let t = e
|
|
1122
|
-
|
|
1123
|
-
let
|
|
1124
|
-
if (typeof
|
|
1125
|
-
let e =
|
|
1126
|
-
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1128
|
+
var Me = (e, t) => je(e, t), Ne = (e) => (t) => je(e, t), Pe = (e) => typeof e == "object" && !!e, Fe = (e) => ae(e), Ie = (e) => (Pe(e) || typeof e == "function") && typeof e.then == "function";
|
|
1129
|
+
function Le(e) {
|
|
1130
|
+
let { localName: t, id: n, className: r } = e, i = t;
|
|
1131
|
+
n && (i += `#${n}`);
|
|
1132
|
+
let a = typeof r == "string" ? r : r.baseVal;
|
|
1133
|
+
if (typeof a == "string") {
|
|
1134
|
+
let e = a.trim();
|
|
1135
|
+
e && (i += `.${e.replace(/\s+/g, ".")}`);
|
|
1136
|
+
}
|
|
1137
|
+
let o = e.type;
|
|
1138
|
+
return o && typeof o == "string" && o !== "text" && (i += `.${o}`), i;
|
|
1129
1139
|
}
|
|
1130
|
-
var
|
|
1131
|
-
function
|
|
1140
|
+
var B = Object.prototype.hasOwnProperty;
|
|
1141
|
+
function Re(e, t) {
|
|
1132
1142
|
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;
|
|
1143
|
+
if (!Pe(e) || !Pe(t)) return !1;
|
|
1144
|
+
let n = e, r = t, i = Object.keys(n), a = Object.keys(r);
|
|
1145
|
+
if (i.length !== a.length) return !1;
|
|
1146
|
+
for (let e of i) if (!B.call(r, e) || !Object.is(n[e], r[e])) return !1;
|
|
1147
|
+
return !0;
|
|
1142
1148
|
}
|
|
1143
1149
|
//#endregion
|
|
1144
1150
|
//#region src/constants.ts
|
|
1145
|
-
var
|
|
1151
|
+
var V = {
|
|
1146
1152
|
ROUTE: "[atom-route]",
|
|
1147
1153
|
BINDING: "[atom-binding]",
|
|
1148
1154
|
LIST: "[atom-list]",
|
|
1149
1155
|
MOUNT: "[atom-mount]"
|
|
1150
|
-
},
|
|
1156
|
+
}, ze = Object.freeze({
|
|
1151
1157
|
mode: "hash",
|
|
1152
1158
|
basePath: "",
|
|
1153
1159
|
autoBindLinks: !1,
|
|
1154
1160
|
activeClass: "active"
|
|
1155
|
-
}),
|
|
1161
|
+
}), Be = Object.freeze({
|
|
1156
1162
|
EVENT: "input",
|
|
1157
1163
|
DEBOUNCE: 0
|
|
1158
|
-
},
|
|
1164
|
+
}), Ve = Object.freeze({ HIGHLIGHT_DURATION_MS: 500 }), He = new Set([
|
|
1159
1165
|
"input",
|
|
1160
1166
|
"select",
|
|
1161
1167
|
"textarea"
|
|
1162
|
-
]),
|
|
1168
|
+
]), Ue = new Set([
|
|
1163
1169
|
"innerHTML",
|
|
1164
1170
|
"outerHTML",
|
|
1165
1171
|
"srcdoc",
|
|
1166
1172
|
"__proto__",
|
|
1167
1173
|
"constructor",
|
|
1168
1174
|
"prototype"
|
|
1169
|
-
]),
|
|
1175
|
+
]), We = "(?: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
1176
|
ROUTE: {
|
|
1171
1177
|
NOT_FOUND: (e) => `Route "${e}" not found and no notFound route configured`,
|
|
1172
1178
|
TEMPLATE_NOT_FOUND: (e) => `Template "${e}" not found`,
|
|
@@ -1194,24 +1200,44 @@ var B = {
|
|
|
1194
1200
|
CLEANUP_ERROR: (e) => `Cleanup error${e ? ` in component <${e}>` : ""}`
|
|
1195
1201
|
},
|
|
1196
1202
|
CORE: { EFFECT_DISPOSE_ERROR: (e) => `Effect dispose error${e ? `: ${e}` : ""}` }
|
|
1197
|
-
},
|
|
1198
|
-
|
|
1203
|
+
}, Ge = "atom-debug-highlight", U = "data-atom-debug", Ke = typeof window < "u", qe = /* @__PURE__ */ new WeakMap(), Je = /* @__PURE__ */ new WeakMap(), Ye = !1, Xe = () => `${Ve.HIGHLIGHT_DURATION_MS / 1e3}s`, Ze = () => `
|
|
1204
|
+
[${U}] {
|
|
1205
|
+
transition: outline ${Xe()} ease-out;
|
|
1206
|
+
}
|
|
1207
|
+
.${Ge} {
|
|
1208
|
+
outline: 2px solid rgba(255, 68, 68, 0.8);
|
|
1209
|
+
outline-offset: 1px;
|
|
1210
|
+
}
|
|
1211
|
+
`.replace(/\s+/g, " ");
|
|
1212
|
+
function Qe() {
|
|
1213
|
+
if (Ye || !Ke) return;
|
|
1214
|
+
if (document.querySelector(`style[${U}]`)) {
|
|
1215
|
+
Ye = !0;
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
let e = document.createElement("style");
|
|
1219
|
+
e.setAttribute(U, ""), e.textContent = Ze(), document.head.appendChild(e), Ye = !0;
|
|
1220
|
+
}
|
|
1221
|
+
function $e() {
|
|
1199
1222
|
let e = globalThis;
|
|
1200
|
-
if (
|
|
1223
|
+
if (e.__ATOM_DEBUG__ !== void 0) return !!e.__ATOM_DEBUG__;
|
|
1201
1224
|
try {
|
|
1202
|
-
if (
|
|
1225
|
+
if (typeof sessionStorage < "u" && sessionStorage.getItem("__ATOM_DEBUG__") === "true") return !0;
|
|
1203
1226
|
} catch {}
|
|
1204
|
-
return !1;
|
|
1227
|
+
return e.process?.env?.NODE_ENV !== "production" && e.process?.env?.NODE_ENV !== void 0 ? !0 : e.__DEV__ === void 0 ? !1 : !!e.__DEV__;
|
|
1205
1228
|
}
|
|
1206
|
-
var
|
|
1229
|
+
var et = class {
|
|
1207
1230
|
constructor() {
|
|
1208
|
-
this.
|
|
1231
|
+
this.enabled = !0;
|
|
1232
|
+
}
|
|
1233
|
+
log(e, ...t) {
|
|
1234
|
+
this.enabled && console.log(e, ...t);
|
|
1209
1235
|
}
|
|
1210
|
-
|
|
1211
|
-
|
|
1236
|
+
atomChanged(e, t, n, r) {
|
|
1237
|
+
this.enabled && console.log(`${e} Atom "${t ?? "anonymous"}" changed:`, n, "→", r);
|
|
1212
1238
|
}
|
|
1213
|
-
|
|
1214
|
-
this.
|
|
1239
|
+
cleanup(e, t) {
|
|
1240
|
+
this.enabled && console.log(`${e} Cleanup: ${t}`);
|
|
1215
1241
|
}
|
|
1216
1242
|
warn(e, t, ...n) {
|
|
1217
1243
|
console.warn(`${e} ${t}`, ...n);
|
|
@@ -1219,64 +1245,62 @@ var H = new class {
|
|
|
1219
1245
|
error(e, t, n) {
|
|
1220
1246
|
console.error(`${e} ${t}`, n);
|
|
1221
1247
|
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
if (!
|
|
1230
|
-
|
|
1231
|
-
let
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
e.
|
|
1235
|
-
},
|
|
1248
|
+
domUpdated(e, t, n, r) {
|
|
1249
|
+
if (!this.enabled) return;
|
|
1250
|
+
let i = "jquery" in t ? t[0] : t;
|
|
1251
|
+
i && i.nodeType === 1 && i.isConnected && (console.log(`${e} DOM updated: ${Le(i)}.${n} =`, r), this._triggerVisualHighlight(i));
|
|
1252
|
+
}
|
|
1253
|
+
_triggerVisualHighlight(e) {
|
|
1254
|
+
let t = globalThis, n = t.requestAnimationFrame, r = t.cancelAnimationFrame;
|
|
1255
|
+
if (!Ke || typeof n != "function") return;
|
|
1256
|
+
Qe();
|
|
1257
|
+
let i = Je.get(e), a = qe.get(e);
|
|
1258
|
+
i !== void 0 && typeof r == "function" && r(i), a !== void 0 && (clearTimeout(a), qe.delete(e)), e.hasAttribute(U) || e.setAttribute(U, ""), Je.set(e, n(() => {
|
|
1259
|
+
Je.delete(e), e.isConnected && (e.classList.add(Ge), qe.set(e, setTimeout(() => {
|
|
1260
|
+
e.classList.remove(Ge), qe.delete(e);
|
|
1261
|
+
}, Ve.HIGHLIGHT_DURATION_MS)));
|
|
1236
1262
|
}));
|
|
1237
1263
|
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
}
|
|
1248
|
-
var Ye = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap();
|
|
1264
|
+
}, W = $e() ? new et() : {
|
|
1265
|
+
enabled: !1,
|
|
1266
|
+
log: () => {},
|
|
1267
|
+
atomChanged: () => {},
|
|
1268
|
+
domUpdated: () => {},
|
|
1269
|
+
cleanup: () => {},
|
|
1270
|
+
warn: (e, t, ...n) => console.warn(`${e} ${t}`, ...n),
|
|
1271
|
+
error: (e, t, n) => console.error(`${e} ${t}`, n)
|
|
1272
|
+
};
|
|
1249
1273
|
//#endregion
|
|
1250
1274
|
//#region src/core/namespace.ts
|
|
1251
|
-
function
|
|
1252
|
-
return
|
|
1275
|
+
function tt(e, t) {
|
|
1276
|
+
return Ce(e, t);
|
|
1253
1277
|
}
|
|
1254
|
-
Object.defineProperty(
|
|
1278
|
+
Object.defineProperty(tt, "debug", {
|
|
1255
1279
|
enumerable: !0,
|
|
1256
1280
|
configurable: !0,
|
|
1257
|
-
get: () =>
|
|
1281
|
+
get: () => W.enabled,
|
|
1258
1282
|
set: (e) => {
|
|
1259
|
-
|
|
1283
|
+
W.enabled = e;
|
|
1260
1284
|
}
|
|
1261
1285
|
});
|
|
1262
|
-
var
|
|
1286
|
+
var nt = () => Promise.resolve();
|
|
1263
1287
|
e.extend({
|
|
1264
|
-
atom:
|
|
1265
|
-
computed:
|
|
1266
|
-
effect:
|
|
1267
|
-
batch:
|
|
1268
|
-
untracked:
|
|
1269
|
-
isAtom:
|
|
1270
|
-
isComputed:
|
|
1271
|
-
isReactive:
|
|
1272
|
-
nextTick:
|
|
1288
|
+
atom: tt,
|
|
1289
|
+
computed: Oe,
|
|
1290
|
+
effect: R,
|
|
1291
|
+
batch: xe,
|
|
1292
|
+
untracked: k,
|
|
1293
|
+
isAtom: ae,
|
|
1294
|
+
isComputed: oe,
|
|
1295
|
+
isReactive: Fe,
|
|
1296
|
+
nextTick: nt,
|
|
1273
1297
|
atomLens: je,
|
|
1274
1298
|
composeLens: Me,
|
|
1275
1299
|
lensFor: Ne
|
|
1276
1300
|
});
|
|
1277
1301
|
//#endregion
|
|
1278
1302
|
//#region src/utils/pool.ts
|
|
1279
|
-
var
|
|
1303
|
+
var rt = class {
|
|
1280
1304
|
constructor(e = 50, t = 256) {
|
|
1281
1305
|
this.limit = e, this.capacity = t, this.pool = [];
|
|
1282
1306
|
}
|
|
@@ -1284,12 +1308,14 @@ var $e = class {
|
|
|
1284
1308
|
return this.pool.pop() ?? [];
|
|
1285
1309
|
}
|
|
1286
1310
|
release(e) {
|
|
1287
|
-
|
|
1311
|
+
if (Object.isFrozen(e)) return;
|
|
1312
|
+
let t = e.length;
|
|
1313
|
+
e.length = 0, this.pool.length < this.limit && t <= this.capacity && this.pool.indexOf(e) === -1 && this.pool.push(e);
|
|
1288
1314
|
}
|
|
1289
1315
|
reset() {
|
|
1290
1316
|
this.pool.length = 0;
|
|
1291
1317
|
}
|
|
1292
|
-
},
|
|
1318
|
+
}, it = class {
|
|
1293
1319
|
constructor(e, t, n = 64) {
|
|
1294
1320
|
this.factory = e, this.reset = t, this.limit = n, this.pool = [];
|
|
1295
1321
|
}
|
|
@@ -1297,7 +1323,7 @@ var $e = class {
|
|
|
1297
1323
|
return this.pool.pop() ?? this.factory();
|
|
1298
1324
|
}
|
|
1299
1325
|
release(e) {
|
|
1300
|
-
this.pool.length < this.limit &&
|
|
1326
|
+
Object.isFrozen(e) || (this.reset(e), this.pool.length < this.limit && this.pool.indexOf(e) === -1 && this.pool.push(e));
|
|
1301
1327
|
}
|
|
1302
1328
|
drain() {
|
|
1303
1329
|
this.pool.length > 0 && (this.pool.length = 0);
|
|
@@ -1305,17 +1331,36 @@ var $e = class {
|
|
|
1305
1331
|
get size() {
|
|
1306
1332
|
return this.pool.length;
|
|
1307
1333
|
}
|
|
1308
|
-
},
|
|
1334
|
+
}, at = 128, ot = new rt(at), st = new rt(at), ct = new it(() => ({
|
|
1309
1335
|
effects: void 0,
|
|
1310
1336
|
cleanups: void 0,
|
|
1311
1337
|
componentCleanup: void 0
|
|
1312
1338
|
}), (e) => {
|
|
1313
|
-
e.effects
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1339
|
+
if (e.effects) {
|
|
1340
|
+
let t = e.effects.length;
|
|
1341
|
+
for (let n = 0; n < t; n++) try {
|
|
1342
|
+
e.effects[n].dispose();
|
|
1343
|
+
} catch {}
|
|
1344
|
+
ot.release(e.effects), e.effects = void 0;
|
|
1345
|
+
}
|
|
1346
|
+
if (e.cleanups) {
|
|
1347
|
+
let t = e.cleanups.length;
|
|
1348
|
+
for (let n = 0; n < t; n++) try {
|
|
1349
|
+
e.cleanups[n]();
|
|
1350
|
+
} catch {}
|
|
1351
|
+
st.release(e.cleanups), e.cleanups = void 0;
|
|
1352
|
+
}
|
|
1353
|
+
if (e.componentCleanup) {
|
|
1354
|
+
try {
|
|
1355
|
+
e.componentCleanup();
|
|
1356
|
+
} catch {}
|
|
1357
|
+
e.componentCleanup = void 0;
|
|
1358
|
+
}
|
|
1359
|
+
}, at), lt = !1;
|
|
1360
|
+
function ut() {
|
|
1361
|
+
lt || typeof document < "u" && document.body && (lt = !0, dt(document.body));
|
|
1317
1362
|
}
|
|
1318
|
-
var
|
|
1363
|
+
var G = "_aes-bound", K = new class {
|
|
1319
1364
|
constructor() {
|
|
1320
1365
|
this.records = /* @__PURE__ */ new WeakMap(), this.preservedNodes = /* @__PURE__ */ new WeakSet(), this.ignoredNodes = /* @__PURE__ */ new WeakSet();
|
|
1321
1366
|
}
|
|
@@ -1332,17 +1377,17 @@ var U = "_aes-bound", W = new class {
|
|
|
1332
1377
|
return this.ignoredNodes.has(e);
|
|
1333
1378
|
}
|
|
1334
1379
|
getOrCreateRecord(e) {
|
|
1335
|
-
|
|
1380
|
+
ut();
|
|
1336
1381
|
let t = this.records.get(e);
|
|
1337
|
-
return t || (t =
|
|
1382
|
+
return t || (t = ct.acquire(), this.records.set(e, t), e.classList.add(G)), t;
|
|
1338
1383
|
}
|
|
1339
1384
|
trackEffect(e, t) {
|
|
1340
1385
|
let n = this.getOrCreateRecord(e);
|
|
1341
|
-
n.effects ||=
|
|
1386
|
+
n.effects ||= ot.acquire(), n.effects.push(t);
|
|
1342
1387
|
}
|
|
1343
1388
|
trackCleanup(e, t) {
|
|
1344
1389
|
let n = this.getOrCreateRecord(e);
|
|
1345
|
-
n.cleanups ||=
|
|
1390
|
+
n.cleanups ||= st.acquire(), n.cleanups.push(t);
|
|
1346
1391
|
}
|
|
1347
1392
|
setComponentCleanup(e, t) {
|
|
1348
1393
|
this.getOrCreateRecord(e).componentCleanup = t;
|
|
@@ -1351,54 +1396,58 @@ var U = "_aes-bound", W = new class {
|
|
|
1351
1396
|
return this.records.has(e);
|
|
1352
1397
|
}
|
|
1353
1398
|
cleanup(e) {
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1399
|
+
if (this.preservedNodes.delete(e), this.ignoredNodes.delete(e), e.nodeType !== 1) return;
|
|
1400
|
+
let t = e, n = this.records.get(t);
|
|
1401
|
+
if (!n) {
|
|
1402
|
+
t.classList.remove(G);
|
|
1357
1403
|
return;
|
|
1358
1404
|
}
|
|
1359
|
-
this.records.delete(
|
|
1360
|
-
let r = t
|
|
1361
|
-
if (
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1405
|
+
this.records.delete(t), t.classList.remove(G);
|
|
1406
|
+
let r = Le(t);
|
|
1407
|
+
if (W.cleanup(V.BINDING, r), n.componentCleanup) {
|
|
1408
|
+
try {
|
|
1409
|
+
n.componentCleanup();
|
|
1410
|
+
} catch (e) {
|
|
1411
|
+
W.error(V.MOUNT, H.MOUNT.CLEANUP_ERROR(r), e);
|
|
1412
|
+
}
|
|
1413
|
+
n.componentCleanup = void 0;
|
|
1365
1414
|
}
|
|
1366
1415
|
if (n.effects) {
|
|
1367
1416
|
for (let e of n.effects) try {
|
|
1368
1417
|
e.dispose();
|
|
1369
1418
|
} catch (e) {
|
|
1370
|
-
|
|
1419
|
+
W.error(V.BINDING, H.CORE.EFFECT_DISPOSE_ERROR(r), e);
|
|
1371
1420
|
}
|
|
1372
|
-
|
|
1421
|
+
ot.release(n.effects), n.effects = void 0;
|
|
1373
1422
|
}
|
|
1374
1423
|
if (n.cleanups) {
|
|
1375
1424
|
for (let e of n.cleanups) try {
|
|
1376
1425
|
e();
|
|
1377
1426
|
} catch (e) {
|
|
1378
|
-
|
|
1427
|
+
W.error(V.BINDING, H.BINDING.CLEANUP_ERROR(r), e);
|
|
1379
1428
|
}
|
|
1380
|
-
|
|
1429
|
+
st.release(n.cleanups), n.cleanups = void 0;
|
|
1381
1430
|
}
|
|
1382
|
-
|
|
1431
|
+
ct.release(n);
|
|
1383
1432
|
}
|
|
1384
1433
|
cleanupDescendants(e) {
|
|
1385
|
-
let t =
|
|
1434
|
+
let t = "getElementsByClassName" in e ? e.getElementsByClassName(G) : e.querySelectorAll(`.${G}`), n = t.length;
|
|
1386
1435
|
if (n === 0) return;
|
|
1387
1436
|
let r = Array(n);
|
|
1388
1437
|
for (let e = 0; e < n; e++) r[e] = t[e];
|
|
1389
1438
|
for (let e = n - 1; e >= 0; e--) {
|
|
1390
1439
|
let t = r[e];
|
|
1391
|
-
this.records.has(t) ? this.cleanup(t) : t.classList.remove(
|
|
1440
|
+
this.records.has(t) ? this.cleanup(t) : t.classList.remove(G);
|
|
1392
1441
|
}
|
|
1393
1442
|
}
|
|
1394
1443
|
cleanupTree(e) {
|
|
1395
1444
|
(e.nodeType === 1 || e.nodeType === 11) && this.cleanupDescendants(e), this.cleanup(e);
|
|
1396
1445
|
}
|
|
1397
|
-
}(),
|
|
1398
|
-
function
|
|
1399
|
-
if (
|
|
1446
|
+
}(), q = /* @__PURE__ */ new Map();
|
|
1447
|
+
function dt(e) {
|
|
1448
|
+
if (q.has(e)) return;
|
|
1400
1449
|
let t = new MutationObserver((e) => {
|
|
1401
|
-
let t =
|
|
1450
|
+
let t = K;
|
|
1402
1451
|
for (let n = 0, r = e.length; n < r; n++) {
|
|
1403
1452
|
let r = e[n].removedNodes;
|
|
1404
1453
|
for (let e = 0, n = r.length; e < n; e++) {
|
|
@@ -1412,197 +1461,249 @@ function ot(e) {
|
|
|
1412
1461
|
t.observe(e, {
|
|
1413
1462
|
childList: !0,
|
|
1414
1463
|
subtree: !0
|
|
1415
|
-
}),
|
|
1464
|
+
}), q.set(e, t);
|
|
1416
1465
|
}
|
|
1417
|
-
function
|
|
1418
|
-
|
|
1466
|
+
function ft() {
|
|
1467
|
+
q.forEach((e) => e.disconnect()), q.clear();
|
|
1468
|
+
}
|
|
1469
|
+
//#endregion
|
|
1470
|
+
//#region src/core/dom.ts
|
|
1471
|
+
function pt(e) {
|
|
1472
|
+
return {
|
|
1473
|
+
el: e,
|
|
1474
|
+
trackCleanup: (t) => K.trackCleanup(e, t)
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
function J(e, t, n = {}) {
|
|
1478
|
+
for (let r = 0, i = e.length; r < i; r++) {
|
|
1479
|
+
let i = e[r];
|
|
1480
|
+
if (i?.nodeType === 1) {
|
|
1481
|
+
let e = i;
|
|
1482
|
+
t(n.needsCtx ? pt(e) : null, e);
|
|
1483
|
+
} else i && W.log(V.BINDING, `Skipping non-Element node (nodeType=${i.nodeType})`);
|
|
1484
|
+
}
|
|
1485
|
+
return e;
|
|
1486
|
+
}
|
|
1487
|
+
function mt(e) {
|
|
1488
|
+
return Array.isArray(e) && e.length === 2 && (typeof e[0] == "function" || e[0] !== null && typeof e[0] == "object" && ("value" in e[0] || "then" in e[0])) ? e : [e];
|
|
1419
1489
|
}
|
|
1420
1490
|
//#endregion
|
|
1421
1491
|
//#region src/core/jquery-patch.ts
|
|
1422
|
-
var
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1492
|
+
var Y = Symbol.for("atom-effect-internal"), ht = Symbol.for("atom-effect-wrapped"), gt = /* @__PURE__ */ new WeakMap(), X = null, _t = (e) => {
|
|
1493
|
+
let t = e;
|
|
1494
|
+
if (t[Y]) return e;
|
|
1495
|
+
let n = t[ht];
|
|
1496
|
+
if (n) return n;
|
|
1497
|
+
if (n = gt.get(e), !n) {
|
|
1498
|
+
n = function(...t) {
|
|
1499
|
+
return xe(() => e.apply(this, t));
|
|
1500
|
+
}, n[Y] = !0, gt.set(e, n);
|
|
1501
|
+
try {
|
|
1502
|
+
t[ht] = n;
|
|
1503
|
+
} catch {}
|
|
1504
|
+
}
|
|
1505
|
+
return n;
|
|
1506
|
+
}, vt = (e) => e[ht] ?? gt.get(e) ?? e;
|
|
1507
|
+
function yt(e) {
|
|
1430
1508
|
let t = {};
|
|
1431
|
-
for (let n in e)
|
|
1509
|
+
for (let n in e) {
|
|
1510
|
+
let r = e[n];
|
|
1511
|
+
typeof r == "function" ? t[n] = _t(r) : r !== void 0 && (t[n] = r);
|
|
1512
|
+
}
|
|
1432
1513
|
return t;
|
|
1433
1514
|
}
|
|
1434
|
-
function
|
|
1515
|
+
function bt(e) {
|
|
1435
1516
|
let t = {};
|
|
1436
1517
|
for (let n in e) {
|
|
1437
1518
|
let r = e[n];
|
|
1438
|
-
t[n] =
|
|
1519
|
+
typeof r == "function" ? t[n] = vt(r) : t[n] = r;
|
|
1439
1520
|
}
|
|
1440
1521
|
return t;
|
|
1441
1522
|
}
|
|
1442
|
-
function
|
|
1443
|
-
|
|
1444
|
-
|
|
1523
|
+
function xt(e, t, n) {
|
|
1524
|
+
let r = e[0];
|
|
1525
|
+
if (r && typeof r == "object") e[0] = t(r);
|
|
1526
|
+
else for (let t = 1; t < e.length; t++) typeof e[t] == "function" && (e[t] = n(e[t]));
|
|
1527
|
+
}
|
|
1528
|
+
function St(e) {
|
|
1529
|
+
return function(...t) {
|
|
1530
|
+
return xt(t, yt, _t), e.apply(this, t) ?? this;
|
|
1531
|
+
};
|
|
1532
|
+
}
|
|
1533
|
+
function Ct() {
|
|
1534
|
+
if (X !== null) return;
|
|
1535
|
+
X = {
|
|
1445
1536
|
on: e.fn.on,
|
|
1537
|
+
one: e.fn.one,
|
|
1446
1538
|
off: e.fn.off,
|
|
1447
1539
|
remove: e.fn.remove,
|
|
1448
1540
|
empty: e.fn.empty,
|
|
1449
1541
|
detach: e.fn.detach
|
|
1450
1542
|
};
|
|
1451
|
-
let t =
|
|
1543
|
+
let t = X;
|
|
1452
1544
|
e.fn.remove = function(e) {
|
|
1453
1545
|
let n = e ? this.filter(e) : this, r = n.length;
|
|
1454
1546
|
for (let e = 0; e < r; e++) {
|
|
1455
1547
|
let t = n[e];
|
|
1456
|
-
t && (
|
|
1548
|
+
t && (K.markIgnored(t), K.cleanupTree(t));
|
|
1457
1549
|
}
|
|
1458
1550
|
return t.remove.call(this, e) ?? this;
|
|
1459
1551
|
}, e.fn.empty = function() {
|
|
1460
1552
|
let e = this.length;
|
|
1461
1553
|
for (let t = 0; t < e; t++) {
|
|
1462
1554
|
let e = this[t];
|
|
1463
|
-
e?.hasChildNodes() &&
|
|
1555
|
+
e?.hasChildNodes() && K.cleanupDescendants(e);
|
|
1464
1556
|
}
|
|
1465
1557
|
return t.empty.call(this) ?? this;
|
|
1466
1558
|
}, e.fn.detach = function(e) {
|
|
1467
1559
|
let n = e ? this.filter(e) : this, r = n.length;
|
|
1468
1560
|
for (let e = 0; e < r; e++) {
|
|
1469
1561
|
let t = n[e];
|
|
1470
|
-
t &&
|
|
1562
|
+
t && K.keep(t);
|
|
1471
1563
|
}
|
|
1472
1564
|
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;
|
|
1565
|
+
}, e.fn.on = St(t.on), e.fn.one = St(t.one), e.fn.off = function(...e) {
|
|
1566
|
+
return xt(e, bt, vt), t.off.apply(this, e) ?? this;
|
|
1492
1567
|
};
|
|
1493
1568
|
}
|
|
1494
|
-
function
|
|
1495
|
-
|
|
1569
|
+
function wt() {
|
|
1570
|
+
X !== null && (e.fn.on = X.on, e.fn.one = X.one, e.fn.off = X.off, e.fn.remove = X.remove, e.fn.empty = X.empty, e.fn.detach = X.detach, X = null);
|
|
1496
1571
|
}
|
|
1497
1572
|
//#endregion
|
|
1498
1573
|
//#region src/types.ts
|
|
1499
|
-
var
|
|
1574
|
+
var Z = /* @__PURE__ */ function(e) {
|
|
1500
1575
|
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[
|
|
1576
|
+
}({}), Tt = 0;
|
|
1577
|
+
function Et(e) {
|
|
1578
|
+
e[Y] = !0;
|
|
1504
1579
|
}
|
|
1505
|
-
var
|
|
1580
|
+
var Dt = class {
|
|
1506
1581
|
constructor(e, t, n) {
|
|
1507
1582
|
this.flags = 0, this.timeoutId = void 0, this.handleCompositionStart = () => {
|
|
1508
|
-
this.flags |=
|
|
1583
|
+
this.flags |= Z.Composing;
|
|
1509
1584
|
}, this.handleCompositionEnd = () => {
|
|
1510
|
-
this.flags &= ~
|
|
1585
|
+
this.flags &= ~Z.Composing, this.handleInput();
|
|
1511
1586
|
}, this.handleFocus = () => {
|
|
1512
|
-
this.flags |=
|
|
1587
|
+
this.flags |= Z.Focused;
|
|
1513
1588
|
}, this.handleBlur = () => {
|
|
1514
|
-
this.flags &= ~
|
|
1515
|
-
let e = !!(this.flags &
|
|
1516
|
-
this.flags &= ~
|
|
1589
|
+
this.flags &= ~Z.Focused;
|
|
1590
|
+
let e = !!(this.flags & Z.Composing);
|
|
1591
|
+
this.flags &= ~Z.Composing;
|
|
1592
|
+
let t = this.flushPendingDebounce();
|
|
1593
|
+
e && !t && this.syncAtomFromDom(), this.normalizeDomValue();
|
|
1517
1594
|
}, this.syncDomFromAtom = () => {
|
|
1518
1595
|
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;
|
|
1596
|
+
this.flags & Z.Busy || k(() => {
|
|
1597
|
+
if (this.isDomUpToDate(e)) return;
|
|
1598
|
+
let t = this.format(e);
|
|
1599
|
+
this.flags |= Z.SyncingToDom;
|
|
1528
1600
|
try {
|
|
1529
|
-
this.writeDom(e, t),
|
|
1601
|
+
this.writeDom(e, t), W.domUpdated(V.BINDING, this.$el, "val", t);
|
|
1530
1602
|
} finally {
|
|
1531
|
-
this.flags &= ~
|
|
1603
|
+
this.flags &= ~Z.SyncingToDom;
|
|
1532
1604
|
}
|
|
1533
1605
|
});
|
|
1534
1606
|
}, this.cleanup = () => {
|
|
1535
1607
|
this.$el.off(this.ns), clearTimeout(this.timeoutId), this.timeoutId = void 0;
|
|
1536
1608
|
}, 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));
|
|
1609
|
+
let r = this.el.tagName;
|
|
1610
|
+
this.isMultipleSelect = r === "SELECT" && this.el.multiple, this.isTextControl = r === "INPUT" || r === "TEXTAREA", this.ns = `.atomBind-${++Tt}`;
|
|
1611
|
+
let { parse: i, format: a, equal: o, readDom: s, getRawDom: c, writeDom: l } = this.initStrategies(n);
|
|
1612
|
+
this.parse = i, this.format = a, this.equal = o, this.readDom = s, this.getRawDom = c, this.writeDom = l;
|
|
1613
|
+
let u = n.debounce ?? 0;
|
|
1614
|
+
u > 0 ? this.handleInput = () => {
|
|
1615
|
+
this.flags & Z.Composing || (clearTimeout(this.timeoutId), this.timeoutId = setTimeout(() => this.syncAtomFromDom(), u));
|
|
1567
1616
|
} : this.handleInput = () => {
|
|
1568
|
-
this.flags &
|
|
1617
|
+
this.flags & Z.Composing || this.syncAtomFromDom();
|
|
1569
1618
|
}, [
|
|
1570
1619
|
this.handleFocus,
|
|
1571
1620
|
this.handleBlur,
|
|
1572
1621
|
this.handleCompositionStart,
|
|
1573
1622
|
this.handleCompositionEnd,
|
|
1574
1623
|
this.handleInput
|
|
1575
|
-
].forEach(
|
|
1624
|
+
].forEach(Et), this.bindEvents(n.event ?? Be.EVENT);
|
|
1625
|
+
}
|
|
1626
|
+
initStrategies(e) {
|
|
1627
|
+
let t = e.parse ?? ((e) => e), n = e.equal ?? Object.is;
|
|
1628
|
+
return this.isMultipleSelect ? {
|
|
1629
|
+
parse: t,
|
|
1630
|
+
format: e.format ?? ((e) => (Array.isArray(e) ? e : e ? [String(e)] : []).join(",")),
|
|
1631
|
+
getRawDom: () => this.$el.val() || [],
|
|
1632
|
+
readDom: () => this.$el.val() || [],
|
|
1633
|
+
writeDom: (e) => {
|
|
1634
|
+
this.$el.val(e);
|
|
1635
|
+
},
|
|
1636
|
+
equal: (e, t) => {
|
|
1637
|
+
if (n(e, t)) return !0;
|
|
1638
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
1639
|
+
let n = e.length;
|
|
1640
|
+
if (n !== t.length) return !1;
|
|
1641
|
+
for (let r = 0; r < n; r++) if (!Object.is(e[r], t[r])) return !1;
|
|
1642
|
+
return !0;
|
|
1643
|
+
}
|
|
1644
|
+
return !1;
|
|
1645
|
+
}
|
|
1646
|
+
} : {
|
|
1647
|
+
parse: t,
|
|
1648
|
+
format: e.format ?? ((e) => String(e ?? "")),
|
|
1649
|
+
equal: n,
|
|
1650
|
+
readDom: () => t(this.el.value),
|
|
1651
|
+
getRawDom: () => this.el.value,
|
|
1652
|
+
writeDom: this.isTextControl ? (e, t) => this.writeTextValue(t) : (e, t) => {
|
|
1653
|
+
this.el.value = t;
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
writeTextValue(e) {
|
|
1658
|
+
let t = this.el;
|
|
1659
|
+
if (this.flags & Z.Focused) try {
|
|
1660
|
+
let n = t.selectionStart, r = t.selectionEnd;
|
|
1661
|
+
t.value = e;
|
|
1662
|
+
let i = e.length;
|
|
1663
|
+
n !== null && r !== null && t.setSelectionRange(Math.min(n, i), Math.min(r, i));
|
|
1664
|
+
} catch {
|
|
1665
|
+
t.value = e;
|
|
1666
|
+
}
|
|
1667
|
+
else t.value = e;
|
|
1576
1668
|
}
|
|
1577
1669
|
flushPendingDebounce() {
|
|
1578
|
-
this.timeoutId
|
|
1670
|
+
return this.timeoutId === void 0 ? !1 : (clearTimeout(this.timeoutId), this.timeoutId = void 0, this.syncAtomFromDom(), !0);
|
|
1579
1671
|
}
|
|
1580
1672
|
normalizeDomValue() {
|
|
1581
1673
|
let e = this.atom.peek(), t = this.format(e), n = this.getRawDom();
|
|
1582
1674
|
this.isMultipleSelect ? this.equal(n, e) || this.writeDom(e, t) : n !== t && this.writeDom(e, t);
|
|
1583
1675
|
}
|
|
1584
1676
|
syncAtomFromDom() {
|
|
1585
|
-
if (!(this.flags &
|
|
1586
|
-
this.flags |=
|
|
1677
|
+
if (!(this.flags & Z.Busy)) {
|
|
1678
|
+
this.flags |= Z.SyncingToAtom;
|
|
1587
1679
|
try {
|
|
1588
1680
|
let e = this.readDom();
|
|
1589
1681
|
this.equal(this.atom.peek(), e) || (this.atom.value = e);
|
|
1590
1682
|
} catch (e) {
|
|
1591
|
-
|
|
1683
|
+
W.warn(V.BINDING, H.BINDING.PARSE_ERROR(e instanceof Error ? e.message : String(e)), e);
|
|
1592
1684
|
} finally {
|
|
1593
|
-
this.flags &= ~
|
|
1685
|
+
this.flags &= ~Z.SyncingToAtom;
|
|
1594
1686
|
}
|
|
1595
1687
|
}
|
|
1596
1688
|
}
|
|
1689
|
+
isDomUpToDate(e) {
|
|
1690
|
+
let t = this.getRawDom();
|
|
1691
|
+
if (this.isMultipleSelect) return this.equal(t, e);
|
|
1692
|
+
if (t === this.format(e)) return !0;
|
|
1693
|
+
if (this.flags & Z.Focused) try {
|
|
1694
|
+
return this.equal(this.readDom(), e);
|
|
1695
|
+
} catch {}
|
|
1696
|
+
return !1;
|
|
1697
|
+
}
|
|
1597
1698
|
bindEvents(e) {
|
|
1598
1699
|
let t = this.ns, n = e.trim().split(/\s+/).map((e) => `${e}${t}`).join(" ");
|
|
1599
1700
|
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
1701
|
}
|
|
1601
1702
|
};
|
|
1602
|
-
function
|
|
1603
|
-
let r = new
|
|
1703
|
+
function Ot(e, t, n) {
|
|
1704
|
+
let r = new Dt(e, t, n);
|
|
1604
1705
|
return {
|
|
1605
|
-
fx:
|
|
1706
|
+
fx: R(r.syncDomFromAtom),
|
|
1606
1707
|
cleanup: () => {
|
|
1607
1708
|
r &&= (r.cleanup(), null);
|
|
1608
1709
|
}
|
|
@@ -1610,88 +1711,114 @@ function gt(e, t, n) {
|
|
|
1610
1711
|
}
|
|
1611
1712
|
//#endregion
|
|
1612
1713
|
//#region src/core/effect-factory.ts
|
|
1613
|
-
function
|
|
1614
|
-
let i =
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1714
|
+
function kt(e, t, n, r) {
|
|
1715
|
+
let i = {
|
|
1716
|
+
latestId: 0,
|
|
1717
|
+
isDisposed: !1
|
|
1718
|
+
};
|
|
1719
|
+
K.trackCleanup(e, () => {
|
|
1720
|
+
i.isDisposed = !0;
|
|
1721
|
+
});
|
|
1722
|
+
let a = (t) => {
|
|
1723
|
+
if (!Ie(t)) {
|
|
1724
|
+
i.latestId++, k(() => {
|
|
1725
|
+
try {
|
|
1726
|
+
n(t), W.domUpdated(V.BINDING, e, r, t);
|
|
1727
|
+
} catch (e) {
|
|
1728
|
+
W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1729
|
+
}
|
|
1730
|
+
});
|
|
1622
1731
|
return;
|
|
1623
1732
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1733
|
+
let a = ++i.latestId;
|
|
1734
|
+
t.then((t) => {
|
|
1735
|
+
a === i.latestId && !i.isDisposed && k(() => {
|
|
1626
1736
|
try {
|
|
1627
|
-
n(
|
|
1737
|
+
n(t), W.domUpdated(V.BINDING, e, `${r} (async)`, t);
|
|
1628
1738
|
} catch (e) {
|
|
1629
|
-
|
|
1739
|
+
W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r), e);
|
|
1630
1740
|
}
|
|
1631
1741
|
});
|
|
1632
1742
|
}).catch((e) => {
|
|
1633
|
-
|
|
1743
|
+
a === i.latestId && !i.isDisposed && W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r), e);
|
|
1634
1744
|
});
|
|
1635
|
-
}, o =
|
|
1636
|
-
o || typeof t == "function" ?
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
}, { name: r })) : E(() => a(t));
|
|
1745
|
+
}, o = Fe(t);
|
|
1746
|
+
o || typeof t == "function" ? K.trackEffect(e, R(() => {
|
|
1747
|
+
a(o ? t.value : t());
|
|
1748
|
+
}, { name: r })) : a(t);
|
|
1640
1749
|
}
|
|
1641
|
-
function
|
|
1750
|
+
function At(e, t, n, r) {
|
|
1642
1751
|
let i = Object.keys(t), a = [], o = [], s = [], c = {};
|
|
1643
1752
|
for (let e = 0, n = i.length; e < n; e++) {
|
|
1644
|
-
let n = i[e], r = t[n], l =
|
|
1753
|
+
let n = i[e], r = t[n], l = Fe(r);
|
|
1645
1754
|
l || typeof r == "function" ? (a.push(n), o.push(r), s.push(l)) : c[n] = r;
|
|
1646
1755
|
}
|
|
1647
|
-
let l =
|
|
1756
|
+
let l = {
|
|
1757
|
+
latestId: 0,
|
|
1758
|
+
isDisposed: !1,
|
|
1759
|
+
cache: {}
|
|
1760
|
+
};
|
|
1761
|
+
K.trackCleanup(e, () => {
|
|
1762
|
+
l.isDisposed = !0;
|
|
1763
|
+
});
|
|
1764
|
+
let u = (t) => {
|
|
1648
1765
|
let a = [], o = {}, s = i.length;
|
|
1649
1766
|
for (let e = 0; e < s; e++) {
|
|
1650
1767
|
let n = i[e], r = t[n];
|
|
1651
|
-
|
|
1768
|
+
if (Ie(r) && B.call(l.cache, n)) {
|
|
1769
|
+
let e = l.cache[n];
|
|
1770
|
+
if (e.p === r) {
|
|
1771
|
+
o[n] = e.v;
|
|
1772
|
+
continue;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
Ie(r) ? a.push(r.then((e) => (l.cache[n] = {
|
|
1776
|
+
p: r,
|
|
1777
|
+
v: e
|
|
1778
|
+
}, {
|
|
1652
1779
|
key: n,
|
|
1653
1780
|
val: e
|
|
1654
1781
|
}))) : o[n] = r;
|
|
1655
1782
|
}
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
let t = ++l;
|
|
1783
|
+
if (a.length > 0) {
|
|
1784
|
+
let t = ++l.latestId;
|
|
1659
1785
|
Promise.all(a).then((i) => {
|
|
1660
|
-
if (t === l) {
|
|
1661
|
-
for (let e = 0; e <
|
|
1786
|
+
if (t === l.latestId && !l.isDisposed) {
|
|
1787
|
+
for (let e = 0, t = i.length; e < t; e++) {
|
|
1662
1788
|
let t = i[e];
|
|
1663
1789
|
o[t.key] = t.val;
|
|
1664
1790
|
}
|
|
1665
|
-
|
|
1791
|
+
k(() => {
|
|
1666
1792
|
try {
|
|
1667
|
-
n(o),
|
|
1793
|
+
n(o), W.domUpdated(V.BINDING, e, `${r} (async)`, o);
|
|
1668
1794
|
} catch (e) {
|
|
1669
|
-
|
|
1795
|
+
W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r), e);
|
|
1670
1796
|
}
|
|
1671
1797
|
});
|
|
1672
1798
|
}
|
|
1799
|
+
}, (e) => {
|
|
1800
|
+
t === l.latestId && !l.isDisposed && W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r), e);
|
|
1673
1801
|
});
|
|
1674
|
-
} else {
|
|
1675
|
-
l++;
|
|
1802
|
+
} else l.latestId++, k(() => {
|
|
1676
1803
|
try {
|
|
1677
|
-
n(o),
|
|
1804
|
+
n(o), W.domUpdated(V.BINDING, e, r, o);
|
|
1678
1805
|
} catch (e) {
|
|
1679
|
-
|
|
1806
|
+
W.error(V.BINDING, H.BINDING.UPDATER_ERROR(r, !0), e);
|
|
1680
1807
|
}
|
|
1681
|
-
}
|
|
1808
|
+
});
|
|
1682
1809
|
};
|
|
1683
|
-
a.length > 0 ?
|
|
1810
|
+
a.length > 0 ? K.trackEffect(e, R(() => {
|
|
1684
1811
|
let e = { ...c };
|
|
1685
1812
|
for (let t = 0, n = a.length; t < n; t++) {
|
|
1686
1813
|
let n = o[t];
|
|
1687
1814
|
e[a[t]] = s[t] ? n.value : n();
|
|
1688
1815
|
}
|
|
1689
|
-
|
|
1690
|
-
}, { name: r })) :
|
|
1816
|
+
u(e);
|
|
1817
|
+
}, { name: r })) : u(c);
|
|
1691
1818
|
}
|
|
1692
1819
|
//#endregion
|
|
1693
1820
|
//#region src/utils/sanitize.ts
|
|
1694
|
-
var
|
|
1821
|
+
var jt = new Set([
|
|
1695
1822
|
"href",
|
|
1696
1823
|
"src",
|
|
1697
1824
|
"action",
|
|
@@ -1705,116 +1832,139 @@ var vt = new Set([
|
|
|
1705
1832
|
"profile",
|
|
1706
1833
|
"usemap",
|
|
1707
1834
|
"classid",
|
|
1708
|
-
"codebase"
|
|
1709
|
-
|
|
1835
|
+
"codebase",
|
|
1836
|
+
"fill",
|
|
1837
|
+
"filter",
|
|
1838
|
+
"mask",
|
|
1839
|
+
"marker-start",
|
|
1840
|
+
"marker-mid",
|
|
1841
|
+
"marker-end",
|
|
1842
|
+
"clip-path"
|
|
1843
|
+
]), Mt = {
|
|
1710
1844
|
colon: ":",
|
|
1711
1845
|
Tab: " ",
|
|
1712
1846
|
NewLine: "\n"
|
|
1713
|
-
},
|
|
1714
|
-
function
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1847
|
+
}, Nt = /&#x([0-9a-f]+);?|&#([0-9]+);?/gi, Pt = /&(colon|Tab|NewLine);/g, Ft = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, It = /[<&\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/, Lt = /<\?[\s\S]*?\?>/g, Rt = /(<(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, zt = /\bon\w+\s*=/gim, Bt = /data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi, Vt = RegExp(`${We}\\s*:`, "gi"), Ht = RegExp(`^\\s*${We}\\s*:`, "i"), Ut = `(?:expression\\s*\\(|behavior\\s*:|-moz-binding\\s*:|(?:\\\\[0-9a-f]{1,6}\\s*|[\\s\\x00-\\x20/'"])*${We}\\s*:(?!image\\/)|data\\s*:\\s*(?!image\\/))`, Wt = new RegExp(Ut, "gim"), Gt = new RegExp(Ut, "im"), Kt = RegExp(`url\\s*\\(\\s*(?:["']?\\s*)?${We}\\s*:`, "i");
|
|
1848
|
+
function qt(e) {
|
|
1849
|
+
return e.replace(Nt, (e, t, n) => {
|
|
1850
|
+
let r = t ? parseInt(t, 16) : parseInt(n, 10);
|
|
1851
|
+
return r >= 0 && r <= 1114111 ? String.fromCodePoint(r) : "";
|
|
1852
|
+
}).replace(Pt, (e, t) => Mt[t] ?? "").replace(Ft, "");
|
|
1853
|
+
}
|
|
1854
|
+
function Jt(e) {
|
|
1855
|
+
return Ht.test(e) || new RegExp(Bt.source, "i").test(e);
|
|
1856
|
+
}
|
|
1857
|
+
function Yt(e) {
|
|
1858
|
+
return e.toLowerCase().includes("url(") && Kt.test(e) || Gt.test(e);
|
|
1859
|
+
}
|
|
1860
|
+
function Xt(e) {
|
|
1861
|
+
if (It.test(e) || e.indexOf(":") !== -1) return !0;
|
|
1862
|
+
let t = e.toLowerCase(), n = t.indexOf("on");
|
|
1863
|
+
for (; n !== -1 && n < e.length - 2;) {
|
|
1864
|
+
let e = t.charCodeAt(n + 2);
|
|
1724
1865
|
if (e >= 97 && e <= 122) return !0;
|
|
1866
|
+
n = t.indexOf("on", n + 1);
|
|
1725
1867
|
}
|
|
1726
1868
|
return !1;
|
|
1727
1869
|
}
|
|
1728
|
-
function
|
|
1870
|
+
function Q(e) {
|
|
1729
1871
|
if (!e) return "";
|
|
1730
1872
|
let t = String(e);
|
|
1731
|
-
if (!
|
|
1732
|
-
let n =
|
|
1873
|
+
if (!Xt(t)) return t;
|
|
1874
|
+
let n = qt(t);
|
|
1733
1875
|
if (n.indexOf("<") !== -1) {
|
|
1734
|
-
n = n.replace(
|
|
1876
|
+
n = n.replace(Lt, "");
|
|
1735
1877
|
let e;
|
|
1736
1878
|
do
|
|
1737
|
-
e = n, n = n.replace(
|
|
1879
|
+
e = n, n = n.replace(Rt, "");
|
|
1738
1880
|
while (n !== e);
|
|
1739
1881
|
}
|
|
1740
|
-
return n.replace(
|
|
1882
|
+
return n.replace(Wt, "data-unsafe-css:").replace(Vt, "data-unsafe-protocol:").replace(Bt, "data-unsafe-protocol:").replace(zt, "data-unsafe-attr=");
|
|
1741
1883
|
}
|
|
1742
|
-
var
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1884
|
+
var Zt = (e, t) => {
|
|
1885
|
+
let n = e.toLowerCase();
|
|
1886
|
+
return jt.has(n) ? Jt(qt(t)) : !1;
|
|
1887
|
+
}, Qt = (e) => Yt(qt(e)), $t = /* @__PURE__ */ new Map();
|
|
1888
|
+
function en(e) {
|
|
1889
|
+
let t = $t.get(e);
|
|
1890
|
+
return t === void 0 ? (t = e.includes("-") ? e.replace(/-./g, (e) => e[1].toUpperCase()) : e, $t.set(e, t), t) : t;
|
|
1746
1891
|
}
|
|
1747
|
-
var
|
|
1748
|
-
function
|
|
1749
|
-
let t =
|
|
1750
|
-
return t || (t =
|
|
1892
|
+
var tn = /* @__PURE__ */ new WeakMap();
|
|
1893
|
+
function nn(e) {
|
|
1894
|
+
let t = tn.get(e);
|
|
1895
|
+
return t || (t = Oe(() => {
|
|
1751
1896
|
let t = e.value;
|
|
1752
|
-
return
|
|
1753
|
-
}),
|
|
1897
|
+
return Ie(t) ? t.then((e) => Q(e)) : Q(t);
|
|
1898
|
+
}), tn.set(e, t)), t;
|
|
1754
1899
|
}
|
|
1755
|
-
function
|
|
1756
|
-
|
|
1757
|
-
el: e,
|
|
1758
|
-
trackCleanup: (t) => W.trackCleanup(e, t)
|
|
1759
|
-
};
|
|
1760
|
-
}
|
|
1761
|
-
function zt({ el: e }, t, n) {
|
|
1762
|
-
_t(e, t, (t) => {
|
|
1900
|
+
function rn({ el: e }, t, n) {
|
|
1901
|
+
kt(e, t, (t) => {
|
|
1763
1902
|
let r = n ? n(t) : String(t ?? "");
|
|
1764
1903
|
e.textContent !== r && (e.textContent = r);
|
|
1765
1904
|
}, "text");
|
|
1766
1905
|
}
|
|
1767
|
-
function
|
|
1768
|
-
let n =
|
|
1769
|
-
|
|
1770
|
-
let
|
|
1771
|
-
|
|
1906
|
+
function an({ el: e }, t) {
|
|
1907
|
+
let n = ae(t) ? nn(t) : t, r = null;
|
|
1908
|
+
kt(e, n, (i) => {
|
|
1909
|
+
let a = n === t ? Q(i) : i;
|
|
1910
|
+
r !== a && (K.cleanupDescendants(e), e.innerHTML = a, r = a);
|
|
1772
1911
|
}, "html");
|
|
1773
1912
|
}
|
|
1774
|
-
function
|
|
1775
|
-
let n = {};
|
|
1776
|
-
for (let e in t) if (
|
|
1913
|
+
function on({ el: e }, t) {
|
|
1914
|
+
let n = {}, r = {};
|
|
1915
|
+
for (let e in t) if (B.call(t, e)) {
|
|
1777
1916
|
let t = e.trim();
|
|
1778
|
-
n[e] = t
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
for (let
|
|
1782
|
-
let
|
|
1783
|
-
|
|
1917
|
+
n[e] = /\s/.test(t) ? t.split(/\s+/).filter(Boolean) : [t];
|
|
1918
|
+
}
|
|
1919
|
+
At(e, t, (t) => {
|
|
1920
|
+
for (let i in t) {
|
|
1921
|
+
let a = !!t[i];
|
|
1922
|
+
if (r[i] === a) continue;
|
|
1923
|
+
let o = n[i];
|
|
1924
|
+
if (a) e.classList.add(...o);
|
|
1925
|
+
else for (let r of o) {
|
|
1926
|
+
let a = !1;
|
|
1927
|
+
for (let e in t) if (e !== i && t[e] && n[e].includes(r)) {
|
|
1928
|
+
a = !0;
|
|
1929
|
+
break;
|
|
1930
|
+
}
|
|
1931
|
+
a || e.classList.remove(r);
|
|
1932
|
+
}
|
|
1933
|
+
r[i] = a;
|
|
1784
1934
|
}
|
|
1785
1935
|
}, "class");
|
|
1786
1936
|
}
|
|
1787
|
-
function
|
|
1788
|
-
let n = e.style, r = {}, i = {};
|
|
1789
|
-
for (let e in t) if (
|
|
1937
|
+
function sn({ el: e }, t) {
|
|
1938
|
+
let n = e.style, r = {}, i = {}, a = {};
|
|
1939
|
+
for (let e in t) if (B.call(t, e)) {
|
|
1790
1940
|
let n = t[e], [a, o] = Array.isArray(n) ? n : [n, ""];
|
|
1791
1941
|
r[e] = a, i[e] = {
|
|
1792
|
-
camel:
|
|
1942
|
+
camel: en(e),
|
|
1793
1943
|
unit: o
|
|
1794
1944
|
};
|
|
1795
1945
|
}
|
|
1796
|
-
|
|
1946
|
+
At(e, r, (e) => {
|
|
1797
1947
|
for (let t in e) {
|
|
1798
|
-
let r = i[t],
|
|
1799
|
-
|
|
1948
|
+
let r = i[t], o = e[t], s = r.unit ? `${o}${r.unit}` : String(o), c = r.camel;
|
|
1949
|
+
a[t] !== s && (Qt(s) || (n[c] = s), a[t] = s);
|
|
1800
1950
|
}
|
|
1801
1951
|
}, "css");
|
|
1802
1952
|
}
|
|
1803
|
-
function
|
|
1953
|
+
function cn({ el: e }, t) {
|
|
1804
1954
|
let n = {}, r = {}, i = {};
|
|
1805
1955
|
for (let a in t) {
|
|
1806
|
-
if (!
|
|
1956
|
+
if (!B.call(t, a)) continue;
|
|
1807
1957
|
let o = a.toLowerCase();
|
|
1808
1958
|
if (o.startsWith("on")) {
|
|
1809
|
-
console.warn(`${
|
|
1959
|
+
console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_EVENT_HANDLER(a)}`);
|
|
1810
1960
|
continue;
|
|
1811
1961
|
}
|
|
1812
1962
|
n[a] = t[a], r[a] = {
|
|
1813
1963
|
isAria: o.startsWith("aria-"),
|
|
1814
|
-
isUrl:
|
|
1964
|
+
isUrl: jt.has(o)
|
|
1815
1965
|
}, i[a] = e.getAttribute(a);
|
|
1816
1966
|
}
|
|
1817
|
-
|
|
1967
|
+
At(e, n, (t) => {
|
|
1818
1968
|
for (let n in t) {
|
|
1819
1969
|
let a = r[n], o = t[n];
|
|
1820
1970
|
if (o == null || o === !1 && !a.isAria) {
|
|
@@ -1822,96 +1972,100 @@ function Ut({ el: e }, t) {
|
|
|
1822
1972
|
continue;
|
|
1823
1973
|
}
|
|
1824
1974
|
let s = o === !0 ? a.isAria ? "true" : n : String(o);
|
|
1825
|
-
if (
|
|
1826
|
-
console.warn(`${
|
|
1975
|
+
if (Zt(n, s)) {
|
|
1976
|
+
console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_PROTOCOL(n)}`);
|
|
1827
1977
|
continue;
|
|
1828
1978
|
}
|
|
1829
1979
|
i[n] !== s && (e.setAttribute(n, s), i[n] = s);
|
|
1830
1980
|
}
|
|
1831
1981
|
}, "attr");
|
|
1832
1982
|
}
|
|
1833
|
-
function
|
|
1834
|
-
let n = e.el, r = {}, i = {};
|
|
1983
|
+
function ln(e, t) {
|
|
1984
|
+
let n = e.el, r = {}, i = {}, a = {};
|
|
1835
1985
|
for (let e in t) {
|
|
1836
|
-
if (!
|
|
1986
|
+
if (!B.call(t, e)) continue;
|
|
1837
1987
|
let n = e.toLowerCase();
|
|
1838
|
-
if (n.startsWith("on") ||
|
|
1839
|
-
console.warn(`${
|
|
1988
|
+
if (n.startsWith("on") || Ue.has(e)) {
|
|
1989
|
+
console.warn(`${V.BINDING} ${n.startsWith("on") ? H.SECURITY.BLOCKED_EVENT_HANDLER(e) : H.SECURITY.BLOCKED_PROP(e)}`);
|
|
1840
1990
|
continue;
|
|
1841
1991
|
}
|
|
1842
|
-
r[e] = t[e], i[e] = { isUrl:
|
|
1992
|
+
r[e] = t[e], i[e] = { isUrl: jt.has(n) };
|
|
1843
1993
|
}
|
|
1844
|
-
|
|
1994
|
+
At(e.el, r, (e) => {
|
|
1845
1995
|
for (let t in e) {
|
|
1846
1996
|
let r = e[t];
|
|
1847
|
-
if (
|
|
1848
|
-
|
|
1849
|
-
|
|
1997
|
+
if (a[t] !== r) {
|
|
1998
|
+
if (typeof r == "string" && Zt(t, r)) {
|
|
1999
|
+
console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_PROTOCOL(t)}`);
|
|
2000
|
+
continue;
|
|
2001
|
+
}
|
|
2002
|
+
n[t] = r, a[t] = r;
|
|
1850
2003
|
}
|
|
1851
|
-
n[t] !== r && (n[t] = r);
|
|
1852
2004
|
}
|
|
1853
2005
|
}, "prop");
|
|
1854
2006
|
}
|
|
1855
|
-
function
|
|
2007
|
+
function un({ el: e }, t, n) {
|
|
1856
2008
|
let r = e.style.display === "none" ? "" : e.style.display;
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
e.style.display !== i && (e.style.display = i);
|
|
2009
|
+
kt(e, t, (t) => {
|
|
2010
|
+
n === !!t ? e.style.display !== "none" && (r = e.style.display, e.style.display = "none") : e.style.display === "none" && (e.style.display = r);
|
|
1860
2011
|
}, n ? "hide" : "show");
|
|
1861
2012
|
}
|
|
1862
|
-
function
|
|
2013
|
+
function dn(t, n, r = {}) {
|
|
1863
2014
|
let i = t.el.tagName.toLowerCase();
|
|
1864
|
-
if (!
|
|
1865
|
-
console.warn(`${
|
|
2015
|
+
if (!He.has(i)) {
|
|
2016
|
+
console.warn(`${V.BINDING} ${H.BINDING.INVALID_INPUT_ELEMENT(i)}`);
|
|
1866
2017
|
return;
|
|
1867
2018
|
}
|
|
1868
|
-
let { fx: a, cleanup: o } =
|
|
1869
|
-
|
|
2019
|
+
let { fx: a, cleanup: o } = Ot(e(t.el), n, r);
|
|
2020
|
+
K.trackEffect(t.el, a), t.trackCleanup(o);
|
|
2021
|
+
}
|
|
2022
|
+
function fn(t) {
|
|
2023
|
+
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");
|
|
1870
2024
|
}
|
|
1871
|
-
function
|
|
2025
|
+
function pn(t, n) {
|
|
1872
2026
|
let r = t.el, i = e(r), a = () => {
|
|
1873
|
-
n.peek() !== r.checked && (n.value = r.checked,
|
|
2027
|
+
n.peek() !== r.checked && (n.value = r.checked, fn(r));
|
|
1874
2028
|
};
|
|
1875
|
-
a[
|
|
2029
|
+
a[Y] = !0, i.on("change change.atomRadioSync", a), t.trackCleanup(() => i.off("change change.atomRadioSync", a)), K.trackEffect(r, R(() => {
|
|
1876
2030
|
let e = !!n.value;
|
|
1877
|
-
|
|
1878
|
-
r.checked !== e && (r.checked = e,
|
|
2031
|
+
k(() => {
|
|
2032
|
+
r.checked !== e && (r.checked = e, W.domUpdated(V.BINDING, r, "checked", e), e && fn(r));
|
|
1879
2033
|
});
|
|
1880
2034
|
}));
|
|
1881
2035
|
}
|
|
1882
|
-
function
|
|
2036
|
+
function mn(t, n) {
|
|
1883
2037
|
let r = e(t.el);
|
|
1884
2038
|
r.on(n), t.trackCleanup(() => r.off(n));
|
|
1885
2039
|
}
|
|
1886
|
-
function
|
|
2040
|
+
function hn({ el: t, trackCleanup: n }, r, i) {
|
|
1887
2041
|
let a = e(t);
|
|
1888
2042
|
a.on(r, i), n(() => a.off(r, i));
|
|
1889
2043
|
}
|
|
1890
|
-
function
|
|
1891
|
-
|
|
2044
|
+
function gn(e) {
|
|
2045
|
+
K.cleanupTree(e);
|
|
1892
2046
|
}
|
|
1893
2047
|
//#endregion
|
|
1894
2048
|
//#region src/bindings/form.ts
|
|
1895
|
-
var
|
|
2049
|
+
var _n = "input, select, textarea", vn = class {
|
|
1896
2050
|
constructor(e, t, n = {}) {
|
|
1897
2051
|
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
2052
|
}
|
|
1899
2053
|
init() {
|
|
1900
|
-
let e =
|
|
2054
|
+
let e = R(() => {
|
|
1901
2055
|
let e = this.atom.value;
|
|
1902
|
-
this.isSyncingFromLeaf || !this.fields.length ||
|
|
1903
|
-
|
|
2056
|
+
this.isSyncingFromLeaf || !this.fields.length || xe(() => {
|
|
2057
|
+
k(() => {
|
|
1904
2058
|
for (let t = 0; t < this.fields.length; t++) {
|
|
1905
|
-
let n = this.fields[t], r =
|
|
2059
|
+
let n = this.fields[t], r = z(e, n.parts);
|
|
1906
2060
|
Object.is(n.atom.peek(), r) || (n.atom.value = r);
|
|
1907
2061
|
}
|
|
1908
2062
|
});
|
|
1909
2063
|
});
|
|
1910
2064
|
});
|
|
1911
|
-
|
|
2065
|
+
K.trackEffect(this.form, e), this.bindElement(this.form), this.setupObserver();
|
|
1912
2066
|
}
|
|
1913
2067
|
bindElement(e) {
|
|
1914
|
-
let t = e.matches?.(
|
|
2068
|
+
let t = e.matches?.(_n) ? [e] : e.querySelectorAll?.(_n) || [];
|
|
1915
2069
|
for (let e = 0, n = t.length; e < n; e++) this.bindControl(t[e]);
|
|
1916
2070
|
}
|
|
1917
2071
|
bindControl(e) {
|
|
@@ -1919,11 +2073,11 @@ var Zt = "input, select, textarea", Qt = class {
|
|
|
1919
2073
|
let t = e, n = t.name;
|
|
1920
2074
|
if (!n) return;
|
|
1921
2075
|
let r = this.elementNames.get(t);
|
|
1922
|
-
if (r !== void 0 && r !== n &&
|
|
2076
|
+
if (r !== void 0 && r !== n && K.cleanup(t), this.elementNames.has(t) && r === n) return;
|
|
1923
2077
|
let i = this.acquireField(n);
|
|
1924
2078
|
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") :
|
|
2079
|
+
let a = pt(t);
|
|
2080
|
+
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") : dn(a, i.atom, this.options);
|
|
1927
2081
|
}
|
|
1928
2082
|
bindToggle(t, n, r, i) {
|
|
1929
2083
|
let a = t.el, o = () => {
|
|
@@ -1933,7 +2087,7 @@ var Zt = "input, select, textarea", Qt = class {
|
|
|
1933
2087
|
a.checked ? t.add(r) : t.delete(r), n.value = Array.from(t);
|
|
1934
2088
|
} else n.value = i ? a.checked : r;
|
|
1935
2089
|
};
|
|
1936
|
-
o[
|
|
2090
|
+
o[Y] = !0, e(a).on("change", o), t.trackCleanup(() => e(a).off("change", o)), K.trackEffect(a, R(() => {
|
|
1937
2091
|
let e = n.value, t = i ? Array.isArray(e) ? e.some((e) => String(e) === r) : !!e : String(e) === r;
|
|
1938
2092
|
a.checked !== t && (a.checked = t);
|
|
1939
2093
|
}));
|
|
@@ -1941,21 +2095,21 @@ var Zt = "input, select, textarea", Qt = class {
|
|
|
1941
2095
|
acquireField(e) {
|
|
1942
2096
|
let t = this.fieldMap.get(e);
|
|
1943
2097
|
if (t) return t.refCount++, t;
|
|
1944
|
-
let n = e.replace(/\[(\w+)\]/g, ".$1").split(".").filter(Boolean), r =
|
|
2098
|
+
let n = e.replace(/\[(\w+)\]/g, ".$1").split(".").filter(Boolean), r = Ce(z(this.atom.peek(), n));
|
|
1945
2099
|
return t = {
|
|
1946
2100
|
atom: r,
|
|
1947
2101
|
parts: n,
|
|
1948
2102
|
name: e,
|
|
1949
2103
|
refCount: 1,
|
|
1950
2104
|
effect: null
|
|
1951
|
-
}, t.effect =
|
|
2105
|
+
}, t.effect = R(() => {
|
|
1952
2106
|
let t = r.value;
|
|
1953
2107
|
this.options.transform && (t = this.options.transform(e, t));
|
|
1954
2108
|
let i = this.atom.peek(), a = Ae(i, n, 0, t);
|
|
1955
2109
|
if (a !== i) {
|
|
1956
2110
|
this.isSyncingFromLeaf = !0;
|
|
1957
2111
|
try {
|
|
1958
|
-
this.atom.value = a, this.options.onChange &&
|
|
2112
|
+
this.atom.value = a, this.options.onChange && k(() => this.options.onChange(e, t));
|
|
1959
2113
|
} finally {
|
|
1960
2114
|
this.isSyncingFromLeaf = !1;
|
|
1961
2115
|
}
|
|
@@ -1968,7 +2122,7 @@ var Zt = "input, select, textarea", Qt = class {
|
|
|
1968
2122
|
let e = this.fields.indexOf(n);
|
|
1969
2123
|
e !== -1 && this.fields.splice(e, 1), n.effect?.dispose(), this.fieldMap.delete(t);
|
|
1970
2124
|
}
|
|
1971
|
-
|
|
2125
|
+
K.cleanup(e);
|
|
1972
2126
|
}
|
|
1973
2127
|
setupObserver() {
|
|
1974
2128
|
let e = new MutationObserver((e) => {
|
|
@@ -1986,141 +2140,107 @@ var Zt = "input, select, textarea", Qt = class {
|
|
|
1986
2140
|
subtree: !0,
|
|
1987
2141
|
attributes: !0,
|
|
1988
2142
|
attributeFilter: ["name"]
|
|
1989
|
-
}),
|
|
2143
|
+
}), K.trackCleanup(this.form, () => e.disconnect());
|
|
1990
2144
|
}
|
|
1991
2145
|
};
|
|
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;
|
|
2146
|
+
function yn(e, t, n = {}) {
|
|
2147
|
+
new vn(e, t, n);
|
|
2007
2148
|
}
|
|
2008
2149
|
e.fn.atomText = function(e, t) {
|
|
2009
|
-
return
|
|
2150
|
+
return J(this, (n) => rn(n, e, t), { needsCtx: !0 });
|
|
2010
2151
|
}, e.fn.atomHtml = function(e) {
|
|
2011
|
-
return
|
|
2152
|
+
return J(this, (t) => an(t, e), { needsCtx: !0 });
|
|
2012
2153
|
}, 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));
|
|
2154
|
+
let n = typeof e == "string" ? t === void 0 ? null : { [e]: t } : e;
|
|
2155
|
+
return n ? J(this, (e) => on(e, n), { needsCtx: !0 }) : (console.warn(`${V.BINDING} ${H.BINDING.MISSING_CONDITION("atomClass")}`), this);
|
|
2019
2156
|
}, 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));
|
|
2157
|
+
let r = typeof e == "string" ? t === void 0 ? null : { [e]: n ? [t, n] : t } : e;
|
|
2158
|
+
return r ? J(this, (e) => sn(e, r), { needsCtx: !0 }) : (console.warn(`${V.BINDING} ${H.BINDING.MISSING_SOURCE("atomCss")}`), this);
|
|
2026
2159
|
}, 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));
|
|
2160
|
+
let n = typeof e == "string" ? t === void 0 ? null : { [e]: t } : e;
|
|
2161
|
+
return n ? J(this, (e) => cn(e, n), { needsCtx: !0 }) : (console.warn(`${V.BINDING} ${H.BINDING.MISSING_SOURCE("atomAttr")}`), this);
|
|
2033
2162
|
}, 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));
|
|
2163
|
+
let n = typeof e == "string" ? t === void 0 ? null : { [e]: t } : e;
|
|
2164
|
+
return n ? J(this, (e) => ln(e, n), { needsCtx: !0 }) : (console.warn(`${V.BINDING} ${H.BINDING.MISSING_SOURCE("atomProp")}`), this);
|
|
2040
2165
|
}, e.fn.atomShow = function(e) {
|
|
2041
|
-
return
|
|
2166
|
+
return J(this, (t) => un(t, e, !1), { needsCtx: !0 });
|
|
2042
2167
|
}, e.fn.atomHide = function(e) {
|
|
2043
|
-
return
|
|
2168
|
+
return J(this, (t) => un(t, e, !0), { needsCtx: !0 });
|
|
2044
2169
|
}, e.fn.atomVal = function(e, t = {}) {
|
|
2045
|
-
return
|
|
2170
|
+
return J(this, (n) => dn(n, e, t), { needsCtx: !0 });
|
|
2046
2171
|
}, e.fn.atomChecked = function(e) {
|
|
2047
|
-
return
|
|
2172
|
+
return J(this, (t) => pn(t, e), { needsCtx: !0 });
|
|
2048
2173
|
}, e.fn.atomForm = function(e, t = {}) {
|
|
2049
|
-
return
|
|
2050
|
-
r instanceof HTMLFormElement
|
|
2051
|
-
});
|
|
2174
|
+
return J(this, (n, r) => {
|
|
2175
|
+
r instanceof HTMLFormElement ? yn(r, e, t) : W.log(V.BINDING, "Skipping non-Form element for atomForm");
|
|
2176
|
+
}, { needsCtx: !1 });
|
|
2052
2177
|
}, e.fn.atomOn = function(e, t) {
|
|
2053
|
-
return
|
|
2178
|
+
return J(this, (n) => hn(n, e, t), { needsCtx: !0 });
|
|
2054
2179
|
};
|
|
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) =>
|
|
2180
|
+
var bn = [
|
|
2181
|
+
(e, t) => rn(e, ...mt(t.text)),
|
|
2182
|
+
(e, t) => an(e, t.html),
|
|
2183
|
+
(e, t) => on(e, t.class),
|
|
2184
|
+
(e, t) => sn(e, t.css),
|
|
2185
|
+
(e, t) => cn(e, t.attr),
|
|
2186
|
+
(e, t) => ln(e, t.prop),
|
|
2187
|
+
(e, t) => un(e, t.show, !1),
|
|
2188
|
+
(e, t) => un(e, t.hide, !0),
|
|
2189
|
+
(e, t) => dn(e, ...mt(t.val)),
|
|
2190
|
+
(e, t) => pn(e, t.checked),
|
|
2064
2191
|
(e, t) => {
|
|
2065
|
-
|
|
2066
|
-
Array.isArray(n) ? Kt(e, n[0], n[1]) : Kt(e, n);
|
|
2192
|
+
e.el instanceof HTMLFormElement && yn(e.el, ...mt(t.form));
|
|
2067
2193
|
},
|
|
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)
|
|
2194
|
+
(e, t) => mn(e, t.on)
|
|
2076
2195
|
];
|
|
2077
2196
|
e.fn.atomBind = function(e) {
|
|
2078
2197
|
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 :
|
|
2198
|
+
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 : J(this, (n) => {
|
|
2080
2199
|
let r = t;
|
|
2081
2200
|
for (; r > 0;) {
|
|
2082
2201
|
let t = r & -r;
|
|
2083
|
-
|
|
2202
|
+
bn[31 - Math.clz32(t)](n, e), r ^= t;
|
|
2084
2203
|
}
|
|
2085
|
-
});
|
|
2204
|
+
}, { needsCtx: !0 });
|
|
2086
2205
|
}, 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;
|
|
2206
|
+
return J(this, (e, t) => gn(t), { needsCtx: !1 });
|
|
2093
2207
|
};
|
|
2094
2208
|
//#endregion
|
|
2095
|
-
//#region src/bindings/list.ts
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2209
|
+
//#region src/bindings/list/utils.ts
|
|
2210
|
+
function xn(t) {
|
|
2211
|
+
return t instanceof Element ? e(t) : t;
|
|
2212
|
+
}
|
|
2213
|
+
function Sn(e, t) {
|
|
2214
|
+
if (e instanceof Element) t === null ? e.removeAttribute("data-atom-key") : e.setAttribute("data-atom-key", t);
|
|
2215
|
+
else if (!e.nodeType) {
|
|
2216
|
+
let n = e;
|
|
2217
|
+
for (let e = 0, r = n.length; e < r; e++) {
|
|
2218
|
+
let r = n[e];
|
|
2219
|
+
r instanceof Element && (t === null ? r.removeAttribute("data-atom-key") : r.setAttribute("data-atom-key", t));
|
|
2220
|
+
}
|
|
2106
2221
|
}
|
|
2107
2222
|
}
|
|
2108
|
-
function
|
|
2109
|
-
|
|
2223
|
+
function Cn(e) {
|
|
2224
|
+
if (e instanceof Element) K.cleanupTree(e);
|
|
2225
|
+
else for (let t = 0, n = e.length; t < n; t++) {
|
|
2226
|
+
let n = e[t];
|
|
2227
|
+
n instanceof Element && K.cleanupTree(n);
|
|
2228
|
+
}
|
|
2110
2229
|
}
|
|
2111
|
-
|
|
2230
|
+
//#endregion
|
|
2231
|
+
//#region src/bindings/list/context.ts
|
|
2232
|
+
var wn = class {
|
|
2112
2233
|
constructor(e, t, n) {
|
|
2113
2234
|
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
2235
|
}
|
|
2115
2236
|
scheduleRemoval(e, t) {
|
|
2116
2237
|
let n = () => {
|
|
2117
|
-
this.fx?.isDisposed || (t[0]?.isConnected && t.remove(), this.removingKeys.delete(e),
|
|
2238
|
+
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
2239
|
}, r = this.onRemove?.(t);
|
|
2119
2240
|
r instanceof Promise ? r.then(n, n) : n();
|
|
2120
2241
|
}
|
|
2121
2242
|
removeItem(e, t) {
|
|
2122
|
-
|
|
2123
|
-
this.removingKeys.add(e), this.scheduleRemoval(e, t);
|
|
2243
|
+
Sn(t, null), this.removingKeys.add(e), this.scheduleRemoval(e, t);
|
|
2124
2244
|
}
|
|
2125
2245
|
dispose() {
|
|
2126
2246
|
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,148 +2249,171 @@ var cn = class {
|
|
|
2129
2249
|
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
2250
|
}
|
|
2131
2251
|
};
|
|
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();
|
|
2252
|
+
//#endregion
|
|
2253
|
+
//#region src/bindings/list/diff.ts
|
|
2254
|
+
function Tn(e, t, n, r, i, a, o) {
|
|
2255
|
+
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 || Re;
|
|
2256
|
+
for (; p <= m && p <= h;) {
|
|
2257
|
+
let e = t[p], n = r(e, p);
|
|
2258
|
+
if (s[p] !== n || !g(c[p], e) || !l[p]) break;
|
|
2259
|
+
d.set(n, p++);
|
|
2260
|
+
}
|
|
2261
|
+
for (; m >= p && h >= p;) {
|
|
2262
|
+
let e = t[h], n = r(e, h);
|
|
2263
|
+
if (s[m] !== n || !g(c[m], e) || !l[m]) break;
|
|
2264
|
+
d.set(n, h--), m--;
|
|
2265
|
+
}
|
|
2266
|
+
let _ = o.map.acquire();
|
|
2267
|
+
for (let e = p; e <= m; e++) _.set(s[e], e);
|
|
2268
|
+
let v = o.set.acquire();
|
|
2160
2269
|
e.ensureBuffers(n);
|
|
2161
|
-
let
|
|
2162
|
-
_.length = n;
|
|
2163
|
-
let v = $.acquire();
|
|
2164
|
-
v.length = n;
|
|
2165
|
-
let y = $.acquire();
|
|
2270
|
+
let y = o.array.acquire();
|
|
2166
2271
|
y.length = n;
|
|
2167
|
-
let b =
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2272
|
+
let b = o.array.acquire();
|
|
2273
|
+
b.length = n;
|
|
2274
|
+
let x = o.array.acquire();
|
|
2275
|
+
x.length = n;
|
|
2276
|
+
let S = e.statesBuffer, C = e.indicesBuffer, w = o.array.acquire(), T = o.array.acquire(), ee = o.array.acquire();
|
|
2277
|
+
for (let e = 0; e < p; e++) {
|
|
2278
|
+
let n = s[e];
|
|
2279
|
+
y[e] = n, b[e] = t[e], x[e] = l[e], S[e] = 3, C[e] = e, v.add(n);
|
|
2280
|
+
}
|
|
2281
|
+
for (let e = f - 1, r = n - 1; r > h; r--, e--) {
|
|
2282
|
+
let n = s[e];
|
|
2283
|
+
y[r] = n, b[r] = t[r], x[r] = l[e], S[r] = 3, C[r] = e, v.add(n);
|
|
2284
|
+
}
|
|
2285
|
+
for (let n = p; n <= h; n++) {
|
|
2286
|
+
let o = t[n], s = r(o, n);
|
|
2287
|
+
if (y[n] = s, b[n] = o, d.set(s, n), v.has(s)) {
|
|
2288
|
+
W.warn(V.LIST, H.LIST.DUPLICATE_KEY(s, n, e.containerSelector)), C[n] = -1;
|
|
2174
2289
|
continue;
|
|
2175
2290
|
}
|
|
2176
|
-
|
|
2177
|
-
let f =
|
|
2291
|
+
v.add(s);
|
|
2292
|
+
let f = _.get(s);
|
|
2178
2293
|
if (f === void 0) {
|
|
2179
|
-
|
|
2294
|
+
w.push(s), T.push(o), ee.push(n), C[n] = -1, S[n] = 1;
|
|
2180
2295
|
continue;
|
|
2181
2296
|
}
|
|
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:
|
|
2297
|
+
let p = c[f];
|
|
2298
|
+
x[n] = l[f], !i && p !== o && !(a ? a(p, o) : Re(p, o)) ? (w.push(s), T.push(o), ee.push(n), S[n] = 2) : S[n] = 0, C[n] = u.has(s) ? -1 : f;
|
|
2299
|
+
}
|
|
2300
|
+
return o.map.release(_), {
|
|
2301
|
+
newKeys: y,
|
|
2302
|
+
newKeySet: v,
|
|
2303
|
+
newItems: b,
|
|
2304
|
+
newNodes: x,
|
|
2305
|
+
newStates: S,
|
|
2306
|
+
newIndices: C,
|
|
2307
|
+
trKeys: w,
|
|
2308
|
+
trItems: T,
|
|
2309
|
+
trIdxs: ee,
|
|
2310
|
+
startIndex: p,
|
|
2311
|
+
oldEndIndex: m,
|
|
2312
|
+
newEndIndex: h
|
|
2198
2313
|
};
|
|
2199
2314
|
}
|
|
2200
|
-
|
|
2315
|
+
//#endregion
|
|
2316
|
+
//#region src/bindings/list/dom.ts
|
|
2317
|
+
var En = 0;
|
|
2318
|
+
function Dn(e, t, n) {
|
|
2319
|
+
if (!e) return;
|
|
2320
|
+
if (e instanceof Element) {
|
|
2321
|
+
n.insertBefore(e, t);
|
|
2322
|
+
return;
|
|
2323
|
+
}
|
|
2324
|
+
let r = e.length;
|
|
2325
|
+
for (let i = 0; i < r; i++) {
|
|
2326
|
+
let r = e[i];
|
|
2327
|
+
r && n.insertBefore(r, t);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
function On(t, n, r, i, a) {
|
|
2331
|
+
if (t.$emptyEl && n > 0 && (t.$emptyEl.remove(), t.$emptyEl = null), n !== 0) return;
|
|
2332
|
+
let { oldKeys: o, oldNodes: s, onRemove: c } = t;
|
|
2333
|
+
if (c) for (let e = 0, n = o.length; e < n; e++) {
|
|
2334
|
+
let n = o[e];
|
|
2335
|
+
s[e] && t.removeItem(n, xn(s[e]));
|
|
2336
|
+
}
|
|
2337
|
+
else {
|
|
2338
|
+
for (let e = 0, n = o.length; e < n; e++) t.removingKeys.delete(o[e]);
|
|
2339
|
+
r.empty();
|
|
2340
|
+
}
|
|
2341
|
+
i && !t.$emptyEl && (t.$emptyEl = e(typeof i == "string" ? Q(i) : i), t.$emptyEl.appendTo(r)), a.release(t.oldKeys), a.release(t.oldItems), a.release(t.oldNodes), t.oldKeys = [], t.oldItems = [], t.oldNodes = [];
|
|
2342
|
+
}
|
|
2343
|
+
function kn(t, n, r) {
|
|
2201
2344
|
let { trKeys: i, trItems: a, trIdxs: o, newNodes: s, newStates: c } = t, l = i.length, u = Array(l), d = [], f = 0;
|
|
2202
2345
|
for (let e = 0; e < l; e++) {
|
|
2203
2346
|
let t = n.render(a[e], o[e]);
|
|
2204
2347
|
u[e] = t, typeof t == "string" && (d.push(t), f++);
|
|
2205
2348
|
}
|
|
2206
2349
|
let p = null;
|
|
2207
|
-
if (d.length > 0) if (d.length === 1) p = [
|
|
2350
|
+
if (d.length > 0) if (d.length === 1) p = [Q(d[0])];
|
|
2208
2351
|
else {
|
|
2209
|
-
let e = `<template data-atom-sep="${(
|
|
2210
|
-
p =
|
|
2352
|
+
let e = `<template data-atom-sep="${(En++).toString(36)}"></template>`;
|
|
2353
|
+
p = Q(d.join(e)).split(e);
|
|
2211
2354
|
}
|
|
2212
|
-
if (r && p && f === l && !n.bind && !n.onAdd && !n.onRemove && !n.events) return p;
|
|
2355
|
+
if (r && p && f === l && !n.bind && !n.onAdd && !n.onRemove && !n.events && e.parseHTML(p.join("")).length === l) return p;
|
|
2213
2356
|
let m = 0;
|
|
2214
2357
|
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]) {
|
|
2358
|
+
let n = u[t], r = e(typeof n == "string" ? e.parseHTML(p[m++]) : n), a = o[t];
|
|
2359
|
+
if (Sn(r, String(i[t])), c[a] === 2 && s[a]) {
|
|
2221
2360
|
let e = s[a];
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
n instanceof Element && W.cleanupTree(n);
|
|
2226
|
-
}
|
|
2227
|
-
sn(e).replaceWith(r);
|
|
2361
|
+
Cn(e);
|
|
2362
|
+
let t = xn(e);
|
|
2363
|
+
t.first().before(r), t.remove();
|
|
2228
2364
|
}
|
|
2229
2365
|
s[a] = r.length === 1 ? r[0] : r;
|
|
2230
2366
|
}
|
|
2231
2367
|
return null;
|
|
2232
2368
|
}
|
|
2233
|
-
function
|
|
2369
|
+
function An(e, t) {
|
|
2234
2370
|
let { startIndex: n, oldEndIndex: r, newKeySet: i } = t;
|
|
2235
2371
|
for (let t = n; t <= r; t++) {
|
|
2236
2372
|
let n = e.oldKeys[t];
|
|
2237
|
-
!i.has(n) && e.oldNodes[t] && e.removeItem(n,
|
|
2373
|
+
!i.has(n) && e.oldNodes[t] && e.removeItem(n, xn(e.oldNodes[t]));
|
|
2238
2374
|
}
|
|
2239
2375
|
}
|
|
2240
|
-
function
|
|
2376
|
+
function jn(t, n, r, i, a) {
|
|
2241
2377
|
let { newKeys: o, newItems: s, newNodes: c, newStates: l, newIndices: u } = n, d = o.length;
|
|
2242
2378
|
if (a !== null) {
|
|
2243
2379
|
r.innerHTML = a.join("");
|
|
2244
2380
|
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]),
|
|
2381
|
+
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
2382
|
return;
|
|
2247
2383
|
}
|
|
2248
|
-
if (t.oldKeys.length === 0) {
|
|
2384
|
+
if (t.oldKeys.length === 0 && t.removingKeys.size === 0) {
|
|
2249
2385
|
let e = document.createDocumentFragment();
|
|
2250
2386
|
for (let t = 0; t < d; t++) {
|
|
2251
2387
|
let n = c[t];
|
|
2252
|
-
if (n instanceof Element) e.appendChild(n);
|
|
2388
|
+
if (n) if (n instanceof Element) e.appendChild(n);
|
|
2253
2389
|
else for (let t = 0; t < n.length; t++) e.appendChild(n[t]);
|
|
2254
2390
|
}
|
|
2255
|
-
r.appendChild(e);
|
|
2391
|
+
r.innerHTML = "", r.appendChild(e);
|
|
2256
2392
|
} else {
|
|
2257
2393
|
let e = null, t = 2147483647;
|
|
2258
2394
|
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;
|
|
2395
|
+
let i = u[n], a = c[n];
|
|
2396
|
+
a && (i !== -1 && i < t ? t = i : Dn(a, e, r), e = a instanceof Element ? a : a[0] ?? null);
|
|
2263
2397
|
}
|
|
2264
2398
|
}
|
|
2265
2399
|
for (let e = 0; e < d; e++) {
|
|
2266
2400
|
let n = l[e];
|
|
2267
2401
|
if (n !== 3) {
|
|
2268
|
-
let r =
|
|
2269
|
-
|
|
2402
|
+
let r = c[e];
|
|
2403
|
+
if (!r) continue;
|
|
2404
|
+
let a = xn(r), l = s[e];
|
|
2405
|
+
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
2406
|
}
|
|
2271
2407
|
}
|
|
2272
2408
|
}
|
|
2273
|
-
|
|
2409
|
+
//#endregion
|
|
2410
|
+
//#region src/bindings/list/index.ts
|
|
2411
|
+
var Mn = /* @__PURE__ */ new WeakMap(), Nn = new it(() => /* @__PURE__ */ new Map(), (e) => e.clear()), Pn = new it(() => /* @__PURE__ */ new Set(), (e) => e.clear()), $ = new rt(100, 1024), Fn = {
|
|
2412
|
+
map: Nn,
|
|
2413
|
+
set: Pn,
|
|
2414
|
+
array: $
|
|
2415
|
+
};
|
|
2416
|
+
function In(t, n) {
|
|
2274
2417
|
let r = typeof n.key == "function" ? n.key : (e) => e[n.key], i = {
|
|
2275
2418
|
bind: n.bind,
|
|
2276
2419
|
update: n.update,
|
|
@@ -2281,20 +2424,20 @@ e.fn.atomList = function(t, n) {
|
|
|
2281
2424
|
for (let a = 0, o = this.length; a < o; a++) {
|
|
2282
2425
|
let o = this[a], s = e(o);
|
|
2283
2426
|
s.off(".atomList");
|
|
2284
|
-
let c =
|
|
2427
|
+
let c = Mn.get(o);
|
|
2285
2428
|
c && (c.fx.dispose(), c.ctx.dispose());
|
|
2286
|
-
let l = new
|
|
2429
|
+
let l = new wn(s, Le(o), n.onRemove), u = R(() => {
|
|
2287
2430
|
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,
|
|
2431
|
+
k(() => {
|
|
2432
|
+
if (On(l, a, s, n.empty, $), a === 0) return;
|
|
2433
|
+
W.log(V.LIST, `${l.containerSelector} updating with ${a} items`);
|
|
2434
|
+
let t = Tn(l, e, a, r, n.update, n.isEqual, Fn), c = kn(t, n, l.oldKeys.length === 0);
|
|
2435
|
+
if (An(l, t), jn(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]);
|
|
2436
|
+
$.release(l.oldKeys), $.release(l.oldItems), $.release(l.oldNodes), l.oldKeys = t.newKeys, l.oldItems = t.newItems, l.oldNodes = t.newNodes, Pn.release(t.newKeySet), $.release(t.trKeys), $.release(t.trItems), $.release(t.trIdxs);
|
|
2294
2437
|
});
|
|
2295
2438
|
});
|
|
2296
2439
|
if (l.fx = u, n.events) for (let e in n.events) {
|
|
2297
|
-
if (!
|
|
2440
|
+
if (!B.call(n.events, e)) continue;
|
|
2298
2441
|
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
2442
|
s.on(`${r}.atomList`, i, function(e) {
|
|
2300
2443
|
let t = e.target.closest?.("[data-atom-key]"), n = t?.getAttribute("data-atom-key");
|
|
@@ -2308,119 +2451,132 @@ e.fn.atomList = function(t, n) {
|
|
|
2308
2451
|
i !== void 0 && a.call(t, l.oldItems[i], i, e);
|
|
2309
2452
|
});
|
|
2310
2453
|
}
|
|
2311
|
-
|
|
2454
|
+
K.trackEffect(o, u), Mn.set(o, {
|
|
2312
2455
|
fx: u,
|
|
2313
2456
|
ctx: l
|
|
2314
|
-
}),
|
|
2315
|
-
l.dispose(),
|
|
2457
|
+
}), K.trackCleanup(o, () => {
|
|
2458
|
+
l.dispose(), Mn.delete(o);
|
|
2316
2459
|
});
|
|
2317
2460
|
}
|
|
2318
2461
|
return this;
|
|
2319
|
-
}
|
|
2462
|
+
}
|
|
2463
|
+
e.fn.atomList = In;
|
|
2320
2464
|
//#endregion
|
|
2321
2465
|
//#region src/bindings/mount.ts
|
|
2322
|
-
var
|
|
2466
|
+
var Ln = Object.freeze({});
|
|
2323
2467
|
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
|
-
}
|
|
2468
|
+
let r = n ?? Ln, i = t.name || "Component";
|
|
2469
|
+
return J(this, (n, a) => {
|
|
2470
|
+
K.cleanupTree(a);
|
|
2471
|
+
try {
|
|
2472
|
+
let n = k(() => xe(() => t(e(a), r)));
|
|
2473
|
+
typeof n == "function" && K.setComponentCleanup(a, n);
|
|
2474
|
+
} catch (e) {
|
|
2475
|
+
W.error(V.MOUNT, H.MOUNT.ERROR(i), e);
|
|
2335
2476
|
}
|
|
2336
|
-
}
|
|
2337
|
-
return this;
|
|
2477
|
+
});
|
|
2338
2478
|
}, e.fn.atomUnmount = function() {
|
|
2339
|
-
|
|
2340
|
-
let t = this[e];
|
|
2341
|
-
t && Xt(t);
|
|
2342
|
-
}
|
|
2343
|
-
return this;
|
|
2479
|
+
return J(this, (e, t) => gn(t));
|
|
2344
2480
|
};
|
|
2345
2481
|
//#endregion
|
|
2346
2482
|
//#region src/features/route.ts
|
|
2347
|
-
function
|
|
2483
|
+
function Rn(e, t) {
|
|
2348
2484
|
try {
|
|
2349
2485
|
history.pushState(e, "", t);
|
|
2350
2486
|
} catch (e) {
|
|
2351
|
-
|
|
2487
|
+
W.warn(V.ROUTE, "PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.", e);
|
|
2352
2488
|
}
|
|
2353
2489
|
}
|
|
2354
|
-
var
|
|
2490
|
+
var zn = class {
|
|
2491
|
+
parseQueryParams(e) {
|
|
2492
|
+
let t = {};
|
|
2493
|
+
return e && new URLSearchParams(e).forEach((e, n) => {
|
|
2494
|
+
t[n] = e;
|
|
2495
|
+
}), t;
|
|
2496
|
+
}
|
|
2355
2497
|
constructor(t) {
|
|
2356
2498
|
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:
|
|
2499
|
+
mode: ze.mode,
|
|
2500
|
+
basePath: ze.basePath,
|
|
2501
|
+
autoBindLinks: ze.autoBindLinks,
|
|
2502
|
+
activeClass: ze.activeClass,
|
|
2503
|
+
notFound: t.notFound || "",
|
|
2504
|
+
beforeTransition: t.beforeTransition || (() => {}),
|
|
2505
|
+
afterTransition: t.afterTransition || (() => {}),
|
|
2361
2506
|
...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 =
|
|
2507
|
+
}, 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 = Ce(this.getRouteName()), this.currentRoute = this.currentRouteAtom, this.queryParamsAtom = Ce(this.getQueryParams()), this.queryParams = Oe(() => this.queryParamsAtom.value), this.init();
|
|
2363
2508
|
}
|
|
2364
2509
|
init() {
|
|
2365
2510
|
let e = this.isHistoryMode ? "popstate" : "hashchange", t = this.handleUrlChange.bind(this);
|
|
2366
2511
|
window.addEventListener(e, t), this.cleanups.push(() => window.removeEventListener(e, t));
|
|
2367
|
-
let n =
|
|
2512
|
+
let n = R(() => {
|
|
2368
2513
|
let e = this.currentRouteAtom.value;
|
|
2369
|
-
|
|
2514
|
+
k(() => {
|
|
2370
2515
|
for (let e of this.routeCleanups) try {
|
|
2371
2516
|
e();
|
|
2372
2517
|
} catch {}
|
|
2373
2518
|
this.routeCleanups.length = 0;
|
|
2374
2519
|
}), this.renderRoute(e);
|
|
2375
2520
|
});
|
|
2376
|
-
this.cleanups.push(() => n.dispose()), this.setupAutoBindLinks(), this.$target[0] &&
|
|
2521
|
+
this.cleanups.push(() => n.dispose()), this.setupAutoBindLinks(), this.$target[0] && K.trackCleanup(this.$target[0], () => this.destroy());
|
|
2377
2522
|
}
|
|
2378
2523
|
getRouteName() {
|
|
2379
2524
|
let { default: e } = this.config;
|
|
2380
2525
|
if (this.isHistoryMode) {
|
|
2381
2526
|
let t = this.basePath, n = location.pathname;
|
|
2382
|
-
return t && n.startsWith(t) && (n = n.substring(t.length)), n.replace(
|
|
2527
|
+
return t && (n === t || n.startsWith(`${t}/`)) && (n = n.substring(t.length)), n.replace(/^\/+/, "") || e;
|
|
2383
2528
|
}
|
|
2384
|
-
|
|
2529
|
+
let t = location.hash, { route: n } = this.splitPath(t.startsWith("#") ? t.substring(1) : t);
|
|
2530
|
+
return n || e;
|
|
2385
2531
|
}
|
|
2386
2532
|
getQueryParams() {
|
|
2387
|
-
let e =
|
|
2388
|
-
if (
|
|
2389
|
-
this.lastRawQuery =
|
|
2390
|
-
let
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2533
|
+
let e = this.getCurrentRawQuery();
|
|
2534
|
+
if (e === this.lastRawQuery) return this.cachedParams;
|
|
2535
|
+
this.lastRawQuery = e;
|
|
2536
|
+
let t = this.parseQueryParams(e);
|
|
2537
|
+
return this.areParamsEqual(t, this.cachedParams) ? this.cachedParams : (e.indexOf("%"), this.cachedParams = t, t);
|
|
2538
|
+
}
|
|
2539
|
+
getCurrentRawQuery() {
|
|
2540
|
+
if (this.isHistoryMode) return location.search.substring(1);
|
|
2541
|
+
let e = location.hash, t = e.indexOf("?");
|
|
2542
|
+
return t === -1 ? "" : e.substring(t + 1);
|
|
2543
|
+
}
|
|
2544
|
+
areParamsEqual(e, t) {
|
|
2545
|
+
let n = Object.keys(e);
|
|
2546
|
+
if (n.length !== Object.keys(t).length) return !1;
|
|
2547
|
+
for (let r of n) if (e[r] !== t[r]) return !1;
|
|
2548
|
+
return !0;
|
|
2549
|
+
}
|
|
2550
|
+
splitPath(e) {
|
|
2551
|
+
let t = e.indexOf("?"), n = t === -1 ? e : e.slice(0, t), r = t === -1 ? void 0 : e.slice(t + 1);
|
|
2552
|
+
return {
|
|
2553
|
+
route: n.replace(/^\/+/, ""),
|
|
2554
|
+
query: r
|
|
2555
|
+
};
|
|
2404
2556
|
}
|
|
2405
2557
|
setUrl(e) {
|
|
2406
|
-
let t = this.isHistoryMode ? `${this.basePath}/${
|
|
2407
|
-
this.isHistoryMode ?
|
|
2558
|
+
let { route: t, query: n } = this.splitPath(e), r = n ? `${t}?${n}` : t, i = this.isHistoryMode ? `${this.basePath}/${r}` : `#${r}`;
|
|
2559
|
+
this.isHistoryMode ? Rn(null, i) : location.hash = i, this.previousUrl = this.isHistoryMode ? i : location.hash;
|
|
2408
2560
|
}
|
|
2409
2561
|
restoreUrl() {
|
|
2410
|
-
|
|
2562
|
+
try {
|
|
2563
|
+
this.isHistoryMode ? history.replaceState(null, "", this.previousUrl) : location.hash = this.previousUrl;
|
|
2564
|
+
} catch (e) {
|
|
2565
|
+
W.warn(V.ROUTE, "Restore URL failed", e);
|
|
2566
|
+
}
|
|
2411
2567
|
}
|
|
2412
2568
|
renderRoute(e) {
|
|
2413
2569
|
if (this.isDestroyed || !this.$target[0]) return;
|
|
2414
2570
|
let { routes: t, notFound: n, beforeTransition: r, afterTransition: i } = this.config, a = t[e] ?? (n ? t[n] : void 0);
|
|
2415
2571
|
if (!a) {
|
|
2416
|
-
|
|
2572
|
+
W.warn(V.ROUTE, H.ROUTE.NOT_FOUND(e));
|
|
2417
2573
|
return;
|
|
2418
2574
|
}
|
|
2419
2575
|
let o = this.getQueryParams(), s = this.previousRoute;
|
|
2420
|
-
r &&
|
|
2576
|
+
r && k(() => r(s, e)), this.$target.empty();
|
|
2421
2577
|
let c = o;
|
|
2422
2578
|
if (a.onEnter) {
|
|
2423
|
-
let e =
|
|
2579
|
+
let e = k(() => a.onEnter(o, this));
|
|
2424
2580
|
e && (c = {
|
|
2425
2581
|
...o,
|
|
2426
2582
|
...e
|
|
@@ -2434,13 +2590,13 @@ var gn = class {
|
|
|
2434
2590
|
let t = document.querySelector(a.template);
|
|
2435
2591
|
if (t instanceof HTMLTemplateElement) e = t, this.templateCache.set(a.template, e);
|
|
2436
2592
|
else {
|
|
2437
|
-
|
|
2593
|
+
W.warn(V.ROUTE, H.ROUTE.TEMPLATE_NOT_FOUND(a.template));
|
|
2438
2594
|
return;
|
|
2439
2595
|
}
|
|
2440
2596
|
}
|
|
2441
2597
|
this.$target.append(e.content.cloneNode(!0)), a.onMount && a.onMount(this.$target.children(), l, this);
|
|
2442
2598
|
}
|
|
2443
|
-
i &&
|
|
2599
|
+
i && k(() => i(s, e)), this.previousRoute = e;
|
|
2444
2600
|
}
|
|
2445
2601
|
handleUrlChange() {
|
|
2446
2602
|
if (this.isDestroyed) return;
|
|
@@ -2448,7 +2604,7 @@ var gn = class {
|
|
|
2448
2604
|
if (e === this.previousUrl) return;
|
|
2449
2605
|
let t = this.getRouteName(), n = this.currentRouteAtom.peek();
|
|
2450
2606
|
if (n !== t) {
|
|
2451
|
-
if (
|
|
2607
|
+
if (k(() => this.config.routes[n]?.onLeave?.(this)) === !1) {
|
|
2452
2608
|
this.restoreUrl();
|
|
2453
2609
|
return;
|
|
2454
2610
|
}
|
|
@@ -2464,34 +2620,33 @@ var gn = class {
|
|
|
2464
2620
|
t != null && this.navigate(t);
|
|
2465
2621
|
};
|
|
2466
2622
|
e(document).on("click", "[data-route]", t), this.cleanups.push(() => e(document).off("click", "[data-route]", t));
|
|
2467
|
-
let n = [], r =
|
|
2623
|
+
let n = [], r = R(() => {
|
|
2468
2624
|
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
|
-
}
|
|
2625
|
+
k(() => {
|
|
2626
|
+
for (let e of n) e.classList.remove(t), e.removeAttribute("aria-current");
|
|
2475
2627
|
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
|
-
}
|
|
2628
|
+
let r = `[data-route="${e.replace(/"/g, "\\\"")}"]`, i = Array.from(document.querySelectorAll(r));
|
|
2629
|
+
for (let e of i) e.classList.add(t), e.setAttribute("aria-current", "page");
|
|
2481
2630
|
n = i;
|
|
2482
2631
|
} catch {
|
|
2483
2632
|
n = [];
|
|
2484
2633
|
}
|
|
2485
2634
|
});
|
|
2486
2635
|
});
|
|
2487
|
-
this.cleanups.push(() =>
|
|
2636
|
+
this.cleanups.push(() => {
|
|
2637
|
+
r.dispose(), n.length = 0;
|
|
2638
|
+
});
|
|
2488
2639
|
}
|
|
2489
|
-
navigate(
|
|
2640
|
+
navigate(t) {
|
|
2490
2641
|
if (this.isDestroyed) return;
|
|
2491
|
-
let
|
|
2492
|
-
if (this.config.routes[
|
|
2493
|
-
let
|
|
2494
|
-
|
|
2642
|
+
let n = this.currentRouteAtom.peek();
|
|
2643
|
+
if (this.config.routes[n]?.onLeave?.(this) === !1) return;
|
|
2644
|
+
let { route: r, query: i } = this.splitPath(t), a = r || this.config.default || "";
|
|
2645
|
+
a && e.batch(() => {
|
|
2646
|
+
this.setUrl(t);
|
|
2647
|
+
let e = i ? this.parseQueryParams(i) : {};
|
|
2648
|
+
this.areParamsEqual(e, this.queryParamsAtom.peek()) || (this.queryParamsAtom.value = e), this.currentRouteAtom.value = a;
|
|
2649
|
+
});
|
|
2495
2650
|
}
|
|
2496
2651
|
destroy() {
|
|
2497
2652
|
if (!this.isDestroyed) {
|
|
@@ -2499,44 +2654,33 @@ var gn = class {
|
|
|
2499
2654
|
for (let e of this.cleanups) try {
|
|
2500
2655
|
e();
|
|
2501
2656
|
} catch {}
|
|
2502
|
-
this.templateCache.clear();
|
|
2657
|
+
this.cleanups.length = 0, this.templateCache.clear();
|
|
2503
2658
|
}
|
|
2504
2659
|
}
|
|
2505
2660
|
};
|
|
2506
|
-
function
|
|
2507
|
-
return new
|
|
2661
|
+
function Bn(e) {
|
|
2662
|
+
return new zn(e);
|
|
2508
2663
|
}
|
|
2509
|
-
e.extend({ route:
|
|
2664
|
+
e.extend({ route: Bn });
|
|
2510
2665
|
//#endregion
|
|
2511
2666
|
//#region src/features/fetch.ts
|
|
2512
|
-
var
|
|
2667
|
+
var Vn = class {
|
|
2513
2668
|
constructor(t, n) {
|
|
2514
2669
|
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();
|
|
2670
|
+
this.abort();
|
|
2671
|
+
let t = new AbortController();
|
|
2672
|
+
this.abortController = t;
|
|
2673
|
+
let { signal: n } = t, r;
|
|
2529
2674
|
try {
|
|
2530
|
-
let
|
|
2531
|
-
|
|
2675
|
+
let t = this.prepareSettings(), i = e.ajax(t);
|
|
2676
|
+
r = () => i.abort(), n.addEventListener("abort", r), n.aborted && i.abort();
|
|
2677
|
+
let a = await i;
|
|
2678
|
+
return this.transformFn ? this.transformFn(a) : a;
|
|
2532
2679
|
} catch (e) {
|
|
2533
|
-
if (
|
|
2534
|
-
let e = /* @__PURE__ */ Error("AbortError");
|
|
2535
|
-
throw e.name = "AbortError", e;
|
|
2536
|
-
}
|
|
2680
|
+
if (n.aborted) throw this.createAbortError();
|
|
2537
2681
|
return this.handleError(e);
|
|
2538
2682
|
} finally {
|
|
2539
|
-
|
|
2683
|
+
r && n.removeEventListener("abort", r), this.abortController === t && (this.abortController = null);
|
|
2540
2684
|
}
|
|
2541
2685
|
};
|
|
2542
2686
|
let r = typeof t == "string";
|
|
@@ -2544,12 +2688,11 @@ var vn = class {
|
|
|
2544
2688
|
let i = typeof n.ajaxOptions == "object" ? n.ajaxOptions : {};
|
|
2545
2689
|
this.staticOptions = {
|
|
2546
2690
|
...i,
|
|
2547
|
-
method: n.method,
|
|
2548
2691
|
headers: {
|
|
2549
2692
|
...i?.headers,
|
|
2550
2693
|
...n.headers
|
|
2551
2694
|
}
|
|
2552
|
-
}, this.transformFn = n.transform, this.onErrorFn = n.onError;
|
|
2695
|
+
}, n.method && (this.staticOptions.method = n.method), this.transformFn = n.transform, this.onErrorFn = n.onError;
|
|
2553
2696
|
}
|
|
2554
2697
|
abort() {
|
|
2555
2698
|
this.abortController?.abort();
|
|
@@ -2565,20 +2708,41 @@ var vn = class {
|
|
|
2565
2708
|
} catch {}
|
|
2566
2709
|
throw t;
|
|
2567
2710
|
}
|
|
2711
|
+
prepareSettings() {
|
|
2712
|
+
let e = this.ajaxOptionsFn?.() ?? {};
|
|
2713
|
+
return {
|
|
2714
|
+
...this.staticOptions,
|
|
2715
|
+
...e,
|
|
2716
|
+
headers: {
|
|
2717
|
+
...this.staticOptions.headers,
|
|
2718
|
+
...e.headers
|
|
2719
|
+
},
|
|
2720
|
+
url: this.isStaticUrl ? this.staticUrl : this.getUrl(),
|
|
2721
|
+
success: void 0,
|
|
2722
|
+
error: void 0,
|
|
2723
|
+
complete: void 0
|
|
2724
|
+
};
|
|
2725
|
+
}
|
|
2726
|
+
createAbortError() {
|
|
2727
|
+
let e = /* @__PURE__ */ Error("AbortError");
|
|
2728
|
+
return e.name = "AbortError", e;
|
|
2729
|
+
}
|
|
2568
2730
|
};
|
|
2569
2731
|
//#endregion
|
|
2570
2732
|
//#region src/index.ts
|
|
2571
2733
|
e.extend({ atomFetch(e, t) {
|
|
2572
|
-
let n = new
|
|
2734
|
+
let n = new Vn(e, t), r = Oe(n.execute, {
|
|
2573
2735
|
defaultValue: t.defaultValue,
|
|
2574
2736
|
lazy: t.eager === !1
|
|
2575
|
-
});
|
|
2576
|
-
return
|
|
2737
|
+
}), i = r.dispose.bind(r);
|
|
2738
|
+
return r.dispose = () => {
|
|
2739
|
+
n.abort(), i();
|
|
2740
|
+
}, Object.assign(r, { abort: () => n.abort() });
|
|
2577
2741
|
} }), e(() => {
|
|
2578
|
-
|
|
2742
|
+
Ct(), document.body && dt(document.body);
|
|
2579
2743
|
});
|
|
2580
|
-
var
|
|
2744
|
+
var Hn = e;
|
|
2581
2745
|
//#endregion
|
|
2582
|
-
export {
|
|
2746
|
+
export { Hn as default, ft as disableAutoCleanup, wt as disablejQueryOverrides, dt as enableAutoCleanup, Ct as enablejQueryOverrides, Fe as isReactive, nt as nextTick, K as registry };
|
|
2583
2747
|
|
|
2584
2748
|
//# sourceMappingURL=index.mjs.map
|