lithent 1.17.3 → 1.18.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
@@ -90,14 +90,14 @@ pnpm add lithent
90
90
 
91
91
  #### Or Use CDN
92
92
 
93
- * UMD : https://cdn.jsdelivr.net/npm/lithent@1.17.2/dist/lithent.umd.js
94
- * UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.17.2/helper/dist/lithentHelper.umd.js
95
- * UMD-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.17.2/ftags/dist/lithentFTags.umd.js
96
- * UMD-TAG: https://cdn.jsdelivr.net/npm/lithent@1.17.2/tag/dist/lithentTag.umd.js
97
- * ESM : https://cdn.jsdelivr.net/npm/lithent@1.17.2/dist/lithent.mjs
98
- * ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.17.2/helper/dist/lithentHelper.mjs
99
- * ESM-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.17.2/ftags/dist/lithentFTags.mjs
100
- * ESM-TAG: https://cdn.jsdelivr.net/npm/lithent@1.17.2/tag/dist/lithentTag.mjs
93
+ * UMD : https://cdn.jsdelivr.net/npm/lithent@1.18.0/dist/lithent.umd.js
94
+ * UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.18.0/helper/dist/lithentHelper.umd.js
95
+ * UMD-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.18.0/ftags/dist/lithentFTags.umd.js
96
+ * UMD-TAG: https://cdn.jsdelivr.net/npm/lithent@1.18.0/tag/dist/lithentTag.umd.js
97
+ * ESM : https://cdn.jsdelivr.net/npm/lithent@1.18.0/dist/lithent.mjs
98
+ * ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.18.0/helper/dist/lithentHelper.mjs
99
+ * ESM-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.18.0/ftags/dist/lithentFTags.mjs
100
+ * ESM-TAG: https://cdn.jsdelivr.net/npm/lithent@1.18.0/tag/dist/lithentTag.mjs
101
101
 
102
102
 
103
103
  It's easier to use lithent with JSX or HTM.
@@ -122,9 +122,9 @@ import { fTags, fFragment, fMount } from 'lithent/ftags';
122
122
  const { section, div, p, br, strong } = fTags;
123
123
 
