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

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
  },
@@ -3787,8 +3806,7 @@ const EditorGroupsHorizontal = 'EditorGroupsHorizontal';
3787
3806
  const EditorGroupsVertical = 'EditorGroupsVertical';
3788
3807
  const EditorContainer = 'EditorContainer';
3789
3808
  const EditorGroupActions = 'EditorGroupActions';
3790
- const EditorGroupActionButton = 'EditorGroupActionButton';
3791
- const SplitEditorGroupButton = 'SplitEditorGroupButton';
3809
+ const SplitEditorGroupButton = 'EditorGroupActionButton SplitEditorGroupButton';
3792
3810
  const MaskIconPreview = 'MaskIcon MaskIconPreview';
3793
3811
  const MaskIconCircleFilled = 'MaskIcon MaskIconCircleFilled';
3794
3812
  const MaskIconClose = 'MaskIcon MaskIconClose';
@@ -3857,6 +3875,10 @@ const getDragOverlayVirtualDom = () => {
3857
3875
  return dragOverlayVirtualDom;
3858
3876
  };
3859
3877
 
3878
+ const getEditorGroupClassName = groupId => {
3879
+ return `EditorGroup-${String(groupId).replaceAll('.', '-')}`;
3880
+ };
3881
+
3860
3882
  const offsetsMatch = (first, second) => {
3861
3883
  return Math.abs(first - second) < 1e-6;
3862
3884
  };
@@ -3905,10 +3927,6 @@ const getSashCorner = layout => {
3905
3927
  };
3906
3928
  };
3907
3929
 
3908
- const getEditorGroupClassName = groupId => {
3909
- return `EditorGroup-${groupId}`;
3910
- };
3911
-
3912
3930
  const CloseGroup = 'close-group';
3913
3931
  const ConfigureLargeFileLimit = 'configure-large-file-limit';
3914
3932
  const OpenLargeFile = 'open-large-file';
@@ -4421,7 +4439,7 @@ const renderEditorGroupActions = (group, groupIndex, splitButtonEnabled) => {
4421
4439
  if (splitButtonEnabled) {
4422
4440
  buttons.push({
4423
4441
  childCount: 1,
4424
- className: mergeClassNames(EditorGroupActionButton, SplitEditorGroupButton),
4442
+ className: SplitEditorGroupButton,
4425
4443
  'data-action': SplitRight$1,
4426
4444
  'data-groupId': String(group.id),
4427
4445
  name: SplitRight$1,
@@ -4490,14 +4508,13 @@ const renderWaterMark = groupId => {
4490
4508
 
4491
4509
  const Focusable = 0;
4492
4510
 
4493
- const renderEmptyEditorGroup = (group, groupIndex, style, closeButtonEnabled = true) => {
4511
+ const renderEmptyEditorGroup = (group, groupIndex, closeButtonEnabled = true) => {
4494
4512
  const closeButtonDom = closeButtonEnabled ? renderEmptyGroupCloseButton(group) : [];
4495
4513
  return [{
4496
4514
  childCount: closeButtonEnabled ? 2 : 1,
4497
4515
  className: mergeClassNames(EditorGroupEmpty, getEditorGroupClassName(group.id)),
4498
4516
  'data-groupId': String(group.id),
4499
4517
  onContextMenu: HandleContextMenu,
4500
- style,
4501
4518
  tabIndex: Focusable,
4502
4519
  type: Div
4503
4520
  }, ...closeButtonDom, ...renderWaterMark(group.id)];
@@ -4508,19 +4525,17 @@ const editorContainerNode = {
4508
4525
  className: EditorContainer,
4509
4526
  type: Div
4510
4527
  };
4511
- const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width', closeButtonEnabled = true, tabDropIndicator) => {
4528
+ const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, closeButtonEnabled = true, tabDropIndicator) => {
4512
4529
  const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
4513
- const style = `${sizeProperty}:${group.size}%;`;
4514
4530
  const hasTabs = group.tabs.length > 0;
4515
4531
  const hasEmptyGroupCloseButton = !hasTabs;
4516
4532
  if (hasEmptyGroupCloseButton) {
4517
- return renderEmptyEditorGroup(group, groupIndex, style, closeButtonEnabled);
4533
+ return renderEmptyEditorGroup(group, groupIndex, closeButtonEnabled);
4518
4534
  }
4519
4535
  return [{
4520
4536
  childCount: 2,
4521
4537
  className: mergeClassNames(EditorGroup, getEditorGroupClassName(group.id)),
4522
4538
  'data-groupId': String(group.id),
4523
- style,
4524
4539
  type: Div
4525
4540
  }, ...renderEditorGroupHeader(group, groupIndex, splitButtonEnabled, tabDropIndicator), editorContainerNode, ...renderEditor(activeTab)];
4526
4541
  };
@@ -4568,11 +4583,11 @@ const mainNode$1 = {
4568
4583
  onDrop: HandleDrop,
4569
4584
  type: Div
4570
4585
  };
4571
- const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'width', tabDropIndicator) => {
4586
+ const renderSingleEditorGroup = (layout, splitButtonEnabled, tabDropIndicator) => {
4572
4587
  const {
4573
4588
  groups
4574
4589
  } = layout;
4575
- return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, sizeProperty, false, tabDropIndicator)];
4590
+ return [mainNode$1, ...renderEditorGroup(groups[0], 0, splitButtonEnabled, false, tabDropIndicator)];
4576
4591
  };
4577
4592
 
4578
4593
  const create = (beforeGroupId, afterGroupId) => {
@@ -4624,14 +4639,10 @@ const addDragOverlay = (dom, dragOverlay) => {
4624
4639
  childCount: dom[0].childCount + 1
4625
4640
  }, dom[1], ...dom.slice(2), getDragOverlayVirtualDom()];
4626
4641
  };
4627
- const getSizeProperty = direction => {
4628
- return direction === Vertical ? 'height' : 'width';
4629
- };
4630
4642
  const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropIndicator) => {
4631
4643
  const segments = getGroupSegments(groups, direction);
4632
4644
  const children = [];
4633
4645
  let childCount = 0;
4634
- const sizeProperty = getSizeProperty(direction);
4635
4646
  for (let i = 0; i < segments.length; i++) {
4636
4647
  const segment = segments[i];
4637
4648
  if (i > 0) {
@@ -4643,16 +4654,14 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropInd
4643
4654
  childCount++;
4644
4655
  }
4645
4656
  if (segment.direction === undefined) {
4646
- children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, sizeProperty, true, tabDropIndicator));
4657
+ children.push(...renderEditorGroup(segment.groups[0], segment.startIndex, splitButtonEnabled, true, tabDropIndicator));
4647
4658
  childCount++;
4648
4659
  continue;
4649
4660
  }
4650
4661
  const nestedDirection = segment.direction;
4651
- const nestedSizeProperty = getSizeProperty(nestedDirection);
4652
4662
  const nestedChildCount = segment.groups.length + segment.groups.length - 1;
4653
4663
  const nestedChildren = [];
4654
4664
  let nestedCount = 0;
4655
- const segmentSize = getSegmentSize(segment);
4656
4665
  for (let j = 0; j < segment.groups.length; j++) {
4657
4666
  if (j > 0) {
4658
4667
  const beforeGroupId = segment.groups[j - 1].id;
@@ -4662,18 +4671,13 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropInd
4662
4671
  nestedCount++;
4663
4672
  }
4664
4673
  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));
4674
+ nestedChildren.push(...renderEditorGroup(group, segment.startIndex + j, splitButtonEnabled, true, tabDropIndicator));
4670
4675
  nestedCount++;
4671
4676
  }
