solely 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +901 -836
- package/dist/index.umd.cjs +11 -11
- package/dist/runtime/component/decorators.d.ts +9 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var Xt = Object.defineProperty;
|
|
2
|
+
var Pt = (n) => {
|
|
3
|
+
throw TypeError(n);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
const
|
|
5
|
+
var Qt = (n, t, e) => t in n ? Xt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
6
|
+
var k = (n, t, e) => Qt(n, typeof t != "symbol" ? t + "" : t, e), gt = (n, t, e) => t.has(n) || Pt("Cannot " + e);
|
|
7
|
+
var P = (n, t, e) => (gt(n, t, "read from private field"), e ? e.call(n) : t.get(n)), T = (n, t, e) => t.has(n) ? Pt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), O = (n, t, e, s) => (gt(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), N = (n, t, e) => (gt(n, t, "access private method"), e);
|
|
8
|
+
const te = {
|
|
9
9
|
dark: {
|
|
10
10
|
gutter: "#858585",
|
|
11
11
|
errorLineBg: "#3c1e1e",
|
|
@@ -16,30 +16,31 @@ const se = {
|
|
|
16
16
|
exprLabel: "#a0a0a0",
|
|
17
17
|
exprCode: "#5ddcff"
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
function
|
|
19
|
+
}, W = te.dark;
|
|
20
|
+
function ot(n) {
|
|
21
21
|
let t = 0;
|
|
22
|
-
for (let e = 0; e <
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
22
|
+
for (let e = 0; e < n.length; ) {
|
|
23
|
+
const s = n.codePointAt(e);
|
|
24
|
+
if (n[e] === " ") {
|
|
25
25
|
t += 4, e++;
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
s >= 9472 && s <= 9599 || s > 255 ? t += 2 : t += 1, e += s > 65535 ? 2 : 1;
|
|
29
29
|
}
|
|
30
30
|
return t;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
32
|
+
function Ot(n, t = {}) {
|
|
33
|
+
const { lineIndex: e = 0, totalLines: s = 1 } = t, r = Math.max(1, Math.floor(n));
|
|
34
|
+
return (s <= 1 || e === 0 ? "^" : "~").repeat(r);
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
-
var
|
|
37
|
-
const r = (
|
|
38
|
-
`color:${
|
|
39
|
-
`color:${
|
|
36
|
+
function ee(n, t = "", e, s = "component") {
|
|
37
|
+
var L;
|
|
38
|
+
const r = (n == null ? void 0 : n.message) ?? String(n), o = `%cTemplate Error%c in <${s}> → ${r}`, i = [
|
|
39
|
+
`color:${W.badgeFg};background:${W.badgeBg};padding:4px 10px;border-radius:6px;font-weight:bold;`,
|
|
40
|
+
`color:${W.arrow};font-weight:bold;`
|
|
40
41
|
];
|
|
41
42
|
if (!t || !(e != null && e.loc) || e.loc.length < 2) {
|
|
42
|
-
console.error(
|
|
43
|
+
console.error(o, ...i), e != null && e.expr && console.log(`Expression: ${e.expr.trim()}`);
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
46
|
const c = e.loc;
|
|
@@ -51,106 +52,107 @@ function ne(s, t = "", e, n = "component") {
|
|
|
51
52
|
console.error(`[Template Error] 行号 ${a} 超出范围`);
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
|
-
const h = a - 1,
|
|
55
|
-
`) : [],
|
|
55
|
+
const h = a - 1, d = Math.max(0, h - 3), E = Math.min(u.length - 1, h + 3), m = String(E + 1).length, p = ((L = e.expr) == null ? void 0 : L.trim()) ?? "", R = p ? p.split(`
|
|
56
|
+
`) : [], g = p ? Math.max(...R.map(ot)) : 0, v = R.length > 1, S = `color:${W.gutter};`, A = `color:${W.arrow};font-weight:bold;`, f = `color:${W.gutter};`, w = `color:${W.errorLineFg};background:${W.errorLineBg};padding:0 4px;`, x = `color:${W.gutter};`, b = `color:${W.arrow};font-weight:bold;padding:0 4px;`;
|
|
56
57
|
console.groupCollapsed(
|
|
57
|
-
`${
|
|
58
|
-
...
|
|
59
|
-
`color:${
|
|
58
|
+
`${o} %c(Line:${a}, Col:${l})`,
|
|
59
|
+
...i,
|
|
60
|
+
`color:${W.gutter};font-weight:normal;`
|
|
60
61
|
);
|
|
61
|
-
for (let
|
|
62
|
-
const
|
|
63
|
-
if (!(
|
|
64
|
-
console.log(`%c${
|
|
62
|
+
for (let $ = d; $ <= E; $++) {
|
|
63
|
+
const I = u[$], M = String($ + 1).padStart(m, " ");
|
|
64
|
+
if (!($ === h)) {
|
|
65
|
+
console.log(`%c${M} │%c ${I}`, S, f);
|
|
65
66
|
continue;
|
|
66
67
|
}
|
|
67
|
-
const
|
|
68
|
-
if (console.log(`%c${
|
|
69
|
-
for (let
|
|
70
|
-
const
|
|
71
|
-
let
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
else if (
|
|
75
|
-
const
|
|
76
|
-
|
|
68
|
+
const D = I.slice(0, Math.max(0, l - 1)), F = ot(D), rt = " ".repeat(m + 3), Yt = M.padEnd(m, " ");
|
|
69
|
+
if (console.log(`%c${Yt} │%c ${I}`, A, w), v)
|
|
70
|
+
for (let j = 0; j < R.length; j++) {
|
|
71
|
+
const pt = R[j], Q = h + j;
|
|
72
|
+
let mt = 0;
|
|
73
|
+
if (j === 0)
|
|
74
|
+
mt = F;
|
|
75
|
+
else if (Q < u.length) {
|
|
76
|
+
const tt = u[Q], it = tt.search(/\S/), Jt = it === -1 ? tt : tt.slice(0, it);
|
|
77
|
+
mt = ot(Jt);
|
|
77
78
|
}
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
console.log(`%c${
|
|
81
|
-
else if (
|
|
82
|
-
const
|
|
83
|
-
console.log(`%c${
|
|
79
|
+
const Zt = Math.max(1, ot(pt.trim())), It = Ot(Zt, { lineIndex: j, totalLines: R.length }), Mt = rt + " ".repeat(mt);
|
|
80
|
+
if (j === 0)
|
|
81
|
+
console.log(`%c${Mt}%c${It}`, x, b);
|
|
82
|
+
else if (Q < u.length) {
|
|
83
|
+
const tt = String(Q + 1).padEnd(m, " "), it = u[Q];
|
|
84
|
+
console.log(`%c${tt} │%c ${it}`, A, w), console.log(`%c${Mt}%c${It}`, x, b);
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
else {
|
|
87
|
-
const
|
|
88
|
-
console.log(`%c${
|
|
88
|
+
const j = rt + " ".repeat(F), pt = Ot(g || 1);
|
|
89
|
+
console.log(`%c${j}%c${pt}`, x, b);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
`%cExpression:%c ${
|
|
93
|
-
`color:${
|
|
94
|
-
`color:${
|
|
92
|
+
p && console.log(
|
|
93
|
+
`%cExpression:%c ${p}`,
|
|
94
|
+
`color:${W.exprLabel};font-weight:bold;`,
|
|
95
|
+
`color:${W.exprCode};font-family:monospace;`
|
|
95
96
|
), console.groupEnd();
|
|
96
97
|
}
|
|
97
|
-
const
|
|
98
|
-
function
|
|
99
|
-
const t =
|
|
100
|
-
if (!
|
|
101
|
-
const e =
|
|
98
|
+
const yt = {};
|
|
99
|
+
function ne(n) {
|
|
100
|
+
const t = n.map((e) => e.replace(/[',"]/g, "")).join(",");
|
|
101
|
+
if (!yt[t]) {
|
|
102
|
+
const e = n[n.length - 1];
|
|
102
103
|
if (e.trim() === "")
|
|
103
104
|
throw new Error("Function body cannot be empty");
|
|
104
|
-
if (
|
|
105
|
+
if (re(e))
|
|
105
106
|
throw new Error("Input contains potentially dangerous code: " + e);
|
|
106
|
-
|
|
107
|
+
yt[t] = new Function(...n);
|
|
107
108
|
}
|
|
108
|
-
return
|
|
109
|
+
return yt[t];
|
|
109
110
|
}
|
|
110
|
-
const
|
|
111
|
-
function
|
|
112
|
-
return
|
|
111
|
+
const se = ["eval", "Function", "process", "require"];
|
|
112
|
+
function re(n) {
|
|
113
|
+
return se.some((t) => new RegExp(`\\b${t}\\b`, "g").test(n));
|
|
113
114
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (
|
|
115
|
+
const ie = /\{\{\{\s*[\s\S]*?\s*\}\}\}/, oe = /\{\{\s*([\s\S]*?)\s*\}\}/g;
|
|
116
|
+
function ae(n, t) {
|
|
117
|
+
if (!(n != null && n.trim())) return "";
|
|
118
|
+
if (ie.test(n))
|
|
117
119
|
throw new Error("Illegal interpolation syntax: use {{ }} instead of {{{ }}}");
|
|
118
|
-
return t === "template" ?
|
|
120
|
+
return t === "template" ? n.replace(oe, (e, s) => `\${${s.trim()}}`) : n;
|
|
119
121
|
}
|
|
120
|
-
function ce(
|
|
121
|
-
const e = (
|
|
122
|
+
function ce(n, t) {
|
|
123
|
+
const e = (s) => s.endsWith(";") ? s : s + ";";
|
|
122
124
|
switch (t) {
|
|
123
125
|
case "template":
|
|
124
|
-
return `return \`${
|
|
126
|
+
return `return \`${n}\`;`;
|
|
125
127
|
case "expression":
|
|
126
|
-
return `return (${
|
|
128
|
+
return `return (${n});`;
|
|
127
129
|
case "handler":
|
|
128
130
|
case "lifecycle":
|
|
129
|
-
return e(
|
|
131
|
+
return e(n);
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
|
-
function le(
|
|
133
|
-
if (!
|
|
134
|
-
const t =
|
|
134
|
+
function le(n) {
|
|
135
|
+
if (!n.length) return { loopValues: "", loopIndices: "" };
|
|
136
|
+
const t = n.map((s) => s.item).join(", "), e = n.map((s) => s.index).join(", ");
|
|
135
137
|
return {
|
|
136
138
|
loopValues: `var [${t}] = loops.map(l => l.itmVal);`,
|
|
137
139
|
loopIndices: `var [${e}] = loops.map(l => l.idxVal);`
|
|
138
140
|
};
|
|
139
141
|
}
|
|
140
|
-
function ue(
|
|
141
|
-
const r =
|
|
142
|
+
function ue(n, t, e, s) {
|
|
143
|
+
const r = n === "lifecycle" ? ["el", "loops"] : n === "handler" ? ["event", "loops"] : ["loops"], i = `
|
|
142
144
|
const { $data } = this;
|
|
143
|
-
${
|
|
145
|
+
${n === "handler" ? "const { value, checked } = event?.target || {};" : ""}
|
|
144
146
|
${e}
|
|
145
|
-
${
|
|
147
|
+
${s}
|
|
146
148
|
${t}
|
|
147
149
|
`.replace(/^\s+|\s+$/gm, "");
|
|
148
|
-
return r.push(
|
|
150
|
+
return r.push(i), r;
|
|
149
151
|
}
|
|
150
|
-
function he(
|
|
151
|
-
if (!(
|
|
152
|
-
const
|
|
153
|
-
return
|
|
152
|
+
function he(n, t, e) {
|
|
153
|
+
if (!(n != null && n.trim())) return () => "";
|
|
154
|
+
const s = ae(n, t), r = ce(s, t), { loopValues: o, loopIndices: i } = le(e), c = ue(t, r, o, i);
|
|
155
|
+
return ne(c);
|
|
154
156
|
}
|
|
155
157
|
const fe = /* @__PURE__ */ new Set([
|
|
156
158
|
"onabort",
|
|
@@ -215,9 +217,9 @@ const fe = /* @__PURE__ */ new Set([
|
|
|
215
217
|
"ontoggle",
|
|
216
218
|
"onvolumechange",
|
|
217
219
|
"onwaiting"
|
|
218
|
-
]),
|
|
219
|
-
if (
|
|
220
|
-
const t = Object.prototype.toString.call(
|
|
220
|
+
]), K = (n) => {
|
|
221
|
+
if (n === null || typeof n != "object") return !1;
|
|
222
|
+
const t = Object.prototype.toString.call(n);
|
|
221
223
|
return ![
|
|
222
224
|
"[object Function]",
|
|
223
225
|
"[object Date]",
|
|
@@ -228,39 +230,39 @@ const fe = /* @__PURE__ */ new Set([
|
|
|
228
230
|
"[object WeakSet]"
|
|
229
231
|
].includes(t);
|
|
230
232
|
};
|
|
231
|
-
function
|
|
233
|
+
function Ye(n = window.location) {
|
|
232
234
|
let t;
|
|
233
|
-
typeof
|
|
235
|
+
typeof n == "string" ? t = new URL(n).hash : t = n.hash;
|
|
234
236
|
const e = t.split("?");
|
|
235
|
-
let
|
|
236
|
-
const r = e[1],
|
|
237
|
-
return
|
|
238
|
-
const [c, a] =
|
|
239
|
-
c && a && (
|
|
237
|
+
let s = e[0];
|
|
238
|
+
const r = e[1], o = {};
|
|
239
|
+
return s = s.replace(/^#\/?/, ""), r && r.split("&").forEach((i) => {
|
|
240
|
+
const [c, a] = i.split("=");
|
|
241
|
+
c && a && (o[decodeURIComponent(c)] = decodeURIComponent(a));
|
|
240
242
|
}), {
|
|
241
|
-
path:
|
|
243
|
+
path: s.split("/").filter(Boolean),
|
|
242
244
|
// 将路径分割成数组并过滤空字符串
|
|
243
|
-
query:
|
|
245
|
+
query: o
|
|
244
246
|
// 查询参数对象
|
|
245
247
|
};
|
|
246
248
|
}
|
|
247
|
-
var
|
|
249
|
+
var y = /* @__PURE__ */ ((n) => (n[n.Element = 0] = "Element", n[n.Text = 1] = "Text", n[n.Comment = 2] = "Comment", n[n.If = 3] = "If", n[n.ElseIf = 4] = "ElseIf", n[n.Else = 5] = "Else", n[n.For = 6] = "For", n[n.Conditional = 7] = "Conditional", n[n.Other = 99] = "Other", n))(y || {});
|
|
248
250
|
const de = {
|
|
249
251
|
// 可选别名
|
|
250
252
|
onMounted: "mounted",
|
|
251
253
|
onUpdated: "updated",
|
|
252
254
|
onUnmounted: "unmounted"
|
|
253
255
|
};
|
|
254
|
-
function pe(
|
|
255
|
-
return de[
|
|
256
|
+
function pe(n) {
|
|
257
|
+
return de[n] ?? null;
|
|
256
258
|
}
|
|
257
|
-
function me(
|
|
258
|
-
return
|
|
259
|
+
function me(n) {
|
|
260
|
+
return n === "mounted" || n === "updated" || n === "unmounted";
|
|
259
261
|
}
|
|
260
|
-
const
|
|
262
|
+
const vt = Symbol.for("solely.irMeta"), X = process.env.NODE_ENV !== "production", ge = /\{\{[\s\S]*?\}\}/;
|
|
261
263
|
class ye {
|
|
262
264
|
constructor() {
|
|
263
|
-
|
|
265
|
+
k(this, "compilers", /* @__PURE__ */ new Map());
|
|
264
266
|
}
|
|
265
267
|
get(t = "anonymous") {
|
|
266
268
|
let e = this.compilers.get(t);
|
|
@@ -271,36 +273,36 @@ class ye {
|
|
|
271
273
|
if (t)
|
|
272
274
|
(e = this.compilers.get(t)) == null || e.clear(), this.compilers.delete(t);
|
|
273
275
|
else {
|
|
274
|
-
for (const
|
|
276
|
+
for (const s of this.compilers.values()) s.clear();
|
|
275
277
|
this.compilers.clear();
|
|
276
278
|
}
|
|
277
279
|
}
|
|
278
280
|
}
|
|
279
|
-
const
|
|
281
|
+
const Wt = new ye();
|
|
280
282
|
class be {
|
|
281
283
|
constructor() {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
k(this, "cache", /* @__PURE__ */ new Map());
|
|
285
|
+
k(this, "functions", []);
|
|
284
286
|
}
|
|
285
287
|
// 缓存 key 生成优化:避免每次都重新分配数组
|
|
286
|
-
makeCacheKey(t, e,
|
|
287
|
-
if (
|
|
288
|
-
const r =
|
|
288
|
+
makeCacheKey(t, e, s) {
|
|
289
|
+
if (s.length === 0) return `${t}:${e}`;
|
|
290
|
+
const r = s.map((o) => Object.keys(o).sort().join(",")).join(";");
|
|
289
291
|
return `${t}:${e}:${r}`;
|
|
290
292
|
}
|
|
291
|
-
compile(t, e,
|
|
293
|
+
compile(t, e, s) {
|
|
292
294
|
const r = e == null ? void 0 : e.trim();
|
|
293
295
|
if (!r) return 0;
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
+
const o = this.makeCacheKey(t, r, s), i = this.cache.get(o);
|
|
297
|
+
if (i !== void 0) return i;
|
|
296
298
|
let c;
|
|
297
299
|
try {
|
|
298
|
-
c = he(r, t,
|
|
300
|
+
c = he(r, t, s);
|
|
299
301
|
} catch (l) {
|
|
300
|
-
|
|
302
|
+
X && console.error(`[IR Compile Error] Type: ${t}, Expr: "${r}"`, l), c = () => "";
|
|
301
303
|
}
|
|
302
304
|
const a = this.functions.push(c);
|
|
303
|
-
return this.cache.set(
|
|
305
|
+
return this.cache.set(o, a), a;
|
|
304
306
|
}
|
|
305
307
|
getFunctions() {
|
|
306
308
|
return this.functions;
|
|
@@ -312,29 +314,29 @@ class be {
|
|
|
312
314
|
this.cache.clear(), this.functions = [];
|
|
313
315
|
}
|
|
314
316
|
}
|
|
315
|
-
function
|
|
316
|
-
const t =
|
|
317
|
-
return t === ":" ? { isDynamic: !0, type: "expression" } : t === "@" ? { isDynamic: !0, type: "handler" } : me(
|
|
317
|
+
function Ft(n) {
|
|
318
|
+
const t = n[0];
|
|
319
|
+
return t === ":" ? { isDynamic: !0, type: "expression" } : t === "@" ? { isDynamic: !0, type: "handler" } : me(n) ? { isDynamic: !0, type: "lifecycle" } : { isDynamic: !1, type: null };
|
|
318
320
|
}
|
|
319
|
-
function we(
|
|
320
|
-
return
|
|
321
|
+
function we(n) {
|
|
322
|
+
return n ? ge.test(n) : !1;
|
|
321
323
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
324
|
+
function xt(n, t, e) {
|
|
325
|
+
X && (n[vt] = { expr: t ?? "", loc: e ?? null });
|
|
324
326
|
}
|
|
325
|
-
function
|
|
326
|
-
if (!
|
|
327
|
-
const t =
|
|
327
|
+
function Ee(n) {
|
|
328
|
+
if (!n.attrs) return;
|
|
329
|
+
const t = n.attrs.find((a) => a.key === "s-model");
|
|
328
330
|
if (!t) return;
|
|
329
|
-
const e = "$data." + t.value.replace("this.", "").replace("$data.", ""),
|
|
330
|
-
|
|
331
|
+
const e = "$data." + t.value.replace("this.", "").replace("$data.", ""), s = t.loc, r = (n.tag || "").toLowerCase(), o = n.attrs.find((a) => a.key === "type"), i = (o == null ? void 0 : o.value) ?? "text";
|
|
332
|
+
n.attrs = n.attrs.filter((a) => a !== t);
|
|
331
333
|
const c = (a, l, u) => {
|
|
332
334
|
var h;
|
|
333
|
-
(h =
|
|
335
|
+
(h = n.attrs) == null || h.push({ key: a, value: l, role: u, loc: s });
|
|
334
336
|
};
|
|
335
337
|
if (r === "input") {
|
|
336
|
-
if (
|
|
337
|
-
const a =
|
|
338
|
+
if (i === "checkbox") {
|
|
339
|
+
const a = n.attrs.find((d) => d.key === "value"), l = a ? JSON.stringify(a.value) : '"on"', u = `Array.isArray(${e}) ? ${e}.includes(${l}) : ${e}`;
|
|
338
340
|
c(":checked", u);
|
|
339
341
|
const h = `
|
|
340
342
|
const _v = ${l};
|
|
@@ -348,8 +350,8 @@ function ve(s) {
|
|
|
348
350
|
c("@change", h, "model");
|
|
349
351
|
return;
|
|
350
352
|
}
|
|
351
|
-
if (
|
|
352
|
-
const a =
|
|
353
|
+
if (i === "radio") {
|
|
354
|
+
const a = n.attrs.find((u) => u.key === "value"), l = (a == null ? void 0 : a.value) ?? "null";
|
|
353
355
|
c(":checked", `${e} == ${JSON.stringify(l)}`), c("@change", `if (checked) ${e} = ${JSON.stringify(l)}`, "model");
|
|
354
356
|
return;
|
|
355
357
|
}
|
|
@@ -361,7 +363,7 @@ function ve(s) {
|
|
|
361
363
|
return;
|
|
362
364
|
}
|
|
363
365
|
if (r === "select") {
|
|
364
|
-
|
|
366
|
+
n.attrs.some((l) => l.key === "multiple") ? (c("updated", `
|
|
365
367
|
const values = Array.isArray(${e}) ? ${e} : ${e} != null ? [${e}] : [];
|
|
366
368
|
for (const opt of el.options) {
|
|
367
369
|
opt.selected = values.includes(opt.value);
|
|
@@ -370,124 +372,124 @@ function ve(s) {
|
|
|
370
372
|
}
|
|
371
373
|
c(":value", e), c("@input", `${e} = $event`, "model");
|
|
372
374
|
}
|
|
373
|
-
function
|
|
374
|
-
if (!
|
|
375
|
+
function lt(n, t, e, s = null) {
|
|
376
|
+
if (!n.attrs || n.attrs.length === 0) return [];
|
|
375
377
|
const r = [];
|
|
376
|
-
for (const
|
|
377
|
-
if (
|
|
378
|
-
const { key:
|
|
378
|
+
for (const o of n.attrs) {
|
|
379
|
+
if (s && s.has(o.key)) continue;
|
|
380
|
+
const { key: i, value: c, role: a } = o, { isDynamic: l, type: u } = Ft(i);
|
|
379
381
|
if (l && u) {
|
|
380
|
-
const h = e.compile(u, c ?? "", t),
|
|
381
|
-
|
|
382
|
+
const h = e.compile(u, c ?? "", t), d = { key: i, fid: h, dynamic: 1, role: a };
|
|
383
|
+
xt(d, c, o.loc ?? n.loc), r.push(d);
|
|
382
384
|
} else
|
|
383
|
-
r.push({ key:
|
|
385
|
+
r.push({ key: i, value: c, dynamic: 0, role: a });
|
|
384
386
|
}
|
|
385
387
|
return r;
|
|
386
388
|
}
|
|
387
|
-
function
|
|
388
|
-
var
|
|
389
|
-
const
|
|
389
|
+
function ve(n, t, e) {
|
|
390
|
+
var o, i, c, a, l, u;
|
|
391
|
+
const s = { type: n.type, dynamic: 0 };
|
|
390
392
|
let r = !1;
|
|
391
|
-
switch (
|
|
392
|
-
case
|
|
393
|
-
const h =
|
|
394
|
-
r ? (
|
|
393
|
+
switch (n.type === y.Text ? we(n.content) && (r = !0) : ((o = n.attrs) != null && o.some((h) => h.key === "s-model" || Ft(h.key).isDynamic) && (r = !0), n.type === y.For && (r = !0)), s.dynamic = r ? 1 : 0, n.type) {
|
|
394
|
+
case y.Text: {
|
|
395
|
+
const h = n.content ?? "";
|
|
396
|
+
r ? (s.fid = e.compile("template", h, t), xt(s, h, n.loc)) : s.txt = h;
|
|
395
397
|
break;
|
|
396
398
|
}
|
|
397
|
-
case
|
|
398
|
-
|
|
399
|
+
case y.Element: {
|
|
400
|
+
s.tag = n.tag, Ee(n), s.attrs = lt(n, t, e), n.children && (s.children = et(n.children, t, e));
|
|
399
401
|
break;
|
|
400
402
|
}
|
|
401
|
-
case
|
|
402
|
-
const h = (
|
|
403
|
-
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
const m = [...t, { item:
|
|
407
|
-
|
|
403
|
+
case y.For: {
|
|
404
|
+
const h = (i = n.attrs) == null ? void 0 : i.find((p) => p.key === "each"), d = (h == null ? void 0 : h.value) ?? "";
|
|
405
|
+
s.fid = e.compile("expression", d, t), s.item = ((a = (c = n.attrs) == null ? void 0 : c.find((p) => p.key === "item")) == null ? void 0 : a.value) ?? "item", s.index = ((u = (l = n.attrs) == null ? void 0 : l.find((p) => p.key === "index")) == null ? void 0 : u.value) ?? "index", xt(s, d, (h == null ? void 0 : h.loc) ?? n.loc);
|
|
406
|
+
const E = /* @__PURE__ */ new Set(["each", "item", "index"]);
|
|
407
|
+
s.attrs = lt(n, t, e, E);
|
|
408
|
+
const m = [...t, { item: s.item, index: s.index }];
|
|
409
|
+
n.children && (s.children = et(n.children, m, e));
|
|
408
410
|
break;
|
|
409
411
|
}
|
|
410
|
-
case
|
|
411
|
-
case
|
|
412
|
-
case
|
|
413
|
-
|
|
412
|
+
case y.If:
|
|
413
|
+
case y.ElseIf:
|
|
414
|
+
case y.Else: {
|
|
415
|
+
X && console.warn(`[IR] Orphaned conditional node found: ${y[n.type]}`), s.attrs = lt(n, t, e), n.children && (s.children = et(n.children, t, e));
|
|
414
416
|
break;
|
|
415
417
|
}
|
|
416
|
-
case
|
|
417
|
-
|
|
418
|
+
case y.Comment: {
|
|
419
|
+
s.txt = n.content ?? "";
|
|
418
420
|
break;
|
|
419
421
|
}
|
|
420
422
|
}
|
|
421
|
-
return
|
|
423
|
+
return s;
|
|
422
424
|
}
|
|
423
|
-
function
|
|
424
|
-
var
|
|
425
|
-
const
|
|
425
|
+
function et(n, t, e) {
|
|
426
|
+
var o;
|
|
427
|
+
const s = [];
|
|
426
428
|
let r = 0;
|
|
427
|
-
for (; r <
|
|
428
|
-
const
|
|
429
|
-
if (
|
|
429
|
+
for (; r < n.length; ) {
|
|
430
|
+
const i = n[r];
|
|
431
|
+
if (i.type === y.If) {
|
|
430
432
|
const c = [];
|
|
431
433
|
let a = r;
|
|
432
|
-
for (; a <
|
|
433
|
-
const l =
|
|
434
|
-
if (u !==
|
|
434
|
+
for (; a < n.length; ) {
|
|
435
|
+
const l = n[a], u = l.type;
|
|
436
|
+
if (u !== y.If && u !== y.ElseIf && u !== y.Else || u === y.If && c.length > 0)
|
|
435
437
|
break;
|
|
436
|
-
let h = null,
|
|
437
|
-
if (u !==
|
|
438
|
-
const
|
|
439
|
-
(
|
|
438
|
+
let h = null, d = "", E = null;
|
|
439
|
+
if (u !== y.Else) {
|
|
440
|
+
const g = (o = l.attrs) == null ? void 0 : o.find(
|
|
441
|
+
(v) => v.key === "test" || v.key === "condition"
|
|
440
442
|
);
|
|
441
|
-
|
|
443
|
+
d = (g == null ? void 0 : g.value) ?? "false", h = e.compile("expression", d, t), E = (g == null ? void 0 : g.loc) ?? l.loc;
|
|
442
444
|
}
|
|
443
|
-
const
|
|
445
|
+
const m = l.children ? et(l.children, t, e) : [], R = lt(l, t, e, /* @__PURE__ */ new Set(["test", "condition"]));
|
|
444
446
|
if (c.push({
|
|
445
447
|
condFid: h,
|
|
446
|
-
children:
|
|
447
|
-
attrs:
|
|
448
|
-
[
|
|
449
|
-
}), a++, u ===
|
|
448
|
+
children: m,
|
|
449
|
+
attrs: R.length > 0 ? R : void 0,
|
|
450
|
+
[vt]: X ? { expr: d, loc: E } : void 0
|
|
451
|
+
}), a++, u === y.Else) break;
|
|
450
452
|
}
|
|
451
|
-
|
|
452
|
-
type:
|
|
453
|
+
s.push({
|
|
454
|
+
type: y.Conditional,
|
|
453
455
|
dynamic: 1,
|
|
454
456
|
branches: c,
|
|
455
|
-
...
|
|
457
|
+
...X && { [vt]: { loc: i.loc } }
|
|
456
458
|
}), r = a;
|
|
457
459
|
} else
|
|
458
|
-
|
|
460
|
+
s.push(ve(i, t, e)), r++;
|
|
459
461
|
}
|
|
460
|
-
return
|
|
462
|
+
return s;
|
|
461
463
|
}
|
|
462
|
-
function xe(
|
|
463
|
-
const { filename: e = "anonymous", source:
|
|
464
|
+
function xe(n, t = {}) {
|
|
465
|
+
const { filename: e = "anonymous", source: s } = t, r = Wt.get(e);
|
|
464
466
|
r.clear();
|
|
465
|
-
const
|
|
467
|
+
const o = performance.now(), i = et(n, [], r), c = performance.now(), a = r.getStats(), l = i.filter((h) => h.dynamic === 1).length, u = {
|
|
466
468
|
type: "root",
|
|
467
469
|
version: "1.1.0",
|
|
468
470
|
// Bump version
|
|
469
471
|
functions: r.getFunctions(),
|
|
470
472
|
// 获取函数列表快照
|
|
471
|
-
nodes:
|
|
473
|
+
nodes: i,
|
|
472
474
|
stats: {
|
|
473
475
|
totalFunctions: a.total,
|
|
474
476
|
cachedFunctions: a.cached,
|
|
475
477
|
dynamicNodes: l,
|
|
476
|
-
totalNodes:
|
|
478
|
+
totalNodes: i.length
|
|
477
479
|
},
|
|
478
480
|
metadata: {
|
|
479
481
|
compiledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
480
|
-
astSize:
|
|
482
|
+
astSize: n.length,
|
|
481
483
|
filename: e,
|
|
482
|
-
...
|
|
484
|
+
...s && { source: s }
|
|
483
485
|
}
|
|
484
486
|
};
|
|
485
|
-
return
|
|
486
|
-
`[IRBuilder] ${e} | ${(c -
|
|
487
|
+
return X && console.log(
|
|
488
|
+
`[IRBuilder] ${e} | ${(c - o).toFixed(2)}ms | Nodes: ${i.length} | Fns: ${a.total}`
|
|
487
489
|
), u;
|
|
488
490
|
}
|
|
489
|
-
function
|
|
490
|
-
|
|
491
|
+
function Ze(n) {
|
|
492
|
+
Wt.clear(n);
|
|
491
493
|
}
|
|
492
494
|
const $e = /<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/, Se = /* @__PURE__ */ new Set([
|
|
493
495
|
"area",
|
|
@@ -505,96 +507,96 @@ const $e = /<\/?([A-Za-z][A-Za-z0-9\-\:]*)[>\s\/]/, Se = /* @__PURE__ */ new Set
|
|
|
505
507
|
"track",
|
|
506
508
|
"wbr"
|
|
507
509
|
]), ke = /\s*([^\s"'/>=]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gs;
|
|
508
|
-
function Ce(
|
|
510
|
+
function Ce(n, t) {
|
|
509
511
|
const e = [];
|
|
510
|
-
let
|
|
511
|
-
const r =
|
|
512
|
-
for (; (
|
|
513
|
-
const
|
|
514
|
-
if (!
|
|
515
|
-
const c =
|
|
516
|
-
let a =
|
|
517
|
-
fe.has(
|
|
518
|
-
const l =
|
|
512
|
+
let s;
|
|
513
|
+
const r = n.replace(/^\s*[^\s"'/>]+/, ""), o = n.length - r.length;
|
|
514
|
+
for (; (s = ke.exec(r)) !== null; ) {
|
|
515
|
+
const i = s[1];
|
|
516
|
+
if (!i) continue;
|
|
517
|
+
const c = s[2] ?? s[3] ?? s[4] ?? "";
|
|
518
|
+
let a = i;
|
|
519
|
+
fe.has(i) && (a = a.replace(/^on/, "@")), a !== "s-model" && (a = a.replace(/^on-/, "@").replace(/^s-/, ":")), a = pe(a) || a;
|
|
520
|
+
const l = s[0], u = l.indexOf("=");
|
|
519
521
|
let h;
|
|
520
522
|
if (u === -1)
|
|
521
|
-
h = l.indexOf(
|
|
523
|
+
h = l.indexOf(i) + i.length;
|
|
522
524
|
else {
|
|
523
|
-
let
|
|
524
|
-
for (;
|
|
525
|
-
if (l[
|
|
526
|
-
let
|
|
527
|
-
for (;
|
|
528
|
-
|
|
529
|
-
h =
|
|
525
|
+
let g = u + 1;
|
|
526
|
+
for (; g < l.length && /\s/.test(l[g]); ) g++;
|
|
527
|
+
if (l[g] === '"' || l[g] === "'") {
|
|
528
|
+
let v = g + 1;
|
|
529
|
+
for (; v < l.length && /\s/.test(l[v]); )
|
|
530
|
+
v++;
|
|
531
|
+
h = v;
|
|
530
532
|
} else {
|
|
531
|
-
let
|
|
532
|
-
for (;
|
|
533
|
-
h =
|
|
533
|
+
let v = g;
|
|
534
|
+
for (; v < l.length && /\s/.test(l[v]); ) v++;
|
|
535
|
+
h = v;
|
|
534
536
|
}
|
|
535
537
|
}
|
|
536
|
-
let
|
|
537
|
-
const m =
|
|
538
|
-
`),
|
|
539
|
-
e.push({ key: a, value: c, loc: [
|
|
538
|
+
let d = s.index + h + o;
|
|
539
|
+
const m = n.slice(0, d).split(`
|
|
540
|
+
`), p = t[0] + m.length - 1, R = m.length > 1 ? m[m.length - 1].length + 1 : t[1] + d;
|
|
541
|
+
e.push({ key: a, value: c, loc: [p, R] });
|
|
540
542
|
}
|
|
541
543
|
return e;
|
|
542
544
|
}
|
|
543
|
-
function Re(
|
|
544
|
-
var
|
|
545
|
-
const e = ((
|
|
545
|
+
function Re(n, t) {
|
|
546
|
+
var i;
|
|
547
|
+
const e = ((i = (n.match($e) || [])[1]) == null ? void 0 : i.toLowerCase()) ?? "", s = Ce(n, t);
|
|
546
548
|
return {
|
|
547
549
|
type: {
|
|
548
|
-
for:
|
|
549
|
-
if:
|
|
550
|
-
elseif:
|
|
551
|
-
else:
|
|
552
|
-
}[e] ??
|
|
550
|
+
for: y.For,
|
|
551
|
+
if: y.If,
|
|
552
|
+
elseif: y.ElseIf,
|
|
553
|
+
else: y.Else
|
|
554
|
+
}[e] ?? y.Element,
|
|
553
555
|
tag: e,
|
|
554
556
|
loc: t,
|
|
555
557
|
children: [],
|
|
556
|
-
attrs:
|
|
558
|
+
attrs: s
|
|
557
559
|
};
|
|
558
560
|
}
|
|
559
|
-
function
|
|
560
|
-
const e =
|
|
561
|
-
if (
|
|
562
|
-
const
|
|
563
|
-
return
|
|
564
|
-
}
|
|
565
|
-
if (
|
|
566
|
-
const
|
|
567
|
-
return
|
|
568
|
-
}
|
|
569
|
-
if (
|
|
570
|
-
return
|
|
571
|
-
if (
|
|
572
|
-
const
|
|
573
|
-
return
|
|
574
|
-
}
|
|
575
|
-
let
|
|
576
|
-
for (;
|
|
577
|
-
const
|
|
578
|
-
if (
|
|
579
|
-
|
|
580
|
-
else if (
|
|
561
|
+
function Ae(n, t) {
|
|
562
|
+
const e = n.length;
|
|
563
|
+
if (n.startsWith("!--", t)) {
|
|
564
|
+
const i = n.indexOf("-->", t + 3);
|
|
565
|
+
return i === -1 ? -1 : i + 2;
|
|
566
|
+
}
|
|
567
|
+
if (n.startsWith("![CDATA[", t)) {
|
|
568
|
+
const i = n.indexOf("]]>", t + 8);
|
|
569
|
+
return i === -1 ? -1 : i + 2;
|
|
570
|
+
}
|
|
571
|
+
if (n[t] === "!")
|
|
572
|
+
return n.indexOf(">", t + 1);
|
|
573
|
+
if (n[t] === "?") {
|
|
574
|
+
const i = n.indexOf("?>", t + 1);
|
|
575
|
+
return i === -1 ? -1 : i + 1;
|
|
576
|
+
}
|
|
577
|
+
let s = !1, r = !1, o = t;
|
|
578
|
+
for (; o < e; ) {
|
|
579
|
+
const i = n[o];
|
|
580
|
+
if (i === "'" && !r)
|
|
581
|
+
s = !s;
|
|
582
|
+
else if (i === '"' && !s)
|
|
581
583
|
r = !r;
|
|
582
|
-
else if (
|
|
583
|
-
return
|
|
584
|
-
|
|
584
|
+
else if (i === ">" && !s && !r)
|
|
585
|
+
return o;
|
|
586
|
+
o++;
|
|
585
587
|
}
|
|
586
588
|
return -1;
|
|
587
589
|
}
|
|
588
|
-
function
|
|
590
|
+
function Le(n) {
|
|
589
591
|
const t = [];
|
|
590
|
-
if (!
|
|
591
|
-
const e = [],
|
|
592
|
+
if (!n) return [];
|
|
593
|
+
const e = [], s = [], r = () => {
|
|
592
594
|
var l;
|
|
593
595
|
return e.length === 0 ? t : (l = e[e.length - 1]).children || (l.children = []);
|
|
594
596
|
};
|
|
595
|
-
let
|
|
596
|
-
const
|
|
597
|
-
for (let l = 0; l <
|
|
597
|
+
let o = 0;
|
|
598
|
+
const i = n.length, c = [0];
|
|
599
|
+
for (let l = 0; l < i; l++) n[l] === `
|
|
598
600
|
` && c.push(l + 1);
|
|
599
601
|
function a(l) {
|
|
600
602
|
let u = 0;
|
|
@@ -602,78 +604,78 @@ function Ae(s) {
|
|
|
602
604
|
u = h;
|
|
603
605
|
return [u + 1, l - c[u] + 1];
|
|
604
606
|
}
|
|
605
|
-
for (;
|
|
606
|
-
const l =
|
|
607
|
-
if (l === -1 || l >
|
|
608
|
-
const S =
|
|
607
|
+
for (; o < i; ) {
|
|
608
|
+
const l = n.indexOf("<", o);
|
|
609
|
+
if (l === -1 || l > o) {
|
|
610
|
+
const S = n.substring(o, l === -1 ? void 0 : l), A = S.trim();
|
|
609
611
|
if (A) {
|
|
610
|
-
const f = S.indexOf(A), w =
|
|
612
|
+
const f = S.indexOf(A), w = o + f, x = a(w);
|
|
611
613
|
r().push({
|
|
612
|
-
type:
|
|
614
|
+
type: y.Text,
|
|
613
615
|
tag: "text",
|
|
614
616
|
content: A,
|
|
615
|
-
loc:
|
|
617
|
+
loc: x,
|
|
616
618
|
children: []
|
|
617
619
|
});
|
|
618
620
|
}
|
|
619
621
|
if (l === -1) break;
|
|
620
|
-
|
|
622
|
+
o = l;
|
|
621
623
|
}
|
|
622
|
-
const u =
|
|
624
|
+
const u = Ae(n, o + 1);
|
|
623
625
|
if (u === -1) {
|
|
624
|
-
const S =
|
|
626
|
+
const S = n.substring(o);
|
|
625
627
|
S.trim() && r().push({
|
|
626
|
-
type:
|
|
628
|
+
type: y.Text,
|
|
627
629
|
tag: "text",
|
|
628
630
|
content: S.trim(),
|
|
629
631
|
children: [],
|
|
630
|
-
loc: a(
|
|
632
|
+
loc: a(o)
|
|
631
633
|
});
|
|
632
634
|
break;
|
|
633
635
|
}
|
|
634
|
-
const h =
|
|
636
|
+
const h = n.substring(o, u + 1), d = r(), E = a(o);
|
|
635
637
|
if (h.startsWith("<!--")) {
|
|
636
|
-
|
|
637
|
-
type:
|
|
638
|
+
d.push({
|
|
639
|
+
type: y.Comment,
|
|
638
640
|
tag: "comment",
|
|
639
641
|
content: h.slice(4, -3),
|
|
640
|
-
loc:
|
|
642
|
+
loc: E,
|
|
641
643
|
children: []
|
|
642
|
-
}),
|
|
644
|
+
}), o = u + 1;
|
|
643
645
|
continue;
|
|
644
646
|
}
|
|
645
647
|
if (h.startsWith("<![CDATA[")) {
|
|
646
|
-
|
|
647
|
-
type:
|
|
648
|
+
d.push({
|
|
649
|
+
type: y.Text,
|
|
648
650
|
tag: "text",
|
|
649
651
|
content: h.slice(9, -3),
|
|
650
|
-
loc:
|
|
652
|
+
loc: E,
|
|
651
653
|
children: []
|
|
652
|
-
}),
|
|
654
|
+
}), o = u + 1;
|
|
653
655
|
continue;
|
|
654
656
|
}
|
|
655
657
|
if (h.startsWith("<!") && !h.startsWith("<!--")) {
|
|
656
|
-
|
|
657
|
-
type:
|
|
658
|
+
d.push({
|
|
659
|
+
type: y.Comment,
|
|
658
660
|
tag: "comment",
|
|
659
661
|
content: h.slice(2, -1),
|
|
660
|
-
loc:
|
|
662
|
+
loc: E,
|
|
661
663
|
children: []
|
|
662
|
-
}),
|
|
664
|
+
}), o = u + 1;
|
|
663
665
|
continue;
|
|
664
666
|
}
|
|
665
667
|
if (h.startsWith("<?")) {
|
|
666
|
-
|
|
667
|
-
type:
|
|
668
|
+
d.push({
|
|
669
|
+
type: y.Comment,
|
|
668
670
|
tag: "comment",
|
|
669
671
|
content: h.slice(2, -2),
|
|
670
|
-
loc:
|
|
672
|
+
loc: E,
|
|
671
673
|
children: []
|
|
672
|
-
}),
|
|
674
|
+
}), o = u + 1;
|
|
673
675
|
continue;
|
|
674
676
|
}
|
|
675
677
|
if (h.startsWith("</")) {
|
|
676
|
-
const S =
|
|
678
|
+
const S = s.pop();
|
|
677
679
|
for (; e.length > 0; ) {
|
|
678
680
|
if ((e[e.length - 1].tag || "").toLowerCase() === (S == null ? void 0 : S.toLowerCase())) {
|
|
679
681
|
e.pop();
|
|
@@ -681,168 +683,168 @@ function Ae(s) {
|
|
|
681
683
|
}
|
|
682
684
|
e.pop();
|
|
683
685
|
}
|
|
684
|
-
|
|
686
|
+
o = u + 1;
|
|
685
687
|
continue;
|
|
686
688
|
}
|
|
687
|
-
const m = Re(h,
|
|
688
|
-
|
|
689
|
-
const
|
|
690
|
-
if ((
|
|
691
|
-
const S = `</${
|
|
689
|
+
const m = Re(h, E);
|
|
690
|
+
d.push(m);
|
|
691
|
+
const p = m.tag || "", R = p.toLowerCase().startsWith("script"), g = p.toLowerCase().startsWith("style"), v = h.endsWith("/>") || Se.has(p.toLowerCase());
|
|
692
|
+
if ((R || g) && !v) {
|
|
693
|
+
const S = `</${p}>`, A = n.toLowerCase().indexOf(S, u + 1);
|
|
692
694
|
if (A !== -1) {
|
|
693
|
-
const f =
|
|
695
|
+
const f = n.substring(u + 1, A);
|
|
694
696
|
f.length && m.children.push({
|
|
695
|
-
type:
|
|
697
|
+
type: y.Text,
|
|
696
698
|
tag: "text",
|
|
697
699
|
content: f,
|
|
698
700
|
loc: a(u + 1),
|
|
699
701
|
children: []
|
|
700
|
-
}),
|
|
702
|
+
}), o = A + S.length;
|
|
701
703
|
continue;
|
|
702
704
|
} else {
|
|
703
|
-
const f =
|
|
705
|
+
const f = n.substring(u + 1);
|
|
704
706
|
f.length && m.children.push({
|
|
705
|
-
type:
|
|
707
|
+
type: y.Text,
|
|
706
708
|
tag: "text",
|
|
707
709
|
content: f,
|
|
708
710
|
loc: a(u + 1),
|
|
709
711
|
children: []
|
|
710
|
-
}),
|
|
712
|
+
}), o = i;
|
|
711
713
|
continue;
|
|
712
714
|
}
|
|
713
715
|
}
|
|
714
|
-
|
|
716
|
+
!v && m.type !== y.Text && m.type !== y.Comment && (e.push(m), s.push(p)), o = u + 1;
|
|
715
717
|
}
|
|
716
718
|
return t;
|
|
717
719
|
}
|
|
718
|
-
const
|
|
719
|
-
function
|
|
720
|
-
const t =
|
|
721
|
-
return t ?
|
|
720
|
+
const ht = Symbol("solely.raw");
|
|
721
|
+
function Vt(n) {
|
|
722
|
+
const t = n && n[ht];
|
|
723
|
+
return t ? Vt(t) : n;
|
|
722
724
|
}
|
|
723
|
-
function Ie(
|
|
724
|
-
return !!(
|
|
725
|
+
function Ie(n) {
|
|
726
|
+
return !!(n && n[ht]);
|
|
725
727
|
}
|
|
726
|
-
const
|
|
727
|
-
if (
|
|
728
|
-
if (
|
|
729
|
-
if (Array.isArray(
|
|
730
|
-
if (
|
|
731
|
-
if (e.has(
|
|
732
|
-
e.set(
|
|
733
|
-
for (let r = 0; r <
|
|
734
|
-
if (
|
|
728
|
+
const $t = (n, t, e = /* @__PURE__ */ new WeakMap()) => {
|
|
729
|
+
if (n === t) return !0;
|
|
730
|
+
if (n == null || t == null || typeof n != "object" || typeof t != "object") return n === t;
|
|
731
|
+
if (Array.isArray(n) && Array.isArray(t)) {
|
|
732
|
+
if (n.length !== t.length) return !1;
|
|
733
|
+
if (e.has(n)) return e.get(n) === t;
|
|
734
|
+
e.set(n, t);
|
|
735
|
+
for (let r = 0; r < n.length; r++)
|
|
736
|
+
if (!$t(n[r], t[r], e)) return !1;
|
|
735
737
|
return !0;
|
|
736
738
|
}
|
|
737
|
-
if (Array.isArray(
|
|
738
|
-
if (e.has(
|
|
739
|
-
e.set(
|
|
740
|
-
const
|
|
741
|
-
if (
|
|
742
|
-
for (const r of
|
|
743
|
-
if (!Reflect.has(t, r) ||
|
|
739
|
+
if (Array.isArray(n) !== Array.isArray(t)) return !1;
|
|
740
|
+
if (e.has(n)) return e.get(n) === t;
|
|
741
|
+
e.set(n, t);
|
|
742
|
+
const s = Reflect.ownKeys(n);
|
|
743
|
+
if (s.length !== Reflect.ownKeys(t).length) return !1;
|
|
744
|
+
for (const r of s)
|
|
745
|
+
if (!Reflect.has(t, r) || !$t(n[r], t[r], e)) return !1;
|
|
744
746
|
return !0;
|
|
745
747
|
};
|
|
746
|
-
function Me(
|
|
747
|
-
const { throttle:
|
|
748
|
+
function Me(n, t, e = {}) {
|
|
749
|
+
const { throttle: s = 0, onBatch: r, immediate: o = !1, deepCompare: i = !1 } = e;
|
|
748
750
|
let c = !0, a = null, l = [], u = 0;
|
|
749
|
-
const h = /* @__PURE__ */ new WeakMap(),
|
|
751
|
+
const h = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), m = Array.isArray(e.filter) ? e.filter : e.filter ? [e.filter] : [], p = (f) => {
|
|
750
752
|
if (m.length === 0) return !0;
|
|
751
753
|
const w = f.map(String).join(".");
|
|
752
|
-
return m.some((
|
|
753
|
-
if (
|
|
754
|
-
const
|
|
755
|
-
return new RegExp(`^${
|
|
754
|
+
return m.some((x) => {
|
|
755
|
+
if (x === "") return !0;
|
|
756
|
+
const b = x.replace(/\./g, "\\.").replace(/\*\*/g, "(.+)").replace(/\*/g, "[^.]+").replace(/\[\d+\]/g, "\\[\\d+\\]");
|
|
757
|
+
return new RegExp(`^${b}$`).test(w);
|
|
756
758
|
});
|
|
757
|
-
},
|
|
759
|
+
}, R = (f) => {
|
|
758
760
|
const w = [];
|
|
759
|
-
let
|
|
760
|
-
for (;
|
|
761
|
-
const
|
|
762
|
-
if (!
|
|
763
|
-
w.unshift(
|
|
761
|
+
let x = f;
|
|
762
|
+
for (; x; ) {
|
|
763
|
+
const b = d.get(x);
|
|
764
|
+
if (!b || b.key == null) break;
|
|
765
|
+
w.unshift(b.key), x = b.parent;
|
|
764
766
|
}
|
|
765
767
|
return w;
|
|
766
|
-
},
|
|
768
|
+
}, g = (f, w) => {
|
|
767
769
|
if (!c) return;
|
|
768
|
-
const
|
|
769
|
-
if (!
|
|
770
|
-
const
|
|
771
|
-
|
|
772
|
-
const
|
|
773
|
-
l = [], a = null, c && (r == null || r(
|
|
774
|
-
},
|
|
775
|
-
},
|
|
776
|
-
const
|
|
777
|
-
return ["push", "pop", "shift", "unshift", "splice"].forEach((
|
|
778
|
-
|
|
770
|
+
const x = R(f);
|
|
771
|
+
if (!p(x)) return;
|
|
772
|
+
const b = { ...w, path: x };
|
|
773
|
+
s > 0 ? (l.push(b), a || (a = setTimeout(() => {
|
|
774
|
+
const L = [...l];
|
|
775
|
+
l = [], a = null, c && (r == null || r(L), L.forEach(t));
|
|
776
|
+
}, s))) : (r == null || r([b]), t(b));
|
|
777
|
+
}, v = (f, w) => {
|
|
778
|
+
const x = {};
|
|
779
|
+
return ["push", "pop", "shift", "unshift", "splice"].forEach((b) => {
|
|
780
|
+
x[b] = function(...L) {
|
|
779
781
|
u++;
|
|
780
|
-
const
|
|
781
|
-
if (u--,
|
|
782
|
-
|
|
783
|
-
else if (
|
|
784
|
-
|
|
785
|
-
else if (
|
|
786
|
-
|
|
787
|
-
else if (
|
|
788
|
-
|
|
789
|
-
else if (
|
|
790
|
-
const [
|
|
791
|
-
|
|
782
|
+
const $ = f[b].apply(f, L);
|
|
783
|
+
if (u--, b === "push")
|
|
784
|
+
g(w, { type: "array-push", index: f.length - L.length, values: L });
|
|
785
|
+
else if (b === "unshift")
|
|
786
|
+
g(w, { type: "array-push", index: 0, values: L });
|
|
787
|
+
else if (b === "pop")
|
|
788
|
+
g(w, { type: "array-splice", index: f.length, deleteCount: 1, insert: [] });
|
|
789
|
+
else if (b === "shift")
|
|
790
|
+
g(w, { type: "array-splice", index: 0, deleteCount: 1, insert: [] });
|
|
791
|
+
else if (b === "splice") {
|
|
792
|
+
const [I, M, ..._] = L;
|
|
793
|
+
g(w, { type: "array-splice", index: I, deleteCount: M, insert: _ });
|
|
792
794
|
}
|
|
793
|
-
return
|
|
795
|
+
return $;
|
|
794
796
|
};
|
|
795
|
-
}), ["sort", "reverse", "fill", "copyWithin"].forEach((
|
|
796
|
-
|
|
797
|
+
}), ["sort", "reverse", "fill", "copyWithin"].forEach((b) => {
|
|
798
|
+
x[b] = function(...L) {
|
|
797
799
|
u++;
|
|
798
|
-
const
|
|
799
|
-
return u--,
|
|
800
|
+
const $ = f[b].apply(f, L);
|
|
801
|
+
return u--, g(w, { type: "array-reset", method: b }), $;
|
|
800
802
|
};
|
|
801
|
-
}), ["indexOf", "lastIndexOf", "includes"].forEach((
|
|
802
|
-
|
|
803
|
-
let
|
|
804
|
-
return (
|
|
803
|
+
}), ["indexOf", "lastIndexOf", "includes"].forEach((b) => {
|
|
804
|
+
x[b] = function(L, ...$) {
|
|
805
|
+
let I = f[b].apply(f, [L, ...$]);
|
|
806
|
+
return (I === -1 || I === !1) && Ie(L) && (I = f[b].apply(f, [Vt(L), ...$])), I;
|
|
805
807
|
};
|
|
806
|
-
}),
|
|
807
|
-
}, S = (f, w,
|
|
808
|
-
if (!Object.isExtensible(f) || f[
|
|
808
|
+
}), x;
|
|
809
|
+
}, S = (f, w, x) => {
|
|
810
|
+
if (!Object.isExtensible(f) || f[ht])
|
|
809
811
|
return f;
|
|
810
|
-
const
|
|
811
|
-
if (
|
|
812
|
-
return
|
|
813
|
-
const
|
|
814
|
-
get(
|
|
815
|
-
if (
|
|
816
|
-
if (Array.isArray(
|
|
817
|
-
const
|
|
818
|
-
if (
|
|
819
|
-
return Reflect.get(
|
|
812
|
+
const b = h.get(f);
|
|
813
|
+
if (b)
|
|
814
|
+
return d.set(b, { parent: w, key: x }), b;
|
|
815
|
+
const L = {
|
|
816
|
+
get(I, M, _) {
|
|
817
|
+
if (M === ht) return I;
|
|
818
|
+
if (Array.isArray(I)) {
|
|
819
|
+
const F = E.get($);
|
|
820
|
+
if (F && Object.prototype.hasOwnProperty.call(F, M))
|
|
821
|
+
return Reflect.get(F, M, _);
|
|
820
822
|
}
|
|
821
|
-
const
|
|
822
|
-
return typeof
|
|
823
|
+
const D = Reflect.get(I, M, _);
|
|
824
|
+
return typeof M == "symbol" ? D : K(D) ? S(D, $, M) : D;
|
|
823
825
|
},
|
|
824
|
-
set(
|
|
825
|
-
const
|
|
826
|
-
if (
|
|
827
|
-
const
|
|
828
|
-
return u === 0 && (Array.isArray(
|
|
826
|
+
set(I, M, _, D) {
|
|
827
|
+
const F = I[M];
|
|
828
|
+
if (i ? $t(F, _) : F === _) return !0;
|
|
829
|
+
const rt = Reflect.set(I, M, _, D);
|
|
830
|
+
return u === 0 && (Array.isArray(F) && Array.isArray(_) ? g($, { type: "array-replace", oldValue: F, newValue: _ }) : g($, { type: "set", key: M, newValue: _, oldValue: F })), rt;
|
|
829
831
|
},
|
|
830
|
-
deleteProperty(
|
|
831
|
-
if (!Reflect.has(
|
|
832
|
-
const
|
|
833
|
-
return
|
|
832
|
+
deleteProperty(I, M) {
|
|
833
|
+
if (!Reflect.has(I, M)) return !1;
|
|
834
|
+
const _ = I[M], D = Reflect.deleteProperty(I, M);
|
|
835
|
+
return D && u === 0 && g($, { type: "delete", key: M, oldValue: _ }), D;
|
|
834
836
|
}
|
|
835
|
-
},
|
|
836
|
-
return h.set(f,
|
|
837
|
-
}, A = S(
|
|
838
|
-
if (
|
|
839
|
-
const f = (w,
|
|
840
|
-
!
|
|
841
|
-
const
|
|
842
|
-
|
|
837
|
+
}, $ = new Proxy(f, L);
|
|
838
|
+
return h.set(f, $), d.set($, { parent: w, key: x }), Array.isArray(f) && E.set($, v(f, $)), $;
|
|
839
|
+
}, A = S(n, null, null);
|
|
840
|
+
if (o) {
|
|
841
|
+
const f = (w, x, b = /* @__PURE__ */ new WeakSet()) => {
|
|
842
|
+
!K(w) || b.has(w) || (b.add(w), Reflect.ownKeys(w).forEach((L) => {
|
|
843
|
+
const $ = w[L];
|
|
844
|
+
g(x, { type: "set", key: L, newValue: $, oldValue: void 0 }), K($) && f($, S($, x, L), b);
|
|
843
845
|
}));
|
|
844
846
|
};
|
|
845
|
-
f(
|
|
847
|
+
f(n, A);
|
|
846
848
|
}
|
|
847
849
|
return {
|
|
848
850
|
proxy: A,
|
|
@@ -854,93 +856,85 @@ function Me(s, t, e = {}) {
|
|
|
854
856
|
}
|
|
855
857
|
};
|
|
856
858
|
}
|
|
857
|
-
const
|
|
858
|
-
var
|
|
859
|
-
|
|
859
|
+
const Nt = Symbol.for("solely.manifest");
|
|
860
|
+
var B, U, H, nt, Y, G, Z, J, q, st, C, Dt, St, jt, Bt, kt, ut, Gt, qt, Ct, Lt;
|
|
861
|
+
class ft extends HTMLElement {
|
|
860
862
|
/* -------------------- 构造 -------------------- */
|
|
861
863
|
constructor(e = {}) {
|
|
862
|
-
var
|
|
864
|
+
var o;
|
|
863
865
|
super();
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
const r =
|
|
878
|
-
|
|
879
|
-
}
|
|
866
|
+
T(this, C);
|
|
867
|
+
T(this, B);
|
|
868
|
+
T(this, U);
|
|
869
|
+
T(this, H);
|
|
870
|
+
T(this, nt);
|
|
871
|
+
T(this, Y);
|
|
872
|
+
T(this, G);
|
|
873
|
+
T(this, Z, !1);
|
|
874
|
+
T(this, J, !1);
|
|
875
|
+
T(this, q, !1);
|
|
876
|
+
T(this, st, !1);
|
|
877
|
+
const s = this.constructor;
|
|
878
|
+
O(this, B, s[Nt] || { tagName: "base-element" });
|
|
879
|
+
const r = P(this, B);
|
|
880
|
+
O(this, Y, (o = r.shadowDOM) != null && o.use ? this.attachShadow({ mode: r.shadowDOM.mode || "open" }) : this), N(this, C, St).call(this, e), N(this, C, Bt).call(this, r), queueMicrotask(() => N(this, C, Ct).call(this));
|
|
881
|
+
}
|
|
882
|
+
// 需要在元素定义前设置的属性列表(Upgrade Property)
|
|
883
|
+
/* -------------------- observedAttributes -------------------- */
|
|
880
884
|
static get observedAttributes() {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
const e = this[Wt];
|
|
884
|
-
if (!(e != null && e.props))
|
|
885
|
-
return R(F, z).set(this, []), [];
|
|
886
|
-
const n = e.props.map((r) => (typeof r == "string" ? r : r.name).replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase());
|
|
887
|
-
return R(F, z).set(this, n), n;
|
|
885
|
+
const e = this[Nt];
|
|
886
|
+
return e != null && e.propMap ? Array.from(e.propMap.keys()) : [];
|
|
888
887
|
}
|
|
889
888
|
/* -------------------- $data -------------------- */
|
|
890
889
|
get $data() {
|
|
891
|
-
return
|
|
890
|
+
return P(this, nt);
|
|
892
891
|
}
|
|
893
892
|
set $data(e) {
|
|
894
|
-
var
|
|
895
|
-
|
|
893
|
+
var s;
|
|
894
|
+
K(e) || (e = {}), (s = P(this, G)) == null || s.call(this), N(this, C, St).call(this, e), N(this, C, ut).call(this);
|
|
896
895
|
}
|
|
897
896
|
refresh() {
|
|
898
|
-
|
|
897
|
+
N(this, C, ut).call(this);
|
|
899
898
|
}
|
|
900
899
|
/* -------------------- 生命周期 -------------------- */
|
|
901
900
|
connectedCallback() {
|
|
902
|
-
var
|
|
901
|
+
var o;
|
|
903
902
|
const e = this.constructor;
|
|
904
|
-
Array.isArray(e.upgradeProps) &&
|
|
905
|
-
const
|
|
906
|
-
if ((
|
|
907
|
-
for (const
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
(u,
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
const u = this.getAttribute(c), h = O(this, k, Lt).call(this, u, a == null ? void 0 : a.default, a == null ? void 0 : a.type);
|
|
914
|
-
this.$data[l] = h;
|
|
915
|
-
} else a && "default" in a && (this.$data[l] = a.default);
|
|
903
|
+
Array.isArray(e.upgradeProps) && N(this, C, Dt).call(this, e.upgradeProps), N(this, C, Ct).call(this);
|
|
904
|
+
const s = P(this, B);
|
|
905
|
+
if ((s.className || s.tagName || "").split(" ").forEach((i) => i && this.classList.add(i)), N(this, C, qt).call(this), s.propMap && K(this.$data))
|
|
906
|
+
for (const [i, c] of s.propMap) {
|
|
907
|
+
const a = c.name;
|
|
908
|
+
if (this.hasAttribute(i)) {
|
|
909
|
+
const l = this.getAttribute(i), u = N(this, C, kt).call(this, l, c.default, c.type);
|
|
910
|
+
this.$data[a] = u;
|
|
911
|
+
} else "default" in c && (this.$data[a] = c.default);
|
|
916
912
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
913
|
+
P(this, H) && O(this, U, Be(
|
|
914
|
+
P(this, H),
|
|
915
|
+
P(this, Y),
|
|
920
916
|
this
|
|
921
|
-
)), this.mounted(), (
|
|
917
|
+
)), this.mounted(), (o = this.onInit) == null || o.call(this);
|
|
922
918
|
}
|
|
923
919
|
disconnectedCallback() {
|
|
924
920
|
var e;
|
|
925
|
-
this.unmounted(), (e =
|
|
926
|
-
}
|
|
927
|
-
attributeChangedCallback(e,
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
newValue: a
|
|
935
|
-
});
|
|
921
|
+
this.unmounted(), (e = P(this, G)) == null || e.call(this), O(this, G, void 0);
|
|
922
|
+
}
|
|
923
|
+
attributeChangedCallback(e, s, r) {
|
|
924
|
+
var u;
|
|
925
|
+
if (s === r || !K(this.$data)) return;
|
|
926
|
+
const i = (u = P(this, B).propMap) == null ? void 0 : u.get(e);
|
|
927
|
+
if (!i) return;
|
|
928
|
+
const c = i.name, a = this.$data[c], l = N(this, C, kt).call(this, r, i.default ?? a, i.type);
|
|
929
|
+
this.$data[c] = l, O(this, q, !0), this.attributeChanged(e, a, l);
|
|
936
930
|
}
|
|
937
931
|
/* -------------------- 事件派发 -------------------- */
|
|
938
|
-
emit(e,
|
|
932
|
+
emit(e, s, r) {
|
|
939
933
|
this.dispatchEvent(
|
|
940
934
|
new CustomEvent(e, {
|
|
941
935
|
bubbles: !0,
|
|
942
936
|
composed: !0,
|
|
943
|
-
detail:
|
|
937
|
+
detail: s,
|
|
944
938
|
...r
|
|
945
939
|
})
|
|
946
940
|
);
|
|
@@ -958,366 +952,437 @@ const F = class F extends HTMLElement {
|
|
|
958
952
|
}
|
|
959
953
|
unmounted() {
|
|
960
954
|
}
|
|
961
|
-
attributeChanged(e,
|
|
955
|
+
attributeChanged(e, s, r) {
|
|
962
956
|
}
|
|
963
957
|
beforeAttributesUpdate() {
|
|
964
958
|
}
|
|
965
959
|
afterAttributesUpdate() {
|
|
966
960
|
}
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
for (const
|
|
971
|
-
if (this.hasOwnProperty(
|
|
972
|
-
const r = this[
|
|
973
|
-
delete this[
|
|
961
|
+
}
|
|
962
|
+
B = new WeakMap(), U = new WeakMap(), H = new WeakMap(), nt = new WeakMap(), Y = new WeakMap(), G = new WeakMap(), Z = new WeakMap(), J = new WeakMap(), q = new WeakMap(), st = new WeakMap(), C = new WeakSet(), // 升级属性(Upgrade Property), 保障在元素被定义前设置的属性能正确触发响应式更新
|
|
963
|
+
Dt = function(e) {
|
|
964
|
+
for (const s of e)
|
|
965
|
+
if (this.hasOwnProperty(s)) {
|
|
966
|
+
const r = this[s];
|
|
967
|
+
delete this[s], this[s] = r;
|
|
974
968
|
}
|
|
975
969
|
}, /* -------------------- 初始化 -------------------- */
|
|
976
|
-
|
|
977
|
-
const { proxy:
|
|
970
|
+
St = function(e) {
|
|
971
|
+
const { proxy: s, unobserve: r } = Me(e, (o) => {
|
|
972
|
+
var i, c;
|
|
973
|
+
if (o.type === "set") {
|
|
974
|
+
const { key: a, newValue: l } = o, u = P(this, B), h = String(a), d = ((i = u.propMap) == null ? void 0 : i.get(
|
|
975
|
+
h.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()
|
|
976
|
+
)) || Array.from(((c = u.propMap) == null ? void 0 : c.values()) || []).find((E) => E.name === h);
|
|
977
|
+
d != null && d.reflect && N(this, C, jt).call(this, d, l);
|
|
978
|
+
}
|
|
978
979
|
this.emit("change", {
|
|
979
980
|
source: "state",
|
|
980
|
-
...
|
|
981
|
-
}),
|
|
981
|
+
...o
|
|
982
|
+
}), N(this, C, ut).call(this);
|
|
982
983
|
});
|
|
983
|
-
|
|
984
|
-
},
|
|
985
|
-
const
|
|
986
|
-
if (
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
const r = e.replace(/-([a-z])/g, (o, c) => c.toUpperCase()), i = n.find(
|
|
998
|
-
(o) => typeof o == "string" ? o === r : o.name === r
|
|
999
|
-
);
|
|
1000
|
-
if (i)
|
|
1001
|
-
return typeof i == "string" ? { name: i } : i;
|
|
1002
|
-
}, Lt = function(e, n, r) {
|
|
1003
|
-
if (e === null) return n;
|
|
984
|
+
O(this, nt, s), O(this, G, r);
|
|
985
|
+
}, jt = function(e, s) {
|
|
986
|
+
const r = e.name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
987
|
+
if (e.type === "boolean")
|
|
988
|
+
s ? this.setAttribute(r, "") : this.removeAttribute(r);
|
|
989
|
+
else {
|
|
990
|
+
const o = typeof s == "object" ? JSON.stringify(s) : String(s);
|
|
991
|
+
this.setAttribute(r, o);
|
|
992
|
+
}
|
|
993
|
+
}, Bt = function(e) {
|
|
994
|
+
e.ir && O(this, H, e.ir);
|
|
995
|
+
}, kt = function(e, s, r) {
|
|
996
|
+
if (e === null)
|
|
997
|
+
return r === "boolean" ? s ?? !1 : s;
|
|
1004
998
|
switch (r) {
|
|
999
|
+
case "boolean":
|
|
1000
|
+
return !0;
|
|
1005
1001
|
case "number": {
|
|
1006
|
-
const
|
|
1007
|
-
return isNaN(
|
|
1002
|
+
const o = Number(e);
|
|
1003
|
+
return isNaN(o) ? s : o;
|
|
1008
1004
|
}
|
|
1009
|
-
case "boolean":
|
|
1010
|
-
return e !== null && e !== "false";
|
|
1011
1005
|
case "object":
|
|
1012
1006
|
try {
|
|
1013
1007
|
return JSON.parse(e);
|
|
1014
1008
|
} catch {
|
|
1015
|
-
return
|
|
1009
|
+
return s;
|
|
1016
1010
|
}
|
|
1017
1011
|
default:
|
|
1018
1012
|
return e;
|
|
1019
1013
|
}
|
|
1020
1014
|
}, /* -------------------- 刷新调度 -------------------- */
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1015
|
+
ut = function() {
|
|
1016
|
+
P(this, J) || !P(this, U) || (O(this, J, !0), queueMicrotask(() => {
|
|
1017
|
+
O(this, J, !1), N(this, C, Gt).call(this);
|
|
1024
1018
|
}));
|
|
1025
|
-
},
|
|
1026
|
-
|
|
1027
|
-
},
|
|
1028
|
-
const
|
|
1029
|
-
if (!
|
|
1030
|
-
const
|
|
1031
|
-
if ("adoptedStyleSheets" in
|
|
1032
|
-
|
|
1033
|
-
let o = R(F, ot).get(n);
|
|
1034
|
-
o || (o = new CSSStyleSheet(), o.replaceSync(n), R(F, ot).set(n, o)), r.adoptedStyleSheets = [
|
|
1035
|
-
...r.adoptedStyleSheets,
|
|
1036
|
-
o
|
|
1037
|
-
], r._styleInjected = !0;
|
|
1019
|
+
}, Gt = function() {
|
|
1020
|
+
P(this, Z) || !this.isConnected || (O(this, Z, !0), P(this, q) && this.beforeAttributesUpdate(), this.beforeUpdate(), P(this, U).update(), this.updated(), P(this, q) && (this.afterAttributesUpdate(), O(this, q, !1)), O(this, Z, !1));
|
|
1021
|
+
}, qt = function() {
|
|
1022
|
+
const e = P(this, B);
|
|
1023
|
+
if (!e.styles) return;
|
|
1024
|
+
const s = P(this, Y);
|
|
1025
|
+
if (e.sheet && s instanceof ShadowRoot && "adoptedStyleSheets" in s) {
|
|
1026
|
+
s.adoptedStyleSheets.includes(e.sheet) || (s.adoptedStyleSheets = [...s.adoptedStyleSheets, e.sheet]);
|
|
1038
1027
|
return;
|
|
1039
1028
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1029
|
+
const r = s instanceof ShadowRoot ? s : document.head, o = `solely-style-${e.tagName}`;
|
|
1030
|
+
if (!r.querySelector(`#${o}`)) {
|
|
1031
|
+
const i = document.createElement("style");
|
|
1032
|
+
i.id = o, i.textContent = e.styles, r.appendChild(i);
|
|
1033
|
+
}
|
|
1043
1034
|
}, /* -------------------- created 保障 -------------------- */
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
},
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1035
|
+
Ct = function() {
|
|
1036
|
+
P(this, st) || (O(this, st, !0), this.created());
|
|
1037
|
+
}, Lt = new WeakMap(), k(ft, "upgradeProps"), /* -------------------- DEV define 保护 -------------------- */
|
|
1038
|
+
T(ft, Lt, !1);
|
|
1039
|
+
const Pe = Symbol.for("solely.manifest"), zt = (n) => {
|
|
1040
|
+
const t = n;
|
|
1041
|
+
return (e) => {
|
|
1042
|
+
const { tagName: s } = t;
|
|
1043
|
+
if (customElements.get(s))
|
|
1044
|
+
return e;
|
|
1045
|
+
if (typeof t.template == "string" && !t.ir)
|
|
1046
|
+
try {
|
|
1047
|
+
const o = Le(t.template);
|
|
1048
|
+
t.ir = xe(o, {
|
|
1049
|
+
source: t.template,
|
|
1050
|
+
filename: s
|
|
1051
|
+
});
|
|
1052
|
+
} catch (o) {
|
|
1053
|
+
console.error(`[Compiler Error] <${s}>:`, o);
|
|
1054
|
+
}
|
|
1055
|
+
if (t.styles && !t.sheet && "CSSStyleSheet" in window)
|
|
1056
|
+
try {
|
|
1057
|
+
const o = new CSSStyleSheet();
|
|
1058
|
+
o.replaceSync(t.styles), t.sheet = o;
|
|
1059
|
+
} catch (o) {
|
|
1060
|
+
console.error(`[Style Error] <${s}>:`, o);
|
|
1061
|
+
}
|
|
1062
|
+
if (t.props && !t.propMap) {
|
|
1063
|
+
const o = /* @__PURE__ */ new Map();
|
|
1064
|
+
t.props.forEach((i) => {
|
|
1065
|
+
const c = typeof i == "string" ? { name: i } : i, a = c.name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1066
|
+
o.set(a, c);
|
|
1067
|
+
}), t.propMap = o;
|
|
1068
|
+
}
|
|
1069
|
+
class r extends e {
|
|
1070
|
+
}
|
|
1071
|
+
return r[Pe] = t, customElements.define(s, r), r;
|
|
1072
|
+
};
|
|
1073
|
+
}, at = Symbol("solely.irCtx"), ct = Symbol("solely.irEvents"), V = Symbol.for("solely.irMeta"), bt = Symbol("solely.prevClassObj"), wt = Symbol("solely.prevStyleObj"), Oe = {
|
|
1058
1074
|
xml: "http://www.w3.org/XML/1998/namespace",
|
|
1059
1075
|
xlink: "http://www.w3.org/1999/xlink",
|
|
1060
1076
|
xmlns: "http://www.w3.org/2000/xmlns/"
|
|
1061
|
-
},
|
|
1077
|
+
}, _t = {
|
|
1062
1078
|
readonly: "readOnly",
|
|
1063
1079
|
for: "htmlFor",
|
|
1064
1080
|
tabindex: "tabIndex",
|
|
1065
1081
|
contenteditable: "contentEditable",
|
|
1066
1082
|
maxlength: "maxLength"
|
|
1067
|
-
},
|
|
1083
|
+
}, Ne = /* @__PURE__ */ new Set(["data-", "aria-", "role", "form"]), _e = /* @__PURE__ */ new Set([
|
|
1068
1084
|
"value",
|
|
1069
1085
|
"selectedIndex"
|
|
1070
1086
|
]);
|
|
1071
|
-
function Te(
|
|
1072
|
-
var
|
|
1073
|
-
const e = s
|
|
1074
|
-
|
|
1087
|
+
function Te(n, t) {
|
|
1088
|
+
var s;
|
|
1089
|
+
const e = (s = t.attrs) == null ? void 0 : s.find((r) => r.key === "class" && !r.dynamic);
|
|
1090
|
+
e != null && e.value && n.setAttribute("class", e.value);
|
|
1075
1091
|
}
|
|
1076
|
-
function
|
|
1077
|
-
var
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1092
|
+
function We(n, t) {
|
|
1093
|
+
var o;
|
|
1094
|
+
if (!n.style) return;
|
|
1095
|
+
const s = (o = t.attrs) == null ? void 0 : o.find((i) => i.key === "style" && !i.dynamic), r = s ? Kt(s.value) : {};
|
|
1096
|
+
for (const i in r) {
|
|
1097
|
+
const c = r[i];
|
|
1098
|
+
i.startsWith("--") ? n.style.setProperty(i, c) : n.style[i] = c;
|
|
1082
1099
|
}
|
|
1083
1100
|
}
|
|
1084
|
-
const Fe = (
|
|
1085
|
-
const e =
|
|
1101
|
+
const Fe = (n, t) => {
|
|
1102
|
+
const e = n, s = Kt(t), r = e[wt];
|
|
1103
|
+
if (!r) {
|
|
1104
|
+
for (const i in s) {
|
|
1105
|
+
const c = s[i];
|
|
1106
|
+
i.startsWith("--") ? n.style.setProperty(i, c) : n.style[i] = c;
|
|
1107
|
+
}
|
|
1108
|
+
e[wt] = s;
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
let o = !1;
|
|
1086
1112
|
for (const i in r)
|
|
1087
|
-
i in
|
|
1088
|
-
for (const i in
|
|
1089
|
-
const
|
|
1090
|
-
i.startsWith("--") ?
|
|
1091
|
-
}
|
|
1092
|
-
e[
|
|
1093
|
-
},
|
|
1094
|
-
const e =
|
|
1095
|
-
|
|
1096
|
-
|
|
1113
|
+
i in s || (i.startsWith("--") ? n.style.removeProperty(i) : n.style[i] = "", o = !0);
|
|
1114
|
+
for (const i in s) {
|
|
1115
|
+
const c = s[i], a = r[i];
|
|
1116
|
+
c !== a && (i.startsWith("--") ? n.style.setProperty(i, c) : n.style[i] = c, o = !0);
|
|
1117
|
+
}
|
|
1118
|
+
o && (e[wt] = s);
|
|
1119
|
+
}, Ve = (n, t) => {
|
|
1120
|
+
const e = n, s = e[bt], r = De(t);
|
|
1121
|
+
if (!s) {
|
|
1122
|
+
for (const i in r)
|
|
1123
|
+
n.classList.add(i);
|
|
1124
|
+
e[bt] = r;
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
let o = !1;
|
|
1128
|
+
for (const i in s)
|
|
1129
|
+
r[i] || (n.classList.remove(i), o = !0);
|
|
1097
1130
|
for (const i in r)
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
const o = e.className.baseVal.split(/\s+/);
|
|
1101
|
-
o.includes(i) || (o.push(i), e.className.baseVal = o.join(" "));
|
|
1102
|
-
} else
|
|
1103
|
-
e.classList.add(i);
|
|
1104
|
-
e[Tt] = r;
|
|
1131
|
+
s[i] || (n.classList.add(i), o = !0);
|
|
1132
|
+
o && (e[bt] = r);
|
|
1105
1133
|
};
|
|
1106
|
-
function
|
|
1107
|
-
const t = {}, e = [[
|
|
1134
|
+
function Kt(n) {
|
|
1135
|
+
const t = {}, e = [[n]];
|
|
1108
1136
|
for (; e.length; ) {
|
|
1109
|
-
const [
|
|
1110
|
-
if (
|
|
1111
|
-
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
continue;
|
|
1120
|
-
}
|
|
1121
|
-
if (n && typeof n == "object")
|
|
1122
|
-
for (const [i, o] of Object.entries(n)) {
|
|
1123
|
-
const c = r ? `${r}-${i}` : i;
|
|
1124
|
-
o && typeof o == "object" && !Array.isArray(o) ? e.push([o, c]) : t[c] = String(o ?? "");
|
|
1137
|
+
const [s, r] = e.pop();
|
|
1138
|
+
if (s) {
|
|
1139
|
+
if (typeof s == "string") {
|
|
1140
|
+
const o = /([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g;
|
|
1141
|
+
let i;
|
|
1142
|
+
for (; (i = o.exec(s)) !== null; ) {
|
|
1143
|
+
const c = i[1].trim(), a = i[2].trim();
|
|
1144
|
+
c && a && (t[c] = a);
|
|
1145
|
+
}
|
|
1146
|
+
continue;
|
|
1125
1147
|
}
|
|
1148
|
+
if (Array.isArray(s)) {
|
|
1149
|
+
for (let o = s.length - 1; o >= 0; o--)
|
|
1150
|
+
e.push([s[o]]);
|
|
1151
|
+
continue;
|
|
1152
|
+
}
|
|
1153
|
+
if (typeof s == "object")
|
|
1154
|
+
for (const o in s) {
|
|
1155
|
+
const i = s[o];
|
|
1156
|
+
if (i == null) continue;
|
|
1157
|
+
const c = r ? `${r}-${o}` : o;
|
|
1158
|
+
typeof i == "object" && !Array.isArray(i) ? e.push([i, c]) : t[c] = String(i);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1126
1161
|
}
|
|
1127
1162
|
return t;
|
|
1128
1163
|
}
|
|
1129
|
-
function
|
|
1130
|
-
const t = {}, e = [
|
|
1164
|
+
function De(n) {
|
|
1165
|
+
const t = {}, e = [n];
|
|
1131
1166
|
for (; e.length; ) {
|
|
1132
|
-
const
|
|
1133
|
-
if (
|
|
1134
|
-
if (typeof
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1167
|
+
const s = e.pop();
|
|
1168
|
+
if (s) {
|
|
1169
|
+
if (typeof s == "string") {
|
|
1170
|
+
const r = s.split(" ");
|
|
1171
|
+
for (let o = 0; o < r.length; o++) {
|
|
1172
|
+
const i = r[o].trim();
|
|
1173
|
+
i && (t[i] = !0);
|
|
1174
|
+
}
|
|
1175
|
+
} else if (Array.isArray(s))
|
|
1176
|
+
for (let r = s.length - 1; r >= 0; r--)
|
|
1177
|
+
e.push(s[r]);
|
|
1178
|
+
else if (typeof s == "object")
|
|
1179
|
+
for (const r in s)
|
|
1180
|
+
s[r] && (t[r] = !0);
|
|
1141
1181
|
}
|
|
1142
1182
|
}
|
|
1143
1183
|
return t;
|
|
1144
1184
|
}
|
|
1145
|
-
function
|
|
1146
|
-
const
|
|
1147
|
-
if (
|
|
1148
|
-
const
|
|
1149
|
-
if (i)
|
|
1185
|
+
function Rt(n, t, e) {
|
|
1186
|
+
const s = e == null ? "" : String(e), r = t.indexOf(":");
|
|
1187
|
+
if (r > 0) {
|
|
1188
|
+
const o = t.slice(0, r), i = Oe[o];
|
|
1189
|
+
if (i) {
|
|
1190
|
+
n.getAttributeNS(i, t) !== s && n.setAttributeNS(i, t, s);
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1150
1193
|
}
|
|
1151
|
-
s.setAttribute(t,
|
|
1194
|
+
n.getAttribute(t) !== s && n.setAttribute(t, s);
|
|
1152
1195
|
}
|
|
1153
|
-
function
|
|
1154
|
-
|
|
1155
|
-
|
|
1196
|
+
function Tt(n, t, e) {
|
|
1197
|
+
const s = _t[t] || t;
|
|
1198
|
+
if (t.startsWith("data-") || t.startsWith("aria-") || Ne.has(t)) {
|
|
1199
|
+
Rt(n, t, e);
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
const r = n, o = r.tagName;
|
|
1203
|
+
if (e == null) {
|
|
1204
|
+
if (typeof r[s] == "boolean")
|
|
1205
|
+
r[s] !== !1 && (r[s] = !1);
|
|
1206
|
+
else {
|
|
1207
|
+
const c = r[s];
|
|
1208
|
+
c !== "" && c !== void 0 && (r[s] = ""), n.hasAttribute(t) && n.removeAttribute(t);
|
|
1209
|
+
}
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
if (s === "src" || s === "href") {
|
|
1213
|
+
const c = String(e);
|
|
1214
|
+
if (r[s] === c || n.getAttribute(s) === c)
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
if (s === "value" && (o === "INPUT" || o === "TEXTAREA") && r.value === e)
|
|
1218
|
+
return;
|
|
1219
|
+
if (typeof e == "boolean") {
|
|
1220
|
+
if (r[s] === e)
|
|
1221
|
+
return;
|
|
1222
|
+
r[s] = e;
|
|
1156
1223
|
return;
|
|
1157
1224
|
}
|
|
1158
|
-
|
|
1159
|
-
s[n] = e;
|
|
1225
|
+
(n instanceof SVGElement || r.ownerSVGElement !== void 0) && !_t[t] ? Rt(n, t, e) : r[s] !== e && (r[s] = e);
|
|
1160
1226
|
}
|
|
1161
|
-
class
|
|
1162
|
-
constructor(t, e,
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
this.ir = t, this.container = e, this.scope =
|
|
1166
|
-
}
|
|
1167
|
-
evalIR(t, e,
|
|
1168
|
-
var
|
|
1227
|
+
class je {
|
|
1228
|
+
constructor(t, e, s = {}) {
|
|
1229
|
+
k(this, "nodeMap", /* @__PURE__ */ new Map());
|
|
1230
|
+
k(this, "marker", !1);
|
|
1231
|
+
this.ir = t, this.container = e, this.scope = s;
|
|
1232
|
+
}
|
|
1233
|
+
evalIR(t, e, s) {
|
|
1234
|
+
var o;
|
|
1169
1235
|
const r = this.ir.functions[t - 1];
|
|
1170
1236
|
try {
|
|
1171
1237
|
return r ? r.apply(this.scope, e) : "";
|
|
1172
|
-
} catch (
|
|
1173
|
-
return
|
|
1238
|
+
} catch (i) {
|
|
1239
|
+
return ee(i.message || i.toString(), ((o = this.ir.metadata) == null ? void 0 : o.source) || "", s, this.scope.tagName), "";
|
|
1174
1240
|
}
|
|
1175
1241
|
}
|
|
1176
1242
|
// ================ 创建节点 ================
|
|
1177
1243
|
createElement(t, e) {
|
|
1178
|
-
const
|
|
1179
|
-
return
|
|
1244
|
+
const s = t.tag;
|
|
1245
|
+
return e instanceof SVGElement || s === "svg" ? document.createElementNS("http://www.w3.org/2000/svg", s) : document.createElement(s);
|
|
1180
1246
|
}
|
|
1181
1247
|
createText(t, e) {
|
|
1182
|
-
const
|
|
1183
|
-
return document.createTextNode(
|
|
1248
|
+
const s = t.dynamic ? this.evalIR(t.fid, [e], t[V]) : t.txt || "";
|
|
1249
|
+
return document.createTextNode(s);
|
|
1184
1250
|
}
|
|
1185
1251
|
createComment(t, e) {
|
|
1186
|
-
const
|
|
1187
|
-
return document.createComment(
|
|
1252
|
+
const s = t.dynamic ? this.evalIR(t.fid, [e], t[V]) : t.txt || "";
|
|
1253
|
+
return document.createComment(s);
|
|
1188
1254
|
}
|
|
1189
1255
|
// ================ 属性全量应用(创建或更新时用) ================
|
|
1190
|
-
applyAttrs(t, e,
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1256
|
+
applyAttrs(t, e, s, r = !1) {
|
|
1257
|
+
const o = [], i = t;
|
|
1258
|
+
i[at] || (i[at] = {
|
|
1193
1259
|
loops: null
|
|
1194
|
-
}),
|
|
1260
|
+
}), i[at].loops = s, i[ct] || (i[ct] = /* @__PURE__ */ Object.create(null));
|
|
1195
1261
|
let c, a = !1, l, u = !1;
|
|
1196
1262
|
for (const h of e) {
|
|
1197
|
-
const { key:
|
|
1198
|
-
if (
|
|
1199
|
-
c = this.evalIR(
|
|
1263
|
+
const { key: d, fid: E, dynamic: m, value: p } = h;
|
|
1264
|
+
if (d === ":class") {
|
|
1265
|
+
c = this.evalIR(E, [s], h[V]), a = !0;
|
|
1200
1266
|
continue;
|
|
1201
1267
|
}
|
|
1202
|
-
if (
|
|
1203
|
-
l = this.evalIR(
|
|
1268
|
+
if (d === ":style") {
|
|
1269
|
+
l = this.evalIR(E, [s], h[V]), u = !0;
|
|
1204
1270
|
continue;
|
|
1205
1271
|
}
|
|
1206
|
-
if (
|
|
1272
|
+
if (d === "class" || d === "style")
|
|
1207
1273
|
continue;
|
|
1208
|
-
const
|
|
1209
|
-
if (
|
|
1210
|
-
const
|
|
1211
|
-
let A =
|
|
1212
|
-
if (A || (A =
|
|
1274
|
+
const R = d[0];
|
|
1275
|
+
if (R === "@") {
|
|
1276
|
+
const v = d.slice(1), S = h.role ?? "user";
|
|
1277
|
+
let A = i[ct][v];
|
|
1278
|
+
if (A || (A = i[ct][v] = {
|
|
1213
1279
|
model: [],
|
|
1214
1280
|
user: []
|
|
1215
|
-
}, t.addEventListener(
|
|
1281
|
+
}, t.addEventListener(v, (f) => {
|
|
1216
1282
|
for (const w of A.model)
|
|
1217
1283
|
w(f);
|
|
1218
1284
|
for (const w of A.user)
|
|
1219
1285
|
w(f);
|
|
1220
1286
|
})), !r) {
|
|
1221
1287
|
const f = (w) => this.evalIR(
|
|
1222
|
-
|
|
1223
|
-
[w,
|
|
1288
|
+
E,
|
|
1289
|
+
[w, i[at].loops],
|
|
1224
1290
|
h[V]
|
|
1225
1291
|
);
|
|
1226
1292
|
A[S].push(f);
|
|
1227
1293
|
}
|
|
1228
1294
|
continue;
|
|
1229
1295
|
}
|
|
1230
|
-
if (
|
|
1296
|
+
if (d === "mounted") {
|
|
1231
1297
|
r || requestAnimationFrame(
|
|
1232
|
-
() => this.evalIR(
|
|
1298
|
+
() => this.evalIR(E, [t, s], h[V])
|
|
1233
1299
|
);
|
|
1234
1300
|
continue;
|
|
1235
1301
|
}
|
|
1236
|
-
if (
|
|
1302
|
+
if (d === "updated") {
|
|
1237
1303
|
r && requestAnimationFrame(
|
|
1238
|
-
() => this.evalIR(
|
|
1304
|
+
() => this.evalIR(E, [t, s], h[V])
|
|
1239
1305
|
);
|
|
1240
1306
|
continue;
|
|
1241
1307
|
}
|
|
1242
|
-
if (
|
|
1243
|
-
this.scope.$refs = this.scope.$refs || {}, this.scope.$refs[
|
|
1308
|
+
if (d === "ref" && p) {
|
|
1309
|
+
this.scope.$refs = this.scope.$refs || {}, this.scope.$refs[p] = t;
|
|
1244
1310
|
continue;
|
|
1245
1311
|
}
|
|
1246
|
-
const
|
|
1247
|
-
if (
|
|
1248
|
-
const
|
|
1249
|
-
t.tagName === "SELECT" &&
|
|
1250
|
-
} else
|
|
1251
|
-
Be(t, p, String(b));
|
|
1312
|
+
const g = m ? this.evalIR(E, [s], h[V]) : p ?? "";
|
|
1313
|
+
if (R === ":") {
|
|
1314
|
+
const v = d.slice(1);
|
|
1315
|
+
t.tagName === "SELECT" && _e.has(v) ? o.push(() => Tt(t, v, g)) : Tt(t, v, g);
|
|
1316
|
+
} else r || Rt(t, d, String(g));
|
|
1252
1317
|
}
|
|
1253
|
-
return
|
|
1318
|
+
return a && Ve(t, c), u && Fe(t, l), o;
|
|
1254
1319
|
}
|
|
1255
1320
|
// ================ 更新已有节点 Text Or Comment ================
|
|
1256
|
-
updateNode(t, e,
|
|
1257
|
-
const r = e.dynamic ? this.evalIR(e.fid, [
|
|
1321
|
+
updateNode(t, e, s) {
|
|
1322
|
+
const r = e.dynamic ? this.evalIR(e.fid, [s], e[V]) : e.txt || "";
|
|
1258
1323
|
e.dynamic && t.textContent !== r && (t.textContent = r);
|
|
1259
1324
|
}
|
|
1260
1325
|
// ================ 核心遍历 ================
|
|
1261
|
-
irToNode(t, e,
|
|
1262
|
-
var l, u, h,
|
|
1263
|
-
const
|
|
1326
|
+
irToNode(t, e, s, r, o) {
|
|
1327
|
+
var l, u, h, d;
|
|
1328
|
+
const i = s + "-" + e, c = this.nodeMap.get(i);
|
|
1264
1329
|
let a;
|
|
1265
1330
|
if (c) {
|
|
1266
1331
|
a = c.node, c.marker = this.marker;
|
|
1267
|
-
let
|
|
1268
|
-
t.dynamic && (t.type ===
|
|
1332
|
+
let E = [];
|
|
1333
|
+
t.dynamic && (t.type === y.Element ? E = this.applyAttrs(
|
|
1269
1334
|
a,
|
|
1270
1335
|
t.attrs ?? [],
|
|
1271
|
-
|
|
1336
|
+
o,
|
|
1272
1337
|
!0
|
|
1273
|
-
) : this.updateNode(a, t,
|
|
1274
|
-
this.irToNode(m,
|
|
1275
|
-
}),
|
|
1338
|
+
) : this.updateNode(a, t, o)), (l = t.children) == null || l.forEach((m, p) => {
|
|
1339
|
+
this.irToNode(m, p, i, a, o);
|
|
1340
|
+
}), E.forEach((m) => m());
|
|
1276
1341
|
} else
|
|
1277
1342
|
switch (t.type) {
|
|
1278
|
-
case
|
|
1279
|
-
a = this.createElement(t, r), Te(a, t),
|
|
1280
|
-
const
|
|
1281
|
-
r.appendChild(a), this.nodeMap.set(
|
|
1282
|
-
this.irToNode(m,
|
|
1283
|
-
}),
|
|
1343
|
+
case y.Element:
|
|
1344
|
+
a = this.createElement(t, r), Te(a, t), We(a, t);
|
|
1345
|
+
const E = this.applyAttrs(a, t.attrs ?? [], o);
|
|
1346
|
+
r.appendChild(a), this.nodeMap.set(i, { irNode: t, node: a, loops: o, marker: this.marker }), (u = t.children) == null || u.forEach((m, p) => {
|
|
1347
|
+
this.irToNode(m, p, i, a, o);
|
|
1348
|
+
}), E.forEach((m) => m());
|
|
1284
1349
|
break;
|
|
1285
|
-
case
|
|
1286
|
-
a = this.createText(t,
|
|
1350
|
+
case y.Text:
|
|
1351
|
+
a = this.createText(t, o), r.appendChild(a), this.nodeMap.set(i, { irNode: t, node: a, loops: o, marker: this.marker });
|
|
1287
1352
|
break;
|
|
1288
|
-
case
|
|
1289
|
-
a = this.createComment(t,
|
|
1353
|
+
case y.Comment:
|
|
1354
|
+
a = this.createComment(t, o), r.appendChild(a), this.nodeMap.set(i, { irNode: t, node: a, loops: o, marker: this.marker });
|
|
1290
1355
|
break;
|
|
1291
|
-
case
|
|
1292
|
-
const m = `${
|
|
1293
|
-
let
|
|
1294
|
-
|
|
1295
|
-
irNode: { type:
|
|
1296
|
-
node:
|
|
1297
|
-
loops:
|
|
1356
|
+
case y.For: {
|
|
1357
|
+
const m = `${i}-end`;
|
|
1358
|
+
let p = (h = this.nodeMap.get(m)) == null ? void 0 : h.node;
|
|
1359
|
+
p ? this.nodeMap.get(m).marker = this.marker : (p = document.createComment(`for:${i}`), r.appendChild(p), this.nodeMap.set(m, {
|
|
1360
|
+
irNode: { type: y.Comment },
|
|
1361
|
+
node: p,
|
|
1362
|
+
loops: o,
|
|
1298
1363
|
marker: this.marker
|
|
1299
1364
|
}));
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1365
|
+
const R = this.evalIR(t.fid, [o], t[V]) || [], g = document.createDocumentFragment();
|
|
1366
|
+
R.forEach((v, S) => {
|
|
1302
1367
|
var f;
|
|
1303
|
-
const A = [...
|
|
1304
|
-
(f = t.children) == null || f.forEach((w,
|
|
1305
|
-
this.irToNode(w,
|
|
1368
|
+
const A = [...o, { itmVal: v, idxVal: S }];
|
|
1369
|
+
(f = t.children) == null || f.forEach((w, x) => {
|
|
1370
|
+
this.irToNode(w, x, `${i}-for-${S}`, g, A);
|
|
1306
1371
|
});
|
|
1307
|
-
}),
|
|
1372
|
+
}), p.parentNode.insertBefore(g, p);
|
|
1308
1373
|
break;
|
|
1309
1374
|
}
|
|
1310
|
-
case
|
|
1311
|
-
const m = `${
|
|
1312
|
-
let
|
|
1313
|
-
|
|
1314
|
-
for (let
|
|
1315
|
-
const
|
|
1316
|
-
if (
|
|
1375
|
+
case y.Conditional: {
|
|
1376
|
+
const m = `${i}-end`;
|
|
1377
|
+
let p = (d = this.nodeMap.get(m)) == null ? void 0 : d.node;
|
|
1378
|
+
p ? this.nodeMap.get(m).marker = this.marker : (p = document.createComment(`if:${i}`), r.appendChild(p), this.nodeMap.set(m, { irNode: {}, node: p, loops: o, marker: this.marker }));
|
|
1379
|
+
for (let R = 0; R < (t.branches || []).length; R++) {
|
|
1380
|
+
const g = t.branches[R];
|
|
1381
|
+
if (g.condFid === null || this.evalIR(g.condFid, [o], g[V])) {
|
|
1317
1382
|
const S = document.createDocumentFragment();
|
|
1318
|
-
|
|
1319
|
-
this.irToNode(A, f, `${
|
|
1320
|
-
}),
|
|
1383
|
+
g.children.forEach((A, f) => {
|
|
1384
|
+
this.irToNode(A, f, `${i}-if-${R}`, S, o);
|
|
1385
|
+
}), p.parentNode.insertBefore(S, p);
|
|
1321
1386
|
break;
|
|
1322
1387
|
}
|
|
1323
1388
|
}
|
|
@@ -1329,17 +1394,17 @@ class qe {
|
|
|
1329
1394
|
cleanupOldNodes() {
|
|
1330
1395
|
for (const [t, e] of this.nodeMap.entries())
|
|
1331
1396
|
if (e.marker !== this.marker) {
|
|
1332
|
-
const { irNode:
|
|
1333
|
-
if (
|
|
1334
|
-
const
|
|
1335
|
-
|
|
1397
|
+
const { irNode: s, node: r, loops: o } = e;
|
|
1398
|
+
if (s.attrs) {
|
|
1399
|
+
const i = s.attrs.find((a) => a.key === "unmounted");
|
|
1400
|
+
i && requestAnimationFrame(() => {
|
|
1336
1401
|
this.evalIR(
|
|
1337
|
-
|
|
1338
|
-
[r,
|
|
1339
|
-
|
|
1402
|
+
i.fid,
|
|
1403
|
+
[r, o],
|
|
1404
|
+
i[V]
|
|
1340
1405
|
);
|
|
1341
1406
|
});
|
|
1342
|
-
const c =
|
|
1407
|
+
const c = s.attrs.find((a) => a.key === "ref");
|
|
1343
1408
|
c && c.value && delete this.scope.$refs[c.value];
|
|
1344
1409
|
}
|
|
1345
1410
|
r == null || r.remove(), this.nodeMap.delete(t);
|
|
@@ -1360,38 +1425,38 @@ class qe {
|
|
|
1360
1425
|
this.container.innerHTML = "", this.nodeMap.clear();
|
|
1361
1426
|
}
|
|
1362
1427
|
}
|
|
1363
|
-
const
|
|
1364
|
-
const
|
|
1365
|
-
return
|
|
1366
|
-
update: () =>
|
|
1367
|
-
destroy: () =>
|
|
1428
|
+
const Be = (n, t, e = {}) => {
|
|
1429
|
+
const s = new je(n, t, e);
|
|
1430
|
+
return s.mount(), {
|
|
1431
|
+
update: () => s.update(),
|
|
1432
|
+
destroy: () => s.destroy()
|
|
1368
1433
|
};
|
|
1369
1434
|
};
|
|
1370
|
-
let
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1435
|
+
let z = null, Ut;
|
|
1436
|
+
const Ht = new Promise((n) => {
|
|
1437
|
+
Ut = n;
|
|
1373
1438
|
});
|
|
1374
|
-
function
|
|
1375
|
-
return
|
|
1439
|
+
function Je(n) {
|
|
1440
|
+
return z || (z = new Ge(n), Ut(z), z);
|
|
1376
1441
|
}
|
|
1377
|
-
function
|
|
1378
|
-
return
|
|
1442
|
+
function Et() {
|
|
1443
|
+
return z;
|
|
1379
1444
|
}
|
|
1380
|
-
class
|
|
1445
|
+
class Ge {
|
|
1381
1446
|
constructor(t) {
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1447
|
+
k(this, "routes");
|
|
1448
|
+
k(this, "base");
|
|
1449
|
+
k(this, "mode");
|
|
1450
|
+
k(this, "beforeEachGuard");
|
|
1451
|
+
k(this, "afterEachGuard");
|
|
1452
|
+
k(this, "currentRoute", null);
|
|
1453
|
+
k(this, "listeners", /* @__PURE__ */ new Set());
|
|
1454
|
+
k(this, "isStarted", !1);
|
|
1390
1455
|
this.routes = t.routes, this.base = t.base ?? "/", this.mode = t.mode || "history", this.beforeEachGuard = t.beforeEach, this.afterEachGuard = t.afterEach;
|
|
1391
1456
|
}
|
|
1392
1457
|
// --- 核心匹配逻辑 ---
|
|
1393
1458
|
matchRoute(t = "/") {
|
|
1394
|
-
const e = t.startsWith("/") ? t : "/" + t, [
|
|
1459
|
+
const e = t.startsWith("/") ? t : "/" + t, [s, r] = e.split("?"), o = s.split("/").filter(Boolean), i = this.parseQuery(r), c = this.recursiveMatch(this.routes, o);
|
|
1395
1460
|
if (c) {
|
|
1396
1461
|
const a = c.matched[c.matched.length - 1];
|
|
1397
1462
|
return a.config.redirect ? this.matchRoute(a.config.redirect) : {
|
|
@@ -1399,7 +1464,7 @@ class Ke {
|
|
|
1399
1464
|
// 这里的结构已经是 [{config, params}, ...]
|
|
1400
1465
|
params: c.params,
|
|
1401
1466
|
// 全局合并后的 params
|
|
1402
|
-
query:
|
|
1467
|
+
query: i,
|
|
1403
1468
|
fullPath: e,
|
|
1404
1469
|
// 合并所有层级的 meta
|
|
1405
1470
|
meta: c.matched.reduce((l, u) => ({ ...l, ...u.config.meta || {} }), {})
|
|
@@ -1408,23 +1473,23 @@ class Ke {
|
|
|
1408
1473
|
return null;
|
|
1409
1474
|
}
|
|
1410
1475
|
recursiveMatch(t, e) {
|
|
1411
|
-
const
|
|
1412
|
-
for (const r of
|
|
1413
|
-
const
|
|
1476
|
+
const s = [...t].sort((r, o) => this.calculateScore(o.path) - this.calculateScore(r.path));
|
|
1477
|
+
for (const r of s) {
|
|
1478
|
+
const o = r.path.split("/").filter(Boolean), i = {};
|
|
1414
1479
|
let c = !0;
|
|
1415
|
-
if (
|
|
1480
|
+
if (o.length === 0 && e.length === 0)
|
|
1416
1481
|
return {
|
|
1417
1482
|
matched: [{ config: r, params: {} }],
|
|
1418
1483
|
params: {}
|
|
1419
1484
|
};
|
|
1420
|
-
for (let a = 0; a <
|
|
1421
|
-
const l =
|
|
1485
|
+
for (let a = 0; a < o.length; a++) {
|
|
1486
|
+
const l = o[a], u = e[a];
|
|
1422
1487
|
if (l.startsWith(":")) {
|
|
1423
1488
|
if (!u) {
|
|
1424
1489
|
c = !1;
|
|
1425
1490
|
break;
|
|
1426
1491
|
}
|
|
1427
|
-
|
|
1492
|
+
i[l.slice(1)] = u;
|
|
1428
1493
|
} else if (l === "*") {
|
|
1429
1494
|
c = !0;
|
|
1430
1495
|
break;
|
|
@@ -1434,19 +1499,19 @@ class Ke {
|
|
|
1434
1499
|
}
|
|
1435
1500
|
}
|
|
1436
1501
|
if (c) {
|
|
1437
|
-
const a =
|
|
1502
|
+
const a = o.length, l = e.slice(a), u = { config: r, params: i };
|
|
1438
1503
|
if (l.length > 0 && r.children) {
|
|
1439
1504
|
const h = this.recursiveMatch(r.children, l);
|
|
1440
1505
|
if (h)
|
|
1441
1506
|
return {
|
|
1442
1507
|
matched: [u, ...h.matched],
|
|
1443
|
-
params: { ...
|
|
1508
|
+
params: { ...i, ...h.params }
|
|
1444
1509
|
// 全局合并 params
|
|
1445
1510
|
};
|
|
1446
|
-
} else if (l.length === 0 ||
|
|
1511
|
+
} else if (l.length === 0 || o.includes("*"))
|
|
1447
1512
|
return {
|
|
1448
1513
|
matched: [u],
|
|
1449
|
-
params:
|
|
1514
|
+
params: i
|
|
1450
1515
|
};
|
|
1451
1516
|
}
|
|
1452
1517
|
}
|
|
@@ -1454,12 +1519,12 @@ class Ke {
|
|
|
1454
1519
|
}
|
|
1455
1520
|
calculateScore(t = "/") {
|
|
1456
1521
|
const e = t.split("/").filter(Boolean);
|
|
1457
|
-
return e.length === 0 ? 1 : e.reduce((
|
|
1522
|
+
return e.length === 0 ? 1 : e.reduce((s, r) => r.startsWith(":") ? s + 5 : r === "*" ? s + 0 : s + 10, 0);
|
|
1458
1523
|
}
|
|
1459
1524
|
parseQuery(t) {
|
|
1460
1525
|
const e = {};
|
|
1461
|
-
return t && new URLSearchParams(t).forEach((r,
|
|
1462
|
-
e[
|
|
1526
|
+
return t && new URLSearchParams(t).forEach((r, o) => {
|
|
1527
|
+
e[o] = r;
|
|
1463
1528
|
}), e;
|
|
1464
1529
|
}
|
|
1465
1530
|
normalizePath(t = "/") {
|
|
@@ -1478,30 +1543,30 @@ class Ke {
|
|
|
1478
1543
|
return e !== "/" && t.startsWith(e) && (t = t.slice(e.length) || "/"), this.normalizePath(t);
|
|
1479
1544
|
}
|
|
1480
1545
|
updateBrowserHistory(t = "/", e) {
|
|
1481
|
-
const
|
|
1546
|
+
const s = this.normalizePath(t), r = this.base || "/";
|
|
1482
1547
|
if (this.mode === "hash")
|
|
1483
|
-
e ? window.location.replace(`#${
|
|
1548
|
+
e ? window.location.replace(`#${s}`) : window.location.hash = s;
|
|
1484
1549
|
else {
|
|
1485
|
-
const
|
|
1486
|
-
e ? window.history.replaceState({ path:
|
|
1550
|
+
const o = r.endsWith("/") ? r.slice(0, -1) : r, i = o === "/" ? s : o + s;
|
|
1551
|
+
e ? window.history.replaceState({ path: i }, "", i) : window.history.pushState({ path: i }, "", i);
|
|
1487
1552
|
}
|
|
1488
1553
|
}
|
|
1489
1554
|
/**
|
|
1490
1555
|
* @param fromEvent 标志位:是否由浏览器 popstate 事件触发
|
|
1491
1556
|
*/
|
|
1492
|
-
async navigate(t = "/", e = !1,
|
|
1493
|
-
const r = this.normalizePath(t),
|
|
1494
|
-
if (!
|
|
1495
|
-
if (
|
|
1557
|
+
async navigate(t = "/", e = !1, s = !1) {
|
|
1558
|
+
const r = this.normalizePath(t), o = this.currentRoute, i = this.matchRoute(r);
|
|
1559
|
+
if (!i) return { success: !1, error: `No route matched: ${r}` };
|
|
1560
|
+
if (o && o.fullPath === i.fullPath) return { success: !0 };
|
|
1496
1561
|
if (this.beforeEachGuard)
|
|
1497
1562
|
try {
|
|
1498
|
-
const c = await this.beforeEachGuard(
|
|
1563
|
+
const c = await this.beforeEachGuard(i, o);
|
|
1499
1564
|
if (c === !1) return { success: !1, cancelled: !0 };
|
|
1500
1565
|
if (typeof c == "string") return this.navigate(c, e);
|
|
1501
1566
|
} catch (c) {
|
|
1502
1567
|
return { success: !1, error: c instanceof Error ? c.message : "Guard Error" };
|
|
1503
1568
|
}
|
|
1504
|
-
return this.currentRoute =
|
|
1569
|
+
return this.currentRoute = i, s || this.updateBrowserHistory(r, e), this.notifyListeners(), this.afterEachGuard && this.afterEachGuard(i, o), { success: !0 };
|
|
1505
1570
|
}
|
|
1506
1571
|
// --- 路径解析逻辑 ---
|
|
1507
1572
|
/**
|
|
@@ -1511,8 +1576,8 @@ class Ke {
|
|
|
1511
1576
|
resolve(t = "/") {
|
|
1512
1577
|
const e = this.normalizePath(t);
|
|
1513
1578
|
if (this.mode === "hash") return `#${e}`;
|
|
1514
|
-
const
|
|
1515
|
-
return
|
|
1579
|
+
const s = this.base.endsWith("/") ? this.base.slice(0, -1) : this.base;
|
|
1580
|
+
return s === "/" ? e : s + e;
|
|
1516
1581
|
}
|
|
1517
1582
|
/**
|
|
1518
1583
|
* 获取当前模式(供外部组件判断,如 RouterLink)
|
|
@@ -1521,8 +1586,8 @@ class Ke {
|
|
|
1521
1586
|
return this.mode;
|
|
1522
1587
|
}
|
|
1523
1588
|
pushWithQuery(t = "/", e) {
|
|
1524
|
-
const
|
|
1525
|
-
return this.push(t + (
|
|
1589
|
+
const s = new URLSearchParams(e).toString(), r = t.includes("?") ? "&" : "?";
|
|
1590
|
+
return this.push(t + (s ? r + s : ""));
|
|
1526
1591
|
}
|
|
1527
1592
|
push(t = "/") {
|
|
1528
1593
|
return this.navigate(t, !1);
|
|
@@ -1550,28 +1615,28 @@ class Ke {
|
|
|
1550
1615
|
return this.currentRoute;
|
|
1551
1616
|
}
|
|
1552
1617
|
}
|
|
1553
|
-
var
|
|
1554
|
-
for (var r =
|
|
1555
|
-
(
|
|
1618
|
+
var qe = Object.getOwnPropertyDescriptor, ze = (n, t, e, s) => {
|
|
1619
|
+
for (var r = s > 1 ? void 0 : s ? qe(t, e) : t, o = n.length - 1, i; o >= 0; o--)
|
|
1620
|
+
(i = n[o]) && (r = i(r) || r);
|
|
1556
1621
|
return r;
|
|
1557
1622
|
};
|
|
1558
|
-
let
|
|
1623
|
+
let dt = class extends ft {
|
|
1559
1624
|
constructor() {
|
|
1560
1625
|
super(...arguments);
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1626
|
+
k(this, "unsubscribe");
|
|
1627
|
+
k(this, "level", 0);
|
|
1628
|
+
k(this, "currentElement", null);
|
|
1629
|
+
k(this, "currentTagName", null);
|
|
1630
|
+
k(this, "routerAttrs", /* @__PURE__ */ new Set());
|
|
1631
|
+
k(this, "prevPropKeys", /* @__PURE__ */ new Set());
|
|
1632
|
+
k(this, "scheduled", !1);
|
|
1633
|
+
k(this, "cache", /* @__PURE__ */ new Map());
|
|
1634
|
+
k(this, "latestLoadId", 0);
|
|
1570
1635
|
}
|
|
1571
1636
|
/* -------------------- 生命周期 -------------------- */
|
|
1572
1637
|
async mounted() {
|
|
1573
1638
|
this.detectLevel();
|
|
1574
|
-
const t = await
|
|
1639
|
+
const t = await Ht;
|
|
1575
1640
|
this.unsubscribe = t.listen(() => {
|
|
1576
1641
|
this.scheduleLoad(t.getCurrentRoute());
|
|
1577
1642
|
}), this.loadRoute(t.getCurrentRoute());
|
|
@@ -1589,52 +1654,52 @@ let yt = class extends mt {
|
|
|
1589
1654
|
detectLevel() {
|
|
1590
1655
|
let t = 0, e = this.parentElement;
|
|
1591
1656
|
for (; e; )
|
|
1592
|
-
e instanceof
|
|
1657
|
+
e instanceof dt && t++, e = e.parentElement;
|
|
1593
1658
|
this.level = t;
|
|
1594
1659
|
}
|
|
1595
1660
|
async loadRoute(t) {
|
|
1596
|
-
const e = ++this.latestLoadId,
|
|
1597
|
-
if (!
|
|
1661
|
+
const e = ++this.latestLoadId, s = t == null ? void 0 : t.matched[this.level];
|
|
1662
|
+
if (!s) {
|
|
1598
1663
|
this.handleEmptyRoute();
|
|
1599
1664
|
return;
|
|
1600
1665
|
}
|
|
1601
|
-
const { config: r } =
|
|
1602
|
-
let
|
|
1603
|
-
if (!
|
|
1666
|
+
const { config: r } = s;
|
|
1667
|
+
let o = r.tagName;
|
|
1668
|
+
if (!o && typeof r.component == "function") {
|
|
1604
1669
|
this.renderLoading();
|
|
1605
1670
|
try {
|
|
1606
1671
|
const c = await r.component();
|
|
1607
|
-
|
|
1672
|
+
o = typeof c == "string" ? c : c.tagName;
|
|
1608
1673
|
} catch (c) {
|
|
1609
1674
|
this.renderError(`Load Error: ${c}`);
|
|
1610
1675
|
return;
|
|
1611
1676
|
}
|
|
1612
1677
|
}
|
|
1613
1678
|
if (e !== this.latestLoadId) return;
|
|
1614
|
-
if (!
|
|
1679
|
+
if (!o) {
|
|
1615
1680
|
this.clear();
|
|
1616
1681
|
return;
|
|
1617
1682
|
}
|
|
1618
|
-
if (!r.forceReload && this.currentElement && this.currentTagName ===
|
|
1683
|
+
if (!r.forceReload && this.currentElement && this.currentTagName === o.toLowerCase()) {
|
|
1619
1684
|
this.syncState(this.currentElement, t == null ? void 0 : t.params, (t == null ? void 0 : t.query) || {}, r.props);
|
|
1620
1685
|
return;
|
|
1621
1686
|
}
|
|
1622
1687
|
this.clear(r.keepAlive);
|
|
1623
|
-
const
|
|
1624
|
-
this.syncState(
|
|
1688
|
+
const i = this.getOrCreateComponent(o, r);
|
|
1689
|
+
this.syncState(i, t == null ? void 0 : t.params, (t == null ? void 0 : t.query) || {}, r.props), this.appendChild(i), this.currentElement = i, this.currentTagName = o.toLowerCase();
|
|
1625
1690
|
}
|
|
1626
1691
|
getOrCreateComponent(t, e) {
|
|
1627
|
-
const
|
|
1628
|
-
if (e.keepAlive && this.cache.has(
|
|
1629
|
-
return this.cache.get(
|
|
1692
|
+
const s = t.toLowerCase();
|
|
1693
|
+
if (e.keepAlive && this.cache.has(s))
|
|
1694
|
+
return this.cache.get(s);
|
|
1630
1695
|
const r = document.createElement(t);
|
|
1631
|
-
return e.keepAlive && this.cache.set(
|
|
1696
|
+
return e.keepAlive && this.cache.set(s, r), r;
|
|
1632
1697
|
}
|
|
1633
|
-
syncState(t, e,
|
|
1634
|
-
const
|
|
1635
|
-
Object.entries(e).forEach(([a, l]) =>
|
|
1636
|
-
|
|
1637
|
-
}),
|
|
1698
|
+
syncState(t, e, s, r = {}) {
|
|
1699
|
+
const o = (a) => a.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), i = /* @__PURE__ */ new Map();
|
|
1700
|
+
Object.entries(e).forEach(([a, l]) => i.set(o(a), String(l))), Object.entries(s).forEach(([a, l]) => i.set(`query-${o(a)}`, String(l))), this.routerAttrs.forEach((a) => {
|
|
1701
|
+
i.has(a) || (t.removeAttribute(a), this.routerAttrs.delete(a));
|
|
1702
|
+
}), i.forEach((a, l) => {
|
|
1638
1703
|
t.getAttribute(l) !== a && t.setAttribute(l, a), this.routerAttrs.add(l);
|
|
1639
1704
|
});
|
|
1640
1705
|
const c = new Set(Object.keys(r));
|
|
@@ -1657,22 +1722,22 @@ let yt = class extends mt {
|
|
|
1657
1722
|
this.currentElement ? this.contains(this.currentElement) && this.removeChild(this.currentElement) : t || (this.innerHTML = ""), this.currentElement = null, this.currentTagName = null, this.routerAttrs.clear(), this.prevPropKeys.clear();
|
|
1658
1723
|
}
|
|
1659
1724
|
};
|
|
1660
|
-
|
|
1661
|
-
|
|
1725
|
+
dt = ze([
|
|
1726
|
+
zt({
|
|
1662
1727
|
tagName: "router-view"
|
|
1663
1728
|
// 注意:删除了 shadowDOM 配置,默认为 false
|
|
1664
1729
|
})
|
|
1665
|
-
],
|
|
1666
|
-
const
|
|
1667
|
-
var
|
|
1668
|
-
for (var r =
|
|
1669
|
-
(
|
|
1730
|
+
], dt);
|
|
1731
|
+
const Xe = dt;
|
|
1732
|
+
var Ke = Object.getOwnPropertyDescriptor, Ue = (n, t, e, s) => {
|
|
1733
|
+
for (var r = s > 1 ? void 0 : s ? Ke(t, e) : t, o = n.length - 1, i; o >= 0; o--)
|
|
1734
|
+
(i = n[o]) && (r = i(r) || r);
|
|
1670
1735
|
return r;
|
|
1671
1736
|
};
|
|
1672
|
-
let
|
|
1737
|
+
let At = class extends ft {
|
|
1673
1738
|
constructor() {
|
|
1674
1739
|
super(...arguments);
|
|
1675
|
-
|
|
1740
|
+
k(this, "_prefetched", !1);
|
|
1676
1741
|
}
|
|
1677
1742
|
set to(t) {
|
|
1678
1743
|
this.$data.to = t, this.updateState();
|
|
@@ -1681,15 +1746,15 @@ let It = class extends mt {
|
|
|
1681
1746
|
return this.$data.to;
|
|
1682
1747
|
}
|
|
1683
1748
|
async mounted() {
|
|
1684
|
-
(await
|
|
1685
|
-
var r,
|
|
1686
|
-
e.defaultPrevented || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || e.button !== 0 || (r = e.target.closest("a")) != null && r.getAttribute("target") || (e.preventDefault(), (
|
|
1749
|
+
(await Ht).listen(() => this.updateState()), this.updateState(), this.addEventListener("click", (e) => {
|
|
1750
|
+
var r, o;
|
|
1751
|
+
e.defaultPrevented || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || e.button !== 0 || (r = e.target.closest("a")) != null && r.getAttribute("target") || (e.preventDefault(), (o = Et()) == null || o.push(this.$data.to));
|
|
1687
1752
|
}), this.addEventListener("mouseenter", () => {
|
|
1688
1753
|
this.prefetchRoute();
|
|
1689
1754
|
}, { once: !0 });
|
|
1690
1755
|
}
|
|
1691
1756
|
updateState() {
|
|
1692
|
-
const t =
|
|
1757
|
+
const t = Et();
|
|
1693
1758
|
if (!t) return;
|
|
1694
1759
|
this.$data.href = t.resolve(this.$data.to);
|
|
1695
1760
|
let e = !1;
|
|
@@ -1698,23 +1763,23 @@ let It = class extends mt {
|
|
|
1698
1763
|
else {
|
|
1699
1764
|
const r = t.getCurrentRoute();
|
|
1700
1765
|
if (r) {
|
|
1701
|
-
const
|
|
1702
|
-
this.hasAttribute("exact") ? e =
|
|
1766
|
+
const o = r.fullPath;
|
|
1767
|
+
this.hasAttribute("exact") ? e = o === this.$data.to : e = o === this.$data.to || o.startsWith(this.$data.to + "/");
|
|
1703
1768
|
}
|
|
1704
1769
|
}
|
|
1705
1770
|
this.$data.isActive = e;
|
|
1706
|
-
const
|
|
1707
|
-
this.classList.toggle(
|
|
1771
|
+
const s = this.$data.activeClass || "active";
|
|
1772
|
+
this.classList.toggle(s, e);
|
|
1708
1773
|
}
|
|
1709
1774
|
// 预加载路由的具体实现
|
|
1710
1775
|
prefetchRoute() {
|
|
1711
1776
|
if (this._prefetched || !this.hasAttribute("prefetch")) return;
|
|
1712
|
-
const t =
|
|
1777
|
+
const t = Et();
|
|
1713
1778
|
t && typeof t.prefetch == "function" && (t.prefetch(this.$data.to), this._prefetched = !0);
|
|
1714
1779
|
}
|
|
1715
1780
|
};
|
|
1716
|
-
|
|
1717
|
-
|
|
1781
|
+
At = Ue([
|
|
1782
|
+
zt({
|
|
1718
1783
|
tagName: "router-link",
|
|
1719
1784
|
// template 中 slot 包裹 label 作为 fallback:
|
|
1720
1785
|
// 如果有子节点,显示子节点;如果没有,显示 label 属性的内容。
|
|
@@ -1747,32 +1812,32 @@ It = He([
|
|
|
1747
1812
|
// 注册所有支持的 props
|
|
1748
1813
|
props: ["to", "active", "exact", "label", "custom", "activeClass", "prefetch"]
|
|
1749
1814
|
})
|
|
1750
|
-
],
|
|
1751
|
-
const
|
|
1815
|
+
], At);
|
|
1816
|
+
const Qe = At;
|
|
1752
1817
|
export {
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1818
|
+
y as ASTType,
|
|
1819
|
+
ft as BaseElement,
|
|
1820
|
+
zt as CustomElement,
|
|
1821
|
+
je as IRRenderer,
|
|
1757
1822
|
de as LIFECYCLE_ATTRS_MAP,
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1823
|
+
Ge as Router,
|
|
1824
|
+
Qe as RouterLink,
|
|
1825
|
+
Xe as RouterView,
|
|
1761
1826
|
xe as buildIR,
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1827
|
+
Ze as clearIRCache,
|
|
1828
|
+
ne as createFunction,
|
|
1829
|
+
Be as createRender,
|
|
1830
|
+
Je as createRouter,
|
|
1766
1831
|
he as genFunction,
|
|
1767
|
-
|
|
1832
|
+
Et as getRouter,
|
|
1768
1833
|
me as isLifecycleKind,
|
|
1769
|
-
|
|
1834
|
+
K as isObject,
|
|
1770
1835
|
fe as listeners,
|
|
1771
1836
|
pe as mapAttrKeyToLifecycleKind,
|
|
1772
1837
|
Me as observe,
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1838
|
+
Ye as parseHashUrl,
|
|
1839
|
+
Le as parseHtml,
|
|
1840
|
+
Ht as routerReady,
|
|
1841
|
+
ee as showTemplateError,
|
|
1842
|
+
Ee as transformModel
|
|
1778
1843
|
};
|