@lvce-editor/menu-worker 1.2.0 → 1.5.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.
@@ -785,10 +785,10 @@ const send = (transport, method, ...params) => {
785
785
  const message = create$4(method, params);
786
786
  transport.send(message);
787
787
  };
788
- const invoke$3 = (ipc, method, ...params) => {
788
+ const invoke$2 = (ipc, method, ...params) => {
789
789
  return invokeHelper(ipc, method, params, false);
790
790
  };
791
- const invokeAndTransfer$1 = (ipc, method, ...params) => {
791
+ const invokeAndTransfer = (ipc, method, ...params) => {
792
792
  return invokeHelper(ipc, method, params, true);
793
793
  };
794
794
 
@@ -824,10 +824,10 @@ const createRpc = ipc => {
824
824
  send(ipc, method, ...params);
825
825
  },
826
826
  invoke(method, ...params) {
827
- return invoke$3(ipc, method, ...params);
827
+ return invoke$2(ipc, method, ...params);
828
828
  },
829
829
  invokeAndTransfer(method, ...params) {
830
- return invokeAndTransfer$1(ipc, method, ...params);
830
+ return invokeAndTransfer(ipc, method, ...params);
831
831
  },
832
832
  async dispose() {
833
833
  await ipc?.dispose();
@@ -879,430 +879,328 @@ const WebWorkerRpcClient = {
879
879
  __proto__: null,
880
880
  create: create$2
881
881
  };
882
- const createMockRpc = ({
883
- commandMap
884
- }) => {
885
- const invocations = [];
886
- const invoke = (method, ...params) => {
887
- invocations.push([method, ...params]);
888
- const command = commandMap[method];
889
- if (!command) {
890
- throw new Error(`command ${method} not found`);
891
- }
892
- return command(...params);
893
- };
894
- const mockRpc = {
895
- invoke,
896
- invokeAndTransfer: invoke,
897
- invocations
898
- };
899
- return mockRpc;
900
- };
901
882
 
902
883
  const Text = 12;
903
884
 
904
- const Escape$2 = 8;
905
- const Space$2 = 9;
906
- const End$2 = 255;
907
- const Home$2 = 12;
908
- const LeftArrow$2 = 13;
909
- const UpArrow$2 = 14;
910
- const RightArrow$2 = 15;
911
- const DownArrow$2 = 16;
912
-
913
- const CtrlCmd = 1 << 11 >>> 0;
914
- const Shift = 1 << 10 >>> 0;
915
-
916
- const DebugWorker = 55;
917
- const RendererWorker$1 = 1;
918
-
919
- const rpcs = Object.create(null);
920
- const set$2 = (id, rpc) => {
921
- rpcs[id] = rpc;
922
- };
923
- const get$1 = id => {
924
- return rpcs[id];
925
- };
885
+ const Backspace$1 = 1;
886
+ const Tab$1 = 2;
887
+ const Enter$1 = 3;
888
+ const Escape$1 = 8;
889
+ const Space$1 = 9;
890
+ const PageUp$1 = 10;
891
+ const PageDown$1 = 11;
892
+ const End$1 = 255;
893
+ const Home$1 = 12;
894
+ const LeftArrow$1 = 13;
895
+ const UpArrow$1 = 14;
896
+ const RightArrow$1 = 15;
897
+ const DownArrow$1 = 16;
898
+ const Insert$1 = 17;
899
+ const Delete$1 = 18;
900
+ const Digit0$1 = 19;
901
+ const Digit1$1 = 20;
902
+ const Digit2$1 = 21;
903
+ const Digit3$1 = 22;
904
+ const Digit4$1 = 23;
905
+ const Digit5$1 = 24;
906
+ const Digit6$1 = 25;
907
+ const Digit7$1 = 26;
908
+ const Digit8$1 = 27;
909
+ const Digit9$1 = 28;
910
+ const KeyA$1 = 29;
911
+ const KeyB$1 = 30;
912
+ const KeyC$1 = 31;
913
+ const KeyD$1 = 32;
914
+ const KeyE$1 = 33;
915
+ const KeyF$1 = 34;
916
+ const KeyG$1 = 35;
917
+ const KeyH$1 = 36;
918
+ const KeyI$1 = 37;
919
+ const KeyJ$1 = 38;
920
+ const KeyK$1 = 39;
921
+ const KeyL$1 = 40;
922
+ const KeyM$1 = 41;
923
+ const KeyN$1 = 42;
924
+ const KeyO$1 = 43;
925
+ const KeyP$1 = 44;
926
+ const KeyQ$1 = 45;
927
+ const KeyR$1 = 46;
928
+ const KeyS$1 = 47;
929
+ const KeyT$1 = 48;
930
+ const KeyU$1 = 49;
931
+ const KeyV$1 = 50;
932
+ const KeyW$1 = 51;
933
+ const KeyX$1 = 52;
934
+ const KeyY$1 = 53;
935
+ const KeyZ$1 = 54;
936
+ const F1$1 = 57;
937
+ const F2$1 = 58;
938
+ const F3$1 = 59;
939
+ const F4$1 = 60;
940
+ const F5$1 = 61;
941
+ const F6$1 = 62;
942
+ const Equal$1 = 84;
943
+ const Comma$1 = 85;
944
+ const Minus$1 = 86;
945
+ const Backquote$1 = 89;
946
+ const Backslash$1 = 91;
947
+ const Star$1 = 131;
948
+ const Plus$1 = 132;
926
949
 
927
- const create$1 = rpcId => {
928
- return {
929
- // @ts-ignore
930
- invoke(method, ...params) {
931
- const rpc = get$1(rpcId);
932
- // @ts-ignore
933
- return rpc.invoke(method, ...params);
934
- },
935
- // @ts-ignore
936
- invokeAndTransfer(method, ...params) {
937
- const rpc = get$1(rpcId);
938
- // @ts-ignore
939
- return rpc.invokeAndTransfer(method, ...params);
940
- },
941
- set(rpc) {
942
- set$2(rpcId, rpc);
943
- },
944
- async dispose() {
945
- const rpc = get$1(rpcId);
946
- await rpc.dispose();
947
- }
948
- };
949
- };
950
+ const Unknown = 'Unknown';
951
+ const Backspace = 'Backspace';
952
+ const Tab = 'Tab';
953
+ const Enter = 'Enter';
954
+ const Escape = 'Escape';
955
+ const Space = 'Space';
956
+ const PageUp = 'PageUp';
957
+ const PageDown = 'PageDown';
958
+ const End = 'End';
959
+ const Home = 'Home';
960
+ const LeftArrow = 'LeftArrow';
961
+ const UpArrow = 'UpArrow';
962
+ const RightArrow = 'RightArrow';
963
+ const DownArrow = 'DownArrow';
964
+ const Insert = 'Insert';
965
+ const Delete = 'Delete';
966
+ const Digit0 = '0';
967
+ const Digit1 = '1';
968
+ const Digit2 = '2';
969
+ const Digit3 = '3';
970
+ const Digit4 = '4';
971
+ const Digit5 = '5';
972
+ const Digit6 = '6';
973
+ const Digit7 = '7';
974
+ const Digit8 = '8';
975
+ const Digit9 = '9';
976
+ const KeyA = 'a';
977
+ const KeyB = 'b';
978
+ const KeyC = 'c';
979
+ const KeyD = 'd';
980
+ const KeyE = 'e';
981
+ const KeyF = 'f';
982
+ const KeyG = 'g';
983
+ const KeyH = 'h';
984
+ const KeyI = 'i';
985
+ const KeyJ = 'j';
986
+ const KeyK = 'k';
987
+ const KeyL = 'l';
988
+ const KeyM = 'm';
989
+ const KeyN = 'n';
990
+ const KeyO = 'o';
991
+ const KeyP = 'p';
992
+ const KeyQ = 'q';
993
+ const KeyR = 'r';
994
+ const KeyS = 's';
995
+ const KeyT = 't';
996
+ const KeyU = 'u';
997
+ const KeyV = 'v';
998
+ const KeyW = 'w';
999
+ const KeyX = 'x';
1000
+ const KeyY = 'y';
1001
+ const KeyZ = 'z';
1002
+ const F1 = 'F1';
1003
+ const F2 = 'F2';
1004
+ const F3 = 'F3';
1005
+ const F4 = 'F4';
1006
+ const F5 = 'F5';
1007
+ const F6 = 'F6';
1008
+ const Equal = '=';
1009
+ const Comma = ',';
1010
+ const Minus = 'Minus';
1011
+ const Backquote = 'Backquote';
1012
+ const Backslash = 'Backslash';
1013
+ const Star = '*';
1014
+ const Plus = '+';
950
1015
 
951
- const {
952
- invoke: invoke$2,
953
- invokeAndTransfer,
954
- set: set$1,
955
- dispose
956
- } = create$1(RendererWorker$1);
957
- const searchFileHtml = async uri => {
958
- return invoke$2('ExtensionHost.searchFileWithHtml', uri);
959
- };
960
- const getFilePathElectron = async file => {
961
- return invoke$2('FileSystemHandle.getFilePathElectron', file);
962
- };
963
- const showContextMenu = async (x, y, id, ...args) => {
964
- return invoke$2('ContextMenu.show', x, y, id, ...args);
965
- };
966
- const getElectronVersion = async () => {
967
- return invoke$2('Process.getElectronVersion');
968
- };
969
- const applyBulkReplacement = async bulkEdits => {
970
- await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
971
- };
972
- const setColorTheme = async id => {
973
- // @ts-ignore
974
- return invoke$2(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
975
- };
976
- const getNodeVersion = async () => {
977
- return invoke$2('Process.getNodeVersion');
978
- };
979
- const getChromeVersion = async () => {
980
- return invoke$2('Process.getChromeVersion');
981
- };
982
- const getV8Version = async () => {
983
- return invoke$2('Process.getV8Version');
984
- };
985
- const getFileHandles = async fileIds => {
986
- const files = await invoke$2('FileSystemHandle.getFileHandles', fileIds);
987
- return files;
988
- };
989
- const setWorkspacePath = async path => {
990
- await invoke$2('Workspace.setPath', path);
991
- };
992
- const registerWebViewInterceptor = async (id, port) => {
993
- await invokeAndTransfer('WebView.registerInterceptor', id, port);
994
- };
995
- const unregisterWebViewInterceptor = async id => {
996
- await invoke$2('WebView.unregisterInterceptor', id);
997
- };
998
- const sendMessagePortToEditorWorker = async (port, rpcId) => {
999
- const command = 'HandleMessagePort.handleMessagePort';
1000
- // @ts-ignore
1001
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1002
- };
1003
- const sendMessagePortToErrorWorker = async (port, rpcId) => {
1004
- const command = 'Errors.handleMessagePort';
1005
- // @ts-ignore
1006
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
1007
- };
1008
- const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
1009
- const command = 'Markdown.handleMessagePort';
1010
- // @ts-ignore
1011
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
1012
- };
1013
- const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1014
- const command = 'IconTheme.handleMessagePort';
1015
- // @ts-ignore
1016
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1017
- };
1018
- const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
1019
- const command = 'FileSystem.handleMessagePort';
1020
- // @ts-ignore
1021
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1022
- };
1023
- const readFile = async uri => {
1024
- return invoke$2('FileSystem.readFile', uri);
1025
- };
1026
- const getWebViewSecret = async key => {
1027
- // @ts-ignore
1028
- return invoke$2('WebView.getSecret', key);
1029
- };
1030
- const setWebViewPort = async (uid, port, origin, portType) => {
1031
- return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
1032
- };
1033
- const setFocus = key => {
1034
- return invoke$2('Focus.setFocus', key);
1035
- };
1036
- const getFileIcon = async options => {
1037
- return invoke$2('IconTheme.getFileIcon', options);
1038
- };
1039
- const getColorThemeNames = async () => {
1040
- return invoke$2('ColorTheme.getColorThemeNames');
1041
- };
1042
- const disableExtension = async id => {
1043
- // @ts-ignore
1044
- return invoke$2('ExtensionManagement.disable', id);
1045
- };
1046
- const enableExtension = async id => {
1047
- // @ts-ignore
1048
- return invoke$2('ExtensionManagement.enable', id);
1049
- };
1050
- const handleDebugChange = async params => {
1051
- // @ts-ignore
1052
- return invoke$2('Run And Debug.handleChange', params);
1053
- };
1054
- const getFolderIcon = async options => {
1055
- return invoke$2('IconTheme.getFolderIcon', options);
1056
- };
1057
- const closeWidget = async widgetId => {
1058
- return invoke$2('Viewlet.closeWidget', widgetId);
1059
- };
1060
- const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1061
- const command = 'HandleMessagePort.handleMessagePort2';
1062
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1063
- };
1064
- const sendMessagePortToSearchProcess = async port => {
1065
- await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
1066
- };
1067
- const confirm = async (message, options) => {
1068
- // @ts-ignore
1069
- const result = await invoke$2('ConfirmPrompt.prompt', message, options);
1070
- return result;
1071
- };
1072
- const getRecentlyOpened$1 = async () => {
1073
- return invoke$2(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1074
- };
1075
- const getKeyBindings$1 = async () => {
1076
- return invoke$2('KeyBindingsInitial.getKeyBindings');
1077
- };
1078
- const writeClipBoardText = async text => {
1079
- await invoke$2('ClipBoard.writeText', /* text */text);
1080
- };
1081
- const writeClipBoardImage = async blob => {
1082
- // @ts-ignore
1083
- await invoke$2('ClipBoard.writeImage', /* text */blob);
1084
- };
1085
- const searchFileMemory = async uri => {
1086
- // @ts-ignore
1087
- return invoke$2('ExtensionHost.searchFileWithMemory', uri);
1088
- };
1089
- const searchFileFetch = async uri => {
1090
- return invoke$2('ExtensionHost.searchFileWithFetch', uri);
1091
- };
1092
- const showMessageBox = async options => {
1093
- return invoke$2('ElectronDialog.showMessageBox', options);
1094
- };
1095
- const handleDebugResumed = async params => {
1096
- await invoke$2('Run And Debug.handleResumed', params);
1097
- };
1098
- const openWidget = async name => {
1099
- await invoke$2('Viewlet.openWidget', name);
1100
- };
1101
- const getIcons = async requests => {
1102
- const icons = await invoke$2('IconTheme.getIcons', requests);
1103
- return icons;
1104
- };
1105
- const activateByEvent = event => {
1106
- return invoke$2('ExtensionHostManagement.activateByEvent', event);
1107
- };
1108
- const setAdditionalFocus = focusKey => {
1109
- // @ts-ignore
1110
- return invoke$2('Focus.setAdditionalFocus', focusKey);
1111
- };
1112
- const getActiveEditorId = () => {
1113
- // @ts-ignore
1114
- return invoke$2('GetActiveEditor.getActiveEditorId');
1115
- };
1116
- const getWorkspacePath = () => {
1117
- return invoke$2('Workspace.getPath');
1118
- };
1119
- const sendMessagePortToRendererProcess = async port => {
1120
- const command = 'HandleMessagePort.handleMessagePort';
1121
- // @ts-ignore
1122
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1123
- };
1124
- const getPreference = async key => {
1125
- return await invoke$2('Preferences.get', key);
1126
- };
1127
- const getAllExtensions = async () => {
1128
- return invoke$2('ExtensionManagement.getAllExtensions');
1129
- };
1130
- const rerenderEditor = async key => {
1131
- // @ts-ignore
1132
- return invoke$2('Editor.rerender', key);
1133
- };
1134
- const handleDebugPaused = async params => {
1135
- await invoke$2('Run And Debug.handlePaused', params);
1136
- };
1137
- const openUri = async (uri, focus, options) => {
1138
- await invoke$2('Main.openUri', uri, focus, options);
1139
- };
1140
- const sendMessagePortToSyntaxHighlightingWorker = async port => {
1141
- await invokeAndTransfer(
1142
- // @ts-ignore
1143
- 'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
1144
- };
1145
- const handleDebugScriptParsed = async script => {
1146
- await invoke$2('Run And Debug.handleScriptParsed', script);
1147
- };
1148
- const getWindowId = async () => {
1149
- return invoke$2('GetWindowId.getWindowId');
1150
- };
1151
- const getBlob = async uri => {
1152
- // @ts-ignore
1153
- return invoke$2('FileSystem.getBlob', uri);
1154
- };
1155
- const getExtensionCommands = async () => {
1156
- return invoke$2('ExtensionHost.getCommands');
1157
- };
1158
- const showErrorDialog = async errorInfo => {
1159
- // @ts-ignore
1160
- await invoke$2('ErrorHandling.showErrorDialog', errorInfo);
1161
- };
1162
- const getFolderSize = async uri => {
1163
- // @ts-ignore
1164
- return await invoke$2('FileSystem.getFolderSize', uri);
1165
- };
1166
- const getExtension = async id => {
1167
- // @ts-ignore
1168
- return invoke$2('ExtensionManagement.getExtension', id);
1169
- };
1170
- const getMarkdownDom = async html => {
1171
- // @ts-ignore
1172
- return invoke$2('Markdown.getVirtualDom', html);
1173
- };
1174
- const renderMarkdown = async (markdown, options) => {
1175
- // @ts-ignore
1176
- return invoke$2('Markdown.renderMarkdown', markdown, options);
1177
- };
1178
- const openNativeFolder = async uri => {
1179
- // @ts-ignore
1180
- await invoke$2('OpenNativeFolder.openNativeFolder', uri);
1181
- };
1182
- const uninstallExtension = async id => {
1183
- return invoke$2('ExtensionManagement.uninstall', id);
1184
- };
1185
- const installExtension = async id => {
1186
- // @ts-ignore
1187
- return invoke$2('ExtensionManagement.install', id);
1188
- };
1189
- const openExtensionSearch = async () => {
1190
- // @ts-ignore
1191
- return invoke$2('SideBar.openViewlet', 'Extensions');
1192
- };
1193
- const setExtensionsSearchValue = async searchValue => {
1194
- // @ts-ignore
1195
- return invoke$2('Extensions.handleInput', searchValue);
1196
- };
1197
- const openExternal = async uri => {
1198
- // @ts-ignore
1199
- await invoke$2('Open.openExternal', uri);
1200
- };
1201
- const openUrl = async uri => {
1202
- // @ts-ignore
1203
- await invoke$2('Open.openUrl', uri);
1204
- };
1205
- const getAllPreferences = async () => {
1206
- // @ts-ignore
1207
- return invoke$2('Preferences.getAll');
1016
+ const getKeyCodeString = keyCode => {
1017
+ switch (keyCode) {
1018
+ case Backspace$1:
1019
+ return Backspace;
1020
+ case Tab$1:
1021
+ return Tab;
1022
+ case Escape$1:
1023
+ return Escape;
1024
+ case Enter$1:
1025
+ return Enter;
1026
+ case Space$1:
1027
+ return Space;
1028
+ case PageUp$1:
1029
+ return PageUp;
1030
+ case PageDown$1:
1031
+ return PageDown;
1032
+ case End$1:
1033
+ return End;
1034
+ case Home$1:
1035
+ return Home;
1036
+ case LeftArrow$1:
1037
+ return LeftArrow;
1038
+ case UpArrow$1:
1039
+ return UpArrow;
1040
+ case RightArrow$1:
1041
+ return RightArrow;
1042
+ case DownArrow$1:
1043
+ return DownArrow;
1044
+ case Insert$1:
1045
+ return Insert;
1046
+ case Delete$1:
1047
+ return Delete;
1048
+ case Digit0$1:
1049
+ return Digit0;
1050
+ case Digit1$1:
1051
+ return Digit1;
1052
+ case Digit2$1:
1053
+ return Digit2;
1054
+ case Digit3$1:
1055
+ return Digit3;
1056
+ case Digit4$1:
1057
+ return Digit4;
1058
+ case Digit5$1:
1059
+ return Digit5;
1060
+ case Digit6$1:
1061
+ return Digit6;
1062
+ case Digit7$1:
1063
+ return Digit7;
1064
+ case Digit8$1:
1065
+ return Digit8;
1066
+ case Digit9$1:
1067
+ return Digit9;
1068
+ case KeyA$1:
1069
+ return KeyA;
1070
+ case KeyB$1:
1071
+ return KeyB;
1072
+ case KeyC$1:
1073
+ return KeyC;
1074
+ case KeyD$1:
1075
+ return KeyD;
1076
+ case KeyE$1:
1077
+ return KeyE;
1078
+ case KeyF$1:
1079
+ return KeyF;
1080
+ case KeyG$1:
1081
+ return KeyG;
1082
+ case KeyH$1:
1083
+ return KeyH;
1084
+ case KeyI$1:
1085
+ return KeyI;
1086
+ case KeyJ$1:
1087
+ return KeyJ;
1088
+ case KeyK$1:
1089
+ return KeyK;
1090
+ case KeyL$1:
1091
+ return KeyL;
1092
+ case KeyM$1:
1093
+ return KeyM;
1094
+ case KeyN$1:
1095
+ return KeyN;
1096
+ case KeyO$1:
1097
+ return KeyO;
1098
+ case KeyP$1:
1099
+ return KeyP;
1100
+ case KeyQ$1:
1101
+ return KeyQ;
1102
+ case KeyR$1:
1103
+ return KeyR;
1104
+ case KeyS$1:
1105
+ return KeyS;
1106
+ case KeyT$1:
1107
+ return KeyT;
1108
+ case KeyU$1:
1109
+ return KeyU;
1110
+ case KeyV$1:
1111
+ return KeyV;
1112
+ case KeyW$1:
1113
+ return KeyW;
1114
+ case KeyX$1:
1115
+ return KeyX;
1116
+ case KeyY$1:
1117
+ return KeyY;
1118
+ case KeyZ$1:
1119
+ return KeyZ;
1120
+ case F1$1:
1121
+ return F1;
1122
+ case F2$1:
1123
+ return F2;
1124
+ case F3$1:
1125
+ return F3;
1126
+ case F4$1:
1127
+ return F4;
1128
+ case F5$1:
1129
+ return F5;
1130
+ case F6$1:
1131
+ return F6;
1132
+ case Backslash$1:
1133
+ return Backslash;
1134
+ case Equal$1:
1135
+ return Equal;
1136
+ case Comma$1:
1137
+ return Comma;
1138
+ case Backquote$1:
1139
+ return Backquote;
1140
+ case Plus$1:
1141
+ return Plus;
1142
+ case Star$1:
1143
+ return Star;
1144
+ case Minus$1:
1145
+ return Minus;
1146
+ default:
1147
+ return Unknown;
1148
+ }
1208
1149
  };
1209
- const showSaveFilePicker = async () => {
1210
- // @ts-ignore
1211
- return invoke$2('FilePicker.showSaveFilePicker');
1150
+
1151
+ const CtrlCmd = 1 << 11 >>> 0;
1152
+ const Shift = 1 << 10 >>> 0;
1153
+
1154
+ const parseKey = rawKey => {
1155
+ const isCtrl = Boolean(rawKey & CtrlCmd);
1156
+ const isShift = Boolean(rawKey & Shift);
1157
+ const keyCode = rawKey & 0x00_00_00_ff;
1158
+ const key = getKeyCodeString(keyCode);
1159
+ return {
1160
+ key,
1161
+ isCtrl,
1162
+ isShift
1163
+ };
1212
1164
  };
1213
- const getLogsDir = async () => {
1214
- // @ts-ignore
1215
- return invoke$2('PlatformPaths.getLogsDir');
1165
+
1166
+ const RendererWorker = 1;
1167
+
1168
+ const rpcs = Object.create(null);
1169
+ const set$2 = (id, rpc) => {
1170
+ rpcs[id] = rpc;
1216
1171
  };
1217
- const registerMockRpc = commandMap => {
1218
- const mockRpc = createMockRpc({
1219
- commandMap
1220
- });
1221
- set$1(mockRpc);
1222
- return mockRpc;
1172
+ const get$1 = id => {
1173
+ return rpcs[id];
1223
1174
  };
1224
1175
 
1225
- const RendererWorker = {
1226
- __proto__: null,
1227
- activateByEvent,
1228
- applyBulkReplacement,
1229
- closeWidget,
1230
- confirm,
1231
- disableExtension,
1232
- dispose,
1233
- enableExtension,
1234
- getActiveEditorId,
1235
- getAllExtensions,
1236
- getAllPreferences,
1237
- getBlob,
1238
- getChromeVersion,
1239
- getColorThemeNames,
1240
- getElectronVersion,
1241
- getExtension,
1242
- getExtensionCommands,
1243
- getFileHandles,
1244
- getFileIcon,
1245
- getFilePathElectron,
1246
- getFolderIcon,
1247
- getFolderSize,
1248
- getIcons,
1249
- getKeyBindings: getKeyBindings$1,
1250
- getLogsDir,
1251
- getMarkdownDom,
1252
- getNodeVersion,
1253
- getPreference,
1254
- getRecentlyOpened: getRecentlyOpened$1,
1255
- getV8Version,
1256
- getWebViewSecret,
1257
- getWindowId,
1258
- getWorkspacePath,
1259
- handleDebugChange,
1260
- handleDebugPaused,
1261
- handleDebugResumed,
1262
- handleDebugScriptParsed,
1263
- installExtension,
1264
- invoke: invoke$2,
1265
- invokeAndTransfer,
1266
- openExtensionSearch,
1267
- openExternal,
1268
- openNativeFolder,
1269
- openUri,
1270
- openUrl,
1271
- openWidget,
1272
- readFile,
1273
- registerMockRpc,
1274
- registerWebViewInterceptor,
1275
- renderMarkdown,
1276
- rerenderEditor,
1277
- searchFileFetch,
1278
- searchFileHtml,
1279
- searchFileMemory,
1280
- sendMessagePortToEditorWorker,
1281
- sendMessagePortToErrorWorker,
1282
- sendMessagePortToExtensionHostWorker,
1283
- sendMessagePortToFileSystemWorker,
1284
- sendMessagePortToIconThemeWorker,
1285
- sendMessagePortToMarkdownWorker,
1286
- sendMessagePortToRendererProcess,
1287
- sendMessagePortToSearchProcess,
1288
- sendMessagePortToSyntaxHighlightingWorker,
1289
- set: set$1,
1290
- setAdditionalFocus,
1291
- setColorTheme,
1292
- setExtensionsSearchValue,
1293
- setFocus,
1294
- setWebViewPort,
1295
- setWorkspacePath,
1296
- showContextMenu,
1297
- showErrorDialog,
1298
- showMessageBox,
1299
- showSaveFilePicker,
1300
- uninstallExtension,
1301
- unregisterWebViewInterceptor,
1302
- writeClipBoardImage,
1303
- writeClipBoardText
1176
+ const create$1 = rpcId => {
1177
+ return {
1178
+ // @ts-ignore
1179
+ invoke(method, ...params) {
1180
+ const rpc = get$1(rpcId);
1181
+ // @ts-ignore
1182
+ return rpc.invoke(method, ...params);
1183
+ },
1184
+ // @ts-ignore
1185
+ invokeAndTransfer(method, ...params) {
1186
+ const rpc = get$1(rpcId);
1187
+ // @ts-ignore
1188
+ return rpc.invokeAndTransfer(method, ...params);
1189
+ },
1190
+ set(rpc) {
1191
+ set$2(rpcId, rpc);
1192
+ },
1193
+ async dispose() {
1194
+ const rpc = get$1(rpcId);
1195
+ await rpc.dispose();
1196
+ }
1197
+ };
1304
1198
  };
1305
1199
 
1200
+ const {
1201
+ invoke: invoke$1,
1202
+ set: set$1} = create$1(RendererWorker);
1203
+
1306
1204
  const matchesArgs = (a, b) => {
1307
1205
  if (!a && !b) {
1308
1206
  return true;
@@ -1329,11 +1227,11 @@ const getCommandKeyBinding = (keyBindings, command, args) => {
1329
1227
  return undefined;
1330
1228
  };
1331
1229
 
1332
- const invoke$1 = async (method, ...params) => {
1230
+ const invoke = async (method, ...params) => {
1333
1231
  // TODO
1334
1232
  };
1335
1233
 
1336
- const state$1 = {
1234
+ const state$2 = {
1337
1235
  /**
1338
1236
  * @type {any}
1339
1237
  */
@@ -1641,11 +1539,8 @@ const MenuEntriesHelp = {
1641
1539
  id: id$6
1642
1540
  };
1643
1541
 
1644
- const {
1645
- invoke} = RendererWorker;
1646
-
1647
1542
  const getRecentlyOpened = () => {
1648
- return invoke(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1543
+ return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1649
1544
  };
1650
1545
 
1651
1546
  const File = 'file://';
@@ -1886,412 +1781,142 @@ const getMenuEntries$3 = async platform => {
1886
1781
  const MenuEntriesTitleBar = {
1887
1782
  __proto__: null,
1888
1783
  getMenuEntries: getMenuEntries$3,
1889
- id: id$1
1890
- };
1891
-
1892
- const id = View$1;
1893
- const getMenuEntries$2 = () => {
1894
- return [];
1895
- };
1896
-
1897
- const MenuEntriesView = {
1898
- __proto__: null,
1899
- getMenuEntries: getMenuEntries$2,
1900
- id
1901
- };
1902
-
1903
- const menus$1 = [MenuEntriesEdit, MenuEntriesFile, MenuEntriesGo, MenuEntriesHelp, MenuEntriesRun, MenuEntriesSelection, MenuEntriesTerminal, MenuEntriesTitleBar, MenuEntriesView, MenuEntriesOpenRecent];
1904
- const getMenus = () => {
1905
- return menus$1;
1906
- };
1907
- const getModule$1 = id => {
1908
- for (const module of menus$1) {
1909
- if (module.id === id) {
1910
- return module;
1911
- }
1912
- }
1913
- return undefined;
1914
- };
1915
- const getMenuEntries$1 = async (id, ...args) => {
1916
- try {
1917
- const module = getModule$1(id);
1918
- // @ts-ignore
1919
- const inject = module.inject || [];
1920
- // @ts-ignore
1921
- return module.getMenuEntries(...args);
1922
- } catch (error) {
1923
- throw new VError(error, `Failed to load menu entries for id ${id}`);
1924
- }
1925
- };
1926
-
1927
- const addKeyBindings = menuEntries => {
1928
- const keyBindings = state$1.matchingKeyBindings;
1929
- const newMenuEntries = [];
1930
- for (const menuEntry of menuEntries) {
1931
- const keyBinding = getCommandKeyBinding(keyBindings, menuEntry.command, menuEntry.args);
1932
- const key = keyBinding ? keyBinding.key : 0;
1933
- const newMenuEntry = {
1934
- ...menuEntry,
1935
- key
1936
- };
1937
- newMenuEntries.push(newMenuEntry);
1938
- }
1939
- return newMenuEntries;
1940
- };
1941
- const getMenuEntriesWithKeyBindings = async (id, ...args) => {
1942
- const menuEntries = await getMenuEntries$1(id, ...args);
1943
- const newMenuEntries = addKeyBindings(menuEntries);
1944
- return newMenuEntries;
1945
- };
1946
- const getMenuEntriesWithKeyBindings2 = async (uid, menuId, ...args) => {
1947
- // @ts-ignore
1948
- const menuEntries = await undefined(uid, menuId, ...args);
1949
- const newMenuEntries = addKeyBindings(menuEntries);
1950
- return newMenuEntries;
1951
- };
1952
-
1953
- const Menu$1 = 'menu';
1954
- const MenuItem$1 = 'menuitem';
1955
- const MenuItemCheckBox = 'menuitemcheckbox';
1956
- const Separator = 'separator';
1957
-
1958
- const MaskIconCheck = 'MaskIconCheck';
1959
- const Menu = 'Menu';
1960
- const MenuItem = 'MenuItem';
1961
- const MenuItemCheckMark = 'MenuItemCheckMark';
1962
- const MenuItemCheckmarkIcon = 'MenuItemCheckmarkIcon';
1963
- const MenuItemFocused = 'MenuItemFocused';
1964
- const MenuItemKeyBinding = 'MenuItemKeyBinding';
1965
- const MenuItemSeparator = 'MenuItemSeparator';
1966
- const MenuItemSeparatorLine = 'MenuItemSeparatorLine';
1967
- const MenuItemSubMenu = 'MenuItemSubMenu';
1968
- const MenuItemSubMenuArrowRight = 'MenuItemSubMenuArrowRight';
1969
-
1970
- const mergeClassNames = (...classNames) => {
1971
- return classNames.filter(Boolean).join(' ');
1972
- };
1973
-
1974
- const text = data => {
1975
- return {
1976
- type: Text,
1977
- text: data,
1978
- childCount: 0
1979
- };
1980
- };
1981
-
1982
- const Div = 4;
1983
- const Span = 8;
1984
-
1985
- const checkboxChecked = {
1986
- type: Div,
1987
- className: mergeClassNames(MenuItem, MenuItemCheckMark),
1988
- role: MenuItemCheckBox,
1989
- ariaChecked: true,
1990
- tabIndex: -1,
1991
- childCount: 2
1992
- };
1993
- const checkMark = {
1994
- type: Div,
1995
- className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck)
1996
- };
1997
- const getMenuItemCheckedDom = menuItem => {
1998
- const {
1999
- label
2000
- } = menuItem;
2001
- return [checkboxChecked, checkMark, text(label)];
2002
- };
2003
-
2004
- const getKeyBindingString = (key, altKey, ctrlKey, shiftKey, metaKey) => {
2005
- let string = '';
2006
- if (ctrlKey) {
2007
- string += 'Ctrl+';
2008
- }
2009
- if (shiftKey) {
2010
- string += 'Shift+';
2011
- }
2012
- string += key.toUpperCase();
2013
- return string;
2014
- };
2015
-
2016
- const Backspace$1 = 1;
2017
- const Tab$1 = 2;
2018
- const Enter$1 = 3;
2019
- const Escape$1 = 8;
2020
- const Space$1 = 9;
2021
- const PageUp$1 = 10;
2022
- const PageDown$1 = 11;
2023
- const End$1 = 255;
2024
- const Home$1 = 12;
2025
- const LeftArrow$1 = 13;
2026
- const UpArrow$1 = 14;
2027
- const RightArrow$1 = 15;
2028
- const DownArrow$1 = 16;
2029
- const Insert$1 = 17;
2030
- const Delete$1 = 18;
2031
- const Digit0$1 = 19;
2032
- const Digit1$1 = 20;
2033
- const Digit2$1 = 21;
2034
- const Digit3$1 = 22;
2035
- const Digit4$1 = 23;
2036
- const Digit5$1 = 24;
2037
- const Digit6$1 = 25;
2038
- const Digit7$1 = 26;
2039
- const Digit8$1 = 27;
2040
- const Digit9$1 = 28;
2041
- const KeyA$1 = 29;
2042
- const KeyB$1 = 30;
2043
- const KeyC$1 = 31;
2044
- const KeyD$1 = 32;
2045
- const KeyE$1 = 33;
2046
- const KeyF$1 = 34;
2047
- const KeyG$1 = 35;
2048
- const KeyH$1 = 36;
2049
- const KeyI$1 = 37;
2050
- const KeyJ$1 = 38;
2051
- const KeyK$1 = 39;
2052
- const KeyL$1 = 40;
2053
- const KeyM$1 = 41;
2054
- const KeyN$1 = 42;
2055
- const KeyO$1 = 43;
2056
- const KeyP$1 = 44;
2057
- const KeyQ$1 = 45;
2058
- const KeyR$1 = 46;
2059
- const KeyS$1 = 47;
2060
- const KeyT$1 = 48;
2061
- const KeyU$1 = 49;
2062
- const KeyV$1 = 50;
2063
- const KeyW$1 = 51;
2064
- const KeyX$1 = 52;
2065
- const KeyY$1 = 53;
2066
- const KeyZ$1 = 54;
2067
- const F1$1 = 57;
2068
- const F2$1 = 58;
2069
- const F3$1 = 59;
2070
- const F4$1 = 60;
2071
- const F5$1 = 61;
2072
- const F6$1 = 62;
2073
- const Equal$1 = 84;
2074
- const Comma$1 = 85;
2075
- const Minus$1 = 86;
2076
- const Backquote$1 = 89;
2077
- const Backslash$1 = 91;
2078
- const Star$1 = 131;
2079
- const Plus$1 = 132;
2080
-
2081
- const Unknown = 'Unknown';
2082
- const Backspace = 'Backspace';
2083
- const Tab = 'Tab';
2084
- const Enter = 'Enter';
2085
- const Escape = 'Escape';
2086
- const Space = 'Space';
2087
- const PageUp = 'PageUp';
2088
- const PageDown = 'PageDown';
2089
- const End = 'End';
2090
- const Home = 'Home';
2091
- const LeftArrow = 'LeftArrow';
2092
- const UpArrow = 'UpArrow';
2093
- const RightArrow = 'RightArrow';
2094
- const DownArrow = 'DownArrow';
2095
- const Insert = 'Insert';
2096
- const Delete = 'Delete';
2097
- const Digit0 = '0';
2098
- const Digit1 = '1';
2099
- const Digit2 = '2';
2100
- const Digit3 = '3';
2101
- const Digit4 = '4';
2102
- const Digit5 = '5';
2103
- const Digit6 = '6';
2104
- const Digit7 = '7';
2105
- const Digit8 = '8';
2106
- const Digit9 = '9';
2107
- const KeyA = 'a';
2108
- const KeyB = 'b';
2109
- const KeyC = 'c';
2110
- const KeyD = 'd';
2111
- const KeyE = 'e';
2112
- const KeyF = 'f';
2113
- const KeyG = 'g';
2114
- const KeyH = 'h';
2115
- const KeyI = 'i';
2116
- const KeyJ = 'j';
2117
- const KeyK = 'k';
2118
- const KeyL = 'l';
2119
- const KeyM = 'm';
2120
- const KeyN = 'n';
2121
- const KeyO = 'o';
2122
- const KeyP = 'p';
2123
- const KeyQ = 'q';
2124
- const KeyR = 'r';
2125
- const KeyS = 's';
2126
- const KeyT = 't';
2127
- const KeyU = 'u';
2128
- const KeyV = 'v';
2129
- const KeyW = 'w';
2130
- const KeyX = 'x';
2131
- const KeyY = 'y';
2132
- const KeyZ = 'z';
2133
- const F1 = 'F1';
2134
- const F2 = 'F2';
2135
- const F3 = 'F3';
2136
- const F4 = 'F4';
2137
- const F5 = 'F5';
2138
- const F6 = 'F6';
2139
- const Equal = '=';
2140
- const Comma = ',';
2141
- const Minus = 'Minus';
2142
- const Backquote = 'Backquote';
2143
- const Backslash = 'Backslash';
2144
- const Star = '*';
2145
- const Plus = '+';
2146
-
2147
- const getKeyCodeString = keyCode => {
2148
- switch (keyCode) {
2149
- case Backspace$1:
2150
- return Backspace;
2151
- case Tab$1:
2152
- return Tab;
2153
- case Escape$1:
2154
- return Escape;
2155
- case Enter$1:
2156
- return Enter;
2157
- case Space$1:
2158
- return Space;
2159
- case PageUp$1:
2160
- return PageUp;
2161
- case PageDown$1:
2162
- return PageDown;
2163
- case End$1:
2164
- return End;
2165
- case Home$1:
2166
- return Home;
2167
- case LeftArrow$1:
2168
- return LeftArrow;
2169
- case UpArrow$1:
2170
- return UpArrow;
2171
- case RightArrow$1:
2172
- return RightArrow;
2173
- case DownArrow$1:
2174
- return DownArrow;
2175
- case Insert$1:
2176
- return Insert;
2177
- case Delete$1:
2178
- return Delete;
2179
- case Digit0$1:
2180
- return Digit0;
2181
- case Digit1$1:
2182
- return Digit1;
2183
- case Digit2$1:
2184
- return Digit2;
2185
- case Digit3$1:
2186
- return Digit3;
2187
- case Digit4$1:
2188
- return Digit4;
2189
- case Digit5$1:
2190
- return Digit5;
2191
- case Digit6$1:
2192
- return Digit6;
2193
- case Digit7$1:
2194
- return Digit7;
2195
- case Digit8$1:
2196
- return Digit8;
2197
- case Digit9$1:
2198
- return Digit9;
2199
- case KeyA$1:
2200
- return KeyA;
2201
- case KeyB$1:
2202
- return KeyB;
2203
- case KeyC$1:
2204
- return KeyC;
2205
- case KeyD$1:
2206
- return KeyD;
2207
- case KeyE$1:
2208
- return KeyE;
2209
- case KeyF$1:
2210
- return KeyF;
2211
- case KeyG$1:
2212
- return KeyG;
2213
- case KeyH$1:
2214
- return KeyH;
2215
- case KeyI$1:
2216
- return KeyI;
2217
- case KeyJ$1:
2218
- return KeyJ;
2219
- case KeyK$1:
2220
- return KeyK;
2221
- case KeyL$1:
2222
- return KeyL;
2223
- case KeyM$1:
2224
- return KeyM;
2225
- case KeyN$1:
2226
- return KeyN;
2227
- case KeyO$1:
2228
- return KeyO;
2229
- case KeyP$1:
2230
- return KeyP;
2231
- case KeyQ$1:
2232
- return KeyQ;
2233
- case KeyR$1:
2234
- return KeyR;
2235
- case KeyS$1:
2236
- return KeyS;
2237
- case KeyT$1:
2238
- return KeyT;
2239
- case KeyU$1:
2240
- return KeyU;
2241
- case KeyV$1:
2242
- return KeyV;
2243
- case KeyW$1:
2244
- return KeyW;
2245
- case KeyX$1:
2246
- return KeyX;
2247
- case KeyY$1:
2248
- return KeyY;
2249
- case KeyZ$1:
2250
- return KeyZ;
2251
- case F1$1:
2252
- return F1;
2253
- case F2$1:
2254
- return F2;
2255
- case F3$1:
2256
- return F3;
2257
- case F4$1:
2258
- return F4;
2259
- case F5$1:
2260
- return F5;
2261
- case F6$1:
2262
- return F6;
2263
- case Backslash$1:
2264
- return Backslash;
2265
- case Equal$1:
2266
- return Equal;
2267
- case Comma$1:
2268
- return Comma;
2269
- case Backquote$1:
2270
- return Backquote;
2271
- case Plus$1:
2272
- return Plus;
2273
- case Star$1:
2274
- return Star;
2275
- case Minus$1:
2276
- return Minus;
2277
- default:
2278
- return Unknown;
1784
+ id: id$1
1785
+ };
1786
+
1787
+ const id = View$1;
1788
+ const getMenuEntries$2 = () => {
1789
+ return [];
1790
+ };
1791
+
1792
+ const MenuEntriesView = {
1793
+ __proto__: null,
1794
+ getMenuEntries: getMenuEntries$2,
1795
+ id
1796
+ };
1797
+
1798
+ const menus$1 = [MenuEntriesEdit, MenuEntriesFile, MenuEntriesGo, MenuEntriesHelp, MenuEntriesRun, MenuEntriesSelection, MenuEntriesTerminal, MenuEntriesTitleBar, MenuEntriesView, MenuEntriesOpenRecent];
1799
+ const getMenus = () => {
1800
+ return menus$1;
1801
+ };
1802
+ const getModule$1 = id => {
1803
+ for (const module of menus$1) {
1804
+ if (module.id === id) {
1805
+ return module;
1806
+ }
1807
+ }
1808
+ return undefined;
1809
+ };
1810
+ const getMenuEntries$1 = async (id, ...args) => {
1811
+ try {
1812
+ const module = getModule$1(id);
1813
+ // @ts-ignore
1814
+ const inject = module.inject || [];
1815
+ // @ts-ignore
1816
+ return module.getMenuEntries(...args);
1817
+ } catch (error) {
1818
+ throw new VError(error, `Failed to load menu entries for id ${id}`);
1819
+ }
1820
+ };
1821
+ const getMenuEntries2 = async (uid, menuId, ...args) => {
1822
+ try {
1823
+ const module = await getModule$1(menuId);
1824
+ // @ts-ignore
1825
+ return module.getMenuEntries(uid, ...args);
1826
+ } catch (error) {
1827
+ throw new VError(error, `Failed to load menu entries for id ${menuId}`);
2279
1828
  }
2280
1829
  };
2281
1830
 
2282
- const parseKey = rawKey => {
2283
- number(rawKey);
2284
- const isCtrl = Boolean(rawKey & CtrlCmd);
2285
- const isShift = Boolean(rawKey & Shift);
2286
- const keyCode = rawKey & 0x00_00_00_ff;
2287
- const key = getKeyCodeString(keyCode);
1831
+ const addKeyBindings = menuEntries => {
1832
+ const keyBindings = state$2.matchingKeyBindings;
1833
+ const newMenuEntries = [];
1834
+ for (const menuEntry of menuEntries) {
1835
+ const keyBinding = getCommandKeyBinding(keyBindings, menuEntry.command, menuEntry.args);
1836
+ const key = keyBinding ? keyBinding.key : 0;
1837
+ const newMenuEntry = {
1838
+ ...menuEntry,
1839
+ key
1840
+ };
1841
+ newMenuEntries.push(newMenuEntry);
1842
+ }
1843
+ return newMenuEntries;
1844
+ };
1845
+ const getMenuEntriesWithKeyBindings = async (id, ...args) => {
1846
+ const menuEntries = await getMenuEntries$1(id, ...args);
1847
+ const newMenuEntries = addKeyBindings(menuEntries);
1848
+ return newMenuEntries;
1849
+ };
1850
+ const getMenuEntriesWithKeyBindings2 = async (uid, menuId, ...args) => {
1851
+ // @ts-ignore
1852
+ const menuEntries = await getMenuEntries2(uid, menuId, ...args);
1853
+ const newMenuEntries = addKeyBindings(menuEntries);
1854
+ return newMenuEntries;
1855
+ };
1856
+
1857
+ const Menu$1 = 'menu';
1858
+ const MenuItem$1 = 'menuitem';
1859
+ const MenuItemCheckBox = 'menuitemcheckbox';
1860
+ const Separator = 'separator';
1861
+
1862
+ const MaskIconCheck = 'MaskIconCheck';
1863
+ const Menu = 'Menu';
1864
+ const MenuItem = 'MenuItem';
1865
+ const MenuItemCheckMark = 'MenuItemCheckMark';
1866
+ const MenuItemCheckmarkIcon = 'MenuItemCheckmarkIcon';
1867
+ const MenuItemFocused = 'MenuItemFocused';
1868
+ const MenuItemKeyBinding = 'MenuItemKeyBinding';
1869
+ const MenuItemSeparator = 'MenuItemSeparator';
1870
+ const MenuItemSeparatorLine = 'MenuItemSeparatorLine';
1871
+ const MenuItemSubMenu = 'MenuItemSubMenu';
1872
+ const MenuItemSubMenuArrowRight = 'MenuItemSubMenuArrowRight';
1873
+
1874
+ const mergeClassNames = (...classNames) => {
1875
+ return classNames.filter(Boolean).join(' ');
1876
+ };
1877
+
1878
+ const text = data => {
2288
1879
  return {
2289
- key,
2290
- isCtrl,
2291
- isShift
1880
+ type: Text,
1881
+ text: data,
1882
+ childCount: 0
2292
1883
  };
2293
1884
  };
2294
1885
 
1886
+ const Div = 4;
1887
+ const Span = 8;
1888
+
1889
+ const checkboxChecked = {
1890
+ type: Div,
1891
+ className: mergeClassNames(MenuItem, MenuItemCheckMark),
1892
+ role: MenuItemCheckBox,
1893
+ ariaChecked: true,
1894
+ tabIndex: -1,
1895
+ childCount: 2
1896
+ };
1897
+ const checkMark = {
1898
+ type: Div,
1899
+ className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck)
1900
+ };
1901
+ const getMenuItemCheckedDom = menuItem => {
1902
+ const {
1903
+ label
1904
+ } = menuItem;
1905
+ return [checkboxChecked, checkMark, text(label)];
1906
+ };
1907
+
1908
+ const getKeyBindingString = (key, altKey, ctrlKey, shiftKey, metaKey) => {
1909
+ let string = '';
1910
+ if (ctrlKey) {
1911
+ string += 'Ctrl+';
1912
+ }
1913
+ if (shiftKey) {
1914
+ string += 'Shift+';
1915
+ }
1916
+ string += key.toUpperCase();
1917
+ return string;
1918
+ };
1919
+
2295
1920
  const getMenuItemDefaultDom = menuItem => {
2296
1921
  const {
2297
1922
  label,
@@ -2461,14 +2086,14 @@ const getVisible = (items, focusedIndex, expanded, level) => {
2461
2086
  };
2462
2087
 
2463
2088
  // TODO lazyload menuEntries and use Command.execute (maybe)
2464
- const CONTEXT_MENU_WIDTH = 250;
2465
- const state = {
2089
+ const CONTEXT_MENU_WIDTH$1 = 250;
2090
+ const state$1 = {
2466
2091
  menus: []};
2467
- const addMenuInternal = menu => {
2468
- if (state.menus.length > 5) {
2092
+ const addMenuInternal$1 = menu => {
2093
+ if (state$1.menus.length > 5) {
2469
2094
  throw new Error('too many menus');
2470
2095
  }
2471
- state.menus.push(menu);
2096
+ state$1.menus.push(menu);
2472
2097
  return menu;
2473
2098
  };
2474
2099
 
@@ -2478,26 +2103,26 @@ const addMenuInternal = menu => {
2478
2103
 
2479
2104
  // TODO more tests
2480
2105
 
2481
- const CONTEXT_MENU_ITEM_HEIGHT = 26;
2482
- const CONTEXT_MENU_SEPARATOR_HEIGHT = 11;
2483
- const CONTEXT_MENU_PADDING = 8;
2484
- const getMenuHeight = items => {
2485
- let height = CONTEXT_MENU_PADDING;
2106
+ const CONTEXT_MENU_ITEM_HEIGHT$1 = 26;
2107
+ const CONTEXT_MENU_SEPARATOR_HEIGHT$1 = 11;
2108
+ const CONTEXT_MENU_PADDING$1 = 8;
2109
+ const getMenuHeight$1 = items => {
2110
+ let height = CONTEXT_MENU_PADDING$1;
2486
2111
  for (const item of items) {
2487
2112
  switch (item.flags) {
2488
2113
  case Separator$1:
2489
- height += CONTEXT_MENU_SEPARATOR_HEIGHT;
2114
+ height += CONTEXT_MENU_SEPARATOR_HEIGHT$1;
2490
2115
  break;
2491
2116
  default:
2492
- height += CONTEXT_MENU_ITEM_HEIGHT;
2117
+ height += CONTEXT_MENU_ITEM_HEIGHT$1;
2493
2118
  break;
2494
2119
  }
2495
2120
  }
2496
2121
  return height;
2497
2122
  };
2498
- const getMenuBounds = (x, y, items) => {
2499
- const menuWidth = CONTEXT_MENU_WIDTH;
2500
- const menuHeight = getMenuHeight(items);
2123
+ const getMenuBounds$1 = (x, y, items) => {
2124
+ const menuWidth = CONTEXT_MENU_WIDTH$1;
2125
+ const menuHeight = getMenuHeight$1(items);
2501
2126
  const layoutState = {
2502
2127
  points: [0, 0]
2503
2128
  };
@@ -2521,40 +2146,40 @@ const getMenuBounds = (x, y, items) => {
2521
2146
  };
2522
2147
  const show$2 = async (x, y, id, mouseBlocking = false, ...args) => {
2523
2148
  const items = await getMenuEntriesWithKeyBindings(id, ...args);
2524
- const bounds = getMenuBounds(x, y, items);
2525
- const menu = addMenuInternal({
2149
+ const bounds = getMenuBounds$1(x, y, items);
2150
+ const menu = addMenuInternal$1({
2526
2151
  id,
2527
2152
  items,
2528
2153
  focusedIndex: -1,
2529
- level: state.menus.length,
2154
+ level: state$1.menus.length,
2530
2155
  x: bounds.x,
2531
2156
  y: bounds.y
2532
2157
  });
2533
2158
  const visible = getVisible(menu.items, -1, false, menu.level);
2534
2159
  const dom = getMenuVirtualDom(visible).slice(1);
2535
- await invoke$1(/* Menu.show */'Menu.showMenu', /* x */bounds.x, /* y */bounds.y, /* width */bounds.width, /* height */bounds.height, /* items */menu.items, /* level */menu.level, /* parentIndex */-1, /* dom */dom, /* mouseBlocking */mouseBlocking);
2160
+ await invoke(/* Menu.show */'Menu.showMenu', /* x */bounds.x, /* y */bounds.y, /* width */bounds.width, /* height */bounds.height, /* items */menu.items, /* level */menu.level, /* parentIndex */-1, /* dom */dom, /* mouseBlocking */mouseBlocking);
2536
2161
  };
2537
2162
  const show2$2 = async (uid, menuId, x, y, mouseBlocking = false, ...args) => {
2538
2163
  const items = await getMenuEntriesWithKeyBindings2(uid, menuId, ...args);
2539
- const bounds = getMenuBounds(x, y, items);
2540
- const menu = addMenuInternal({
2164
+ const bounds = getMenuBounds$1(x, y, items);
2165
+ const menu = addMenuInternal$1({
2541
2166
  id: menuId,
2542
2167
  items,
2543
2168
  focusedIndex: -1,
2544
- level: state.menus.length,
2169
+ level: state$1.menus.length,
2545
2170
  x: bounds.x,
2546
2171
  y: bounds.y
2547
2172
  });
2548
2173
  const visible = getVisible(menu.items, -1, false, menu.level);
2549
2174
  const dom = getMenuVirtualDom(visible).slice(1);
2550
- await invoke$1(/* Menu.show */'Menu.showMenu', /* x */bounds.x, /* y */bounds.y, /* width */bounds.width, /* height */bounds.height, /* items */menu.items, /* level */menu.level, /* parentIndex */-1, /* dom */dom, /* mouseBlocking */mouseBlocking);
2175
+ await invoke(/* Menu.show */'Menu.showMenu', /* x */bounds.x, /* y */bounds.y, /* width */bounds.width, /* height */bounds.height, /* items */menu.items, /* level */menu.level, /* parentIndex */-1, /* dom */dom, /* mouseBlocking */mouseBlocking);
2551
2176
  };
2552
2177
  const hide = async (restoreFocus = true) => {
2553
- if (state.menus.length === 0) {
2178
+ if (state$1.menus.length === 0) {
2554
2179
  return;
2555
2180
  }
2556
- state.menus = [];
2557
- await invoke$1(/* Menu.hide */'Menu.hide', /* restoreFocus */restoreFocus);
2181
+ state$1.menus = [];
2182
+ await invoke(/* Menu.hide */'Menu.hide', /* restoreFocus */restoreFocus);
2558
2183
  };
2559
2184
 
2560
2185
  const show$1 = async (x, y, id, ...args) => {
@@ -2673,90 +2298,149 @@ const FocusTitleBarMenuBar = 26;
2673
2298
 
2674
2299
  const getKeyBindings = () => {
2675
2300
  return [{
2676
- key: DownArrow$2,
2301
+ key: DownArrow$1,
2677
2302
  command: 'TitleBarMenuBar.handleKeyArrowDown',
2678
2303
  when: FocusTitleBarMenuBar
2679
2304
  }, {
2680
- key: UpArrow$2,
2305
+ key: UpArrow$1,
2681
2306
  command: 'TitleBarMenuBar.handleKeyArrowUp',
2682
2307
  when: FocusTitleBarMenuBar
2683
2308
  }, {
2684
- key: RightArrow$2,
2309
+ key: RightArrow$1,
2685
2310
  command: 'TitleBarMenuBar.handleKeyArrowRight',
2686
2311
  when: FocusTitleBarMenuBar
2687
2312
  }, {
2688
- key: LeftArrow$2,
2313
+ key: LeftArrow$1,
2689
2314
  command: 'TitleBarMenuBar.handleKeyArrowLeft',
2690
2315
  when: FocusTitleBarMenuBar
2691
2316
  }, {
2692
- key: Space$2,
2317
+ key: Space$1,
2693
2318
  command: 'TitleBarMenuBar.handleKeySpace',
2694
2319
  when: FocusTitleBarMenuBar
2695
2320
  }, {
2696
- key: Home$2,
2321
+ key: Home$1,
2697
2322
  command: 'TitleBarMenuBar.handleKeyHome',
2698
2323
  when: FocusTitleBarMenuBar
2699
2324
  }, {
2700
- key: End$2,
2325
+ key: End$1,
2701
2326
  command: 'TitleBarMenuBar.handleKeyEnd',
2702
2327
  when: FocusTitleBarMenuBar
2703
2328
  }, {
2704
- key: Escape$2,
2329
+ key: Escape$1,
2705
2330
  command: 'TitleBarMenuBar.handleKeyEscape',
2706
2331
  when: FocusTitleBarMenuBar
2707
2332
  }];
2708
2333
  };
2709
2334
 
2710
- const menus = [MenuEntriesEdit, MenuEntriesFile, MenuEntriesGo, MenuEntriesHelp, MenuEntriesRun, MenuEntriesSelection, MenuEntriesTerminal, MenuEntriesTitleBar, MenuEntriesView, MenuEntriesOpenRecent];
2335
+ // TODO lazyload menuEntries and use Command.execute (maybe)
2336
+ const CONTEXT_MENU_WIDTH = 250;
2711
2337
 
2712
- const getMenuIds = () => {
2713
- return menus.map(menu => menu.id);
2714
- };
2715
- const getMenuEntries = (id, platform) => {
2716
- const menu = menus.find(item => item.id === id);
2717
- if (!menu) {
2718
- return [];
2338
+ // TODO difference between focusing with mouse or keyboard
2339
+ // with mouse -> open submenu
2340
+ // with keyboard -> don't open submenu, only focus
2341
+
2342
+ // TODO this code seems a bit too complicated, maybe it can be simplified
2343
+
2344
+ const state = {
2345
+ menus: []};
2346
+ const addMenuInternal = menu => {
2347
+ if (state.menus.length > 5) {
2348
+ throw new Error('too many menus');
2719
2349
  }
2720
- return menu.getMenuEntries(platform);
2350
+ state.menus.push(menu);
2351
+ return menu;
2721
2352
  };
2722
2353
 
2723
- const maximize = async () => {
2724
- await invoke('ElectronWindow.maximize');
2354
+ // TODO handle printable letter and focus item that starts with that letter
2355
+
2356
+ // TODO pageup / pagedown keys
2357
+
2358
+ // TODO more tests
2359
+
2360
+ const CONTEXT_MENU_ITEM_HEIGHT = 26;
2361
+ const CONTEXT_MENU_SEPARATOR_HEIGHT = 11;
2362
+ const CONTEXT_MENU_PADDING = 8;
2363
+ const getMenuHeight = items => {
2364
+ let height = CONTEXT_MENU_PADDING;
2365
+ for (const item of items) {
2366
+ switch (item.flags) {
2367
+ case Separator$1:
2368
+ height += CONTEXT_MENU_SEPARATOR_HEIGHT;
2369
+ break;
2370
+ default:
2371
+ height += CONTEXT_MENU_ITEM_HEIGHT;
2372
+ break;
2373
+ }
2374
+ }
2375
+ return height;
2725
2376
  };
2726
- const minimize = async () => {
2727
- await invoke('ElectronWindow.minimize');
2377
+ const getMenuBounds = (x, y, items) => {
2378
+ const menuWidth = CONTEXT_MENU_WIDTH;
2379
+ const menuHeight = getMenuHeight(items);
2380
+ const layoutState = {
2381
+ points: [0, 0]
2382
+ };
2383
+ const windowWidth = layoutState.points[0];
2384
+ const windowHeight = layoutState.points[1];
2385
+ // TODO maybe only send labels and keybindings to ui (id not needed on ui)
2386
+ // TODO what about separators?
2387
+
2388
+ if (x + menuWidth > windowWidth) {
2389
+ x -= menuWidth;
2390
+ }
2391
+ if (y + menuHeight > windowHeight) {
2392
+ y -= menuHeight;
2393
+ }
2394
+ return {
2395
+ x,
2396
+ y,
2397
+ width: menuWidth,
2398
+ height: menuHeight
2399
+ };
2728
2400
  };
2729
- const close = async () => {
2730
- await invoke('ElectronWindow.close');
2401
+ const getMenuShowCommands = async (items, menuId, x, y, mouseBlocking = false) => {
2402
+ const bounds = getMenuBounds(x, y, items);
2403
+ const menu = addMenuInternal({
2404
+ id: menuId,
2405
+ items,
2406
+ focusedIndex: -1,
2407
+ level: state.menus.length,
2408
+ x: bounds.x,
2409
+ y: bounds.y
2410
+ });
2411
+ const visible = getVisible(menu.items, -1, false, menu.level);
2412
+ const dom = getMenuVirtualDom(visible).slice(1);
2413
+ return {
2414
+ menu,
2415
+ commands: [/* Menu.show */'Menu.showMenu', /* x */bounds.x, /* y */bounds.y, /* width */bounds.width, /* height */bounds.height, /* items */menu.items, /* level */menu.level, /* parentIndex */-1, /* dom */dom, /* mouseBlocking */mouseBlocking]
2416
+ };
2731
2417
  };
2732
2418
 
2733
- const handleClickClose = async state => {
2734
- await close();
2735
- return state;
2419
+ const getMenuHideCommands = async (restoreFocus = true) => {
2420
+ if (state.menus.length === 0) {
2421
+ return {
2422
+ newMenus: [],
2423
+ commands: []
2424
+ };
2425
+ }
2426
+ state.menus = [];
2427
+ return {
2428
+ commands: [/* Menu.hide */'Menu.hide', /* restoreFocus */restoreFocus],
2429
+ newMenus: []
2430
+ };
2736
2431
  };
2737
2432
 
2738
- const handleClickMinimize = async state => {
2739
- await minimize();
2740
- return state;
2741
- };
2433
+ const menus = [MenuEntriesEdit, MenuEntriesFile, MenuEntriesGo, MenuEntriesHelp, MenuEntriesRun, MenuEntriesSelection, MenuEntriesTerminal, MenuEntriesTitleBar, MenuEntriesView, MenuEntriesOpenRecent];
2742
2434
 
2743
- const handleClickToggleMaximize = async state => {
2744
- const fn = maximize;
2745
- await fn();
2746
- return state;
2435
+ const getMenuIds = () => {
2436
+ return menus.map(menu => menu.id);
2747
2437
  };
2748
-
2749
- const handleClick = (state, className) => {
2750
- if (className.includes('Minimize')) {
2751
- return handleClickMinimize(state);
2752
- }
2753
- if (className.includes('Maximize') || className.includes('Restore')) {
2754
- return handleClickToggleMaximize(state);
2755
- }
2756
- if (className.includes('Close')) {
2757
- return handleClickClose(state);
2438
+ const getMenuEntries = (id, platform) => {
2439
+ const menu = menus.find(item => item.id === id);
2440
+ if (!menu) {
2441
+ return [];
2758
2442
  }
2759
- return state;
2443
+ return menu.getMenuEntries(platform);
2760
2444
  };
2761
2445
 
2762
2446
  const handleContextMenu = state => {
@@ -2892,7 +2576,6 @@ const wrapCommand = fn => {
2892
2576
  const commandMap = {
2893
2577
  'Menu.getMenuEntries': getMenuEntries,
2894
2578
  'Menu.getMenuIds': getMenuIds,
2895
- 'Menu.handleButtonsClick': handleClick,
2896
2579
  'Menu.handleContextMenu': handleContextMenu,
2897
2580
  'Menu.renderEventListeners': renderEventListeners,
2898
2581
  'Menu.diff2': diff2,
@@ -2903,7 +2586,9 @@ const commandMap = {
2903
2586
  'Menu.render2': render2,
2904
2587
  'Menu.saveState': saveState,
2905
2588
  'Menu.show': show,
2906
- 'Menu.show2': show2
2589
+ 'Menu.show2': show2,
2590
+ 'Menu.getShowCommands': getMenuShowCommands,
2591
+ 'Menu.getHideCommands': getMenuHideCommands
2907
2592
  };
2908
2593
 
2909
2594
  const listen = async () => {