@lvce-editor/main-area-worker 9.63.1 → 9.64.1

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.
@@ -598,6 +598,9 @@ const restoreExistingError = (error, currentStack) => {
598
598
  };
599
599
  const restoreMethodNotFoundError = (error, currentStack) => {
600
600
  const restoredError = new JsonRpcError(error.message);
601
+ Object.assign(restoredError, {
602
+ code: error.code
603
+ });
601
604
  const parentStack = getParentStack(error);
602
605
  setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
603
606
  return restoredError;
@@ -617,9 +620,13 @@ const applyDataProperties = (restoredError, error) => {
617
620
  // @ts-ignore
618
621
  restoredError.codeFrame = error.data.codeFrame;
619
622
  }
620
- if (error.data.code) {
623
+ if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
621
624
  // @ts-ignore
622
- restoredError.code = error.data.code;
625
+ Object.defineProperty(restoredError, 'code', {
626
+ configurable: true,
627
+ value: error.data.code,
628
+ writable: true
629
+ });
623
630
  }
624
631
  if (error.data.type) {
625
632
  // @ts-ignore
@@ -641,6 +648,13 @@ const applyDirectProperties = (restoredError, error) => {
641
648
  };
642
649
  const restoreMessageError = (error, _currentStack) => {
643
650
  const restoredError = constructError(error.message, error.type, error.name);
651
+ if (typeof error.code === 'string' || typeof error.code === 'number') {
652
+ Object.defineProperty(restoredError, 'code', {
653
+ configurable: true,
654
+ value: error.code,
655
+ writable: true
656
+ });
657
+ }
644
658
  if (error.data) {
645
659
  applyDataProperties(restoredError, error);
646
660
  } else {
@@ -719,7 +733,7 @@ const getErrorProperty = (error, prettyError) => {
719
733
  return {
720
734
  code: Custom,
721
735
  data: {
722
- code: prettyError.code,
736
+ code: prettyError.code ?? error?.code,
723
737
  codeFrame: prettyError.codeFrame,
724
738
  name: prettyError.name,
725
739
  stack: getStack(prettyError),
@@ -756,7 +770,12 @@ const getErrorResponseSimple = (id, error) => {
756
770
  return {
757
771
  error: {
758
772
  code: Custom,
759
- data: error,
773
+ data: error instanceof Error ? {
774
+ ...error,
775
+ code: 'code' in error ? error.code : undefined,
776
+ stack: error.stack,
777
+ type: error.name
778
+ } : error,
760
779
  // @ts-ignore
761
780
  message: error.message
762
781
  },
@@ -1779,14 +1798,42 @@ const getActiveFileUri = state => {
1779
1798
  return editorInput && 'uri' in editorInput ? editorInput.uri : '';
1780
1799
  };
1781
1800
 
1801
+ const getActiveTab = state => {
1802
+ const {
1803
+ layout
1804
+ } = state;
1805
+ const {
1806
+ groups
1807
+ } = layout;
1808
+ const activeGroup = groups.find(group => group.focused);
1809
+ if (!activeGroup || !activeGroup.activeTabId) {
1810
+ return undefined;
1811
+ }
1812
+ const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
1813
+ if (!activeTab) {
1814
+ return undefined;
1815
+ }
1816
+ return {
1817
+ groupId: activeGroup.id,
1818
+ tab: activeTab
1819
+ };
1820
+ };
1821
+
1822
+ const hasActiveTextEditor = state => {
1823
+ const activeTab = getActiveTab(state);
1824
+ return activeTab?.tab.editorInput?.type === 'editor';
1825
+ };
1826
+
1782
1827
  const notifyActiveEditorChange = async (oldState, newState) => {
1783
1828
  const oldUri = getActiveFileUri(oldState);
1784
1829
  const newUri = getActiveFileUri(newState);
1785
- if (oldUri === newUri) {
1830
+ const oldIsTextEditor = hasActiveTextEditor(oldState);
1831
+ const newIsTextEditor = hasActiveTextEditor(newState);
1832
+ if (oldUri === newUri && oldIsTextEditor === newIsTextEditor) {
1786
1833
  return;
1787
1834
  }
1788
1835
  try {
1789
- await invoke$1(newState.applicationId, 'Layout.handleActiveEditorChange', newUri);
1836
+ await invoke$1(newState.applicationId, 'Layout.handleActiveEditorChange', newUri, newIsTextEditor);
1790
1837
  } catch (error) {
1791
1838
  console.warn('Failed to notify viewlets about active editor change', error);
1792
1839
  }
@@ -2745,27 +2792,6 @@ const diff2 = uid => {
2745
2792
  return result;
2746
2793
  };
2747
2794
 
2748
- const getActiveTab = state => {
2749
- const {
2750
- layout
2751
- } = state;
2752
- const {
2753
- groups
2754
- } = layout;
2755
- const activeGroup = groups.find(group => group.focused);
2756
- if (!activeGroup || !activeGroup.activeTabId) {
2757
- return undefined;
2758
- }
2759
- const activeTab = activeGroup.tabs.find(tab => tab.id === activeGroup.activeTabId);
2760
- if (!activeTab) {
2761
- return undefined;
2762
- }
2763
- return {
2764
- groupId: activeGroup.id,
2765
- tab: activeTab
2766
- };
2767
- };
2768
-
2769
2795
  const state = {
2770
2796
  connected: false
2771
2797
  };
@@ -3787,8 +3813,7 @@ const EditorGroupsHorizontal = 'EditorGroupsHorizontal';
3787
3813
  const EditorGroupsVertical = 'EditorGroupsVertical';
3788
3814
  const EditorContainer = 'EditorContainer';
3789
3815
  const EditorGroupActions = 'EditorGroupActions';
3790
- const EditorGroupActionButton = 'EditorGroupActionButton';
3791
- const SplitEditorGroupButton = 'SplitEditorGroupButton';
3816
+ const SplitEditorGroupButton = 'EditorGroupActionButton SplitEditorGroupButton';
3792
3817
  const MaskIconPreview = 'MaskIcon MaskIconPreview';
3793
3818
  const MaskIconCircleFilled = 'MaskIcon MaskIconCircleFilled';
3794
3819
  const MaskIconClose = 'MaskIcon MaskIconClose';
@@ -3857,6 +3882,10 @@ const getDragOverlayVirtualDom = () => {
3857
3882
  return dragOverlayVirtualDom;
3858
3883
  };
3859
3884
 
3885
+ const getEditorGroupClassName = groupId => {
3886
+ return `EditorGroup-${String(groupId).replaceAll('.', '-')}`;
3887
+ };
3888
+
3860
3889
  const offsetsMatch = (first, second) => {
3861
3890
  return Math.abs(first - second) < 1e-6;
3862
3891
  };
@@ -3905,10 +3934,6 @@ const getSashCorner = layout => {
3905
3934
  };
3906
3935
  };
3907
3936
 
3908
- const getEditorGroupClassName = groupId => {
3909
- return `EditorGroup-${groupId}`;
3910
- };
3911
-
3912
3937
  const CloseGroup = 'close-group';
3913
3938
  const ConfigureLargeFileLimit = 'configure-large-file-limit';
3914
3939
  const OpenLargeFile = 'open-large-file';
@@ -4421,7 +4446,7 @@ const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
4421
4446
  if (splitButtonEnabled) {
4422
4447
  buttons.push({
4423
4448
  childCount: 1,
4424
- className: mergeClassNames(EditorGroupActionButton, SplitEditorGroupButton),
4449
+ className: SplitEditorGroupButton,
4425
4450
  'data-action': SplitRight$1,
4426
4451
  'data-groupId': String(group.id),
4427
4452
  name: SplitRight$1,
@@ -4490,14 +4515,13 @@ const renderWaterMark = groupId => {
4490
4515
 
4491
4516
  const Focusable = 0;
4492
4517
 
4493
- const renderEmptyEditorGroup = (group, groupIndex, style, closeButtonEnabled = true) => {
4518
+ const renderEmptyEditorGroup = (group, groupIndex, closeButtonEnabled = true) => {
4494
4519
  const closeButtonDom = closeButtonEnabled ? renderEmptyGroupCloseButton(group) : [];
4495
4520
  return [{
4496
4521
  childCount: closeButtonEnabled ? 2 : 1,
4497
4522
  className: mergeClassNames(EditorGroupEmpty, getEditorGroupClassName(group.id)),
4498
4523
  'data-groupId': String(group.id),
4499
4524
  onContextMenu: HandleContextMenu,
4500
- style,
4501
4525
  tabIndex: Focusable,
4502
4526
  type: Div
4503
4527
  }, ...closeButtonDom, ...renderWaterMark(group.id)];
@@ -4508,19 +4532,17 @@ const editorContainerNode = {
4508
4532
  className: EditorContainer,
4509
4533
  type: Div
4510
4534
  };
4511
- const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width', closeButtonEnabled = true, tabDropIndicator) => {
4535
+ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, closeButtonEnabled = true, tabDropIndicator) => {
4512
4536
  const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
4513
- const style = `${sizeProperty}:${group.size}%;`;
4514
4537
  const hasTabs = group.tabs.length > 0;
4515
4538
  const hasEmptyGroupCloseButton = !hasTabs;
4516
4539
  if (hasEmptyGroupCloseButton) {
4517
- return renderEmptyEditorGroup(group, groupIndex, style, closeButtonEnabled);
4540
+ return renderEmptyEditorGroup(group, groupIndex, closeButtonEnabled);
4518
4541
  }
4519
4542
  return [{
4520
4543
  childCount: 2,
4521
4544
  className: mergeClassNames(EditorGroup, getEditorGroupClassName(group.id)),
4522
4545
  'data-groupId': String(group.id),
4523
- style,
4524
4546
  type: Div
4525
4547
  }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled, tabDropIndicator), editorContainerNode, ...renderEditor(activeTab)];
4526
4548
  };
@@ -4545,6 +4567,7 @@ const renderSash = (direction, sashId) => {
4545
4567
  }, {
4546
4568
  childCount: 0,
4547
4569
  className: getSashBorderClassName(direction),
4570
+ 'data-sashId': sashId,
4548
4571
  type: Div
4549
4572
  }];
4550
4573
  };
@@ -4568,11 +4591,11 @@ const mainNode$1 = {
4568
4591
  onDrop: HandleDrop,
4569
4592
  type: Div
4570
4593
  };
4571
- const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width', tabDropIndicator) => {
4594
+ const renderSingleEditorGroup = (layout, splitButtonEnabled, tabDropIndicator) => {
4572
4595
  const {
4573
4596
  groups
4574
4597
  } = layout;
4575
- return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, sizeProperty, false, tabDropIndicator)];
4598
+ return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, false, tabDropIndicator)];
4576
4599
  };
4577
4600
 
4578
4601
  const create = (beforeGroupId, afterGroupId) => {
@@ -4624,14 +4647,10 @@ const addDragOverlay = (dom, dragOverlay) => {
4624
4647
  childCount: dom[0].childCount + 1
4625
4648
  }, dom[1], ...dom.slice(2), getDragOverlayVirtualDom()];
4626
4649
  };
4627
- const getSizeProperty = direction => {
4628
- return direction === Vertical ? 'height' : 'width';
4629
- };
4630
4650
  const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropIndicator) => {
4631
4651
  const segments = getGroupSegments(groups, direction);
4632
4652
  const children = [];
4633
4653
  let childCount = 0;
4634
- const sizeProperty = getSizeProperty(direction);
4635
4654
  for (let i = 0; i < segments.length; i++) {
4636
4655
  const segment = segments[i];
4637
4656
  if (i > 0) {
@@ -4643,16 +4662,14 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropInd
4643
4662
  childCount++;
4644
4663
  }
4645
4664
  if (segment.direction === undefined) {
4646
- children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, sizeProperty, true, tabDropIndicator));
4665
+ children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, true, tabDropIndicator));
4647
4666
  childCount++;
4648
4667
  continue;
4649
4668
  }
4650
4669
  const nestedDirection = segment.direction;
4651
- const nestedSizeProperty = getSizeProperty(nestedDirection);
4652
4670
  const nestedChildCount = segment.groups.length + segment.groups.length - 1;
4653
4671
  const nestedChildren = [];
4654
4672
  let nestedCount = 0;
4655
- const segmentSize = getSegmentSize(segment);
4656
4673
  for (let j = 0; j < segment.groups.length; j++) {
4657
4674
  if (j > 0) {
4658
4675
  const beforeGroupId = segment.groups[j - 1].id;
@@ -4662,18 +4679,13 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropInd
4662
4679
  nestedCount++;
4663
4680
  }
4664
4681
  const group = segment.groups[j];
4665
- const normalizedSize = Number((group.size / segmentSize * 100).toFixed(6));
4666
- nestedChildren.push(...renderEditorGroup({
4667
- ...group,
4668
- size: normalizedSize
4669
- }, segment.startIndex + j, splitButtonEnabled, nestedSizeProperty, true, tabDropIndicator));
4682
+ nestedChildren.push(...renderEditorGroup(group, segment.startIndex + j, splitButtonEnabled, true, tabDropIndicator));
4670
4683
  nestedCount++;
4671
4684
  }
4672
4685
  children.push({
4673
4686
  childCount: nestedChildCount,
4674
- className: getContainerClassName(nestedDirection, segment.groups.length),
4687
+ className: mergeClassNames(getContainerClassName(nestedDirection, segment.groups.length), `${getEditorGroupClassName(segment.groups[0].id)}-Segment`),
4675
4688
  role: None$2,
4676
- style: `${sizeProperty}:${segmentSize}%;`,
4677
4689
  type: Div
4678
4690
  });
4679
4691
  children.push(...nestedChildren);
@@ -4690,9 +4702,8 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay,
4690
4702
  direction,
4691
4703
  groups
4692
4704
  } = layout;
4693
- const sizeProperty = getSizeProperty(direction);
4694
4705
  if (groups.length === 1) {
4695
- return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty, tabDropIndicator), dragOverlay);
4706
+ return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, tabDropIndicator), dragOverlay);
4696
4707
  }
