@lvce-editor/renderer-process 21.2.0 → 21.3.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.
@@ -681,38 +681,6 @@ const propertyToAttribute = {
681
681
 
682
682
  // Style properties that need to be set on element.style
683
683
  const styleProperties = new Set(['width', 'height', 'top', 'left', 'marginTop', 'paddingLeft', 'paddingRight']);
684
-
685
- // TODO merge this with the setProp function
686
-
687
- const setAttribute = ($Element, key, value) => {
688
- // Handle width/height for images (set as attributes, not style)
689
- if ((key === 'width' || key === 'height') && $Element instanceof HTMLImageElement) {
690
- // @ts-ignore - dynamic property access
691
- $Element[key] = value;
692
- return;
693
- }
694
-
695
- // Handle style properties
696
- if (styleProperties.has(key)) {
697
- // @ts-ignore - dynamic style property access
698
- $Element.style[key] = typeof value === 'number' ? `${value}px` : value;
699
- return;
700
- }
701
-
702
- // Handle aria attributes - map camelCase to hyphenated form
703
- if (key in propertyToAttribute) {
704
- $Element.setAttribute(propertyToAttribute[key], value);
705
- return;
706
- }
707
-
708
- // Use property assignment for known DOM properties, attribute for others
709
- if (key in $Element) {
710
- // @ts-ignore - dynamic property access
711
- $Element[key] = value;
712
- } else {
713
- $Element.setAttribute(key, value);
714
- }
715
- };
716
684
  const removeAttribute = ($Element, key) => {
717
685
  // Handle style properties
718
686
  if (styleProperties.has(key)) {
@@ -751,40 +719,6 @@ const NavigateChild = 7;
751
719
  const NavigateParent = 8;
752
720
  const RemoveChild = 9;
753
721
  const NavigateSibling = 10;
754
- const applyPatch = ($Element, patches, eventMap = {}) => {
755
- let $Current = $Element;
756
- for (const patch of patches) {
757
- switch (patch.type) {
758
- case Add:
759
- add$1($Current, patch.nodes, eventMap);
760
- break;
761
- case NavigateChild:
762
- $Current = $Current.childNodes[patch.index];
763
- break;
764
- case NavigateParent:
765
- $Current = $Current.parentNode;
766
- break;
767
- case NavigateSibling:
768
- $Current = $Current.parentNode.childNodes[patch.index];
769
- break;
770
- case RemoveAttribute:
771
- removeAttribute($Current, patch.key);
772
- break;
773
- case RemoveChild:
774
- removeChild($Current, patch.index);
775
- break;
776
- case Replace:
777
- $Current = replace($Current, patch.nodes, eventMap);
778
- break;
779
- case SetAttribute:
780
- setAttribute($Current, patch.key, patch.value);
781
- break;
782
- case SetText:
783
- setText$3($Current, patch.value);
784
- break;
785
- }
786
- }
787
- };
788
722
  const dragInfos = Object.create(null);
789
723
  const setDragInfo = (id, data) => {
790
724
  dragInfos[id] = data;
@@ -795,30 +729,6 @@ const getDragInfo = id => {
795
729
  const isDragInfoOld = data => {
796
730
  return Array.isArray(data);
797
731
  };
798
- let id$1 = 0;
799
- const create$G = () => {
800
- return ++id$1;
801
- };
802
- const state$8 = Object.create(null);
803
- const acquire$1 = id => {
804
- const promise = state$8[id];
805
- delete state$8[id];
806
- return promise;
807
- };
808
- const getFileHandles$1 = async ids => {
809
- const promises = ids.map(acquire$1);
810
- const handles = await Promise.all(promises);
811
- return handles;
812
- };
813
- const add = promise => {
814
- const id = create$G();
815
- state$8[id] = promise;
816
- return id;
817
- };
818
- const addFileHandle$1 = fileHandle => {
819
- const promise = Promise.resolve(fileHandle);
820
- return add(promise);
821
- };
822
732
  const setDragImage = (dataTransfer, label) => {
823
733
  const dragImage = document.createElement('div');
824
734
  dragImage.className = 'DragImage';
@@ -867,6 +777,30 @@ const stopIgnore = () => {
867
777
  const enabled = () => {
868
778
  return ignore;
869
779
  };
780
+ let id$1 = 0;
781
+ const create$G = () => {
782
+ return ++id$1;
783
+ };
784
+ const state$8 = Object.create(null);
785
+ const acquire$1 = id => {
786
+ const promise = state$8[id];
787
+ delete state$8[id];
788
+ return promise;
789
+ };
790
+ const getFileHandles$1 = async ids => {
791
+ const promises = ids.map(acquire$1);
792
+ const handles = await Promise.all(promises);
793
+ return handles;
794
+ };
795
+ const add = promise => {
796
+ const id = create$G();
797
+ state$8[id] = promise;
798
+ return id;
799
+ };
800
+ const addFileHandle$1 = fileHandle => {
801
+ const promise = Promise.resolve(fileHandle);
802
+ return add(promise);
803
+ };
870
804
  const unwrapItemString = async item => {
871
805
  const {
872
806
  resolve,
@@ -1055,6 +989,41 @@ const getEventListenerMap = id => {
1055
989
  const map = listeners[id];
1056
990
  return map;
1057
991
  };
992
+ const applyPatch = ($Element, patches, eventMap = {}, id = 0) => {
993
+ const events = getEventListenerMap(id) || eventMap;
994
+ let $Current = $Element;
995
+ for (const patch of patches) {
996
+ switch (patch.type) {
997
+ case Add:
998
+ add$1($Current, patch.nodes, events);
999
+ break;
1000
+ case NavigateChild:
1001
+ $Current = $Current.childNodes[patch.index];
1002
+ break;
1003
+ case NavigateParent:
1004
+ $Current = $Current.parentNode;
1005
+ break;
1006
+ case NavigateSibling:
1007
+ $Current = $Current.parentNode.childNodes[patch.index];
1008
+ break;
1009
+ case RemoveAttribute:
1010
+ removeAttribute($Current, patch.key);
1011
+ break;
1012
+ case RemoveChild:
1013
+ removeChild($Current, patch.index);
1014
+ break;
1015
+ case Replace:
1016
+ $Current = replace($Current, patch.nodes, events);
1017
+ break;
1018
+ case SetAttribute:
1019
+ setProp($Current, patch.key, patch.value, events);
1020
+ break;
1021
+ case SetText:
1022
+ setText$3($Current, patch.value);
1023
+ break;
1024
+ }
1025
+ }
1026
+ };
1058
1027
  const getActiveElementInside = $Viewlet => {
1059
1028
  if (!$Viewlet) {
1060
1029
  return undefined;
@@ -9158,7 +9127,7 @@ const setPatches = (uid, patches) => {
9158
9127
  setDom2(uid, patches[0].nodes);
9159
9128
  return;
9160
9129
  }
9161
- applyPatch($Viewlet, patches);
9130
+ applyPatch($Viewlet, patches, {}, uid);
9162
9131
  };
9163
9132
 
9164
9133
  // TODO this code is bad
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "21.2.0",
3
+ "version": "21.3.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"