@lvce-editor/main-area-worker 9.33.2 → 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;
@@ -3801,6 +3805,7 @@ const createEmptyGroup$1 = (state, uri, requestId, preview = false, title = getL
3801
3805
  layout
3802
3806
  } = state;
3803
3807
  const {
3808
+ direction,
3804
3809
  groups
3805
3810
  } = layout;
3806
3811
  const groupId = create$2();
@@ -3823,6 +3828,7 @@ const createEmptyGroup$1 = (state, uri, requestId, preview = false, title = getL
3823
3828
  };
3824
3829
  const newGroup = {
3825
3830
  activeTabId: newTab.id,
3831
+ direction,
3826
3832
  focused: true,
3827
3833
  id: groupId,
3828
3834
  isEmpty: false,
@@ -4340,7 +4346,7 @@ const getGroupSegments = (groups, parentDirection) => {
4340
4346
  let index = 0;
4341
4347
  while (index < groups.length) {
4342
4348
  const group = groups[index];
4343
- if (group.direction !== undefined && group.direction !== parentDirection) {
4349
+ if (group.direction !== parentDirection) {
4344
4350
  const startIndex = index;
4345
4351
  const nestedGroups = [group];
4346
4352
  const {
@@ -4408,7 +4414,7 @@ const splitOnlyGroup = (state, groups, groupId, newGroupId, direction, splitLayo
4408
4414
  if (group.id === groupId) {
4409
4415
  return {
4410
4416
  ...group,
4411
- direction: undefined,
4417
+ direction: splitLayoutDirection,
4412
4418
  focused: false,
4413
4419
  size: 50
4414
4420
  };
@@ -4417,7 +4423,7 @@ const splitOnlyGroup = (state, groups, groupId, newGroupId, direction, splitLayo
4417
4423
  });
4418
4424
  const newGroup = {
4419
4425
  ...baseNewGroup,
4420
- direction: undefined,
4426
+ direction: splitLayoutDirection,
4421
4427
  size: 50
4422
4428
  };
4423
4429
  const reorderedGroups = isTrailingSplit(direction) ? [...updatedGroups, newGroup] : [newGroup, ...updatedGroups];
@@ -4478,7 +4484,7 @@ const splitAtRootLevel = (state, groups, groupId, newGroupId, direction, baseNew
4478
4484
  if (group.id === groupId) {
4479
4485
  return {
4480
4486
  ...group,
4481
- direction: undefined,
4487
+ direction: state.layout.direction,
4482
4488
  focused: false,
4483
4489
  size: 50
4484
4490
  };
@@ -4487,7 +4493,7 @@ const splitAtRootLevel = (state, groups, groupId, newGroupId, direction, baseNew
4487
4493
  });
4488
4494
  const newGroup = {
4489
4495
  ...baseNewGroup,
4490
- direction: undefined,
4496
+ direction: state.layout.direction,
4491
4497
  size: 50
4492
4498
  };
4493
4499
  const reorderedGroups = isTrailingSplit(direction) ? [...updatedGroups, newGroup] : (() => {
@@ -4512,6 +4518,7 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
4512
4518
  const splitLayoutDirection = getSplitLayoutDirection(direction);
4513
4519
  const baseNewGroup = {
4514
4520
  activeTabId: undefined,
4521
+ direction: sourceGroup.direction,
4515
4522
  focused: true,
4516
4523
  id: newGroupId,
4517
4524
  isEmpty: true,
@@ -4521,10 +4528,10 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
4521
4528
  if (groups.length === 1) {
4522
4529
  return splitOnlyGroup(state, groups, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup);
4523
4530
  }
4524
- if (sourceGroup.direction === splitLayoutDirection) {
4531
+ if (sourceGroup.direction !== layoutDirection && sourceGroup.direction === splitLayoutDirection) {
4525
4532
  return splitWithinMatchingNestedDirection(state, groups, sourceGroup, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup);
4526
4533
  }
4527
- if (splitLayoutDirection !== layoutDirection && sourceGroup.direction === undefined) {
4534
+ if (splitLayoutDirection !== layoutDirection && sourceGroup.direction === layoutDirection) {
4528
4535
  return splitStandaloneSourceIntoNestedDirection(state, groups, sourceGroup, groupId, newGroupId, direction, splitLayoutDirection, baseNewGroup);
4529
4536
  }
4530
4537
  const segments = getGroupSegments(groups, layoutDirection);
@@ -5489,7 +5496,7 @@ const isValidTab = tab => {
5489
5496
  };
5490
5497
 
5491
5498
  const isValidEditorGroup = group => {
5492
- 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';
5493
5500
  };
5494
5501
 
5495
5502
  const isValidMainAreaLayout = layout => {
@@ -5523,6 +5530,12 @@ const normalizeRestoredTab = tab => {
5523
5530
  isPreview: typeof tab?.isPreview === 'boolean' ? tab.isPreview : false
5524
5531
  };
5525
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
+ };
5526
5539
  const tryRestoreLayout = savedState => {
5527
5540
  if (savedState === undefined || savedState === null) {
5528
5541
  return undefined;
@@ -5554,12 +5567,10 @@ const tryRestoreLayout = savedState => {
5554
5567
  ...rawLayout,
5555
5568
  direction: layoutDirection,
5556
5569
  groups: rawLayout.groups.map(group => {
5557
- const groupDirection = normalizeLayoutDirection(group?.direction);
5570
+ const groupDirection = normalizeGroupDirection(group, layoutDirection);
5558
5571
  return {
5559
5572
  ...group,
5560
- ...(groupDirection !== undefined && {
5561
- direction: groupDirection
5562
- }),
5573
+ direction: groupDirection,
5563
5574
  tabs: Array.isArray(group?.tabs) ? group.tabs.map(normalizeRestoredTab) : []
5564
5575
  };
5565
5576
  })
@@ -6185,13 +6196,17 @@ const getDragOverlayCss = dragOverlay => {
6185
6196
  y
6186
6197
  } = dragOverlay;
6187
6198
  return [`.DragOverlay {
6188
- left: ${x}px;
6189
- top: ${y}px;
6190
- width: ${width}px;
6191
- height: ${height}px;
6199
+ --DragOverlayLeft: ${x}px;
6200
+ --DragOverlayTop: ${y}px;
6201
+ --DragOverlayWidth: ${width}px;
6202
+ --DragOverlayHeight: ${height}px;
6192
6203
  }`];
6193
6204
  };
6194
6205
 
6206
+ const getEditorGroupClassName = groupId => {
6207
+ return `EditorGroup-${groupId}`;
6208
+ };
6209
+
6195
6210
  const getEditorGroupCss = layout => {
6196
6211
  const {
6197
6212
  direction,
@@ -6199,7 +6214,7 @@ const getEditorGroupCss = layout => {
6199
6214
  } = layout;
6200
6215
  const groupSizeVariable = direction === Vertical ? '--EditorGroupHeight' : '--EditorGroupWidth';
6201
6216
  return groups.map(group => {
6202
- return `.EditorGroup[data-groupId="${group.id}"] {
6217
+ return `.${getEditorGroupClassName(group.id)} {
6203
6218
  ${groupSizeVariable}: ${group.size}%;
6204
6219
  }`;
6205
6220
  });
@@ -6924,7 +6939,7 @@ const renderEmptyEditorGroup = (group, groupIndex, style, closeButtonEnabled = t
6924
6939
  const closeButtonDom = closeButtonEnabled ? renderEmptyGroupCloseButton(group) : [];
6925
6940
  return [{
6926
6941
  childCount: closeButtonEnabled ? 2 : 1,
6927
- className: EditorGroupEmpty,
6942
+ className: mergeClassNames(EditorGroupEmpty, getEditorGroupClassName(group.id)),
6928
6943
  'data-groupId': String(group.id),
6929
6944
  onContextMenu: HandleContextMenu,
6930
6945
  style,
@@ -6948,7 +6963,7 @@ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizePr
6948
6963
  }
6949
6964
  return [{
6950
6965
  childCount: 2,
6951
- className: EditorGroup,
6966
+ className: mergeClassNames(EditorGroup, getEditorGroupClassName(group.id)),
6952
6967
  'data-groupId': String(group.id),
6953
6968
  style,
6954
6969
  type: Div
@@ -7025,10 +7040,10 @@ const addDragOverlay = (dom, dragOverlay) => {
7025
7040
  if (!dragOverlay) {
7026
7041
  return dom;
7027
7042
  }
7028
- return [dom[0], {
7029
- ...dom[1],
7030
- childCount: dom[1].childCount + 1
7031
- }, ...dom.slice(2), getDragOverlayVirtualDom()];
7043
+ return [{
7044
+ ...dom[0],
7045
+ childCount: dom[0].childCount + 1
7046
+ }, dom[1], ...dom.slice(2), getDragOverlayVirtualDom()];
7032
7047
  };
7033
7048
  const getSizeProperty = direction => {
7034
7049
  return direction === Vertical ? 'height' : 'width';
@@ -7140,10 +7155,21 @@ const renderItems = (oldState, newState) => {
7140
7155
  return [SetDom2, uid, dom];
7141
7156
  };
7142
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
+ };
7143
7169
  const renderIncremental = (oldState, newState) => {
7144
7170
  const oldDom = renderItems(oldState, oldState)[2];
7145
7171
  const newDom = renderItems(newState, newState)[2];
7146
- const patches = diffTree(oldDom, newDom);
7172
+ const patches = avoidRootReplacement(diffTree(oldDom, newDom));
7147
7173
  return [SetPatches, newState.uid, patches];
7148
7174
  };
7149
7175
 
@@ -7472,9 +7498,10 @@ const saveState = state => {
7472
7498
  const flipDirection = direction => {
7473
7499
  return direction === Horizontal ? Vertical : Horizontal;
7474
7500
  };
7475
- const createEmptyGroup = () => {
7501
+ const createEmptyGroup = direction => {
7476
7502
  return {
7477
7503
  activeTabId: undefined,
7504
+ direction,
7478
7505
  focused: false,
7479
7506
  id: create$2(),
7480
7507
  isEmpty: true,
@@ -7505,9 +7532,9 @@ const mergeGroups = (target, groups, activeGroupId) => {
7505
7532
  tabs
7506
7533
  };
7507
7534
  };
7508
- const getGroupsForSlotCount = (groups, slotCount, activeGroupId) => {
7535
+ const getGroupsForSlotCount = (groups, slotCount, activeGroupId, direction) => {
7509
7536
  if (slotCount === 1) {
7510
- const firstGroup = groups[0] ?? createEmptyGroup();
7537
+ const firstGroup = groups[0] ?? createEmptyGroup(direction);
7511
7538
  return [mergeGroups(firstGroup, groups.slice(1), activeGroupId)];
7512
7539
  }
7513
7540
  if (groups.length === slotCount) {
@@ -7516,7 +7543,7 @@ const getGroupsForSlotCount = (groups, slotCount, activeGroupId) => {
7516
7543
  if (groups.length < slotCount) {
7517
7544
  const missingGroups = Array.from({
7518
7545
  length: slotCount - groups.length
7519
- }, createEmptyGroup);
7546
+ }, () => createEmptyGroup(direction));
7520
7547
  return [...groups, ...missingGroups];
7521
7548
  }
7522
7549
  const retainedGroups = groups.slice(0, slotCount);
@@ -7535,7 +7562,7 @@ const setEditorLayout = (state, direction, slots) => {
7535
7562
  activeGroupId,
7536
7563
  groups: currentGroups
7537
7564
  } = layout;
7538
- const groups = getGroupsForSlotCount(currentGroups, slots.length, activeGroupId);
7565
+ const groups = getGroupsForSlotCount(currentGroups, slots.length, activeGroupId, direction);
7539
7566
  const originalActiveIndex = currentGroups.findIndex(group => group.id === activeGroupId);
7540
7567
  const activeIndex = originalActiveIndex >= slots.length ? slots.length - 1 : getActiveGroupIndex(groups, activeGroupId);
7541
7568
  const nextGroups = groups.map((group, index) => {
@@ -7573,45 +7600,56 @@ const flipLayout = state => {
7573
7600
  direction: flipDirection(direction),
7574
7601
  groups: groups.map(group => ({
7575
7602
  ...group,
7576
- direction: group.direction === undefined ? undefined : flipDirection(group.direction)
7603
+ direction: flipDirection(group.direction)
7577
7604
  }))
7578
7605
  }
7579
7606
  };
7580
7607
  };
7581
7608
  const setEditorLayoutSingle = state => {
7582
7609
  return setEditorLayout(state, Horizontal, [{
7610
+ direction: Horizontal,
7583
7611
  size: 100
7584
7612
  }]);
7585
7613
  };
7586
7614
  const setEditorLayoutTwoColumns = state => {
7587
7615
  return setEditorLayout(state, Horizontal, [{
7616
+ direction: Horizontal,
7588
7617
  size: 50
7589
7618
  }, {
7619
+ direction: Horizontal,
7590
7620
  size: 50
7591
7621
  }]);
7592
7622
  };
7593
7623
  const setEditorLayoutThreeColumns = state => {
7594
7624
  return setEditorLayout(state, Horizontal, [{
7625
+ direction: Horizontal,
7595
7626
  size: 33.333333
7596
7627
  }, {
7628
+ direction: Horizontal,
7597
7629
  size: 33.333333
7598
7630
  }, {
7631
+ direction: Horizontal,
7599
7632
  size: 33.333334
7600
7633
  }]);
7601
7634
  };
7602
7635
  const setEditorLayoutTwoRows = state => {
7603
7636
  return setEditorLayout(state, Vertical, [{
7637
+ direction: Vertical,
7604
7638
  size: 50
7605
7639
  }, {
7640
+ direction: Vertical,
7606
7641
  size: 50
7607
7642
  }]);
7608
7643
  };
7609
7644
  const setEditorLayoutThreeRows = state => {
7610
7645
  return setEditorLayout(state, Vertical, [{
7646
+ direction: Vertical,
7611
7647
  size: 33.333333
7612
7648
  }, {
7649
+ direction: Vertical,
7613
7650
  size: 33.333333
7614
7651
  }, {
7652
+ direction: Vertical,
7615
7653
  size: 33.333334
7616
7654
  }]);
7617
7655
  };
@@ -7639,6 +7677,7 @@ const setEditorLayoutGrid = state => {
7639
7677
  const setEditorLayoutTwoRowsRight = state => {
7640
7678
  const segmentId = create$2();
7641
7679
  return setEditorLayout(state, Horizontal, [{
7680
+ direction: Horizontal,
7642
7681
  size: 50
7643
7682
  }, {
7644
7683
  direction: Vertical,
@@ -7653,6 +7692,7 @@ const setEditorLayoutTwoRowsRight = state => {
7653
7692
  const setEditorLayoutTwoColumnsBottom = state => {
7654
7693
  const segmentId = create$2();
7655
7694
  return setEditorLayout(state, Vertical, [{
7695
+ direction: Vertical,
7656
7696
  size: 50
7657
7697
  }, {
7658
7698
  direction: Horizontal,
@@ -7671,6 +7711,7 @@ const splitDown = (state, groupId) => {
7671
7711
  } = state;
7672
7712
  const {
7673
7713
  activeGroupId,
7714
+ direction,
7674
7715
  groups
7675
7716
  } = layout;
7676
7717
 
@@ -7679,6 +7720,7 @@ const splitDown = (state, groupId) => {
7679
7720
  const initialGroupId = create$2();
7680
7721
  const initialGroup = {
7681
7722
  activeTabId: undefined,
7723
+ direction,
7682
7724
  focused: true,
7683
7725
  id: initialGroupId,
7684
7726
  isEmpty: true,
@@ -7708,12 +7750,14 @@ const splitLeft = (state, groupId) => {
7708
7750
  } = state;
7709
7751
  const {
7710
7752
  activeGroupId,
7753
+ direction,
7711
7754
  groups
7712
7755
  } = layout;
7713
7756
  if (groups.length === 0) {
7714
7757
  const initialGroupId = create$2();
7715
7758
  const initialGroup = {
7716
7759
  activeTabId: undefined,
7760
+ direction,
7717
7761
  focused: true,
7718
7762
  id: initialGroupId,
7719
7763
  isEmpty: true,
@@ -7740,6 +7784,7 @@ const splitRight = (state, groupId) => {
7740
7784
  } = state;
7741
7785
  const {
7742
7786
  activeGroupId,
7787
+ direction,
7743
7788
  groups
7744
7789
  } = layout;
7745
7790
 
@@ -7748,6 +7793,7 @@ const splitRight = (state, groupId) => {
7748
7793
  const initialGroupId = create$2();
7749
7794
  const initialGroup = {
7750
7795
  activeTabId: undefined,
7796
+ direction,
7751
7797
  focused: true,
7752
7798
  id: initialGroupId,
7753
7799
  isEmpty: true,
@@ -7774,12 +7820,14 @@ const splitUp = (state, groupId) => {
7774
7820
  } = state;
7775
7821
  const {
7776
7822
  activeGroupId,
7823
+ direction,
7777
7824
  groups
7778
7825
  } = layout;
7779
7826
  if (groups.length === 0) {
7780
7827
  const initialGroupId = create$2();
7781
7828
  const initialGroup = {
7782
7829
  activeTabId: undefined,
7830
+ direction,
7783
7831
  focused: true,
7784
7832
  id: initialGroupId,
7785
7833
  isEmpty: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.33.2",
3
+ "version": "9.33.3",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",