@lvce-editor/main-area-worker 9.33.1 → 9.33.3

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.
@@ -1503,6 +1503,10 @@ const Main$1 = 24;
1503
1503
  const Separator = 1;
1504
1504
  const None$1 = 0;
1505
1505
 
1506
+ const Add$1 = 6;
1507
+ const NavigateChild$1 = 7;
1508
+ const NavigateParent$1 = 8;
1509
+
1506
1510
  const Electron = 2;
1507
1511
 
1508
1512
  const ClipBoardWorker = 3400;
@@ -2326,7 +2330,10 @@ const findTabInState = (state, groupId, tabId) => {
2326
2330
  const {
2327
2331
  layout
2328
2332
  } = state;
2329
- const group = layout.groups.find(g => g.id === groupId);
2333
+ const {
2334
+ groups
2335
+ } = layout;
2336
+ const group = groups.find(g => g.id === groupId);
2330
2337
  return group?.tabs.find(t => t.id === tabId);
2331
2338
  };
2332
2339
 
@@ -2334,6 +2341,9 @@ const closeTabWithViewlet = async (state, groupId, tabId) => {
2334
2341
  const {
2335
2342
  layout
2336
2343
  } = state;
2344
+ const {
2345
+ groups
2346
+ } = layout;
2337
2347
  const tab = findTabInState(state, groupId, tabId);
2338
2348
  const commands = [];
2339
2349
  if (tab && tab.editorUid !== -1) {
@@ -2343,7 +2353,7 @@ const closeTabWithViewlet = async (state, groupId, tabId) => {
2343
2353
  commands.push(...disposeCommands);
2344
2354
  }
2345
2355
  const newState = closeTab(state, groupId, tabId);
2346
- const group = layout.groups.find(g => g.id === groupId);
2356
+ const group = groups.find(g => g.id === groupId);
2347
2357
  const wasActiveTab = group?.activeTabId === tabId;
2348
2358
  const newGroup = wasActiveTab ? newState.layout.groups.find(candidate => candidate.id === groupId) : undefined;
2349
2359
  const newActiveTabId = newGroup?.activeTabId;
@@ -2467,9 +2477,12 @@ const closeAll$1 = async state => {
2467
2477
  const {
2468
2478
  layout
2469
2479
  } = state;
2470
- const editorUids = layout.groups.flatMap(group => group.tabs.map(tab => tab.editorUid)).filter(editorUid => editorUid !== -1);
2480
+ const {
2481
+ groups
2482
+ } = layout;
2483
+ const editorUids = groups.flatMap(group => group.tabs.map(tab => tab.editorUid)).filter(editorUid => editorUid !== -1);
2471
2484
  await disposeEditors(editorUids);
2472
- const entries = layout.groups.flatMap((group, groupIndex) => {
2485
+ const entries = groups.flatMap((group, groupIndex) => {
2473
2486
  return group.tabs.map((tab, tabIndex) => ({
2474
2487
  group,
2475
2488
  groupIndex,
@@ -2635,7 +2648,10 @@ const closeFirstTabByUri = (state, uri) => {
2635
2648
  const {
2636
2649
  layout
2637
2650
  } = state;
2638
- const matchingGroup = layout.groups.find(group => {
2651
+ const {
2652
+ groups
2653
+ } = layout;
2654
+ const matchingGroup = groups.find(group => {
2639
2655
  return group.tabs.some(tab => tab.uri === uri);
2640
2656
  });
2641
2657
  const matchingTab = matchingGroup?.tabs.find(tab => tab.uri === uri);
@@ -2660,7 +2676,10 @@ const getGroupById = (state, groupId) => {
2660
2676
  const {
2661
2677
  layout
2662
2678
  } = state;
2663
- return layout.groups.find(group => group.id === groupId);
2679
+ const {
2680
+ groups
2681
+ } = layout;
2682
+ return groups.find(group => group.id === groupId);
2664
2683
  };
2665
2684
 
2666
2685
  const closeTabsRight = (state, groupId) => {
@@ -3045,7 +3064,10 @@ const getSelectedTabData = (state, groupIndex, index) => {
3045
3064
  const {
3046
3065
  layout
3047
3066
  } = state;
3048
- const group = layout.groups[groupIndex];
3067
+ const {
3068
+ groups
3069
+ } = layout;
3070
+ const group = groups[groupIndex];
3049
3071
  if (!group || index < 0 || index >= group.tabs.length) {
3050
3072
  return undefined;
3051
3073
  }
@@ -3226,6 +3248,7 @@ const selectTab = async (state, groupIndex, index) => {
3226
3248
  uid
3227
3249
  } = state;
3228
3250
  const {
3251
+ activeGroupId,
3229
3252
  groups
3230
3253
  } = layout;
3231
3254
  if (groupIndex < 0 || groupIndex >= groups.length) {
@@ -3242,7 +3265,7 @@ const selectTab = async (state, groupIndex, index) => {
3242
3265
  tabId
3243
3266
  } = selectedTabData;
3244
3267
  const normalizedTab = normalizeTabEditorInput(tab);
3245
- const isAlreadyActive = layout.activeGroupId === groupId && group.activeTabId === tabId;
3268
+ const isAlreadyActive = activeGroupId === groupId && group.activeTabId === tabId;
3246
3269
  if (isAlreadyActive && !shouldLoadContentForTab(normalizedTab)) {
3247
3270
  return state;
3248
3271
  }
@@ -3458,6 +3481,9 @@ const restoreExistingUri = (state, entry) => {
3458
3481
  const {
3459
3482
  layout
3460
3483
  } = state;
3484
+ const {
3485
+ groups: layoutGroups
3486
+ } = layout;
3461
3487
  if (!entry.tab.uri) {
3462
3488
  return undefined;
3463
3489
  }
@@ -3465,11 +3491,11 @@ const restoreExistingUri = (state, entry) => {
3465
3491
  if (!existing) {
3466
3492
  return undefined;
3467
3493
  }
3468
- const groupIndex = layout.groups.findIndex(group => group.id === existing.groupId);
3494
+ const groupIndex = layoutGroups.findIndex(group => group.id === existing.groupId);
3469
3495
  if (groupIndex === -1) {
3470
3496
  return undefined;
3471
3497
  }
3472
- const tabIndex = layout.groups[groupIndex].tabs.findIndex(tab => tab.id === existing.tab.id);
3498
+ const tabIndex = layoutGroups[groupIndex].tabs.findIndex(tab => tab.id === existing.tab.id);
3473
3499
  if (tabIndex === -1) {
3474
3500
  return undefined;
3475
3501
  }
@@ -3637,7 +3663,10 @@ const getTabCount = state => {
3637
3663
  const {
3638
3664
  layout
3639
3665
  } = state;
3640
- return layout.groups.reduce((sum, group) => sum + group.tabs.length, 0);
3666
+ const {
3667
+ groups
3668
+ } = layout;
3669
+ return groups.reduce((sum, group) => sum + group.tabs.length, 0);
3641
3670
  };
3642
3671
 
3643
3672
  const getCurrentState = state => {
@@ -3754,12 +3783,15 @@ const updateTabUriTitles = state => {
3754
3783
  homeDirUri: rawHomeDirUri,
3755
3784
  layout
3756
3785
  } = state;
3786
+ const {
3787
+ groups
3788
+ } = layout;
3757
3789
  const homeDirUri = rawHomeDirUri || '';
3758
3790
  return {
3759
3791
  ...state,
3760
3792
  layout: {
3761
3793
  ...layout,
3762
- groups: layout.groups.map(group => ({
3794
+ groups: groups.map(group => ({
3763
3795
  ...group,
3764
3796
  tabs: group.tabs.map(tab => updateTabUriTitle(tab, homeDirUri))
3765
3797
  }))
@@ -3773,6 +3805,7 @@ const createEmptyGroup$1 = (state, uri, requestId, preview = false, title = getL
3773
3805
  layout
3774
3806
  } = state;
3775
3807
  const {
3808
+ direction,
3776
3809
  groups
3777
3810
  } = layout;
3778
3811
  const groupId = create$2();
@@ -3795,6 +3828,7 @@ const createEmptyGroup$1 = (state, uri, requestId, preview = false, title = getL
3795
3828
  };
3796
3829
  const newGroup = {
3797
3830
  activeTabId: newTab.id,
3831
+ direction,
3798
3832
  focused: true,
3799
3833
  id: groupId,
3800
3834
  isEmpty: false,
@@ -4143,7 +4177,11 @@ const getActivePreviewEditorUid = state => {
4143
4177
  const {
4144
4178
  layout
4145
4179
  } = state;
4146
- const activeGroup = layout.activeGroupId === undefined ? layout.groups.find(group => group.focused) : layout.groups.find(group => group.id === layout.activeGroupId);
4180
+ const {
4181
+ activeGroupId,
4182
+ groups
4183
+ } = layout;
4184
+ const activeGroup = activeGroupId === undefined ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
4147
4185
  const activeTab = activeGroup?.tabs.find(tab => tab.id === activeGroup.activeTabId);
4148
4186
  return activeTab?.isPreview ? activeTab.editorUid : -1;
4149
4187
  };
@@ -4308,7 +4346,7 @@ const getGroupSegments = (groups, parentDirection) => {
4308
4346
  let index = 0;
4309
4347
  while (index < groups.length) {
4310
4348
  const group = groups[index];
4311
- if (group.direction !== undefined && group.direction !== parentDirection) {
4349
+ if (group.direction !== parentDirection) {
4312
4350
  const startIndex = index;
4313
4351
  const nestedGroups = [group];
4314
4352
  const {
@@ -4359,11 +4397,14 @@ const createNextState = (state, activeGroupId, groups) => {
4359
4397
  const {
4360
4398
  layout
4361
4399
  } = state;
4400
+ const {
4401
+ direction
4402
+ } = layout;
4362
4403
  return {
4363
4404
  ...state,
4364
4405
  layout: {
4365
4406
  activeGroupId,
4366
- direction: layout.direction,
4407
+ direction,
4367
4408
  groups
4368
4409
  }
4369
4410
  };
@@ -4373,7 +4414,7 @@ const splitOnlyGroup = (state, groups, groupId, newGroupId, direction, splitLayo
4373
4414
  if (group.id === groupId) {
4374
4415
  return {
4375
4416
  ...group,
4376
- direction: undefined,
4417
+ direction: splitLayoutDirection,
4377
4418
  focused: false,
4378
4419
  size: 50
4379
4420
  };
@@ -4382,7 +4423,7 @@ const splitOnlyGroup = (state, groups, groupId, newGroupId, direction, splitLayo
4382
4423
  });
4383
4424
  const newGroup = {
4384
4425
  ...baseNewGroup,
4385
- direction: undefined,
4426
+ direction: splitLayoutDirection,
4386
4427
  size: 50
4387
4428
  };
4388
4429
  const reorderedGroups = isTrailingSplit(direction) ? [...updatedGroups, newGroup] : [newGroup, ...updatedGroups];
@@ -4443,7 +4484,7 @@ const splitAtRootLevel = (state, groups, groupId, newGroupId, direction, baseNew
4443
4484
  if (group.id === groupId) {
4444
4485
  return {
4445
4486
  ...group,
4446
- direction: undefined,
4487
+ direction: state.layout.direction,
4447
4488
  focused: false,
4448
4489
  size: 50
4449
4490
  };
@@ -4452,7 +4493,7 @@ const splitAtRootLevel = (state, groups, groupId, newGroupId, direction, baseNew
4452
4493
  });
4453
4494
  const newGroup = {
4454
4495
  ...baseNewGroup,
4455
- direction: undefined,
4496
+ direction: state.layout.direction,
4456
4497
  size: 50
4457
4498
  };
4458
4499
  const reorderedGroups = isTrailingSplit(direction) ? [...updatedGroups, newGroup] : (() => {
@@ -4466,6 +4507,7 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
4466
4507
  layout
4467
4508
  } = state;
4468
4509
  const {
4510
+ direction: layoutDirection,
4469
4511
  groups
4470
4512
  } = layout;
4471
4513
  const sourceGroup = groups.find(group => group.id === groupId);
@@ -4476,6 +4518,7 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
4476
4518
  const splitLayoutDirection = getSplitLayoutDirection(direction);
4477
4519
  const baseNewGroup = {
4478
4520
  activeTabId: undefined,
4521
+ direction: sourceGroup.direction,
4479
4522
  focused: true,
4480
4523
  id: newGroupId,
4481
4524
  isEmpty: true,
@@ -4485,15 +4528,15 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
4485
4528
  if (groups.length === 1) {
4486
4529
  return splitOnlyGroup(state, groups, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup);
4487
4530
  }
4488
- if (sourceGroup.direction === splitLayoutDirection) {
4531
+ if (sourceGroup.direction !== layoutDirection && sourceGroup.direction === splitLayoutDirection) {
4489
4532
  return splitWithinMatchingNestedDirection(state, groups, sourceGroup, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup);
4490
4533
  }
4491
- if (splitLayoutDirection !== layout.direction && sourceGroup.direction === undefined) {
4534
+ if (splitLayoutDirection !== layoutDirection && sourceGroup.direction === layoutDirection) {
4492
4535
  return splitStandaloneSourceIntoNestedDirection(state, groups, sourceGroup, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup);
4493
4536
  }
4494
- const segments = getGroupSegments(groups, layout.direction);
4537
+ const segments = getGroupSegments(groups, layoutDirection);
4495
4538
  const hasNestedSegments = segments.some(segment => segment.direction !== undefined);
4496
- if (splitLayoutDirection === layout.direction && !hasNestedSegments) {
4539
+ if (splitLayoutDirection === layoutDirection && !hasNestedSegments) {
4497
4540
  return splitAtRootLevel(state, groups, groupId, newGroupId, direction, baseNewGroup);
4498
4541
  }
4499
4542
  return createNextState(state, newGroupId, groups);
@@ -4608,12 +4651,15 @@ const handleDoubleClick = (state, groupIndexRaw, indexRaw) => {
4608
4651
  const {
4609
4652
  layout
4610
4653
  } = state;
4654
+ const {
4655
+ groups
4656
+ } = layout;
4611
4657
  if (!groupIndexRaw || !indexRaw) {
4612
4658
  return state;
4613
4659
  }
4614
4660
  const groupIndex = Number.parseInt(groupIndexRaw);
4615
4661
  const tabIndex = Number.parseInt(indexRaw);
4616
- const tab = layout.groups[groupIndex]?.tabs[tabIndex];
4662
+ const tab = groups[groupIndex]?.tabs[tabIndex];
4617
4663
  if (!tab?.isPreview) {
4618
4664
  return state;
4619
4665
  }
@@ -4710,7 +4756,10 @@ const getDragOverlay = (state, eventX, eventY) => {
4710
4756
  x,
4711
4757
  y
4712
4758
  } = state;
4713
- const hasOpenEditor = layout.groups.some(group => !group.isEmpty);
4759
+ const {
4760
+ groups
4761
+ } = layout;
4762
+ const hasOpenEditor = groups.some(group => !group.isEmpty);
4714
4763
  const contentY = hasOpenEditor ? tabHeight : 0;
4715
4764
  const contentHeight = Math.max(0, height - contentY);
4716
4765
  const relativeX = eventX - x;
@@ -4920,8 +4969,11 @@ const handleHeaderDoubleClick = async (state, className, groupIndexRaw) => {
4920
4969
  };
4921
4970
 
4922
4971
  const getAllTabs = layout => {
4972
+ const {
4973
+ groups
4974
+ } = layout;
4923
4975
  const allTabs = [];
4924
- for (const group of layout.groups) {
4976
+ for (const group of groups) {
4925
4977
  allTabs.push(...group.tabs);
4926
4978
  }
4927
4979
  return allTabs;
@@ -4932,6 +4984,9 @@ const loadFileIcons = async state => {
4932
4984
  fileIconCache,
4933
4985
  layout
4934
4986
  } = state;
4987
+ const {
4988
+ groups
4989
+ } = layout;
4935
4990
  try {
4936
4991
  const allTabs = getAllTabs(layout);
4937
4992
  const {
@@ -4941,7 +4996,7 @@ const loadFileIcons = async state => {
4941
4996
  // Update tabs with their icons
4942
4997
  const updatedLayout = {
4943
4998
  ...layout,
4944
- groups: layout.groups.map(group => ({
4999
+ groups: groups.map(group => ({
4945
5000
  ...group,
4946
5001
  tabs: group.tabs.map(tab => ({
4947
5002
  ...tab,
@@ -5054,7 +5109,11 @@ const offsetsMatch = (first, second) => {
5054
5109
  return Math.abs(first - second) < 1e-6;
5055
5110
  };
5056
5111
  const getSashCorner = layout => {
5057
- const segments = getGroupSegments(layout.groups, layout.direction);
5112
+ const {
5113
+ direction,
5114
+ groups
5115
+ } = layout;
5116
+ const segments = getGroupSegments(groups, direction);
5058
5117
  if (segments.length !== 2) {
5059
5118
  return undefined;
5060
5119
  }
@@ -5074,7 +5133,7 @@ const getSashCorner = layout => {
5074
5133
  return undefined;
5075
5134
  }
5076
5135
  const rootOffset = firstSegmentSize / totalSize * 100;
5077
- if (layout.direction === Horizontal) {
5136
+ if (direction === Horizontal) {
5078
5137
  return {
5079
5138
  leftOffset: rootOffset,
5080
5139
  topOffset: firstNestedOffset,
@@ -5098,6 +5157,9 @@ const handleSashCornerPointerDown = async (state, clientX, clientY) => {
5098
5157
  const {
5099
5158
  layout
5100
5159
  } = state;
5160
+ const {
5161
+ groups
5162
+ } = layout;
5101
5163
  if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {
5102
5164
  return state;
5103
5165
  }
@@ -5108,7 +5170,7 @@ const handleSashCornerPointerDown = async (state, clientX, clientY) => {
5108
5170
  return {
5109
5171
  ...state,
5110
5172
  sashCornerDrag: {
5111
- groupSizes: layout.groups.map(group => ({
5173
+ groupSizes: groups.map(group => ({
5112
5174
  id: group.id,
5113
5175
  size: group.size
5114
5176
  })),
@@ -5157,6 +5219,9 @@ const handleSashCornerPointerMove = async (state, clientX, clientY) => {
5157
5219
  sashCornerDrag,
5158
5220
  width
5159
5221
  } = state;
5222
+ const {
5223
+ groups
5224
+ } = layout;
5160
5225
  if (!sashCornerDrag || !width || !height || !Number.isFinite(clientX) || !Number.isFinite(clientY)) {
5161
5226
  return state;
5162
5227
  }
@@ -5183,7 +5248,7 @@ const handleSashCornerPointerMove = async (state, clientX, clientY) => {
5183
5248
  ...state,
5184
5249
  layout: {
5185
5250
  ...layout,
5186
- groups: layout.groups.map(group => {
5251
+ groups: groups.map(group => {
5187
5252
  const xSize = xBeforeGroupIdSet.has(group.id) ? xBeforeSize : xAfterSize;
5188
5253
  const ySize = yBeforeGroupIdSet.has(group.id) ? yBeforeSize : yAfterSize;
5189
5254
  return {
@@ -5431,7 +5496,7 @@ const isValidTab = tab => {
5431
5496
  };
5432
5497
 
5433
5498
  const isValidEditorGroup = group => {
5434
- 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';
5499
+ return group && typeof group.id === 'number' && Array.isArray(group.tabs) && group.tabs.every(isValidTab) && (group.activeTabId === undefined || typeof group.activeTabId === 'number') && 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';
5435
5500
  };
5436
5501
 
5437
5502
  const isValidMainAreaLayout = layout => {
@@ -5465,6 +5530,12 @@ const normalizeRestoredTab = tab => {
5465
5530
  isPreview: typeof tab?.isPreview === 'boolean' ? tab.isPreview : false
5466
5531
  };
5467
5532
  };
5533
+ const normalizeGroupDirection = (group, layoutDirection) => {
5534
+ if (!group || typeof group !== 'object' || !Object.hasOwn(group, 'direction')) {
5535
+ return layoutDirection;
5536
+ }
5537
+ return normalizeLayoutDirection(group.direction);
5538
+ };
5468
5539
  const tryRestoreLayout = savedState => {
5469
5540
  if (savedState === undefined || savedState === null) {
5470
5541
  return undefined;
@@ -5496,12 +5567,10 @@ const tryRestoreLayout = savedState => {
5496
5567
  ...rawLayout,
5497
5568
  direction: layoutDirection,
5498
5569
  groups: rawLayout.groups.map(group => {
5499
- const groupDirection = normalizeLayoutDirection(group?.direction);
5570
+ const groupDirection = normalizeGroupDirection(group, layoutDirection);
5500
5571
  return {
5501
5572
  ...group,
5502
- ...(groupDirection !== undefined && {
5503
- direction: groupDirection
5504
- }),
5573
+ direction: groupDirection,
5505
5574
  tabs: Array.isArray(group?.tabs) ? group.tabs.map(normalizeRestoredTab) : []
5506
5575
  };
5507
5576
  })
@@ -5513,9 +5582,12 @@ const tryRestoreLayout = savedState => {
5513
5582
  };
5514
5583
 
5515
5584
  const createViewlets = async (layout, viewletModuleIds, bounds) => {
5585
+ const {
5586
+ groups
5587
+ } = layout;
5516
5588
  const editorUids = {};
5517
5589
  const titles = {};
5518
- for (const group of layout.groups) {
5590
+ for (const group of groups) {
5519
5591
  const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
5520
5592
  if (activeTab && viewletModuleIds[activeTab.id]) {
5521
5593
  const editorUid = activeTab.editorUid === -1 ? create$2() : activeTab.editorUid;
@@ -5533,8 +5605,11 @@ const createViewlets = async (layout, viewletModuleIds, bounds) => {
5533
5605
  };
5534
5606
 
5535
5607
  const getViewletModuleIds = async layout => {
5608
+ const {
5609
+ groups
5610
+ } = layout;
5536
5611
  const viewletModuleIds = {};
5537
- for (const group of layout.groups) {
5612
+ for (const group of groups) {
5538
5613
  const {
5539
5614
  tabs
5540
5615
  } = group;
@@ -6121,17 +6196,25 @@ const getDragOverlayCss = dragOverlay => {
6121
6196
  y
6122
6197
  } = dragOverlay;
6123
6198
  return [`.DragOverlay {
6124
- left: ${x}px;
6125
- top: ${y}px;
6126
- width: ${width}px;
6127
- height: ${height}px;
6199
+ --DragOverlayLeft: ${x}px;
6200
+ --DragOverlayTop: ${y}px;
6201
+ --DragOverlayWidth: ${width}px;
6202
+ --DragOverlayHeight: ${height}px;
6128
6203
  }`];
6129
6204
  };
6130
6205
 
6206
+ const getEditorGroupClassName = groupId => {
6207
+ return `EditorGroup-${groupId}`;
6208
+ };
6209
+
6131
6210
  const getEditorGroupCss = layout => {
6132
- const groupSizeVariable = layout.direction === Vertical ? '--EditorGroupHeight' : '--EditorGroupWidth';
6133
- return layout.groups.map(group => {
6134
- return `.EditorGroup[data-groupId="${group.id}"] {
6211
+ const {
6212
+ direction,
6213
+ groups
6214
+ } = layout;
6215
+ const groupSizeVariable = direction === Vertical ? '--EditorGroupHeight' : '--EditorGroupWidth';
6216
+ return groups.map(group => {
6217
+ return `.${getEditorGroupClassName(group.id)} {
6135
6218
  ${groupSizeVariable}: ${group.size}%;
6136
6219
  }`;
6137
6220
  });
@@ -6173,7 +6256,11 @@ const renderSashCss = ({
6173
6256
  }`;
6174
6257
  };
6175
6258
  const getProtoSashCss = (layout, width) => {
6176
- const segments = getGroupSegments(layout.groups, layout.direction);
6259
+ const {
6260
+ direction,
6261
+ groups
6262
+ } = layout;
6263
+ const segments = getGroupSegments(groups, direction);
6177
6264
  const hasNestedSegments = segments.some(segment => segment.direction !== undefined);
6178
6265
  const rules = [];
6179
6266
  let segmentOffset = 0;
@@ -6182,9 +6269,9 @@ const getProtoSashCss = (layout, width) => {
6182
6269
  const beforeGroupId = segments[i - 1].groups.at(-1)?.id || 0;
6183
6270
  const afterGroupId = segments[i].groups[0].id;
6184
6271
  const sashId = create(beforeGroupId, afterGroupId);
6185
- const value = hasNestedSegments || layout.direction !== Horizontal || !width ? `${segmentOffset}%` : getSashOffset(layout, i, width);
6272
+ const value = hasNestedSegments || direction !== Horizontal || !width ? `${segmentOffset}%` : getSashOffset(layout, i, width);
6186
6273
  rules.push({
6187
- property: toSashProperty(layout.direction),
6274
+ property: toSashProperty(direction),
6188
6275
  sashId,
6189
6276
  value
6190
6277
  });
@@ -6211,58 +6298,17 @@ const getProtoSashCss = (layout, width) => {
6211
6298
  return rules;
6212
6299
  };
6213
6300
  const getSashCss = (layout, width = 0) => {
6214
- if (layout.groups.length <= 1) {
6301
+ const {
6302
+ groups
6303
+ } = layout;
6304
+ if (groups.length <= 1) {
6215
6305
  return [];
6216
6306
  }
6217
6307
  return getProtoSashCss(layout, width).map(renderSashCss);
6218
6308
  };
6219
6309
 
6220
6310
  const getCss = (layout, width = 0, dragOverlay) => {
6221
- const rules = [`.Main {
6222
- position: relative;
6223
- }`, `.editor-groups-container {
6224
- overflow: auto;
6225
- }`, `.DragOverlay {
6226
- position: absolute;
6227
- z-index: 1;
6228
- contain: strict;
6229
- pointer-events: none;
6230
- background: rgba(83, 89, 93, 0.5);
6231
- transition: all 100ms;
6232
- }`, `.SashBorder {
6233
- background: var(--SashBorder, gray);
6234
- }`, `.SashBorderHorizontal {
6235
- width: 100%;
6236
- height: 1px;
6237
- }`, `.SashBorderVertical {
6238
- width: 1px;
6239
- height: 100%;
6240
- }`, `.SashCorner {
6241
- position: absolute;
6242
- z-index: 2;
6243
- display: flex;
6244
- align-items: center;
6245
- justify-content: center;
6246
- width: 12px;
6247
- height: 12px;
6248
- padding: 0;
6249
- border: 0;
6250
- background: transparent;
6251
- cursor: all-scroll;
6252
- transform: translate(-50%, -50%);
6253
- }`, `.SashCorner::after {
6254
- content: '';
6255
- width: 4px;
6256
- height: 4px;
6257
- background: var(--SashBorder, gray);
6258
- }`, `.SashCorner:hover::after,
6259
- .SashCorner:active::after {
6260
- background: var(--SashHoverBorder, #3d5252);
6261
- }`, `.EditorGroup {
6262
- min-width: 250px;
6263
- width: var(--EditorGroupWidth, auto);
6264
- /*height: var(--EditorGroupHeight, auto);*/
6265
- }`];
6311
+ const rules = [];
6266
6312
  if (layout) {
6267
6313
  rules.push(...getEditorGroupCss(layout), ...getDragOverlayCss(dragOverlay), ...getSashCss(layout, width));
6268
6314
  const sashCorner = getSashCorner(layout);
@@ -6893,7 +6939,7 @@ const renderEmptyEditorGroup = (group, groupIndex, style, closeButtonEnabled = t
6893
6939
  const closeButtonDom = closeButtonEnabled ? renderEmptyGroupCloseButton(group) : [];
6894
6940
  return [{
6895
6941
  childCount: closeButtonEnabled ? 2 : 1,
6896
- className: EditorGroupEmpty,
6942
+ className: mergeClassNames(EditorGroupEmpty, getEditorGroupClassName(group.id)),
6897
6943
  'data-groupId': String(group.id),
6898
6944
  onContextMenu: HandleContextMenu,
6899
6945
  style,
@@ -6917,7 +6963,7 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
6917
6963
  }
6918
6964
  return [{
6919
6965
  childCount: 2,
6920
- className: EditorGroup,
6966
+ className: mergeClassNames(EditorGroup, getEditorGroupClassName(group.id)),
6921
6967
  'data-groupId': String(group.id),
6922
6968
  style,
6923
6969
  type: Div
@@ -6966,7 +7012,10 @@ const mainNode$1 = {
6966
7012
  type: Div
6967
7013
  };
6968
7014
  const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width') => {
6969
- return [mainNode$1, ...renderEditorGroup(layout.groups[0], 0, splitButtonEnabled, sizeProperty, false)];
7015
+ const {
7016
+ groups
7017
+ } = layout;
7018
+ return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, sizeProperty, false)];
6970
7019
  };
6971
7020
 
6972
7021
  const getDirectionClassName = (direction, isSplit) => {
@@ -6991,10 +7040,10 @@ const addDragOverlay = (dom, dragOverlay) => {
6991
7040
  if (!dragOverlay) {
6992
7041
  return dom;
6993
7042
  }
6994
- return [dom[0], {
6995
- ...dom[1],
6996
- childCount: dom[1].childCount + 1
6997
- }, ...dom.slice(2), getDragOverlayVirtualDom()];
7043
+ return [{
7044
+ ...dom[0],
7045
+ childCount: dom[0].childCount + 1
7046
+ }, dom[1], ...dom.slice(2), getDragOverlayVirtualDom()];
6998
7047
  };
6999
7048
  const getSizeProperty = direction => {
7000
7049
  return direction === Vertical ? 'height' : 'width';
@@ -7106,10 +7155,21 @@ const renderItems = (oldState, newState) => {
7106
7155
  return [SetDom2, uid, dom];
7107
7156
  };
7108
7157
 
7158
+ const avoidRootReplacement = patches => {
7159
+ if (patches.length !== 1 || patches[0].type !== Add$1 || patches[0].nodes?.length !== 1 || patches[0].nodes[0].className !== DragOverlay) {
7160
+ return patches;
7161
+ }
7162
+ return [{
7163
+ index: 0,
7164
+ type: NavigateChild$1
7165
+ }, {
7166
+ type: NavigateParent$1
7167
+ }, ...patches];
7168
+ };
7109
7169
  const renderIncremental = (oldState, newState) => {
7110
7170
  const oldDom = renderItems(oldState, oldState)[2];
7111
7171
  const newDom = renderItems(newState, newState)[2];
7112
- const patches = diffTree(oldDom, newDom);
7172
+ const patches = avoidRootReplacement(diffTree(oldDom, newDom));
7113
7173
  return [SetPatches, newState.uid, patches];
7114
7174
  };
7115
7175
 
@@ -7416,7 +7476,10 @@ const saveState = state => {
7416
7476
  const {
7417
7477
  layout
7418
7478
  } = state;
7419
- const filteredGroups = getFilteredGroups(layout.groups);
7479
+ const {
7480
+ groups
7481
+ } = layout;
7482
+ const filteredGroups = getFilteredGroups(groups);
7420
7483
 
7421
7484
  // Update activeGroupId if it points to a removed group
7422
7485
  const {
@@ -7435,9 +7498,10 @@ const saveState = state => {
7435
7498
  const flipDirection = direction => {
7436
7499
  return direction === Horizontal ? Vertical : Horizontal;
7437
7500
  };
7438
- const createEmptyGroup = () => {
7501
+ const createEmptyGroup = direction => {
7439
7502
  return {
7440
7503
  activeTabId: undefined,
7504
+ direction,
7441
7505
  focused: false,
7442
7506
  id: create$2(),
7443
7507
  isEmpty: true,
@@ -7468,9 +7532,9 @@ const mergeGroups = (target, groups, activeGroupId) => {
7468
7532
  tabs
7469
7533
  };
7470
7534
  };
7471
- const getGroupsForSlotCount = (groups, slotCount, activeGroupId) => {
7535
+ const getGroupsForSlotCount = (groups, slotCount, activeGroupId, direction) => {
7472
7536
  if (slotCount === 1) {
7473
- const firstGroup = groups[0] ?? createEmptyGroup();
7537
+ const firstGroup = groups[0] ?? createEmptyGroup(direction);
7474
7538
  return [mergeGroups(firstGroup, groups.slice(1), activeGroupId)];
7475
7539
  }
7476
7540
  if (groups.length === slotCount) {
@@ -7479,7 +7543,7 @@ const getGroupsForSlotCount = (groups, slotCount, activeGroupId) => {
7479
7543
  if (groups.length < slotCount) {
7480
7544
  const missingGroups = Array.from({
7481
7545
  length: slotCount - groups.length
7482
- }, createEmptyGroup);
7546
+ }, () => createEmptyGroup(direction));
7483
7547
  return [...groups, ...missingGroups];
7484
7548
  }
7485
7549
  const retainedGroups = groups.slice(0, slotCount);
@@ -7494,9 +7558,13 @@ const setEditorLayout = (state, direction, slots) => {
7494
7558
  const {
7495
7559
  layout
7496
7560
  } = state;
7497
- const groups = getGroupsForSlotCount(layout.groups, slots.length, layout.activeGroupId);
7498
- const originalActiveIndex = layout.groups.findIndex(group => group.id === layout.activeGroupId);
7499
- const activeIndex = originalActiveIndex >= slots.length ? slots.length - 1 : getActiveGroupIndex(groups, layout.activeGroupId);
7561
+ const {
7562
+ activeGroupId,
7563
+ groups: currentGroups
7564
+ } = layout;
7565
+ const groups = getGroupsForSlotCount(currentGroups, slots.length, activeGroupId, direction);
7566
+ const originalActiveIndex = currentGroups.findIndex(group => group.id === activeGroupId);
7567
+ const activeIndex = originalActiveIndex >= slots.length ? slots.length - 1 : getActiveGroupIndex(groups, activeGroupId);
7500
7568
  const nextGroups = groups.map((group, index) => {
7501
7569
  const slot = slots[index];
7502
7570
  const focused = index === activeIndex;
@@ -7521,52 +7589,67 @@ const flipLayout = state => {
7521
7589
  const {
7522
7590
  layout
7523
7591
  } = state;
7592
+ const {
7593
+ direction,
7594
+ groups
7595
+ } = layout;
7524
7596
  return {
7525
7597
  ...state,
7526
7598
  layout: {
7527
7599
  ...layout,
7528
- direction: flipDirection(layout.direction),
7529
- groups: layout.groups.map(group => ({
7600
+ direction: flipDirection(direction),
7601
+ groups: groups.map(group => ({
7530
7602
  ...group,
7531
- direction: group.direction === undefined ? undefined : flipDirection(group.direction)
7603
+ direction: flipDirection(group.direction)
7532
7604
  }))
7533
7605
  }
7534
7606
  };
7535
7607
  };
7536
7608
  const setEditorLayoutSingle = state => {
7537
7609
  return setEditorLayout(state, Horizontal, [{
7610
+ direction: Horizontal,
7538
7611
  size: 100
7539
7612
  }]);
7540
7613
  };
7541
7614
  const setEditorLayoutTwoColumns = state => {
7542
7615
  return setEditorLayout(state, Horizontal, [{
7616
+ direction: Horizontal,
7543
7617
  size: 50
7544
7618
  }, {
7619
+ direction: Horizontal,
7545
7620
  size: 50
7546
7621
  }]);
7547
7622
  };
7548
7623
  const setEditorLayoutThreeColumns = state => {
7549
7624
  return setEditorLayout(state, Horizontal, [{
7625
+ direction: Horizontal,
7550
7626
  size: 33.333333
7551
7627
  }, {
7628
+ direction: Horizontal,
7552
7629
  size: 33.333333
7553
7630
  }, {
7631
+ direction: Horizontal,
7554
7632
  size: 33.333334
7555
7633
  }]);
7556
7634
  };
7557
7635
  const setEditorLayoutTwoRows = state => {
7558
7636
  return setEditorLayout(state, Vertical, [{
7637
+ direction: Vertical,
7559
7638
  size: 50
7560
7639
  }, {
7640
+ direction: Vertical,
7561
7641
  size: 50
7562
7642
  }]);
7563
7643
  };
7564
7644
  const setEditorLayoutThreeRows = state => {
7565
7645
  return setEditorLayout(state, Vertical, [{
7646
+ direction: Vertical,
7566
7647
  size: 33.333333
7567
7648
  }, {
7649
+ direction: Vertical,
7568
7650
  size: 33.333333
7569
7651
  }, {
7652
+ direction: Vertical,
7570
7653
  size: 33.333334
7571
7654
  }]);
7572
7655
  };
@@ -7594,6 +7677,7 @@ const setEditorLayoutGrid = state => {
7594
7677
  const setEditorLayoutTwoRowsRight = state => {
7595
7678
  const segmentId = create$2();
7596
7679
  return setEditorLayout(state, Horizontal, [{
7680
+ direction: Horizontal,
7597
7681
  size: 50
7598
7682
  }, {
7599
7683
  direction: Vertical,
@@ -7608,6 +7692,7 @@ const setEditorLayoutTwoRowsRight = state => {
7608
7692
  const setEditorLayoutTwoColumnsBottom = state => {
7609
7693
  const segmentId = create$2();
7610
7694
  return setEditorLayout(state, Vertical, [{
7695
+ direction: Vertical,
7611
7696
  size: 50
7612
7697
  }, {
7613
7698
  direction: Horizontal,
@@ -7625,6 +7710,8 @@ const splitDown = (state, groupId) => {
7625
7710
  layout
7626
7711
  } = state;
7627
7712
  const {
7713
+ activeGroupId,
7714
+ direction,
7628
7715
  groups
7629
7716
  } = layout;
7630
7717
 
@@ -7633,6 +7720,7 @@ const splitDown = (state, groupId) => {
7633
7720
  const initialGroupId = create$2();
7634
7721
  const initialGroup = {
7635
7722
  activeTabId: undefined,
7723
+ direction,
7636
7724
  focused: true,
7637
7725
  id: initialGroupId,
7638
7726
  isEmpty: true,
@@ -7649,7 +7737,7 @@ const splitDown = (state, groupId) => {
7649
7737
  };
7650
7738
  return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, 'down');
7651
7739
  }
7652
- const resolvedGroupId = groupId ?? layout.activeGroupId;
7740
+ const resolvedGroupId = groupId ?? activeGroupId;
7653
7741
  if (!resolvedGroupId) {
7654
7742
  return state;
7655
7743
  }
@@ -7662,12 +7750,14 @@ const splitLeft = (state, groupId) => {
7662
7750
  } = state;
7663
7751
  const {
7664
7752
  activeGroupId,
7753
+ direction,
7665
7754
  groups
7666
7755
  } = layout;
7667
7756
  if (groups.length === 0) {
7668
7757
  const initialGroupId = create$2();
7669
7758
  const initialGroup = {
7670
7759
  activeTabId: undefined,
7760
+ direction,
7671
7761
  focused: true,
7672
7762
  id: initialGroupId,
7673
7763
  isEmpty: true,
@@ -7694,6 +7784,7 @@ const splitRight = (state, groupId) => {
7694
7784
  } = state;
7695
7785
  const {
7696
7786
  activeGroupId,
7787
+ direction,
7697
7788
  groups
7698
7789
  } = layout;
7699
7790
 
@@ -7702,6 +7793,7 @@ const splitRight = (state, groupId) => {
7702
7793
  const initialGroupId = create$2();
7703
7794
  const initialGroup = {
7704
7795
  activeTabId: undefined,
7796
+ direction,
7705
7797
  focused: true,
7706
7798
  id: initialGroupId,
7707
7799
  isEmpty: true,
@@ -7727,12 +7819,15 @@ const splitUp = (state, groupId) => {
7727
7819
  layout
7728
7820
  } = state;
7729
7821
  const {
7822
+ activeGroupId,
7823
+ direction,
7730
7824
  groups
7731
7825
  } = layout;
7732
7826
  if (groups.length === 0) {
7733
7827
  const initialGroupId = create$2();
7734
7828
  const initialGroup = {
7735
7829
  activeTabId: undefined,
7830
+ direction,
7736
7831
  focused: true,
7737
7832
  id: initialGroupId,
7738
7833
  isEmpty: true,
@@ -7749,7 +7844,7 @@ const splitUp = (state, groupId) => {
7749
7844
  };
7750
7845
  return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, 'up');
7751
7846
  }
7752
- const resolvedGroupId = groupId ?? layout.activeGroupId;
7847
+ const resolvedGroupId = groupId ?? activeGroupId;
7753
7848
  if (!resolvedGroupId) {
7754
7849
  return state;
7755
7850
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.33.1",
3
+ "version": "9.33.3",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",