@lvce-editor/quick-pick-worker 4.23.2 → 4.24.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/quickPickWorkerMain.js +51 -10
- package/package.json +1 -1
|
@@ -663,6 +663,9 @@ const restoreExistingError = (error, currentStack) => {
|
|
|
663
663
|
};
|
|
664
664
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
665
665
|
const restoredError = new JsonRpcError(error.message);
|
|
666
|
+
Object.assign(restoredError, {
|
|
667
|
+
code: error.code
|
|
668
|
+
});
|
|
666
669
|
const parentStack = getParentStack(error);
|
|
667
670
|
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
668
671
|
return restoredError;
|
|
@@ -682,9 +685,13 @@ const applyDataProperties = (restoredError, error) => {
|
|
|
682
685
|
// @ts-ignore
|
|
683
686
|
restoredError.codeFrame = error.data.codeFrame;
|
|
684
687
|
}
|
|
685
|
-
if (error.data.code) {
|
|
688
|
+
if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
|
|
686
689
|
// @ts-ignore
|
|
687
|
-
restoredError
|
|
690
|
+
Object.defineProperty(restoredError, 'code', {
|
|
691
|
+
configurable: true,
|
|
692
|
+
value: error.data.code,
|
|
693
|
+
writable: true
|
|
694
|
+
});
|
|
688
695
|
}
|
|
689
696
|
if (error.data.type) {
|
|
690
697
|
// @ts-ignore
|
|
@@ -705,7 +712,14 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
705
712
|
}
|
|
706
713
|
};
|
|
707
714
|
const restoreMessageError = (error, _currentStack) => {
|
|
708
|
-
const restoredError = constructError(error.message, error.type, error.name);
|
|
715
|
+
const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
|
|
716
|
+
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
717
|
+
Object.defineProperty(restoredError, 'code', {
|
|
718
|
+
configurable: true,
|
|
719
|
+
value: error.code,
|
|
720
|
+
writable: true
|
|
721
|
+
});
|
|
722
|
+
}
|
|
709
723
|
if (error.data) {
|
|
710
724
|
applyDataProperties(restoredError, error);
|
|
711
725
|
} else {
|
|
@@ -713,6 +727,23 @@ const restoreMessageError = (error, _currentStack) => {
|
|
|
713
727
|
}
|
|
714
728
|
return restoredError;
|
|
715
729
|
};
|
|
730
|
+
const getFallbackMessage = error => {
|
|
731
|
+
if (error && typeof error.message === 'string' && error.message) {
|
|
732
|
+
return error.message;
|
|
733
|
+
}
|
|
734
|
+
if (error && error.data) {
|
|
735
|
+
return getFallbackMessage(error.data);
|
|
736
|
+
}
|
|
737
|
+
const stringified = String(error);
|
|
738
|
+
if (stringified !== '[object Object]') {
|
|
739
|
+
return stringified;
|
|
740
|
+
}
|
|
741
|
+
try {
|
|
742
|
+
return JSON.stringify(error);
|
|
743
|
+
} catch {
|
|
744
|
+
return stringified;
|
|
745
|
+
}
|
|
746
|
+
};
|
|
716
747
|
const restoreJsonRpcError = error => {
|
|
717
748
|
const currentStack = getCurrentStack();
|
|
718
749
|
if (error && error instanceof Error) {
|
|
@@ -721,13 +752,13 @@ const restoreJsonRpcError = error => {
|
|
|
721
752
|
if (error && error.code && error.code === MethodNotFound) {
|
|
722
753
|
return restoreMethodNotFoundError(error, currentStack);
|
|
723
754
|
}
|
|
755
|
+
if (error && error.error) {
|
|
756
|
+
return restoreJsonRpcError(error.error);
|
|
757
|
+
}
|
|
724
758
|
if (error && error.message) {
|
|
725
759
|
return restoreMessageError(error);
|
|
726
760
|
}
|
|
727
|
-
|
|
728
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
729
|
-
}
|
|
730
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
761
|
+
return new Error(`JsonRpc Error: ${getFallbackMessage(error)}`);
|
|
731
762
|
};
|
|
732
763
|
const unwrapJsonRpcResult = responseMessage => {
|
|
733
764
|
if ('error' in responseMessage) {
|
|
@@ -784,9 +815,9 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
784
815
|
return {
|
|
785
816
|
code: Custom$2,
|
|
786
817
|
data: {
|
|
787
|
-
code: prettyError.code,
|
|
818
|
+
code: prettyError.code ?? error?.code,
|
|
788
819
|
codeFrame: prettyError.codeFrame,
|
|
789
|
-
name: prettyError.name,
|
|
820
|
+
name: prettyError.name ?? error?.name,
|
|
790
821
|
stack: getStack(prettyError),
|
|
791
822
|
type: getErrorType(prettyError)
|
|
792
823
|
},
|
|
@@ -821,7 +852,12 @@ const getErrorResponseSimple = (id, error) => {
|
|
|
821
852
|
return {
|
|
822
853
|
error: {
|
|
823
854
|
code: Custom$2,
|
|
824
|
-
data: error
|
|
855
|
+
data: error instanceof Error ? {
|
|
856
|
+
...error,
|
|
857
|
+
code: 'code' in error ? error.code : undefined,
|
|
858
|
+
stack: error.stack,
|
|
859
|
+
type: error.name
|
|
860
|
+
} : error,
|
|
825
861
|
// @ts-ignore
|
|
826
862
|
message: error.message
|
|
827
863
|
},
|
|
@@ -5165,6 +5201,11 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
5165
5201
|
if (item === RenderFocusedIndex) {
|
|
5166
5202
|
continue;
|
|
5167
5203
|
}
|
|
5204
|
+
if (item === RenderFocus) {
|
|
5205
|
+
// Register shortcuts before rendering/focusing the input. Waiting for its
|
|
5206
|
+
// DOM focus event leaves a round trip where Enter can be lost.
|
|
5207
|
+
commands.push(['Viewlet.setFocusContext', newState.uid, FocusQuickPickInput]);
|
|
5208
|
+
}
|
|
5168
5209
|
const fn = getRenderer(item);
|
|
5169
5210
|
commands.push(fn(oldState, newState));
|
|
5170
5211
|
}
|