@lvce-editor/virtual-dom-worker 3.6.0 → 4.1.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.d.ts CHANGED
@@ -6,24 +6,24 @@ declare const Polite = "polite";
6
6
  export interface DomEventListener {
7
7
  readonly name: string | number;
8
8
  readonly params: readonly (string | number)[];
9
- readonly preventDefault?: boolean;
10
9
  readonly passive?: boolean;
10
+ readonly preventDefault?: boolean;
11
11
  }
12
12
  export declare const mergeClassNames: (...classNames: readonly string[]) => string;
13
13
  export declare const px: (value: number) => string;
14
14
  export declare const position: (x: number, y: number) => string;
15
15
  export interface VirtualDomNode {
16
- readonly type: number;
17
16
  readonly [key: string]: any;
17
+ readonly type: number;
18
18
  }
19
19
  export declare const text: (data: string) => VirtualDomNode;
20
20
  export interface AddPatch {
21
- readonly type: 6;
22
21
  readonly nodes: readonly VirtualDomNode[];
22
+ readonly type: 6;
23
23
  }
24
24
  export interface AttributePatch {
25
- readonly type: 3;
26
25
  readonly key: string;
26
+ readonly type: 3;
27
27
  readonly value: any;
28
28
  }
29
29
  export type NavigateChildPatch = {
@@ -38,21 +38,21 @@ export type NavigateSiblingPatch = {
38
38
  readonly index: number;
39
39
  };
40
40
  export interface RemoveAttributePatch {
41
- readonly type: 4;
42
41
  readonly key: string;
42
+ readonly type: 4;
43
43
  }
44
44
  export interface RemoveChildPatch {
45
- readonly type: 9;
46
45
  readonly index: number;
46
+ readonly type: 9;
47
47
  }
48
48
  export interface RemovePatch {
49
- readonly type: 5;
50
49
  readonly index: number;
50
+ readonly type: 5;
51
51
  }
52
52
  export interface ReplacePatch {
53
- readonly type: 2;
54
53
  readonly index: number;
55
54
  readonly node: VirtualDomNode;
55
+ readonly type: 2;
56
56
  }
57
57
  export interface TextPatch {
58
58
  readonly type: 1;
@@ -8,8 +8,8 @@ export const applyPendingPatches = (patches, pendingPatches, skip) => {
8
8
  }
9
9
  else {
10
10
  patches.push({
11
- type,
12
11
  index,
12
+ type,
13
13
  });
14
14
  }
15
15
  }
@@ -1,8 +1,8 @@
1
1
  import { VirtualDomElements } from '@lvce-editor/constants';
2
2
  export const text = (data) => {
3
3
  return {
4
- type: VirtualDomElements.Text,
5
- text: data,
6
4
  childCount: 0,
5
+ text: data,
6
+ type: VirtualDomElements.Text,
7
7
  };
8
8
  };
@@ -40,12 +40,12 @@ export const diff = (oldNodes, newNodes) => {
40
40
  const oldTotal = GetTotalChildCount.getTotalChildCount(oldNodes, i);
41
41
  const newTotal = GetTotalChildCount.getTotalChildCount(newNodes, j);
42
42
  patches.push({
43
- type: PatchType.RemoveChild,
44
43
  index: siblingOffset,
44
+ type: PatchType.RemoveChild,
45
45
  });
46
46
  patches.push({
47
- type: PatchType.Add,
48
47
  nodes: newNodes.slice(j, j + newTotal),
48
+ type: PatchType.Add,
49
49
  });
50
50
  siblingOffset++;
51
51
  i += oldTotal;
@@ -92,8 +92,8 @@ export const diff = (oldNodes, newNodes) => {
92
92
  for (const key of newKeys) {
93
93
  if (oldNode[key] !== newNode[key]) {
94
94
  patches.push({
95
- type: PatchType.SetAttribute,
96
95
  key,
96
+ type: PatchType.SetAttribute,
97
97
  value: newNode[key],
98
98
  });
99
99
  }
@@ -101,8 +101,8 @@ export const diff = (oldNodes, newNodes) => {
101
101
  for (const key of oldKeys) {
102
102
  if (!(key in newNode)) {
103
103
  patches.push({
104
- type: PatchType.RemoveAttribute,
105
104
  key,
105
+ type: PatchType.RemoveAttribute,
106
106
  });
107
107
  }
108
108
  }
@@ -119,8 +119,8 @@ export const diff = (oldNodes, newNodes) => {
119
119
  ApplyPendingPatches.applyPendingPatches(patches, pendingPatches, 0);
120
120
  for (let k = 0; k < oldNode.childCount; k++) {
121
121
  patches.push({
122
- type: PatchType.RemoveChild,
123
122
  index: 0,
123
+ type: PatchType.RemoveChild,
124
124
  });
125
125
  }
126
126
  i += GetTotalChildCount.getTotalChildCount(oldNodes, i);
@@ -132,8 +132,8 @@ export const diff = (oldNodes, newNodes) => {
132
132
  ApplyPendingPatches.applyPendingPatches(patches, pendingPatches, 0);
133
133
  const total = GetTotalChildCount.getTotalChildCount(newNodes, j);
134
134
  patches.push({
135
- type: PatchType.Add,
136
135
  nodes: newNodes.slice(j + 1, j + total),
136
+ type: PatchType.Add,
137
137
  });
138
138
  i++;
139
139
  j += total;
@@ -150,8 +150,8 @@ export const diff = (oldNodes, newNodes) => {
150
150
  });
151
151
  }
152
152
  patches.push({
153
- type: PatchType.RemoveChild,
154
153
  index: siblingOffset,
154
+ type: PatchType.RemoveChild,
155
155
  });
156
156
  i += GetTotalChildCount.getTotalChildCount(oldNodes, i);
157
157
  indexStack.pop();
@@ -160,15 +160,15 @@ export const diff = (oldNodes, newNodes) => {
160
160
  while (j < newNodes.length) {
161
161
  if (siblingOffset > 0) {
162
162
  patches.push({
163
- type: PatchType.NavigateSibling,
164
163
  index: siblingOffset,
164
+ type: PatchType.NavigateSibling,
165
165
  });
166
166
  siblingOffset = 0;
167
167
  }
168
168
  const count = GetTotalChildCount.getTotalChildCount(newNodes, j);
169
169
  patches.push({
170
- type: PatchType.Add,
171
170
  nodes: newNodes.slice(j, j + count),
171
+ type: PatchType.Add,
172
172
  });
173
173
  j += count;
174
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom-worker",
3
- "version": "3.6.0",
3
+ "version": "4.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/virtual-dom.git"
@@ -9,7 +9,7 @@
9
9
  "type": "module",
10
10
  "main": "dist/index.js",
11
11
  "dependencies": {
12
- "@lvce-editor/constants": "^1.24.0"
12
+ "@lvce-editor/constants": "^2.8.0"
13
13
  },
14
14
  "types": "dist/index.d.ts"
15
15
  }