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