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