@lvce-editor/main-area-worker 9.30.1 → 9.30.2

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.
@@ -1739,6 +1739,8 @@ const SetCss = 'Viewlet.setCss';
1739
1739
  const SetDom2 = 'Viewlet.setDom2';
1740
1740
  const SetPatches = 'Viewlet.setPatches';
1741
1741
 
1742
+ const FocusEditorText = 12;
1743
+
1742
1744
  const {
1743
1745
  set: set$4
1744
1746
  } = create$3(ClipBoardWorker);
@@ -2235,18 +2237,25 @@ const closeTabWithViewlet = async (state, groupId, tabId) => {
2235
2237
  const newState = closeTab(state, groupId, tabId);
2236
2238
  const group = state.layout.groups.find(g => g.id === groupId);
2237
2239
  const wasActiveTab = group?.activeTabId === tabId;
2238
- if (wasActiveTab) {
2239
- const newGroup = newState.layout.groups.find(g => g.id === groupId);
2240
- const newActiveTabId = newGroup?.activeTabId;
2241
- if (newActiveTabId !== undefined) {
2242
- const {
2243
- commands: switchCommands,
2244
- newState: switchedState
2245
- } = switchViewlet(newState);
2246
- commands.push(...switchCommands);
2247
- await executeViewletCommands(commands);
2248
- return switchedState;
2240
+ const newGroup = wasActiveTab ? newState.layout.groups.find(candidate => candidate.id === groupId) : undefined;
2241
+ const newActiveTabId = newGroup?.activeTabId;
2242
+ if (wasActiveTab && commands.length > 0) {
2243
+ if (newActiveTabId === undefined) {
2244
+ return {
2245
+ ...newState,
2246
+ pendingViewletUpdate: {
2247
+ disposal: tab.editorUid
2248
+ }
2249
+ };
2249
2250
  }
2251
+ const newActiveTab = newGroup?.tabs.find(candidate => candidate.id === newActiveTabId);
2252
+ return {
2253
+ ...newState,
2254
+ pendingViewletUpdate: {
2255
+ disposal: tab.editorUid,
2256
+ focus: newActiveTab?.editorUid === -1 ? undefined : newActiveTab?.editorUid
2257
+ }
2258
+ };
2250
2259
  }
2251
2260
  if (commands.length > 0) {
2252
2261
  await executeViewletCommands(commands);
@@ -2296,10 +2305,7 @@ const closeTabAndSave = async (state, groupId, tabId) => {
2296
2305
  return state;
2297
2306
  }
2298
2307
  }
2299
- if (tab.uri?.startsWith('simple-browser://')) {
2300
- return closeTabWithViewlet(state, groupId, tabId);
2301
- }
2302
- return closeTab(state, groupId, tabId);
2308
+ return closeTabWithViewlet(state, groupId, tabId);
2303
2309
  };
2304
2310
 
2305
2311
  const getFocusedGroup = state => {
@@ -2677,9 +2683,13 @@ const isEqual = (oldState, newState) => {
2677
2683
  const RenderItems = 4;
2678
2684
  const RenderCss = 10;
2679
2685
  const RenderIncremental = 11;
2686
+ const RenderPendingViewletUpdate = 12;
2680
2687
 
2681
- const modules = [isEqual, isEqual$1];
2682
- const numbers = [RenderIncremental, RenderCss];
2688
+ const isPendingViewletUpdateEqual = (oldState, newState) => {
2689
+ return newState.pendingViewletUpdate === undefined;
2690
+ };
2691
+ const modules = [isEqual, isEqual$1, isPendingViewletUpdateEqual];
2692
+ const numbers = [RenderIncremental, RenderCss, RenderPendingViewletUpdate];
2683
2693
 
2684
2694
  const diff = (oldState, newState) => {
2685
2695
  const diffResult = [];
@@ -6522,6 +6532,15 @@ const renderIncremental = (oldState, newState) => {
6522
6532
  return [SetPatches, newState.uid, patches];
6523
6533
  };
6524
6534
 
6535
+ const renderPendingViewletUpdate = (oldState, newState) => {
6536
+ const update = newState.pendingViewletUpdate;
6537
+ newState.pendingViewletUpdate = undefined;
6538
+ setTimeout(() => {
6539
+ void invoke('Viewlet.dispose', update.disposal).catch(() => {});
6540
+ }, 50);
6541
+ return update.focus === undefined ? [] : ['Viewlet.setFocusContext', update.focus, FocusEditorText, 0, update.focus, 'Editor'];
6542
+ };
6543
+
6525
6544
  const getRenderer = diffType => {
6526
6545
  switch (diffType) {
6527
6546
  case RenderCss:
@@ -6530,6 +6549,8 @@ const getRenderer = diffType => {
6530
6549
  return renderIncremental;
6531
6550
  case RenderItems:
6532
6551
  return renderItems;
6552
+ case RenderPendingViewletUpdate:
6553
+ return renderPendingViewletUpdate;
6533
6554
  default:
6534
6555
  throw new Error('unknown renderer');
6535
6556
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.30.1",
3
+ "version": "9.30.2",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",