@lvce-editor/virtual-dom-worker 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -158,10 +158,12 @@ var applyPendingPatches = (patches, pendingPatches, skip) => {
|
|
|
158
158
|
pendingPatches.length = 0;
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
-
// src/parts/
|
|
161
|
+
// src/parts/IsKey/IsKey.ts
|
|
162
162
|
var isKey = (key) => {
|
|
163
163
|
return key !== "type" && key !== "childCount";
|
|
164
164
|
};
|
|
165
|
+
|
|
166
|
+
// src/parts/GetKeys/GetKeys.ts
|
|
165
167
|
var getKeys = (node) => {
|
|
166
168
|
const keys = Object.keys(node).filter(isKey);
|
|
167
169
|
return keys;
|
|
@@ -195,6 +197,13 @@ var diff = (oldNodes, newNodes) => {
|
|
|
195
197
|
if (siblingOffset > 0) {
|
|
196
198
|
}
|
|
197
199
|
if (siblingOffset === maxSiblingOffset) {
|
|
200
|
+
indexStack.pop();
|
|
201
|
+
indexStack.pop();
|
|
202
|
+
pendingPatches.push(NavigateParent, 0);
|
|
203
|
+
maxSiblingOffset = indexStack.pop();
|
|
204
|
+
siblingOffset = indexStack.pop() + 1;
|
|
205
|
+
}
|
|
206
|
+
while (siblingOffset === maxSiblingOffset) {
|
|
198
207
|
pendingPatches.push(NavigateParent, 0);
|
|
199
208
|
maxSiblingOffset = indexStack.pop();
|
|
200
209
|
siblingOffset = indexStack.pop() + 1;
|
|
@@ -252,6 +261,9 @@ var diff = (oldNodes, newNodes) => {
|
|
|
252
261
|
}
|
|
253
262
|
}
|
|
254
263
|
if (hasAttributeChanges) {
|
|
264
|
+
if (siblingOffset > 0) {
|
|
265
|
+
pendingPatches.push(NavigateSibling, siblingOffset);
|
|
266
|
+
}
|
|
255
267
|
applyPendingPatches(patches, pendingPatches, 0);
|
|
256
268
|
for (const key of newKeys) {
|
|
257
269
|
if (oldNode[key] !== newNode[key]) {
|
|
@@ -289,6 +301,7 @@ var diff = (oldNodes, newNodes) => {
|
|
|
289
301
|
}
|
|
290
302
|
i += getTotalChildCount(oldNodes, i);
|
|
291
303
|
j++;
|
|
304
|
+
siblingOffset++;
|
|
292
305
|
continue;
|
|
293
306
|
}
|
|
294
307
|
if (newNode.childCount) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts'
|
|
2
|
-
|
|
3
|
-
const isKey = (key: string): boolean => {
|
|
4
|
-
return key !== 'type' && key !== 'childCount'
|
|
5
|
-
}
|
|
1
|
+
import type { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts'
|
|
2
|
+
import * as IsKey from '../IsKey/IsKey.ts'
|
|
6
3
|
|
|
7
4
|
export const getKeys = (node: VirtualDomNode): readonly string[] => {
|
|
8
|
-
const keys = Object.keys(node).filter(isKey)
|
|
5
|
+
const keys = Object.keys(node).filter(IsKey.isKey)
|
|
9
6
|
return keys
|
|
10
7
|
}
|
|
@@ -24,7 +24,17 @@ export const diff = (
|
|
|
24
24
|
if (siblingOffset > 0) {
|
|
25
25
|
// pendingPatches.push(PatchType.NavigateSibling, siblingOffset)
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
// TODO maybe don't have the current element in indexstack
|
|
27
29
|
if (siblingOffset === maxSiblingOffset) {
|
|
30
|
+
indexStack.pop()
|
|
31
|
+
indexStack.pop()
|
|
32
|
+
pendingPatches.push(PatchType.NavigateParent, 0)
|
|
33
|
+
maxSiblingOffset = indexStack.pop() as number
|
|
34
|
+
siblingOffset = (indexStack.pop() as number) + 1
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
while (siblingOffset === maxSiblingOffset) {
|
|
28
38
|
pendingPatches.push(PatchType.NavigateParent, 0)
|
|
29
39
|
maxSiblingOffset = indexStack.pop() as number
|
|
30
40
|
siblingOffset = (indexStack.pop() as number) + 1
|
|
@@ -93,6 +103,9 @@ export const diff = (
|
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
if (hasAttributeChanges) {
|
|
106
|
+
if (siblingOffset > 0) {
|
|
107
|
+
pendingPatches.push(PatchType.NavigateSibling, siblingOffset)
|
|
108
|
+
}
|
|
96
109
|
ApplyPendingPatches.applyPendingPatches(patches, pendingPatches, 0)
|
|
97
110
|
|
|
98
111
|
for (const key of newKeys) {
|
|
@@ -133,6 +146,7 @@ export const diff = (
|
|
|
133
146
|
}
|
|
134
147
|
i += GetTotalChildCount.getTotalChildCount(oldNodes, i)
|
|
135
148
|
j++
|
|
149
|
+
siblingOffset++
|
|
136
150
|
continue
|
|
137
151
|
}
|
|
138
152
|
|