4697
4708
  const editorGroupsContainerClassName = getContainerClassName(direction, groups.length);
4698
4709
  if (groups.length === 0) {
@@ -7781,11 +7792,6 @@ const handleWorkspaceRefreshWithContext = async (context, refresh = {}) => {
7781
7792
  }
7782
7793
  };
7783
7794
 
7784
- const hasActiveTextEditor = state => {
7785
- const activeTab = getActiveTab(state);
7786
- return activeTab?.tab.editorInput?.type === 'editor';
7787
- };
7788
-
7789
7795
  const getTabs = group => {
7790
7796
  return group.tabs;
7791
7797
  };
@@ -8105,17 +8111,34 @@ const getDragOverlayCss = dragOverlay => {
8105
8111
  }`];
8106
8112
  };
8107
8113
 
8114
+ const getSizeCss = (className, direction, size) => {
8115
+ const width = direction === Vertical ? 100 : size;
8116
+ const height = direction === Vertical ? size : 100;
8117
+ return `.${className} {
8118
+ width: ${width}%;
8119
+ height: ${height}%;
8120
+ }`;
8121
+ };
8108
8122
  const getEditorGroupCss = layout => {
8109
8123
  const {
8110
8124
  direction,
8111
8125
  groups
8112
8126
  } = layout;
8113
- const groupSizeVariable = direction === Vertical ? '--EditorGroupHeight' : '--EditorGroupWidth';
8114
- return groups.map(group => {
8115
- return `.${getEditorGroupClassName(group.id)} {
8116
- ${groupSizeVariable}: ${group.size}%;
8117
- }`;
8118
- });
8127
+ const rules = [];
8128
+ for (const segment of getGroupSegments(groups, direction)) {
8129
+ if (segment.direction === undefined) {
8130
+ const group = segment.groups[0];
8131
+ rules.push(getSizeCss(getEditorGroupClassName(group.id), direction, group.size));
8132
+ continue;
8133
+ }
8134
+ const segmentSize = getSegmentSize(segment);
8135
+ rules.push(getSizeCss(`${getEditorGroupClassName(segment.groups[0].id)}-Segment`, direction, segmentSize));
8136
+ for (const group of segment.groups) {
8137
+ const normalizedSize = Number((group.size / segmentSize * 100).toFixed(6));
8138
+ rules.push(getSizeCss(getEditorGroupClassName(group.id), segment.direction, normalizedSize));
8139
+ }
8140
+ }
8141
+ return rules;
8119
8142
  };
8120
8143
 
8121
8144
  const MIN_GROUP_WIDTH_PX = 250;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.63.1",
3
+ "version": "9.64.1",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",