@lvce-editor/pty-host 8.6.0 → 8.8.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.
- package/dist/ptyHostMain.js +100 -52
- package/package.json +1 -1
package/dist/ptyHostMain.js
CHANGED
|
@@ -270,7 +270,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
270
270
|
for (const property of Object.values(value)) {
|
|
271
271
|
walkValue(property, transferrables, isTransferrable);
|
|
272
272
|
}
|
|
273
|
-
return;
|
|
274
273
|
}
|
|
275
274
|
};
|
|
276
275
|
const getTransferrables = value => {
|
|
@@ -473,7 +472,14 @@ class IpcError extends VError {
|
|
|
473
472
|
const cause = new Error(message);
|
|
474
473
|
// @ts-ignore
|
|
475
474
|
cause.code = code;
|
|
476
|
-
|
|
475
|
+
if (stack) {
|
|
476
|
+
Object.defineProperty(cause, 'stack', {
|
|
477
|
+
configurable: true,
|
|
478
|
+
enumerable: false,
|
|
479
|
+
value: stack,
|
|
480
|
+
writable: true
|
|
481
|
+
});
|
|
482
|
+
}
|
|
477
483
|
super(cause, betterMessage);
|
|
478
484
|
} else {
|
|
479
485
|
super(betterMessage);
|
|
@@ -764,13 +770,13 @@ const signal$4 = webSocket => {
|
|
|
764
770
|
webSocket.resume();
|
|
765
771
|
};
|
|
766
772
|
const wrap$9 = webSocket => {
|
|
767
|
-
|
|
773
|
+
const wrap = {
|
|
768
774
|
dispose() {
|
|
769
|
-
|
|
775
|
+
wrap.webSocket.close();
|
|
770
776
|
},
|
|
771
777
|
// @ts-ignore
|
|
772
778
|
off(event, listener) {
|
|
773
|
-
|
|
779
|
+
wrap.webSocket.off(event, listener);
|
|
774
780
|
},
|
|
775
781
|
// @ts-ignore
|
|
776
782
|
on(event, listener) {
|
|
@@ -784,7 +790,7 @@ const wrap$9 = webSocket => {
|
|
|
784
790
|
const data = deserialize(message);
|
|
785
791
|
const event = {
|
|
786
792
|
data,
|
|
787
|
-
target:
|
|
793
|
+
target: wrap
|
|
788
794
|
};
|
|
789
795
|
listener(event);
|
|
790
796
|
};
|
|
@@ -797,7 +803,7 @@ const wrap$9 = webSocket => {
|
|
|
797
803
|
// @ts-ignore
|
|
798
804
|
send(message) {
|
|
799
805
|
const stringifiedMessage = serialize(message);
|
|
800
|
-
|
|
806
|
+
wrap.webSocket.send(stringifiedMessage);
|
|
801
807
|
},
|
|
802
808
|
start() {
|
|
803
809
|
throw new Error('start method is deprecated');
|
|
@@ -808,6 +814,7 @@ const wrap$9 = webSocket => {
|
|
|
808
814
|
*/
|
|
809
815
|
wrappedListener: undefined
|
|
810
816
|
};
|
|
817
|
+
return wrap;
|
|
811
818
|
};
|
|
812
819
|
const IpcChildWithWebSocket = {
|
|
813
820
|
__proto__: null,
|
|
@@ -869,7 +876,10 @@ const constructError = (message, type, name) => {
|
|
|
869
876
|
if (ErrorConstructor === Error) {
|
|
870
877
|
const error = new Error(message);
|
|
871
878
|
if (name && name !== 'VError') {
|
|
872
|
-
error
|
|
879
|
+
Object.defineProperty(error, 'name', {
|
|
880
|
+
configurable: true,
|
|
881
|
+
value: name
|
|
882
|
+
});
|
|
873
883
|
}
|
|
874
884
|
return error;
|
|
875
885
|
}
|
|
@@ -886,8 +896,10 @@ const getCurrentStack = () => {
|
|
|
886
896
|
const currentStack = joinLines$1(splitLines$1(new Error().stack || '').slice(stackLinesToSkip));
|
|
887
897
|
return currentStack;
|
|
888
898
|
};
|
|
889
|
-
const getNewLineIndex$1 = (string, startIndex
|
|
890
|
-
|
|
899
|
+
const getNewLineIndex$1 = (string, startIndex) => {
|
|
900
|
+
{
|
|
901
|
+
return string.indexOf(NewLine$2);
|
|
902
|
+
}
|
|
891
903
|
};
|
|
892
904
|
const getParentStack = error => {
|
|
893
905
|
let parentStack = error.stack || error.data || error.message || '';
|
|
@@ -898,55 +910,91 @@ const getParentStack = error => {
|
|
|
898
910
|
};
|
|
899
911
|
const MethodNotFound = -32601;
|
|
900
912
|
const Custom = -32001;
|
|
913
|
+
const setStack = (error, stack) => {
|
|
914
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
915
|
+
if (descriptor) {
|
|
916
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
920
|
+
error.stack = stack;
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
Object.defineProperty(error, 'stack', {
|
|
925
|
+
configurable: true,
|
|
926
|
+
value: stack,
|
|
927
|
+
writable: true
|
|
928
|
+
});
|
|
929
|
+
};
|
|
930
|
+
const restoreExistingError = (error, currentStack) => {
|
|
931
|
+
if (typeof error.stack === 'string') {
|
|
932
|
+
setStack(error, `${error.stack}${NewLine$2}${currentStack}`);
|
|
933
|
+
}
|
|
934
|
+
return error;
|
|
935
|
+
};
|
|
936
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
937
|
+
const restoredError = new JsonRpcError(error.message);
|
|
938
|
+
const parentStack = getParentStack(error);
|
|
939
|
+
setStack(restoredError, `${parentStack}${NewLine$2}${currentStack}`);
|
|
940
|
+
return restoredError;
|
|
941
|
+
};
|
|
942
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
943
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
944
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine$2}${error.data.stack}${NewLine$2}${currentStack}`);
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
if (error.data.stack) {
|
|
948
|
+
setStack(restoredError, error.data.stack);
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
const applyDataProperties = (restoredError, error) => {
|
|
952
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
953
|
+
if (error.data.codeFrame) {
|
|
954
|
+
// @ts-ignore
|
|
955
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
956
|
+
}
|
|
957
|
+
if (error.data.code) {
|
|
958
|
+
// @ts-ignore
|
|
959
|
+
restoredError.code = error.data.code;
|
|
960
|
+
}
|
|
961
|
+
if (error.data.type) {
|
|
962
|
+
// @ts-ignore
|
|
963
|
+
restoredError.name = error.data.type;
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
967
|
+
if (error.stack) {
|
|
968
|
+
const lowerStack = restoredError.stack || '';
|
|
969
|
+
const indexNewLine = getNewLineIndex$1(lowerStack);
|
|
970
|
+
const parentStack = getParentStack(error);
|
|
971
|
+
// @ts-ignore
|
|
972
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
973
|
+
}
|
|
974
|
+
if (error.codeFrame) {
|
|
975
|
+
// @ts-ignore
|
|
976
|
+
restoredError.codeFrame = error.codeFrame;
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
980
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
981
|
+
if (error.data) {
|
|
982
|
+
applyDataProperties(restoredError, error);
|
|
983
|
+
} else {
|
|
984
|
+
applyDirectProperties(restoredError, error);
|
|
985
|
+
}
|
|
986
|
+
return restoredError;
|
|
987
|
+
};
|
|
901
988
|
const restoreJsonRpcError = error => {
|
|
902
989
|
const currentStack = getCurrentStack();
|
|
903
990
|
if (error && error instanceof Error) {
|
|
904
|
-
|
|
905
|
-
error.stack = error.stack + NewLine$2 + currentStack;
|
|
906
|
-
}
|
|
907
|
-
return error;
|
|
991
|
+
return restoreExistingError(error, currentStack);
|
|
908
992
|
}
|
|
909
993
|
if (error && error.code && error.code === MethodNotFound) {
|
|
910
|
-
|
|
911
|
-
const parentStack = getParentStack(error);
|
|
912
|
-
restoredError.stack = parentStack + NewLine$2 + currentStack;
|
|
913
|
-
return restoredError;
|
|
994
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
914
995
|
}
|
|
915
996
|
if (error && error.message) {
|
|
916
|
-
|
|
917
|
-
if (error.data) {
|
|
918
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
919
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine$2 + error.data.stack + NewLine$2 + currentStack;
|
|
920
|
-
} else if (error.data.stack) {
|
|
921
|
-
restoredError.stack = error.data.stack;
|
|
922
|
-
}
|
|
923
|
-
if (error.data.codeFrame) {
|
|
924
|
-
// @ts-ignore
|
|
925
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
926
|
-
}
|
|
927
|
-
if (error.data.code) {
|
|
928
|
-
// @ts-ignore
|
|
929
|
-
restoredError.code = error.data.code;
|
|
930
|
-
}
|
|
931
|
-
if (error.data.type) {
|
|
932
|
-
// @ts-ignore
|
|
933
|
-
restoredError.name = error.data.type;
|
|
934
|
-
}
|
|
935
|
-
} else {
|
|
936
|
-
if (error.stack) {
|
|
937
|
-
const lowerStack = restoredError.stack || '';
|
|
938
|
-
// @ts-ignore
|
|
939
|
-
const indexNewLine = getNewLineIndex$1(lowerStack);
|
|
940
|
-
const parentStack = getParentStack(error);
|
|
941
|
-
// @ts-ignore
|
|
942
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
943
|
-
}
|
|
944
|
-
if (error.codeFrame) {
|
|
945
|
-
// @ts-ignore
|
|
946
|
-
restoredError.codeFrame = error.codeFrame;
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
return restoredError;
|
|
997
|
+
return restoreMessageError(error);
|
|
950
998
|
}
|
|
951
999
|
if (typeof error === 'string') {
|
|
952
1000
|
return new Error(`JsonRpc Error: ${error}`);
|