@lvce-editor/virtual-dom-worker 1.18.0 → 1.20.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/README.md CHANGED
@@ -1 +1 @@
1
- # virtual dom
1
+ # virtual dom
package/dist/index.js CHANGED
@@ -1,129 +1,121 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ const mergeClassNames = (...classNames) => {
2
+ return classNames.filter(Boolean).join(' ');
5
3
  };
6
4
 
7
- // src/parts/MergeClassNames/MergeClassNames.ts
8
- var mergeClassNames = (...classNames) => {
9
- return classNames.filter(Boolean).join(" ");
10
- };
5
+ const Audio = 0;
6
+ const Button = 1;
7
+ const Col = 2;
8
+ const ColGroup = 3;
9
+ const Div = 4;
10
+ const H1 = 5;
11
+ const Input = 6;
12
+ const Kbd = 7;
13
+ const Span = 8;
14
+ const Table = 9;
15
+ const TBody = 10;
16
+ const Td = 11;
17
+ const Text = 12;
18
+ const Th = 13;
19
+ const THead = 14;
20
+ const Tr = 15;
21
+ const I = 16;
22
+ const Img = 17;
23
+ const Root = 0;
24
+ const Ins = 20;
25
+ const Del = 21;
26
+ const H2 = 22;
27
+ const H3 = 23;
28
+ const H4 = 24;
29
+ const H5 = 25;
30
+ const H6 = 26;
31
+ const Article = 27;
32
+ const Aside = 28;
33
+ const Footer = 29;
34
+ const Header = 30;
35
+ const Nav = 40;
36
+ const Section = 41;
37
+ const Search = 42;
38
+ const Dd = 43;
39
+ const Dl = 44;
40
+ const Figcaption = 45;
41
+ const Figure = 46;
42
+ const Hr = 47;
43
+ const Li = 48;
44
+ const Ol = 49;
45
+ const P = 50;
46
+ const Pre = 51;
47
+ const A = 53;
48
+ const Abbr = 54;
49
+ const Br = 55;
50
+ const Cite = 56;
51
+ const Data = 57;
52
+ const Time = 58;
53
+ const Tfoot = 59;
54
+ const Ul = 60;
55
+ const Video = 61;
56
+ const TextArea = 62;
57
+ const Select = 63;
58
+ const Option = 64;
11
59
 
12
- // src/parts/VirtualDomElements/VirtualDomElements.ts
13
- var VirtualDomElements_exports = {};
14
- __export(VirtualDomElements_exports, {
15
- A: () => A,
16
- Abbr: () => Abbr,
17
- Article: () => Article,
18
- Aside: () => Aside,
19
- Audio: () => Audio,
20
- Br: () => Br,
21
- Button: () => Button,
22
- Cite: () => Cite,
23
- Col: () => Col,
24
- ColGroup: () => ColGroup,
25
- Data: () => Data,
26
- Dd: () => Dd,
27
- Del: () => Del,
28
- Div: () => Div,
29
- Dl: () => Dl,
30
- Figcaption: () => Figcaption,
31
- Figure: () => Figure,
32
- Footer: () => Footer,
33
- H1: () => H1,
34
- H2: () => H2,
35
- H3: () => H3,
36
- H4: () => H4,
37
- H5: () => H5,
38
- H6: () => H6,
39
- Header: () => Header,
40
- Hr: () => Hr,
41
- I: () => I,
42
- Img: () => Img,
43
- Input: () => Input,
44
- Ins: () => Ins,
45
- Kbd: () => Kbd,
46
- Li: () => Li,
47
- Nav: () => Nav,
48
- Ol: () => Ol,
49
- Option: () => Option,
50
- P: () => P,
51
- Pre: () => Pre,
52
- Root: () => Root,
53
- Search: () => Search,
54
- Section: () => Section,
55
- Select: () => Select,
56
- Span: () => Span,
57
- TBody: () => TBody,
58
- THead: () => THead,
59
- Table: () => Table,
60
- Td: () => Td,
61
- Text: () => Text,
62
- TextArea: () => TextArea,
63
- Tfoot: () => Tfoot,
64
- Th: () => Th,
65
- Time: () => Time,
66
- Tr: () => Tr,
67
- Ul: () => Ul,
68
- Video: () => Video
69
- });
70
- var Audio = 0;
71
- var Button = 1;
72
- var Col = 2;
73
- var ColGroup = 3;
74
- var Div = 4;
75
- var H1 = 5;
76
- var Input = 6;
77
- var Kbd = 7;
78
- var Span = 8;
79
- var Table = 9;
80
- var TBody = 10;
81
- var Td = 11;
82
- var Text = 12;
83
- var Th = 13;
84
- var THead = 14;
85
- var Tr = 15;
86
- var I = 16;
87
- var Img = 17;
88
- var Root = 0;
89
- var Ins = 20;
90
- var Del = 21;
91
- var H2 = 22;
92
- var H3 = 23;
93
- var H4 = 24;
94
- var H5 = 25;
95
- var H6 = 26;
96
- var Article = 27;
97
- var Aside = 28;
98
- var Footer = 29;
99
- var Header = 30;
100
- var Nav = 40;
101
- var Section = 41;
102
- var Search = 42;
103
- var Dd = 43;
104
- var Dl = 44;
105
- var Figcaption = 45;
106
- var Figure = 46;
107
- var Hr = 47;
108
- var Li = 48;
109
- var Ol = 49;
110
- var P = 50;
111
- var Pre = 51;
112
- var A = 53;
113
- var Abbr = 54;
114
- var Br = 55;
115
- var Cite = 56;
116
- var Data = 57;
117
- var Time = 58;
118
- var Tfoot = 59;
119
- var Ul = 60;
120
- var Video = 61;
121
- var TextArea = 62;
122
- var Select = 63;
123
- var Option = 64;
60
+ const VirtualDomElements = {
61
+ __proto__: null,
62
+ A,
63
+ Abbr,
64
+ Article,
65
+ Aside,
66
+ Audio,
67
+ Br,
68
+ Button,
69
+ Cite,
70
+ Col,
71
+ ColGroup,
72
+ Data,
73
+ Dd,
74
+ Del,
75
+ Div,
76
+ Dl,
77
+ Figcaption,
78
+ Figure,
79
+ Footer,
80
+ H1,
81
+ H2,
82
+ H3,
83
+ H4,
84
+ H5,
85
+ H6,
86
+ Header,
87
+ Hr,
88
+ I,
89
+ Img,
90
+ Input,
91
+ Ins,
92
+ Kbd,
93
+ Li,
94
+ Nav,
95
+ Ol,
96
+ Option,
97
+ P,
98
+ Pre,
99
+ Root,
100
+ Search,
101
+ Section,
102
+ Select,
103
+ Span,
104
+ TBody,
105
+ THead,
106
+ Table,
107
+ Td,
108
+ Text,
109
+ TextArea,
110
+ Tfoot,
111
+ Th,
112
+ Time,
113
+ Tr,
114
+ Ul,
115
+ Video
116
+ };
124
117
 
