@lvce-editor/main-area-worker 5.4.0 → 5.6.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.
@@ -98,10 +98,22 @@ const closeAll$1 = state => {
98
98
  };
99
99
  };
100
100
 
101
+ const Button$1 = 'event.button';
102
+ const ClientX = 'event.clientX';
103
+ const ClientY = 'event.clientY';
104
+ const TargetName = 'event.target.name';
105
+
106
+ const Tab = 13;
107
+
108
+ const Separator = 1;
109
+ const None = 0;
110
+
101
111
  const ExtensionHostWorker = 44;
102
112
  const IconThemeWorker = 7009;
103
113
  const RendererWorker = 1;
104
114
 
115
+ const SetDom2 = 'Viewlet.setDom2';
116
+
105
117
  const normalizeLine = line => {
106
118
  if (line.startsWith('Error: ')) {
107
119
  return line.slice('Error: '.length);
@@ -1645,18 +1657,6 @@ const diff2 = uid => {
1645
1657
  return result;
1646
1658
  };
1647
1659
 
1648
- const Button$1 = 'event.button';
1649
- const ClientX = 'event.clientX';
1650
- const ClientY = 'event.clientY';
1651
- const TargetName = 'event.target.name';
1652
-
1653
- const Tab = 13;
1654
-
1655
- const Separator = 1;
1656
- const None = 0;
1657
-
1658
- const SetDom2 = 'Viewlet.setDom2';
1659
-
1660
1660
  const getMenuIds = () => {
1661
1661
  return [Tab];
1662
1662
  };
@@ -1752,6 +1752,10 @@ const shouldLoadContent = tab => {
1752
1752
  if (tab.loadingState === 'loaded' && tab.content) {
1753
1753
  return false;
1754
1754
  }
1755
+ // Don't load if content already exists
1756
+ if (tab.content) {
1757
+ return false;
1758
+ }
1755
1759
  return true;
1756
1760
  };
1757
1761
  const getActiveTabId$1 = state => {
@@ -2930,6 +2934,42 @@ const resize = (state, dimensions) => {
2930
2934
  };
2931
2935
  };
2932
2936
 
2937
+ const getActiveTab = state => {
2938
+ const {
2939
+ layout
2940
+ } = state;
2941
+ const {
2942
+ groups
2943
+ } = layout;
2944
+ const activeGroup = groups.find(group => group.focused);
2945
+ if (!activeGroup || !activeGroup.activeTabId) {
2946
+ return undefined;
2947
+ }
2948
+ const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
2949
+ if (!activeTab) {
2950
+ return undefined;
2951
+ }
2952
+ return {
2953
+ groupId: activeGroup.id,
2954
+ tab: activeTab
2955
+ };
2956
+ };
2957
+
2958
+ const save = async state => {
2959
+ const activeTabData = getActiveTab(state);
2960
+ if (!activeTabData) {
2961
+ return state;
2962
+ }
2963
+ const {
2964
+ tab
2965
+ } = activeTabData;
2966
+ if (tab.loadingState !== 'loaded') {
2967
+ return state;
2968
+ }
2969
+ await invoke('Editor.save', tab.editorUid);
2970
+ return state;
2971
+ };
2972
+
2933
2973
  const saveState = state => {
2934
2974
  const {
2935
2975
  layout
@@ -2958,6 +2998,7 @@ const commandMap = {
2958
2998
  'MainArea.render2': render2,
2959
2999
  'MainArea.renderEventListeners': renderEventListeners,
2960
3000
  'MainArea.resize': wrapCommand(resize),
3001
+ 'MainArea.save': wrapCommand(save),
2961
3002
  'MainArea.saveState': wrapGetter(saveState),
2962
3003
  'MainArea.selectTab': wrapCommand(selectTab),
2963
3004
  'MainArea.terminate': terminate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "5.4.0",
3
+ "version": "5.6.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",