solely 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/solely.js +188 -180
- package/dist/solely.umd.cjs +1 -1
- package/dist/utils/ast-processor copy /344/277/256/346/255/243/345/244/232/351/207/215/345/276/252/347/216/257/351/224/231/350/257/257.d.ts" +2 -0
- package/dist/utils/html-parse copy /344/277/256/346/255/243/345/244/232/351/207/215/345/276/252/347/216/257/351/224/231/350/257/257.d.ts" +25 -0
- package/dist/utils/html-parse.d.ts +2 -1
- package/package.json +1 -1
package/dist/solely.js
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Q = (e) => {
|
|
2
2
|
throw TypeError(e);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
const
|
|
7
|
-
function
|
|
4
|
+
var V = (e, t, n) => t.has(e) || Q("Cannot " + n);
|
|
5
|
+
var E = (e, t, n) => (V(e, t, "read from private field"), n ? n.call(e) : t.get(e)), m = (e, t, n) => t.has(e) ? Q("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), f = (e, t, n, s) => (V(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n), M = (e, t, n) => (V(e, t, "access private method"), n);
|
|
6
|
+
const ht = /<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g, ut = /<\/?([^\s]+?)[/\s>]/, ft = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g, pt = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"], F = /\{\{(.+?)\}\}/g;
|
|
7
|
+
function mt(e) {
|
|
8
8
|
return e.replace(/>\s+</g, "><").replace(/\s+/g, " ");
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const n = (t.match(
|
|
12
|
-
rootId: 0,
|
|
10
|
+
function dt(e, t) {
|
|
11
|
+
const n = (t.match(ut) || [])[1] || "", s = {
|
|
12
|
+
rootId: "0",
|
|
13
13
|
tagName: n,
|
|
14
14
|
attrs: {},
|
|
15
15
|
props: {},
|
|
16
16
|
on: {},
|
|
17
17
|
children: []
|
|
18
|
-
}, r = new RegExp(
|
|
18
|
+
}, r = new RegExp(ft);
|
|
19
19
|
for (; ; ) {
|
|
20
20
|
const a = r.exec(t);
|
|
21
21
|
if (a === null) break;
|
|
22
22
|
if (!a[0].trim()) continue;
|
|
23
|
-
const [o,
|
|
24
|
-
if (
|
|
25
|
-
s.on[o.startsWith("on-") ? o.slice(3) : o.slice(2)] =
|
|
23
|
+
const [o, c] = a[1] ? a[1].trim().split("=") : [a[2], a[3].trim().slice(1, -1)];
|
|
24
|
+
if (Z.includes(o) || o.startsWith("on-"))
|
|
25
|
+
s.on[o.startsWith("on-") ? o.slice(3) : o.slice(2)] = K(e, c);
|
|
26
26
|
else if (o.startsWith("s-")) {
|
|
27
27
|
const h = o.slice(2);
|
|
28
28
|
switch (h) {
|
|
29
29
|
case "model":
|
|
30
|
-
s.model =
|
|
30
|
+
s.model = c;
|
|
31
31
|
break;
|
|
32
32
|
case "style":
|
|
33
|
-
s.styles = (
|
|
33
|
+
s.styles = (i) => d(e, c, i);
|
|
34
34
|
break;
|
|
35
35
|
case "class":
|
|
36
|
-
s.classes = (
|
|
36
|
+
s.classes = (i) => d(e, c, i);
|
|
37
37
|
break;
|
|
38
38
|
case "readonly":
|
|
39
|
-
s.props.readOnly = (
|
|
39
|
+
s.props.readOnly = (i) => d(e, c, i);
|
|
40
40
|
break;
|
|
41
41
|
default:
|
|
42
|
-
s.props[h] = (
|
|
42
|
+
s.props[h] = (i) => d(e, c, i);
|
|
43
43
|
break;
|
|
44
44
|
}
|
|
45
45
|
} else
|
|
46
|
-
s.attrs[o] =
|
|
46
|
+
s.attrs[o] = c;
|
|
47
47
|
r.lastIndex--;
|
|
48
48
|
}
|
|
49
|
-
if (n === "For" ? s.fn = (a) =>
|
|
50
|
-
const a = s.model.replace("this.", "").replace("$data.", ""), o = (h) =>
|
|
51
|
-
n === "input" ? s.attrs.type === "checkbox" || s.attrs.type === "radio" ? (s.props.checked = o, s.on.change =
|
|
49
|
+
if (n === "For" ? s.fn = (a) => d(e, s.attrs.each, a) : (n === "If" || n === "ElseIf") && (s.fn = (a) => d(e, s.attrs.condition, a)), s.model) {
|
|
50
|
+
const a = s.model.replace("this.", "").replace("$data.", ""), o = (h) => d(e, `$data.${a}`, h), c = (h) => K(e, `$data.${a}=${h}`);
|
|
51
|
+
n === "input" ? s.attrs.type === "checkbox" || s.attrs.type === "radio" ? (s.props.checked = o, s.on.change = c("checked")) : (s.props.value = o, s.on.input = c("value")) : n === "textarea" ? (s.props.value = o, s.on.input = c("value")) : n === "select" && (s.props.value = o, s.on.change = c("value"));
|
|
52
52
|
}
|
|
53
53
|
return s;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function gt(e, t) {
|
|
56
56
|
const n = [];
|
|
57
57
|
if (!t) return n;
|
|
58
|
-
t =
|
|
58
|
+
t = mt(t);
|
|
59
59
|
const s = [], r = [], a = () => {
|
|
60
|
-
var
|
|
61
|
-
return s.length === 0 ? n : (
|
|
60
|
+
var c;
|
|
61
|
+
return s.length === 0 ? n : (c = s[s.length - 1]).children || (c.children = []);
|
|
62
62
|
};
|
|
63
63
|
let o = 0;
|
|
64
|
-
return t.replace(
|
|
65
|
-
const
|
|
64
|
+
return t.replace(ht, (c, h) => {
|
|
65
|
+
const i = a();
|
|
66
66
|
if (h > o) {
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
rootId: 0,
|
|
67
|
+
const l = t.substring(o, h).trim();
|
|
68
|
+
if (l) {
|
|
69
|
+
F.lastIndex = 0;
|
|
70
|
+
const P = !F.test(l) ? l : (W) => l.replace(F, (T, D) => d(e, D, W));
|
|
71
|
+
i.push({
|
|
72
|
+
rootId: "0",
|
|
73
73
|
tagName: "text",
|
|
74
74
|
attrs: {},
|
|
75
75
|
props: {},
|
|
76
76
|
on: {},
|
|
77
|
-
content:
|
|
77
|
+
content: P,
|
|
78
78
|
children: []
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
if (o = h +
|
|
83
|
-
|
|
84
|
-
rootId: 0,
|
|
82
|
+
if (o = h + c.length, c.startsWith("<!--") && c.endsWith("-->"))
|
|
83
|
+
i.push({
|
|
84
|
+
rootId: "0",
|
|
85
85
|
tagName: "comment",
|
|
86
86
|
attrs: {},
|
|
87
87
|
props: {},
|
|
88
88
|
on: {},
|
|
89
|
-
content:
|
|
89
|
+
content: c.slice(4, -3),
|
|
90
90
|
children: []
|
|
91
91
|
});
|
|
92
|
-
else if (
|
|
93
|
-
const
|
|
94
|
-
for (; s.length > 0 && s[s.length - 1].tagName !==
|
|
92
|
+
else if (c.startsWith("</")) {
|
|
93
|
+
const l = r.pop();
|
|
94
|
+
for (; s.length > 0 && s[s.length - 1].tagName !== l; )
|
|
95
95
|
s.pop();
|
|
96
96
|
s.pop();
|
|
97
97
|
} else {
|
|
98
|
-
const
|
|
99
|
-
|
|
98
|
+
const l = dt(e, c), u = c.endsWith("/>") || pt.includes(l.tagName);
|
|
99
|
+
i.push(l), u || (s.push(l), r.push(l.tagName));
|
|
100
100
|
}
|
|
101
101
|
return "";
|
|
102
102
|
}), t.length > o && n.push({
|
|
103
|
-
rootId: 0,
|
|
103
|
+
rootId: "0",
|
|
104
104
|
tagName: "text",
|
|
105
105
|
attrs: {},
|
|
106
106
|
props: {},
|
|
@@ -109,13 +109,13 @@ function Et(e, t) {
|
|
|
109
109
|
children: []
|
|
110
110
|
}), n;
|
|
111
111
|
}
|
|
112
|
-
const
|
|
112
|
+
const d = (e, t, n) => {
|
|
113
113
|
try {
|
|
114
|
-
return
|
|
114
|
+
return J(["$data", ...n.map((r) => r.item), ...n.map((r) => r.index), `return (${t})`]).bind(e)(e.$data, ...n.map((r) => r.value), ...n.map((r) => r.valueIndex));
|
|
115
115
|
} catch (s) {
|
|
116
116
|
console.error(s);
|
|
117
117
|
}
|
|
118
|
-
},
|
|
118
|
+
}, K = (e, t) => (n, s) => J(["$data", "event", "value", "checked", ...s.map((a) => a.item), ...s.map((a) => a.index), t]).bind(e)(e.$data, n, n.target.value, n.target.checked, ...s.map((a) => a.value), ...s.map((a) => a.valueIndex)), Z = [
|
|
119
119
|
"onabort",
|
|
120
120
|
"onautocomplete",
|
|
121
121
|
"onautocompleteerror",
|
|
@@ -178,31 +178,31 @@ const g = (e, t, n) => {
|
|
|
178
178
|
"ontoggle",
|
|
179
179
|
"onvolumechange",
|
|
180
180
|
"onwaiting"
|
|
181
|
-
],
|
|
181
|
+
], Et = /* @__PURE__ */ (() => {
|
|
182
182
|
const e = typeof requestAnimationFrame == "function" ? (t) => requestAnimationFrame(t) : typeof Promise < "u" ? (t) => Promise.resolve().then(t) : (t) => setTimeout(t, 0);
|
|
183
183
|
return (t, ...n) => {
|
|
184
184
|
if (typeof t != "function")
|
|
185
185
|
throw new Error("runInAsyncQueue expects a function as its first argument");
|
|
186
186
|
e(() => t(...n));
|
|
187
187
|
};
|
|
188
|
-
})(),
|
|
189
|
-
function
|
|
188
|
+
})(), j = {};
|
|
189
|
+
function J(e) {
|
|
190
190
|
const t = e.map((n) => n.replace(/[',"]/g, "")).join(",");
|
|
191
|
-
if (!
|
|
191
|
+
if (!j[t]) {
|
|
192
192
|
const n = e[e.length - 1];
|
|
193
193
|
if (n.trim() === "")
|
|
194
194
|
throw new Error("Function body cannot be empty");
|
|
195
195
|
if (yt(n))
|
|
196
196
|
throw new Error("Input contains potentially dangerous code: " + n);
|
|
197
|
-
|
|
197
|
+
j[t] = new Function(...e);
|
|
198
198
|
}
|
|
199
|
-
return
|
|
199
|
+
return j[t];
|
|
200
200
|
}
|
|
201
|
-
const
|
|
201
|
+
const vt = ["eval", "Function", "process", "require"];
|
|
202
202
|
function yt(e) {
|
|
203
|
-
return
|
|
203
|
+
return vt.some((t) => new RegExp(`\\b${t}\\b`, "g").test(e));
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const bt = "http://www.w3.org/1999/xlink", wt = "http://www.w3.org/2000/xmlns/", $t = "http://www.w3.org/XML/1998/namespace", kt = "http://www.w3.org/2000/svg", Y = (e) => typeof e.content == "function" ? e.content(e.loops || []) : e.content || "", _t = (e) => {
|
|
206
206
|
const t = Y(e), n = e.elm;
|
|
207
207
|
n.textContent !== t && (n.textContent = t);
|
|
208
208
|
}, tt = (e, t, n = []) => {
|
|
@@ -213,22 +213,22 @@ const wt = "http://www.w3.org/1999/xlink", _t = "http://www.w3.org/2000/xmlns/",
|
|
|
213
213
|
}, et = (e, t) => {
|
|
214
214
|
const { styles: n, loops: s = [] } = t;
|
|
215
215
|
if (!n) return;
|
|
216
|
-
const r = n(s), a =
|
|
217
|
-
Object.entries(a).forEach(([o,
|
|
218
|
-
e.style[o] =
|
|
216
|
+
const r = n(s), a = q(r);
|
|
217
|
+
Object.entries(a).forEach(([o, c]) => {
|
|
218
|
+
e.style[o] = c;
|
|
219
219
|
});
|
|
220
220
|
}, nt = (e, t) => {
|
|
221
221
|
const { classes: n, loops: s = [] } = t;
|
|
222
222
|
if (!n) return;
|
|
223
223
|
const r = n(s), a = st(r);
|
|
224
|
-
Object.entries(a).forEach(([o,
|
|
225
|
-
|
|
224
|
+
Object.entries(a).forEach(([o, c]) => {
|
|
225
|
+
c ? e.classList.add(o) : e.classList.remove(o);
|
|
226
226
|
});
|
|
227
|
-
},
|
|
227
|
+
}, q = (e) => {
|
|
228
228
|
let t = {};
|
|
229
229
|
return typeof e == "object" && e !== null && !Array.isArray(e) ? Object.entries(e).forEach(([n, s]) => {
|
|
230
230
|
if (typeof s == "object" && s !== null && !Array.isArray(s)) {
|
|
231
|
-
const r =
|
|
231
|
+
const r = q(s);
|
|
232
232
|
Object.entries(r).forEach(([a, o]) => {
|
|
233
233
|
t[`${n}-${a}`] = o;
|
|
234
234
|
});
|
|
@@ -237,7 +237,7 @@ const wt = "http://www.w3.org/1999/xlink", _t = "http://www.w3.org/2000/xmlns/",
|
|
|
237
237
|
const [s, r] = n.split(":").map((a) => a.trim());
|
|
238
238
|
s && r && (t[s] = r);
|
|
239
239
|
}) : Array.isArray(e) && e.forEach((n) => {
|
|
240
|
-
const s =
|
|
240
|
+
const s = q(n);
|
|
241
241
|
Object.entries(s).forEach(([r, a]) => {
|
|
242
242
|
t[r] = a;
|
|
243
243
|
});
|
|
@@ -257,107 +257,115 @@ const wt = "http://www.w3.org/1999/xlink", _t = "http://www.w3.org/2000/xmlns/",
|
|
|
257
257
|
}, rt = (e, t, n) => {
|
|
258
258
|
const s = (r) => n.on[t](r, n.loops || []);
|
|
259
259
|
e.addEventListener(t, s, !1), n.handlers = n.handlers || {}, n.handlers[t] = s;
|
|
260
|
-
},
|
|
260
|
+
}, Ct = (e, t) => {
|
|
261
261
|
const n = t.elm;
|
|
262
262
|
Object.keys(t.on).forEach((s) => {
|
|
263
263
|
e.handlers && e.handlers[s] && n.removeEventListener(s, e.handlers[s], !1), rt(n, s, t);
|
|
264
264
|
}), tt(n, t.props, t.loops), nt(n, t), et(n, t), at(n, e.children, t.children);
|
|
265
|
-
},
|
|
265
|
+
}, xt = (e, t) => {
|
|
266
266
|
switch (t.elm = e.elm, t.tagName) {
|
|
267
267
|
case "comment":
|
|
268
268
|
break;
|
|
269
269
|
case "text":
|
|
270
|
-
|
|
270
|
+
_t(t);
|
|
271
271
|
break;
|
|
272
272
|
case "slot":
|
|
273
273
|
break;
|
|
274
274
|
default:
|
|
275
|
-
|
|
275
|
+
Ct(e, t);
|
|
276
276
|
break;
|
|
277
277
|
}
|
|
278
|
-
},
|
|
278
|
+
}, B = (e, t, n) => {
|
|
279
279
|
n ? e.insertBefore(t, n) : e.appendChild(t);
|
|
280
|
-
},
|
|
280
|
+
}, At = (e, t, n) => {
|
|
281
281
|
const s = Y(t), r = document.createTextNode(s);
|
|
282
|
-
t.elm = r,
|
|
283
|
-
},
|
|
282
|
+
t.elm = r, B(e, r, n);
|
|
283
|
+
}, Rt = (e, t, n) => {
|
|
284
284
|
const s = t.content, r = document.createComment(s);
|
|
285
|
-
t.elm = r,
|
|
286
|
-
},
|
|
287
|
-
t.tagName === "svg" && (s =
|
|
285
|
+
t.elm = r, B(e, r, n);
|
|
286
|
+
}, It = (e, t, n, s) => {
|
|
287
|
+
t.tagName === "svg" && (s = kt);
|
|
288
288
|
const r = s ? document.createElementNS(s, t.tagName) : document.createElement(t.tagName);
|
|
289
289
|
Object.keys(t.attrs).forEach((a) => {
|
|
290
290
|
const o = t.attrs[a] || "";
|
|
291
|
-
a.charAt(0) !== "x" ? r.setAttribute(a, o) : a.startsWith("xml:") ? r.setAttributeNS(
|
|
291
|
+
a.charAt(0) !== "x" ? r.setAttribute(a, o) : a.startsWith("xml:") ? r.setAttributeNS($t, a, o) : a.startsWith("xlink:") ? r.setAttributeNS(bt, a, o) : a.startsWith("xmlns:") ? r.setAttributeNS(wt, a, o) : r.setAttribute(a, o);
|
|
292
292
|
}), Object.keys(t.on).forEach((a) => {
|
|
293
293
|
rt(r, a, t);
|
|
294
|
-
}), tt(r, t.props, t.loops), nt(r, t), et(r, t), t.elm = r,
|
|
295
|
-
|
|
294
|
+
}), tt(r, t.props, t.loops), nt(r, t), et(r, t), t.elm = r, B(e, r, n), t.tagName === "foreignObject" && (s = void 0), t.children.forEach((a) => {
|
|
295
|
+
N(r, a, void 0, s);
|
|
296
296
|
});
|
|
297
|
-
},
|
|
297
|
+
}, N = (e, t, n, s) => {
|
|
298
298
|
switch (t.tagName) {
|
|
299
299
|
case "comment":
|
|
300
|
-
|
|
300
|
+
Rt(e, t, n);
|
|
301
301
|
break;
|
|
302
302
|
case "text":
|
|
303
|
-
|
|
303
|
+
At(e, t, n);
|
|
304
304
|
break;
|
|
305
305
|
default:
|
|
306
|
-
|
|
306
|
+
It(e, t, n, s);
|
|
307
307
|
break;
|
|
308
308
|
}
|
|
309
|
-
},
|
|
310
|
-
var
|
|
311
|
-
for (let
|
|
312
|
-
const
|
|
313
|
-
if (
|
|
314
|
-
let
|
|
315
|
-
for (((
|
|
316
|
-
((
|
|
317
|
-
|
|
318
|
-
} else if (
|
|
319
|
-
const { item:
|
|
320
|
-
(
|
|
321
|
-
const
|
|
322
|
-
y(e,
|
|
309
|
+
}, St = (e) => e && (e.tagName === "ElseIf" || e.tagName === "comment"), Wt = (e) => e && e.tagName === "Else", y = (e, t, n = [], s = "0", r) => {
|
|
310
|
+
var a, o, c;
|
|
311
|
+
for (let h = 0; h < t.length; h++) {
|
|
312
|
+
const i = t[h];
|
|
313
|
+
if (i.tagName === "If") {
|
|
314
|
+
let l = !1, u = 1;
|
|
315
|
+
for (((a = i.fn) == null ? void 0 : a.call(i, n)) && (y(e, i.children, n, `${s}-if-${u}`, u), l = !0), u++; h + 1 < t.length && St(t[h + 1]); )
|
|
316
|
+
((c = (o = t[h + 1]).fn) == null ? void 0 : c.call(o, n)) && !l && (y(e, t[h + 1].children, n, `${s}-if-${u}`, u), l = !0), h++, u++;
|
|
317
|
+
h + 1 < t.length && Wt(t[h + 1]) && (l || (y(e, t[h + 1].children, n, `${s}-if-${u}`, u), l = !0), h++);
|
|
318
|
+
} else if (i.tagName === "For") {
|
|
319
|
+
const { item: l = "item", index: u = "index" } = i.attrs;
|
|
320
|
+
(i.fn(n) || []).forEach((W, T) => {
|
|
321
|
+
const D = { item: l, value: W, index: u, valueIndex: T };
|
|
322
|
+
y(e, i.children, [...n, D], `${s}-for-${T}`, 1);
|
|
323
323
|
});
|
|
324
324
|
} else {
|
|
325
|
-
const
|
|
326
|
-
...
|
|
325
|
+
const l = {
|
|
326
|
+
...i,
|
|
327
327
|
loops: n,
|
|
328
328
|
children: [],
|
|
329
329
|
rootId: s,
|
|
330
|
-
ifId:
|
|
330
|
+
ifId: r,
|
|
331
|
+
key: i.key || `${s}-${h}`
|
|
332
|
+
// 添加 key 属性
|
|
331
333
|
};
|
|
332
|
-
y(
|
|
334
|
+
y(l.children, i.children, n, `${s}-${h}`), e.push(l);
|
|
333
335
|
}
|
|
334
|
-
r && s++;
|
|
335
336
|
}
|
|
336
337
|
}, at = (e, t, n) => {
|
|
337
|
-
var
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
c.rootId === u.rootId ? (u.ifId && c.ifId !== u.ifId ? ((a = c.elm) == null || a.remove(), M(e, u, (o = t[s + 1]) == null ? void 0 : o.elm)) : At(c, u), r++, s++) : c.rootId > u.rootId ? ((i = c.elm) == null || i.remove(), s++) : (M(e, u, (h = t[s + 1]) == null ? void 0 : h.elm), r++);
|
|
342
|
-
}
|
|
343
|
-
for (; s < t.length; )
|
|
344
|
-
(l = t[s].elm) == null || l.remove(), s++;
|
|
338
|
+
var o, c, h;
|
|
339
|
+
const s = /* @__PURE__ */ new Map();
|
|
340
|
+
t.forEach((i, l) => s.set(i.key, { node: i, index: l }));
|
|
341
|
+
let r = 0, a = 0;
|
|
345
342
|
for (; r < n.length; ) {
|
|
346
|
-
const
|
|
347
|
-
|
|
343
|
+
const i = n[r], l = s.get(i.key);
|
|
344
|
+
if (l) {
|
|
345
|
+
const u = l.node;
|
|
346
|
+
i.ifId && u.ifId !== i.ifId ? ((o = u.elm) == null || o.remove(), N(e, i, (c = t[a + 1]) == null ? void 0 : c.elm)) : xt(u, i), s.delete(i.key), a++;
|
|
347
|
+
} else {
|
|
348
|
+
const u = (h = t[a]) == null ? void 0 : h.elm;
|
|
349
|
+
N(e, i, u);
|
|
350
|
+
}
|
|
351
|
+
r++;
|
|
348
352
|
}
|
|
349
|
-
|
|
353
|
+
s.forEach(({ node: i }) => {
|
|
354
|
+
var l;
|
|
355
|
+
return (l = i.elm) == null ? void 0 : l.remove();
|
|
356
|
+
});
|
|
357
|
+
}, U = (e, t, n = []) => {
|
|
350
358
|
if (!t || t.length === 0) return [];
|
|
351
359
|
const s = [];
|
|
352
|
-
return y(s, t || [], [], 0
|
|
360
|
+
return y(s, t || [], [], "0"), at(e, n, s), s;
|
|
353
361
|
}, ot = (e) => typeof e == "object" && e != null;
|
|
354
362
|
function Mt(e = window.location) {
|
|
355
363
|
let t;
|
|
356
364
|
typeof e == "string" ? t = new URL(e).hash : t = e.hash;
|
|
357
365
|
const n = t.split("?"), s = n[0].substring(2), r = n[1], a = {};
|
|
358
366
|
return r && r.split("&").forEach((o) => {
|
|
359
|
-
const [
|
|
360
|
-
|
|
367
|
+
const [c, h] = o.split("=");
|
|
368
|
+
c && h && (a[decodeURIComponent(c)] = decodeURIComponent(h));
|
|
361
369
|
}), {
|
|
362
370
|
path: s.split("/"),
|
|
363
371
|
// 将路径分割成数组
|
|
@@ -372,82 +380,82 @@ const it = (e, t) => new Proxy(e, {
|
|
|
372
380
|
},
|
|
373
381
|
set: (n, s, r) => (n[s] !== r && (n[s] = r, t(s, r)), !0)
|
|
374
382
|
});
|
|
375
|
-
var
|
|
376
|
-
class
|
|
383
|
+
var A, R, I, w, S, $, k, H;
|
|
384
|
+
class Ft extends HTMLElement {
|
|
377
385
|
constructor() {
|
|
378
386
|
super();
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
387
|
+
m(this, k);
|
|
388
|
+
m(this, A, {});
|
|
389
|
+
m(this, R, []);
|
|
390
|
+
m(this, I, []);
|
|
391
|
+
m(this, w, !1);
|
|
392
|
+
m(this, S, !1);
|
|
393
|
+
m(this, $);
|
|
386
394
|
const n = this._manifest || {};
|
|
387
|
-
n.template && typeof n.template == "string" &&
|
|
395
|
+
n.template && typeof n.template == "string" && f(this, R, gt(this, n.template)), n.shadowDOM && n.shadowDOM.use ? f(this, $, this.attachShadow({
|
|
388
396
|
mode: n.shadowDOM.mode || "open"
|
|
389
|
-
})) :
|
|
397
|
+
})) : f(this, $, this);
|
|
390
398
|
}
|
|
391
399
|
get $data() {
|
|
392
|
-
let n =
|
|
393
|
-
return ot(n) && (n = it(n, () =>
|
|
400
|
+
let n = E(this, A);
|
|
401
|
+
return ot(n) && (n = it(n, () => M(this, k, H).call(this))), n;
|
|
394
402
|
}
|
|
395
403
|
set $data(n) {
|
|
396
|
-
|
|
404
|
+
f(this, A, n || {}), M(this, k, H).call(this);
|
|
397
405
|
}
|
|
398
406
|
connectedCallback() {
|
|
399
407
|
const n = this._manifest || {};
|
|
400
408
|
(n.className || n.tagName || "").split(" ").forEach((r) => {
|
|
401
409
|
r && this.classList.add(r);
|
|
402
|
-
}),
|
|
410
|
+
}), M(this, k, H).call(this);
|
|
403
411
|
}
|
|
404
412
|
onInit() {
|
|
405
413
|
}
|
|
406
414
|
disconnectedCallback() {
|
|
407
415
|
}
|
|
408
416
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
417
|
+
A = new WeakMap(), R = new WeakMap(), I = new WeakMap(), w = new WeakMap(), S = new WeakMap(), $ = new WeakMap(), k = new WeakSet(), H = function() {
|
|
418
|
+
E(this, w) || (f(this, w, !0), Et(() => {
|
|
419
|
+
f(this, I, U(E(this, $), E(this, R), E(this, I))), f(this, w, !1), this.isConnected && !E(this, S) && (f(this, S, !0), this.onInit());
|
|
412
420
|
}));
|
|
413
421
|
};
|
|
414
|
-
const
|
|
422
|
+
const Ht = (e) => (t) => {
|
|
415
423
|
if (customElements.get(e.tagName)) {
|
|
416
424
|
console.warn(`标签名称 "${e.tagName}" 已经被注册`);
|
|
417
425
|
return;
|
|
418
426
|
}
|
|
419
|
-
return t.prototype._manifest =
|
|
420
|
-
},
|
|
427
|
+
return t.prototype._manifest = Ot(e), customElements.define(e.tagName, t), t;
|
|
428
|
+
}, Ot = (e) => (e = Object.assign({
|
|
421
429
|
hasConfig: !1
|
|
422
430
|
}, e), e);
|
|
423
|
-
var
|
|
431
|
+
var Lt = Object.defineProperty, Pt = Object.getOwnPropertyDescriptor, ct = (e) => {
|
|
424
432
|
throw TypeError(e);
|
|
425
|
-
},
|
|
426
|
-
for (var r = s > 1 ? void 0 : s ?
|
|
433
|
+
}, Tt = (e, t, n, s) => {
|
|
434
|
+
for (var r = s > 1 ? void 0 : s ? Pt(t, n) : t, a = e.length - 1, o; a >= 0; a--)
|
|
427
435
|
(o = e[a]) && (r = (s ? o(t, n, r) : o(r)) || r);
|
|
428
|
-
return s && r &&
|
|
429
|
-
},
|
|
430
|
-
let
|
|
436
|
+
return s && r && Lt(t, n, r), r;
|
|
437
|
+
}, G = (e, t, n) => t.has(e) || ct("Cannot " + n), g = (e, t, n) => (G(e, t, "read from private field"), n ? n.call(e) : t.get(e)), v = (e, t, n) => t.has(e) ? ct("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), p = (e, t, n, s) => (G(e, t, "write to private field"), t.set(e, n), n), Dt = (e, t, n) => (G(e, t, "access private method"), n), _, O, x, C, b, L, z, lt;
|
|
438
|
+
let X = class extends HTMLElement {
|
|
431
439
|
constructor() {
|
|
432
|
-
super(...arguments),
|
|
440
|
+
super(...arguments), v(this, z), v(this, _, []), v(this, O, []), v(this, x, null), v(this, C), v(this, b, []), v(this, L, {});
|
|
433
441
|
}
|
|
434
442
|
get isRouterView() {
|
|
435
443
|
return !0;
|
|
436
444
|
}
|
|
437
445
|
get $routes() {
|
|
438
|
-
return
|
|
446
|
+
return g(this, b);
|
|
439
447
|
}
|
|
440
448
|
set $routes(e) {
|
|
441
|
-
p(this,
|
|
449
|
+
p(this, b, e), this.onHashChange();
|
|
442
450
|
}
|
|
443
451
|
get $remainingPath() {
|
|
444
|
-
return
|
|
452
|
+
return g(this, O);
|
|
445
453
|
}
|
|
446
454
|
get $matchedRoute() {
|
|
447
|
-
return
|
|
455
|
+
return g(this, x);
|
|
448
456
|
}
|
|
449
457
|
set $pipe(e) {
|
|
450
|
-
p(this,
|
|
458
|
+
p(this, L, e || {}), this.onHashChange();
|
|
451
459
|
}
|
|
452
460
|
connectedCallback() {
|
|
453
461
|
window.addEventListener("hashchange", this.onHashChange.bind(this)), this.onHashChange();
|
|
@@ -459,7 +467,7 @@ let Z = class extends HTMLElement {
|
|
|
459
467
|
var n;
|
|
460
468
|
if (!this.isConnected) return;
|
|
461
469
|
const { path: e } = Mt(window.location), t = this.findAncestorWithRouterView(this);
|
|
462
|
-
t ? (p(this,
|
|
470
|
+
t ? (p(this, C, t.$remainingPath), p(this, b, ((n = t.$matchedRoute) == null ? void 0 : n.children) || [])) : p(this, C, e), Dt(this, z, lt).call(this);
|
|
463
471
|
}
|
|
464
472
|
matchRoute(e, t) {
|
|
465
473
|
for (const n of e) {
|
|
@@ -467,13 +475,13 @@ let Z = class extends HTMLElement {
|
|
|
467
475
|
let r = !0;
|
|
468
476
|
const a = {};
|
|
469
477
|
for (let o = 0; o < s.length; o++) {
|
|
470
|
-
const
|
|
471
|
-
if (
|
|
472
|
-
a[
|
|
473
|
-
else if (
|
|
478
|
+
const c = s[o];
|
|
479
|
+
if (c.startsWith(":"))
|
|
480
|
+
a[c.substring(1)] = t[o];
|
|
481
|
+
else if (c === "*") {
|
|
474
482
|
r = !0;
|
|
475
483
|
break;
|
|
476
|
-
} else if (
|
|
484
|
+
} else if (c !== t[o]) {
|
|
477
485
|
r = !1;
|
|
478
486
|
break;
|
|
479
487
|
}
|
|
@@ -505,53 +513,53 @@ let Z = class extends HTMLElement {
|
|
|
505
513
|
return null;
|
|
506
514
|
}
|
|
507
515
|
};
|
|
508
|
-
|
|
516
|
+
_ = /* @__PURE__ */ new WeakMap();
|
|
517
|
+
O = /* @__PURE__ */ new WeakMap();
|
|
518
|
+
x = /* @__PURE__ */ new WeakMap();
|
|
519
|
+
C = /* @__PURE__ */ new WeakMap();
|
|
520
|
+
b = /* @__PURE__ */ new WeakMap();
|
|
509
521
|
L = /* @__PURE__ */ new WeakMap();
|
|
510
|
-
|
|
511
|
-
I = /* @__PURE__ */ new WeakMap();
|
|
512
|
-
w = /* @__PURE__ */ new WeakMap();
|
|
513
|
-
P = /* @__PURE__ */ new WeakMap();
|
|
514
|
-
B = /* @__PURE__ */ new WeakSet();
|
|
522
|
+
z = /* @__PURE__ */ new WeakSet();
|
|
515
523
|
lt = function() {
|
|
516
524
|
var h;
|
|
517
|
-
const e =
|
|
518
|
-
p(this,
|
|
525
|
+
const e = g(this, C) || [], { matchedRoute: t, params: n, remainingPath: s } = this.matchRoute(g(this, b), e);
|
|
526
|
+
p(this, O, s);
|
|
519
527
|
const r = (t == null ? void 0 : t.tagName) || "comment", a = {}, o = {};
|
|
520
|
-
for (const [
|
|
521
|
-
a[
|
|
522
|
-
for (const [
|
|
523
|
-
|
|
524
|
-
const
|
|
528
|
+
for (const [i, l] of Object.entries(n))
|
|
529
|
+
a[i] = () => l;
|
|
530
|
+
for (const [i, l] of Object.entries(g(this, L)))
|
|
531
|
+
Z.includes(i) || i.startsWith("on-") ? o[i.startsWith("on-") ? i.slice(3) : i.slice(2)] = l : a[i] = () => l;
|
|
532
|
+
const c = [
|
|
525
533
|
{
|
|
526
534
|
tagName: r,
|
|
527
|
-
rootId: 0,
|
|
535
|
+
rootId: "0",
|
|
528
536
|
attrs: {},
|
|
529
537
|
props: a,
|
|
530
538
|
on: o,
|
|
531
539
|
children: []
|
|
532
540
|
}
|
|
533
541
|
];
|
|
534
|
-
((h =
|
|
542
|
+
((h = g(this, x)) == null ? void 0 : h.tagName) !== r ? (this.innerHTML = "", p(this, _, U(this, c, []))) : p(this, _, U(this, c, g(this, _))), p(this, x, t || {
|
|
535
543
|
tagName: "comment",
|
|
536
544
|
path: "",
|
|
537
545
|
children: []
|
|
538
546
|
}), this.propagateRoutes(this);
|
|
539
547
|
};
|
|
540
|
-
|
|
541
|
-
|
|
548
|
+
X = Tt([
|
|
549
|
+
Ht({
|
|
542
550
|
tagName: "router-view"
|
|
543
551
|
})
|
|
544
|
-
],
|
|
552
|
+
], X);
|
|
545
553
|
export {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
554
|
+
Ft as BaseElement,
|
|
555
|
+
Ht as CustomElement,
|
|
556
|
+
X as RouterViewElement,
|
|
557
|
+
J as createFunction,
|
|
550
558
|
ot as isObject,
|
|
551
|
-
|
|
559
|
+
Z as listeners,
|
|
552
560
|
it as observe,
|
|
553
561
|
Mt as parseHashUrl,
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
562
|
+
gt as parseHtml,
|
|
563
|
+
U as patch,
|
|
564
|
+
Et as runInAsyncQueue
|
|
557
565
|
};
|
package/dist/solely.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.solely={}))})(this,function(l){"use strict";var gt=l=>{throw TypeError(l)};var et=(l,m,p)=>m.has(l)||gt("Cannot "+p);var C=(l,m,p)=>(et(l,m,"read from private field"),p?p.call(l):m.get(l)),y=(l,m,p)=>m.has(l)?gt("Cannot add the same private member more than once"):m instanceof WeakSet?m.add(l):m.set(l,p),E=(l,m,p,T)=>(et(l,m,"write to private field"),T?T.call(l,p):m.set(l,p),p),j=(l,m,p)=>(et(l,m,"access private method"),p);var x,H,M,I,O,R,A,F;const m=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,p=/<\/?([^\s]+?)[/\s>]/,T=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],q=/\{\{(.+?)\}\}/g;function vt(n){return n.replace(/>\s+</g,"><").replace(/\s+/g," ")}function bt(n,t){const e=(t.match(p)||[])[1]||"",s={rootId:0,tagName:e,attrs:{},props:{},on:{},children:[]},r=new RegExp(T);for(;;){const a=r.exec(t);if(a===null)break;if(!a[0].trim())continue;const[o,i]=a[1]?a[1].trim().split("="):[a[2],a[3].trim().slice(1,-1)];if(U.includes(o)||o.startsWith("on-"))s.on[o.startsWith("on-")?o.slice(3):o.slice(2)]=st(n,i);else if(o.startsWith("s-")){const u=o.slice(2);switch(u){case"model":s.model=i;break;case"style":s.styles=h=>v(n,i,h);break;case"class":s.classes=h=>v(n,i,h);break;case"readonly":s.props.readOnly=h=>v(n,i,h);break;default:s.props[u]=h=>v(n,i,h);break}}else s.attrs[o]=i;r.lastIndex--}if(e==="For"?s.fn=a=>v(n,s.attrs.each,a):(e==="If"||e==="ElseIf")&&(s.fn=a=>v(n,s.attrs.condition,a)),s.model){const a=s.model.replace("this.","").replace("$data.",""),o=u=>v(n,`$data.${a}`,u),i=u=>st(n,`$data.${a}=${u}`);e==="input"?s.attrs.type==="checkbox"||s.attrs.type==="radio"?(s.props.checked=o,s.on.change=i("checked")):(s.props.value=o,s.on.input=i("value")):e==="textarea"?(s.props.value=o,s.on.input=i("value")):e==="select"&&(s.props.value=o,s.on.change=i("value"))}return s}function nt(n,t){const e=[];if(!t)return e;t=vt(t);const s=[],r=[],a=()=>{var i;return s.length===0?e:(i=s[s.length-1]).children||(i.children=[])};let o=0;return t.replace(m,(i,u)=>{const h=a();if(u>o){const c=t.substring(o,u).trim();if(c){q.lastIndex=0;const g=!q.test(c)?c:N=>c.replace(q,(Y,tt)=>v(n,tt,N));h.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:g,children:[]})}}if(o=u+i.length,i.startsWith("<!--")&&i.endsWith("-->"))h.push({rootId:0,tagName:"comment",attrs:{},props:{},on:{},content:i.slice(4,-3),children:[]});else if(i.startsWith("</")){const c=r.pop();for(;s.length>0&&s[s.length-1].tagName!==c;)s.pop();s.pop()}else{const c=bt(n,i),f=i.endsWith("/>")||Et.includes(c.tagName);h.push(c),f||(s.push(c),r.push(c.tagName))}return""}),t.length>o&&e.push({rootId:0,tagName:"text",attrs:{},props:{},on:{},content:t.substring(o).trim(),children:[]}),e}const v=(n,t,e)=>{try{return z(["$data",...e.map(r=>r.item),...e.map(r=>r.index),`return (${t})`]).bind(n)(n.$data,...e.map(r=>r.value),...e.map(r=>r.valueIndex))}catch(s){console.error(s)}},st=(n,t)=>(e,s)=>z(["$data","event","value","checked",...s.map(a=>a.item),...s.map(a=>a.index),t]).bind(n)(n.$data,e,e.target.value,e.target.checked,...s.map(a=>a.value),...s.map(a=>a.valueIndex)),U=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],rt=(()=>{const n=typeof requestAnimationFrame=="function"?t=>requestAnimationFrame(t):typeof Promise<"u"?t=>Promise.resolve().then(t):t=>setTimeout(t,0);return(t,...e)=>{if(typeof t!="function")throw new Error("runInAsyncQueue expects a function as its first argument");n(()=>t(...e))}})(),B={};function z(n){const t=n.map(e=>e.replace(/[',"]/g,"")).join(",");if(!B[t]){const e=n[n.length-1];if(e.trim()==="")throw new Error("Function body cannot be empty");if(wt(e))throw new Error("Input contains potentially dangerous code: "+e);B[t]=new Function(...n)}return B[t]}const yt=["eval","Function","process","require"];function wt(n){return yt.some(t=>new RegExp(`\\b${t}\\b`,"g").test(n))}const Ct="http://www.w3.org/1999/xlink",_t="http://www.w3.org/2000/xmlns/",kt="http://www.w3.org/XML/1998/namespace",It="http://www.w3.org/2000/svg",at=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",Rt=n=>{const t=at(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},ot=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},it=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=Q(r);Object.entries(a).forEach(([o,i])=>{n.style[o]=i})},ct=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=lt(r);Object.entries(a).forEach(([o,i])=>{i?n.classList.add(o):n.classList.remove(o)})},Q=n=>{let t={};return typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=Q(s);Object.entries(r).forEach(([a,o])=>{t[`${e}-${a}`]=o})}else typeof s=="string"||typeof s=="number"?t[e]=`${s}`:t[e]=String(s)}):typeof n=="string"?n.split(";").forEach(e=>{const[s,r]=e.split(":").map(a=>a.trim());s&&r&&(t[s]=r)}):Array.isArray(n)&&n.forEach(e=>{const s=Q(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),t},lt=n=>{let t={};return typeof n=="object"&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{t[e]=!!s}):typeof n=="string"?n.split(" ").forEach(e=>{e!==""&&(t[e]=!0)}):Array.isArray(n)&&n.forEach(e=>{const s=lt(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),t},ht=(n,t,e)=>{const s=r=>e.on[t](r,e.loops||[]);n.addEventListener(t,s,!1),e.handlers=e.handlers||{},e.handlers[t]=s},At=(n,t)=>{const e=t.elm;Object.keys(t.on).forEach(s=>{n.handlers&&n.handlers[s]&&e.removeEventListener(s,n.handlers[s],!1),ht(e,s,t)}),ot(e,t.props,t.loops),ct(e,t),it(e,t),ut(e,n.children,t.children)},St=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":Rt(t);break;case"slot":break;default:At(n,t);break}},G=(n,t,e)=>{e?n.insertBefore(t,e):n.appendChild(t)},$t=(n,t,e)=>{const s=at(t),r=document.createTextNode(s);t.elm=r,G(n,r,e)},Wt=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,G(n,r,e)},xt=(n,t,e,s)=>{t.tagName==="svg"&&(s=It);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(a=>{const o=t.attrs[a]||"";a.charAt(0)!=="x"?r.setAttribute(a,o):a.startsWith("xml:")?r.setAttributeNS(kt,a,o):a.startsWith("xlink:")?r.setAttributeNS(Ct,a,o):a.startsWith("xmlns:")?r.setAttributeNS(_t,a,o):r.setAttribute(a,o)}),Object.keys(t.on).forEach(a=>{ht(r,a,t)}),ot(r,t.props,t.loops),ct(r,t),it(r,t),t.elm=r,G(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(a=>{P(r,a,void 0,s)})},P=(n,t,e,s)=>{switch(t.tagName){case"comment":Wt(n,t,e);break;case"text":$t(n,t,e);break;default:xt(n,t,e,s);break}},Ht=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Mt=n=>n&&n.tagName==="Else",_=(n,t,e=[],s=0,r=!0,a)=>{var o,i,u;for(let h=0;h<t.length;h++){const c=t[h];if(c.tagName==="If"){let f=!1,g=1;for(((o=c.fn)==null?void 0:o.call(c,e))&&(_(n,c.children,e,s,!1,g),f=!0),g++;h+1<t.length&&Ht(t[h+1]);)((u=(i=t[h+1]).fn)==null?void 0:u.call(i,e))&&!f&&(_(n,t[h+1].children,e,s,!1,g),f=!0),h++,g++;h+1<t.length&&Mt(t[h+1])&&(f||(_(n,t[h+1].children,e,s,!1,g),f=!0),h++)}else if(c.tagName==="For"){const{item:f="item",index:g="index"}=c.attrs;(c.fn(e)||[]).forEach((Y,tt)=>{const jt={item:f,value:Y,index:g,valueIndex:tt};_(n,c.children,[...e,jt],s,!1)})}else{const f={...c,loops:e,children:[],rootId:s,ifId:a};_(f.children,c.children,e),n.push(f)}r&&s++}},ut=(n,t,e)=>{var a,o,i,u,h;let s=0,r=0;for(;s<t.length&&r<e.length;){const c=t[s],f=e[r];c.rootId===f.rootId?(f.ifId&&c.ifId!==f.ifId?((a=c.elm)==null||a.remove(),P(n,f,(o=t[s+1])==null?void 0:o.elm)):St(c,f),r++,s++):c.rootId>f.rootId?((i=c.elm)==null||i.remove(),s++):(P(n,f,(u=t[s+1])==null?void 0:u.elm),r++)}for(;s<t.length;)(h=t[s].elm)==null||h.remove(),s++;for(;r<e.length;){const c=e[r];P(n,c),r++}},V=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return _(s,t||[],[],0,!0),ut(n,e,s),s},K=n=>typeof n=="object"&&n!=null;function ft(n=window.location){let t;typeof n=="string"?t=new URL(n).hash:t=n.hash;const e=t.split("?"),s=e[0].substring(2),r=e[1],a={};return r&&r.split("&").forEach(o=>{const[i,u]=o.split("=");i&&u&&(a[decodeURIComponent(i)]=decodeURIComponent(u))}),{path:s.split("/"),query:a}}const X=(n,t)=>new Proxy(n,{get:(e,s)=>{let r=e[s];return K(r)&&(r=X(r,t)),r},set:(e,s,r)=>(e[s]!==r&&(e[s]=r,t(s,r)),!0)});class Ot extends HTMLElement{constructor(){super();y(this,A);y(this,x,{});y(this,H,[]);y(this,M,[]);y(this,I,!1);y(this,O,!1);y(this,R);const e=this._manifest||{};e.template&&typeof e.template=="string"&&E(this,H,nt(this,e.template)),e.shadowDOM&&e.shadowDOM.use?E(this,R,this.attachShadow({mode:e.shadowDOM.mode||"open"})):E(this,R,this)}get $data(){let e=C(this,x);return K(e)&&(e=X(e,()=>j(this,A,F).call(this))),e}set $data(e){E(this,x,e||{}),j(this,A,F).call(this)}connectedCallback(){const e=this._manifest||{};(e.className||e.tagName||"").split(" ").forEach(r=>{r&&this.classList.add(r)}),j(this,A,F).call(this)}onInit(){}disconnectedCallback(){}}x=new WeakMap,H=new WeakMap,M=new WeakMap,I=new WeakMap,O=new WeakMap,R=new WeakMap,A=new WeakSet,F=function(){C(this,I)||(E(this,I,!0),rt(()=>{E(this,M,V(C(this,R),C(this,H),C(this,M))),E(this,I,!1),this.isConnected&&!C(this,O)&&(E(this,O,!0),this.onInit())}))};const mt=n=>t=>{if(customElements.get(n.tagName)){console.warn(`标签名称 "${n.tagName}" 已经被注册`);return}return t.prototype._manifest=Tt(n),customElements.define(n.tagName,t),t},Tt=n=>(n=Object.assign({hasConfig:!1},n),n);var Pt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,pt=n=>{throw TypeError(n)},Lt=(n,t,e,s)=>{for(var r=s>1?void 0:s?Vt(t,e):t,a=n.length-1,o;a>=0;a--)(o=n[a])&&(r=(s?o(t,e,r):o(r))||r);return s&&r&&Pt(t,e,r),r},Z=(n,t,e)=>t.has(n)||pt("Cannot "+e),b=(n,t,e)=>(Z(n,t,"read from private field"),e?e.call(n):t.get(n)),w=(n,t,e)=>t.has(n)?pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),d=(n,t,e,s)=>(Z(n,t,"write to private field"),t.set(n,e),e),Dt=(n,t,e)=>(Z(n,t,"access private method"),e),S,L,$,W,k,D,J,dt;l.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),w(this,J),w(this,S,[]),w(this,L,[]),w(this,$,null),w(this,W),w(this,k,[]),w(this,D,{})}get isRouterView(){return!0}get $routes(){return b(this,k)}set $routes(t){d(this,k,t),this.onHashChange()}get $remainingPath(){return b(this,L)}get $matchedRoute(){return b(this,$)}set $pipe(t){d(this,D,t||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",this.onHashChange.bind(this)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",this.onHashChange.bind(this))}onHashChange(){var s;if(!this.isConnected)return;const{path:t}=ft(window.location),e=this.findAncestorWithRouterView(this);e?(d(this,W,e.$remainingPath),d(this,k,((s=e.$matchedRoute)==null?void 0:s.children)||[])):d(this,W,t),Dt(this,J,dt).call(this)}matchRoute(t,e){for(const s of t){const r=s.path.split("/");let a=!0;const o={};for(let i=0;i<r.length;i++){const u=r[i];if(u.startsWith(":"))o[u.substring(1)]=e[i];else if(u==="*"){a=!0;break}else if(u!==e[i]){a=!1;break}}if(a)return{matchedRoute:s,params:o,remainingPath:e.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:e}}propagateRoutes(t){for(const e of t.childNodes)e.isRouterView?e.onHashChange():this.propagateRoutes(e)}findAncestorWithRouterView(t){let e=t.parentNode;for(;e;){if(e.isRouterView)return e;e=e.parentElement}return null}},S=new WeakMap,L=new WeakMap,$=new WeakMap,W=new WeakMap,k=new WeakMap,D=new WeakMap,J=new WeakSet,dt=function(){var u;const n=b(this,W)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(b(this,k),n);d(this,L,s);const r=(t==null?void 0:t.tagName)||"comment",a={},o={};for(const[h,c]of Object.entries(e))a[h]=()=>c;for(const[h,c]of Object.entries(b(this,D)))U.includes(h)||h.startsWith("on-")?o[h.startsWith("on-")?h.slice(3):h.slice(2)]=c:a[h]=()=>c;const i=[{tagName:r,rootId:0,attrs:{},props:a,on:o,children:[]}];((u=b(this,$))==null?void 0:u.tagName)!==r?(this.innerHTML="",d(this,S,V(this,i,[]))):d(this,S,V(this,i,b(this,S))),d(this,$,t||{tagName:"comment",path:"",children:[]}),this.propagateRoutes(this)},l.RouterViewElement=Lt([mt({tagName:"router-view"})],l.RouterViewElement),l.BaseElement=Ot,l.CustomElement=mt,l.createFunction=z,l.isObject=K,l.listeners=U,l.observe=X,l.parseHashUrl=ft,l.parseHtml=nt,l.patch=V,l.runInAsyncQueue=rt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(h,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(h=typeof globalThis<"u"?globalThis:h||self,f(h.solely={}))})(this,function(h){"use strict";var gt=h=>{throw TypeError(h)};var et=(h,f,p)=>f.has(h)||gt("Cannot "+p);var w=(h,f,p)=>(et(h,f,"read from private field"),p?p.call(h):f.get(h)),y=(h,f,p)=>f.has(h)?gt("Cannot add the same private member more than once"):f instanceof WeakSet?f.add(h):f.set(h,p),g=(h,f,p,O)=>(et(h,f,"write to private field"),O?O.call(h,p):f.set(h,p),p),D=(h,f,p)=>(et(h,f,"access private method"),p);var W,x,M,C,H,_,R,j;const f=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,p=/<\/?([^\s]+?)[/\s>]/,O=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],F=/\{\{(.+?)\}\}/g;function vt(n){return n.replace(/>\s+</g,"><").replace(/\s+/g," ")}function yt(n,t){const e=(t.match(p)||[])[1]||"",s={rootId:"0",tagName:e,attrs:{},props:{},on:{},children:[]},r=new RegExp(O);for(;;){const a=r.exec(t);if(a===null)break;if(!a[0].trim())continue;const[o,c]=a[1]?a[1].trim().split("="):[a[2],a[3].trim().slice(1,-1)];if(q.includes(o)||o.startsWith("on-"))s.on[o.startsWith("on-")?o.slice(3):o.slice(2)]=st(n,c);else if(o.startsWith("s-")){const l=o.slice(2);switch(l){case"model":s.model=c;break;case"style":s.styles=i=>E(n,c,i);break;case"class":s.classes=i=>E(n,c,i);break;case"readonly":s.props.readOnly=i=>E(n,c,i);break;default:s.props[l]=i=>E(n,c,i);break}}else s.attrs[o]=c;r.lastIndex--}if(e==="For"?s.fn=a=>E(n,s.attrs.each,a):(e==="If"||e==="ElseIf")&&(s.fn=a=>E(n,s.attrs.condition,a)),s.model){const a=s.model.replace("this.","").replace("$data.",""),o=l=>E(n,`$data.${a}`,l),c=l=>st(n,`$data.${a}=${l}`);e==="input"?s.attrs.type==="checkbox"||s.attrs.type==="radio"?(s.props.checked=o,s.on.change=c("checked")):(s.props.value=o,s.on.input=c("value")):e==="textarea"?(s.props.value=o,s.on.input=c("value")):e==="select"&&(s.props.value=o,s.on.change=c("value"))}return s}function nt(n,t){const e=[];if(!t)return e;t=vt(t);const s=[],r=[],a=()=>{var c;return s.length===0?e:(c=s[s.length-1]).children||(c.children=[])};let o=0;return t.replace(f,(c,l)=>{const i=a();if(l>o){const u=t.substring(o,l).trim();if(u){F.lastIndex=0;const J=!F.test(u)?u:L=>u.replace(F,(Y,tt)=>E(n,tt,L));i.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:J,children:[]})}}if(o=l+c.length,c.startsWith("<!--")&&c.endsWith("-->"))i.push({rootId:"0",tagName:"comment",attrs:{},props:{},on:{},content:c.slice(4,-3),children:[]});else if(c.startsWith("</")){const u=r.pop();for(;s.length>0&&s[s.length-1].tagName!==u;)s.pop();s.pop()}else{const u=yt(n,c),m=c.endsWith("/>")||Et.includes(u.tagName);i.push(u),m||(s.push(u),r.push(u.tagName))}return""}),t.length>o&&e.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:t.substring(o).trim(),children:[]}),e}const E=(n,t,e)=>{try{return B(["$data",...e.map(r=>r.item),...e.map(r=>r.index),`return (${t})`]).bind(n)(n.$data,...e.map(r=>r.value),...e.map(r=>r.valueIndex))}catch(s){console.error(s)}},st=(n,t)=>(e,s)=>B(["$data","event","value","checked",...s.map(a=>a.item),...s.map(a=>a.index),t]).bind(n)(n.$data,e,e.target.value,e.target.checked,...s.map(a=>a.value),...s.map(a=>a.valueIndex)),q=["onabort","onautocomplete","onautocompleteerror","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onwheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting"],rt=(()=>{const n=typeof requestAnimationFrame=="function"?t=>requestAnimationFrame(t):typeof Promise<"u"?t=>Promise.resolve().then(t):t=>setTimeout(t,0);return(t,...e)=>{if(typeof t!="function")throw new Error("runInAsyncQueue expects a function as its first argument");n(()=>t(...e))}})(),U={};function B(n){const t=n.map(e=>e.replace(/[',"]/g,"")).join(",");if(!U[t]){const e=n[n.length-1];if(e.trim()==="")throw new Error("Function body cannot be empty");if(wt(e))throw new Error("Input contains potentially dangerous code: "+e);U[t]=new Function(...n)}return U[t]}const bt=["eval","Function","process","require"];function wt(n){return bt.some(t=>new RegExp(`\\b${t}\\b`,"g").test(n))}const $t="http://www.w3.org/1999/xlink",kt="http://www.w3.org/2000/xmlns/",Ct="http://www.w3.org/XML/1998/namespace",_t="http://www.w3.org/2000/svg",at=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",Rt=n=>{const t=at(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},ot=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},it=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=N(r);Object.entries(a).forEach(([o,c])=>{n.style[o]=c})},ct=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),a=lt(r);Object.entries(a).forEach(([o,c])=>{c?n.classList.add(o):n.classList.remove(o)})},N=n=>{let t={};return typeof n=="object"&&n!==null&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=N(s);Object.entries(r).forEach(([a,o])=>{t[`${e}-${a}`]=o})}else typeof s=="string"||typeof s=="number"?t[e]=`${s}`:t[e]=String(s)}):typeof n=="string"?n.split(";").forEach(e=>{const[s,r]=e.split(":").map(a=>a.trim());s&&r&&(t[s]=r)}):Array.isArray(n)&&n.forEach(e=>{const s=N(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),t},lt=n=>{let t={};return typeof n=="object"&&!Array.isArray(n)?Object.entries(n).forEach(([e,s])=>{t[e]=!!s}):typeof n=="string"?n.split(" ").forEach(e=>{e!==""&&(t[e]=!0)}):Array.isArray(n)&&n.forEach(e=>{const s=lt(e);Object.entries(s).forEach(([r,a])=>{t[r]=a})}),t},ht=(n,t,e)=>{const s=r=>e.on[t](r,e.loops||[]);n.addEventListener(t,s,!1),e.handlers=e.handlers||{},e.handlers[t]=s},At=(n,t)=>{const e=t.elm;Object.keys(t.on).forEach(s=>{n.handlers&&n.handlers[s]&&e.removeEventListener(s,n.handlers[s],!1),ht(e,s,t)}),ot(e,t.props,t.loops),ct(e,t),it(e,t),ut(e,n.children,t.children)},St=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":Rt(t);break;case"slot":break;default:At(n,t);break}},z=(n,t,e)=>{e?n.insertBefore(t,e):n.appendChild(t)},It=(n,t,e)=>{const s=at(t),r=document.createTextNode(s);t.elm=r,z(n,r,e)},Wt=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,z(n,r,e)},xt=(n,t,e,s)=>{t.tagName==="svg"&&(s=_t);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(a=>{const o=t.attrs[a]||"";a.charAt(0)!=="x"?r.setAttribute(a,o):a.startsWith("xml:")?r.setAttributeNS(Ct,a,o):a.startsWith("xlink:")?r.setAttributeNS($t,a,o):a.startsWith("xmlns:")?r.setAttributeNS(kt,a,o):r.setAttribute(a,o)}),Object.keys(t.on).forEach(a=>{ht(r,a,t)}),ot(r,t.props,t.loops),ct(r,t),it(r,t),t.elm=r,z(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(a=>{Q(r,a,void 0,s)})},Q=(n,t,e,s)=>{switch(t.tagName){case"comment":Wt(n,t,e);break;case"text":It(n,t,e);break;default:xt(n,t,e,s);break}},Mt=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Ht=n=>n&&n.tagName==="Else",$=(n,t,e=[],s="0",r)=>{var a,o,c;for(let l=0;l<t.length;l++){const i=t[l];if(i.tagName==="If"){let u=!1,m=1;for(((a=i.fn)==null?void 0:a.call(i,e))&&($(n,i.children,e,`${s}-if-${m}`,m),u=!0),m++;l+1<t.length&&Mt(t[l+1]);)((c=(o=t[l+1]).fn)==null?void 0:c.call(o,e))&&!u&&($(n,t[l+1].children,e,`${s}-if-${m}`,m),u=!0),l++,m++;l+1<t.length&&Ht(t[l+1])&&(u||($(n,t[l+1].children,e,`${s}-if-${m}`,m),u=!0),l++)}else if(i.tagName==="For"){const{item:u="item",index:m="index"}=i.attrs;(i.fn(e)||[]).forEach((L,Y)=>{const tt={item:u,value:L,index:m,valueIndex:Y};$(n,i.children,[...e,tt],`${s}-for-${Y}`,1)})}else{const u={...i,loops:e,children:[],rootId:s,ifId:r,key:i.key||`${s}-${l}`};$(u.children,i.children,e,`${s}-${l}`),n.push(u)}}},ut=(n,t,e)=>{var o,c,l;const s=new Map;t.forEach((i,u)=>s.set(i.key,{node:i,index:u}));let r=0,a=0;for(;r<e.length;){const i=e[r],u=s.get(i.key);if(u){const m=u.node;i.ifId&&m.ifId!==i.ifId?((o=m.elm)==null||o.remove(),Q(n,i,(c=t[a+1])==null?void 0:c.elm)):St(m,i),s.delete(i.key),a++}else{const m=(l=t[a])==null?void 0:l.elm;Q(n,i,m)}r++}s.forEach(({node:i})=>{var u;return(u=i.elm)==null?void 0:u.remove()})},T=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return $(s,t||[],[],"0"),ut(n,e,s),s},G=n=>typeof n=="object"&&n!=null;function ft(n=window.location){let t;typeof n=="string"?t=new URL(n).hash:t=n.hash;const e=t.split("?"),s=e[0].substring(2),r=e[1],a={};return r&&r.split("&").forEach(o=>{const[c,l]=o.split("=");c&&l&&(a[decodeURIComponent(c)]=decodeURIComponent(l))}),{path:s.split("/"),query:a}}const K=(n,t)=>new Proxy(n,{get:(e,s)=>{let r=e[s];return G(r)&&(r=K(r,t)),r},set:(e,s,r)=>(e[s]!==r&&(e[s]=r,t(s,r)),!0)});class Ot extends HTMLElement{constructor(){super();y(this,R);y(this,W,{});y(this,x,[]);y(this,M,[]);y(this,C,!1);y(this,H,!1);y(this,_);const e=this._manifest||{};e.template&&typeof e.template=="string"&&g(this,x,nt(this,e.template)),e.shadowDOM&&e.shadowDOM.use?g(this,_,this.attachShadow({mode:e.shadowDOM.mode||"open"})):g(this,_,this)}get $data(){let e=w(this,W);return G(e)&&(e=K(e,()=>D(this,R,j).call(this))),e}set $data(e){g(this,W,e||{}),D(this,R,j).call(this)}connectedCallback(){const e=this._manifest||{};(e.className||e.tagName||"").split(" ").forEach(r=>{r&&this.classList.add(r)}),D(this,R,j).call(this)}onInit(){}disconnectedCallback(){}}W=new WeakMap,x=new WeakMap,M=new WeakMap,C=new WeakMap,H=new WeakMap,_=new WeakMap,R=new WeakSet,j=function(){w(this,C)||(g(this,C,!0),rt(()=>{g(this,M,T(w(this,_),w(this,x),w(this,M))),g(this,C,!1),this.isConnected&&!w(this,H)&&(g(this,H,!0),this.onInit())}))};const mt=n=>t=>{if(customElements.get(n.tagName)){console.warn(`标签名称 "${n.tagName}" 已经被注册`);return}return t.prototype._manifest=Tt(n),customElements.define(n.tagName,t),t},Tt=n=>(n=Object.assign({hasConfig:!1},n),n);var Pt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,pt=n=>{throw TypeError(n)},Lt=(n,t,e,s)=>{for(var r=s>1?void 0:s?Vt(t,e):t,a=n.length-1,o;a>=0;a--)(o=n[a])&&(r=(s?o(t,e,r):o(r))||r);return s&&r&&Pt(t,e,r),r},X=(n,t,e)=>t.has(n)||pt("Cannot "+e),v=(n,t,e)=>(X(n,t,"read from private field"),e?e.call(n):t.get(n)),b=(n,t,e)=>t.has(n)?pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),d=(n,t,e,s)=>(X(n,t,"write to private field"),t.set(n,e),e),Dt=(n,t,e)=>(X(n,t,"access private method"),e),A,P,S,I,k,V,Z,dt;h.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),b(this,Z),b(this,A,[]),b(this,P,[]),b(this,S,null),b(this,I),b(this,k,[]),b(this,V,{})}get isRouterView(){return!0}get $routes(){return v(this,k)}set $routes(t){d(this,k,t),this.onHashChange()}get $remainingPath(){return v(this,P)}get $matchedRoute(){return v(this,S)}set $pipe(t){d(this,V,t||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",this.onHashChange.bind(this)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",this.onHashChange.bind(this))}onHashChange(){var s;if(!this.isConnected)return;const{path:t}=ft(window.location),e=this.findAncestorWithRouterView(this);e?(d(this,I,e.$remainingPath),d(this,k,((s=e.$matchedRoute)==null?void 0:s.children)||[])):d(this,I,t),Dt(this,Z,dt).call(this)}matchRoute(t,e){for(const s of t){const r=s.path.split("/");let a=!0;const o={};for(let c=0;c<r.length;c++){const l=r[c];if(l.startsWith(":"))o[l.substring(1)]=e[c];else if(l==="*"){a=!0;break}else if(l!==e[c]){a=!1;break}}if(a)return{matchedRoute:s,params:o,remainingPath:e.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:e}}propagateRoutes(t){for(const e of t.childNodes)e.isRouterView?e.onHashChange():this.propagateRoutes(e)}findAncestorWithRouterView(t){let e=t.parentNode;for(;e;){if(e.isRouterView)return e;e=e.parentElement}return null}},A=new WeakMap,P=new WeakMap,S=new WeakMap,I=new WeakMap,k=new WeakMap,V=new WeakMap,Z=new WeakSet,dt=function(){var l;const n=v(this,I)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(v(this,k),n);d(this,P,s);const r=(t==null?void 0:t.tagName)||"comment",a={},o={};for(const[i,u]of Object.entries(e))a[i]=()=>u;for(const[i,u]of Object.entries(v(this,V)))q.includes(i)||i.startsWith("on-")?o[i.startsWith("on-")?i.slice(3):i.slice(2)]=u:a[i]=()=>u;const c=[{tagName:r,rootId:"0",attrs:{},props:a,on:o,children:[]}];((l=v(this,S))==null?void 0:l.tagName)!==r?(this.innerHTML="",d(this,A,T(this,c,[]))):d(this,A,T(this,c,v(this,A))),d(this,S,t||{tagName:"comment",path:"",children:[]}),this.propagateRoutes(this)},h.RouterViewElement=Lt([mt({tagName:"router-view"})],h.RouterViewElement),h.BaseElement=Ot,h.CustomElement=mt,h.createFunction=B,h.isObject=G,h.listeners=q,h.observe=K,h.parseHashUrl=ft,h.parseHtml=nt,h.patch=T,h.runInAsyncQueue=rt,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface Loop {
|
|
2
|
+
item: string;
|
|
3
|
+
value: any;
|
|
4
|
+
index: string;
|
|
5
|
+
valueIndex: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ASTNode {
|
|
8
|
+
key?: string;
|
|
9
|
+
handlers?: Record<string, EventListenerOrEventListenerObject>;
|
|
10
|
+
rootId: string;
|
|
11
|
+
tagName: string;
|
|
12
|
+
attrs: Record<string, string>;
|
|
13
|
+
props: Record<string, Function>;
|
|
14
|
+
styles?: Function;
|
|
15
|
+
classes?: Function;
|
|
16
|
+
on: Record<string, (event: Event, loops: Loop[]) => any>;
|
|
17
|
+
content?: string | ((loops: Loop[]) => string);
|
|
18
|
+
children: ASTNode[];
|
|
19
|
+
elm?: Node;
|
|
20
|
+
fn?: Function;
|
|
21
|
+
loops?: Loop[];
|
|
22
|
+
ifId?: number;
|
|
23
|
+
model?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function parseHtml(ctx: any, html: string): ASTNode[];
|
|
@@ -5,8 +5,9 @@ export interface Loop {
|
|
|
5
5
|
valueIndex: number;
|
|
6
6
|
}
|
|
7
7
|
export interface ASTNode {
|
|
8
|
+
key?: string;
|
|
8
9
|
handlers?: Record<string, EventListenerOrEventListenerObject>;
|
|
9
|
-
rootId:
|
|
10
|
+
rootId: string;
|
|
10
11
|
tagName: string;
|
|
11
12
|
attrs: Record<string, string>;
|
|
12
13
|
props: Record<string, Function>;
|