@lvce-editor/menu-worker 1.1.0 → 1.3.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.
@@ -421,7 +421,7 @@ const create$4 = (method, params) => {
421
421
  };
422
422
  };
423
423
  const callbacks = Object.create(null);
424
- const set$4 = (id, fn) => {
424
+ const set$3 = (id, fn) => {
425
425
  callbacks[id] = fn;
426
426
  };
427
427
  const get$2 = id => {
@@ -440,7 +440,7 @@ const registerPromise = () => {
440
440
  resolve,
441
441
  promise
442
442
  } = Promise.withResolvers();
443
- set$4(id, resolve);
443
+ set$3(id, resolve);
444
444
  return {
445
445
  id,
446
446
  promise
@@ -785,7 +785,7 @@ const send = (transport, method, ...params) => {
785
785
  const message = create$4(method, params);
786
786
  transport.send(message);
787
787
  };
788
- const invoke$2 = (ipc, method, ...params) => {
788
+ const invoke$3 = (ipc, method, ...params) => {
789
789
  return invokeHelper(ipc, method, params, false);
790
790
  };
791
791
  const invokeAndTransfer$1 = (ipc, method, ...params) => {
@@ -824,7 +824,7 @@ const createRpc = ipc => {
824
824
  send(ipc, method, ...params);
825
825
  },
826
826
  invoke(method, ...params) {
827
- return invoke$2(ipc, method, ...params);
827
+ return invoke$3(ipc, method, ...params);
828
828
  },
829
829
  invokeAndTransfer(method, ...params) {
830
830
  return invokeAndTransfer$1(ipc, method, ...params);
@@ -899,73 +899,6 @@ const createMockRpc = ({
899
899
  return mockRpc;
900
900
  };
901
901
 
902
- const RenderEntries = 1;
903
- const RenderFocusedIndex = 2;
904
- const RenderMenus = 3;
905
-
906
- const diffType$2 = RenderEntries;
907
- const isEqual$2 = (oldState, newState) => {
908
- return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
909
- };
910
-
911
- const diffType$1 = RenderFocusedIndex;
912
- const isEqual$1 = (oldState, newState) => {
913
- return oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
914
- };
915
-
916
- const diffType = RenderMenus;
917
- const isEqual = (oldState, newState) => {
918
- return oldState.menus === newState.menus;
919
- };
920
-
921
- const modules = [isEqual$2, isEqual$1, isEqual];
922
- const numbers = [diffType$2, diffType$1, diffType];
923
-
924
- const diff = (oldState, newState) => {
925
- const diffResult = [];
926
- for (let i = 0; i < modules.length; i++) {
927
- const fn = modules[i];
928
- if (!fn(oldState, newState)) {
929
- diffResult.push(numbers[i]);
930
- }
931
- }
932
- return diffResult;
933
- };
934
-
935
- const create$1 = () => {
936
- const states = Object.create(null);
937
- return {
938
- get(uid) {
939
- return states[uid];
940
- },
941
- set(uid, oldState, newState) {
942
- states[uid] = {
943
- oldState,
944
- newState
945
- };
946
- }
947
- };
948
- };
949
-
950
- const {
951
- get: get$1,
952
- set: set$3
953
- } = create$1();
954
-
955
- const diff2 = uid => {
956
- const {
957
- oldState,
958
- newState
959
- } = get$1(uid);
960
- return diff(oldState, newState);
961
- };
962
-
963
- const commandsIds = ['closeMenu', 'handleClickAt', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleClick', 'handleFocus', 'handleFocusOut', 'handleKeyArrowDown', 'handleKeyArrowLeft', 'handleKeyArrowRight', 'handleKeyArrowUp', 'handleKeyEnd', 'handleKeyEnter', 'handleKeyEscape', 'handleKeyHome', 'handleKeySpace', 'handleMenuClick', 'handleMenuMouseOver', 'handleMouseOut', 'handleMouseOver', 'handlePointerOver', 'handlePointerOut', 'toggleIndex', 'toggleMenu'];
964
-
965
- const getCommandIds = () => {
966
- return commandsIds;
967
- };
968
-
969
902
  const Text = 12;
970
903
 
971
904
  const Escape$2 = 8;
@@ -983,445 +916,94 @@ const Shift = 1 << 10 >>> 0;
983
916
  const DebugWorker = 55;
984
917
  const RendererWorker$1 = 1;
985
918
 
986
- const mergeClassNames = (...classNames) => {
987
- return classNames.filter(Boolean).join(' ');
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];
988
925
  };
989
926
 
990
- const text = data => {
927
+ const create$1 = rpcId => {
991
928
  return {
992
- type: Text,
993
- text: data,
994
- childCount: 0
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
+ }
995
948
  };
996
949
  };
997
950
 
998
- const FocusTitleBarMenuBar = 26;
999
-
1000
- const getKeyBindings$1 = () => {
1001
- return [{
1002
- key: DownArrow$2,
1003
- command: 'TitleBarMenuBar.handleKeyArrowDown',
1004
- when: FocusTitleBarMenuBar
1005
- }, {
1006
- key: UpArrow$2,
1007
- command: 'TitleBarMenuBar.handleKeyArrowUp',
1008
- when: FocusTitleBarMenuBar
1009
- }, {
1010
- key: RightArrow$2,
1011
- command: 'TitleBarMenuBar.handleKeyArrowRight',
1012
- when: FocusTitleBarMenuBar
1013
- }, {
1014
- key: LeftArrow$2,
1015
- command: 'TitleBarMenuBar.handleKeyArrowLeft',
1016
- when: FocusTitleBarMenuBar
1017
- }, {
1018
- key: Space$2,
1019
- command: 'TitleBarMenuBar.handleKeySpace',
1020
- when: FocusTitleBarMenuBar
1021
- }, {
1022
- key: Home$2,
1023
- command: 'TitleBarMenuBar.handleKeyHome',
1024
- when: FocusTitleBarMenuBar
1025
- }, {
1026
- key: End$2,
1027
- command: 'TitleBarMenuBar.handleKeyEnd',
1028
- when: FocusTitleBarMenuBar
1029
- }, {
1030
- key: Escape$2,
1031
- command: 'TitleBarMenuBar.handleKeyEscape',
1032
- when: FocusTitleBarMenuBar
1033
- }];
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);
1034
959
  };
1035
-
1036
- const emptyObject = {};
1037
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1038
- const i18nString = (key, placeholders = emptyObject) => {
1039
- if (placeholders === emptyObject) {
1040
- return key;
1041
- }
1042
- const replacer = (match, rest) => {
1043
- return placeholders[rest];
1044
- };
1045
- return key.replaceAll(RE_PLACEHOLDER, replacer);
960
+ const getFilePathElectron = async file => {
961
+ return invoke$2('FileSystemHandle.getFilePathElectron', file);
1046
962
  };
1047
-
1048
- /**
1049
- * @enum {string}
1050
- */
1051
- const UiStrings$2 = {
1052
- Copy: 'Copy',
1053
- CopyLineDown: 'Copy Line Down',
1054
- CopyLineUp: 'Copy Line Up',
1055
- Cut: 'Cut',
1056
- MoveLineDown: 'Move Line Down',
1057
- MoveLineUp: 'Move Line Up',
1058
- Paste: 'Paste',
1059
- Redo: 'Redo',
1060
- SelectAll: 'Select All',
1061
- ToggleBlockComment: 'Toggle Block Comment',
1062
- ToggleLineComment: 'Toggle Line Comment',
1063
- Undo: 'Undo'};
1064
- const cut = () => {
1065
- return i18nString(UiStrings$2.Cut);
963
+ const showContextMenu = async (x, y, id, ...args) => {
964
+ return invoke$2('ContextMenu.show', x, y, id, ...args);
1066
965
  };
1067
- const copy = () => {
1068
- return i18nString(UiStrings$2.Copy);
966
+ const getElectronVersion = async () => {
967
+ return invoke$2('Process.getElectronVersion');
1069
968
  };
1070
- const paste = () => {
1071
- return i18nString(UiStrings$2.Paste);
969
+ const applyBulkReplacement = async bulkEdits => {
970
+ await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
1072
971
  };
1073
- const undo = () => {
1074
- return i18nString(UiStrings$2.Undo);
972
+ const setColorTheme = async id => {
973
+ // @ts-ignore
974
+ return invoke$2(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1075
975
  };
1076
- const redo = () => {
1077
- return i18nString(UiStrings$2.Redo);
976
+ const getNodeVersion = async () => {
977
+ return invoke$2('Process.getNodeVersion');
1078
978
  };
1079
- const toggleLineComment = () => {
1080
- return i18nString(UiStrings$2.ToggleLineComment);
979
+ const getChromeVersion = async () => {
980
+ return invoke$2('Process.getChromeVersion');
1081
981
  };
1082
- const toggleBlockComment = () => {
1083
- return i18nString(UiStrings$2.ToggleBlockComment);
982
+ const getV8Version = async () => {
983
+ return invoke$2('Process.getV8Version');
1084
984
  };
1085
- const selectAll = () => {
1086
- return i18nString(UiStrings$2.SelectAll);
985
+ const getFileHandles = async fileIds => {
986
+ const files = await invoke$2('FileSystemHandle.getFileHandles', fileIds);
987
+ return files;
1087
988
  };
1088
- const copyLineUp = () => {
1089
- return i18nString(UiStrings$2.CopyLineUp);
989
+ const setWorkspacePath = async path => {
990
+ await invoke$2('Workspace.setPath', path);
1090
991
  };
1091
- const copyLineDown = () => {
1092
- return i18nString(UiStrings$2.CopyLineDown);
992
+ const registerWebViewInterceptor = async (id, port) => {
993
+ await invokeAndTransfer('WebView.registerInterceptor', id, port);
1093
994
  };
1094
- const moveLineUp = () => {
1095
- return i18nString(UiStrings$2.MoveLineUp);
995
+ const unregisterWebViewInterceptor = async id => {
996
+ await invoke$2('WebView.unregisterInterceptor', id);
1096
997
  };
1097
- const moveLineDown = () => {
1098
- return i18nString(UiStrings$2.MoveLineDown);
998
+ const sendMessagePortToEditorWorker = async (port, rpcId) => {
999
+ const command = 'HandleMessagePort.handleMessagePort';
1000
+ // @ts-ignore
1001
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1099
1002
  };
1100
-
1101
- const Edit$1 = 2;
1102
- const File$2 = 5;
1103
- const Go$1 = 6;
1104
- const Help$1 = 7;
1105
- const OpenRecent = 9;
1106
- const Run$1 = 10;
1107
- const Selection$1 = 11;
1108
- const Terminal$1 = 14;
1109
- const TitleBar = 15;
1110
- const View$1 = 16;
1111
-
1112
- const Separator$1 = 1;
1113
- const None = 0;
1114
- const SubMenu = 4;
1115
- const Checked = 2;
1116
- const Unchecked = 3;
1117
- const Disabled = 5;
1118
- const RestoreFocus = 6;
1119
- const Ignore = 7;
1120
-
1121
- const menuEntrySeparator = {
1122
- id: 'separator',
1123
- label: '',
1124
- flags: Separator$1,
1125
- command: ''
1126
- };
1127
-
1128
- const id$9 = Edit$1;
1129
- const getMenuEntries$c = () => {
1130
- return [{
1131
- id: 'undo',
1132
- label: undo(),
1133
- flags: Disabled,
1134
- command: /* TODO */'-1'
1135
- }, {
1136
- id: 'redo',
1137
- label: redo(),
1138
- flags: Disabled,
1139
- command: /* TODO */'-1'
1140
- }, menuEntrySeparator, {
1141
- id: 'cut',
1142
- label: cut(),
1143
- flags: None,
1144
- command: /* Editor.cut */'Editor.cut'
1145
- }, {
1146
- id: 'copy',
1147
- label: copy(),
1148
- flags: None,
1149
- command: /* Editor.copy */'Editor.copy'
1150
- }, {
1151
- id: 'paste',
1152
- label: paste(),
1153
- flags: None,
1154
- command: /* Editor.paste */'Editor.paste'
1155
- }, menuEntrySeparator, {
1156
- id: 'toggle-line-comment',
1157
- label: toggleLineComment(),
1158
- flags: None,
1159
- command: /* Editor.toggleLineComment */'Editor.toggleLineComment'
1160
- }, {
1161
- id: 'toggle-block-comment',
1162
- label: toggleBlockComment(),
1163
- flags: None,
1164
- command: /* Editor.toggleBlockComment */'Editor.toggleBlockComment'
1165
- }];
1166
- };
1167
-
1168
- const MenuEntriesEdit = {
1169
- __proto__: null,
1170
- getMenuEntries: getMenuEntries$c,
1171
- id: id$9
1172
- };
1173
-
1174
- /**
1175
- * @enum {string}
1176
- */
1177
- const UiStrings$1 = {
1178
- NewFile: 'New File',
1179
- NewWindow: 'New Window',
1180
- OpenFile: 'Open File',
1181
- OpenFolder: 'Open Folder',
1182
- OpenRecent: 'Open Recent',
1183
- Exit: 'Exit',
1184
- Save: 'Save',
1185
- SaveAll: 'Save All'
1186
- };
1187
- const newFile = () => {
1188
- return i18nString(UiStrings$1.NewFile);
1189
- };
1190
- const newWindow = () => {
1191
- return i18nString(UiStrings$1.NewWindow);
1192
- };
1193
- const openFile = () => {
1194
- return i18nString(UiStrings$1.OpenFile);
1195
- };
1196
- const openFolder = () => {
1197
- return i18nString(UiStrings$1.OpenFolder);
1198
- };
1199
- const openRecent = () => {
1200
- return i18nString(UiStrings$1.OpenRecent);
1201
- };
1202
- const save = () => {
1203
- return i18nString(UiStrings$1.Save);
1204
- };
1205
- const saveAll = () => {
1206
- return i18nString(UiStrings$1.SaveAll);
1207
- };
1208
- const exit = () => {
1209
- return i18nString(UiStrings$1.Exit);
1210
- };
1211
-
1212
- const Web = 1;
1213
- const Electron = 2;
1214
-
1215
- const id$8 = File$2;
1216
- const getMenuEntries$b = platform => {
1217
- const entries = [{
1218
- id: 'newFile',
1219
- label: newFile(),
1220
- flags: None,
1221
- command: '-1'
1222
- }, {
1223
- id: 'newWindow',
1224
- label: newWindow(),
1225
- flags: None,
1226
- command: /* Window.openNew */'Window.openNew'
1227
- }, menuEntrySeparator, {
1228
- id: 'openFile',
1229
- label: openFile(),
1230
- flags: None,
1231
- command: 'Dialog.openFile'
1232
- }, {
1233
- id: 'openFolder',
1234
- label: openFolder(),
1235
- flags: RestoreFocus,
1236
- command: 'Dialog.openFolder'
1237
- }, {
1238
- id: OpenRecent,
1239
- label: openRecent(),
1240
- flags: SubMenu,
1241
- command: ''
1242
- }, menuEntrySeparator, {
1243
- id: 'save',
1244
- label: save(),
1245
- flags: None,
1246
- command: 'Main.save'
1247
- }, {
1248
- id: 'saveAll',
1249
- label: saveAll(),
1250
- flags: None,
1251
- command: 'Main.saveAll'
1252
- }];
1253
- if (platform === Electron) {
1254
- entries.push(menuEntrySeparator, {
1255
- id: 'exit',
1256
- label: exit(),
1257
- flags: Ignore,
1258
- command: 'Chrome.exit'
1259
- });
1260
- }
1261
- return entries;
1262
- };
1263
-
1264
- const MenuEntriesFile = {
1265
- __proto__: null,
1266
- getMenuEntries: getMenuEntries$b,
1267
- id: id$8
1268
- };
1269
-
1270
- const id$7 = Go$1;
1271
- const getMenuEntries$a = () => {
1272
- return [];
1273
- };
1274
-
1275
- const MenuEntriesGo = {
1276
- __proto__: null,
1277
- getMenuEntries: getMenuEntries$a,
1278
- id: id$7
1279
- };
1280
-
1281
- const About = 'About';
1282
- const Edit = 'Edit';
1283
- const File$1 = 'File';
1284
- const Go = 'Go';
1285
- const Help = 'Help';
1286
- const OpenProcessExplorer = 'Open Process Explorer';
1287
- const Run = 'Run';
1288
- const Selection = 'Selection';
1289
- const Terminal = 'Terminal';
1290
- const ToggleDeveloperTools = 'Toggle Developer Tools';
1291
- const View = 'View';
1292
-
1293
- const toggleDeveloperTools = () => {
1294
- return i18nString(ToggleDeveloperTools);
1295
- };
1296
- const openProcessExplorer = () => {
1297
- return i18nString(OpenProcessExplorer);
1298
- };
1299
- const about = () => {
1300
- return i18nString(About);
1301
- };
1302
-
1303
- const id$6 = Help$1;
1304
- const getMenuEntries$9 = async platform => {
1305
- const entries = [];
1306
- if (platform !== Web) {
1307
- entries.push({
1308
- id: 'toggleDeveloperTools',
1309
- label: toggleDeveloperTools(),
1310
- flags: None,
1311
- command: 'Developer.toggleDeveloperTools'
1312
- }, {
1313
- id: 'openProcessExplorer',
1314
- label: openProcessExplorer(),
1315
- flags: RestoreFocus,
1316
- command: 'Developer.openProcessExplorer'
1317
- });
1318
- }
1319
- if (entries.length > 0) {
1320
- entries.push(menuEntrySeparator);
1321
- }
1322
- entries.push({
1323
- id: 'about',
1324
- label: about(),
1325
- flags: None,
1326
- command: 'About.showAbout'
1327
- });
1328
- return entries;
1329
- };
1330
-
1331
- const MenuEntriesHelp = {
1332
- __proto__: null,
1333
- getMenuEntries: getMenuEntries$9,
1334
- id: id$6
1335
- };
1336
-
1337
- const rpcs = Object.create(null);
1338
- const set$2 = (id, rpc) => {
1339
- rpcs[id] = rpc;
1340
- };
1341
- const get = id => {
1342
- return rpcs[id];
1343
- };
1344
-
1345
- const create = rpcId => {
1346
- return {
1347
- // @ts-ignore
1348
- invoke(method, ...params) {
1349
- const rpc = get(rpcId);
1350
- // @ts-ignore
1351
- return rpc.invoke(method, ...params);
1352
- },
1353
- // @ts-ignore
1354
- invokeAndTransfer(method, ...params) {
1355
- const rpc = get(rpcId);
1356
- // @ts-ignore
1357
- return rpc.invokeAndTransfer(method, ...params);
1358
- },
1359
- set(rpc) {
1360
- set$2(rpcId, rpc);
1361
- },
1362
- async dispose() {
1363
- const rpc = get(rpcId);
1364
- await rpc.dispose();
1365
- }
1366
- };
1367
- };
1368
-
1369
- const {
1370
- invoke: invoke$1,
1371
- invokeAndTransfer,
1372
- set: set$1,
1373
- dispose
1374
- } = create(RendererWorker$1);
1375
- const searchFileHtml = async uri => {
1376
- return invoke$1('ExtensionHost.searchFileWithHtml', uri);
1377
- };
1378
- const getFilePathElectron = async file => {
1379
- return invoke$1('FileSystemHandle.getFilePathElectron', file);
1380
- };
1381
- const showContextMenu = async (x, y, id, ...args) => {
1382
- return invoke$1('ContextMenu.show', x, y, id, ...args);
1383
- };
1384
- const getElectronVersion = async () => {
1385
- return invoke$1('Process.getElectronVersion');
1386
- };
1387
- const applyBulkReplacement = async bulkEdits => {
1388
- await invoke$1('BulkReplacement.applyBulkReplacement', bulkEdits);
1389
- };
1390
- const setColorTheme = async id => {
1391
- // @ts-ignore
1392
- return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1393
- };
1394
- const getNodeVersion = async () => {
1395
- return invoke$1('Process.getNodeVersion');
1396
- };
1397
- const getChromeVersion = async () => {
1398
- return invoke$1('Process.getChromeVersion');
1399
- };
1400
- const getV8Version = async () => {
1401
- return invoke$1('Process.getV8Version');
1402
- };
1403
- const getFileHandles = async fileIds => {
1404
- const files = await invoke$1('FileSystemHandle.getFileHandles', fileIds);
1405
- return files;
1406
- };
1407
- const setWorkspacePath = async path => {
1408
- await invoke$1('Workspace.setPath', path);
1409
- };
1410
- const registerWebViewInterceptor = async (id, port) => {
1411
- await invokeAndTransfer('WebView.registerInterceptor', id, port);
1412
- };
1413
- const unregisterWebViewInterceptor = async id => {
1414
- await invoke$1('WebView.unregisterInterceptor', id);
1415
- };
1416
- const sendMessagePortToEditorWorker = async (port, rpcId) => {
1417
- const command = 'HandleMessagePort.handleMessagePort';
1418
- // @ts-ignore
1419
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1420
- };
1421
- const sendMessagePortToErrorWorker = async (port, rpcId) => {
1422
- const command = 'Errors.handleMessagePort';
1423
- // @ts-ignore
1424
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
1003
+ const sendMessagePortToErrorWorker = async (port, rpcId) => {
1004
+ const command = 'Errors.handleMessagePort';
1005
+ // @ts-ignore
1006
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
1425
1007
  };
1426
1008
  const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
1427
1009
  const command = 'Markdown.handleMessagePort';
@@ -1439,41 +1021,41 @@ const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
1439
1021
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1440
1022
  };
1441
1023
  const readFile = async uri => {
1442
- return invoke$1('FileSystem.readFile', uri);
1024
+ return invoke$2('FileSystem.readFile', uri);
1443
1025
  };
1444
1026
  const getWebViewSecret = async key => {
1445
1027
  // @ts-ignore
1446
- return invoke$1('WebView.getSecret', key);
1028
+ return invoke$2('WebView.getSecret', key);
1447
1029
  };
1448
1030
  const setWebViewPort = async (uid, port, origin, portType) => {
1449
1031
  return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
1450
1032
  };
1451
1033
  const setFocus = key => {
1452
- return invoke$1('Focus.setFocus', key);
1034
+ return invoke$2('Focus.setFocus', key);
1453
1035
  };
1454
1036
  const getFileIcon = async options => {
1455
- return invoke$1('IconTheme.getFileIcon', options);
1037
+ return invoke$2('IconTheme.getFileIcon', options);
1456
1038
  };
1457
1039
  const getColorThemeNames = async () => {
1458
- return invoke$1('ColorTheme.getColorThemeNames');
1040
+ return invoke$2('ColorTheme.getColorThemeNames');
1459
1041
  };
1460
1042
  const disableExtension = async id => {
1461
1043
  // @ts-ignore
1462
- return invoke$1('ExtensionManagement.disable', id);
1044
+ return invoke$2('ExtensionManagement.disable', id);
1463
1045
  };
1464
1046
  const enableExtension = async id => {
1465
1047
  // @ts-ignore
1466
- return invoke$1('ExtensionManagement.enable', id);
1048
+ return invoke$2('ExtensionManagement.enable', id);
1467
1049
  };
1468
1050
  const handleDebugChange = async params => {
1469
1051
  // @ts-ignore
1470
- return invoke$1('Run And Debug.handleChange', params);
1052
+ return invoke$2('Run And Debug.handleChange', params);
1471
1053
  };
1472
1054
  const getFolderIcon = async options => {
1473
- return invoke$1('IconTheme.getFolderIcon', options);
1055
+ return invoke$2('IconTheme.getFolderIcon', options);
1474
1056
  };
1475
1057
  const closeWidget = async widgetId => {
1476
- return invoke$1('Viewlet.closeWidget', widgetId);
1058
+ return invoke$2('Viewlet.closeWidget', widgetId);
1477
1059
  };
1478
1060
  const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1479
1061
  const command = 'HandleMessagePort.handleMessagePort2';
@@ -1484,55 +1066,55 @@ const sendMessagePortToSearchProcess = async port => {
1484
1066
  };
1485
1067
  const confirm = async (message, options) => {
1486
1068
  // @ts-ignore
1487
- const result = await invoke$1('ConfirmPrompt.prompt', message, options);
1069
+ const result = await invoke$2('ConfirmPrompt.prompt', message, options);
1488
1070
  return result;
1489
1071
  };
1490
1072
  const getRecentlyOpened$1 = async () => {
1491
- return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1073
+ return invoke$2(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1492
1074
  };
1493
- const getKeyBindings = async () => {
1494
- return invoke$1('KeyBindingsInitial.getKeyBindings');
1075
+ const getKeyBindings$1 = async () => {
1076
+ return invoke$2('KeyBindingsInitial.getKeyBindings');
1495
1077
  };
1496
1078
  const writeClipBoardText = async text => {
1497
- await invoke$1('ClipBoard.writeText', /* text */text);
1079
+ await invoke$2('ClipBoard.writeText', /* text */text);
1498
1080
  };
1499
1081
  const writeClipBoardImage = async blob => {
1500
1082
  // @ts-ignore
1501
- await invoke$1('ClipBoard.writeImage', /* text */blob);
1083
+ await invoke$2('ClipBoard.writeImage', /* text */blob);
1502
1084
  };
1503
1085
  const searchFileMemory = async uri => {
1504
1086
  // @ts-ignore
1505
- return invoke$1('ExtensionHost.searchFileWithMemory', uri);
1087
+ return invoke$2('ExtensionHost.searchFileWithMemory', uri);
1506
1088
  };
1507
1089
  const searchFileFetch = async uri => {
1508
- return invoke$1('ExtensionHost.searchFileWithFetch', uri);
1090
+ return invoke$2('ExtensionHost.searchFileWithFetch', uri);
1509
1091
  };
1510
1092
  const showMessageBox = async options => {
1511
- return invoke$1('ElectronDialog.showMessageBox', options);
1093
+ return invoke$2('ElectronDialog.showMessageBox', options);
1512
1094
  };
1513
1095
  const handleDebugResumed = async params => {
1514
- await invoke$1('Run And Debug.handleResumed', params);
1096
+ await invoke$2('Run And Debug.handleResumed', params);
1515
1097
  };
1516
1098
  const openWidget = async name => {
1517
- await invoke$1('Viewlet.openWidget', name);
1099
+ await invoke$2('Viewlet.openWidget', name);
1518
1100
  };
1519
1101
  const getIcons = async requests => {
1520
- const icons = await invoke$1('IconTheme.getIcons', requests);
1102
+ const icons = await invoke$2('IconTheme.getIcons', requests);
1521
1103
  return icons;
1522
1104
  };
1523
1105
  const activateByEvent = event => {
1524
- return invoke$1('ExtensionHostManagement.activateByEvent', event);
1106
+ return invoke$2('ExtensionHostManagement.activateByEvent', event);
1525
1107
  };
1526
1108
  const setAdditionalFocus = focusKey => {
1527
1109
  // @ts-ignore
1528
- return invoke$1('Focus.setAdditionalFocus', focusKey);
1110
+ return invoke$2('Focus.setAdditionalFocus', focusKey);
1529
1111
  };
1530
1112
  const getActiveEditorId = () => {
1531
1113
  // @ts-ignore
1532
- return invoke$1('GetActiveEditor.getActiveEditorId');
1114
+ return invoke$2('GetActiveEditor.getActiveEditorId');
1533
1115
  };
1534
1116
  const getWorkspacePath = () => {
1535
- return invoke$1('Workspace.getPath');
1117
+ return invoke$2('Workspace.getPath');
1536
1118
  };
1537
1119
  const sendMessagePortToRendererProcess = async port => {
1538
1120
  const command = 'HandleMessagePort.handleMessagePort';
@@ -1540,20 +1122,20 @@ const sendMessagePortToRendererProcess = async port => {
1540
1122
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1541
1123
  };
1542
1124
  const getPreference = async key => {
1543
- return await invoke$1('Preferences.get', key);
1125
+ return await invoke$2('Preferences.get', key);
1544
1126
  };
1545
1127
  const getAllExtensions = async () => {
1546
- return invoke$1('ExtensionManagement.getAllExtensions');
1128
+ return invoke$2('ExtensionManagement.getAllExtensions');
1547
1129
  };
1548
1130
  const rerenderEditor = async key => {
1549
1131
  // @ts-ignore
1550
- return invoke$1('Editor.rerender', key);
1132
+ return invoke$2('Editor.rerender', key);
1551
1133
  };
1552
1134
  const handleDebugPaused = async params => {
1553
- await invoke$1('Run And Debug.handlePaused', params);
1135
+ await invoke$2('Run And Debug.handlePaused', params);
1554
1136
  };
1555
1137
  const openUri = async (uri, focus, options) => {
1556
- await invoke$1('Main.openUri', uri, focus, options);
1138
+ await invoke$2('Main.openUri', uri, focus, options);
1557
1139
  };
1558
1140
  const sendMessagePortToSyntaxHighlightingWorker = async port => {
1559
1141
  await invokeAndTransfer(
@@ -1561,173 +1143,506 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
1561
1143
  'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
1562
1144
  };
1563
1145
  const handleDebugScriptParsed = async script => {
1564
- await invoke$1('Run And Debug.handleScriptParsed', script);
1146
+ await invoke$2('Run And Debug.handleScriptParsed', script);
1565
1147
  };
1566
1148
  const getWindowId = async () => {
1567
- return invoke$1('GetWindowId.getWindowId');
1149
+ return invoke$2('GetWindowId.getWindowId');
1568
1150
  };
1569
1151
  const getBlob = async uri => {
1570
1152
  // @ts-ignore
1571
- return invoke$1('FileSystem.getBlob', uri);
1153
+ return invoke$2('FileSystem.getBlob', uri);
1572
1154
  };
1573
1155
  const getExtensionCommands = async () => {
1574
- return invoke$1('ExtensionHost.getCommands');
1156
+ return invoke$2('ExtensionHost.getCommands');
1575
1157
  };
1576
1158
  const showErrorDialog = async errorInfo => {
1577
1159
  // @ts-ignore
1578
- await invoke$1('ErrorHandling.showErrorDialog', errorInfo);
1160
+ await invoke$2('ErrorHandling.showErrorDialog', errorInfo);
1579
1161
  };
1580
1162
  const getFolderSize = async uri => {
1581
1163
  // @ts-ignore
1582
- return await invoke$1('FileSystem.getFolderSize', uri);
1164
+ return await invoke$2('FileSystem.getFolderSize', uri);
1583
1165
  };
1584
1166
  const getExtension = async id => {
1585
1167
  // @ts-ignore
1586
- return invoke$1('ExtensionManagement.getExtension', id);
1168
+ return invoke$2('ExtensionManagement.getExtension', id);
1587
1169
  };
1588
1170
  const getMarkdownDom = async html => {
1589
1171
  // @ts-ignore
1590
- return invoke$1('Markdown.getVirtualDom', html);
1172
+ return invoke$2('Markdown.getVirtualDom', html);
1591
1173
  };
1592
1174
  const renderMarkdown = async (markdown, options) => {
1593
1175
  // @ts-ignore
1594
- return invoke$1('Markdown.renderMarkdown', markdown, options);
1176
+ return invoke$2('Markdown.renderMarkdown', markdown, options);
1595
1177
  };
1596
1178
  const openNativeFolder = async uri => {
1597
1179
  // @ts-ignore
1598
- await invoke$1('OpenNativeFolder.openNativeFolder', uri);
1180
+ await invoke$2('OpenNativeFolder.openNativeFolder', uri);
1599
1181
  };
1600
1182
  const uninstallExtension = async id => {
1601
- return invoke$1('ExtensionManagement.uninstall', id);
1183
+ return invoke$2('ExtensionManagement.uninstall', id);
1602
1184
  };
1603
1185
  const installExtension = async id => {
1604
1186
  // @ts-ignore
1605
- return invoke$1('ExtensionManagement.install', id);
1187
+ return invoke$2('ExtensionManagement.install', id);
1606
1188
  };
1607
1189
  const openExtensionSearch = async () => {
1608
1190
  // @ts-ignore
1609
- return invoke$1('SideBar.openViewlet', 'Extensions');
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');
1208
+ };
1209
+ const showSaveFilePicker = async () => {
1210
+ // @ts-ignore
1211
+ return invoke$2('FilePicker.showSaveFilePicker');
1212
+ };
1213
+ const getLogsDir = async () => {
1214
+ // @ts-ignore
1215
+ return invoke$2('PlatformPaths.getLogsDir');
1216
+ };
1217
+ const registerMockRpc = commandMap => {
1218
+ const mockRpc = createMockRpc({
1219
+ commandMap
1220
+ });
1221
+ set$1(mockRpc);
1222
+ return mockRpc;
1223
+ };
1224
+
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
1304
+ };
1305
+
1306
+ const matchesArgs = (a, b) => {
1307
+ if (!a && !b) {
1308
+ return true;
1309
+ }
1310
+ if (!a && b || !b && a) {
1311
+ return false;
1312
+ }
1313
+ if (a.length !== b.length) {
1314
+ return false;
1315
+ }
1316
+ for (let i = 0; i < a.length; i++) {
1317
+ if (a[i] !== b[i]) {
1318
+ return false;
1319
+ }
1320
+ }
1321
+ return true;
1322
+ };
1323
+ const getCommandKeyBinding = (keyBindings, command, args) => {
1324
+ for (const keyBinding of keyBindings) {
1325
+ if (keyBinding.command === command && matchesArgs(keyBinding.args, args)) {
1326
+ return keyBinding;
1327
+ }
1328
+ }
1329
+ return undefined;
1330
+ };
1331
+
1332
+ const invoke$1 = async (method, ...params) => {
1333
+ // TODO
1334
+ };
1335
+
1336
+ const state$1 = {
1337
+ /**
1338
+ * @type {any}
1339
+ */
1340
+ matchingKeyBindings: []
1341
+ };
1342
+
1343
+ const emptyObject = {};
1344
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1345
+ const i18nString = (key, placeholders = emptyObject) => {
1346
+ if (placeholders === emptyObject) {
1347
+ return key;
1348
+ }
1349
+ const replacer = (match, rest) => {
1350
+ return placeholders[rest];
1351
+ };
1352
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1353
+ };
1354
+
1355
+ /**
1356
+ * @enum {string}
1357
+ */
1358
+ const UiStrings$2 = {
1359
+ Copy: 'Copy',
1360
+ CopyLineDown: 'Copy Line Down',
1361
+ CopyLineUp: 'Copy Line Up',
1362
+ Cut: 'Cut',
1363
+ MoveLineDown: 'Move Line Down',
1364
+ MoveLineUp: 'Move Line Up',
1365
+ Paste: 'Paste',
1366
+ Redo: 'Redo',
1367
+ SelectAll: 'Select All',
1368
+ ToggleBlockComment: 'Toggle Block Comment',
1369
+ ToggleLineComment: 'Toggle Line Comment',
1370
+ Undo: 'Undo'};
1371
+ const cut = () => {
1372
+ return i18nString(UiStrings$2.Cut);
1373
+ };
1374
+ const copy = () => {
1375
+ return i18nString(UiStrings$2.Copy);
1376
+ };
1377
+ const paste = () => {
1378
+ return i18nString(UiStrings$2.Paste);
1379
+ };
1380
+ const undo = () => {
1381
+ return i18nString(UiStrings$2.Undo);
1382
+ };
1383
+ const redo = () => {
1384
+ return i18nString(UiStrings$2.Redo);
1385
+ };
1386
+ const toggleLineComment = () => {
1387
+ return i18nString(UiStrings$2.ToggleLineComment);
1388
+ };
1389
+ const toggleBlockComment = () => {
1390
+ return i18nString(UiStrings$2.ToggleBlockComment);
1391
+ };
1392
+ const selectAll = () => {
1393
+ return i18nString(UiStrings$2.SelectAll);
1394
+ };
1395
+ const copyLineUp = () => {
1396
+ return i18nString(UiStrings$2.CopyLineUp);
1397
+ };
1398
+ const copyLineDown = () => {
1399
+ return i18nString(UiStrings$2.CopyLineDown);
1400
+ };
1401
+ const moveLineUp = () => {
1402
+ return i18nString(UiStrings$2.MoveLineUp);
1403
+ };
1404
+ const moveLineDown = () => {
1405
+ return i18nString(UiStrings$2.MoveLineDown);
1406
+ };
1407
+
1408
+ const Edit$1 = 2;
1409
+ const File$2 = 5;
1410
+ const Go$1 = 6;
1411
+ const Help$1 = 7;
1412
+ const OpenRecent = 9;
1413
+ const Run$1 = 10;
1414
+ const Selection$1 = 11;
1415
+ const Terminal$1 = 14;
1416
+ const TitleBar = 15;
1417
+ const View$1 = 16;
1418
+
1419
+ const Separator$1 = 1;
1420
+ const None = 0;
1421
+ const SubMenu = 4;
1422
+ const Checked = 2;
1423
+ const Unchecked = 3;
1424
+ const Disabled = 5;
1425
+ const RestoreFocus = 6;
1426
+ const Ignore = 7;
1427
+
1428
+ const menuEntrySeparator = {
1429
+ id: 'separator',
1430
+ label: '',
1431
+ flags: Separator$1,
1432
+ command: ''
1433
+ };
1434
+
1435
+ const id$9 = Edit$1;
1436
+ const getMenuEntries$d = () => {
1437
+ return [{
1438
+ id: 'undo',
1439
+ label: undo(),
1440
+ flags: Disabled,
1441
+ command: /* TODO */'-1'
1442
+ }, {
1443
+ id: 'redo',
1444
+ label: redo(),
1445
+ flags: Disabled,
1446
+ command: /* TODO */'-1'
1447
+ }, menuEntrySeparator, {
1448
+ id: 'cut',
1449
+ label: cut(),
1450
+ flags: None,
1451
+ command: /* Editor.cut */'Editor.cut'
1452
+ }, {
1453
+ id: 'copy',
1454
+ label: copy(),
1455
+ flags: None,
1456
+ command: /* Editor.copy */'Editor.copy'
1457
+ }, {
1458
+ id: 'paste',
1459
+ label: paste(),
1460
+ flags: None,
1461
+ command: /* Editor.paste */'Editor.paste'
1462
+ }, menuEntrySeparator, {
1463
+ id: 'toggle-line-comment',
1464
+ label: toggleLineComment(),
1465
+ flags: None,
1466
+ command: /* Editor.toggleLineComment */'Editor.toggleLineComment'
1467
+ }, {
1468
+ id: 'toggle-block-comment',
1469
+ label: toggleBlockComment(),
1470
+ flags: None,
1471
+ command: /* Editor.toggleBlockComment */'Editor.toggleBlockComment'
1472
+ }];
1473
+ };
1474
+
1475
+ const MenuEntriesEdit = {
1476
+ __proto__: null,
1477
+ getMenuEntries: getMenuEntries$d,
1478
+ id: id$9
1479
+ };
1480
+
1481
+ /**
1482
+ * @enum {string}
1483
+ */
1484
+ const UiStrings$1 = {
1485
+ NewFile: 'New File',
1486
+ NewWindow: 'New Window',
1487
+ OpenFile: 'Open File',
1488
+ OpenFolder: 'Open Folder',
1489
+ OpenRecent: 'Open Recent',
1490
+ Exit: 'Exit',
1491
+ Save: 'Save',
1492
+ SaveAll: 'Save All'
1493
+ };
1494
+ const newFile = () => {
1495
+ return i18nString(UiStrings$1.NewFile);
1496
+ };
1497
+ const newWindow = () => {
1498
+ return i18nString(UiStrings$1.NewWindow);
1499
+ };
1500
+ const openFile = () => {
1501
+ return i18nString(UiStrings$1.OpenFile);
1502
+ };
1503
+ const openFolder = () => {
1504
+ return i18nString(UiStrings$1.OpenFolder);
1505
+ };
1506
+ const openRecent = () => {
1507
+ return i18nString(UiStrings$1.OpenRecent);
1508
+ };
1509
+ const save = () => {
1510
+ return i18nString(UiStrings$1.Save);
1511
+ };
1512
+ const saveAll = () => {
1513
+ return i18nString(UiStrings$1.SaveAll);
1514
+ };
1515
+ const exit = () => {
1516
+ return i18nString(UiStrings$1.Exit);
1517
+ };
1518
+
1519
+ const Web = 1;
1520
+ const Electron = 2;
1521
+
1522
+ const id$8 = File$2;
1523
+ const getMenuEntries$c = platform => {
1524
+ const entries = [{
1525
+ id: 'newFile',
1526
+ label: newFile(),
1527
+ flags: None,
1528
+ command: '-1'
1529
+ }, {
1530
+ id: 'newWindow',
1531
+ label: newWindow(),
1532
+ flags: None,
1533
+ command: /* Window.openNew */'Window.openNew'
1534
+ }, menuEntrySeparator, {
1535
+ id: 'openFile',
1536
+ label: openFile(),
1537
+ flags: None,
1538
+ command: 'Dialog.openFile'
1539
+ }, {
1540
+ id: 'openFolder',
1541
+ label: openFolder(),
1542
+ flags: RestoreFocus,
1543
+ command: 'Dialog.openFolder'
1544
+ }, {
1545
+ id: OpenRecent,
1546
+ label: openRecent(),
1547
+ flags: SubMenu,
1548
+ command: ''
1549
+ }, menuEntrySeparator, {
1550
+ id: 'save',
1551
+ label: save(),
1552
+ flags: None,
1553
+ command: 'Main.save'
1554
+ }, {
1555
+ id: 'saveAll',
1556
+ label: saveAll(),
1557
+ flags: None,
1558
+ command: 'Main.saveAll'
1559
+ }];
1560
+ if (platform === Electron) {
1561
+ entries.push(menuEntrySeparator, {
1562
+ id: 'exit',
1563
+ label: exit(),
1564
+ flags: Ignore,
1565
+ command: 'Chrome.exit'
1566
+ });
1567
+ }
1568
+ return entries;
1610
1569
  };
1611
- const setExtensionsSearchValue = async searchValue => {
1612
- // @ts-ignore
1613
- return invoke$1('Extensions.handleInput', searchValue);
1570
+
1571
+ const MenuEntriesFile = {
1572
+ __proto__: null,
1573
+ getMenuEntries: getMenuEntries$c,
1574
+ id: id$8
1614
1575
  };
1615
- const openExternal = async uri => {
1616
- // @ts-ignore
1617
- await invoke$1('Open.openExternal', uri);
1576
+
1577
+ const id$7 = Go$1;
1578
+ const getMenuEntries$b = () => {
1579
+ return [];
1618
1580
  };
1619
- const openUrl = async uri => {
1620
- // @ts-ignore
1621
- await invoke$1('Open.openUrl', uri);
1581
+
1582
+ const MenuEntriesGo = {
1583
+ __proto__: null,
1584
+ getMenuEntries: getMenuEntries$b,
1585
+ id: id$7
1622
1586
  };
1623
- const getAllPreferences = async () => {
1624
- // @ts-ignore
1625
- return invoke$1('Preferences.getAll');
1587
+
1588
+ const About = 'About';
1589
+ const Edit = 'Edit';
1590
+ const File$1 = 'File';
1591
+ const Go = 'Go';
1592
+ const Help = 'Help';
1593
+ const OpenProcessExplorer = 'Open Process Explorer';
1594
+ const Run = 'Run';
1595
+ const Selection = 'Selection';
1596
+ const Terminal = 'Terminal';
1597
+ const ToggleDeveloperTools = 'Toggle Developer Tools';
1598
+ const View = 'View';
1599
+
1600
+ const toggleDeveloperTools = () => {
1601
+ return i18nString(ToggleDeveloperTools);
1626
1602
  };
1627
- const showSaveFilePicker = async () => {
1628
- // @ts-ignore
1629
- return invoke$1('FilePicker.showSaveFilePicker');
1603
+ const openProcessExplorer = () => {
1604
+ return i18nString(OpenProcessExplorer);
1630
1605
  };
1631
- const getLogsDir = async () => {
1632
- // @ts-ignore
1633
- return invoke$1('PlatformPaths.getLogsDir');
1606
+ const about = () => {
1607
+ return i18nString(About);
1634
1608
  };
1635
- const registerMockRpc = commandMap => {
1636
- const mockRpc = createMockRpc({
1637
- commandMap
1609
+
1610
+ const id$6 = Help$1;
1611
+ const getMenuEntries$a = async platform => {
1612
+ const entries = [];
1613
+ if (platform !== Web) {
1614
+ entries.push({
1615
+ id: 'toggleDeveloperTools',
1616
+ label: toggleDeveloperTools(),
1617
+ flags: None,
1618
+ command: 'Developer.toggleDeveloperTools'
1619
+ }, {
1620
+ id: 'openProcessExplorer',
1621
+ label: openProcessExplorer(),
1622
+ flags: RestoreFocus,
1623
+ command: 'Developer.openProcessExplorer'
1624
+ });
1625
+ }
1626
+ if (entries.length > 0) {
1627
+ entries.push(menuEntrySeparator);
1628
+ }
1629
+ entries.push({
1630
+ id: 'about',
1631
+ label: about(),
1632
+ flags: None,
1633
+ command: 'About.showAbout'
1638
1634
  });
1639
- set$1(mockRpc);
1640
- return mockRpc;
1635
+ return entries;
1641
1636
  };
1642
1637
 
1643
- const RendererWorker = {
1638
+ const MenuEntriesHelp = {
1644
1639
  __proto__: null,
1645
- activateByEvent,
1646
- applyBulkReplacement,
1647
- closeWidget,
1648
- confirm,
1649
- disableExtension,
1650
- dispose,
1651
- enableExtension,
1652
- getActiveEditorId,
1653
- getAllExtensions,
1654
- getAllPreferences,
1655
- getBlob,
1656
- getChromeVersion,
1657
- getColorThemeNames,
1658
- getElectronVersion,
1659
- getExtension,
1660
- getExtensionCommands,
1661
- getFileHandles,
1662
- getFileIcon,
1663
- getFilePathElectron,
1664
- getFolderIcon,
1665
- getFolderSize,
1666
- getIcons,
1667
- getKeyBindings,
1668
- getLogsDir,
1669
- getMarkdownDom,
1670
- getNodeVersion,
1671
- getPreference,
1672
- getRecentlyOpened: getRecentlyOpened$1,
1673
- getV8Version,
1674
- getWebViewSecret,
1675
- getWindowId,
1676
- getWorkspacePath,
1677
- handleDebugChange,
1678
- handleDebugPaused,
1679
- handleDebugResumed,
1680
- handleDebugScriptParsed,
1681
- installExtension,
1682
- invoke: invoke$1,
1683
- invokeAndTransfer,
1684
- openExtensionSearch,
1685
- openExternal,
1686
- openNativeFolder,
1687
- openUri,
1688
- openUrl,
1689
- openWidget,
1690
- readFile,
1691
- registerMockRpc,
1692
- registerWebViewInterceptor,
1693
- renderMarkdown,
1694
- rerenderEditor,
1695
- searchFileFetch,
1696
- searchFileHtml,
1697
- searchFileMemory,
1698
- sendMessagePortToEditorWorker,
1699
- sendMessagePortToErrorWorker,
1700
- sendMessagePortToExtensionHostWorker,
1701
- sendMessagePortToFileSystemWorker,
1702
- sendMessagePortToIconThemeWorker,
1703
- sendMessagePortToMarkdownWorker,
1704
- sendMessagePortToRendererProcess,
1705
- sendMessagePortToSearchProcess,
1706
- sendMessagePortToSyntaxHighlightingWorker,
1707
- set: set$1,
1708
- setAdditionalFocus,
1709
- setColorTheme,
1710
- setExtensionsSearchValue,
1711
- setFocus,
1712
- setWebViewPort,
1713
- setWorkspacePath,
1714
- showContextMenu,
1715
- showErrorDialog,
1716
- showMessageBox,
1717
- showSaveFilePicker,
1718
- uninstallExtension,
1719
- unregisterWebViewInterceptor,
1720
- writeClipBoardImage,
1721
- writeClipBoardText
1640
+ getMenuEntries: getMenuEntries$a,
1641
+ id: id$6
1722
1642
  };
1723
1643
 
1724
- const {
1725
- invoke,
1726
- set
1727
- } = RendererWorker;
1728
-
1729
1644
  const getRecentlyOpened = () => {
1730
- return invoke(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1645
+ return invoke$2(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1731
1646
  };
1732
1647
 
1733
1648
  const File = 'file://';
@@ -1758,7 +1673,7 @@ const toMenuItem = folder => {
1758
1673
  };
1759
1674
  };
1760
1675
  const id$5 = OpenRecent;
1761
- const getMenuEntries$8 = async () => {
1676
+ const getMenuEntries$9 = async () => {
1762
1677
  const allItems = await getRecentlyOpened();
1763
1678
  const itemsToShow = allItems.slice(0, MAX_MENU_RECENT_ENTRIES);
1764
1679
  const items = [];
@@ -1781,23 +1696,23 @@ const getMenuEntries$8 = async () => {
1781
1696
 
1782
1697
  const MenuEntriesOpenRecent = {
1783
1698
  __proto__: null,
1784
- getMenuEntries: getMenuEntries$8,
1699
+ getMenuEntries: getMenuEntries$9,
1785
1700
  id: id$5
1786
1701
  };
1787
1702
 
1788
1703
  const id$4 = Run$1;
1789
- const getMenuEntries$7 = () => {
1704
+ const getMenuEntries$8 = () => {
1790
1705
  return [];
1791
1706
  };
1792
1707
 
1793
1708
  const MenuEntriesRun = {
1794
1709
  __proto__: null,
1795
- getMenuEntries: getMenuEntries$7,
1710
+ getMenuEntries: getMenuEntries$8,
1796
1711
  id: id$4
1797
1712
  };
1798
1713
 
1799
1714
  const id$3 = Selection$1;
1800
- const getMenuEntries$6 = () => {
1715
+ const getMenuEntries$7 = () => {
1801
1716
  return [{
1802
1717
  id: 'selectAll',
1803
1718
  label: selectAll(),
@@ -1828,7 +1743,7 @@ const getMenuEntries$6 = () => {
1828
1743
 
1829
1744
  const MenuEntriesSelection = {
1830
1745
  __proto__: null,
1831
- getMenuEntries: getMenuEntries$6,
1746
+ getMenuEntries: getMenuEntries$7,
1832
1747
  id: id$3
1833
1748
  };
1834
1749
 
@@ -1843,7 +1758,7 @@ const newTerminal = () => {
1843
1758
  };
1844
1759
 
1845
1760
  const id$2 = Terminal$1;
1846
- const getMenuEntries$5 = () => {
1761
+ const getMenuEntries$6 = () => {
1847
1762
  return [{
1848
1763
  id: 'newTerminal',
1849
1764
  label: newTerminal(),
@@ -1855,7 +1770,7 @@ const getMenuEntries$5 = () => {
1855
1770
 
1856
1771
  const MenuEntriesTerminal = {
1857
1772
  __proto__: null,
1858
- getMenuEntries: getMenuEntries$5,
1773
+ getMenuEntries: getMenuEntries$6,
1859
1774
  id: id$2
1860
1775
  };
1861
1776
 
@@ -1884,7 +1799,7 @@ const help = () => {
1884
1799
  return i18nString(Help);
1885
1800
  };
1886
1801
 
1887
- const getMenuEntries$4 = () => {
1802
+ const getMenuEntries$5 = () => {
1888
1803
  return [{
1889
1804
  id: File$2,
1890
1805
  label: file(),
@@ -1923,7 +1838,7 @@ const getMenuEntries$4 = () => {
1923
1838
  }];
1924
1839
  };
1925
1840
 
1926
- const getMenuEntries$3 = () => {
1841
+ const getMenuEntries$4 = () => {
1927
1842
  return [{
1928
1843
  id: File$2,
1929
1844
  label: file(),
@@ -1954,106 +1869,82 @@ const getMenuEntries$3 = () => {
1954
1869
  const getFn = platform => {
1955
1870
  switch (platform) {
1956
1871
  case Web:
1957
- return getMenuEntries$3;
1958
- default:
1959
1872
  return getMenuEntries$4;
1873
+ default:
1874
+ return getMenuEntries$5;
1960
1875
  }
1961
- };
1962
- const id$1 = TitleBar;
1963
- const getMenuEntries$2 = async platform => {
1964
- const fn = getFn(platform);
1965
- return fn();
1966
- };
1967
-
1968
- const MenuEntriesTitleBar = {
1969
- __proto__: null,
1970
- getMenuEntries: getMenuEntries$2,
1971
- id: id$1
1972
- };
1973
-
1974
- const id = View$1;
1975
- const getMenuEntries$1 = () => {
1976
- return [];
1977
- };
1978
-
1979
- const MenuEntriesView = {
1980
- __proto__: null,
1981
- getMenuEntries: getMenuEntries$1,
1982
- id
1983
- };
1984
-
1985
- const menus$1 = [MenuEntriesEdit, MenuEntriesFile, MenuEntriesGo, MenuEntriesHelp, MenuEntriesRun, MenuEntriesSelection, MenuEntriesTerminal, MenuEntriesTitleBar, MenuEntriesView, MenuEntriesOpenRecent];
1986
-
1987
- const getMenuIds = () => {
1988
- return menus$1.map(menu => menu.id);
1989
- };
1990
- const getMenuEntries = (id, platform) => {
1991
- const menu = menus$1.find(item => item.id === id);
1992
- if (!menu) {
1993
- return [];
1994
- }
1995
- return menu.getMenuEntries(platform);
1996
- };
1997
-
1998
- const maximize = async () => {
1999
- await invoke('ElectronWindow.maximize');
2000
- };
2001
- const minimize = async () => {
2002
- await invoke('ElectronWindow.minimize');
2003
- };
2004
- const close = async () => {
2005
- await invoke('ElectronWindow.close');
2006
- };
2007
-
2008
- const handleClickClose = async state => {
2009
- await close();
2010
- return state;
2011
- };
2012
-
2013
- const handleClickMinimize = async state => {
2014
- await minimize();
2015
- return state;
2016
- };
2017
-
2018
- const handleClickToggleMaximize = async state => {
2019
- const fn = maximize;
2020
- await fn();
2021
- return state;
2022
- };
2023
-
2024
- const handleClick = (state, className) => {
2025
- if (className.includes('Minimize')) {
2026
- return handleClickMinimize(state);
2027
- }
2028
- if (className.includes('Maximize') || className.includes('Restore')) {
2029
- return handleClickToggleMaximize(state);
2030
- }
2031
- if (className.includes('Close')) {
2032
- return handleClickClose(state);
2033
- }
2034
- return state;
1876
+ };
1877
+ const id$1 = TitleBar;
1878
+ const getMenuEntries$3 = async platform => {
1879
+ const fn = getFn(platform);
1880
+ return fn();
2035
1881
  };
2036
1882
 
2037
- const handleContextMenu = state => {
2038
- return state;
1883
+ const MenuEntriesTitleBar = {
1884
+ __proto__: null,
1885
+ getMenuEntries: getMenuEntries$3,
1886
+ id: id$1
2039
1887
  };
2040
1888
 
2041
- const loadContent = async (state, titleBarEntries) => {
2042
- return {
2043
- ...state
2044
- };
1889
+ const id = View$1;
1890
+ const getMenuEntries$2 = () => {
1891
+ return [];
2045
1892
  };
2046
1893
 
2047
- const menus = [MenuEntriesEdit, MenuEntriesFile, MenuEntriesGo, MenuEntriesHelp, MenuEntriesRun, MenuEntriesSelection, MenuEntriesTerminal, MenuEntriesTitleBar, MenuEntriesView, MenuEntriesOpenRecent];
1894
+ const MenuEntriesView = {
1895
+ __proto__: null,
1896
+ getMenuEntries: getMenuEntries$2,
1897
+ id
1898
+ };
1899
+
1900
+ const menus$1 = [MenuEntriesEdit, MenuEntriesFile, MenuEntriesGo, MenuEntriesHelp, MenuEntriesRun, MenuEntriesSelection, MenuEntriesTerminal, MenuEntriesTitleBar, MenuEntriesView, MenuEntriesOpenRecent];
2048
1901
  const getMenus = () => {
2049
- return menus;
1902
+ return menus$1;
1903
+ };
1904
+ const getModule$1 = id => {
1905
+ for (const module of menus$1) {
1906
+ if (module.id === id) {
1907
+ return module;
1908
+ }
1909
+ }
1910
+ return undefined;
1911
+ };
1912
+ const getMenuEntries$1 = async (id, ...args) => {
1913
+ try {
1914
+ const module = getModule$1(id);
1915
+ // @ts-ignore
1916
+ const inject = module.inject || [];
1917
+ // @ts-ignore
1918
+ return module.getMenuEntries(...args);
1919
+ } catch (error) {
1920
+ throw new VError(error, `Failed to load menu entries for id ${id}`);
1921
+ }
2050
1922
  };
2051
1923
 
2052
- const renderFocusedIndex = (oldState, newState) => {
2053
- if (newState.focusedIndex === -1) {
2054
- return [];
1924
+ const addKeyBindings = menuEntries => {
1925
+ const keyBindings = state$1.matchingKeyBindings;
1926
+ const newMenuEntries = [];
1927
+ for (const menuEntry of menuEntries) {
1928
+ const keyBinding = getCommandKeyBinding(keyBindings, menuEntry.command, menuEntry.args);
1929
+ const key = keyBinding ? keyBinding.key : 0;
1930
+ const newMenuEntry = {
1931
+ ...menuEntry,
1932
+ key
1933
+ };
1934
+ newMenuEntries.push(newMenuEntry);
2055
1935
  }
2056
- return ['Viewlet.focusSelector', '.ViewletTitleBarMenuBar'];
1936
+ return newMenuEntries;
1937
+ };
1938
+ const getMenuEntriesWithKeyBindings = async (id, ...args) => {
1939
+ const menuEntries = await getMenuEntries$1(id, ...args);
1940
+ const newMenuEntries = addKeyBindings(menuEntries);
1941
+ return newMenuEntries;
1942
+ };
1943
+ const getMenuEntriesWithKeyBindings2 = async (uid, menuId, ...args) => {
1944
+ // @ts-ignore
1945
+ const menuEntries = await undefined(uid, menuId, ...args);
1946
+ const newMenuEntries = addKeyBindings(menuEntries);
1947
+ return newMenuEntries;
2057
1948
  };
2058
1949
 
2059
1950
  const Menu$1 = 'menu';
@@ -2073,6 +1964,18 @@ const MenuItemSeparatorLine = 'MenuItemSeparatorLine';
2073
1964
  const MenuItemSubMenu = 'MenuItemSubMenu';
2074
1965
  const MenuItemSubMenuArrowRight = 'MenuItemSubMenuArrowRight';
2075
1966
 
1967
+ const mergeClassNames = (...classNames) => {
1968
+ return classNames.filter(Boolean).join(' ');
1969
+ };
1970
+
1971
+ const text = data => {
1972
+ return {
1973
+ type: Text,
1974
+ text: data,
1975
+ childCount: 0
1976
+ };
1977
+ };
1978
+
2076
1979
  const Div = 4;
2077
1980
  const Span = 8;
2078
1981
 
@@ -2554,6 +2457,325 @@ const getVisible = (items, focusedIndex, expanded, level) => {
2554
2457
  return visibleItems;
2555
2458
  };
2556
2459
 
2460
+ // TODO lazyload menuEntries and use Command.execute (maybe)
2461
+ const CONTEXT_MENU_WIDTH = 250;
2462
+ const state = {
2463
+ menus: []};
2464
+ const addMenuInternal = menu => {
2465
+ if (state.menus.length > 5) {
2466
+ throw new Error('too many menus');
2467
+ }
2468
+ state.menus.push(menu);
2469
+ return menu;
2470
+ };
2471
+
2472
+ // TODO handle printable letter and focus item that starts with that letter
2473
+
2474
+ // TODO pageup / pagedown keys
2475
+
2476
+ // TODO more tests
2477
+
2478
+ const CONTEXT_MENU_ITEM_HEIGHT = 26;
2479
+ const CONTEXT_MENU_SEPARATOR_HEIGHT = 11;
2480
+ const CONTEXT_MENU_PADDING = 8;
2481
+ const getMenuHeight = items => {
2482
+ let height = CONTEXT_MENU_PADDING;
2483
+ for (const item of items) {
2484
+ switch (item.flags) {
2485
+ case Separator$1:
2486
+ height += CONTEXT_MENU_SEPARATOR_HEIGHT;
2487
+ break;
2488
+ default:
2489
+ height += CONTEXT_MENU_ITEM_HEIGHT;
2490
+ break;
2491
+ }
2492
+ }
2493
+ return height;
2494
+ };
2495
+ const getMenuBounds = (x, y, items) => {
2496
+ const menuWidth = CONTEXT_MENU_WIDTH;
2497
+ const menuHeight = getMenuHeight(items);
2498
+ const layoutState = {
2499
+ points: [0, 0]
2500
+ };
2501
+ const windowWidth = layoutState.points[0];
2502
+ const windowHeight = layoutState.points[1];
2503
+ // TODO maybe only send labels and keybindings to ui (id not needed on ui)
2504
+ // TODO what about separators?
2505
+
2506
+ if (x + menuWidth > windowWidth) {
2507
+ x -= menuWidth;
2508
+ }
2509
+ if (y + menuHeight > windowHeight) {
2510
+ y -= menuHeight;
2511
+ }
2512
+ return {
2513
+ x,
2514
+ y,
2515
+ width: menuWidth,
2516
+ height: menuHeight
2517
+ };
2518
+ };
2519
+ const show$2 = async (x, y, id, mouseBlocking = false, ...args) => {
2520
+ const items = await getMenuEntriesWithKeyBindings(id, ...args);
2521
+ const bounds = getMenuBounds(x, y, items);
2522
+ const menu = addMenuInternal({
2523
+ id,
2524
+ items,
2525
+ focusedIndex: -1,
2526
+ level: state.menus.length,
2527
+ x: bounds.x,
2528
+ y: bounds.y
2529
+ });
2530
+ const visible = getVisible(menu.items, -1, false, menu.level);
2531
+ const dom = getMenuVirtualDom(visible).slice(1);
2532
+ 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);
2533
+ };
2534
+ const show2$2 = async (uid, menuId, x, y, mouseBlocking = false, ...args) => {
2535
+ const items = await getMenuEntriesWithKeyBindings2(uid, menuId, ...args);
2536
+ const bounds = getMenuBounds(x, y, items);
2537
+ const menu = addMenuInternal({
2538
+ id: menuId,
2539
+ items,
2540
+ focusedIndex: -1,
2541
+ level: state.menus.length,
2542
+ x: bounds.x,
2543
+ y: bounds.y
2544
+ });
2545
+ const visible = getVisible(menu.items, -1, false, menu.level);
2546
+ const dom = getMenuVirtualDom(visible).slice(1);
2547
+ 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);
2548
+ };
2549
+ const hide = async (restoreFocus = true) => {
2550
+ if (state.menus.length === 0) {
2551
+ return;
2552
+ }
2553
+ state.menus = [];
2554
+ await invoke$1(/* Menu.hide */'Menu.hide', /* restoreFocus */restoreFocus);
2555
+ };
2556
+
2557
+ const show$1 = async (x, y, id, ...args) => {
2558
+ // @ts-ignore
2559
+ await hide();
2560
+ // TODO handle error
2561
+ // TODO race condition
2562
+ await show$2(x, y, id, /* mouseBlocking */true, ...args);
2563
+ // TODO maybe only send labels and keybindings to ui (id not needed on ui)
2564
+ // TODO what about separators?
2565
+ };
2566
+ const show2$1 = async (uid, menuId, x, y, ...args) => {
2567
+ // @ts-ignore
2568
+ await hide();
2569
+ // TODO handle error
2570
+ // TODO race condition
2571
+ await show2$2(uid, menuId, x, y, /* mouseBlocking */true, ...args);
2572
+ // TODO maybe only send labels and keybindings to ui (id not needed on ui)
2573
+ // TODO what about separators?
2574
+ };
2575
+
2576
+ const ContextMenuBrowser = {
2577
+ __proto__: null,
2578
+ show: show$1,
2579
+ show2: show2$1
2580
+ };
2581
+
2582
+ const getModule = async platform => {
2583
+ return ContextMenuBrowser;
2584
+ };
2585
+ const show = async (x, y, id, ...args) => {
2586
+ number(x);
2587
+ number(y);
2588
+ number(id);
2589
+ const module = await getModule();
2590
+ return module.show(x, y, id, ...args);
2591
+ };
2592
+ const show2 = async (uid, menuId, x, y, ...args) => {
2593
+ number(uid);
2594
+ number(menuId);
2595
+ number(x);
2596
+ number(y);
2597
+ const module = getModule();
2598
+ // @ts-ignore
2599
+ return module.show2(uid, menuId, x, y, ...args);
2600
+ };
2601
+
2602
+ const RenderEntries = 1;
2603
+ const RenderFocusedIndex = 2;
2604
+ const RenderMenus = 3;
2605
+
2606
+ const diffType$2 = RenderEntries;
2607
+ const isEqual$2 = (oldState, newState) => {
2608
+ return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
2609
+ };
2610
+
2611
+ const diffType$1 = RenderFocusedIndex;
2612
+ const isEqual$1 = (oldState, newState) => {
2613
+ return oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
2614
+ };
2615
+
2616
+ const diffType = RenderMenus;
2617
+ const isEqual = (oldState, newState) => {
2618
+ return oldState.menus === newState.menus;
2619
+ };
2620
+
2621
+ const modules = [isEqual$2, isEqual$1, isEqual];
2622
+ const numbers = [diffType$2, diffType$1, diffType];
2623
+
2624
+ const diff = (oldState, newState) => {
2625
+ const diffResult = [];
2626
+ for (let i = 0; i < modules.length; i++) {
2627
+ const fn = modules[i];
2628
+ if (!fn(oldState, newState)) {
2629
+ diffResult.push(numbers[i]);
2630
+ }
2631
+ }
2632
+ return diffResult;
2633
+ };
2634
+
2635
+ const create = () => {
2636
+ const states = Object.create(null);
2637
+ return {
2638
+ get(uid) {
2639
+ return states[uid];
2640
+ },
2641
+ set(uid, oldState, newState) {
2642
+ states[uid] = {
2643
+ oldState,
2644
+ newState
2645
+ };
2646
+ }
2647
+ };
2648
+ };
2649
+
2650
+ const {
2651
+ get,
2652
+ set
2653
+ } = create();
2654
+
2655
+ const diff2 = uid => {
2656
+ const {
2657
+ oldState,
2658
+ newState
2659
+ } = get(uid);
2660
+ return diff(oldState, newState);
2661
+ };
2662
+
2663
+ const commandsIds = ['closeMenu', 'handleClickAt', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleClick', 'handleFocus', 'handleFocusOut', 'handleKeyArrowDown', 'handleKeyArrowLeft', 'handleKeyArrowRight', 'handleKeyArrowUp', 'handleKeyEnd', 'handleKeyEnter', 'handleKeyEscape', 'handleKeyHome', 'handleKeySpace', 'handleMenuClick', 'handleMenuMouseOver', 'handleMouseOut', 'handleMouseOver', 'handlePointerOver', 'handlePointerOut', 'toggleIndex', 'toggleMenu'];
2664
+
2665
+ const getCommandIds = () => {
2666
+ return commandsIds;
2667
+ };
2668
+
2669
+ const FocusTitleBarMenuBar = 26;
2670
+
2671
+ const getKeyBindings = () => {
2672
+ return [{
2673
+ key: DownArrow$2,
2674
+ command: 'TitleBarMenuBar.handleKeyArrowDown',
2675
+ when: FocusTitleBarMenuBar
2676
+ }, {
2677
+ key: UpArrow$2,
2678
+ command: 'TitleBarMenuBar.handleKeyArrowUp',
2679
+ when: FocusTitleBarMenuBar
2680
+ }, {
2681
+ key: RightArrow$2,
2682
+ command: 'TitleBarMenuBar.handleKeyArrowRight',
2683
+ when: FocusTitleBarMenuBar
2684
+ }, {
2685
+ key: LeftArrow$2,
2686
+ command: 'TitleBarMenuBar.handleKeyArrowLeft',
2687
+ when: FocusTitleBarMenuBar
2688
+ }, {
2689
+ key: Space$2,
2690
+ command: 'TitleBarMenuBar.handleKeySpace',
2691
+ when: FocusTitleBarMenuBar
2692
+ }, {
2693
+ key: Home$2,
2694
+ command: 'TitleBarMenuBar.handleKeyHome',
2695
+ when: FocusTitleBarMenuBar
2696
+ }, {
2697
+ key: End$2,
2698
+ command: 'TitleBarMenuBar.handleKeyEnd',
2699
+ when: FocusTitleBarMenuBar
2700
+ }, {
2701
+ key: Escape$2,
2702
+ command: 'TitleBarMenuBar.handleKeyEscape',
2703
+ when: FocusTitleBarMenuBar
2704
+ }];
2705
+ };
2706
+
2707
+ const menus = [MenuEntriesEdit, MenuEntriesFile, MenuEntriesGo, MenuEntriesHelp, MenuEntriesRun, MenuEntriesSelection, MenuEntriesTerminal, MenuEntriesTitleBar, MenuEntriesView, MenuEntriesOpenRecent];
2708
+
2709
+ const getMenuIds = () => {
2710
+ return menus.map(menu => menu.id);
2711
+ };
2712
+ const getMenuEntries = (id, platform) => {
2713
+ const menu = menus.find(item => item.id === id);
2714
+ if (!menu) {
2715
+ return [];
2716
+ }
2717
+ return menu.getMenuEntries(platform);
2718
+ };
2719
+
2720
+ const {
2721
+ invoke} = RendererWorker;
2722
+
2723
+ const maximize = async () => {
2724
+ await invoke('ElectronWindow.maximize');
2725
+ };
2726
+ const minimize = async () => {
2727
+ await invoke('ElectronWindow.minimize');
2728
+ };
2729
+ const close = async () => {
2730
+ await invoke('ElectronWindow.close');
2731
+ };
2732
+
2733
+ const handleClickClose = async state => {
2734
+ await close();
2735
+ return state;
2736
+ };
2737
+
2738
+ const handleClickMinimize = async state => {
2739
+ await minimize();
2740
+ return state;
2741
+ };
2742
+
2743
+ const handleClickToggleMaximize = async state => {
2744
+ const fn = maximize;
2745
+ await fn();
2746
+ return state;
2747
+ };
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);
2758
+ }
2759
+ return state;
2760
+ };
2761
+
2762
+ const handleContextMenu = state => {
2763
+ return state;
2764
+ };
2765
+
2766
+ const loadContent = async (state, titleBarEntries) => {
2767
+ return {
2768
+ ...state
2769
+ };
2770
+ };
2771
+
2772
+ const renderFocusedIndex = (oldState, newState) => {
2773
+ if (newState.focusedIndex === -1) {
2774
+ return [];
2775
+ }
2776
+ return ['Viewlet.focusSelector', '.ViewletTitleBarMenuBar'];
2777
+ };
2778
+
2557
2779
  const SetMenus = 'setMenus';
2558
2780
 
2559
2781
  const renderMenus = (oldState, newState) => {
@@ -2611,8 +2833,8 @@ const render2 = async (uid, diffResult) => {
2611
2833
  const {
2612
2834
  oldState,
2613
2835
  newState
2614
- } = get$1(uid);
2615
- set$3(uid, newState, newState);
2836
+ } = get(uid);
2837
+ set(uid, newState, newState);
2616
2838
  const commands = applyRender(oldState, newState, diffResult);
2617
2839
  return commands;
2618
2840
  };
@@ -2656,13 +2878,13 @@ const wrapCommand = fn => {
2656
2878
  const wrapped = async (uid, ...args) => {
2657
2879
  const {
2658
2880
  newState
2659
- } = get$1(uid);
2881
+ } = get(uid);
2660
2882
  const newerState = await fn(newState, ...args);
2661
2883
  if (newState === newerState) {
2662
2884
  return;
2663
2885
  }
2664
- const latest = get$1(uid);
2665
- set$3(uid, latest.oldState, newerState);
2886
+ const latest = get(uid);
2887
+ set(uid, latest.oldState, newerState);
2666
2888
  };
2667
2889
  return wrapped;
2668
2890
  };
@@ -2675,18 +2897,20 @@ const commandMap = {
2675
2897
  'Menu.renderEventListeners': renderEventListeners,
2676
2898
  'Menu.diff2': diff2,
2677
2899
  'Menu.getCommands': getCommandIds,
2678
- 'Menu.getKeyBindings': getKeyBindings$1,
2900
+ 'Menu.getKeyBindings': getKeyBindings,
2679
2901
  'Menu.getMenus': getMenus,
2680
2902
  'Menu.loadContent': wrapCommand(loadContent),
2681
2903
  'Menu.render2': render2,
2682
- 'Menu.saveState': saveState
2904
+ 'Menu.saveState': saveState,
2905
+ 'Menu.show': show,
2906
+ 'Menu.show2': show2
2683
2907
  };
2684
2908
 
2685
2909
  const listen = async () => {
2686
2910
  const rpc = await WebWorkerRpcClient.create({
2687
2911
  commandMap: commandMap
2688
2912
  });
2689
- set(rpc);
2913
+ set$1(rpc);
2690
2914
  };
2691
2915
 
2692
2916
  const main = async () => {