@lvce-editor/running-extensions-view 1.26.0 → 1.28.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.
@@ -645,6 +645,9 @@ const restoreExistingError = (error, currentStack) => {
645
645
  };
646
646
  const restoreMethodNotFoundError = (error, currentStack) => {
647
647
  const restoredError = new JsonRpcError(error.message);
648
+ Object.assign(restoredError, {
649
+ code: error.code
650
+ });
648
651
  const parentStack = getParentStack(error);
649
652
  setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
650
653
  return restoredError;
@@ -664,9 +667,13 @@ const applyDataProperties = (restoredError, error) => {
664
667
  // @ts-ignore
665
668
  restoredError.codeFrame = error.data.codeFrame;
666
669
  }
667
- if (error.data.code) {
670
+ if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
668
671
  // @ts-ignore
669
- restoredError.code = error.data.code;
672
+ Object.defineProperty(restoredError, 'code', {
673
+ configurable: true,
674
+ value: error.data.code,
675
+ writable: true
676
+ });
670
677
  }
671
678
  if (error.data.type) {
672
679
  // @ts-ignore
@@ -687,7 +694,14 @@ const applyDirectProperties = (restoredError, error) => {
687
694
  }
688
695
  };
689
696
  const restoreMessageError = (error, _currentStack) => {
690
- const restoredError = constructError(error.message, error.type, error.name);
697
+ const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
698
+ if (typeof error.code === 'string' || typeof error.code === 'number') {
699
+ Object.defineProperty(restoredError, 'code', {
700
+ configurable: true,
701
+ value: error.code,
702
+ writable: true
703
+ });
704
+ }
691
705
  if (error.data) {
692
706
  applyDataProperties(restoredError, error);
693
707
  } else {
@@ -695,6 +709,23 @@ const restoreMessageError = (error, _currentStack) => {
695
709
  }
696
710
  return restoredError;
697
711
  };
712
+ const getFallbackMessage = error => {
713
+ if (error && typeof error.message === 'string' && error.message) {
714
+ return error.message;
715
+ }
716
+ if (error && error.data) {
717
+ return getFallbackMessage(error.data);
718
+ }
719
+ const stringified = String(error);
720
+ if (stringified !== '[object Object]') {
721
+ return stringified;
722
+ }
723
+ try {
724
+ return JSON.stringify(error);
725
+ } catch {
726
+ return stringified;
727
+ }
728
+ };
698
729
  const restoreJsonRpcError = error => {
699
730
  const currentStack = getCurrentStack();
700
731
  if (error && error instanceof Error) {
@@ -703,13 +734,13 @@ const restoreJsonRpcError = error => {
703
734
  if (error && error.code && error.code === MethodNotFound) {
704
735
  return restoreMethodNotFoundError(error, currentStack);
705
736
  }
737
+ if (error && error.error) {
738
+ return restoreJsonRpcError(error.error);
739
+ }
706
740
  if (error && error.message) {
707
741
  return restoreMessageError(error);
708
742
  }
709
- if (typeof error === 'string') {
710
- return new Error(`JsonRpc Error: ${error}`);
711
- }
712
- return new Error(`JsonRpc Error: ${error}`);
743
+ return new Error(`JsonRpc Error: ${getFallbackMessage(error)}`);
713
744
  };
714
745
  const unwrapJsonRpcResult = responseMessage => {
715
746
  if ('error' in responseMessage) {
@@ -766,9 +797,9 @@ const getErrorProperty = (error, prettyError) => {
766
797
  return {
767
798
  code: Custom,
768
799
  data: {
769
- code: prettyError.code,
800
+ code: prettyError.code ?? error?.code,
770
801
  codeFrame: prettyError.codeFrame,
771
- name: prettyError.name,
802
+ name: prettyError.name ?? error?.name,
772
803
  stack: getStack(prettyError),
773
804
  type: getErrorType(prettyError)
774
805
  },
@@ -803,7 +834,12 @@ const getErrorResponseSimple = (id, error) => {
803
834
  return {
804
835
  error: {
805
836
  code: Custom,
806
- data: error,
837
+ data: error instanceof Error ? {
838
+ ...error,
839
+ code: 'code' in error ? error.code : undefined,
840
+ stack: error.stack,
841
+ type: error.name
842
+ } : error,
807
843
  // @ts-ignore
808
844
  message: error.message
809
845
  },
@@ -2486,13 +2522,14 @@ const getRunningExtensionsEmptyDom = loaded => {
2486
2522
  return [runningExtensionsNode, emptyNode, text(message)];
2487
2523
  };
2488
2524
 
2525
+ const containerClassName = mergeClassNames(RunningExtensions, Grow);
2489
2526
  const getRunningExtensionsVirtualDom = (extensions, loaded, focusedIndex = -1, selectedIndex = -1, focusOutline = false) => {
2490
2527
  if (extensions.length === 0) {
2491
2528
  return getRunningExtensionsEmptyDom(loaded);
2492
2529
  }
2493
2530
  return [{
2494
2531
  childCount: extensions.length,
2495
- className: mergeClassNames(RunningExtensions, Grow),
2532
+ className: containerClassName,
2496
2533
  onBlur: HandleBlur,
2497
2534
  onClick: HandleClick,
2498
2535
  onContextMenu: HandleContextMenu,
@@ -2560,12 +2597,7 @@ const getIssuesUrl = repository => {
2560
2597
  if (typeof repository !== 'string' || !URL.canParse(repository)) {
2561
2598
  return '';
2562
2599
  }
2563
- let url;
2564
- try {
2565
- url = new URL(repository);
2566
- } catch {
2567
- return '';
2568
- }
2600
+ const url = new URL(repository);
2569
2601
  if (url.protocol !== 'https:' || url.hostname !== 'github.com') {
2570
2602
  return '';
2571
2603
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/running-extensions-view",
3
- "version": "1.26.0",
3
+ "version": "1.28.0",
4
4
  "description": "Running Extensions View Worker",
5
5
  "repository": {
6
6
  "type": "git",