solely 0.0.29 → 0.0.30
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/solely.js +186 -173
- package/dist/solely.umd.cjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/solely.js
CHANGED
|
@@ -2,13 +2,13 @@ var ft = (t) => {
|
|
|
2
2
|
throw TypeError(t);
|
|
3
3
|
};
|
|
4
4
|
var st = (t, e, n) => e.has(t) || ft("Cannot " + n);
|
|
5
|
-
var x = (t, e, n) => (st(t, e, "read from private field"), n ? n.call(t) : e.get(t)),
|
|
6
|
-
const
|
|
5
|
+
var x = (t, e, n) => (st(t, e, "read from private field"), n ? n.call(t) : e.get(t)), P = (t, e, n) => e.has(t) ? ft("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), A = (t, e, n, s) => (st(t, e, "write to private field"), s ? s.call(t, n) : e.set(t, n), n), I = (t, e, n) => (st(t, e, "access private method"), n);
|
|
6
|
+
const St = /<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g, _t = /<\/?([^\s]+?)[/\s>]/, Wt = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g, It = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"], rt = /\{\{(.+?)\}\}/g;
|
|
7
7
|
function Ot(t) {
|
|
8
8
|
return t.replace(/>\s+</g, "><").replace(/\s+/g, " ");
|
|
9
9
|
}
|
|
10
10
|
function jt(t, e) {
|
|
11
|
-
const n = (e.match(
|
|
11
|
+
const n = (e.match(_t) || [])[1] || "", s = {
|
|
12
12
|
rootId: "0",
|
|
13
13
|
tagName: n,
|
|
14
14
|
attrs: {},
|
|
@@ -32,39 +32,48 @@ function jt(t, e) {
|
|
|
32
32
|
s.model = i;
|
|
33
33
|
break;
|
|
34
34
|
case "style":
|
|
35
|
-
s.styles = (
|
|
35
|
+
s.styles = (p) => w(t, i, p);
|
|
36
36
|
break;
|
|
37
37
|
case "class":
|
|
38
|
-
s.classes = (
|
|
38
|
+
s.classes = (p) => w(t, i, p);
|
|
39
39
|
break;
|
|
40
40
|
case "readonly":
|
|
41
|
-
s.props.readOnly = (
|
|
41
|
+
s.props.readOnly = (p) => w(t, i, p);
|
|
42
|
+
break;
|
|
43
|
+
case "for":
|
|
44
|
+
s.props.htmlFor = (p) => w(t, i, p);
|
|
45
|
+
break;
|
|
46
|
+
case "tabindex":
|
|
47
|
+
s.props.tabIndex = (p) => w(t, i, p);
|
|
48
|
+
break;
|
|
49
|
+
case "contenteditable":
|
|
50
|
+
s.props.contentEditable = (p) => w(t, i, p);
|
|
42
51
|
break;
|
|
43
52
|
default:
|
|
44
|
-
s.props[f] = (
|
|
53
|
+
s.props[f] = (p) => w(t, i, p);
|
|
45
54
|
break;
|
|
46
55
|
}
|
|
47
56
|
} else
|
|
48
57
|
s.attrs[a] = i;
|
|
49
58
|
r.lastIndex--;
|
|
50
59
|
}
|
|
51
|
-
if (n === "For" ? s.fn = (o) =>
|
|
52
|
-
const o = s.model.replace("this.", "").replace("$data.", ""), a = (f) =>
|
|
60
|
+
if (n === "For" ? s.fn = (o) => w(t, s.attrs.each, o) : (n === "If" || n === "ElseIf") && (s.fn = (o) => w(t, s.attrs.condition, o)), s.model) {
|
|
61
|
+
const o = s.model.replace("this.", "").replace("$data.", ""), a = (f) => w(t, `$data.${o}`, f), i = (f, p) => {
|
|
53
62
|
if (s.on[f]) {
|
|
54
63
|
const l = s.on[f];
|
|
55
64
|
s.on[f] = (c, u) => {
|
|
56
|
-
|
|
65
|
+
p(c, u), l(c, u);
|
|
57
66
|
};
|
|
58
67
|
} else
|
|
59
|
-
s.on[f] =
|
|
68
|
+
s.on[f] = p;
|
|
60
69
|
};
|
|
61
70
|
if (n === "input") {
|
|
62
71
|
const f = s.attrs.type || "text";
|
|
63
72
|
if (f === "checkbox")
|
|
64
73
|
s.props.checked = a, i("change", H(t, `$data.${o}=checked`));
|
|
65
74
|
else if (f === "radio") {
|
|
66
|
-
const
|
|
67
|
-
s.props.checked = (l) => a(l) ==
|
|
75
|
+
const p = s.attrs.value;
|
|
76
|
+
s.props.checked = (l) => a(l) == p, i("change", H(t, `if(checked){$data.${o}='${p}'}`));
|
|
68
77
|
} else
|
|
69
78
|
s.props.value = a, i("input", H(t, `$data.${o}=value`));
|
|
70
79
|
} else if (n === "textarea")
|
|
@@ -77,21 +86,21 @@ function jt(t, e) {
|
|
|
77
86
|
$data.${o} = Array.from(event.target.selectedOptions).map(o => o.value);
|
|
78
87
|
`)
|
|
79
88
|
) : (i("change", H(t, `$data.${o}=value`)), s.props.value = a);
|
|
80
|
-
const
|
|
81
|
-
const
|
|
89
|
+
const p = (u, d = []) => {
|
|
90
|
+
const v = a(d);
|
|
82
91
|
if (f) {
|
|
83
|
-
const
|
|
84
|
-
for (const
|
|
85
|
-
|
|
92
|
+
const k = Array.isArray(v) ? v : v != null ? [v] : [];
|
|
93
|
+
for (const M of u.options)
|
|
94
|
+
M.selected = k.includes(M.value);
|
|
86
95
|
} else {
|
|
87
|
-
const
|
|
88
|
-
u.value !==
|
|
96
|
+
const k = v ?? "";
|
|
97
|
+
u.value !== k && (u.value = k);
|
|
89
98
|
}
|
|
90
99
|
}, l = s.onMounted, c = s.onUpdated;
|
|
91
|
-
s.onMounted = (u,
|
|
92
|
-
l == null || l(u,
|
|
93
|
-
}, s.onUpdated = (u,
|
|
94
|
-
c == null || c(u,
|
|
100
|
+
s.onMounted = (u, d) => {
|
|
101
|
+
l == null || l(u, d), p(u, d || []);
|
|
102
|
+
}, s.onUpdated = (u, d) => {
|
|
103
|
+
c == null || c(u, d), p(u, d || []);
|
|
95
104
|
};
|
|
96
105
|
}
|
|
97
106
|
}
|
|
@@ -106,14 +115,14 @@ function Tt(t, e) {
|
|
|
106
115
|
return s.length === 0 ? n : (i = s[s.length - 1]).children || (i.children = []);
|
|
107
116
|
};
|
|
108
117
|
let a = 0;
|
|
109
|
-
return e.replace(
|
|
110
|
-
const
|
|
118
|
+
return e.replace(St, (i, f) => {
|
|
119
|
+
const p = o();
|
|
111
120
|
if (f > a) {
|
|
112
121
|
const l = e.substring(a, f).trim();
|
|
113
122
|
if (l) {
|
|
114
123
|
rt.lastIndex = 0;
|
|
115
|
-
const u = !rt.test(l) ? l : (
|
|
116
|
-
|
|
124
|
+
const u = !rt.test(l) ? l : (d) => l.replace(rt, (v, k) => w(t, k, d));
|
|
125
|
+
p.push({
|
|
117
126
|
rootId: "0",
|
|
118
127
|
tagName: "text",
|
|
119
128
|
attrs: {},
|
|
@@ -125,7 +134,7 @@ function Tt(t, e) {
|
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
136
|
if (a = f + i.length, i.startsWith("<!--") && i.endsWith("-->"))
|
|
128
|
-
|
|
137
|
+
p.push({
|
|
129
138
|
rootId: "0",
|
|
130
139
|
tagName: "comment",
|
|
131
140
|
attrs: {},
|
|
@@ -141,7 +150,7 @@ function Tt(t, e) {
|
|
|
141
150
|
s.pop();
|
|
142
151
|
} else {
|
|
143
152
|
const l = jt(t, i), c = i.endsWith("/>") || It.includes(l.tagName);
|
|
144
|
-
|
|
153
|
+
p.push(l), c || (s.push(l), r.push(l.tagName));
|
|
145
154
|
}
|
|
146
155
|
return "";
|
|
147
156
|
}), e.length > a && n.push({
|
|
@@ -154,7 +163,7 @@ function Tt(t, e) {
|
|
|
154
163
|
children: []
|
|
155
164
|
}), n;
|
|
156
165
|
}
|
|
157
|
-
const
|
|
166
|
+
const w = (t, e, n) => {
|
|
158
167
|
try {
|
|
159
168
|
return lt([
|
|
160
169
|
"$data",
|
|
@@ -309,22 +318,26 @@ function Ut(t) {
|
|
|
309
318
|
const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/", Bt = "http://www.w3.org/XML/1998/namespace", zt = "http://www.w3.org/2000/svg", yt = (t) => typeof t.content == "function" ? t.content(t.loops || []) : t.content || "", Gt = (t) => {
|
|
310
319
|
const e = yt(t), n = t.elm;
|
|
311
320
|
n.textContent !== e && (n.textContent = e);
|
|
312
|
-
}, Et = (t, e, n = []) => {
|
|
321
|
+
}, Kt = ["role", "form"], Et = (t, e, n = []) => {
|
|
313
322
|
Object.keys(e).forEach((s) => {
|
|
314
323
|
const r = e[s](n);
|
|
315
|
-
|
|
324
|
+
if (s.startsWith("data-") || s.startsWith("aria-") || Kt.includes(s)) {
|
|
325
|
+
const o = t.getAttribute(s), a = r == null ? null : String(r);
|
|
326
|
+
o !== a && (a == null ? t.removeAttribute(s) : t.setAttribute(s, a));
|
|
327
|
+
} else
|
|
328
|
+
t[s] !== r && (t[s] = r);
|
|
316
329
|
});
|
|
317
|
-
},
|
|
330
|
+
}, bt = (t, e) => {
|
|
318
331
|
const { styles: n, loops: s = [] } = e;
|
|
319
332
|
if (!n) return;
|
|
320
333
|
const r = n(s), o = at(r);
|
|
321
334
|
Object.entries(o).forEach(([a, i]) => {
|
|
322
335
|
t.style[a] = i;
|
|
323
336
|
});
|
|
324
|
-
},
|
|
337
|
+
}, vt = (t, e) => {
|
|
325
338
|
const { classes: n, loops: s = [] } = e;
|
|
326
339
|
if (!n) return;
|
|
327
|
-
const r = n(s), o =
|
|
340
|
+
const r = n(s), o = $t(r);
|
|
328
341
|
Object.entries(o).forEach(([a, i]) => {
|
|
329
342
|
i ? t.classList.add(a) : t.classList.remove(a);
|
|
330
343
|
});
|
|
@@ -346,29 +359,29 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
346
359
|
e[r] = o;
|
|
347
360
|
});
|
|
348
361
|
}), e;
|
|
349
|
-
},
|
|
362
|
+
}, $t = (t) => {
|
|
350
363
|
let e = {};
|
|
351
364
|
return typeof t == "object" && !Array.isArray(t) ? Object.entries(t).forEach(([n, s]) => {
|
|
352
365
|
e[n] = !!s;
|
|
353
366
|
}) : typeof t == "string" ? t.split(" ").forEach((n) => {
|
|
354
367
|
n !== "" && (e[n] = !0);
|
|
355
368
|
}) : Array.isArray(t) && t.forEach((n) => {
|
|
356
|
-
const s =
|
|
369
|
+
const s = $t(n);
|
|
357
370
|
Object.entries(s).forEach(([r, o]) => {
|
|
358
371
|
e[r] = o;
|
|
359
372
|
});
|
|
360
373
|
}), e;
|
|
361
|
-
},
|
|
374
|
+
}, At = (t, e, n) => {
|
|
362
375
|
const s = (r) => n.on[e](r, n.loops || []);
|
|
363
376
|
t.addEventListener(e, s, !1), n.handlers = n.handlers || {}, n.handlers[e] = s;
|
|
364
|
-
},
|
|
377
|
+
}, Qt = (t, e) => {
|
|
365
378
|
const n = e.elm;
|
|
366
379
|
Object.keys(e.on).forEach((s) => {
|
|
367
|
-
t.handlers && t.handlers[s] && n.removeEventListener(s, t.handlers[s], !1),
|
|
368
|
-
}), Et(n, e.props, e.loops),
|
|
380
|
+
t.handlers && t.handlers[s] && n.removeEventListener(s, t.handlers[s], !1), At(n, s, e);
|
|
381
|
+
}), Et(n, e.props, e.loops), vt(n, e), bt(n, e), typeof e.onUpdated == "function" && requestAnimationFrame(() => {
|
|
369
382
|
e.onUpdated(n, e.loops || []);
|
|
370
|
-
}),
|
|
371
|
-
},
|
|
383
|
+
}), kt(n, t.children, e.children);
|
|
384
|
+
}, Jt = (t, e) => {
|
|
372
385
|
switch (e.elm = t.elm, e.tagName) {
|
|
373
386
|
case "comment":
|
|
374
387
|
break;
|
|
@@ -376,26 +389,26 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
376
389
|
Gt(e);
|
|
377
390
|
break;
|
|
378
391
|
default:
|
|
379
|
-
|
|
392
|
+
Qt(t, e);
|
|
380
393
|
break;
|
|
381
394
|
}
|
|
382
395
|
}, ut = (t, e, n) => {
|
|
383
396
|
n && n.parentNode === t ? t.insertBefore(e, n) : t.appendChild(e);
|
|
384
|
-
},
|
|
397
|
+
}, Nt = (t, e, n) => {
|
|
385
398
|
const s = yt(e), r = document.createTextNode(s);
|
|
386
399
|
e.elm = r, ut(t, r, n);
|
|
387
|
-
},
|
|
400
|
+
}, Xt = (t, e, n) => {
|
|
388
401
|
const s = e.content, r = document.createComment(s);
|
|
389
402
|
e.elm = r, ut(t, r, n);
|
|
390
|
-
},
|
|
403
|
+
}, Zt = (t, e, n, s) => {
|
|
391
404
|
e.tagName === "svg" && (s = zt);
|
|
392
405
|
const r = s ? document.createElementNS(s, e.tagName) : document.createElement(e.tagName);
|
|
393
406
|
Object.keys(e.attrs).forEach((o) => {
|
|
394
407
|
const a = e.attrs[o] || "";
|
|
395
408
|
o.charAt(0) !== "x" ? r.setAttribute(o, a) : o.startsWith("xml:") ? r.setAttributeNS(Bt, o, a) : o.startsWith("xlink:") ? r.setAttributeNS(qt, o, a) : o.startsWith("xmlns:") ? r.setAttributeNS(Vt, o, a) : r.setAttribute(o, a);
|
|
396
409
|
}), Object.keys(e.on).forEach((o) => {
|
|
397
|
-
|
|
398
|
-
}), Et(r, e.props, e.loops),
|
|
410
|
+
At(r, o, e);
|
|
411
|
+
}), Et(r, e.props, e.loops), vt(r, e), bt(r, e), e.elm = r, ut(t, r, n), e.tagName === "foreignObject" && (s = void 0), e.children.forEach((o) => {
|
|
399
412
|
N(r, o, void 0, s);
|
|
400
413
|
}), typeof e.onMounted == "function" && requestAnimationFrame(() => {
|
|
401
414
|
e.onMounted(r, e.loops || []);
|
|
@@ -403,33 +416,33 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
403
416
|
}, N = (t, e, n, s) => {
|
|
404
417
|
switch (e.tagName) {
|
|
405
418
|
case "comment":
|
|
406
|
-
|
|
419
|
+
Xt(t, e, n);
|
|
407
420
|
break;
|
|
408
421
|
case "text":
|
|
409
|
-
|
|
422
|
+
Nt(t, e, n);
|
|
410
423
|
break;
|
|
411
424
|
default:
|
|
412
|
-
|
|
425
|
+
Zt(t, e, n, s);
|
|
413
426
|
break;
|
|
414
427
|
}
|
|
415
|
-
},
|
|
416
|
-
var i, f,
|
|
428
|
+
}, Yt = (t) => t && (t.tagName === "ElseIf" || t.tagName === "comment"), te = (t) => t && t.tagName === "Else", F = (t, e, n = [], s = "0", r) => {
|
|
429
|
+
var i, f, p;
|
|
417
430
|
let o = 0, a = 0;
|
|
418
431
|
for (let l = 0; l < e.length; l++) {
|
|
419
432
|
const c = e[l];
|
|
420
433
|
if (c.tagName === "If") {
|
|
421
434
|
let u = !1;
|
|
422
435
|
o++;
|
|
423
|
-
let
|
|
424
|
-
for (((i = c.fn) == null ? void 0 : i.call(c, n)) && (F(t, c.children, n, `${s}-if-${o}-${
|
|
425
|
-
((
|
|
426
|
-
l + 1 < e.length &&
|
|
436
|
+
let d = 1;
|
|
437
|
+
for (((i = c.fn) == null ? void 0 : i.call(c, n)) && (F(t, c.children, n, `${s}-if-${o}-${d}`, d), u = !0), d++; l + 1 < e.length && Yt(e[l + 1]); )
|
|
438
|
+
((p = (f = e[l + 1]).fn) == null ? void 0 : p.call(f, n)) && !u && (F(t, e[l + 1].children, n, `${s}-if-${o}-${d}`, d), u = !0), l++, d++;
|
|
439
|
+
l + 1 < e.length && te(e[l + 1]) && (u || (F(t, e[l + 1].children, n, `${s}-if-${o}-${d}`, d), u = !0), l++);
|
|
427
440
|
} else if (c.tagName === "For") {
|
|
428
441
|
a++;
|
|
429
|
-
const { item: u = "item", index:
|
|
430
|
-
(c.fn(n) || []).forEach((
|
|
431
|
-
const Q = { item: u, value:
|
|
432
|
-
F(t, c.children, [...n, Q], `${s}-for-${a}-${
|
|
442
|
+
const { item: u = "item", index: d = "index" } = c.attrs;
|
|
443
|
+
(c.fn(n) || []).forEach((k, M) => {
|
|
444
|
+
const Q = { item: u, value: k, index: d, valueIndex: M };
|
|
445
|
+
F(t, c.children, [...n, Q], `${s}-for-${a}-${M}`, 1);
|
|
433
446
|
});
|
|
434
447
|
} else {
|
|
435
448
|
const u = {
|
|
@@ -444,31 +457,31 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
444
457
|
F(u.children, c.children, n, `${s}-${l}`), t.push(u);
|
|
445
458
|
}
|
|
446
459
|
}
|
|
447
|
-
},
|
|
448
|
-
var a, i, f,
|
|
460
|
+
}, kt = (t, e, n) => {
|
|
461
|
+
var a, i, f, p, l;
|
|
449
462
|
const s = /* @__PURE__ */ new Map();
|
|
450
463
|
e.forEach((c, u) => s.set(c.key, { node: c, index: u }));
|
|
451
464
|
let r = 0, o = 0;
|
|
452
465
|
for (; r < n.length; ) {
|
|
453
466
|
const c = n[r], u = s.get(c.key);
|
|
454
467
|
if (u) {
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
457
|
-
(a =
|
|
458
|
-
const
|
|
459
|
-
N(t, c,
|
|
468
|
+
const d = u.node;
|
|
469
|
+
if (d.tagName !== c.tagName) {
|
|
470
|
+
(a = d.elm) == null || a.remove();
|
|
471
|
+
const v = (i = e[o + 1]) == null ? void 0 : i.elm;
|
|
472
|
+
N(t, c, v), s.delete(c.key), o++;
|
|
460
473
|
} else {
|
|
461
|
-
if (c.ifId &&
|
|
462
|
-
(f =
|
|
463
|
-
const
|
|
464
|
-
N(t, c,
|
|
474
|
+
if (c.ifId && d.ifId !== c.ifId) {
|
|
475
|
+
(f = d.elm) == null || f.remove();
|
|
476
|
+
const v = (p = e[o + 1]) == null ? void 0 : p.elm;
|
|
477
|
+
N(t, c, v);
|
|
465
478
|
} else
|
|
466
|
-
|
|
479
|
+
Jt(d, c);
|
|
467
480
|
s.delete(c.key), o++;
|
|
468
481
|
}
|
|
469
482
|
} else {
|
|
470
|
-
const
|
|
471
|
-
N(t, c,
|
|
483
|
+
const d = (l = e[o]) == null ? void 0 : l.elm;
|
|
484
|
+
N(t, c, d);
|
|
472
485
|
}
|
|
473
486
|
r++;
|
|
474
487
|
}
|
|
@@ -479,7 +492,7 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
479
492
|
}, Ct = (t, e, n = []) => {
|
|
480
493
|
if (!e || e.length === 0) return [];
|
|
481
494
|
const s = [];
|
|
482
|
-
return F(s, e || [], [], "0"),
|
|
495
|
+
return F(s, e || [], [], "0"), kt(t, n, s), s;
|
|
483
496
|
}, j = (t) => {
|
|
484
497
|
if (t === null || typeof t != "object") return !1;
|
|
485
498
|
const e = Object.prototype.toString.call(t);
|
|
@@ -493,7 +506,7 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
493
506
|
"[object WeakSet]"
|
|
494
507
|
].includes(e);
|
|
495
508
|
};
|
|
496
|
-
function
|
|
509
|
+
function ee(t = window.location) {
|
|
497
510
|
let e;
|
|
498
511
|
typeof t == "string" ? e = new URL(t).hash : e = t.hash;
|
|
499
512
|
const n = e.split("?"), s = n[0].substring(2), r = n[1], o = {};
|
|
@@ -508,110 +521,110 @@ function te(t = window.location) {
|
|
|
508
521
|
};
|
|
509
522
|
}
|
|
510
523
|
function pt(t, e, n = {}) {
|
|
511
|
-
const s = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakSet(), o = /* @__PURE__ */ new WeakMap(), { throttle: a = 0, deepCompare: i = !1, onBatch: f = null, immediate:
|
|
512
|
-
let c = [], u = null,
|
|
513
|
-
const
|
|
524
|
+
const s = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakSet(), o = /* @__PURE__ */ new WeakMap(), { throttle: a = 0, deepCompare: i = !1, onBatch: f = null, immediate: p = !1 } = n, l = Array.isArray(n.filter) ? n.filter : n.filter ? [n.filter] : [];
|
|
525
|
+
let c = [], u = null, d = !0;
|
|
526
|
+
const v = (h, m, b = /* @__PURE__ */ new WeakMap()) => {
|
|
514
527
|
if (h === m) return !0;
|
|
515
528
|
if (h == null || m == null || typeof h != "object" || typeof m != "object") return h === m;
|
|
516
|
-
if (
|
|
517
|
-
if (
|
|
529
|
+
if (b.has(h)) return b.get(h) === m;
|
|
530
|
+
if (b.set(h, m), Array.isArray(h) && Array.isArray(m)) {
|
|
518
531
|
if (h.length !== m.length) return !1;
|
|
519
532
|
for (let g = 0; g < h.length; g++)
|
|
520
|
-
if (
|
|
533
|
+
if (!v(h[g], m[g], b)) return !1;
|
|
521
534
|
return !0;
|
|
522
535
|
}
|
|
523
536
|
if (Array.isArray(h) !== Array.isArray(m)) return !1;
|
|
524
|
-
const
|
|
525
|
-
if (
|
|
526
|
-
for (const g of
|
|
527
|
-
if (!Object.prototype.hasOwnProperty.call(m, g) ||
|
|
537
|
+
const $ = Object.keys(h), y = Object.keys(m);
|
|
538
|
+
if ($.length !== y.length) return !1;
|
|
539
|
+
for (const g of $)
|
|
540
|
+
if (!Object.prototype.hasOwnProperty.call(m, g) || !v(h[g], m[g], b)) return !1;
|
|
528
541
|
return !0;
|
|
529
|
-
},
|
|
542
|
+
}, k = (h) => {
|
|
530
543
|
if (l.length === 0) return !0;
|
|
531
544
|
const m = h.map(String).join(".");
|
|
532
|
-
return l.some((
|
|
533
|
-
if (!
|
|
545
|
+
return l.some((b) => {
|
|
546
|
+
if (!b) return !0;
|
|
534
547
|
try {
|
|
535
548
|
return new RegExp(
|
|
536
|
-
"^" +
|
|
549
|
+
"^" + b.replace(/\./g, "\\.").replace(/\[\*\]/g, "(\\.\\d+)?").replace(/\*\*/g, "(.+)").replace(/\*/g, "[^.]+") + "$"
|
|
537
550
|
).test(m);
|
|
538
551
|
} catch {
|
|
539
552
|
return !0;
|
|
540
553
|
}
|
|
541
554
|
});
|
|
542
|
-
},
|
|
543
|
-
|
|
544
|
-
if (!
|
|
555
|
+
}, M = (h, m, b) => {
|
|
556
|
+
d && k(h) && (a > 0 ? (c.push({ path: h, newValue: m, oldValue: b }), u || (u = setTimeout(() => {
|
|
557
|
+
if (!d) {
|
|
545
558
|
u = null;
|
|
546
559
|
return;
|
|
547
560
|
}
|
|
548
|
-
const
|
|
549
|
-
c = [], u = null, f && f(
|
|
550
|
-
for (const y of
|
|
561
|
+
const $ = c;
|
|
562
|
+
c = [], u = null, f && f($);
|
|
563
|
+
for (const y of $)
|
|
551
564
|
e(y.path, y.newValue, y.oldValue);
|
|
552
|
-
}, a))) : (e(h, m,
|
|
565
|
+
}, a))) : (e(h, m, b), f && f([{ path: h, newValue: m, oldValue: b }])));
|
|
553
566
|
}, Q = (h, m) => {
|
|
554
567
|
if (!j(h) || !(Array.isArray(h) || Object.prototype.toString.call(h) === "[object Object]")) return h;
|
|
555
|
-
const
|
|
568
|
+
const b = {};
|
|
556
569
|
if (["push", "pop", "shift", "unshift", "splice", "sort", "reverse"].forEach((y) => {
|
|
557
570
|
const g = Array.prototype[y];
|
|
558
|
-
|
|
559
|
-
if (!
|
|
560
|
-
const C = [...h],
|
|
561
|
-
return
|
|
571
|
+
b[y] = function(...E) {
|
|
572
|
+
if (!d) return Reflect.apply(g, h, E);
|
|
573
|
+
const C = [...h], W = g.apply(h, E);
|
|
574
|
+
return v(h, C) || M(m, h, C), W;
|
|
562
575
|
};
|
|
563
576
|
}), s.has(h)) {
|
|
564
577
|
const y = s.get(h);
|
|
565
578
|
return o.set(y, m), y;
|
|
566
579
|
}
|
|
567
580
|
r.add(h);
|
|
568
|
-
const
|
|
581
|
+
const $ = new Proxy(h, {
|
|
569
582
|
get(y, g, E) {
|
|
570
|
-
if (Array.isArray(y) &&
|
|
571
|
-
return Reflect.get(
|
|
583
|
+
if (Array.isArray(y) && b.hasOwnProperty(g))
|
|
584
|
+
return Reflect.get(b, g, E);
|
|
572
585
|
const C = Reflect.get(y, g, E);
|
|
573
586
|
if (j(C)) {
|
|
574
|
-
const J = [...o.get(
|
|
587
|
+
const J = [...o.get($) || [], g], nt = Q(C, J);
|
|
575
588
|
return o.set(nt, J), nt;
|
|
576
589
|
}
|
|
577
590
|
return C;
|
|
578
591
|
},
|
|
579
592
|
set(y, g, E, C) {
|
|
580
|
-
const
|
|
581
|
-
if (i && J ?
|
|
582
|
-
const Mt = Reflect.set(y, g, E, C), Pt = o.get(
|
|
583
|
-
return
|
|
593
|
+
const W = Reflect.get(y, g, C), J = j(E) && !(E instanceof Date || E instanceof RegExp || E instanceof Map || E instanceof Set);
|
|
594
|
+
if (i && J ? v(W, E) : W === E) return !0;
|
|
595
|
+
const Mt = Reflect.set(y, g, E, C), Pt = o.get($) || m;
|
|
596
|
+
return M([...Pt, g], E, W), Mt;
|
|
584
597
|
},
|
|
585
598
|
deleteProperty(y, g) {
|
|
586
599
|
if (Reflect.has(y, g)) {
|
|
587
|
-
const E = y[g], C = Reflect.deleteProperty(y, g),
|
|
588
|
-
return C && r.has(y) &&
|
|
600
|
+
const E = y[g], C = Reflect.deleteProperty(y, g), W = o.get($) || [];
|
|
601
|
+
return C && r.has(y) && M([...W, g], void 0, E), C;
|
|
589
602
|
}
|
|
590
603
|
return !1;
|
|
591
604
|
}
|
|
592
605
|
});
|
|
593
|
-
return s.set(h,
|
|
606
|
+
return s.set(h, $), o.set($, m), $;
|
|
594
607
|
}, Rt = Q(t, []);
|
|
595
|
-
if (
|
|
596
|
-
const h = (m,
|
|
597
|
-
if (!(!j(m) || !
|
|
598
|
-
|
|
608
|
+
if (p) {
|
|
609
|
+
const h = (m, b, $ = /* @__PURE__ */ new WeakSet()) => {
|
|
610
|
+
if (!(!j(m) || !d || $.has(m))) {
|
|
611
|
+
$.add(m);
|
|
599
612
|
for (const y of Object.keys(m)) {
|
|
600
|
-
const g = [...
|
|
601
|
-
|
|
613
|
+
const g = [...b, y], E = m[y];
|
|
614
|
+
k(g) && e(g, E, void 0), j(E) && h(E, g, $);
|
|
602
615
|
}
|
|
603
616
|
}
|
|
604
617
|
};
|
|
605
618
|
h(t, []);
|
|
606
619
|
}
|
|
607
620
|
return { proxy: Rt, unobserve: () => {
|
|
608
|
-
|
|
621
|
+
d && (d = !1, c = [], u && (clearTimeout(u), u = null));
|
|
609
622
|
}, resume: () => {
|
|
610
|
-
|
|
623
|
+
d = !0;
|
|
611
624
|
} };
|
|
612
625
|
}
|
|
613
|
-
var V, z, G, L, K, D, _,
|
|
614
|
-
class
|
|
626
|
+
var V, z, G, L, K, D, _, R, U, it;
|
|
627
|
+
class ue extends HTMLElement {
|
|
615
628
|
// 停止数据监听函数
|
|
616
629
|
// -----------------------------------------------------
|
|
617
630
|
/**
|
|
@@ -623,25 +636,25 @@ class le extends HTMLElement {
|
|
|
623
636
|
constructor(n = {}) {
|
|
624
637
|
var a;
|
|
625
638
|
super();
|
|
626
|
-
|
|
639
|
+
P(this, R);
|
|
627
640
|
// ---------------------- 私有属性 ----------------------
|
|
628
|
-
|
|
641
|
+
P(this, V);
|
|
629
642
|
// 响应式数据(Proxy)
|
|
630
|
-
|
|
643
|
+
P(this, z, []);
|
|
631
644
|
// 模板解析后的虚拟节点 AST
|
|
632
|
-
|
|
645
|
+
P(this, G, []);
|
|
633
646
|
// 上一次渲染的虚拟节点
|
|
634
|
-
|
|
647
|
+
P(this, L, !1);
|
|
635
648
|
// 节流刷新,防止重复 patch
|
|
636
|
-
|
|
649
|
+
P(this, K, !1);
|
|
637
650
|
// 是否已挂载
|
|
638
|
-
|
|
651
|
+
P(this, D);
|
|
639
652
|
// 渲染根节点(Shadow DOM 优先)
|
|
640
|
-
|
|
653
|
+
P(this, _);
|
|
641
654
|
const s = this._manifest || {};
|
|
642
|
-
|
|
643
|
-
const { proxy: r, unobserve: o } = pt(n, () =>
|
|
644
|
-
|
|
655
|
+
A(this, D, (a = s.shadowDOM) != null && a.use ? this.attachShadow({ mode: s.shadowDOM.mode || "open" }) : this);
|
|
656
|
+
const { proxy: r, unobserve: o } = pt(n, () => I(this, R, U).call(this));
|
|
657
|
+
A(this, V, r), A(this, _, o), s.template && typeof s.template == "string" && A(this, z, Tt(this, s.template)), Promise.resolve().then(() => this.created());
|
|
645
658
|
}
|
|
646
659
|
/** Web Components 标准方法:声明哪些属性变化会触发 attributeChangedCallback */
|
|
647
660
|
static get observedAttributes() {
|
|
@@ -656,15 +669,15 @@ class le extends HTMLElement {
|
|
|
656
669
|
/** 更新组件数据 */
|
|
657
670
|
set $data(n) {
|
|
658
671
|
j(n) || (n = {}), x(this, _) && x(this, _).call(this);
|
|
659
|
-
const { proxy: s, unobserve: r } = pt(n, () =>
|
|
660
|
-
|
|
672
|
+
const { proxy: s, unobserve: r } = pt(n, () => I(this, R, U).call(this));
|
|
673
|
+
A(this, V, s), A(this, _, r), I(this, R, U).call(this);
|
|
661
674
|
}
|
|
662
675
|
/**
|
|
663
676
|
* 手动刷新组件
|
|
664
677
|
* 外部可调用,用于数据未触发 observe 或强制刷新
|
|
665
678
|
*/
|
|
666
679
|
refresh() {
|
|
667
|
-
|
|
680
|
+
I(this, R, U).call(this);
|
|
668
681
|
}
|
|
669
682
|
// ---------------------- Web Components 生命周期 ----------------------
|
|
670
683
|
connectedCallback() {
|
|
@@ -675,22 +688,22 @@ class le extends HTMLElement {
|
|
|
675
688
|
}
|
|
676
689
|
if (n.props && j(this.$data))
|
|
677
690
|
for (const r of n.props) {
|
|
678
|
-
const o = typeof r == "string" ? r : r.name, a = typeof r == "object" && "type" in r ? r.type : void 0, i = o.replace(/-([a-z])/g, (
|
|
691
|
+
const o = typeof r == "string" ? r : r.name, a = typeof r == "object" && "type" in r ? r.type : void 0, i = o.replace(/-([a-z])/g, (p, l) => l.toUpperCase()), f = this.$data[i];
|
|
679
692
|
if (this.hasAttribute(o)) {
|
|
680
|
-
const
|
|
681
|
-
this.$data[i] =
|
|
693
|
+
const p = this.getAttribute(o);
|
|
694
|
+
this.$data[i] = I(this, R, it).call(this, p, f, a);
|
|
682
695
|
}
|
|
683
696
|
}
|
|
684
|
-
|
|
697
|
+
I(this, R, U).call(this);
|
|
685
698
|
}
|
|
686
699
|
disconnectedCallback() {
|
|
687
700
|
var n;
|
|
688
|
-
this.isConnected && (this.unmounted(), (n = x(this, _)) == null || n.call(this),
|
|
701
|
+
this.isConnected && (this.unmounted(), (n = x(this, _)) == null || n.call(this), A(this, _, void 0));
|
|
689
702
|
}
|
|
690
703
|
attributeChangedCallback(n, s, r) {
|
|
691
704
|
if (s === r || !j(this.$data)) return;
|
|
692
705
|
const o = n.replace(/-([a-z])/g, (i, f) => f.toUpperCase()), a = this.$data[o];
|
|
693
|
-
this.$data[o] =
|
|
706
|
+
this.$data[o] = I(this, R, it).call(this, r, a);
|
|
694
707
|
}
|
|
695
708
|
// ---------------------- 自定义生命周期钩子 ----------------------
|
|
696
709
|
/** 兼容旧组件的初始化钩子(首次 mounted 后调用) */
|
|
@@ -712,16 +725,16 @@ class le extends HTMLElement {
|
|
|
712
725
|
unmounted() {
|
|
713
726
|
}
|
|
714
727
|
}
|
|
715
|
-
V = new WeakMap(), z = new WeakMap(), G = new WeakMap(), L = new WeakMap(), K = new WeakMap(), D = new WeakMap(), _ = new WeakMap(),
|
|
728
|
+
V = new WeakMap(), z = new WeakMap(), G = new WeakMap(), L = new WeakMap(), K = new WeakMap(), D = new WeakMap(), _ = new WeakMap(), R = new WeakSet(), // ---------------------- 渲染核心逻辑 ----------------------
|
|
716
729
|
/** 内部刷新函数,由 observe() 或外部调用触发 */
|
|
717
730
|
U = function() {
|
|
718
|
-
x(this, L) || (
|
|
731
|
+
x(this, L) || (A(this, L, !0), Dt(() => {
|
|
719
732
|
var n;
|
|
720
733
|
if (!this.isConnected) {
|
|
721
|
-
|
|
734
|
+
A(this, L, !1);
|
|
722
735
|
return;
|
|
723
736
|
}
|
|
724
|
-
this.beforeUpdate(),
|
|
737
|
+
this.beforeUpdate(), A(this, G, Ct(x(this, D), x(this, z), x(this, G))), A(this, L, !1), x(this, K) ? this.updated() : (A(this, K, !0), this.mounted(), (n = this.onInit) == null || n.call(this));
|
|
725
738
|
}));
|
|
726
739
|
}, // ---------------------- 属性类型转换工具 ----------------------
|
|
727
740
|
it = function(n, s, r) {
|
|
@@ -742,28 +755,28 @@ it = function(n, s, r) {
|
|
|
742
755
|
return n;
|
|
743
756
|
}
|
|
744
757
|
};
|
|
745
|
-
const
|
|
758
|
+
const ne = (t) => (e) => {
|
|
746
759
|
if (customElements.get(t.tagName)) {
|
|
747
760
|
console.warn(`标签名称 "${t.tagName}" 已经被注册`);
|
|
748
761
|
return;
|
|
749
762
|
}
|
|
750
|
-
return e.prototype._manifest =
|
|
751
|
-
},
|
|
763
|
+
return e.prototype._manifest = se(t), customElements.define(t.tagName, e), e;
|
|
764
|
+
}, se = (t) => (t = Object.assign({
|
|
752
765
|
hasConfig: !1
|
|
753
766
|
}, t), t);
|
|
754
|
-
var
|
|
767
|
+
var re = Object.getOwnPropertyDescriptor, xt = (t) => {
|
|
755
768
|
throw TypeError(t);
|
|
756
|
-
},
|
|
757
|
-
for (var r = s > 1 ? void 0 : s ?
|
|
769
|
+
}, oe = (t, e, n, s) => {
|
|
770
|
+
for (var r = s > 1 ? void 0 : s ? re(e, n) : e, o = t.length - 1, a; o >= 0; o--)
|
|
758
771
|
(a = t[o]) && (r = a(r) || r);
|
|
759
772
|
return r;
|
|
760
|
-
}, ht = (t, e, n) => e.has(t) || xt("Cannot " + n),
|
|
773
|
+
}, ht = (t, e, n) => e.has(t) || xt("Cannot " + n), S = (t, e, n) => (ht(t, e, "read from private field"), n ? n.call(t) : e.get(t)), O = (t, e, n) => e.has(t) ? xt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), T = (t, e, n, s) => (ht(t, e, "write to private field"), e.set(t, n), n), ae = (t, e, n) => (ht(t, e, "access private method"), n), Y, tt, et, B, q, X, Z, ct, wt;
|
|
761
774
|
function dt(t) {
|
|
762
775
|
return t instanceof HTMLElement && t.isRouterView === !0;
|
|
763
776
|
}
|
|
764
777
|
let mt = class extends HTMLElement {
|
|
765
778
|
constructor() {
|
|
766
|
-
super(...arguments),
|
|
779
|
+
super(...arguments), O(this, ct), O(this, Y, []), O(this, tt, []), O(this, et, null), O(this, B), O(this, q, []), O(this, X, {}), O(this, Z, this.onHashChange.bind(this));
|
|
767
780
|
}
|
|
768
781
|
// #endregion
|
|
769
782
|
// #region 公共属性和访问器
|
|
@@ -771,16 +784,16 @@ let mt = class extends HTMLElement {
|
|
|
771
784
|
return !0;
|
|
772
785
|
}
|
|
773
786
|
get $routes() {
|
|
774
|
-
return
|
|
787
|
+
return S(this, q);
|
|
775
788
|
}
|
|
776
789
|
set $routes(t) {
|
|
777
790
|
T(this, q, t), this.onHashChange();
|
|
778
791
|
}
|
|
779
792
|
get $remainingPath() {
|
|
780
|
-
return
|
|
793
|
+
return S(this, tt);
|
|
781
794
|
}
|
|
782
795
|
get $matchedRoute() {
|
|
783
|
-
return
|
|
796
|
+
return S(this, et);
|
|
784
797
|
}
|
|
785
798
|
set $pipe(t) {
|
|
786
799
|
T(this, X, t || {}), this.onHashChange();
|
|
@@ -788,10 +801,10 @@ let mt = class extends HTMLElement {
|
|
|
788
801
|
// #endregion
|
|
789
802
|
// #region 生命周期回调
|
|
790
803
|
connectedCallback() {
|
|
791
|
-
window.addEventListener("hashchange",
|
|
804
|
+
window.addEventListener("hashchange", S(this, Z)), this.onHashChange();
|
|
792
805
|
}
|
|
793
806
|
disconnectedCallback() {
|
|
794
|
-
window.removeEventListener("hashchange",
|
|
807
|
+
window.removeEventListener("hashchange", S(this, Z));
|
|
795
808
|
}
|
|
796
809
|
// #endregion
|
|
797
810
|
/**
|
|
@@ -804,10 +817,10 @@ let mt = class extends HTMLElement {
|
|
|
804
817
|
if (t)
|
|
805
818
|
T(this, B, t.$remainingPath), T(this, q, ((e = t.$matchedRoute) == null ? void 0 : e.children) || []);
|
|
806
819
|
else {
|
|
807
|
-
const { path: n } =
|
|
820
|
+
const { path: n } = ee(window.location);
|
|
808
821
|
T(this, B, n);
|
|
809
822
|
}
|
|
810
|
-
|
|
823
|
+
ae(this, ct, wt).call(this);
|
|
811
824
|
}
|
|
812
825
|
/**
|
|
813
826
|
* 准备传递给子组件的 props 和事件监听
|
|
@@ -818,7 +831,7 @@ let mt = class extends HTMLElement {
|
|
|
818
831
|
const e = {}, n = {};
|
|
819
832
|
for (const [s, r] of Object.entries(t))
|
|
820
833
|
e[s] = () => r;
|
|
821
|
-
for (const [s, r] of Object.entries(
|
|
834
|
+
for (const [s, r] of Object.entries(S(this, X))) {
|
|
822
835
|
const o = s.toLowerCase();
|
|
823
836
|
let a = null;
|
|
824
837
|
o.startsWith("on-") ? a = o.slice(3) : o.startsWith("on") && gt.includes(o.slice(2)) && (a = o.slice(2)), a ? n[a] = r : e[s] = () => r;
|
|
@@ -895,7 +908,7 @@ X = /* @__PURE__ */ new WeakMap();
|
|
|
895
908
|
Z = /* @__PURE__ */ new WeakMap();
|
|
896
909
|
ct = /* @__PURE__ */ new WeakSet();
|
|
897
910
|
wt = function() {
|
|
898
|
-
const t =
|
|
911
|
+
const t = S(this, B) || [], { matchedRoute: e, params: n, remainingPath: s } = this.matchRoute(S(this, q), t);
|
|
899
912
|
T(this, tt, s), T(this, et, e);
|
|
900
913
|
const r = (e == null ? void 0 : e.tagName) || "comment", { props: o, on: a } = this.prepareComponentData(n);
|
|
901
914
|
T(this, Y, Ct(this, [{
|
|
@@ -906,22 +919,22 @@ wt = function() {
|
|
|
906
919
|
props: o,
|
|
907
920
|
on: a,
|
|
908
921
|
children: []
|
|
909
|
-
}],
|
|
922
|
+
}], S(this, Y))), this.propagateToChildRouterViews();
|
|
910
923
|
};
|
|
911
|
-
mt =
|
|
912
|
-
|
|
924
|
+
mt = oe([
|
|
925
|
+
ne({
|
|
913
926
|
tagName: "router-view"
|
|
914
927
|
})
|
|
915
928
|
], mt);
|
|
916
929
|
export {
|
|
917
|
-
|
|
918
|
-
|
|
930
|
+
ue as BaseElement,
|
|
931
|
+
ne as CustomElement,
|
|
919
932
|
mt as RouterViewElement,
|
|
920
933
|
lt as createFunction,
|
|
921
934
|
j as isObject,
|
|
922
935
|
gt as listeners,
|
|
923
936
|
pt as observe,
|
|
924
|
-
|
|
937
|
+
ee as parseHashUrl,
|
|
925
938
|
Tt as parseHtml,
|
|
926
939
|
Ct as patch,
|
|
927
940
|
Dt as runInAsyncQueue
|
package/dist/solely.umd.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(d,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(d=typeof globalThis<"u"?globalThis:d||self,v(d.solely={}))})(this,function(d){"use strict";var It=d=>{throw TypeError(d)};var yt=(d,v,C)=>v.has(d)||It("Cannot "+C);var M=(d,v,C)=>(yt(d,v,"read from private field"),C?C.call(d):v.get(d)),j=(d,v,C)=>v.has(d)?It("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(d):v.set(d,C),w=(d,v,C,X)=>(yt(d,v,"write to private field"),X?X.call(d,C):v.set(d,C),C),D=(d,v,C)=>(yt(d,v,"access private method"),C);var z,Q,J,V,N,U,I,_,G,Et;const v=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,C=/<\/?([^\s]+?)[/\s>]/,X=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Ot=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],it=/\{\{(.+?)\}\}/g;function jt(t){return t.replace(/>\s+</g,"><").replace(/\s+/g," ")}function Tt(t,e){const n=(e.match(C)||[])[1]||"",s={rootId:"0",tagName:n,attrs:{},props:{},on:{},children:[]},r=new RegExp(X);for(;;){const o=r.exec(e);if(o===null)break;if(!o[0].trim())continue;const[a,i]=o[1]?o[1].trim().split("="):[o[2],o[3].trim().slice(1,-1)];if(a==="onMounted"||a==="onUpdated")s[a]=Ht(t,i);else if(ct.includes(a)||a.startsWith("on-"))s.on[a.startsWith("on-")?a.slice(3):a.slice(2)]=F(t,i);else if(a.startsWith("s-")){const l=a.slice(2);switch(l){case"model":s.model=i;break;case"style":s.styles=p=>P(t,i,p);break;case"class":s.classes=p=>P(t,i,p);break;case"readonly":s.props.readOnly=p=>P(t,i,p);break;case"for":s.props.htmlFor=p=>P(t,i,p);break;case"tabindex":s.props.tabIndex=p=>P(t,i,p);break;case"contenteditable":s.props.contentEditable=p=>P(t,i,p);break;default:s.props[l]=p=>P(t,i,p);break}}else s.attrs[a]=i;r.lastIndex--}if(n==="For"?s.fn=o=>P(t,s.attrs.each,o):(n==="If"||n==="ElseIf")&&(s.fn=o=>P(t,s.attrs.condition,o)),s.model){const o=s.model.replace("this.","").replace("$data.",""),a=l=>P(t,`$data.${o}`,l),i=(l,p)=>{if(s.on[l]){const u=s.on[l];s.on[l]=(c,h)=>{p(c,h),u(c,h)}}else s.on[l]=p};if(n==="input"){const l=s.attrs.type||"text";if(l==="checkbox")s.props.checked=a,i("change",F(t,`$data.${o}=checked`));else if(l==="radio"){const p=s.attrs.value;s.props.checked=u=>a(u)==p,i("change",F(t,`if(checked){$data.${o}='${p}'}`))}else s.props.value=a,i("input",F(t,`$data.${o}=value`))}else if(n==="textarea")s.props.value=a,i("input",F(t,`$data.${o}=value`));else if(n==="select"){const l="multiple"in s.attrs;l?i("change",F(t,`
|
|
2
2
|
$data.${o} = Array.from(event.target.selectedOptions).map(o => o.value);
|
|
3
|
-
`)):(i("change",F(n,`$data.${o}=value`)),s.props.value=a);const m=(h,d=[])=>{const k=a(d);if(l){const R=Array.isArray(k)?k:k!=null?[k]:[];for(const I of h.options)I.selected=R.includes(I.value)}else{const R=k??"";h.value!==R&&(h.value=R)}},u=s.onMounted,c=s.onUpdated;s.onMounted=(h,d)=>{u==null||u(h,d),m(h,d||[])},s.onUpdated=(h,d)=>{c==null||c(h,d),m(h,d||[])}}}return s}function vt(n,t){const e=[];if(!t)return e;t=jt(t);const s=[],r=[],o=()=>{var i;return s.length===0?e:(i=s[s.length-1]).children||(i.children=[])};let a=0;return t.replace(b,(i,l)=>{const m=o();if(l>a){const u=t.substring(a,l).trim();if(u){it.lastIndex=0;const h=!it.test(u)?u:d=>u.replace(it,(k,R)=>j(n,R,d));m.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:h,children:[]})}}if(a=l+i.length,i.startsWith("<!--")&&i.endsWith("-->"))m.push({rootId:"0",tagName:"comment",attrs:{},props:{},on:{},content:i.slice(4,-3),children:[]});else if(i.startsWith("</")){const u=r.pop();for(;s.length>0&&s[s.length-1].tagName!==u;)s.pop();s.pop()}else{const u=Tt(n,i),c=i.endsWith("/>")||Ot.includes(u.tagName);m.push(u),c||(s.push(u),r.push(u.tagName))}return""}),t.length>a&&e.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:t.substring(a).trim(),children:[]}),e}const j=(n,t,e)=>{try{return Z(["$data",...e.map(r=>r.item),...e.map(r=>r.index),`return (${t})`]).bind(n)(n.$data,...e.map(r=>r.value),...e.map(r=>r.valueIndex))}catch(s){return console.error(`[BaseElement][${n.tagName}] Error evaluating expression: {{ ${t} }}`,n,s),""}},F=(n,t)=>(e,s)=>{var r,o;try{return Z(["$data","event","value","checked",...s.map(i=>i.item),...s.map(i=>i.index),t]).bind(n)(n.$data,e,(r=e==null?void 0:e.target)==null?void 0:r.value,(o=e==null?void 0:e.target)==null?void 0:o.checked,...s.map(i=>i.value),...s.map(i=>i.valueIndex))}catch(a){console.error(`[BaseElement][${n.tagName}] Error executing event handler "${t}"`,n,a)}},Ht=(n,t)=>(e,s=[])=>{try{Z(["$data","elm",...s.map(o=>o.item),...s.map(o=>o.index),`(function(){ ${t} }).call(this)`]).bind(n)(n.$data,e,...s.map(o=>o.value),...s.map(o=>o.valueIndex))}catch(r){console.error(`[BaseElement][${n.tagName}] Error executing lifecycle handler "${t}"`,n,r)}},ct=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],Lt=typeof requestAnimationFrame=="function"?n=>requestAnimationFrame(n):typeof Promise<"u"?n=>Promise.resolve().then(n):n=>setTimeout(n,0),bt=(n,...t)=>{if(typeof n!="function")throw new Error("runInAsyncQueue expects a function as its first argument");Lt(()=>n(...t))},lt={};function Z(n){const t=n.map(e=>e.replace(/[',"]/g,"")).join(",");if(!lt[t]){const e=n[n.length-1];if(e.trim()==="")throw new Error("Function body cannot be empty");if(Ft(e))throw new Error("Input contains potentially dangerous code: "+e);lt[t]=new Function(...n)}return lt[t]}const Dt=["eval","Function","process","require"];function Ft(n){return Dt.some(t=>new RegExp(`\\b${t}\\b`,"g").test(n))}const Ut="http://www.w3.org/1999/xlink",Vt="http://www.w3.org/2000/xmlns/",qt="http://www.w3.org/XML/1998/namespace",Bt="http://www.w3.org/2000/svg",$t=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",zt=n=>{const t=$t(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},kt=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},At=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),o=ut(r);Object.entries(o).forEach(([a,i])=>{n.style[a]=i})},Ct=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),o=wt(r);Object.entries(o).forEach(([a,i])=>{i?n.classList.add(a):n.classList.remove(a)})},ut=n=>{let t={};return typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=ut(s);Object.entries(r).forEach(([o,a])=>{t[`${e}-${o}`]=a})}else typeof s=="string"||typeof s=="number"?t[e]=`${s}`:t[e]=String(s)}):typeof n=="string"?n.split(";").forEach(e=>{const[s,r]=e.split(":").map(o=>o.trim());s&&r&&(t[s]=r)}):Array.isArray(n)&&n.forEach(e=>{const s=ut(e);Object.entries(s).forEach(([r,o])=>{t[r]=o})}),t},wt=n=>{let t={};return typeof n=="object"&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{t[e]=!!s}):typeof n=="string"?n.split(" ").forEach(e=>{e!==""&&(t[e]=!0)}):Array.isArray(n)&&n.forEach(e=>{const s=wt(e);Object.entries(s).forEach(([r,o])=>{t[r]=o})}),t},Rt=(n,t,e)=>{const s=r=>e.on[t](r,e.loops||[]);n.addEventListener(t,s,!1),e.handlers=e.handlers||{},e.handlers[t]=s},Gt=(n,t)=>{const e=t.elm;Object.keys(t.on).forEach(s=>{n.handlers&&n.handlers[s]&&e.removeEventListener(s,n.handlers[s],!1),Rt(e,s,t)}),kt(e,t.props,t.loops),Ct(e,t),At(e,t),typeof t.onUpdated=="function"&&requestAnimationFrame(()=>{t.onUpdated(e,t.loops||[])}),Mt(e,n.children,t.children)},Kt=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":zt(t);break;default:Gt(n,t);break}},ht=(n,t,e)=>{e&&e.parentNode===n?n.insertBefore(t,e):n.appendChild(t)},Qt=(n,t,e)=>{const s=$t(t),r=document.createTextNode(s);t.elm=r,ht(n,r,e)},Jt=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,ht(n,r,e)},Nt=(n,t,e,s)=>{t.tagName==="svg"&&(s=Bt);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(o=>{const a=t.attrs[o]||"";o.charAt(0)!=="x"?r.setAttribute(o,a):o.startsWith("xml:")?r.setAttributeNS(qt,o,a):o.startsWith("xlink:")?r.setAttributeNS(Ut,o,a):o.startsWith("xmlns:")?r.setAttributeNS(Vt,o,a):r.setAttribute(o,a)}),Object.keys(t.on).forEach(o=>{Rt(r,o,t)}),kt(r,t.props,t.loops),Ct(r,t),At(r,t),t.elm=r,ht(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(o=>{Y(r,o,void 0,s)}),typeof t.onMounted=="function"&&requestAnimationFrame(()=>{t.onMounted(r,t.loops||[])})},Y=(n,t,e,s)=>{switch(t.tagName){case"comment":Jt(n,t,e);break;case"text":Qt(n,t,e);break;default:Nt(n,t,e,s);break}},Xt=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Zt=n=>n&&n.tagName==="Else",q=(n,t,e=[],s="0",r)=>{var i,l,m;let o=0,a=0;for(let u=0;u<t.length;u++){const c=t[u];if(c.tagName==="If"){let h=!1;o++;let d=1;for(((i=c.fn)==null?void 0:i.call(c,e))&&(q(n,c.children,e,`${s}-if-${o}-${d}`,d),h=!0),d++;u+1<t.length&&Xt(t[u+1]);)((m=(l=t[u+1]).fn)==null?void 0:m.call(l,e))&&!h&&(q(n,t[u+1].children,e,`${s}-if-${o}-${d}`,d),h=!0),u++,d++;u+1<t.length&&Zt(t[u+1])&&(h||(q(n,t[u+1].children,e,`${s}-if-${o}-${d}`,d),h=!0),u++)}else if(c.tagName==="For"){a++;const{item:h="item",index:d="index"}=c.attrs;(c.fn(e)||[]).forEach((R,I)=>{const ot={item:h,value:R,index:d,valueIndex:I};q(n,c.children,[...e,ot],`${s}-for-${a}-${I}`,1)})}else{const h={...c,loops:e,children:[],rootId:s,ifId:r,key:c.key||`${s}-${u}`};q(h.children,c.children,e,`${s}-${u}`),n.push(h)}}},Mt=(n,t,e)=>{var a,i,l,m,u;const s=new Map;t.forEach((c,h)=>s.set(c.key,{node:c,index:h}));let r=0,o=0;for(;r<e.length;){const c=e[r],h=s.get(c.key);if(h){const d=h.node;if(d.tagName!==c.tagName){(a=d.elm)==null||a.remove();const k=(i=t[o+1])==null?void 0:i.elm;Y(n,c,k),s.delete(c.key),o++}else{if(c.ifId&&d.ifId!==c.ifId){(l=d.elm)==null||l.remove();const k=(m=t[o+1])==null?void 0:m.elm;Y(n,c,k)}else Kt(d,c);s.delete(c.key),o++}}else{const d=(u=t[o])==null?void 0:u.elm;Y(n,c,d)}r++}s.forEach(({node:c})=>{var h;return(h=c.elm)==null?void 0:h.remove()})},ft=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return q(s,t||[],[],"0"),Mt(n,e,s),s},_=n=>{if(n===null||typeof n!="object")return!1;const t=Object.prototype.toString.call(n);return!["[object Function]","[object Date]","[object RegExp]","[object Map]","[object Set]","[object WeakMap]","[object WeakSet]"].includes(t)};function Pt(n=window.location){let t;typeof n=="string"?t=new URL(n).hash:t=n.hash;const e=t.split("?"),s=e[0].substring(2),r=e[1],o={};return r&&r.split("&").forEach(a=>{const[i,l]=a.split("=");i&&l&&(o[decodeURIComponent(i)]=decodeURIComponent(l))}),{path:s.split("/"),query:o}}function pt(n,t,e={}){const s=new WeakMap,r=new WeakSet,o=new WeakMap,{throttle:a=0,deepCompare:i=!1,onBatch:l=null,immediate:m=!1}=e,u=Array.isArray(e.filter)?e.filter:e.filter?[e.filter]:[];let c=[],h=null,d=!0;const k=(f,g,$=new WeakMap)=>{if(f===g)return!0;if(f==null||g==null||typeof f!="object"||typeof g!="object")return f===g;if($.has(f))return $.get(f)===g;if($.set(f,g),Array.isArray(f)&&Array.isArray(g)){if(f.length!==g.length)return!1;for(let y=0;y<f.length;y++)if(!k(f[y],g[y],$))return!1;return!0}if(Array.isArray(f)!==Array.isArray(g))return!1;const A=Object.keys(f),E=Object.keys(g);if(A.length!==E.length)return!1;for(const y of A)if(!Object.prototype.hasOwnProperty.call(g,y)||!k(f[y],g[y],$))return!1;return!0},R=f=>{if(u.length===0)return!0;const g=f.map(String).join(".");return u.some($=>{if(!$)return!0;try{return new RegExp("^"+$.replace(/\./g,"\\.").replace(/\[\*\]/g,"(\\.\\d+)?").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+")+"$").test(g)}catch{return!0}})},I=(f,g,$)=>{d&&R(f)&&(a>0?(c.push({path:f,newValue:g,oldValue:$}),h||(h=setTimeout(()=>{if(!d){h=null;return}const A=c;c=[],h=null,l&&l(A);for(const E of A)t(E.path,E.newValue,E.oldValue)},a))):(t(f,g,$),l&&l([{path:f,newValue:g,oldValue:$}])))},ot=(f,g)=>{if(!_(f)||!(Array.isArray(f)||Object.prototype.toString.call(f)==="[object Object]"))return f;const $={};if(["push","pop","shift","unshift","splice","sort","reverse"].forEach(E=>{const y=Array.prototype[E];$[E]=function(...v){if(!d)return Reflect.apply(y,f,v);const M=[...f],L=y.apply(f,v);return k(f,M)||I(g,f,M),L}}),s.has(f)){const E=s.get(f);return o.set(E,g),E}r.add(f);const A=new Proxy(f,{get(E,y,v){if(Array.isArray(E)&&$.hasOwnProperty(y))return Reflect.get($,y,v);const M=Reflect.get(E,y,v);if(_(M)){const at=[...o.get(A)||[],y],gt=ot(M,at);return o.set(gt,at),gt}return M},set(E,y,v,M){const L=Reflect.get(E,y,M),at=_(v)&&!(v instanceof Date||v instanceof RegExp||v instanceof Map||v instanceof Set);if(i&&at?k(L,v):L===v)return!0;const oe=Reflect.set(E,y,v,M),ae=o.get(A)||g;return I([...ae,y],v,L),oe},deleteProperty(E,y){if(Reflect.has(E,y)){const v=E[y],M=Reflect.deleteProperty(E,y),L=o.get(A)||[];return M&&r.has(E)&&I([...L,y],void 0,v),M}return!1}});return s.set(f,A),o.set(A,g),A},re=ot(n,[]);if(m){const f=(g,$,A=new WeakSet)=>{if(!(!_(g)||!d||A.has(g))){A.add(g);for(const E of Object.keys(g)){const y=[...$,E],v=g[E];R(y)&&t(y,v,void 0),_(v)&&f(v,y,A)}}};f(n,[])}return{proxy:re,unobserve:()=>{d&&(d=!1,c=[],h&&(clearTimeout(h),h=null))},resume:()=>{d=!0}}}class Yt extends HTMLElement{constructor(e={}){var a;super();O(this,S);O(this,z);O(this,Q,[]);O(this,J,[]);O(this,U,!1);O(this,N,!1);O(this,V);O(this,W);const s=this._manifest||{};w(this,V,(a=s.shadowDOM)!=null&&a.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this);const{proxy:r,unobserve:o}=pt(e,()=>D(this,S,G).call(this));w(this,z,r),w(this,W,o),s.template&&typeof s.template=="string"&&w(this,Q,vt(this,s.template)),Promise.resolve().then(()=>this.created())}static get observedAttributes(){const e=this._manifest||this.prototype._manifest;return e!=null&&e.props?e.props.map(s=>typeof s=="string"?s:s.name):[]}get $data(){return P(this,z)}set $data(e){_(e)||(e={}),P(this,W)&&P(this,W).call(this);const{proxy:s,unobserve:r}=pt(e,()=>D(this,S,G).call(this));w(this,z,s),w(this,W,r),D(this,S,G).call(this)}refresh(){D(this,S,G).call(this)}connectedCallback(){const e=this._manifest||{};if((e.className||e.tagName||"").split(" ").forEach(r=>r&&this.classList.add(r)),e.styles&&!P(this,V).querySelector("style[data-manifest-style]")){const r=document.createElement("style");r.setAttribute("data-manifest-style","true"),r.textContent=e.styles,P(this,V).appendChild(r)}if(e.props&&_(this.$data))for(const r of e.props){const o=typeof r=="string"?r:r.name,a=typeof r=="object"&&"type"in r?r.type:void 0,i=o.replace(/-([a-z])/g,(m,u)=>u.toUpperCase()),l=this.$data[i];if(this.hasAttribute(o)){const m=this.getAttribute(o);this.$data[i]=D(this,S,Et).call(this,m,l,a)}}D(this,S,G).call(this)}disconnectedCallback(){var e;this.isConnected&&(this.unmounted(),(e=P(this,W))==null||e.call(this),w(this,W,void 0))}attributeChangedCallback(e,s,r){if(s===r||!_(this.$data))return;const o=e.replace(/-([a-z])/g,(i,l)=>l.toUpperCase()),a=this.$data[o];this.$data[o]=D(this,S,Et).call(this,r,a)}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}}z=new WeakMap,Q=new WeakMap,J=new WeakMap,U=new WeakMap,N=new WeakMap,V=new WeakMap,W=new WeakMap,S=new WeakSet,G=function(){P(this,U)||(w(this,U,!0),bt(()=>{var e;if(!this.isConnected){w(this,U,!1);return}this.beforeUpdate(),w(this,J,ft(P(this,V),P(this,Q),P(this,J))),w(this,U,!1),P(this,N)?this.updated():(w(this,N,!0),this.mounted(),(e=this.onInit)==null||e.call(this))}))},Et=function(e,s,r){if(e===null)return s;switch(r||typeof s){case"number":const a=Number(e);return isNaN(a)?s:a;case"boolean":return e==="true";case"object":try{return JSON.parse(e)}catch{return s}default:return e}};const St=n=>t=>{if(customElements.get(n.tagName)){console.warn(`标签名称 "${n.tagName}" 已经被注册`);return}return t.prototype._manifest=te(n),customElements.define(n.tagName,t),t},te=n=>(n=Object.assign({hasConfig:!1},n),n);var ee=Object.getOwnPropertyDescriptor,_t=n=>{throw TypeError(n)},ne=(n,t,e,s)=>{for(var r=s>1?void 0:s?ee(t,e):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=a(r)||r);return r},dt=(n,t,e)=>t.has(n)||_t("Cannot "+e),x=(n,t,e)=>(dt(n,t,"read from private field"),e?e.call(n):t.get(n)),T=(n,t,e)=>t.has(n)?_t("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),H=(n,t,e,s)=>(dt(n,t,"write to private field"),t.set(n,e),e),se=(n,t,e)=>(dt(n,t,"access private method"),e),tt,et,nt,K,B,st,rt,mt,xt;function Wt(n){return n instanceof HTMLElement&&n.isRouterView===!0}p.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),T(this,mt),T(this,tt,[]),T(this,et,[]),T(this,nt,null),T(this,K),T(this,B,[]),T(this,st,{}),T(this,rt,this.onHashChange.bind(this))}get isRouterView(){return!0}get $routes(){return x(this,B)}set $routes(t){H(this,B,t),this.onHashChange()}get $remainingPath(){return x(this,et)}get $matchedRoute(){return x(this,nt)}set $pipe(t){H(this,st,t||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",x(this,rt)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",x(this,rt))}onHashChange(){var e;if(!this.isConnected)return;const t=this.findAncestorRouterView();if(t)H(this,K,t.$remainingPath),H(this,B,((e=t.$matchedRoute)==null?void 0:e.children)||[]);else{const{path:s}=Pt(window.location);H(this,K,s)}se(this,mt,xt).call(this)}prepareComponentData(t){const e={},s={};for(const[r,o]of Object.entries(t))e[r]=()=>o;for(const[r,o]of Object.entries(x(this,st))){const a=r.toLowerCase();let i=null;a.startsWith("on-")?i=a.slice(3):a.startsWith("on")&&ct.includes(a.slice(2))&&(i=a.slice(2)),i?s[i]=o:e[r]=()=>o}return{props:e,on:s}}matchRoute(t,e){for(const s of t){const r=s.path.split("/").filter(i=>i),o={};if(r.length>e.length&&!r.includes("*"))continue;let a=!0;for(let i=0;i<r.length;i++){const l=r[i],m=e[i];if(l.startsWith(":"))o[l.substring(1)]=m;else{if(l==="*")return{matchedRoute:s,params:o,remainingPath:[]};if(l!==m){a=!1;break}}}if(a)return{matchedRoute:s,params:o,remainingPath:e.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:e}}propagateToChildRouterViews(t=this){for(const e of t.childNodes)Wt(e)?e.onHashChange():this.propagateToChildRouterViews(e)}findAncestorRouterView(){let t=this.parentElement;for(;t;){if(Wt(t))return t;t=t.parentElement}return null}},tt=new WeakMap,et=new WeakMap,nt=new WeakMap,K=new WeakMap,B=new WeakMap,st=new WeakMap,rt=new WeakMap,mt=new WeakSet,xt=function(){const n=x(this,K)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(x(this,B),n);H(this,et,s),H(this,nt,t);const r=(t==null?void 0:t.tagName)||"comment",{props:o,on:a}=this.prepareComponentData(e);H(this,tt,ft(this,[{tagName:r,rootId:"0",attrs:{},props:o,on:a,children:[]}],x(this,tt))),this.propagateToChildRouterViews()},p.RouterViewElement=ne([St({tagName:"router-view"})],p.RouterViewElement),p.BaseElement=Yt,p.CustomElement=St,p.createFunction=Z,p.isObject=_,p.listeners=ct,p.observe=pt,p.parseHashUrl=Pt,p.parseHtml=vt,p.patch=ft,p.runInAsyncQueue=bt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
3
|
+
`)):(i("change",F(t,`$data.${o}=value`)),s.props.value=a);const p=(h,m=[])=>{const A=a(m);if(l){const R=Array.isArray(A)?A:A!=null?[A]:[];for(const O of h.options)O.selected=R.includes(O.value)}else{const R=A??"";h.value!==R&&(h.value=R)}},u=s.onMounted,c=s.onUpdated;s.onMounted=(h,m)=>{u==null||u(h,m),p(h,m||[])},s.onUpdated=(h,m)=>{c==null||c(h,m),p(h,m||[])}}}return s}function bt(t,e){const n=[];if(!e)return n;e=jt(e);const s=[],r=[],o=()=>{var i;return s.length===0?n:(i=s[s.length-1]).children||(i.children=[])};let a=0;return e.replace(v,(i,l)=>{const p=o();if(l>a){const u=e.substring(a,l).trim();if(u){it.lastIndex=0;const h=!it.test(u)?u:m=>u.replace(it,(A,R)=>P(t,R,m));p.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:h,children:[]})}}if(a=l+i.length,i.startsWith("<!--")&&i.endsWith("-->"))p.push({rootId:"0",tagName:"comment",attrs:{},props:{},on:{},content:i.slice(4,-3),children:[]});else if(i.startsWith("</")){const u=r.pop();for(;s.length>0&&s[s.length-1].tagName!==u;)s.pop();s.pop()}else{const u=Tt(t,i),c=i.endsWith("/>")||Ot.includes(u.tagName);p.push(u),c||(s.push(u),r.push(u.tagName))}return""}),e.length>a&&n.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:e.substring(a).trim(),children:[]}),n}const P=(t,e,n)=>{try{return Z(["$data",...n.map(r=>r.item),...n.map(r=>r.index),`return (${e})`]).bind(t)(t.$data,...n.map(r=>r.value),...n.map(r=>r.valueIndex))}catch(s){return console.error(`[BaseElement][${t.tagName}] Error evaluating expression: {{ ${e} }}`,t,s),""}},F=(t,e)=>(n,s)=>{var r,o;try{return Z(["$data","event","value","checked",...s.map(i=>i.item),...s.map(i=>i.index),e]).bind(t)(t.$data,n,(r=n==null?void 0:n.target)==null?void 0:r.value,(o=n==null?void 0:n.target)==null?void 0:o.checked,...s.map(i=>i.value),...s.map(i=>i.valueIndex))}catch(a){console.error(`[BaseElement][${t.tagName}] Error executing event handler "${e}"`,t,a)}},Ht=(t,e)=>(n,s=[])=>{try{Z(["$data","elm",...s.map(o=>o.item),...s.map(o=>o.index),`(function(){ ${e} }).call(this)`]).bind(t)(t.$data,n,...s.map(o=>o.value),...s.map(o=>o.valueIndex))}catch(r){console.error(`[BaseElement][${t.tagName}] Error executing lifecycle handler "${e}"`,t,r)}},ct=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],Lt=typeof requestAnimationFrame=="function"?t=>requestAnimationFrame(t):typeof Promise<"u"?t=>Promise.resolve().then(t):t=>setTimeout(t,0),vt=(t,...e)=>{if(typeof t!="function")throw new Error("runInAsyncQueue expects a function as its first argument");Lt(()=>t(...e))},lt={};function Z(t){const e=t.map(n=>n.replace(/[',"]/g,"")).join(",");if(!lt[e]){const n=t[t.length-1];if(n.trim()==="")throw new Error("Function body cannot be empty");if(Ft(n))throw new Error("Input contains potentially dangerous code: "+n);lt[e]=new Function(...t)}return lt[e]}const Dt=["eval","Function","process","require"];function Ft(t){return Dt.some(e=>new RegExp(`\\b${e}\\b`,"g").test(t))}const Vt="http://www.w3.org/1999/xlink",Ut="http://www.w3.org/2000/xmlns/",qt="http://www.w3.org/XML/1998/namespace",Bt="http://www.w3.org/2000/svg",$t=t=>typeof t.content=="function"?t.content(t.loops||[]):t.content||"",zt=t=>{const e=$t(t),n=t.elm;n.textContent!==e&&(n.textContent=e)},Gt=["role","form"],At=(t,e,n=[])=>{Object.keys(e).forEach(s=>{const r=e[s](n);if(s.startsWith("data-")||s.startsWith("aria-")||Gt.includes(s)){const o=t.getAttribute(s),a=r==null?null:String(r);o!==a&&(a==null?t.removeAttribute(s):t.setAttribute(s,a))}else t[s]!==r&&(t[s]=r)})},kt=(t,e)=>{const{styles:n,loops:s=[]}=e;if(!n)return;const r=n(s),o=ut(r);Object.entries(o).forEach(([a,i])=>{t.style[a]=i})},Ct=(t,e)=>{const{classes:n,loops:s=[]}=e;if(!n)return;const r=n(s),o=wt(r);Object.entries(o).forEach(([a,i])=>{i?t.classList.add(a):t.classList.remove(a)})},ut=t=>{let e={};return typeof t=="object"&&t!==null&&!Array.isArray(t)?Object.entries(t).forEach(([n,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=ut(s);Object.entries(r).forEach(([o,a])=>{e[`${n}-${o}`]=a})}else typeof s=="string"||typeof s=="number"?e[n]=`${s}`:e[n]=String(s)}):typeof t=="string"?t.split(";").forEach(n=>{const[s,r]=n.split(":").map(o=>o.trim());s&&r&&(e[s]=r)}):Array.isArray(t)&&t.forEach(n=>{const s=ut(n);Object.entries(s).forEach(([r,o])=>{e[r]=o})}),e},wt=t=>{let e={};return typeof t=="object"&&!Array.isArray(t)?Object.entries(t).forEach(([n,s])=>{e[n]=!!s}):typeof t=="string"?t.split(" ").forEach(n=>{n!==""&&(e[n]=!0)}):Array.isArray(t)&&t.forEach(n=>{const s=wt(n);Object.entries(s).forEach(([r,o])=>{e[r]=o})}),e},Rt=(t,e,n)=>{const s=r=>n.on[e](r,n.loops||[]);t.addEventListener(e,s,!1),n.handlers=n.handlers||{},n.handlers[e]=s},Kt=(t,e)=>{const n=e.elm;Object.keys(e.on).forEach(s=>{t.handlers&&t.handlers[s]&&n.removeEventListener(s,t.handlers[s],!1),Rt(n,s,e)}),At(n,e.props,e.loops),Ct(n,e),kt(n,e),typeof e.onUpdated=="function"&&requestAnimationFrame(()=>{e.onUpdated(n,e.loops||[])}),St(n,t.children,e.children)},Qt=(t,e)=>{switch(e.elm=t.elm,e.tagName){case"comment":break;case"text":zt(e);break;default:Kt(t,e);break}},ht=(t,e,n)=>{n&&n.parentNode===t?t.insertBefore(e,n):t.appendChild(e)},Jt=(t,e,n)=>{const s=$t(e),r=document.createTextNode(s);e.elm=r,ht(t,r,n)},Nt=(t,e,n)=>{const s=e.content,r=document.createComment(s);e.elm=r,ht(t,r,n)},Xt=(t,e,n,s)=>{e.tagName==="svg"&&(s=Bt);const r=s?document.createElementNS(s,e.tagName):document.createElement(e.tagName);Object.keys(e.attrs).forEach(o=>{const a=e.attrs[o]||"";o.charAt(0)!=="x"?r.setAttribute(o,a):o.startsWith("xml:")?r.setAttributeNS(qt,o,a):o.startsWith("xlink:")?r.setAttributeNS(Vt,o,a):o.startsWith("xmlns:")?r.setAttributeNS(Ut,o,a):r.setAttribute(o,a)}),Object.keys(e.on).forEach(o=>{Rt(r,o,e)}),At(r,e.props,e.loops),Ct(r,e),kt(r,e),e.elm=r,ht(t,r,n),e.tagName==="foreignObject"&&(s=void 0),e.children.forEach(o=>{Y(r,o,void 0,s)}),typeof e.onMounted=="function"&&requestAnimationFrame(()=>{e.onMounted(r,e.loops||[])})},Y=(t,e,n,s)=>{switch(e.tagName){case"comment":Nt(t,e,n);break;case"text":Jt(t,e,n);break;default:Xt(t,e,n,s);break}},Zt=t=>t&&(t.tagName==="ElseIf"||t.tagName==="comment"),Yt=t=>t&&t.tagName==="Else",q=(t,e,n=[],s="0",r)=>{var i,l,p;let o=0,a=0;for(let u=0;u<e.length;u++){const c=e[u];if(c.tagName==="If"){let h=!1;o++;let m=1;for(((i=c.fn)==null?void 0:i.call(c,n))&&(q(t,c.children,n,`${s}-if-${o}-${m}`,m),h=!0),m++;u+1<e.length&&Zt(e[u+1]);)((p=(l=e[u+1]).fn)==null?void 0:p.call(l,n))&&!h&&(q(t,e[u+1].children,n,`${s}-if-${o}-${m}`,m),h=!0),u++,m++;u+1<e.length&&Yt(e[u+1])&&(h||(q(t,e[u+1].children,n,`${s}-if-${o}-${m}`,m),h=!0),u++)}else if(c.tagName==="For"){a++;const{item:h="item",index:m="index"}=c.attrs;(c.fn(n)||[]).forEach((R,O)=>{const ot={item:h,value:R,index:m,valueIndex:O};q(t,c.children,[...n,ot],`${s}-for-${a}-${O}`,1)})}else{const h={...c,loops:n,children:[],rootId:s,ifId:r,key:c.key||`${s}-${u}`};q(h.children,c.children,n,`${s}-${u}`),t.push(h)}}},St=(t,e,n)=>{var a,i,l,p,u;const s=new Map;e.forEach((c,h)=>s.set(c.key,{node:c,index:h}));let r=0,o=0;for(;r<n.length;){const c=n[r],h=s.get(c.key);if(h){const m=h.node;if(m.tagName!==c.tagName){(a=m.elm)==null||a.remove();const A=(i=e[o+1])==null?void 0:i.elm;Y(t,c,A),s.delete(c.key),o++}else{if(c.ifId&&m.ifId!==c.ifId){(l=m.elm)==null||l.remove();const A=(p=e[o+1])==null?void 0:p.elm;Y(t,c,A)}else Qt(m,c);s.delete(c.key),o++}}else{const m=(u=e[o])==null?void 0:u.elm;Y(t,c,m)}r++}s.forEach(({node:c})=>{var h;return(h=c.elm)==null?void 0:h.remove()})},ft=(t,e,n=[])=>{if(!e||e.length===0)return[];const s=[];return q(s,e||[],[],"0"),St(t,n,s),s},x=t=>{if(t===null||typeof t!="object")return!1;const e=Object.prototype.toString.call(t);return!["[object Function]","[object Date]","[object RegExp]","[object Map]","[object Set]","[object WeakMap]","[object WeakSet]"].includes(e)};function Mt(t=window.location){let e;typeof t=="string"?e=new URL(t).hash:e=t.hash;const n=e.split("?"),s=n[0].substring(2),r=n[1],o={};return r&&r.split("&").forEach(a=>{const[i,l]=a.split("=");i&&l&&(o[decodeURIComponent(i)]=decodeURIComponent(l))}),{path:s.split("/"),query:o}}function pt(t,e,n={}){const s=new WeakMap,r=new WeakSet,o=new WeakMap,{throttle:a=0,deepCompare:i=!1,onBatch:l=null,immediate:p=!1}=n,u=Array.isArray(n.filter)?n.filter:n.filter?[n.filter]:[];let c=[],h=null,m=!0;const A=(f,g,$=new WeakMap)=>{if(f===g)return!0;if(f==null||g==null||typeof f!="object"||typeof g!="object")return f===g;if($.has(f))return $.get(f)===g;if($.set(f,g),Array.isArray(f)&&Array.isArray(g)){if(f.length!==g.length)return!1;for(let y=0;y<f.length;y++)if(!A(f[y],g[y],$))return!1;return!0}if(Array.isArray(f)!==Array.isArray(g))return!1;const k=Object.keys(f),E=Object.keys(g);if(k.length!==E.length)return!1;for(const y of k)if(!Object.prototype.hasOwnProperty.call(g,y)||!A(f[y],g[y],$))return!1;return!0},R=f=>{if(u.length===0)return!0;const g=f.map(String).join(".");return u.some($=>{if(!$)return!0;try{return new RegExp("^"+$.replace(/\./g,"\\.").replace(/\[\*\]/g,"(\\.\\d+)?").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+")+"$").test(g)}catch{return!0}})},O=(f,g,$)=>{m&&R(f)&&(a>0?(c.push({path:f,newValue:g,oldValue:$}),h||(h=setTimeout(()=>{if(!m){h=null;return}const k=c;c=[],h=null,l&&l(k);for(const E of k)e(E.path,E.newValue,E.oldValue)},a))):(e(f,g,$),l&&l([{path:f,newValue:g,oldValue:$}])))},ot=(f,g)=>{if(!x(f)||!(Array.isArray(f)||Object.prototype.toString.call(f)==="[object Object]"))return f;const $={};if(["push","pop","shift","unshift","splice","sort","reverse"].forEach(E=>{const y=Array.prototype[E];$[E]=function(...b){if(!m)return Reflect.apply(y,f,b);const S=[...f],L=y.apply(f,b);return A(f,S)||O(g,f,S),L}}),s.has(f)){const E=s.get(f);return o.set(E,g),E}r.add(f);const k=new Proxy(f,{get(E,y,b){if(Array.isArray(E)&&$.hasOwnProperty(y))return Reflect.get($,y,b);const S=Reflect.get(E,y,b);if(x(S)){const at=[...o.get(k)||[],y],gt=ot(S,at);return o.set(gt,at),gt}return S},set(E,y,b,S){const L=Reflect.get(E,y,S),at=x(b)&&!(b instanceof Date||b instanceof RegExp||b instanceof Map||b instanceof Set);if(i&&at?A(L,b):L===b)return!0;const ae=Reflect.set(E,y,b,S),ie=o.get(k)||g;return O([...ie,y],b,L),ae},deleteProperty(E,y){if(Reflect.has(E,y)){const b=E[y],S=Reflect.deleteProperty(E,y),L=o.get(k)||[];return S&&r.has(E)&&O([...L,y],void 0,b),S}return!1}});return s.set(f,k),o.set(k,g),k},oe=ot(t,[]);if(p){const f=(g,$,k=new WeakSet)=>{if(!(!x(g)||!m||k.has(g))){k.add(g);for(const E of Object.keys(g)){const y=[...$,E],b=g[E];R(y)&&e(y,b,void 0),x(b)&&f(b,y,k)}}};f(t,[])}return{proxy:oe,unobserve:()=>{m&&(m=!1,c=[],h&&(clearTimeout(h),h=null))},resume:()=>{m=!0}}}class te extends HTMLElement{constructor(n={}){var a;super();j(this,_);j(this,z);j(this,Q,[]);j(this,J,[]);j(this,V,!1);j(this,N,!1);j(this,U);j(this,I);const s=this._manifest||{};w(this,U,(a=s.shadowDOM)!=null&&a.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this);const{proxy:r,unobserve:o}=pt(n,()=>D(this,_,G).call(this));w(this,z,r),w(this,I,o),s.template&&typeof s.template=="string"&&w(this,Q,bt(this,s.template)),Promise.resolve().then(()=>this.created())}static get observedAttributes(){const n=this._manifest||this.prototype._manifest;return n!=null&&n.props?n.props.map(s=>typeof s=="string"?s:s.name):[]}get $data(){return M(this,z)}set $data(n){x(n)||(n={}),M(this,I)&&M(this,I).call(this);const{proxy:s,unobserve:r}=pt(n,()=>D(this,_,G).call(this));w(this,z,s),w(this,I,r),D(this,_,G).call(this)}refresh(){D(this,_,G).call(this)}connectedCallback(){const n=this._manifest||{};if((n.className||n.tagName||"").split(" ").forEach(r=>r&&this.classList.add(r)),n.styles&&!M(this,U).querySelector("style[data-manifest-style]")){const r=document.createElement("style");r.setAttribute("data-manifest-style","true"),r.textContent=n.styles,M(this,U).appendChild(r)}if(n.props&&x(this.$data))for(const r of n.props){const o=typeof r=="string"?r:r.name,a=typeof r=="object"&&"type"in r?r.type:void 0,i=o.replace(/-([a-z])/g,(p,u)=>u.toUpperCase()),l=this.$data[i];if(this.hasAttribute(o)){const p=this.getAttribute(o);this.$data[i]=D(this,_,Et).call(this,p,l,a)}}D(this,_,G).call(this)}disconnectedCallback(){var n;this.isConnected&&(this.unmounted(),(n=M(this,I))==null||n.call(this),w(this,I,void 0))}attributeChangedCallback(n,s,r){if(s===r||!x(this.$data))return;const o=n.replace(/-([a-z])/g,(i,l)=>l.toUpperCase()),a=this.$data[o];this.$data[o]=D(this,_,Et).call(this,r,a)}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}}z=new WeakMap,Q=new WeakMap,J=new WeakMap,V=new WeakMap,N=new WeakMap,U=new WeakMap,I=new WeakMap,_=new WeakSet,G=function(){M(this,V)||(w(this,V,!0),vt(()=>{var n;if(!this.isConnected){w(this,V,!1);return}this.beforeUpdate(),w(this,J,ft(M(this,U),M(this,Q),M(this,J))),w(this,V,!1),M(this,N)?this.updated():(w(this,N,!0),this.mounted(),(n=this.onInit)==null||n.call(this))}))},Et=function(n,s,r){if(n===null)return s;switch(r||typeof s){case"number":const a=Number(n);return isNaN(a)?s:a;case"boolean":return n==="true";case"object":try{return JSON.parse(n)}catch{return s}default:return n}};const Pt=t=>e=>{if(customElements.get(t.tagName)){console.warn(`标签名称 "${t.tagName}" 已经被注册`);return}return e.prototype._manifest=ee(t),customElements.define(t.tagName,e),e},ee=t=>(t=Object.assign({hasConfig:!1},t),t);var ne=Object.getOwnPropertyDescriptor,_t=t=>{throw TypeError(t)},se=(t,e,n,s)=>{for(var r=s>1?void 0:s?ne(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},dt=(t,e,n)=>e.has(t)||_t("Cannot "+n),W=(t,e,n)=>(dt(t,e,"read from private field"),n?n.call(t):e.get(t)),T=(t,e,n)=>e.has(t)?_t("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),H=(t,e,n,s)=>(dt(t,e,"write to private field"),e.set(t,n),n),re=(t,e,n)=>(dt(t,e,"access private method"),n),tt,et,nt,K,B,st,rt,mt,xt;function Wt(t){return t instanceof HTMLElement&&t.isRouterView===!0}d.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),T(this,mt),T(this,tt,[]),T(this,et,[]),T(this,nt,null),T(this,K),T(this,B,[]),T(this,st,{}),T(this,rt,this.onHashChange.bind(this))}get isRouterView(){return!0}get $routes(){return W(this,B)}set $routes(e){H(this,B,e),this.onHashChange()}get $remainingPath(){return W(this,et)}get $matchedRoute(){return W(this,nt)}set $pipe(e){H(this,st,e||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",W(this,rt)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",W(this,rt))}onHashChange(){var n;if(!this.isConnected)return;const e=this.findAncestorRouterView();if(e)H(this,K,e.$remainingPath),H(this,B,((n=e.$matchedRoute)==null?void 0:n.children)||[]);else{const{path:s}=Mt(window.location);H(this,K,s)}re(this,mt,xt).call(this)}prepareComponentData(e){const n={},s={};for(const[r,o]of Object.entries(e))n[r]=()=>o;for(const[r,o]of Object.entries(W(this,st))){const a=r.toLowerCase();let i=null;a.startsWith("on-")?i=a.slice(3):a.startsWith("on")&&ct.includes(a.slice(2))&&(i=a.slice(2)),i?s[i]=o:n[r]=()=>o}return{props:n,on:s}}matchRoute(e,n){for(const s of e){const r=s.path.split("/").filter(i=>i),o={};if(r.length>n.length&&!r.includes("*"))continue;let a=!0;for(let i=0;i<r.length;i++){const l=r[i],p=n[i];if(l.startsWith(":"))o[l.substring(1)]=p;else{if(l==="*")return{matchedRoute:s,params:o,remainingPath:[]};if(l!==p){a=!1;break}}}if(a)return{matchedRoute:s,params:o,remainingPath:n.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:n}}propagateToChildRouterViews(e=this){for(const n of e.childNodes)Wt(n)?n.onHashChange():this.propagateToChildRouterViews(n)}findAncestorRouterView(){let e=this.parentElement;for(;e;){if(Wt(e))return e;e=e.parentElement}return null}},tt=new WeakMap,et=new WeakMap,nt=new WeakMap,K=new WeakMap,B=new WeakMap,st=new WeakMap,rt=new WeakMap,mt=new WeakSet,xt=function(){const t=W(this,K)||[],{matchedRoute:e,params:n,remainingPath:s}=this.matchRoute(W(this,B),t);H(this,et,s),H(this,nt,e);const r=(e==null?void 0:e.tagName)||"comment",{props:o,on:a}=this.prepareComponentData(n);H(this,tt,ft(this,[{tagName:r,rootId:"0",attrs:{},props:o,on:a,children:[]}],W(this,tt))),this.propagateToChildRouterViews()},d.RouterViewElement=se([Pt({tagName:"router-view"})],d.RouterViewElement),d.BaseElement=te,d.CustomElement=Pt,d.createFunction=Z,d.isObject=x,d.listeners=ct,d.observe=pt,d.parseHashUrl=Mt,d.parseHtml=bt,d.patch=ft,d.runInAsyncQueue=vt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|