@lvce-editor/extension-host-worker 8.5.0 → 8.6.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 +1449 -1426
- package/package.json +1 -1
|
@@ -579,7 +579,7 @@ const registerMethod = ({
|
|
|
579
579
|
}
|
|
580
580
|
};
|
|
581
581
|
};
|
|
582
|
-
const create$
|
|
582
|
+
const create$l = ({
|
|
583
583
|
additionalMethodNames = [],
|
|
584
584
|
executeKey = '',
|
|
585
585
|
name,
|
|
@@ -632,7 +632,7 @@ const String$1 = 'string';
|
|
|
632
632
|
|
|
633
633
|
const {
|
|
634
634
|
executeBraceCompletionProvider,
|
|
635
|
-
registerBraceCompletionProvider} = create$
|
|
635
|
+
registerBraceCompletionProvider} = create$l({
|
|
636
636
|
name: 'BraceCompletion',
|
|
637
637
|
resultShape: {
|
|
638
638
|
type: Boolean$1
|
|
@@ -642,7 +642,7 @@ const {
|
|
|
642
642
|
const {
|
|
643
643
|
executeClosingTagProvider,
|
|
644
644
|
registerClosingTagProvider
|
|
645
|
-
} = create$
|
|
645
|
+
} = create$l({
|
|
646
646
|
name: 'ClosingTag',
|
|
647
647
|
resultShape: {
|
|
648
648
|
allowUndefined: true,
|
|
@@ -654,7 +654,7 @@ const {
|
|
|
654
654
|
const {
|
|
655
655
|
executeCodeActionProvider,
|
|
656
656
|
registerCodeActionProvider
|
|
657
|
-
} = create$
|
|
657
|
+
} = create$l({
|
|
658
658
|
name: 'CodeAction',
|
|
659
659
|
resultShape: {
|
|
660
660
|
items: {
|
|
@@ -736,7 +736,7 @@ const executeCommand$1 = async (id, ...args) => {
|
|
|
736
736
|
const {
|
|
737
737
|
executeCommentProvider,
|
|
738
738
|
registerCommentProvider
|
|
739
|
-
} = create$
|
|
739
|
+
} = create$l({
|
|
740
740
|
name: 'Comment',
|
|
741
741
|
resultShape() {
|
|
742
742
|
return '';
|
|
@@ -747,7 +747,7 @@ const {
|
|
|
747
747
|
executeCompletionProvider,
|
|
748
748
|
executeresolveCompletionItemProvider,
|
|
749
749
|
registerCompletionProvider
|
|
750
|
-
} = create$
|
|
750
|
+
} = create$l({
|
|
751
751
|
additionalMethodNames: [
|
|
752
752
|
// @ts-ignore
|
|
753
753
|
{
|
|
@@ -777,19 +777,60 @@ const setConfigurations = preferences => {
|
|
|
777
777
|
state$9.configuration = preferences;
|
|
778
778
|
};
|
|
779
779
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
780
|
+
class CommandNotFoundError extends Error {
|
|
781
|
+
constructor(command) {
|
|
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);
|
|
789
|
+
};
|
|
790
|
+
const getCommand = key => {
|
|
791
|
+
return commands[key];
|
|
792
|
+
};
|
|
793
|
+
const execute = (command, ...args) => {
|
|
794
|
+
const fn = getCommand(command);
|
|
795
|
+
if (!fn) {
|
|
796
|
+
throw new CommandNotFoundError(command);
|
|
797
|
+
}
|
|
798
|
+
return fn(...args);
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
const createMockRpc = ({
|
|
802
|
+
commandMap
|
|
803
|
+
}) => {
|
|
804
|
+
const invocations = [];
|
|
805
|
+
const invoke = (method, ...params) => {
|
|
806
|
+
invocations.push([method, ...params]);
|
|
807
|
+
const command = commandMap[method];
|
|
808
|
+
if (!command) {
|
|
809
|
+
throw new Error(`command ${method} not found`);
|
|
810
|
+
}
|
|
811
|
+
return command(...params);
|
|
812
|
+
};
|
|
813
|
+
const mockRpc = {
|
|
814
|
+
invocations,
|
|
815
|
+
invoke,
|
|
816
|
+
invokeAndTransfer: invoke
|
|
817
|
+
};
|
|
818
|
+
return mockRpc;
|
|
819
|
+
};
|
|
783
820
|
|
|
784
821
|
const rpcs$2 = Object.create(null);
|
|
785
|
-
const set$
|
|
822
|
+
const set$c = (id, rpc) => {
|
|
786
823
|
rpcs$2[id] = rpc;
|
|
787
824
|
};
|
|
788
825
|
const get$b = id => {
|
|
789
826
|
return rpcs$2[id];
|
|
790
827
|
};
|
|
828
|
+
const remove$5 = id => {
|
|
829
|
+
delete rpcs$2[id];
|
|
830
|
+
};
|
|
791
831
|
|
|
792
|
-
|
|
832
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
833
|
+
const create$k = rpcId => {
|
|
793
834
|
return {
|
|
794
835
|
async dispose() {
|
|
795
836
|
const rpc = get$b(rpcId);
|
|
@@ -807,1624 +848,1597 @@ const create$b = rpcId => {
|
|
|
807
848
|
// @ts-ignore
|
|
808
849
|
return rpc.invokeAndTransfer(method, ...params);
|
|
809
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
|
+
},
|
|
810
863
|
set(rpc) {
|
|
811
|
-
set$
|
|
864
|
+
set$c(rpcId, rpc);
|
|
812
865
|
}
|
|
813
866
|
};
|
|
814
867
|
};
|
|
815
868
|
|
|
869
|
+
const DebugWorker$1 = 55;
|
|
870
|
+
const ExtensionManagementWorker = 9006;
|
|
871
|
+
const RendererWorker$1 = 1;
|
|
872
|
+
|
|
816
873
|
const {
|
|
817
|
-
|
|
818
|
-
invoke: invoke$6,
|
|
819
|
-
invokeAndTransfer: invokeAndTransfer$4,
|
|
820
|
-
set: set$c
|
|
821
|
-
} = create$b(DebugWorker$1);
|
|
874
|
+
invoke: invoke$6} = create$k(DebugWorker$1);
|
|
822
875
|
|
|
823
876
|
const DebugWorker = {
|
|
824
877
|
__proto__: null,
|
|
825
|
-
|
|
826
|
-
invoke: invoke$6,
|
|
827
|
-
invokeAndTransfer: invokeAndTransfer$4,
|
|
828
|
-
set: set$c
|
|
878
|
+
invoke: invoke$6
|
|
829
879
|
};
|
|
830
880
|
|
|
831
|
-
const
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
881
|
+
const {
|
|
882
|
+
invoke: invoke$5,
|
|
883
|
+
invokeAndTransfer: invokeAndTransfer$3,
|
|
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);
|
|
836
898
|
};
|
|
837
|
-
const
|
|
838
|
-
|
|
899
|
+
const sendMessagePortToIframeWorker = async (port, rpcId) => {
|
|
900
|
+
const command = 'Iframes.handleMessagePort';
|
|
901
|
+
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToIframeWorker', port, command, rpcId);
|
|
839
902
|
};
|
|
840
|
-
const
|
|
841
|
-
|
|
903
|
+
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
904
|
+
const command = 'Extensions.handleMessagePort';
|
|
905
|
+
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
842
906
|
};
|
|
843
|
-
|
|
844
|
-
|
|
907
|
+
|
|
908
|
+
const {
|
|
909
|
+
invoke: invoke$2
|
|
910
|
+
} = DebugWorker;
|
|
911
|
+
|
|
912
|
+
const state$8 = {
|
|
913
|
+
debugProviderMap: Object.create(null)
|
|
845
914
|
};
|
|
846
|
-
const
|
|
847
|
-
const
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
}
|
|
915
|
+
const getDebugProvider = id => {
|
|
916
|
+
const provider = state$8.debugProviderMap[id];
|
|
917
|
+
if (!provider) {
|
|
918
|
+
// @ts-ignore
|
|
919
|
+
throw new VError(`no debug provider "${id}" found`);
|
|
852
920
|
}
|
|
853
|
-
return
|
|
921
|
+
return provider;
|
|
854
922
|
};
|
|
855
|
-
const
|
|
856
|
-
if (!
|
|
857
|
-
|
|
858
|
-
}
|
|
859
|
-
if (isTransferrable(value)) {
|
|
860
|
-
transferrables.push(value);
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
if (Array.isArray(value)) {
|
|
864
|
-
for (const item of value) {
|
|
865
|
-
walkValue(item, transferrables, isTransferrable);
|
|
866
|
-
}
|
|
867
|
-
return;
|
|
868
|
-
}
|
|
869
|
-
if (typeof value === 'object') {
|
|
870
|
-
for (const property of Object.values(value)) {
|
|
871
|
-
walkValue(property, transferrables, isTransferrable);
|
|
872
|
-
}
|
|
873
|
-
return;
|
|
923
|
+
const registerDebugProvider = debugProvider => {
|
|
924
|
+
if (!debugProvider.id) {
|
|
925
|
+
throw new Error('Failed to register debug system provider: missing id');
|
|
874
926
|
}
|
|
927
|
+
state$8.debugProviderMap[debugProvider.id] = debugProvider;
|
|
875
928
|
};
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
return transferrables;
|
|
929
|
+
const handlePaused = async params => {
|
|
930
|
+
// @ts-ignore
|
|
931
|
+
await invoke$2('Debug.paused', params);
|
|
880
932
|
};
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
885
|
-
data
|
|
886
|
-
}));
|
|
887
|
-
};
|
|
888
|
-
that.onMessage(handleMessage);
|
|
889
|
-
const handleClose = event => {
|
|
890
|
-
that.dispatchEvent(new Event('close'));
|
|
891
|
-
};
|
|
892
|
-
that.onClose(handleClose);
|
|
933
|
+
const handleResumed = async () => {
|
|
934
|
+
// @ts-ignore
|
|
935
|
+
await invoke$2('Debug.resumed');
|
|
893
936
|
};
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
this._rawIpc = rawIpc;
|
|
898
|
-
attachEvents(this);
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
902
|
-
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
903
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
904
|
-
const NewLine$2 = '\n';
|
|
905
|
-
const joinLines$1 = lines => {
|
|
906
|
-
return lines.join(NewLine$2);
|
|
937
|
+
const handleScriptParsed = async parsedScript => {
|
|
938
|
+
// @ts-ignore
|
|
939
|
+
await invoke$2('Debug.scriptParsed', parsedScript);
|
|
907
940
|
};
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
941
|
+
const handleChange = async params => {
|
|
942
|
+
object(params);
|
|
943
|
+
// @ts-ignore
|
|
944
|
+
await invoke$2('Debug.handleChange', params);
|
|
912
945
|
};
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
946
|
+
const start = async (protocol, path) => {
|
|
947
|
+
try {
|
|
948
|
+
const provider = getDebugProvider(protocol);
|
|
949
|
+
const emitter = {
|
|
950
|
+
handleChange,
|
|
951
|
+
handlePaused,
|
|
952
|
+
handleResumed,
|
|
953
|
+
handleScriptParsed
|
|
919
954
|
};
|
|
955
|
+
await provider.start(emitter, path);
|
|
956
|
+
} catch (error) {
|
|
957
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
920
958
|
}
|
|
921
|
-
let lastIndex = index - 1;
|
|
922
|
-
while (++lastIndex < lines.length) {
|
|
923
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
924
|
-
break;
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
return {
|
|
928
|
-
actualMessage: lines[index - 1],
|
|
929
|
-
rest: lines.slice(index, lastIndex)
|
|
930
|
-
};
|
|
931
|
-
};
|
|
932
|
-
const splitLines$2 = lines => {
|
|
933
|
-
return lines.split(NewLine$2);
|
|
934
|
-
};
|
|
935
|
-
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
936
|
-
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
937
|
-
const isMessageCodeBlockStartIndex = line => {
|
|
938
|
-
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
939
|
-
};
|
|
940
|
-
const isMessageCodeBlockEndIndex = line => {
|
|
941
|
-
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
942
|
-
};
|
|
943
|
-
const getMessageCodeBlock = stderr => {
|
|
944
|
-
const lines = splitLines$2(stderr);
|
|
945
|
-
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
946
|
-
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
947
|
-
const relevantLines = lines.slice(startIndex, endIndex);
|
|
948
|
-
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
949
|
-
return relevantMessage;
|
|
950
959
|
};
|
|
951
|
-
const
|
|
952
|
-
|
|
960
|
+
const listProcesses = async (protocol, path) => {
|
|
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');
|
|
968
|
+
}
|
|
953
969
|
};
|
|
954
|
-
const
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
};
|
|
970
|
+
const resume = async protocol => {
|
|
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');
|
|
976
|
+
}
|
|
962
977
|
};
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
-
|
|
978
|
+
const pause = async protocol => {
|
|
979
|
+
try {
|
|
980
|
+
const provider = getDebugProvider(protocol);
|
|
981
|
+
return await provider.pause();
|
|
982
|
+
} catch (error) {
|
|
983
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
966
984
|
}
|
|
967
|
-
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
968
985
|
};
|
|
969
|
-
const
|
|
970
|
-
|
|
971
|
-
|
|
986
|
+
const getScriptSource = async (protocol, scriptId) => {
|
|
987
|
+
try {
|
|
988
|
+
const provider = getDebugProvider(protocol);
|
|
989
|
+
return await provider.getScriptSource(scriptId);
|
|
990
|
+
} catch (error) {
|
|
991
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
972
992
|
}
|
|
973
|
-
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
974
993
|
};
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
const
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
};
|
|
994
|
+
|
|
995
|
+
// TODO create direct connection from debug worker to extension, not needing extension host worker apis
|
|
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
|
+
}
|
|
986
1004
|
};
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
}
|
|
1005
|
+
const getCallStack = async protocol => {
|
|
1006
|
+
try {
|
|
1007
|
+
const provider = getDebugProvider(protocol);
|
|
1008
|
+
return await provider.getCallStack();
|
|
1009
|
+
} catch (error) {
|
|
1010
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
1011
|
+
}
|
|
992
1012
|
};
|
|
993
|
-
const
|
|
994
|
-
|
|
995
|
-
|
|
1013
|
+
const getScopeChain = async protocol => {
|
|
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');
|
|
996
1019
|
}
|
|
997
|
-
|
|
998
|
-
|
|
1020
|
+
};
|
|
1021
|
+
const getScripts = async protocol => {
|
|
1022
|
+
try {
|
|
1023
|
+
const provider = getDebugProvider(protocol);
|
|
1024
|
+
return await provider.getScripts();
|
|
1025
|
+
} catch (error) {
|
|
1026
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
999
1027
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1028
|
+
};
|
|
1029
|
+
const getPausedStatus = async protocol => {
|
|
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');
|
|
1002
1035
|
}
|
|
1003
|
-
const lines = splitLines$2(stderr);
|
|
1004
|
-
const {
|
|
1005
|
-
actualMessage,
|
|
1006
|
-
rest
|
|
1007
|
-
} = getDetails(lines);
|
|
1008
|
-
return {
|
|
1009
|
-
code: '',
|
|
1010
|
-
message: actualMessage,
|
|
1011
|
-
stack: rest
|
|
1012
|
-
};
|
|
1013
1036
|
};
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
code,
|
|
1021
|
-
message,
|
|
1022
|
-
stack
|
|
1023
|
-
} = getHelpfulChildProcessError(stdout, stderr);
|
|
1024
|
-
const cause = new Error(message);
|
|
1025
|
-
// @ts-ignore
|
|
1026
|
-
cause.code = code;
|
|
1027
|
-
cause.stack = stack;
|
|
1028
|
-
super(cause, betterMessage);
|
|
1029
|
-
} else {
|
|
1030
|
-
super(betterMessage);
|
|
1031
|
-
}
|
|
1032
|
-
// @ts-ignore
|
|
1033
|
-
this.name = 'IpcError';
|
|
1034
|
-
// @ts-ignore
|
|
1035
|
-
this.stdout = stdout;
|
|
1036
|
-
// @ts-ignore
|
|
1037
|
-
this.stderr = stderr;
|
|
1037
|
+
const stepInto = async protocol => {
|
|
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');
|
|
1038
1043
|
}
|
|
1039
|
-
}
|
|
1040
|
-
const readyMessage = 'ready';
|
|
1041
|
-
const getData$2 = event => {
|
|
1042
|
-
return event.data;
|
|
1043
1044
|
};
|
|
1044
|
-
const
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1045
|
+
const stepOut = async protocol => {
|
|
1046
|
+
try {
|
|
1047
|
+
const provider = getDebugProvider(protocol);
|
|
1048
|
+
return await provider.stepOut();
|
|
1049
|
+
} catch (error) {
|
|
1050
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
1051
|
+
}
|
|
1048
1052
|
};
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1053
|
+
const stepOver = async protocol => {
|
|
1054
|
+
try {
|
|
1055
|
+
const provider = getDebugProvider(protocol);
|
|
1056
|
+
return await provider.stepOver();
|
|
1057
|
+
} catch (error) {
|
|
1058
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
1059
|
+
}
|
|
1051
1060
|
};
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1061
|
+
const setPauseOnException = async (protocol, value) => {
|
|
1062
|
+
try {
|
|
1063
|
+
const provider = getDebugProvider(protocol);
|
|
1064
|
+
return await provider.setPauseOnExceptions(value);
|
|
1065
|
+
} catch (error) {
|
|
1066
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
1055
1067
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1068
|
+
};
|
|
1069
|
+
const getProperties = async (protocol, objectId) => {
|
|
1070
|
+
try {
|
|
1071
|
+
const provider = getDebugProvider(protocol);
|
|
1072
|
+
return await provider.getProperties(objectId);
|
|
1073
|
+
} catch (error) {
|
|
1074
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
1058
1075
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1076
|
+
};
|
|
1077
|
+
const evaluate = async (protocol, expression, callFrameId) => {
|
|
1078
|
+
try {
|
|
1079
|
+
const provider = getDebugProvider(protocol);
|
|
1080
|
+
return await provider.evaluate(expression, callFrameId);
|
|
1081
|
+
} catch (error) {
|
|
1082
|
+
throw new VError(error, 'Failed to execute debug provider');
|
|
1062
1083
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1084
|
+
};
|
|
1085
|
+
const setPauseOnExceptions = async (protocol, value) => {
|
|
1086
|
+
try {
|
|
1087
|
+
const provider = getDebugProvider(protocol);
|
|
1088
|
+
return await provider.setPauseOnExceptions(value);
|
|
1089
|
+
} catch (error) {
|
|
1090
|
+
throw new VError(error, 'Failed to execute setPauseOnExceptions');
|
|
1065
1091
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
const {
|
|
1095
|
+
executeDefinitionProvider,
|
|
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
|
|
1068
1112
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
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
|
|
1072
1125
|
}
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
const RendererWorker = 1;
|
|
1129
|
+
|
|
1130
|
+
const invoke$1 = (method, ...params) => {
|
|
1131
|
+
const rpc = get$b(RendererWorker);
|
|
1132
|
+
return rpc.invoke(method, ...params);
|
|
1076
1133
|
};
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
signal: signal$9,
|
|
1081
|
-
wrap: wrap$g
|
|
1134
|
+
const invokeAndTransfer$1 = (method, ...params) => {
|
|
1135
|
+
const rpc = get$b(RendererWorker);
|
|
1136
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1082
1137
|
};
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
return globalThis;
|
|
1138
|
+
|
|
1139
|
+
const showInformationMessage = message => {
|
|
1140
|
+
string(message);
|
|
1141
|
+
const result = invoke$1('ExtensionHostDialog.showInformationMessage', message);
|
|
1142
|
+
return result;
|
|
1089
1143
|
};
|
|
1090
|
-
|
|
1091
|
-
|
|
1144
|
+
|
|
1145
|
+
const env = {};
|
|
1146
|
+
|
|
1147
|
+
const exec = async (command, args, options) => {
|
|
1148
|
+
throw new DepecratedError(`vscode.exec is deprecated, use createNodeRpc instead`);
|
|
1092
1149
|
};
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
// @ts-ignore
|
|
1099
|
-
this._rawIpc.postMessage(message);
|
|
1100
|
-
}
|
|
1101
|
-
sendAndTransfer(message) {
|
|
1102
|
-
const transfer = getTransferrables(message);
|
|
1150
|
+
|
|
1151
|
+
const fileSystemProviderMap = Object.create(null);
|
|
1152
|
+
const get$a = protocol => {
|
|
1153
|
+
const provider = fileSystemProviderMap[protocol];
|
|
1154
|
+
if (!provider) {
|
|
1103
1155
|
// @ts-ignore
|
|
1104
|
-
|
|
1105
|
-
}
|
|
1106
|
-
dispose() {
|
|
1107
|
-
// ignore
|
|
1156
|
+
throw new VError(`no file system provider for protocol "${protocol}" found`);
|
|
1108
1157
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1158
|
+
return provider;
|
|
1159
|
+
};
|
|
1160
|
+
const set$9 = (id, provider) => {
|
|
1161
|
+
if (!id) {
|
|
1162
|
+
throw new Error('Failed to register file system provider: missing id');
|
|
1111
1163
|
}
|
|
1112
|
-
|
|
1113
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
const wrap$f = global => {
|
|
1117
|
-
return new IpcChildWithModuleWorker(global);
|
|
1118
|
-
};
|
|
1119
|
-
const waitForFirstMessage = async port => {
|
|
1120
|
-
const {
|
|
1121
|
-
promise,
|
|
1122
|
-
resolve
|
|
1123
|
-
} = Promise.withResolvers();
|
|
1124
|
-
port.addEventListener('message', resolve, {
|
|
1125
|
-
once: true
|
|
1126
|
-
});
|
|
1127
|
-
const event = await promise;
|
|
1128
|
-
// @ts-ignore
|
|
1129
|
-
return event.data;
|
|
1164
|
+
fileSystemProviderMap[id] = provider;
|
|
1130
1165
|
};
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
1136
|
-
if (firstMessage.method !== 'initialize') {
|
|
1137
|
-
throw new IpcError('unexpected first message');
|
|
1138
|
-
}
|
|
1139
|
-
const type = firstMessage.params[0];
|
|
1140
|
-
if (type === 'message-port') {
|
|
1141
|
-
parentIpc.send({
|
|
1142
|
-
id: firstMessage.id,
|
|
1143
|
-
jsonrpc: '2.0',
|
|
1144
|
-
result: null
|
|
1145
|
-
});
|
|
1146
|
-
parentIpc.dispose();
|
|
1147
|
-
const port = firstMessage.params[1];
|
|
1148
|
-
return port;
|
|
1166
|
+
|
|
1167
|
+
const registerFileSystemProvider = fileSystemProvider => {
|
|
1168
|
+
if (!fileSystemProvider.id) {
|
|
1169
|
+
throw new Error('Failed to register file system provider: missing id');
|
|
1149
1170
|
}
|
|
1150
|
-
|
|
1171
|
+
set$9(fileSystemProvider.id, fileSystemProvider);
|
|
1151
1172
|
};
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
}
|
|
1159
|
-
sendAndTransfer(message) {
|
|
1160
|
-
const transfer = getTransferrables(message);
|
|
1161
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1162
|
-
}
|
|
1163
|
-
dispose() {
|
|
1164
|
-
if (this._rawIpc.close) {
|
|
1165
|
-
this._rawIpc.close();
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
onClose(callback) {
|
|
1169
|
-
// ignore
|
|
1170
|
-
}
|
|
1171
|
-
onMessage(callback) {
|
|
1172
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1173
|
-
this._rawIpc.start();
|
|
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');
|
|
1174
1179
|
}
|
|
1175
|
-
}
|
|
1176
|
-
const wrap$e = port => {
|
|
1177
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
1178
1180
|
};
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
const Open = 2;
|
|
1186
|
-
const Close = 3;
|
|
1187
|
-
const addListener = (emitter, type, callback) => {
|
|
1188
|
-
if ('addEventListener' in emitter) {
|
|
1189
|
-
emitter.addEventListener(type, callback);
|
|
1190
|
-
} else {
|
|
1191
|
-
emitter.on(type, callback);
|
|
1181
|
+
const readFile$2 = async (protocol, path) => {
|
|
1182
|
+
try {
|
|
1183
|
+
const provider = get$a(protocol);
|
|
1184
|
+
return await provider.readFile(path);
|
|
1185
|
+
} catch (error) {
|
|
1186
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
1192
1187
|
}
|
|
1193
1188
|
};
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1189
|
+
const mkdir$2 = async (protocol, path) => {
|
|
1190
|
+
try {
|
|
1191
|
+
const provider = get$a(protocol);
|
|
1192
|
+
return await provider.mkdir(path);
|
|
1193
|
+
} catch (error) {
|
|
1194
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
1199
1195
|
}
|
|
1200
1196
|
};
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
}
|
|
1211
|
-
resolve(value);
|
|
1212
|
-
};
|
|
1213
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
1214
|
-
const listener = event => {
|
|
1215
|
-
cleanup({
|
|
1216
|
-
event,
|
|
1217
|
-
type
|
|
1218
|
-
});
|
|
1219
|
-
};
|
|
1220
|
-
addListener(eventEmitter, event, listener);
|
|
1221
|
-
listenerMap[event] = listener;
|
|
1222
|
-
}
|
|
1223
|
-
return promise;
|
|
1197
|
+
const readFileExternal = async path => {
|
|
1198
|
+
// TODO when file is local,
|
|
1199
|
+
// don't ask renderer worker
|
|
1200
|
+
// instead read file directly from shared process
|
|
1201
|
+
// this avoid parsing the potentially large message
|
|
1202
|
+
// and improve performance by not blocking the renderer worker
|
|
1203
|
+
// when reading / writing large files
|
|
1204
|
+
const content = await invoke$1('FileSystem.readFile', path);
|
|
1205
|
+
return content;
|
|
1224
1206
|
};
|
|
1225
|
-
const
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1228
|
-
messagePort
|
|
1229
|
-
}) => {
|
|
1230
|
-
if (!isMessagePort(messagePort)) {
|
|
1231
|
-
throw new IpcError('port must be of type MessagePort');
|
|
1232
|
-
}
|
|
1233
|
-
if (isMessagePortOpen) {
|
|
1234
|
-
return messagePort;
|
|
1235
|
-
}
|
|
1236
|
-
const eventPromise = getFirstEvent(messagePort, {
|
|
1237
|
-
message: Message$1
|
|
1238
|
-
});
|
|
1239
|
-
messagePort.start();
|
|
1240
|
-
const {
|
|
1241
|
-
event,
|
|
1242
|
-
type
|
|
1243
|
-
} = await eventPromise;
|
|
1244
|
-
if (type !== Message$1) {
|
|
1245
|
-
throw new IpcError('Failed to wait for ipc message');
|
|
1246
|
-
}
|
|
1247
|
-
if (event.data !== readyMessage) {
|
|
1248
|
-
throw new IpcError('unexpected first message');
|
|
1249
|
-
}
|
|
1250
|
-
return messagePort;
|
|
1207
|
+
const removeExternal = async path => {
|
|
1208
|
+
const content = await invoke$1('FileSystem.remove', path);
|
|
1209
|
+
return content;
|
|
1251
1210
|
};
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1211
|
+
const existsExternal = async uri => {
|
|
1212
|
+
return await invoke$1('FileSystem.exists', uri);
|
|
1254
1213
|
};
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
send(message) {
|
|
1258
|
-
this._rawIpc.postMessage(message);
|
|
1259
|
-
}
|
|
1260
|
-
sendAndTransfer(message) {
|
|
1261
|
-
const transfer = getTransferrables(message);
|
|
1262
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1263
|
-
}
|
|
1264
|
-
dispose() {
|
|
1265
|
-
this._rawIpc.close();
|
|
1266
|
-
}
|
|
1267
|
-
onMessage(callback) {
|
|
1268
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1269
|
-
}
|
|
1270
|
-
onClose(callback) {}
|
|
1271
|
-
}
|
|
1272
|
-
const wrap$5 = messagePort => {
|
|
1273
|
-
return new IpcParentWithMessagePort(messagePort);
|
|
1214
|
+
const mkdirExternal = async uri => {
|
|
1215
|
+
return await invoke$1('FileSystem.mkdir', uri);
|
|
1274
1216
|
};
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
create: create$5$2,
|
|
1278
|
-
signal: signal$1,
|
|
1279
|
-
wrap: wrap$5
|
|
1217
|
+
const writeFileExternal = async (uri, content) => {
|
|
1218
|
+
return await invoke$1('FileSystem.writeFile', uri, content);
|
|
1280
1219
|
};
|
|
1281
|
-
const
|
|
1282
|
-
return
|
|
1220
|
+
const statExternal = async uri => {
|
|
1221
|
+
return await invoke$1('FileSystem.stat', uri);
|
|
1283
1222
|
};
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1223
|
+
const readDirWithFileTypesExternal = async path => {
|
|
1224
|
+
// TODO when file is local,
|
|
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;
|
|
1232
|
+
};
|
|
1233
|
+
const remove$4 = async (protocol, path) => {
|
|
1288
1234
|
try {
|
|
1289
|
-
|
|
1235
|
+
const provider = get$a(protocol);
|
|
1236
|
+
return await provider.remove(path);
|
|
1290
1237
|
} catch (error) {
|
|
1291
|
-
throw new VError(error, '
|
|
1238
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
1292
1239
|
}
|
|
1293
1240
|
};
|
|
1294
|
-
const
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
};
|
|
1301
|
-
const create$a = async ({
|
|
1302
|
-
webSocket
|
|
1303
|
-
}) => {
|
|
1304
|
-
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
1305
|
-
if (firstWebSocketEvent.type === Error$3) {
|
|
1306
|
-
throw new IpcError(`WebSocket connection error`);
|
|
1307
|
-
}
|
|
1308
|
-
if (firstWebSocketEvent.type === Close) {
|
|
1309
|
-
throw new IpcError('Websocket connection was immediately closed');
|
|
1241
|
+
const rename$1 = async (protocol, oldUri, newUri) => {
|
|
1242
|
+
try {
|
|
1243
|
+
const provider = get$a(protocol);
|
|
1244
|
+
return await provider.rename(oldUri, newUri);
|
|
1245
|
+
} catch (error) {
|
|
1246
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
1310
1247
|
}
|
|
1311
|
-
return webSocket;
|
|
1312
1248
|
};
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1249
|
+
const writeFile$3 = async (protocol, uri, content) => {
|
|
1250
|
+
try {
|
|
1251
|
+
const provider = get$a(protocol);
|
|
1252
|
+
return await provider.writeFile(uri, content);
|
|
1253
|
+
} catch (error) {
|
|
1254
|
+
throw new VError(error, 'Failed to execute file system provider');
|
|
1319
1255
|
}
|
|
1320
|
-
|
|
1321
|
-
|
|
1256
|
+
};
|
|
1257
|
+
const getPathSeparator = protocol => {
|
|
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');
|
|
1322
1263
|
}
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
const {
|
|
1267
|
+
executeFormattingProvider,
|
|
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
|
|
1328
1288
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
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;
|
|
1331
1297
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
return new IpcParentWithWebSocket$1(webSocket);
|
|
1335
|
-
};
|
|
1336
|
-
const IpcParentWithWebSocket$1$1 = {
|
|
1337
|
-
__proto__: null,
|
|
1338
|
-
create: create$a,
|
|
1339
|
-
wrap: wrap$1
|
|
1298
|
+
offset += position.columnIndex;
|
|
1299
|
+
return offset;
|
|
1340
1300
|
};
|
|
1341
1301
|
|
|
1342
|
-
const
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
super(message);
|
|
1353
|
-
this.name = 'JsonRpcError';
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
const NewLine$1 = '\n';
|
|
1357
|
-
const DomException = 'DOMException';
|
|
1358
|
-
const ReferenceError$1 = 'ReferenceError';
|
|
1359
|
-
const SyntaxError$1 = 'SyntaxError';
|
|
1360
|
-
const TypeError$1 = 'TypeError';
|
|
1361
|
-
const getErrorConstructor = (message, type) => {
|
|
1362
|
-
if (type) {
|
|
1363
|
-
switch (type) {
|
|
1364
|
-
case DomException:
|
|
1365
|
-
return DOMException;
|
|
1366
|
-
case TypeError$1:
|
|
1367
|
-
return TypeError;
|
|
1368
|
-
case SyntaxError$1:
|
|
1369
|
-
return SyntaxError;
|
|
1370
|
-
case ReferenceError$1:
|
|
1371
|
-
return ReferenceError;
|
|
1372
|
-
default:
|
|
1373
|
-
return Error;
|
|
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;
|
|
1374
1312
|
}
|
|
1313
|
+
const newIndex = newLineIndex + 1;
|
|
1314
|
+
if (newIndex > offset) {
|
|
1315
|
+
break;
|
|
1316
|
+
}
|
|
1317
|
+
index = newIndex;
|
|
1318
|
+
rowIndex++;
|
|
1375
1319
|
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
}
|
|
1382
|
-
if (message.startsWith('ReferenceError: ')) {
|
|
1383
|
-
return ReferenceError;
|
|
1384
|
-
}
|
|
1385
|
-
return Error;
|
|
1320
|
+
const columnIndex = offset - index;
|
|
1321
|
+
return {
|
|
1322
|
+
columnIndex,
|
|
1323
|
+
rowIndex
|
|
1324
|
+
};
|
|
1386
1325
|
};
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1326
|
+
|
|
1327
|
+
const {
|
|
1328
|
+
executeHoverProvider,
|
|
1329
|
+
registerHoverProvider} = create$l({
|
|
1330
|
+
name: 'Hover',
|
|
1331
|
+
resultShape: {
|
|
1332
|
+
allowUndefined: true,
|
|
1333
|
+
properties: {},
|
|
1334
|
+
type: Object$1
|
|
1391
1335
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
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
|
|
1398
1347
|
}
|
|
1399
|
-
|
|
1348
|
+
});
|
|
1349
|
+
|
|
1350
|
+
const WebSocket$1 = 5;
|
|
1351
|
+
const ElectronMessagePort = 6;
|
|
1352
|
+
const ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1 = 7;
|
|
1353
|
+
|
|
1354
|
+
const isMessagePort = value => {
|
|
1355
|
+
return value && value instanceof MessagePort;
|
|
1400
1356
|
};
|
|
1401
|
-
const
|
|
1402
|
-
return
|
|
1357
|
+
const isMessagePortMain = value => {
|
|
1358
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
1403
1359
|
};
|
|
1404
|
-
const
|
|
1405
|
-
return
|
|
1360
|
+
const isOffscreenCanvas = value => {
|
|
1361
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
1406
1362
|
};
|
|
1407
|
-
const
|
|
1408
|
-
|
|
1409
|
-
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(stackLinesToSkip));
|
|
1410
|
-
return currentStack;
|
|
1363
|
+
const isInstanceOf = (value, constructorName) => {
|
|
1364
|
+
return value?.constructor?.name === constructorName;
|
|
1411
1365
|
};
|
|
1412
|
-
const
|
|
1413
|
-
return
|
|
1366
|
+
const isSocket = value => {
|
|
1367
|
+
return isInstanceOf(value, 'Socket');
|
|
1414
1368
|
};
|
|
1415
|
-
const
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1369
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
1370
|
+
const isTransferrable = value => {
|
|
1371
|
+
for (const fn of transferrables) {
|
|
1372
|
+
if (fn(value)) {
|
|
1373
|
+
return true;
|
|
1374
|
+
}
|
|
1419
1375
|
}
|
|
1420
|
-
return
|
|
1376
|
+
return false;
|
|
1421
1377
|
};
|
|
1422
|
-
const
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
const currentStack = getCurrentStack();
|
|
1426
|
-
if (error && error instanceof Error) {
|
|
1427
|
-
if (typeof error.stack === 'string') {
|
|
1428
|
-
error.stack = error.stack + NewLine$1 + currentStack;
|
|
1429
|
-
}
|
|
1430
|
-
return error;
|
|
1378
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
1379
|
+
if (!value) {
|
|
1380
|
+
return;
|
|
1431
1381
|
}
|
|
1432
|
-
if (
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
restoredError.stack = parentStack + NewLine$1 + currentStack;
|
|
1436
|
-
return restoredError;
|
|
1382
|
+
if (isTransferrable(value)) {
|
|
1383
|
+
transferrables.push(value);
|
|
1384
|
+
return;
|
|
1437
1385
|
}
|
|
1438
|
-
if (
|
|
1439
|
-
const
|
|
1440
|
-
|
|
1441
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
1442
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine$1 + error.data.stack + NewLine$1 + currentStack;
|
|
1443
|
-
} else if (error.data.stack) {
|
|
1444
|
-
restoredError.stack = error.data.stack;
|
|
1445
|
-
}
|
|
1446
|
-
if (error.data.codeFrame) {
|
|
1447
|
-
// @ts-ignore
|
|
1448
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
1449
|
-
}
|
|
1450
|
-
if (error.data.code) {
|
|
1451
|
-
// @ts-ignore
|
|
1452
|
-
restoredError.code = error.data.code;
|
|
1453
|
-
}
|
|
1454
|
-
if (error.data.type) {
|
|
1455
|
-
// @ts-ignore
|
|
1456
|
-
restoredError.name = error.data.type;
|
|
1457
|
-
}
|
|
1458
|
-
} else {
|
|
1459
|
-
if (error.stack) {
|
|
1460
|
-
const lowerStack = restoredError.stack || '';
|
|
1461
|
-
// @ts-ignore
|
|
1462
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
1463
|
-
const parentStack = getParentStack(error);
|
|
1464
|
-
// @ts-ignore
|
|
1465
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
1466
|
-
}
|
|
1467
|
-
if (error.codeFrame) {
|
|
1468
|
-
// @ts-ignore
|
|
1469
|
-
restoredError.codeFrame = error.codeFrame;
|
|
1470
|
-
}
|
|
1386
|
+
if (Array.isArray(value)) {
|
|
1387
|
+
for (const item of value) {
|
|
1388
|
+
walkValue(item, transferrables, isTransferrable);
|
|
1471
1389
|
}
|
|
1472
|
-
return
|
|
1473
|
-
}
|
|
1474
|
-
if (typeof error === 'string') {
|
|
1475
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
1476
|
-
}
|
|
1477
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
1478
|
-
};
|
|
1479
|
-
const unwrapJsonRpcResult = responseMessage => {
|
|
1480
|
-
if ('error' in responseMessage) {
|
|
1481
|
-
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
1482
|
-
throw restoredError;
|
|
1390
|
+
return;
|
|
1483
1391
|
}
|
|
1484
|
-
if ('
|
|
1485
|
-
|
|
1392
|
+
if (typeof value === 'object') {
|
|
1393
|
+
for (const property of Object.values(value)) {
|
|
1394
|
+
walkValue(property, transferrables, isTransferrable);
|
|
1395
|
+
}
|
|
1396
|
+
return;
|
|
1486
1397
|
}
|
|
1487
|
-
throw new JsonRpcError('unexpected response message');
|
|
1488
1398
|
};
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1399
|
+
const getTransferrables = value => {
|
|
1400
|
+
const transferrables = [];
|
|
1401
|
+
walkValue(value, transferrables, isTransferrable);
|
|
1402
|
+
return transferrables;
|
|
1491
1403
|
};
|
|
1492
|
-
const
|
|
1493
|
-
const
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1404
|
+
const attachEvents = that => {
|
|
1405
|
+
const handleMessage = (...args) => {
|
|
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);
|
|
1501
1416
|
};
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
1508
|
-
return prettyError.constructor.name;
|
|
1417
|
+
class Ipc extends EventTarget {
|
|
1418
|
+
constructor(rawIpc) {
|
|
1419
|
+
super();
|
|
1420
|
+
this._rawIpc = rawIpc;
|
|
1421
|
+
attachEvents(this);
|
|
1509
1422
|
}
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
const
|
|
1513
|
-
|
|
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);
|
|
1514
1430
|
};
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
return stackString.slice(newLineIndex + 1);
|
|
1520
|
-
}
|
|
1521
|
-
return stackString;
|
|
1431
|
+
const RE_AT = /^\s+at/;
|
|
1432
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
1433
|
+
const isNormalStackLine = line => {
|
|
1434
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
1522
1435
|
};
|
|
1523
|
-
const
|
|
1524
|
-
|
|
1436
|
+
const getDetails = lines => {
|
|
1437
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
1438
|
+
if (index === -1) {
|
|
1525
1439
|
return {
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
data: error.stack
|
|
1440
|
+
actualMessage: joinLines$1(lines),
|
|
1441
|
+
rest: []
|
|
1529
1442
|
};
|
|
1530
1443
|
}
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
stack: getStack(prettyError),
|
|
1536
|
-
codeFrame: prettyError.codeFrame,
|
|
1537
|
-
type: getErrorType(prettyError),
|
|
1538
|
-
code: prettyError.code,
|
|
1539
|
-
name: prettyError.name
|
|
1444
|
+
let lastIndex = index - 1;
|
|
1445
|
+
while (++lastIndex < lines.length) {
|
|
1446
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
1447
|
+
break;
|
|
1540
1448
|
}
|
|
1541
|
-
}
|
|
1542
|
-
};
|
|
1543
|
-
const create$1$1 = (id, error) => {
|
|
1449
|
+
}
|
|
1544
1450
|
return {
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
error
|
|
1451
|
+
actualMessage: lines[index - 1],
|
|
1452
|
+
rest: lines.slice(index, lastIndex)
|
|
1548
1453
|
};
|
|
1549
1454
|
};
|
|
1550
|
-
const
|
|
1551
|
-
|
|
1552
|
-
logError(error, prettyError);
|
|
1553
|
-
const errorProperty = getErrorProperty(error, prettyError);
|
|
1554
|
-
return create$1$1(id, errorProperty);
|
|
1455
|
+
const splitLines$2 = lines => {
|
|
1456
|
+
return lines.split(NewLine$2);
|
|
1555
1457
|
};
|
|
1556
|
-
const
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
result: result ?? null
|
|
1561
|
-
};
|
|
1458
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
1459
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
1460
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
1461
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
1562
1462
|
};
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1565
|
-
return create$9(message, resultProperty);
|
|
1463
|
+
const isMessageCodeBlockEndIndex = line => {
|
|
1464
|
+
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
1566
1465
|
};
|
|
1567
|
-
const
|
|
1466
|
+
const getMessageCodeBlock = stderr => {
|
|
1467
|
+
const lines = splitLines$2(stderr);
|
|
1468
|
+
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
1469
|
+
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
1470
|
+
const relevantLines = lines.slice(startIndex, endIndex);
|
|
1471
|
+
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
1472
|
+
return relevantMessage;
|
|
1473
|
+
};
|
|
1474
|
+
const isModuleNotFoundMessage = line => {
|
|
1475
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
1476
|
+
};
|
|
1477
|
+
const getModuleNotFoundError = stderr => {
|
|
1478
|
+
const lines = splitLines$2(stderr);
|
|
1479
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1480
|
+
const message = lines[messageIndex];
|
|
1568
1481
|
return {
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
error: {
|
|
1572
|
-
code: Custom,
|
|
1573
|
-
// @ts-ignore
|
|
1574
|
-
message: error.message,
|
|
1575
|
-
data: error
|
|
1576
|
-
}
|
|
1482
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
1483
|
+
message
|
|
1577
1484
|
};
|
|
1578
1485
|
};
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
return getSuccessResponse(message, result);
|
|
1583
|
-
} catch (error) {
|
|
1584
|
-
if (ipc.canUseSimpleErrorResponse) {
|
|
1585
|
-
return getErrorResponseSimple(message.id, error);
|
|
1586
|
-
}
|
|
1587
|
-
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1486
|
+
const isModuleNotFoundError = stderr => {
|
|
1487
|
+
if (!stderr) {
|
|
1488
|
+
return false;
|
|
1588
1489
|
}
|
|
1490
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
1589
1491
|
};
|
|
1590
|
-
const
|
|
1591
|
-
|
|
1492
|
+
const isModulesSyntaxError = stderr => {
|
|
1493
|
+
if (!stderr) {
|
|
1494
|
+
return false;
|
|
1495
|
+
}
|
|
1496
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
1592
1497
|
};
|
|
1593
|
-
const
|
|
1594
|
-
|
|
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);
|
|
1595
1502
|
};
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1503
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
1504
|
+
const message = getMessageCodeBlock(stderr);
|
|
1505
|
+
return {
|
|
1506
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
1507
|
+
message: `Incompatible native node module: ${message}`
|
|
1508
|
+
};
|
|
1598
1509
|
};
|
|
1599
|
-
const
|
|
1600
|
-
|
|
1601
|
-
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
1602
|
-
const normalizeParams = args => {
|
|
1603
|
-
if (args.length === 1) {
|
|
1604
|
-
const options = args[0];
|
|
1605
|
-
return {
|
|
1606
|
-
ipc: options.ipc,
|
|
1607
|
-
message: options.message,
|
|
1608
|
-
execute: options.execute,
|
|
1609
|
-
resolve: options.resolve || defaultResolve,
|
|
1610
|
-
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
1611
|
-
logError: options.logError || defaultLogError,
|
|
1612
|
-
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
1613
|
-
};
|
|
1614
|
-
}
|
|
1510
|
+
const getModuleSyntaxError = () => {
|
|
1615
1511
|
return {
|
|
1616
|
-
|
|
1617
|
-
message:
|
|
1618
|
-
execute: args[2],
|
|
1619
|
-
resolve: args[3],
|
|
1620
|
-
preparePrettyError: args[4],
|
|
1621
|
-
logError: args[5],
|
|
1622
|
-
requiresSocket: args[6]
|
|
1512
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
1513
|
+
message: `ES Modules are not supported in electron`
|
|
1623
1514
|
};
|
|
1624
1515
|
};
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
message,
|
|
1629
|
-
ipc,
|
|
1630
|
-
execute,
|
|
1631
|
-
resolve,
|
|
1632
|
-
preparePrettyError,
|
|
1633
|
-
logError,
|
|
1634
|
-
requiresSocket
|
|
1635
|
-
} = options;
|
|
1636
|
-
if ('id' in message) {
|
|
1637
|
-
if ('method' in message) {
|
|
1638
|
-
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1639
|
-
try {
|
|
1640
|
-
ipc.send(response);
|
|
1641
|
-
} catch (error) {
|
|
1642
|
-
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1643
|
-
ipc.send(errorResponse);
|
|
1644
|
-
}
|
|
1645
|
-
return;
|
|
1646
|
-
}
|
|
1647
|
-
resolve(message.id, message);
|
|
1648
|
-
return;
|
|
1649
|
-
}
|
|
1650
|
-
if ('method' in message) {
|
|
1651
|
-
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1652
|
-
return;
|
|
1516
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
1517
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
1518
|
+
return getNativeModuleErrorMessage(stderr);
|
|
1653
1519
|
}
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
class CommandNotFoundError extends Error {
|
|
1658
|
-
constructor(command) {
|
|
1659
|
-
super(`Command not found ${command}`);
|
|
1660
|
-
this.name = 'CommandNotFoundError';
|
|
1520
|
+
if (isModulesSyntaxError(stderr)) {
|
|
1521
|
+
return getModuleSyntaxError();
|
|
1661
1522
|
}
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
const register$1 = commandMap => {
|
|
1665
|
-
Object.assign(commands, commandMap);
|
|
1666
|
-
};
|
|
1667
|
-
const getCommand = key => {
|
|
1668
|
-
return commands[key];
|
|
1669
|
-
};
|
|
1670
|
-
const execute = (command, ...args) => {
|
|
1671
|
-
const fn = getCommand(command);
|
|
1672
|
-
if (!fn) {
|
|
1673
|
-
throw new CommandNotFoundError(command);
|
|
1523
|
+
if (isModuleNotFoundError(stderr)) {
|
|
1524
|
+
return getModuleNotFoundError(stderr);
|
|
1674
1525
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1526
|
+
const lines = splitLines$2(stderr);
|
|
1527
|
+
const {
|
|
1528
|
+
actualMessage,
|
|
1529
|
+
rest
|
|
1530
|
+
} = getDetails(lines);
|
|
1680
1531
|
return {
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
};
|
|
1685
|
-
};
|
|
1686
|
-
const create$o = (id, method, params) => {
|
|
1687
|
-
const message = {
|
|
1688
|
-
id,
|
|
1689
|
-
jsonrpc: Two,
|
|
1690
|
-
method,
|
|
1691
|
-
params
|
|
1532
|
+
code: '',
|
|
1533
|
+
message: actualMessage,
|
|
1534
|
+
stack: rest
|
|
1692
1535
|
};
|
|
1693
|
-
return message;
|
|
1694
1536
|
};
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
};
|
|
1713
|
-
};
|
|
1714
|
-
|
|
1715
|
-
// @ts-ignore
|
|
1716
|
-
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
1717
|
-
const {
|
|
1718
|
-
id,
|
|
1719
|
-
promise
|
|
1720
|
-
} = registerPromise(callbacks);
|
|
1721
|
-
const message = create$o(id, method, params);
|
|
1722
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1723
|
-
ipc.sendAndTransfer(message);
|
|
1724
|
-
} else {
|
|
1725
|
-
ipc.send(message);
|
|
1726
|
-
}
|
|
1727
|
-
const responseMessage = await promise;
|
|
1728
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
1729
|
-
};
|
|
1730
|
-
const createRpc$1 = ipc => {
|
|
1731
|
-
const callbacks = Object.create(null);
|
|
1732
|
-
ipc._resolve = (id, response) => {
|
|
1733
|
-
const fn = callbacks[id];
|
|
1734
|
-
if (!fn) {
|
|
1735
|
-
console.warn(`callback ${id} may already be disposed`);
|
|
1736
|
-
return;
|
|
1537
|
+
class IpcError extends VError {
|
|
1538
|
+
// @ts-ignore
|
|
1539
|
+
constructor(betterMessage, stdout = '', stderr = '') {
|
|
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);
|
|
1737
1554
|
}
|
|
1738
|
-
fn(response);
|
|
1739
|
-
delete callbacks[id];
|
|
1740
|
-
};
|
|
1741
|
-
const rpc = {
|
|
1742
|
-
async dispose() {
|
|
1743
|
-
await ipc?.dispose();
|
|
1744
|
-
},
|
|
1745
|
-
invoke(method, ...params) {
|
|
1746
|
-
return invokeHelper(callbacks, ipc, method, params, false);
|
|
1747
|
-
},
|
|
1748
|
-
invokeAndTransfer(method, ...params) {
|
|
1749
|
-
return invokeHelper(callbacks, ipc, method, params, true);
|
|
1750
|
-
},
|
|
1751
1555
|
// @ts-ignore
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
return
|
|
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;
|
|
1762
1566
|
};
|
|
1763
|
-
const
|
|
1764
|
-
|
|
1567
|
+
const listen$8 = ({
|
|
1568
|
+
port
|
|
1569
|
+
}) => {
|
|
1570
|
+
return port;
|
|
1765
1571
|
};
|
|
1766
|
-
const
|
|
1767
|
-
|
|
1572
|
+
const signal$9 = port => {
|
|
1573
|
+
port.postMessage(readyMessage);
|
|
1768
1574
|
};
|
|
1769
|
-
|
|
1770
|
-
|
|
1575
|
+
class IpcChildWithMessagePort extends Ipc {
|
|
1576
|
+
getData(event) {
|
|
1577
|
+
return getData$2(event);
|
|
1578
|
+
}
|
|
1579
|
+
send(message) {
|
|
1580
|
+
this._rawIpc.postMessage(message);
|
|
1581
|
+
}
|
|
1582
|
+
sendAndTransfer(message) {
|
|
1583
|
+
const transfer = getTransferrables(message);
|
|
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();
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
const wrap$g = port => {
|
|
1598
|
+
return new IpcChildWithMessagePort(port);
|
|
1771
1599
|
};
|
|
1772
|
-
const
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1600
|
+
const IpcChildWithMessagePort$1 = {
|
|
1601
|
+
__proto__: null,
|
|
1602
|
+
listen: listen$8,
|
|
1603
|
+
signal: signal$9,
|
|
1604
|
+
wrap: wrap$g
|
|
1776
1605
|
};
|
|
1777
|
-
const
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
// deprecated
|
|
1782
|
-
ipc.on('message', handleMessage);
|
|
1606
|
+
const listen$7 = () => {
|
|
1607
|
+
// @ts-ignore
|
|
1608
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
1609
|
+
throw new TypeError('module is not in web worker scope');
|
|
1783
1610
|
}
|
|
1611
|
+
return globalThis;
|
|
1784
1612
|
};
|
|
1785
|
-
const
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1613
|
+
const signal$8 = global => {
|
|
1614
|
+
global.postMessage(readyMessage);
|
|
1615
|
+
};
|
|
1616
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
1617
|
+
getData(event) {
|
|
1618
|
+
return getData$2(event);
|
|
1789
1619
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1620
|
+
send(message) {
|
|
1621
|
+
// @ts-ignore
|
|
1622
|
+
this._rawIpc.postMessage(message);
|
|
1623
|
+
}
|
|
1624
|
+
sendAndTransfer(message) {
|
|
1625
|
+
const transfer = getTransferrables(message);
|
|
1626
|
+
// @ts-ignore
|
|
1627
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1628
|
+
}
|
|
1629
|
+
dispose() {
|
|
1630
|
+
// ignore
|
|
1631
|
+
}
|
|
1632
|
+
onClose(callback) {
|
|
1633
|
+
// ignore
|
|
1634
|
+
}
|
|
1635
|
+
onMessage(callback) {
|
|
1636
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
const wrap$f = global => {
|
|
1640
|
+
return new IpcChildWithModuleWorker(global);
|
|
1792
1641
|
};
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
port: messagePort
|
|
1642
|
+
const waitForFirstMessage = async port => {
|
|
1643
|
+
const {
|
|
1644
|
+
promise,
|
|
1645
|
+
resolve
|
|
1646
|
+
} = Promise.withResolvers();
|
|
1647
|
+
port.addEventListener('message', resolve, {
|
|
1648
|
+
once: true
|
|
1801
1649
|
});
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
return
|
|
1650
|
+
const event = await promise;
|
|
1651
|
+
// @ts-ignore
|
|
1652
|
+
return event.data;
|
|
1805
1653
|
};
|
|
1806
|
-
const
|
|
1807
|
-
|
|
1808
|
-
|
|
1654
|
+
const listen$6 = async () => {
|
|
1655
|
+
const parentIpcRaw = listen$7();
|
|
1656
|
+
signal$8(parentIpcRaw);
|
|
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;
|
|
1809
1674
|
};
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
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();
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
onClose(callback) {
|
|
1692
|
+
// ignore
|
|
1693
|
+
}
|
|
1694
|
+
onMessage(callback) {
|
|
1695
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1696
|
+
this._rawIpc.start();
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
const wrap$e = port => {
|
|
1700
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
1825
1701
|
};
|
|
1826
|
-
const
|
|
1702
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
1827
1703
|
__proto__: null,
|
|
1828
|
-
|
|
1704
|
+
listen: listen$6,
|
|
1705
|
+
wrap: wrap$e
|
|
1829
1706
|
};
|
|
1830
|
-
const
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
messagePort
|
|
1840
|
-
});
|
|
1841
|
-
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1842
|
-
handleIpc(ipc);
|
|
1843
|
-
const rpc = createRpc$1(ipc);
|
|
1844
|
-
messagePort.start();
|
|
1845
|
-
return rpc;
|
|
1707
|
+
const Error$3 = 1;
|
|
1708
|
+
const Open = 2;
|
|
1709
|
+
const Close = 3;
|
|
1710
|
+
const addListener = (emitter, type, callback) => {
|
|
1711
|
+
if ('addEventListener' in emitter) {
|
|
1712
|
+
emitter.addEventListener(type, callback);
|
|
1713
|
+
} else {
|
|
1714
|
+
emitter.on(type, callback);
|
|
1715
|
+
}
|
|
1846
1716
|
};
|
|
1847
|
-
const
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
messagePort
|
|
1854
|
-
});
|
|
1717
|
+
const removeListener = (emitter, type, callback) => {
|
|
1718
|
+
if ('removeEventListener' in emitter) {
|
|
1719
|
+
emitter.removeEventListener(type, callback);
|
|
1720
|
+
} else {
|
|
1721
|
+
emitter.off(type, callback);
|
|
1722
|
+
}
|
|
1855
1723
|
};
|
|
1856
|
-
const
|
|
1857
|
-
|
|
1858
|
-
|
|
1724
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
1725
|
+
const {
|
|
1726
|
+
promise,
|
|
1727
|
+
resolve
|
|
1728
|
+
} = Promise.withResolvers();
|
|
1729
|
+
const listenerMap = Object.create(null);
|
|
1730
|
+
const cleanup = value => {
|
|
1731
|
+
for (const event of Object.keys(eventMap)) {
|
|
1732
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
1733
|
+
}
|
|
1734
|
+
resolve(value);
|
|
1735
|
+
};
|
|
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;
|
|
1859
1747
|
};
|
|
1748
|
+
const Message$1 = 3;
|
|
1860
1749
|
const create$5$1 = async ({
|
|
1861
|
-
commandMap,
|
|
1862
1750
|
isMessagePortOpen,
|
|
1863
|
-
|
|
1751
|
+
messagePort
|
|
1864
1752
|
}) => {
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
messagePort: port2
|
|
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
|
|
1874
1761
|
});
|
|
1762
|
+
messagePort.start();
|
|
1763
|
+
const {
|
|
1764
|
+
event,
|
|
1765
|
+
type
|
|
1766
|
+
} = await eventPromise;
|
|
1767
|
+
if (type !== Message$1) {
|
|
1768
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
1769
|
+
}
|
|
1770
|
+
if (event.data !== readyMessage) {
|
|
1771
|
+
throw new IpcError('unexpected first message');
|
|
1772
|
+
}
|
|
1773
|
+
return messagePort;
|
|
1875
1774
|
};
|
|
1876
|
-
const
|
|
1877
|
-
|
|
1878
|
-
create: create$5$1
|
|
1775
|
+
const signal$1 = messagePort => {
|
|
1776
|
+
messagePort.start();
|
|
1879
1777
|
};
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
}
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1778
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
1779
|
+
getData = getData$2;
|
|
1780
|
+
send(message) {
|
|
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);
|
|
1893
1797
|
};
|
|
1894
|
-
const
|
|
1798
|
+
const IpcParentWithMessagePort$1 = {
|
|
1895
1799
|
__proto__: null,
|
|
1896
|
-
create: create$
|
|
1800
|
+
create: create$5$1,
|
|
1801
|
+
signal: signal$1,
|
|
1802
|
+
wrap: wrap$5
|
|
1897
1803
|
};
|
|
1898
|
-
const
|
|
1899
|
-
|
|
1900
|
-
}) => {
|
|
1901
|
-
// TODO create a commandMap per rpc instance
|
|
1902
|
-
register$1(commandMap);
|
|
1903
|
-
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1904
|
-
handleIpc(ipc);
|
|
1905
|
-
const rpc = createRpc$1(ipc);
|
|
1906
|
-
return rpc;
|
|
1804
|
+
const stringifyCompact = value => {
|
|
1805
|
+
return JSON.stringify(value);
|
|
1907
1806
|
};
|
|
1908
|
-
const
|
|
1909
|
-
|
|
1910
|
-
|
|
1807
|
+
const parse$1 = content => {
|
|
1808
|
+
if (content === 'undefined') {
|
|
1809
|
+
return null;
|
|
1810
|
+
}
|
|
1811
|
+
try {
|
|
1812
|
+
return JSON.parse(content);
|
|
1813
|
+
} catch (error) {
|
|
1814
|
+
throw new VError(error, 'failed to parse json');
|
|
1815
|
+
}
|
|
1911
1816
|
};
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
send
|
|
1919
|
-
}) => {
|
|
1920
|
-
let rpcPromise;
|
|
1921
|
-
const getOrCreate = () => {
|
|
1922
|
-
if (!rpcPromise) {
|
|
1923
|
-
rpcPromise = create$5$1({
|
|
1924
|
-
commandMap,
|
|
1925
|
-
isMessagePortOpen,
|
|
1926
|
-
send
|
|
1927
|
-
});
|
|
1928
|
-
}
|
|
1929
|
-
return rpcPromise;
|
|
1930
|
-
};
|
|
1931
|
-
return {
|
|
1932
|
-
async dispose() {
|
|
1933
|
-
const rpc = await getOrCreate();
|
|
1934
|
-
await rpc.dispose();
|
|
1935
|
-
},
|
|
1936
|
-
async invoke(method, ...params) {
|
|
1937
|
-
const rpc = await getOrCreate();
|
|
1938
|
-
return rpc.invoke(method, ...params);
|
|
1939
|
-
},
|
|
1940
|
-
async invokeAndTransfer(method, ...params) {
|
|
1941
|
-
const rpc = await getOrCreate();
|
|
1942
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1943
|
-
},
|
|
1944
|
-
async send(method, ...params) {
|
|
1945
|
-
const rpc = await getOrCreate();
|
|
1946
|
-
rpc.send(method, ...params);
|
|
1947
|
-
}
|
|
1948
|
-
};
|
|
1817
|
+
const waitForWebSocketToBeOpen = webSocket => {
|
|
1818
|
+
return getFirstEvent(webSocket, {
|
|
1819
|
+
close: Close,
|
|
1820
|
+
error: Error$3,
|
|
1821
|
+
open: Open
|
|
1822
|
+
});
|
|
1949
1823
|
};
|
|
1950
|
-
const
|
|
1951
|
-
|
|
1952
|
-
|
|
1824
|
+
const create$j = async ({
|
|
1825
|
+
webSocket
|
|
1826
|
+
}) => {
|
|
1827
|
+
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
1828
|
+
if (firstWebSocketEvent.type === Error$3) {
|
|
1829
|
+
throw new IpcError(`WebSocket connection error`);
|
|
1830
|
+
}
|
|
1831
|
+
if (firstWebSocketEvent.type === Close) {
|
|
1832
|
+
throw new IpcError('Websocket connection was immediately closed');
|
|
1833
|
+
}
|
|
1834
|
+
return webSocket;
|
|
1953
1835
|
};
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1836
|
+
let IpcParentWithWebSocket$1 = class IpcParentWithWebSocket extends Ipc {
|
|
1837
|
+
getData(event) {
|
|
1838
|
+
return parse$1(event.data);
|
|
1839
|
+
}
|
|
1840
|
+
send(message) {
|
|
1841
|
+
this._rawIpc.send(stringifyCompact(message));
|
|
1842
|
+
}
|
|
1843
|
+
sendAndTransfer(message) {
|
|
1844
|
+
throw new Error('sendAndTransfer not supported');
|
|
1845
|
+
}
|
|
1846
|
+
dispose() {
|
|
1847
|
+
this._rawIpc.close();
|
|
1848
|
+
}
|
|
1849
|
+
onClose(callback) {
|
|
1850
|
+
this._rawIpc.addEventListener('close', callback);
|
|
1851
|
+
}
|
|
1852
|
+
onMessage(callback) {
|
|
1853
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1854
|
+
}
|
|
1972
1855
|
};
|
|
1973
|
-
const
|
|
1974
|
-
|
|
1975
|
-
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToIframeWorker', port, command, rpcId);
|
|
1856
|
+
const wrap$1 = webSocket => {
|
|
1857
|
+
return new IpcParentWithWebSocket$1(webSocket);
|
|
1976
1858
|
};
|
|
1977
|
-
const
|
|
1978
|
-
|
|
1979
|
-
|
|
1859
|
+
const IpcParentWithWebSocket$1$1 = {
|
|
1860
|
+
__proto__: null,
|
|
1861
|
+
create: create$j,
|
|
1862
|
+
wrap: wrap$1
|
|
1980
1863
|
};
|
|
1981
1864
|
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
const state$8 = {
|
|
1987
|
-
debugProviderMap: Object.create(null)
|
|
1865
|
+
const Two$1 = '2.0';
|
|
1866
|
+
const callbacks = Object.create(null);
|
|
1867
|
+
const get$9 = id => {
|
|
1868
|
+
return callbacks[id];
|
|
1988
1869
|
};
|
|
1989
|
-
const
|
|
1990
|
-
|
|
1991
|
-
if (!provider) {
|
|
1992
|
-
// @ts-ignore
|
|
1993
|
-
throw new VError(`no debug provider "${id}" found`);
|
|
1994
|
-
}
|
|
1995
|
-
return provider;
|
|
1870
|
+
const remove$3 = id => {
|
|
1871
|
+
delete callbacks[id];
|
|
1996
1872
|
};
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
1873
|
+
class JsonRpcError extends Error {
|
|
1874
|
+
constructor(message) {
|
|
1875
|
+
super(message);
|
|
1876
|
+
this.name = 'JsonRpcError';
|
|
2000
1877
|
}
|
|
2001
|
-
|
|
1878
|
+
}
|
|
1879
|
+
const NewLine$1 = '\n';
|
|
1880
|
+
const DomException = 'DOMException';
|
|
1881
|
+
const ReferenceError$1 = 'ReferenceError';
|
|
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;
|
|
2002
1909
|
};
|
|
2003
|
-
const
|
|
2004
|
-
|
|
2005
|
-
|
|
1910
|
+
const constructError = (message, type, name) => {
|
|
1911
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
1912
|
+
if (ErrorConstructor === DOMException && name) {
|
|
1913
|
+
return new ErrorConstructor(message, name);
|
|
1914
|
+
}
|
|
1915
|
+
if (ErrorConstructor === Error) {
|
|
1916
|
+
const error = new Error(message);
|
|
1917
|
+
if (name && name !== 'VError') {
|
|
1918
|
+
error.name = name;
|
|
1919
|
+
}
|
|
1920
|
+
return error;
|
|
1921
|
+
}
|
|
1922
|
+
return new ErrorConstructor(message);
|
|
2006
1923
|
};
|
|
2007
|
-
const
|
|
2008
|
-
|
|
2009
|
-
await invoke$2('Debug.resumed');
|
|
1924
|
+
const joinLines = lines => {
|
|
1925
|
+
return lines.join(NewLine$1);
|
|
2010
1926
|
};
|
|
2011
|
-
const
|
|
2012
|
-
|
|
2013
|
-
await invoke$2('Debug.scriptParsed', parsedScript);
|
|
1927
|
+
const splitLines$1 = lines => {
|
|
1928
|
+
return lines.split(NewLine$1);
|
|
2014
1929
|
};
|
|
2015
|
-
const
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
1930
|
+
const getCurrentStack = () => {
|
|
1931
|
+
const stackLinesToSkip = 3;
|
|
1932
|
+
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(stackLinesToSkip));
|
|
1933
|
+
return currentStack;
|
|
2019
1934
|
};
|
|
2020
|
-
const
|
|
2021
|
-
|
|
2022
|
-
const provider = getDebugProvider(protocol);
|
|
2023
|
-
const emitter = {
|
|
2024
|
-
handleChange,
|
|
2025
|
-
handlePaused,
|
|
2026
|
-
handleResumed,
|
|
2027
|
-
handleScriptParsed
|
|
2028
|
-
};
|
|
2029
|
-
await provider.start(emitter, path);
|
|
2030
|
-
} catch (error) {
|
|
2031
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
2032
|
-
}
|
|
1935
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
1936
|
+
return string.indexOf(NewLine$1, startIndex);
|
|
2033
1937
|
};
|
|
2034
|
-
const
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
array(processes);
|
|
2039
|
-
return processes;
|
|
2040
|
-
} catch (error) {
|
|
2041
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1938
|
+
const getParentStack = error => {
|
|
1939
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
1940
|
+
if (parentStack.startsWith(' at')) {
|
|
1941
|
+
parentStack = error.message + NewLine$1 + parentStack;
|
|
2042
1942
|
}
|
|
1943
|
+
return parentStack;
|
|
2043
1944
|
};
|
|
2044
|
-
const
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
1945
|
+
const MethodNotFound = -32601;
|
|
1946
|
+
const Custom = -32001;
|
|
1947
|
+
const restoreJsonRpcError = error => {
|
|
1948
|
+
const currentStack = getCurrentStack();
|
|
1949
|
+
if (error && error instanceof Error) {
|
|
1950
|
+
if (typeof error.stack === 'string') {
|
|
1951
|
+
error.stack = error.stack + NewLine$1 + currentStack;
|
|
1952
|
+
}
|
|
1953
|
+
return error;
|
|
2050
1954
|
}
|
|
2051
|
-
|
|
2052
|
-
const
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
return
|
|
2056
|
-
} catch (error) {
|
|
2057
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1955
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
1956
|
+
const restoredError = new JsonRpcError(error.message);
|
|
1957
|
+
const parentStack = getParentStack(error);
|
|
1958
|
+
restoredError.stack = parentStack + NewLine$1 + currentStack;
|
|
1959
|
+
return restoredError;
|
|
2058
1960
|
}
|
|
2059
|
-
|
|
2060
|
-
const
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
1961
|
+
if (error && error.message) {
|
|
1962
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
1963
|
+
if (error.data) {
|
|
1964
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
1965
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine$1 + error.data.stack + NewLine$1 + currentStack;
|
|
1966
|
+
} else if (error.data.stack) {
|
|
1967
|
+
restoredError.stack = error.data.stack;
|
|
1968
|
+
}
|
|
1969
|
+
if (error.data.codeFrame) {
|
|
1970
|
+
// @ts-ignore
|
|
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;
|
|
2066
1996
|
}
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
// TODO create direct connection from debug worker to extension, not needing extension host worker apis
|
|
2070
|
-
|
|
2071
|
-
const getStatus = async protocol => {
|
|
2072
|
-
try {
|
|
2073
|
-
const provider = getDebugProvider(protocol);
|
|
2074
|
-
return await provider.getStatus();
|
|
2075
|
-
} catch (error) {
|
|
2076
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
1997
|
+
if (typeof error === 'string') {
|
|
1998
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
2077
1999
|
}
|
|
2000
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
2078
2001
|
};
|
|
2079
|
-
const
|
|
2080
|
-
|
|
2081
|
-
const
|
|
2082
|
-
|
|
2083
|
-
} catch (error) {
|
|
2084
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
2002
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
2003
|
+
if ('error' in responseMessage) {
|
|
2004
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
2005
|
+
throw restoredError;
|
|
2085
2006
|
}
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
try {
|
|
2089
|
-
const provider = getDebugProvider(protocol);
|
|
2090
|
-
return await provider.getScopeChain();
|
|
2091
|
-
} catch (error) {
|
|
2092
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
2007
|
+
if ('result' in responseMessage) {
|
|
2008
|
+
return responseMessage.result;
|
|
2093
2009
|
}
|
|
2010
|
+
throw new JsonRpcError('unexpected response message');
|
|
2094
2011
|
};
|
|
2095
|
-
const
|
|
2096
|
-
|
|
2097
|
-
const provider = getDebugProvider(protocol);
|
|
2098
|
-
return await provider.getScripts();
|
|
2099
|
-
} catch (error) {
|
|
2100
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
2101
|
-
}
|
|
2012
|
+
const warn$1 = (...args) => {
|
|
2013
|
+
console.warn(...args);
|
|
2102
2014
|
};
|
|
2103
|
-
const
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2015
|
+
const resolve = (id, response) => {
|
|
2016
|
+
const fn = get$9(id);
|
|
2017
|
+
if (!fn) {
|
|
2018
|
+
console.log(response);
|
|
2019
|
+
warn$1(`callback ${id} may already be disposed`);
|
|
2020
|
+
return;
|
|
2109
2021
|
}
|
|
2022
|
+
fn(response);
|
|
2023
|
+
remove$3(id);
|
|
2110
2024
|
};
|
|
2111
|
-
const
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
return
|
|
2115
|
-
} catch (error) {
|
|
2116
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
2025
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
2026
|
+
const getErrorType = prettyError => {
|
|
2027
|
+
if (prettyError && prettyError.type) {
|
|
2028
|
+
return prettyError.type;
|
|
2117
2029
|
}
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
try {
|
|
2121
|
-
const provider = getDebugProvider(protocol);
|
|
2122
|
-
return await provider.stepOut();
|
|
2123
|
-
} catch (error) {
|
|
2124
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
2030
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
2031
|
+
return prettyError.constructor.name;
|
|
2125
2032
|
}
|
|
2033
|
+
return undefined;
|
|
2126
2034
|
};
|
|
2127
|
-
const
|
|
2128
|
-
|
|
2129
|
-
const provider = getDebugProvider(protocol);
|
|
2130
|
-
return await provider.stepOver();
|
|
2131
|
-
} catch (error) {
|
|
2132
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
2133
|
-
}
|
|
2035
|
+
const isAlreadyStack = line => {
|
|
2036
|
+
return line.trim().startsWith('at ');
|
|
2134
2037
|
};
|
|
2135
|
-
const
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
throw new VError(error, 'Failed to execute debug provider');
|
|
2038
|
+
const getStack = prettyError => {
|
|
2039
|
+
const stackString = prettyError.stack || '';
|
|
2040
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
2041
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
2042
|
+
return stackString.slice(newLineIndex + 1);
|
|
2141
2043
|
}
|
|
2044
|
+
return stackString;
|
|
2142
2045
|
};
|
|
2143
|
-
const
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2046
|
+
const getErrorProperty = (error, prettyError) => {
|
|
2047
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
2048
|
+
return {
|
|
2049
|
+
code: MethodNotFound,
|
|
2050
|
+
data: error.stack,
|
|
2051
|
+
message: error.message
|
|
2052
|
+
};
|
|
2149
2053
|
}
|
|
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
|
+
};
|
|
2066
|
+
const create$1$1 = (id, error) => {
|
|
2067
|
+
return {
|
|
2068
|
+
error,
|
|
2069
|
+
id,
|
|
2070
|
+
jsonrpc: Two$1
|
|
2071
|
+
};
|
|
2072
|
+
};
|
|
2073
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
2074
|
+
const prettyError = preparePrettyError(error);
|
|
2075
|
+
logError(error, prettyError);
|
|
2076
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
2077
|
+
return create$1$1(id, errorProperty);
|
|
2078
|
+
};
|
|
2079
|
+
const create$i = (message, result) => {
|
|
2080
|
+
return {
|
|
2081
|
+
id: message.id,
|
|
2082
|
+
jsonrpc: Two$1,
|
|
2083
|
+
result: result ?? null
|
|
2084
|
+
};
|
|
2085
|
+
};
|
|
2086
|
+
const getSuccessResponse = (message, result) => {
|
|
2087
|
+
const resultProperty = result ?? null;
|
|
2088
|
+
return create$i(message, resultProperty);
|
|
2089
|
+
};
|
|
2090
|
+
const getErrorResponseSimple = (id, error) => {
|
|
2091
|
+
return {
|
|
2092
|
+
error: {
|
|
2093
|
+
code: Custom,
|
|
2094
|
+
data: error,
|
|
2095
|
+
// @ts-ignore
|
|
2096
|
+
message: error.message
|
|
2097
|
+
},
|
|
2098
|
+
id,
|
|
2099
|
+
jsonrpc: Two$1
|
|
2100
|
+
};
|
|
2150
2101
|
};
|
|
2151
|
-
const
|
|
2102
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
2152
2103
|
try {
|
|
2153
|
-
const
|
|
2154
|
-
return
|
|
2104
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
2105
|
+
return getSuccessResponse(message, result);
|
|
2155
2106
|
} catch (error) {
|
|
2156
|
-
|
|
2107
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
2108
|
+
return getErrorResponseSimple(message.id, error);
|
|
2109
|
+
}
|
|
2110
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
2157
2111
|
}
|
|
2158
2112
|
};
|
|
2159
|
-
const
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2113
|
+
const defaultPreparePrettyError = error => {
|
|
2114
|
+
return error;
|
|
2115
|
+
};
|
|
2116
|
+
const defaultLogError = () => {
|
|
2117
|
+
// ignore
|
|
2118
|
+
};
|
|
2119
|
+
const defaultRequiresSocket = () => {
|
|
2120
|
+
return false;
|
|
2166
2121
|
};
|
|
2122
|
+
const defaultResolve = resolve;
|
|
2167
2123
|
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2124
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
2125
|
+
const normalizeParams = args => {
|
|
2126
|
+
if (args.length === 1) {
|
|
2127
|
+
const options = args[0];
|
|
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
|
+
};
|
|
2137
|
+
}
|
|
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
|
+
};
|
|
2148
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
2149
|
+
const options = normalizeParams(args);
|
|
2150
|
+
const {
|
|
2151
|
+
execute,
|
|
2152
|
+
ipc,
|
|
2153
|
+
logError,
|
|
2154
|
+
message,
|
|
2155
|
+
preparePrettyError,
|
|
2156
|
+
requiresSocket,
|
|
2157
|
+
resolve
|
|
2158
|
+
} = options;
|
|
2159
|
+
if ('id' in message) {
|
|
2160
|
+
if ('method' in message) {
|
|
2161
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
2162
|
+
try {
|
|
2163
|
+
ipc.send(response);
|
|
2164
|
+
} catch (error) {
|
|
2165
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
2166
|
+
ipc.send(errorResponse);
|
|
2183
2167
|
}
|
|
2184
|
-
|
|
2185
|
-
|
|
2168
|
+
return;
|
|
2169
|
+
}
|
|
2170
|
+
resolve(message.id, message);
|
|
2171
|
+
return;
|
|
2186
2172
|
}
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
executeDiagnosticProvider,
|
|
2191
|
-
registerDiagnosticProvider
|
|
2192
|
-
} = create$c({
|
|
2193
|
-
name: 'Diagnostic',
|
|
2194
|
-
resultShape: {
|
|
2195
|
-
items: {
|
|
2196
|
-
type: Object$1
|
|
2197
|
-
},
|
|
2198
|
-
type: Array$1
|
|
2173
|
+
if ('method' in message) {
|
|
2174
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
2175
|
+
return;
|
|
2199
2176
|
}
|
|
2200
|
-
|
|
2177
|
+
throw new JsonRpcError('unexpected message');
|
|
2178
|
+
};
|
|
2201
2179
|
|
|
2202
|
-
const
|
|
2180
|
+
const Two = '2.0';
|
|
2203
2181
|
|
|
2204
|
-
const
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
2182
|
+
const create$h = (method, params) => {
|
|
2183
|
+
return {
|
|
2184
|
+
jsonrpc: Two,
|
|
2185
|
+
method,
|
|
2186
|
+
params
|
|
2187
|
+
};
|
|
2211
2188
|
};
|
|
2212
2189
|
|
|
2213
|
-
const
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2190
|
+
const create$g = (id, method, params) => {
|
|
2191
|
+
const message = {
|
|
2192
|
+
id,
|
|
2193
|
+
jsonrpc: Two,
|
|
2194
|
+
method,
|
|
2195
|
+
params
|
|
2196
|
+
};
|
|
2197
|
+
return message;
|
|
2217
2198
|
};
|
|
2218
2199
|
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
throw new DepecratedError(`vscode.exec is deprecated, use createNodeRpc instead`);
|
|
2200
|
+
let id$2 = 0;
|
|
2201
|
+
const create$f = () => {
|
|
2202
|
+
return ++id$2;
|
|
2223
2203
|
};
|
|
2224
2204
|
|
|
2225
|
-
const
|
|
2226
|
-
const
|
|
2227
|
-
const
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
return
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
throw new Error('Failed to register file system provider: missing id');
|
|
2237
|
-
}
|
|
2238
|
-
fileSystemProviderMap[id] = provider;
|
|
2205
|
+
const registerPromise = map => {
|
|
2206
|
+
const id = create$f();
|
|
2207
|
+
const {
|
|
2208
|
+
promise,
|
|
2209
|
+
resolve
|
|
2210
|
+
} = Promise.withResolvers();
|
|
2211
|
+
map[id] = resolve;
|
|
2212
|
+
return {
|
|
2213
|
+
id,
|
|
2214
|
+
promise
|
|
2215
|
+
};
|
|
2239
2216
|
};
|
|
2240
2217
|
|
|
2241
|
-
const
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
} catch (error) {
|
|
2252
|
-
throw new VError(error, 'Failed to execute file system provider');
|
|
2253
|
-
}
|
|
2254
|
-
};
|
|
2255
|
-
const readFile$2 = async (protocol, path) => {
|
|
2256
|
-
try {
|
|
2257
|
-
const provider = get$9(protocol);
|
|
2258
|
-
return await provider.readFile(path);
|
|
2259
|
-
} catch (error) {
|
|
2260
|
-
throw new VError(error, 'Failed to execute file system provider');
|
|
2261
|
-
}
|
|
2262
|
-
};
|
|
2263
|
-
const mkdir$2 = async (protocol, path) => {
|
|
2264
|
-
try {
|
|
2265
|
-
const provider = get$9(protocol);
|
|
2266
|
-
return await provider.mkdir(path);
|
|
2267
|
-
} catch (error) {
|
|
2268
|
-
throw new VError(error, 'Failed to execute file system provider');
|
|
2218
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
2219
|
+
const {
|
|
2220
|
+
id,
|
|
2221
|
+
promise
|
|
2222
|
+
} = registerPromise(callbacks);
|
|
2223
|
+
const message = create$g(id, method, params);
|
|
2224
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
2225
|
+
ipc.sendAndTransfer(message);
|
|
2226
|
+
} else {
|
|
2227
|
+
ipc.send(message);
|
|
2269
2228
|
}
|
|
2229
|
+
const responseMessage = await promise;
|
|
2230
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
2270
2231
|
};
|
|
2271
|
-
const
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
const
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
// when reading / writing large files
|
|
2304
|
-
const content = await invoke$1('FileSystem.readDirWithFileTypes', path);
|
|
2305
|
-
return content;
|
|
2232
|
+
const createRpc$1 = ipc => {
|
|
2233
|
+
const callbacks = Object.create(null);
|
|
2234
|
+
ipc._resolve = (id, response) => {
|
|
2235
|
+
const fn = callbacks[id];
|
|
2236
|
+
if (!fn) {
|
|
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;
|
|
2306
2264
|
};
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
return await provider.remove(path);
|
|
2311
|
-
} catch (error) {
|
|
2312
|
-
throw new VError(error, 'Failed to execute file system provider');
|
|
2313
|
-
}
|
|
2265
|
+
|
|
2266
|
+
const requiresSocket = () => {
|
|
2267
|
+
return false;
|
|
2314
2268
|
};
|
|
2315
|
-
const
|
|
2316
|
-
|
|
2317
|
-
const provider = get$9(protocol);
|
|
2318
|
-
return await provider.rename(oldUri, newUri);
|
|
2319
|
-
} catch (error) {
|
|
2320
|
-
throw new VError(error, 'Failed to execute file system provider');
|
|
2321
|
-
}
|
|
2269
|
+
const preparePrettyError = error => {
|
|
2270
|
+
return error;
|
|
2322
2271
|
};
|
|
2323
|
-
const
|
|
2324
|
-
|
|
2325
|
-
const provider = get$9(protocol);
|
|
2326
|
-
return await provider.writeFile(uri, content);
|
|
2327
|
-
} catch (error) {
|
|
2328
|
-
throw new VError(error, 'Failed to execute file system provider');
|
|
2329
|
-
}
|
|
2272
|
+
const logError = () => {
|
|
2273
|
+
// handled by renderer worker
|
|
2330
2274
|
};
|
|
2331
|
-
const
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
} catch (error) {
|
|
2336
|
-
throw new VError(error, 'Failed to execute file system provider');
|
|
2337
|
-
}
|
|
2275
|
+
const handleMessage = event => {
|
|
2276
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
2277
|
+
const actualExecute = event?.target?.execute || execute;
|
|
2278
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
2338
2279
|
};
|
|
2339
2280
|
|
|
2340
|
-
const {
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
allowUndefined: true,
|
|
2347
|
-
items: {
|
|
2348
|
-
properties: {
|
|
2349
|
-
endOffset: {
|
|
2350
|
-
type: Number
|
|
2351
|
-
},
|
|
2352
|
-
inserted: {
|
|
2353
|
-
type: String$1
|
|
2354
|
-
},
|
|
2355
|
-
startOffset: {
|
|
2356
|
-
type: Number
|
|
2357
|
-
}
|
|
2358
|
-
},
|
|
2359
|
-
type: Object$1
|
|
2360
|
-
},
|
|
2361
|
-
type: Array$1
|
|
2281
|
+
const handleIpc = ipc => {
|
|
2282
|
+
if ('addEventListener' in ipc) {
|
|
2283
|
+
ipc.addEventListener('message', handleMessage);
|
|
2284
|
+
} else if ('on' in ipc) {
|
|
2285
|
+
// deprecated
|
|
2286
|
+
ipc.on('message', handleMessage);
|
|
2362
2287
|
}
|
|
2363
|
-
}
|
|
2288
|
+
};
|
|
2364
2289
|
|
|
2365
|
-
const
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
const newLineIndex = textDocument.text.indexOf('\n', offset);
|
|
2370
|
-
offset = newLineIndex + 1;
|
|
2290
|
+
const listen$1 = async (module, options) => {
|
|
2291
|
+
const rawIpc = await module.listen(options);
|
|
2292
|
+
if (module.signal) {
|
|
2293
|
+
module.signal(rawIpc);
|
|
2371
2294
|
}
|
|
2372
|
-
|
|
2373
|
-
return
|
|
2295
|
+
const ipc = module.wrap(rawIpc);
|
|
2296
|
+
return ipc;
|
|
2374
2297
|
};
|
|
2375
2298
|
|
|
2376
|
-
const
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2299
|
+
const create$e = async ({
|
|
2300
|
+
commandMap,
|
|
2301
|
+
isMessagePortOpen = true,
|
|
2302
|
+
messagePort
|
|
2303
|
+
}) => {
|
|
2304
|
+
// TODO create a commandMap per rpc instance
|
|
2305
|
+
register$1(commandMap);
|
|
2306
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
2307
|
+
isMessagePortOpen,
|
|
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;
|
|
2315
|
+
};
|
|
2316
|
+
|
|
2317
|
+
const create$d = async ({
|
|
2318
|
+
commandMap,
|
|
2319
|
+
isMessagePortOpen,
|
|
2320
|
+
send
|
|
2321
|
+
}) => {
|
|
2380
2322
|
const {
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2323
|
+
port1,
|
|
2324
|
+
port2
|
|
2325
|
+
} = new MessageChannel();
|
|
2326
|
+
await send(port1);
|
|
2327
|
+
return create$e({
|
|
2328
|
+
commandMap,
|
|
2329
|
+
isMessagePortOpen,
|
|
2330
|
+
messagePort: port2
|
|
2331
|
+
});
|
|
2332
|
+
};
|
|
2333
|
+
|
|
2334
|
+
const createSharedLazyRpc = factory => {
|
|
2335
|
+
let rpcPromise;
|
|
2336
|
+
const getOrCreate = () => {
|
|
2337
|
+
if (!rpcPromise) {
|
|
2338
|
+
rpcPromise = factory();
|
|
2391
2339
|
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
}
|
|
2395
|
-
const columnIndex = offset - index;
|
|
2340
|
+
return rpcPromise;
|
|
2341
|
+
};
|
|
2396
2342
|
return {
|
|
2397
|
-
|
|
2398
|
-
|
|
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);
|
|
2358
|
+
}
|
|
2399
2359
|
};
|
|
2400
2360
|
};
|
|
2401
2361
|
|
|
2402
|
-
const {
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2362
|
+
const create$c = async ({
|
|
2363
|
+
commandMap,
|
|
2364
|
+
isMessagePortOpen,
|
|
2365
|
+
send
|
|
2366
|
+
}) => {
|
|
2367
|
+
return createSharedLazyRpc(() => {
|
|
2368
|
+
return create$d({
|
|
2369
|
+
commandMap,
|
|
2370
|
+
isMessagePortOpen,
|
|
2371
|
+
send
|
|
2372
|
+
});
|
|
2373
|
+
});
|
|
2374
|
+
};
|
|
2412
2375
|
|
|
2413
|
-
const {
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
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
|
+
};
|
|
2424
2390
|
|
|
2425
|
-
const
|
|
2426
|
-
|
|
2427
|
-
|
|
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
|
+
};
|
|
2421
|
+
|
|
2422
|
+
const create$8 = async ({
|
|
2423
|
+
commandMap,
|
|
2424
|
+
messagePort
|
|
2425
|
+
}) => {
|
|
2426
|
+
return create$e({
|
|
2427
|
+
commandMap,
|
|
2428
|
+
messagePort
|
|
2429
|
+
});
|
|
2430
|
+
};
|
|
2431
|
+
|
|
2432
|
+
const create$7 = async ({
|
|
2433
|
+
commandMap
|
|
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
|
+
};
|
|
2428
2442
|
|
|
2429
2443
|
const getPortTuple = () => {
|
|
2430
2444
|
const {
|
|
@@ -2463,7 +2477,7 @@ const create$6 = async ({
|
|
|
2463
2477
|
port1,
|
|
2464
2478
|
port2
|
|
2465
2479
|
} = getPortTuple();
|
|
2466
|
-
const rpcPromise =
|
|
2480
|
+
const rpcPromise = create$9({
|
|
2467
2481
|
commandMap,
|
|
2468
2482
|
isMessagePortOpen: true,
|
|
2469
2483
|
messagePort: port2
|
|
@@ -2502,7 +2516,7 @@ const create$5 = async ({
|
|
|
2502
2516
|
const port = await getPort();
|
|
2503
2517
|
// TODO rpc module should start port
|
|
2504
2518
|
port.start();
|
|
2505
|
-
const rpc = await
|
|
2519
|
+
const rpc = await create$9({
|
|
2506
2520
|
commandMap: {},
|
|
2507
2521
|
isMessagePortOpen: true,
|
|
2508
2522
|
messagePort: port
|
|
@@ -2530,7 +2544,7 @@ const create$4 = async ({
|
|
|
2530
2544
|
string(type);
|
|
2531
2545
|
const wsUrl = getWebSocketUrl(type, location.host);
|
|
2532
2546
|
const webSocket = new WebSocket(wsUrl);
|
|
2533
|
-
const rpc = await
|
|
2547
|
+
const rpc = await create$b({
|
|
2534
2548
|
commandMap: {},
|
|
2535
2549
|
webSocket
|
|
2536
2550
|
});
|
|
@@ -2648,7 +2662,7 @@ const send = async port => {
|
|
|
2648
2662
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, initialCommand);
|
|
2649
2663
|
};
|
|
2650
2664
|
const launchFileSystemProcess = async () => {
|
|
2651
|
-
const rpc = await
|
|
2665
|
+
const rpc = await create$d({
|
|
2652
2666
|
commandMap: {},
|
|
2653
2667
|
send
|
|
2654
2668
|
});
|
|
@@ -2773,7 +2787,7 @@ const {
|
|
|
2773
2787
|
executefileReferenceProvider,
|
|
2774
2788
|
executeReferenceProvider,
|
|
2775
2789
|
getProvider: getProvider$1,
|
|
2776
|
-
registerReferenceProvider} = create$
|
|
2790
|
+
registerReferenceProvider} = create$l({
|
|
2777
2791
|
additionalMethodNames: [
|
|
2778
2792
|
// @ts-ignore
|
|
2779
2793
|
{
|
|
@@ -2835,7 +2849,7 @@ const validateResult = renameResult => {
|
|
|
2835
2849
|
const {
|
|
2836
2850
|
executeprepareRenameProvider,
|
|
2837
2851
|
executeRenameProvider,
|
|
2838
|
-
registerRenameProvider} = create$
|
|
2852
|
+
registerRenameProvider} = create$l({
|
|
2839
2853
|
additionalMethodNames: [
|
|
2840
2854
|
// @ts-ignore
|
|
2841
2855
|
{
|
|
@@ -2992,7 +3006,7 @@ const createRpc = ({
|
|
|
2992
3006
|
|
|
2993
3007
|
const {
|
|
2994
3008
|
executeSelectionProvider,
|
|
2995
|
-
registerSelectionProvider} = create$
|
|
3009
|
+
registerSelectionProvider} = create$l({
|
|
2996
3010
|
name: 'Selection',
|
|
2997
3011
|
resultShape: {
|
|
2998
3012
|
allowUndefined: true,
|
|
@@ -3254,7 +3268,7 @@ const getFileDecorations = async (providerId, uris) => {
|
|
|
3254
3268
|
|
|
3255
3269
|
const {
|
|
3256
3270
|
executeTabCompletionProvider,
|
|
3257
|
-
registerTabCompletionProvider} = create$
|
|
3271
|
+
registerTabCompletionProvider} = create$l({
|
|
3258
3272
|
name: 'TabCompletion',
|
|
3259
3273
|
resultShape: {
|
|
3260
3274
|
allowUndefined: true,
|
|
@@ -3293,7 +3307,7 @@ const executeTextSearchProvider = async (scheme, query) => {
|
|
|
3293
3307
|
|
|
3294
3308
|
const {
|
|
3295
3309
|
executeTypeDefinitionProvider,
|
|
3296
|
-
registerTypeDefinitionProvider} = create$
|
|
3310
|
+
registerTypeDefinitionProvider} = create$l({
|
|
3297
3311
|
name: 'TypeDefinition',
|
|
3298
3312
|
resultShape: {
|
|
3299
3313
|
allowUndefined: true,
|
|
@@ -3344,7 +3358,7 @@ const createWebView = async (providerId, port, uri, uid, origin, webView) => {
|
|
|
3344
3358
|
// TODO cancel promise when webview is disposed before sending message
|
|
3345
3359
|
// TODO handle case when webview doesn't send ready message
|
|
3346
3360
|
|
|
3347
|
-
const rpc = await
|
|
3361
|
+
const rpc = await create$9({
|
|
3348
3362
|
commandMap: provider.commands || {},
|
|
3349
3363
|
isMessagePortOpen: false,
|
|
3350
3364
|
messagePort: port
|
|
@@ -3631,7 +3645,7 @@ const setup = ({
|
|
|
3631
3645
|
};
|
|
3632
3646
|
|
|
3633
3647
|
const launchExtensionManagementWorker = async () => {
|
|
3634
|
-
const rpc = await
|
|
3648
|
+
const rpc = await create$c({
|
|
3635
3649
|
commandMap: {},
|
|
3636
3650
|
async send(port) {
|
|
3637
3651
|
await sendMessagePortToExtensionManagementWorker(port, 0);
|
|
@@ -3642,7 +3656,7 @@ const launchExtensionManagementWorker = async () => {
|
|
|
3642
3656
|
|
|
3643
3657
|
const launchFileSearchWorker = async () => {
|
|
3644
3658
|
try {
|
|
3645
|
-
const rpc = await
|
|
3659
|
+
const rpc = await create$c({
|
|
3646
3660
|
commandMap: {},
|
|
3647
3661
|
async send(port) {
|
|
3648
3662
|
await sendMessagePortToFileSearchWorker(port, 0);
|
|
@@ -4871,7 +4885,7 @@ const hydrate$1 = async () => {
|
|
|
4871
4885
|
};
|
|
4872
4886
|
|
|
4873
4887
|
const launchIframeWorker = async () => {
|
|
4874
|
-
const rpc = await
|
|
4888
|
+
const rpc = await create$d({
|
|
4875
4889
|
commandMap: {},
|
|
4876
4890
|
async send(port) {
|
|
4877
4891
|
await sendMessagePortToIframeWorker(port, 0);
|
|
@@ -5122,27 +5136,36 @@ const mkdir$1 = () => {
|
|
|
5122
5136
|
const remove$2 = () => {
|
|
5123
5137
|
throw new Error('not implemented');
|
|
5124
5138
|
};
|
|
5139
|
+
const normalizeUri = uri => {
|
|
5140
|
+
if (uri.startsWith('fetch://')) {
|
|
5141
|
+
return uri.slice('fetch://'.length);
|
|
5142
|
+
}
|
|
5143
|
+
return uri;
|
|
5144
|
+
};
|
|
5125
5145
|
const readDirWithFileTypes$1 = async uri => {
|
|
5146
|
+
const normalizedUri = normalizeUri(uri);
|
|
5147
|
+
const directoryPrefix = normalizedUri.endsWith(Slash) ? normalizedUri : `${normalizedUri}${Slash}`;
|
|
5126
5148
|
const fileList = await getJson(fileMapUrl);
|
|
5127
5149
|
const dirents = [];
|
|
5128
5150
|
for (const fileUri of fileList) {
|
|
5129
|
-
if (fileUri.startsWith(
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
name,
|
|
5138
|
-
type: Directory$1
|
|
5139
|
-
});
|
|
5140
|
-
} else {
|
|
5141
|
-
dirents.push({
|
|
5142
|
-
name: rest,
|
|
5143
|
-
type: File$1
|
|
5144
|
-
});
|
|
5151
|
+
if (!fileUri.startsWith(directoryPrefix)) {
|
|
5152
|
+
continue;
|
|
5153
|
+
}
|
|
5154
|
+
const rest = fileUri.slice(directoryPrefix.length);
|
|
5155
|
+
if (rest.includes(Slash)) {
|
|
5156
|
+
const name = rest.slice(0, rest.indexOf(Slash));
|
|
5157
|
+
if (dirents.some(dirent => dirent.name === name)) {
|
|
5158
|
+
continue;
|
|
5145
5159
|
}
|
|
5160
|
+
dirents.push({
|
|
5161
|
+
name,
|
|
5162
|
+
type: Directory$1
|
|
5163
|
+
});
|
|
5164
|
+
} else {
|
|
5165
|
+
dirents.push({
|
|
5166
|
+
name: rest,
|
|
5167
|
+
type: File$1
|
|
5168
|
+
});
|
|
5146
5169
|
}
|
|
5147
5170
|
}
|
|
5148
5171
|
return dirents;
|
|
@@ -5516,22 +5539,22 @@ const handleBeforeUnload = () => {
|
|
|
5516
5539
|
};
|
|
5517
5540
|
|
|
5518
5541
|
const handleMessagePort2 = async (port, rpcId) => {
|
|
5519
|
-
const rpc = await
|
|
5542
|
+
const rpc = await create$8({
|
|
5520
5543
|
commandMap: {},
|
|
5521
5544
|
messagePort: port
|
|
5522
5545
|
});
|
|
5523
5546
|
if (rpcId) {
|
|
5524
|
-
set$
|
|
5547
|
+
set$c(rpcId, rpc);
|
|
5525
5548
|
}
|
|
5526
5549
|
};
|
|
5527
5550
|
|
|
5528
5551
|
const handleMessagePort = async (port, rpcId) => {
|
|
5529
|
-
const rpc = await
|
|
5552
|
+
const rpc = await create$a({
|
|
5530
5553
|
commandMap: {},
|
|
5531
5554
|
messagePort: port
|
|
5532
5555
|
});
|
|
5533
5556
|
if (rpcId) {
|
|
5534
|
-
set$
|
|
5557
|
+
set$c(rpcId, rpc);
|
|
5535
5558
|
}
|
|
5536
5559
|
};
|
|
5537
5560
|
|
|
@@ -6175,7 +6198,7 @@ const commandMap = {
|
|
|
6175
6198
|
[FileSystemMkdir]: mkdir$2,
|
|
6176
6199
|
[FileSystemReadDirWithFileTypes]: readDirWithFileTypes$2,
|
|
6177
6200
|
[FileSystemReadFile]: readFile$2,
|
|
6178
|
-
[FileSystemRemove]: remove$
|
|
6201
|
+
[FileSystemRemove]: remove$4,
|
|
6179
6202
|
[FileSystemRename]: rename$1,
|
|
6180
6203
|
[FileSystemWriteFile]: writeFile$3,
|
|
6181
6204
|
[FormattingExecuteFormmattingProvider]: executeFormattingProvider,
|
|
@@ -6292,10 +6315,10 @@ const commandMap = {
|
|
|
6292
6315
|
};
|
|
6293
6316
|
|
|
6294
6317
|
const launchRendererWorker = async () => {
|
|
6295
|
-
const rpc = await
|
|
6318
|
+
const rpc = await create$7({
|
|
6296
6319
|
commandMap: commandMap
|
|
6297
6320
|
});
|
|
6298
|
-
set$
|
|
6321
|
+
set$c(RendererWorker, rpc);
|
|
6299
6322
|
};
|
|
6300
6323
|
|
|
6301
6324
|
const listen = async () => {
|