lithent 1.0.7 → 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 +157 -157
- package/dist/lithent.mjs.map +1 -1
- package/dist/lithent.umd.js +1 -1
- package/dist/lithent.umd.js.map +1 -1
- package/dist/utils/index.d.ts +0 -2
- 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/hook/useUpdate.ts +1 -1
- package/src/render.ts +14 -5
- package/src/tests/fragment.tsx +124 -12
- package/src/tests/hoc.tsx +2 -0
- package/src/tests/renewEventTest.tsx +73 -0
- package/src/utils/index.ts +2 -11
- package/src/wDom.ts +1 -1
- package/examples/dist/assets/index-22f97357.js +0 -2
- package/examples/dist/assets/index-22f97357.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,23 +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" : x(e, "fragment") ? t = "f" : x(e, "element") ? t = "e" : x(e, "loop") ? t = "l" : x(e, "text") ? t = "t" :
|
|
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(),
|
|
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) => {
|
|
21
21
|
u.set(e, {
|
|
22
22
|
vd: { value: null },
|
|
23
23
|
up: () => {
|
|
@@ -29,89 +29,89 @@ const C = (e) => typeof e == "object" && !("resolve" in e), x = (e, t) => C(e) &
|
|
|
29
29
|
mts: [],
|
|
30
30
|
umts: []
|
|
31
31
|
});
|
|
32
|
-
}, E = () => R.value, Z = (e, t) => u.get(e)[t],
|
|
33
|
-
R.value = e,
|
|
34
|
-
},
|
|
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
35
|
u.get(E()).umts.push(e);
|
|
36
36
|
}, Q = (e) => {
|
|
37
37
|
const { compKey: t } = e;
|
|
38
|
-
t &&
|
|
39
|
-
},
|
|
38
|
+
t && Se(t), K(e);
|
|
39
|
+
}, K = (e) => {
|
|
40
40
|
(e.children || []).forEach((t) => {
|
|
41
|
-
t.compKey ? Q(t) :
|
|
41
|
+
t.compKey ? Q(t) : K(t);
|
|
42
42
|
});
|
|
43
|
-
},
|
|
43
|
+
}, Se = (e) => {
|
|
44
44
|
const t = u.get(e);
|
|
45
45
|
t && (t.umts.forEach((s) => s()), t.umts = [], u.delete(e));
|
|
46
46
|
};
|
|
47
47
|
let O = [];
|
|
48
48
|
const B = () => {
|
|
49
|
-
O.forEach((e) =>
|
|
50
|
-
},
|
|
49
|
+
O.forEach((e) => be(e)), O = [];
|
|
50
|
+
}, Ne = (e) => {
|
|
51
51
|
e.compKey && O.push(e);
|
|
52
|
-
},
|
|
52
|
+
}, rt = (e) => u.get(E()).mts.push(e), be = (e) => {
|
|
53
53
|
const { compKey: t } = e;
|
|
54
54
|
if (t) {
|
|
55
55
|
const s = u.get(t), c = s == null ? void 0 : s.mts, n = s == null ? void 0 : s.upS;
|
|
56
56
|
R.value = t, n && (n.value = 0), c && (s.mts = [], c.forEach((r) => {
|
|
57
57
|
const o = r();
|
|
58
|
-
o &&
|
|
58
|
+
o && Te(o);
|
|
59
59
|
}));
|
|
60
60
|
}
|
|
61
|
-
},
|
|
61
|
+
}, G = (e, t = () => []) => {
|
|
62
62
|
const s = u.get(E()), { upD: c, upS: n } = s, r = c[n.value];
|
|
63
|
-
if (r &&
|
|
63
|
+
if (r && Ue(r, t())) {
|
|
64
64
|
const o = e();
|
|
65
65
|
o && s.upCB.push(o);
|
|
66
66
|
}
|
|
67
67
|
c[n.value] = t(), n.value += 1;
|
|
68
|
-
},
|
|
68
|
+
}, Fe = (e) => {
|
|
69
69
|
const { compKey: t } = e;
|
|
70
70
|
if (t) {
|
|
71
71
|
const s = u.get(t), c = s == null ? void 0 : s.upCB, n = s == null ? void 0 : s.upS;
|
|
72
72
|
R.value = t, n && (n.value = 0), e.ctor && c && (s.upCB = [], c.forEach((r) => r()));
|
|
73
73
|
}
|
|
74
|
-
},
|
|
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) => {
|
|
75
75
|
t ?? (t = document.body), e.isRoot = !0, e.wrapElement = t;
|
|
76
76
|
const c = N(e);
|
|
77
77
|
return s ? (e.afterElement = s, t.insertBefore(c, s)) : t.appendChild(c), B(), () => {
|
|
78
78
|
var r;
|
|
79
79
|
const n = (r = u.get(e.compProps || {})) == null ? void 0 : r.vd.value;
|
|
80
|
-
n && (Q(n),
|
|
80
|
+
n && (Q(n), I(n), Ae(n));
|
|
81
81
|
};
|
|
82
|
-
},
|
|
82
|
+
}, m = (e) => {
|
|
83
83
|
const { needRerender: t } = e;
|
|
84
84
|
t && t !== "N" && {
|
|
85
85
|
A: q,
|
|
86
|
-
D:
|
|
87
|
-
R:
|
|
88
|
-
U:
|
|
89
|
-
SR:
|
|
90
|
-
SU:
|
|
86
|
+
D: j,
|
|
87
|
+
R: Le,
|
|
88
|
+
U: Me,
|
|
89
|
+
SR: D,
|
|
90
|
+
SU: Oe
|
|
91
91
|
}[t](e);
|
|
92
|
-
}, j = (e) => {
|
|
93
|
-
e.props && e.el && D(e.props, e.el), (e.children || []).forEach((t) => {
|
|
94
|
-
j(t);
|
|
95
|
-
});
|
|
96
|
-
}, Fe = (e) => {
|
|
97
|
-
g(e, e.wrapElement);
|
|
98
92
|
}, I = (e) => {
|
|
99
|
-
e.
|
|
93
|
+
e.props && e.el && te(e.props, e.el), (e.children || []).forEach((t) => {
|
|
94
|
+
I(t);
|
|
95
|
+
});
|
|
96
|
+
}, Ae = (e) => {
|
|
97
|
+
w(e, e.wrapElement);
|
|
98
|
+
}, j = (e) => {
|
|
99
|
+
e.oldProps && e.el && te(e.oldProps, e.el), w(
|
|
100
100
|
e,
|
|
101
101
|
b(p(e))
|
|
102
102
|
);
|
|
103
|
-
},
|
|
103
|
+
}, w = (e, t) => {
|
|
104
104
|
var s, c;
|
|
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 &&
|
|
106
|
-
},
|
|
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 && W(e, t), delete e.el);
|
|
106
|
+
}, W = (e, t) => {
|
|
107
107
|
((e == null ? void 0 : e.oldChildren) || (e == null ? void 0 : e.children) || []).forEach((s) => {
|
|
108
108
|
var c, n;
|
|
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 &&
|
|
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);
|
|
110
110
|
});
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
|
|
111
|
+
}, D = (e) => {
|
|
112
|
+
j(e), q(e);
|
|
113
|
+
}, Oe = (e) => {
|
|
114
|
+
j(e), q(e, e.el);
|
|
115
115
|
}, q = (e, t) => {
|
|
116
116
|
t || (t = N(e));
|
|
117
117
|
const s = p(e);
|
|
@@ -120,132 +120,132 @@ const B = () => {
|
|
|
120
120
|
t && c && (r ? c.insertBefore(t, r) : c.appendChild(t), B());
|
|
121
121
|
}
|
|
122
122
|
}, L = (e, t) => {
|
|
123
|
-
const s = t.children || [], n = s.indexOf(e) + 1, r = s.slice(n), o =
|
|
123
|
+
const s = t.children || [], n = s.indexOf(e) + 1, r = s.slice(n), o = ee(r), l = t.type || "";
|
|
124
124
|
if (o)
|
|
125
125
|
return o;
|
|
126
|
-
if (!t.isRoot &&
|
|
126
|
+
if (!t.isRoot && y(l))
|
|
127
127
|
return L(t, p(t));
|
|
128
|
-
if (t.isRoot &&
|
|
128
|
+
if (t.isRoot && y(l) && t.afterElement)
|
|
129
129
|
return t.afterElement;
|
|
130
|
-
},
|
|
130
|
+
}, ee = (e) => e.reduce(
|
|
131
131
|
(t, s) => {
|
|
132
|
-
const c = s.type, n = s.el, r = c &&
|
|
133
|
-
return t || (r ?
|
|
132
|
+
const c = s.type, n = s.el, r = c && y(c);
|
|
133
|
+
return t || (r ? ee(s.children || []) : n && n.nodeType !== 11 ? n : t);
|
|
134
134
|
},
|
|
135
135
|
void 0
|
|
136
|
-
),
|
|
136
|
+
), Le = (e) => {
|
|
137
137
|
const t = p(e), s = e.el;
|
|
138
138
|
if (t.type && s)
|
|
139
139
|
if (s.nodeType === 11)
|
|
140
|
-
|
|
140
|
+
D(e);
|
|
141
141
|
else {
|
|
142
142
|
const c = b(t), n = N(e);
|
|
143
143
|
c && c.replaceChild(n, s), B();
|
|
144
144
|
}
|
|
145
|
-
},
|
|
146
|
-
|
|
145
|
+
}, te = (e, t) => {
|
|
146
|
+
a(e || {}).forEach(([s, c]) => {
|
|
147
147
|
s.match(/^on/) && t.removeEventListener(
|
|
148
|
-
|
|
148
|
+
V(s),
|
|
149
149
|
c
|
|
150
150
|
);
|
|
151
151
|
});
|
|
152
|
-
},
|
|
152
|
+
}, Me = (e) => {
|
|
153
153
|
var s;
|
|
154
154
|
const t = e.el;
|
|
155
155
|
if (e.type === "text") {
|
|
156
|
-
|
|
156
|
+
Qe(e);
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
159
|
if (t) {
|
|
160
160
|
const { oldProps: c, props: n } = e;
|
|
161
|
-
|
|
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) || ""));
|
|
162
162
|
}
|
|
163
|
-
(e.children || []).forEach((c) =>
|
|
164
|
-
},
|
|
163
|
+
(e.children || []).forEach((c) => m(c)), Fe(e);
|
|
164
|
+
}, Qe = (e) => {
|
|
165
165
|
const t = e.el;
|
|
166
166
|
t && (t.nodeValue = String(e.text));
|
|
167
|
-
},
|
|
167
|
+
}, se = (e, t, s) => {
|
|
168
168
|
const c = { ...s };
|
|
169
|
-
|
|
169
|
+
a(e || {}).forEach(([n, r]) => {
|
|
170
170
|
let o = !0;
|
|
171
|
-
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(
|
|
172
172
|
r,
|
|
173
173
|
z(n, c.style) ? c.style : {},
|
|
174
174
|
t
|
|
175
|
-
) :
|
|
175
|
+
) : ve(n, r) ? r.value = t : n.match(/^on/) ? je(
|
|
176
176
|
t,
|
|
177
177
|
n,
|
|
178
178
|
r,
|
|
179
179
|
c[n]
|
|
180
|
-
) :
|
|
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(
|
|
181
181
|
null,
|
|
182
|
-
|
|
182
|
+
X(n),
|
|
183
183
|
r
|
|
184
184
|
) : t.setAttribute(
|
|
185
|
-
|
|
185
|
+
X(n),
|
|
186
186
|
r
|
|
187
187
|
)))), o && delete c[n];
|
|
188
188
|
}), Y(c).forEach(
|
|
189
189
|
(n) => t.removeAttribute(n)
|
|
190
190
|
);
|
|
191
|
-
},
|
|
191
|
+
}, Be = (e) => {
|
|
192
192
|
let t = !0;
|
|
193
193
|
return typeof e == "boolean" && (e || (t = !1), e = ""), [t, String(e)];
|
|
194
194
|
}, N = (e) => {
|
|
195
195
|
let t;
|
|
196
|
-
const { type: s, tag: c, text: n, props: r, children: o = [] } = e, l =
|
|
197
|
-
return c === "svg" && (
|
|
198
|
-
},
|
|
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) => {
|
|
199
199
|
const s = e.reduce(
|
|
200
200
|
(c, n) => (n.type && c.appendChild(N(n)), c),
|
|
201
|
-
|
|
201
|
+
g()
|
|
202
202
|
);
|
|
203
203
|
t && s.hasChildNodes() && t.appendChild(s);
|
|
204
|
-
},
|
|
205
|
-
const n =
|
|
204
|
+
}, je = (e, t, s, c) => {
|
|
205
|
+
const n = V(t);
|
|
206
206
|
c !== s && (c && e.removeEventListener(n, c), s && e.addEventListener(n, s));
|
|
207
|
-
},
|
|
207
|
+
}, qe = (e, t, s) => {
|
|
208
208
|
const c = { ...t }, n = s == null ? void 0 : s.style;
|
|
209
|
-
n && (
|
|
209
|
+
n && (a(e).forEach(([r, o]) => {
|
|
210
210
|
n[r] = o, delete c[r];
|
|
211
|
-
}),
|
|
211
|
+
}), a(c).forEach(
|
|
212
212
|
([r]) => n[r] = ""
|
|
213
213
|
));
|
|
214
214
|
}, b = (e) => {
|
|
215
|
-
const t =
|
|
215
|
+
const t = y(e.type);
|
|
216
216
|
return e.isRoot && t ? e.wrapElement : t ? b(p(e)) : e.el;
|
|
217
|
-
}, F = (e, t) =>
|
|
217
|
+
}, F = (e, t) => _e(
|
|
218
218
|
e,
|
|
219
|
-
ke
|
|
219
|
+
Re[ke(e)](e, t),
|
|
220
220
|
t
|
|
221
|
-
),
|
|
222
|
-
const c =
|
|
221
|
+
), _e = (e, t, s) => {
|
|
222
|
+
const c = Je(e, t, s), n = [
|
|
223
223
|
c,
|
|
224
224
|
t,
|
|
225
225
|
s
|
|
226
|
-
], r =
|
|
227
|
-
return c.children =
|
|
228
|
-
},
|
|
229
|
-
s !== "A" && t && (e.el = t.el), s && ["D", "R", "SR"].includes(s) && (t != null && t.compKey && (Q(t),
|
|
230
|
-
},
|
|
231
|
-
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);
|
|
232
232
|
let f;
|
|
233
233
|
return n ? f = "D" : d ? f = "N" : c ? t ? f = h ? "SU" : "U" : f = h ? "SR" : "R" : f = "A", f;
|
|
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
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
239
|
const { compProps: s, compChild: c } = e, { props: n, children: r } = t;
|
|
240
|
-
return s &&
|
|
241
|
-
},
|
|
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(
|
|
242
242
|
(t) => S(F(t), { getParent: () => e })
|
|
243
|
-
),
|
|
243
|
+
), Ke = (e, t) => e.type === "loop" && C(i((e.children || [])[0])) ? Ve(e, t) : (e.children || []).map(
|
|
244
244
|
(s, c) => S(F(s, (t.children || [])[c]), {
|
|
245
245
|
getParent: () => e
|
|
246
246
|
})
|
|
247
|
-
),
|
|
248
|
-
const [s, c] =
|
|
247
|
+
), Ve = (e, t) => {
|
|
248
|
+
const [s, c] = ge(
|
|
249
249
|
e,
|
|
250
250
|
t
|
|
251
251
|
);
|
|
@@ -253,39 +253,39 @@ const B = () => {
|
|
|
253
253
|
const r = n.el;
|
|
254
254
|
r != null && r.parentNode && r.parentNode.removeChild(r);
|
|
255
255
|
}), s;
|
|
256
|
-
},
|
|
256
|
+
}, ge = (e, t) => {
|
|
257
257
|
const s = [...e.children || []], c = [...t.children || []];
|
|
258
258
|
return [s.map((r) => {
|
|
259
|
-
const o =
|
|
259
|
+
const o = me(r, c), l = F(r, o);
|
|
260
260
|
return o && c.splice(c.indexOf(o), 1), l.getParent = () => e, l;
|
|
261
261
|
}), c];
|
|
262
|
-
},
|
|
262
|
+
}, me = (e, t) => t.find(
|
|
263
263
|
(s) => i(s) === i(e)
|
|
264
264
|
);
|
|
265
265
|
let P = [], M = !1;
|
|
266
|
-
const
|
|
266
|
+
const ce = (e, t) => {
|
|
267
267
|
u.get(e).up = () => {
|
|
268
268
|
P.push({
|
|
269
269
|
compKey: e,
|
|
270
270
|
exec: t
|
|
271
|
-
}), M || (M = !0, queueMicrotask(
|
|
271
|
+
}), M || (M = !0, queueMicrotask(We));
|
|
272
272
|
};
|
|
273
|
-
},
|
|
273
|
+
}, we = (e) => () => {
|
|
274
274
|
var c;
|
|
275
275
|
const t = (c = u.get(e)) == null ? void 0 : c.up;
|
|
276
276
|
let s = !1;
|
|
277
277
|
return t && (t(), s = !0), s;
|
|
278
|
-
},
|
|
278
|
+
}, ne = (e, t) => {
|
|
279
279
|
(e.children || []).forEach((s) => {
|
|
280
280
|
const c = s.compKey;
|
|
281
|
-
c && t.push(c),
|
|
281
|
+
c && t.push(c), ne(s, t);
|
|
282
282
|
});
|
|
283
|
-
},
|
|
283
|
+
}, We = () => {
|
|
284
284
|
let e = [];
|
|
285
285
|
P.forEach((c) => {
|
|
286
286
|
var r, o;
|
|
287
287
|
const n = (o = (r = u.get(c.compKey)) == null ? void 0 : r.vd) == null ? void 0 : o.value;
|
|
288
|
-
n &&
|
|
288
|
+
n && ne(n, e);
|
|
289
289
|
});
|
|
290
290
|
const t = [], s = P.reduce((c, n) => {
|
|
291
291
|
const { compKey: r } = n;
|
|
@@ -296,66 +296,66 @@ const te = (e, t) => {
|
|
|
296
296
|
c && c.exec();
|
|
297
297
|
}
|
|
298
298
|
P = [], M = !1;
|
|
299
|
-
},
|
|
300
|
-
u.get(E()).upR.push(() =>
|
|
301
|
-
},
|
|
299
|
+
}, ut = (e, t = () => []) => {
|
|
300
|
+
u.get(E()).upR.push(() => G(e, t)), G(e, t);
|
|
301
|
+
}, De = () => {
|
|
302
302
|
var t;
|
|
303
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
313
|
A.value = !0;
|
|
314
|
-
const n =
|
|
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
|
-
A.value = !1,
|
|
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,11 +364,11 @@ const te = (e, t) => {
|
|
|
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 =
|
|
371
|
+
const c = ue(e, t, s);
|
|
372
372
|
return A.value ? c : c.resolve();
|
|
373
373
|
}
|
|
374
374
|
return {
|
|
@@ -377,29 +377,29 @@ const te = (e, t) => {
|
|
|
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
|