125
- // src/parts/Text/Text.ts
126
- var text = (data) => {
118
+ const text = data => {
127
119
  return {
128
120
  type: Text,
129
121
  text: data,
@@ -131,23 +123,23 @@ var text = (data) => {
131
123
  };
132
124
  };
133
125
 
134
- // src/parts/PatchType/PatchType.ts
135
- var SetText = 1;
136
- var SetAttribute = 3;
137
- var RemoveAttribute = 4;
138
- var Add = 6;
139
- var NavigateChild = 7;
140
- var NavigateParent = 8;
141
- var RemoveChild = 9;
142
- var NavigateSibling = 10;
126
+ const SetText = 1;
127
+ const SetAttribute = 3;
128
+ const RemoveAttribute = 4;
129
+ const Add = 6;
130
+ const NavigateChild = 7;
131
+ const NavigateParent = 8;
132
+ const RemoveChild = 9;
133
+ const NavigateSibling = 10;
143
134
 
144
- // src/parts/ApplyPendingPatches/ApplyPendingPatches.ts
145
- var applyPendingPatches = (patches, pendingPatches, skip) => {
135
+ const applyPendingPatches = (patches, pendingPatches, skip) => {
146
136
  for (let k = 0; k < pendingPatches.length - skip; k += 2) {
147
137
  const type = pendingPatches[k];
148
138
  const index = pendingPatches[k + 1];
149
139
  if (type === NavigateParent) {
150
- patches.push({ type });
140
+ patches.push({
141
+ type
142
+ });
151
143
  } else {
152
144
  patches.push({
153
145
  type,
@@ -158,19 +150,16 @@ var applyPendingPatches = (patches, pendingPatches, skip) => {
158
150
  pendingPatches.length = 0;
159
151
  };
160
152
 
161
- // src/parts/IsKey/IsKey.ts
162
- var isKey = (key) => {
163
- return key !== "type" && key !== "childCount";
153
+ const isKey = key => {
154
+ return key !== 'type' && key !== 'childCount';
164
155
  };
165
156
 
166
- // src/parts/GetKeys/GetKeys.ts
167
- var getKeys = (node) => {
157
+ const getKeys = node => {
168
158
  const keys = Object.keys(node).filter(isKey);
169
159
  return keys;
170
160
  };
171
161
 
172
- // src/parts/GetTotalChildCount/GetTotalChildCount.ts
173
- var getTotalChildCount = (nodes, index) => {
162
+ const getTotalChildCount = (nodes, index) => {
174
163
  let i = index;
175
164
  let pending = 1;
176
165
  while (pending) {
@@ -182,8 +171,7 @@ var getTotalChildCount = (nodes, index) => {
182
171
  return i - index;
183
172
  };
184
173
 
185
- // src/parts/VirtualDomDiff/VirtualDomDiff.ts
186
- var diff = (oldNodes, newNodes) => {
174
+ const diff = (oldNodes, newNodes) => {
187
175
  const patches = [];
188
176
  const pendingPatches = [];
189
177
  let i = 0;
@@ -194,8 +182,8 @@ var diff = (oldNodes, newNodes) => {
194
182
  while (i < oldNodes.length && j < newNodes.length) {
195
183
  const oldNode = oldNodes[i];
196
184
  const newNode = newNodes[j];
197
- if (siblingOffset > 0) {
198
- }
185
+
186
+ // TODO maybe don't have the current element in indexstack
199
187
  if (siblingOffset === maxSiblingOffset) {
200
188
  indexStack.pop();
201
189
  indexStack.pop();
@@ -350,9 +338,5 @@ var diff = (oldNodes, newNodes) => {
350
338
  }
351
339
  return patches;
352
340
  };
353
- export {
354
- VirtualDomElements_exports as VirtualDomElements,
355
- diff,
356
- mergeClassNames,
357
- text
358
- };
341
+
342
+ export { VirtualDomElements, diff, mergeClassNames, text };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom-worker",
3
- "version": "1.18.0",
3
+ "version": "1.20.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -1,4 +1,4 @@
1
- export * from '../DomEventListener/DomEventListener.ts'
1
+ export type * from '../DomEventListener/DomEventListener.ts'
2
2
  export * from '../MergeClassNames/MergeClassNames.ts'
3
3
  export * from '../Text/Text.ts'
4
4
  export { diff } from '../VirtualDomDiff/VirtualDomDiff.ts'