lithent 1.0.6 → 1.0.7
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 +7 -7
- package/dist/lithent.mjs +139 -139
- package/dist/lithent.mjs.map +1 -1
- package/dist/lithent.umd.js +1 -1
- package/dist/lithent.umd.js.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/redraw.d.ts +3 -0
- package/dist/utils/universalRef.d.ts +2 -7
- package/examples/dist/assets/index-22f97357.js +2 -0
- package/examples/dist/assets/index-22f97357.js.map +1 -0
- package/examples/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/diff.ts +39 -4
- package/src/render.ts +5 -1
- package/src/tests/test13-2.tsx +61 -0
- package/src/tests/test16.tsx +2 -6
- package/src/types/index.ts +5 -0
- package/src/utils/index.ts +1 -36
- package/src/utils/redraw.ts +76 -0
- package/src/utils/universalRef.ts +1 -83
- package/src/wDom.ts +2 -3
- package/examples/dist/assets/index-6f85ca2a.js +0 -2
- package/examples/dist/assets/index-6f85ca2a.js.map +0 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ used lightly in a variety of situations.
|
|
|
9
9
|
- https://superlucky84.github.io/lithent
|
|
10
10
|
- (This guide page is written in lithent.)
|
|
11
11
|
|
|
12
|
-
`(9.86 kB
|
|
12
|
+
`(9.86 kB │ gzip: 3.91 kB)`
|
|
13
13
|
|
|
14
14
|
## 🚩 Table of Contents
|
|
15
15
|
|
|
@@ -60,10 +60,10 @@ pnpm add lithent
|
|
|
60
60
|
|
|
61
61
|
#### Or Use CDN
|
|
62
62
|
|
|
63
|
-
* UMD : https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
64
|
-
* UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
65
|
-
* ESM : https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
66
|
-
* ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
63
|
+
* UMD : https://cdn.jsdelivr.net/npm/lithent@1.0.7/dist/lithent.umd.js
|
|
64
|
+
* UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.7/helper/dist/lithentHelper.umd.js
|
|
65
|
+
* ESM : https://cdn.jsdelivr.net/npm/lithent@1.0.7/dist/lithent.mjs
|
|
66
|
+
* ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.7/helper/dist/lithentHelper.mjs
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
It's easier to use lithent with JSX or HTM.
|
|
@@ -121,8 +121,8 @@ const destroy = render(html`<${Component} />`, document.getElementById('root'),
|
|
|
121
121
|
#### With UMD
|
|
122
122
|
|
|
123
123
|
```html
|
|
124
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
125
|
-
<!--script src="https://cdn.jsdelivr.net/npm/lithent@1.0.
|
|
124
|
+
<script src="https://cdn.jsdelivr.net/npm/lithent@1.0.7/dist/lithent.umd.js"></script>
|
|
125
|
+
<!--script src="https://cdn.jsdelivr.net/npm/lithent@1.0.7/helper/dist/lithentHelper.umd.js"></script-->
|
|
126
126
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/htm/3.1.1/htm.js"></script>
|
|
127
127
|
|
|
128
128
|
<div id="root"></div>
|
package/dist/lithent.mjs
CHANGED
|
@@ -1,37 +1,23 @@
|
|
|
1
|
-
const C = (e) => typeof e == "object" && !("resolve" in e),
|
|
1
|
+
const C = (e) => typeof e == "object" && !("resolve" in e), x = (e, t) => C(e) && e.type === t, fe = (e, t) => "ctor" in e ? e.ctor === (t == null ? void 0 : t.ctor) : e === (t == null ? void 0 : t.ctor), de = (e, t) => {
|
|
2
2
|
var s, c;
|
|
3
3
|
return C(e) && (t == null ? void 0 : t.type) === "fragment" && ((s = t == null ? void 0 : t.children) == null ? void 0 : s.length) === ((c = e == null ? void 0 : e.children) == null ? void 0 : c.length);
|
|
4
4
|
}, pe = (e, t) => {
|
|
5
5
|
var s, c;
|
|
6
6
|
return C(e) && (t == null ? void 0 : t.type) === "element" && (t == null ? void 0 : t.tag) === e.tag && ((s = t == null ? void 0 : t.children) == null ? void 0 : s.length) === ((c = e == null ? void 0 : e.children) == null ? void 0 : c.length);
|
|
7
|
-
}, U = (e, t) => C(e) && (t == null ? void 0 : t.type) === e.type && (e.type !== "loop" || e.type === "loop" &&
|
|
7
|
+
}, U = (e, t) => C(e) && (t == null ? void 0 : t.type) === e.type && (e.type !== "loop" || e.type === "loop" && a(i((e.children || [])[0])) && a(i((t.children || [])[0]))), i = (e) => {
|
|
8
8
|
var t, s;
|
|
9
9
|
return ((t = e == null ? void 0 : e.compProps) == null ? void 0 : t.key) ?? ((s = e == null ? void 0 : e.props) == null ? void 0 : s.key);
|
|
10
|
-
},
|
|
10
|
+
}, v = (e) => e && ["fragment", "loop"].includes(e), T = (e) => typeof e == "function" && !$(e) || typeof e == "object" && "resolve" in e, $ = (e) => typeof e == "function" && e === ce, H = (e) => C(e) && !e.type, a = (e) => e != null, z = (e, t) => e === "style" && typeof t == "object", he = (e, t) => e === "ref" && typeof t == "object", ie = (e) => e.nodeType === 1 && e.tagName === "OPTION", ye = (e) => e.nodeType === 1 && e.tagName === "TEXTAREA", ve = (e) => e.nodeType === 1 && ["radio", "checkbox"].includes(e.type), ae = (e) => {
|
|
11
11
|
let t = "et";
|
|
12
|
-
return T(e) ? t = "c" :
|
|
13
|
-
},
|
|
12
|
+
return T(e) ? t = "c" : x(e, "fragment") ? t = "f" : x(e, "element") ? t = "e" : x(e, "loop") ? t = "l" : x(e, "text") ? t = "t" : H(e) && (t = "et"), t;
|
|
13
|
+
}, ke = {
|
|
14
14
|
c: fe,
|
|
15
15
|
l: U,
|
|
16
16
|
t: U,
|
|
17
17
|
e: pe,
|
|
18
18
|
f: de,
|
|
19
19
|
et: U
|
|
20
|
-
}, p = (e) => e.getParent && e.getParent(),
|
|
21
|
-
const { compProps: s, compChild: c } = e, { props: n, children: r } = t;
|
|
22
|
-
return s && Re(s, n), c && Ee(c, r), e.reRender && e.reRender();
|
|
23
|
-
}, J = (e) => e.replace(/^on(.*)/, (t, s) => s.toLowerCase()), G = (e) => e === "className" ? "class" : e, k = Object.entries, Y = Object.keys, S = Object.assign, Re = (e, t) => {
|
|
24
|
-
e && t !== e && (Y(e).forEach((s) => delete e[s]), k(t || {}).forEach(([s, c]) => e[s] = c));
|
|
25
|
-
}, Ee = (e, t) => {
|
|
26
|
-
e && t !== e && (e.splice(0, e.length), t && t.forEach((s) => e.push(s)));
|
|
27
|
-
};
|
|
28
|
-
let x = [], A = !1;
|
|
29
|
-
const y = { value: "" }, a = { value: {} }, O = { value: !1 }, u = /* @__PURE__ */ new WeakMap(), xe = (e) => () => {
|
|
30
|
-
var c;
|
|
31
|
-
const t = (c = u.get(e)) == null ? void 0 : c.up;
|
|
32
|
-
let s = !1;
|
|
33
|
-
return t && (t(), s = !0), s;
|
|
34
|
-
}, Pe = (e) => {
|
|
20
|
+
}, p = (e) => e.getParent && e.getParent(), J = (e) => e.replace(/^on(.*)/, (t, s) => s.toLowerCase()), G = (e) => e === "className" ? "class" : e, k = Object.entries, Y = Object.keys, S = Object.assign, y = { value: "" }, R = { value: {} }, A = { value: !1 }, u = /* @__PURE__ */ new WeakMap(), Ce = (e) => {
|
|
35
21
|
u.set(e, {
|
|
36
22
|
vd: { value: null },
|
|
37
23
|
up: () => {
|
|
@@ -43,183 +29,155 @@ const y = { value: "" }, a = { value: {} }, O = { value: !1 }, u = /* @__PURE__
|
|
|
43
29
|
mts: [],
|
|
44
30
|
umts: []
|
|
45
31
|
});
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
exec: t
|
|
51
|
-
}), A || (A = !0, queueMicrotask(Ne));
|
|
52
|
-
};
|
|
53
|
-
}, Te = (e) => a.value = e, Se = (e) => {
|
|
54
|
-
a.value = e, Pe(e);
|
|
55
|
-
}, K = (e, t) => {
|
|
56
|
-
(e.children || []).forEach((s) => {
|
|
57
|
-
const c = s.compKey;
|
|
58
|
-
c && t.push(c), K(s, t);
|
|
59
|
-
});
|
|
60
|
-
}, Ne = () => {
|
|
61
|
-
let e = [];
|
|
62
|
-
x.forEach((c) => {
|
|
63
|
-
var r, o;
|
|
64
|
-
const n = (o = (r = u.get(c.compKey)) == null ? void 0 : r.vd) == null ? void 0 : o.value;
|
|
65
|
-
n && K(n, e);
|
|
66
|
-
});
|
|
67
|
-
const t = [], s = x.reduce((c, n) => {
|
|
68
|
-
const { compKey: r } = n;
|
|
69
|
-
return e.includes(r) || t.includes(r) || (t.push(r), c.push(n)), c;
|
|
70
|
-
}, []);
|
|
71
|
-
for (; s.length; ) {
|
|
72
|
-
const c = s.shift();
|
|
73
|
-
c && c.exec();
|
|
74
|
-
}
|
|
75
|
-
x = [], A = !1;
|
|
76
|
-
}, be = (e) => {
|
|
77
|
-
u.get(R()).umts.push(e);
|
|
32
|
+
}, E = () => R.value, Z = (e, t) => u.get(e)[t], Re = (e) => R.value = e, Ee = (e) => {
|
|
33
|
+
R.value = e, Ce(e);
|
|
34
|
+
}, xe = (e) => {
|
|
35
|
+
u.get(E()).umts.push(e);
|
|
78
36
|
}, Q = (e) => {
|
|
79
37
|
const { compKey: t } = e;
|
|
80
|
-
t &&
|
|
81
|
-
},
|
|
38
|
+
t && Pe(t), V(e);
|
|
39
|
+
}, V = (e) => {
|
|
82
40
|
(e.children || []).forEach((t) => {
|
|
83
|
-
t.compKey ? Q(t) :
|
|
41
|
+
t.compKey ? Q(t) : V(t);
|
|
84
42
|
});
|
|
85
|
-
},
|
|
43
|
+
}, Pe = (e) => {
|
|
86
44
|
const t = u.get(e);
|
|
87
45
|
t && (t.umts.forEach((s) => s()), t.umts = [], u.delete(e));
|
|
88
46
|
};
|
|
89
|
-
let
|
|
47
|
+
let O = [];
|
|
90
48
|
const B = () => {
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
e.compKey &&
|
|
94
|
-
}, ct = (e) => u.get(
|
|
49
|
+
O.forEach((e) => Se(e)), O = [];
|
|
50
|
+
}, Te = (e) => {
|
|
51
|
+
e.compKey && O.push(e);
|
|
52
|
+
}, ct = (e) => u.get(E()).mts.push(e), Se = (e) => {
|
|
95
53
|
const { compKey: t } = e;
|
|
96
54
|
if (t) {
|
|
97
55
|
const s = u.get(t), c = s == null ? void 0 : s.mts, n = s == null ? void 0 : s.upS;
|
|
98
|
-
|
|
56
|
+
R.value = t, n && (n.value = 0), c && (s.mts = [], c.forEach((r) => {
|
|
99
57
|
const o = r();
|
|
100
|
-
o &&
|
|
58
|
+
o && xe(o);
|
|
101
59
|
}));
|
|
102
60
|
}
|
|
103
61
|
}, X = (e, t = () => []) => {
|
|
104
|
-
const s = u.get(
|
|
105
|
-
if (r &&
|
|
62
|
+
const s = u.get(E()), { upD: c, upS: n } = s, r = c[n.value];
|
|
63
|
+
if (r && be(r, t())) {
|
|
106
64
|
const o = e();
|
|
107
65
|
o && s.upCB.push(o);
|
|
108
66
|
}
|
|
109
67
|
c[n.value] = t(), n.value += 1;
|
|
110
|
-
},
|
|
68
|
+
}, Ne = (e) => {
|
|
111
69
|
const { compKey: t } = e;
|
|
112
70
|
if (t) {
|
|
113
71
|
const s = u.get(t), c = s == null ? void 0 : s.upCB, n = s == null ? void 0 : s.upS;
|
|
114
|
-
|
|
72
|
+
R.value = t, n && (n.value = 0), e.ctor && c && (s.upCB = [], c.forEach((r) => r()));
|
|
115
73
|
}
|
|
116
|
-
},
|
|
74
|
+
}, be = (e, t) => !e.length && !e.length ? !0 : e.some((s, c) => s !== t[c]), nt = (e, t, s) => {
|
|
117
75
|
t ?? (t = document.body), e.isRoot = !0, e.wrapElement = t;
|
|
118
76
|
const c = N(e);
|
|
119
77
|
return s ? (e.afterElement = s, t.insertBefore(c, s)) : t.appendChild(c), B(), () => {
|
|
120
78
|
var r;
|
|
121
79
|
const n = (r = u.get(e.compProps || {})) == null ? void 0 : r.vd.value;
|
|
122
|
-
n && (Q(n), j(n),
|
|
80
|
+
n && (Q(n), j(n), Fe(n));
|
|
123
81
|
};
|
|
124
|
-
},
|
|
82
|
+
}, K = (e) => {
|
|
125
83
|
const { needRerender: t } = e;
|
|
126
84
|
t && t !== "N" && {
|
|
127
85
|
A: q,
|
|
128
86
|
D: I,
|
|
129
|
-
R:
|
|
130
|
-
U:
|
|
131
|
-
SR:
|
|
132
|
-
SU:
|
|
87
|
+
R: Ae,
|
|
88
|
+
U: Oe,
|
|
89
|
+
SR: w,
|
|
90
|
+
SU: Ue
|
|
133
91
|
}[t](e);
|
|
134
92
|
}, j = (e) => {
|
|
135
|
-
e.props && e.el &&
|
|
93
|
+
e.props && e.el && D(e.props, e.el), (e.children || []).forEach((t) => {
|
|
136
94
|
j(t);
|
|
137
95
|
});
|
|
138
|
-
},
|
|
139
|
-
|
|
96
|
+
}, Fe = (e) => {
|
|
97
|
+
g(e, e.wrapElement);
|
|
140
98
|
}, I = (e) => {
|
|
141
|
-
e.oldProps && e.el &&
|
|
99
|
+
e.oldProps && e.el && D(e.oldProps, e.el), g(
|
|
142
100
|
e,
|
|
143
101
|
b(p(e))
|
|
144
102
|
);
|
|
145
|
-
},
|
|
103
|
+
}, g = (e, t) => {
|
|
146
104
|
var s, c;
|
|
147
|
-
t && e.el && (((s = e.el) == null ? void 0 : s.nodeType) === 1 ? t.removeChild(e.el) : ((c = e.el) == null ? void 0 : c.nodeType) === 11 &&
|
|
148
|
-
},
|
|
105
|
+
t && e.el && (((s = e.el) == null ? void 0 : s.nodeType) === 1 ? t.removeChild(e.el) : ((c = e.el) == null ? void 0 : c.nodeType) === 11 && m(e, t), delete e.el);
|
|
106
|
+
}, m = (e, t) => {
|
|
149
107
|
((e == null ? void 0 : e.oldChildren) || (e == null ? void 0 : e.children) || []).forEach((s) => {
|
|
150
108
|
var c, n;
|
|
151
|
-
((c = s.el) == null ? void 0 : c.nodeType) === 1 ? t.removeChild(s == null ? void 0 : s.el) : ((n = s.el) == null ? void 0 : n.nodeType) === 11 &&
|
|
109
|
+
((c = s.el) == null ? void 0 : c.nodeType) === 1 ? t.removeChild(s == null ? void 0 : s.el) : ((n = s.el) == null ? void 0 : n.nodeType) === 11 && m(s, t);
|
|
152
110
|
});
|
|
153
|
-
},
|
|
111
|
+
}, w = (e) => {
|
|
154
112
|
I(e), q(e);
|
|
155
|
-
},
|
|
113
|
+
}, Ue = (e) => {
|
|
156
114
|
I(e), q(e, e.el);
|
|
157
115
|
}, q = (e, t) => {
|
|
158
116
|
t || (t = N(e));
|
|
159
117
|
const s = p(e);
|
|
160
118
|
if (s.type) {
|
|
161
|
-
const c = b(s), r = s.type === "loop" ?
|
|
119
|
+
const c = b(s), r = s.type === "loop" ? L(s, p(s)) : L(e, s);
|
|
162
120
|
t && c && (r ? c.insertBefore(t, r) : c.appendChild(t), B());
|
|
163
121
|
}
|
|
164
|
-
},
|
|
165
|
-
const s = t.children || [], n = s.indexOf(e) + 1, r = s.slice(n), o =
|
|
122
|
+
}, L = (e, t) => {
|
|
123
|
+
const s = t.children || [], n = s.indexOf(e) + 1, r = s.slice(n), o = W(r), l = t.type || "";
|
|
166
124
|
if (o)
|
|
167
125
|
return o;
|
|
168
|
-
if (!t.isRoot &&
|
|
169
|
-
return
|
|
170
|
-
if (t.isRoot && t.afterElement)
|
|
126
|
+
if (!t.isRoot && v(l))
|
|
127
|
+
return L(t, p(t));
|
|
128
|
+
if (t.isRoot && v(l) && t.afterElement)
|
|
171
129
|
return t.afterElement;
|
|
172
|
-
},
|
|
130
|
+
}, W = (e) => e.reduce(
|
|
173
131
|
(t, s) => {
|
|
174
|
-
const c = s.type, n = s.el, r = c &&
|
|
175
|
-
return t || (r ?
|
|
132
|
+
const c = s.type, n = s.el, r = c && v(c);
|
|
133
|
+
return t || (r ? W(s.children || []) : n && n.nodeType !== 11 ? n : t);
|
|
176
134
|
},
|
|
177
135
|
void 0
|
|
178
|
-
),
|
|
136
|
+
), Ae = (e) => {
|
|
179
137
|
const t = p(e), s = e.el;
|
|
180
138
|
if (t.type && s)
|
|
181
139
|
if (s.nodeType === 11)
|
|
182
|
-
|
|
140
|
+
w(e);
|
|
183
141
|
else {
|
|
184
142
|
const c = b(t), n = N(e);
|
|
185
143
|
c && c.replaceChild(n, s), B();
|
|
186
144
|
}
|
|
187
|
-
},
|
|
145
|
+
}, D = (e, t) => {
|
|
188
146
|
k(e || {}).forEach(([s, c]) => {
|
|
189
147
|
s.match(/^on/) && t.removeEventListener(
|
|
190
148
|
J(s),
|
|
191
149
|
c
|
|
192
150
|
);
|
|
193
151
|
});
|
|
194
|
-
},
|
|
152
|
+
}, Oe = (e) => {
|
|
195
153
|
var s;
|
|
196
154
|
const t = e.el;
|
|
197
155
|
if (e.type === "text") {
|
|
198
|
-
|
|
156
|
+
Le(e);
|
|
199
157
|
return;
|
|
200
158
|
}
|
|
201
159
|
if (t) {
|
|
202
160
|
const { oldProps: c, props: n } = e;
|
|
203
|
-
|
|
161
|
+
ee(n, t, c), delete e.oldProps, e.tag === "input" && (t.value = String(((s = e == null ? void 0 : e.props) == null ? void 0 : s.value) || ""));
|
|
204
162
|
}
|
|
205
|
-
(e.children || []).forEach((c) =>
|
|
206
|
-
},
|
|
163
|
+
(e.children || []).forEach((c) => K(c)), Ne(e);
|
|
164
|
+
}, Le = (e) => {
|
|
207
165
|
const t = e.el;
|
|
208
166
|
t && (t.nodeValue = String(e.text));
|
|
209
|
-
},
|
|
167
|
+
}, ee = (e, t, s) => {
|
|
210
168
|
const c = { ...s };
|
|
211
169
|
k(e || {}).forEach(([n, r]) => {
|
|
212
170
|
let o = !0;
|
|
213
|
-
n === "key" || (n === "innerHTML" && typeof r == "string" ? t.innerHTML = r : z(n, r) ?
|
|
171
|
+
n === "key" || (n === "innerHTML" && typeof r == "string" ? t.innerHTML = r : z(n, r) ? je(
|
|
214
172
|
r,
|
|
215
173
|
z(n, c.style) ? c.style : {},
|
|
216
174
|
t
|
|
217
|
-
) : he(n, r) ? r.value = t : n.match(/^on/) ?
|
|
175
|
+
) : he(n, r) ? r.value = t : n.match(/^on/) ? Be(
|
|
218
176
|
t,
|
|
219
177
|
n,
|
|
220
178
|
r,
|
|
221
179
|
c[n]
|
|
222
|
-
) : ve(t) && n === "checked" ? t.checked = !!r : ye(t) && n === "value" ? t.value = r : ie(t) && n === "selected" ? t.selected = !!r : n && ([o, r] =
|
|
180
|
+
) : ve(t) && n === "checked" ? t.checked = !!r : ye(t) && n === "value" ? t.value = r : ie(t) && n === "selected" ? t.selected = !!r : n && ([o, r] = Me(r), o && (y.value && n !== "xmlns" ? t.setAttributeNS(
|
|
223
181
|
null,
|
|
224
182
|
G(n),
|
|
225
183
|
r
|
|
@@ -230,23 +188,23 @@ const B = () => {
|
|
|
230
188
|
}), Y(c).forEach(
|
|
231
189
|
(n) => t.removeAttribute(n)
|
|
232
190
|
);
|
|
233
|
-
},
|
|
191
|
+
}, Me = (e) => {
|
|
234
192
|
let t = !0;
|
|
235
193
|
return typeof e == "boolean" && (e || (t = !1), e = ""), [t, String(e)];
|
|
236
194
|
}, N = (e) => {
|
|
237
195
|
let t;
|
|
238
|
-
const { type: s, tag: c, text: n, props: r, children: o = [] } = e, l =
|
|
239
|
-
return c === "svg" && (y.value = String(r == null ? void 0 : r.xmlns)), l ? t = new DocumentFragment() : s === "element" && c ? t = y.value ? document.createElementNS(y.value, c) : document.createElement(c) : s === "text" &&
|
|
240
|
-
},
|
|
196
|
+
const { type: s, tag: c, text: n, props: r, children: o = [] } = e, l = v(s);
|
|
197
|
+
return c === "svg" && (y.value = String(r == null ? void 0 : r.xmlns)), l ? t = new DocumentFragment() : s === "element" && c ? t = y.value ? document.createElementNS(y.value, c) : document.createElement(c) : s === "text" && a(n) ? t = document.createTextNode(String(n)) : t = document.createElement("e"), Qe(o, t), ee(r, t), e.el = t, Te(e), c === "svg" && (y.value = ""), t;
|
|
198
|
+
}, Qe = (e, t) => {
|
|
241
199
|
const s = e.reduce(
|
|
242
200
|
(c, n) => (n.type && c.appendChild(N(n)), c),
|
|
243
201
|
new DocumentFragment()
|
|
244
202
|
);
|
|
245
203
|
t && s.hasChildNodes() && t.appendChild(s);
|
|
246
|
-
},
|
|
204
|
+
}, Be = (e, t, s, c) => {
|
|
247
205
|
const n = J(t);
|
|
248
206
|
c !== s && (c && e.removeEventListener(n, c), s && e.addEventListener(n, s));
|
|
249
|
-
},
|
|
207
|
+
}, je = (e, t, s) => {
|
|
250
208
|
const c = { ...t }, n = s == null ? void 0 : s.style;
|
|
251
209
|
n && (k(e).forEach(([r, o]) => {
|
|
252
210
|
n[r] = o, delete c[r];
|
|
@@ -254,33 +212,40 @@ const B = () => {
|
|
|
254
212
|
([r]) => n[r] = ""
|
|
255
213
|
));
|
|
256
214
|
}, b = (e) => {
|
|
257
|
-
const t =
|
|
215
|
+
const t = v(e.type);
|
|
258
216
|
return e.isRoot && t ? e.wrapElement : t ? b(p(e)) : e.el;
|
|
259
|
-
}, F = (e, t) =>
|
|
217
|
+
}, F = (e, t) => Ie(
|
|
260
218
|
e,
|
|
261
|
-
|
|
219
|
+
ke[ae(e)](e, t),
|
|
262
220
|
t
|
|
263
|
-
),
|
|
264
|
-
const c =
|
|
221
|
+
), Ie = (e, t, s) => {
|
|
222
|
+
const c = $e(e, t, s), n = [
|
|
265
223
|
c,
|
|
266
224
|
t,
|
|
267
225
|
s
|
|
268
|
-
], r =
|
|
269
|
-
return c.children =
|
|
270
|
-
},
|
|
226
|
+
], r = _e(...n);
|
|
227
|
+
return c.children = He(...n), c.needRerender = r, qe(c, s, r), c;
|
|
228
|
+
}, qe = (e, t, s) => {
|
|
271
229
|
s !== "A" && t && (e.el = t.el), s && ["D", "R", "SR"].includes(s) && (t != null && t.compKey && (Q(t), j(t)), e.oldChildren = t == null ? void 0 : t.children), e.oldProps = t == null ? void 0 : t.props;
|
|
272
|
-
},
|
|
273
|
-
const c = s && s.type, n = H(e), o = !!e.getParent && p(e).type, l = i(e), h = o === "loop" &&
|
|
230
|
+
}, _e = (e, t, s) => {
|
|
231
|
+
const c = s && s.type, n = H(e), o = !!e.getParent && p(e).type, l = i(e), h = o === "loop" && a(l), d = e.type === "text" && t && e.text === (s == null ? void 0 : s.text);
|
|
274
232
|
let f;
|
|
275
233
|
return n ? f = "D" : d ? f = "N" : c ? t ? f = h ? "SU" : "U" : f = h ? "SR" : "R" : f = "A", f;
|
|
276
|
-
},
|
|
234
|
+
}, ze = (e, t) => {
|
|
235
|
+
e && t !== e && (Y(e).forEach((s) => delete e[s]), k(t || {}).forEach(([s, c]) => e[s] = c));
|
|
236
|
+
}, Ge = (e, t) => {
|
|
237
|
+
e && t !== e && (e.splice(0, e.length), t && t.forEach((s) => e.push(s)));
|
|
238
|
+
}, Xe = (e, t) => {
|
|
239
|
+
const { compProps: s, compChild: c } = e, { props: n, children: r } = t;
|
|
240
|
+
return s && ze(s, n), c && Ge(c, r), e.reRender && e.reRender();
|
|
241
|
+
}, $e = (e, t, s) => T(e) ? t && s ? Xe(s, e) : e.resolve() : e, He = (e, t, s) => t && s ? Ye(e, s) : Je(e), Je = (e) => (e.children || []).map(
|
|
277
242
|
(t) => S(F(t), { getParent: () => e })
|
|
278
|
-
),
|
|
243
|
+
), Ye = (e, t) => e.type === "loop" && a(i((e.children || [])[0])) ? Ze(e, t) : (e.children || []).map(
|
|
279
244
|
(s, c) => S(F(s, (t.children || [])[c]), {
|
|
280
245
|
getParent: () => e
|
|
281
246
|
})
|
|
282
|
-
),
|
|
283
|
-
const [s, c] =
|
|
247
|
+
), Ze = (e, t) => {
|
|
248
|
+
const [s, c] = Ve(
|
|
284
249
|
e,
|
|
285
250
|
t
|
|
286
251
|
);
|
|
@@ -288,19 +253,54 @@ const B = () => {
|
|
|
288
253
|
const r = n.el;
|
|
289
254
|
r != null && r.parentNode && r.parentNode.removeChild(r);
|
|
290
255
|
}), s;
|
|
291
|
-
},
|
|
256
|
+
}, Ve = (e, t) => {
|
|
292
257
|
const s = [...e.children || []], c = [...t.children || []];
|
|
293
258
|
return [s.map((r) => {
|
|
294
|
-
const o =
|
|
259
|
+
const o = Ke(r, c), l = F(r, o);
|
|
295
260
|
return o && c.splice(c.indexOf(o), 1), l.getParent = () => e, l;
|
|
296
261
|
}), c];
|
|
297
|
-
},
|
|
262
|
+
}, Ke = (e, t) => t.find(
|
|
298
263
|
(s) => i(s) === i(e)
|
|
299
|
-
)
|
|
300
|
-
|
|
264
|
+
);
|
|
265
|
+
let P = [], M = !1;
|
|
266
|
+
const te = (e, t) => {
|
|
267
|
+
u.get(e).up = () => {
|
|
268
|
+
P.push({
|
|
269
|
+
compKey: e,
|
|
270
|
+
exec: t
|
|
271
|
+
}), M || (M = !0, queueMicrotask(me));
|
|
272
|
+
};
|
|
273
|
+
}, ge = (e) => () => {
|
|
274
|
+
var c;
|
|
275
|
+
const t = (c = u.get(e)) == null ? void 0 : c.up;
|
|
276
|
+
let s = !1;
|
|
277
|
+
return t && (t(), s = !0), s;
|
|
278
|
+
}, se = (e, t) => {
|
|
279
|
+
(e.children || []).forEach((s) => {
|
|
280
|
+
const c = s.compKey;
|
|
281
|
+
c && t.push(c), se(s, t);
|
|
282
|
+
});
|
|
283
|
+
}, me = () => {
|
|
284
|
+
let e = [];
|
|
285
|
+
P.forEach((c) => {
|
|
286
|
+
var r, o;
|
|
287
|
+
const n = (o = (r = u.get(c.compKey)) == null ? void 0 : r.vd) == null ? void 0 : o.value;
|
|
288
|
+
n && se(n, e);
|
|
289
|
+
});
|
|
290
|
+
const t = [], s = P.reduce((c, n) => {
|
|
291
|
+
const { compKey: r } = n;
|
|
292
|
+
return e.includes(r) || t.includes(r) || (t.push(r), c.push(n)), c;
|
|
293
|
+
}, []);
|
|
294
|
+
for (; s.length; ) {
|
|
295
|
+
const c = s.shift();
|
|
296
|
+
c && c.exec();
|
|
297
|
+
}
|
|
298
|
+
P = [], M = !1;
|
|
299
|
+
}, rt = (e, t = () => []) => {
|
|
300
|
+
u.get(E()).upR.push(() => X(e, t)), X(e, t);
|
|
301
301
|
}, we = () => {
|
|
302
302
|
var t;
|
|
303
|
-
const e = (t = u.get(
|
|
303
|
+
const e = (t = u.get(E())) == null ? void 0 : t.upR;
|
|
304
304
|
e != null && e.length && e.forEach((s) => s());
|
|
305
305
|
}, ce = (e, ...t) => ({
|
|
306
306
|
type: "fragment",
|
|
@@ -310,24 +310,24 @@ const B = () => {
|
|
|
310
310
|
return T(o) || (c.value = o), o;
|
|
311
311
|
}, ut = (e) => (t, s) => e, ne = (e, t, s, c) => {
|
|
312
312
|
var f;
|
|
313
|
-
|
|
313
|
+
A.value = !0;
|
|
314
314
|
const n = re(e, t, s), r = F(n, c), { isRoot: o, getParent: l, wrapElement: h, afterElement: d } = c;
|
|
315
315
|
if (r.getParent = l, !o && l) {
|
|
316
316
|
const _ = ((f = l()) == null ? void 0 : f.children) || [], le = _.indexOf(c);
|
|
317
317
|
_.splice(le, 1, r);
|
|
318
318
|
} else
|
|
319
319
|
r.isRoot = !0, r.wrapElement = h, r.afterElement = d;
|
|
320
|
-
|
|
320
|
+
A.value = !1, K(r);
|
|
321
321
|
}, re = (e, t, s) => ({ tagName: e.name, ctor: e, props: t, children: s, resolve: (o = t) => {
|
|
322
|
-
|
|
323
|
-
const h = e(t, s)(
|
|
322
|
+
Ee(o);
|
|
323
|
+
const h = e(t, s)(ge(o), t, s), d = We(
|
|
324
324
|
h,
|
|
325
325
|
o,
|
|
326
326
|
e,
|
|
327
327
|
t,
|
|
328
328
|
s
|
|
329
329
|
), f = d;
|
|
330
|
-
return
|
|
330
|
+
return te(
|
|
331
331
|
o,
|
|
332
332
|
() => ne(e, t, s, f)
|
|
333
333
|
), Z(o, "vd").value = d, d;
|
|
@@ -349,9 +349,9 @@ const B = () => {
|
|
|
349
349
|
const r = () => et(e, t, s, c, n, r);
|
|
350
350
|
return r;
|
|
351
351
|
}, et = (e, t, s, c, n, r) => {
|
|
352
|
-
|
|
352
|
+
Re(t), we();
|
|
353
353
|
const o = e(c);
|
|
354
|
-
return
|
|
354
|
+
return te(
|
|
355
355
|
t,
|
|
356
356
|
() => ne(s, c, n, o)
|
|
357
357
|
), oe(o, t, s, c, n, r), Z(t, "vd").value = o, o;
|
|
@@ -369,7 +369,7 @@ const B = () => {
|
|
|
369
369
|
return ce(t, ...s);
|
|
370
370
|
if (T(e)) {
|
|
371
371
|
const c = re(e, t, s);
|
|
372
|
-
return
|
|
372
|
+
return A.value ? c : c.resolve();
|
|
373
373
|
}
|
|
374
374
|
return {
|
|
375
375
|
type: "element",
|