@lvce-editor/extension-host-worker 8.9.0 → 8.11.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/extensionHostWorkerMain.js +1471 -1457
- package/package.json +1 -1
|
@@ -777,1668 +777,1670 @@ const setConfigurations = preferences => {
|
|
|
777
777
|
state$9.configuration = preferences;
|
|
778
778
|
};
|
|
779
779
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
super(`Command not found ${command}`);
|
|
783
|
-
this.name = 'CommandNotFoundError';
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
const commands = Object.create(null);
|
|
787
|
-
const register$1 = commandMap => {
|
|
788
|
-
Object.assign(commands, commandMap);
|
|
780
|
+
const isMessagePort = value => {
|
|
781
|
+
return value && value instanceof MessagePort;
|
|
789
782
|
};
|
|
790
|
-
const
|
|
791
|
-
return
|
|
783
|
+
const isMessagePortMain = value => {
|
|
784
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
792
785
|
};
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
786
|
+
const isOffscreenCanvas = value => {
|
|
787
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
788
|
+
};
|
|
789
|
+
const isInstanceOf = (value, constructorName) => {
|
|
790
|
+
return value?.constructor?.name === constructorName;
|
|
791
|
+
};
|
|
792
|
+
const isSocket = value => {
|
|
793
|
+
return isInstanceOf(value, 'Socket');
|
|
794
|
+
};
|
|
795
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
796
|
+
const isTransferrable = value => {
|
|
797
|
+
for (const fn of transferrables) {
|
|
798
|
+
if (fn(value)) {
|
|
799
|
+
return true;
|
|
800
|
+
}
|
|
797
801
|
}
|
|
798
|
-
return
|
|
802
|
+
return false;
|
|
799
803
|
};
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
804
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
805
|
+
if (!value) {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
if (isTransferrable(value)) {
|
|
809
|
+
transferrables.push(value);
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
if (Array.isArray(value)) {
|
|
813
|
+
for (const item of value) {
|
|
814
|
+
walkValue(item, transferrables, isTransferrable);
|
|
810
815
|
}
|
|
811
|
-
return
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
if (typeof value === 'object') {
|
|
819
|
+
for (const property of Object.values(value)) {
|
|
820
|
+
walkValue(property, transferrables, isTransferrable);
|
|
821
|
+
}
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
const getTransferrables = value => {
|
|
826
|
+
const transferrables = [];
|
|
827
|
+
walkValue(value, transferrables, isTransferrable);
|
|
828
|
+
return transferrables;
|
|
829
|
+
};
|
|
830
|
+
const attachEvents = that => {
|
|
831
|
+
const handleMessage = (...args) => {
|
|
832
|
+
const data = that.getData(...args);
|
|
833
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
834
|
+
data
|
|
835
|
+
}));
|
|
812
836
|
};
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
invokeAndTransfer: invoke
|
|
837
|
+
that.onMessage(handleMessage);
|
|
838
|
+
const handleClose = event => {
|
|
839
|
+
that.dispatchEvent(new Event('close'));
|
|
817
840
|
};
|
|
818
|
-
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
const rpcs$2 = Object.create(null);
|
|
822
|
-
const set$c = (id, rpc) => {
|
|
823
|
-
rpcs$2[id] = rpc;
|
|
841
|
+
that.onClose(handleClose);
|
|
824
842
|
};
|
|
825
|
-
|
|
826
|
-
|
|
843
|
+
class Ipc extends EventTarget {
|
|
844
|
+
constructor(rawIpc) {
|
|
845
|
+
super();
|
|
846
|
+
this._rawIpc = rawIpc;
|
|
847
|
+
attachEvents(this);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
851
|
+
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
852
|
+
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
853
|
+
const NewLine$2 = '\n';
|
|
854
|
+
const joinLines$1 = lines => {
|
|
855
|
+
return lines.join(NewLine$2);
|
|
827
856
|
};
|
|
828
|
-
const
|
|
829
|
-
|
|
857
|
+
const RE_AT = /^\s+at/;
|
|
858
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
859
|
+
const isNormalStackLine = line => {
|
|
860
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
830
861
|
};
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
return rpc.invoke(method, ...params);
|
|
844
|
-
},
|
|
845
|
-
// @ts-ignore
|
|
846
|
-
invokeAndTransfer(method, ...params) {
|
|
847
|
-
const rpc = get$b(rpcId);
|
|
848
|
-
// @ts-ignore
|
|
849
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
850
|
-
},
|
|
851
|
-
registerMockRpc(commandMap) {
|
|
852
|
-
const mockRpc = createMockRpc({
|
|
853
|
-
commandMap
|
|
854
|
-
});
|
|
855
|
-
set$c(rpcId, mockRpc);
|
|
856
|
-
// @ts-ignore
|
|
857
|
-
mockRpc[Symbol.dispose] = () => {
|
|
858
|
-
remove$5(rpcId);
|
|
859
|
-
};
|
|
860
|
-
// @ts-ignore
|
|
861
|
-
return mockRpc;
|
|
862
|
-
},
|
|
863
|
-
set(rpc) {
|
|
864
|
-
set$c(rpcId, rpc);
|
|
862
|
+
const getDetails = lines => {
|
|
863
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
864
|
+
if (index === -1) {
|
|
865
|
+
return {
|
|
866
|
+
actualMessage: joinLines$1(lines),
|
|
867
|
+
rest: []
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
let lastIndex = index - 1;
|
|
871
|
+
while (++lastIndex < lines.length) {
|
|
872
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
873
|
+
break;
|
|
865
874
|
}
|
|
875
|
+
}
|
|
876
|
+
return {
|
|
877
|
+
actualMessage: lines[index - 1],
|
|
878
|
+
rest: lines.slice(index, lastIndex)
|
|
866
879
|
};
|
|
867
880
|
};
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
const ExtensionManagementWorker = 9006;
|
|
871
|
-
const RendererWorker$1 = 1;
|
|
872
|
-
|
|
873
|
-
const {
|
|
874
|
-
invoke: invoke$6} = create$k(DebugWorker$1);
|
|
875
|
-
|
|
876
|
-
const DebugWorker = {
|
|
877
|
-
__proto__: null,
|
|
878
|
-
invoke: invoke$6
|
|
881
|
+
const splitLines$2 = lines => {
|
|
882
|
+
return lines.split(NewLine$2);
|
|
879
883
|
};
|
|
880
|
-
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
set: set$b
|
|
885
|
-
} = create$k(ExtensionManagementWorker);
|
|
886
|
-
|
|
887
|
-
const {
|
|
888
|
-
invoke: invoke$4,
|
|
889
|
-
set: set$a
|
|
890
|
-
} = create$k(7013);
|
|
891
|
-
|
|
892
|
-
const {
|
|
893
|
-
invoke: invoke$3,
|
|
894
|
-
invokeAndTransfer: invokeAndTransfer$2} = create$k(RendererWorker$1);
|
|
895
|
-
const sendMessagePortToFileSearchWorker = async (port, rpcId = 0) => {
|
|
896
|
-
const command = 'QuickPick.handleMessagePort';
|
|
897
|
-
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSearchWorker', port, command, rpcId);
|
|
884
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
885
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
886
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
887
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
898
888
|
};
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToIframeWorker', port, command, rpcId);
|
|
889
|
+
const isMessageCodeBlockEndIndex = line => {
|
|
890
|
+
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
902
891
|
};
|
|
903
|
-
const
|
|
904
|
-
const
|
|
905
|
-
|
|
892
|
+
const getMessageCodeBlock = stderr => {
|
|
893
|
+
const lines = splitLines$2(stderr);
|
|
894
|
+
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
895
|
+
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
896
|
+
const relevantLines = lines.slice(startIndex, endIndex);
|
|
897
|
+
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
898
|
+
return relevantMessage;
|
|
906
899
|
};
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
invoke: invoke$2
|
|
910
|
-
} = DebugWorker;
|
|
911
|
-
|
|
912
|
-
const state$8 = {
|
|
913
|
-
debugProviderMap: Object.create(null)
|
|
900
|
+
const isModuleNotFoundMessage = line => {
|
|
901
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
914
902
|
};
|
|
915
|
-
const
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
903
|
+
const getModuleNotFoundError = stderr => {
|
|
904
|
+
const lines = splitLines$2(stderr);
|
|
905
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
906
|
+
const message = lines[messageIndex];
|
|
907
|
+
return {
|
|
908
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
909
|
+
message
|
|
910
|
+
};
|
|
911
|
+
};
|
|
912
|
+
const isModuleNotFoundError = stderr => {
|
|
913
|
+
if (!stderr) {
|
|
914
|
+
return false;
|
|
920
915
|
}
|
|
921
|
-
return
|
|
916
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
922
917
|
};
|
|
923
|
-
const
|
|
924
|
-
if (!
|
|
925
|
-
|
|
918
|
+
const isModulesSyntaxError = stderr => {
|
|
919
|
+
if (!stderr) {
|
|
920
|
+
return false;
|
|
926
921
|
}
|
|
927
|
-
|
|
922
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
928
923
|
};
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
|
|
924
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
925
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
926
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
927
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
932
928
|
};
|
|
933
|
-
const
|
|
934
|
-
|
|
935
|
-
|
|
929
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
930
|
+
const message = getMessageCodeBlock(stderr);
|
|
931
|
+
return {
|
|
932
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
933
|
+
message: `Incompatible native node module: ${message}`
|
|
934
|
+
};
|
|
936
935
|
};
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
object(params);
|
|
943
|
-
// @ts-ignore
|
|
944
|
-
await invoke$2('Debug.handleChange', params);
|
|
936
|
+
const getModuleSyntaxError = () => {
|
|
937
|
+
return {
|
|
938
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
939
|
+
message: `ES Modules are not supported in electron`
|
|
940
|
+
};
|
|
945
941
|
};
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
const emitter = {
|
|
950
|
-
handleChange,
|
|
951
|
-
handlePaused,
|
|
952
|
-
handleResumed,
|
|
953
|
-
handleScriptParsed
|
|
954
|
-
};
|
|
955
|
-
await provider.start(emitter, path);
|
|
956
|
-
} catch (error) {
|
|
957
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
942
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
943
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
944
|
+
return getNativeModuleErrorMessage(stderr);
|
|
958
945
|
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
try {
|
|
962
|
-
const provider = getDebugProvider(protocol);
|
|
963
|
-
const processes = await provider.listProcesses(path);
|
|
964
|
-
array(processes);
|
|
965
|
-
return processes;
|
|
966
|
-
} catch (error) {
|
|
967
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
946
|
+
if (isModulesSyntaxError(stderr)) {
|
|
947
|
+
return getModuleSyntaxError();
|
|
968
948
|
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
try {
|
|
972
|
-
const provider = getDebugProvider(protocol);
|
|
973
|
-
return await provider.resume();
|
|
974
|
-
} catch (error) {
|
|
975
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
949
|
+
if (isModuleNotFoundError(stderr)) {
|
|
950
|
+
return getModuleNotFoundError(stderr);
|
|
976
951
|
}
|
|
952
|
+
const lines = splitLines$2(stderr);
|
|
953
|
+
const {
|
|
954
|
+
actualMessage,
|
|
955
|
+
rest
|
|
956
|
+
} = getDetails(lines);
|
|
957
|
+
return {
|
|
958
|
+
code: '',
|
|
959
|
+
message: actualMessage,
|
|
960
|
+
stack: rest
|
|
961
|
+
};
|
|
977
962
|
};
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
963
|
+
class IpcError extends VError {
|
|
964
|
+
// @ts-ignore
|
|
965
|
+
constructor(betterMessage, stdout = '', stderr = '') {
|
|
966
|
+
if (stdout || stderr) {
|
|
967
|
+
// @ts-ignore
|
|
968
|
+
const {
|
|
969
|
+
code,
|
|
970
|
+
message,
|
|
971
|
+
stack
|
|
972
|
+
} = getHelpfulChildProcessError(stdout, stderr);
|
|
973
|
+
const cause = new Error(message);
|
|
974
|
+
// @ts-ignore
|
|
975
|
+
cause.code = code;
|
|
976
|
+
cause.stack = stack;
|
|
977
|
+
super(cause, betterMessage);
|
|
978
|
+
} else {
|
|
979
|
+
super(betterMessage);
|
|
980
|
+
}
|
|
981
|
+
// @ts-ignore
|
|
982
|
+
this.name = 'IpcError';
|
|
983
|
+
// @ts-ignore
|
|
984
|
+
this.stdout = stdout;
|
|
985
|
+
// @ts-ignore
|
|
986
|
+
this.stderr = stderr;
|
|
984
987
|
}
|
|
988
|
+
}
|
|
989
|
+
const readyMessage = 'ready';
|
|
990
|
+
const getData$2 = event => {
|
|
991
|
+
return event.data;
|
|
985
992
|
};
|
|
986
|
-
const
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
} catch (error) {
|
|
991
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
992
|
-
}
|
|
993
|
+
const listen$8 = ({
|
|
994
|
+
port
|
|
995
|
+
}) => {
|
|
996
|
+
return port;
|
|
993
997
|
};
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
const getStatus = async protocol => {
|
|
998
|
-
try {
|
|
999
|
-
const provider = getDebugProvider(protocol);
|
|
1000
|
-
return await provider.getStatus();
|
|
1001
|
-
} catch (error) {
|
|
1002
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1003
|
-
}
|
|
998
|
+
const signal$9 = port => {
|
|
999
|
+
port.postMessage(readyMessage);
|
|
1004
1000
|
};
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
return await provider.getCallStack();
|
|
1009
|
-
} catch (error) {
|
|
1010
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1001
|
+
class IpcChildWithMessagePort extends Ipc {
|
|
1002
|
+
getData(event) {
|
|
1003
|
+
return getData$2(event);
|
|
1011
1004
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
try {
|
|
1015
|
-
const provider = getDebugProvider(protocol);
|
|
1016
|
-
return await provider.getScopeChain();
|
|
1017
|
-
} catch (error) {
|
|
1018
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1005
|
+
send(message) {
|
|
1006
|
+
this._rawIpc.postMessage(message);
|
|
1019
1007
|
}
|
|
1020
|
-
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1023
|
-
const provider = getDebugProvider(protocol);
|
|
1024
|
-
return await provider.getScripts();
|
|
1025
|
-
} catch (error) {
|
|
1026
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1008
|
+
sendAndTransfer(message) {
|
|
1009
|
+
const transfer = getTransferrables(message);
|
|
1010
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1027
1011
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
try {
|
|
1031
|
-
const provider = getDebugProvider(protocol);
|
|
1032
|
-
return await provider.getStatus();
|
|
1033
|
-
} catch (error) {
|
|
1034
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1012
|
+
dispose() {
|
|
1013
|
+
// ignore
|
|
1035
1014
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
try {
|
|
1039
|
-
const provider = getDebugProvider(protocol);
|
|
1040
|
-
return await provider.stepInto();
|
|
1041
|
-
} catch (error) {
|
|
1042
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1015
|
+
onClose(callback) {
|
|
1016
|
+
// ignore
|
|
1043
1017
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
const provider = getDebugProvider(protocol);
|
|
1048
|
-
return await provider.stepOut();
|
|
1049
|
-
} catch (error) {
|
|
1050
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1018
|
+
onMessage(callback) {
|
|
1019
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1020
|
+
this._rawIpc.start();
|
|
1051
1021
|
}
|
|
1022
|
+
}
|
|
1023
|
+
const wrap$g = port => {
|
|
1024
|
+
return new IpcChildWithMessagePort(port);
|
|
1052
1025
|
};
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1059
|
-
}
|
|
1026
|
+
const IpcChildWithMessagePort$1 = {
|
|
1027
|
+
__proto__: null,
|
|
1028
|
+
listen: listen$8,
|
|
1029
|
+
signal: signal$9,
|
|
1030
|
+
wrap: wrap$g
|
|
1060
1031
|
};
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
} catch (error) {
|
|
1066
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1032
|
+
const listen$7 = () => {
|
|
1033
|
+
// @ts-ignore
|
|
1034
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
1035
|
+
throw new TypeError('module is not in web worker scope');
|
|
1067
1036
|
}
|
|
1037
|
+
return globalThis;
|
|
1068
1038
|
};
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1071
|
-
const provider = getDebugProvider(protocol);
|
|
1072
|
-
return await provider.getProperties(objectId);
|
|
1073
|
-
} catch (error) {
|
|
1074
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1075
|
-
}
|
|
1039
|
+
const signal$8 = global => {
|
|
1040
|
+
global.postMessage(readyMessage);
|
|
1076
1041
|
};
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
return await provider.evaluate(expression, callFrameId);
|
|
1081
|
-
} catch (error) {
|
|
1082
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1042
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
1043
|
+
getData(event) {
|
|
1044
|
+
return getData$2(event);
|
|
1083
1045
|
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
const provider = getDebugProvider(protocol);
|
|
1088
|
-
return await provider.setPauseOnExceptions(value);
|
|
1089
|
-
} catch (error) {
|
|
1090
|
-
throw new VError(error, 'Failed to execute setPauseOnExceptions');
|
|
1046
|
+
send(message) {
|
|
1047
|
+
// @ts-ignore
|
|
1048
|
+
this._rawIpc.postMessage(message);
|
|
1091
1049
|
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
registerDefinitionProvider} = create$l({
|
|
1097
|
-
name: 'Definition',
|
|
1098
|
-
resultShape: {
|
|
1099
|
-
allowUndefined: true,
|
|
1100
|
-
properties: {
|
|
1101
|
-
endOffset: {
|
|
1102
|
-
type: Number
|
|
1103
|
-
},
|
|
1104
|
-
startOffset: {
|
|
1105
|
-
type: Number
|
|
1106
|
-
},
|
|
1107
|
-
uri: {
|
|
1108
|
-
type: String$1
|
|
1109
|
-
}
|
|
1110
|
-
},
|
|
1111
|
-
type: Object$1
|
|
1050
|
+
sendAndTransfer(message) {
|
|
1051
|
+
const transfer = getTransferrables(message);
|
|
1052
|
+
// @ts-ignore
|
|
1053
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1112
1054
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
const {
|
|
1116
|
-
executeDiagnosticProvider,
|
|
1117
|
-
registerDiagnosticProvider
|
|
1118
|
-
} = create$l({
|
|
1119
|
-
name: 'Diagnostic',
|
|
1120
|
-
resultShape: {
|
|
1121
|
-
items: {
|
|
1122
|
-
type: Object$1
|
|
1123
|
-
},
|
|
1124
|
-
type: Array$1
|
|
1055
|
+
dispose() {
|
|
1056
|
+
// ignore
|
|
1125
1057
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
const rpc = get$b(RendererWorker);
|
|
1136
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1137
|
-
};
|
|
1138
|
-
|
|
1139
|
-
const showInformationMessage = message => {
|
|
1140
|
-
string(message);
|
|
1141
|
-
const result = invoke$1('ExtensionHostDialog.showInformationMessage', message);
|
|
1142
|
-
return result;
|
|
1058
|
+
onClose(callback) {
|
|
1059
|
+
// ignore
|
|
1060
|
+
}
|
|
1061
|
+
onMessage(callback) {
|
|
1062
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
const wrap$f = global => {
|
|
1066
|
+
return new IpcChildWithModuleWorker(global);
|
|
1143
1067
|
};
|
|
1144
|
-
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1068
|
+
const waitForFirstMessage = async port => {
|
|
1069
|
+
const {
|
|
1070
|
+
promise,
|
|
1071
|
+
resolve
|
|
1072
|
+
} = Promise.withResolvers();
|
|
1073
|
+
port.addEventListener('message', resolve, {
|
|
1074
|
+
once: true
|
|
1075
|
+
});
|
|
1076
|
+
const event = await promise;
|
|
1077
|
+
// @ts-ignore
|
|
1078
|
+
return event.data;
|
|
1149
1079
|
};
|
|
1150
|
-
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
throw new
|
|
1080
|
+
const listen$6 = async () => {
|
|
1081
|
+
const parentIpcRaw = listen$7();
|
|
1082
|
+
signal$8(parentIpcRaw);
|
|
1083
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
1084
|
+
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
1085
|
+
if (firstMessage.method !== 'initialize') {
|
|
1086
|
+
throw new IpcError('unexpected first message');
|
|
1157
1087
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1088
|
+
const type = firstMessage.params[0];
|
|
1089
|
+
if (type === 'message-port') {
|
|
1090
|
+
parentIpc.send({
|
|
1091
|
+
id: firstMessage.id,
|
|
1092
|
+
jsonrpc: '2.0',
|
|
1093
|
+
result: null
|
|
1094
|
+
});
|
|
1095
|
+
parentIpc.dispose();
|
|
1096
|
+
const port = firstMessage.params[1];
|
|
1097
|
+
return port;
|
|
1163
1098
|
}
|
|
1164
|
-
|
|
1099
|
+
return globalThis;
|
|
1165
1100
|
};
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
throw new Error('Failed to register file system provider: missing id');
|
|
1101
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
1102
|
+
getData(event) {
|
|
1103
|
+
return getData$2(event);
|
|
1170
1104
|
}
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
const readDirWithFileTypes$2 = async (protocol, path) => {
|
|
1174
|
-
try {
|
|
1175
|
-
const provider = get$a(protocol);
|
|
1176
|
-
return await provider.readDirWithFileTypes(path);
|
|
1177
|
-
} catch (error) {
|
|
1178
|
-
throw new VError(error, 'Failed to execute file system provider');
|
|
1105
|
+
send(message) {
|
|
1106
|
+
this._rawIpc.postMessage(message);
|
|
1179
1107
|
}
|
|
1180
|
-
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1108
|
+
sendAndTransfer(message) {
|
|
1109
|
+
const transfer = getTransferrables(message);
|
|
1110
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1111
|
+
}
|
|
1112
|
+
dispose() {
|
|
1113
|
+
if (this._rawIpc.close) {
|
|
1114
|
+
this._rawIpc.close();
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
onClose(callback) {
|
|
1118
|
+
// ignore
|
|
1119
|
+
}
|
|
1120
|
+
onMessage(callback) {
|
|
1121
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1122
|
+
this._rawIpc.start();
|
|
1187
1123
|
}
|
|
1124
|
+
}
|
|
1125
|
+
const wrap$e = port => {
|
|
1126
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
1188
1127
|
};
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1128
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
1129
|
+
__proto__: null,
|
|
1130
|
+
listen: listen$6,
|
|
1131
|
+
wrap: wrap$e
|
|
1132
|
+
};
|
|
1133
|
+
const Error$3 = 1;
|
|
1134
|
+
const Open = 2;
|
|
1135
|
+
const Close = 3;
|
|
1136
|
+
const addListener = (emitter, type, callback) => {
|
|
1137
|
+
if ('addEventListener' in emitter) {
|
|
1138
|
+
emitter.addEventListener(type, callback);
|
|
1139
|
+
} else {
|
|
1140
|
+
emitter.on(type, callback);
|
|
1195
1141
|
}
|
|
1196
1142
|
};
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
// when reading / writing large files
|
|
1204
|
-
const content = await invoke$1('FileSystem.readFile', path);
|
|
1205
|
-
return content;
|
|
1143
|
+
const removeListener = (emitter, type, callback) => {
|
|
1144
|
+
if ('removeEventListener' in emitter) {
|
|
1145
|
+
emitter.removeEventListener(type, callback);
|
|
1146
|
+
} else {
|
|
1147
|
+
emitter.off(type, callback);
|
|
1148
|
+
}
|
|
1206
1149
|
};
|
|
1207
|
-
const
|
|
1208
|
-
const
|
|
1209
|
-
|
|
1150
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
1151
|
+
const {
|
|
1152
|
+
promise,
|
|
1153
|
+
resolve
|
|
1154
|
+
} = Promise.withResolvers();
|
|
1155
|
+
const listenerMap = Object.create(null);
|
|
1156
|
+
const cleanup = value => {
|
|
1157
|
+
for (const event of Object.keys(eventMap)) {
|
|
1158
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
1159
|
+
}
|
|
1160
|
+
resolve(value);
|
|
1161
|
+
};
|
|
1162
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
1163
|
+
const listener = event => {
|
|
1164
|
+
cleanup({
|
|
1165
|
+
event,
|
|
1166
|
+
type
|
|
1167
|
+
});
|
|
1168
|
+
};
|
|
1169
|
+
addListener(eventEmitter, event, listener);
|
|
1170
|
+
listenerMap[event] = listener;
|
|
1171
|
+
}
|
|
1172
|
+
return promise;
|
|
1210
1173
|
};
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1174
|
+
const Message$1 = 3;
|
|
1175
|
+
const create$5$1 = async ({
|
|
1176
|
+
isMessagePortOpen,
|
|
1177
|
+
messagePort
|
|
1178
|
+
}) => {
|
|
1179
|
+
if (!isMessagePort(messagePort)) {
|
|
1180
|
+
throw new IpcError('port must be of type MessagePort');
|
|
1181
|
+
}
|
|
1182
|
+
if (isMessagePortOpen) {
|
|
1183
|
+
return messagePort;
|
|
1184
|
+
}
|
|
1185
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
1186
|
+
message: Message$1
|
|
1187
|
+
});
|
|
1188
|
+
messagePort.start();
|
|
1189
|
+
const {
|
|
1190
|
+
event,
|
|
1191
|
+
type
|
|
1192
|
+
} = await eventPromise;
|
|
1193
|
+
if (type !== Message$1) {
|
|
1194
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
1195
|
+
}
|
|
1196
|
+
if (event.data !== readyMessage) {
|
|
1197
|
+
throw new IpcError('unexpected first message');
|
|
1198
|
+
}
|
|
1199
|
+
return messagePort;
|
|
1213
1200
|
};
|
|
1214
|
-
const
|
|
1215
|
-
|
|
1201
|
+
const signal$1 = messagePort => {
|
|
1202
|
+
messagePort.start();
|
|
1216
1203
|
};
|
|
1217
|
-
|
|
1218
|
-
|
|
1204
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
1205
|
+
getData = getData$2;
|
|
1206
|
+
send(message) {
|
|
1207
|
+
this._rawIpc.postMessage(message);
|
|
1208
|
+
}
|
|
1209
|
+
sendAndTransfer(message) {
|
|
1210
|
+
const transfer = getTransferrables(message);
|
|
1211
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1212
|
+
}
|
|
1213
|
+
dispose() {
|
|
1214
|
+
this._rawIpc.close();
|
|
1215
|
+
}
|
|
1216
|
+
onMessage(callback) {
|
|
1217
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1218
|
+
}
|
|
1219
|
+
onClose(callback) {}
|
|
1220
|
+
}
|
|
1221
|
+
const wrap$5 = messagePort => {
|
|
1222
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
1219
1223
|
};
|
|
1220
|
-
const
|
|
1221
|
-
|
|
1224
|
+
const IpcParentWithMessagePort$1 = {
|
|
1225
|
+
__proto__: null,
|
|
1226
|
+
create: create$5$1,
|
|
1227
|
+
signal: signal$1,
|
|
1228
|
+
wrap: wrap$5
|
|
1222
1229
|
};
|
|
1223
|
-
const
|
|
1224
|
-
|
|
1225
|
-
// don't ask renderer worker
|
|
1226
|
-
// instead read file directly from shared process
|
|
1227
|
-
// this avoid parsing the potentially large message
|
|
1228
|
-
// and improve performance by not blocking the renderer worker
|
|
1229
|
-
// when reading / writing large files
|
|
1230
|
-
const content = await invoke$1('FileSystem.readDirWithFileTypes', path);
|
|
1231
|
-
return content;
|
|
1230
|
+
const stringifyCompact = value => {
|
|
1231
|
+
return JSON.stringify(value);
|
|
1232
1232
|
};
|
|
1233
|
-
const
|
|
1233
|
+
const parse$1 = content => {
|
|
1234
|
+
if (content === 'undefined') {
|
|
1235
|
+
return null;
|
|
1236
|
+
}
|
|
1234
1237
|
try {
|
|
1235
|
-
|
|
1236
|
-
return await provider.remove(path);
|
|
1238
|
+
return JSON.parse(content);
|
|
1237
1239
|
} catch (error) {
|
|
1238
|
-
throw new VError(error, '
|
|
1240
|
+
throw new VError(error, 'failed to parse json');
|
|
1239
1241
|
}
|
|
1240
1242
|
};
|
|
1241
|
-
const
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
}
|
|
1243
|
+
const waitForWebSocketToBeOpen = webSocket => {
|
|
1244
|
+
return getFirstEvent(webSocket, {
|
|
1245
|
+
close: Close,
|
|
1246
|
+
error: Error$3,
|
|
1247
|
+
open: Open
|
|
1248
|
+
});
|
|
1248
1249
|
};
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
throw new
|
|
1250
|
+
const create$k = async ({
|
|
1251
|
+
webSocket
|
|
1252
|
+
}) => {
|
|
1253
|
+
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
1254
|
+
if (firstWebSocketEvent.type === Error$3) {
|
|
1255
|
+
throw new IpcError(`WebSocket connection error`);
|
|
1255
1256
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
try {
|
|
1259
|
-
const provider = get$a(protocol);
|
|
1260
|
-
return provider.pathSeparator;
|
|
1261
|
-
} catch (error) {
|
|
1262
|
-
throw new VError(error, 'Failed to execute file system provider');
|
|
1257
|
+
if (firstWebSocketEvent.type === Close) {
|
|
1258
|
+
throw new IpcError('Websocket connection was immediately closed');
|
|
1263
1259
|
}
|
|
1260
|
+
return webSocket;
|
|
1264
1261
|
};
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
registerFormattingProvider} = create$l({
|
|
1269
|
-
executeKey: 'format',
|
|
1270
|
-
name: 'Formatting',
|
|
1271
|
-
resultShape: {
|
|
1272
|
-
allowUndefined: true,
|
|
1273
|
-
items: {
|
|
1274
|
-
properties: {
|
|
1275
|
-
endOffset: {
|
|
1276
|
-
type: Number
|
|
1277
|
-
},
|
|
1278
|
-
inserted: {
|
|
1279
|
-
type: String$1
|
|
1280
|
-
},
|
|
1281
|
-
startOffset: {
|
|
1282
|
-
type: Number
|
|
1283
|
-
}
|
|
1284
|
-
},
|
|
1285
|
-
type: Object$1
|
|
1286
|
-
},
|
|
1287
|
-
type: Array$1
|
|
1262
|
+
let IpcParentWithWebSocket$1 = class IpcParentWithWebSocket extends Ipc {
|
|
1263
|
+
getData(event) {
|
|
1264
|
+
return parse$1(event.data);
|
|
1288
1265
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
const getOffset = (textDocument, position) => {
|
|
1292
|
-
let offset = 0;
|
|
1293
|
-
let rowIndex = 0;
|
|
1294
|
-
while (rowIndex++ < position.rowIndex) {
|
|
1295
|
-
const newLineIndex = textDocument.text.indexOf('\n', offset);
|
|
1296
|
-
offset = newLineIndex + 1;
|
|
1266
|
+
send(message) {
|
|
1267
|
+
this._rawIpc.send(stringifyCompact(message));
|
|
1297
1268
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
};
|
|
1301
|
-
|
|
1302
|
-
const getPosition = (textDocument, offset) => {
|
|
1303
|
-
let index = 0;
|
|
1304
|
-
let rowIndex = 0;
|
|
1305
|
-
const {
|
|
1306
|
-
text
|
|
1307
|
-
} = textDocument;
|
|
1308
|
-
while (index < offset) {
|
|
1309
|
-
const newLineIndex = text.indexOf('\n', index);
|
|
1310
|
-
if (newLineIndex === -1) {
|
|
1311
|
-
break;
|
|
1312
|
-
}
|
|
1313
|
-
const newIndex = newLineIndex + 1;
|
|
1314
|
-
if (newIndex > offset) {
|
|
1315
|
-
break;
|
|
1316
|
-
}
|
|
1317
|
-
index = newIndex;
|
|
1318
|
-
rowIndex++;
|
|
1269
|
+
sendAndTransfer(message) {
|
|
1270
|
+
throw new Error('sendAndTransfer not supported');
|
|
1319
1271
|
}
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
columnIndex,
|
|
1323
|
-
rowIndex
|
|
1324
|
-
};
|
|
1325
|
-
};
|
|
1326
|
-
|
|
1327
|
-
const {
|
|
1328
|
-
executeHoverProvider,
|
|
1329
|
-
registerHoverProvider} = create$l({
|
|
1330
|
-
name: 'Hover',
|
|
1331
|
-
resultShape: {
|
|
1332
|
-
allowUndefined: true,
|
|
1333
|
-
properties: {},
|
|
1334
|
-
type: Object$1
|
|
1272
|
+
dispose() {
|
|
1273
|
+
this._rawIpc.close();
|
|
1335
1274
|
}
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
const {
|
|
1339
|
-
executeImplementationProvider,
|
|
1340
|
-
registerImplementationProvider} = create$l({
|
|
1341
|
-
name: 'Implementation',
|
|
1342
|
-
resultShape: {
|
|
1343
|
-
items: {
|
|
1344
|
-
type: Object$1
|
|
1345
|
-
},
|
|
1346
|
-
type: Array$1
|
|
1275
|
+
onClose(callback) {
|
|
1276
|
+
this._rawIpc.addEventListener('close', callback);
|
|
1347
1277
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
const
|
|
1278
|
+
onMessage(callback) {
|
|
1279
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1280
|
+
}
|
|
1281
|
+
};
|
|
1282
|
+
const wrap$1 = webSocket => {
|
|
1283
|
+
return new IpcParentWithWebSocket$1(webSocket);
|
|
1284
|
+
};
|
|
1285
|
+
const IpcParentWithWebSocket$1$1 = {
|
|
1286
|
+
__proto__: null,
|
|
1287
|
+
create: create$k,
|
|
1288
|
+
wrap: wrap$1
|
|
1289
|
+
};
|
|
1353
1290
|
|
|
1354
|
-
|
|
1355
|
-
|
|
1291
|
+
class CommandNotFoundError extends Error {
|
|
1292
|
+
constructor(command) {
|
|
1293
|
+
super(`Command not found ${command}`);
|
|
1294
|
+
this.name = 'CommandNotFoundError';
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
const commands = Object.create(null);
|
|
1298
|
+
const register$1 = commandMap => {
|
|
1299
|
+
Object.assign(commands, commandMap);
|
|
1356
1300
|
};
|
|
1357
|
-
const
|
|
1358
|
-
return
|
|
1301
|
+
const getCommand = key => {
|
|
1302
|
+
return commands[key];
|
|
1359
1303
|
};
|
|
1360
|
-
const
|
|
1361
|
-
|
|
1304
|
+
const execute = (command, ...args) => {
|
|
1305
|
+
const fn = getCommand(command);
|
|
1306
|
+
if (!fn) {
|
|
1307
|
+
throw new CommandNotFoundError(command);
|
|
1308
|
+
}
|
|
1309
|
+
return fn(...args);
|
|
1362
1310
|
};
|
|
1363
|
-
|
|
1364
|
-
|
|
1311
|
+
|
|
1312
|
+
const Two$1 = '2.0';
|
|
1313
|
+
const callbacks = Object.create(null);
|
|
1314
|
+
const get$b = id => {
|
|
1315
|
+
return callbacks[id];
|
|
1365
1316
|
};
|
|
1366
|
-
const
|
|
1367
|
-
|
|
1317
|
+
const remove$5 = id => {
|
|
1318
|
+
delete callbacks[id];
|
|
1368
1319
|
};
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1320
|
+
class JsonRpcError extends Error {
|
|
1321
|
+
constructor(message) {
|
|
1322
|
+
super(message);
|
|
1323
|
+
this.name = 'JsonRpcError';
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
const NewLine$1 = '\n';
|
|
1327
|
+
const DomException = 'DOMException';
|
|
1328
|
+
const ReferenceError$1 = 'ReferenceError';
|
|
1329
|
+
const SyntaxError$1 = 'SyntaxError';
|
|
1330
|
+
const TypeError$1 = 'TypeError';
|
|
1331
|
+
const getErrorConstructor = (message, type) => {
|
|
1332
|
+
if (type) {
|
|
1333
|
+
switch (type) {
|
|
1334
|
+
case DomException:
|
|
1335
|
+
return DOMException;
|
|
1336
|
+
case ReferenceError$1:
|
|
1337
|
+
return ReferenceError;
|
|
1338
|
+
case SyntaxError$1:
|
|
1339
|
+
return SyntaxError;
|
|
1340
|
+
case TypeError$1:
|
|
1341
|
+
return TypeError;
|
|
1342
|
+
default:
|
|
1343
|
+
return Error;
|
|
1374
1344
|
}
|
|
1375
1345
|
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
const walkValue = (value, transferrables, isTransferrable) => {
|
|
1379
|
-
if (!value) {
|
|
1380
|
-
return;
|
|
1346
|
+
if (message.startsWith('TypeError: ')) {
|
|
1347
|
+
return TypeError;
|
|
1381
1348
|
}
|
|
1382
|
-
if (
|
|
1383
|
-
|
|
1384
|
-
return;
|
|
1349
|
+
if (message.startsWith('SyntaxError: ')) {
|
|
1350
|
+
return SyntaxError;
|
|
1385
1351
|
}
|
|
1386
|
-
if (
|
|
1387
|
-
|
|
1388
|
-
walkValue(item, transferrables, isTransferrable);
|
|
1389
|
-
}
|
|
1390
|
-
return;
|
|
1352
|
+
if (message.startsWith('ReferenceError: ')) {
|
|
1353
|
+
return ReferenceError;
|
|
1391
1354
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1355
|
+
return Error;
|
|
1356
|
+
};
|
|
1357
|
+
const constructError = (message, type, name) => {
|
|
1358
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
1359
|
+
if (ErrorConstructor === DOMException && name) {
|
|
1360
|
+
return new ErrorConstructor(message, name);
|
|
1361
|
+
}
|
|
1362
|
+
if (ErrorConstructor === Error) {
|
|
1363
|
+
const error = new Error(message);
|
|
1364
|
+
if (name && name !== 'VError') {
|
|
1365
|
+
error.name = name;
|
|
1395
1366
|
}
|
|
1396
|
-
return;
|
|
1367
|
+
return error;
|
|
1397
1368
|
}
|
|
1369
|
+
return new ErrorConstructor(message);
|
|
1398
1370
|
};
|
|
1399
|
-
const
|
|
1400
|
-
|
|
1401
|
-
walkValue(value, transferrables, isTransferrable);
|
|
1402
|
-
return transferrables;
|
|
1371
|
+
const joinLines = lines => {
|
|
1372
|
+
return lines.join(NewLine$1);
|
|
1403
1373
|
};
|
|
1404
|
-
const
|
|
1405
|
-
|
|
1406
|
-
const data = that.getData(...args);
|
|
1407
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
1408
|
-
data
|
|
1409
|
-
}));
|
|
1410
|
-
};
|
|
1411
|
-
that.onMessage(handleMessage);
|
|
1412
|
-
const handleClose = event => {
|
|
1413
|
-
that.dispatchEvent(new Event('close'));
|
|
1414
|
-
};
|
|
1415
|
-
that.onClose(handleClose);
|
|
1374
|
+
const splitLines$1 = lines => {
|
|
1375
|
+
return lines.split(NewLine$1);
|
|
1416
1376
|
};
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
attachEvents(this);
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
1425
|
-
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
1426
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
1427
|
-
const NewLine$2 = '\n';
|
|
1428
|
-
const joinLines$1 = lines => {
|
|
1429
|
-
return lines.join(NewLine$2);
|
|
1377
|
+
const getCurrentStack = () => {
|
|
1378
|
+
const stackLinesToSkip = 3;
|
|
1379
|
+
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(stackLinesToSkip));
|
|
1380
|
+
return currentStack;
|
|
1430
1381
|
};
|
|
1431
|
-
const
|
|
1432
|
-
|
|
1433
|
-
const isNormalStackLine = line => {
|
|
1434
|
-
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
1382
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
1383
|
+
return string.indexOf(NewLine$1, startIndex);
|
|
1435
1384
|
};
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1438
|
-
if (
|
|
1439
|
-
|
|
1440
|
-
actualMessage: joinLines$1(lines),
|
|
1441
|
-
rest: []
|
|
1442
|
-
};
|
|
1385
|
+
const getParentStack = error => {
|
|
1386
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
1387
|
+
if (parentStack.startsWith(' at')) {
|
|
1388
|
+
parentStack = error.message + NewLine$1 + parentStack;
|
|
1443
1389
|
}
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1390
|
+
return parentStack;
|
|
1391
|
+
};
|
|
1392
|
+
const MethodNotFound = -32601;
|
|
1393
|
+
const Custom = -32001;
|
|
1394
|
+
const restoreJsonRpcError = error => {
|
|
1395
|
+
const currentStack = getCurrentStack();
|
|
1396
|
+
if (error && error instanceof Error) {
|
|
1397
|
+
if (typeof error.stack === 'string') {
|
|
1398
|
+
error.stack = error.stack + NewLine$1 + currentStack;
|
|
1448
1399
|
}
|
|
1400
|
+
return error;
|
|
1449
1401
|
}
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1402
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
1403
|
+
const restoredError = new JsonRpcError(error.message);
|
|
1404
|
+
const parentStack = getParentStack(error);
|
|
1405
|
+
restoredError.stack = parentStack + NewLine$1 + currentStack;
|
|
1406
|
+
return restoredError;
|
|
1407
|
+
}
|
|
1408
|
+
if (error && error.message) {
|
|
1409
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
1410
|
+
if (error.data) {
|
|
1411
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
1412
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine$1 + error.data.stack + NewLine$1 + currentStack;
|
|
1413
|
+
} else if (error.data.stack) {
|
|
1414
|
+
restoredError.stack = error.data.stack;
|
|
1415
|
+
}
|
|
1416
|
+
if (error.data.codeFrame) {
|
|
1417
|
+
// @ts-ignore
|
|
1418
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
1419
|
+
}
|
|
1420
|
+
if (error.data.code) {
|
|
1421
|
+
// @ts-ignore
|
|
1422
|
+
restoredError.code = error.data.code;
|
|
1423
|
+
}
|
|
1424
|
+
if (error.data.type) {
|
|
1425
|
+
// @ts-ignore
|
|
1426
|
+
restoredError.name = error.data.type;
|
|
1427
|
+
}
|
|
1428
|
+
} else {
|
|
1429
|
+
if (error.stack) {
|
|
1430
|
+
const lowerStack = restoredError.stack || '';
|
|
1431
|
+
// @ts-ignore
|
|
1432
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
1433
|
+
const parentStack = getParentStack(error);
|
|
1434
|
+
// @ts-ignore
|
|
1435
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
1436
|
+
}
|
|
1437
|
+
if (error.codeFrame) {
|
|
1438
|
+
// @ts-ignore
|
|
1439
|
+
restoredError.codeFrame = error.codeFrame;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
return restoredError;
|
|
1443
|
+
}
|
|
1444
|
+
if (typeof error === 'string') {
|
|
1445
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
1446
|
+
}
|
|
1447
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
1457
1448
|
};
|
|
1458
|
-
const
|
|
1459
|
-
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1449
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
1450
|
+
if ('error' in responseMessage) {
|
|
1451
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
1452
|
+
throw restoredError;
|
|
1453
|
+
}
|
|
1454
|
+
if ('result' in responseMessage) {
|
|
1455
|
+
return responseMessage.result;
|
|
1456
|
+
}
|
|
1457
|
+
throw new JsonRpcError('unexpected response message');
|
|
1462
1458
|
};
|
|
1463
|
-
const
|
|
1464
|
-
|
|
1459
|
+
const warn$1 = (...args) => {
|
|
1460
|
+
console.warn(...args);
|
|
1465
1461
|
};
|
|
1466
|
-
const
|
|
1467
|
-
const
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1462
|
+
const resolve = (id, response) => {
|
|
1463
|
+
const fn = get$b(id);
|
|
1464
|
+
if (!fn) {
|
|
1465
|
+
console.log(response);
|
|
1466
|
+
warn$1(`callback ${id} may already be disposed`);
|
|
1467
|
+
return;
|
|
1468
|
+
}
|
|
1469
|
+
fn(response);
|
|
1470
|
+
remove$5(id);
|
|
1473
1471
|
};
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1472
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1473
|
+
const getErrorType = prettyError => {
|
|
1474
|
+
if (prettyError && prettyError.type) {
|
|
1475
|
+
return prettyError.type;
|
|
1476
|
+
}
|
|
1477
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
1478
|
+
return prettyError.constructor.name;
|
|
1479
|
+
}
|
|
1480
|
+
return undefined;
|
|
1476
1481
|
};
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1479
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1480
|
-
const message = lines[messageIndex];
|
|
1481
|
-
return {
|
|
1482
|
-
code: ERR_MODULE_NOT_FOUND,
|
|
1483
|
-
message
|
|
1484
|
-
};
|
|
1482
|
+
const isAlreadyStack = line => {
|
|
1483
|
+
return line.trim().startsWith('at ');
|
|
1485
1484
|
};
|
|
1486
|
-
const
|
|
1487
|
-
|
|
1488
|
-
|
|
1485
|
+
const getStack = prettyError => {
|
|
1486
|
+
const stackString = prettyError.stack || '';
|
|
1487
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
1488
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
1489
|
+
return stackString.slice(newLineIndex + 1);
|
|
1489
1490
|
}
|
|
1490
|
-
return
|
|
1491
|
+
return stackString;
|
|
1491
1492
|
};
|
|
1492
|
-
const
|
|
1493
|
-
if (
|
|
1494
|
-
return
|
|
1493
|
+
const getErrorProperty = (error, prettyError) => {
|
|
1494
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
1495
|
+
return {
|
|
1496
|
+
code: MethodNotFound,
|
|
1497
|
+
data: error.stack,
|
|
1498
|
+
message: error.message
|
|
1499
|
+
};
|
|
1495
1500
|
}
|
|
1496
|
-
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
1497
|
-
};
|
|
1498
|
-
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
1499
|
-
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
1500
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
1501
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
1502
|
-
};
|
|
1503
|
-
const getNativeModuleErrorMessage = stderr => {
|
|
1504
|
-
const message = getMessageCodeBlock(stderr);
|
|
1505
1501
|
return {
|
|
1506
|
-
code:
|
|
1507
|
-
|
|
1502
|
+
code: Custom,
|
|
1503
|
+
data: {
|
|
1504
|
+
code: prettyError.code,
|
|
1505
|
+
codeFrame: prettyError.codeFrame,
|
|
1506
|
+
name: prettyError.name,
|
|
1507
|
+
stack: getStack(prettyError),
|
|
1508
|
+
type: getErrorType(prettyError)
|
|
1509
|
+
},
|
|
1510
|
+
message: prettyError.message
|
|
1508
1511
|
};
|
|
1509
1512
|
};
|
|
1510
|
-
const
|
|
1513
|
+
const create$1$1 = (id, error) => {
|
|
1511
1514
|
return {
|
|
1512
|
-
|
|
1513
|
-
|
|
1515
|
+
error,
|
|
1516
|
+
id,
|
|
1517
|
+
jsonrpc: Two$1
|
|
1514
1518
|
};
|
|
1515
1519
|
};
|
|
1516
|
-
const
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
if (isModuleNotFoundError(stderr)) {
|
|
1524
|
-
return getModuleNotFoundError(stderr);
|
|
1525
|
-
}
|
|
1526
|
-
const lines = splitLines$2(stderr);
|
|
1527
|
-
const {
|
|
1528
|
-
actualMessage,
|
|
1529
|
-
rest
|
|
1530
|
-
} = getDetails(lines);
|
|
1520
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
1521
|
+
const prettyError = preparePrettyError(error);
|
|
1522
|
+
logError(error, prettyError);
|
|
1523
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
1524
|
+
return create$1$1(id, errorProperty);
|
|
1525
|
+
};
|
|
1526
|
+
const create$j = (message, result) => {
|
|
1531
1527
|
return {
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1528
|
+
id: message.id,
|
|
1529
|
+
jsonrpc: Two$1,
|
|
1530
|
+
result: result ?? null
|
|
1535
1531
|
};
|
|
1536
1532
|
};
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
if (stdout || stderr) {
|
|
1541
|
-
// @ts-ignore
|
|
1542
|
-
const {
|
|
1543
|
-
code,
|
|
1544
|
-
message,
|
|
1545
|
-
stack
|
|
1546
|
-
} = getHelpfulChildProcessError(stdout, stderr);
|
|
1547
|
-
const cause = new Error(message);
|
|
1548
|
-
// @ts-ignore
|
|
1549
|
-
cause.code = code;
|
|
1550
|
-
cause.stack = stack;
|
|
1551
|
-
super(cause, betterMessage);
|
|
1552
|
-
} else {
|
|
1553
|
-
super(betterMessage);
|
|
1554
|
-
}
|
|
1555
|
-
// @ts-ignore
|
|
1556
|
-
this.name = 'IpcError';
|
|
1557
|
-
// @ts-ignore
|
|
1558
|
-
this.stdout = stdout;
|
|
1559
|
-
// @ts-ignore
|
|
1560
|
-
this.stderr = stderr;
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
const readyMessage = 'ready';
|
|
1564
|
-
const getData$2 = event => {
|
|
1565
|
-
return event.data;
|
|
1533
|
+
const getSuccessResponse = (message, result) => {
|
|
1534
|
+
const resultProperty = result ?? null;
|
|
1535
|
+
return create$j(message, resultProperty);
|
|
1566
1536
|
};
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1537
|
+
const getErrorResponseSimple = (id, error) => {
|
|
1538
|
+
return {
|
|
1539
|
+
error: {
|
|
1540
|
+
code: Custom,
|
|
1541
|
+
data: error,
|
|
1542
|
+
// @ts-ignore
|
|
1543
|
+
message: error.message
|
|
1544
|
+
},
|
|
1545
|
+
id,
|
|
1546
|
+
jsonrpc: Two$1
|
|
1547
|
+
};
|
|
1574
1548
|
};
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1585
|
-
}
|
|
1586
|
-
dispose() {
|
|
1587
|
-
// ignore
|
|
1588
|
-
}
|
|
1589
|
-
onClose(callback) {
|
|
1590
|
-
// ignore
|
|
1591
|
-
}
|
|
1592
|
-
onMessage(callback) {
|
|
1593
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1594
|
-
this._rawIpc.start();
|
|
1549
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
1550
|
+
try {
|
|
1551
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
1552
|
+
return getSuccessResponse(message, result);
|
|
1553
|
+
} catch (error) {
|
|
1554
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
1555
|
+
return getErrorResponseSimple(message.id, error);
|
|
1556
|
+
}
|
|
1557
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1595
1558
|
}
|
|
1596
|
-
}
|
|
1597
|
-
const wrap$g = port => {
|
|
1598
|
-
return new IpcChildWithMessagePort(port);
|
|
1599
1559
|
};
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1602
|
-
listen: listen$8,
|
|
1603
|
-
signal: signal$9,
|
|
1604
|
-
wrap: wrap$g
|
|
1560
|
+
const defaultPreparePrettyError = error => {
|
|
1561
|
+
return error;
|
|
1605
1562
|
};
|
|
1606
|
-
const
|
|
1607
|
-
//
|
|
1608
|
-
if (typeof WorkerGlobalScope === 'undefined') {
|
|
1609
|
-
throw new TypeError('module is not in web worker scope');
|
|
1610
|
-
}
|
|
1611
|
-
return globalThis;
|
|
1563
|
+
const defaultLogError = () => {
|
|
1564
|
+
// ignore
|
|
1612
1565
|
};
|
|
1613
|
-
const
|
|
1614
|
-
|
|
1566
|
+
const defaultRequiresSocket = () => {
|
|
1567
|
+
return false;
|
|
1615
1568
|
};
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
}
|
|
1632
|
-
onClose(callback) {
|
|
1633
|
-
// ignore
|
|
1634
|
-
}
|
|
1635
|
-
onMessage(callback) {
|
|
1636
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1569
|
+
const defaultResolve = resolve;
|
|
1570
|
+
|
|
1571
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
1572
|
+
const normalizeParams = args => {
|
|
1573
|
+
if (args.length === 1) {
|
|
1574
|
+
const options = args[0];
|
|
1575
|
+
return {
|
|
1576
|
+
execute: options.execute,
|
|
1577
|
+
ipc: options.ipc,
|
|
1578
|
+
logError: options.logError || defaultLogError,
|
|
1579
|
+
message: options.message,
|
|
1580
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
1581
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
1582
|
+
resolve: options.resolve || defaultResolve
|
|
1583
|
+
};
|
|
1637
1584
|
}
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1585
|
+
return {
|
|
1586
|
+
execute: args[2],
|
|
1587
|
+
ipc: args[0],
|
|
1588
|
+
logError: args[5],
|
|
1589
|
+
message: args[1],
|
|
1590
|
+
preparePrettyError: args[4],
|
|
1591
|
+
requiresSocket: args[6],
|
|
1592
|
+
resolve: args[3]
|
|
1593
|
+
};
|
|
1641
1594
|
};
|
|
1642
|
-
const
|
|
1595
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
1596
|
+
const options = normalizeParams(args);
|
|
1643
1597
|
const {
|
|
1644
|
-
|
|
1598
|
+
execute,
|
|
1599
|
+
ipc,
|
|
1600
|
+
logError,
|
|
1601
|
+
message,
|
|
1602
|
+
preparePrettyError,
|
|
1603
|
+
requiresSocket,
|
|
1645
1604
|
resolve
|
|
1646
|
-
} =
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
const parentIpc = wrap$f(parentIpcRaw);
|
|
1658
|
-
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
1659
|
-
if (firstMessage.method !== 'initialize') {
|
|
1660
|
-
throw new IpcError('unexpected first message');
|
|
1661
|
-
}
|
|
1662
|
-
const type = firstMessage.params[0];
|
|
1663
|
-
if (type === 'message-port') {
|
|
1664
|
-
parentIpc.send({
|
|
1665
|
-
id: firstMessage.id,
|
|
1666
|
-
jsonrpc: '2.0',
|
|
1667
|
-
result: null
|
|
1668
|
-
});
|
|
1669
|
-
parentIpc.dispose();
|
|
1670
|
-
const port = firstMessage.params[1];
|
|
1671
|
-
return port;
|
|
1672
|
-
}
|
|
1673
|
-
return globalThis;
|
|
1674
|
-
};
|
|
1675
|
-
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
1676
|
-
getData(event) {
|
|
1677
|
-
return getData$2(event);
|
|
1678
|
-
}
|
|
1679
|
-
send(message) {
|
|
1680
|
-
this._rawIpc.postMessage(message);
|
|
1681
|
-
}
|
|
1682
|
-
sendAndTransfer(message) {
|
|
1683
|
-
const transfer = getTransferrables(message);
|
|
1684
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1685
|
-
}
|
|
1686
|
-
dispose() {
|
|
1687
|
-
if (this._rawIpc.close) {
|
|
1688
|
-
this._rawIpc.close();
|
|
1605
|
+
} = options;
|
|
1606
|
+
if ('id' in message) {
|
|
1607
|
+
if ('method' in message) {
|
|
1608
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1609
|
+
try {
|
|
1610
|
+
ipc.send(response);
|
|
1611
|
+
} catch (error) {
|
|
1612
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1613
|
+
ipc.send(errorResponse);
|
|
1614
|
+
}
|
|
1615
|
+
return;
|
|
1689
1616
|
}
|
|
1617
|
+
resolve(message.id, message);
|
|
1618
|
+
return;
|
|
1690
1619
|
}
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
onMessage(callback) {
|
|
1695
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1696
|
-
this._rawIpc.start();
|
|
1620
|
+
if ('method' in message) {
|
|
1621
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1622
|
+
return;
|
|
1697
1623
|
}
|
|
1698
|
-
|
|
1699
|
-
const wrap$e = port => {
|
|
1700
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
1624
|
+
throw new JsonRpcError('unexpected message');
|
|
1701
1625
|
};
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1626
|
+
|
|
1627
|
+
const Two = '2.0';
|
|
1628
|
+
|
|
1629
|
+
const create$i = (method, params) => {
|
|
1630
|
+
return {
|
|
1631
|
+
jsonrpc: Two,
|
|
1632
|
+
method,
|
|
1633
|
+
params
|
|
1634
|
+
};
|
|
1706
1635
|
};
|
|
1707
|
-
|
|
1708
|
-
const
|
|
1709
|
-
const
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1636
|
+
|
|
1637
|
+
const create$h = (id, method, params) => {
|
|
1638
|
+
const message = {
|
|
1639
|
+
id,
|
|
1640
|
+
jsonrpc: Two,
|
|
1641
|
+
method,
|
|
1642
|
+
params
|
|
1643
|
+
};
|
|
1644
|
+
return message;
|
|
1716
1645
|
};
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
emitter.off(type, callback);
|
|
1722
|
-
}
|
|
1646
|
+
|
|
1647
|
+
let id$2 = 0;
|
|
1648
|
+
const create$g = () => {
|
|
1649
|
+
return ++id$2;
|
|
1723
1650
|
};
|
|
1724
|
-
|
|
1651
|
+
|
|
1652
|
+
const registerPromise = map => {
|
|
1653
|
+
const id = create$g();
|
|
1725
1654
|
const {
|
|
1726
1655
|
promise,
|
|
1727
1656
|
resolve
|
|
1728
1657
|
} = Promise.withResolvers();
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
}
|
|
1734
|
-
resolve(value);
|
|
1658
|
+
map[id] = resolve;
|
|
1659
|
+
return {
|
|
1660
|
+
id,
|
|
1661
|
+
promise
|
|
1735
1662
|
};
|
|
1736
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
1737
|
-
const listener = event => {
|
|
1738
|
-
cleanup({
|
|
1739
|
-
event,
|
|
1740
|
-
type
|
|
1741
|
-
});
|
|
1742
|
-
};
|
|
1743
|
-
addListener(eventEmitter, event, listener);
|
|
1744
|
-
listenerMap[event] = listener;
|
|
1745
|
-
}
|
|
1746
|
-
return promise;
|
|
1747
1663
|
};
|
|
1748
|
-
|
|
1749
|
-
const
|
|
1750
|
-
isMessagePortOpen,
|
|
1751
|
-
messagePort
|
|
1752
|
-
}) => {
|
|
1753
|
-
if (!isMessagePort(messagePort)) {
|
|
1754
|
-
throw new IpcError('port must be of type MessagePort');
|
|
1755
|
-
}
|
|
1756
|
-
if (isMessagePortOpen) {
|
|
1757
|
-
return messagePort;
|
|
1758
|
-
}
|
|
1759
|
-
const eventPromise = getFirstEvent(messagePort, {
|
|
1760
|
-
message: Message$1
|
|
1761
|
-
});
|
|
1762
|
-
messagePort.start();
|
|
1664
|
+
|
|
1665
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
1763
1666
|
const {
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
} =
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1667
|
+
id,
|
|
1668
|
+
promise
|
|
1669
|
+
} = registerPromise(callbacks);
|
|
1670
|
+
const message = create$h(id, method, params);
|
|
1671
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1672
|
+
ipc.sendAndTransfer(message);
|
|
1673
|
+
} else {
|
|
1674
|
+
ipc.send(message);
|
|
1772
1675
|
}
|
|
1773
|
-
|
|
1676
|
+
const responseMessage = await promise;
|
|
1677
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
1774
1678
|
};
|
|
1775
|
-
const
|
|
1776
|
-
|
|
1679
|
+
const createRpc$1 = ipc => {
|
|
1680
|
+
const callbacks = Object.create(null);
|
|
1681
|
+
ipc._resolve = (id, response) => {
|
|
1682
|
+
const fn = callbacks[id];
|
|
1683
|
+
if (!fn) {
|
|
1684
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
fn(response);
|
|
1688
|
+
delete callbacks[id];
|
|
1689
|
+
};
|
|
1690
|
+
const rpc = {
|
|
1691
|
+
async dispose() {
|
|
1692
|
+
await ipc?.dispose();
|
|
1693
|
+
},
|
|
1694
|
+
invoke(method, ...params) {
|
|
1695
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
1696
|
+
},
|
|
1697
|
+
invokeAndTransfer(method, ...params) {
|
|
1698
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
1699
|
+
},
|
|
1700
|
+
// @ts-ignore
|
|
1701
|
+
ipc,
|
|
1702
|
+
/**
|
|
1703
|
+
* @deprecated
|
|
1704
|
+
*/
|
|
1705
|
+
send(method, ...params) {
|
|
1706
|
+
const message = create$i(method, params);
|
|
1707
|
+
ipc.send(message);
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
return rpc;
|
|
1777
1711
|
};
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
this._rawIpc.postMessage(message);
|
|
1782
|
-
}
|
|
1783
|
-
sendAndTransfer(message) {
|
|
1784
|
-
const transfer = getTransferrables(message);
|
|
1785
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1786
|
-
}
|
|
1787
|
-
dispose() {
|
|
1788
|
-
this._rawIpc.close();
|
|
1789
|
-
}
|
|
1790
|
-
onMessage(callback) {
|
|
1791
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1792
|
-
}
|
|
1793
|
-
onClose(callback) {}
|
|
1794
|
-
}
|
|
1795
|
-
const wrap$5 = messagePort => {
|
|
1796
|
-
return new IpcParentWithMessagePort(messagePort);
|
|
1712
|
+
|
|
1713
|
+
const requiresSocket = () => {
|
|
1714
|
+
return false;
|
|
1797
1715
|
};
|
|
1798
|
-
const
|
|
1799
|
-
|
|
1800
|
-
create: create$5$1,
|
|
1801
|
-
signal: signal$1,
|
|
1802
|
-
wrap: wrap$5
|
|
1716
|
+
const preparePrettyError = error => {
|
|
1717
|
+
return error;
|
|
1803
1718
|
};
|
|
1804
|
-
const
|
|
1805
|
-
|
|
1719
|
+
const logError = () => {
|
|
1720
|
+
// handled by renderer worker
|
|
1806
1721
|
};
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1809
|
-
|
|
1722
|
+
const handleMessage = event => {
|
|
1723
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1724
|
+
const actualExecute = event?.target?.execute || execute;
|
|
1725
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
const handleIpc = ipc => {
|
|
1729
|
+
if ('addEventListener' in ipc) {
|
|
1730
|
+
ipc.addEventListener('message', handleMessage);
|
|
1731
|
+
} else if ('on' in ipc) {
|
|
1732
|
+
// deprecated
|
|
1733
|
+
ipc.on('message', handleMessage);
|
|
1810
1734
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1735
|
+
};
|
|
1736
|
+
|
|
1737
|
+
const listen$1 = async (module, options) => {
|
|
1738
|
+
const rawIpc = await module.listen(options);
|
|
1739
|
+
if (module.signal) {
|
|
1740
|
+
module.signal(rawIpc);
|
|
1815
1741
|
}
|
|
1742
|
+
const ipc = module.wrap(rawIpc);
|
|
1743
|
+
return ipc;
|
|
1816
1744
|
};
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1745
|
+
|
|
1746
|
+
const create$f = async ({
|
|
1747
|
+
commandMap,
|
|
1748
|
+
isMessagePortOpen = true,
|
|
1749
|
+
messagePort
|
|
1750
|
+
}) => {
|
|
1751
|
+
// TODO create a commandMap per rpc instance
|
|
1752
|
+
register$1(commandMap);
|
|
1753
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1754
|
+
isMessagePortOpen,
|
|
1755
|
+
messagePort
|
|
1822
1756
|
});
|
|
1757
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1758
|
+
handleIpc(ipc);
|
|
1759
|
+
const rpc = createRpc$1(ipc);
|
|
1760
|
+
messagePort.start();
|
|
1761
|
+
return rpc;
|
|
1823
1762
|
};
|
|
1824
|
-
|
|
1825
|
-
|
|
1763
|
+
|
|
1764
|
+
const create$e = async ({
|
|
1765
|
+
commandMap,
|
|
1766
|
+
isMessagePortOpen,
|
|
1767
|
+
send
|
|
1826
1768
|
}) => {
|
|
1827
|
-
const
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1769
|
+
const {
|
|
1770
|
+
port1,
|
|
1771
|
+
port2
|
|
1772
|
+
} = new MessageChannel();
|
|
1773
|
+
await send(port1);
|
|
1774
|
+
return create$f({
|
|
1775
|
+
commandMap,
|
|
1776
|
+
isMessagePortOpen,
|
|
1777
|
+
messagePort: port2
|
|
1778
|
+
});
|
|
1835
1779
|
};
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1780
|
+
|
|
1781
|
+
const createSharedLazyRpc = factory => {
|
|
1782
|
+
let rpcPromise;
|
|
1783
|
+
const getOrCreate = () => {
|
|
1784
|
+
if (!rpcPromise) {
|
|
1785
|
+
rpcPromise = factory();
|
|
1786
|
+
}
|
|
1787
|
+
return rpcPromise;
|
|
1788
|
+
};
|
|
1789
|
+
return {
|
|
1790
|
+
async dispose() {
|
|
1791
|
+
const rpc = await getOrCreate();
|
|
1792
|
+
await rpc.dispose();
|
|
1793
|
+
},
|
|
1794
|
+
async invoke(method, ...params) {
|
|
1795
|
+
const rpc = await getOrCreate();
|
|
1796
|
+
return rpc.invoke(method, ...params);
|
|
1797
|
+
},
|
|
1798
|
+
async invokeAndTransfer(method, ...params) {
|
|
1799
|
+
const rpc = await getOrCreate();
|
|
1800
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1801
|
+
},
|
|
1802
|
+
async send(method, ...params) {
|
|
1803
|
+
const rpc = await getOrCreate();
|
|
1804
|
+
rpc.send(method, ...params);
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1855
1807
|
};
|
|
1856
|
-
|
|
1857
|
-
|
|
1808
|
+
|
|
1809
|
+
const create$d = async ({
|
|
1810
|
+
commandMap,
|
|
1811
|
+
isMessagePortOpen,
|
|
1812
|
+
send
|
|
1813
|
+
}) => {
|
|
1814
|
+
return createSharedLazyRpc(() => {
|
|
1815
|
+
return create$e({
|
|
1816
|
+
commandMap,
|
|
1817
|
+
isMessagePortOpen,
|
|
1818
|
+
send
|
|
1819
|
+
});
|
|
1820
|
+
});
|
|
1858
1821
|
};
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1822
|
+
|
|
1823
|
+
const create$c = async ({
|
|
1824
|
+
commandMap,
|
|
1825
|
+
webSocket
|
|
1826
|
+
}) => {
|
|
1827
|
+
// TODO create a commandMap per rpc instance
|
|
1828
|
+
register$1(commandMap);
|
|
1829
|
+
const rawIpc = await IpcParentWithWebSocket$1$1.create({
|
|
1830
|
+
webSocket
|
|
1831
|
+
});
|
|
1832
|
+
const ipc = IpcParentWithWebSocket$1$1.wrap(rawIpc);
|
|
1833
|
+
handleIpc(ipc);
|
|
1834
|
+
const rpc = createRpc$1(ipc);
|
|
1835
|
+
return rpc;
|
|
1863
1836
|
};
|
|
1864
1837
|
|
|
1865
|
-
const
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1838
|
+
const create$b = async ({
|
|
1839
|
+
commandMap,
|
|
1840
|
+
messagePort
|
|
1841
|
+
}) => {
|
|
1842
|
+
// TODO create a commandMap per rpc instance
|
|
1843
|
+
register$1(commandMap);
|
|
1844
|
+
const ipc = await listen$1(IpcChildWithMessagePort$1, {
|
|
1845
|
+
port: messagePort
|
|
1846
|
+
});
|
|
1847
|
+
handleIpc(ipc);
|
|
1848
|
+
const rpc = createRpc$1(ipc);
|
|
1849
|
+
return rpc;
|
|
1869
1850
|
};
|
|
1870
|
-
|
|
1871
|
-
|
|
1851
|
+
|
|
1852
|
+
const create$a = async ({
|
|
1853
|
+
commandMap,
|
|
1854
|
+
isMessagePortOpen,
|
|
1855
|
+
messagePort
|
|
1856
|
+
}) => {
|
|
1857
|
+
// TODO create a commandMap per rpc instance
|
|
1858
|
+
register$1(commandMap);
|
|
1859
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1860
|
+
isMessagePortOpen,
|
|
1861
|
+
messagePort
|
|
1862
|
+
});
|
|
1863
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1864
|
+
handleIpc(ipc);
|
|
1865
|
+
const rpc = createRpc$1(ipc);
|
|
1866
|
+
return rpc;
|
|
1872
1867
|
};
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
const SyntaxError$1 = 'SyntaxError';
|
|
1883
|
-
const TypeError$1 = 'TypeError';
|
|
1884
|
-
const getErrorConstructor = (message, type) => {
|
|
1885
|
-
if (type) {
|
|
1886
|
-
switch (type) {
|
|
1887
|
-
case DomException:
|
|
1888
|
-
return DOMException;
|
|
1889
|
-
case ReferenceError$1:
|
|
1890
|
-
return ReferenceError;
|
|
1891
|
-
case SyntaxError$1:
|
|
1892
|
-
return SyntaxError;
|
|
1893
|
-
case TypeError$1:
|
|
1894
|
-
return TypeError;
|
|
1895
|
-
default:
|
|
1896
|
-
return Error;
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
if (message.startsWith('TypeError: ')) {
|
|
1900
|
-
return TypeError;
|
|
1901
|
-
}
|
|
1902
|
-
if (message.startsWith('SyntaxError: ')) {
|
|
1903
|
-
return SyntaxError;
|
|
1904
|
-
}
|
|
1905
|
-
if (message.startsWith('ReferenceError: ')) {
|
|
1906
|
-
return ReferenceError;
|
|
1907
|
-
}
|
|
1908
|
-
return Error;
|
|
1868
|
+
|
|
1869
|
+
const create$9 = async ({
|
|
1870
|
+
commandMap,
|
|
1871
|
+
messagePort
|
|
1872
|
+
}) => {
|
|
1873
|
+
return create$f({
|
|
1874
|
+
commandMap,
|
|
1875
|
+
messagePort
|
|
1876
|
+
});
|
|
1909
1877
|
};
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1878
|
+
|
|
1879
|
+
const create$8 = async ({
|
|
1880
|
+
commandMap
|
|
1881
|
+
}) => {
|
|
1882
|
+
// TODO create a commandMap per rpc instance
|
|
1883
|
+
register$1(commandMap);
|
|
1884
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1885
|
+
handleIpc(ipc);
|
|
1886
|
+
const rpc = createRpc$1(ipc);
|
|
1887
|
+
return rpc;
|
|
1888
|
+
};
|
|
1889
|
+
|
|
1890
|
+
const createMockRpc = ({
|
|
1891
|
+
commandMap
|
|
1892
|
+
}) => {
|
|
1893
|
+
const invocations = [];
|
|
1894
|
+
const invoke = (method, ...params) => {
|
|
1895
|
+
invocations.push([method, ...params]);
|
|
1896
|
+
const command = commandMap[method];
|
|
1897
|
+
if (!command) {
|
|
1898
|
+
throw new Error(`command ${method} not found`);
|
|
1919
1899
|
}
|
|
1920
|
-
return
|
|
1921
|
-
}
|
|
1922
|
-
|
|
1900
|
+
return command(...params);
|
|
1901
|
+
};
|
|
1902
|
+
const mockRpc = {
|
|
1903
|
+
invocations,
|
|
1904
|
+
invoke,
|
|
1905
|
+
invokeAndTransfer: invoke
|
|
1906
|
+
};
|
|
1907
|
+
return mockRpc;
|
|
1923
1908
|
};
|
|
1924
|
-
|
|
1925
|
-
|
|
1909
|
+
|
|
1910
|
+
const rpcs$2 = Object.create(null);
|
|
1911
|
+
const set$c = (id, rpc) => {
|
|
1912
|
+
rpcs$2[id] = rpc;
|
|
1926
1913
|
};
|
|
1927
|
-
const
|
|
1928
|
-
return
|
|
1914
|
+
const get$a = id => {
|
|
1915
|
+
return rpcs$2[id];
|
|
1929
1916
|
};
|
|
1930
|
-
const
|
|
1931
|
-
|
|
1932
|
-
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(stackLinesToSkip));
|
|
1933
|
-
return currentStack;
|
|
1917
|
+
const remove$4 = id => {
|
|
1918
|
+
delete rpcs$2[id];
|
|
1934
1919
|
};
|
|
1935
|
-
|
|
1936
|
-
return
|
|
1920
|
+
|
|
1921
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1922
|
+
const create$7 = rpcId => {
|
|
1923
|
+
return {
|
|
1924
|
+
async dispose() {
|
|
1925
|
+
const rpc = get$a(rpcId);
|
|
1926
|
+
await rpc.dispose();
|
|
1927
|
+
},
|
|
1928
|
+
// @ts-ignore
|
|
1929
|
+
invoke(method, ...params) {
|
|
1930
|
+
const rpc = get$a(rpcId);
|
|
1931
|
+
// @ts-ignore
|
|
1932
|
+
return rpc.invoke(method, ...params);
|
|
1933
|
+
},
|
|
1934
|
+
// @ts-ignore
|
|
1935
|
+
invokeAndTransfer(method, ...params) {
|
|
1936
|
+
const rpc = get$a(rpcId);
|
|
1937
|
+
// @ts-ignore
|
|
1938
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1939
|
+
},
|
|
1940
|
+
registerMockRpc(commandMap) {
|
|
1941
|
+
const mockRpc = createMockRpc({
|
|
1942
|
+
commandMap
|
|
1943
|
+
});
|
|
1944
|
+
set$c(rpcId, mockRpc);
|
|
1945
|
+
// @ts-ignore
|
|
1946
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1947
|
+
remove$4(rpcId);
|
|
1948
|
+
};
|
|
1949
|
+
// @ts-ignore
|
|
1950
|
+
return mockRpc;
|
|
1951
|
+
},
|
|
1952
|
+
set(rpc) {
|
|
1953
|
+
set$c(rpcId, rpc);
|
|
1954
|
+
}
|
|
1955
|
+
};
|
|
1937
1956
|
};
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1957
|
+
|
|
1958
|
+
const DebugWorker$1 = 55;
|
|
1959
|
+
const ExtensionManagementWorker = 9006;
|
|
1960
|
+
const RendererWorker$1 = 1;
|
|
1961
|
+
|
|
1962
|
+
const {
|
|
1963
|
+
invoke: invoke$6} = create$7(DebugWorker$1);
|
|
1964
|
+
|
|
1965
|
+
const DebugWorker = {
|
|
1966
|
+
__proto__: null,
|
|
1967
|
+
invoke: invoke$6
|
|
1944
1968
|
};
|
|
1945
|
-
|
|
1946
|
-
const
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
1972
|
-
}
|
|
1973
|
-
if (error.data.code) {
|
|
1974
|
-
// @ts-ignore
|
|
1975
|
-
restoredError.code = error.data.code;
|
|
1976
|
-
}
|
|
1977
|
-
if (error.data.type) {
|
|
1978
|
-
// @ts-ignore
|
|
1979
|
-
restoredError.name = error.data.type;
|
|
1980
|
-
}
|
|
1981
|
-
} else {
|
|
1982
|
-
if (error.stack) {
|
|
1983
|
-
const lowerStack = restoredError.stack || '';
|
|
1984
|
-
// @ts-ignore
|
|
1985
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
1986
|
-
const parentStack = getParentStack(error);
|
|
1987
|
-
// @ts-ignore
|
|
1988
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
1989
|
-
}
|
|
1990
|
-
if (error.codeFrame) {
|
|
1991
|
-
// @ts-ignore
|
|
1992
|
-
restoredError.codeFrame = error.codeFrame;
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
return restoredError;
|
|
1996
|
-
}
|
|
1997
|
-
if (typeof error === 'string') {
|
|
1998
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
1999
|
-
}
|
|
2000
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
1969
|
+
|
|
1970
|
+
const {
|
|
1971
|
+
invoke: invoke$5,
|
|
1972
|
+
invokeAndTransfer: invokeAndTransfer$3,
|
|
1973
|
+
set: set$b
|
|
1974
|
+
} = create$7(ExtensionManagementWorker);
|
|
1975
|
+
|
|
1976
|
+
const {
|
|
1977
|
+
invoke: invoke$4,
|
|
1978
|
+
set: set$a
|
|
1979
|
+
} = create$7(7013);
|
|
1980
|
+
|
|
1981
|
+
const {
|
|
1982
|
+
invoke: invoke$3,
|
|
1983
|
+
invokeAndTransfer: invokeAndTransfer$2} = create$7(RendererWorker$1);
|
|
1984
|
+
const sendMessagePortToFileSearchWorker = async (port, rpcId = 0) => {
|
|
1985
|
+
const command = 'QuickPick.handleMessagePort';
|
|
1986
|
+
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSearchWorker', port, command, rpcId);
|
|
1987
|
+
};
|
|
1988
|
+
const sendMessagePortToIframeWorker = async (port, rpcId) => {
|
|
1989
|
+
const command = 'Iframes.handleMessagePort';
|
|
1990
|
+
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToIframeWorker', port, command, rpcId);
|
|
1991
|
+
};
|
|
1992
|
+
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
1993
|
+
const command = 'Extensions.handleMessagePort';
|
|
1994
|
+
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
2001
1995
|
};
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
1996
|
+
|
|
1997
|
+
const {
|
|
1998
|
+
invoke: invoke$2
|
|
1999
|
+
} = DebugWorker;
|
|
2000
|
+
|
|
2001
|
+
const state$8 = {
|
|
2002
|
+
debugProviderMap: Object.create(null)
|
|
2003
|
+
};
|
|
2004
|
+
const getDebugProvider = id => {
|
|
2005
|
+
const provider = state$8.debugProviderMap[id];
|
|
2006
|
+
if (!provider) {
|
|
2007
|
+
// @ts-ignore
|
|
2008
|
+
throw new VError(`no debug provider "${id}" found`);
|
|
2006
2009
|
}
|
|
2007
|
-
|
|
2008
|
-
|
|
2010
|
+
return provider;
|
|
2011
|
+
};
|
|
2012
|
+
const registerDebugProvider = debugProvider => {
|
|
2013
|
+
if (!debugProvider.id) {
|
|
2014
|
+
throw new Error('Failed to register debug system provider: missing id');
|
|
2009
2015
|
}
|
|
2010
|
-
|
|
2016
|
+
state$8.debugProviderMap[debugProvider.id] = debugProvider;
|
|
2011
2017
|
};
|
|
2012
|
-
const
|
|
2013
|
-
|
|
2018
|
+
const handlePaused = async params => {
|
|
2019
|
+
// @ts-ignore
|
|
2020
|
+
await invoke$2('Debug.paused', params);
|
|
2014
2021
|
};
|
|
2015
|
-
const
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2022
|
+
const handleResumed = async () => {
|
|
2023
|
+
// @ts-ignore
|
|
2024
|
+
await invoke$2('Debug.resumed');
|
|
2025
|
+
};
|
|
2026
|
+
const handleScriptParsed = async parsedScript => {
|
|
2027
|
+
// @ts-ignore
|
|
2028
|
+
await invoke$2('Debug.scriptParsed', parsedScript);
|
|
2029
|
+
};
|
|
2030
|
+
const handleChange = async params => {
|
|
2031
|
+
object(params);
|
|
2032
|
+
// @ts-ignore
|
|
2033
|
+
await invoke$2('Debug.handleChange', params);
|
|
2034
|
+
};
|
|
2035
|
+
const start = async (protocol, path) => {
|
|
2036
|
+
try {
|
|
2037
|
+
const provider = getDebugProvider(protocol);
|
|
2038
|
+
const emitter = {
|
|
2039
|
+
handleChange,
|
|
2040
|
+
handlePaused,
|
|
2041
|
+
handleResumed,
|
|
2042
|
+
handleScriptParsed
|
|
2043
|
+
};
|
|
2044
|
+
await provider.start(emitter, path);
|
|
2045
|
+
} catch (error) {
|
|
2046
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2021
2047
|
}
|
|
2022
|
-
fn(response);
|
|
2023
|
-
remove$3(id);
|
|
2024
2048
|
};
|
|
2025
|
-
const
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2049
|
+
const listProcesses = async (protocol, path) => {
|
|
2050
|
+
try {
|
|
2051
|
+
const provider = getDebugProvider(protocol);
|
|
2052
|
+
const processes = await provider.listProcesses(path);
|
|
2053
|
+
array(processes);
|
|
2054
|
+
return processes;
|
|
2055
|
+
} catch (error) {
|
|
2056
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2029
2057
|
}
|
|
2030
|
-
|
|
2031
|
-
|
|
2058
|
+
};
|
|
2059
|
+
const resume = async protocol => {
|
|
2060
|
+
try {
|
|
2061
|
+
const provider = getDebugProvider(protocol);
|
|
2062
|
+
return await provider.resume();
|
|
2063
|
+
} catch (error) {
|
|
2064
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2032
2065
|
}
|
|
2033
|
-
return undefined;
|
|
2034
2066
|
};
|
|
2035
|
-
const
|
|
2036
|
-
|
|
2067
|
+
const pause = async protocol => {
|
|
2068
|
+
try {
|
|
2069
|
+
const provider = getDebugProvider(protocol);
|
|
2070
|
+
return await provider.pause();
|
|
2071
|
+
} catch (error) {
|
|
2072
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2073
|
+
}
|
|
2037
2074
|
};
|
|
2038
|
-
const
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2075
|
+
const getScriptSource = async (protocol, scriptId) => {
|
|
2076
|
+
try {
|
|
2077
|
+
const provider = getDebugProvider(protocol);
|
|
2078
|
+
return await provider.getScriptSource(scriptId);
|
|
2079
|
+
} catch (error) {
|
|
2080
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2043
2081
|
}
|
|
2044
|
-
return stackString;
|
|
2045
2082
|
};
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2083
|
+
|
|
2084
|
+
// TODO create direct connection from debug worker to extension, not needing extension host worker apis
|
|
2085
|
+
|
|
2086
|
+
const getStatus = async protocol => {
|
|
2087
|
+
try {
|
|
2088
|
+
const provider = getDebugProvider(protocol);
|
|
2089
|
+
return await provider.getStatus();
|
|
2090
|
+
} catch (error) {
|
|
2091
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2053
2092
|
}
|
|
2054
|
-
return {
|
|
2055
|
-
code: Custom,
|
|
2056
|
-
data: {
|
|
2057
|
-
code: prettyError.code,
|
|
2058
|
-
codeFrame: prettyError.codeFrame,
|
|
2059
|
-
name: prettyError.name,
|
|
2060
|
-
stack: getStack(prettyError),
|
|
2061
|
-
type: getErrorType(prettyError)
|
|
2062
|
-
},
|
|
2063
|
-
message: prettyError.message
|
|
2064
|
-
};
|
|
2065
2093
|
};
|
|
2066
|
-
const
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2094
|
+
const getCallStack = async protocol => {
|
|
2095
|
+
try {
|
|
2096
|
+
const provider = getDebugProvider(protocol);
|
|
2097
|
+
return await provider.getCallStack();
|
|
2098
|
+
} catch (error) {
|
|
2099
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2100
|
+
}
|
|
2072
2101
|
};
|
|
2073
|
-
const
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2102
|
+
const getScopeChain = async protocol => {
|
|
2103
|
+
try {
|
|
2104
|
+
const provider = getDebugProvider(protocol);
|
|
2105
|
+
return await provider.getScopeChain();
|
|
2106
|
+
} catch (error) {
|
|
2107
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2108
|
+
}
|
|
2078
2109
|
};
|
|
2079
|
-
const
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2110
|
+
const getScripts = async protocol => {
|
|
2111
|
+
try {
|
|
2112
|
+
const provider = getDebugProvider(protocol);
|
|
2113
|
+
return await provider.getScripts();
|
|
2114
|
+
} catch (error) {
|
|
2115
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2116
|
+
}
|
|
2085
2117
|
};
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2118
|
+
|
|
2119
|
+
// eslint-disable-next-line sonarjs/no-identical-functions
|
|
2120
|
+
const getPausedStatus = async protocol => {
|
|
2121
|
+
try {
|
|
2122
|
+
const provider = getDebugProvider(protocol);
|
|
2123
|
+
return await provider.getStatus();
|
|
2124
|
+
} catch (error) {
|
|
2125
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2126
|
+
}
|
|
2089
2127
|
};
|
|
2090
|
-
const
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
},
|
|
2098
|
-
id,
|
|
2099
|
-
jsonrpc: Two$1
|
|
2100
|
-
};
|
|
2128
|
+
const stepInto = async protocol => {
|
|
2129
|
+
try {
|
|
2130
|
+
const provider = getDebugProvider(protocol);
|
|
2131
|
+
return await provider.stepInto();
|
|
2132
|
+
} catch (error) {
|
|
2133
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2134
|
+
}
|
|
2101
2135
|
};
|
|
2102
|
-
const
|
|
2136
|
+
const stepOut = async protocol => {
|
|
2103
2137
|
try {
|
|
2104
|
-
const
|
|
2105
|
-
return
|
|
2138
|
+
const provider = getDebugProvider(protocol);
|
|
2139
|
+
return await provider.stepOut();
|
|
2106
2140
|
} catch (error) {
|
|
2107
|
-
|
|
2108
|
-
return getErrorResponseSimple(message.id, error);
|
|
2109
|
-
}
|
|
2110
|
-
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
2141
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2111
2142
|
}
|
|
2112
2143
|
};
|
|
2113
|
-
const
|
|
2114
|
-
|
|
2144
|
+
const stepOver = async protocol => {
|
|
2145
|
+
try {
|
|
2146
|
+
const provider = getDebugProvider(protocol);
|
|
2147
|
+
return await provider.stepOver();
|
|
2148
|
+
} catch (error) {
|
|
2149
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2150
|
+
}
|
|
2115
2151
|
};
|
|
2116
|
-
const
|
|
2117
|
-
|
|
2152
|
+
const setPauseOnException = async (protocol, value) => {
|
|
2153
|
+
try {
|
|
2154
|
+
const provider = getDebugProvider(protocol);
|
|
2155
|
+
return await provider.setPauseOnExceptions(value);
|
|
2156
|
+
} catch (error) {
|
|
2157
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2158
|
+
}
|
|
2118
2159
|
};
|
|
2119
|
-
const
|
|
2120
|
-
|
|
2160
|
+
const getProperties = async (protocol, objectId) => {
|
|
2161
|
+
try {
|
|
2162
|
+
const provider = getDebugProvider(protocol);
|
|
2163
|
+
return await provider.getProperties(objectId);
|
|
2164
|
+
} catch (error) {
|
|
2165
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2166
|
+
}
|
|
2121
2167
|
};
|
|
2122
|
-
const
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
return {
|
|
2129
|
-
execute: options.execute,
|
|
2130
|
-
ipc: options.ipc,
|
|
2131
|
-
logError: options.logError || defaultLogError,
|
|
2132
|
-
message: options.message,
|
|
2133
|
-
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
2134
|
-
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
2135
|
-
resolve: options.resolve || defaultResolve
|
|
2136
|
-
};
|
|
2168
|
+
const evaluate = async (protocol, expression, callFrameId) => {
|
|
2169
|
+
try {
|
|
2170
|
+
const provider = getDebugProvider(protocol);
|
|
2171
|
+
return await provider.evaluate(expression, callFrameId);
|
|
2172
|
+
} catch (error) {
|
|
2173
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
2137
2174
|
}
|
|
2138
|
-
return {
|
|
2139
|
-
execute: args[2],
|
|
2140
|
-
ipc: args[0],
|
|
2141
|
-
logError: args[5],
|
|
2142
|
-
message: args[1],
|
|
2143
|
-
preparePrettyError: args[4],
|
|
2144
|
-
requiresSocket: args[6],
|
|
2145
|
-
resolve: args[3]
|
|
2146
|
-
};
|
|
2147
2175
|
};
|
|
2148
|
-
const
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2176
|
+
const setPauseOnExceptions = async (protocol, value) => {
|
|
2177
|
+
try {
|
|
2178
|
+
const provider = getDebugProvider(protocol);
|
|
2179
|
+
return await provider.setPauseOnExceptions(value);
|
|
2180
|
+
} catch (error) {
|
|
2181
|
+
throw new VError(error, 'Failed to execute setPauseOnExceptions');
|
|
2182
|
+
}
|
|
2183
|
+
};
|
|
2184
|
+
|
|
2185
|
+
const {
|
|
2186
|
+
executeDefinitionProvider,
|
|
2187
|
+
registerDefinitionProvider} = create$l({
|
|
2188
|
+
name: 'Definition',
|
|
2189
|
+
resultShape: {
|
|
2190
|
+
allowUndefined: true,
|
|
2191
|
+
properties: {
|
|
2192
|
+
endOffset: {
|
|
2193
|
+
type: Number
|
|
2194
|
+
},
|
|
2195
|
+
startOffset: {
|
|
2196
|
+
type: Number
|
|
2197
|
+
},
|
|
2198
|
+
uri: {
|
|
2199
|
+
type: String$1
|
|
2167
2200
|
}
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
resolve(message.id, message);
|
|
2171
|
-
return;
|
|
2201
|
+
},
|
|
2202
|
+
type: Object$1
|
|
2172
2203
|
}
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2204
|
+
});
|
|
2205
|
+
|
|
2206
|
+
const {
|
|
2207
|
+
executeDiagnosticProvider,
|
|
2208
|
+
registerDiagnosticProvider
|
|
2209
|
+
} = create$l({
|
|
2210
|
+
name: 'Diagnostic',
|
|
2211
|
+
resultShape: {
|
|
2212
|
+
items: {
|
|
2213
|
+
type: Object$1
|
|
2214
|
+
},
|
|
2215
|
+
type: Array$1
|
|
2176
2216
|
}
|
|
2177
|
-
|
|
2178
|
-
};
|
|
2217
|
+
});
|
|
2179
2218
|
|
|
2180
|
-
const
|
|
2219
|
+
const RendererWorker = 1;
|
|
2181
2220
|
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
method,
|
|
2186
|
-
params
|
|
2187
|
-
};
|
|
2221
|
+
const invoke$1 = (method, ...params) => {
|
|
2222
|
+
const rpc = get$a(RendererWorker);
|
|
2223
|
+
return rpc.invoke(method, ...params);
|
|
2188
2224
|
};
|
|
2189
|
-
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2192
|
-
id,
|
|
2193
|
-
jsonrpc: Two,
|
|
2194
|
-
method,
|
|
2195
|
-
params
|
|
2196
|
-
};
|
|
2197
|
-
return message;
|
|
2225
|
+
const invokeAndTransfer$1 = (method, ...params) => {
|
|
2226
|
+
const rpc = get$a(RendererWorker);
|
|
2227
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
2198
2228
|
};
|
|
2199
2229
|
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2230
|
+
const showInformationMessage = message => {
|
|
2231
|
+
string(message);
|
|
2232
|
+
const result = invoke$1('ExtensionHostDialog.showInformationMessage', message);
|
|
2233
|
+
return result;
|
|
2203
2234
|
};
|
|
2204
2235
|
|
|
2205
|
-
const
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
resolve
|
|
2210
|
-
} = Promise.withResolvers();
|
|
2211
|
-
map[id] = resolve;
|
|
2212
|
-
return {
|
|
2213
|
-
id,
|
|
2214
|
-
promise
|
|
2215
|
-
};
|
|
2236
|
+
const env = {};
|
|
2237
|
+
|
|
2238
|
+
const exec = async (command, args, options) => {
|
|
2239
|
+
throw new DepecratedError(`vscode.exec is deprecated, use createNodeRpc instead`);
|
|
2216
2240
|
};
|
|
2217
2241
|
|
|
2218
|
-
const
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
2225
|
-
ipc.sendAndTransfer(message);
|
|
2226
|
-
} else {
|
|
2227
|
-
ipc.send(message);
|
|
2242
|
+
const fileSystemProviderMap = Object.create(null);
|
|
2243
|
+
const get$9 = protocol => {
|
|
2244
|
+
const provider = fileSystemProviderMap[protocol];
|
|
2245
|
+
if (!provider) {
|
|
2246
|
+
// @ts-ignore
|
|
2247
|
+
throw new VError(`no file system provider for protocol "${protocol}" found`);
|
|
2228
2248
|
}
|
|
2229
|
-
|
|
2230
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
2249
|
+
return provider;
|
|
2231
2250
|
};
|
|
2232
|
-
const
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
console.warn(`callback ${id} may already be disposed`);
|
|
2238
|
-
return;
|
|
2239
|
-
}
|
|
2240
|
-
fn(response);
|
|
2241
|
-
delete callbacks[id];
|
|
2242
|
-
};
|
|
2243
|
-
const rpc = {
|
|
2244
|
-
async dispose() {
|
|
2245
|
-
await ipc?.dispose();
|
|
2246
|
-
},
|
|
2247
|
-
invoke(method, ...params) {
|
|
2248
|
-
return invokeHelper(callbacks, ipc, method, params, false);
|
|
2249
|
-
},
|
|
2250
|
-
invokeAndTransfer(method, ...params) {
|
|
2251
|
-
return invokeHelper(callbacks, ipc, method, params, true);
|
|
2252
|
-
},
|
|
2253
|
-
// @ts-ignore
|
|
2254
|
-
ipc,
|
|
2255
|
-
/**
|
|
2256
|
-
* @deprecated
|
|
2257
|
-
*/
|
|
2258
|
-
send(method, ...params) {
|
|
2259
|
-
const message = create$h(method, params);
|
|
2260
|
-
ipc.send(message);
|
|
2261
|
-
}
|
|
2262
|
-
};
|
|
2263
|
-
return rpc;
|
|
2251
|
+
const set$9 = (id, provider) => {
|
|
2252
|
+
if (!id) {
|
|
2253
|
+
throw new Error('Failed to register file system provider: missing id');
|
|
2254
|
+
}
|
|
2255
|
+
fileSystemProviderMap[id] = provider;
|
|
2264
2256
|
};
|
|
2265
2257
|
|
|
2266
|
-
const
|
|
2267
|
-
|
|
2258
|
+
const registerFileSystemProvider = fileSystemProvider => {
|
|
2259
|
+
if (!fileSystemProvider.id) {
|
|
2260
|
+
throw new Error('Failed to register file system provider: missing id');
|
|
2261
|
+
}
|
|
2262
|
+
set$9(fileSystemProvider.id, fileSystemProvider);
|
|
2268
2263
|
};
|
|
2269
|
-
const
|
|
2270
|
-
|
|
2264
|
+
const readDirWithFileTypes$2 = async (protocol, path) => {
|
|
2265
|
+
try {
|
|
2266
|
+
const provider = get$9(protocol);
|
|
2267
|
+
return await provider.readDirWithFileTypes(path);
|
|
2268
|
+
} catch (error) {
|
|
2269
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
2270
|
+
}
|
|
2271
2271
|
};
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2272
|
+
const readFile$2 = async (protocol, path) => {
|
|
2273
|
+
try {
|
|
2274
|
+
const provider = get$9(protocol);
|
|
2275
|
+
return await provider.readFile(path);
|
|
2276
|
+
} catch (error) {
|
|
2277
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
2278
|
+
}
|
|
2274
2279
|
};
|
|
2275
|
-
const
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2280
|
+
const mkdir$2 = async (protocol, path) => {
|
|
2281
|
+
try {
|
|
2282
|
+
const provider = get$9(protocol);
|
|
2283
|
+
return await provider.mkdir(path);
|
|
2284
|
+
} catch (error) {
|
|
2285
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
const readFileExternal = async path => {
|
|
2289
|
+
// TODO when file is local,
|
|
2290
|
+
// don't ask renderer worker
|
|
2291
|
+
// instead read file directly from shared process
|
|
2292
|
+
// this avoid parsing the potentially large message
|
|
2293
|
+
// and improve performance by not blocking the renderer worker
|
|
2294
|
+
// when reading / writing large files
|
|
2295
|
+
const content = await invoke$1('FileSystem.readFile', path);
|
|
2296
|
+
return content;
|
|
2297
|
+
};
|
|
2298
|
+
const removeExternal = async path => {
|
|
2299
|
+
const content = await invoke$1('FileSystem.remove', path);
|
|
2300
|
+
return content;
|
|
2301
|
+
};
|
|
2302
|
+
const existsExternal = async uri => {
|
|
2303
|
+
return await invoke$1('FileSystem.exists', uri);
|
|
2304
|
+
};
|
|
2305
|
+
const mkdirExternal = async uri => {
|
|
2306
|
+
return await invoke$1('FileSystem.mkdir', uri);
|
|
2307
|
+
};
|
|
2308
|
+
const writeFileExternal = async (uri, content) => {
|
|
2309
|
+
return await invoke$1('FileSystem.writeFile', uri, content);
|
|
2310
|
+
};
|
|
2311
|
+
const statExternal = async uri => {
|
|
2312
|
+
return await invoke$1('FileSystem.stat', uri);
|
|
2313
|
+
};
|
|
2314
|
+
const readDirWithFileTypesExternal = async path => {
|
|
2315
|
+
// TODO when file is local,
|
|
2316
|
+
// don't ask renderer worker
|
|
2317
|
+
// instead read file directly from shared process
|
|
2318
|
+
// this avoid parsing the potentially large message
|
|
2319
|
+
// and improve performance by not blocking the renderer worker
|
|
2320
|
+
// when reading / writing large files
|
|
2321
|
+
const content = await invoke$1('FileSystem.readDirWithFileTypes', path);
|
|
2322
|
+
return content;
|
|
2323
|
+
};
|
|
2324
|
+
const remove$3 = async (protocol, path) => {
|
|
2325
|
+
try {
|
|
2326
|
+
const provider = get$9(protocol);
|
|
2327
|
+
return await provider.remove(path);
|
|
2328
|
+
} catch (error) {
|
|
2329
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
2330
|
+
}
|
|
2331
|
+
};
|
|
2332
|
+
const rename$1 = async (protocol, oldUri, newUri) => {
|
|
2333
|
+
try {
|
|
2334
|
+
const provider = get$9(protocol);
|
|
2335
|
+
return await provider.rename(oldUri, newUri);
|
|
2336
|
+
} catch (error) {
|
|
2337
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
2338
|
+
}
|
|
2339
|
+
};
|
|
2340
|
+
const writeFile$3 = async (protocol, uri, content) => {
|
|
2341
|
+
try {
|
|
2342
|
+
const provider = get$9(protocol);
|
|
2343
|
+
return await provider.writeFile(uri, content);
|
|
2344
|
+
} catch (error) {
|
|
2345
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
2346
|
+
}
|
|
2279
2347
|
};
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
ipc.on('message', handleMessage);
|
|
2348
|
+
const getPathSeparator = protocol => {
|
|
2349
|
+
try {
|
|
2350
|
+
const provider = get$9(protocol);
|
|
2351
|
+
return provider.pathSeparator;
|
|
2352
|
+
} catch (error) {
|
|
2353
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
2287
2354
|
}
|
|
2288
2355
|
};
|
|
2289
2356
|
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2357
|
+
const {
|
|
2358
|
+
executeFormattingProvider,
|
|
2359
|
+
registerFormattingProvider} = create$l({
|
|
2360
|
+
executeKey: 'format',
|
|
2361
|
+
name: 'Formatting',
|
|
2362
|
+
resultShape: {
|
|
2363
|
+
allowUndefined: true,
|
|
2364
|
+
items: {
|
|
2365
|
+
properties: {
|
|
2366
|
+
endOffset: {
|
|
2367
|
+
type: Number
|
|
2368
|
+
},
|
|
2369
|
+
inserted: {
|
|
2370
|
+
type: String$1
|
|
2371
|
+
},
|
|
2372
|
+
startOffset: {
|
|
2373
|
+
type: Number
|
|
2374
|
+
}
|
|
2375
|
+
},
|
|
2376
|
+
type: Object$1
|
|
2377
|
+
},
|
|
2378
|
+
type: Array$1
|
|
2294
2379
|
}
|
|
2295
|
-
|
|
2296
|
-
return ipc;
|
|
2297
|
-
};
|
|
2380
|
+
});
|
|
2298
2381
|
|
|
2299
|
-
const
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
messagePort
|
|
2309
|
-
});
|
|
2310
|
-
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
2311
|
-
handleIpc(ipc);
|
|
2312
|
-
const rpc = createRpc$1(ipc);
|
|
2313
|
-
messagePort.start();
|
|
2314
|
-
return rpc;
|
|
2382
|
+
const getOffset = (textDocument, position) => {
|
|
2383
|
+
let offset = 0;
|
|
2384
|
+
let rowIndex = 0;
|
|
2385
|
+
while (rowIndex++ < position.rowIndex) {
|
|
2386
|
+
const newLineIndex = textDocument.text.indexOf('\n', offset);
|
|
2387
|
+
offset = newLineIndex + 1;
|
|
2388
|
+
}
|
|
2389
|
+
offset += position.columnIndex;
|
|
2390
|
+
return offset;
|
|
2315
2391
|
};
|
|
2316
2392
|
|
|
2317
|
-
const
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
send
|
|
2321
|
-
}) => {
|
|
2393
|
+
const getPosition = (textDocument, offset) => {
|
|
2394
|
+
let index = 0;
|
|
2395
|
+
let rowIndex = 0;
|
|
2322
2396
|
const {
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
isMessagePortOpen,
|
|
2330
|
-
messagePort: port2
|
|
2331
|
-
});
|
|
2332
|
-
};
|
|
2333
|
-
|
|
2334
|
-
const createSharedLazyRpc = factory => {
|
|
2335
|
-
let rpcPromise;
|
|
2336
|
-
const getOrCreate = () => {
|
|
2337
|
-
if (!rpcPromise) {
|
|
2338
|
-
rpcPromise = factory();
|
|
2397
|
+
text
|
|
2398
|
+
} = textDocument;
|
|
2399
|
+
while (index < offset) {
|
|
2400
|
+
const newLineIndex = text.indexOf('\n', index);
|
|
2401
|
+
if (newLineIndex === -1) {
|
|
2402
|
+
break;
|
|
2339
2403
|
}
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
async dispose() {
|
|
2344
|
-
const rpc = await getOrCreate();
|
|
2345
|
-
await rpc.dispose();
|
|
2346
|
-
},
|
|
2347
|
-
async invoke(method, ...params) {
|
|
2348
|
-
const rpc = await getOrCreate();
|
|
2349
|
-
return rpc.invoke(method, ...params);
|
|
2350
|
-
},
|
|
2351
|
-
async invokeAndTransfer(method, ...params) {
|
|
2352
|
-
const rpc = await getOrCreate();
|
|
2353
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
2354
|
-
},
|
|
2355
|
-
async send(method, ...params) {
|
|
2356
|
-
const rpc = await getOrCreate();
|
|
2357
|
-
rpc.send(method, ...params);
|
|
2404
|
+
const newIndex = newLineIndex + 1;
|
|
2405
|
+
if (newIndex > offset) {
|
|
2406
|
+
break;
|
|
2358
2407
|
}
|
|
2408
|
+
index = newIndex;
|
|
2409
|
+
rowIndex++;
|
|
2410
|
+
}
|
|
2411
|
+
const columnIndex = offset - index;
|
|
2412
|
+
return {
|
|
2413
|
+
columnIndex,
|
|
2414
|
+
rowIndex
|
|
2359
2415
|
};
|
|
2360
2416
|
};
|
|
2361
2417
|
|
|
2362
|
-
const
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
});
|
|
2373
|
-
});
|
|
2374
|
-
};
|
|
2375
|
-
|
|
2376
|
-
const create$b = async ({
|
|
2377
|
-
commandMap,
|
|
2378
|
-
webSocket
|
|
2379
|
-
}) => {
|
|
2380
|
-
// TODO create a commandMap per rpc instance
|
|
2381
|
-
register$1(commandMap);
|
|
2382
|
-
const rawIpc = await IpcParentWithWebSocket$1$1.create({
|
|
2383
|
-
webSocket
|
|
2384
|
-
});
|
|
2385
|
-
const ipc = IpcParentWithWebSocket$1$1.wrap(rawIpc);
|
|
2386
|
-
handleIpc(ipc);
|
|
2387
|
-
const rpc = createRpc$1(ipc);
|
|
2388
|
-
return rpc;
|
|
2389
|
-
};
|
|
2390
|
-
|
|
2391
|
-
const create$a = async ({
|
|
2392
|
-
commandMap,
|
|
2393
|
-
messagePort
|
|
2394
|
-
}) => {
|
|
2395
|
-
// TODO create a commandMap per rpc instance
|
|
2396
|
-
register$1(commandMap);
|
|
2397
|
-
const ipc = await listen$1(IpcChildWithMessagePort$1, {
|
|
2398
|
-
port: messagePort
|
|
2399
|
-
});
|
|
2400
|
-
handleIpc(ipc);
|
|
2401
|
-
const rpc = createRpc$1(ipc);
|
|
2402
|
-
return rpc;
|
|
2403
|
-
};
|
|
2404
|
-
|
|
2405
|
-
const create$9 = async ({
|
|
2406
|
-
commandMap,
|
|
2407
|
-
isMessagePortOpen,
|
|
2408
|
-
messagePort
|
|
2409
|
-
}) => {
|
|
2410
|
-
// TODO create a commandMap per rpc instance
|
|
2411
|
-
register$1(commandMap);
|
|
2412
|
-
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
2413
|
-
isMessagePortOpen,
|
|
2414
|
-
messagePort
|
|
2415
|
-
});
|
|
2416
|
-
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
2417
|
-
handleIpc(ipc);
|
|
2418
|
-
const rpc = createRpc$1(ipc);
|
|
2419
|
-
return rpc;
|
|
2420
|
-
};
|
|
2418
|
+
const {
|
|
2419
|
+
executeHoverProvider,
|
|
2420
|
+
registerHoverProvider} = create$l({
|
|
2421
|
+
name: 'Hover',
|
|
2422
|
+
resultShape: {
|
|
2423
|
+
allowUndefined: true,
|
|
2424
|
+
properties: {},
|
|
2425
|
+
type: Object$1
|
|
2426
|
+
}
|
|
2427
|
+
});
|
|
2421
2428
|
|
|
2422
|
-
const
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2429
|
+
const {
|
|
2430
|
+
executeImplementationProvider,
|
|
2431
|
+
registerImplementationProvider} = create$l({
|
|
2432
|
+
name: 'Implementation',
|
|
2433
|
+
resultShape: {
|
|
2434
|
+
items: {
|
|
2435
|
+
type: Object$1
|
|
2436
|
+
},
|
|
2437
|
+
type: Array$1
|
|
2438
|
+
}
|
|
2439
|
+
});
|
|
2431
2440
|
|
|
2432
|
-
const
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
// TODO create a commandMap per rpc instance
|
|
2436
|
-
register$1(commandMap);
|
|
2437
|
-
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
2438
|
-
handleIpc(ipc);
|
|
2439
|
-
const rpc = createRpc$1(ipc);
|
|
2440
|
-
return rpc;
|
|
2441
|
-
};
|
|
2441
|
+
const WebSocket$1 = 5;
|
|
2442
|
+
const ElectronMessagePort = 6;
|
|
2443
|
+
const ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1 = 7;
|
|
2442
2444
|
|
|
2443
2445
|
const getPortTuple = () => {
|
|
2444
2446
|
const {
|
|
@@ -2477,7 +2479,7 @@ const create$6 = async ({
|
|
|
2477
2479
|
port1,
|
|
2478
2480
|
port2
|
|
2479
2481
|
} = getPortTuple();
|
|
2480
|
-
const rpcPromise = create$
|
|
2482
|
+
const rpcPromise = create$a({
|
|
2481
2483
|
commandMap,
|
|
2482
2484
|
isMessagePortOpen: true,
|
|
2483
2485
|
messagePort: port2
|
|
@@ -2516,7 +2518,7 @@ const create$5 = async ({
|
|
|
2516
2518
|
const port = await getPort();
|
|
2517
2519
|
// TODO rpc module should start port
|
|
2518
2520
|
port.start();
|
|
2519
|
-
const rpc = await create$
|
|
2521
|
+
const rpc = await create$a({
|
|
2520
2522
|
commandMap: {},
|
|
2521
2523
|
isMessagePortOpen: true,
|
|
2522
2524
|
messagePort: port
|
|
@@ -2544,7 +2546,7 @@ const create$4 = async ({
|
|
|
2544
2546
|
string(type);
|
|
2545
2547
|
const wsUrl = getWebSocketUrl(type, location.host);
|
|
2546
2548
|
const webSocket = new WebSocket(wsUrl);
|
|
2547
|
-
const rpc = await create$
|
|
2549
|
+
const rpc = await create$c({
|
|
2548
2550
|
commandMap: {},
|
|
2549
2551
|
webSocket
|
|
2550
2552
|
});
|
|
@@ -2662,7 +2664,7 @@ const send = async port => {
|
|
|
2662
2664
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, initialCommand);
|
|
2663
2665
|
};
|
|
2664
2666
|
const launchFileSystemProcess = async () => {
|
|
2665
|
-
const rpc = await create$
|
|
2667
|
+
const rpc = await create$e({
|
|
2666
2668
|
commandMap: {},
|
|
2667
2669
|
send
|
|
2668
2670
|
});
|
|
@@ -3296,15 +3298,24 @@ const getStatusBarItems = async () => {
|
|
|
3296
3298
|
return statusBarItems;
|
|
3297
3299
|
};
|
|
3298
3300
|
const getStatusBarItems2 = async () => {
|
|
3299
|
-
const
|
|
3301
|
+
const sourceProviders = Object.values(state$7.providers);
|
|
3300
3302
|
const statusBarItems = [];
|
|
3301
|
-
for (const provider of
|
|
3303
|
+
for (const provider of sourceProviders) {
|
|
3302
3304
|
// @ts-ignore
|
|
3303
3305
|
if (provider && provider.getStatusBarItems) {
|
|
3304
3306
|
// @ts-ignore
|
|
3305
3307
|
statusBarItems.push(...provider.getStatusBarItems());
|
|
3306
3308
|
}
|
|
3307
3309
|
}
|
|
3310
|
+
const values = Object.values(providers);
|
|
3311
|
+
for (const provider of values) {
|
|
3312
|
+
if (provider && provider.getStatusBarItem) {
|
|
3313
|
+
const item = provider.getStatusBarItem();
|
|
3314
|
+
if (item) {
|
|
3315
|
+
statusBarItems.push(item);
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3308
3319
|
return statusBarItems;
|
|
3309
3320
|
};
|
|
3310
3321
|
const registerChangeListener = () => {
|
|
@@ -3414,7 +3425,7 @@ const createWebView = async (providerId, port, uri, uid, origin, webView) => {
|
|
|
3414
3425
|
// TODO cancel promise when webview is disposed before sending message
|
|
3415
3426
|
// TODO handle case when webview doesn't send ready message
|
|
3416
3427
|
|
|
3417
|
-
const rpc = await create$
|
|
3428
|
+
const rpc = await create$a({
|
|
3418
3429
|
commandMap: provider.commands || {},
|
|
3419
3430
|
isMessagePortOpen: false,
|
|
3420
3431
|
messagePort: port
|
|
@@ -3704,7 +3715,7 @@ const setup = ({
|
|
|
3704
3715
|
};
|
|
3705
3716
|
|
|
3706
3717
|
const launchExtensionManagementWorker = async () => {
|
|
3707
|
-
const rpc = await create$
|
|
3718
|
+
const rpc = await create$d({
|
|
3708
3719
|
commandMap: {},
|
|
3709
3720
|
async send(port) {
|
|
3710
3721
|
await sendMessagePortToExtensionManagementWorker(port, 0);
|
|
@@ -3715,7 +3726,7 @@ const launchExtensionManagementWorker = async () => {
|
|
|
3715
3726
|
|
|
3716
3727
|
const launchFileSearchWorker = async () => {
|
|
3717
3728
|
try {
|
|
3718
|
-
const rpc = await create$
|
|
3729
|
+
const rpc = await create$d({
|
|
3719
3730
|
commandMap: {},
|
|
3720
3731
|
async send(port) {
|
|
3721
3732
|
await sendMessagePortToFileSearchWorker(port, 0);
|
|
@@ -4944,7 +4955,7 @@ const hydrate$1 = async () => {
|
|
|
4944
4955
|
};
|
|
4945
4956
|
|
|
4946
4957
|
const launchIframeWorker = async () => {
|
|
4947
|
-
const rpc = await create$
|
|
4958
|
+
const rpc = await create$e({
|
|
4948
4959
|
commandMap: {},
|
|
4949
4960
|
async send(port) {
|
|
4950
4961
|
await sendMessagePortToIframeWorker(port, 0);
|
|
@@ -5279,6 +5290,9 @@ const getContentType = uri => {
|
|
|
5279
5290
|
return mime;
|
|
5280
5291
|
};
|
|
5281
5292
|
|
|
5293
|
+
/* eslint-disable sonarjs/prefer-single-boolean-return, sonarjs/redundant-type-aliases, sonarjs/cognitive-complexity */
|
|
5294
|
+
|
|
5295
|
+
|
|
5282
5296
|
// TODO move this to an extension?
|
|
5283
5297
|
|
|
5284
5298
|
const readFile = uri => {
|
|
@@ -5293,10 +5307,7 @@ const readFile = uri => {
|
|
|
5293
5307
|
};
|
|
5294
5308
|
const exists = uri => {
|
|
5295
5309
|
const dirent = getDirent(uri) || getDirent(`${uri}/`);
|
|
5296
|
-
|
|
5297
|
-
return false;
|
|
5298
|
-
}
|
|
5299
|
-
return true;
|
|
5310
|
+
return !!dirent;
|
|
5300
5311
|
};
|
|
5301
5312
|
const stat = uri => {
|
|
5302
5313
|
const dirent = getDirent(uri);
|
|
@@ -5411,6 +5422,15 @@ const rename = (oldUri, newUri) => {
|
|
|
5411
5422
|
}
|
|
5412
5423
|
renameFile(oldUri, newUri);
|
|
5413
5424
|
};
|
|
5425
|
+
const isDirectChildDirectory = (key, uri) => {
|
|
5426
|
+
return !key.slice(0, -1).includes(Slash, uri.length) && key !== `${uri}/` && key !== uri;
|
|
5427
|
+
};
|
|
5428
|
+
const pushDirent = (dirents, name, type) => {
|
|
5429
|
+
dirents.push({
|
|
5430
|
+
name,
|
|
5431
|
+
type
|
|
5432
|
+
});
|
|
5433
|
+
};
|
|
5414
5434
|
const readDirWithFileTypes = uri => {
|
|
5415
5435
|
if (!uri.endsWith(Slash)) {
|
|
5416
5436
|
uri += Slash;
|
|
@@ -5421,21 +5441,15 @@ const readDirWithFileTypes = uri => {
|
|
|
5421
5441
|
// @ts-ignore
|
|
5422
5442
|
switch (value.type) {
|
|
5423
5443
|
case Directory$1:
|
|
5424
|
-
if (
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
// @ts-ignore
|
|
5428
|
-
type: value.type
|
|
5429
|
-
});
|
|
5444
|
+
if (isDirectChildDirectory(key, uri)) {
|
|
5445
|
+
// @ts-ignore
|
|
5446
|
+
pushDirent(dirents, key.slice(uri.length, -1), value.type);
|
|
5430
5447
|
}
|
|
5431
5448
|
break;
|
|
5432
5449
|
case File$1:
|
|
5433
5450
|
if (!key.includes(Slash, uri.length + 1)) {
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
// @ts-ignore
|
|
5437
|
-
type: value.type
|
|
5438
|
-
});
|
|
5451
|
+
// @ts-ignore
|
|
5452
|
+
pushDirent(dirents, key.slice(uri.length), value.type);
|
|
5439
5453
|
}
|
|
5440
5454
|
break;
|
|
5441
5455
|
}
|
|
@@ -5569,7 +5583,7 @@ const handleBeforeUnload = () => {
|
|
|
5569
5583
|
};
|
|
5570
5584
|
|
|
5571
5585
|
const handleMessagePort2 = async (port, rpcId) => {
|
|
5572
|
-
const rpc = await create$
|
|
5586
|
+
const rpc = await create$9({
|
|
5573
5587
|
commandMap: {},
|
|
5574
5588
|
messagePort: port
|
|
5575
5589
|
});
|
|
@@ -5579,7 +5593,7 @@ const handleMessagePort2 = async (port, rpcId) => {
|
|
|
5579
5593
|
};
|
|
5580
5594
|
|
|
5581
5595
|
const handleMessagePort = async (port, rpcId) => {
|
|
5582
|
-
const rpc = await create$
|
|
5596
|
+
const rpc = await create$b({
|
|
5583
5597
|
commandMap: {},
|
|
5584
5598
|
messagePort: port
|
|
5585
5599
|
});
|
|
@@ -6228,7 +6242,7 @@ const commandMap = {
|
|
|
6228
6242
|
[FileSystemMkdir]: mkdir$2,
|
|
6229
6243
|
[FileSystemReadDirWithFileTypes]: readDirWithFileTypes$2,
|
|
6230
6244
|
[FileSystemReadFile]: readFile$2,
|
|
6231
|
-
[FileSystemRemove]: remove$
|
|
6245
|
+
[FileSystemRemove]: remove$3,
|
|
6232
6246
|
[FileSystemRename]: rename$1,
|
|
6233
6247
|
[FileSystemWriteFile]: writeFile$3,
|
|
6234
6248
|
[FormattingExecuteFormmattingProvider]: executeFormattingProvider,
|
|
@@ -6347,7 +6361,7 @@ const commandMap = {
|
|
|
6347
6361
|
};
|
|
6348
6362
|
|
|
6349
6363
|
const launchRendererWorker = async () => {
|
|
6350
|
-
const rpc = await create$
|
|
6364
|
+
const rpc = await create$8({
|
|
6351
6365
|
commandMap: commandMap
|
|
6352
6366
|
});
|
|
6353
6367
|
set$c(RendererWorker, rpc);
|