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