@lvce-editor/main-area-worker 9.66.1 → 9.67.1

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.
@@ -2288,7 +2288,10 @@ const closeTabWithViewlet = async (state, groupId, tabId) => {
2288
2288
  return newState;
2289
2289
  };
2290
2290
 
2291
- const saveEditor = async editorUid => {
2291
+ const saveEditor = async (editorUid, skipFormatting = false) => {
2292
+ if (skipFormatting) {
2293
+ return invoke$2('Editor.save', editorUid, true);
2294
+ }
2292
2295
  return invoke$2('Editor.save', editorUid);
2293
2296
  };
2294
2297
 
@@ -7894,25 +7897,25 @@ const getEditorInputUris = editorInput => {
7894
7897
  return [];
7895
7898
  }
7896
7899
  };
7897
- const getChangedEditorUid = (editorUid, editorInput, uri, changedUris) => {
7900
+ const getChangedEditorUid = (editorUid, editorInput, uri, changedUris, reloadAll) => {
7898
7901
  if (editorUid === -1) {
7899
7902
  return undefined;
7900
7903
  }
7901
7904
  const uris = getEditorInputUris(editorInput);
7902
- if (uris.some(editorUri => changedUris.has(editorUri)) || uris.length === 0 && uri && changedUris.has(uri)) {
7905
+ if (reloadAll && (uris.length > 0 || uri) || uris.some(editorUri => changedUris.has(editorUri)) || uris.length === 0 && uri && changedUris.has(uri)) {
7903
7906
  return editorUid;
7904
7907
  }
7905
7908
  return undefined;
7906
7909
  };
7907
- const reloadChangedEditors = async (state, changed) => {
7908
- if (changed.length === 0) {
7910
+ const reloadChangedEditors = async (state, changed, reloadAll) => {
7911
+ if (changed.length === 0 && !reloadAll) {
7909
7912
  return;
7910
7913
  }
7911
7914
  const changedUris = new Set(changed);
7912
7915
  const editorUids = new Set();
7913
7916
  for (const group of state.layout.groups) {
7914
7917
  for (const tab of group.tabs) {
7915
- const editorUid = getChangedEditorUid(tab.editorUid, tab.editorInput, tab.uri, changedUris);
7918
+ const editorUid = getChangedEditorUid(tab.editorUid, tab.editorInput, tab.uri, changedUris, reloadAll);
7916
7919
  if (editorUid !== undefined) {
7917
7920
  editorUids.add(editorUid);
7918
7921
  }
@@ -7929,6 +7932,7 @@ const handleWorkspaceRefresh = async (state, refresh = {}) => {
7929
7932
  deleted = [],
7930
7933
  renamed = []
7931
7934
  } = changes;
7935
+ const reloadAll = changes.reloadAll === true;
7932
7936
  let newState = state;
7933
7937
  for (const [oldUri, newUri] of renamed) {
7934
7938
  newState = await handleUriChange(newState, oldUri, newUri);
@@ -7941,7 +7945,7 @@ const handleWorkspaceRefresh = async (state, refresh = {}) => {
7941
7945
  }
7942
7946
  }
7943
7947
  }
7944
- await reloadChangedEditors(newState, changed);
7948
+ await reloadChangedEditors(newState, changed, reloadAll);
7945
7949
  return newState;
7946
7950
  };
7947
7951
  const handleWorkspaceRefreshWithContext = async (context, refresh = {}) => {
@@ -8733,8 +8737,8 @@ const resize$1 = (state, dimensions) => {
8733
8737
  };
8734
8738
 
8735
8739
  const settingsUri = 'app://settings.json';
8736
- const saveEditorAndHandleSettingsChange = async (tab, applicationId) => {
8737
- const editorState = await saveEditor(tab.editorUid);
8740
+ const saveEditorAndHandleSettingsChange = async (tab, applicationId, skipFormatting = false) => {
8741
+ const editorState = await saveEditor(tab.editorUid, skipFormatting);
8738
8742
  if (!editorState?.modified && tab.uri === settingsUri) {
8739
8743
  await invoke$1(applicationId, 'Layout.handleSettingsChanged');
8740
8744
  }
@@ -8761,7 +8765,7 @@ const getLatestStoredState = (uid, fallbackState, referenceTabId, referenceTabUr
8761
8765
  }
8762
8766
  return fallbackState;
8763
8767
  };
8764
- const save = async state => {
8768
+ const saveInternal = async (state, skipFormatting) => {
8765
8769
  const {
8766
8770
  uid
8767
8771
  } = state;
@@ -8778,10 +8782,10 @@ const save = async state => {
8778
8782
  return currentState;
8779
8783
  }
8780
8784
  if (!tab.isDirty) {
8781
- await saveEditorAndHandleSettingsChange(tab, state.applicationId);
8785
+ await saveEditorAndHandleSettingsChange(tab, state.applicationId, skipFormatting);
8782
8786
  return getLatestStoredState(uid, currentState, tab.id, tab.uri);
8783
8787
  }
8784
- const editorState = await saveEditorAndHandleSettingsChange(tab, state.applicationId);
8788
+ const editorState = await saveEditorAndHandleSettingsChange(tab, state.applicationId, skipFormatting);
8785
8789
  const latestState = getLatestStoredState(uid, currentState, tab.id, tab.uri);
8786
8790
  if (editorState?.modified) {
8787
8791
  return latestState;
@@ -8794,6 +8798,12 @@ const save = async state => {
8794
8798
  isDirty: false
8795
8799
  });
8796
8800
  };
8801
+ const save = async state => {
8802
+ return saveInternal(state, false);
8803
+ };
8804
+ const saveWithoutFormatting = async state => {
8805
+ return saveInternal(state, true);
8806
+ };
8797
8807
 
8798
8808
  const getSavedTab = tab => {
8799
8809
  const normalizedTab = normalizeTabEditorInput(tab);
@@ -9215,6 +9225,7 @@ const commandMap = {
9215
9225
  'MainArea.restoreClosedTab': wrapSerialCommand(restoreClosedTab),
9216
9226
  'MainArea.save': wrapSerialCommand(save),
9217
9227
  'MainArea.saveState': wrapGetter(saveState),
9228
+ 'MainArea.saveWithoutFormatting': wrapSerialCommand(saveWithoutFormatting),
9218
9229
  'MainArea.selectTab': wrapSerialCommand(selectTab),
9219
9230
  'MainArea.setComponentState': setComponentState,
9220
9231
  'MainArea.setEditorLayoutGrid': wrapSerialCommand(setEditorLayoutGrid),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.66.1",
3
+ "version": "9.67.1",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",