@lvce-editor/main-area-worker 9.67.6 → 9.67.7

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.
@@ -2107,11 +2107,20 @@ const findTabById = (state, tabId) => {
2107
2107
  return undefined;
2108
2108
  };
2109
2109
 
2110
- const switchViewlet = async (state, fromTabId, toTabId) => {
2110
+ const switchViewlet = async (state, fromTabId, toTabId, waitForBlur = true) => {
2111
2111
  const previous = fromTabId === undefined ? undefined : findTabById(state, fromTabId)?.tab;
2112
2112
  if (fromTabId !== toTabId && previous && previous.editorUid >= 0 && previous.loadingState === 'loaded' && previous.editorInput?.type === 'editor') {
2113
2113
  // Browsers do not consistently emit blur when a focused editor reference is detached.
2114
- await invoke$1(state.applicationId, 'Viewlet.executeViewletCommand', previous.editorUid, 'handleBlur');
2114
+ const blur = invoke$1(state.applicationId, 'Viewlet.executeViewletCommand', previous.editorUid, 'handleBlur');
2115
+ if (waitForBlur) {
2116
+ await blur;
2117
+ } else {
2118
+ // Opening a new editor can originate inside the outgoing editor's command queue.
2119
+ // Waiting for blur there would deadlock the navigation command.
2120
+ void blur.catch(() => {
2121
+ // The outgoing editor may have been disposed while blur was queued.
2122
+ });
2123
+ }
2115
2124
  }
2116
2125
  return {
2117
2126
  commands: [],
@@ -3397,11 +3406,12 @@ const selectTab = async (state, groupIndex, index) => {
3397
3406
  } = selectedTabData;
3398
3407
  const normalizedTab = normalizeTabEditorInput(tab);
3399
3408
  const isAlreadyActive = activeGroupId === groupId && group.activeTabId === tabId;
3400
- if (isAlreadyActive && !shouldLoadContentForTab(normalizedTab)) {
3409
+ const needsLoading = shouldLoadContentForTab(normalizedTab);
3410
+ const needsViewlet = normalizedTab.editorUid === -1 && Boolean(normalizedTab.uri);
3411
+ if (isAlreadyActive && !needsLoading && !needsViewlet) {
3401
3412
  return state;
3402
3413
  }
3403
3414
  const previousTabId = getActiveTabId$1(state);
3404
- const needsLoading = shouldLoadContentForTab(normalizedTab);
3405
3415
  const requestId = needsLoading ? getNextRequestId() : 0;
3406
3416
  const updatedGroups = getUpdatedGroups(groups, groupIndex, needsLoading, tabId);
3407
3417
  let newState = {
@@ -5602,7 +5612,7 @@ const openInputWithContext = async (context, options) => {
5602
5612
  let intermediateState = stateWithViewlet;
5603
5613
  const {
5604
5614
  newState: switchedState
5605
- } = await switchViewlet(intermediateState, previousTabId, tabId);
5615
+ } = await switchViewlet(intermediateState, previousTabId, tabId, false);
5606
5616
  intermediateState = switchedState;
5607
5617
  await context.updateState(() => intermediateState);
5608
5618
  const tabWithViewlet = findTabById(intermediateState, tabId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.67.6",
3
+ "version": "9.67.7",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",