124
124
  /* UMD
125
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.17.2/dist/lithent.umd.js"></script>
126
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.17.2/helper/dist/lithentHelper.umd.js"></script>
127
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.17.2/ftags/dist/lithentFTags.umd.js"></script>
125
+ <script src="https://cdn.jsdelivr.net/npm/lithent@1.18.0/dist/lithent.umd.js"></script>
126
+ <script src="https://cdn.jsdelivr.net/npm/lithent@1.18.0/helper/dist/lithentHelper.umd.js"></script>
127
+ <script src="https://cdn.jsdelivr.net/npm/lithent@1.18.0/ftags/dist/lithentFTags.umd.js"></script>
128
128
 
129
129
  const { render } = lithent;
130
130
  const { fTags, fMount, fFragment } = lithentFTags;
@@ -197,10 +197,10 @@ const destroy = render(lTag`<${Component} />`, document.getElementById('root'),
197
197
  #### With UMD
198
198
 
199
199
  ```html
200
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.17.2/dist/lithent.umd.js"></script>
201
- <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.17.2/helper/dist/lithentHelper.umd.js"></script-->
202
- <script src="https://cdn.jsdelivr.net/npm/lithent@1.17.2/tag/dist/lithentTag.umd.js"></script>
203
- <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.17.2/ftags/dist/lithentFTags.umd.js"></script-->
200
+ <script src="https://cdn.jsdelivr.net/npm/lithent@1.18.0/dist/lithent.umd.js"></script>
201
+ <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.18.0/helper/dist/lithentHelper.umd.js"></script-->
202
+ <script src="https://cdn.jsdelivr.net/npm/lithent@1.18.0/tag/dist/lithentTag.umd.js"></script>
203
+ <!--script src="https://cdn.jsdelivr.net/npm/lithent@1.18.0/ftags/dist/lithentFTags.umd.js"></script-->
204
204
 
205
205
  <div id="root"></div>
206
206
 
package/dist/lithent.mjs CHANGED
@@ -1,4 +1,4 @@
1
- const R = (e) => typeof e == "object" && !("resolve" in e), a = (e, t) => R(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) => {
1
+ const R = (e) => typeof e == "object" && !("resolve" in e), N = (e, t) => R(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
3
  return R(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
  }, ie = (e, t) => {
@@ -10,7 +10,7 @@ const R = (e) => typeof e == "object" && !("resolve" in e), a = (e, t) => R(e) &
10
10
  }, o = (e) => {
11
11
  var t, s;
12
12
  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);
13
- }, C = (e) => e && ["fragment", "loop"].includes(e), T = (e) => typeof e == "function" && !g(e) || typeof e == "object" && "resolve" in e, g = (e) => typeof e == "function" && e === J, m = (e) => R(e) && !e.type, E = (e) => e != null, Y = (e, t) => e === "style" && typeof t == "object", ve = (e, t) => e === "ref" && typeof t == "object", Ce = (e, t) => {
13
+ }, v = (e) => e && ["fragment", "loop"].includes(e), T = (e) => typeof e == "function" && !g(e) || typeof e == "object" && "resolve" in e, g = (e) => typeof e == "function" && e === J, m = (e) => R(e) && !e.type, E = (e) => e != null, Y = (e, t) => e === "style" && typeof t == "object", Ce = (e, t) => e === "ref" && typeof t == "object", ve = (e, t) => {
14
14
  const s = Object.getOwnPropertyDescriptor(
15
15
  e.constructor.prototype,
16
16
  t
@@ -18,7 +18,7 @@ const R = (e) => typeof e == "object" && !("resolve" in e), a = (e, t) => R(e) &
18
18
  return s && s.get && s.set;
19
19
  }, Re = (e) => {
20
20
  let t = "et";
21
- return T(e) ? t = "c" : a(e, "fragment") ? t = "f" : a(e, "element") ? t = "e" : a(e, "loop") ? t = "l" : a(e, "text") ? t = "t" : m(e) && (t = "et"), t;
21
+ return T(e) ? t = "c" : N(e, "fragment") ? t = "f" : N(e, "element") ? t = "e" : N(e, "loop") ? t = "l" : N(e, "text") ? t = "t" : m(e) && (t = "et"), t;
22
22
  }, ke = {
23
23
  c: pe,
24
24
  l: ye,
@@ -26,7 +26,7 @@ const R = (e) => typeof e == "object" && !("resolve" in e), a = (e, t) => R(e) &
26
26
  e: ie,
27
27
  f: he,
28
28
  et: X
29
- }, v = Symbol.for("lithentWDomSymbol"), k = { value: "" }, S = { value: {} }, O = { value: !1 }, f = /* @__PURE__ */ new WeakMap(), Ee = (e) => {
29
+ }, C = Symbol.for("lithentWDomSymbol"), k = { value: "" }, S = { value: {} }, O = { value: !1 }, f = /* @__PURE__ */ new WeakMap(), Ee = (e) => {
30
30
  f.set(e, {
31
31
  vd: { value: null },
32
32
  up: () => {
@@ -38,40 +38,40 @@ const R = (e) => typeof e == "object" && !("resolve" in e), a = (e, t) => R(e) &
38
38
  mts: [],
39
39
  umts: []
40
40
  });
41
- }, x = () => S.value, Z = (e, t) => f.get(e) ? f.get(e)[t] : null, Pe = (e) => S.value = e, Se = (e) => {
41
+ }, a = () => S.value, Z = (e, t) => f.get(e) ? f.get(e)[t] : null, Pe = (e) => S.value = e, Se = (e) => {
42
42
  S.value = e, Ee(e);
43
- }, i = (e) => e.getParent && e.getParent(), P = Object.entries, w = Object.keys, b = Object.assign, lt = (e) => typeof e == "object" && !Array.isArray(e) && !Object.getOwnPropertySymbols(e).includes(v), xe = (e) => {
44
- f.get(x()).umts.push(e);
43
+ }, y = (e) => e.getParent && e.getParent(), P = Object.entries, w = Object.keys, b = Object.assign, lt = (e) => typeof e == "object" && !Array.isArray(e) && !Object.getOwnPropertySymbols(e).includes(C), ae = (e) => {
44
+ f.get(a()).umts.push(e);
45
45
  }, U = (e) => {
46
46
  const { compKey: t } = e;
47
- t && Ne(t), W(e);
47
+ t && xe(t), W(e);
48
48
  }, W = (e) => {
49
49
  (e.children || []).forEach((t) => {
50
50
  t.compKey ? U(t) : W(t);
51
51
  });
52
- }, Ne = (e) => {
52
+ }, xe = (e) => {
53
53
  const t = f.get(e);
54
54
  t && (t.umts.forEach((s) => s()), t.umts = [], f.delete(e));
55
55
  };
56
56
  let Q = [];
57
57
  const I = () => {
58
58
  Q.forEach((e) => Te(e)), Q = [];
59
- }, ae = (e) => {
59
+ }, Ne = (e) => {
60
60
  e.compKey && Q.push(e);
61
61
  }, ft = (e) => {
62
62
  var t;
63
- return (((t = f.get(x())) == null ? void 0 : t.mts) || []).push(e);
63
+ return (((t = f.get(a())) == null ? void 0 : t.mts) || []).push(e);
64
64
  }, Te = (e) => {
65
65
  const { compKey: t } = e;
66
66
  if (t) {
67
67
  const s = f.get(t), c = s == null ? void 0 : s.mts, r = s == null ? void 0 : s.upS;
68
68
  S.value = t, r && (r.value = 0), c && (s.mts = [], c.forEach((n) => {
69
69
  const u = n();
70
- u && xe(u);
70
+ u && ae(u);
71
71
  }));
72
72
  }
73
73
  }, H = (e, t = () => []) => {
74
- const s = f.get(x()), { upD: c, upS: r } = s, n = c[r.value];
74
+ const s = f.get(a()), { upD: c, upS: r } = s, n = c[r.value];
75
75
  if (n && Ue(n, t())) {
76
76
  const u = e();
77
77
  u && s.upCB.push(u);
@@ -111,7 +111,7 @@ const I = () => {
111
111
  }, $ = (e) => {
112
112
  e.oldProps && e.el && ue(e.oldProps, e.el), te(
113
113
  e,
114
- A(i(e))
114
+ A(y(e))
115
115
  );
116
116
  }, te = (e, t) => {
117
117
  var s, c;
@@ -125,36 +125,36 @@ const I = () => {
125
125
  }, ce = (e) => {
126
126
  $(e), G(e);
127
127
  }, Ae = (e) => {
128
- if (B(e), i(e).needRerender !== "CNSU") {
128
+ if (B(e), y(e).needRerender !== "CNSU") {
129
129
  const s = ne(e);
130
130
  G(e, s);
131
131
  }
132
132
  }, G = (e, t) => {
133
133
  t || (t = L(e));
134
- const s = i(e);
134
+ const s = y(e);
135
135
  if (s.type) {
136
- const c = A(s), n = s.type === "loop" && s.needRerender && s.needRerender !== "CNSU" ? j(s, i(s)) : j(e, s);
136
+ const c = A(s), n = s.type === "loop" && s.needRerender && s.needRerender !== "CNSU" ? j(s, y(s)) : j(e, s);
137
137
  t && c && (e.tag !== "portal" && (n ? c.insertBefore(t, n) : c.appendChild(t)), I());
138
138
  }
139
- }, ne = (e) => C(e.type) ? ((e == null ? void 0 : e.children) || []).reduce((t, s) => {
139
+ }, ne = (e) => v(e.type) ? ((e == null ? void 0 : e.children) || []).reduce((t, s) => {
140
140
  const c = ne(s);
141
141
  return c && t.appendChild(c), t;
142
142
  }, z()) : e.el, j = (e, t) => {
143
143
  const s = t.children || [], r = s.indexOf(e) + 1, n = s.slice(r), u = re(n), l = t.type || "";
144
144
  if (u)
145
145
  return u;
146
- if (!t.isRoot && C(l))
147
- return j(t, i(t));
148
- if (t.isRoot && C(l) && t.afterElement)
146
+ if (!t.isRoot && v(l))
147
+ return j(t, y(t));
148
+ if (t.isRoot && v(l) && t.afterElement)
149
149
  return t.afterElement;
150
150
  }, re = (e) => e.reduce(
151
151
  (t, s) => {
152
- const c = s.type, r = s.el, n = c && C(c);
152
+ const c = s.type, r = s.el, n = c && v(c);
153
153
  return t || (n ? re(s.children || []) : r && r.nodeType !== 11 ? r : t);
154
154
  },
155
155
  void 0
156
156
  ), Me = (e) => {
157
- const t = i(e), s = e.el;
157
+ const t = y(e), s = e.el;
158
158
  if (t.type && s)
159
159
  if (s.nodeType === 11)
160
160
  ce(e);
@@ -196,12 +196,12 @@ const I = () => {
196
196
  u,
197
197
  Y(n, r.style) ? r.style : {},
198
198
  t
199
- ) : ve(n, u) ? u.value = t : n.match(/^on/) ? K(
199
+ ) : Ce(n, u) ? u.value = t : n.match(/^on/) ? K(
200
200
  t,
201
201
  n,
202
202
  u,
203
203
  r[n]
204
- ) : n && (n !== "type" && Ce(t, n) ? t[n] = u : Qe(
204
+ ) : n && (n !== "type" && ve(t, n) ? t[n] = u : Qe(
205
205
  Fe(n),
206
206
  t,
207
207
  u
@@ -213,8 +213,8 @@ const I = () => {
213
213
  k.value && e !== "xmlns" ? t.setAttributeNS(null, e, s) : t.setAttribute(e, s);
214
214
  }, L = (e, t) => {
215
215
  let s;
216
- const { type: c, tag: r, text: n, props: u, children: l = [] } = e, p = C(c);
217
- return r === "svg" && (k.value = String(u == null ? void 0 : u.xmlns)), t ? s = e.el : (p ? s = z() : c === "element" && r ? r === "portal" && (u != null && u.portal) ? s = u.portal : s = k.value ? document.createElementNS(k.value, r) : V(r) : c === "text" && E(n) ? s = document.createTextNode(String(n)) : s = V("e"), e.el = s), je(l, s, t), le(u, s, null, t), ae(e), r === "svg" && (k.value = ""), s;
216
+ const { type: c, tag: r, text: n, props: u, children: l = [] } = e, h = v(c);
217
+ return r === "svg" && (k.value = String(u == null ? void 0 : u.xmlns)), t ? s = e.el : (h ? s = z() : c === "element" && r ? r === "portal" && (u != null && u.portal) ? s = u.portal : s = k.value ? document.createElementNS(k.value, r) : V(r) : c === "text" && E(n) ? s = document.createTextNode(String(n)) : s = V("e"), e.el = s), je(l, s, t), le(u, s, null, t), Ne(e), r === "svg" && (k.value = ""), s;
218
218
  }, je = (e, t, s) => {
219
219
  const c = e.reduce(
220
220
  (r, n) => {
@@ -238,8 +238,8 @@ const I = () => {
238
238
  ([n]) => r[n] = ""
239
239
  ));
240
240
  }, A = (e) => {
241
- const t = C(e.type);
242
- return e.isRoot && t ? e.wrapElement : t ? A(i(e)) : e.el;
241
+ const t = v(e.type);
242
+ return e.isRoot && t ? e.wrapElement : t ? A(y(e)) : e.el;
243
243
  }, M = (e, t) => qe(
244
244
  e,
245
245
  ke[Re(e)](e, t),
@@ -254,9 +254,9 @@ const I = () => {
254
254
  }, _e = (e, t, s) => {
255
255
  s !== "A" && t && (e.el = t.el), s && ["D", "R", "SR"].includes(s) && (t && (U(t), F(t)), e.oldChildren = t == null ? void 0 : t.children), e.oldProps = t == null ? void 0 : t.props;
256
256
  }, Ie = (e, t, s) => {
257
- const c = s && s.type, r = m(e), n = e.isRoot, u = s && i(s), l = !n && (u == null ? void 0 : u.type), p = o(e), h = l === "loop" && E(p), y = e.type === "text" && t && e.text === (s == null ? void 0 : s.text), N = e === s;
257
+ const c = s && s.type, r = m(e), n = e.isRoot, u = s && y(s), l = !n && (u == null ? void 0 : u.type), h = o(e), p = l === "loop" && E(h), i = e.type === "text" && t && e.text === (s == null ? void 0 : s.text), x = e === s;
258
258
  let d;
259
- return r ? d = "D" : y || N ? d = "N" : c ? t ? d = h ? "SU" : "U" : d = h ? "SR" : "R" : d = "A", e.type === "loop" && d === "U" && s && ze(e, s) && (d = "CNSU"), d;
259
+ return r ? d = "D" : i || x ? d = "N" : c ? t ? d = p ? "SU" : "U" : d = p ? "SR" : "R" : d = "A", e.type === "loop" && d === "U" && s && ze(e, s) && (d = "CNSU"), d;
260
260
  }, ze = (e, t) => {
261
261
  const s = [...(t == null ? void 0 : t.children) || []], c = [...(e == null ? void 0 : e.children) || []].filter(
262
262
  (u) => s.find((l) => o(u) === o(l))
@@ -312,33 +312,33 @@ const me = (e, t) => {
312
312
  e();
313
313
  }), q.clear(), _ = !1;
314
314
  }, dt = (e, t = () => []) => {
315
- f.get(x()).upR.push(() => H(e, t)), H(e, t);
315
+ f.get(a()).upR.push(() => H(e, t)), H(e, t);
316
316
  }, De = () => {
317
317
  var t;
318
- const e = (t = f.get(x())) == null ? void 0 : t.upR;
318
+ const e = (t = f.get(a())) == null ? void 0 : t.upR;
319
319
  e != null && e.length && e.forEach((s) => s());
320
320
  }, J = (e, ...t) => ({
321
321
  type: "fragment",
322
- [v]: !0,
322
+ [C]: !0,
323
323
  children: t
324
324
  }), et = (e, t, ...s) => {
325
325
  const c = { value: void 0 }, r = t || {}, n = de(c, s), u = rt(e, r, n);
326
326
  return T(u) || (c.value = u), u;
327
327
  }, pt = (e, t) => et("portal", { portal: t }, e), ht = (e) => (t, s) => e, tt = (e, t, s, c) => {
328
- var y;
328
+ var i;
329
329
  if (c.isLegacy)
330
330
  return;
331
331
  O.value = !0;
332
- const r = fe(e, t, s), n = M(r, c), { isRoot: u, getParent: l, wrapElement: p, afterElement: h } = c;
332
+ const r = fe(e, t, s), n = M(r, c), { isRoot: u, getParent: l, wrapElement: h, afterElement: p } = c;
333
333
  if (n.getParent = l, !u && l) {
334
- const N = ((y = l()) == null ? void 0 : y.children) || [], d = N.indexOf(c);
335
- N.splice(d, 1, n);
334
+ const x = ((i = l()) == null ? void 0 : i.children) || [], d = x.indexOf(c);
335
+ x.splice(d, 1, n);
336
336
  } else
337
- n.isRoot = !0, n.wrapElement = p, n.afterElement = h;
337
+ n.isRoot = !0, n.wrapElement = h, n.afterElement = p;
338
338
  O.value = !1, ee(n);
339
339
  }, fe = (e, t, s) => ({ tagName: e.name, ctor: e, props: t, children: s, resolve: (u = t) => {
340
340
  Se(u);
341
- const p = e(t, s)(we(u), t, s);
341
+ const l = e(t, s), p = (typeof l == "function" ? l : () => () => l)(we(u), t, s);
342
342
  return st(
343
343
  p,
344
344
  u,
@@ -348,9 +348,9 @@ const me = (e, t) => {
348
348
  );
349
349
  } }), st = (e, t, s, c, r) => {
350
350
  let n = e, u = e(c);
351
- u.reRender && (n = (p) => {
352
- const h = e(p), y = J({}, h);
353
- return h.getParent = () => y, y;
351
+ u.reRender && (n = (h) => {
352
+ const p = e(h), i = J({}, p);
353
+ return p.getParent = () => i, i;
354
354
  }, u = n(c));
355
355
  const l = ct(
356
356
  n,
@@ -388,7 +388,7 @@ const me = (e, t) => {
388
388
  }
389
389
  return {
390
390
  type: "element",
391
- [v]: !0,
391
+ [C]: !0,
392
392
  tag: e,
393
393
  props: t,
394
394
  children: s
@@ -397,16 +397,16 @@ const me = (e, t) => {
397
397
  (s) => b(ut(s), { getParent: () => e.value })
398
398
  ), ut = (e) => {
399
399
  if (e == null || e === !1)
400
- return { type: null, [v]: !0 };
400
+ return { type: null, [C]: !0 };
401
401
  if (Array.isArray(e)) {
402
402
  const t = { value: void 0 }, s = de(t, e), c = {
403
403
  type: "loop",
404
- [v]: !0,
404
+ [C]: !0,
405
405
  children: s
406
406
  };
407
407
  return t.value = c, c;
408
408
  } else if (typeof e == "string" || typeof e == "number")
409
- return { type: "text", [v]: !0, text: e };
409
+ return { type: "text", [C]: !0, text: e };
410
410
  return e;
411
411
  }, it = (e) => ({ value: e }), yt = () => Promise.resolve();
412
412
  export {