solely 0.0.28 → 0.0.30
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 +51 -1
- package/dist/solely.js +186 -175
- package/dist/solely.umd.cjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -315,6 +315,55 @@ class StyledCard extends BaseElement<{ txt: string }> {
|
|
|
315
315
|
|
|
316
316
|
---
|
|
317
317
|
|
|
318
|
+
### 插槽(Slots)支持
|
|
319
|
+
|
|
320
|
+
当 shadowDOM 功能处于开启状态时,该组件支持使用标准的 Web Components 插槽功能,并允许对插槽名称进行动态修改。
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
// 带插槽的组件
|
|
324
|
+
@CustomElement({
|
|
325
|
+
tagName: 'my-layout',
|
|
326
|
+
template: `
|
|
327
|
+
<header><slot name="header"></slot></header>
|
|
328
|
+
<main><slot></slot></main>
|
|
329
|
+
<footer><slot s-name="$data.footerSlotName"></slot></footer>
|
|
330
|
+
`,
|
|
331
|
+
shadowDOM: { use: true },
|
|
332
|
+
styles: `
|
|
333
|
+
header, footer { background: #f0f0f0; padding: 10px; }
|
|
334
|
+
main { padding: 20px; }
|
|
335
|
+
`
|
|
336
|
+
})
|
|
337
|
+
class MyLayout extends BaseElement<{ footerSlotName: string }> {
|
|
338
|
+
constructor() {
|
|
339
|
+
super({ footerSlotName: 'default-footer' })
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// 动态修改插槽名称
|
|
343
|
+
changeFooterSlot() {
|
|
344
|
+
this.$data.footerSlotName = 'custom-footer'
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
```html
|
|
350
|
+
<my-layout>
|
|
351
|
+
<!-- 命名插槽 -->
|
|
352
|
+
<h1 slot="header">页面标题</h1>
|
|
353
|
+
|
|
354
|
+
<!-- 默认插槽 -->
|
|
355
|
+
<p>这是页面内容...</p>
|
|
356
|
+
|
|
357
|
+
<!-- 动态插槽 -->
|
|
358
|
+
<div slot="default-footer">默认页脚</div>
|
|
359
|
+
<div slot="custom-footer">自定义页脚</div>
|
|
360
|
+
</my-layout>
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
使用动态插槽时,通过 `s-name="$data.slotName"` 语法绑定动态插槽名称,当数据变化时,插槽内容会自动重新分配。
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
318
367
|
## 组件通信
|
|
319
368
|
|
|
320
369
|
| 方式 | 示例 |
|
|
@@ -427,6 +476,7 @@ npm run pack:local # 生成 solely-<ver>.tgz,file: 引用
|
|
|
427
476
|
|---|---|
|
|
428
477
|
| 必须先写 `this.` 吗? | 模板中可省略,直接写 `$data.xxx` |
|
|
429
478
|
| 什么时候用 Shadow DOM? | 需要样式/结构隔离时,在 `@CustomElement({shadowDOM: { use: true }})` 开启 |
|
|
479
|
+
| 组件支持插槽(Slots)吗? | 是的,当 shadowDOM 功能处于开启状态时,支持标准 Web Components 插槽功能,并允许使用 `s-name="$data.slotName"` 语法动态修改插槽名称 |
|
|
430
480
|
| 能给子组件传对象吗? | 可以,用 `s-对象='json-string'` 或在父组件里直接 `querySelector('child').$data = {...}` |
|
|
431
481
|
| 路由能否用 history 模式? | 当前仅实现 hash 模式,history 模式可自行扩展 |
|
|
432
482
|
| 如何调试响应式数据? | 浏览器 DevTools 控制台直接 `document.querySelector('my-el').$data` 即可读写 |
|
|
@@ -446,7 +496,7 @@ npm run pack:local # 生成 solely-<ver>.tgz,file: 引用
|
|
|
446
496
|
|
|
447
497
|
## 版本与发布
|
|
448
498
|
|
|
449
|
-
- 当前版本:**0.0.
|
|
499
|
+
- 当前版本:**0.0.30**
|
|
450
500
|
- 遵循语义化版本(SemVer)
|
|
451
501
|
- 构建产物位于 `dist/`,`package.json` 的 `"module"` 指向 `dist/solely.js`,类型声明 `dist/solely.d.ts`
|
|
452
502
|
|
package/dist/solely.js
CHANGED
|
@@ -2,13 +2,13 @@ var ft = (t) => {
|
|
|
2
2
|
throw TypeError(t);
|
|
3
3
|
};
|
|
4
4
|
var st = (t, e, n) => e.has(t) || ft("Cannot " + n);
|
|
5
|
-
var x = (t, e, n) => (st(t, e, "read from private field"), n ? n.call(t) : e.get(t)),
|
|
6
|
-
const
|
|
5
|
+
var x = (t, e, n) => (st(t, e, "read from private field"), n ? n.call(t) : e.get(t)), P = (t, e, n) => e.has(t) ? ft("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), A = (t, e, n, s) => (st(t, e, "write to private field"), s ? s.call(t, n) : e.set(t, n), n), I = (t, e, n) => (st(t, e, "access private method"), n);
|
|
6
|
+
const St = /<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g, _t = /<\/?([^\s]+?)[/\s>]/, Wt = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g, It = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"], rt = /\{\{(.+?)\}\}/g;
|
|
7
7
|
function Ot(t) {
|
|
8
8
|
return t.replace(/>\s+</g, "><").replace(/\s+/g, " ");
|
|
9
9
|
}
|
|
10
10
|
function jt(t, e) {
|
|
11
|
-
const n = (e.match(
|
|
11
|
+
const n = (e.match(_t) || [])[1] || "", s = {
|
|
12
12
|
rootId: "0",
|
|
13
13
|
tagName: n,
|
|
14
14
|
attrs: {},
|
|
@@ -32,39 +32,48 @@ function jt(t, e) {
|
|
|
32
32
|
s.model = i;
|
|
33
33
|
break;
|
|
34
34
|
case "style":
|
|
35
|
-
s.styles = (
|
|
35
|
+
s.styles = (p) => w(t, i, p);
|
|
36
36
|
break;
|
|
37
37
|
case "class":
|
|
38
|
-
s.classes = (
|
|
38
|
+
s.classes = (p) => w(t, i, p);
|
|
39
39
|
break;
|
|
40
40
|
case "readonly":
|
|
41
|
-
s.props.readOnly = (
|
|
41
|
+
s.props.readOnly = (p) => w(t, i, p);
|
|
42
|
+
break;
|
|
43
|
+
case "for":
|
|
44
|
+
s.props.htmlFor = (p) => w(t, i, p);
|
|
45
|
+
break;
|
|
46
|
+
case "tabindex":
|
|
47
|
+
s.props.tabIndex = (p) => w(t, i, p);
|
|
48
|
+
break;
|
|
49
|
+
case "contenteditable":
|
|
50
|
+
s.props.contentEditable = (p) => w(t, i, p);
|
|
42
51
|
break;
|
|
43
52
|
default:
|
|
44
|
-
s.props[f] = (
|
|
53
|
+
s.props[f] = (p) => w(t, i, p);
|
|
45
54
|
break;
|
|
46
55
|
}
|
|
47
56
|
} else
|
|
48
57
|
s.attrs[a] = i;
|
|
49
58
|
r.lastIndex--;
|
|
50
59
|
}
|
|
51
|
-
if (n === "For" ? s.fn = (o) =>
|
|
52
|
-
const o = s.model.replace("this.", "").replace("$data.", ""), a = (f) =>
|
|
60
|
+
if (n === "For" ? s.fn = (o) => w(t, s.attrs.each, o) : (n === "If" || n === "ElseIf") && (s.fn = (o) => w(t, s.attrs.condition, o)), s.model) {
|
|
61
|
+
const o = s.model.replace("this.", "").replace("$data.", ""), a = (f) => w(t, `$data.${o}`, f), i = (f, p) => {
|
|
53
62
|
if (s.on[f]) {
|
|
54
63
|
const l = s.on[f];
|
|
55
64
|
s.on[f] = (c, u) => {
|
|
56
|
-
|
|
65
|
+
p(c, u), l(c, u);
|
|
57
66
|
};
|
|
58
67
|
} else
|
|
59
|
-
s.on[f] =
|
|
68
|
+
s.on[f] = p;
|
|
60
69
|
};
|
|
61
70
|
if (n === "input") {
|
|
62
71
|
const f = s.attrs.type || "text";
|
|
63
72
|
if (f === "checkbox")
|
|
64
73
|
s.props.checked = a, i("change", H(t, `$data.${o}=checked`));
|
|
65
74
|
else if (f === "radio") {
|
|
66
|
-
const
|
|
67
|
-
s.props.checked = (l) => a(l) ==
|
|
75
|
+
const p = s.attrs.value;
|
|
76
|
+
s.props.checked = (l) => a(l) == p, i("change", H(t, `if(checked){$data.${o}='${p}'}`));
|
|
68
77
|
} else
|
|
69
78
|
s.props.value = a, i("input", H(t, `$data.${o}=value`));
|
|
70
79
|
} else if (n === "textarea")
|
|
@@ -77,21 +86,21 @@ function jt(t, e) {
|
|
|
77
86
|
$data.${o} = Array.from(event.target.selectedOptions).map(o => o.value);
|
|
78
87
|
`)
|
|
79
88
|
) : (i("change", H(t, `$data.${o}=value`)), s.props.value = a);
|
|
80
|
-
const
|
|
81
|
-
const
|
|
89
|
+
const p = (u, d = []) => {
|
|
90
|
+
const v = a(d);
|
|
82
91
|
if (f) {
|
|
83
|
-
const
|
|
84
|
-
for (const
|
|
85
|
-
|
|
92
|
+
const k = Array.isArray(v) ? v : v != null ? [v] : [];
|
|
93
|
+
for (const M of u.options)
|
|
94
|
+
M.selected = k.includes(M.value);
|
|
86
95
|
} else {
|
|
87
|
-
const
|
|
88
|
-
u.value !==
|
|
96
|
+
const k = v ?? "";
|
|
97
|
+
u.value !== k && (u.value = k);
|
|
89
98
|
}
|
|
90
99
|
}, l = s.onMounted, c = s.onUpdated;
|
|
91
|
-
s.onMounted = (u,
|
|
92
|
-
l == null || l(u,
|
|
93
|
-
}, s.onUpdated = (u,
|
|
94
|
-
c == null || c(u,
|
|
100
|
+
s.onMounted = (u, d) => {
|
|
101
|
+
l == null || l(u, d), p(u, d || []);
|
|
102
|
+
}, s.onUpdated = (u, d) => {
|
|
103
|
+
c == null || c(u, d), p(u, d || []);
|
|
95
104
|
};
|
|
96
105
|
}
|
|
97
106
|
}
|
|
@@ -106,14 +115,14 @@ function Tt(t, e) {
|
|
|
106
115
|
return s.length === 0 ? n : (i = s[s.length - 1]).children || (i.children = []);
|
|
107
116
|
};
|
|
108
117
|
let a = 0;
|
|
109
|
-
return e.replace(
|
|
110
|
-
const
|
|
118
|
+
return e.replace(St, (i, f) => {
|
|
119
|
+
const p = o();
|
|
111
120
|
if (f > a) {
|
|
112
121
|
const l = e.substring(a, f).trim();
|
|
113
122
|
if (l) {
|
|
114
123
|
rt.lastIndex = 0;
|
|
115
|
-
const u = !rt.test(l) ? l : (
|
|
116
|
-
|
|
124
|
+
const u = !rt.test(l) ? l : (d) => l.replace(rt, (v, k) => w(t, k, d));
|
|
125
|
+
p.push({
|
|
117
126
|
rootId: "0",
|
|
118
127
|
tagName: "text",
|
|
119
128
|
attrs: {},
|
|
@@ -125,7 +134,7 @@ function Tt(t, e) {
|
|
|
125
134
|
}
|
|
126
135
|
}
|
|
127
136
|
if (a = f + i.length, i.startsWith("<!--") && i.endsWith("-->"))
|
|
128
|
-
|
|
137
|
+
p.push({
|
|
129
138
|
rootId: "0",
|
|
130
139
|
tagName: "comment",
|
|
131
140
|
attrs: {},
|
|
@@ -141,7 +150,7 @@ function Tt(t, e) {
|
|
|
141
150
|
s.pop();
|
|
142
151
|
} else {
|
|
143
152
|
const l = jt(t, i), c = i.endsWith("/>") || It.includes(l.tagName);
|
|
144
|
-
|
|
153
|
+
p.push(l), c || (s.push(l), r.push(l.tagName));
|
|
145
154
|
}
|
|
146
155
|
return "";
|
|
147
156
|
}), e.length > a && n.push({
|
|
@@ -154,7 +163,7 @@ function Tt(t, e) {
|
|
|
154
163
|
children: []
|
|
155
164
|
}), n;
|
|
156
165
|
}
|
|
157
|
-
const
|
|
166
|
+
const w = (t, e, n) => {
|
|
158
167
|
try {
|
|
159
168
|
return lt([
|
|
160
169
|
"$data",
|
|
@@ -309,22 +318,26 @@ function Ut(t) {
|
|
|
309
318
|
const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/", Bt = "http://www.w3.org/XML/1998/namespace", zt = "http://www.w3.org/2000/svg", yt = (t) => typeof t.content == "function" ? t.content(t.loops || []) : t.content || "", Gt = (t) => {
|
|
310
319
|
const e = yt(t), n = t.elm;
|
|
311
320
|
n.textContent !== e && (n.textContent = e);
|
|
312
|
-
}, Et = (t, e, n = []) => {
|
|
321
|
+
}, Kt = ["role", "form"], Et = (t, e, n = []) => {
|
|
313
322
|
Object.keys(e).forEach((s) => {
|
|
314
323
|
const r = e[s](n);
|
|
315
|
-
|
|
324
|
+
if (s.startsWith("data-") || s.startsWith("aria-") || Kt.includes(s)) {
|
|
325
|
+
const o = t.getAttribute(s), a = r == null ? null : String(r);
|
|
326
|
+
o !== a && (a == null ? t.removeAttribute(s) : t.setAttribute(s, a));
|
|
327
|
+
} else
|
|
328
|
+
t[s] !== r && (t[s] = r);
|
|
316
329
|
});
|
|
317
|
-
},
|
|
330
|
+
}, bt = (t, e) => {
|
|
318
331
|
const { styles: n, loops: s = [] } = e;
|
|
319
332
|
if (!n) return;
|
|
320
333
|
const r = n(s), o = at(r);
|
|
321
334
|
Object.entries(o).forEach(([a, i]) => {
|
|
322
335
|
t.style[a] = i;
|
|
323
336
|
});
|
|
324
|
-
},
|
|
337
|
+
}, vt = (t, e) => {
|
|
325
338
|
const { classes: n, loops: s = [] } = e;
|
|
326
339
|
if (!n) return;
|
|
327
|
-
const r = n(s), o =
|
|
340
|
+
const r = n(s), o = $t(r);
|
|
328
341
|
Object.entries(o).forEach(([a, i]) => {
|
|
329
342
|
i ? t.classList.add(a) : t.classList.remove(a);
|
|
330
343
|
});
|
|
@@ -346,58 +359,56 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
346
359
|
e[r] = o;
|
|
347
360
|
});
|
|
348
361
|
}), e;
|
|
349
|
-
},
|
|
362
|
+
}, $t = (t) => {
|
|
350
363
|
let e = {};
|
|
351
364
|
return typeof t == "object" && !Array.isArray(t) ? Object.entries(t).forEach(([n, s]) => {
|
|
352
365
|
e[n] = !!s;
|
|
353
366
|
}) : typeof t == "string" ? t.split(" ").forEach((n) => {
|
|
354
367
|
n !== "" && (e[n] = !0);
|
|
355
368
|
}) : Array.isArray(t) && t.forEach((n) => {
|
|
356
|
-
const s =
|
|
369
|
+
const s = $t(n);
|
|
357
370
|
Object.entries(s).forEach(([r, o]) => {
|
|
358
371
|
e[r] = o;
|
|
359
372
|
});
|
|
360
373
|
}), e;
|
|
361
|
-
},
|
|
374
|
+
}, At = (t, e, n) => {
|
|
362
375
|
const s = (r) => n.on[e](r, n.loops || []);
|
|
363
376
|
t.addEventListener(e, s, !1), n.handlers = n.handlers || {}, n.handlers[e] = s;
|
|
364
|
-
},
|
|
377
|
+
}, Qt = (t, e) => {
|
|
365
378
|
const n = e.elm;
|
|
366
379
|
Object.keys(e.on).forEach((s) => {
|
|
367
|
-
t.handlers && t.handlers[s] && n.removeEventListener(s, t.handlers[s], !1),
|
|
368
|
-
}), Et(n, e.props, e.loops),
|
|
380
|
+
t.handlers && t.handlers[s] && n.removeEventListener(s, t.handlers[s], !1), At(n, s, e);
|
|
381
|
+
}), Et(n, e.props, e.loops), vt(n, e), bt(n, e), typeof e.onUpdated == "function" && requestAnimationFrame(() => {
|
|
369
382
|
e.onUpdated(n, e.loops || []);
|
|
370
|
-
}),
|
|
371
|
-
},
|
|
383
|
+
}), kt(n, t.children, e.children);
|
|
384
|
+
}, Jt = (t, e) => {
|
|
372
385
|
switch (e.elm = t.elm, e.tagName) {
|
|
373
386
|
case "comment":
|
|
374
387
|
break;
|
|
375
388
|
case "text":
|
|
376
389
|
Gt(e);
|
|
377
390
|
break;
|
|
378
|
-
case "slot":
|
|
379
|
-
break;
|
|
380
391
|
default:
|
|
381
|
-
|
|
392
|
+
Qt(t, e);
|
|
382
393
|
break;
|
|
383
394
|
}
|
|
384
395
|
}, ut = (t, e, n) => {
|
|
385
396
|
n && n.parentNode === t ? t.insertBefore(e, n) : t.appendChild(e);
|
|
386
|
-
},
|
|
397
|
+
}, Nt = (t, e, n) => {
|
|
387
398
|
const s = yt(e), r = document.createTextNode(s);
|
|
388
399
|
e.elm = r, ut(t, r, n);
|
|
389
|
-
},
|
|
400
|
+
}, Xt = (t, e, n) => {
|
|
390
401
|
const s = e.content, r = document.createComment(s);
|
|
391
402
|
e.elm = r, ut(t, r, n);
|
|
392
|
-
},
|
|
403
|
+
}, Zt = (t, e, n, s) => {
|
|
393
404
|
e.tagName === "svg" && (s = zt);
|
|
394
405
|
const r = s ? document.createElementNS(s, e.tagName) : document.createElement(e.tagName);
|
|
395
406
|
Object.keys(e.attrs).forEach((o) => {
|
|
396
407
|
const a = e.attrs[o] || "";
|
|
397
408
|
o.charAt(0) !== "x" ? r.setAttribute(o, a) : o.startsWith("xml:") ? r.setAttributeNS(Bt, o, a) : o.startsWith("xlink:") ? r.setAttributeNS(qt, o, a) : o.startsWith("xmlns:") ? r.setAttributeNS(Vt, o, a) : r.setAttribute(o, a);
|
|
398
409
|
}), Object.keys(e.on).forEach((o) => {
|
|
399
|
-
|
|
400
|
-
}), Et(r, e.props, e.loops),
|
|
410
|
+
At(r, o, e);
|
|
411
|
+
}), Et(r, e.props, e.loops), vt(r, e), bt(r, e), e.elm = r, ut(t, r, n), e.tagName === "foreignObject" && (s = void 0), e.children.forEach((o) => {
|
|
401
412
|
N(r, o, void 0, s);
|
|
402
413
|
}), typeof e.onMounted == "function" && requestAnimationFrame(() => {
|
|
403
414
|
e.onMounted(r, e.loops || []);
|
|
@@ -405,33 +416,33 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
405
416
|
}, N = (t, e, n, s) => {
|
|
406
417
|
switch (e.tagName) {
|
|
407
418
|
case "comment":
|
|
408
|
-
|
|
419
|
+
Xt(t, e, n);
|
|
409
420
|
break;
|
|
410
421
|
case "text":
|
|
411
|
-
|
|
422
|
+
Nt(t, e, n);
|
|
412
423
|
break;
|
|
413
424
|
default:
|
|
414
|
-
|
|
425
|
+
Zt(t, e, n, s);
|
|
415
426
|
break;
|
|
416
427
|
}
|
|
417
|
-
},
|
|
418
|
-
var i, f,
|
|
428
|
+
}, Yt = (t) => t && (t.tagName === "ElseIf" || t.tagName === "comment"), te = (t) => t && t.tagName === "Else", F = (t, e, n = [], s = "0", r) => {
|
|
429
|
+
var i, f, p;
|
|
419
430
|
let o = 0, a = 0;
|
|
420
431
|
for (let l = 0; l < e.length; l++) {
|
|
421
432
|
const c = e[l];
|
|
422
433
|
if (c.tagName === "If") {
|
|
423
434
|
let u = !1;
|
|
424
435
|
o++;
|
|
425
|
-
let
|
|
426
|
-
for (((i = c.fn) == null ? void 0 : i.call(c, n)) && (F(t, c.children, n, `${s}-if-${o}-${
|
|
427
|
-
((
|
|
428
|
-
l + 1 < e.length &&
|
|
436
|
+
let d = 1;
|
|
437
|
+
for (((i = c.fn) == null ? void 0 : i.call(c, n)) && (F(t, c.children, n, `${s}-if-${o}-${d}`, d), u = !0), d++; l + 1 < e.length && Yt(e[l + 1]); )
|
|
438
|
+
((p = (f = e[l + 1]).fn) == null ? void 0 : p.call(f, n)) && !u && (F(t, e[l + 1].children, n, `${s}-if-${o}-${d}`, d), u = !0), l++, d++;
|
|
439
|
+
l + 1 < e.length && te(e[l + 1]) && (u || (F(t, e[l + 1].children, n, `${s}-if-${o}-${d}`, d), u = !0), l++);
|
|
429
440
|
} else if (c.tagName === "For") {
|
|
430
441
|
a++;
|
|
431
|
-
const { item: u = "item", index:
|
|
432
|
-
(c.fn(n) || []).forEach((
|
|
433
|
-
const Q = { item: u, value:
|
|
434
|
-
F(t, c.children, [...n, Q], `${s}-for-${a}-${
|
|
442
|
+
const { item: u = "item", index: d = "index" } = c.attrs;
|
|
443
|
+
(c.fn(n) || []).forEach((k, M) => {
|
|
444
|
+
const Q = { item: u, value: k, index: d, valueIndex: M };
|
|
445
|
+
F(t, c.children, [...n, Q], `${s}-for-${a}-${M}`, 1);
|
|
435
446
|
});
|
|
436
447
|
} else {
|
|
437
448
|
const u = {
|
|
@@ -446,31 +457,31 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
446
457
|
F(u.children, c.children, n, `${s}-${l}`), t.push(u);
|
|
447
458
|
}
|
|
448
459
|
}
|
|
449
|
-
},
|
|
450
|
-
var a, i, f,
|
|
460
|
+
}, kt = (t, e, n) => {
|
|
461
|
+
var a, i, f, p, l;
|
|
451
462
|
const s = /* @__PURE__ */ new Map();
|
|
452
463
|
e.forEach((c, u) => s.set(c.key, { node: c, index: u }));
|
|
453
464
|
let r = 0, o = 0;
|
|
454
465
|
for (; r < n.length; ) {
|
|
455
466
|
const c = n[r], u = s.get(c.key);
|
|
456
467
|
if (u) {
|
|
457
|
-
const
|
|
458
|
-
if (
|
|
459
|
-
(a =
|
|
460
|
-
const
|
|
461
|
-
N(t, c,
|
|
468
|
+
const d = u.node;
|
|
469
|
+
if (d.tagName !== c.tagName) {
|
|
470
|
+
(a = d.elm) == null || a.remove();
|
|
471
|
+
const v = (i = e[o + 1]) == null ? void 0 : i.elm;
|
|
472
|
+
N(t, c, v), s.delete(c.key), o++;
|
|
462
473
|
} else {
|
|
463
|
-
if (c.ifId &&
|
|
464
|
-
(f =
|
|
465
|
-
const
|
|
466
|
-
N(t, c,
|
|
474
|
+
if (c.ifId && d.ifId !== c.ifId) {
|
|
475
|
+
(f = d.elm) == null || f.remove();
|
|
476
|
+
const v = (p = e[o + 1]) == null ? void 0 : p.elm;
|
|
477
|
+
N(t, c, v);
|
|
467
478
|
} else
|
|
468
|
-
|
|
479
|
+
Jt(d, c);
|
|
469
480
|
s.delete(c.key), o++;
|
|
470
481
|
}
|
|
471
482
|
} else {
|
|
472
|
-
const
|
|
473
|
-
N(t, c,
|
|
483
|
+
const d = (l = e[o]) == null ? void 0 : l.elm;
|
|
484
|
+
N(t, c, d);
|
|
474
485
|
}
|
|
475
486
|
r++;
|
|
476
487
|
}
|
|
@@ -481,7 +492,7 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
481
492
|
}, Ct = (t, e, n = []) => {
|
|
482
493
|
if (!e || e.length === 0) return [];
|
|
483
494
|
const s = [];
|
|
484
|
-
return F(s, e || [], [], "0"),
|
|
495
|
+
return F(s, e || [], [], "0"), kt(t, n, s), s;
|
|
485
496
|
}, j = (t) => {
|
|
486
497
|
if (t === null || typeof t != "object") return !1;
|
|
487
498
|
const e = Object.prototype.toString.call(t);
|
|
@@ -495,7 +506,7 @@ const qt = "http://www.w3.org/1999/xlink", Vt = "http://www.w3.org/2000/xmlns/",
|
|
|
495
506
|
"[object WeakSet]"
|
|
496
507
|
].includes(e);
|
|
497
508
|
};
|
|
498
|
-
function
|
|
509
|
+
function ee(t = window.location) {
|
|
499
510
|
let e;
|
|
500
511
|
typeof t == "string" ? e = new URL(t).hash : e = t.hash;
|
|
501
512
|
const n = e.split("?"), s = n[0].substring(2), r = n[1], o = {};
|
|
@@ -510,110 +521,110 @@ function te(t = window.location) {
|
|
|
510
521
|
};
|
|
511
522
|
}
|
|
512
523
|
function pt(t, e, n = {}) {
|
|
513
|
-
const s = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakSet(), o = /* @__PURE__ */ new WeakMap(), { throttle: a = 0, deepCompare: i = !1, onBatch: f = null, immediate:
|
|
514
|
-
let c = [], u = null,
|
|
515
|
-
const
|
|
524
|
+
const s = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakSet(), o = /* @__PURE__ */ new WeakMap(), { throttle: a = 0, deepCompare: i = !1, onBatch: f = null, immediate: p = !1 } = n, l = Array.isArray(n.filter) ? n.filter : n.filter ? [n.filter] : [];
|
|
525
|
+
let c = [], u = null, d = !0;
|
|
526
|
+
const v = (h, m, b = /* @__PURE__ */ new WeakMap()) => {
|
|
516
527
|
if (h === m) return !0;
|
|
517
528
|
if (h == null || m == null || typeof h != "object" || typeof m != "object") return h === m;
|
|
518
|
-
if (
|
|
519
|
-
if (
|
|
529
|
+
if (b.has(h)) return b.get(h) === m;
|
|
530
|
+
if (b.set(h, m), Array.isArray(h) && Array.isArray(m)) {
|
|
520
531
|
if (h.length !== m.length) return !1;
|
|
521
532
|
for (let g = 0; g < h.length; g++)
|
|
522
|
-
if (
|
|
533
|
+
if (!v(h[g], m[g], b)) return !1;
|
|
523
534
|
return !0;
|
|
524
535
|
}
|
|
525
536
|
if (Array.isArray(h) !== Array.isArray(m)) return !1;
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
528
|
-
for (const g of
|
|
529
|
-
if (!Object.prototype.hasOwnProperty.call(m, g) ||
|
|
537
|
+
const $ = Object.keys(h), y = Object.keys(m);
|
|
538
|
+
if ($.length !== y.length) return !1;
|
|
539
|
+
for (const g of $)
|
|
540
|
+
if (!Object.prototype.hasOwnProperty.call(m, g) || !v(h[g], m[g], b)) return !1;
|
|
530
541
|
return !0;
|
|
531
|
-
},
|
|
542
|
+
}, k = (h) => {
|
|
532
543
|
if (l.length === 0) return !0;
|
|
533
544
|
const m = h.map(String).join(".");
|
|
534
|
-
return l.some((
|
|
535
|
-
if (!
|
|
545
|
+
return l.some((b) => {
|
|
546
|
+
if (!b) return !0;
|
|
536
547
|
try {
|
|
537
548
|
return new RegExp(
|
|
538
|
-
"^" +
|
|
549
|
+
"^" + b.replace(/\./g, "\\.").replace(/\[\*\]/g, "(\\.\\d+)?").replace(/\*\*/g, "(.+)").replace(/\*/g, "[^.]+") + "$"
|
|
539
550
|
).test(m);
|
|
540
551
|
} catch {
|
|
541
552
|
return !0;
|
|
542
553
|
}
|
|
543
554
|
});
|
|
544
|
-
},
|
|
545
|
-
|
|
546
|
-
if (!
|
|
555
|
+
}, M = (h, m, b) => {
|
|
556
|
+
d && k(h) && (a > 0 ? (c.push({ path: h, newValue: m, oldValue: b }), u || (u = setTimeout(() => {
|
|
557
|
+
if (!d) {
|
|
547
558
|
u = null;
|
|
548
559
|
return;
|
|
549
560
|
}
|
|
550
|
-
const
|
|
551
|
-
c = [], u = null, f && f(
|
|
552
|
-
for (const y of
|
|
561
|
+
const $ = c;
|
|
562
|
+
c = [], u = null, f && f($);
|
|
563
|
+
for (const y of $)
|
|
553
564
|
e(y.path, y.newValue, y.oldValue);
|
|
554
|
-
}, a))) : (e(h, m,
|
|
565
|
+
}, a))) : (e(h, m, b), f && f([{ path: h, newValue: m, oldValue: b }])));
|
|
555
566
|
}, Q = (h, m) => {
|
|
556
567
|
if (!j(h) || !(Array.isArray(h) || Object.prototype.toString.call(h) === "[object Object]")) return h;
|
|
557
|
-
const
|
|
568
|
+
const b = {};
|
|
558
569
|
if (["push", "pop", "shift", "unshift", "splice", "sort", "reverse"].forEach((y) => {
|
|
559
570
|
const g = Array.prototype[y];
|
|
560
|
-
|
|
561
|
-
if (!
|
|
562
|
-
const C = [...h],
|
|
563
|
-
return
|
|
571
|
+
b[y] = function(...E) {
|
|
572
|
+
if (!d) return Reflect.apply(g, h, E);
|
|
573
|
+
const C = [...h], W = g.apply(h, E);
|
|
574
|
+
return v(h, C) || M(m, h, C), W;
|
|
564
575
|
};
|
|
565
576
|
}), s.has(h)) {
|
|
566
577
|
const y = s.get(h);
|
|
567
578
|
return o.set(y, m), y;
|
|
568
579
|
}
|
|
569
580
|
r.add(h);
|
|
570
|
-
const
|
|
581
|
+
const $ = new Proxy(h, {
|
|
571
582
|
get(y, g, E) {
|
|
572
|
-
if (Array.isArray(y) &&
|
|
573
|
-
return Reflect.get(
|
|
583
|
+
if (Array.isArray(y) && b.hasOwnProperty(g))
|
|
584
|
+
return Reflect.get(b, g, E);
|
|
574
585
|
const C = Reflect.get(y, g, E);
|
|
575
586
|
if (j(C)) {
|
|
576
|
-
const J = [...o.get(
|
|
587
|
+
const J = [...o.get($) || [], g], nt = Q(C, J);
|
|
577
588
|
return o.set(nt, J), nt;
|
|
578
589
|
}
|
|
579
590
|
return C;
|
|
580
591
|
},
|
|
581
592
|
set(y, g, E, C) {
|
|
582
|
-
const
|
|
583
|
-
if (i && J ?
|
|
584
|
-
const Mt = Reflect.set(y, g, E, C), Pt = o.get(
|
|
585
|
-
return
|
|
593
|
+
const W = Reflect.get(y, g, C), J = j(E) && !(E instanceof Date || E instanceof RegExp || E instanceof Map || E instanceof Set);
|
|
594
|
+
if (i && J ? v(W, E) : W === E) return !0;
|
|
595
|
+
const Mt = Reflect.set(y, g, E, C), Pt = o.get($) || m;
|
|
596
|
+
return M([...Pt, g], E, W), Mt;
|
|
586
597
|
},
|
|
587
598
|
deleteProperty(y, g) {
|
|
588
599
|
if (Reflect.has(y, g)) {
|
|
589
|
-
const E = y[g], C = Reflect.deleteProperty(y, g),
|
|
590
|
-
return C && r.has(y) &&
|
|
600
|
+
const E = y[g], C = Reflect.deleteProperty(y, g), W = o.get($) || [];
|
|
601
|
+
return C && r.has(y) && M([...W, g], void 0, E), C;
|
|
591
602
|
}
|
|
592
603
|
return !1;
|
|
593
604
|
}
|
|
594
605
|
});
|
|
595
|
-
return s.set(h,
|
|
606
|
+
return s.set(h, $), o.set($, m), $;
|
|
596
607
|
}, Rt = Q(t, []);
|
|
597
|
-
if (
|
|
598
|
-
const h = (m,
|
|
599
|
-
if (!(!j(m) || !
|
|
600
|
-
|
|
608
|
+
if (p) {
|
|
609
|
+
const h = (m, b, $ = /* @__PURE__ */ new WeakSet()) => {
|
|
610
|
+
if (!(!j(m) || !d || $.has(m))) {
|
|
611
|
+
$.add(m);
|
|
601
612
|
for (const y of Object.keys(m)) {
|
|
602
|
-
const g = [...
|
|
603
|
-
|
|
613
|
+
const g = [...b, y], E = m[y];
|
|
614
|
+
k(g) && e(g, E, void 0), j(E) && h(E, g, $);
|
|
604
615
|
}
|
|
605
616
|
}
|
|
606
617
|
};
|
|
607
618
|
h(t, []);
|
|
608
619
|
}
|
|
609
620
|
return { proxy: Rt, unobserve: () => {
|
|
610
|
-
|
|
621
|
+
d && (d = !1, c = [], u && (clearTimeout(u), u = null));
|
|
611
622
|
}, resume: () => {
|
|
612
|
-
|
|
623
|
+
d = !0;
|
|
613
624
|
} };
|
|
614
625
|
}
|
|
615
|
-
var V, z, G, L, K, D, _,
|
|
616
|
-
class
|
|
626
|
+
var V, z, G, L, K, D, _, R, U, it;
|
|
627
|
+
class ue extends HTMLElement {
|
|
617
628
|
// 停止数据监听函数
|
|
618
629
|
// -----------------------------------------------------
|
|
619
630
|
/**
|
|
@@ -625,25 +636,25 @@ class le extends HTMLElement {
|
|
|
625
636
|
constructor(n = {}) {
|
|
626
637
|
var a;
|
|
627
638
|
super();
|
|
628
|
-
|
|
639
|
+
P(this, R);
|
|
629
640
|
// ---------------------- 私有属性 ----------------------
|
|
630
|
-
|
|
641
|
+
P(this, V);
|
|
631
642
|
// 响应式数据(Proxy)
|
|
632
|
-
|
|
643
|
+
P(this, z, []);
|
|
633
644
|
// 模板解析后的虚拟节点 AST
|
|
634
|
-
|
|
645
|
+
P(this, G, []);
|
|
635
646
|
// 上一次渲染的虚拟节点
|
|
636
|
-
|
|
647
|
+
P(this, L, !1);
|
|
637
648
|
// 节流刷新,防止重复 patch
|
|
638
|
-
|
|
649
|
+
P(this, K, !1);
|
|
639
650
|
// 是否已挂载
|
|
640
|
-
|
|
651
|
+
P(this, D);
|
|
641
652
|
// 渲染根节点(Shadow DOM 优先)
|
|
642
|
-
|
|
653
|
+
P(this, _);
|
|
643
654
|
const s = this._manifest || {};
|
|
644
|
-
|
|
645
|
-
const { proxy: r, unobserve: o } = pt(n, () =>
|
|
646
|
-
|
|
655
|
+
A(this, D, (a = s.shadowDOM) != null && a.use ? this.attachShadow({ mode: s.shadowDOM.mode || "open" }) : this);
|
|
656
|
+
const { proxy: r, unobserve: o } = pt(n, () => I(this, R, U).call(this));
|
|
657
|
+
A(this, V, r), A(this, _, o), s.template && typeof s.template == "string" && A(this, z, Tt(this, s.template)), Promise.resolve().then(() => this.created());
|
|
647
658
|
}
|
|
648
659
|
/** Web Components 标准方法:声明哪些属性变化会触发 attributeChangedCallback */
|
|
649
660
|
static get observedAttributes() {
|
|
@@ -658,15 +669,15 @@ class le extends HTMLElement {
|
|
|
658
669
|
/** 更新组件数据 */
|
|
659
670
|
set $data(n) {
|
|
660
671
|
j(n) || (n = {}), x(this, _) && x(this, _).call(this);
|
|
661
|
-
const { proxy: s, unobserve: r } = pt(n, () =>
|
|
662
|
-
|
|
672
|
+
const { proxy: s, unobserve: r } = pt(n, () => I(this, R, U).call(this));
|
|
673
|
+
A(this, V, s), A(this, _, r), I(this, R, U).call(this);
|
|
663
674
|
}
|
|
664
675
|
/**
|
|
665
676
|
* 手动刷新组件
|
|
666
677
|
* 外部可调用,用于数据未触发 observe 或强制刷新
|
|
667
678
|
*/
|
|
668
679
|
refresh() {
|
|
669
|
-
|
|
680
|
+
I(this, R, U).call(this);
|
|
670
681
|
}
|
|
671
682
|
// ---------------------- Web Components 生命周期 ----------------------
|
|
672
683
|
connectedCallback() {
|
|
@@ -677,22 +688,22 @@ class le extends HTMLElement {
|
|
|
677
688
|
}
|
|
678
689
|
if (n.props && j(this.$data))
|
|
679
690
|
for (const r of n.props) {
|
|
680
|
-
const o = typeof r == "string" ? r : r.name, a = typeof r == "object" && "type" in r ? r.type : void 0, i = o.replace(/-([a-z])/g, (
|
|
691
|
+
const o = typeof r == "string" ? r : r.name, a = typeof r == "object" && "type" in r ? r.type : void 0, i = o.replace(/-([a-z])/g, (p, l) => l.toUpperCase()), f = this.$data[i];
|
|
681
692
|
if (this.hasAttribute(o)) {
|
|
682
|
-
const
|
|
683
|
-
this.$data[i] =
|
|
693
|
+
const p = this.getAttribute(o);
|
|
694
|
+
this.$data[i] = I(this, R, it).call(this, p, f, a);
|
|
684
695
|
}
|
|
685
696
|
}
|
|
686
|
-
|
|
697
|
+
I(this, R, U).call(this);
|
|
687
698
|
}
|
|
688
699
|
disconnectedCallback() {
|
|
689
700
|
var n;
|
|
690
|
-
this.isConnected && (this.unmounted(), (n = x(this, _)) == null || n.call(this),
|
|
701
|
+
this.isConnected && (this.unmounted(), (n = x(this, _)) == null || n.call(this), A(this, _, void 0));
|
|
691
702
|
}
|
|
692
703
|
attributeChangedCallback(n, s, r) {
|
|
693
704
|
if (s === r || !j(this.$data)) return;
|
|
694
705
|
const o = n.replace(/-([a-z])/g, (i, f) => f.toUpperCase()), a = this.$data[o];
|
|
695
|
-
this.$data[o] =
|
|
706
|
+
this.$data[o] = I(this, R, it).call(this, r, a);
|
|
696
707
|
}
|
|
697
708
|
// ---------------------- 自定义生命周期钩子 ----------------------
|
|
698
709
|
/** 兼容旧组件的初始化钩子(首次 mounted 后调用) */
|
|
@@ -714,16 +725,16 @@ class le extends HTMLElement {
|
|
|
714
725
|
unmounted() {
|
|
715
726
|
}
|
|
716
727
|
}
|
|
717
|
-
V = new WeakMap(), z = new WeakMap(), G = new WeakMap(), L = new WeakMap(), K = new WeakMap(), D = new WeakMap(), _ = new WeakMap(),
|
|
728
|
+
V = new WeakMap(), z = new WeakMap(), G = new WeakMap(), L = new WeakMap(), K = new WeakMap(), D = new WeakMap(), _ = new WeakMap(), R = new WeakSet(), // ---------------------- 渲染核心逻辑 ----------------------
|
|
718
729
|
/** 内部刷新函数,由 observe() 或外部调用触发 */
|
|
719
730
|
U = function() {
|
|
720
|
-
x(this, L) || (
|
|
731
|
+
x(this, L) || (A(this, L, !0), Dt(() => {
|
|
721
732
|
var n;
|
|
722
733
|
if (!this.isConnected) {
|
|
723
|
-
|
|
734
|
+
A(this, L, !1);
|
|
724
735
|
return;
|
|
725
736
|
}
|
|
726
|
-
this.beforeUpdate(),
|
|
737
|
+
this.beforeUpdate(), A(this, G, Ct(x(this, D), x(this, z), x(this, G))), A(this, L, !1), x(this, K) ? this.updated() : (A(this, K, !0), this.mounted(), (n = this.onInit) == null || n.call(this));
|
|
727
738
|
}));
|
|
728
739
|
}, // ---------------------- 属性类型转换工具 ----------------------
|
|
729
740
|
it = function(n, s, r) {
|
|
@@ -744,28 +755,28 @@ it = function(n, s, r) {
|
|
|
744
755
|
return n;
|
|
745
756
|
}
|
|
746
757
|
};
|
|
747
|
-
const
|
|
758
|
+
const ne = (t) => (e) => {
|
|
748
759
|
if (customElements.get(t.tagName)) {
|
|
749
760
|
console.warn(`标签名称 "${t.tagName}" 已经被注册`);
|
|
750
761
|
return;
|
|
751
762
|
}
|
|
752
|
-
return e.prototype._manifest =
|
|
753
|
-
},
|
|
763
|
+
return e.prototype._manifest = se(t), customElements.define(t.tagName, e), e;
|
|
764
|
+
}, se = (t) => (t = Object.assign({
|
|
754
765
|
hasConfig: !1
|
|
755
766
|
}, t), t);
|
|
756
|
-
var
|
|
767
|
+
var re = Object.getOwnPropertyDescriptor, xt = (t) => {
|
|
757
768
|
throw TypeError(t);
|
|
758
|
-
},
|
|
759
|
-
for (var r = s > 1 ? void 0 : s ?
|
|
769
|
+
}, oe = (t, e, n, s) => {
|
|
770
|
+
for (var r = s > 1 ? void 0 : s ? re(e, n) : e, o = t.length - 1, a; o >= 0; o--)
|
|
760
771
|
(a = t[o]) && (r = a(r) || r);
|
|
761
772
|
return r;
|
|
762
|
-
}, ht = (t, e, n) => e.has(t) || xt("Cannot " + n),
|
|
773
|
+
}, ht = (t, e, n) => e.has(t) || xt("Cannot " + n), S = (t, e, n) => (ht(t, e, "read from private field"), n ? n.call(t) : e.get(t)), O = (t, e, n) => e.has(t) ? xt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), T = (t, e, n, s) => (ht(t, e, "write to private field"), e.set(t, n), n), ae = (t, e, n) => (ht(t, e, "access private method"), n), Y, tt, et, B, q, X, Z, ct, wt;
|
|
763
774
|
function dt(t) {
|
|
764
775
|
return t instanceof HTMLElement && t.isRouterView === !0;
|
|
765
776
|
}
|
|
766
777
|
let mt = class extends HTMLElement {
|
|
767
778
|
constructor() {
|
|
768
|
-
super(...arguments),
|
|
779
|
+
super(...arguments), O(this, ct), O(this, Y, []), O(this, tt, []), O(this, et, null), O(this, B), O(this, q, []), O(this, X, {}), O(this, Z, this.onHashChange.bind(this));
|
|
769
780
|
}
|
|
770
781
|
// #endregion
|
|
771
782
|
// #region 公共属性和访问器
|
|
@@ -773,16 +784,16 @@ let mt = class extends HTMLElement {
|
|
|
773
784
|
return !0;
|
|
774
785
|
}
|
|
775
786
|
get $routes() {
|
|
776
|
-
return
|
|
787
|
+
return S(this, q);
|
|
777
788
|
}
|
|
778
789
|
set $routes(t) {
|
|
779
790
|
T(this, q, t), this.onHashChange();
|
|
780
791
|
}
|
|
781
792
|
get $remainingPath() {
|
|
782
|
-
return
|
|
793
|
+
return S(this, tt);
|
|
783
794
|
}
|
|
784
795
|
get $matchedRoute() {
|
|
785
|
-
return
|
|
796
|
+
return S(this, et);
|
|
786
797
|
}
|
|
787
798
|
set $pipe(t) {
|
|
788
799
|
T(this, X, t || {}), this.onHashChange();
|
|
@@ -790,10 +801,10 @@ let mt = class extends HTMLElement {
|
|
|
790
801
|
// #endregion
|
|
791
802
|
// #region 生命周期回调
|
|
792
803
|
connectedCallback() {
|
|
793
|
-
window.addEventListener("hashchange",
|
|
804
|
+
window.addEventListener("hashchange", S(this, Z)), this.onHashChange();
|
|
794
805
|
}
|
|
795
806
|
disconnectedCallback() {
|
|
796
|
-
window.removeEventListener("hashchange",
|
|
807
|
+
window.removeEventListener("hashchange", S(this, Z));
|
|
797
808
|
}
|
|
798
809
|
// #endregion
|
|
799
810
|
/**
|
|
@@ -806,10 +817,10 @@ let mt = class extends HTMLElement {
|
|
|
806
817
|
if (t)
|
|
807
818
|
T(this, B, t.$remainingPath), T(this, q, ((e = t.$matchedRoute) == null ? void 0 : e.children) || []);
|
|
808
819
|
else {
|
|
809
|
-
const { path: n } =
|
|
820
|
+
const { path: n } = ee(window.location);
|
|
810
821
|
T(this, B, n);
|
|
811
822
|
}
|
|
812
|
-
|
|
823
|
+
ae(this, ct, wt).call(this);
|
|
813
824
|
}
|
|
814
825
|
/**
|
|
815
826
|
* 准备传递给子组件的 props 和事件监听
|
|
@@ -820,7 +831,7 @@ let mt = class extends HTMLElement {
|
|
|
820
831
|
const e = {}, n = {};
|
|
821
832
|
for (const [s, r] of Object.entries(t))
|
|
822
833
|
e[s] = () => r;
|
|
823
|
-
for (const [s, r] of Object.entries(
|
|
834
|
+
for (const [s, r] of Object.entries(S(this, X))) {
|
|
824
835
|
const o = s.toLowerCase();
|
|
825
836
|
let a = null;
|
|
826
837
|
o.startsWith("on-") ? a = o.slice(3) : o.startsWith("on") && gt.includes(o.slice(2)) && (a = o.slice(2)), a ? n[a] = r : e[s] = () => r;
|
|
@@ -897,7 +908,7 @@ X = /* @__PURE__ */ new WeakMap();
|
|
|
897
908
|
Z = /* @__PURE__ */ new WeakMap();
|
|
898
909
|
ct = /* @__PURE__ */ new WeakSet();
|
|
899
910
|
wt = function() {
|
|
900
|
-
const t =
|
|
911
|
+
const t = S(this, B) || [], { matchedRoute: e, params: n, remainingPath: s } = this.matchRoute(S(this, q), t);
|
|
901
912
|
T(this, tt, s), T(this, et, e);
|
|
902
913
|
const r = (e == null ? void 0 : e.tagName) || "comment", { props: o, on: a } = this.prepareComponentData(n);
|
|
903
914
|
T(this, Y, Ct(this, [{
|
|
@@ -908,22 +919,22 @@ wt = function() {
|
|
|
908
919
|
props: o,
|
|
909
920
|
on: a,
|
|
910
921
|
children: []
|
|
911
|
-
}],
|
|
922
|
+
}], S(this, Y))), this.propagateToChildRouterViews();
|
|
912
923
|
};
|
|
913
|
-
mt =
|
|
914
|
-
|
|
924
|
+
mt = oe([
|
|
925
|
+
ne({
|
|
915
926
|
tagName: "router-view"
|
|
916
927
|
})
|
|
917
928
|
], mt);
|
|
918
929
|
export {
|
|
919
|
-
|
|
920
|
-
|
|
930
|
+
ue as BaseElement,
|
|
931
|
+
ne as CustomElement,
|
|
921
932
|
mt as RouterViewElement,
|
|
922
933
|
lt as createFunction,
|
|
923
934
|
j as isObject,
|
|
924
935
|
gt as listeners,
|
|
925
936
|
pt as observe,
|
|
926
|
-
|
|
937
|
+
ee as parseHashUrl,
|
|
927
938
|
Tt as parseHtml,
|
|
928
939
|
Ct as patch,
|
|
929
940
|
Dt as runInAsyncQueue
|
package/dist/solely.umd.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(d,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(d=typeof globalThis<"u"?globalThis:d||self,v(d.solely={}))})(this,function(d){"use strict";var It=d=>{throw TypeError(d)};var yt=(d,v,C)=>v.has(d)||It("Cannot "+C);var M=(d,v,C)=>(yt(d,v,"read from private field"),C?C.call(d):v.get(d)),j=(d,v,C)=>v.has(d)?It("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(d):v.set(d,C),w=(d,v,C,X)=>(yt(d,v,"write to private field"),X?X.call(d,C):v.set(d,C),C),D=(d,v,C)=>(yt(d,v,"access private method"),C);var z,Q,J,V,N,U,I,_,G,Et;const v=/<!--(?:.|\s)*?-->|<[a-zA-Z0-9\-/](?:"[^"]*"|'[^']*'|[^'">])*>/g,C=/<\/?([^\s]+?)[/\s>]/,X=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g,Ot=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],it=/\{\{(.+?)\}\}/g;function jt(t){return t.replace(/>\s+</g,"><").replace(/\s+/g," ")}function Tt(t,e){const n=(e.match(C)||[])[1]||"",s={rootId:"0",tagName:n,attrs:{},props:{},on:{},children:[]},r=new RegExp(X);for(;;){const o=r.exec(e);if(o===null)break;if(!o[0].trim())continue;const[a,i]=o[1]?o[1].trim().split("="):[o[2],o[3].trim().slice(1,-1)];if(a==="onMounted"||a==="onUpdated")s[a]=Ht(t,i);else if(ct.includes(a)||a.startsWith("on-"))s.on[a.startsWith("on-")?a.slice(3):a.slice(2)]=F(t,i);else if(a.startsWith("s-")){const l=a.slice(2);switch(l){case"model":s.model=i;break;case"style":s.styles=p=>P(t,i,p);break;case"class":s.classes=p=>P(t,i,p);break;case"readonly":s.props.readOnly=p=>P(t,i,p);break;case"for":s.props.htmlFor=p=>P(t,i,p);break;case"tabindex":s.props.tabIndex=p=>P(t,i,p);break;case"contenteditable":s.props.contentEditable=p=>P(t,i,p);break;default:s.props[l]=p=>P(t,i,p);break}}else s.attrs[a]=i;r.lastIndex--}if(n==="For"?s.fn=o=>P(t,s.attrs.each,o):(n==="If"||n==="ElseIf")&&(s.fn=o=>P(t,s.attrs.condition,o)),s.model){const o=s.model.replace("this.","").replace("$data.",""),a=l=>P(t,`$data.${o}`,l),i=(l,p)=>{if(s.on[l]){const u=s.on[l];s.on[l]=(c,h)=>{p(c,h),u(c,h)}}else s.on[l]=p};if(n==="input"){const l=s.attrs.type||"text";if(l==="checkbox")s.props.checked=a,i("change",F(t,`$data.${o}=checked`));else if(l==="radio"){const p=s.attrs.value;s.props.checked=u=>a(u)==p,i("change",F(t,`if(checked){$data.${o}='${p}'}`))}else s.props.value=a,i("input",F(t,`$data.${o}=value`))}else if(n==="textarea")s.props.value=a,i("input",F(t,`$data.${o}=value`));else if(n==="select"){const l="multiple"in s.attrs;l?i("change",F(t,`
|
|
2
2
|
$data.${o} = Array.from(event.target.selectedOptions).map(o => o.value);
|
|
3
|
-
`)):(i("change",F(n,`$data.${o}=value`)),s.props.value=a);const m=(h,d=[])=>{const k=a(d);if(l){const R=Array.isArray(k)?k:k!=null?[k]:[];for(const I of h.options)I.selected=R.includes(I.value)}else{const R=k??"";h.value!==R&&(h.value=R)}},u=s.onMounted,c=s.onUpdated;s.onMounted=(h,d)=>{u==null||u(h,d),m(h,d||[])},s.onUpdated=(h,d)=>{c==null||c(h,d),m(h,d||[])}}}return s}function bt(n,t){const e=[];if(!t)return e;t=jt(t);const s=[],r=[],o=()=>{var i;return s.length===0?e:(i=s[s.length-1]).children||(i.children=[])};let a=0;return t.replace(v,(i,l)=>{const m=o();if(l>a){const u=t.substring(a,l).trim();if(u){it.lastIndex=0;const h=!it.test(u)?u:d=>u.replace(it,(k,R)=>j(n,R,d));m.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:h,children:[]})}}if(a=l+i.length,i.startsWith("<!--")&&i.endsWith("-->"))m.push({rootId:"0",tagName:"comment",attrs:{},props:{},on:{},content:i.slice(4,-3),children:[]});else if(i.startsWith("</")){const u=r.pop();for(;s.length>0&&s[s.length-1].tagName!==u;)s.pop();s.pop()}else{const u=Tt(n,i),c=i.endsWith("/>")||Ot.includes(u.tagName);m.push(u),c||(s.push(u),r.push(u.tagName))}return""}),t.length>a&&e.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:t.substring(a).trim(),children:[]}),e}const j=(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){return console.error(`[BaseElement][${n.tagName}] Error evaluating expression: {{ ${t} }}`,n,s),""}},F=(n,t)=>(e,s)=>{var r,o;try{return Z(["$data","event","value","checked",...s.map(i=>i.item),...s.map(i=>i.index),t]).bind(n)(n.$data,e,(r=e==null?void 0:e.target)==null?void 0:r.value,(o=e==null?void 0:e.target)==null?void 0:o.checked,...s.map(i=>i.value),...s.map(i=>i.valueIndex))}catch(a){console.error(`[BaseElement][${n.tagName}] Error executing event handler "${t}"`,n,a)}},Ht=(n,t)=>(e,s=[])=>{try{Z(["$data","elm",...s.map(o=>o.item),...s.map(o=>o.index),`(function(){ ${t} }).call(this)`]).bind(n)(n.$data,e,...s.map(o=>o.value),...s.map(o=>o.valueIndex))}catch(r){console.error(`[BaseElement][${n.tagName}] Error executing lifecycle handler "${t}"`,n,r)}},ct=["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"],Lt=typeof requestAnimationFrame=="function"?n=>requestAnimationFrame(n):typeof Promise<"u"?n=>Promise.resolve().then(n):n=>setTimeout(n,0),vt=(n,...t)=>{if(typeof n!="function")throw new Error("runInAsyncQueue expects a function as its first argument");Lt(()=>n(...t))},lt={};function Z(n){const t=n.map(e=>e.replace(/[',"]/g,"")).join(",");if(!lt[t]){const e=n[n.length-1];if(e.trim()==="")throw new Error("Function body cannot be empty");if(Ft(e))throw new Error("Input contains potentially dangerous code: "+e);lt[t]=new Function(...n)}return lt[t]}const Dt=["eval","Function","process","require"];function Ft(n){return Dt.some(t=>new RegExp(`\\b${t}\\b`,"g").test(n))}const Ut="http://www.w3.org/1999/xlink",Vt="http://www.w3.org/2000/xmlns/",qt="http://www.w3.org/XML/1998/namespace",Bt="http://www.w3.org/2000/svg",$t=n=>typeof n.content=="function"?n.content(n.loops||[]):n.content||"",zt=n=>{const t=$t(n),e=n.elm;e.textContent!==t&&(e.textContent=t)},kt=(n,t,e=[])=>{Object.keys(t).forEach(s=>{const r=t[s](e);n[s]!==r&&(n[s]=r)})},At=(n,t)=>{const{styles:e,loops:s=[]}=t;if(!e)return;const r=e(s),o=ut(r);Object.entries(o).forEach(([a,i])=>{n.style[a]=i})},Ct=(n,t)=>{const{classes:e,loops:s=[]}=t;if(!e)return;const r=e(s),o=wt(r);Object.entries(o).forEach(([a,i])=>{i?n.classList.add(a):n.classList.remove(a)})},ut=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=ut(s);Object.entries(r).forEach(([o,a])=>{t[`${e}-${o}`]=a})}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(o=>o.trim());s&&r&&(t[s]=r)}):Array.isArray(n)&&n.forEach(e=>{const s=ut(e);Object.entries(s).forEach(([r,o])=>{t[r]=o})}),t},wt=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=wt(e);Object.entries(s).forEach(([r,o])=>{t[r]=o})}),t},Rt=(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},Gt=(n,t)=>{const e=t.elm;Object.keys(t.on).forEach(s=>{n.handlers&&n.handlers[s]&&e.removeEventListener(s,n.handlers[s],!1),Rt(e,s,t)}),kt(e,t.props,t.loops),Ct(e,t),At(e,t),typeof t.onUpdated=="function"&&requestAnimationFrame(()=>{t.onUpdated(e,t.loops||[])}),Mt(e,n.children,t.children)},Kt=(n,t)=>{switch(t.elm=n.elm,t.tagName){case"comment":break;case"text":zt(t);break;case"slot":break;default:Gt(n,t);break}},ht=(n,t,e)=>{e&&e.parentNode===n?n.insertBefore(t,e):n.appendChild(t)},Qt=(n,t,e)=>{const s=$t(t),r=document.createTextNode(s);t.elm=r,ht(n,r,e)},Jt=(n,t,e)=>{const s=t.content,r=document.createComment(s);t.elm=r,ht(n,r,e)},Nt=(n,t,e,s)=>{t.tagName==="svg"&&(s=Bt);const r=s?document.createElementNS(s,t.tagName):document.createElement(t.tagName);Object.keys(t.attrs).forEach(o=>{const a=t.attrs[o]||"";o.charAt(0)!=="x"?r.setAttribute(o,a):o.startsWith("xml:")?r.setAttributeNS(qt,o,a):o.startsWith("xlink:")?r.setAttributeNS(Ut,o,a):o.startsWith("xmlns:")?r.setAttributeNS(Vt,o,a):r.setAttribute(o,a)}),Object.keys(t.on).forEach(o=>{Rt(r,o,t)}),kt(r,t.props,t.loops),Ct(r,t),At(r,t),t.elm=r,ht(n,r,e),t.tagName==="foreignObject"&&(s=void 0),t.children.forEach(o=>{Y(r,o,void 0,s)}),typeof t.onMounted=="function"&&requestAnimationFrame(()=>{t.onMounted(r,t.loops||[])})},Y=(n,t,e,s)=>{switch(t.tagName){case"comment":Jt(n,t,e);break;case"text":Qt(n,t,e);break;default:Nt(n,t,e,s);break}},Xt=n=>n&&(n.tagName==="ElseIf"||n.tagName==="comment"),Zt=n=>n&&n.tagName==="Else",q=(n,t,e=[],s="0",r)=>{var i,l,m;let o=0,a=0;for(let u=0;u<t.length;u++){const c=t[u];if(c.tagName==="If"){let h=!1;o++;let d=1;for(((i=c.fn)==null?void 0:i.call(c,e))&&(q(n,c.children,e,`${s}-if-${o}-${d}`,d),h=!0),d++;u+1<t.length&&Xt(t[u+1]);)((m=(l=t[u+1]).fn)==null?void 0:m.call(l,e))&&!h&&(q(n,t[u+1].children,e,`${s}-if-${o}-${d}`,d),h=!0),u++,d++;u+1<t.length&&Zt(t[u+1])&&(h||(q(n,t[u+1].children,e,`${s}-if-${o}-${d}`,d),h=!0),u++)}else if(c.tagName==="For"){a++;const{item:h="item",index:d="index"}=c.attrs;(c.fn(e)||[]).forEach((R,I)=>{const ot={item:h,value:R,index:d,valueIndex:I};q(n,c.children,[...e,ot],`${s}-for-${a}-${I}`,1)})}else{const h={...c,loops:e,children:[],rootId:s,ifId:r,key:c.key||`${s}-${u}`};q(h.children,c.children,e,`${s}-${u}`),n.push(h)}}},Mt=(n,t,e)=>{var a,i,l,m,u;const s=new Map;t.forEach((c,h)=>s.set(c.key,{node:c,index:h}));let r=0,o=0;for(;r<e.length;){const c=e[r],h=s.get(c.key);if(h){const d=h.node;if(d.tagName!==c.tagName){(a=d.elm)==null||a.remove();const k=(i=t[o+1])==null?void 0:i.elm;Y(n,c,k),s.delete(c.key),o++}else{if(c.ifId&&d.ifId!==c.ifId){(l=d.elm)==null||l.remove();const k=(m=t[o+1])==null?void 0:m.elm;Y(n,c,k)}else Kt(d,c);s.delete(c.key),o++}}else{const d=(u=t[o])==null?void 0:u.elm;Y(n,c,d)}r++}s.forEach(({node:c})=>{var h;return(h=c.elm)==null?void 0:h.remove()})},ft=(n,t,e=[])=>{if(!t||t.length===0)return[];const s=[];return q(s,t||[],[],"0"),Mt(n,e,s),s},_=n=>{if(n===null||typeof n!="object")return!1;const t=Object.prototype.toString.call(n);return!["[object Function]","[object Date]","[object RegExp]","[object Map]","[object Set]","[object WeakMap]","[object WeakSet]"].includes(t)};function Pt(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],o={};return r&&r.split("&").forEach(a=>{const[i,l]=a.split("=");i&&l&&(o[decodeURIComponent(i)]=decodeURIComponent(l))}),{path:s.split("/"),query:o}}function pt(n,t,e={}){const s=new WeakMap,r=new WeakSet,o=new WeakMap,{throttle:a=0,deepCompare:i=!1,onBatch:l=null,immediate:m=!1}=e,u=Array.isArray(e.filter)?e.filter:e.filter?[e.filter]:[];let c=[],h=null,d=!0;const k=(f,g,$=new WeakMap)=>{if(f===g)return!0;if(f==null||g==null||typeof f!="object"||typeof g!="object")return f===g;if($.has(f))return $.get(f)===g;if($.set(f,g),Array.isArray(f)&&Array.isArray(g)){if(f.length!==g.length)return!1;for(let y=0;y<f.length;y++)if(!k(f[y],g[y],$))return!1;return!0}if(Array.isArray(f)!==Array.isArray(g))return!1;const A=Object.keys(f),E=Object.keys(g);if(A.length!==E.length)return!1;for(const y of A)if(!Object.prototype.hasOwnProperty.call(g,y)||!k(f[y],g[y],$))return!1;return!0},R=f=>{if(u.length===0)return!0;const g=f.map(String).join(".");return u.some($=>{if(!$)return!0;try{return new RegExp("^"+$.replace(/\./g,"\\.").replace(/\[\*\]/g,"(\\.\\d+)?").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+")+"$").test(g)}catch{return!0}})},I=(f,g,$)=>{d&&R(f)&&(a>0?(c.push({path:f,newValue:g,oldValue:$}),h||(h=setTimeout(()=>{if(!d){h=null;return}const A=c;c=[],h=null,l&&l(A);for(const E of A)t(E.path,E.newValue,E.oldValue)},a))):(t(f,g,$),l&&l([{path:f,newValue:g,oldValue:$}])))},ot=(f,g)=>{if(!_(f)||!(Array.isArray(f)||Object.prototype.toString.call(f)==="[object Object]"))return f;const $={};if(["push","pop","shift","unshift","splice","sort","reverse"].forEach(E=>{const y=Array.prototype[E];$[E]=function(...b){if(!d)return Reflect.apply(y,f,b);const M=[...f],L=y.apply(f,b);return k(f,M)||I(g,f,M),L}}),s.has(f)){const E=s.get(f);return o.set(E,g),E}r.add(f);const A=new Proxy(f,{get(E,y,b){if(Array.isArray(E)&&$.hasOwnProperty(y))return Reflect.get($,y,b);const M=Reflect.get(E,y,b);if(_(M)){const at=[...o.get(A)||[],y],gt=ot(M,at);return o.set(gt,at),gt}return M},set(E,y,b,M){const L=Reflect.get(E,y,M),at=_(b)&&!(b instanceof Date||b instanceof RegExp||b instanceof Map||b instanceof Set);if(i&&at?k(L,b):L===b)return!0;const oe=Reflect.set(E,y,b,M),ae=o.get(A)||g;return I([...ae,y],b,L),oe},deleteProperty(E,y){if(Reflect.has(E,y)){const b=E[y],M=Reflect.deleteProperty(E,y),L=o.get(A)||[];return M&&r.has(E)&&I([...L,y],void 0,b),M}return!1}});return s.set(f,A),o.set(A,g),A},re=ot(n,[]);if(m){const f=(g,$,A=new WeakSet)=>{if(!(!_(g)||!d||A.has(g))){A.add(g);for(const E of Object.keys(g)){const y=[...$,E],b=g[E];R(y)&&t(y,b,void 0),_(b)&&f(b,y,A)}}};f(n,[])}return{proxy:re,unobserve:()=>{d&&(d=!1,c=[],h&&(clearTimeout(h),h=null))},resume:()=>{d=!0}}}class Yt extends HTMLElement{constructor(e={}){var a;super();O(this,S);O(this,z);O(this,Q,[]);O(this,J,[]);O(this,U,!1);O(this,N,!1);O(this,V);O(this,W);const s=this._manifest||{};w(this,V,(a=s.shadowDOM)!=null&&a.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this);const{proxy:r,unobserve:o}=pt(e,()=>D(this,S,G).call(this));w(this,z,r),w(this,W,o),s.template&&typeof s.template=="string"&&w(this,Q,bt(this,s.template)),Promise.resolve().then(()=>this.created())}static get observedAttributes(){const e=this._manifest||this.prototype._manifest;return e!=null&&e.props?e.props.map(s=>typeof s=="string"?s:s.name):[]}get $data(){return P(this,z)}set $data(e){_(e)||(e={}),P(this,W)&&P(this,W).call(this);const{proxy:s,unobserve:r}=pt(e,()=>D(this,S,G).call(this));w(this,z,s),w(this,W,r),D(this,S,G).call(this)}refresh(){D(this,S,G).call(this)}connectedCallback(){const e=this._manifest||{};if((e.className||e.tagName||"").split(" ").forEach(r=>r&&this.classList.add(r)),e.styles&&!P(this,V).querySelector("style[data-manifest-style]")){const r=document.createElement("style");r.setAttribute("data-manifest-style","true"),r.textContent=e.styles,P(this,V).appendChild(r)}if(e.props&&_(this.$data))for(const r of e.props){const o=typeof r=="string"?r:r.name,a=typeof r=="object"&&"type"in r?r.type:void 0,i=o.replace(/-([a-z])/g,(m,u)=>u.toUpperCase()),l=this.$data[i];if(this.hasAttribute(o)){const m=this.getAttribute(o);this.$data[i]=D(this,S,Et).call(this,m,l,a)}}D(this,S,G).call(this)}disconnectedCallback(){var e;this.isConnected&&(this.unmounted(),(e=P(this,W))==null||e.call(this),w(this,W,void 0))}attributeChangedCallback(e,s,r){if(s===r||!_(this.$data))return;const o=e.replace(/-([a-z])/g,(i,l)=>l.toUpperCase()),a=this.$data[o];this.$data[o]=D(this,S,Et).call(this,r,a)}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}}z=new WeakMap,Q=new WeakMap,J=new WeakMap,U=new WeakMap,N=new WeakMap,V=new WeakMap,W=new WeakMap,S=new WeakSet,G=function(){P(this,U)||(w(this,U,!0),vt(()=>{var e;if(!this.isConnected){w(this,U,!1);return}this.beforeUpdate(),w(this,J,ft(P(this,V),P(this,Q),P(this,J))),w(this,U,!1),P(this,N)?this.updated():(w(this,N,!0),this.mounted(),(e=this.onInit)==null||e.call(this))}))},Et=function(e,s,r){if(e===null)return s;switch(r||typeof s){case"number":const a=Number(e);return isNaN(a)?s:a;case"boolean":return e==="true";case"object":try{return JSON.parse(e)}catch{return s}default:return e}};const St=n=>t=>{if(customElements.get(n.tagName)){console.warn(`标签名称 "${n.tagName}" 已经被注册`);return}return t.prototype._manifest=te(n),customElements.define(n.tagName,t),t},te=n=>(n=Object.assign({hasConfig:!1},n),n);var ee=Object.getOwnPropertyDescriptor,_t=n=>{throw TypeError(n)},ne=(n,t,e,s)=>{for(var r=s>1?void 0:s?ee(t,e):t,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=a(r)||r);return r},dt=(n,t,e)=>t.has(n)||_t("Cannot "+e),x=(n,t,e)=>(dt(n,t,"read from private field"),e?e.call(n):t.get(n)),T=(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),H=(n,t,e,s)=>(dt(n,t,"write to private field"),t.set(n,e),e),se=(n,t,e)=>(dt(n,t,"access private method"),e),tt,et,nt,K,B,st,rt,mt,xt;function Wt(n){return n instanceof HTMLElement&&n.isRouterView===!0}p.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),T(this,mt),T(this,tt,[]),T(this,et,[]),T(this,nt,null),T(this,K),T(this,B,[]),T(this,st,{}),T(this,rt,this.onHashChange.bind(this))}get isRouterView(){return!0}get $routes(){return x(this,B)}set $routes(t){H(this,B,t),this.onHashChange()}get $remainingPath(){return x(this,et)}get $matchedRoute(){return x(this,nt)}set $pipe(t){H(this,st,t||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",x(this,rt)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",x(this,rt))}onHashChange(){var e;if(!this.isConnected)return;const t=this.findAncestorRouterView();if(t)H(this,K,t.$remainingPath),H(this,B,((e=t.$matchedRoute)==null?void 0:e.children)||[]);else{const{path:s}=Pt(window.location);H(this,K,s)}se(this,mt,xt).call(this)}prepareComponentData(t){const e={},s={};for(const[r,o]of Object.entries(t))e[r]=()=>o;for(const[r,o]of Object.entries(x(this,st))){const a=r.toLowerCase();let i=null;a.startsWith("on-")?i=a.slice(3):a.startsWith("on")&&ct.includes(a.slice(2))&&(i=a.slice(2)),i?s[i]=o:e[r]=()=>o}return{props:e,on:s}}matchRoute(t,e){for(const s of t){const r=s.path.split("/").filter(i=>i),o={};if(r.length>e.length&&!r.includes("*"))continue;let a=!0;for(let i=0;i<r.length;i++){const l=r[i],m=e[i];if(l.startsWith(":"))o[l.substring(1)]=m;else{if(l==="*")return{matchedRoute:s,params:o,remainingPath:[]};if(l!==m){a=!1;break}}}if(a)return{matchedRoute:s,params:o,remainingPath:e.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:e}}propagateToChildRouterViews(t=this){for(const e of t.childNodes)Wt(e)?e.onHashChange():this.propagateToChildRouterViews(e)}findAncestorRouterView(){let t=this.parentElement;for(;t;){if(Wt(t))return t;t=t.parentElement}return null}},tt=new WeakMap,et=new WeakMap,nt=new WeakMap,K=new WeakMap,B=new WeakMap,st=new WeakMap,rt=new WeakMap,mt=new WeakSet,xt=function(){const n=x(this,K)||[],{matchedRoute:t,params:e,remainingPath:s}=this.matchRoute(x(this,B),n);H(this,et,s),H(this,nt,t);const r=(t==null?void 0:t.tagName)||"comment",{props:o,on:a}=this.prepareComponentData(e);H(this,tt,ft(this,[{tagName:r,rootId:"0",attrs:{},props:o,on:a,children:[]}],x(this,tt))),this.propagateToChildRouterViews()},p.RouterViewElement=ne([St({tagName:"router-view"})],p.RouterViewElement),p.BaseElement=Yt,p.CustomElement=St,p.createFunction=Z,p.isObject=_,p.listeners=ct,p.observe=pt,p.parseHashUrl=Pt,p.parseHtml=bt,p.patch=ft,p.runInAsyncQueue=vt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
3
|
+
`)):(i("change",F(t,`$data.${o}=value`)),s.props.value=a);const p=(h,m=[])=>{const A=a(m);if(l){const R=Array.isArray(A)?A:A!=null?[A]:[];for(const O of h.options)O.selected=R.includes(O.value)}else{const R=A??"";h.value!==R&&(h.value=R)}},u=s.onMounted,c=s.onUpdated;s.onMounted=(h,m)=>{u==null||u(h,m),p(h,m||[])},s.onUpdated=(h,m)=>{c==null||c(h,m),p(h,m||[])}}}return s}function bt(t,e){const n=[];if(!e)return n;e=jt(e);const s=[],r=[],o=()=>{var i;return s.length===0?n:(i=s[s.length-1]).children||(i.children=[])};let a=0;return e.replace(v,(i,l)=>{const p=o();if(l>a){const u=e.substring(a,l).trim();if(u){it.lastIndex=0;const h=!it.test(u)?u:m=>u.replace(it,(A,R)=>P(t,R,m));p.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:h,children:[]})}}if(a=l+i.length,i.startsWith("<!--")&&i.endsWith("-->"))p.push({rootId:"0",tagName:"comment",attrs:{},props:{},on:{},content:i.slice(4,-3),children:[]});else if(i.startsWith("</")){const u=r.pop();for(;s.length>0&&s[s.length-1].tagName!==u;)s.pop();s.pop()}else{const u=Tt(t,i),c=i.endsWith("/>")||Ot.includes(u.tagName);p.push(u),c||(s.push(u),r.push(u.tagName))}return""}),e.length>a&&n.push({rootId:"0",tagName:"text",attrs:{},props:{},on:{},content:e.substring(a).trim(),children:[]}),n}const P=(t,e,n)=>{try{return Z(["$data",...n.map(r=>r.item),...n.map(r=>r.index),`return (${e})`]).bind(t)(t.$data,...n.map(r=>r.value),...n.map(r=>r.valueIndex))}catch(s){return console.error(`[BaseElement][${t.tagName}] Error evaluating expression: {{ ${e} }}`,t,s),""}},F=(t,e)=>(n,s)=>{var r,o;try{return Z(["$data","event","value","checked",...s.map(i=>i.item),...s.map(i=>i.index),e]).bind(t)(t.$data,n,(r=n==null?void 0:n.target)==null?void 0:r.value,(o=n==null?void 0:n.target)==null?void 0:o.checked,...s.map(i=>i.value),...s.map(i=>i.valueIndex))}catch(a){console.error(`[BaseElement][${t.tagName}] Error executing event handler "${e}"`,t,a)}},Ht=(t,e)=>(n,s=[])=>{try{Z(["$data","elm",...s.map(o=>o.item),...s.map(o=>o.index),`(function(){ ${e} }).call(this)`]).bind(t)(t.$data,n,...s.map(o=>o.value),...s.map(o=>o.valueIndex))}catch(r){console.error(`[BaseElement][${t.tagName}] Error executing lifecycle handler "${e}"`,t,r)}},ct=["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"],Lt=typeof requestAnimationFrame=="function"?t=>requestAnimationFrame(t):typeof Promise<"u"?t=>Promise.resolve().then(t):t=>setTimeout(t,0),vt=(t,...e)=>{if(typeof t!="function")throw new Error("runInAsyncQueue expects a function as its first argument");Lt(()=>t(...e))},lt={};function Z(t){const e=t.map(n=>n.replace(/[',"]/g,"")).join(",");if(!lt[e]){const n=t[t.length-1];if(n.trim()==="")throw new Error("Function body cannot be empty");if(Ft(n))throw new Error("Input contains potentially dangerous code: "+n);lt[e]=new Function(...t)}return lt[e]}const Dt=["eval","Function","process","require"];function Ft(t){return Dt.some(e=>new RegExp(`\\b${e}\\b`,"g").test(t))}const Vt="http://www.w3.org/1999/xlink",Ut="http://www.w3.org/2000/xmlns/",qt="http://www.w3.org/XML/1998/namespace",Bt="http://www.w3.org/2000/svg",$t=t=>typeof t.content=="function"?t.content(t.loops||[]):t.content||"",zt=t=>{const e=$t(t),n=t.elm;n.textContent!==e&&(n.textContent=e)},Gt=["role","form"],At=(t,e,n=[])=>{Object.keys(e).forEach(s=>{const r=e[s](n);if(s.startsWith("data-")||s.startsWith("aria-")||Gt.includes(s)){const o=t.getAttribute(s),a=r==null?null:String(r);o!==a&&(a==null?t.removeAttribute(s):t.setAttribute(s,a))}else t[s]!==r&&(t[s]=r)})},kt=(t,e)=>{const{styles:n,loops:s=[]}=e;if(!n)return;const r=n(s),o=ut(r);Object.entries(o).forEach(([a,i])=>{t.style[a]=i})},Ct=(t,e)=>{const{classes:n,loops:s=[]}=e;if(!n)return;const r=n(s),o=wt(r);Object.entries(o).forEach(([a,i])=>{i?t.classList.add(a):t.classList.remove(a)})},ut=t=>{let e={};return typeof t=="object"&&t!==null&&!Array.isArray(t)?Object.entries(t).forEach(([n,s])=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=ut(s);Object.entries(r).forEach(([o,a])=>{e[`${n}-${o}`]=a})}else typeof s=="string"||typeof s=="number"?e[n]=`${s}`:e[n]=String(s)}):typeof t=="string"?t.split(";").forEach(n=>{const[s,r]=n.split(":").map(o=>o.trim());s&&r&&(e[s]=r)}):Array.isArray(t)&&t.forEach(n=>{const s=ut(n);Object.entries(s).forEach(([r,o])=>{e[r]=o})}),e},wt=t=>{let e={};return typeof t=="object"&&!Array.isArray(t)?Object.entries(t).forEach(([n,s])=>{e[n]=!!s}):typeof t=="string"?t.split(" ").forEach(n=>{n!==""&&(e[n]=!0)}):Array.isArray(t)&&t.forEach(n=>{const s=wt(n);Object.entries(s).forEach(([r,o])=>{e[r]=o})}),e},Rt=(t,e,n)=>{const s=r=>n.on[e](r,n.loops||[]);t.addEventListener(e,s,!1),n.handlers=n.handlers||{},n.handlers[e]=s},Kt=(t,e)=>{const n=e.elm;Object.keys(e.on).forEach(s=>{t.handlers&&t.handlers[s]&&n.removeEventListener(s,t.handlers[s],!1),Rt(n,s,e)}),At(n,e.props,e.loops),Ct(n,e),kt(n,e),typeof e.onUpdated=="function"&&requestAnimationFrame(()=>{e.onUpdated(n,e.loops||[])}),St(n,t.children,e.children)},Qt=(t,e)=>{switch(e.elm=t.elm,e.tagName){case"comment":break;case"text":zt(e);break;default:Kt(t,e);break}},ht=(t,e,n)=>{n&&n.parentNode===t?t.insertBefore(e,n):t.appendChild(e)},Jt=(t,e,n)=>{const s=$t(e),r=document.createTextNode(s);e.elm=r,ht(t,r,n)},Nt=(t,e,n)=>{const s=e.content,r=document.createComment(s);e.elm=r,ht(t,r,n)},Xt=(t,e,n,s)=>{e.tagName==="svg"&&(s=Bt);const r=s?document.createElementNS(s,e.tagName):document.createElement(e.tagName);Object.keys(e.attrs).forEach(o=>{const a=e.attrs[o]||"";o.charAt(0)!=="x"?r.setAttribute(o,a):o.startsWith("xml:")?r.setAttributeNS(qt,o,a):o.startsWith("xlink:")?r.setAttributeNS(Vt,o,a):o.startsWith("xmlns:")?r.setAttributeNS(Ut,o,a):r.setAttribute(o,a)}),Object.keys(e.on).forEach(o=>{Rt(r,o,e)}),At(r,e.props,e.loops),Ct(r,e),kt(r,e),e.elm=r,ht(t,r,n),e.tagName==="foreignObject"&&(s=void 0),e.children.forEach(o=>{Y(r,o,void 0,s)}),typeof e.onMounted=="function"&&requestAnimationFrame(()=>{e.onMounted(r,e.loops||[])})},Y=(t,e,n,s)=>{switch(e.tagName){case"comment":Nt(t,e,n);break;case"text":Jt(t,e,n);break;default:Xt(t,e,n,s);break}},Zt=t=>t&&(t.tagName==="ElseIf"||t.tagName==="comment"),Yt=t=>t&&t.tagName==="Else",q=(t,e,n=[],s="0",r)=>{var i,l,p;let o=0,a=0;for(let u=0;u<e.length;u++){const c=e[u];if(c.tagName==="If"){let h=!1;o++;let m=1;for(((i=c.fn)==null?void 0:i.call(c,n))&&(q(t,c.children,n,`${s}-if-${o}-${m}`,m),h=!0),m++;u+1<e.length&&Zt(e[u+1]);)((p=(l=e[u+1]).fn)==null?void 0:p.call(l,n))&&!h&&(q(t,e[u+1].children,n,`${s}-if-${o}-${m}`,m),h=!0),u++,m++;u+1<e.length&&Yt(e[u+1])&&(h||(q(t,e[u+1].children,n,`${s}-if-${o}-${m}`,m),h=!0),u++)}else if(c.tagName==="For"){a++;const{item:h="item",index:m="index"}=c.attrs;(c.fn(n)||[]).forEach((R,O)=>{const ot={item:h,value:R,index:m,valueIndex:O};q(t,c.children,[...n,ot],`${s}-for-${a}-${O}`,1)})}else{const h={...c,loops:n,children:[],rootId:s,ifId:r,key:c.key||`${s}-${u}`};q(h.children,c.children,n,`${s}-${u}`),t.push(h)}}},St=(t,e,n)=>{var a,i,l,p,u;const s=new Map;e.forEach((c,h)=>s.set(c.key,{node:c,index:h}));let r=0,o=0;for(;r<n.length;){const c=n[r],h=s.get(c.key);if(h){const m=h.node;if(m.tagName!==c.tagName){(a=m.elm)==null||a.remove();const A=(i=e[o+1])==null?void 0:i.elm;Y(t,c,A),s.delete(c.key),o++}else{if(c.ifId&&m.ifId!==c.ifId){(l=m.elm)==null||l.remove();const A=(p=e[o+1])==null?void 0:p.elm;Y(t,c,A)}else Qt(m,c);s.delete(c.key),o++}}else{const m=(u=e[o])==null?void 0:u.elm;Y(t,c,m)}r++}s.forEach(({node:c})=>{var h;return(h=c.elm)==null?void 0:h.remove()})},ft=(t,e,n=[])=>{if(!e||e.length===0)return[];const s=[];return q(s,e||[],[],"0"),St(t,n,s),s},x=t=>{if(t===null||typeof t!="object")return!1;const e=Object.prototype.toString.call(t);return!["[object Function]","[object Date]","[object RegExp]","[object Map]","[object Set]","[object WeakMap]","[object WeakSet]"].includes(e)};function Mt(t=window.location){let e;typeof t=="string"?e=new URL(t).hash:e=t.hash;const n=e.split("?"),s=n[0].substring(2),r=n[1],o={};return r&&r.split("&").forEach(a=>{const[i,l]=a.split("=");i&&l&&(o[decodeURIComponent(i)]=decodeURIComponent(l))}),{path:s.split("/"),query:o}}function pt(t,e,n={}){const s=new WeakMap,r=new WeakSet,o=new WeakMap,{throttle:a=0,deepCompare:i=!1,onBatch:l=null,immediate:p=!1}=n,u=Array.isArray(n.filter)?n.filter:n.filter?[n.filter]:[];let c=[],h=null,m=!0;const A=(f,g,$=new WeakMap)=>{if(f===g)return!0;if(f==null||g==null||typeof f!="object"||typeof g!="object")return f===g;if($.has(f))return $.get(f)===g;if($.set(f,g),Array.isArray(f)&&Array.isArray(g)){if(f.length!==g.length)return!1;for(let y=0;y<f.length;y++)if(!A(f[y],g[y],$))return!1;return!0}if(Array.isArray(f)!==Array.isArray(g))return!1;const k=Object.keys(f),E=Object.keys(g);if(k.length!==E.length)return!1;for(const y of k)if(!Object.prototype.hasOwnProperty.call(g,y)||!A(f[y],g[y],$))return!1;return!0},R=f=>{if(u.length===0)return!0;const g=f.map(String).join(".");return u.some($=>{if(!$)return!0;try{return new RegExp("^"+$.replace(/\./g,"\\.").replace(/\[\*\]/g,"(\\.\\d+)?").replace(/\*\*/g,"(.+)").replace(/\*/g,"[^.]+")+"$").test(g)}catch{return!0}})},O=(f,g,$)=>{m&&R(f)&&(a>0?(c.push({path:f,newValue:g,oldValue:$}),h||(h=setTimeout(()=>{if(!m){h=null;return}const k=c;c=[],h=null,l&&l(k);for(const E of k)e(E.path,E.newValue,E.oldValue)},a))):(e(f,g,$),l&&l([{path:f,newValue:g,oldValue:$}])))},ot=(f,g)=>{if(!x(f)||!(Array.isArray(f)||Object.prototype.toString.call(f)==="[object Object]"))return f;const $={};if(["push","pop","shift","unshift","splice","sort","reverse"].forEach(E=>{const y=Array.prototype[E];$[E]=function(...b){if(!m)return Reflect.apply(y,f,b);const S=[...f],L=y.apply(f,b);return A(f,S)||O(g,f,S),L}}),s.has(f)){const E=s.get(f);return o.set(E,g),E}r.add(f);const k=new Proxy(f,{get(E,y,b){if(Array.isArray(E)&&$.hasOwnProperty(y))return Reflect.get($,y,b);const S=Reflect.get(E,y,b);if(x(S)){const at=[...o.get(k)||[],y],gt=ot(S,at);return o.set(gt,at),gt}return S},set(E,y,b,S){const L=Reflect.get(E,y,S),at=x(b)&&!(b instanceof Date||b instanceof RegExp||b instanceof Map||b instanceof Set);if(i&&at?A(L,b):L===b)return!0;const ae=Reflect.set(E,y,b,S),ie=o.get(k)||g;return O([...ie,y],b,L),ae},deleteProperty(E,y){if(Reflect.has(E,y)){const b=E[y],S=Reflect.deleteProperty(E,y),L=o.get(k)||[];return S&&r.has(E)&&O([...L,y],void 0,b),S}return!1}});return s.set(f,k),o.set(k,g),k},oe=ot(t,[]);if(p){const f=(g,$,k=new WeakSet)=>{if(!(!x(g)||!m||k.has(g))){k.add(g);for(const E of Object.keys(g)){const y=[...$,E],b=g[E];R(y)&&e(y,b,void 0),x(b)&&f(b,y,k)}}};f(t,[])}return{proxy:oe,unobserve:()=>{m&&(m=!1,c=[],h&&(clearTimeout(h),h=null))},resume:()=>{m=!0}}}class te extends HTMLElement{constructor(n={}){var a;super();j(this,_);j(this,z);j(this,Q,[]);j(this,J,[]);j(this,V,!1);j(this,N,!1);j(this,U);j(this,I);const s=this._manifest||{};w(this,U,(a=s.shadowDOM)!=null&&a.use?this.attachShadow({mode:s.shadowDOM.mode||"open"}):this);const{proxy:r,unobserve:o}=pt(n,()=>D(this,_,G).call(this));w(this,z,r),w(this,I,o),s.template&&typeof s.template=="string"&&w(this,Q,bt(this,s.template)),Promise.resolve().then(()=>this.created())}static get observedAttributes(){const n=this._manifest||this.prototype._manifest;return n!=null&&n.props?n.props.map(s=>typeof s=="string"?s:s.name):[]}get $data(){return M(this,z)}set $data(n){x(n)||(n={}),M(this,I)&&M(this,I).call(this);const{proxy:s,unobserve:r}=pt(n,()=>D(this,_,G).call(this));w(this,z,s),w(this,I,r),D(this,_,G).call(this)}refresh(){D(this,_,G).call(this)}connectedCallback(){const n=this._manifest||{};if((n.className||n.tagName||"").split(" ").forEach(r=>r&&this.classList.add(r)),n.styles&&!M(this,U).querySelector("style[data-manifest-style]")){const r=document.createElement("style");r.setAttribute("data-manifest-style","true"),r.textContent=n.styles,M(this,U).appendChild(r)}if(n.props&&x(this.$data))for(const r of n.props){const o=typeof r=="string"?r:r.name,a=typeof r=="object"&&"type"in r?r.type:void 0,i=o.replace(/-([a-z])/g,(p,u)=>u.toUpperCase()),l=this.$data[i];if(this.hasAttribute(o)){const p=this.getAttribute(o);this.$data[i]=D(this,_,Et).call(this,p,l,a)}}D(this,_,G).call(this)}disconnectedCallback(){var n;this.isConnected&&(this.unmounted(),(n=M(this,I))==null||n.call(this),w(this,I,void 0))}attributeChangedCallback(n,s,r){if(s===r||!x(this.$data))return;const o=n.replace(/-([a-z])/g,(i,l)=>l.toUpperCase()),a=this.$data[o];this.$data[o]=D(this,_,Et).call(this,r,a)}onInit(){}created(){}mounted(){}beforeUpdate(){}updated(){}unmounted(){}}z=new WeakMap,Q=new WeakMap,J=new WeakMap,V=new WeakMap,N=new WeakMap,U=new WeakMap,I=new WeakMap,_=new WeakSet,G=function(){M(this,V)||(w(this,V,!0),vt(()=>{var n;if(!this.isConnected){w(this,V,!1);return}this.beforeUpdate(),w(this,J,ft(M(this,U),M(this,Q),M(this,J))),w(this,V,!1),M(this,N)?this.updated():(w(this,N,!0),this.mounted(),(n=this.onInit)==null||n.call(this))}))},Et=function(n,s,r){if(n===null)return s;switch(r||typeof s){case"number":const a=Number(n);return isNaN(a)?s:a;case"boolean":return n==="true";case"object":try{return JSON.parse(n)}catch{return s}default:return n}};const Pt=t=>e=>{if(customElements.get(t.tagName)){console.warn(`标签名称 "${t.tagName}" 已经被注册`);return}return e.prototype._manifest=ee(t),customElements.define(t.tagName,e),e},ee=t=>(t=Object.assign({hasConfig:!1},t),t);var ne=Object.getOwnPropertyDescriptor,_t=t=>{throw TypeError(t)},se=(t,e,n,s)=>{for(var r=s>1?void 0:s?ne(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=a(r)||r);return r},dt=(t,e,n)=>e.has(t)||_t("Cannot "+n),W=(t,e,n)=>(dt(t,e,"read from private field"),n?n.call(t):e.get(t)),T=(t,e,n)=>e.has(t)?_t("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),H=(t,e,n,s)=>(dt(t,e,"write to private field"),e.set(t,n),n),re=(t,e,n)=>(dt(t,e,"access private method"),n),tt,et,nt,K,B,st,rt,mt,xt;function Wt(t){return t instanceof HTMLElement&&t.isRouterView===!0}d.RouterViewElement=class extends HTMLElement{constructor(){super(...arguments),T(this,mt),T(this,tt,[]),T(this,et,[]),T(this,nt,null),T(this,K),T(this,B,[]),T(this,st,{}),T(this,rt,this.onHashChange.bind(this))}get isRouterView(){return!0}get $routes(){return W(this,B)}set $routes(e){H(this,B,e),this.onHashChange()}get $remainingPath(){return W(this,et)}get $matchedRoute(){return W(this,nt)}set $pipe(e){H(this,st,e||{}),this.onHashChange()}connectedCallback(){window.addEventListener("hashchange",W(this,rt)),this.onHashChange()}disconnectedCallback(){window.removeEventListener("hashchange",W(this,rt))}onHashChange(){var n;if(!this.isConnected)return;const e=this.findAncestorRouterView();if(e)H(this,K,e.$remainingPath),H(this,B,((n=e.$matchedRoute)==null?void 0:n.children)||[]);else{const{path:s}=Mt(window.location);H(this,K,s)}re(this,mt,xt).call(this)}prepareComponentData(e){const n={},s={};for(const[r,o]of Object.entries(e))n[r]=()=>o;for(const[r,o]of Object.entries(W(this,st))){const a=r.toLowerCase();let i=null;a.startsWith("on-")?i=a.slice(3):a.startsWith("on")&&ct.includes(a.slice(2))&&(i=a.slice(2)),i?s[i]=o:n[r]=()=>o}return{props:n,on:s}}matchRoute(e,n){for(const s of e){const r=s.path.split("/").filter(i=>i),o={};if(r.length>n.length&&!r.includes("*"))continue;let a=!0;for(let i=0;i<r.length;i++){const l=r[i],p=n[i];if(l.startsWith(":"))o[l.substring(1)]=p;else{if(l==="*")return{matchedRoute:s,params:o,remainingPath:[]};if(l!==p){a=!1;break}}}if(a)return{matchedRoute:s,params:o,remainingPath:n.slice(r.length)}}return{matchedRoute:null,params:{},remainingPath:n}}propagateToChildRouterViews(e=this){for(const n of e.childNodes)Wt(n)?n.onHashChange():this.propagateToChildRouterViews(n)}findAncestorRouterView(){let e=this.parentElement;for(;e;){if(Wt(e))return e;e=e.parentElement}return null}},tt=new WeakMap,et=new WeakMap,nt=new WeakMap,K=new WeakMap,B=new WeakMap,st=new WeakMap,rt=new WeakMap,mt=new WeakSet,xt=function(){const t=W(this,K)||[],{matchedRoute:e,params:n,remainingPath:s}=this.matchRoute(W(this,B),t);H(this,et,s),H(this,nt,e);const r=(e==null?void 0:e.tagName)||"comment",{props:o,on:a}=this.prepareComponentData(n);H(this,tt,ft(this,[{tagName:r,rootId:"0",attrs:{},props:o,on:a,children:[]}],W(this,tt))),this.propagateToChildRouterViews()},d.RouterViewElement=se([Pt({tagName:"router-view"})],d.RouterViewElement),d.BaseElement=te,d.CustomElement=Pt,d.createFunction=Z,d.isObject=x,d.listeners=ct,d.observe=pt,d.parseHashUrl=Mt,d.parseHtml=bt,d.patch=ft,d.runInAsyncQueue=vt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|