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