4672
4677
  children.push({
4673
4678
  childCount: nestedChildCount,
4674
- className: getContainerClassName(nestedDirection, segment.groups.length),
4679
+ className: mergeClassNames(getContainerClassName(nestedDirection, segment.groups.length), `${getEditorGroupClassName(segment.groups[0].id)}-Segment`),
4675
4680
  role: None$2,
4676
- style: `${sizeProperty}:${segmentSize}%;`,
4677
4681
  type: Div
4678
4682
  });
4679
4683
  children.push(...nestedChildren);
@@ -4690,9 +4694,8 @@ const getMainAreaVirtualDom = (layout, splitButtonEnabled = false, dragOverlay,
4690
4694
  direction,
4691
4695
  groups
4692
4696
  } = layout;
4693
- const sizeProperty = getSizeProperty(direction);
4694
4697
  if (groups.length === 1) {
4695
- return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, sizeProperty, tabDropIndicator), dragOverlay);
4698
+ return addDragOverlay(renderSingleEditorGroup(layout, splitButtonEnabled, tabDropIndicator), dragOverlay);
4696
4699
  }
4697
4700
  const editorGroupsContainerClassName = getContainerClassName(direction, groups.length);
4698
4701
  if (groups.length === 0) {
@@ -8105,17 +8108,34 @@ const getDragOverlayCss = dragOverlay => {
8105
8108
  }`];
8106
8109
  };
8107
8110
 
8111
+ const getSizeCss = (className, direction, size) => {
8112
+ const width = direction === Vertical ? 100 : size;
8113
+ const height = direction === Vertical ? size : 100;
8114
+ return `.${className} {
8115
+ width: ${width}%;
8116
+ height: ${height}%;
8117
+ }`;
8118
+ };
8108
8119
  const getEditorGroupCss = layout => {
8109
8120
  const {
8110
8121
  direction,
8111
8122
  groups
8112
8123
  } = layout;
8113
- const groupSizeVariable = direction === Vertical ? '--EditorGroupHeight' : '--EditorGroupWidth';
8114
- return groups.map(group => {
8115
- return `.${getEditorGroupClassName(group.id)} {
8116
- ${groupSizeVariable}: ${group.size}%;
8117
- }`;
8118
- });
8124
+ const rules = [];
8125
+ for (const segment of getGroupSegments(groups, direction)) {
8126
+ if (segment.direction === undefined) {
8127
+ const group = segment.groups[0];
8128
+ rules.push(getSizeCss(getEditorGroupClassName(group.id), direction, group.size));
8129
+ continue;
8130
+ }
8131
+ const segmentSize = getSegmentSize(segment);
8132
+ rules.push(getSizeCss(`${getEditorGroupClassName(segment.groups[0].id)}-Segment`, direction, segmentSize));
8133
+ for (const group of segment.groups) {
8134
+ const normalizedSize = Number((group.size / segmentSize * 100).toFixed(6));
8135
+ rules.push(getSizeCss(getEditorGroupClassName(group.id), segment.direction, normalizedSize));
8136
+ }
8137
+ }
8138
+ return rules;
8119
8139
  };
8120
8140
 
8121
8141
  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.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",