lithent 1.0.7 → 1.1.0

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 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 │ gzip: 3.91 kB)`
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 domes to specific parts of a pre-drawn SSR page.
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.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
63
+ * UMD : https://cdn.jsdelivr.net/npm/lithent@1.1.0/dist/lithent.umd.js
64
+ * UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.1.0/helper/dist/lithentHelper.umd.js
65
+ * ESM : https://cdn.jsdelivr.net/npm/lithent@1.1.0/dist/lithent.mjs
66
+ * ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.1.0/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.7/dist/lithent.umd.js"></script>
125
- <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.0.7/helper/dist/lithentHelper.umd.js"></script-->
124
+ <script src="https://cdn.jsdelivr.net/npm/lithent@1.1.0/dist/lithent.umd.js"></script>
125
+ <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.1.0/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 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) => {
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 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
- }, pe = (e, t) => {
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 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" && a(i((e.children || [])[0])) && a(i((t.children || [])[0]))), i = (e) => {
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
- }, 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) => {
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" : H(e) && (t = "et"), t;
13
- }, ke = {
14
- c: fe,
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: pe,
18
- f: de,
17
+ e: ie,
18
+ f: he,
19
19
  et: U
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) => {
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], Re = (e) => R.value = e, Ee = (e) => {
33
- R.value = e, Ce(e);
34
- }, xe = (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
35
  u.get(E()).umts.push(e);
36
36
  }, Q = (e) => {
37
37
  const { compKey: t } = e;
38
- t && Pe(t), V(e);
39
- }, V = (e) => {
38
+ t && Se(t), K(e);
39
+ }, K = (e) => {
40
40
  (e.children || []).forEach((t) => {
41
- t.compKey ? Q(t) : V(t);
41
+ t.compKey ? Q(t) : K(t);
42
42
  });
43
- }, Pe = (e) => {
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) => Se(e)), O = [];
50
- }, Te = (e) => {
49
+ O.forEach((e) => be(e)), O = [];
50
+ }, Ne = (e) => {
51
51
  e.compKey && O.push(e);
52
- }, ct = (e) => u.get(E()).mts.push(e), Se = (e) => {
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 && xe(o);
58
+ o && Te(o);
59
59
  }));
60
60
  }
61
- }, X = (e, t = () => []) => {
61
+ }, G = (e, t = () => []) => {
62
62
  const s = u.get(E()), { upD: c, upS: n } = s, r = c[n.value];
63
- if (r && be(r, t())) {
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
- }, Ne = (e) => {
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
- }, be = (e, t) => !e.length && !e.length ? !0 : e.some((s, c) => s !== t[c]), nt = (e, t, s) => {
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), j(n), Fe(n));
80
+ n && (Q(n), I(n), Ae(n));
81
81
  };
82
- }, K = (e) => {
82
+ }, m = (e) => {
83
83
  const { needRerender: t } = e;
84
84
  t && t !== "N" && {
85
85
  A: q,
86
- D: I,
87
- R: Ae,
88
- U: Oe,
89
- SR: w,
90
- SU: Ue
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.oldProps && e.el && D(e.oldProps, e.el), g(
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
- }, g = (e, t) => {
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 && m(e, t), delete e.el);
106
- }, m = (e, t) => {
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 && m(s, t);
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
- }, w = (e) => {
112
- I(e), q(e);
113
- }, Ue = (e) => {
114
- I(e), q(e, e.el);
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 = W(r), l = t.type || "";
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 && v(l))
126
+ if (!t.isRoot && y(l))
127
127
  return L(t, p(t));
128
- if (t.isRoot && v(l) && t.afterElement)
128
+ if (t.isRoot && y(l) && t.afterElement)
129
129
  return t.afterElement;
130
- }, W = (e) => e.reduce(
130
+ }, ee = (e) => e.reduce(
131
131
  (t, s) => {
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);
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
- ), Ae = (e) => {
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
- w(e);
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
- }, D = (e, t) => {
146
- k(e || {}).forEach(([s, c]) => {
145
+ }, te = (e, t) => {
146
+ a(e || {}).forEach(([s, c]) => {
147
147
  s.match(/^on/) && t.removeEventListener(
148
- J(s),
148
+ V(s),
149
149
  c
150
150
  );
151
151
  });
152
- }, Oe = (e) => {
152
+ }, Me = (e) => {
153
153
  var s;
154
154
  const t = e.el;
155
155
  if (e.type === "text") {
156
- Le(e);
156
+ Qe(e);
157
157
  return;
158
158
  }
159
159
  if (t) {
160
160
  const { oldProps: c, props: n } = e;
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) || ""));
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) => K(c)), Ne(e);
164
- }, Le = (e) => {
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
- }, ee = (e, t, s) => {
167
+ }, se = (e, t, s) => {
168
168
  const c = { ...s };
169
- k(e || {}).forEach(([n, r]) => {
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) ? je(
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
- ) : he(n, r) ? r.value = t : n.match(/^on/) ? Be(
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
- ) : 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(
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
- G(n),
182
+ X(n),
183
183
  r
184
184
  ) : t.setAttribute(
185
- G(n),
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
- }, Me = (e) => {
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 = 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) => {
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
- new DocumentFragment()
201
+ g()
202
202
  );
203
203
  t && s.hasChildNodes() && t.appendChild(s);
204
- }, Be = (e, t, s, c) => {
205
- const n = J(t);
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
- }, je = (e, t, s) => {
207
+ }, qe = (e, t, s) => {
208
208
  const c = { ...t }, n = s == null ? void 0 : s.style;
209
- n && (k(e).forEach(([r, o]) => {
209
+ n && (a(e).forEach(([r, o]) => {
210
210
  n[r] = o, delete c[r];
211
- }), k(c).forEach(
211
+ }), a(c).forEach(
212
212
  ([r]) => n[r] = ""
213
213
  ));
214
214
  }, b = (e) => {
215
- const t = v(e.type);
215
+ const t = y(e.type);
216
216
  return e.isRoot && t ? e.wrapElement : t ? b(p(e)) : e.el;
217
- }, F = (e, t) => Ie(
217
+ }, F = (e, t) => _e(
218
218
  e,
219
- ke[ae(e)](e, t),
219
+ Re[ke(e)](e, t),
220
220
  t
221
- ), Ie = (e, t, s) => {
222
- const c = $e(e, t, s), n = [
221
+ ), _e = (e, t, s) => {
222
+ const c = Je(e, t, s), n = [
223
223
  c,
224
224
  t,
225
225
  s
226
- ], r = _e(...n);
227
- return c.children = He(...n), c.needRerender = r, qe(c, s, r), c;
228
- }, qe = (e, t, s) => {
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;
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);
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 && 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(
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
- ), Ye = (e, t) => e.type === "loop" && a(i((e.children || [])[0])) ? Ze(e, t) : (e.children || []).map(
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
- ), Ze = (e, t) => {
248
- const [s, c] = Ve(
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
- }, Ve = (e, t) => {
256
+ }, ge = (e, t) => {
257
257
  const s = [...e.children || []], c = [...t.children || []];
258
258
  return [s.map((r) => {
259
- const o = Ke(r, c), l = F(r, 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
- }, Ke = (e, t) => t.find(
262
+ }, me = (e, t) => t.find(
263
263
  (s) => i(s) === i(e)
264
264
  );
265
265
  let P = [], M = !1;
266
- const te = (e, t) => {
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(me));
271
+ }), M || (M = !0, queueMicrotask(We));
272
272
  };
273
- }, ge = (e) => () => {
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
- }, se = (e, t) => {
278
+ }, ne = (e, t) => {
279
279
  (e.children || []).forEach((s) => {
280
280
  const c = s.compKey;
281
- c && t.push(c), se(s, t);
281
+ c && t.push(c), ne(s, t);
282
282
  });
283
- }, me = () => {
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 && se(n, e);
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
- }, rt = (e, t = () => []) => {
300
- u.get(E()).upR.push(() => X(e, t)), X(e, t);
301
- }, we = () => {
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
- }, ce = (e, ...t) => ({
305
+ }, re = (e, ...t) => ({
306
306
  type: "fragment",
307
307
  children: t
308
- }), ot = (e, t, ...s) => {
309
- const c = { value: void 0 }, n = t || {}, r = ue(c, s), o = tt(e, n, 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
- }, ut = (e) => (t, s) => e, ne = (e, t, s, c) => {
311
+ }, ft = (e) => (t, s) => e, oe = (e, t, s, c) => {
312
312
  var f;
313
313
  A.value = !0;
314
- const n = re(e, t, s), r = F(n, c), { isRoot: o, getParent: l, wrapElement: h, afterElement: d } = c;
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) || [], le = _.indexOf(c);
317
- _.splice(le, 1, r);
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, K(r);
321
- }, re = (e, t, s) => ({ tagName: e.name, ctor: e, props: t, children: s, resolve: (o = t) => {
322
- Ee(o);
323
- const h = e(t, s)(ge(o), t, s), d = We(
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 te(
330
+ return ce(
331
331
  o,
332
- () => ne(e, t, s, f)
332
+ () => oe(e, t, s, f)
333
333
  ), Z(o, "vd").value = d, d;
334
- } }), We = (e, t, s, c, n) => {
334
+ } }), et = (e, t, s, c, n) => {
335
335
  const r = e(c);
336
336
  if (r.reRender)
337
337
  throw new Error(
338
- 'The root of a component must not be a component, use "Fragment"'
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 oe(
340
+ return le(
341
341
  r,
342
342
  t,
343
343
  s,
344
344
  c,
345
345
  n,
346
- De(e, t, s, c, n)
346
+ tt(e, t, s, c, n)
347
347
  ), r;
348
- }, De = (e, t, s, c, n) => {
349
- const r = () => et(e, t, s, c, n, r);
348
+ }, tt = (e, t, s, c, n) => {
349
+ const r = () => st(e, t, s, c, n, r);
350
350
  return r;
351
- }, et = (e, t, s, c, n, r) => {
352
- Re(t), we();
351
+ }, st = (e, t, s, c, n, r) => {
352
+ xe(t), De();
353
353
  const o = e(c);
354
- return te(
354
+ return ce(
355
355
  t,
356
- () => ne(s, c, n, o)
357
- ), oe(o, t, s, c, n, r), Z(t, "vd").value = o, o;
358
- }, oe = (e, t, s, c, n, r) => {
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
- }, tt = (e, t, s) => {
368
- if ($(e))
369
- return ce(t, ...s);
367
+ }, ct = (e, t, s) => {
368
+ if (H(e))
369
+ return re(t, ...s);
370
370
  if (T(e)) {
371
- const c = re(e, t, s);
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
- }, ue = (e, t) => t.map(
381
- (s) => S(st(s), { getParent: () => e.value })
382
- ), st = (e) => {
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: ue(t, e)
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
- }, lt = (e) => ({ value: e }), ft = () => Promise.resolve();
394
+ }, dt = (e) => ({ value: e }), pt = () => Promise.resolve();
395
395
  export {
396
- ce as Fragment,
397
- ot as h,
398
- ut as mount,
399
- ct as mountCallback,
400
- ft as nextTick,
401
- lt as ref,
402
- nt as render,
403
- rt as updateCallback
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