@lvce-editor/main-area-worker 9.28.1 → 9.28.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.
@@ -4083,8 +4083,11 @@ const getGroupSegments = (groups, parentDirection) => {
4083
4083
  if (group.direction !== undefined && group.direction !== parentDirection) {
4084
4084
  const startIndex = index;
4085
4085
  const nestedGroups = [group];
4086
+ const {
4087
+ segmentId
4088
+ } = group;
4086
4089
  index++;
4087
- while (index < groups.length && groups[index].direction === group.direction) {
4090
+ while (index < groups.length && groups[index].direction === group.direction && groups[index].segmentId === segmentId) {
4088
4091
  nestedGroups.push(groups[index]);
4089
4092
  index++;
4090
4093
  }
@@ -4176,6 +4179,7 @@ const splitWithinMatchingNestedDirection = (state, groups, sourceGroup, groupId,
4176
4179
  const newGroup = {
4177
4180
  ...baseNewGroup,
4178
4181
  direction: splitLayoutDirection,
4182
+ segmentId: sourceGroup.segmentId,
4179
4183
  size: Number((sourceGroup.size / 2).toFixed(6))
4180
4184
  };
4181
4185
  const insertIndex = isTrailingSplit(direction) ? sourceIndex + 1 : sourceIndex;
@@ -4185,15 +4189,18 @@ const splitWithinMatchingNestedDirection = (state, groups, sourceGroup, groupId,
4185
4189
  const splitStandaloneSourceIntoNestedDirection = (state, groups, sourceGroup, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup) => {
4186
4190
  const sourceIndex = groups.findIndex(group => group.id === groupId);
4187
4191
  const halfSize = Number((sourceGroup.size / 2).toFixed(6));
4192
+ const segmentId = sourceGroup.segmentId ?? sourceGroup.id;
4188
4193
  const updatedSourceGroup = {
4189
4194
  ...sourceGroup,
4190
4195
  direction: splitLayoutDirection,
4191
4196
  focused: false,
4197
+ segmentId,
4192
4198
  size: halfSize
4193
4199
  };
4194
4200
  const newGroup = {
4195
4201
  ...baseNewGroup,
4196
4202
  direction: splitLayoutDirection,
4203
+ segmentId,
4197
4204
  size: Number((sourceGroup.size - halfSize).toFixed(6))
4198
4205
  };
4199
4206
  const replacementGroups = isTrailingSplit(direction) ? [updatedSourceGroup, newGroup] : [newGroup, updatedSourceGroup];
@@ -4329,7 +4336,10 @@ const handleClickCloseTab = async (state, rawGroupIndex, rawIndex) => {
4329
4336
  return closeTabAndSave(state, groupId, tabId);
4330
4337
  };
4331
4338
 
4332
- const handleClickTab = async (state, groupIndexRaw, indexRaw) => {
4339
+ const handleClickTab = async (state, groupIndexRaw, indexRaw, button = 0) => {
4340
+ if (button !== 0) {
4341
+ return state;
4342
+ }
4333
4343
  if (!groupIndexRaw || !indexRaw) {
4334
4344
  return state;
4335
4345
  }
@@ -4859,7 +4869,7 @@ const isValidTab = tab => {
4859
4869
  };
4860
4870
 
4861
4871
  const isValidEditorGroup = group => {
4862
- return group && typeof group.id === 'number' && Array.isArray(group.tabs) && group.tabs.every(isValidTab) && (group.activeTabId === undefined || typeof group.activeTabId === 'number') && (group.direction === undefined || isLayoutDirection(group.direction)) && typeof group.focused === 'boolean' && typeof group.size === 'number' && group.size > 0 && typeof group.isEmpty === 'boolean';
4872
+ return group && typeof group.id === 'number' && Array.isArray(group.tabs) && group.tabs.every(isValidTab) && (group.activeTabId === undefined || typeof group.activeTabId === 'number') && (group.direction === undefined || isLayoutDirection(group.direction)) && typeof group.focused === 'boolean' && (group.segmentId === undefined || typeof group.segmentId === 'number') && typeof group.size === 'number' && group.size > 0 && typeof group.isEmpty === 'boolean';
4863
4873
  };
4864
4874
 
4865
4875
  const isValidMainAreaLayout = layout => {
@@ -5095,6 +5105,24 @@ const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
5095
5105
  return loadContent(state, savedState);
5096
5106
  };
5097
5107
 
5108
+ const handleWorkspaceRefresh = async (state, deletedUris = []) => {
5109
+ const deleted = new Set(deletedUris);
5110
+ let newState = state;
5111
+ for (const group of state.layout.groups) {
5112
+ for (const tab of group.tabs) {
5113
+ if (tab.editorInput?.type === 'editor' && deleted.has(tab.editorInput.uri)) {
5114
+ newState = await closeTabWithViewlet(newState, group.id, tab.id);
5115
+ }
5116
+ }
5117
+ }
5118
+ return newState;
5119
+ };
5120
+ const handleWorkspaceRefreshWithContext = async (context, deletedUris = []) => {
5121
+ const state = context.getState();
5122
+ const newState = await handleWorkspaceRefresh(state, deletedUris);
5123
+ await context.updateState(() => newState);
5124
+ };
5125
+
5098
5126
  const hasActiveTextEditor = state => {
5099
5127
  const activeTab = getActiveTab(state);
5100
5128
  return activeTab?.tab.editorInput?.type === 'editor';
@@ -6452,7 +6480,7 @@ const renderEventListeners = () => {
6452
6480
  params: ['handleClickCloseTab', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
6453
6481
  }, {
6454
6482
  name: HandleClickTab,
6455
- params: ['handleClickTab', 'event.target.dataset.groupIndex', 'event.target.dataset.index']
6483
+ params: ['handleClickTab', 'event.target.dataset.groupIndex', 'event.target.dataset.index', Button$1]
6456
6484
  }, {
6457
6485
  name: HandleContextMenu,
6458
6486
  params: ['handleContextMenu', 'event.target.dataset.groupId', ClientX, ClientY],
@@ -6745,6 +6773,7 @@ const setEditorLayout = (state, direction, slots) => {
6745
6773
  ...group,
6746
6774
  direction: slot.direction,
6747
6775
  focused,
6776
+ segmentId: slot.segmentId,
6748
6777
  size: slot.size
6749
6778
  };
6750
6779
  });
@@ -6808,39 +6837,51 @@ const setEditorLayoutThreeRows = state => {
6808
6837
  }]);
6809
6838
  };
6810
6839
  const setEditorLayoutGrid = state => {
6840
+ const leftSegmentId = create$2();
6841
+ const rightSegmentId = create$2();
6811
6842
  return setEditorLayout(state, Horizontal, [{
6812
6843
  direction: Vertical,
6844
+ segmentId: leftSegmentId,
6813
6845
  size: 25
6814
6846
  }, {
6815
6847
  direction: Vertical,
6848
+ segmentId: leftSegmentId,
6816
6849
  size: 25
6817
6850
  }, {
6818
6851
  direction: Vertical,
6852
+ segmentId: rightSegmentId,
6819
6853
  size: 25
6820
6854
  }, {
6821
6855
  direction: Vertical,
6856
+ segmentId: rightSegmentId,
6822
6857
  size: 25
6823
6858
  }]);
6824
6859
  };
6825
6860
  const setEditorLayoutTwoRowsRight = state => {
6861
+ const segmentId = create$2();
6826
6862
  return setEditorLayout(state, Horizontal, [{
6827
6863
  size: 50
6828
6864
  }, {
6829
6865
  direction: Vertical,
6866
+ segmentId,
6830
6867
  size: 25
6831
6868
  }, {
6832
6869
  direction: Vertical,
6870
+ segmentId,
6833
6871
  size: 25
6834
6872
  }]);
6835
6873
  };
6836
6874
  const setEditorLayoutTwoColumnsBottom = state => {
6875
+ const segmentId = create$2();
6837
6876
  return setEditorLayout(state, Vertical, [{
6838
6877
  size: 50
6839
6878
  }, {
6840
6879
  direction: Horizontal,
6880
+ segmentId,
6841
6881
  size: 25
6842
6882
  }, {
6843
6883
  direction: Horizontal,
6884
+ segmentId,
6844
6885
  size: 25
6845
6886
  }]);
6846
6887
  };
@@ -7046,6 +7087,7 @@ const commandMap = {
7046
7087
  'MainArea.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
7047
7088
  'MainArea.handleUriChange': wrapSerialCommand(handleUriChange),
7048
7089
  'MainArea.handleWorkspaceChange': wrapSerialCommand(handleWorkspaceChange),
7090
+ 'MainArea.handleWorkspaceRefresh': wrapAsyncCommand(handleWorkspaceRefreshWithContext),
7049
7091
  'MainArea.hasActiveTextEditor': wrapGetter(hasActiveTextEditor),
7050
7092
  'MainArea.initialize': initialize,
7051
7093
  'MainArea.loadContent': wrapSerialCommand(loadContent),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.28.1",
3
+ "version": "9.28.2",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",