@lvce-editor/virtual-dom 6.2.0 → 6.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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +62 -61
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export interface TextPatch {
|
|
|
45
45
|
readonly value: string;
|
|
46
46
|
}
|
|
47
47
|
export type Patch = TextPatch | AttributePatch | ReplacePatch | RemoveAttributePatch | RemovePatch | AddPatch | NavigateChildPatch | NavigateParentPatch | RemoveChildPatch | NavigateSiblingPatch;
|
|
48
|
-
export declare const applyPatch: ($Element: Node, patches: readonly Patch[], eventMap?: Record<string, any
|
|
48
|
+
export declare const applyPatch: ($Element: Node, patches: readonly Patch[], eventMap?: Record<string, any>, id?: any) => void;
|
|
49
49
|
export declare const setComponentUid: ($Element: any, uid: any) => void;
|
|
50
50
|
export declare const getComponentUid: ($Element: any) => number;
|
|
51
51
|
export declare const getComponentUidFromEvent: (event: any) => number;
|
package/dist/index.js
CHANGED
|
@@ -735,41 +735,6 @@ const NavigateParent = 8;
|
|
|
735
735
|
const RemoveChild = 9;
|
|
736
736
|
const NavigateSibling = 10;
|
|
737
737
|
|
|
738
|
-
const applyPatch = ($Element, patches, eventMap = {}) => {
|
|
739
|
-
let $Current = $Element;
|
|
740
|
-
for (const patch of patches) {
|
|
741
|
-
switch (patch.type) {
|
|
742
|
-
case Add:
|
|
743
|
-
add$1($Current, patch.nodes, eventMap);
|
|
744
|
-
break;
|
|
745
|
-
case NavigateChild:
|
|
746
|
-
$Current = $Current.childNodes[patch.index];
|
|
747
|
-
break;
|
|
748
|
-
case NavigateParent:
|
|
749
|
-
$Current = $Current.parentNode;
|
|
750
|
-
break;
|
|
751
|
-
case NavigateSibling:
|
|
752
|
-
$Current = $Current.parentNode.childNodes[patch.index];
|
|
753
|
-
break;
|
|
754
|
-
case RemoveAttribute:
|
|
755
|
-
removeAttribute($Current, patch.key);
|
|
756
|
-
break;
|
|
757
|
-
case RemoveChild:
|
|
758
|
-
removeChild($Current, patch.index);
|
|
759
|
-
break;
|
|
760
|
-
case Replace:
|
|
761
|
-
$Current = replace($Current, patch.nodes, eventMap);
|
|
762
|
-
break;
|
|
763
|
-
case SetAttribute:
|
|
764
|
-
setProp($Current, patch.key, patch.value, eventMap);
|
|
765
|
-
break;
|
|
766
|
-
case SetText:
|
|
767
|
-
setText($Current, patch.value);
|
|
768
|
-
break;
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
|
|
773
738
|
const dragInfos = Object.create(null);
|
|
774
739
|
const setDragInfo = (id, data) => {
|
|
775
740
|
dragInfos[id] = data;
|
|
@@ -784,32 +749,6 @@ const isDragInfoOld = data => {
|
|
|
784
749
|
return Array.isArray(data);
|
|
785
750
|
};
|
|
786
751
|
|
|
787
|
-
let id = 0;
|
|
788
|
-
const create = () => {
|
|
789
|
-
return ++id;
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
const state = Object.create(null);
|
|
793
|
-
const acquire = id => {
|
|
794
|
-
const promise = state[id];
|
|
795
|
-
delete state[id];
|
|
796
|
-
return promise;
|
|
797
|
-
};
|
|
798
|
-
const getFileHandles = async ids => {
|
|
799
|
-
const promises = ids.map(acquire);
|
|
800
|
-
const handles = await Promise.all(promises);
|
|
801
|
-
return handles;
|
|
802
|
-
};
|
|
803
|
-
const add = promise => {
|
|
804
|
-
const id = create();
|
|
805
|
-
state[id] = promise;
|
|
806
|
-
return id;
|
|
807
|
-
};
|
|
808
|
-
const addFileHandle = fileHandle => {
|
|
809
|
-
const promise = Promise.resolve(fileHandle);
|
|
810
|
-
return add(promise);
|
|
811
|
-
};
|
|
812
|
-
|
|
813
752
|
const setDragImage = (dataTransfer, label) => {
|
|
814
753
|
const dragImage = document.createElement('div');
|
|
815
754
|
dragImage.className = 'DragImage';
|
|
@@ -862,6 +801,32 @@ const enabled = () => {
|
|
|
862
801
|
return ignore;
|
|
863
802
|
};
|
|
864
803
|
|
|
804
|
+
let id = 0;
|
|
805
|
+
const create = () => {
|
|
806
|
+
return ++id;
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
const state = Object.create(null);
|
|
810
|
+
const acquire = id => {
|
|
811
|
+
const promise = state[id];
|
|
812
|
+
delete state[id];
|
|
813
|
+
return promise;
|
|
814
|
+
};
|
|
815
|
+
const getFileHandles = async ids => {
|
|
816
|
+
const promises = ids.map(acquire);
|
|
817
|
+
const handles = await Promise.all(promises);
|
|
818
|
+
return handles;
|
|
819
|
+
};
|
|
820
|
+
const add = promise => {
|
|
821
|
+
const id = create();
|
|
822
|
+
state[id] = promise;
|
|
823
|
+
return id;
|
|
824
|
+
};
|
|
825
|
+
const addFileHandle = fileHandle => {
|
|
826
|
+
const promise = Promise.resolve(fileHandle);
|
|
827
|
+
return add(promise);
|
|
828
|
+
};
|
|
829
|
+
|
|
865
830
|
const unwrapItemString = async item => {
|
|
866
831
|
const {
|
|
867
832
|
resolve,
|
|
@@ -1056,6 +1021,42 @@ const getEventListenerMap = id => {
|
|
|
1056
1021
|
return map;
|
|
1057
1022
|
};
|
|
1058
1023
|
|
|
1024
|
+
const applyPatch = ($Element, patches, eventMap = {}, id = 0) => {
|
|
1025
|
+
const events = getEventListenerMap(id) || eventMap;
|
|
1026
|
+
let $Current = $Element;
|
|
1027
|
+
for (const patch of patches) {
|
|
1028
|
+
switch (patch.type) {
|
|
1029
|
+
case Add:
|
|
1030
|
+
add$1($Current, patch.nodes, events);
|
|
1031
|
+
break;
|
|
1032
|
+
case NavigateChild:
|
|
1033
|
+
$Current = $Current.childNodes[patch.index];
|
|
1034
|
+
break;
|
|
1035
|
+
case NavigateParent:
|
|
1036
|
+
$Current = $Current.parentNode;
|
|
1037
|
+
break;
|
|
1038
|
+
case NavigateSibling:
|
|
1039
|
+
$Current = $Current.parentNode.childNodes[patch.index];
|
|
1040
|
+
break;
|
|
1041
|
+
case RemoveAttribute:
|
|
1042
|
+
removeAttribute($Current, patch.key);
|
|
1043
|
+
break;
|
|
1044
|
+
case RemoveChild:
|
|
1045
|
+
removeChild($Current, patch.index);
|
|
1046
|
+
break;
|
|
1047
|
+
case Replace:
|
|
1048
|
+
$Current = replace($Current, patch.nodes, events);
|
|
1049
|
+
break;
|
|
1050
|
+
case SetAttribute:
|
|
1051
|
+
setProp($Current, patch.key, patch.value, events);
|
|
1052
|
+
break;
|
|
1053
|
+
case SetText:
|
|
1054
|
+
setText($Current, patch.value);
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1059
1060
|
const getActiveElementInside = $Viewlet => {
|
|
1060
1061
|
if (!$Viewlet) {
|
|
1061
1062
|
return undefined;
|