lithent 1.20.0 → 1.20.2
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 +15 -79
- package/dist/lithent.mjs +121 -119
- package/dist/lithent.mjs.map +1 -1
- package/dist/lithent.umd.js +1 -1
- package/dist/lithent.umd.js.map +1 -1
- package/examples/dist/assets/index-Ch3C2eh3.js +2 -0
- package/examples/dist/assets/index-Ch3C2eh3.js.map +1 -0
- package/examples/dist/index.html +1 -1
- package/package.json +39 -36
- package/src/render.ts +5 -4
- package/src/tests/core-styleUpdate.tsx +49 -0
- package/examples/dist/assets/index-BKrlmwUB.js +0 -2
- package/examples/dist/assets/index-BKrlmwUB.js.map +0 -1
package/README.md
CHANGED
|
@@ -38,8 +38,6 @@ used lightly in a variety of situations.
|
|
|
38
38
|
- [Examples](#examples)
|
|
39
39
|
- [With ESM](#with-esm)
|
|
40
40
|
- [With UMD](#with-umd)
|
|
41
|
-
- [Context API](#context-api)
|
|
42
|
-
- [Multi-value Provider Example](#multi-value-provider-example)
|
|
43
41
|
- [Related Projects](#related-projects)
|
|
44
42
|
- [Develop Guide](#develop-guide)
|
|
45
43
|
- [Test](#test)
|
|
@@ -92,14 +90,14 @@ pnpm add lithent
|
|
|
92
90
|
|
|
93
91
|
#### Or Use CDN
|
|
94
92
|
|
|
95
|
-
* UMD : https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
96
|
-
* UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
97
|
-
* UMD-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
98
|
-
* UMD-TAG: https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
99
|
-
* ESM : https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
100
|
-
* ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
101
|
-
* ESM-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
102
|
-
* ESM-TAG: https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
93
|
+
* UMD : https://cdn.jsdelivr.net/npm/lithent@1.20.2/dist/lithent.umd.js
|
|
94
|
+
* UMD-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.20.2/helper/dist/lithentHelper.umd.js
|
|
95
|
+
* UMD-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.20.2/ftags/dist/lithentFTags.umd.js
|
|
96
|
+
* UMD-TAG: https://cdn.jsdelivr.net/npm/lithent@1.20.2/tag/dist/lithentTag.umd.js
|
|
97
|
+
* ESM : https://cdn.jsdelivr.net/npm/lithent@1.20.2/dist/lithent.mjs
|
|
98
|
+
* ESM-HELPER: https://cdn.jsdelivr.net/npm/lithent@1.20.2/helper/dist/lithentHelper.mjs
|
|
99
|
+
* ESM-FTAGS: https://cdn.jsdelivr.net/npm/lithent@1.20.2/ftags/dist/lithentFTags.mjs
|
|
100
|
+
* ESM-TAG: https://cdn.jsdelivr.net/npm/lithent@1.20.2/tag/dist/lithentTag.mjs
|
|
103
101
|
|
|
104
102
|
|
|
105
103
|
It's easier to use lithent with JSX or HTM.
|
|
@@ -124,9 +122,9 @@ import { fTags, fFragment, fMount } from 'lithent/ftags';
|
|
|
124
122
|
const { section, div, p, br, strong } = fTags;
|
|
125
123
|
|
|
126
124
|
/* UMD
|
|
127
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
128
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
129
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
125
|
+
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/dist/lithent.umd.js"></script>
|
|
126
|
+
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/helper/dist/lithentHelper.umd.js"></script>
|
|
127
|
+
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/ftags/dist/lithentFTags.umd.js"></script>
|
|
130
128
|
|
|
131
129
|
const { render } = lithent;
|
|
132
130
|
const { fTags, fMount, fFragment } = lithentFTags;
|
|
@@ -199,10 +197,10 @@ const destroy = render(lTag`<${Component} />`, document.getElementById('root'),
|
|
|
199
197
|
#### With UMD
|
|
200
198
|
|
|
201
199
|
```html
|
|
202
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
203
|
-
<!--script src="https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
204
|
-
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
205
|
-
<!--script src="https://cdn.jsdelivr.net/npm/lithent@1.20.
|
|
200
|
+
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/dist/lithent.umd.js"></script>
|
|
201
|
+
<!--script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/helper/dist/lithentHelper.umd.js"></script-->
|
|
202
|
+
<script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/tag/dist/lithentTag.umd.js"></script>
|
|
203
|
+
<!--script src="https://cdn.jsdelivr.net/npm/lithent@1.20.2/ftags/dist/lithentFTags.umd.js"></script-->
|
|
206
204
|
|
|
207
205
|
<div id="root"></div>
|
|
208
206
|
|
|
@@ -234,68 +232,6 @@ const destroy = render(lTag`<${Component} />`, document.getElementById('root'),
|
|
|
234
232
|
</script>
|
|
235
233
|
```
|
|
236
234
|
|
|
237
|
-
## Context API
|
|
238
|
-
|
|
239
|
-
Lithent-helper ships a lightweight context system so you can share state without manual prop drilling. Providers stay isolated from consumer renews and you can subscribe to every key or only the slices you need.
|
|
240
|
-
|
|
241
|
-
### Multi-value Provider Example
|
|
242
|
-
|
|
243
|
-
```tsx
|
|
244
|
-
import { h, mount } from 'lithent';
|
|
245
|
-
import { createContext } from 'lithent-helper';
|
|
246
|
-
|
|
247
|
-
type AppState = { user: string; theme: string; count: number };
|
|
248
|
-
|
|
249
|
-
const AppContext = createContext<AppState>();
|
|
250
|
-
const { Provider, contextState, useContext } = AppContext;
|
|
251
|
-
|
|
252
|
-
const AppProvider = mount((_renew, _props, children) => {
|
|
253
|
-
// Provider owns the shared state; consumers cannot trigger its renew directly.
|
|
254
|
-
const user = contextState('Alice');
|
|
255
|
-
const theme = contextState('dark');
|
|
256
|
-
const count = contextState(0);
|
|
257
|
-
|
|
258
|
-
return () => (
|
|
259
|
-
<Provider user={user} theme={theme} count={count}>
|
|
260
|
-
{children}
|
|
261
|
-
</Provider>
|
|
262
|
-
);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
const StatsPanel = mount(renew => {
|
|
266
|
-
// Omitting the subscribe list subscribes to every value exposed by the Provider.
|
|
267
|
-
const ctx = useContext(AppContext, renew);
|
|
268
|
-
return () => (
|
|
269
|
-
<section>
|
|
270
|
-
<p>User: {ctx.user?.value}</p>
|
|
271
|
-
<p>Theme: {ctx.theme?.value}</p>
|
|
272
|
-
<p>Count: {ctx.count?.value}</p>
|
|
273
|
-
<button onClick={() => ctx.count && (ctx.count.value += 1)}>
|
|
274
|
-
Increment
|
|
275
|
-
</button>
|
|
276
|
-
<button onClick={() => ctx.count && (ctx.count.value = 3)}>
|
|
277
|
-
Set count to 3
|
|
278
|
-
</button>
|
|
279
|
-
</section>
|
|
280
|
-
);
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
const ThemeBadge = mount(renew => {
|
|
284
|
-
// Subscribe only to the theme key; user/count updates will not rerender this component.
|
|
285
|
-
const ctx = useContext(AppContext, renew, ['theme']);
|
|
286
|
-
return () => <span>Theme: {ctx.theme?.value}</span>;
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
const App = mount(() => {
|
|
290
|
-
return () => (
|
|
291
|
-
<AppProvider>
|
|
292
|
-
<StatsPanel />
|
|
293
|
-
<ThemeBadge />
|
|
294
|
-
</AppProvider>
|
|
295
|
-
);
|
|
296
|
-
});
|
|
297
|
-
```
|
|
298
|
-
|
|
299
235
|
## Related Projects
|
|
300
236
|
- [htm](https://www.npmjs.com/package/htm) - making **H**yperscript **T**agged **M**arkup possible
|
|
301
237
|
|
package/dist/lithent.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const a = (e) => typeof e == "object" && !("resolve" in e),
|
|
1
|
+
const a = (e) => typeof e == "object" && !("resolve" in e), E = (e, t) => a(e) && e.type === t, he = (e, t) => "ctor" in e ? e.ctor === (t && t.ctor) : e === (t && t.ctor), ae = (e, t) => !!(a(e) && t && t.type === "f" && t.children && t.children.length === (e.children && e.children.length)), ye = (e, t) => !!(a(e) && t && t.type === "e" && t.tag === e.tag && t.children && t.children.length === (e.children && e.children.length)), G = (e, t) => !!(a(e) && t && t.type === e.type), Ce = (e, t) => !!(a(e) && t && t.type === e.type && (k(f((e.children || [])[0])) && k(f((t.children || [])[0])) || t.children && e.children && t.children.length === e.children.length)), f = (e) => e && e.compProps && e.compProps.key || e && e.props && e.props.key, h = (e) => e && ["f", "l"].includes(e), P = (e) => typeof e == "function" && !H(e) || typeof e == "object" && "resolve" in e, H = (e) => typeof e == "function" && e === _, ve = (e) => a(e) && !e.type, k = (e) => e != null, J = (e, t) => e === "style" && typeof t == "object", ke = (e, t) => e === "ref" && typeof t == "object", Re = (e, t) => {
|
|
2
2
|
const n = Object.getOwnPropertyDescriptor(
|
|
3
3
|
e.constructor.prototype,
|
|
4
4
|
t
|
|
5
5
|
);
|
|
6
6
|
return n && n.get && n.set;
|
|
7
|
-
},
|
|
7
|
+
}, Ee = (e) => P(e) ? "c" : E(e, "f") ? "f" : E(e, "e") ? "e" : E(e, "l") ? "l" : E(e, "t") ? "t" : "et", Pe = {
|
|
8
8
|
c: he,
|
|
9
9
|
l: Ce,
|
|
10
10
|
t: G,
|
|
@@ -71,9 +71,9 @@ const Te = (e) => {
|
|
|
71
71
|
}, Ue = (e) => {
|
|
72
72
|
const { compKey: t } = e;
|
|
73
73
|
if (t) {
|
|
74
|
-
const n = u.get(t), c = n && n.mts,
|
|
75
|
-
y.value = t,
|
|
76
|
-
const o =
|
|
74
|
+
const n = u.get(t), c = n && n.mts, s = n && n.upS;
|
|
75
|
+
y.value = t, s && (s.value = 0), c && (n.mts = [], c.forEach((r) => {
|
|
76
|
+
const o = r();
|
|
77
77
|
o && W(o);
|
|
78
78
|
}));
|
|
79
79
|
}
|
|
@@ -87,9 +87,9 @@ const Te = (e) => {
|
|
|
87
87
|
const { compKey: t } = e;
|
|
88
88
|
if (t) {
|
|
89
89
|
const n = u.get(t), c = n && n.wdCB;
|
|
90
|
-
y.value = t, c && c.length > 0 && (n.wdCB = [], c.forEach((
|
|
91
|
-
const
|
|
92
|
-
|
|
90
|
+
y.value = t, c && c.length > 0 && (n.wdCB = [], c.forEach((s) => {
|
|
91
|
+
const r = s();
|
|
92
|
+
r && typeof r == "function" && W(r);
|
|
93
93
|
}));
|
|
94
94
|
}
|
|
95
95
|
}, Y = (e, t = () => []) => {
|
|
@@ -97,23 +97,23 @@ const Te = (e) => {
|
|
|
97
97
|
if (!n) return;
|
|
98
98
|
const c = u.get(n);
|
|
99
99
|
if (!c) return;
|
|
100
|
-
const { upD:
|
|
100
|
+
const { upD: s, upS: r } = c, o = s[r.value], l = t();
|
|
101
101
|
if (o && Le(o, l)) {
|
|
102
|
-
const
|
|
103
|
-
|
|
102
|
+
const p = e();
|
|
103
|
+
p && c.upCB.push(p);
|
|
104
104
|
}
|
|
105
|
-
r
|
|
105
|
+
s[r.value] = l, r.value += 1;
|
|
106
106
|
}, Fe = (e) => {
|
|
107
107
|
const { compKey: t } = e;
|
|
108
108
|
if (t) {
|
|
109
|
-
const n = u.get(t), c = n && n.upCB,
|
|
110
|
-
y.value = t,
|
|
109
|
+
const n = u.get(t), c = n && n.upCB, s = n && n.upS;
|
|
110
|
+
y.value = t, s && (s.value = 0), e.ctor && c && (n.upCB = [], c.forEach((r) => r()));
|
|
111
111
|
}
|
|
112
112
|
}, Le = (e, t) => e.length ? e.some((n, c) => n !== t[c]) : !0, Ae = (e) => e === "className" ? "class" : e, ee = (e) => e.replace(/^on(.*)/, (t, n) => n.toLowerCase()), j = () => new DocumentFragment(), Z = (e) => document.createElement(e), Rt = (e, t, n, c) => {
|
|
113
113
|
e.isRoot = !0, t = t || document.body, e.wrapElement = t;
|
|
114
|
-
const
|
|
115
|
-
return n ? (e.afterElement = n, t.insertBefore(
|
|
116
|
-
const
|
|
114
|
+
const s = M(e, c);
|
|
115
|
+
return n ? (e.afterElement = n, t.insertBefore(s, n)) : c || (t.tagName === "HTML" ? t.replaceWith(s) : t.appendChild(s)), Q(), () => {
|
|
116
|
+
const r = u.get(e.compProps || {}), o = r && r.vd.value || e;
|
|
117
117
|
o !== e && x(o), N(o), Oe(o);
|
|
118
118
|
};
|
|
119
119
|
}, te = (e) => {
|
|
@@ -146,8 +146,8 @@ const Te = (e) => {
|
|
|
146
146
|
const c = n.el && n.el.nodeType;
|
|
147
147
|
if (c)
|
|
148
148
|
if ([1, 3].includes(c)) {
|
|
149
|
-
const
|
|
150
|
-
|
|
149
|
+
const s = n.el;
|
|
150
|
+
s.tagName === "HTML" ? s.innerHTML = "" : s.remove();
|
|
151
151
|
} else c === 11 && ce(n);
|
|
152
152
|
});
|
|
153
153
|
}, se = (e) => {
|
|
@@ -161,14 +161,14 @@ const Te = (e) => {
|
|
|
161
161
|
t || (t = M(e));
|
|
162
162
|
const n = i(e);
|
|
163
163
|
if (n.type) {
|
|
164
|
-
const c = b(n),
|
|
165
|
-
t && c && (e.tag !== "portal" && (
|
|
164
|
+
const c = b(n), r = n.type === "l" && n.needRerender && n.needRerender !== "CNSU" ? L(n, i(n)) : L(e, n);
|
|
165
|
+
t && c && (e.tag !== "portal" && (r ? c.insertBefore(t, r) : c.appendChild(t)), Q());
|
|
166
166
|
}
|
|
167
167
|
}, re = (e) => h(e.type) ? (e && e.children || []).reduce((t, n) => {
|
|
168
168
|
const c = re(n);
|
|
169
169
|
return c && t.appendChild(c), t;
|
|
170
170
|
}, j()) : e.el, L = (e, t) => {
|
|
171
|
-
const n = t.children || [],
|
|
171
|
+
const n = t.children || [], s = n.indexOf(e) + 1, r = n.slice(s), o = oe(r), l = t.type || "";
|
|
172
172
|
if (o)
|
|
173
173
|
return o;
|
|
174
174
|
if (!t.isRoot && h(l))
|
|
@@ -178,8 +178,8 @@ const Te = (e) => {
|
|
|
178
178
|
}, oe = (e) => e.reduce(
|
|
179
179
|
(t, n) => {
|
|
180
180
|
if (t) return t;
|
|
181
|
-
const { type: c, el:
|
|
182
|
-
return c && h(c) ? oe(n.children || []) :
|
|
181
|
+
const { type: c, el: s } = n;
|
|
182
|
+
return c && h(c) ? oe(n.children || []) : s && s.nodeType !== 11 ? s : t;
|
|
183
183
|
},
|
|
184
184
|
void 0
|
|
185
185
|
), Qe = (e) => {
|
|
@@ -188,8 +188,8 @@ const Te = (e) => {
|
|
|
188
188
|
if (n.nodeType === 11)
|
|
189
189
|
se(e);
|
|
190
190
|
else {
|
|
191
|
-
const c = b(t),
|
|
192
|
-
c && e.tag !== "portal" && c.replaceChild(
|
|
191
|
+
const c = b(t), s = M(e);
|
|
192
|
+
c && e.tag !== "portal" && c.replaceChild(s, n), Q();
|
|
193
193
|
}
|
|
194
194
|
}, le = (e, t) => {
|
|
195
195
|
R(e || {}).forEach(([n, c]) => {
|
|
@@ -213,100 +213,102 @@ const Te = (e) => {
|
|
|
213
213
|
}, je = (e) => {
|
|
214
214
|
e.el && (e.el.nodeValue = String(e.text));
|
|
215
215
|
}, ue = (e, t, n, c) => {
|
|
216
|
-
const
|
|
217
|
-
R(e || {}).forEach(([
|
|
218
|
-
c &&
|
|
216
|
+
const s = { ...n };
|
|
217
|
+
R(e || {}).forEach(([r, o]) => {
|
|
218
|
+
c && r.match(/^on/) ? $(
|
|
219
219
|
t,
|
|
220
|
-
|
|
220
|
+
r,
|
|
221
221
|
o,
|
|
222
|
-
r
|
|
223
|
-
) : (
|
|
222
|
+
s[r]
|
|
223
|
+
) : (r === "key" || o === s[r] || r === "portal" && typeof o == "object" || (r === "innerHTML" && typeof o == "string" ? t.innerHTML = o : J(r, o) ? _e(
|
|
224
224
|
o,
|
|
225
|
-
J(
|
|
225
|
+
J(r, s.style) ? s.style : {},
|
|
226
226
|
t
|
|
227
|
-
) : ke(
|
|
227
|
+
) : ke(r, o) ? o.value = t : r.match(/^on/) ? $(
|
|
228
228
|
t,
|
|
229
|
-
|
|
229
|
+
r,
|
|
230
230
|
o,
|
|
231
|
-
r
|
|
232
|
-
) :
|
|
233
|
-
Ae(
|
|
231
|
+
s[r]
|
|
232
|
+
) : r && (r !== "type" && Re(t, r) ? t[r] = o : qe(
|
|
233
|
+
Ae(r),
|
|
234
234
|
t,
|
|
235
235
|
o
|
|
236
|
-
))), delete r
|
|
237
|
-
}), w(
|
|
238
|
-
(
|
|
236
|
+
))), delete s[r]);
|
|
237
|
+
}), w(s).forEach(
|
|
238
|
+
(r) => t.removeAttribute(r)
|
|
239
239
|
);
|
|
240
240
|
}, qe = (e, t, n) => v.value && e !== "xmlns" ? t.setAttributeNS(null, e, n) : t.setAttribute(e, n), M = (e, t) => {
|
|
241
241
|
let n;
|
|
242
|
-
const { type: c, tag:
|
|
243
|
-
return ge(e),
|
|
242
|
+
const { type: c, tag: s, text: r, props: o, children: l = [] } = e, p = h(c);
|
|
243
|
+
return ge(e), s === "svg" && (v.value = String(o && o.xmlns)), t ? n = e.el : (p ? n = j() : c === "e" && s ? s === "portal" && o && o.portal ? n = o.portal : n = v.value ? document.createElementNS(v.value, s) : Z(s) : c === "t" && k(r) ? n = document.createTextNode(String(r)) : n = Z("e"), e.el = n), me(l, n, t), ue(o, n, null, t), Te(e), s === "svg" && (v.value = ""), n;
|
|
244
244
|
}, me = (e, t, n) => {
|
|
245
|
-
const c = e.reduce((
|
|
246
|
-
if (
|
|
247
|
-
const o = M(
|
|
248
|
-
|
|
245
|
+
const c = e.reduce((s, r) => {
|
|
246
|
+
if (r.type) {
|
|
247
|
+
const o = M(r, n);
|
|
248
|
+
r.tag !== "portal" && !n && s.appendChild(o);
|
|
249
249
|
}
|
|
250
|
-
return
|
|
250
|
+
return s;
|
|
251
251
|
}, j());
|
|
252
252
|
!n && t && c.hasChildNodes() && t.appendChild(c);
|
|
253
253
|
}, $ = (e, t, n, c) => {
|
|
254
|
-
const
|
|
255
|
-
c !== n && (c && e.removeEventListener(
|
|
254
|
+
const s = ee(t);
|
|
255
|
+
c !== n && (c && e.removeEventListener(s, c), n && e.addEventListener(s, n));
|
|
256
256
|
}, _e = (e, t, n) => {
|
|
257
|
-
const c = { ...t },
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}))
|
|
257
|
+
const c = { ...t }, s = n instanceof HTMLElement ? n : null, r = s == null ? void 0 : s.style;
|
|
258
|
+
if (!r) return;
|
|
259
|
+
const o = r;
|
|
260
|
+
R(e).forEach(([l, p]) => {
|
|
261
|
+
o[l] = p, delete c[l];
|
|
262
|
+
}), R(c).forEach(([l]) => {
|
|
263
|
+
o[l] = "";
|
|
264
|
+
});
|
|
263
265
|
}, b = (e) => {
|
|
264
266
|
const t = h(e.type);
|
|
265
267
|
return e.isRoot && t ? e.wrapElement : t ? b(i(e)) : e.el;
|
|
266
268
|
}, T = (e, t) => Ie(
|
|
267
269
|
e,
|
|
268
|
-
Ee
|
|
270
|
+
Pe[Ee(e)](e, t),
|
|
269
271
|
t
|
|
270
272
|
), Ie = (e, t, n) => {
|
|
271
|
-
const c = $e(e, t, n),
|
|
273
|
+
const c = $e(e, t, n), s = Ge(
|
|
272
274
|
c,
|
|
273
275
|
t,
|
|
274
276
|
n
|
|
275
|
-
),
|
|
276
|
-
return
|
|
277
|
+
), r = s === "N";
|
|
278
|
+
return r || (c.children = He(
|
|
277
279
|
c,
|
|
278
280
|
t,
|
|
279
281
|
n
|
|
280
|
-
)), c.needRerender =
|
|
282
|
+
)), c.needRerender = s, ze(c, n, s), !r && n && (n.isLegacy = !0, delete n.children), c;
|
|
281
283
|
}, ze = (e, t, n) => {
|
|
282
284
|
n !== "A" && t && (e.el = t.el), n && ["D", "R", "SR"].includes(n) && (t && (x(t), N(t)), e.oldChildren = t && t.children), e.oldProps = t && t.props;
|
|
283
285
|
}, Ge = (e, t, n) => {
|
|
284
286
|
if (ve(e)) return "D";
|
|
285
287
|
if (e.type === "t" && t && e.text === (n && n.text) || e === n) return "N";
|
|
286
288
|
if (!(n && n.type)) return "A";
|
|
287
|
-
const
|
|
288
|
-
let
|
|
289
|
-
return e.type === "l" &&
|
|
289
|
+
const r = f(e), o = i(n), l = !e.isRoot && o && o.type === "l" && k(r);
|
|
290
|
+
let p = t ? l ? "SU" : "U" : l ? "SR" : "R";
|
|
291
|
+
return e.type === "l" && p === "U" && n && Je(e, n) && (p = "CNSU"), p;
|
|
290
292
|
}, Je = (e, t) => {
|
|
291
293
|
const n = [...t && t.children || []], c = [...e && e.children || []].filter(
|
|
292
|
-
(o) => n.find((l) =>
|
|
293
|
-
),
|
|
294
|
-
(o) => c.find((l) =>
|
|
294
|
+
(o) => n.find((l) => f(o) === f(l))
|
|
295
|
+
), s = n.filter(
|
|
296
|
+
(o) => c.find((l) => f(o) === f(l))
|
|
295
297
|
);
|
|
296
|
-
let
|
|
297
|
-
return
|
|
298
|
-
(o, l) =>
|
|
299
|
-
)),
|
|
298
|
+
let r = s.length === c.length;
|
|
299
|
+
return r && (r = s.every(
|
|
300
|
+
(o, l) => f(o) === f(c[l])
|
|
301
|
+
)), r;
|
|
300
302
|
}, Xe = (e, t) => {
|
|
301
303
|
e && t !== e && (w(e).forEach((n) => delete e[n]), R(t || {}).forEach(([n, c]) => e[n] = c));
|
|
302
304
|
}, Ye = (e, t) => {
|
|
303
305
|
e && (e.splice(0, e.length), t && t.forEach((n) => e.push(n)));
|
|
304
306
|
}, Ze = (e, t) => {
|
|
305
|
-
const { compProps: n, compChild: c } = e, { props:
|
|
306
|
-
return n && Xe(n,
|
|
307
|
-
}, $e = (e, t, n) =>
|
|
307
|
+
const { compProps: n, compChild: c } = e, { props: s, children: r } = t;
|
|
308
|
+
return n && Xe(n, s), c && r && c !== r && Ye(c, r), e.reRender && e.reRender();
|
|
309
|
+
}, $e = (e, t, n) => P(e) ? t && n ? Ze(n, e) : e.resolve() : e, He = (e, t, n) => t && n ? Ke(e, n) : Ve(e), Ve = (e) => (e.children || []).map(
|
|
308
310
|
(t) => S(T(t), { getParent: () => e })
|
|
309
|
-
), Ke = (e, t) => e.type === "l" && k(
|
|
311
|
+
), Ke = (e, t) => e.type === "l" && k(f((e.children || [])[0])) ? we(e, t) : (e.children || []).map(
|
|
310
312
|
(n, c) => S(T(n, (t.children || [])[c]), {
|
|
311
313
|
getParent: () => e
|
|
312
314
|
})
|
|
@@ -315,17 +317,17 @@ const Te = (e) => {
|
|
|
315
317
|
e,
|
|
316
318
|
t
|
|
317
319
|
);
|
|
318
|
-
return c.forEach((
|
|
319
|
-
x(
|
|
320
|
+
return c.forEach((s) => {
|
|
321
|
+
x(s), N(s), q(s);
|
|
320
322
|
}), n;
|
|
321
323
|
}, We = (e, t) => {
|
|
322
324
|
const n = [...t.children || []];
|
|
323
|
-
return [(e.children || []).map((
|
|
324
|
-
const
|
|
325
|
-
return
|
|
325
|
+
return [(e.children || []).map((s) => {
|
|
326
|
+
const r = De(s, n), o = T(s, r);
|
|
327
|
+
return r && n.splice(n.indexOf(r), 1), o.getParent = () => e, o;
|
|
326
328
|
}), n];
|
|
327
329
|
}, De = (e, t) => t.find(
|
|
328
|
-
(n) =>
|
|
330
|
+
(n) => f(n) === f(e)
|
|
329
331
|
), O = /* @__PURE__ */ new Map();
|
|
330
332
|
let B = !1;
|
|
331
333
|
const et = (e, t) => {
|
|
@@ -339,7 +341,7 @@ const et = (e, t) => {
|
|
|
339
341
|
O.forEach((e) => {
|
|
340
342
|
e();
|
|
341
343
|
}), O.clear(), B = !1;
|
|
342
|
-
},
|
|
344
|
+
}, Et = (e, t = () => []) => {
|
|
343
345
|
const n = C();
|
|
344
346
|
if (!n) return;
|
|
345
347
|
const c = u.get(n);
|
|
@@ -355,16 +357,16 @@ const et = (e, t) => {
|
|
|
355
357
|
[d]: !0,
|
|
356
358
|
children: t
|
|
357
359
|
}), st = (e, t, ...n) => {
|
|
358
|
-
const c = { value: void 0 },
|
|
359
|
-
return
|
|
360
|
-
},
|
|
361
|
-
const c = (
|
|
362
|
-
if (!(!
|
|
363
|
-
if (
|
|
364
|
-
const o =
|
|
365
|
-
o !== -1 &&
|
|
360
|
+
const c = { value: void 0 }, s = pe(c, n), r = lt(e, t || {}, s);
|
|
361
|
+
return P(r) || (c.value = r), r;
|
|
362
|
+
}, Pt = (e, t) => st("portal", { portal: t }, e), St = (e) => (t, n) => e, rt = (e, t, n) => {
|
|
363
|
+
const c = (s, r) => {
|
|
364
|
+
if (!(!s || r.has(s))) {
|
|
365
|
+
if (r.add(s), s.compChild) {
|
|
366
|
+
const o = s.compChild.indexOf(t);
|
|
367
|
+
o !== -1 && s.compChild.splice(o, 1, n);
|
|
366
368
|
}
|
|
367
|
-
c(
|
|
369
|
+
c(s.getParent ? s.getParent() : void 0, r);
|
|
368
370
|
}
|
|
369
371
|
};
|
|
370
372
|
c(e, /* @__PURE__ */ new Set());
|
|
@@ -372,17 +374,17 @@ const et = (e, t) => {
|
|
|
372
374
|
if (c.isLegacy)
|
|
373
375
|
return;
|
|
374
376
|
g.value = !0;
|
|
375
|
-
const
|
|
376
|
-
if (
|
|
377
|
+
const s = fe(e, t, n), r = T(s, c), { isRoot: o, getParent: l, wrapElement: p, afterElement: de } = c;
|
|
378
|
+
if (r.getParent = l, !o && l) {
|
|
377
379
|
const U = l(), I = U && U.children || [], z = I.indexOf(c);
|
|
378
|
-
z !== -1 && I.splice(z, 1,
|
|
380
|
+
z !== -1 && I.splice(z, 1, r), rt(U, c, r);
|
|
379
381
|
} else
|
|
380
|
-
|
|
381
|
-
g.value = !1, te(
|
|
382
|
+
r.isRoot = !0, r.wrapElement = p, r.afterElement = de;
|
|
383
|
+
g.value = !1, te(r);
|
|
382
384
|
}, lt = (e, t, n) => {
|
|
383
385
|
if (H(e))
|
|
384
386
|
return _(t, ...n);
|
|
385
|
-
if (
|
|
387
|
+
if (P(e)) {
|
|
386
388
|
const c = fe(e, t, n);
|
|
387
389
|
return g.value ? c : c.resolve();
|
|
388
390
|
}
|
|
@@ -412,52 +414,52 @@ const et = (e, t) => {
|
|
|
412
414
|
return e;
|
|
413
415
|
}, pt = (e, t, n) => (c = t) => {
|
|
414
416
|
Ne(c);
|
|
415
|
-
const
|
|
417
|
+
const s = e(t, n), o = (typeof s == "function" ? s : () => () => s)(
|
|
416
418
|
tt(c),
|
|
417
419
|
t,
|
|
418
420
|
n
|
|
419
421
|
);
|
|
420
422
|
return ft(o, c, e, t, n);
|
|
421
423
|
}, fe = (e, t, n) => {
|
|
422
|
-
const c = e.name,
|
|
423
|
-
return { tagName: c, ctor:
|
|
424
|
-
}, ft = (e, t, n, c,
|
|
425
|
-
const { wrappedComponentMaker:
|
|
424
|
+
const c = e.name, s = e, r = n, o = pt(e, t, r);
|
|
425
|
+
return { tagName: c, ctor: s, props: t, children: r, resolve: o };
|
|
426
|
+
}, ft = (e, t, n, c, s) => {
|
|
427
|
+
const { wrappedComponentMaker: r, customNode: o } = ht(
|
|
426
428
|
e,
|
|
427
429
|
c
|
|
428
430
|
), l = it(
|
|
429
|
-
|
|
431
|
+
r,
|
|
430
432
|
t,
|
|
431
433
|
n,
|
|
432
434
|
c,
|
|
433
|
-
|
|
435
|
+
s
|
|
434
436
|
);
|
|
435
|
-
return ie(o, t, n, c,
|
|
436
|
-
}, it = (e, t, n, c,
|
|
437
|
-
const
|
|
438
|
-
return
|
|
439
|
-
}, dt = (e, t, n, c,
|
|
437
|
+
return ie(o, t, n, c, s, l), o;
|
|
438
|
+
}, it = (e, t, n, c, s) => {
|
|
439
|
+
const r = () => dt(e, t, n, c, s, r);
|
|
440
|
+
return r;
|
|
441
|
+
}, dt = (e, t, n, c, s, r) => {
|
|
440
442
|
xe(t), ct();
|
|
441
443
|
const o = e(c);
|
|
442
|
-
return ie(o, t, n, c,
|
|
444
|
+
return ie(o, t, n, c, s, r), o;
|
|
443
445
|
}, ht = (e, t) => {
|
|
444
446
|
let n = e(t);
|
|
445
447
|
if (!n.reRender)
|
|
446
448
|
return { wrappedComponentMaker: e, customNode: n };
|
|
447
|
-
const c = (
|
|
448
|
-
const
|
|
449
|
-
return
|
|
449
|
+
const c = (s) => {
|
|
450
|
+
const r = e(s), o = _({}, r);
|
|
451
|
+
return r.getParent = () => o, o;
|
|
450
452
|
};
|
|
451
453
|
return n = c(t), { wrappedComponentMaker: c, customNode: n };
|
|
452
|
-
}, ie = (e, t, n, c,
|
|
454
|
+
}, ie = (e, t, n, c, s, r) => {
|
|
453
455
|
S(e, {
|
|
454
456
|
compProps: c,
|
|
455
|
-
compChild:
|
|
457
|
+
compChild: s,
|
|
456
458
|
ctor: n,
|
|
457
459
|
tagName: n.name,
|
|
458
460
|
compKey: t,
|
|
459
|
-
reRender:
|
|
460
|
-
}), et(t, () => ot(n, c,
|
|
461
|
+
reRender: r
|
|
462
|
+
}), et(t, () => ot(n, c, s, e)), X(t, "vd") && (X(t, "vd").value = e);
|
|
461
463
|
}, xt = (e) => ({ value: e }), Nt = () => Promise.resolve();
|
|
462
464
|
export {
|
|
463
465
|
_ as Fragment,
|
|
@@ -472,11 +474,11 @@ export {
|
|
|
472
474
|
vt as mountCallback,
|
|
473
475
|
kt as mountReadyCallback,
|
|
474
476
|
Nt as nextTick,
|
|
475
|
-
|
|
477
|
+
Pt as portal,
|
|
476
478
|
xt as ref,
|
|
477
479
|
Rt as render,
|
|
478
480
|
ot as replaceWDom,
|
|
479
481
|
at as setComponentMapManualMode,
|
|
480
|
-
|
|
482
|
+
Et as updateCallback
|
|
481
483
|
};
|
|
482
484
|
//# sourceMappingURL=lithent.mjs.map
|