@lvce-editor/main-area-worker 9.67.9 → 9.68.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.
@@ -1765,7 +1765,7 @@ const closeTab = (state, groupId, tabId) => {
1765
1765
 
1766
1766
  const handleAttach = async command => {
1767
1767
  // TODO find a better way to append editors
1768
- const parentNodeSelector = '.editor-groups-container, .EditorGroup';
1768
+ const parentNodeSelector = '.EditorGroupsContainer, .EditorGroup';
1769
1769
  await invoke$2('Layout.attachViewlet', parentNodeSelector, command.instanceId);
1770
1770
  };
1771
1771
 
@@ -2310,11 +2310,23 @@ const closeTabWithViewlet = async (state, groupId, tabId) => {
2310
2310
  return newState;
2311
2311
  };
2312
2312
 
2313
+ const legacyRenderers = new WeakSet();
2313
2314
  const saveEditor = async (editorUid, skipFormatting = false) => {
2314
- if (skipFormatting) {
2315
- return invoke$2('Editor.save', editorUid, true);
2315
+ const args = skipFormatting ? [editorUid, true] : [editorUid];
2316
+ const rpc = get$2(RendererWorker);
2317
+ if (legacyRenderers.has(rpc)) {
2318
+ return invoke$2('Editor.save', ...args);
2319
+ }
2320
+ try {
2321
+ return await invoke$2('Viewlet.save', ...args);
2322
+ } catch (error) {
2323
+ // Older renderers support only text editors. Never retry an actual save failure.
2324
+ if (!(error instanceof Error) || !['Command not found Viewlet.save', 'Command "Viewlet.save" not found (renderer worker)'].includes(error.message)) {
2325
+ throw error;
2326
+ }
2327
+ legacyRenderers.add(rpc);
2328
+ return invoke$2('Editor.save', ...args);
2316
2329
  }
2317
- return invoke$2('Editor.save', editorUid);
2318
2330
  };
2319
2331
 
2320
2332
  const promptLegacy = async (message, discardPrompt) => {
@@ -2885,6 +2897,7 @@ const focus = async state => {
2885
2897
  }
2886
2898
  const selector = activeTab?.tab.terminal ? '.xterm-helper-textarea' : '[name="editor"]';
2887
2899
  if (isConnected()) {
2900
+ await invoke$1(state.applicationId, 'Layout.renderMainAreaPending', state.uid);
2888
2901
  await invoke('Viewlet.focusSelector', editorUid, selector);
2889
2902
  await invoke('Viewlet.focusSelectorAfterRender', editorUid, selector);
2890
2903
  } else {
@@ -3885,7 +3898,7 @@ const EditorContentLargeFileActions = 'EditorContentLargeFileActions';
3885
3898
  const EditorLargeFileWarningIcon = 'MaskIcon MaskIconWarning EditorLargeFileWarningIcon';
3886
3899
  const DragOverlay = 'DragOverlay';
3887
3900
  const Main = 'Main';
3888
- const EDITOR_GROUPS_CONTAINER = 'editor-groups-container';
3901
+ const EDITOR_GROUPS_CONTAINER = 'EditorGroupsContainer';
3889
3902
  const TabIcon = 'TabIcon';
3890
3903
  const TabTitle = 'TabTitle';
3891
3904
  const Button = 'Button';
@@ -8849,6 +8862,23 @@ const save = async state => {
8849
8862
  const saveWithoutFormatting = async state => {
8850
8863
  return saveInternal(state, true);
8851
8864
  };
8865
+ const saveAll = async context => {
8866
+ const initialState = context.getState();
8867
+ const tabs = initialState.layout.groups.flatMap(group => group.tabs).filter(tab => tab.isDirty && tab.loadingState !== 'loading');
8868
+ for (const tab of tabs) {
8869
+ const current = context.getState().layout.groups.flatMap(group => group.tabs).find(item => item.id === tab.id);
8870
+ if (!current?.isDirty || current.editorUid !== tab.editorUid) {
8871
+ continue;
8872
+ }
8873
+ const result = await saveEditorAndHandleSettingsChange(current, initialState.applicationId);
8874
+ if (result?.modified) {
8875
+ continue;
8876
+ }
8877
+ await context.updateState(state => updateTab(state, tab.id, {
8878
+ isDirty: false
8879
+ }));
8880
+ }
8881
+ };
8852
8882
 
8853
8883
  const getSavedTab = tab => {
8854
8884
  const normalizedTab = normalizeTabEditorInput(tab);
@@ -9205,6 +9235,7 @@ const commandMap = {
9205
9235
  'Main.openUris': wrapSerialAsyncCommand(openUrisWithContext),
9206
9236
  'Main.restoreClosedTab': wrapSerialCommand(restoreClosedTab),
9207
9237
  'Main.save': wrapSerialCommand(save),
9238
+ 'Main.saveAll': wrapAsyncCommand(saveAll),
9208
9239
  'Main.saveState': wrapGetter(saveState),
9209
9240
  'Main.splitRight': splitRightAndResize,
9210
9241
  'MainArea.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
@@ -9286,6 +9317,7 @@ const commandMap = {
9286
9317
  'MainArea.resize': resize,
9287
9318
  'MainArea.restoreClosedTab': wrapSerialCommand(restoreClosedTab),
9288
9319
  'MainArea.save': wrapSerialCommand(save),
9320
+ 'MainArea.saveAll': wrapAsyncCommand(saveAll),
9289
9321
  'MainArea.saveState': wrapGetter(saveState),
9290
9322
  'MainArea.saveWithoutFormatting': wrapSerialCommand(saveWithoutFormatting),
9291
9323
  'MainArea.selectTab': wrapSerialCommand(selectTab),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.67.9",
3
+ "version": "9.68.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",