@lvce-editor/title-bar-worker 2.28.0 → 3.0.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.
@@ -433,7 +433,7 @@ const create$4 = (method, params) => {
433
433
  };
434
434
  };
435
435
  const callbacks = Object.create(null);
436
- const set$4 = (id, fn) => {
436
+ const set$3 = (id, fn) => {
437
437
  callbacks[id] = fn;
438
438
  };
439
439
  const get$2 = id => {
@@ -442,9 +442,9 @@ const get$2 = id => {
442
442
  const remove = id => {
443
443
  delete callbacks[id];
444
444
  };
445
- let id$a = 0;
445
+ let id = 0;
446
446
  const create$3$1 = () => {
447
- return ++id$a;
447
+ return ++id;
448
448
  };
449
449
  const registerPromise = () => {
450
450
  const id = create$3$1();
@@ -452,7 +452,7 @@ const registerPromise = () => {
452
452
  resolve,
453
453
  promise
454
454
  } = Promise.withResolvers();
455
- set$4(id, resolve);
455
+ set$3(id, resolve);
456
456
  return {
457
457
  id,
458
458
  promise
@@ -797,10 +797,10 @@ const send = (transport, method, ...params) => {
797
797
  const message = create$4(method, params);
798
798
  transport.send(message);
799
799
  };
800
- const invoke$2 = (ipc, method, ...params) => {
800
+ const invoke$1 = (ipc, method, ...params) => {
801
801
  return invokeHelper(ipc, method, params, false);
802
802
  };
803
- const invokeAndTransfer$1 = (ipc, method, ...params) => {
803
+ const invokeAndTransfer = (ipc, method, ...params) => {
804
804
  return invokeHelper(ipc, method, params, true);
805
805
  };
806
806
 
@@ -836,10 +836,10 @@ const createRpc = ipc => {
836
836
  send(ipc, method, ...params);
837
837
  },
838
838
  invoke(method, ...params) {
839
- return invoke$2(ipc, method, ...params);
839
+ return invoke$1(ipc, method, ...params);
840
840
  },
841
841
  invokeAndTransfer(method, ...params) {
842
- return invokeAndTransfer$1(ipc, method, ...params);
842
+ return invokeAndTransfer(ipc, method, ...params);
843
843
  },
844
844
  async dispose() {
845
845
  await ipc?.dispose();
@@ -891,372 +891,10 @@ const WebWorkerRpcClient = {
891
891
  __proto__: null,
892
892
  create: create$3
893
893
  };
894
- const createMockRpc = ({
895
- commandMap
896
- }) => {
897
- const invocations = [];
898
- const invoke = (method, ...params) => {
899
- invocations.push([method, ...params]);
900
- const command = commandMap[method];
901
- if (!command) {
902
- throw new Error(`command ${method} not found`);
903
- }
904
- return command(...params);
905
- };
906
- const mockRpc = {
907
- invoke,
908
- invokeAndTransfer: invoke,
909
- invocations
910
- };
911
- return mockRpc;
912
- };
913
-
914
- const toCommandId = key => {
915
- const dotIndex = key.indexOf('.');
916
- return key.slice(dotIndex + 1);
917
- };
918
- const create$2 = () => {
919
- const states = Object.create(null);
920
- const commandMapRef = {};
921
- return {
922
- get(uid) {
923
- return states[uid];
924
- },
925
- set(uid, oldState, newState) {
926
- states[uid] = {
927
- oldState,
928
- newState
929
- };
930
- },
931
- dispose(uid) {
932
- delete states[uid];
933
- },
934
- getKeys() {
935
- return Object.keys(states).map(key => {
936
- return Number.parseInt(key);
937
- });
938
- },
939
- clear() {
940
- for (const key of Object.keys(states)) {
941
- delete states[key];
942
- }
943
- },
944
- wrapCommand(fn) {
945
- const wrapped = async (uid, ...args) => {
946
- const {
947
- newState
948
- } = states[uid];
949
- const newerState = await fn(newState, ...args);
950
- if (newState === newerState) {
951
- return;
952
- }
953
- const latest = states[uid];
954
- states[uid] = {
955
- oldState: latest.oldState,
956
- newState: newerState
957
- };
958
- };
959
- return wrapped;
960
- },
961
- wrapGetter(fn) {
962
- const wrapped = (uid, ...args) => {
963
- const {
964
- newState
965
- } = states[uid];
966
- return fn(newState, ...args);
967
- };
968
- return wrapped;
969
- },
970
- diff(uid, modules, numbers) {
971
- const {
972
- oldState,
973
- newState
974
- } = states[uid];
975
- const diffResult = [];
976
- for (let i = 0; i < modules.length; i++) {
977
- const fn = modules[i];
978
- if (!fn(oldState, newState)) {
979
- diffResult.push(numbers[i]);
980
- }
981
- }
982
- return diffResult;
983
- },
984
- getCommandIds() {
985
- const keys = Object.keys(commandMapRef);
986
- const ids = keys.map(toCommandId);
987
- return ids;
988
- },
989
- registerCommands(commandMap) {
990
- Object.assign(commandMapRef, commandMap);
991
- }
992
- };
993
- };
994
- const terminate = () => {
995
- globalThis.close();
996
- };
997
-
998
- const Web = 1;
999
- const Electron = 2;
1000
- const Remote = 3;
1001
-
1002
- const DEFAULT_UID = 1;
1003
- const createDefaultState = (uid = DEFAULT_UID) => ({
1004
- assetDir: '',
1005
- buttons: [],
1006
- controlsOverlayEnabled: false,
1007
- focusedIndex: -1,
1008
- height: 30,
1009
- iconWidth: 30,
1010
- isMenuOpen: false,
1011
- labelFontFamily: 'system-ui, Ubuntu, Droid Sans, sans-serif',
1012
- labelFontSize: 13,
1013
- labelFontWeight: 400,
1014
- labelLetterSpacing: 0,
1015
- labelPadding: 8,
1016
- menus: [],
1017
- platform: Electron,
1018
- title: '',
1019
- titleBarButtons: [],
1020
- titleBarButtonsEnabled: true,
1021
- titleBarButtonsWidth: 90,
1022
- titleBarEntries: [],
1023
- titleBarHeight: 30,
1024
- titleBarIconEnabled: true,
1025
- titleBarIconWidth: 30,
1026
- titleBarMenuBarEnabled: true,
1027
- titleBarStyleCustom: true,
1028
- titleBarTitleEnabled: true,
1029
- uid,
1030
- width: 800,
1031
- x: 0,
1032
- y: 0,
1033
- layoutControlsEnabled: false,
1034
- commandCenterEnabled: false
1035
- });
1036
-
1037
- const emptyObject = {};
1038
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1039
- const i18nString = (key, placeholders = emptyObject) => {
1040
- if (placeholders === emptyObject) {
1041
- return key;
1042
- }
1043
- const replacer = (match, rest) => {
1044
- return placeholders[rest];
1045
- };
1046
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1047
- };
1048
-
1049
- const About = 'About';
1050
- const CheckForUpdates = 'Check For Updates';
1051
- const ClearRecentlyOpened = 'Clear Recently Opened';
1052
- const Close = 'Close';
1053
- const MenuBar$1 = 'Menu Bar';
1054
- const CommandCenter = 'Command Center';
1055
- const Edit$1 = 'Edit';
1056
- const File$2 = 'File';
1057
- const Go$1 = 'Go';
1058
- const Help$1 = 'Help';
1059
- const Maximize = 'Maximize';
1060
- const Minimize = 'Minimize';
1061
- const MoreDot = 'More ...';
1062
- const NewTerminal = 'New Terminal';
1063
- const OpenProcessExplorer = 'Open Process Explorer';
1064
- const Run$1 = 'Run';
1065
- const Selection$1 = 'Selection';
1066
- const Terminal$1 = 'Terminal';
1067
- const ToggleDeveloperTools = 'Toggle Developer Tools';
1068
- const View$1 = 'View';
1069
-
1070
- const file = () => {
1071
- return i18nString(File$2);
1072
- };
1073
- const edit = () => {
1074
- return i18nString(Edit$1);
1075
- };
1076
- const selection = () => {
1077
- return i18nString(Selection$1);
1078
- };
1079
- const view = () => {
1080
- return i18nString(View$1);
1081
- };
1082
- const go = () => {
1083
- return i18nString(Go$1);
1084
- };
1085
- const run = () => {
1086
- return i18nString(Run$1);
1087
- };
1088
- const terminal = () => {
1089
- return i18nString(Terminal$1);
1090
- };
1091
- const help = () => {
1092
- return i18nString(Help$1);
1093
- };
1094
- const minimize$1 = () => {
1095
- return i18nString(Minimize);
1096
- };
1097
- const maximize$1 = () => {
1098
- return i18nString(Maximize);
1099
- };
1100
- const close$1 = () => {
1101
- return i18nString(Close);
1102
- };
1103
- const menuBar = () => {
1104
- return i18nString(MenuBar$1);
1105
- };
1106
- const commandCenter = () => {
1107
- return i18nString(CommandCenter);
1108
- };
1109
-
1110
- const getTitleBarButtonsElectron = (controlsOverlayEnabled, titleBarStyleCustom) => {
1111
- if (controlsOverlayEnabled) {
1112
- return [];
1113
- }
1114
- if (titleBarStyleCustom) {
1115
- // TODO don't render title bar buttons on windows when electron window controls overlay is enabled
1116
- return [{
1117
- label: minimize$1(),
1118
- icon: 'Minimize',
1119
- id: 'Minimize',
1120
- onClick: 'handleClickMinimize'
1121
- }, {
1122
- label: maximize$1(),
1123
- icon: 'Maximize',
1124
- id: 'ToggleMaximize',
1125
- onClick: 'handleClickToggleMaximize'
1126
- }, {
1127
- label: close$1(),
1128
- icon: 'ChromeClose',
1129
- id: 'Close',
1130
- onClick: 'handleClickClose'
1131
- }];
1132
- }
1133
- return [];
1134
- };
1135
-
1136
- const getTitleBarButtonsRemote = () => {
1137
- return [];
1138
- };
1139
-
1140
- const getTitleBarButtonsWeb = () => {
1141
- return [];
1142
- };
1143
-
1144
- const getTitleBarButtons = (platform, controlsOverlayEnabled, titleBarStyleCustom) => {
1145
- switch (platform) {
1146
- case Electron:
1147
- return getTitleBarButtonsElectron(controlsOverlayEnabled, titleBarStyleCustom);
1148
- case Web:
1149
- return getTitleBarButtonsWeb();
1150
- case Remote:
1151
- return getTitleBarButtonsRemote();
1152
- default:
1153
- return [];
1154
- }
1155
- };
1156
-
1157
- const {
1158
- get: get$1,
1159
- set: set$3,
1160
- getCommandIds,
1161
- registerCommands,
1162
- wrapCommand,
1163
- wrapGetter
1164
- } = create$2();
1165
-
1166
- const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled, titleBarStyleCustom, assetDir) => {
1167
- const titleBarButtons = getTitleBarButtons(platform, controlsOverlayEnabled, titleBarStyleCustom);
1168
- const state = {
1169
- ...createDefaultState(),
1170
- uid: id,
1171
- titleBarEntries: [],
1172
- focusedIndex: -1,
1173
- isMenuOpen: false,
1174
- menus: [],
1175
- labelFontWeight: 400,
1176
- labelFontSize: 13,
1177
- labelFontFamily: 'system-ui, Ubuntu, Droid Sans, sans-serif',
1178
- labelPadding: 8,
1179
- labelLetterSpacing: 0,
1180
- titleBarHeight: height,
1181
- x,
1182
- y,
1183
- width,
1184
- height,
1185
- iconWidth: 30,
1186
- platform,
1187
- controlsOverlayEnabled,
1188
- titleBarStyleCustom,
1189
- titleBarButtons,
1190
- assetDir,
1191
- layoutControlsEnabled: false,
1192
- commandCenterEnabled: false
1193
- };
1194
- set$3(id, state, state);
1195
- };
1196
-
1197
- const RenderEntries = 1;
1198
- const RenderFocusedIndex = 2;
1199
- const RenderMenus = 3;
1200
-
1201
- const isEqual$3 = (oldState, newState) => {
1202
- return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
1203
- };
1204
-
1205
- const isEqual$2 = (oldState, newState) => {
1206
- return oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
1207
- };
1208
-
1209
- const isEqual$1 = (oldState, newState) => {
1210
- return oldState.menus === newState.menus;
1211
- };
1212
-
1213
- const modules$1 = [isEqual$3, isEqual$2, isEqual$1];
1214
- const numbers$1 = [RenderEntries, RenderFocusedIndex, RenderMenus];
1215
-
1216
- const diff = (oldState, newState) => {
1217
- const diffResult = [];
1218
- for (let i = 0; i < modules$1.length; i++) {
1219
- const fn = modules$1[i];
1220
- if (!fn(oldState, newState)) {
1221
- diffResult.push(numbers$1[i]);
1222
- }
1223
- }
1224
- return diffResult;
1225
- };
1226
-
1227
- const diff2 = uid => {
1228
- const {
1229
- oldState,
1230
- newState
1231
- } = get$1(uid);
1232
- return diff(oldState, newState);
1233
- };
1234
-
1235
- const isEqual = (oldState, newState) => {
1236
- return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.assetDir === newState.assetDir && oldState.titleBarIconEnabled === newState.titleBarIconEnabled && oldState.title === newState.title && oldState.titleBarTitleEnabled === newState.titleBarTitleEnabled && oldState.platform === newState.platform && oldState.controlsOverlayEnabled === newState.controlsOverlayEnabled && oldState.titleBarStyleCustom === newState.titleBarStyleCustom && oldState.titleBarButtonsEnabled === newState.titleBarButtonsEnabled && oldState.titleBarButtons === newState.titleBarButtons;
1237
- };
1238
-
1239
- const modules = [isEqual, isEqual$2, isEqual$1];
1240
- const numbers = [RenderEntries, RenderFocusedIndex, RenderMenus];
1241
-
1242
- const diff3 = uid => {
1243
- const {
1244
- oldState,
1245
- newState
1246
- } = get$1(uid);
1247
- const diffResult = [];
1248
- for (let i = 0; i < modules.length; i++) {
1249
- const fn = modules[i];
1250
- if (!fn(oldState, newState)) {
1251
- diffResult.push(numbers[i]);
1252
- }
1253
- }
1254
- return diffResult;
1255
- };
1256
894
 
1257
895
  const ContentInfo = 'contentinfo';
1258
896
  const Menu$1 = 'menu';
1259
- const MenuBar = 'menubar';
897
+ const MenuBar$1 = 'menubar';
1260
898
  const MenuItem$1 = 'menuitem';
1261
899
  const MenuItemCheckBox = 'menuitemcheckbox';
1262
900
  const None$1 = 'none';
@@ -1540,29 +1178,415 @@ const getKeyCodeString = keyCode => {
1540
1178
  }
1541
1179
  };
1542
1180
 
1543
- const Script = 2;
1181
+ const CtrlCmd = 1 << 11 >>> 0;
1182
+ const Shift = 1 << 10 >>> 0;
1183
+
1184
+ const Edit$2 = 2;
1185
+ const File$3 = 5;
1186
+ const Go$2 = 6;
1187
+ const Help$2 = 7;
1188
+ const OpenRecent$1 = 9;
1189
+ const Run$2 = 10;
1190
+ const Selection$2 = 11;
1191
+ const Terminal$2 = 14;
1192
+ const TitleBar = 15;
1193
+ const View$2 = 16;
1194
+ const TitleBarContextMenu = 90;
1195
+
1196
+ const parseKey = rawKey => {
1197
+ const isCtrl = Boolean(rawKey & CtrlCmd);
1198
+ const isShift = Boolean(rawKey & Shift);
1199
+ const keyCode = rawKey & 0x00_00_00_ff;
1200
+ const key = getKeyCodeString(keyCode);
1201
+ return {
1202
+ key,
1203
+ isCtrl,
1204
+ isShift
1205
+ };
1206
+ };
1207
+
1208
+ const RendererWorker = 1;
1209
+
1210
+ const FocusTitleBarMenuBar = 26;
1211
+
1212
+ const rpcs = Object.create(null);
1213
+ const set$2 = (id, rpc) => {
1214
+ rpcs[id] = rpc;
1215
+ };
1216
+ const get$1 = id => {
1217
+ return rpcs[id];
1218
+ };
1219
+
1220
+ const create$2 = rpcId => {
1221
+ return {
1222
+ // @ts-ignore
1223
+ invoke(method, ...params) {
1224
+ const rpc = get$1(rpcId);
1225
+ // @ts-ignore
1226
+ return rpc.invoke(method, ...params);
1227
+ },
1228
+ // @ts-ignore
1229
+ invokeAndTransfer(method, ...params) {
1230
+ const rpc = get$1(rpcId);
1231
+ // @ts-ignore
1232
+ return rpc.invokeAndTransfer(method, ...params);
1233
+ },
1234
+ set(rpc) {
1235
+ set$2(rpcId, rpc);
1236
+ },
1237
+ async dispose() {
1238
+ const rpc = get$1(rpcId);
1239
+ await rpc.dispose();
1240
+ }
1241
+ };
1242
+ };
1243
+
1244
+ const {
1245
+ invoke,
1246
+ set: set$1} = create$2(RendererWorker);
1247
+
1248
+ const toCommandId = key => {
1249
+ const dotIndex = key.indexOf('.');
1250
+ return key.slice(dotIndex + 1);
1251
+ };
1252
+ const create$1 = () => {
1253
+ const states = Object.create(null);
1254
+ const commandMapRef = {};
1255
+ return {
1256
+ get(uid) {
1257
+ return states[uid];
1258
+ },
1259
+ set(uid, oldState, newState) {
1260
+ states[uid] = {
1261
+ oldState,
1262
+ newState
1263
+ };
1264
+ },
1265
+ dispose(uid) {
1266
+ delete states[uid];
1267
+ },
1268
+ getKeys() {
1269
+ return Object.keys(states).map(key => {
1270
+ return Number.parseInt(key);
1271
+ });
1272
+ },
1273
+ clear() {
1274
+ for (const key of Object.keys(states)) {
1275
+ delete states[key];
1276
+ }
1277
+ },
1278
+ wrapCommand(fn) {
1279
+ const wrapped = async (uid, ...args) => {
1280
+ const {
1281
+ newState
1282
+ } = states[uid];
1283
+ const newerState = await fn(newState, ...args);
1284
+ if (newState === newerState) {
1285
+ return;
1286
+ }
1287
+ const latest = states[uid];
1288
+ states[uid] = {
1289
+ oldState: latest.oldState,
1290
+ newState: newerState
1291
+ };
1292
+ };
1293
+ return wrapped;
1294
+ },
1295
+ wrapGetter(fn) {
1296
+ const wrapped = (uid, ...args) => {
1297
+ const {
1298
+ newState
1299
+ } = states[uid];
1300
+ return fn(newState, ...args);
1301
+ };
1302
+ return wrapped;
1303
+ },
1304
+ diff(uid, modules, numbers) {
1305
+ const {
1306
+ oldState,
1307
+ newState
1308
+ } = states[uid];
1309
+ const diffResult = [];
1310
+ for (let i = 0; i < modules.length; i++) {
1311
+ const fn = modules[i];
1312
+ if (!fn(oldState, newState)) {
1313
+ diffResult.push(numbers[i]);
1314
+ }
1315
+ }
1316
+ return diffResult;
1317
+ },
1318
+ getCommandIds() {
1319
+ const keys = Object.keys(commandMapRef);
1320
+ const ids = keys.map(toCommandId);
1321
+ return ids;
1322
+ },
1323
+ registerCommands(commandMap) {
1324
+ Object.assign(commandMapRef, commandMap);
1325
+ }
1326
+ };
1327
+ };
1328
+ const terminate = () => {
1329
+ globalThis.close();
1330
+ };
1331
+
1332
+ const Web = 1;
1333
+ const Electron = 2;
1334
+ const Remote = 3;
1335
+
1336
+ const DEFAULT_UID = 1;
1337
+ const createDefaultState = (uid = DEFAULT_UID) => ({
1338
+ assetDir: '',
1339
+ buttons: [],
1340
+ commandCenterEnabled: false,
1341
+ controlsOverlayEnabled: false,
1342
+ focusedIndex: -1,
1343
+ height: 30,
1344
+ iconWidth: 30,
1345
+ isMenuOpen: false,
1346
+ labelFontFamily: 'system-ui, Ubuntu, Droid Sans, sans-serif',
1347
+ labelFontSize: 13,
1348
+ labelFontWeight: 400,
1349
+ labelLetterSpacing: 0,
1350
+ labelPadding: 8,
1351
+ layoutControlsEnabled: false,
1352
+ menus: [],
1353
+ platform: Electron,
1354
+ title: '',
1355
+ titleBarButtons: [],
1356
+ titleBarButtonsEnabled: true,
1357
+ titleBarButtonsWidth: 90,
1358
+ titleBarEntries: [],
1359
+ titleBarHeight: 30,
1360
+ titleBarIconEnabled: true,
1361
+ titleBarIconWidth: 30,
1362
+ titleBarMenuBarEnabled: true,
1363
+ titleBarStyleCustom: true,
1364
+ titleBarTitleEnabled: true,
1365
+ uid,
1366
+ width: 800,
1367
+ x: 0,
1368
+ y: 0
1369
+ });
1370
+
1371
+ const emptyObject = {};
1372
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1373
+ const i18nString = (key, placeholders = emptyObject) => {
1374
+ if (placeholders === emptyObject) {
1375
+ return key;
1376
+ }
1377
+ const replacer = (match, rest) => {
1378
+ return placeholders[rest];
1379
+ };
1380
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1381
+ };
1382
+
1383
+ const About = 'About';
1384
+ const CheckForUpdates = 'Check For Updates';
1385
+ const ClearRecentlyOpened = 'Clear Recently Opened';
1386
+ const Close = 'Close';
1387
+ const MenuBar = 'Menu Bar';
1388
+ const CommandCenter = 'Command Center';
1389
+ const Edit$1 = 'Edit';
1390
+ const File$2 = 'File';
1391
+ const Go$1 = 'Go';
1392
+ const Help$1 = 'Help';
1393
+ const Maximize = 'Maximize';
1394
+ const Minimize = 'Minimize';
1395
+ const MoreDot = 'More ...';
1396
+ const NewTerminal = 'New Terminal';
1397
+ const OpenProcessExplorer = 'Open Process Explorer';
1398
+ const Run$1 = 'Run';
1399
+ const Selection$1 = 'Selection';
1400
+ const Terminal$1 = 'Terminal';
1401
+ const ToggleDeveloperTools = 'Toggle Developer Tools';
1402
+ const View$1 = 'View';
1544
1403
 
1545
- const CtrlCmd = 1 << 11 >>> 0;
1546
- const Shift = 1 << 10 >>> 0;
1404
+ const file = () => {
1405
+ return i18nString(File$2);
1406
+ };
1407
+ const edit = () => {
1408
+ return i18nString(Edit$1);
1409
+ };
1410
+ const selection = () => {
1411
+ return i18nString(Selection$1);
1412
+ };
1413
+ const view = () => {
1414
+ return i18nString(View$1);
1415
+ };
1416
+ const go = () => {
1417
+ return i18nString(Go$1);
1418
+ };
1419
+ const run = () => {
1420
+ return i18nString(Run$1);
1421
+ };
1422
+ const terminal = () => {
1423
+ return i18nString(Terminal$1);
1424
+ };
1425
+ const help = () => {
1426
+ return i18nString(Help$1);
1427
+ };
1428
+ const minimize$1 = () => {
1429
+ return i18nString(Minimize);
1430
+ };
1431
+ const maximize$1 = () => {
1432
+ return i18nString(Maximize);
1433
+ };
1434
+ const close$1 = () => {
1435
+ return i18nString(Close);
1436
+ };
1437
+ const menuBar = () => {
1438
+ return i18nString(MenuBar);
1439
+ };
1440
+ const commandCenter = () => {
1441
+ return i18nString(CommandCenter);
1442
+ };
1443
+
1444
+ const getTitleBarButtonsElectron = (controlsOverlayEnabled, titleBarStyleCustom) => {
1445
+ if (controlsOverlayEnabled) {
1446
+ return [];
1447
+ }
1448
+ if (titleBarStyleCustom) {
1449
+ // TODO don't render title bar buttons on windows when electron window controls overlay is enabled
1450
+ return [{
1451
+ icon: 'Minimize',
1452
+ id: 'Minimize',
1453
+ label: minimize$1(),
1454
+ onClick: 'handleClickMinimize'
1455
+ }, {
1456
+ icon: 'Maximize',
1457
+ id: 'ToggleMaximize',
1458
+ label: maximize$1(),
1459
+ onClick: 'handleClickToggleMaximize'
1460
+ }, {
1461
+ icon: 'ChromeClose',
1462
+ id: 'Close',
1463
+ label: close$1(),
1464
+ onClick: 'handleClickClose'
1465
+ }];
1466
+ }
1467
+ return [];
1468
+ };
1547
1469
 
1548
- const TitleBar$1 = 15;
1470
+ const getTitleBarButtonsRemote = () => {
1471
+ return [];
1472
+ };
1549
1473
 
1550
- const parseKey = rawKey => {
1551
- const isCtrl = Boolean(rawKey & CtrlCmd);
1552
- const isShift = Boolean(rawKey & Shift);
1553
- const keyCode = rawKey & 0x00_00_00_ff;
1554
- const key = getKeyCodeString(keyCode);
1555
- return {
1556
- key,
1557
- isCtrl,
1558
- isShift
1474
+ const getTitleBarButtonsWeb = () => {
1475
+ return [];
1476
+ };
1477
+
1478
+ const getTitleBarButtons = (platform, controlsOverlayEnabled, titleBarStyleCustom) => {
1479
+ switch (platform) {
1480
+ case Electron:
1481
+ return getTitleBarButtonsElectron(controlsOverlayEnabled, titleBarStyleCustom);
1482
+ case Remote:
1483
+ return getTitleBarButtonsRemote();
1484
+ case Web:
1485
+ return getTitleBarButtonsWeb();
1486
+ default:
1487
+ return [];
1488
+ }
1489
+ };
1490
+
1491
+ const {
1492
+ get,
1493
+ getCommandIds,
1494
+ registerCommands,
1495
+ set,
1496
+ wrapCommand,
1497
+ wrapGetter
1498
+ } = create$1();
1499
+
1500
+ const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled, titleBarStyleCustom, assetDir) => {
1501
+ const titleBarButtons = getTitleBarButtons(platform, controlsOverlayEnabled, titleBarStyleCustom);
1502
+ const state = {
1503
+ ...createDefaultState(),
1504
+ assetDir,
1505
+ commandCenterEnabled: false,
1506
+ controlsOverlayEnabled,
1507
+ focusedIndex: -1,
1508
+ height,
1509
+ iconWidth: 30,
1510
+ isMenuOpen: false,
1511
+ labelFontFamily: 'system-ui, Ubuntu, Droid Sans, sans-serif',
1512
+ labelFontSize: 13,
1513
+ labelFontWeight: 400,
1514
+ labelLetterSpacing: 0,
1515
+ labelPadding: 8,
1516
+ layoutControlsEnabled: false,
1517
+ menus: [],
1518
+ platform,
1519
+ titleBarButtons,
1520
+ titleBarEntries: [],
1521
+ titleBarHeight: height,
1522
+ titleBarStyleCustom,
1523
+ uid: id,
1524
+ width,
1525
+ x,
1526
+ y
1559
1527
  };
1528
+ set(id, state, state);
1560
1529
  };
1561
1530
 
1562
- const DebugWorker = 55;
1563
- const RendererWorker$1 = 1;
1531
+ const RenderEntries = 1;
1532
+ const RenderFocusedIndex = 2;
1533
+ const RenderMenus = 3;
1564
1534
 
1565
- const FocusTitleBarMenuBar = 26;
1535
+ const isEqual$3 = (oldState, newState) => {
1536
+ return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
1537
+ };
1538
+
1539
+ const isEqual$2 = (oldState, newState) => {
1540
+ return oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
1541
+ };
1542
+
1543
+ const isEqual$1 = (oldState, newState) => {
1544
+ return oldState.menus === newState.menus;
1545
+ };
1546
+
1547
+ const modules$1 = [isEqual$3, isEqual$2, isEqual$1];
1548
+ const numbers$1 = [RenderEntries, RenderFocusedIndex, RenderMenus];
1549
+
1550
+ const diff = (oldState, newState) => {
1551
+ const diffResult = [];
1552
+ for (let i = 0; i < modules$1.length; i++) {
1553
+ const fn = modules$1[i];
1554
+ if (!fn(oldState, newState)) {
1555
+ diffResult.push(numbers$1[i]);
1556
+ }
1557
+ }
1558
+ return diffResult;
1559
+ };
1560
+
1561
+ const diff2 = uid => {
1562
+ const {
1563
+ newState,
1564
+ oldState
1565
+ } = get(uid);
1566
+ return diff(oldState, newState);
1567
+ };
1568
+
1569
+ const isEqual = (oldState, newState) => {
1570
+ return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.assetDir === newState.assetDir && oldState.titleBarIconEnabled === newState.titleBarIconEnabled && oldState.title === newState.title && oldState.titleBarTitleEnabled === newState.titleBarTitleEnabled && oldState.platform === newState.platform && oldState.controlsOverlayEnabled === newState.controlsOverlayEnabled && oldState.titleBarStyleCustom === newState.titleBarStyleCustom && oldState.titleBarButtonsEnabled === newState.titleBarButtonsEnabled && oldState.titleBarButtons === newState.titleBarButtons;
1571
+ };
1572
+
1573
+ const modules = [isEqual, isEqual$2, isEqual$1];
1574
+ const numbers = [RenderEntries, RenderFocusedIndex, RenderMenus];
1575
+
1576
+ const diff3 = uid => {
1577
+ const {
1578
+ newState,
1579
+ oldState
1580
+ } = get(uid);
1581
+ const diffResult = [];
1582
+ for (let i = 0; i < modules.length; i++) {
1583
+ const fn = modules[i];
1584
+ if (!fn(oldState, newState)) {
1585
+ diffResult.push(numbers[i]);
1586
+ }
1587
+ }
1588
+ return diffResult;
1589
+ };
1566
1590
 
1567
1591
  const mergeClassNames = (...classNames) => {
1568
1592
  return classNames.filter(Boolean).join(' ');
@@ -1580,38 +1604,38 @@ const text = data => {
1580
1604
  };
1581
1605
  };
1582
1606
 
1583
- const getKeyBindings$1 = () => {
1607
+ const getKeyBindings = () => {
1584
1608
  return [{
1585
- key: DownArrow$1,
1586
1609
  command: 'TitleBar.handleKeyArrowDown',
1610
+ key: DownArrow$1,
1587
1611
  when: FocusTitleBarMenuBar
1588
1612
  }, {
1589
- key: UpArrow$1,
1590
1613
  command: 'TitleBar.handleKeyArrowUp',
1614
+ key: UpArrow$1,
1591
1615
  when: FocusTitleBarMenuBar
1592
1616
  }, {
1593
- key: RightArrow$1,
1594
1617
  command: 'TitleBar.handleKeyArrowRight',
1618
+ key: RightArrow$1,
1595
1619
  when: FocusTitleBarMenuBar
1596
1620
  }, {
1597
- key: LeftArrow$1,
1598
1621
  command: 'TitleBar.handleKeyArrowLeft',
1622
+ key: LeftArrow$1,
1599
1623
  when: FocusTitleBarMenuBar
1600
1624
  }, {
1601
- key: Space$1,
1602
1625
  command: 'TitleBar.handleKeySpace',
1626
+ key: Space$1,
1603
1627
  when: FocusTitleBarMenuBar
1604
1628
  }, {
1605
- key: Home$1,
1606
1629
  command: 'TitleBar.handleKeyHome',
1630
+ key: Home$1,
1607
1631
  when: FocusTitleBarMenuBar
1608
1632
  }, {
1609
- key: End$1,
1610
1633
  command: 'TitleBar.handleKeyEnd',
1634
+ key: End$1,
1611
1635
  when: FocusTitleBarMenuBar
1612
1636
  }, {
1613
- key: Escape$1,
1614
1637
  command: 'TitleBar.handleKeyEscape',
1638
+ key: Escape$1,
1615
1639
  when: FocusTitleBarMenuBar
1616
1640
  }];
1617
1641
  };
@@ -1627,28 +1651,33 @@ const Ignore = 7;
1627
1651
 
1628
1652
  const getMenuEntriesTitleBarContextMenu = async state => {
1629
1653
  const {
1630
- titleBarMenuBarEnabled,
1631
- commandCenterEnabled
1654
+ commandCenterEnabled,
1655
+ titleBarMenuBarEnabled
1632
1656
  } = state;
1633
1657
  // TODO checked state should be depending on whether or not that feature is currently visible or not
1634
1658
  return [{
1635
- id: 'MenuBar',
1636
- label: menuBar(),
1659
+ command: titleBarMenuBarEnabled ? 'TitleBar.hideMenuBar' : 'TitleBar.showMenuBar',
1637
1660
  flags: titleBarMenuBarEnabled ? Checked : Unchecked,
1638
- command: titleBarMenuBarEnabled ? 'TitleBar.hideMenuBar' : 'TitleBar.showMenuBar'
1661
+ id: 'MenuBar',
1662
+ label: menuBar()
1639
1663
  }, {
1640
- id: 'Command center',
1641
- label: commandCenter(),
1664
+ command: commandCenterEnabled ? 'TitleBar.hideCommandCenter' : 'TitleBar.showCommandCenter',
1642
1665
  flags: commandCenterEnabled ? Checked : Unchecked,
1643
- command: commandCenterEnabled ? 'TitleBar.hideCommandCenter' : 'TitleBar.showCommandCenter'
1666
+ id: 'Command center',
1667
+ label: commandCenter()
1644
1668
  }, {
1645
- id: 'layout controls',
1646
- label: 'layout controls',
1669
+ command: '',
1647
1670
  flags: Checked,
1648
- command: ''
1671
+ id: 'layout controls',
1672
+ label: 'layout controls'
1649
1673
  }];
1650
1674
  };
1651
1675
 
1676
+ const MenuIdTitleBarContextMenu = 50;
1677
+ const getMenuIds = () => {
1678
+ return [Edit$2, File$3, Go$2, Help$2, OpenRecent$1, Run$2, Selection$2, Terminal$2, TitleBar, View$2, MenuIdTitleBarContextMenu, TitleBarContextMenu];
1679
+ };
1680
+
1652
1681
  /**
1653
1682
  * @enum {string}
1654
1683
  */
@@ -1664,7 +1693,8 @@ const UiStrings$1 = {
1664
1693
  SelectAll: 'Select All',
1665
1694
  ToggleBlockComment: 'Toggle Block Comment',
1666
1695
  ToggleLineComment: 'Toggle Line Comment',
1667
- Undo: 'Undo'};
1696
+ Undo: 'Undo'
1697
+ };
1668
1698
  const cut = () => {
1669
1699
  return i18nString(UiStrings$1.Cut);
1670
1700
  };
@@ -1702,83 +1732,64 @@ const moveLineDown = () => {
1702
1732
  return i18nString(UiStrings$1.MoveLineDown);
1703
1733
  };
1704
1734
 
1705
- const Edit = 2;
1706
- const File$1 = 5;
1707
- const Go = 6;
1708
- const Help = 7;
1709
- const OpenRecent = 9;
1710
- const Run = 10;
1711
- const Selection = 11;
1712
- const Terminal = 14;
1713
- const TitleBar = 15;
1714
- const View = 16;
1715
-
1716
1735
  const menuEntrySeparator = {
1717
- id: 'separator',
1718
- label: '',
1736
+ command: '',
1719
1737
  flags: Separator,
1720
- command: ''
1738
+ id: 'separator',
1739
+ label: ''
1721
1740
  };
1722
1741
 
1723
- const id$9 = Edit;
1724
- const getMenuEntries$d = () => {
1742
+ const getMenuEntries$c = () => {
1725
1743
  return [{
1726
- id: 'undo',
1727
- label: undo(),
1744
+ command: /* TODO */'-1',
1728
1745
  flags: Disabled,
1729
- command: /* TODO */'-1'
1746
+ id: 'undo',
1747
+ label: undo()
1730
1748
  }, {
1731
- id: 'redo',
1732
- label: redo(),
1749
+ command: /* TODO */'-1',
1733
1750
  flags: Disabled,
1734
- command: /* TODO */'-1'
1751
+ id: 'redo',
1752
+ label: redo()
1735
1753
  }, menuEntrySeparator, {
1736
- id: 'cut',
1737
- label: cut(),
1754
+ command: /* Editor.cut */'Editor.cut',
1738
1755
  flags: None,
1739
- command: /* Editor.cut */'Editor.cut'
1756
+ id: 'cut',
1757
+ label: cut()
1740
1758
  }, {
1741
- id: 'copy',
1742
- label: copy(),
1759
+ command: /* Editor.copy */'Editor.copy',
1743
1760
  flags: None,
1744
- command: /* Editor.copy */'Editor.copy'
1761
+ id: 'copy',
1762
+ label: copy()
1745
1763
  }, {
1746
- id: 'paste',
1747
- label: paste(),
1764
+ command: /* Editor.paste */'Editor.paste',
1748
1765
  flags: None,
1749
- command: /* Editor.paste */'Editor.paste'
1766
+ id: 'paste',
1767
+ label: paste()
1750
1768
  }, menuEntrySeparator, {
1751
- id: 'toggle-line-comment',
1752
- label: toggleLineComment(),
1769
+ command: /* Editor.toggleLineComment */'Editor.toggleLineComment',
1753
1770
  flags: None,
1754
- command: /* Editor.toggleLineComment */'Editor.toggleLineComment'
1771
+ id: 'toggle-line-comment',
1772
+ label: toggleLineComment()
1755
1773
  }, {
1756
- id: 'toggle-block-comment',
1757
- label: toggleBlockComment(),
1774
+ command: /* Editor.toggleBlockComment */'Editor.toggleBlockComment',
1758
1775
  flags: None,
1759
- command: /* Editor.toggleBlockComment */'Editor.toggleBlockComment'
1776
+ id: 'toggle-block-comment',
1777
+ label: toggleBlockComment()
1760
1778
  }];
1761
1779
  };
1762
1780
 
1763
- const MenuEntriesEdit = {
1764
- __proto__: null,
1765
- getMenuEntries: getMenuEntries$d,
1766
- id: id$9
1767
- };
1768
-
1769
1781
  /**
1770
1782
  * @enum {string}
1771
1783
  */
1772
1784
  const UiStrings = {
1785
+ Exit: 'Exit',
1773
1786
  NewFile: 'New File',
1774
1787
  NewWindow: 'New Window',
1775
1788
  OpenFile: 'Open File',
1776
1789
  OpenFolder: 'Open Folder',
1777
1790
  OpenRecent: 'Open Recent',
1778
- Exit: 'Exit',
1779
1791
  Save: 'Save',
1780
- SaveAll: 'Save All'
1781
- };
1792
+ SaveAll: 'Save All'};
1782
1793
  const newFile = () => {
1783
1794
  return i18nString(UiStrings.NewFile);
1784
1795
  };
@@ -1788,547 +1799,139 @@ const newWindow = () => {
1788
1799
  const openFile = () => {
1789
1800
  return i18nString(UiStrings.OpenFile);
1790
1801
  };
1791
- const openFolder = () => {
1792
- return i18nString(UiStrings.OpenFolder);
1793
- };
1794
- const openRecent = () => {
1795
- return i18nString(UiStrings.OpenRecent);
1796
- };
1797
- const save = () => {
1798
- return i18nString(UiStrings.Save);
1799
- };
1800
- const saveAll = () => {
1801
- return i18nString(UiStrings.SaveAll);
1802
- };
1803
- const exit = () => {
1804
- return i18nString(UiStrings.Exit);
1805
- };
1806
-
1807
- const id$8 = File$1;
1808
- const getMenuEntries$c = platform => {
1809
- const entries = [{
1810
- id: 'newFile',
1811
- label: newFile(),
1812
- flags: None,
1813
- command: '-1'
1814
- }, {
1815
- id: 'newWindow',
1816
- label: newWindow(),
1817
- flags: None,
1818
- command: /* Window.openNew */'Window.openNew'
1819
- }, menuEntrySeparator, {
1820
- id: 'openFile',
1821
- label: openFile(),
1822
- flags: None,
1823
- command: 'Dialog.openFile'
1824
- }, {
1825
- id: 'openFolder',
1826
- label: openFolder(),
1827
- flags: RestoreFocus,
1828
- command: 'Dialog.openFolder'
1829
- }, {
1830
- id: OpenRecent,
1831
- label: openRecent(),
1832
- flags: SubMenu,
1833
- command: ''
1834
- }, menuEntrySeparator, {
1835
- id: 'save',
1836
- label: save(),
1837
- flags: None,
1838
- command: 'Main.save'
1839
- }, {
1840
- id: 'saveAll',
1841
- label: saveAll(),
1842
- flags: None,
1843
- command: 'Main.saveAll'
1844
- }];
1845
- if (platform === Electron) {
1846
- entries.push(menuEntrySeparator, {
1847
- id: 'exit',
1848
- label: exit(),
1849
- flags: Ignore,
1850
- command: 'Chrome.exit'
1851
- });
1852
- }
1853
- return entries;
1854
- };
1855
-
1856
- const MenuEntriesFile = {
1857
- __proto__: null,
1858
- getMenuEntries: getMenuEntries$c,
1859
- id: id$8
1860
- };
1861
-
1862
- const id$7 = Go;
1863
- const getMenuEntries$b = () => {
1864
- return [];
1865
- };
1866
-
1867
- const MenuEntriesGo = {
1868
- __proto__: null,
1869
- getMenuEntries: getMenuEntries$b,
1870
- id: id$7
1871
- };
1872
-
1873
- const toggleDeveloperTools = () => {
1874
- return i18nString(ToggleDeveloperTools);
1875
- };
1876
- const openProcessExplorer = () => {
1877
- return i18nString(OpenProcessExplorer);
1878
- };
1879
- const checkForUpdates = () => {
1880
- return i18nString(CheckForUpdates);
1881
- };
1882
- const about = () => {
1883
- return i18nString(About);
1884
- };
1885
-
1886
- const isAutoUpdateSupported = platform => {
1887
- if (platform !== Electron) {
1888
- return false;
1889
- }
1890
- return false;
1891
- };
1892
-
1893
- const id$6 = Help;
1894
- const getMenuEntries$a = async platform => {
1895
- const autoUpdateSupported = isAutoUpdateSupported(platform);
1896
- const entries = [];
1897
- if (platform !== Web) {
1898
- entries.push({
1899
- id: 'toggleDeveloperTools',
1900
- label: toggleDeveloperTools(),
1901
- flags: None,
1902
- command: 'Developer.toggleDeveloperTools'
1903
- }, {
1904
- id: 'openProcessExplorer',
1905
- label: openProcessExplorer(),
1906
- flags: RestoreFocus,
1907
- command: 'Developer.openProcessExplorer'
1908
- });
1909
- }
1910
- if (autoUpdateSupported) {
1911
- entries.push(menuEntrySeparator, {
1912
- id: 'checkForUpdates',
1913
- label: checkForUpdates(),
1914
- flags: RestoreFocus,
1915
- command: 'AutoUpdater.checkForUpdates'
1916
- });
1917
- }
1918
- if (entries.length > 0) {
1919
- entries.push(menuEntrySeparator);
1920
- }
1921
- entries.push({
1922
- id: 'about',
1923
- label: about(),
1924
- flags: None,
1925
- command: 'About.showAbout'
1926
- });
1927
- return entries;
1928
- };
1929
-
1930
- const MenuEntriesHelp = {
1931
- __proto__: null,
1932
- getMenuEntries: getMenuEntries$a,
1933
- id: id$6
1934
- };
1935
-
1936
- const rpcs = Object.create(null);
1937
- const set$2 = (id, rpc) => {
1938
- rpcs[id] = rpc;
1939
- };
1940
- const get = id => {
1941
- return rpcs[id];
1942
- };
1943
-
1944
- const create$1 = rpcId => {
1945
- return {
1946
- // @ts-ignore
1947
- invoke(method, ...params) {
1948
- const rpc = get(rpcId);
1949
- // @ts-ignore
1950
- return rpc.invoke(method, ...params);
1951
- },
1952
- // @ts-ignore
1953
- invokeAndTransfer(method, ...params) {
1954
- const rpc = get(rpcId);
1955
- // @ts-ignore
1956
- return rpc.invokeAndTransfer(method, ...params);
1957
- },
1958
- set(rpc) {
1959
- set$2(rpcId, rpc);
1960
- },
1961
- async dispose() {
1962
- const rpc = get(rpcId);
1963
- await rpc.dispose();
1964
- }
1965
- };
1966
- };
1967
-
1968
- const {
1969
- invoke: invoke$1,
1970
- invokeAndTransfer,
1971
- set: set$1,
1972
- dispose
1973
- } = create$1(RendererWorker$1);
1974
- const searchFileHtml = async uri => {
1975
- return invoke$1('ExtensionHost.searchFileWithHtml', uri);
1976
- };
1977
- const getFilePathElectron = async file => {
1978
- return invoke$1('FileSystemHandle.getFilePathElectron', file);
1979
- };
1980
- const showContextMenu = async (x, y, id, ...args) => {
1981
- return invoke$1('ContextMenu.show', x, y, id, ...args);
1982
- };
1983
- const showContextMenu2 = async (uid, menuId, x, y, args) => {
1984
- // @ts-ignore
1985
- await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1986
- };
1987
- const getElectronVersion = async () => {
1988
- return invoke$1('Process.getElectronVersion');
1989
- };
1990
- const applyBulkReplacement = async bulkEdits => {
1991
- await invoke$1('BulkReplacement.applyBulkReplacement', bulkEdits);
1992
- };
1993
- const setColorTheme = async id => {
1994
- // @ts-ignore
1995
- return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1996
- };
1997
- const getNodeVersion = async () => {
1998
- return invoke$1('Process.getNodeVersion');
1999
- };
2000
- const getChromeVersion = async () => {
2001
- return invoke$1('Process.getChromeVersion');
2002
- };
2003
- const getV8Version = async () => {
2004
- return invoke$1('Process.getV8Version');
2005
- };
2006
- const getFileHandles = async fileIds => {
2007
- const files = await invoke$1('FileSystemHandle.getFileHandles', fileIds);
2008
- return files;
2009
- };
2010
- const setWorkspacePath = async path => {
2011
- await invoke$1('Workspace.setPath', path);
2012
- };
2013
- const registerWebViewInterceptor = async (id, port) => {
2014
- await invokeAndTransfer('WebView.registerInterceptor', id, port);
2015
- };
2016
- const unregisterWebViewInterceptor = async id => {
2017
- await invoke$1('WebView.unregisterInterceptor', id);
2018
- };
2019
- const sendMessagePortToEditorWorker = async (port, rpcId) => {
2020
- const command = 'HandleMessagePort.handleMessagePort';
2021
- // @ts-ignore
2022
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
2023
- };
2024
- const sendMessagePortToErrorWorker = async (port, rpcId) => {
2025
- const command = 'Errors.handleMessagePort';
2026
- // @ts-ignore
2027
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
2028
- };
2029
- const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
2030
- const command = 'Markdown.handleMessagePort';
2031
- // @ts-ignore
2032
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
2033
- };
2034
- const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
2035
- const command = 'IconTheme.handleMessagePort';
2036
- // @ts-ignore
2037
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
2038
- };
2039
- const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
2040
- const command = 'FileSystem.handleMessagePort';
2041
- // @ts-ignore
2042
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
2043
- };
2044
- const readFile = async uri => {
2045
- return invoke$1('FileSystem.readFile', uri);
2046
- };
2047
- const getWebViewSecret = async key => {
2048
- // @ts-ignore
2049
- return invoke$1('WebView.getSecret', key);
2050
- };
2051
- const setWebViewPort = async (uid, port, origin, portType) => {
2052
- return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
2053
- };
2054
- const setFocus$1 = key => {
2055
- return invoke$1('Focus.setFocus', key);
2056
- };
2057
- const getFileIcon = async options => {
2058
- return invoke$1('IconTheme.getFileIcon', options);
2059
- };
2060
- const getColorThemeNames = async () => {
2061
- return invoke$1('ColorTheme.getColorThemeNames');
2062
- };
2063
- const disableExtension = async id => {
2064
- // @ts-ignore
2065
- return invoke$1('ExtensionManagement.disable', id);
2066
- };
2067
- const enableExtension = async id => {
2068
- // @ts-ignore
2069
- return invoke$1('ExtensionManagement.enable', id);
2070
- };
2071
- const handleDebugChange = async params => {
2072
- // @ts-ignore
2073
- return invoke$1('Run And Debug.handleChange', params);
2074
- };
2075
- const getFolderIcon = async options => {
2076
- return invoke$1('IconTheme.getFolderIcon', options);
2077
- };
2078
- const closeWidget = async widgetId => {
2079
- return invoke$1('Viewlet.closeWidget', widgetId);
2080
- };
2081
- const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
2082
- const command = 'HandleMessagePort.handleMessagePort2';
2083
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
2084
- };
2085
- const sendMessagePortToSearchProcess = async port => {
2086
- await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
2087
- };
2088
- const confirm = async (message, options) => {
2089
- // @ts-ignore
2090
- const result = await invoke$1('ConfirmPrompt.prompt', message, options);
2091
- return result;
2092
- };
2093
- const getRecentlyOpened$1 = async () => {
2094
- return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
2095
- };
2096
- const getKeyBindings = async () => {
2097
- return invoke$1('KeyBindingsInitial.getKeyBindings');
2098
- };
2099
- const writeClipBoardText = async text => {
2100
- await invoke$1('ClipBoard.writeText', /* text */text);
2101
- };
2102
- const writeClipBoardImage = async blob => {
2103
- // @ts-ignore
2104
- await invoke$1('ClipBoard.writeImage', /* text */blob);
2105
- };
2106
- const searchFileMemory = async uri => {
2107
- // @ts-ignore
2108
- return invoke$1('ExtensionHost.searchFileWithMemory', uri);
2109
- };
2110
- const searchFileFetch = async uri => {
2111
- return invoke$1('ExtensionHost.searchFileWithFetch', uri);
2112
- };
2113
- const showMessageBox = async options => {
2114
- return invoke$1('ElectronDialog.showMessageBox', options);
2115
- };
2116
- const handleDebugResumed = async params => {
2117
- await invoke$1('Run And Debug.handleResumed', params);
2118
- };
2119
- const openWidget = async name => {
2120
- await invoke$1('Viewlet.openWidget', name);
2121
- };
2122
- const getIcons = async requests => {
2123
- const icons = await invoke$1('IconTheme.getIcons', requests);
2124
- return icons;
2125
- };
2126
- const activateByEvent = event => {
2127
- return invoke$1('ExtensionHostManagement.activateByEvent', event);
2128
- };
2129
- const setAdditionalFocus = focusKey => {
2130
- // @ts-ignore
2131
- return invoke$1('Focus.setAdditionalFocus', focusKey);
2132
- };
2133
- const getActiveEditorId = () => {
2134
- // @ts-ignore
2135
- return invoke$1('GetActiveEditor.getActiveEditorId');
2136
- };
2137
- const getWorkspacePath = () => {
2138
- return invoke$1('Workspace.getPath');
2139
- };
2140
- const sendMessagePortToRendererProcess = async port => {
2141
- const command = 'HandleMessagePort.handleMessagePort';
2142
- // @ts-ignore
2143
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
2144
- };
2145
- const getPreference = async key => {
2146
- return await invoke$1('Preferences.get', key);
2147
- };
2148
- const getAllExtensions = async () => {
2149
- return invoke$1('ExtensionManagement.getAllExtensions');
2150
- };
2151
- const rerenderEditor = async key => {
2152
- // @ts-ignore
2153
- return invoke$1('Editor.rerender', key);
2154
- };
2155
- const handleDebugPaused = async params => {
2156
- await invoke$1('Run And Debug.handlePaused', params);
2157
- };
2158
- const openUri = async (uri, focus, options) => {
2159
- await invoke$1('Main.openUri', uri, focus, options);
2160
- };
2161
- const sendMessagePortToSyntaxHighlightingWorker = async port => {
2162
- await invokeAndTransfer(
2163
- // @ts-ignore
2164
- 'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
2165
- };
2166
- const handleDebugScriptParsed = async script => {
2167
- await invoke$1('Run And Debug.handleScriptParsed', script);
2168
- };
2169
- const getWindowId = async () => {
2170
- return invoke$1('GetWindowId.getWindowId');
2171
- };
2172
- const getBlob = async uri => {
2173
- // @ts-ignore
2174
- return invoke$1('FileSystem.getBlob', uri);
2175
- };
2176
- const getExtensionCommands = async () => {
2177
- return invoke$1('ExtensionHost.getCommands');
2178
- };
2179
- const showErrorDialog = async errorInfo => {
2180
- // @ts-ignore
2181
- await invoke$1('ErrorHandling.showErrorDialog', errorInfo);
2182
- };
2183
- const getFolderSize = async uri => {
2184
- // @ts-ignore
2185
- return await invoke$1('FileSystem.getFolderSize', uri);
2186
- };
2187
- const getExtension = async id => {
2188
- // @ts-ignore
2189
- return invoke$1('ExtensionManagement.getExtension', id);
2190
- };
2191
- const getMarkdownDom = async html => {
2192
- // @ts-ignore
2193
- return invoke$1('Markdown.getVirtualDom', html);
2194
- };
2195
- const renderMarkdown = async (markdown, options) => {
2196
- // @ts-ignore
2197
- return invoke$1('Markdown.renderMarkdown', markdown, options);
2198
- };
2199
- const openNativeFolder = async uri => {
2200
- // @ts-ignore
2201
- await invoke$1('OpenNativeFolder.openNativeFolder', uri);
1802
+ const openFolder = () => {
1803
+ return i18nString(UiStrings.OpenFolder);
2202
1804
  };
2203
- const uninstallExtension = async id => {
2204
- return invoke$1('ExtensionManagement.uninstall', id);
1805
+ const openRecent = () => {
1806
+ return i18nString(UiStrings.OpenRecent);
2205
1807
  };
2206
- const installExtension = async id => {
2207
- // @ts-ignore
2208
- return invoke$1('ExtensionManagement.install', id);
1808
+ const save = () => {
1809
+ return i18nString(UiStrings.Save);
2209
1810
  };
2210
- const openExtensionSearch = async () => {
2211
- // @ts-ignore
2212
- return invoke$1('SideBar.openViewlet', 'Extensions');
1811
+ const saveAll = () => {
1812
+ return i18nString(UiStrings.SaveAll);
2213
1813
  };
2214
- const setExtensionsSearchValue = async searchValue => {
2215
- // @ts-ignore
2216
- return invoke$1('Extensions.handleInput', searchValue, Script);
1814
+ const exit = () => {
1815
+ return i18nString(UiStrings.Exit);
2217
1816
  };
2218
- const openExternal = async uri => {
2219
- // @ts-ignore
2220
- await invoke$1('Open.openExternal', uri);
1817
+
1818
+ const Edit = 2;
1819
+ const File$1 = 5;
1820
+ const Go = 6;
1821
+ const Help = 7;
1822
+ const OpenRecent = 9;
1823
+ const Run = 10;
1824
+ const Selection = 11;
1825
+ const Terminal = 14;
1826
+ const View = 16;
1827
+
1828
+ const getMenuEntries$b = platform => {
1829
+ const entries = [{
1830
+ command: '-1',
1831
+ flags: None,
1832
+ id: 'newFile',
1833
+ label: newFile()
1834
+ }, {
1835
+ command: 'Window.openNew',
1836
+ flags: None,
1837
+ id: 'newWindow',
1838
+ label: newWindow()
1839
+ }, menuEntrySeparator, {
1840
+ command: 'Dialog.openFile',
1841
+ flags: None,
1842
+ id: 'openFile',
1843
+ label: openFile()
1844
+ }, {
1845
+ command: 'Dialog.openFolder',
1846
+ flags: RestoreFocus,
1847
+ id: 'openFolder',
1848
+ label: openFolder()
1849
+ }, {
1850
+ command: '',
1851
+ flags: SubMenu,
1852
+ id: OpenRecent,
1853
+ label: openRecent()
1854
+ }, menuEntrySeparator, {
1855
+ command: 'Main.save',
1856
+ flags: None,
1857
+ id: 'save',
1858
+ label: save()
1859
+ }, {
1860
+ command: 'Main.saveAll',
1861
+ flags: None,
1862
+ id: 'saveAll',
1863
+ label: saveAll()
1864
+ }];
1865
+ if (platform === Electron) {
1866
+ entries.push(menuEntrySeparator, {
1867
+ command: 'Chrome.exit',
1868
+ flags: Ignore,
1869
+ id: 'exit',
1870
+ label: exit()
1871
+ });
1872
+ }
1873
+ return entries;
2221
1874
  };
2222
- const openUrl = async uri => {
2223
- // @ts-ignore
2224
- await invoke$1('Open.openUrl', uri);
1875
+
1876
+ const getMenuEntries$a = () => {
1877
+ return [];
2225
1878
  };
2226
- const getAllPreferences = async () => {
2227
- // @ts-ignore
2228
- return invoke$1('Preferences.getAll');
1879
+
1880
+ const toggleDeveloperTools = () => {
1881
+ return i18nString(ToggleDeveloperTools);
2229
1882
  };
2230
- const showSaveFilePicker = async () => {
2231
- // @ts-ignore
2232
- return invoke$1('FilePicker.showSaveFilePicker');
1883
+ const openProcessExplorer = () => {
1884
+ return i18nString(OpenProcessExplorer);
2233
1885
  };
2234
- const getLogsDir = async () => {
2235
- // @ts-ignore
2236
- return invoke$1('PlatformPaths.getLogsDir');
1886
+ const checkForUpdates = () => {
1887
+ return i18nString(CheckForUpdates);
2237
1888
  };
2238
- const registerMockRpc = commandMap => {
2239
- const mockRpc = createMockRpc({
2240
- commandMap
2241
- });
2242
- set$1(mockRpc);
2243
- return mockRpc;
1889
+ const about = () => {
1890
+ return i18nString(About);
2244
1891
  };
2245
1892
 
2246
- const RendererWorker = {
2247
- __proto__: null,
2248
- activateByEvent,
2249
- applyBulkReplacement,
2250
- closeWidget,
2251
- confirm,
2252
- disableExtension,
2253
- dispose,
2254
- enableExtension,
2255
- getActiveEditorId,
2256
- getAllExtensions,
2257
- getAllPreferences,
2258
- getBlob,
2259
- getChromeVersion,
2260
- getColorThemeNames,
2261
- getElectronVersion,
2262
- getExtension,
2263
- getExtensionCommands,
2264
- getFileHandles,
2265
- getFileIcon,
2266
- getFilePathElectron,
2267
- getFolderIcon,
2268
- getFolderSize,
2269
- getIcons,
2270
- getKeyBindings,
2271
- getLogsDir,
2272
- getMarkdownDom,
2273
- getNodeVersion,
2274
- getPreference,
2275
- getRecentlyOpened: getRecentlyOpened$1,
2276
- getV8Version,
2277
- getWebViewSecret,
2278
- getWindowId,
2279
- getWorkspacePath,
2280
- handleDebugChange,
2281
- handleDebugPaused,
2282
- handleDebugResumed,
2283
- handleDebugScriptParsed,
2284
- installExtension,
2285
- invoke: invoke$1,
2286
- invokeAndTransfer,
2287
- openExtensionSearch,
2288
- openExternal,
2289
- openNativeFolder,
2290
- openUri,
2291
- openUrl,
2292
- openWidget,
2293
- readFile,
2294
- registerMockRpc,
2295
- registerWebViewInterceptor,
2296
- renderMarkdown,
2297
- rerenderEditor,
2298
- searchFileFetch,
2299
- searchFileHtml,
2300
- searchFileMemory,
2301
- sendMessagePortToEditorWorker,
2302
- sendMessagePortToErrorWorker,
2303
- sendMessagePortToExtensionHostWorker,
2304
- sendMessagePortToFileSystemWorker,
2305
- sendMessagePortToIconThemeWorker,
2306
- sendMessagePortToMarkdownWorker,
2307
- sendMessagePortToRendererProcess,
2308
- sendMessagePortToSearchProcess,
2309
- sendMessagePortToSyntaxHighlightingWorker,
2310
- set: set$1,
2311
- setAdditionalFocus,
2312
- setColorTheme,
2313
- setExtensionsSearchValue,
2314
- setFocus: setFocus$1,
2315
- setWebViewPort,
2316
- setWorkspacePath,
2317
- showContextMenu,
2318
- showContextMenu2,
2319
- showErrorDialog,
2320
- showMessageBox,
2321
- showSaveFilePicker,
2322
- uninstallExtension,
2323
- unregisterWebViewInterceptor,
2324
- writeClipBoardImage,
2325
- writeClipBoardText
1893
+ const isAutoUpdateSupported = platform => {
1894
+ if (platform !== Electron) {
1895
+ return false;
1896
+ }
1897
+ return false;
2326
1898
  };
2327
1899
 
2328
- const {
2329
- invoke,
2330
- set
2331
- } = RendererWorker;
1900
+ const getMenuEntries$9 = async platform => {
1901
+ const autoUpdateSupported = isAutoUpdateSupported(platform);
1902
+ const entries = [];
1903
+ if (platform !== Web) {
1904
+ entries.push({
1905
+ command: 'Developer.toggleDeveloperTools',
1906
+ flags: None,
1907
+ id: 'toggleDeveloperTools',
1908
+ label: toggleDeveloperTools()
1909
+ }, {
1910
+ command: 'Developer.openProcessExplorer',
1911
+ flags: RestoreFocus,
1912
+ id: 'openProcessExplorer',
1913
+ label: openProcessExplorer()
1914
+ });
1915
+ }
1916
+ if (autoUpdateSupported) {
1917
+ entries.push(menuEntrySeparator, {
1918
+ command: 'AutoUpdater.checkForUpdates',
1919
+ flags: RestoreFocus,
1920
+ id: 'checkForUpdates',
1921
+ label: checkForUpdates()
1922
+ });
1923
+ }
1924
+ if (entries.length > 0) {
1925
+ entries.push(menuEntrySeparator);
1926
+ }
1927
+ entries.push({
1928
+ command: 'About.showAbout',
1929
+ flags: None,
1930
+ id: 'about',
1931
+ label: about()
1932
+ });
1933
+ return entries;
1934
+ };
2332
1935
 
2333
1936
  const getRecentlyOpened = () => {
2334
1937
  return invoke(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
@@ -2362,14 +1965,13 @@ const toMenuItem = folder => {
2362
1965
  const homeDir = getHomeDir();
2363
1966
  const label = getTitle$1(homeDir, folder);
2364
1967
  return {
2365
- label,
2366
- flags: None,
1968
+ args: [folder],
2367
1969
  command: 'Workspace.setPath',
2368
- args: [folder]
1970
+ flags: None,
1971
+ label
2369
1972
  };
2370
1973
  };
2371
- const id$5 = OpenRecent;
2372
- const getMenuEntries$9 = async () => {
1974
+ const getMenuEntries$8 = async () => {
2373
1975
  const allItems = await getRecentlyOpened();
2374
1976
  const itemsToShow = allItems.slice(0, MAX_MENU_RECENT_ENTRIES);
2375
1977
  const items = [];
@@ -2377,221 +1979,92 @@ const getMenuEntries$9 = async () => {
2377
1979
  items.push(...itemsToShow.map(toMenuItem), menuEntrySeparator);
2378
1980
  }
2379
1981
  items.push({
2380
- id: 'more',
2381
- label: moreDot(),
1982
+ command: 'QuickPick.showRecent',
2382
1983
  flags: None,
2383
- command: 'QuickPick.showRecent'
1984
+ id: 'more',
1985
+ label: moreDot()
2384
1986
  }, menuEntrySeparator, {
2385
- id: 'clearRecentlyOpened',
2386
- label: clearRecentlyOpened(),
1987
+ command: 'RecentlyOpened.clearRecentlyOpened',
2387
1988
  flags: None,
2388
- command: 'RecentlyOpened.clearRecentlyOpened'
1989
+ id: 'clearRecentlyOpened',
1990
+ label: clearRecentlyOpened()
2389
1991
  });
2390
1992
  return items;
2391
1993
  };
2392
1994
 
2393
- const MenuEntriesOpenRecent = {
2394
- __proto__: null,
2395
- getMenuEntries: getMenuEntries$9,
2396
- id: id$5
2397
- };
2398
-
2399
- const id$4 = Run;
2400
- const getMenuEntries$8 = () => {
1995
+ const getMenuEntries$7 = () => {
2401
1996
  return [];
2402
1997
  };
2403
1998
 
2404
- const MenuEntriesRun = {
2405
- __proto__: null,
2406
- getMenuEntries: getMenuEntries$8,
2407
- id: id$4
2408
- };
2409
-
2410
- const id$3 = Selection;
2411
- const getMenuEntries$7 = () => {
1999
+ const getMenuEntries$6 = () => {
2412
2000
  return [{
2413
- id: 'selectAll',
2414
- label: selectAll(),
2001
+ command: 'Editor.selectAll',
2415
2002
  flags: None,
2416
- command: 'Editor.selectAll'
2003
+ id: 'selectAll',
2004
+ label: selectAll()
2417
2005
  }, {
2418
- id: 'copyLineUp',
2419
- label: copyLineUp(),
2006
+ command: 'Editor.copyLineUp',
2420
2007
  flags: None,
2421
- command: 'Editor.copyLineUp'
2008
+ id: 'copyLineUp',
2009
+ label: copyLineUp()
2422
2010
  }, {
2423
- id: 'copyLineDown',
2424
- label: copyLineDown(),
2011
+ command: 'Editor.copyLineDown',
2425
2012
  flags: None,
2426
- command: 'Editor.copyLineDown'
2013
+ id: 'copyLineDown',
2014
+ label: copyLineDown()
2427
2015
  }, {
2428
- id: 'moveLineUp',
2429
- label: moveLineUp(),
2016
+ command: 'Editor.moveLineUp',
2430
2017
  flags: Disabled,
2431
- command: 'Editor.moveLineUp'
2018
+ id: 'moveLineUp',
2019
+ label: moveLineUp()
2432
2020
  }, {
2433
- id: 'moveLineDown',
2434
- label: moveLineDown(),
2021
+ command: 'Editor.moveLineDown',
2435
2022
  flags: Disabled,
2436
- command: 'Editor.moveLineDown'
2437
- }];
2438
- };
2439
-
2440
- const MenuEntriesSelection = {
2441
- __proto__: null,
2442
- getMenuEntries: getMenuEntries$7,
2443
- id: id$3
2444
- };
2445
-
2446
- const id$2 = Terminal;
2447
- const getMenuEntries$6 = () => {
2448
- return [{
2449
- id: 'newTerminal',
2450
- label: i18nString(NewTerminal),
2451
- flags: None,
2452
- command: 'Layout.togglePanel',
2453
- args: ['Terminal']
2023
+ id: 'moveLineDown',
2024
+ label: moveLineDown()
2454
2025
  }];
2455
2026
  };
2456
2027
 
2457
- const MenuEntriesTerminal = {
2458
- __proto__: null,
2459
- getMenuEntries: getMenuEntries$6,
2460
- id: id$2
2461
- };
2462
-
2463
2028
  const getMenuEntries$5 = () => {
2464
2029
  return [{
2465
- id: File$1,
2466
- label: file(),
2467
- flags: SubMenu,
2468
- command: ''
2469
- }, {
2470
- id: Edit,
2471
- label: edit(),
2472
- flags: SubMenu,
2473
- command: ''
2474
- }, {
2475
- id: Selection,
2476
- label: selection(),
2477
- flags: SubMenu,
2478
- command: ''
2479
- }, {
2480
- id: View,
2481
- label: view(),
2482
- flags: SubMenu,
2483
- command: ''
2484
- }, {
2485
- id: Go,
2486
- label: go(),
2487
- flags: SubMenu,
2488
- command: ''
2489
- }, {
2490
- id: Run,
2491
- label: run(),
2492
- keyboardShortCut: 'Alt+r',
2493
- flags: SubMenu,
2494
- command: ''
2495
- }, {
2496
- id: Terminal,
2497
- label: terminal(),
2498
- keyboardShortCut: 'Alt+t',
2499
- flags: SubMenu,
2500
- command: ''
2501
- }, {
2502
- id: Help,
2503
- label: help(),
2504
- keyboardShortCut: 'Alt+h',
2505
- flags: SubMenu,
2506
- command: ''
2507
- }];
2508
- };
2509
-
2510
- const getMenuEntries$4 = () => {
2511
- return [{
2512
- id: File$1,
2513
- label: file(),
2514
- flags: None,
2515
- command: ''
2516
- }, {
2517
- id: Edit,
2518
- label: edit(),
2519
- flags: None,
2520
- command: ''
2521
- }, {
2522
- id: Selection,
2523
- label: selection(),
2524
- flags: None,
2525
- command: ''
2526
- }, {
2527
- id: View,
2528
- label: view(),
2529
- flags: None,
2530
- command: ''
2531
- }, {
2532
- id: Go,
2533
- label: go(),
2534
- flags: None,
2535
- command: ''
2536
- }, {
2537
- id: Help,
2538
- label: help(),
2030
+ args: ['Terminal'],
2031
+ command: 'Layout.togglePanel',
2539
2032
  flags: None,
2540
- command: ''
2033
+ id: 'newTerminal',
2034
+ label: i18nString(NewTerminal)
2541
2035
  }];
2542
2036
  };
2543
2037
 
2544
- const getFn = platform => {
2545
- switch (platform) {
2546
- case Web:
2547
- return getMenuEntries$4;
2548
- default:
2549
- return getMenuEntries$5;
2550
- }
2551
- };
2552
- const id$1 = TitleBar;
2553
- const getMenuEntries$3 = async platform => {
2554
- const fn = getFn(platform);
2555
- return fn();
2556
- };
2557
-
2558
- const MenuEntriesTitleBar = {
2559
- __proto__: null,
2560
- getMenuEntries: getMenuEntries$3,
2561
- id: id$1
2562
- };
2563
-
2564
- const id = View;
2565
- const getMenuEntries$2 = () => {
2038
+ const getMenuEntries$4 = () => {
2566
2039
  return [];
2567
2040
  };
2568
2041
 
2569
- const MenuEntriesView = {
2570
- __proto__: null,
2571
- getMenuEntries: getMenuEntries$2,
2572
- id
2573
- };
2574
-
2575
- const menus$1 = [MenuEntriesEdit, MenuEntriesFile, MenuEntriesGo, MenuEntriesHelp, MenuEntriesRun, MenuEntriesSelection, MenuEntriesTerminal, MenuEntriesTitleBar, MenuEntriesView, MenuEntriesOpenRecent];
2576
-
2577
- const MenuIdTitleBarContextMenu = 50;
2578
- const getMenuIds = () => {
2579
- return [...menus$1.map(menu => menu.id), MenuIdTitleBarContextMenu];
2580
- };
2581
- const getMenuEntries$1 = async (id, platform) => {
2582
- const menu = menus$1.find(item => item.id === id);
2583
- if (!menu) {
2584
- return [];
2585
- }
2586
- return menu.getMenuEntries(platform);
2587
- };
2588
-
2589
2042
  const getMenuEntries2 = async (state, props) => {
2590
- if (props.menuId === MenuIdTitleBarContextMenu) {
2591
- return getMenuEntriesTitleBarContextMenu(state);
2043
+ switch (props.menuId) {
2044
+ case Edit$2:
2045
+ return getMenuEntries$c();
2046
+ case File$3:
2047
+ return getMenuEntries$b(props.platform);
2048
+ case Go$2:
2049
+ return getMenuEntries$a();
2050
+ case Help$2:
2051
+ return getMenuEntries$9(props.platform);
2052
+ case OpenRecent$1:
2053
+ return getMenuEntries$8();
2054
+ case Run$2:
2055
+ return getMenuEntries$7();
2056
+ case Selection$2:
2057
+ return getMenuEntries$6();
2058
+ case Terminal$2:
2059
+ return getMenuEntries$5();
2060
+ case TitleBarContextMenu:
2061
+ case MenuIdTitleBarContextMenu:
2062
+ return getMenuEntriesTitleBarContextMenu(state);
2063
+ case View$2:
2064
+ return getMenuEntries$4();
2065
+ default:
2066
+ return [];
2592
2067
  }
2593
- // TODO
2594
- return [];
2595
2068
  };
2596
2069
 
2597
2070
  const maximize = async () => {
@@ -2636,7 +2109,7 @@ const handleClick$1 = async (state, className) => {
2636
2109
 
2637
2110
  const show2 = async (uid, menuId, x, y, args) => {
2638
2111
  // @ts-ignore
2639
- await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
2112
+ await invoke('ContextMenu.show2', uid, menuId, x, y, args);
2640
2113
  };
2641
2114
 
2642
2115
  const handleContextMenu = async (state, button, eventX, eventY) => {
@@ -2675,6 +2148,7 @@ const getTotalWidth = entries => {
2675
2148
  };
2676
2149
 
2677
2150
  // TODO lazyload menuEntries and use Command.execute (maybe)
2151
+
2678
2152
  const CONTEXT_MENU_ITEM_HEIGHT = 26;
2679
2153
  const CONTEXT_MENU_SEPARATOR_HEIGHT = 11;
2680
2154
  const CONTEXT_MENU_PADDING = 8;
@@ -2738,8 +2212,8 @@ const getIndexToFocusPrevious = menu => {
2738
2212
  };
2739
2213
  const canBeFocused = item => {
2740
2214
  switch (item.flags) {
2741
- case Separator:
2742
2215
  case Disabled:
2216
+ case Separator:
2743
2217
  return false;
2744
2218
  default:
2745
2219
  return true;
@@ -2756,36 +2230,13 @@ const getIndexToFocusNext = menu => {
2756
2230
 
2757
2231
  // TODO more tests
2758
2232
 
2759
- const menus = [MenuEntriesEdit, MenuEntriesFile, MenuEntriesGo, MenuEntriesHelp, MenuEntriesRun, MenuEntriesSelection, MenuEntriesTerminal, MenuEntriesTitleBar, MenuEntriesView, MenuEntriesOpenRecent];
2760
- const getMenus = () => {
2761
- return menus;
2762
- };
2763
- const getModule = id => {
2764
- for (const module of menus) {
2765
- if (module.id === id) {
2766
- return module;
2767
- }
2768
- }
2769
- return undefined;
2770
- };
2771
- const getMenuEntries = async (id, ...args) => {
2772
- try {
2773
- const module = getModule(id);
2774
- // @ts-ignore
2775
- const inject = module.inject || [];
2776
- // @ts-ignore
2777
- return module.getMenuEntries(...args);
2778
- } catch (error) {
2779
- throw new VError(error, `Failed to load menu entries for id ${id}`);
2780
- }
2781
- };
2782
-
2783
2233
  const openMenuAtIndex = async (state, index, shouldBeFocused) => {
2784
2234
  const {
2235
+ iconWidth,
2236
+ platform,
2785
2237
  titleBarEntries,
2786
2238
  titleBarHeight,
2787
- x,
2788
- iconWidth
2239
+ x
2789
2240
  } = state;
2790
2241
  // TODO race conditions
2791
2242
  // TODO send renderer process
@@ -2795,7 +2246,10 @@ const openMenuAtIndex = async (state, index, shouldBeFocused) => {
2795
2246
  const {
2796
2247
  id
2797
2248
  } = titleBarEntry;
2798
- const items = await getMenuEntries(id);
2249
+ const items = await getMenuEntries2(state, {
2250
+ menuId: id,
2251
+ platform
2252
+ });
2799
2253
  const relevantEntries = titleBarEntries.slice(0, index);
2800
2254
  const totalWidths = getTotalWidth(relevantEntries);
2801
2255
  const offset = totalWidths;
@@ -2807,20 +2261,20 @@ const openMenuAtIndex = async (state, index, shouldBeFocused) => {
2807
2261
  const height = getMenuHeight(items);
2808
2262
  const menuFocusedIndex = shouldBeFocused ? getIndexToFocusNextStartingAt(items, 0) : -1;
2809
2263
  const menu = {
2264
+ focusedIndex: menuFocusedIndex,
2265
+ height,
2810
2266
  id,
2811
2267
  items,
2812
- focusedIndex: menuFocusedIndex,
2813
2268
  level: 0,
2814
- x: menuX,
2815
- y: menuY,
2816
2269
  width,
2817
- height
2270
+ x: menuX,
2271
+ y: menuY
2818
2272
  };
2819
2273
  const menus = [menu];
2820
2274
  return {
2821
2275
  ...state,
2822
- isMenuOpen: true,
2823
2276
  focusedIndex: index,
2277
+ isMenuOpen: true,
2824
2278
  menus
2825
2279
  };
2826
2280
  };
@@ -2829,8 +2283,8 @@ const focusIndex = async (state, index) => {
2829
2283
  object(state);
2830
2284
  number(index);
2831
2285
  const {
2832
- isMenuOpen,
2833
- focusedIndex
2286
+ focusedIndex,
2287
+ isMenuOpen
2834
2288
  } = state;
2835
2289
  if (index === focusedIndex) {
2836
2290
  return state;
@@ -2869,9 +2323,9 @@ const handleMouseOut = ifElse(handleMouseOutMenuOpen, handleMouseOutMenuClosed);
2869
2323
 
2870
2324
  const handlePointerOut = (state, clientX, clientY) => {
2871
2325
  const {
2872
- x,
2873
2326
  iconWidth,
2874
- titleBarEntries
2327
+ titleBarEntries,
2328
+ x
2875
2329
  } = state;
2876
2330
  const menuX = getMenuOffset(x, clientX, iconWidth);
2877
2331
  const index = getTitleBarIndexFromPosition(titleBarEntries, menuX);
@@ -2906,8 +2360,10 @@ const handlePointerOver = (state, name) => {
2906
2360
  };
2907
2361
 
2908
2362
  const hideCommandCenter = async state => {
2909
- // TODO
2910
- return state;
2363
+ return {
2364
+ ...state,
2365
+ commandCenterEnabled: false
2366
+ };
2911
2367
  };
2912
2368
 
2913
2369
  const hideMenuBar = async state => {
@@ -2981,31 +2437,160 @@ const getTitle = workspaceUri => {
2981
2437
  return baseName;
2982
2438
  };
2983
2439
 
2440
+ const getMenuEntries$3 = () => {
2441
+ return [{
2442
+ command: '',
2443
+ flags: SubMenu,
2444
+ id: File$1,
2445
+ label: file()
2446
+ }, {
2447
+ command: '',
2448
+ flags: SubMenu,
2449
+ id: Edit,
2450
+ label: edit()
2451
+ }, {
2452
+ command: '',
2453
+ flags: SubMenu,
2454
+ id: Selection,
2455
+ label: selection()
2456
+ }, {
2457
+ command: '',
2458
+ flags: SubMenu,
2459
+ id: View,
2460
+ label: view()
2461
+ }, {
2462
+ command: '',
2463
+ flags: SubMenu,
2464
+ id: Go,
2465
+ label: go()
2466
+ }, {
2467
+ command: '',
2468
+ flags: SubMenu,
2469
+ id: Run,
2470
+ keyboardShortCut: 'Alt+r',
2471
+ label: run()
2472
+ }, {
2473
+ command: '',
2474
+ flags: SubMenu,
2475
+ id: Terminal,
2476
+ keyboardShortCut: 'Alt+t',
2477
+ label: terminal()
2478
+ }, {
2479
+ command: '',
2480
+ flags: SubMenu,
2481
+ id: Help,
2482
+ keyboardShortCut: 'Alt+h',
2483
+ label: help()
2484
+ }];
2485
+ };
2486
+
2487
+ const getMenuEntries$2 = () => {
2488
+ return [{
2489
+ command: '',
2490
+ flags: None,
2491
+ id: File$1,
2492
+ label: file()
2493
+ }, {
2494
+ command: '',
2495
+ flags: None,
2496
+ id: Edit,
2497
+ label: edit()
2498
+ }, {
2499
+ command: '',
2500
+ flags: None,
2501
+ id: Selection,
2502
+ label: selection()
2503
+ }, {
2504
+ command: '',
2505
+ flags: None,
2506
+ id: View,
2507
+ label: view()
2508
+ }, {
2509
+ command: '',
2510
+ flags: None,
2511
+ id: Go,
2512
+ label: go()
2513
+ }, {
2514
+ command: '',
2515
+ flags: None,
2516
+ id: Help,
2517
+ label: help()
2518
+ }];
2519
+ };
2520
+
2521
+ const getFn$1 = platform => {
2522
+ switch (platform) {
2523
+ case Web:
2524
+ return getMenuEntries$2;
2525
+ default:
2526
+ return getMenuEntries$3;
2527
+ }
2528
+ };
2529
+ const getMenuEntries$1 = async platform => {
2530
+ const fn = getFn$1(platform);
2531
+ return fn();
2532
+ };
2533
+
2534
+ const getFn = id => {
2535
+ switch (id) {
2536
+ case Edit$2:
2537
+ return getMenuEntries$c;
2538
+ case File$3:
2539
+ return getMenuEntries$b;
2540
+ case Go$2:
2541
+ return getMenuEntries$a;
2542
+ case Help$2:
2543
+ return getMenuEntries$9;
2544
+ case OpenRecent$1:
2545
+ return getMenuEntries$8;
2546
+ case Run$2:
2547
+ return getMenuEntries$7;
2548
+ case Selection$2:
2549
+ return getMenuEntries$6;
2550
+ case Terminal$2:
2551
+ return getMenuEntries$5;
2552
+ case TitleBar:
2553
+ return getMenuEntries$1;
2554
+ case View$2:
2555
+ return getMenuEntries$4;
2556
+ default:
2557
+ return undefined;
2558
+ }
2559
+ };
2560
+ const getMenuEntries = async (id, ...args) => {
2561
+ try {
2562
+ const fn = getFn(id);
2563
+ // @ts-ignore
2564
+ return fn(...args);
2565
+ } catch (error) {
2566
+ throw new VError(error, `Failed to load menu entries for id ${id}`);
2567
+ }
2568
+ };
2569
+
2984
2570
  const loadContent2 = async state => {
2985
2571
  const {
2986
- platform,
2987
2572
  controlsOverlayEnabled,
2988
- titleBarStyleCustom,
2989
2573
  labelFontFamily,
2990
2574
  labelFontSize,
2991
2575
  labelFontWeight,
2992
2576
  labelLetterSpacing,
2993
- labelPadding
2577
+ labelPadding,
2578
+ platform,
2579
+ titleBarStyleCustom
2994
2580
  } = state;
2995
- const titleBarEntries = await getMenuEntries(TitleBar$1);
2581
+ const titleBarEntries = await getMenuEntries(TitleBar);
2996
2582
  const withWidths = addWidths(titleBarEntries, labelPadding, labelFontWeight, labelFontSize, labelFontFamily, labelLetterSpacing);
2997
2583
  const buttons = getTitleBarButtons(platform, controlsOverlayEnabled, titleBarStyleCustom);
2998
- // @ts-ignore
2999
2584
  const workspaceUri = await invoke('Workspace.getUri');
3000
2585
  const title = getTitle(workspaceUri);
3001
2586
  const iconWidth = 30;
3002
2587
  return {
3003
2588
  ...state,
3004
- titleBarEntries: withWidths,
3005
- titleBarButtons: buttons,
3006
2589
  buttons,
2590
+ iconWidth,
3007
2591
  title,
3008
- iconWidth
2592
+ titleBarButtons: buttons,
2593
+ titleBarEntries: withWidths
3009
2594
  };
3010
2595
  };
3011
2596
 
@@ -3037,16 +2622,16 @@ const TitleBarTopLevelEntryLabel = 'TitleBarTopLevelEntryLabel';
3037
2622
  const Viewlet = 'Viewlet';
3038
2623
 
3039
2624
  const checkboxChecked = {
3040
- type: Div,
2625
+ ariaChecked: true,
2626
+ childCount: 2,
3041
2627
  className: mergeClassNames(MenuItem, MenuItemCheckMark),
3042
2628
  role: MenuItemCheckBox,
3043
- ariaChecked: true,
3044
2629
  tabIndex: -1,
3045
- childCount: 2
2630
+ type: Div
3046
2631
  };
3047
2632
  const checkMark = {
3048
- type: Div,
3049
- className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck)
2633
+ className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck),
2634
+ type: Div
3050
2635
  };
3051
2636
  const getMenuItemCheckedDom = menuItem => {
3052
2637
  const {
@@ -3071,9 +2656,9 @@ const getKeyDom = key => {
3071
2656
  const parsedKey = parseKey(key);
3072
2657
  const keyBindingsString = getKeyBindingString(parsedKey.key, false, parsedKey.isCtrl, parsedKey.isShift);
3073
2658
  return [{
3074
- type: Span,
2659
+ childCount: 1,
3075
2660
  className: MenuItemKeyBinding,
3076
- childCount: 1
2661
+ type: Span
3077
2662
  }, text(keyBindingsString)];
3078
2663
  };
3079
2664
 
@@ -3086,29 +2671,29 @@ const getMenuItemClassName = isFocused => {
3086
2671
  };
3087
2672
  const getMenuItemDefaultDom = menuItem => {
3088
2673
  const {
3089
- label,
3090
2674
  isFocused,
3091
- key
2675
+ key,
2676
+ label
3092
2677
  } = menuItem;
3093
2678
  const className = getMenuItemClassName(isFocused);
3094
2679
  const keyDom = key ? getKeyDom(key) : [];
3095
2680
  const childCount = key ? 2 : 1;
3096
2681
  return [{
3097
- type: Div,
2682
+ childCount,
3098
2683
  className,
3099
2684
  role: MenuItem$1,
3100
2685
  tabIndex: -1,
3101
- childCount
2686
+ type: Div
3102
2687
  }, text(label), ...keyDom];
3103
2688
  };
3104
2689
 
3105
2690
  const disabled = {
3106
- type: Div,
2691
+ childCount: 1,
3107
2692
  className: MenuItem,
2693
+ disabled: true,
3108
2694
  role: MenuItem$1,
3109
2695
  tabIndex: -1,
3110
- disabled: true,
3111
- childCount: 1
2696
+ type: Div
3112
2697
  };
3113
2698
  const getMenuItemDisabledDom = menuItem => {
3114
2699
  const {
@@ -3122,53 +2707,53 @@ const getMenuItemsNoopDom = () => {
3122
2707
  };
3123
2708
 
3124
2709
  const separator = {
3125
- type: Div,
2710
+ childCount: 1,
3126
2711
  className: MenuItemSeparator,
3127
2712
  role: Separator$1,
3128
- childCount: 1
2713
+ type: Div
3129
2714
  };
3130
2715
  const separatorLine = {
3131
- type: Div,
2716
+ childCount: 0,
3132
2717
  className: MenuItemSeparatorLine,
3133
- childCount: 0
2718
+ type: Div
3134
2719
  };
3135
2720
  const getMenuItemSeparatorDom = menuItem => {
3136
2721
  return [separator, separatorLine];
3137
2722
  };
3138
2723
 
3139
2724
  const arrowRight = {
3140
- type: Div,
2725
+ childCount: 0,
3141
2726
  className: MenuItemSubMenuArrowRight,
3142
- childCount: 0
2727
+ type: Div
3143
2728
  };
3144
2729
  const getMenuItemSubMenuDom = menuItem => {
3145
2730
  const {
3146
- label,
3147
- isFocused,
3148
2731
  isExpanded,
2732
+ isFocused,
2733
+ label,
3149
2734
  level
3150
2735
  } = menuItem;
3151
2736
  const baseClassName = mergeClassNames(MenuItem, MenuItemSubMenu);
3152
2737
  const className = isFocused ? mergeClassNames(baseClassName, MenuItemFocused) : baseClassName;
3153
2738
  return [{
3154
- type: Div,
2739
+ ariaExpanded: isExpanded,
2740
+ ariaHasPopup: true,
2741
+ ariaOwns: isExpanded ? `Menu-${level + 1}` : undefined,
2742
+ childCount: 2,
3155
2743
  className,
3156
2744
  role: MenuItem$1,
3157
2745
  tabIndex: -1,
3158
- ariaHasPopup: true,
3159
- ariaExpanded: isExpanded,
3160
- ariaOwns: isExpanded ? `Menu-${level + 1}` : undefined,
3161
- childCount: 2
2746
+ type: Div
3162
2747
  }, text(label), arrowRight];
3163
2748
  };
3164
2749
 
3165
2750
  const checkboxUnchecked = {
3166
- type: Div,
2751
+ ariaChecked: false,
2752
+ childCount: 1,
3167
2753
  className: MenuItem,
3168
2754
  role: MenuItemCheckBox,
3169
- ariaChecked: false,
3170
2755
  tabIndex: -1,
3171
- childCount: 1
2756
+ type: Div
3172
2757
  };
3173
2758
  const getMenuItemUncheckedDom = menuItem => {
3174
2759
  const {
@@ -3179,20 +2764,20 @@ const getMenuItemUncheckedDom = menuItem => {
3179
2764
 
3180
2765
  const getMenuItemRenderer = flags => {
3181
2766
  switch (flags) {
2767
+ case Checked:
2768
+ return getMenuItemCheckedDom;
2769
+ case Disabled:
2770
+ return getMenuItemDisabledDom;
2771
+ case Ignore:
3182
2772
  case None:
3183
2773
  case RestoreFocus:
3184
- case Ignore:
3185
2774
  return getMenuItemDefaultDom;
3186
2775
  case Separator:
3187
2776
  return getMenuItemSeparatorDom;
3188
- case Checked:
3189
- return getMenuItemCheckedDom;
3190
- case Unchecked:
3191
- return getMenuItemUncheckedDom;
3192
- case Disabled:
3193
- return getMenuItemDisabledDom;
3194
2777
  case SubMenu:
3195
2778
  return getMenuItemSubMenuDom;
2779
+ case Unchecked:
2780
+ return getMenuItemUncheckedDom;
3196
2781
  default:
3197
2782
  return getMenuItemsNoopDom;
3198
2783
  }
@@ -3208,11 +2793,11 @@ const getMenuItemVirtualDom = menuItem => {
3208
2793
 
3209
2794
  const getMenuVirtualDom = menuItems => {
3210
2795
  const dom = [{
3211
- type: Div,
2796
+ childCount: menuItems.length,
3212
2797
  className: Menu,
3213
2798
  role: Menu$1,
3214
2799
  tabIndex: -1,
3215
- childCount: menuItems.length
2800
+ type: Div
3216
2801
  }, ...menuItems.flatMap(getMenuItemVirtualDom)];
3217
2802
  return dom;
3218
2803
  };
@@ -3226,12 +2811,12 @@ const getVisible = (items, focusedIndex, expanded, level) => {
3226
2811
  label
3227
2812
  } = item;
3228
2813
  visibleItems.push({
3229
- label,
3230
2814
  flags,
3231
- isFocused: i === focusedIndex,
3232
2815
  isExpanded: i === focusedIndex && expanded,
3233
- level,
3234
- key: item.key
2816
+ isFocused: i === focusedIndex,
2817
+ key: item.key,
2818
+ label,
2819
+ level
3235
2820
  });
3236
2821
  }
3237
2822
  return visibleItems;
@@ -3264,7 +2849,10 @@ const renderMenus = (oldState, newState) => {
3264
2849
  } else if (difference < 0) {
3265
2850
  changes.push(['closeMenus', newLength]);
3266
2851
  }
3267
- return ['Viewlet.send', newState.uid, /* method */SetMenus, /* changes */changes, newState.uid];
2852
+ const {
2853
+ uid
2854
+ } = newState;
2855
+ return ['Viewlet.send', uid, /* method */SetMenus, /* changes */changes, uid];
3268
2856
  };
3269
2857
 
3270
2858
  const getIcon = assetDir => {
@@ -3273,50 +2861,50 @@ const getIcon = assetDir => {
3273
2861
 
3274
2862
  const getIconVirtualDom = (icon, type = Div) => {
3275
2863
  return {
3276
- type,
2864
+ childCount: 0,
3277
2865
  className: `MaskIcon MaskIcon${icon}`,
3278
2866
  role: None$1,
3279
- childCount: 0
2867
+ type
3280
2868
  };
3281
2869
  };
3282
2870
 
3283
2871
  const createTitleBarButton = button => {
3284
2872
  const {
3285
- id,
3286
2873
  icon,
2874
+ id,
3287
2875
  label,
3288
2876
  onClick
3289
2877
  } = button;
3290
2878
  const dom = [{
3291
- type: Button$1,
3292
- className: `TitleBarButton TitleBarButton${id}`,
3293
2879
  ariaLabel: label,
3294
2880
  childCount: 1,
3295
- onClick
2881
+ className: `TitleBarButton TitleBarButton${id}`,
2882
+ onClick,
2883
+ type: Button$1
3296
2884
  }, getIconVirtualDom(icon, I)];
3297
2885
  return dom;
3298
2886
  };
3299
2887
 
3300
2888
  const getTitleBarButtonsVirtualDom = buttons => {
3301
2889
  return [{
3302
- type: Div,
2890
+ childCount: buttons.length,
3303
2891
  className: mergeClassNames(Viewlet, TitleBarButtons),
3304
- childCount: buttons.length
2892
+ type: Div
3305
2893
  }, ...buttons.flatMap(createTitleBarButton)];
3306
2894
  };
3307
2895
 
3308
2896
  const parentNode$1 = {
3309
- type: Div,
2897
+ childCount: 1,
3310
2898
  className: mergeClassNames(Viewlet, TitleBarIcon),
3311
- childCount: 1
2899
+ type: Div
3312
2900
  };
3313
2901
  const getTitleBarIconVirtualDom = iconSrc => {
3314
2902
  return [parentNode$1, {
3315
- type: Img,
2903
+ alt: '',
2904
+ childCount: 0,
3316
2905
  className: TitleBarIconIcon,
3317
2906
  src: iconSrc,
3318
- alt: '',
3319
- childCount: 0
2907
+ type: Img
3320
2908
  }];
3321
2909
  };
3322
2910
 
@@ -3335,21 +2923,22 @@ const HandleContextMenu = 11;
3335
2923
  const getItemVirtualDom = item => {
3336
2924
  // @ts-ignore
3337
2925
  const {
3338
- keyboardShortCut,
3339
- label,
2926
+ isFocused,
3340
2927
  isOpen,
3341
- isFocused
2928
+ keyboardShortCut,
2929
+ label
3342
2930
  } = item;
3343
2931
  // TODO avoid mutation
3344
2932
  const dom = [{
3345
- type: Button$1,
3346
- className: TitleBarTopLevelEntry,
3347
- ariaHasPopup: true,
3348
2933
  ariaExpanded: isOpen,
3349
- role: MenuItem$1,
3350
- childCount: 1,
2934
+ ariaHasPopup: true,
3351
2935
  ariaKeyShortcuts: keyboardShortCut,
3352
- name: label // TODO have separate name attribute
2936
+ childCount: 1,
2937
+ className: TitleBarTopLevelEntry,
2938
+ name: label,
2939
+ // TODO have separate name attribute
2940
+ role: MenuItem$1,
2941
+ type: Button$1
3353
2942
  }];
3354
2943
  if (isOpen) {
3355
2944
  // @ts-ignore
@@ -3360,9 +2949,9 @@ const getItemVirtualDom = item => {
3360
2949
  // @ts-ignore
3361
2950
  dom[0].id = 'TitleBarEntryActive';
3362
2951
  dom.push({
3363
- type: Div,
2952
+ childCount: 1,
3364
2953
  className: TitleBarTopLevelEntryLabel,
3365
- childCount: 1
2954
+ type: Div
3366
2955
  });
3367
2956
  }
3368
2957
  dom.push(text(label));
@@ -3376,24 +2965,24 @@ const getTitleBarMenuBarItemsVirtualDom = visibleItems => {
3376
2965
  const activeId = 'TitleBarEntryActive';
3377
2966
  const getTitleBarMenuBarVirtualDom = (visibleItems, focusedIndex) => {
3378
2967
  return [{
3379
- type: Div,
3380
- className: mergeClassNames(Viewlet, TitleBarMenuBar),
3381
- role: MenuBar,
3382
- tabIndex: 0,
2968
+ ariaActivedescendant: focusedIndex === -1 ? '' : activeId,
3383
2969
  childCount: visibleItems.length,
3384
- onMouseDown: HandleClick,
3385
- onFocusOut: HandleFocusOut,
2970
+ className: mergeClassNames(Viewlet, TitleBarMenuBar),
3386
2971
  onFocusIn: HandleFocusIn,
3387
- onPointerOver: HandlePointerOver,
2972
+ onFocusOut: HandleFocusOut,
2973
+ onMouseDown: HandleClick,
3388
2974
  onPointerOut: HandlePointerOut,
3389
- ariaActivedescendant: focusedIndex === -1 ? '' : activeId
2975
+ onPointerOver: HandlePointerOver,
2976
+ role: MenuBar$1,
2977
+ tabIndex: 0,
2978
+ type: Div
3390
2979
  }, ...getTitleBarMenuBarItemsVirtualDom(visibleItems)];
3391
2980
  };
3392
2981
 
3393
2982
  const parentNode = {
3394
- type: Div,
2983
+ childCount: 1,
3395
2984
  className: 'TitleBarTitle',
3396
- childCount: 1
2985
+ type: Div
3397
2986
  };
3398
2987
  const getTitleVirtualDom = title => {
3399
2988
  return [parentNode, text(title)];
@@ -3416,8 +3005,8 @@ const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) =>
3416
3005
  const isFocused = i === focusedIndex;
3417
3006
  visible.push({
3418
3007
  ...entry,
3419
- isOpen,
3420
- isFocused
3008
+ isFocused,
3009
+ isOpen
3421
3010
  });
3422
3011
  }
3423
3012
  const hasOverflow = visible.length < entries.length;
@@ -3441,21 +3030,21 @@ const getVisibleTitleBarEntries = (entries, width, focusedIndex, isMenuOpen) =>
3441
3030
 
3442
3031
  const getTitleBarVirtualDom = state => {
3443
3032
  const {
3444
- titleBarEntries,
3445
- width,
3033
+ assetDir,
3446
3034
  focusedIndex,
3447
3035
  isMenuOpen,
3448
- assetDir,
3449
3036
  title,
3450
- titleBarButtons
3037
+ titleBarButtons,
3038
+ titleBarEntries,
3039
+ width
3451
3040
  } = state;
3452
3041
  const dom = [{
3453
- type: Div,
3042
+ ariaLabel: 'Title Bar',
3043
+ childCount: 4,
3454
3044
  className: 'Viewlet TitleBar',
3455
3045
  id: 'TitleBar',
3456
3046
  role: ContentInfo,
3457
- ariaLabel: 'Title Bar',
3458
- childCount: 4
3047
+ type: Div
3459
3048
  }];
3460
3049
 
3461
3050
  // Add icon if enabled
@@ -3506,10 +3095,10 @@ const getRenderer3 = diffType => {
3506
3095
 
3507
3096
  const render3 = async (uid, diffResult) => {
3508
3097
  const {
3509
- oldState,
3510
- newState
3511
- } = get$1(uid);
3512
- set$3(uid, newState, newState);
3098
+ newState,
3099
+ oldState
3100
+ } = get(uid);
3101
+ set(uid, newState, newState);
3513
3102
  const commands = [];
3514
3103
  for (const item of diffResult) {
3515
3104
  const fn = getRenderer3(item);
@@ -3573,10 +3162,10 @@ const resize = async (state, dimensions) => {
3573
3162
  return {
3574
3163
  ...state,
3575
3164
  ...dimensions,
3576
- x: menuBarX,
3577
- y: menuBarY,
3165
+ height: menuBarHeight,
3578
3166
  width: menuBarWidth,
3579
- height: menuBarHeight
3167
+ x: menuBarX,
3168
+ y: menuBarY
3580
3169
  };
3581
3170
  };
3582
3171
 
@@ -3589,9 +3178,18 @@ const saveState = state => {
3589
3178
  };
3590
3179
  };
3591
3180
 
3181
+ const setPlatform = (state, platform) => {
3182
+ return {
3183
+ ...state,
3184
+ platform
3185
+ };
3186
+ };
3187
+
3592
3188
  const showCommandCenter = async state => {
3593
- // TODO
3594
- return state;
3189
+ return {
3190
+ ...state,
3191
+ commandCenterEnabled: true
3192
+ };
3595
3193
  };
3596
3194
 
3597
3195
  const showMenuBar = async state => {
@@ -3604,24 +3202,24 @@ const showMenuBar = async state => {
3604
3202
  const create = (id, uri, x, y, width, height) => {
3605
3203
  const state = {
3606
3204
  ...createDefaultState(),
3607
- uid: id,
3608
- titleBarEntries: [],
3609
3205
  focusedIndex: -1,
3206
+ height,
3207
+ iconWidth: 30,
3610
3208
  isMenuOpen: false,
3611
- menus: [],
3612
- labelFontWeight: 400,
3613
- labelFontSize: 13,
3614
3209
  labelFontFamily: 'system-ui, Ubuntu, Droid Sans, sans-serif',
3615
- labelPadding: 8,
3210
+ labelFontSize: 13,
3211
+ labelFontWeight: 400,
3616
3212
  labelLetterSpacing: 0,
3213
+ labelPadding: 8,
3214
+ menus: [],
3215
+ titleBarEntries: [],
3617
3216
  titleBarHeight: height,
3618
- x,
3619
- y,
3217
+ uid: id,
3620
3218
  width,
3621
- height,
3622
- iconWidth: 30
3219
+ x,
3220
+ y
3623
3221
  };
3624
- set$3(id, state, state);
3222
+ set(id, state, state);
3625
3223
  return state;
3626
3224
  };
3627
3225
 
@@ -3635,9 +3233,9 @@ const closeMenu = (state, keepFocus) => {
3635
3233
  const newFocusedIndex = keepFocus ? focusedIndex : -1;
3636
3234
  return {
3637
3235
  ...state,
3638
- menus: [],
3236
+ focusedIndex: newFocusedIndex,
3639
3237
  isMenuOpen: false,
3640
- focusedIndex: newFocusedIndex
3238
+ menus: []
3641
3239
  };
3642
3240
  };
3643
3241
 
@@ -3673,8 +3271,8 @@ const focusLast = state => {
3673
3271
 
3674
3272
  const focusNext = state => {
3675
3273
  const {
3676
- titleBarEntries,
3677
- focusedIndex
3274
+ focusedIndex,
3275
+ titleBarEntries
3678
3276
  } = state;
3679
3277
  const indexToFocus = next(titleBarEntries, focusedIndex);
3680
3278
  return focusIndex(state, indexToFocus);
@@ -3682,8 +3280,8 @@ const focusNext = state => {
3682
3280
 
3683
3281
  const focusPrevious = state => {
3684
3282
  const {
3685
- titleBarEntries,
3686
- focusedIndex
3283
+ focusedIndex,
3284
+ titleBarEntries
3687
3285
  } = state;
3688
3286
  const indexToFocus = previous(titleBarEntries, focusedIndex);
3689
3287
  return focusIndex(state, indexToFocus);
@@ -3693,8 +3291,8 @@ const LeftClick = 0;
3693
3291
 
3694
3292
  const toggleIndex = async (state, index) => {
3695
3293
  const {
3696
- isMenuOpen,
3697
- focusedIndex
3294
+ focusedIndex,
3295
+ isMenuOpen
3698
3296
  } = state;
3699
3297
  if (isMenuOpen && focusedIndex === index) {
3700
3298
  return closeMenu(state, /* keepFocus */true);
@@ -3714,9 +3312,9 @@ const handleClick = async (state, button, index) => {
3714
3312
 
3715
3313
  const handleClickAt = async (state, button, eventX, eventY) => {
3716
3314
  const {
3315
+ iconWidth,
3717
3316
  titleBarEntries,
3718
- x,
3719
- iconWidth
3317
+ x
3720
3318
  } = state;
3721
3319
  const menuOffset = getMenuOffset(x, eventX, iconWidth);
3722
3320
  const index = getTitleBarIndexFromPosition(titleBarEntries, menuOffset);
@@ -3812,8 +3410,8 @@ const handleKeyArrowRightMenuOpen = async state => {
3812
3410
  // if menu can open sub menu to the right -> do that
3813
3411
  const menu = menus.at(-1);
3814
3412
  const {
3815
- items,
3816
3413
  focusedIndex,
3414
+ items,
3817
3415
  x,
3818
3416
  y
3819
3417
  } = menu;
@@ -3824,11 +3422,11 @@ const handleKeyArrowRightMenuOpen = async state => {
3824
3422
  if (item.flags === SubMenu) {
3825
3423
  const subMenuEntries = await getMenuEntries(item.id);
3826
3424
  const subMenu = {
3827
- level: menus.length,
3828
- items: subMenuEntries,
3829
3425
  focusedIndex: 0,
3830
- y: y + focusedIndex * 25,
3831
- x: x + MENU_WIDTH
3426
+ items: subMenuEntries,
3427
+ level: menus.length,
3428
+ x: x + MENU_WIDTH,
3429
+ y: y + focusedIndex * 25
3832
3430
  };
3833
3431
  const newParentMenu = {
3834
3432
  ...menu,
@@ -3954,9 +3552,9 @@ const selectIndexNone = async (state, item) => {
3954
3552
  await executeMenuItemCommand(item);
3955
3553
  return {
3956
3554
  ...state,
3957
- menus: [],
3555
+ focusedIndex: -1,
3958
3556
  isMenuOpen: false,
3959
- focusedIndex: -1
3557
+ menus: []
3960
3558
  };
3961
3559
  };
3962
3560
 
@@ -3964,8 +3562,8 @@ const selectIndexRestoreFocus = async (state, item) => {
3964
3562
  await executeMenuItemCommand(item);
3965
3563
  return {
3966
3564
  ...state,
3967
- menus: [],
3968
- isMenuOpen: false
3565
+ isMenuOpen: false,
3566
+ menus: []
3969
3567
  };
3970
3568
  };
3971
3569
 
@@ -3975,16 +3573,16 @@ const selectIndexSubMenu = async (state, menu, index) => {
3975
3573
  } = state;
3976
3574
  const {
3977
3575
  items,
3576
+ level,
3978
3577
  x,
3979
- y,
3980
- level
3578
+ y
3981
3579
  } = menu;
3982
3580
  const item = items[index];
3983
3581
  const subMenuEntries = await getMenuEntries(item.id);
3984
3582
  const subMenu = {
3985
- level: menus.length,
3986
- items: subMenuEntries,
3987
3583
  focusedIndex: -1,
3584
+ items: subMenuEntries,
3585
+ level: menus.length,
3988
3586
  x: x + MENU_WIDTH,
3989
3587
  y: y + index * 25
3990
3588
  };
@@ -4009,14 +3607,14 @@ const handleMenuClick = async (state, level, index) => {
4009
3607
  return state;
4010
3608
  }
4011
3609
  switch (item.flags) {
3610
+ case Ignore:
3611
+ return selectIndexIgnore(state, item);
4012
3612
  case None:
4013
3613
  return selectIndexNone(state, item);
4014
- case SubMenu:
4015
- return selectIndexSubMenu(state, menu, index);
4016
3614
  case RestoreFocus:
4017
3615
  return selectIndexRestoreFocus(state, item);
4018
- case Ignore:
4019
- return selectIndexIgnore(state, item);
3616
+ case SubMenu:
3617
+ return selectIndexSubMenu(state, menu, index);
4020
3618
  default:
4021
3619
  return state;
4022
3620
  }
@@ -4031,10 +3629,10 @@ const handleMenuMouseOver = async (state, level, index) => {
4031
3629
  } = state;
4032
3630
  const menu = menus[level];
4033
3631
  const {
4034
- items,
4035
3632
  focusedIndex,
4036
- y,
4037
- x
3633
+ items,
3634
+ x,
3635
+ y
4038
3636
  } = menu;
4039
3637
  const item = items[index];
4040
3638
  if (focusedIndex === index) {
@@ -4071,11 +3669,11 @@ const handleMenuMouseOver = async (state, level, index) => {
4071
3669
  const item = items[index];
4072
3670
  const subMenuEntries = await getMenuEntries(item.id);
4073
3671
  const subMenu = {
4074
- level: menus.length,
4075
- items: subMenuEntries,
4076
3672
  focusedIndex: -1,
4077
- y: y + index * 25,
4078
- x: x + MENU_WIDTH
3673
+ items: subMenuEntries,
3674
+ level: menus.length,
3675
+ x: x + MENU_WIDTH,
3676
+ y: y + index * 25
4079
3677
  };
4080
3678
  const newParentMenu = {
4081
3679
  ...menu,
@@ -4122,11 +3720,9 @@ const commandMap = {
4122
3720
  'TitleBar.focusPrevious': wrapCommand(focusPrevious),
4123
3721
  'TitleBar.getCommandIds': getCommandIds,
4124
3722
  'TitleBar.getCommands': getCommandIds,
4125
- 'TitleBar.getKeyBindings': getKeyBindings$1,
4126
- 'TitleBar.getMenuEntries': getMenuEntries$1,
3723
+ 'TitleBar.getKeyBindings': getKeyBindings,
4127
3724
  'TitleBar.getMenuEntries2': getMenuEntries2,
4128
3725
  'TitleBar.getMenuIds': getMenuIds,
4129
- 'TitleBar.getMenus': getMenus,
4130
3726
  'TitleBar.handleButtonsClick': handleClick$1,
4131
3727
  'TitleBar.handleClick': wrapCommand(handleClick),
4132
3728
  'TitleBar.handleClickAt': wrapCommand(handleClickAt),
@@ -4158,6 +3754,7 @@ const commandMap = {
4158
3754
  'TitleBar.renderEventListeners': renderEventListeners,
4159
3755
  'TitleBar.resize': wrapCommand(resize),
4160
3756
  'TitleBar.saveState': wrapGetter(saveState),
3757
+ 'TitleBar.setPlatform': wrapCommand(setPlatform),
4161
3758
  'TitleBar.showCommandCenter': wrapCommand(showCommandCenter),
4162
3759
  'TitleBar.showMenuBar': wrapCommand(showMenuBar),
4163
3760
  'TitleBar.terminate': terminate,
@@ -4165,23 +3762,12 @@ const commandMap = {
4165
3762
  'TitleBar.toggleMenu': wrapCommand(toggleMenu)
4166
3763
  };
4167
3764
 
4168
- // deprecated, can be removed in the future.
4169
- // currently enabled for backwards compatability
4170
- for (const [key, value] of Object.entries(commandMap)) {
4171
- const [prefix, name] = key.split('.');
4172
- if (prefix === 'TitleBar') {
4173
- const alternate = `TitleBarMenuBar.${name}`;
4174
- // @ts-ignore
4175
- commandMap[alternate] = value;
4176
- }
4177
- }
4178
-
4179
3765
  const listen = async () => {
4180
3766
  registerCommands(commandMap);
4181
3767
  const rpc = await WebWorkerRpcClient.create({
4182
3768
  commandMap: commandMap
4183
3769
  });
4184
- set(rpc);
3770
+ set$1(rpc);
4185
3771
  };
4186
3772
 
4187
3773
  const main = async () => {