@lvce-editor/problems-view 1.25.3 → 1.25.4

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.
@@ -712,7 +712,10 @@ const constructError = (message, type, name) => {
712
712
  if (ErrorConstructor === Error) {
713
713
  const error = new Error(message);
714
714
  if (name && name !== 'VError') {
715
- error.name = name;
715
+ Object.defineProperty(error, 'name', {
716
+ configurable: true,
717
+ value: name
718
+ });
716
719
  }
717
720
  return error;
718
721
  }
@@ -729,8 +732,10 @@ const getCurrentStack = () => {
729
732
  const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
730
733
  return currentStack;
731
734
  };
732
- const getNewLineIndex = (string, startIndex = undefined) => {
733
- return string.indexOf(NewLine, startIndex);
735
+ const getNewLineIndex = (string, startIndex) => {
736
+ {
737
+ return string.indexOf(NewLine);
738
+ }
734
739
  };
735
740
  const getParentStack = error => {
736
741
  let parentStack = error.stack || error.data || error.message || '';
@@ -741,55 +746,91 @@ const getParentStack = error => {
741
746
  };
742
747
  const MethodNotFound = -32601;
743
748
  const Custom = -32001;
749
+ const setStack = (error, stack) => {
750
+ const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
751
+ if (descriptor) {
752
+ if (!descriptor.configurable && !descriptor.writable) {
753
+ return;
754
+ }
755
+ if (!descriptor.configurable && descriptor.writable) {
756
+ error.stack = stack;
757
+ return;
758
+ }
759
+ }
760
+ Object.defineProperty(error, 'stack', {
761
+ configurable: true,
762
+ value: stack,
763
+ writable: true
764
+ });
765
+ };
766
+ const restoreExistingError = (error, currentStack) => {
767
+ if (typeof error.stack === 'string') {
768
+ setStack(error, `${error.stack}${NewLine}${currentStack}`);
769
+ }
770
+ return error;
771
+ };
772
+ const restoreMethodNotFoundError = (error, currentStack) => {
773
+ const restoredError = new JsonRpcError(error.message);
774
+ const parentStack = getParentStack(error);
775
+ setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
776
+ return restoredError;
777
+ };
778
+ const restoreStackFromData = (restoredError, error, currentStack) => {
779
+ if (error.data.stack && error.data.type && error.message) {
780
+ setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
781
+ return;
782
+ }
783
+ if (error.data.stack) {
784
+ setStack(restoredError, error.data.stack);
785
+ }
786
+ };
787
+ const applyDataProperties = (restoredError, error) => {
788
+ restoreStackFromData(restoredError, error, getCurrentStack());
789
+ if (error.data.codeFrame) {
790
+ // @ts-ignore
791
+ restoredError.codeFrame = error.data.codeFrame;
792
+ }
793
+ if (error.data.code) {
794
+ // @ts-ignore
795
+ restoredError.code = error.data.code;
796
+ }
797
+ if (error.data.type) {
798
+ // @ts-ignore
799
+ restoredError.name = error.data.type;
800
+ }
801
+ };
802
+ const applyDirectProperties = (restoredError, error) => {
803
+ if (error.stack) {
804
+ const lowerStack = restoredError.stack || '';
805
+ const indexNewLine = getNewLineIndex(lowerStack);
806
+ const parentStack = getParentStack(error);
807
+ // @ts-ignore
808
+ setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
809
+ }
810
+ if (error.codeFrame) {
811
+ // @ts-ignore
812
+ restoredError.codeFrame = error.codeFrame;
813
+ }
814
+ };
815
+ const restoreMessageError = (error, _currentStack) => {
816
+ const restoredError = constructError(error.message, error.type, error.name);
817
+ if (error.data) {
818
+ applyDataProperties(restoredError, error);
819
+ } else {
820
+ applyDirectProperties(restoredError, error);
821
+ }
822
+ return restoredError;
823
+ };
744
824
  const restoreJsonRpcError = error => {
745
825
  const currentStack = getCurrentStack();
746
826
  if (error && error instanceof Error) {
747
- if (typeof error.stack === 'string') {
748
- error.stack = error.stack + NewLine + currentStack;
749
- }
750
- return error;
827
+ return restoreExistingError(error, currentStack);
751
828
  }
752
829
  if (error && error.code && error.code === MethodNotFound) {
753
- const restoredError = new JsonRpcError(error.message);
754
- const parentStack = getParentStack(error);
755
- restoredError.stack = parentStack + NewLine + currentStack;
756
- return restoredError;
830
+ return restoreMethodNotFoundError(error, currentStack);
757
831
  }
758
832
  if (error && error.message) {
759
- const restoredError = constructError(error.message, error.type, error.name);
760
- if (error.data) {
761
- if (error.data.stack && error.data.type && error.message) {
762
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
763
- } else if (error.data.stack) {
764
- restoredError.stack = error.data.stack;
765
- }
766
- if (error.data.codeFrame) {
767
- // @ts-ignore
768
- restoredError.codeFrame = error.data.codeFrame;
769
- }
770
- if (error.data.code) {
771
- // @ts-ignore
772
- restoredError.code = error.data.code;
773
- }
774
- if (error.data.type) {
775
- // @ts-ignore
776
- restoredError.name = error.data.type;
777
- }
778
- } else {
779
- if (error.stack) {
780
- const lowerStack = restoredError.stack || '';
781
- // @ts-ignore
782
- const indexNewLine = getNewLineIndex(lowerStack);
783
- const parentStack = getParentStack(error);
784
- // @ts-ignore
785
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
786
- }
787
- if (error.codeFrame) {
788
- // @ts-ignore
789
- restoredError.codeFrame = error.codeFrame;
790
- }
791
- }
792
- return restoredError;
833
+ return restoreMessageError(error);
793
834
  }
794
835
  if (typeof error === 'string') {
795
836
  return new Error(`JsonRpc Error: ${error}`);
@@ -2157,6 +2198,7 @@ const MessageAction = 'MessageAction';
2157
2198
  const Problem = 'Problem';
2158
2199
  const ProblemAt = 'ProblemAt';
2159
2200
  const ProblemBadge = 'ProblemBadge';
2201
+ const ProblemLabel = 'ProblemLabel';
2160
2202
  const Problems = 'Problems';
2161
2203
  const ProblemSelected = 'ProblemSelected';
2162
2204
  const ProblemsErrorIcon = 'ProblemsErrorIcon';
@@ -2396,7 +2438,7 @@ const getProblemVirtualDom = problem => {
2396
2438
  const lineColumn = atLineColumn(rowIndex, columnIndex);
2397
2439
  const label = {
2398
2440
  childCount: 1,
2399
- className: Label,
2441
+ className: ProblemLabel,
2400
2442
  type: Div
2401
2443
  };
2402
2444
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.25.3",
3
+ "version": "1.25.4",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",