@lvce-editor/explorer-view 2.45.0 → 2.46.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.
@@ -523,6 +523,16 @@ const constructError = (message, type, name) => {
523
523
  }
524
524
  return new ErrorConstructor(message);
525
525
  };
526
+ const joinLines = lines => {
527
+ return lines.join(NewLine);
528
+ };
529
+ const splitLines = lines => {
530
+ return lines.split(NewLine);
531
+ };
532
+ const getCurrentStack = () => {
533
+ const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
534
+ return currentStack;
535
+ };
526
536
  const getNewLineIndex = (string, startIndex = undefined) => {
527
537
  return string.indexOf(NewLine, startIndex);
528
538
  };
@@ -533,19 +543,16 @@ const getParentStack = error => {
533
543
  }
534
544
  return parentStack;
535
545
  };
536
- const joinLines = lines => {
537
- return lines.join(NewLine);
538
- };
539
546
  const MethodNotFound = -32601;
540
547
  const Custom = -32001;
541
- const splitLines = lines => {
542
- return lines.split(NewLine);
543
- };
544
548
  const restoreJsonRpcError = error => {
549
+ const currentStack = getCurrentStack();
545
550
  if (error && error instanceof Error) {
551
+ if (typeof error.stack === 'string') {
552
+ error.stack = error.stack + NewLine + currentStack;
553
+ }
546
554
  return error;
547
555
  }
548
- const currentStack = joinLines(splitLines(new Error().stack || '').slice(1));
549
556
  if (error && error.code && error.code === MethodNotFound) {
550
557
  const restoredError = new JsonRpcError(error.message);
551
558
  const parentStack = getParentStack(error);
@@ -626,6 +633,17 @@ const getErrorType = prettyError => {
626
633
  }
627
634
  return undefined;
628
635
  };
636
+ const isAlreadyStack = line => {
637
+ return line.trim().startsWith('at ');
638
+ };
639
+ const getStack = prettyError => {
640
+ const stackString = prettyError.stack || '';
641
+ const newLineIndex = stackString.indexOf('\n');
642
+ if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
643
+ return stackString.slice(newLineIndex + 1);
644
+ }
645
+ return stackString;
646
+ };
629
647
  const getErrorProperty = (error, prettyError) => {
630
648
  if (error && error.code === E_COMMAND_NOT_FOUND) {
631
649
  return {
@@ -638,7 +656,7 @@ const getErrorProperty = (error, prettyError) => {
638
656
  code: Custom,
639
657
  message: prettyError.message,
640
658
  data: {
641
- stack: prettyError.stack,
659
+ stack: getStack(prettyError),
642
660
  codeFrame: prettyError.codeFrame,
643
661
  type: getErrorType(prettyError),
644
662
  code: prettyError.code,
@@ -851,7 +869,7 @@ const WebWorkerRpcClient = {
851
869
  };
852
870
 
853
871
  const rpcs = Object.create(null);
854
- const set$9 = (id, rpc) => {
872
+ const set$a = (id, rpc) => {
855
873
  rpcs[id] = rpc;
856
874
  };
857
875
  const get$1 = id => {
@@ -875,19 +893,19 @@ const create$2 = rpcId => {
875
893
  return rpc.invokeAndTransfer(method, ...params);
876
894
  },
877
895
  set(rpc) {
878
- set$9(rpcId, rpc);
896
+ set$a(rpcId, rpc);
879
897
  }
880
898
  };
881
899
  };
882
900
  const RendererWorker$1 = 1;
883
901
  const {
884
- invoke: invoke$4,
885
- set: set$4
902
+ invoke: invoke$5,
903
+ set: set$5
886
904
  } = create$2(RendererWorker$1);
887
905
  const RendererWorker = {
888
906
  __proto__: null,
889
- invoke: invoke$4,
890
- set: set$4
907
+ invoke: invoke$5,
908
+ set: set$5
891
909
  };
892
910
 
893
911
  const {
@@ -4300,6 +4318,11 @@ const getErrorMessagePosition = (itemHeight, focusedIndex, minLineY, depth, inde
4300
4318
  };
4301
4319
  };
4302
4320
 
4321
+ const None$2 = 'none';
4322
+ const ToolBar = 'toolbar';
4323
+ const Tree = 'tree';
4324
+ const TreeItem$1 = 'treeitem';
4325
+
4303
4326
  const Actions = 'Actions';
4304
4327
  const Button$2 = 'Button';
4305
4328
  const ButtonNarrow = 'ButtonNarrow';
@@ -4322,7 +4345,7 @@ const MaskIconChevronRight = 'MaskIconChevronRight';
4322
4345
  const ScrollBar = 'ScrollBar';
4323
4346
  const ScrollBarSmall = 'ScrollBarSmall';
4324
4347
  const ScrollBarThumb = 'ScrollBarThumb';
4325
- const TreeItem$1 = 'TreeItem';
4348
+ const TreeItem = 'TreeItem';
4326
4349
  const TreeItemActive = 'TreeItemActive';
4327
4350
  const Viewlet = 'Viewlet';
4328
4351
  const Welcome = 'Welcome';
@@ -4413,11 +4436,6 @@ const getExplorerWelcomeVirtualDom = isWide => {
4413
4436
  }, text(openFolder$1())];
4414
4437
  };
4415
4438
 
4416
- const None$2 = 'none';
4417
- const ToolBar = 'toolbar';
4418
- const Tree = 'tree';
4419
- const TreeItem = 'treeitem';
4420
-
4421
4439
  const chevronDownVirtualDom = {
4422
4440
  type: Div,
4423
4441
  className: mergeClassNames(Chevron, MaskIconChevronDown),
@@ -4505,7 +4523,7 @@ const getExplorerItemVirtualDom = item => {
4505
4523
  const chevronDom = getChevronVirtualDom(chevron);
4506
4524
  return [{
4507
4525
  type: Div,
4508
- role: TreeItem,
4526
+ role: TreeItem$1,
4509
4527
  className,
4510
4528
  draggable: true,
4511
4529
  title: path,
@@ -4563,6 +4581,11 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
4563
4581
  return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
4564
4582
  };
4565
4583
 
4584
+ const getScrollBarTop = (height, contentHeight, scrollTop) => {
4585
+ const scrollBarTop = Math.round(scrollTop / contentHeight * height);
4586
+ return scrollBarTop;
4587
+ };
4588
+
4566
4589
  const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
4567
4590
  const shouldShowScrollbar = scrollBarHeight > 0;
4568
4591
  if (!shouldShowScrollbar) {
@@ -4598,7 +4621,7 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
4598
4621
  return getExplorerWelcomeVirtualDom(isWide);
4599
4622
  }
4600
4623
  const scrollBarHeight = getScrollBarSize(height, contentHeight, 20);
4601
- const scrollBarTop = Math.round(scrollTop / contentHeight * height);
4624
+ const scrollBarTop = getScrollBarTop(height, contentHeight, scrollTop);
4602
4625
  const scrollBarDom = getScrollBarVirtualDom(scrollBarHeight, scrollBarTop);
4603
4626
  const errorDom = getErrorMessageDom(errorMessage, errorMessageLeft, errorMessageTop);
4604
4627
  const childCount = getChildCount(scrollBarDom.length, errorDom.length);
@@ -4606,7 +4629,7 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
4606
4629
  type: Div,
4607
4630
  childCount,
4608
4631
  className: mergeClassNames(Viewlet, Explorer),
4609
- role: 'none'
4632
+ role: None$2
4610
4633
  };
4611
4634
  const dom = [parentNode, ...getListItemsVirtualDom(visibleItems, focusedIndex, focused, dropTargets), ...scrollBarDom, ...errorDom];
4612
4635
  return dom;
@@ -4647,8 +4670,8 @@ const getExpandedType = type => {
4647
4670
  }
4648
4671
  };
4649
4672
 
4650
- const focused = mergeClassNames(TreeItem$1, TreeItemActive);
4651
- const selected = mergeClassNames(TreeItem$1, TreeItemActive);
4673
+ const focused = mergeClassNames(TreeItem, TreeItemActive);
4674
+ const selected = mergeClassNames(TreeItem, TreeItemActive);
4652
4675
  const getTreeItemClassName = (isSelected, isFocused) => {
4653
4676
  if (isFocused) {
4654
4677
  return focused;
@@ -4656,7 +4679,7 @@ const getTreeItemClassName = (isSelected, isFocused) => {
4656
4679
  if (isSelected) {
4657
4680
  return selected;
4658
4681
  }
4659
- return TreeItem$1;
4682
+ return TreeItem;
4660
4683
  };
4661
4684
 
4662
4685
  const defaultIndent$1 = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.45.0",
3
+ "version": "2.46.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",