lithent 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/lithent.mjs +177 -177
- 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 -4
- package/dist/utils/redraw.d.ts +3 -0
- package/dist/utils/universalRef.d.ts +2 -7
- package/examples/dist/assets/index-35f93159.js +2 -0
- package/examples/dist/assets/index-35f93159.js.map +1 -0
- package/examples/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/diff.ts +39 -4
- package/src/hook/useUpdate.ts +1 -1
- package/src/render.ts +19 -6
- package/src/tests/fragment.tsx +124 -12
- package/src/tests/hoc.tsx +2 -0
- package/src/tests/renewEventTest.tsx +73 -0
- 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 +3 -47
- package/src/utils/redraw.ts +76 -0
- package/src/utils/universalRef.ts +1 -83
- package/src/wDom.ts +3 -4
- 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.
|
|
12
|
+
`(9.97 kB │ gzip: 3.98 kB)`
|
|
13
13
|
|
|
14
14
|
## 🚩 Table of Contents
|
|
15
15
|
|
|
@@ -32,7 +32,7 @@ used lightly in a variety of situations.
|
|
|
32
32
|
|
|
33
33
|
In a real-world development environment, you may want to use Virtual DOM lightly, with only the bare minimum of core functionality.
|
|
34
34
|
|
|
35
|
-
"Lithent" makes it easy to add, remove, and update virtual
|
|
35
|
+
"Lithent" makes it easy to add, remove, and update virtual DOM to specific parts of a pre-drawn SSR page.
|
|
36
36
|
|
|
37
37
|
"Lithent" has implemented the bare minimum functionality needed to create and update virtual DOM in general (we only need to know 'render', 'mounter', 'updater', 'renewer', 'mountCallback', and 'updateCallback').
|
|
38
38
|
|
|
@@ -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.8/dist/lithent.umd.js
|
|
64
|
+
* UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.8/helper/dist/lithentHelper.umd.js
|
|
65
|
+
* ESM : https://cdn.jsdelivr.net/npm/lithent@1.0.8/dist/lithent.mjs
|
|
66
|
+
* ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.0.8/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.8/dist/lithent.umd.js"></script>
|
|
125
|
+
<!--script src="https://cdn.jsdelivr.net/npm/lithent@1.0.8/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
|
|
1
|
+
const k = (e) => typeof e == "object" && !("resolve" in e), x = (e, t) => k(e) && e.type === t, pe = (e, t) => "ctor" in e ? e.ctor === (t == null ? void 0 : t.ctor) : e === (t == null ? void 0 : t.ctor), he = (e, t) => {
|
|
2
2
|
var s, c;
|
|
3
|
-
return
|
|
4
|
-
},
|
|
3
|
+
return k(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
|
+
}, ie = (e, t) => {
|
|
5
5
|
var s, c;
|
|
6
|
-
return
|
|
7
|
-
}, U = (e, t) =>
|
|
6
|
+
return k(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) => k(e) && (t == null ? void 0 : t.type) === e.type && (e.type !== "loop" || e.type === "loop" && C(i((e.children || [])[0])) && C(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
|
+
}, y = (e) => e && ["fragment", "loop"].includes(e), T = (e) => typeof e == "function" && !H(e) || typeof e == "object" && "resolve" in e, H = (e) => typeof e == "function" && e === re, J = (e) => k(e) && !e.type, C = (e) => e != null, z = (e, t) => e === "style" && typeof t == "object", ve = (e, t) => e === "ref" && typeof t == "object", ye = (e) => e.nodeType === 1 && e.tagName === "OPTION", Ce = (e) => e.nodeType === 1 && e.tagName === "TEXTAREA", ae = (e) => e.nodeType === 1 && ["radio", "checkbox"].includes(e.type), ke = (e) => {
|
|
11
11
|
let t = "et";
|
|
12
|
-
return T(e) ? t = "c" :
|
|
13
|
-
},
|
|
14
|
-
c:
|
|
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" : J(e) && (t = "et"), t;
|
|
13
|
+
}, Re = {
|
|
14
|
+
c: pe,
|
|
15
15
|
l: U,
|
|
16
16
|
t: U,
|
|
17
|
-
e:
|
|
18
|
-
f:
|
|
17
|
+
e: ie,
|
|
18
|
+
f: he,
|
|
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(), a = Object.entries, Y = Object.keys, S = Object.assign, v = { value: "" }, R = { value: {} }, A = { value: !1 }, u = /* @__PURE__ */ new WeakMap(), Ee = (e) => {
|
|
35
21
|
u.set(e, {
|
|
36
22
|
vd: { value: null },
|
|
37
23
|
up: () => {
|
|
@@ -43,101 +29,73 @@ 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], xe = (e) => R.value = e, Pe = (e) => {
|
|
33
|
+
R.value = e, Ee(e);
|
|
34
|
+
}, Te = (e) => {
|
|
35
|
+
u.get(E()).umts.push(e);
|
|
78
36
|
}, Q = (e) => {
|
|
79
37
|
const { compKey: t } = e;
|
|
80
|
-
t &&
|
|
81
|
-
},
|
|
38
|
+
t && Se(t), K(e);
|
|
39
|
+
}, K = (e) => {
|
|
82
40
|
(e.children || []).forEach((t) => {
|
|
83
|
-
t.compKey ? Q(t) :
|
|
41
|
+
t.compKey ? Q(t) : K(t);
|
|
84
42
|
});
|
|
85
|
-
},
|
|
43
|
+
}, Se = (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
|
-
},
|
|
49
|
+
O.forEach((e) => be(e)), O = [];
|
|
50
|
+
}, Ne = (e) => {
|
|
51
|
+
e.compKey && O.push(e);
|
|
52
|
+
}, rt = (e) => u.get(E()).mts.push(e), be = (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 && Te(o);
|
|
101
59
|
}));
|
|
102
60
|
}
|
|
103
|
-
},
|
|
104
|
-
const s = u.get(
|
|
105
|
-
if (r &&
|
|
61
|
+
}, G = (e, t = () => []) => {
|
|
62
|
+
const s = u.get(E()), { upD: c, upS: n } = s, r = c[n.value];
|
|
63
|
+
if (r && Ue(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
|
+
}, Fe = (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
|
+
}, Ue = (e, t) => e.length ? e.some((s, c) => s !== t[c]) : !0, X = (e) => e === "className" ? "class" : e, V = (e) => e.replace(/^on(.*)/, (t, s) => s.toLowerCase()), g = () => new DocumentFragment(), $ = (e) => document.createElement(e), ot = (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),
|
|
80
|
+
n && (Q(n), I(n), Ae(n));
|
|
123
81
|
};
|
|
124
82
|
}, m = (e) => {
|
|
125
83
|
const { needRerender: t } = e;
|
|
126
84
|
t && t !== "N" && {
|
|
127
85
|
A: q,
|
|
128
|
-
D:
|
|
129
|
-
R:
|
|
130
|
-
U:
|
|
86
|
+
D: j,
|
|
87
|
+
R: Le,
|
|
88
|
+
U: Me,
|
|
131
89
|
SR: D,
|
|
132
|
-
SU:
|
|
90
|
+
SU: Oe
|
|
133
91
|
}[t](e);
|
|
134
|
-
},
|
|
92
|
+
}, I = (e) => {
|
|
135
93
|
e.props && e.el && te(e.props, e.el), (e.children || []).forEach((t) => {
|
|
136
|
-
|
|
94
|
+
I(t);
|
|
137
95
|
});
|
|
138
|
-
},
|
|
96
|
+
}, Ae = (e) => {
|
|
139
97
|
w(e, e.wrapElement);
|
|
140
|
-
},
|
|
98
|
+
}, j = (e) => {
|
|
141
99
|
e.oldProps && e.el && te(e.oldProps, e.el), w(
|
|
142
100
|
e,
|
|
143
101
|
b(p(e))
|
|
@@ -151,31 +109,31 @@ const B = () => {
|
|
|
151
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 && W(s, t);
|
|
152
110
|
});
|
|
153
111
|
}, D = (e) => {
|
|
154
|
-
|
|
155
|
-
},
|
|
156
|
-
|
|
112
|
+
j(e), q(e);
|
|
113
|
+
}, Oe = (e) => {
|
|
114
|
+
j(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
|
-
},
|
|
122
|
+
}, L = (e, t) => {
|
|
165
123
|
const s = t.children || [], n = s.indexOf(e) + 1, r = s.slice(n), o = ee(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 && y(l))
|
|
127
|
+
return L(t, p(t));
|
|
128
|
+
if (t.isRoot && y(l) && t.afterElement)
|
|
171
129
|
return t.afterElement;
|
|
172
130
|
}, ee = (e) => e.reduce(
|
|
173
131
|
(t, s) => {
|
|
174
|
-
const c = s.type, n = s.el, r = c &&
|
|
132
|
+
const c = s.type, n = s.el, r = c && y(c);
|
|
175
133
|
return t || (r ? ee(s.children || []) : n && n.nodeType !== 11 ? n : t);
|
|
176
134
|
},
|
|
177
135
|
void 0
|
|
178
|
-
),
|
|
136
|
+
), Le = (e) => {
|
|
179
137
|
const t = p(e), s = e.el;
|
|
180
138
|
if (t.type && s)
|
|
181
139
|
if (s.nodeType === 11)
|
|
@@ -185,101 +143,108 @@ const B = () => {
|
|
|
185
143
|
c && c.replaceChild(n, s), B();
|
|
186
144
|
}
|
|
187
145
|
}, te = (e, t) => {
|
|
188
|
-
|
|
146
|
+
a(e || {}).forEach(([s, c]) => {
|
|
189
147
|
s.match(/^on/) && t.removeEventListener(
|
|
190
|
-
|
|
148
|
+
V(s),
|
|
191
149
|
c
|
|
192
150
|
);
|
|
193
151
|
});
|
|
194
|
-
},
|
|
152
|
+
}, Me = (e) => {
|
|
195
153
|
var s;
|
|
196
154
|
const t = e.el;
|
|
197
155
|
if (e.type === "text") {
|
|
198
|
-
|
|
156
|
+
Qe(e);
|
|
199
157
|
return;
|
|
200
158
|
}
|
|
201
159
|
if (t) {
|
|
202
160
|
const { oldProps: c, props: n } = e;
|
|
203
161
|
se(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) => m(c)),
|
|
206
|
-
},
|
|
163
|
+
(e.children || []).forEach((c) => m(c)), Fe(e);
|
|
164
|
+
}, Qe = (e) => {
|
|
207
165
|
const t = e.el;
|
|
208
166
|
t && (t.nodeValue = String(e.text));
|
|
209
167
|
}, se = (e, t, s) => {
|
|
210
168
|
const c = { ...s };
|
|
211
|
-
|
|
169
|
+
a(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) ? qe(
|
|
214
172
|
r,
|
|
215
173
|
z(n, c.style) ? c.style : {},
|
|
216
174
|
t
|
|
217
|
-
) :
|
|
175
|
+
) : ve(n, r) ? r.value = t : n.match(/^on/) ? je(
|
|
218
176
|
t,
|
|
219
177
|
n,
|
|
220
178
|
r,
|
|
221
179
|
c[n]
|
|
222
|
-
) :
|
|
180
|
+
) : ae(t) && n === "checked" ? t.checked = !!r : Ce(t) && n === "value" ? t.value = r : ye(t) && n === "selected" ? t.selected = !!r : n && ([o, r] = Be(r), o && (v.value && n !== "xmlns" ? t.setAttributeNS(
|
|
223
181
|
null,
|
|
224
|
-
|
|
182
|
+
X(n),
|
|
225
183
|
r
|
|
226
184
|
) : t.setAttribute(
|
|
227
|
-
|
|
185
|
+
X(n),
|
|
228
186
|
r
|
|
229
187
|
)))), o && delete c[n];
|
|
230
188
|
}), Y(c).forEach(
|
|
231
189
|
(n) => t.removeAttribute(n)
|
|
232
190
|
);
|
|
233
|
-
},
|
|
191
|
+
}, Be = (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" && (
|
|
240
|
-
},
|
|
196
|
+
const { type: s, tag: c, text: n, props: r, children: o = [] } = e, l = y(s);
|
|
197
|
+
return c === "svg" && (v.value = String(r == null ? void 0 : r.xmlns)), l ? t = g() : s === "element" && c ? t = v.value ? document.createElementNS(v.value, c) : $(c) : s === "text" && C(n) ? t = document.createTextNode(String(n)) : t = $("e"), Ie(o, t), se(r, t), e.el = t, Ne(e), c === "svg" && (v.value = ""), t;
|
|
198
|
+
}, Ie = (e, t) => {
|
|
241
199
|
const s = e.reduce(
|
|
242
200
|
(c, n) => (n.type && c.appendChild(N(n)), c),
|
|
243
|
-
|
|
201
|
+
g()
|
|
244
202
|
);
|
|
245
203
|
t && s.hasChildNodes() && t.appendChild(s);
|
|
246
|
-
},
|
|
247
|
-
const n =
|
|
204
|
+
}, je = (e, t, s, c) => {
|
|
205
|
+
const n = V(t);
|
|
248
206
|
c !== s && (c && e.removeEventListener(n, c), s && e.addEventListener(n, s));
|
|
249
|
-
},
|
|
207
|
+
}, qe = (e, t, s) => {
|
|
250
208
|
const c = { ...t }, n = s == null ? void 0 : s.style;
|
|
251
|
-
n && (
|
|
209
|
+
n && (a(e).forEach(([r, o]) => {
|
|
252
210
|
n[r] = o, delete c[r];
|
|
253
|
-
}),
|
|
211
|
+
}), a(c).forEach(
|
|
254
212
|
([r]) => n[r] = ""
|
|
255
213
|
));
|
|
256
214
|
}, b = (e) => {
|
|
257
|
-
const t =
|
|
215
|
+
const t = y(e.type);
|
|
258
216
|
return e.isRoot && t ? e.wrapElement : t ? b(p(e)) : e.el;
|
|
259
|
-
}, F = (e, t) =>
|
|
217
|
+
}, F = (e, t) => _e(
|
|
260
218
|
e,
|
|
261
|
-
|
|
219
|
+
Re[ke(e)](e, t),
|
|
262
220
|
t
|
|
263
|
-
),
|
|
221
|
+
), _e = (e, t, s) => {
|
|
264
222
|
const c = Je(e, t, s), n = [
|
|
265
223
|
c,
|
|
266
224
|
t,
|
|
267
225
|
s
|
|
268
|
-
], r =
|
|
269
|
-
return c.children = Ye(...n), c.needRerender = r,
|
|
270
|
-
},
|
|
271
|
-
s !== "A" && t && (e.el = t.el), s && ["D", "R", "SR"].includes(s) && (t != null && t.compKey && (Q(t),
|
|
272
|
-
},
|
|
273
|
-
const c = s && s.type, n =
|
|
226
|
+
], r = Ge(...n);
|
|
227
|
+
return c.children = Ye(...n), c.needRerender = r, ze(c, s, r), c;
|
|
228
|
+
}, ze = (e, t, s) => {
|
|
229
|
+
s !== "A" && t && (e.el = t.el), s && ["D", "R", "SR"].includes(s) && (t != null && t.compKey && (Q(t), I(t)), e.oldChildren = t == null ? void 0 : t.children), e.oldProps = t == null ? void 0 : t.props;
|
|
230
|
+
}, Ge = (e, t, s) => {
|
|
231
|
+
const c = s && s.type, n = J(e), o = !!e.getParent && p(e).type, l = i(e), h = o === "loop" && C(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
|
+
}, Xe = (e, t) => {
|
|
235
|
+
e && t !== e && (Y(e).forEach((s) => delete e[s]), a(t || {}).forEach(([s, c]) => e[s] = c));
|
|
236
|
+
}, $e = (e, t) => {
|
|
237
|
+
e && t !== e && (e.splice(0, e.length), t && t.forEach((s) => e.push(s)));
|
|
238
|
+
}, He = (e, t) => {
|
|
239
|
+
const { compProps: s, compChild: c } = e, { props: n, children: r } = t;
|
|
240
|
+
return s && Xe(s, n), c && $e(c, r), e.reRender && e.reRender();
|
|
241
|
+
}, Je = (e, t, s) => T(e) ? t && s ? He(s, e) : e.resolve() : e, Ye = (e, t, s) => t && s ? Ke(e, s) : Ze(e), Ze = (e) => (e.children || []).map(
|
|
277
242
|
(t) => S(F(t), { getParent: () => e })
|
|
278
|
-
),
|
|
243
|
+
), Ke = (e, t) => e.type === "loop" && C(i((e.children || [])[0])) ? Ve(e, t) : (e.children || []).map(
|
|
279
244
|
(s, c) => S(F(s, (t.children || [])[c]), {
|
|
280
245
|
getParent: () => e
|
|
281
246
|
})
|
|
282
|
-
),
|
|
247
|
+
), Ve = (e, t) => {
|
|
283
248
|
const [s, c] = ge(
|
|
284
249
|
e,
|
|
285
250
|
t
|
|
@@ -296,66 +261,101 @@ const B = () => {
|
|
|
296
261
|
}), c];
|
|
297
262
|
}, me = (e, t) => t.find(
|
|
298
263
|
(s) => i(s) === i(e)
|
|
299
|
-
)
|
|
300
|
-
|
|
301
|
-
|
|
264
|
+
);
|
|
265
|
+
let P = [], M = !1;
|
|
266
|
+
const ce = (e, t) => {
|
|
267
|
+
u.get(e).up = () => {
|
|
268
|
+
P.push({
|
|
269
|
+
compKey: e,
|
|
270
|
+
exec: t
|
|
271
|
+
}), M || (M = !0, queueMicrotask(We));
|
|
272
|
+
};
|
|
273
|
+
}, we = (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
|
+
}, ne = (e, t) => {
|
|
279
|
+
(e.children || []).forEach((s) => {
|
|
280
|
+
const c = s.compKey;
|
|
281
|
+
c && t.push(c), ne(s, t);
|
|
282
|
+
});
|
|
283
|
+
}, We = () => {
|
|
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 && ne(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
|
+
}, ut = (e, t = () => []) => {
|
|
300
|
+
u.get(E()).upR.push(() => G(e, t)), G(e, t);
|
|
301
|
+
}, De = () => {
|
|
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
|
+
}, re = (e, ...t) => ({
|
|
306
306
|
type: "fragment",
|
|
307
307
|
children: t
|
|
308
|
-
}),
|
|
309
|
-
const c = { value: void 0 }, n = t || {}, r =
|
|
308
|
+
}), lt = (e, t, ...s) => {
|
|
309
|
+
const c = { value: void 0 }, n = t || {}, r = fe(c, s), o = ct(e, n, r);
|
|
310
310
|
return T(o) || (c.value = o), o;
|
|
311
|
-
},
|
|
311
|
+
}, ft = (e) => (t, s) => e, oe = (e, t, s, c) => {
|
|
312
312
|
var f;
|
|
313
|
-
|
|
314
|
-
const n =
|
|
313
|
+
A.value = !0;
|
|
314
|
+
const n = ue(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
|
-
const _ = ((f = l()) == null ? void 0 : f.children) || [],
|
|
317
|
-
_.splice(
|
|
316
|
+
const _ = ((f = l()) == null ? void 0 : f.children) || [], de = _.indexOf(c);
|
|
317
|
+
_.splice(de, 1, r);
|
|
318
318
|
} else
|
|
319
319
|
r.isRoot = !0, r.wrapElement = h, r.afterElement = d;
|
|
320
|
-
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
const h = e(t, s)(
|
|
320
|
+
A.value = !1, m(r);
|
|
321
|
+
}, ue = (e, t, s) => ({ tagName: e.name, ctor: e, props: t, children: s, resolve: (o = t) => {
|
|
322
|
+
Pe(o);
|
|
323
|
+
const h = e(t, s)(we(o), t, s), d = et(
|
|
324
324
|
h,
|
|
325
325
|
o,
|
|
326
326
|
e,
|
|
327
327
|
t,
|
|
328
328
|
s
|
|
329
329
|
), f = d;
|
|
330
|
-
return
|
|
330
|
+
return ce(
|
|
331
331
|
o,
|
|
332
|
-
() =>
|
|
332
|
+
() => oe(e, t, s, f)
|
|
333
333
|
), Z(o, "vd").value = d, d;
|
|
334
|
-
} }),
|
|
334
|
+
} }), et = (e, t, s, c, n) => {
|
|
335
335
|
const r = e(c);
|
|
336
336
|
if (r.reRender)
|
|
337
337
|
throw new Error(
|
|
338
|
-
'
|
|
338
|
+
'Avoid the case where the first element of a component is a component. Instead of "mount(()=>()=><Component />)" replace it with something like "mount(()=>()=><Fragment><Component /></Fragment>)".'
|
|
339
339
|
);
|
|
340
|
-
return
|
|
340
|
+
return le(
|
|
341
341
|
r,
|
|
342
342
|
t,
|
|
343
343
|
s,
|
|
344
344
|
c,
|
|
345
345
|
n,
|
|
346
|
-
|
|
346
|
+
tt(e, t, s, c, n)
|
|
347
347
|
), r;
|
|
348
|
-
},
|
|
349
|
-
const r = () =>
|
|
348
|
+
}, tt = (e, t, s, c, n) => {
|
|
349
|
+
const r = () => st(e, t, s, c, n, r);
|
|
350
350
|
return r;
|
|
351
|
-
},
|
|
352
|
-
|
|
351
|
+
}, st = (e, t, s, c, n, r) => {
|
|
352
|
+
xe(t), De();
|
|
353
353
|
const o = e(c);
|
|
354
|
-
return
|
|
354
|
+
return ce(
|
|
355
355
|
t,
|
|
356
|
-
() =>
|
|
357
|
-
),
|
|
358
|
-
},
|
|
356
|
+
() => oe(s, c, n, o)
|
|
357
|
+
), le(o, t, s, c, n, r), Z(t, "vd").value = o, o;
|
|
358
|
+
}, le = (e, t, s, c, n, r) => {
|
|
359
359
|
S(e, {
|
|
360
360
|
compProps: c,
|
|
361
361
|
compChild: n,
|
|
@@ -364,12 +364,12 @@ const B = () => {
|
|
|
364
364
|
compKey: t,
|
|
365
365
|
reRender: r
|
|
366
366
|
});
|
|
367
|
-
},
|
|
368
|
-
if (
|
|
369
|
-
return
|
|
367
|
+
}, ct = (e, t, s) => {
|
|
368
|
+
if (H(e))
|
|
369
|
+
return re(t, ...s);
|
|
370
370
|
if (T(e)) {
|
|
371
|
-
const c =
|
|
372
|
-
return
|
|
371
|
+
const c = ue(e, t, s);
|
|
372
|
+
return A.value ? c : c.resolve();
|
|
373
373
|
}
|
|
374
374
|
return {
|
|
375
375
|
type: "element",
|
|
@@ -377,29 +377,29 @@ const B = () => {
|
|
|
377
377
|
props: t,
|
|
378
378
|
children: s
|
|
379
379
|
};
|
|
380
|
-
},
|
|
381
|
-
(s) => S(
|
|
382
|
-
),
|
|
380
|
+
}, fe = (e, t) => t.map(
|
|
381
|
+
(s) => S(nt(s), { getParent: () => e.value })
|
|
382
|
+
), nt = (e) => {
|
|
383
383
|
if (e == null || e === !1)
|
|
384
384
|
return { type: null };
|
|
385
385
|
if (Array.isArray(e)) {
|
|
386
386
|
const t = { value: void 0 }, c = {
|
|
387
387
|
type: "loop",
|
|
388
|
-
children:
|
|
388
|
+
children: fe(t, e)
|
|
389
389
|
};
|
|
390
390
|
return t.value = c, c;
|
|
391
391
|
} else if (typeof e == "string" || typeof e == "number")
|
|
392
392
|
return { type: "text", text: e };
|
|
393
393
|
return e;
|
|
394
|
-
},
|
|
394
|
+
}, dt = (e) => ({ value: e }), pt = () => Promise.resolve();
|
|
395
395
|
export {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
396
|
+
re as Fragment,
|
|
397
|
+
lt as h,
|
|
398
|
+
ft as mount,
|
|
399
|
+
rt as mountCallback,
|
|
400
|
+
pt as nextTick,
|
|
401
|
+
dt as ref,
|
|
402
|
+
ot as render,
|
|
403
|
+
ut as updateCallback
|
|
404
404
|
};
|
|
405
405
|
//# sourceMappingURL=lithent.mjs.map
|