@lvce-editor/virtual-dom 1.8.0 → 1.10.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
@@ -22,3 +22,8 @@ export const rememberFocus: (
22
22
  ) => void
23
23
 
24
24
  export const registerEventListeners: any
25
+
26
+ export const applyPatch: (
27
+ $Element: HTMLElement,
28
+ patches: readonly any[],
29
+ ) => void
package/dist/index.js CHANGED
@@ -1,12 +1,3 @@
1
- // src/parts/PatchType/PatchType.ts
2
- var SetText = 1;
3
- var SetAttribute = 3;
4
- var RemoveAttribute = 4;
5
- var Add = 6;
6
- var NavigateChild = 7;
7
- var RemoveChild = 9;
8
- var NavigateSibling = 10;
9
-
10
1
  // src/parts/ElementTags/ElementTags.ts
11
2
  var Audio = "audio";
12
3
  var Button = "button";
@@ -59,6 +50,7 @@ var Video = "video";
59
50
  var TextArea = "textarea";
60
51
  var Select = "select";
61
52
  var Option = "option";
53
+ var Code = "code";
62
54
 
63
55
  // src/parts/VirtualDomElements/VirtualDomElements.ts
64
56
  var Audio2 = 0;
@@ -113,6 +105,7 @@ var Video2 = 61;
113
105
  var TextArea2 = 62;
114
106
  var Select2 = 63;
115
107
  var Option2 = 64;
108
+ var Code2 = 65;
116
109
 
117
110
  // src/parts/ElementTagMap/ElementTagMap.ts
118
111
  var getElementTag = (type) => {
@@ -219,6 +212,8 @@ var getElementTag = (type) => {
219
212
  return Select;
220
213
  case Option2:
221
214
  return Option;
215
+ case Code2:
216
+ return Code;
222
217
  default:
223
218
  throw new Error(`element tag not found ${type}`);
224
219
  }
@@ -488,6 +483,16 @@ var add = ($Element, nodes) => {
488
483
  renderInternal2($Element, nodes, {}, {});
489
484
  };
490
485
 
486
+ // src/parts/PatchType/PatchType.ts
487
+ var SetText = 1;
488
+ var SetAttribute = 3;
489
+ var RemoveAttribute = 4;
490
+ var Add = 6;
491
+ var NavigateChild = 7;
492
+ var NavigateParent = 8;
493
+ var RemoveChild = 9;
494
+ var NavigateSibling = 10;
495
+
491
496
  // src/parts/ApplyPatch/ApplyPatch.ts
492
497
  var applyPatch = ($Element, patches) => {
493
498
  let $Current = $Element;
@@ -518,6 +523,9 @@ var applyPatch = ($Element, patches) => {
518
523
  case NavigateChild:
519
524
  $Current = $Current.childNodes[patch.index];
520
525
  break;
526
+ case NavigateParent:
527
+ $Current = $Current.parentNode;
528
+ break;
521
529
  default:
522
530
  break;
523
531
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -2,6 +2,5 @@ import type { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts'
2
2
 
3
3
  export interface AddPatch {
4
4
  readonly type: 6
5
- readonly index: number
6
5
  readonly nodes: readonly VirtualDomNode[]
7
6
  }
@@ -1,6 +1,6 @@
1
1
  import { Patch } from '../Patch/Patch.ts'
2
- import * as PatchType from '../PatchType/PatchType.ts'
3
2
  import * as PatchFunctions from '../PatchFunctions/PatchFunctions.ts'
3
+ import * as PatchType from '../PatchType/PatchType.ts'
4
4
 
5
5
  export const applyPatch = ($Element: Node, patches: readonly Patch[]): void => {
6
6
  let $Current = $Element
@@ -31,6 +31,9 @@ export const applyPatch = ($Element: Node, patches: readonly Patch[]): void => {
31
31
  case PatchType.NavigateChild:
32
32
  $Current = ($Current as HTMLElement).childNodes[patch.index]
33
33
  break
34
+ case PatchType.NavigateParent:
35
+ $Current = $Current.parentNode as HTMLElement
36
+ break
34
37
  default:
35
38
  break
36
39
  }
@@ -105,6 +105,8 @@ export const getElementTag = (type) => {
105
105
  return ElementTag.Select
106
106
  case VirtualDomElements.Option:
107
107
  return ElementTag.Option
108
+ case VirtualDomElements.Code:
109
+ return ElementTag.Code
108
110
  default:
109
111
  throw new Error(`element tag not found ${type}`)
110
112
  }
@@ -50,3 +50,4 @@ export const Video = 'video'
50
50
  export const TextArea = 'textarea'
51
51
  export const Select = 'select'
52
52
  export const Option = 'option'
53
+ export const Code = 'code'
@@ -1,4 +1,3 @@
1
1
  export type NavigateParentPatch = {
2
2
  readonly type: 8
3
- readonly count: number
4
3
  }
@@ -1,5 +1,5 @@
1
- import { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts'
2
1
  import * as RenderInternal from '../RenderInternal/RenderInternal.ts'
2
+ import { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts'
3
3
 
4
4
  export const setAttribute = (
5
5
  $Element: HTMLElement,
@@ -1,5 +1,4 @@
1
1
  export interface RemoveAttributePatch {
2
2
  readonly type: 4
3
- readonly index: number
4
3
  readonly key: string
5
4
  }
@@ -52,3 +52,4 @@ export const Video = 61
52
52
  export const TextArea = 62
53
53
  export const Select = 63
54
54
  export const Option = 64
55
+ export const Code = 65