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