lithent 1.0.2 → 1.0.3

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/dist/lithent.mjs CHANGED
@@ -1,111 +1,41 @@
1
- const checkPlainWDomType = (wDom) => typeof wDom === "object" && !("resolve" in wDom);
2
- const checkPlainType = (wDom, typeName) => checkPlainWDomType(wDom) && wDom.type === typeName;
3
- const checkSameCustomComponent = (newWDom, originalWDom) => "ctor" in newWDom ? newWDom.ctor === (originalWDom == null ? void 0 : originalWDom.ctor) : newWDom === (originalWDom == null ? void 0 : originalWDom.ctor);
4
- const checkSameFragment = (newWDom, originalWDom) => {
5
- var _a, _b;
6
- return checkPlainWDomType(newWDom) && (originalWDom == null ? void 0 : originalWDom.type) === "fragment" && ((_a = originalWDom == null ? void 0 : originalWDom.children) == null ? void 0 : _a.length) === ((_b = newWDom == null ? void 0 : newWDom.children) == null ? void 0 : _b.length);
7
- };
8
- const checkSameTagElement = (newWDom, originalWDom) => {
9
- var _a, _b;
10
- return checkPlainWDomType(newWDom) && (originalWDom == null ? void 0 : originalWDom.type) === "element" && (originalWDom == null ? void 0 : originalWDom.tag) === newWDom.tag && ((_a = originalWDom == null ? void 0 : originalWDom.children) == null ? void 0 : _a.length) === ((_b = newWDom == null ? void 0 : newWDom.children) == null ? void 0 : _b.length);
11
- };
12
- const checkNormalTypeElement = (newWDom, originalWDom) => {
13
- var _a, _b;
14
- return checkPlainWDomType(newWDom) && (originalWDom == null ? void 0 : originalWDom.type) === newWDom.type && (((_a = originalWDom == null ? void 0 : originalWDom.children) == null ? void 0 : _a.length) === ((_b = newWDom == null ? void 0 : newWDom.children) == null ? void 0 : _b.length) || newWDom.type === "loop" && checkExisty(getKey((newWDom.children || [])[0])) && checkExisty(getKey((originalWDom.children || [])[0])));
15
- };
16
- const getKey = (target) => {
17
- var _a, _b, _c;
18
- return (_c = (_a = target == null ? void 0 : target.compProps) == null ? void 0 : _a.key) != null ? _c : (_b = target == null ? void 0 : target.props) == null ? void 0 : _b.key;
19
- };
20
- const checkVirtualType = (type) => type && ["fragment", "loop"].includes(type);
21
- const checkCustemComponentFunction = (target) => typeof target === "function" && !checkFragmentFunction(target) || typeof target === "object" && "resolve" in target;
22
- const checkFragmentFunction = (target) => typeof target === "function" && target === Fragment;
23
- const checkEmptyElement = (wDom) => checkPlainWDomType(wDom) && !wDom.type;
24
- const checkExisty = (value) => value !== null && value !== void 0;
25
- const checkStyleData = (dataKey, dataValue) => dataKey === "style" && typeof dataValue === "object";
26
- const checkRefData = (dataKey, dataValue) => dataKey === "ref" && typeof dataValue === "object";
27
- const checkOptionElement = (element) => element.nodeType === 1 && element.tagName === "OPTION";
28
- const checkTextareaElement = (element) => element.nodeType === 1 && element.tagName === "TEXTAREA";
29
- const checkCheckableElement = (element) => element.nodeType === 1 && ["radio", "checkbox"].includes(element.type);
30
- const checkNormalAttribute = (dataValue) => typeof dataValue === "number" || typeof dataValue === "string";
31
- const getWDomType = (wDom) => {
32
- let result = "et";
33
- if (checkCustemComponentFunction(wDom)) {
34
- result = "c";
35
- } else if (checkPlainType(wDom, "fragment")) {
36
- result = "f";
37
- } else if (checkPlainType(wDom, "element")) {
38
- result = "e";
39
- } else if (checkPlainType(wDom, "loop")) {
40
- result = "l";
41
- } else if (checkPlainType(wDom, "text")) {
42
- result = "t";
43
- } else if (checkEmptyElement(wDom)) {
44
- result = "et";
45
- }
46
- return result;
47
- };
48
- const checkSameWDomWithOriginal = {
49
- c: checkSameCustomComponent,
50
- l: checkNormalTypeElement,
51
- t: checkNormalTypeElement,
52
- e: checkSameTagElement,
53
- f: checkSameFragment,
54
- et: checkNormalTypeElement
55
- };
56
- const getParent = (vDom) => {
57
- const parentVDom = vDom.getParent && vDom.getParent();
58
- return parentVDom;
59
- };
60
- const reRender = (vDom, infoVdom) => {
61
- const { compProps: props, compChild: children } = vDom;
62
- const { props: infoProps, children: infoChidren } = infoVdom;
63
- if (props) {
64
- updateProps$1(props, infoProps);
65
- }
66
- if (children) {
67
- updateChildren(children, infoChidren);
68
- }
69
- const newVDom = vDom.reRender && vDom.reRender();
70
- return newVDom;
71
- };
72
- const getEventName = (eventKey) => eventKey.replace(/^on(.*)/, (_match, p1) => p1.toLowerCase());
73
- const getAttrKey = (keyName) => keyName === "className" ? "class" : keyName;
74
- const entries = Object.entries;
75
- const keys = Object.keys;
76
- const assign = Object.assign;
77
- const updateProps$1 = (props, infoProps) => {
78
- if (props && infoProps !== props) {
79
- keys(props).forEach((key) => delete props[key]);
80
- entries(infoProps || {}).forEach(([key, value]) => props[key] = value);
81
- }
82
- };
83
- const updateChildren = (children, infoChidren) => {
84
- if (children && infoChidren !== children) {
85
- children.splice(0, children.length);
86
- if (infoChidren) {
87
- infoChidren.forEach((childrenItem) => children.push(childrenItem));
88
- }
89
- }
90
- };
91
- let redrawQueue = [];
92
- let redrawQueueTimeout = false;
93
- const xmlnsRef = { value: "" };
94
- const compKeyRef = { value: {} };
95
- const needDiffRef = { value: false };
96
- const componentRef = /* @__PURE__ */ new WeakMap();
97
- const componentRender = (compKey) => () => {
98
- var _a;
99
- const up = (_a = componentRef.get(compKey)) == null ? void 0 : _a.up;
100
- let result = false;
101
- if (up) {
102
- up();
103
- result = true;
104
- }
105
- return result;
106
- };
107
- const setComponetRef = (compKey) => {
108
- componentRef.set(compKey, {
1
+ const k = (e) => typeof e == "object" && !("resolve" in e), E = (e, t) => k(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) => {
2
+ var s, c;
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
+ }, pe = (e, t) => {
5
+ var s, c;
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) => {
8
+ var s, c;
9
+ return k(e) && (t == null ? void 0 : t.type) === e.type && (((s = t == null ? void 0 : t.children) == null ? void 0 : s.length) === ((c = e == null ? void 0 : e.children) == null ? void 0 : c.length) || e.type === "loop" && v(i((e.children || [])[0])) && v(i((t.children || [])[0])));
10
+ }, i = (e) => {
11
+ var t, s, c;
12
+ return (c = (t = e == null ? void 0 : e.compProps) == null ? void 0 : t.key) != null ? c : (s = e == null ? void 0 : e.props) == null ? void 0 : s.key;
13
+ }, P = (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) => k(e) && !e.type, v = (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), Ce = (e) => typeof e == "number" || typeof e == "string", ke = (e) => {
14
+ let t = "et";
15
+ return T(e) ? t = "c" : E(e, "fragment") ? t = "f" : E(e, "element") ? t = "e" : E(e, "loop") ? t = "l" : E(e, "text") ? t = "t" : H(e) && (t = "et"), t;
16
+ }, ae = {
17
+ c: fe,
18
+ l: U,
19
+ t: U,
20
+ e: pe,
21
+ f: de,
22
+ et: U
23
+ }, p = (e) => e.getParent && e.getParent(), Re = (e, t) => {
24
+ const { compProps: s, compChild: c } = e, { props: n, children: r } = t;
25
+ return s && Ee(s, n), c && xe(c, r), e.reRender && e.reRender();
26
+ }, J = (e) => e.replace(/^on(.*)/, (t, s) => s.toLowerCase()), G = (e) => e === "className" ? "class" : e, C = Object.entries, Y = Object.keys, S = Object.assign, Ee = (e, t) => {
27
+ e && t !== e && (Y(e).forEach((s) => delete e[s]), C(t || {}).forEach(([s, c]) => e[s] = c));
28
+ }, xe = (e, t) => {
29
+ e && t !== e && (e.splice(0, e.length), t && t.forEach((s) => e.push(s)));
30
+ };
31
+ let x = [], A = !1;
32
+ const y = { value: "" }, a = { value: {} }, O = { value: !1 }, o = /* @__PURE__ */ new WeakMap(), Pe = (e) => () => {
33
+ var c;
34
+ const t = (c = o.get(e)) == null ? void 0 : c.up;
35
+ let s = !1;
36
+ return t && (t(), s = !0), s;
37
+ }, Te = (e) => {
38
+ o.set(e, {
109
39
  vd: { value: null },
110
40
  up: () => {
111
41
  },
@@ -116,722 +46,355 @@ const setComponetRef = (compKey) => {
116
46
  mts: [],
117
47
  umts: []
118
48
  });
119
- };
120
- const getComponentKey = () => compKeyRef.value;
121
- const getComponentSubInfo = (compKey, subKey) => componentRef.get(compKey)[subKey];
122
- const setRedrawAction = (compKey, exec) => {
123
- componentRef.get(compKey).up = () => {
124
- redrawQueue.push({
125
- compKey,
126
- exec
127
- });
128
- if (!redrawQueueTimeout) {
129
- redrawQueueTimeout = true;
130
- queueMicrotask(execRedrawQueue);
131
- }
49
+ }, R = () => a.value, Z = (e, t) => o.get(e)[t], V = (e, t) => {
50
+ o.get(e).up = () => {
51
+ x.push({
52
+ compKey: e,
53
+ exec: t
54
+ }), A || (A = !0, queueMicrotask(be));
132
55
  };
133
- };
134
- const initUpdateHookState = (compKey) => compKeyRef.value = compKey;
135
- const initMountHookState = (compKey) => {
136
- compKeyRef.value = compKey;
137
- setComponetRef(compKey);
138
- };
139
- const recursiveGetChildKeys = (wDom, result) => {
140
- (wDom.children || []).forEach((item) => {
141
- const childComKey = item.compKey;
142
- if (childComKey) {
143
- result.push(childComKey);
144
- }
145
- recursiveGetChildKeys(item, result);
56
+ }, Se = (e) => a.value = e, Ne = (e) => {
57
+ a.value = e, Te(e);
58
+ }, K = (e, t) => {
59
+ (e.children || []).forEach((s) => {
60
+ const c = s.compKey;
61
+ c && t.push(c), K(s, t);
146
62
  });
147
- };
148
- const execRedrawQueue = () => {
149
- let childItemList = [];
150
- redrawQueue.forEach((item) => {
151
- var _a, _b;
152
- const childVd = (_b = (_a = componentRef.get(item.compKey)) == null ? void 0 : _a.vd) == null ? void 0 : _b.value;
153
- if (childVd) {
154
- recursiveGetChildKeys(childVd, childItemList);
155
- }
63
+ }, be = () => {
64
+ let e = [];
65
+ x.forEach((c) => {
66
+ var r, u;
67
+ const n = (u = (r = o.get(c.compKey)) == null ? void 0 : r.vd) == null ? void 0 : u.value;
68
+ n && K(n, e);
156
69
  });
157
- const addedKey = [];
158
- const result = redrawQueue.reduce((acc, item) => {
159
- const { compKey } = item;
160
- if (childItemList.includes(compKey) || addedKey.includes(compKey)) {
161
- return acc;
162
- }
163
- addedKey.push(compKey);
164
- acc.push(item);
165
- return acc;
70
+ const t = [], s = x.reduce((c, n) => {
71
+ const { compKey: r } = n;
72
+ return e.includes(r) || t.includes(r) || (t.push(r), c.push(n)), c;
166
73
  }, []);
167
- while (result.length) {
168
- const action = result.shift();
169
- if (action) {
170
- action.exec();
171
- }
172
- }
173
- redrawQueue = [];
174
- redrawQueueTimeout = false;
175
- };
176
- const unmount = (effectAction) => {
177
- componentRef.get(getComponentKey()).umts.push(effectAction);
178
- };
179
- const runUnmountQueueFromWDom = (newWDom) => {
180
- const { compKey } = newWDom;
181
- if (compKey) {
182
- removeItem(compKey);
183
- }
184
- recursiveRunUnmount(newWDom);
185
- };
186
- const recursiveRunUnmount = (wDom) => {
187
- (wDom.children || []).forEach((item) => {
188
- const childComKey = item.compKey;
189
- if (childComKey) {
190
- runUnmountQueueFromWDom(item);
191
- } else {
192
- recursiveRunUnmount(item);
193
- }
74
+ for (; s.length; ) {
75
+ const c = s.shift();
76
+ c && c.exec();
77
+ }
78
+ x = [], A = !1;
79
+ }, Fe = (e) => {
80
+ o.get(R()).umts.push(e);
81
+ }, Q = (e) => {
82
+ const { compKey: t } = e;
83
+ t && Ue(t), g(e);
84
+ }, g = (e) => {
85
+ (e.children || []).forEach((t) => {
86
+ t.compKey ? Q(t) : g(t);
194
87
  });
195
- };
196
- const removeItem = (compKey) => {
197
- const subInfo = componentRef.get(compKey);
198
- if (subInfo) {
199
- subInfo.umts.forEach((effect) => effect());
200
- subInfo.umts = [];
201
- componentRef.delete(compKey);
202
- }
203
- };
204
- let mountedQueue = [];
205
- const execMountedQueue = () => {
206
- mountedQueue.forEach((item) => runMountedQueueFromWDom(item));
207
- mountedQueue = [];
208
- };
209
- const addMountedQueue = (wDom) => {
210
- if (wDom.compKey) {
211
- mountedQueue.push(wDom);
212
- }
213
- };
214
- const mountCallback = (effectAction) => componentRef.get(getComponentKey()).mts.push(effectAction);
215
- const runMountedQueueFromWDom = (newWDom) => {
216
- const { compKey } = newWDom;
217
- if (compKey) {
218
- const component = componentRef.get(compKey);
219
- const queue = component == null ? void 0 : component.mts;
220
- const sequence = component == null ? void 0 : component.upS;
221
- compKeyRef.value = compKey;
222
- if (sequence) {
223
- sequence.value = 0;
224
- }
225
- if (queue) {
226
- component.mts = [];
227
- queue.forEach((effect) => {
228
- const callback = effect();
229
- if (callback) {
230
- unmount(callback);
231
- }
232
- });
233
- }
234
- }
235
- };
236
- const useUpdated = (effectAction, dependencies = () => []) => {
237
- const component = componentRef.get(getComponentKey());
238
- const { upD, upS } = component;
239
- const def = upD[upS.value];
240
- if (def && checkNeedPushQueue(def, dependencies())) {
241
- const callback = effectAction();
242
- if (callback) {
243
- component.upCB.push(callback);
244
- }
245
- }
246
- upD[upS.value] = dependencies();
247
- upS.value += 1;
248
- };
249
- const runUpdatedQueueFromWDom = (newWDom) => {
250
- const { compKey } = newWDom;
251
- if (compKey) {
252
- const component = componentRef.get(compKey);
253
- const queue = component == null ? void 0 : component.upCB;
254
- const sequence = component == null ? void 0 : component.upS;
255
- compKeyRef.value = compKey;
256
- if (sequence) {
257
- sequence.value = 0;
258
- }
259
- if (newWDom.ctor && queue) {
260
- component.upCB = [];
261
- queue.forEach((effect) => effect());
262
- }
263
- }
264
- };
265
- const checkNeedPushQueue = (originalDefs, newDefs) => !originalDefs.length && !originalDefs.length ? true : originalDefs.some((def, index) => def !== newDefs[index]);
266
- const render = (wDom, wrapElement, afterElement) => {
267
- wrapElement != null ? wrapElement : wrapElement = document.body;
268
- wDom.isRoot = true;
269
- wDom.wrapElement = wrapElement;
270
- const Dom = wDomToDom(wDom);
271
- if (afterElement) {
272
- wDom.afterElement = afterElement;
273
- wrapElement.insertBefore(Dom, afterElement);
274
- } else {
275
- wrapElement.appendChild(Dom);
276
- }
277
- execMountedQueue();
278
- return () => {
279
- var _a;
280
- const component = (_a = componentRef.get(wDom.compProps || {})) == null ? void 0 : _a.vd.value;
281
- if (component) {
282
- runUnmountQueueFromWDom(component);
283
- recursiveRemoveEvent(component);
284
- rootDelete(component);
285
- }
88
+ }, Ue = (e) => {
89
+ const t = o.get(e);
90
+ t && (t.umts.forEach((s) => s()), t.umts = [], o.delete(e));
91
+ };
92
+ let L = [];
93
+ const B = () => {
94
+ L.forEach((e) => Oe(e)), L = [];
95
+ }, Ae = (e) => {
96
+ e.compKey && L.push(e);
97
+ }, ct = (e) => o.get(R()).mts.push(e), Oe = (e) => {
98
+ const { compKey: t } = e;
99
+ if (t) {
100
+ const s = o.get(t), c = s == null ? void 0 : s.mts, n = s == null ? void 0 : s.upS;
101
+ a.value = t, n && (n.value = 0), c && (s.mts = [], c.forEach((r) => {
102
+ const u = r();
103
+ u && Fe(u);
104
+ }));
105
+ }
106
+ }, X = (e, t = () => []) => {
107
+ const s = o.get(R()), { upD: c, upS: n } = s, r = c[n.value];
108
+ if (r && Me(r, t())) {
109
+ const u = e();
110
+ u && s.upCB.push(u);
111
+ }
112
+ c[n.value] = t(), n.value += 1;
113
+ }, Le = (e) => {
114
+ const { compKey: t } = e;
115
+ if (t) {
116
+ const s = o.get(t), c = s == null ? void 0 : s.upCB, n = s == null ? void 0 : s.upS;
117
+ a.value = t, n && (n.value = 0), e.ctor && c && (s.upCB = [], c.forEach((r) => r()));
118
+ }
119
+ }, Me = (e, t) => !e.length && !e.length ? !0 : e.some((s, c) => s !== t[c]), nt = (e, t, s) => {
120
+ t != null || (t = document.body), e.isRoot = !0, e.wrapElement = t;
121
+ const c = N(e);
122
+ return s ? (e.afterElement = s, t.insertBefore(c, s)) : t.appendChild(c), B(), () => {
123
+ var r;
124
+ const n = (r = o.get(e.compProps || {})) == null ? void 0 : r.vd.value;
125
+ n && (Q(n), j(n), Qe(n));
286
126
  };
287
- };
288
- const wDomUpdate = (newWDomTree) => {
289
- const { needRerender } = newWDomTree;
290
- if (needRerender && needRerender !== "N") {
291
- ({
292
- A: typeAdd,
293
- D: typeDelete,
294
- R: typeReplace,
295
- U: typeUpdate,
296
- SR: typeSortedReplace,
297
- SU: typeSortedUpdate
298
- })[needRerender](newWDomTree);
299
- }
300
- };
301
- const recursiveRemoveEvent = (originalWDom) => {
302
- if (originalWDom.props && originalWDom.el) {
303
- removeEvent(originalWDom.props, originalWDom.el);
304
- }
305
- (originalWDom.children || []).forEach((childItem) => {
306
- recursiveRemoveEvent(childItem);
127
+ }, m = (e) => {
128
+ const { needRerender: t } = e;
129
+ t && t !== "N" && {
130
+ A: q,
131
+ D: I,
132
+ R: je,
133
+ U: Ie,
134
+ SR: D,
135
+ SU: Be
136
+ }[t](e);
137
+ }, j = (e) => {
138
+ e.props && e.el && te(e.props, e.el), (e.children || []).forEach((t) => {
139
+ j(t);
307
140
  });
308
- };
309
- const rootDelete = (newWDom) => {
310
- deleteRealDom(newWDom, newWDom.wrapElement);
311
- };
312
- const typeDelete = (newWDom) => {
313
- if (newWDom.oldProps && newWDom.el) {
314
- removeEvent(newWDom.oldProps, newWDom.el);
315
- }
316
- deleteRealDom(
317
- newWDom,
318
- findRealParentElement(getParent(newWDom))
141
+ }, Qe = (e) => {
142
+ w(e, e.wrapElement);
143
+ }, I = (e) => {
144
+ e.oldProps && e.el && te(e.oldProps, e.el), w(
145
+ e,
146
+ b(p(e))
319
147
  );
320
- };
321
- const deleteRealDom = (newWDom, parent) => {
322
- var _a, _b;
323
- if (parent && newWDom.el) {
324
- if (((_a = newWDom.el) == null ? void 0 : _a.nodeType) === 1) {
325
- parent.removeChild(newWDom.el);
326
- } else if (((_b = newWDom.el) == null ? void 0 : _b.nodeType) === 11) {
327
- findChildWithRemoveElement(newWDom, parent);
328
- }
329
- delete newWDom.el;
330
- }
331
- };
332
- const findChildWithRemoveElement = (newWDom, parent) => {
333
- ((newWDom == null ? void 0 : newWDom.oldChildren) || (newWDom == null ? void 0 : newWDom.children) || []).forEach((item) => {
334
- var _a, _b;
335
- if (((_a = item.el) == null ? void 0 : _a.nodeType) === 1) {
336
- parent.removeChild(item == null ? void 0 : item.el);
337
- } else if (((_b = item.el) == null ? void 0 : _b.nodeType) === 11) {
338
- findChildWithRemoveElement(item, parent);
339
- }
148
+ }, w = (e, t) => {
149
+ var s, c;
150
+ 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);
151
+ }, W = (e, t) => {
152
+ ((e == null ? void 0 : e.oldChildren) || (e == null ? void 0 : e.children) || []).forEach((s) => {
153
+ var c, n;
154
+ ((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);
340
155
  });
341
- };
342
- const typeSortedReplace = (newWDom) => {
343
- typeDelete(newWDom);
344
- typeAdd(newWDom);
345
- };
346
- const typeSortedUpdate = (newWDom) => {
347
- typeDelete(newWDom);
348
- typeAdd(newWDom, newWDom.el);
349
- };
350
- const typeAdd = (newWDom, newElement) => {
351
- if (!newElement) {
352
- newElement = wDomToDom(newWDom);
353
- }
354
- const parentWDom = getParent(newWDom);
355
- if (parentWDom.type) {
356
- const parentEl = findRealParentElement(parentWDom);
357
- const isLoop = parentWDom.type === "loop";
358
- const nextEl = isLoop ? startFindNextBrotherElement(parentWDom, getParent(parentWDom)) : startFindNextBrotherElement(newWDom, parentWDom);
359
- if (newElement && parentEl) {
360
- if (nextEl) {
361
- parentEl.insertBefore(newElement, nextEl);
362
- } else {
363
- parentEl.appendChild(newElement);
364
- }
365
- execMountedQueue();
366
- }
367
- }
368
- };
369
- const startFindNextBrotherElement = (wDom, parentWDom) => {
370
- const brothers = parentWDom.children || [];
371
- const index = brothers.indexOf(wDom);
372
- const nextIndex = index + 1;
373
- const candidiateBrothers = brothers.slice(nextIndex);
374
- const finedNextEl = findChildFragmentNextElement(candidiateBrothers);
375
- const parentType = parentWDom.type || "";
376
- if (finedNextEl) {
377
- return finedNextEl;
378
- }
379
- if (!parentWDom.isRoot && checkVirtualType(parentType)) {
380
- return startFindNextBrotherElement(parentWDom, getParent(parentWDom));
381
- } else if (parentWDom.isRoot && parentWDom.afterElement) {
382
- return parentWDom.afterElement;
383
- }
384
- return void 0;
385
- };
386
- const findChildFragmentNextElement = (candidiateBrothers) => candidiateBrothers.reduce(
387
- (targetEl, bItem) => {
388
- const type = bItem.type;
389
- const el = bItem.el;
390
- const isFragment = type && checkVirtualType(type);
391
- if (targetEl) {
392
- return targetEl;
393
- } else if (isFragment) {
394
- return findChildFragmentNextElement(bItem.children || []);
395
- } else if (el && el.nodeType !== 11) {
396
- return el;
397
- }
398
- return targetEl;
156
+ }, D = (e) => {
157
+ I(e), q(e);
158
+ }, Be = (e) => {
159
+ I(e), q(e, e.el);
160
+ }, q = (e, t) => {
161
+ t || (t = N(e));
162
+ const s = p(e);
163
+ if (s.type) {
164
+ const c = b(s), r = s.type === "loop" ? M(s, p(s)) : M(e, s);
165
+ t && c && (r ? c.insertBefore(t, r) : c.appendChild(t), B());
166
+ }
167
+ }, M = (e, t) => {
168
+ const s = t.children || [], n = s.indexOf(e) + 1, r = s.slice(n), u = ee(r), l = t.type || "";
169
+ if (u)
170
+ return u;
171
+ if (!t.isRoot && P(l))
172
+ return M(t, p(t));
173
+ if (t.isRoot && t.afterElement)
174
+ return t.afterElement;
175
+ }, ee = (e) => e.reduce(
176
+ (t, s) => {
177
+ const c = s.type, n = s.el, r = c && P(c);
178
+ return t || (r ? ee(s.children || []) : n && n.nodeType !== 11 ? n : t);
399
179
  },
400
180
  void 0
401
- );
402
- const typeReplace = (newWDom) => {
403
- const parentWDom = getParent(newWDom);
404
- const orignalElement = newWDom.el;
405
- if (parentWDom.type && orignalElement) {
406
- if (orignalElement.nodeType === 11) {
407
- typeSortedReplace(newWDom);
408
- } else {
409
- const parentElement = findRealParentElement(parentWDom);
410
- const newElement = wDomToDom(newWDom);
411
- if (parentElement) {
412
- parentElement.replaceChild(newElement, orignalElement);
413
- }
414
- execMountedQueue();
415
- }
416
- }
417
- };
418
- const removeEvent = (oldProps, element) => {
419
- entries(oldProps || {}).forEach(([dataKey, dataValue]) => {
420
- if (dataKey.match(/^on/)) {
421
- element.removeEventListener(
422
- getEventName(dataKey),
423
- dataValue
424
- );
181
+ ), je = (e) => {
182
+ const t = p(e), s = e.el;
183
+ if (t.type && s)
184
+ if (s.nodeType === 11)
185
+ D(e);
186
+ else {
187
+ const c = b(t), n = N(e);
188
+ c && c.replaceChild(n, s), B();
425
189
  }
190
+ }, te = (e, t) => {
191
+ C(e || {}).forEach(([s, c]) => {
192
+ s.match(/^on/) && t.removeEventListener(
193
+ J(s),
194
+ c
195
+ );
426
196
  });
427
- };
428
- const typeUpdate = (newWDom) => {
429
- var _a;
430
- const element = newWDom.el;
431
- if (newWDom.type === "text") {
432
- updateText(newWDom);
197
+ }, Ie = (e) => {
198
+ var s;
199
+ const t = e.el;
200
+ if (e.type === "text") {
201
+ qe(e);
433
202
  return;
434
203
  }
435
- if (element) {
436
- const { oldProps, props } = newWDom;
437
- updateProps(props, element, oldProps);
438
- delete newWDom.oldProps;
439
- if (newWDom.tag === "input") {
440
- element.value = String(((_a = newWDom == null ? void 0 : newWDom.props) == null ? void 0 : _a.value) || "");
441
- }
442
- }
443
- (newWDom.children || []).forEach((childItem) => wDomUpdate(childItem));
444
- runUpdatedQueueFromWDom(newWDom);
445
- };
446
- const updateText = (newWDom) => {
447
- const element = newWDom.el;
448
- if (element) {
449
- element.nodeValue = String(newWDom.text);
450
- }
451
- };
452
- const updateProps = (props, element, oldProps) => {
453
- const originalProps = { ...oldProps };
454
- entries(props || {}).forEach(([dataKey, dataValue]) => {
455
- if (dataKey === "key")
456
- ;
457
- else if (dataKey === "innerHTML" && typeof dataValue === "string") {
458
- element.innerHTML = dataValue;
459
- } else if (checkStyleData(dataKey, dataValue)) {
460
- updateStyle(
461
- dataValue,
462
- checkStyleData(dataKey, originalProps.style) ? originalProps.style : {},
463
- element
464
- );
465
- } else if (checkRefData(dataKey, dataValue)) {
466
- dataValue.value = element;
467
- } else if (dataKey.match(/^on/)) {
468
- updateEvent(
469
- element,
470
- dataKey,
471
- dataValue,
472
- originalProps[dataKey]
473
- );
474
- } else if (checkCheckableElement(element) && dataKey === "checked") {
475
- element.checked = !!dataValue;
476
- } else if (checkTextareaElement(element) && dataKey === "value") {
477
- element.value = dataValue;
478
- } else if (checkOptionElement(element) && dataKey === "selected") {
479
- element.selected = !!dataValue;
480
- } else if (checkNormalAttribute(dataValue)) {
481
- if (xmlnsRef.value && dataKey !== "xmlns") {
482
- element.setAttributeNS(
483
- null,
484
- getAttrKey(dataKey),
485
- String(dataValue)
486
- );
487
- } else {
488
- element.setAttribute(
489
- getAttrKey(dataKey),
490
- String(dataValue)
491
- );
492
- }
493
- }
494
- delete originalProps[dataKey];
495
- });
496
- keys(originalProps).forEach(
497
- (dataKey) => element.removeAttribute(dataKey)
204
+ if (t) {
205
+ const { oldProps: c, props: n } = e;
206
+ 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) || ""));
207
+ }
208
+ (e.children || []).forEach((c) => m(c)), Le(e);
209
+ }, qe = (e) => {
210
+ const t = e.el;
211
+ t && (t.nodeValue = String(e.text));
212
+ }, se = (e, t, s) => {
213
+ const c = { ...s };
214
+ C(e || {}).forEach(([n, r]) => {
215
+ n === "key" || (n === "innerHTML" && typeof r == "string" ? t.innerHTML = r : z(n, r) ? Ge(
216
+ r,
217
+ z(n, c.style) ? c.style : {},
218
+ t
219
+ ) : he(n, r) ? r.value = t : n.match(/^on/) ? ze(
220
+ t,
221
+ n,
222
+ r,
223
+ c[n]
224
+ ) : ve(t) && n === "checked" ? t.checked = !!r : ye(t) && n === "value" ? t.value = r : ie(t) && n === "selected" ? t.selected = !!r : Ce(r) && (y.value && n !== "xmlns" ? t.setAttributeNS(
225
+ null,
226
+ G(n),
227
+ String(r)
228
+ ) : t.setAttribute(
229
+ G(n),
230
+ String(r)
231
+ ))), delete c[n];
232
+ }), Y(c).forEach(
233
+ (n) => t.removeAttribute(n)
498
234
  );
499
- };
500
- const wDomToDom = (wDom) => {
501
- let element;
502
- const { type, tag, text, props, children = [] } = wDom;
503
- const isVirtualType = checkVirtualType(type);
504
- if (tag === "svg") {
505
- xmlnsRef.value = String(props == null ? void 0 : props.xmlns);
506
- }
507
- if (isVirtualType) {
508
- element = new DocumentFragment();
509
- } else if (type === "element" && tag) {
510
- element = xmlnsRef.value ? document.createElementNS(xmlnsRef.value, tag) : document.createElement(tag);
511
- } else if (type === "text" && checkExisty(text)) {
512
- element = document.createTextNode(String(text));
513
- } else {
514
- element = document.createElement("e");
515
- }
516
- wDomChildrenToDom(children, element);
517
- updateProps(props, element);
518
- wDom.el = element;
519
- addMountedQueue(wDom);
520
- if (tag === "svg") {
521
- xmlnsRef.value = "";
522
- }
523
- return element;
524
- };
525
- const wDomChildrenToDom = (children, parentElement) => {
526
- const elementChildren = children.reduce(
527
- (acc, childItem) => {
528
- if (childItem.type) {
529
- acc.appendChild(wDomToDom(childItem));
530
- }
531
- return acc;
532
- },
235
+ }, N = (e) => {
236
+ let t;
237
+ const { type: s, tag: c, text: n, props: r, children: u = [] } = e, l = P(s);
238
+ 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" && v(n) ? t = document.createTextNode(String(n)) : t = document.createElement("e"), _e(u, t), se(r, t), e.el = t, Ae(e), c === "svg" && (y.value = ""), t;
239
+ }, _e = (e, t) => {
240
+ const s = e.reduce(
241
+ (c, n) => (n.type && c.appendChild(N(n)), c),
533
242
  new DocumentFragment()
534
243
  );
535
- if (parentElement && elementChildren.hasChildNodes()) {
536
- parentElement.appendChild(elementChildren);
537
- }
538
- };
539
- const updateEvent = (element, eventKey, newEventHandler, oldEventHandler) => {
540
- const eventName = getEventName(eventKey);
541
- if (oldEventHandler !== newEventHandler) {
542
- if (oldEventHandler) {
543
- element.removeEventListener(eventName, oldEventHandler);
544
- }
545
- if (newEventHandler) {
546
- element.addEventListener(eventName, newEventHandler);
547
- }
548
- }
549
- };
550
- const updateStyle = (style, oldStyle, element) => {
551
- const originalStyle = { ...oldStyle };
552
- const elementStyle = element == null ? void 0 : element.style;
553
- if (elementStyle) {
554
- entries(style).forEach(([styleKey, dataValue]) => {
555
- elementStyle[styleKey] = dataValue;
556
- delete originalStyle[styleKey];
557
- });
558
- entries(originalStyle).forEach(
559
- ([styleKey]) => elementStyle[styleKey] = ""
560
- );
561
- }
562
- };
563
- const findRealParentElement = (vDom) => {
564
- const isVirtualType = checkVirtualType(vDom.type);
565
- if (vDom.isRoot && isVirtualType) {
566
- return vDom.wrapElement;
567
- }
568
- if (!isVirtualType) {
569
- return vDom.el;
570
- }
571
- return findRealParentElement(getParent(vDom));
572
- };
573
- const makeNewWDomTree = (newWDom, originalWDom) => remakeNewWDom(
574
- newWDom,
575
- checkSameWDomWithOriginal[getWDomType(newWDom)](newWDom, originalWDom),
576
- originalWDom
577
- );
578
- const remakeNewWDom = (newWDom, isSameType, originalWDom) => {
579
- const remakeWDom = generalize(newWDom, isSameType, originalWDom);
580
- const param = [
581
- remakeWDom,
582
- isSameType,
583
- originalWDom
584
- ];
585
- const needRerender = addReRenderTypeProperty(...param);
586
- remakeWDom.children = remakeChildrenForDiff(...param);
587
- remakeWDom.needRerender = needRerender;
588
- inheritPropForRender(remakeWDom, originalWDom, needRerender);
589
- return remakeWDom;
590
- };
591
- const inheritPropForRender = (remakeWDom, originalWDom, needRerender) => {
592
- if (needRerender !== "A" && originalWDom) {
593
- remakeWDom.el = originalWDom.el;
594
- }
595
- if (needRerender && ["D", "R", "SR"].includes(needRerender)) {
596
- if (originalWDom == null ? void 0 : originalWDom.compKey) {
597
- runUnmountQueueFromWDom(originalWDom);
598
- recursiveRemoveEvent(originalWDom);
599
- }
600
- remakeWDom.oldChildren = originalWDom == null ? void 0 : originalWDom.children;
601
- }
602
- remakeWDom.oldProps = originalWDom == null ? void 0 : originalWDom.props;
603
- };
604
- const addReRenderTypeProperty = (newWDom, isSameType, originalWDom) => {
605
- const existOriginalWDom = originalWDom && originalWDom.type;
606
- const isEmptyElement = checkEmptyElement(newWDom);
607
- const isRoot = !newWDom.getParent;
608
- const parentType = !isRoot && getParent(newWDom).type;
609
- const key = getKey(newWDom);
610
- const isKeyCheckedWDom = parentType === "loop" && checkExisty(key);
611
- const isSameText = newWDom.type === "text" && isSameType && newWDom.text === (originalWDom == null ? void 0 : originalWDom.text);
612
- let result;
613
- if (isEmptyElement) {
614
- result = "D";
615
- } else if (isSameText) {
616
- result = "N";
617
- } else if (!existOriginalWDom) {
618
- result = "A";
619
- } else if (isSameType) {
620
- result = isKeyCheckedWDom ? "SU" : "U";
621
- } else {
622
- result = isKeyCheckedWDom ? "SR" : "R";
623
- }
624
- return result;
625
- };
626
- const generalize = (newWDom, isSameType, originalWDom) => {
627
- if (checkCustemComponentFunction(newWDom)) {
628
- return isSameType && originalWDom ? reRender(originalWDom, newWDom) : newWDom.resolve();
629
- }
630
- return newWDom;
631
- };
632
- const remakeChildrenForDiff = (newWDom, isSameType, originalWDom) => isSameType && originalWDom ? remakeChildrenForUpdate(newWDom, originalWDom) : remakeChildrenForAdd(newWDom);
633
- const remakeChildrenForAdd = (newWDom) => (newWDom.children || []).map((item) => {
634
- const childItem = makeNewWDomTree(item);
635
- childItem.getParent = () => newWDom;
636
- return childItem;
637
- });
638
- const remakeChildrenForUpdate = (newWDom, originalWDom) => {
639
- if (newWDom.type === "loop" && checkExisty(getKey((newWDom.children || [])[0]))) {
640
- return remakeChildrenForLoopUpdate(newWDom, originalWDom);
641
- }
642
- return (newWDom.children || []).map((item, index) => {
643
- const childItem = makeNewWDomTree(
644
- item,
645
- (originalWDom.children || [])[index]
646
- );
647
- childItem.getParent = () => newWDom;
648
- return childItem;
649
- });
650
- };
651
- const remakeChildrenForLoopUpdate = (newWDom, originalWDom) => {
652
- const [remakedChildren, unUsedChildren] = diffLoopChildren(
653
- newWDom,
654
- originalWDom
244
+ t && s.hasChildNodes() && t.appendChild(s);
245
+ }, ze = (e, t, s, c) => {
246
+ const n = J(t);
247
+ c !== s && (c && e.removeEventListener(n, c), s && e.addEventListener(n, s));
248
+ }, Ge = (e, t, s) => {
249
+ const c = { ...t }, n = s == null ? void 0 : s.style;
250
+ n && (C(e).forEach(([r, u]) => {
251
+ n[r] = u, delete c[r];
252
+ }), C(c).forEach(
253
+ ([r]) => n[r] = ""
254
+ ));
255
+ }, b = (e) => {
256
+ const t = P(e.type);
257
+ return e.isRoot && t ? e.wrapElement : t ? b(p(e)) : e.el;
258
+ }, F = (e, t) => Xe(
259
+ e,
260
+ ae[ke(e)](e, t),
261
+ t
262
+ ), Xe = (e, t, s) => {
263
+ const c = Je(e, t, s), n = [
264
+ c,
265
+ t,
266
+ s
267
+ ], r = He(...n);
268
+ return c.children = Ye(...n), c.needRerender = r, $e(c, s, r), c;
269
+ }, $e = (e, t, s) => {
270
+ 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;
271
+ }, He = (e, t, s) => {
272
+ const c = s && s.type, n = H(e), u = !!e.getParent && p(e).type, l = i(e), h = u === "loop" && v(l), d = e.type === "text" && t && e.text === (s == null ? void 0 : s.text);
273
+ let f;
274
+ return n ? f = "D" : d ? f = "N" : c ? t ? f = h ? "SU" : "U" : f = h ? "SR" : "R" : f = "A", f;
275
+ }, Je = (e, t, s) => T(e) ? t && s ? Re(s, e) : e.resolve() : e, Ye = (e, t, s) => t && s ? Ve(e, s) : Ze(e), Ze = (e) => (e.children || []).map(
276
+ (t) => S(F(t), { getParent: () => e })
277
+ ), Ve = (e, t) => e.type === "loop" && v(i((e.children || [])[0])) ? Ke(e, t) : (e.children || []).map(
278
+ (s, c) => S(F(s, (t.children || [])[c]), {
279
+ getParent: () => e
280
+ })
281
+ ), Ke = (e, t) => {
282
+ const [s, c] = ge(
283
+ e,
284
+ t
655
285
  );
656
- unUsedChildren.map((unusedItem) => {
657
- const el = unusedItem.el;
658
- if (el == null ? void 0 : el.parentNode) {
659
- el.parentNode.removeChild(el);
660
- }
661
- });
662
- return remakedChildren;
663
- };
664
- const diffLoopChildren = (newWDom, originalWDom) => {
665
- const newChildren = [...newWDom.children || []];
666
- const originalChildren = [...originalWDom.children || []];
667
- const remakedChildren = newChildren.map((item) => {
668
- const originalItem = findSameKeyOriginalItem(item, originalChildren);
669
- const childItem = makeNewWDomTree(item, originalItem);
670
- if (originalItem) {
671
- originalChildren.splice(originalChildren.indexOf(originalItem), 1);
672
- }
673
- childItem.getParent = () => newWDom;
674
- return childItem;
675
- });
676
- return [remakedChildren, originalChildren];
677
- };
678
- const findSameKeyOriginalItem = (item, originalChildren) => originalChildren.find(
679
- (orignalChildItem) => getKey(orignalChildItem) === getKey(item)
680
- );
681
- const updateCallback = (effectAction, dependencies = () => []) => {
682
- const updateReqs = componentRef.get(getComponentKey()).upR;
683
- updateReqs.push(() => useUpdated(effectAction, dependencies));
684
- useUpdated(effectAction, dependencies);
685
- };
686
- const runUpdateCallback = () => {
687
- var _a;
688
- const updateReqs = (_a = componentRef.get(getComponentKey())) == null ? void 0 : _a.upR;
689
- if (updateReqs == null ? void 0 : updateReqs.length) {
690
- updateReqs.forEach((callback) => callback());
691
- }
692
- };
693
- const Fragment = (_props, ...children) => ({
286
+ return c.map((n) => {
287
+ const r = n.el;
288
+ r != null && r.parentNode && r.parentNode.removeChild(r);
289
+ }), s;
290
+ }, ge = (e, t) => {
291
+ const s = [...e.children || []], c = [...t.children || []];
292
+ return [s.map((r) => {
293
+ const u = me(r, c), l = F(r, u);
294
+ return u && c.splice(c.indexOf(u), 1), l.getParent = () => e, l;
295
+ }), c];
296
+ }, me = (e, t) => t.find(
297
+ (s) => i(s) === i(e)
298
+ ), rt = (e, t = () => []) => {
299
+ o.get(R()).upR.push(() => X(e, t)), X(e, t);
300
+ }, we = () => {
301
+ var t;
302
+ const e = (t = o.get(R())) == null ? void 0 : t.upR;
303
+ e != null && e.length && e.forEach((s) => s());
304
+ }, ce = (e, ...t) => ({
694
305
  type: "fragment",
695
- children
696
- });
697
- const h = (tag, props, ...children) => {
698
- const nodeParentPointer = { value: void 0 };
699
- const newProps = props || {};
700
- const newChildren = remakeChildren(nodeParentPointer, children);
701
- const node = makeNode(tag, newProps, newChildren);
702
- if (!checkCustemComponentFunction(node)) {
703
- nodeParentPointer.value = node;
704
- }
705
- return node;
706
- };
707
- const mount = (component) => (_props, _children) => component;
708
- const reRenderCustomComponent = (tag, props, children, originalWDom) => {
709
- var _a;
710
- needDiffRef.value = true;
711
- const newWDom = makeWDomResolver(tag, props, children);
712
- const newWDomTree = makeNewWDomTree(newWDom, originalWDom);
713
- const { isRoot, getParent: getParent2, wrapElement, afterElement } = originalWDom;
714
- newWDomTree.getParent = getParent2;
715
- if (!isRoot && getParent2) {
716
- const brothers = ((_a = getParent2()) == null ? void 0 : _a.children) || [];
717
- const index = brothers.indexOf(originalWDom);
718
- brothers.splice(index, 1, newWDomTree);
719
- } else {
720
- newWDomTree.isRoot = true;
721
- newWDomTree.wrapElement = wrapElement;
722
- newWDomTree.afterElement = afterElement;
723
- }
724
- needDiffRef.value = false;
725
- wDomUpdate(newWDomTree);
726
- };
727
- const makeWDomResolver = (tag, props, children) => {
728
- const tagName = tag.name;
729
- const ctor = tag;
730
- const resolve = (compKey = props) => {
731
- initMountHookState(compKey);
732
- const component = tag(props, children);
733
- const componentMaker = component(componentRender(compKey), props, children);
734
- const customNode = makeCustomNode(
735
- componentMaker,
736
- compKey,
737
- tag,
738
- props,
739
- children
740
- );
741
- const originalWDom = customNode;
742
- setRedrawAction(
743
- compKey,
744
- () => reRenderCustomComponent(tag, props, children, originalWDom)
745
- );
746
- getComponentSubInfo(compKey, "vd").value = customNode;
747
- return customNode;
748
- };
749
- return { tagName, ctor, props, children, resolve };
750
- };
751
- const makeCustomNode = (componentMaker, compKey, tag, props, children) => {
752
- const customNode = componentMaker(props);
753
- addComponentProps(
754
- customNode,
755
- compKey,
756
- tag,
757
- props,
758
- children,
759
- makeReRender(componentMaker, compKey, tag, props, children)
760
- );
761
- return customNode;
762
- };
763
- const makeReRender = (componentMaker, compKey, tag, props, children) => {
764
- const reRender2 = () => wDomMaker(componentMaker, compKey, tag, props, children, reRender2);
765
- return reRender2;
766
- };
767
- const wDomMaker = (componentMaker, compKey, tag, props, children, reRender2) => {
768
- initUpdateHookState(compKey);
769
- runUpdateCallback();
770
- const originalWDom = componentMaker(props);
771
- setRedrawAction(
772
- compKey,
773
- () => reRenderCustomComponent(tag, props, children, originalWDom)
774
- );
775
- addComponentProps(originalWDom, compKey, tag, props, children, reRender2);
776
- getComponentSubInfo(compKey, "vd").value = originalWDom;
777
- return originalWDom;
778
- };
779
- const addComponentProps = (wDom, compKey, tag, props, children, reRender2) => {
780
- assign(wDom, {
781
- compProps: props,
782
- compChild: children,
783
- ctor: tag,
784
- tagName: tag.name,
785
- compKey,
786
- reRender: reRender2
306
+ children: t
307
+ }), ut = (e, t, ...s) => {
308
+ const c = { value: void 0 }, n = t || {}, r = oe(c, s), u = tt(e, n, r);
309
+ return T(u) || (c.value = u), u;
310
+ }, ot = (e) => (t, s) => e, ne = (e, t, s, c) => {
311
+ var f;
312
+ O.value = !0;
313
+ const n = re(e, t, s), r = F(n, c), { isRoot: u, getParent: l, wrapElement: h, afterElement: d } = c;
314
+ if (r.getParent = l, !u && l) {
315
+ const _ = ((f = l()) == null ? void 0 : f.children) || [], le = _.indexOf(c);
316
+ _.splice(le, 1, r);
317
+ } else
318
+ r.isRoot = !0, r.wrapElement = h, r.afterElement = d;
319
+ O.value = !1, m(r);
320
+ }, re = (e, t, s) => ({ tagName: e.name, ctor: e, props: t, children: s, resolve: (u = t) => {
321
+ Ne(u);
322
+ const h = e(t, s)(Pe(u), t, s), d = We(
323
+ h,
324
+ u,
325
+ e,
326
+ t,
327
+ s
328
+ ), f = d;
329
+ return V(
330
+ u,
331
+ () => ne(e, t, s, f)
332
+ ), Z(u, "vd").value = d, d;
333
+ } }), We = (e, t, s, c, n) => {
334
+ const r = e(c);
335
+ return ue(
336
+ r,
337
+ t,
338
+ s,
339
+ c,
340
+ n,
341
+ De(e, t, s, c, n)
342
+ ), r;
343
+ }, De = (e, t, s, c, n) => {
344
+ const r = () => et(e, t, s, c, n, r);
345
+ return r;
346
+ }, et = (e, t, s, c, n, r) => {
347
+ Se(t), we();
348
+ const u = e(c);
349
+ return V(
350
+ t,
351
+ () => ne(s, c, n, u)
352
+ ), ue(u, t, s, c, n, r), Z(t, "vd").value = u, u;
353
+ }, ue = (e, t, s, c, n, r) => {
354
+ S(e, {
355
+ compProps: c,
356
+ compChild: n,
357
+ ctor: s,
358
+ tagName: s.name,
359
+ compKey: t,
360
+ reRender: r
787
361
  });
788
- };
789
- const makeNode = (tag, props, children) => {
790
- if (checkFragmentFunction(tag)) {
791
- return Fragment(props, ...children);
792
- } else if (checkCustemComponentFunction(tag)) {
793
- const componetMakeResolver = makeWDomResolver(tag, props, children);
794
- return needDiffRef.value ? componetMakeResolver : componetMakeResolver.resolve();
362
+ }, tt = (e, t, s) => {
363
+ if ($(e))
364
+ return ce(t, ...s);
365
+ if (T(e)) {
366
+ const c = re(e, t, s);
367
+ return O.value ? c : c.resolve();
795
368
  }
796
369
  return {
797
370
  type: "element",
798
- tag,
799
- props,
800
- children
371
+ tag: e,
372
+ props: t,
373
+ children: s
801
374
  };
802
- };
803
- const remakeChildren = (nodeParentPointer, children) => children.map((item) => {
804
- const childItem = makeChildrenItem(item);
805
- childItem.getParent = () => nodeParentPointer.value;
806
- return childItem;
807
- });
808
- const makeChildrenItem = (item) => {
809
- if (item === null || item === void 0 || item === false) {
375
+ }, oe = (e, t) => t.map(
376
+ (s) => S(st(s), { getParent: () => e.value })
377
+ ), st = (e) => {
378
+ if (e == null || e === !1)
810
379
  return { type: null };
811
- } else if (Array.isArray(item)) {
812
- const nodeParentPointer = { value: void 0 };
813
- const children = remakeChildren(nodeParentPointer, item);
814
- const node = {
380
+ if (Array.isArray(e)) {
381
+ const t = { value: void 0 }, c = {
815
382
  type: "loop",
816
- children
383
+ children: oe(t, e)
817
384
  };
818
- nodeParentPointer.value = node;
819
- return node;
820
- } else if (typeof item === "string" || typeof item === "number") {
821
- return { type: "text", text: item };
822
- }
823
- return item;
824
- };
825
- const ref = (initValue) => ({ value: initValue });
826
- const nextTick = () => Promise.resolve();
385
+ return t.value = c, c;
386
+ } else if (typeof e == "string" || typeof e == "number")
387
+ return { type: "text", text: e };
388
+ return e;
389
+ }, lt = (e) => ({ value: e }), ft = () => Promise.resolve();
827
390
  export {
828
- Fragment,
829
- h,
830
- mount,
831
- mountCallback,
832
- nextTick,
833
- ref,
834
- render,
835
- updateCallback
391
+ ce as Fragment,
392
+ ut as h,
393
+ ot as mount,
394
+ ct as mountCallback,
395
+ ft as nextTick,
396
+ lt as ref,
397
+ nt as render,
398
+ rt as updateCallback
836
399
  };
837
400
  //# sourceMappingURL=lithent.mjs.map