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