lithent 1.0.2 → 1.0.4
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 +7 -8
- package/dist/lithent.mjs +363 -796
- package/dist/lithent.mjs.map +1 -1
- package/dist/lithent.umd.js +1 -1
- package/dist/lithent.umd.js.map +1 -1
- package/dist/utils/predicator.d.ts +0 -1
- package/examples/dist/assets/index.f6f52820.js +2 -0
- package/examples/dist/assets/index.f6f52820.js.map +1 -0
- package/examples/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/diff.ts +12 -26
- package/src/render.ts +33 -14
- package/src/tests/renew.tsx +3 -2
- package/src/utils/predicator.ts +0 -5
- package/src/wDom.ts +3 -7
- package/examples/dist/assets/index.1e9792b7.js +0 -2
- package/examples/dist/assets/index.1e9792b7.js.map +0 -1
package/dist/lithent.mjs
CHANGED
|
@@ -1,111 +1,41 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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 C = (e) => typeof e == "object" && !("resolve" in e), E = (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) => {
|
|
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) => {
|
|
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) => {
|
|
8
|
+
var s, c;
|
|
9
|
+
return C(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" && y(i((e.children || [])[0])) && y(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) => C(e) && !e.type, y = (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", ve = (e) => e.nodeType === 1 && e.tagName === "TEXTAREA", ye = (e) => e.nodeType === 1 && ["radio", "checkbox"].includes(e.type), 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
|
+
}, Ce = {
|
|
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 && ae(s, n), c && Ee(c, r), e.reRender && e.reRender();
|
|
26
|
+
}, J = (e) => e.replace(/^on(.*)/, (t, s) => s.toLowerCase()), G = (e) => e === "className" ? "class" : e, k = Object.entries, Y = Object.keys, S = Object.assign, ae = (e, t) => {
|
|
27
|
+
e && t !== e && (Y(e).forEach((s) => delete e[s]), k(t || {}).forEach(([s, c]) => e[s] = c));
|
|
28
|
+
}, Ee = (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 v = { value: "" }, R = { value: {} }, O = { value: !1 }, u = /* @__PURE__ */ new WeakMap(), xe = (e) => () => {
|
|
33
|
+
var c;
|
|
34
|
+
const t = (c = u.get(e)) == null ? void 0 : c.up;
|
|
35
|
+
let s = !1;
|
|
36
|
+
return t && (t(), s = !0), s;
|
|
37
|
+
}, Pe = (e) => {
|
|
38
|
+
u.set(e, {
|
|
109
39
|
vd: { value: null },
|
|
110
40
|
up: () => {
|
|
111
41
|
},
|
|
@@ -116,722 +46,359 @@ const setComponetRef = (compKey) => {
|
|
|
116
46
|
mts: [],
|
|
117
47
|
umts: []
|
|
118
48
|
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
compKey,
|
|
126
|
-
exec
|
|
127
|
-
});
|
|
128
|
-
if (!redrawQueueTimeout) {
|
|
129
|
-
redrawQueueTimeout = true;
|
|
130
|
-
queueMicrotask(execRedrawQueue);
|
|
131
|
-
}
|
|
49
|
+
}, a = () => R.value, Z = (e, t) => u.get(e)[t], V = (e, t) => {
|
|
50
|
+
u.get(e).up = () => {
|
|
51
|
+
x.push({
|
|
52
|
+
compKey: e,
|
|
53
|
+
exec: t
|
|
54
|
+
}), A || (A = !0, queueMicrotask(Ne));
|
|
132
55
|
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
+
}, Te = (e) => R.value = e, Se = (e) => {
|
|
57
|
+
R.value = e, Pe(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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (childVd) {
|
|
154
|
-
recursiveGetChildKeys(childVd, childItemList);
|
|
155
|
-
}
|
|
63
|
+
}, Ne = () => {
|
|
64
|
+
let e = [];
|
|
65
|
+
x.forEach((c) => {
|
|
66
|
+
var r, o;
|
|
67
|
+
const n = (o = (r = u.get(c.compKey)) == null ? void 0 : r.vd) == null ? void 0 : o.value;
|
|
68
|
+
n && K(n, e);
|
|
156
69
|
});
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
+
}, be = (e) => {
|
|
80
|
+
u.get(a()).umts.push(e);
|
|
81
|
+
}, Q = (e) => {
|
|
82
|
+
const { compKey: t } = e;
|
|
83
|
+
t && Fe(t), g(e);
|
|
84
|
+
}, g = (e) => {
|
|
85
|
+
(e.children || []).forEach((t) => {
|
|
86
|
+
t.compKey ? Q(t) : g(t);
|
|
194
87
|
});
|
|
195
|
-
}
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
+
}, Fe = (e) => {
|
|
89
|
+
const t = u.get(e);
|
|
90
|
+
t && (t.umts.forEach((s) => s()), t.umts = [], u.delete(e));
|
|
91
|
+
};
|
|
92
|
+
let L = [];
|
|
93
|
+
const B = () => {
|
|
94
|
+
L.forEach((e) => Ae(e)), L = [];
|
|
95
|
+
}, Ue = (e) => {
|
|
96
|
+
e.compKey && L.push(e);
|
|
97
|
+
}, ct = (e) => u.get(a()).mts.push(e), Ae = (e) => {
|
|
98
|
+
const { compKey: t } = e;
|
|
99
|
+
if (t) {
|
|
100
|
+
const s = u.get(t), c = s == null ? void 0 : s.mts, n = s == null ? void 0 : s.upS;
|
|
101
|
+
R.value = t, n && (n.value = 0), c && (s.mts = [], c.forEach((r) => {
|
|
102
|
+
const o = r();
|
|
103
|
+
o && be(o);
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
}, X = (e, t = () => []) => {
|
|
107
|
+
const s = u.get(a()), { upD: c, upS: n } = s, r = c[n.value];
|
|
108
|
+
if (r && Le(r, t())) {
|
|
109
|
+
const o = e();
|
|
110
|
+
o && s.upCB.push(o);
|
|
111
|
+
}
|
|
112
|
+
c[n.value] = t(), n.value += 1;
|
|
113
|
+
}, Oe = (e) => {
|
|
114
|
+
const { compKey: t } = e;
|
|
115
|
+
if (t) {
|
|
116
|
+
const s = u.get(t), c = s == null ? void 0 : s.upCB, n = s == null ? void 0 : s.upS;
|
|
117
|
+
R.value = t, n && (n.value = 0), e.ctor && c && (s.upCB = [], c.forEach((r) => r()));
|
|
118
|
+
}
|
|
119
|
+
}, Le = (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 = u.get(e.compProps || {})) == null ? void 0 : r.vd.value;
|
|
125
|
+
n && (Q(n), j(n), Me(n));
|
|
286
126
|
};
|
|
287
|
-
}
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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: Be,
|
|
133
|
+
U: je,
|
|
134
|
+
SR: D,
|
|
135
|
+
SU: Qe
|
|
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
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
removeEvent(newWDom.oldProps, newWDom.el);
|
|
315
|
-
}
|
|
316
|
-
deleteRealDom(
|
|
317
|
-
newWDom,
|
|
318
|
-
findRealParentElement(getParent(newWDom))
|
|
141
|
+
}, Me = (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
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
+
}, Qe = (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), o = ee(r), l = t.type || "";
|
|
169
|
+
if (o)
|
|
170
|
+
return o;
|
|
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
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
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
|
+
), Be = (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
|
+
k(e || {}).forEach(([s, c]) => {
|
|
192
|
+
s.match(/^on/) && t.removeEventListener(
|
|
193
|
+
J(s),
|
|
194
|
+
c
|
|
195
|
+
);
|
|
426
196
|
});
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
updateText(newWDom);
|
|
197
|
+
}, je = (e) => {
|
|
198
|
+
var s;
|
|
199
|
+
const t = e.el;
|
|
200
|
+
if (e.type === "text") {
|
|
201
|
+
Ie(e);
|
|
433
202
|
return;
|
|
434
203
|
}
|
|
435
|
-
if (
|
|
436
|
-
const { oldProps, props } =
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
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)), Oe(e);
|
|
209
|
+
}, Ie = (e) => {
|
|
210
|
+
const t = e.el;
|
|
211
|
+
t && (t.nodeValue = String(e.text));
|
|
212
|
+
}, se = (e, t, s) => {
|
|
213
|
+
const c = { ...s };
|
|
214
|
+
k(e || {}).forEach(([n, r]) => {
|
|
215
|
+
let o = !0;
|
|
216
|
+
n === "key" || (n === "innerHTML" && typeof r == "string" ? t.innerHTML = r : z(n, r) ? Ge(
|
|
217
|
+
r,
|
|
218
|
+
z(n, c.style) ? c.style : {},
|
|
219
|
+
t
|
|
220
|
+
) : he(n, r) ? r.value = t : n.match(/^on/) ? ze(
|
|
221
|
+
t,
|
|
222
|
+
n,
|
|
223
|
+
r,
|
|
224
|
+
c[n]
|
|
225
|
+
) : ye(t) && n === "checked" ? t.checked = !!r : ve(t) && n === "value" ? t.value = r : ie(t) && n === "selected" ? t.selected = !!r : n && ([o, r] = qe(r), o && (v.value && n !== "xmlns" ? t.setAttributeNS(
|
|
226
|
+
null,
|
|
227
|
+
G(n),
|
|
228
|
+
r
|
|
229
|
+
) : t.setAttribute(
|
|
230
|
+
G(n),
|
|
231
|
+
r
|
|
232
|
+
)))), o && delete c[n];
|
|
233
|
+
}), Y(c).forEach(
|
|
234
|
+
(n) => t.removeAttribute(n)
|
|
498
235
|
);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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
|
-
},
|
|
236
|
+
}, qe = (e) => {
|
|
237
|
+
let t = !0;
|
|
238
|
+
return typeof e == "boolean" && (e || (t = !1), e = ""), [t, String(e)];
|
|
239
|
+
}, N = (e) => {
|
|
240
|
+
let t;
|
|
241
|
+
const { type: s, tag: c, text: n, props: r, children: o = [] } = e, l = P(s);
|
|
242
|
+
return c === "svg" && (v.value = String(r == null ? void 0 : r.xmlns)), l ? t = new DocumentFragment() : s === "element" && c ? t = v.value ? document.createElementNS(v.value, c) : document.createElement(c) : s === "text" && y(n) ? t = document.createTextNode(String(n)) : t = document.createElement("e"), _e(o, t), se(r, t), e.el = t, Ue(e), c === "svg" && (v.value = ""), t;
|
|
243
|
+
}, _e = (e, t) => {
|
|
244
|
+
const s = e.reduce(
|
|
245
|
+
(c, n) => (n.type && c.appendChild(N(n)), c),
|
|
533
246
|
new DocumentFragment()
|
|
534
247
|
);
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
}
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
|
|
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
|
|
248
|
+
t && s.hasChildNodes() && t.appendChild(s);
|
|
249
|
+
}, ze = (e, t, s, c) => {
|
|
250
|
+
const n = J(t);
|
|
251
|
+
c !== s && (c && e.removeEventListener(n, c), s && e.addEventListener(n, s));
|
|
252
|
+
}, Ge = (e, t, s) => {
|
|
253
|
+
const c = { ...t }, n = s == null ? void 0 : s.style;
|
|
254
|
+
n && (k(e).forEach(([r, o]) => {
|
|
255
|
+
n[r] = o, delete c[r];
|
|
256
|
+
}), k(c).forEach(
|
|
257
|
+
([r]) => n[r] = ""
|
|
258
|
+
));
|
|
259
|
+
}, b = (e) => {
|
|
260
|
+
const t = P(e.type);
|
|
261
|
+
return e.isRoot && t ? e.wrapElement : t ? b(p(e)) : e.el;
|
|
262
|
+
}, F = (e, t) => Xe(
|
|
263
|
+
e,
|
|
264
|
+
Ce[ke(e)](e, t),
|
|
265
|
+
t
|
|
266
|
+
), Xe = (e, t, s) => {
|
|
267
|
+
const c = Je(e, t, s), n = [
|
|
268
|
+
c,
|
|
269
|
+
t,
|
|
270
|
+
s
|
|
271
|
+
], r = He(...n);
|
|
272
|
+
return c.children = Ye(...n), c.needRerender = r, $e(c, s, r), c;
|
|
273
|
+
}, $e = (e, t, s) => {
|
|
274
|
+
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;
|
|
275
|
+
}, He = (e, t, s) => {
|
|
276
|
+
const c = s && s.type, n = H(e), o = !!e.getParent && p(e).type, l = i(e), h = o === "loop" && y(l), d = e.type === "text" && t && e.text === (s == null ? void 0 : s.text);
|
|
277
|
+
let f;
|
|
278
|
+
return n ? f = "D" : d ? f = "N" : c ? t ? f = h ? "SU" : "U" : f = h ? "SR" : "R" : f = "A", f;
|
|
279
|
+
}, 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(
|
|
280
|
+
(t) => S(F(t), { getParent: () => e })
|
|
281
|
+
), Ve = (e, t) => e.type === "loop" && y(i((e.children || [])[0])) ? Ke(e, t) : (e.children || []).map(
|
|
282
|
+
(s, c) => S(F(s, (t.children || [])[c]), {
|
|
283
|
+
getParent: () => e
|
|
284
|
+
})
|
|
285
|
+
), Ke = (e, t) => {
|
|
286
|
+
const [s, c] = ge(
|
|
287
|
+
e,
|
|
288
|
+
t
|
|
655
289
|
);
|
|
656
|
-
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
return
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
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) => ({
|
|
290
|
+
return c.map((n) => {
|
|
291
|
+
const r = n.el;
|
|
292
|
+
r != null && r.parentNode && r.parentNode.removeChild(r);
|
|
293
|
+
}), s;
|
|
294
|
+
}, ge = (e, t) => {
|
|
295
|
+
const s = [...e.children || []], c = [...t.children || []];
|
|
296
|
+
return [s.map((r) => {
|
|
297
|
+
const o = me(r, c), l = F(r, o);
|
|
298
|
+
return o && c.splice(c.indexOf(o), 1), l.getParent = () => e, l;
|
|
299
|
+
}), c];
|
|
300
|
+
}, me = (e, t) => t.find(
|
|
301
|
+
(s) => i(s) === i(e)
|
|
302
|
+
), rt = (e, t = () => []) => {
|
|
303
|
+
u.get(a()).upR.push(() => X(e, t)), X(e, t);
|
|
304
|
+
}, we = () => {
|
|
305
|
+
var t;
|
|
306
|
+
const e = (t = u.get(a())) == null ? void 0 : t.upR;
|
|
307
|
+
e != null && e.length && e.forEach((s) => s());
|
|
308
|
+
}, ce = (e, ...t) => ({
|
|
694
309
|
type: "fragment",
|
|
695
|
-
children
|
|
696
|
-
})
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
)
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
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
|
|
310
|
+
children: t
|
|
311
|
+
}), ot = (e, t, ...s) => {
|
|
312
|
+
const c = { value: void 0 }, n = t || {}, r = ue(c, s), o = tt(e, n, r);
|
|
313
|
+
return T(o) || (c.value = o), o;
|
|
314
|
+
}, ut = (e) => (t, s) => e, ne = (e, t, s, c) => {
|
|
315
|
+
var f;
|
|
316
|
+
O.value = !0;
|
|
317
|
+
const n = re(e, t, s), r = F(n, c), { isRoot: o, getParent: l, wrapElement: h, afterElement: d } = c;
|
|
318
|
+
if (r.getParent = l, !o && l) {
|
|
319
|
+
const _ = ((f = l()) == null ? void 0 : f.children) || [], le = _.indexOf(c);
|
|
320
|
+
_.splice(le, 1, r);
|
|
321
|
+
} else
|
|
322
|
+
r.isRoot = !0, r.wrapElement = h, r.afterElement = d;
|
|
323
|
+
O.value = !1, m(r);
|
|
324
|
+
}, re = (e, t, s) => ({ tagName: e.name, ctor: e, props: t, children: s, resolve: (o = t) => {
|
|
325
|
+
Se(o);
|
|
326
|
+
const h = e(t, s)(xe(o), t, s), d = We(
|
|
327
|
+
h,
|
|
328
|
+
o,
|
|
329
|
+
e,
|
|
330
|
+
t,
|
|
331
|
+
s
|
|
332
|
+
), f = d;
|
|
333
|
+
return V(
|
|
334
|
+
o,
|
|
335
|
+
() => ne(e, t, s, f)
|
|
336
|
+
), Z(o, "vd").value = d, d;
|
|
337
|
+
} }), We = (e, t, s, c, n) => {
|
|
338
|
+
const r = e(c);
|
|
339
|
+
return oe(
|
|
340
|
+
r,
|
|
341
|
+
t,
|
|
342
|
+
s,
|
|
343
|
+
c,
|
|
344
|
+
n,
|
|
345
|
+
De(e, t, s, c, n)
|
|
346
|
+
), r;
|
|
347
|
+
}, De = (e, t, s, c, n) => {
|
|
348
|
+
const r = () => et(e, t, s, c, n, r);
|
|
349
|
+
return r;
|
|
350
|
+
}, et = (e, t, s, c, n, r) => {
|
|
351
|
+
Te(t), we();
|
|
352
|
+
const o = e(c);
|
|
353
|
+
return V(
|
|
354
|
+
t,
|
|
355
|
+
() => ne(s, c, n, o)
|
|
356
|
+
), oe(o, t, s, c, n, r), Z(t, "vd").value = o, o;
|
|
357
|
+
}, oe = (e, t, s, c, n, r) => {
|
|
358
|
+
S(e, {
|
|
359
|
+
compProps: c,
|
|
360
|
+
compChild: n,
|
|
361
|
+
ctor: s,
|
|
362
|
+
tagName: s.name,
|
|
363
|
+
compKey: t,
|
|
364
|
+
reRender: r
|
|
787
365
|
});
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
return needDiffRef.value ? componetMakeResolver : componetMakeResolver.resolve();
|
|
366
|
+
}, tt = (e, t, s) => {
|
|
367
|
+
if ($(e))
|
|
368
|
+
return ce(t, ...s);
|
|
369
|
+
if (T(e)) {
|
|
370
|
+
const c = re(e, t, s);
|
|
371
|
+
return O.value ? c : c.resolve();
|
|
795
372
|
}
|
|
796
373
|
return {
|
|
797
374
|
type: "element",
|
|
798
|
-
tag,
|
|
799
|
-
props,
|
|
800
|
-
children
|
|
375
|
+
tag: e,
|
|
376
|
+
props: t,
|
|
377
|
+
children: s
|
|
801
378
|
};
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
return childItem;
|
|
807
|
-
});
|
|
808
|
-
const makeChildrenItem = (item) => {
|
|
809
|
-
if (item === null || item === void 0 || item === false) {
|
|
379
|
+
}, ue = (e, t) => t.map(
|
|
380
|
+
(s) => S(st(s), { getParent: () => e.value })
|
|
381
|
+
), st = (e) => {
|
|
382
|
+
if (e == null || e === !1)
|
|
810
383
|
return { type: null };
|
|
811
|
-
|
|
812
|
-
const
|
|
813
|
-
const children = remakeChildren(nodeParentPointer, item);
|
|
814
|
-
const node = {
|
|
384
|
+
if (Array.isArray(e)) {
|
|
385
|
+
const t = { value: void 0 }, c = {
|
|
815
386
|
type: "loop",
|
|
816
|
-
children
|
|
387
|
+
children: ue(t, e)
|
|
817
388
|
};
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
return item;
|
|
824
|
-
};
|
|
825
|
-
const ref = (initValue) => ({ value: initValue });
|
|
826
|
-
const nextTick = () => Promise.resolve();
|
|
389
|
+
return t.value = c, c;
|
|
390
|
+
} else if (typeof e == "string" || typeof e == "number")
|
|
391
|
+
return { type: "text", text: e };
|
|
392
|
+
return e;
|
|
393
|
+
}, lt = (e) => ({ value: e }), ft = () => Promise.resolve();
|
|
827
394
|
export {
|
|
828
|
-
Fragment,
|
|
829
|
-
h,
|
|
830
|
-
mount,
|
|
831
|
-
mountCallback,
|
|
832
|
-
nextTick,
|
|
833
|
-
ref,
|
|
834
|
-
render,
|
|
835
|
-
updateCallback
|
|
395
|
+
ce as Fragment,
|
|
396
|
+
ot as h,
|
|
397
|
+
ut as mount,
|
|
398
|
+
ct as mountCallback,
|
|
399
|
+
ft as nextTick,
|
|
400
|
+
lt as ref,
|
|
401
|
+
nt as render,
|
|
402
|
+
rt as updateCallback
|
|
836
403
|
};
|
|
837
404
|
//# sourceMappingURL=lithent.mjs.map
|