@lvce-editor/status-bar-worker 3.3.0 → 3.4.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.
- package/dist/statusBarWorkerMain.js +102 -53
- package/package.json +1 -1
|
@@ -325,7 +325,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
325
325
|
for (const property of Object.values(value)) {
|
|
326
326
|
walkValue(property, transferrables, isTransferrable);
|
|
327
327
|
}
|
|
328
|
-
return;
|
|
329
328
|
}
|
|
330
329
|
};
|
|
331
330
|
const getTransferrables = value => {
|
|
@@ -479,7 +478,14 @@ class IpcError extends VError {
|
|
|
479
478
|
const cause = new Error(message);
|
|
480
479
|
// @ts-ignore
|
|
481
480
|
cause.code = code;
|
|
482
|
-
|
|
481
|
+
if (stack) {
|
|
482
|
+
Object.defineProperty(cause, 'stack', {
|
|
483
|
+
configurable: true,
|
|
484
|
+
enumerable: false,
|
|
485
|
+
value: stack,
|
|
486
|
+
writable: true
|
|
487
|
+
});
|
|
488
|
+
}
|
|
483
489
|
super(cause, betterMessage);
|
|
484
490
|
} else {
|
|
485
491
|
super(betterMessage);
|
|
@@ -766,7 +772,10 @@ const constructError = (message, type, name) => {
|
|
|
766
772
|
if (ErrorConstructor === Error) {
|
|
767
773
|
const error = new Error(message);
|
|
768
774
|
if (name && name !== 'VError') {
|
|
769
|
-
error
|
|
775
|
+
Object.defineProperty(error, 'name', {
|
|
776
|
+
configurable: true,
|
|
777
|
+
value: name
|
|
778
|
+
});
|
|
770
779
|
}
|
|
771
780
|
return error;
|
|
772
781
|
}
|
|
@@ -783,8 +792,10 @@ const getCurrentStack = () => {
|
|
|
783
792
|
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
784
793
|
return currentStack;
|
|
785
794
|
};
|
|
786
|
-
const getNewLineIndex = (string, startIndex
|
|
787
|
-
|
|
795
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
796
|
+
{
|
|
797
|
+
return string.indexOf(NewLine);
|
|
798
|
+
}
|
|
788
799
|
};
|
|
789
800
|
const getParentStack = error => {
|
|
790
801
|
let parentStack = error.stack || error.data || error.message || '';
|
|
@@ -795,55 +806,91 @@ const getParentStack = error => {
|
|
|
795
806
|
};
|
|
796
807
|
const MethodNotFound = -32601;
|
|
797
808
|
const Custom = -32001;
|
|
809
|
+
const setStack = (error, stack) => {
|
|
810
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
811
|
+
if (descriptor) {
|
|
812
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
816
|
+
error.stack = stack;
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
Object.defineProperty(error, 'stack', {
|
|
821
|
+
configurable: true,
|
|
822
|
+
value: stack,
|
|
823
|
+
writable: true
|
|
824
|
+
});
|
|
825
|
+
};
|
|
826
|
+
const restoreExistingError = (error, currentStack) => {
|
|
827
|
+
if (typeof error.stack === 'string') {
|
|
828
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
829
|
+
}
|
|
830
|
+
return error;
|
|
831
|
+
};
|
|
832
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
833
|
+
const restoredError = new JsonRpcError(error.message);
|
|
834
|
+
const parentStack = getParentStack(error);
|
|
835
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
836
|
+
return restoredError;
|
|
837
|
+
};
|
|
838
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
839
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
840
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
if (error.data.stack) {
|
|
844
|
+
setStack(restoredError, error.data.stack);
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
const applyDataProperties = (restoredError, error) => {
|
|
848
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
849
|
+
if (error.data.codeFrame) {
|
|
850
|
+
// @ts-ignore
|
|
851
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
852
|
+
}
|
|
853
|
+
if (error.data.code) {
|
|
854
|
+
// @ts-ignore
|
|
855
|
+
restoredError.code = error.data.code;
|
|
856
|
+
}
|
|
857
|
+
if (error.data.type) {
|
|
858
|
+
// @ts-ignore
|
|
859
|
+
restoredError.name = error.data.type;
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
863
|
+
if (error.stack) {
|
|
864
|
+
const lowerStack = restoredError.stack || '';
|
|
865
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
866
|
+
const parentStack = getParentStack(error);
|
|
867
|
+
// @ts-ignore
|
|
868
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
869
|
+
}
|
|
870
|
+
if (error.codeFrame) {
|
|
871
|
+
// @ts-ignore
|
|
872
|
+
restoredError.codeFrame = error.codeFrame;
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
876
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
877
|
+
if (error.data) {
|
|
878
|
+
applyDataProperties(restoredError, error);
|
|
879
|
+
} else {
|
|
880
|
+
applyDirectProperties(restoredError, error);
|
|
881
|
+
}
|
|
882
|
+
return restoredError;
|
|
883
|
+
};
|
|
798
884
|
const restoreJsonRpcError = error => {
|
|
799
885
|
const currentStack = getCurrentStack();
|
|
800
886
|
if (error && error instanceof Error) {
|
|
801
|
-
|
|
802
|
-
error.stack = error.stack + NewLine + currentStack;
|
|
803
|
-
}
|
|
804
|
-
return error;
|
|
887
|
+
return restoreExistingError(error, currentStack);
|
|
805
888
|
}
|
|
806
889
|
if (error && error.code && error.code === MethodNotFound) {
|
|
807
|
-
|
|
808
|
-
const parentStack = getParentStack(error);
|
|
809
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
810
|
-
return restoredError;
|
|
890
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
811
891
|
}
|
|
812
892
|
if (error && error.message) {
|
|
813
|
-
|
|
814
|
-
if (error.data) {
|
|
815
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
816
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
817
|
-
} else if (error.data.stack) {
|
|
818
|
-
restoredError.stack = error.data.stack;
|
|
819
|
-
}
|
|
820
|
-
if (error.data.codeFrame) {
|
|
821
|
-
// @ts-ignore
|
|
822
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
823
|
-
}
|
|
824
|
-
if (error.data.code) {
|
|
825
|
-
// @ts-ignore
|
|
826
|
-
restoredError.code = error.data.code;
|
|
827
|
-
}
|
|
828
|
-
if (error.data.type) {
|
|
829
|
-
// @ts-ignore
|
|
830
|
-
restoredError.name = error.data.type;
|
|
831
|
-
}
|
|
832
|
-
} else {
|
|
833
|
-
if (error.stack) {
|
|
834
|
-
const lowerStack = restoredError.stack || '';
|
|
835
|
-
// @ts-ignore
|
|
836
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
837
|
-
const parentStack = getParentStack(error);
|
|
838
|
-
// @ts-ignore
|
|
839
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
840
|
-
}
|
|
841
|
-
if (error.codeFrame) {
|
|
842
|
-
// @ts-ignore
|
|
843
|
-
restoredError.codeFrame = error.codeFrame;
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
return restoredError;
|
|
893
|
+
return restoreMessageError(error);
|
|
847
894
|
}
|
|
848
895
|
if (typeof error === 'string') {
|
|
849
896
|
return new Error(`JsonRpc Error: ${error}`);
|
|
@@ -1786,26 +1833,28 @@ const text = data => {
|
|
|
1786
1833
|
const HandleContextMenu = 2;
|
|
1787
1834
|
const HandleClick = 11;
|
|
1788
1835
|
|
|
1789
|
-
const getTextVirtualDom = element => {
|
|
1836
|
+
const getTextVirtualDom = (element, name) => {
|
|
1790
1837
|
return [{
|
|
1791
1838
|
childCount: 1,
|
|
1792
1839
|
className: 'StatusBarItemLabel',
|
|
1840
|
+
name,
|
|
1793
1841
|
type: Span
|
|
1794
1842
|
}, text(element.value)];
|
|
1795
1843
|
};
|
|
1796
|
-
const getIconVirtualDom = element => {
|
|
1844
|
+
const getIconVirtualDom = (element, name) => {
|
|
1797
1845
|
return [{
|
|
1798
1846
|
childCount: 0,
|
|
1799
1847
|
className: mergeClassNames(MaskIcon, element.value),
|
|
1848
|
+
name,
|
|
1800
1849
|
type: Div
|
|
1801
1850
|
}];
|
|
1802
1851
|
};
|
|
1803
|
-
const getStatusBarItemElementVirtualDom = element => {
|
|
1852
|
+
const getStatusBarItemElementVirtualDom = (element, name) => {
|
|
1804
1853
|
if (element.type === 'text') {
|
|
1805
|
-
return getTextVirtualDom(element);
|
|
1854
|
+
return getTextVirtualDom(element, name);
|
|
1806
1855
|
}
|
|
1807
1856
|
if (element.type === 'icon') {
|
|
1808
|
-
return getIconVirtualDom(element);
|
|
1857
|
+
return getIconVirtualDom(element, name);
|
|
1809
1858
|
}
|
|
1810
1859
|
return [];
|
|
1811
1860
|
};
|
|
@@ -1817,7 +1866,7 @@ const getStatusBarItemVirtualDom = statusBarItem => {
|
|
|
1817
1866
|
name,
|
|
1818
1867
|
tooltip
|
|
1819
1868
|
} = statusBarItem;
|
|
1820
|
-
const elementNodes = elements.flatMap(getStatusBarItemElementVirtualDom);
|
|
1869
|
+
const elementNodes = elements.flatMap(element => getStatusBarItemElementVirtualDom(element, name));
|
|
1821
1870
|
const buttonNode = {
|
|
1822
1871
|
ariaLabel,
|
|
1823
1872
|
childCount: elements.length,
|