@lvce-editor/menu-worker 3.1.0 → 4.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.
Files changed (2) hide show
  1. package/dist/menuWorkerMain.js +546 -874
  2. package/package.json +1 -1
@@ -225,8 +225,8 @@ const getModuleNotFoundError = stderr => {
225
225
  const messageIndex = lines.findIndex(isModuleNotFoundMessage);
226
226
  const message = lines[messageIndex];
227
227
  return {
228
- message,
229
- code: ERR_MODULE_NOT_FOUND
228
+ code: ERR_MODULE_NOT_FOUND,
229
+ message
230
230
  };
231
231
  };
232
232
  const isModuleNotFoundError = stderr => {
@@ -249,14 +249,14 @@ const isUnhelpfulNativeModuleError = stderr => {
249
249
  const getNativeModuleErrorMessage = stderr => {
250
250
  const message = getMessageCodeBlock(stderr);
251
251
  return {
252
- message: `Incompatible native node module: ${message}`,
253
- code: E_INCOMPATIBLE_NATIVE_MODULE
252
+ code: E_INCOMPATIBLE_NATIVE_MODULE,
253
+ message: `Incompatible native node module: ${message}`
254
254
  };
255
255
  };
256
256
  const getModuleSyntaxError = () => {
257
257
  return {
258
- message: `ES Modules are not supported in electron`,
259
- code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
258
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
259
+ message: `ES Modules are not supported in electron`
260
260
  };
261
261
  };
262
262
  const getHelpfulChildProcessError = (stdout, stderr) => {
@@ -275,8 +275,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
275
275
  rest
276
276
  } = getDetails(lines);
277
277
  return {
278
- message: actualMessage,
279
278
  code: '',
279
+ message: actualMessage,
280
280
  stack: rest
281
281
  };
282
282
  };
@@ -286,8 +286,8 @@ class IpcError extends VError {
286
286
  if (stdout || stderr) {
287
287
  // @ts-ignore
288
288
  const {
289
- message,
290
289
  code,
290
+ message,
291
291
  stack
292
292
  } = getHelpfulChildProcessError(stdout, stderr);
293
293
  const cause = new Error(message);
@@ -348,8 +348,8 @@ const wrap$f = global => {
348
348
  };
349
349
  const waitForFirstMessage = async port => {
350
350
  const {
351
- resolve,
352
- promise
351
+ promise,
352
+ resolve
353
353
  } = Promise.withResolvers();
354
354
  port.addEventListener('message', resolve, {
355
355
  once: true
@@ -369,8 +369,8 @@ const listen$6 = async () => {
369
369
  const type = firstMessage.params[0];
370
370
  if (type === 'message-port') {
371
371
  parentIpc.send({
372
- jsonrpc: '2.0',
373
372
  id: firstMessage.id,
373
+ jsonrpc: '2.0',
374
374
  result: null
375
375
  });
376
376
  parentIpc.dispose();
@@ -427,8 +427,8 @@ const removeListener = (emitter, type, callback) => {
427
427
  };
428
428
  const getFirstEvent = (eventEmitter, eventMap) => {
429
429
  const {
430
- resolve,
431
- promise
430
+ promise,
431
+ resolve
432
432
  } = Promise.withResolvers();
433
433
  const listenerMap = Object.create(null);
434
434
  const cleanup = value => {
@@ -440,8 +440,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
440
440
  for (const [event, type] of Object.entries(eventMap)) {
441
441
  const listener = event => {
442
442
  cleanup({
443
- type,
444
- event
443
+ event,
444
+ type
445
445
  });
446
446
  };
447
447
  addListener(eventEmitter, event, listener);
@@ -451,8 +451,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
451
451
  };
452
452
  const Message$1 = 3;
453
453
  const create$5$1 = async ({
454
- messagePort,
455
- isMessagePortOpen
454
+ isMessagePortOpen,
455
+ messagePort
456
456
  }) => {
457
457
  if (!isMessagePort(messagePort)) {
458
458
  throw new IpcError('port must be of type MessagePort');
@@ -465,8 +465,8 @@ const create$5$1 = async ({
465
465
  });
466
466
  messagePort.start();
467
467
  const {
468
- type,
469
- event
468
+ event,
469
+ type
470
470
  } = await eventPromise;
471
471
  if (type !== Message$1) {
472
472
  throw new IpcError('Failed to wait for ipc message');
@@ -506,56 +506,35 @@ const IpcParentWithMessagePort$1 = {
506
506
  wrap: wrap$5
507
507
  };
508
508
 
509
- const Two = '2.0';
510
- const create$4 = (method, params) => {
511
- return {
512
- jsonrpc: Two,
513
- method,
514
- params
515
- };
509
+ class CommandNotFoundError extends Error {
510
+ constructor(command) {
511
+ super(`Command not found ${command}`);
512
+ this.name = 'CommandNotFoundError';
513
+ }
514
+ }
515
+ const commands = Object.create(null);
516
+ const register = commandMap => {
517
+ Object.assign(commands, commandMap);
516
518
  };
517
- const callbacks = Object.create(null);
518
- const set$5 = (id, fn) => {
519
- callbacks[id] = fn;
519
+ const getCommand = key => {
520
+ return commands[key];
521
+ };
522
+ const execute = (command, ...args) => {
523
+ const fn = getCommand(command);
524
+ if (!fn) {
525
+ throw new CommandNotFoundError(command);
526
+ }
527
+ return fn(...args);
520
528
  };
529
+
530
+ const Two$1 = '2.0';
531
+ const callbacks = Object.create(null);
521
532
  const get$3 = id => {
522
533
  return callbacks[id];
523
534
  };
524
- const remove = id => {
535
+ const remove$1 = id => {
525
536
  delete callbacks[id];
526
537
  };
527
- let id$a = 0;
528
- const create$3$1 = () => {
529
- return ++id$a;
530
- };
531
- const registerPromise = () => {
532
- const id = create$3$1();
533
- const {
534
- resolve,
535
- promise
536
- } = Promise.withResolvers();
537
- set$5(id, resolve);
538
- return {
539
- id,
540
- promise
541
- };
542
- };
543
- const create$2$1 = (method, params) => {
544
- const {
545
- id,
546
- promise
547
- } = registerPromise();
548
- const message = {
549
- jsonrpc: Two,
550
- method,
551
- params,
552
- id
553
- };
554
- return {
555
- message,
556
- promise
557
- };
558
- };
559
538
  class JsonRpcError extends Error {
560
539
  constructor(message) {
561
540
  super(message);
@@ -572,12 +551,12 @@ const getErrorConstructor = (message, type) => {
572
551
  switch (type) {
573
552
  case DomException:
574
553
  return DOMException;
575
- case TypeError$1:
576
- return TypeError;
577
- case SyntaxError$1:
578
- return SyntaxError;
579
554
  case ReferenceError$1:
580
555
  return ReferenceError;
556
+ case SyntaxError$1:
557
+ return SyntaxError;
558
+ case TypeError$1:
559
+ return TypeError;
581
560
  default:
582
561
  return Error;
583
562
  }
@@ -706,7 +685,7 @@ const resolve = (id, response) => {
706
685
  return;
707
686
  }
708
687
  fn(response);
709
- remove(id);
688
+ remove$1(id);
710
689
  };
711
690
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
712
691
  const getErrorType = prettyError => {
@@ -733,27 +712,27 @@ const getErrorProperty = (error, prettyError) => {
733
712
  if (error && error.code === E_COMMAND_NOT_FOUND) {
734
713
  return {
735
714
  code: MethodNotFound,
736
- message: error.message,
737
- data: error.stack
715
+ data: error.stack,
716
+ message: error.message
738
717
  };
739
718
  }
740
719
  return {
741
720
  code: Custom,
742
- message: prettyError.message,
743
721
  data: {
744
- stack: getStack(prettyError),
745
- codeFrame: prettyError.codeFrame,
746
- type: getErrorType(prettyError),
747
722
  code: prettyError.code,
748
- name: prettyError.name
749
- }
723
+ codeFrame: prettyError.codeFrame,
724
+ name: prettyError.name,
725
+ stack: getStack(prettyError),
726
+ type: getErrorType(prettyError)
727
+ },
728
+ message: prettyError.message
750
729
  };
751
730
  };
752
731
  const create$1$1 = (id, error) => {
753
732
  return {
754
- jsonrpc: Two,
733
+ error,
755
734
  id,
756
- error
735
+ jsonrpc: Two$1
757
736
  };
758
737
  };
759
738
  const getErrorResponse = (id, error, preparePrettyError, logError) => {
@@ -762,27 +741,27 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
762
741
  const errorProperty = getErrorProperty(error, prettyError);
763
742
  return create$1$1(id, errorProperty);
764
743
  };
765
- const create$6 = (message, result) => {
744
+ const create$8 = (message, result) => {
766
745
  return {
767
- jsonrpc: Two,
768
746
  id: message.id,
747
+ jsonrpc: Two$1,
769
748
  result: result ?? null
770
749
  };
771
750
  };
772
751
  const getSuccessResponse = (message, result) => {
773
752
  const resultProperty = result ?? null;
774
- return create$6(message, resultProperty);
753
+ return create$8(message, resultProperty);
775
754
  };
776
755
  const getErrorResponseSimple = (id, error) => {
777
756
  return {
778
- jsonrpc: Two,
779
- id,
780
757
  error: {
781
758
  code: Custom,
759
+ data: error,
782
760
  // @ts-ignore
783
- message: error.message,
784
- data: error
785
- }
761
+ message: error.message
762
+ },
763
+ id,
764
+ jsonrpc: Two$1
786
765
  };
787
766
  };
788
767
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
@@ -812,35 +791,35 @@ const normalizeParams = args => {
812
791
  if (args.length === 1) {
813
792
  const options = args[0];
814
793
  return {
794
+ execute: options.execute,
815
795
  ipc: options.ipc,
796
+ logError: options.logError || defaultLogError,
816
797
  message: options.message,
817
- execute: options.execute,
818
- resolve: options.resolve || defaultResolve,
819
798
  preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
820
- logError: options.logError || defaultLogError,
821
- requiresSocket: options.requiresSocket || defaultRequiresSocket
799
+ requiresSocket: options.requiresSocket || defaultRequiresSocket,
800
+ resolve: options.resolve || defaultResolve
822
801
  };
823
802
  }
824
803
  return {
804
+ execute: args[2],
825
805
  ipc: args[0],
806
+ logError: args[5],
826
807
  message: args[1],
827
- execute: args[2],
828
- resolve: args[3],
829
808
  preparePrettyError: args[4],
830
- logError: args[5],
831
- requiresSocket: args[6]
809
+ requiresSocket: args[6],
810
+ resolve: args[3]
832
811
  };
833
812
  };
834
813
  const handleJsonRpcMessage = async (...args) => {
835
814
  const options = normalizeParams(args);
836
815
  const {
837
- message,
838
- ipc,
839
816
  execute,
840
- resolve,
841
- preparePrettyError,
817
+ ipc,
842
818
  logError,
843
- requiresSocket
819
+ message,
820
+ preparePrettyError,
821
+ requiresSocket,
822
+ resolve
844
823
  } = options;
845
824
  if ('id' in message) {
846
825
  if ('method' in message) {
@@ -862,11 +841,51 @@ const handleJsonRpcMessage = async (...args) => {
862
841
  }
863
842
  throw new JsonRpcError('unexpected message');
864
843
  };
865
- const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
844
+
845
+ const Two = '2.0';
846
+
847
+ const create$7 = (method, params) => {
848
+ return {
849
+ jsonrpc: Two,
850
+ method,
851
+ params
852
+ };
853
+ };
854
+
855
+ const create$6 = (id, method, params) => {
856
+ const message = {
857
+ id,
858
+ jsonrpc: Two,
859
+ method,
860
+ params
861
+ };
862
+ return message;
863
+ };
864
+
865
+ let id$a = 0;
866
+ const create$5 = () => {
867
+ return ++id$a;
868
+ };
869
+
870
+ const registerPromise = map => {
871
+ const id = create$5();
866
872
  const {
867
- message,
873
+ promise,
874
+ resolve
875
+ } = Promise.withResolvers();
876
+ map[id] = resolve;
877
+ return {
878
+ id,
868
879
  promise
869
- } = create$2$1(method, params);
880
+ };
881
+ };
882
+
883
+ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
884
+ const {
885
+ id,
886
+ promise
887
+ } = registerPromise(callbacks);
888
+ const message = create$6(id, method, params);
870
889
  if (useSendAndTransfer && ipc.sendAndTransfer) {
871
890
  ipc.sendAndTransfer(message);
872
891
  } else {
@@ -875,60 +894,40 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
875
894
  const responseMessage = await promise;
876
895
  return unwrapJsonRpcResult(responseMessage);
877
896
  };
878
- const send$1 = (transport, method, ...params) => {
879
- const message = create$4(method, params);
880
- transport.send(message);
881
- };
882
- const invoke$4 = (ipc, method, ...params) => {
883
- return invokeHelper(ipc, method, params, false);
884
- };
885
- const invokeAndTransfer$1 = (ipc, method, ...params) => {
886
- return invokeHelper(ipc, method, params, true);
887
- };
888
-
889
- class CommandNotFoundError extends Error {
890
- constructor(command) {
891
- super(`Command not found ${command}`);
892
- this.name = 'CommandNotFoundError';
893
- }
894
- }
895
- const commands = Object.create(null);
896
- const register = commandMap => {
897
- Object.assign(commands, commandMap);
898
- };
899
- const getCommand = key => {
900
- return commands[key];
901
- };
902
- const execute = (command, ...args) => {
903
- const fn = getCommand(command);
904
- if (!fn) {
905
- throw new CommandNotFoundError(command);
906
- }
907
- return fn(...args);
908
- };
909
-
910
897
  const createRpc = ipc => {
898
+ const callbacks = Object.create(null);
899
+ ipc._resolve = (id, response) => {
900
+ const fn = callbacks[id];
901
+ if (!fn) {
902
+ console.warn(`callback ${id} may already be disposed`);
903
+ return;
904
+ }
905
+ fn(response);
906
+ delete callbacks[id];
907
+ };
911
908
  const rpc = {
909
+ async dispose() {
910
+ await ipc?.dispose();
911
+ },
912
+ invoke(method, ...params) {
913
+ return invokeHelper(callbacks, ipc, method, params, false);
914
+ },
915
+ invokeAndTransfer(method, ...params) {
916
+ return invokeHelper(callbacks, ipc, method, params, true);
917
+ },
912
918
  // @ts-ignore
913
919
  ipc,
914
920
  /**
915
921
  * @deprecated
916
922
  */
917
923
  send(method, ...params) {
918
- send$1(ipc, method, ...params);
919
- },
920
- invoke(method, ...params) {
921
- return invoke$4(ipc, method, ...params);
922
- },
923
- invokeAndTransfer(method, ...params) {
924
- return invokeAndTransfer$1(ipc, method, ...params);
925
- },
926
- async dispose() {
927
- await ipc?.dispose();
924
+ const message = create$7(method, params);
925
+ ipc.send(message);
928
926
  }
929
927
  };
930
928
  return rpc;
931
929
  };
930
+
932
931
  const requiresSocket = () => {
933
932
  return false;
934
933
  };
@@ -941,8 +940,9 @@ const logError = () => {
941
940
  const handleMessage = event => {
942
941
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
943
942
  const actualExecute = event?.target?.execute || execute;
944
- return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
943
+ return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
945
944
  };
945
+
946
946
  const handleIpc = ipc => {
947
947
  if ('addEventListener' in ipc) {
948
948
  ipc.addEventListener('message', handleMessage);
@@ -951,6 +951,7 @@ const handleIpc = ipc => {
951
951
  ipc.on('message', handleMessage);
952
952
  }
953
953
  };
954
+
954
955
  const listen$1 = async (module, options) => {
955
956
  const rawIpc = await module.listen(options);
956
957
  if (module.signal) {
@@ -959,15 +960,17 @@ const listen$1 = async (module, options) => {
959
960
  const ipc = module.wrap(rawIpc);
960
961
  return ipc;
961
962
  };
962
- const create$5 = async ({
963
+
964
+ const create$4 = async ({
963
965
  commandMap,
966
+ isMessagePortOpen = true,
964
967
  messagePort
965
968
  }) => {
966
969
  // TODO create a commandMap per rpc instance
967
970
  register(commandMap);
968
971
  const rawIpc = await IpcParentWithMessagePort$1.create({
969
- messagePort,
970
- isMessagePortOpen: true
972
+ isMessagePortOpen,
973
+ messagePort
971
974
  });
972
975
  const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
973
976
  handleIpc(ipc);
@@ -975,8 +978,10 @@ const create$5 = async ({
975
978
  messagePort.start();
976
979
  return rpc;
977
980
  };
981
+
978
982
  const create$3 = async ({
979
983
  commandMap,
984
+ isMessagePortOpen,
980
985
  send
981
986
  }) => {
982
987
  const {
@@ -984,15 +989,13 @@ const create$3 = async ({
984
989
  port2
985
990
  } = new MessageChannel();
986
991
  await send(port1);
987
- return create$5({
992
+ return create$4({
988
993
  commandMap,
994
+ isMessagePortOpen,
989
995
  messagePort: port2
990
996
  });
991
997
  };
992
- const TransferMessagePortRpcParent = {
993
- __proto__: null,
994
- create: create$3
995
- };
998
+
996
999
  const create$2 = async ({
997
1000
  commandMap
998
1001
  }) => {
@@ -1003,10 +1006,7 @@ const create$2 = async ({
1003
1006
  const rpc = createRpc(ipc);
1004
1007
  return rpc;
1005
1008
  };
1006
- const WebWorkerRpcClient = {
1007
- __proto__: null,
1008
- create: create$2
1009
- };
1009
+
1010
1010
  const createMockRpc = ({
1011
1011
  commandMap
1012
1012
  }) => {
@@ -1020,13 +1020,62 @@ const createMockRpc = ({
1020
1020
  return command(...params);
1021
1021
  };
1022
1022
  const mockRpc = {
1023
+ invocations,
1023
1024
  invoke,
1024
- invokeAndTransfer: invoke,
1025
- invocations
1025
+ invokeAndTransfer: invoke
1026
1026
  };
1027
1027
  return mockRpc;
1028
1028
  };
1029
1029
 
1030
+ const rpcs = Object.create(null);
1031
+ const set$4 = (id, rpc) => {
1032
+ rpcs[id] = rpc;
1033
+ };
1034
+ const get$2 = id => {
1035
+ return rpcs[id];
1036
+ };
1037
+ const remove = id => {
1038
+ delete rpcs[id];
1039
+ };
1040
+
1041
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
1042
+ const create$1 = rpcId => {
1043
+ return {
1044
+ async dispose() {
1045
+ const rpc = get$2(rpcId);
1046
+ await rpc.dispose();
1047
+ },
1048
+ // @ts-ignore
1049
+ invoke(method, ...params) {
1050
+ const rpc = get$2(rpcId);
1051
+ // @ts-ignore
1052
+ return rpc.invoke(method, ...params);
1053
+ },
1054
+ // @ts-ignore
1055
+ invokeAndTransfer(method, ...params) {
1056
+ const rpc = get$2(rpcId);
1057
+ // @ts-ignore
1058
+ return rpc.invokeAndTransfer(method, ...params);
1059
+ },
1060
+ registerMockRpc(commandMap) {
1061
+ const mockRpc = createMockRpc({
1062
+ commandMap
1063
+ });
1064
+ set$4(rpcId, mockRpc);
1065
+ // @ts-ignore
1066
+ mockRpc[Symbol.dispose] = () => {
1067
+ remove(rpcId);
1068
+ };
1069
+ // @ts-ignore
1070
+ return mockRpc;
1071
+ },
1072
+ set(rpc) {
1073
+ set$4(rpcId, rpc);
1074
+ }
1075
+ };
1076
+ };
1077
+
1078
+ const Div$1 = 4;
1030
1079
  const Text = 12;
1031
1080
 
1032
1081
  const Button = 'event.button';
@@ -1166,34 +1215,14 @@ const Plus = '+';
1166
1215
 
1167
1216
  const getKeyCodeString = keyCode => {
1168
1217
  switch (keyCode) {
1218
+ case Backquote$1:
1219
+ return Backquote;
1220
+ case Backslash$1:
1221
+ return Backslash;
1169
1222
  case Backspace$1:
1170
1223
  return Backspace;
1171
- case Tab$1:
1172
- return Tab;
1173
- case Escape$1:
1174
- return Escape;
1175
- case Enter$1:
1176
- return Enter;
1177
- case Space$1:
1178
- return Space;
1179
- case PageUp$1:
1180
- return PageUp;
1181
- case PageDown$1:
1182
- return PageDown;
1183
- case End$1:
1184
- return End;
1185
- case Home$1:
1186
- return Home;
1187
- case LeftArrow$1:
1188
- return LeftArrow;
1189
- case UpArrow$1:
1190
- return UpArrow;
1191
- case RightArrow$1:
1192
- return RightArrow;
1193
- case DownArrow$1:
1194
- return DownArrow;
1195
- case Insert$1:
1196
- return Insert;
1224
+ case Comma$1:
1225
+ return Comma;
1197
1226
  case Delete$1:
1198
1227
  return Delete;
1199
1228
  case Digit0$1:
@@ -1216,6 +1245,32 @@ const getKeyCodeString = keyCode => {
1216
1245
  return Digit8;
1217
1246
  case Digit9$1:
1218
1247
  return Digit9;
1248
+ case DownArrow$1:
1249
+ return DownArrow;
1250
+ case End$1:
1251
+ return End;
1252
+ case Enter$1:
1253
+ return Enter;
1254
+ case Equal$1:
1255
+ return Equal;
1256
+ case Escape$1:
1257
+ return Escape;
1258
+ case F1$1:
1259
+ return F1;
1260
+ case F2$1:
1261
+ return F2;
1262
+ case F3$1:
1263
+ return F3;
1264
+ case F4$1:
1265
+ return F4;
1266
+ case F5$1:
1267
+ return F5;
1268
+ case F6$1:
1269
+ return F6;
1270
+ case Home$1:
1271
+ return Home;
1272
+ case Insert$1:
1273
+ return Insert;
1219
1274
  case KeyA$1:
1220
1275
  return KeyA;
1221
1276
  case KeyB$1:
@@ -1268,484 +1323,102 @@ const getKeyCodeString = keyCode => {
1268
1323
  return KeyY;
1269
1324
  case KeyZ$1:
1270
1325
  return KeyZ;
1271
- case F1$1:
1272
- return F1;
1273
- case F2$1:
1274
- return F2;
1275
- case F3$1:
1276
- return F3;
1277
- case F4$1:
1278
- return F4;
1279
- case F5$1:
1280
- return F5;
1281
- case F6$1:
1282
- return F6;
1283
- case Backslash$1:
1284
- return Backslash;
1285
- case Equal$1:
1286
- return Equal;
1287
- case Comma$1:
1288
- return Comma;
1289
- case Backquote$1:
1290
- return Backquote;
1326
+ case LeftArrow$1:
1327
+ return LeftArrow;
1328
+ case Minus$1:
1329
+ return Minus;
1330
+ case PageDown$1:
1331
+ return PageDown;
1332
+ case PageUp$1:
1333
+ return PageUp;
1291
1334
  case Plus$1:
1292
1335
  return Plus;
1336
+ case RightArrow$1:
1337
+ return RightArrow;
1338
+ case Space$1:
1339
+ return Space;
1293
1340
  case Star$1:
1294
1341
  return Star;
1295
- case Minus$1:
1296
- return Minus;
1342
+ case Tab$1:
1343
+ return Tab;
1344
+ case UpArrow$1:
1345
+ return UpArrow;
1297
1346
  default:
1298
1347
  return Unknown;
1299
1348
  }
1300
1349
  };
1301
1350
 
1302
- const Script = 2;
1303
-
1304
- const CtrlCmd = 1 << 11 >>> 0;
1305
- const Shift = 1 << 10 >>> 0;
1306
-
1307
- const Separator$2 = 1;
1308
- const None$1 = 0;
1309
- const SubMenu$1 = 4;
1310
- const Disabled$1 = 5;
1311
- const RestoreFocus$1 = 6;
1312
- const Ignore$1 = 7;
1313
-
1314
- const parseKey = rawKey => {
1315
- const isCtrl = Boolean(rawKey & CtrlCmd);
1316
- const isShift = Boolean(rawKey & Shift);
1317
- const keyCode = rawKey & 0x00_00_00_ff;
1318
- const key = getKeyCodeString(keyCode);
1319
- return {
1320
- key,
1321
- isCtrl,
1322
- isShift
1323
- };
1324
- };
1325
-
1326
- const DebugWorker = 55;
1327
- const RendererProcess = 1670;
1328
- const RendererWorker$1 = 1;
1329
-
1330
- const FocusSelector = 'Viewlet.focusSelector';
1331
-
1332
- const rpcs = Object.create(null);
1333
- const set$4 = (id, rpc) => {
1334
- rpcs[id] = rpc;
1335
- };
1336
- const get$2 = id => {
1337
- return rpcs[id];
1338
- };
1339
-
1340
- const create$1 = rpcId => {
1341
- return {
1342
- // @ts-ignore
1343
- invoke(method, ...params) {
1344
- const rpc = get$2(rpcId);
1345
- // @ts-ignore
1346
- return rpc.invoke(method, ...params);
1347
- },
1348
- // @ts-ignore
1349
- invokeAndTransfer(method, ...params) {
1350
- const rpc = get$2(rpcId);
1351
- // @ts-ignore
1352
- return rpc.invokeAndTransfer(method, ...params);
1353
- },
1354
- set(rpc) {
1355
- set$4(rpcId, rpc);
1356
- },
1357
- async dispose() {
1358
- const rpc = get$2(rpcId);
1359
- await rpc.dispose();
1360
- }
1361
- };
1362
- };
1363
-
1364
- const {
1365
- invoke: invoke$3,
1366
- set: set$3} = create$1(RendererProcess);
1367
-
1368
- const {
1369
- invoke: invoke$2,
1370
- invokeAndTransfer,
1371
- set: set$2,
1372
- dispose
1373
- } = create$1(RendererWorker$1);
1374
- const searchFileHtml = async uri => {
1375
- return invoke$2('ExtensionHost.searchFileWithHtml', uri);
1376
- };
1377
- const getFilePathElectron = async file => {
1378
- return invoke$2('FileSystemHandle.getFilePathElectron', file);
1379
- };
1380
- /**
1381
- * @deprecated
1382
- */
1383
- const showContextMenu = async (x, y, id, ...args) => {
1384
- return invoke$2('ContextMenu.show', x, y, id, ...args);
1385
- };
1386
- const showContextMenu2 = async (uid, menuId, x, y, args) => {
1387
- number(uid);
1388
- number(menuId);
1389
- number(x);
1390
- number(y);
1391
- // @ts-ignore
1392
- await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
1393
- };
1394
- const getElectronVersion = async () => {
1395
- return invoke$2('Process.getElectronVersion');
1396
- };
1397
- const applyBulkReplacement = async bulkEdits => {
1398
- await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
1399
- };
1400
- const setColorTheme = async id => {
1401
- // @ts-ignore
1402
- return invoke$2(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1403
- };
1404
- const getNodeVersion = async () => {
1405
- return invoke$2('Process.getNodeVersion');
1406
- };
1407
- const getChromeVersion = async () => {
1408
- return invoke$2('Process.getChromeVersion');
1409
- };
1410
- const getV8Version = async () => {
1411
- return invoke$2('Process.getV8Version');
1412
- };
1413
- const getFileHandles = async fileIds => {
1414
- const files = await invoke$2('FileSystemHandle.getFileHandles', fileIds);
1415
- return files;
1416
- };
1417
- const setWorkspacePath = async path => {
1418
- await invoke$2('Workspace.setPath', path);
1419
- };
1420
- const registerWebViewInterceptor = async (id, port) => {
1421
- await invokeAndTransfer('WebView.registerInterceptor', id, port);
1422
- };
1423
- const unregisterWebViewInterceptor = async id => {
1424
- await invoke$2('WebView.unregisterInterceptor', id);
1425
- };
1426
- const sendMessagePortToEditorWorker = async (port, rpcId) => {
1427
- const command = 'HandleMessagePort.handleMessagePort';
1428
- // @ts-ignore
1429
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1430
- };
1431
- const sendMessagePortToErrorWorker = async (port, rpcId) => {
1432
- const command = 'Errors.handleMessagePort';
1433
- // @ts-ignore
1434
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
1435
- };
1436
- const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
1437
- const command = 'Markdown.handleMessagePort';
1438
- // @ts-ignore
1439
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
1440
- };
1441
- const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1442
- const command = 'IconTheme.handleMessagePort';
1443
- // @ts-ignore
1444
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1445
- };
1446
- const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
1447
- const command = 'FileSystem.handleMessagePort';
1448
- // @ts-ignore
1449
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1450
- };
1451
- const readFile = async uri => {
1452
- return invoke$2('FileSystem.readFile', uri);
1453
- };
1454
- const getWebViewSecret = async key => {
1455
- // @ts-ignore
1456
- return invoke$2('WebView.getSecret', key);
1457
- };
1458
- const setWebViewPort = async (uid, port, origin, portType) => {
1459
- return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
1460
- };
1461
- const setFocus = key => {
1462
- return invoke$2('Focus.setFocus', key);
1463
- };
1464
- const getFileIcon = async options => {
1465
- return invoke$2('IconTheme.getFileIcon', options);
1466
- };
1467
- const getColorThemeNames = async () => {
1468
- return invoke$2('ColorTheme.getColorThemeNames');
1469
- };
1470
- const disableExtension = async id => {
1471
- // @ts-ignore
1472
- return invoke$2('ExtensionManagement.disable', id);
1473
- };
1474
- const enableExtension = async id => {
1475
- // @ts-ignore
1476
- return invoke$2('ExtensionManagement.enable', id);
1477
- };
1478
- const handleDebugChange = async params => {
1479
- // @ts-ignore
1480
- return invoke$2('Run And Debug.handleChange', params);
1481
- };
1482
- const getFolderIcon = async options => {
1483
- return invoke$2('IconTheme.getFolderIcon', options);
1484
- };
1485
- const closeWidget = async widgetId => {
1486
- return invoke$2('Viewlet.closeWidget', widgetId);
1487
- };
1488
- const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1489
- const command = 'HandleMessagePort.handleMessagePort2';
1490
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1491
- };
1492
- const sendMessagePortToSearchProcess = async port => {
1493
- await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
1494
- };
1495
- const confirm = async (message, options) => {
1496
- // @ts-ignore
1497
- const result = await invoke$2('ConfirmPrompt.prompt', message, options);
1498
- return result;
1499
- };
1500
- const getRecentlyOpened$1 = async () => {
1501
- return invoke$2(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1502
- };
1503
- const getKeyBindings$1 = async () => {
1504
- return invoke$2('KeyBindingsInitial.getKeyBindings');
1505
- };
1506
- const writeClipBoardText = async text => {
1507
- await invoke$2('ClipBoard.writeText', /* text */text);
1508
- };
1509
- const readClipBoardText = async () => {
1510
- return invoke$2('ClipBoard.readText');
1511
- };
1512
- const writeClipBoardImage = async blob => {
1513
- // @ts-ignore
1514
- await invoke$2('ClipBoard.writeImage', /* text */blob);
1515
- };
1516
- const searchFileMemory = async uri => {
1517
- // @ts-ignore
1518
- return invoke$2('ExtensionHost.searchFileWithMemory', uri);
1519
- };
1520
- const searchFileFetch = async uri => {
1521
- return invoke$2('ExtensionHost.searchFileWithFetch', uri);
1522
- };
1523
- const showMessageBox = async options => {
1524
- return invoke$2('ElectronDialog.showMessageBox', options);
1525
- };
1526
- const handleDebugResumed = async params => {
1527
- await invoke$2('Run And Debug.handleResumed', params);
1528
- };
1529
- const openWidget = async name => {
1530
- await invoke$2('Viewlet.openWidget', name);
1531
- };
1532
- const getIcons = async requests => {
1533
- const icons = await invoke$2('IconTheme.getIcons', requests);
1534
- return icons;
1535
- };
1536
- const activateByEvent = event => {
1537
- return invoke$2('ExtensionHostManagement.activateByEvent', event);
1538
- };
1539
- const setAdditionalFocus = focusKey => {
1540
- // @ts-ignore
1541
- return invoke$2('Focus.setAdditionalFocus', focusKey);
1542
- };
1543
- const getActiveEditorId = () => {
1544
- // @ts-ignore
1545
- return invoke$2('GetActiveEditor.getActiveEditorId');
1546
- };
1547
- const getWorkspacePath = () => {
1548
- return invoke$2('Workspace.getPath');
1549
- };
1550
- const sendMessagePortToRendererProcess = async port => {
1551
- const command = 'HandleMessagePort.handleMessagePort';
1552
- // @ts-ignore
1553
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1554
- };
1555
- const sendMessagePortToTextMeasurementWorker = async port => {
1556
- const command = 'TextMeasurement.handleMessagePort';
1557
- // @ts-ignore
1558
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
1559
- };
1560
- const sendMessagePortToSourceControlWorker = async port => {
1561
- const command = 'SourceControl.handleMessagePort';
1562
- // @ts-ignore
1563
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
1564
- };
1565
- const getPreference = async key => {
1566
- return await invoke$2('Preferences.get', key);
1567
- };
1568
- const getAllExtensions = async () => {
1569
- return invoke$2('ExtensionManagement.getAllExtensions');
1570
- };
1571
- const rerenderEditor = async key => {
1572
- // @ts-ignore
1573
- return invoke$2('Editor.rerender', key);
1574
- };
1575
- const handleDebugPaused = async params => {
1576
- await invoke$2('Run And Debug.handlePaused', params);
1577
- };
1578
- const openUri = async (uri, focus, options) => {
1579
- await invoke$2('Main.openUri', uri, focus, options);
1580
- };
1581
- const sendMessagePortToSyntaxHighlightingWorker = async port => {
1582
- await invokeAndTransfer(
1583
- // @ts-ignore
1584
- 'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
1585
- };
1586
- const handleDebugScriptParsed = async script => {
1587
- await invoke$2('Run And Debug.handleScriptParsed', script);
1588
- };
1589
- const getWindowId = async () => {
1590
- return invoke$2('GetWindowId.getWindowId');
1591
- };
1592
- const getBlob = async uri => {
1593
- // @ts-ignore
1594
- return invoke$2('FileSystem.getBlob', uri);
1595
- };
1596
- const getExtensionCommands = async () => {
1597
- return invoke$2('ExtensionHost.getCommands');
1598
- };
1599
- const showErrorDialog = async errorInfo => {
1600
- // @ts-ignore
1601
- await invoke$2('ErrorHandling.showErrorDialog', errorInfo);
1602
- };
1603
- const getFolderSize = async uri => {
1604
- // @ts-ignore
1605
- return await invoke$2('FileSystem.getFolderSize', uri);
1606
- };
1607
- const getExtension = async id => {
1608
- // @ts-ignore
1609
- return invoke$2('ExtensionManagement.getExtension', id);
1610
- };
1611
- const getMarkdownDom = async html => {
1612
- // @ts-ignore
1613
- return invoke$2('Markdown.getVirtualDom', html);
1614
- };
1615
- const renderMarkdown = async (markdown, options) => {
1616
- // @ts-ignore
1617
- return invoke$2('Markdown.renderMarkdown', markdown, options);
1618
- };
1619
- const openNativeFolder = async uri => {
1620
- // @ts-ignore
1621
- await invoke$2('OpenNativeFolder.openNativeFolder', uri);
1622
- };
1623
- const uninstallExtension = async id => {
1624
- return invoke$2('ExtensionManagement.uninstall', id);
1625
- };
1626
- const installExtension = async id => {
1627
- // @ts-ignore
1628
- return invoke$2('ExtensionManagement.install', id);
1629
- };
1630
- const openExtensionSearch = async () => {
1631
- // @ts-ignore
1632
- return invoke$2('SideBar.openViewlet', 'Extensions');
1633
- };
1634
- const setExtensionsSearchValue = async searchValue => {
1635
- // @ts-ignore
1636
- return invoke$2('Extensions.handleInput', searchValue, Script);
1637
- };
1638
- const openExternal = async uri => {
1639
- // @ts-ignore
1640
- await invoke$2('Open.openExternal', uri);
1641
- };
1642
- const openUrl = async uri => {
1643
- // @ts-ignore
1644
- await invoke$2('Open.openUrl', uri);
1645
- };
1646
- const getAllPreferences = async () => {
1647
- // @ts-ignore
1648
- return invoke$2('Preferences.getAll');
1649
- };
1650
- const showSaveFilePicker = async () => {
1651
- // @ts-ignore
1652
- return invoke$2('FilePicker.showSaveFilePicker');
1653
- };
1654
- const getLogsDir = async () => {
1655
- // @ts-ignore
1656
- return invoke$2('PlatformPaths.getLogsDir');
1351
+ const CtrlCmd = 1 << 11 >>> 0;
1352
+ const Shift = 1 << 10 >>> 0;
1353
+
1354
+ const Separator$2 = 1;
1355
+ const None$1 = 0;
1356
+ const SubMenu$1 = 4;
1357
+ const Checked$1 = 2;
1358
+ const Unchecked$1 = 3;
1359
+ const Disabled$1 = 5;
1360
+ const RestoreFocus$1 = 6;
1361
+ const Ignore$1 = 7;
1362
+
1363
+ const parseKey = rawKey => {
1364
+ const isCtrl = Boolean(rawKey & CtrlCmd);
1365
+ const isShift = Boolean(rawKey & Shift);
1366
+ const keyCode = rawKey & 0x00_00_00_ff;
1367
+ const key = getKeyCodeString(keyCode);
1368
+ return {
1369
+ isCtrl,
1370
+ isShift,
1371
+ key
1372
+ };
1657
1373
  };
1658
- const registerMockRpc = commandMap => {
1659
- const mockRpc = createMockRpc({
1660
- commandMap
1661
- });
1662
- set$2(mockRpc);
1663
- return mockRpc;
1374
+
1375
+ const DebugWorker = 55;
1376
+ const RendererProcess = 1670;
1377
+ const RendererWorker$1 = 1;
1378
+
1379
+ const FocusSelector = 'Viewlet.focusSelector';
1380
+
1381
+ const {
1382
+ invoke: invoke$3,
1383
+ set: set$3
1384
+ } = create$1(RendererProcess);
1385
+
1386
+ const {
1387
+ invoke: invoke$2,
1388
+ invokeAndTransfer,
1389
+ set: set$2
1390
+ } = create$1(RendererWorker$1);
1391
+ const sendMessagePortToRendererProcess = async port => {
1392
+ const command = 'HandleMessagePort.handleMessagePort';
1393
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1664
1394
  };
1665
1395
 
1666
1396
  const RendererWorker = {
1667
1397
  __proto__: null,
1668
- activateByEvent,
1669
- applyBulkReplacement,
1670
- closeWidget,
1671
- confirm,
1672
- disableExtension,
1673
- dispose,
1674
- enableExtension,
1675
- getActiveEditorId,
1676
- getAllExtensions,
1677
- getAllPreferences,
1678
- getBlob,
1679
- getChromeVersion,
1680
- getColorThemeNames,
1681
- getElectronVersion,
1682
- getExtension,
1683
- getExtensionCommands,
1684
- getFileHandles,
1685
- getFileIcon,
1686
- getFilePathElectron,
1687
- getFolderIcon,
1688
- getFolderSize,
1689
- getIcons,
1690
- getKeyBindings: getKeyBindings$1,
1691
- getLogsDir,
1692
- getMarkdownDom,
1693
- getNodeVersion,
1694
- getPreference,
1695
- getRecentlyOpened: getRecentlyOpened$1,
1696
- getV8Version,
1697
- getWebViewSecret,
1698
- getWindowId,
1699
- getWorkspacePath,
1700
- handleDebugChange,
1701
- handleDebugPaused,
1702
- handleDebugResumed,
1703
- handleDebugScriptParsed,
1704
- installExtension,
1705
1398
  invoke: invoke$2,
1706
1399
  invokeAndTransfer,
1707
- openExtensionSearch,
1708
- openExternal,
1709
- openNativeFolder,
1710
- openUri,
1711
- openUrl,
1712
- openWidget,
1713
- readClipBoardText,
1714
- readFile,
1715
- registerMockRpc,
1716
- registerWebViewInterceptor,
1717
- renderMarkdown,
1718
- rerenderEditor,
1719
- searchFileFetch,
1720
- searchFileHtml,
1721
- searchFileMemory,
1722
- sendMessagePortToEditorWorker,
1723
- sendMessagePortToErrorWorker,
1724
- sendMessagePortToExtensionHostWorker,
1725
- sendMessagePortToFileSystemWorker,
1726
- sendMessagePortToIconThemeWorker,
1727
- sendMessagePortToMarkdownWorker,
1728
1400
  sendMessagePortToRendererProcess,
1729
- sendMessagePortToSearchProcess,
1730
- sendMessagePortToSourceControlWorker,
1731
- sendMessagePortToSyntaxHighlightingWorker,
1732
- sendMessagePortToTextMeasurementWorker,
1733
- set: set$2,
1734
- setAdditionalFocus,
1735
- setColorTheme,
1736
- setExtensionsSearchValue,
1737
- setFocus,
1738
- setWebViewPort,
1739
- setWorkspacePath,
1740
- showContextMenu,
1741
- showContextMenu2,
1742
- showErrorDialog,
1743
- showMessageBox,
1744
- showSaveFilePicker,
1745
- uninstallExtension,
1746
- unregisterWebViewInterceptor,
1747
- writeClipBoardImage,
1748
- writeClipBoardText
1401
+ set: set$2
1402
+ };
1403
+
1404
+ const send = port => {
1405
+ return sendMessagePortToRendererProcess(port);
1406
+ };
1407
+ const createRendererProcessRpc = async () => {
1408
+ try {
1409
+ const rpc = await create$3({
1410
+ commandMap: {},
1411
+ send
1412
+ });
1413
+ return rpc;
1414
+ } catch (error) {
1415
+ throw new VError(error, `Failed to create renderer process rpc`);
1416
+ }
1417
+ };
1418
+
1419
+ const initializeRendererProcess = async () => {
1420
+ const rpc = await createRendererProcessRpc();
1421
+ set$3(rpc);
1749
1422
  };
1750
1423
 
1751
1424
  /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
@@ -1758,8 +1431,9 @@ const RendererWorker = {
1758
1431
  // TODO this code seems a bit too complicated, maybe it can be simplified
1759
1432
 
1760
1433
  const state$1 = {
1761
- menus: [],
1762
- latestTimeStamp: 0};
1434
+ latestTimeStamp: 0,
1435
+ menus: []
1436
+ };
1763
1437
  const addMenuInternal = menu => {
1764
1438
  if (state$1.menus.length > 5) {
1765
1439
  throw new Error('too many menus');
@@ -1857,10 +1531,10 @@ const getMenuBounds = (x, y, items) => {
1857
1531
  y = Math.max(y, 0);
1858
1532
  }
1859
1533
  return {
1860
- x,
1861
- y,
1534
+ height: menuHeight,
1862
1535
  width: menuWidth,
1863
- height: menuHeight
1536
+ x,
1537
+ y
1864
1538
  };
1865
1539
  };
1866
1540
 
@@ -1934,7 +1608,8 @@ const UiStrings$2 = {
1934
1608
  SelectAll: 'Select All',
1935
1609
  ToggleBlockComment: 'Toggle Block Comment',
1936
1610
  ToggleLineComment: 'Toggle Line Comment',
1937
- Undo: 'Undo'};
1611
+ Undo: 'Undo'
1612
+ };
1938
1613
  const cut = () => {
1939
1614
  return i18nString(UiStrings$2.Cut);
1940
1615
  };
@@ -1984,49 +1659,49 @@ const TitleBar = 15;
1984
1659
  const View$1 = 16;
1985
1660
 
1986
1661
  const menuEntrySeparator = {
1987
- id: 'separator',
1988
- label: '',
1662
+ command: '',
1989
1663
  flags: Separator$2,
1990
- command: ''
1664
+ id: 'separator',
1665
+ label: ''
1991
1666
  };
1992
1667
 
1993
1668
  const id$9 = Edit$1;
1994
1669
  const getMenuEntries$d = () => {
1995
1670
  return [{
1996
- id: 'undo',
1997
- label: undo(),
1671
+ command: /* TODO */'-1',
1998
1672
  flags: Disabled,
1999
- command: /* TODO */'-1'
1673
+ id: 'undo',
1674
+ label: undo()
2000
1675
  }, {
2001
- id: 'redo',
2002
- label: redo(),
1676
+ command: /* TODO */'-1',
2003
1677
  flags: Disabled,
2004
- command: /* TODO */'-1'
1678
+ id: 'redo',
1679
+ label: redo()
2005
1680
  }, menuEntrySeparator, {
2006
- id: 'cut',
2007
- label: cut(),
1681
+ command: /* Editor.cut */'Editor.cut',
2008
1682
  flags: None,
2009
- command: /* Editor.cut */'Editor.cut'
1683
+ id: 'cut',
1684
+ label: cut()
2010
1685
  }, {
2011
- id: 'copy',
2012
- label: copy(),
1686
+ command: /* Editor.copy */'Editor.copy',
2013
1687
  flags: None,
2014
- command: /* Editor.copy */'Editor.copy'
1688
+ id: 'copy',
1689
+ label: copy()
2015
1690
  }, {
2016
- id: 'paste',
2017
- label: paste(),
1691
+ command: /* Editor.paste */'Editor.paste',
2018
1692
  flags: None,
2019
- command: /* Editor.paste */'Editor.paste'
1693
+ id: 'paste',
1694
+ label: paste()
2020
1695
  }, menuEntrySeparator, {
2021
- id: 'toggle-line-comment',
2022
- label: toggleLineComment(),
1696
+ command: /* Editor.toggleLineComment */'Editor.toggleLineComment',
2023
1697
  flags: None,
2024
- command: /* Editor.toggleLineComment */'Editor.toggleLineComment'
1698
+ id: 'toggle-line-comment',
1699
+ label: toggleLineComment()
2025
1700
  }, {
2026
- id: 'toggle-block-comment',
2027
- label: toggleBlockComment(),
1701
+ command: /* Editor.toggleBlockComment */'Editor.toggleBlockComment',
2028
1702
  flags: None,
2029
- command: /* Editor.toggleBlockComment */'Editor.toggleBlockComment'
1703
+ id: 'toggle-block-comment',
1704
+ label: toggleBlockComment()
2030
1705
  }];
2031
1706
  };
2032
1707
 
@@ -2040,15 +1715,14 @@ const MenuEntriesEdit = {
2040
1715
  * @enum {string}
2041
1716
  */
2042
1717
  const UiStrings$1 = {
1718
+ Exit: 'Exit',
2043
1719
  NewFile: 'New File',
2044
1720
  NewWindow: 'New Window',
2045
1721
  OpenFile: 'Open File',
2046
1722
  OpenFolder: 'Open Folder',
2047
1723
  OpenRecent: 'Open Recent',
2048
- Exit: 'Exit',
2049
1724
  Save: 'Save',
2050
- SaveAll: 'Save All'
2051
- };
1725
+ SaveAll: 'Save All'};
2052
1726
  const newFile = () => {
2053
1727
  return i18nString(UiStrings$1.NewFile);
2054
1728
  };
@@ -2080,47 +1754,47 @@ const Electron = 2;
2080
1754
  const id$8 = File$2;
2081
1755
  const getMenuEntries$c = platform => {
2082
1756
  const entries = [{
2083
- id: 'newFile',
2084
- label: newFile(),
1757
+ command: '-1',
2085
1758
  flags: None,
2086
- command: '-1'
1759
+ id: 'newFile',
1760
+ label: newFile()
2087
1761
  }, {
2088
- id: 'newWindow',
2089
- label: newWindow(),
1762
+ command: /* Window.openNew */'Window.openNew',
2090
1763
  flags: None,
2091
- command: /* Window.openNew */'Window.openNew'
1764
+ id: 'newWindow',
1765
+ label: newWindow()
2092
1766
  }, menuEntrySeparator, {
2093
- id: 'openFile',
2094
- label: openFile(),
1767
+ command: 'Dialog.openFile',
2095
1768
  flags: None,
2096
- command: 'Dialog.openFile'
1769
+ id: 'openFile',
1770
+ label: openFile()
2097
1771
  }, {
2098
- id: 'openFolder',
2099
- label: openFolder(),
1772
+ command: 'Dialog.openFolder',
2100
1773
  flags: RestoreFocus,
2101
- command: 'Dialog.openFolder'
1774
+ id: 'openFolder',
1775
+ label: openFolder()
2102
1776
  }, {
2103
- id: OpenRecent,
2104
- label: openRecent(),
1777
+ command: '',
2105
1778
  flags: SubMenu,
2106
- command: ''
1779
+ id: OpenRecent,
1780
+ label: openRecent()
2107
1781
  }, menuEntrySeparator, {
2108
- id: 'save',
2109
- label: save(),
1782
+ command: 'Main.save',
2110
1783
  flags: None,
2111
- command: 'Main.save'
1784
+ id: 'save',
1785
+ label: save()
2112
1786
  }, {
2113
- id: 'saveAll',
2114
- label: saveAll(),
1787
+ command: 'Main.saveAll',
2115
1788
  flags: None,
2116
- command: 'Main.saveAll'
1789
+ id: 'saveAll',
1790
+ label: saveAll()
2117
1791
  }];
2118
1792
  if (platform === Electron) {
2119
1793
  entries.push(menuEntrySeparator, {
2120
- id: 'exit',
2121
- label: exit(),
1794
+ command: 'Chrome.exit',
2122
1795
  flags: Ignore,
2123
- command: 'Chrome.exit'
1796
+ id: 'exit',
1797
+ label: exit()
2124
1798
  });
2125
1799
  }
2126
1800
  return entries;
@@ -2170,25 +1844,25 @@ const getMenuEntries$a = async platform => {
2170
1844
  const entries = [];
2171
1845
  if (platform !== Web) {
2172
1846
  entries.push({
2173
- id: 'toggleDeveloperTools',
2174
- label: toggleDeveloperTools(),
1847
+ command: 'Developer.toggleDeveloperTools',
2175
1848
  flags: None,
2176
- command: 'Developer.toggleDeveloperTools'
1849
+ id: 'toggleDeveloperTools',
1850
+ label: toggleDeveloperTools()
2177
1851
  }, {
2178
- id: 'openProcessExplorer',
2179
- label: openProcessExplorer(),
1852
+ command: 'Developer.openProcessExplorer',
2180
1853
  flags: RestoreFocus,
2181
- command: 'Developer.openProcessExplorer'
1854
+ id: 'openProcessExplorer',
1855
+ label: openProcessExplorer()
2182
1856
  });
2183
1857
  }
2184
1858
  if (entries.length > 0) {
2185
1859
  entries.push(menuEntrySeparator);
2186
1860
  }
2187
1861
  entries.push({
2188
- id: 'about',
2189
- label: about(),
1862
+ command: 'About.showAbout',
2190
1863
  flags: None,
2191
- command: 'About.showAbout'
1864
+ id: 'about',
1865
+ label: about()
2192
1866
  });
2193
1867
  return entries;
2194
1868
  };
@@ -2224,10 +1898,10 @@ const toMenuItem = folder => {
2224
1898
  const homeDir = getHomeDir();
2225
1899
  const label = getTitle(homeDir, folder);
2226
1900
  return {
2227
- label,
2228
- flags: None,
1901
+ args: [folder],
2229
1902
  command: 'Workspace.setPath',
2230
- args: [folder]
1903
+ flags: None,
1904
+ label
2231
1905
  };
2232
1906
  };
2233
1907
  const id$5 = OpenRecent;
@@ -2239,15 +1913,15 @@ const getMenuEntries$9 = async () => {
2239
1913
  items.push(...itemsToShow.map(toMenuItem), menuEntrySeparator);
2240
1914
  }
2241
1915
  items.push({
2242
- id: 'more',
2243
- label: '...',
1916
+ command: 'QuickPick.showRecent',
2244
1917
  flags: None,
2245
- command: 'QuickPick.showRecent'
1918
+ id: 'more',
1919
+ label: '...'
2246
1920
  }, menuEntrySeparator, {
2247
- id: 'clearRecentlyOpened',
2248
- label: 'clear',
1921
+ command: 'RecentlyOpened.clearRecentlyOpened',
2249
1922
  flags: None,
2250
- command: 'RecentlyOpened.clearRecentlyOpened'
1923
+ id: 'clearRecentlyOpened',
1924
+ label: 'clear'
2251
1925
  });
2252
1926
  return items;
2253
1927
  };
@@ -2272,30 +1946,30 @@ const MenuEntriesRun = {
2272
1946
  const id$3 = Selection$1;
2273
1947
  const getMenuEntries$7 = () => {
2274
1948
  return [{
2275
- id: 'selectAll',
2276
- label: selectAll(),
1949
+ command: 'Editor.selectAll',
2277
1950
  flags: None,
2278
- command: 'Editor.selectAll'
1951
+ id: 'selectAll',
1952
+ label: selectAll()
2279
1953
  }, {
2280
- id: 'copyLineUp',
2281
- label: copyLineUp(),
1954
+ command: 'Editor.copyLineUp',
2282
1955
  flags: None,
2283
- command: 'Editor.copyLineUp'
1956
+ id: 'copyLineUp',
1957
+ label: copyLineUp()
2284
1958
  }, {
2285
- id: 'copyLineDown',
2286
- label: copyLineDown(),
1959
+ command: 'Editor.copyLineDown',
2287
1960
  flags: None,
2288
- command: 'Editor.copyLineDown'
1961
+ id: 'copyLineDown',
1962
+ label: copyLineDown()
2289
1963
  }, {
2290
- id: 'moveLineUp',
2291
- label: moveLineUp(),
1964
+ command: 'Editor.moveLineUp',
2292
1965
  flags: Disabled,
2293
- command: 'Editor.moveLineUp'
1966
+ id: 'moveLineUp',
1967
+ label: moveLineUp()
2294
1968
  }, {
2295
- id: 'moveLineDown',
2296
- label: moveLineDown(),
1969
+ command: 'Editor.moveLineDown',
2297
1970
  flags: Disabled,
2298
- command: 'Editor.moveLineDown'
1971
+ id: 'moveLineDown',
1972
+ label: moveLineDown()
2299
1973
  }];
2300
1974
  };
2301
1975
 
@@ -2309,8 +1983,7 @@ const MenuEntriesSelection = {
2309
1983
  * @enum {string}
2310
1984
  */
2311
1985
  const UiStrings = {
2312
- NewTerminal: 'New Terminal'
2313
- };
1986
+ NewTerminal: 'New Terminal'};
2314
1987
  const newTerminal = () => {
2315
1988
  return i18nString(UiStrings.NewTerminal);
2316
1989
  };
@@ -2318,11 +1991,11 @@ const newTerminal = () => {
2318
1991
  const id$2 = Terminal$1;
2319
1992
  const getMenuEntries$6 = () => {
2320
1993
  return [{
2321
- id: 'newTerminal',
2322
- label: newTerminal(),
2323
- flags: None,
1994
+ args: ['Terminal'],
2324
1995
  command: 'Layout.togglePanel',
2325
- args: ['Terminal']
1996
+ flags: None,
1997
+ id: 'newTerminal',
1998
+ label: newTerminal()
2326
1999
  }];
2327
2000
  };
2328
2001
 
@@ -2359,68 +2032,68 @@ const help = () => {
2359
2032
 
2360
2033
  const getMenuEntries$5 = () => {
2361
2034
  return [{
2035
+ flags: SubMenu,
2362
2036
  id: File$2,
2363
- label: file(),
2364
- flags: SubMenu
2037
+ label: file()
2365
2038
  }, {
2039
+ flags: SubMenu,
2366
2040
  id: Edit$1,
2367
- label: edit(),
2368
- flags: SubMenu
2041
+ label: edit()
2369
2042
  }, {
2043
+ flags: SubMenu,
2370
2044
  id: Selection$1,
2371
- label: selection(),
2372
- flags: SubMenu
2045
+ label: selection()
2373
2046
  }, {
2047
+ flags: SubMenu,
2374
2048
  id: View$1,
2375
- label: view(),
2376
- flags: SubMenu
2049
+ label: view()
2377
2050
  }, {
2051
+ flags: SubMenu,
2378
2052
  id: Go$1,
2379
- label: go(),
2380
- flags: SubMenu
2053
+ label: go()
2381
2054
  }, {
2055
+ flags: SubMenu,
2382
2056
  id: Run$1,
2383
- label: run(),
2384
2057
  keyboardShortCut: 'Alt+r',
2385
- flags: SubMenu
2058
+ label: run()
2386
2059
  }, {
2060
+ flags: SubMenu,
2387
2061
  id: Terminal$1,
2388
- label: terminal(),
2389
2062
  keyboardShortCut: 'Alt+t',
2390
- flags: SubMenu
2063
+ label: terminal()
2391
2064
  }, {
2065
+ flags: SubMenu,
2392
2066
  id: Help$1,
2393
- label: help(),
2394
2067
  keyboardShortCut: 'Alt+h',
2395
- flags: SubMenu
2068
+ label: help()
2396
2069
  }];
2397
2070
  };
2398
2071
 
2399
2072
  const getMenuEntries$4 = () => {
2400
2073
  return [{
2074
+ flags: None,
2401
2075
  id: File$2,
2402
- label: file(),
2403
- flags: None
2076
+ label: file()
2404
2077
  }, {
2078
+ flags: None,
2405
2079
  id: Edit$1,
2406
- label: edit(),
2407
- flags: None
2080
+ label: edit()
2408
2081
  }, {
2082
+ flags: None,
2409
2083
  id: Selection$1,
2410
- label: selection(),
2411
- flags: None
2084
+ label: selection()
2412
2085
  }, {
2086
+ flags: None,
2413
2087
  id: View$1,
2414
- label: view(),
2415
- flags: None
2088
+ label: view()
2416
2089
  }, {
2090
+ flags: None,
2417
2091
  id: Go$1,
2418
- label: go(),
2419
- flags: None
2092
+ label: go()
2420
2093
  }, {
2094
+ flags: None,
2421
2095
  id: Help$1,
2422
- label: help(),
2423
- flags: None
2096
+ label: help()
2424
2097
  }];
2425
2098
  };
2426
2099
 
@@ -2517,9 +2190,9 @@ const mergeClassNames = (...classNames) => {
2517
2190
 
2518
2191
  const text = data => {
2519
2192
  return {
2520
- type: Text,
2193
+ childCount: 0,
2521
2194
  text: data,
2522
- childCount: 0
2195
+ type: Text
2523
2196
  };
2524
2197
  };
2525
2198
 
@@ -2527,16 +2200,16 @@ const Div = 4;
2527
2200
  const Span = 8;
2528
2201
 
2529
2202
  const checkboxChecked = {
2530
- type: Div,
2203
+ ariaChecked: true,
2204
+ childCount: 2,
2531
2205
  className: mergeClassNames(MenuItem, MenuItemCheckMark),
2532
2206
  role: MenuItemCheckBox,
2533
- ariaChecked: true,
2534
2207
  tabIndex: -1,
2535
- childCount: 2
2208
+ type: Div
2536
2209
  };
2537
2210
  const checkMark = {
2538
- type: Div,
2539
- className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck)
2211
+ className: mergeClassNames(MenuItemCheckmarkIcon, MaskIconCheck),
2212
+ type: Div
2540
2213
  };
2541
2214
  const getMenuItemCheckedDom = menuItem => {
2542
2215
  const {
@@ -2559,41 +2232,41 @@ const getKeyBindingString = (key, altKey, ctrlKey, shiftKey, metaKey) => {
2559
2232
 
2560
2233
  const getMenuItemDefaultDom = menuItem => {
2561
2234
  const {
2562
- label,
2563
2235
  isFocused,
2564
- key
2236
+ key,
2237
+ label
2565
2238
  } = menuItem;
2566
2239
  let className = MenuItem;
2567
2240
  if (isFocused) {
2568
2241
  className += ' ' + MenuItemFocused;
2569
2242
  }
2570
2243
  const dom = [{
2571
- type: Div,
2244
+ childCount: 1,
2572
2245
  className,
2573
2246
  role: MenuItem$1,
2574
2247
  tabIndex: -1,
2575
- childCount: 1
2248
+ type: Div
2576
2249
  }, text(label)];
2577
2250
  if (key) {
2578
2251
  dom[0].childCount++;
2579
2252
  const parsedKey = parseKey(key);
2580
2253
  const keyBindingsString = getKeyBindingString(parsedKey.key, false, parsedKey.isCtrl, parsedKey.isShift);
2581
2254
  dom.push({
2582
- type: Span,
2255
+ childCount: 1,
2583
2256
  className: MenuItemKeyBinding,
2584
- childCount: 1
2257
+ type: Span
2585
2258
  }, text(keyBindingsString));
2586
2259
  }
2587
2260
  return dom;
2588
2261
  };
2589
2262
 
2590
2263
  const disabled = {
2591
- type: Div,
2264
+ childCount: 1,
2592
2265
  className: MenuItem,
2266
+ disabled: true,
2593
2267
  role: MenuItem$1,
2594
2268
  tabIndex: -1,
2595
- disabled: true,
2596
- childCount: 1
2269
+ type: Div
2597
2270
  };
2598
2271
  const getMenuItemDisabledDom = menuItem => {
2599
2272
  const {
@@ -2603,34 +2276,37 @@ const getMenuItemDisabledDom = menuItem => {
2603
2276
  };
2604
2277
 
2605
2278
  const getMenuItemsNoopDom = () => {
2606
- return [];
2279
+ return [{
2280
+ childCount: 1,
2281
+ type: Div$1
2282
+ }, text(`Unsupport menu item type`)];
2607
2283
  };
2608
2284
 
2609
2285
  const separator = {
2610
- type: Div,
2286
+ childCount: 1,
2611
2287
  className: MenuItemSeparator,
2612
2288
  role: Separator,
2613
- childCount: 1
2289
+ type: Div
2614
2290
  };
2615
2291
  const separatorLine = {
2616
- type: Div,
2292
+ childCount: 0,
2617
2293
  className: MenuItemSeparatorLine,
2618
- childCount: 0
2294
+ type: Div
2619
2295
  };
2620
2296
  const getMenuItemSeparatorDom = menuItem => {
2621
2297
  return [separator, separatorLine];
2622
2298
  };
2623
2299
 
2624
2300
  const arrowRight = {
2625
- type: Div,
2301
+ childCount: 0,
2626
2302
  className: MenuItemSubMenuArrowRight,
2627
- childCount: 0
2303
+ type: Div
2628
2304
  };
2629
2305
  const getMenuItemSubMenuDom = menuItem => {
2630
2306
  const {
2631
- label,
2632
- isFocused,
2633
2307
  isExpanded,
2308
+ isFocused,
2309
+ label,
2634
2310
  level
2635
2311
  } = menuItem;
2636
2312
  let className = MenuItem;
@@ -2639,24 +2315,24 @@ const getMenuItemSubMenuDom = menuItem => {
2639
2315
  className += ' ' + MenuItemFocused;
2640
2316
  }
2641
2317
  return [{
2642
- type: Div,
2318
+ ariaExpanded: isExpanded,
2319
+ ariaHasPopup: true,
2320
+ ariaOwns: isExpanded ? `Menu-${level + 1}` : undefined,
2321
+ childCount: 2,
2643
2322
  className,
2644
2323
  role: MenuItem$1,
2645
2324
  tabIndex: -1,
2646
- ariaHasPopup: true,
2647
- ariaExpanded: isExpanded,
2648
- ariaOwns: isExpanded ? `Menu-${level + 1}` : undefined,
2649
- childCount: 2
2325
+ type: Div
2650
2326
  }, text(label), arrowRight];
2651
2327
  };
2652
2328
 
2653
2329
  const checkboxUnchecked = {
2654
- type: Div,
2330
+ ariaChecked: false,
2331
+ childCount: 1,
2655
2332
  className: MenuItem,
2656
2333
  role: MenuItemCheckBox,
2657
- ariaChecked: false,
2658
2334
  tabIndex: -1,
2659
- childCount: 1
2335
+ type: Div
2660
2336
  };
2661
2337
  const getMenuItemUncheckedDom = menuItem => {
2662
2338
  const {
@@ -2667,20 +2343,20 @@ const getMenuItemUncheckedDom = menuItem => {
2667
2343
 
2668
2344
  const getMenuItemRenderer = flags => {
2669
2345
  switch (flags) {
2346
+ case Checked:
2347
+ return getMenuItemCheckedDom;
2348
+ case Disabled:
2349
+ return getMenuItemDisabledDom;
2350
+ case Ignore:
2670
2351
  case None:
2671
2352
  case RestoreFocus:
2672
- case Ignore:
2673
2353
  return getMenuItemDefaultDom;
2674
2354
  case Separator$1:
2675
2355
  return getMenuItemSeparatorDom;
2676
- case Checked:
2677
- return getMenuItemCheckedDom;
2678
- case Unchecked:
2679
- return getMenuItemUncheckedDom;
2680
- case Disabled:
2681
- return getMenuItemDisabledDom;
2682
2356
  case SubMenu:
2683
2357
  return getMenuItemSubMenuDom;
2358
+ case Unchecked:
2359
+ return getMenuItemUncheckedDom;
2684
2360
  default:
2685
2361
  return getMenuItemsNoopDom;
2686
2362
  }
@@ -2696,11 +2372,11 @@ const getMenuItemVirtualDom = menuItem => {
2696
2372
 
2697
2373
  const getMenuVirtualDom = menuItems => {
2698
2374
  const dom = [{
2699
- type: Div,
2375
+ childCount: menuItems.length,
2700
2376
  className: Menu,
2701
2377
  role: Menu$1,
2702
2378
  tabIndex: -1,
2703
- childCount: menuItems.length
2379
+ type: Div
2704
2380
  }, ...menuItems.flatMap(getMenuItemVirtualDom)];
2705
2381
  return dom;
2706
2382
  };
@@ -2714,12 +2390,12 @@ const getVisible = (items, focusedIndex, expanded, level) => {
2714
2390
  label
2715
2391
  } = item;
2716
2392
  visibleItems.push({
2717
- label,
2718
2393
  flags,
2719
- isFocused: i === focusedIndex,
2720
2394
  isExpanded: i === focusedIndex && expanded,
2721
- level,
2722
- key: item.key
2395
+ isFocused: i === focusedIndex,
2396
+ key: item.key,
2397
+ label,
2398
+ level
2723
2399
  });
2724
2400
  }
2725
2401
  return visibleItems;
@@ -2752,8 +2428,8 @@ const getMenuHeight = items => {
2752
2428
  const getMenuHideCommands = async (restoreFocus = true) => {
2753
2429
  if (getCount() === 0) {
2754
2430
  return {
2755
- newMenus: [],
2756
- commands: []
2431
+ commands: [],
2432
+ newMenus: []
2757
2433
  };
2758
2434
  }
2759
2435
  reset();
@@ -2790,9 +2466,9 @@ const show$2 = async (x, y, id, mouseBlocking = false, ...args) => {
2790
2466
  const items = await getMenuEntriesWithKeyBindings(id, ...args);
2791
2467
  const bounds = getMenuBounds(x, y, items);
2792
2468
  const menu = addMenuInternal({
2469
+ focusedIndex: -1,
2793
2470
  id,
2794
2471
  items,
2795
- focusedIndex: -1,
2796
2472
  level: getCount(),
2797
2473
  x: bounds.x,
2798
2474
  y: bounds.y
@@ -2805,9 +2481,9 @@ const show2$2 = async (uid, menuId, x, y, mouseBlocking = false, ...args) => {
2805
2481
  const items = await getMenuEntriesWithKeyBindings2(uid, menuId, ...args);
2806
2482
  const bounds = getMenuBounds(x, y, items);
2807
2483
  const menu = addMenuInternal({
2484
+ focusedIndex: -1,
2808
2485
  id: menuId,
2809
2486
  items,
2810
- focusedIndex: -1,
2811
2487
  level: getCount(),
2812
2488
  x: bounds.x,
2813
2489
  y: bounds.y
@@ -2903,8 +2579,8 @@ const create = () => {
2903
2579
  },
2904
2580
  set(uid, oldState, newState) {
2905
2581
  states[uid] = {
2906
- oldState,
2907
- newState
2582
+ newState,
2583
+ oldState
2908
2584
  };
2909
2585
  }
2910
2586
  };
@@ -2917,16 +2593,16 @@ const {
2917
2593
 
2918
2594
  const diff2 = uid => {
2919
2595
  const {
2920
- oldState,
2921
- newState
2596
+ newState,
2597
+ oldState
2922
2598
  } = get(uid);
2923
2599
  return diff(oldState, newState);
2924
2600
  };
2925
2601
 
2926
2602
  const canBeFocused = item => {
2927
2603
  switch (item.flags) {
2928
- case Separator$2:
2929
2604
  case Disabled$1:
2605
+ case Separator$2:
2930
2606
  return false;
2931
2607
  default:
2932
2608
  return true;
@@ -3033,36 +2709,36 @@ const FocusTitleBarMenuBar = 26;
3033
2709
 
3034
2710
  const getKeyBindings = () => {
3035
2711
  return [{
3036
- key: DownArrow$1,
3037
2712
  command: 'TitleBarMenuBar.handleKeyArrowDown',
2713
+ key: DownArrow$1,
3038
2714
  when: FocusTitleBarMenuBar
3039
2715
  }, {
3040
- key: UpArrow$1,
3041
2716
  command: 'TitleBarMenuBar.handleKeyArrowUp',
2717
+ key: UpArrow$1,
3042
2718
  when: FocusTitleBarMenuBar
3043
2719
  }, {
3044
- key: RightArrow$1,
3045
2720
  command: 'TitleBarMenuBar.handleKeyArrowRight',
2721
+ key: RightArrow$1,
3046
2722
  when: FocusTitleBarMenuBar
3047
2723
  }, {
3048
- key: LeftArrow$1,
3049
2724
  command: 'TitleBarMenuBar.handleKeyArrowLeft',
2725
+ key: LeftArrow$1,
3050
2726
  when: FocusTitleBarMenuBar
3051
2727
  }, {
3052
- key: Space$1,
3053
2728
  command: 'TitleBarMenuBar.handleKeySpace',
2729
+ key: Space$1,
3054
2730
  when: FocusTitleBarMenuBar
3055
2731
  }, {
3056
- key: Home$1,
3057
2732
  command: 'TitleBarMenuBar.handleKeyHome',
2733
+ key: Home$1,
3058
2734
  when: FocusTitleBarMenuBar
3059
2735
  }, {
3060
- key: End$1,
3061
2736
  command: 'TitleBarMenuBar.handleKeyEnd',
2737
+ key: End$1,
3062
2738
  when: FocusTitleBarMenuBar
3063
2739
  }, {
3064
- key: Escape$1,
3065
2740
  command: 'TitleBarMenuBar.handleKeyEscape',
2741
+ key: Escape$1,
3066
2742
  when: FocusTitleBarMenuBar
3067
2743
  }];
3068
2744
  };
@@ -3097,9 +2773,9 @@ const getMenuEntries = (id, platform) => {
3097
2773
  const getMenuShowCommands = async (items, menuId, x, y, mouseBlocking = false) => {
3098
2774
  const bounds = getMenuBounds(x, y, items);
3099
2775
  const menu = addMenuInternal({
2776
+ focusedIndex: -1,
3100
2777
  id: menuId,
3101
2778
  items,
3102
- focusedIndex: -1,
3103
2779
  level: getCount(),
3104
2780
  x: bounds.x,
3105
2781
  y: bounds.y
@@ -3107,9 +2783,9 @@ const getMenuShowCommands = async (items, menuId, x, y, mouseBlocking = false) =
3107
2783
  const visible = getVisible(menu.items, -1, false, menu.level);
3108
2784
  const dom = getMenuVirtualDom(visible).slice(1);
3109
2785
  return {
3110
- menus: getAll(),
2786
+ commands: [/* Menu.show */'Menu.showMenu', /* x */bounds.x, /* y */bounds.y, /* width */bounds.width, /* height */bounds.height, /* items */menu.items, /* level */menu.level, /* parentIndex */-1, /* dom */dom, /* mouseBlocking */mouseBlocking],
3111
2787
  menu,
3112
- commands: [/* Menu.show */'Menu.showMenu', /* x */bounds.x, /* y */bounds.y, /* width */bounds.width, /* height */bounds.height, /* items */menu.items, /* level */menu.level, /* parentIndex */-1, /* dom */dom, /* mouseBlocking */mouseBlocking]
2788
+ menus: getAll()
3113
2789
  };
3114
2790
  };
3115
2791
 
@@ -3127,8 +2803,8 @@ const hideSubMenus = async level => {
3127
2803
  const MENU_DELAY_TRIANGLE = 300;
3128
2804
  const resolveAfterTimeout = async () => {
3129
2805
  const {
3130
- resolve,
3131
- promise
2806
+ promise,
2807
+ resolve
3132
2808
  } = Promise.withResolvers();
3133
2809
  setTimeout(resolve, MENU_DELAY_TRIANGLE);
3134
2810
  await promise;
@@ -3141,14 +2817,14 @@ const showSubMenuAtEnter = async (level, index, enterX, enterY) => {
3141
2817
  const item = parentMenu.items[index];
3142
2818
  const subMenuItems = await getMenuEntries$1(item.id);
3143
2819
  const subMenu = addMenuInternal({
2820
+ enterX,
2821
+ enterY,
2822
+ focusedIndex: -1,
3144
2823
  id: item.id,
3145
2824
  items: subMenuItems,
3146
- focusedIndex: -1,
3147
2825
  level: getCount(),
3148
- y: parentMenu.y + index * 25,
3149
2826
  x: parentMenu.x + MENU_WIDTH,
3150
- enterX,
3151
- enterY
2827
+ y: parentMenu.y + index * 25
3152
2828
  });
3153
2829
  const width = getMenuWidth();
3154
2830
  const height = getMenuHeight(subMenuItems);
@@ -3273,8 +2949,8 @@ const applyRender = (oldState, newState, diffResult) => {
3273
2949
 
3274
2950
  const render2 = async (uid, diffResult) => {
3275
2951
  const {
3276
- oldState,
3277
- newState
2952
+ newState,
2953
+ oldState
3278
2954
  } = get(uid);
3279
2955
  set(uid, newState, newState);
3280
2956
  const commands = applyRender(oldState, newState, diffResult);
@@ -3316,6 +2992,8 @@ const saveState = uid => {
3316
2992
  };
3317
2993
  };
3318
2994
 
2995
+ const selectIndexDefault = async () => {};
2996
+
3319
2997
  const {
3320
2998
  invoke} = RendererWorker;
3321
2999
 
@@ -3323,36 +3001,46 @@ const executeMenuItemCommand = async item => {
3323
3001
  await invoke(item.command, ...(item.args || []));
3324
3002
  };
3325
3003
 
3004
+ const selectIndexIgnore = async (menu, item) => {
3005
+ await executeMenuItemCommand(item);
3006
+ };
3007
+
3326
3008
  const selectIndexNone = async (menu, item) => {
3327
- await Promise.all([hide(/* restoreFocus */false), executeMenuItemCommand(item)]);
3009
+ await hide(/* restoreFocus */false);
3010
+ await executeMenuItemCommand(item);
3328
3011
  };
3012
+
3329
3013
  const selectIndexRestoreFocus = async (menu, item) => {
3330
- await Promise.all([hide(/* restoreFocus */true), executeMenuItemCommand(item)]);
3014
+ await hide(/* restoreFocus */true);
3015
+ await executeMenuItemCommand(item);
3331
3016
  };
3017
+
3332
3018
  const selectIndexSubMenu = async (menu, item, index) => {
3333
3019
  if (menu.focusedIndex === index) {
3334
3020
  return;
3335
3021
  }
3336
3022
  await showSubMenu(menu.level, menu.focusedIndex);
3337
3023
  };
3338
- const selectIndexDefault = async () => {};
3339
- const selectIndexIgnore = async (menu, item) => {
3340
- await executeMenuItemCommand(item);
3341
- };
3024
+
3342
3025
  const getSelectIndexFunction = flags => {
3343
3026
  switch (flags) {
3027
+ case Checked$1:
3028
+ return selectIndexRestoreFocus;
3029
+ case Ignore$1:
3030
+ return selectIndexIgnore;
3344
3031
  case None$1:
3345
3032
  return selectIndexNone;
3033
+ case RestoreFocus$1:
3034
+ return selectIndexRestoreFocus;
3346
3035
  case SubMenu$1:
3347
3036
  return selectIndexSubMenu;
3348
- case RestoreFocus$1:
3037
+ case Unchecked$1:
3349
3038
  return selectIndexRestoreFocus;
3350
- case Ignore$1:
3351
- return selectIndexIgnore;
3352
3039
  default:
3353
3040
  return selectIndexDefault;
3354
3041
  }
3355
3042
  };
3043
+
3356
3044
  const selectIndex = async (level, index) => {
3357
3045
  const menu = get$1(level);
3358
3046
  // TODO avoid assignment
@@ -3421,31 +3109,15 @@ const commandMap = {
3421
3109
  'Menu.showSubMenu': showSubMenu
3422
3110
  };
3423
3111
 
3424
- const send = port => {
3425
- return sendMessagePortToRendererProcess(port);
3426
- };
3427
- const createRendererProcessRpc = async () => {
3428
- try {
3429
- const rpc = await TransferMessagePortRpcParent.create({
3430
- commandMap: {},
3431
- send
3432
- });
3433
- return rpc;
3434
- } catch (error) {
3435
- throw new VError(error, `Failed to create renderer process rpc`);
3436
- }
3437
- };
3438
-
3439
- const initializeRendererProcess = async () => {
3440
- const rpc = await createRendererProcessRpc();
3441
- set$3(rpc);
3442
- };
3443
-
3444
- const listen = async () => {
3445
- const rpc = await WebWorkerRpcClient.create({
3112
+ const initializeRendererWorker = async () => {
3113
+ const rpc = await create$2({
3446
3114
  commandMap: commandMap
3447
3115
  });
3448
3116
  set$2(rpc);
3117
+ };
3118
+
3119
+ const listen = async () => {
3120
+ await initializeRendererWorker();
3449
3121
  await initializeRendererProcess();
3450
3122
  };
3451
3123