@lvce-editor/title-bar-worker 3.10.0 → 3.11.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.
@@ -462,7 +462,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
462
462
  return promise;
463
463
  };
464
464
  const Message$1 = 3;
465
- const create$5$1 = async ({
465
+ const create$5 = async ({
466
466
  isMessagePortOpen,
467
467
  messagePort
468
468
  }) => {
@@ -513,61 +513,19 @@ const wrap$5 = messagePort => {
513
513
  };
514
514
  const IpcParentWithMessagePort$1 = {
515
515
  __proto__: null,
516
- create: create$5$1,
516
+ create: create$5,
517
517
  signal: signal$1,
518
518
  wrap: wrap$5
519
519
  };
520
520
 
521
- const Two = '2.0';
522
- const create$4$1 = (method, params) => {
523
- return {
524
- jsonrpc: Two,
525
- method,
526
- params
527
- };
528
- };
521
+ const Two$1 = '2.0';
529
522
  const callbacks = Object.create(null);
530
- const set$3 = (id, fn) => {
531
- callbacks[id] = fn;
532
- };
533
523
  const get$2 = id => {
534
524
  return callbacks[id];
535
525
  };
536
526
  const remove = id => {
537
527
  delete callbacks[id];
538
528
  };
539
- let id = 0;
540
- const create$3$1 = () => {
541
- return ++id;
542
- };
543
- const registerPromise = () => {
544
- const id = create$3$1();
545
- const {
546
- resolve,
547
- promise
548
- } = Promise.withResolvers();
549
- set$3(id, resolve);
550
- return {
551
- id,
552
- promise
553
- };
554
- };
555
- const create$2$1 = (method, params) => {
556
- const {
557
- id,
558
- promise
559
- } = registerPromise();
560
- const message = {
561
- jsonrpc: Two,
562
- method,
563
- params,
564
- id
565
- };
566
- return {
567
- message,
568
- promise
569
- };
570
- };
571
529
  class JsonRpcError extends Error {
572
530
  constructor(message) {
573
531
  super(message);
@@ -761,9 +719,9 @@ const getErrorProperty = (error, prettyError) => {
761
719
  }
762
720
  };
763
721
  };
764
- const create$1$1 = (id, error) => {
722
+ const create$1$2 = (id, error) => {
765
723
  return {
766
- jsonrpc: Two,
724
+ jsonrpc: Two$1,
767
725
  id,
768
726
  error
769
727
  };
@@ -772,22 +730,22 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
772
730
  const prettyError = preparePrettyError(error);
773
731
  logError(error, prettyError);
774
732
  const errorProperty = getErrorProperty(error, prettyError);
775
- return create$1$1(id, errorProperty);
733
+ return create$1$2(id, errorProperty);
776
734
  };
777
- const create$6 = (message, result) => {
735
+ const create$3 = (message, result) => {
778
736
  return {
779
- jsonrpc: Two,
737
+ jsonrpc: Two$1,
780
738
  id: message.id,
781
739
  result: result ?? null
782
740
  };
783
741
  };
784
742
  const getSuccessResponse = (message, result) => {
785
743
  const resultProperty = result ?? null;
786
- return create$6(message, resultProperty);
744
+ return create$3(message, resultProperty);
787
745
  };
788
746
  const getErrorResponseSimple = (id, error) => {
789
747
  return {
790
- jsonrpc: Two,
748
+ jsonrpc: Two$1,
791
749
  id,
792
750
  error: {
793
751
  code: Custom,
@@ -874,29 +832,6 @@ const handleJsonRpcMessage = async (...args) => {
874
832
  }
875
833
  throw new JsonRpcError('unexpected message');
876
834
  };
877
- const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
878
- const {
879
- message,
880
- promise
881
- } = create$2$1(method, params);
882
- if (useSendAndTransfer && ipc.sendAndTransfer) {
883
- ipc.sendAndTransfer(message);
884
- } else {
885
- ipc.send(message);
886
- }
887
- const responseMessage = await promise;
888
- return unwrapJsonRpcResult(responseMessage);
889
- };
890
- const send = (transport, method, ...params) => {
891
- const message = create$4$1(method, params);
892
- transport.send(message);
893
- };
894
- const invoke$1 = (ipc, method, ...params) => {
895
- return invokeHelper(ipc, method, params, false);
896
- };
897
- const invokeAndTransfer$1 = (ipc, method, ...params) => {
898
- return invokeHelper(ipc, method, params, true);
899
- };
900
835
 
901
836
  class CommandNotFoundError extends Error {
902
837
  constructor(command) {
@@ -919,24 +854,87 @@ const execute = (command, ...args) => {
919
854
  return fn(...args);
920
855
  };
921
856
 
857
+ const Two = '2.0';
858
+ const create$s = (method, params) => {
859
+ return {
860
+ jsonrpc: Two,
861
+ method,
862
+ params
863
+ };
864
+ };
865
+ const create$r = (id, method, params) => {
866
+ const message = {
867
+ id,
868
+ jsonrpc: Two,
869
+ method,
870
+ params
871
+ };
872
+ return message;
873
+ };
874
+ let id = 0;
875
+ const create$q = () => {
876
+ return ++id;
877
+ };
878
+
879
+ /* eslint-disable n/no-unsupported-features/es-syntax */
880
+
881
+ const registerPromise = map => {
882
+ const id = create$q();
883
+ const {
884
+ promise,
885
+ resolve
886
+ } = Promise.withResolvers();
887
+ map[id] = resolve;
888
+ return {
889
+ id,
890
+ promise
891
+ };
892
+ };
893
+
894
+ // @ts-ignore
895
+ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
896
+ const {
897
+ id,
898
+ promise
899
+ } = registerPromise(callbacks);
900
+ const message = create$r(id, method, params);
901
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
902
+ ipc.sendAndTransfer(message);
903
+ } else {
904
+ ipc.send(message);
905
+ }
906
+ const responseMessage = await promise;
907
+ return unwrapJsonRpcResult(responseMessage);
908
+ };
922
909
  const createRpc = ipc => {
910
+ const callbacks = Object.create(null);
911
+ ipc._resolve = (id, response) => {
912
+ const fn = callbacks[id];
913
+ if (!fn) {
914
+ console.warn(`callback ${id} may already be disposed`);
915
+ return;
916
+ }
917
+ fn(response);
918
+ delete callbacks[id];
919
+ };
923
920
  const rpc = {
921
+ async dispose() {
922
+ await ipc?.dispose();
923
+ },
924
+ invoke(method, ...params) {
925
+ return invokeHelper(callbacks, ipc, method, params, false);
926
+ },
927
+ invokeAndTransfer(method, ...params) {
928
+ return invokeHelper(callbacks, ipc, method, params, true);
929
+ },
924
930
  // @ts-ignore
925
931
  ipc,
926
932
  /**
927
933
  * @deprecated
928
934
  */
929
935
  send(method, ...params) {
930
- send(ipc, method, ...params);
931
- },
932
- invoke(method, ...params) {
933
- return invoke$1(ipc, method, ...params);
934
- },
935
- invokeAndTransfer(method, ...params) {
936
- return invokeAndTransfer$1(ipc, method, ...params);
937
- },
938
- async dispose() {
939
- await ipc?.dispose();
936
+ const message = create$s(method, params);
937
+ ipc.send(message);
940
938
  }
941
939
  };
942
940
  return rpc;
@@ -953,7 +951,7 @@ const logError = () => {
953
951
  const handleMessage = event => {
954
952
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
955
953
  const actualExecute = event?.target?.execute || execute;
956
- return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
954
+ return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
957
955
  };
958
956
  const handleIpc = ipc => {
959
957
  if ('addEventListener' in ipc) {
@@ -971,15 +969,16 @@ const listen$1 = async (module, options) => {
971
969
  const ipc = module.wrap(rawIpc);
972
970
  return ipc;
973
971
  };
974
- const create$5 = async ({
972
+ const create$4 = async ({
975
973
  commandMap,
974
+ isMessagePortOpen = true,
976
975
  messagePort
977
976
  }) => {
978
977
  // TODO create a commandMap per rpc instance
979
978
  register(commandMap);
980
979
  const rawIpc = await IpcParentWithMessagePort$1.create({
981
- messagePort,
982
- isMessagePortOpen: true
980
+ isMessagePortOpen,
981
+ messagePort
983
982
  });
984
983
  const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
985
984
  handleIpc(ipc);
@@ -987,8 +986,9 @@ const create$5 = async ({
987
986
  messagePort.start();
988
987
  return rpc;
989
988
  };
990
- const create$3 = async ({
989
+ const create$2$1 = async ({
991
990
  commandMap,
991
+ isMessagePortOpen,
992
992
  send
993
993
  }) => {
994
994
  const {
@@ -996,16 +996,17 @@ const create$3 = async ({
996
996
  port2
997
997
  } = new MessageChannel();
998
998
  await send(port1);
999
- return create$5({
999
+ return create$4({
1000
1000
  commandMap,
1001
+ isMessagePortOpen,
1001
1002
  messagePort: port2
1002
1003
  });
1003
1004
  };
1004
1005
  const TransferMessagePortRpcParent = {
1005
1006
  __proto__: null,
1006
- create: create$3
1007
+ create: create$2$1
1007
1008
  };
1008
- const create$4 = async ({
1009
+ const create$1$1 = async ({
1009
1010
  commandMap
1010
1011
  }) => {
1011
1012
  // TODO create a commandMap per rpc instance
@@ -1017,14 +1018,25 @@ const create$4 = async ({
1017
1018
  };
1018
1019
  const WebWorkerRpcClient = {
1019
1020
  __proto__: null,
1020
- create: create$4
1021
+ create: create$1$1
1021
1022
  };
1022
1023
 
1023
1024
  const ContentInfo = 'contentinfo';
1025
+ const Menu$1 = 'menu';
1026
+ const MenuBar$1 = 'menubar';
1027
+ const MenuItem$1 = 'menuitem';
1028
+ const MenuItemCheckBox = 'menuitemcheckbox';
1029
+ const None$1 = 'none';
1030
+ const Separator$2 = 'separator';
1024
1031
 
1025
- const Div$1 = 4;
1032
+ const Button$1 = 1;
1033
+ const Div = 4;
1034
+ const Span = 8;
1035
+ const Text = 12;
1036
+ const I = 16;
1037
+ const Img = 17;
1026
1038
 
1027
- const Button$1 = 'event.button';
1039
+ const Button = 'event.button';
1028
1040
  const ClientX = 'event.clientX';
1029
1041
  const ClientY = 'event.clientY';
1030
1042
  const TargetName = 'event.target.name';
@@ -1032,16 +1044,16 @@ const TargetName = 'event.target.name';
1032
1044
  const Backspace$1 = 1;
1033
1045
  const Tab$1 = 2;
1034
1046
  const Enter$1 = 3;
1035
- const Escape$2 = 8;
1036
- const Space$2 = 9;
1047
+ const Escape$1 = 8;
1048
+ const Space$1 = 9;
1037
1049
  const PageUp$1 = 10;
1038
1050
  const PageDown$1 = 11;
1039
- const End$2 = 255;
1040
- const Home$2 = 12;
1041
- const LeftArrow$2 = 13;
1042
- const UpArrow$2 = 14;
1043
- const RightArrow$2 = 15;
1044
- const DownArrow$2 = 16;
1051
+ const End$1 = 255;
1052
+ const Home$1 = 12;
1053
+ const LeftArrow$1 = 13;
1054
+ const UpArrow$1 = 14;
1055
+ const RightArrow$1 = 15;
1056
+ const DownArrow$1 = 16;
1045
1057
  const Insert$1 = 17;
1046
1058
  const Delete$1 = 18;
1047
1059
  const Digit0$1 = 19;
@@ -1098,16 +1110,16 @@ const Unknown = 'Unknown';
1098
1110
  const Backspace = 'Backspace';
1099
1111
  const Tab = 'Tab';
1100
1112
  const Enter = 'Enter';
1101
- const Escape$1 = 'Escape';
1102
- const Space$1 = 'Space';
1113
+ const Escape = 'Escape';
1114
+ const Space = 'Space';
1103
1115
  const PageUp = 'PageUp';
1104
1116
  const PageDown = 'PageDown';
1105
- const End$1 = 'End';
1106
- const Home$1 = 'Home';
1107
- const LeftArrow$1 = 'LeftArrow';
1108
- const UpArrow$1 = 'UpArrow';
1109
- const RightArrow$1 = 'RightArrow';
1110
- const DownArrow$1 = 'DownArrow';
1117
+ const End = 'End';
1118
+ const Home = 'Home';
1119
+ const LeftArrow = 'LeftArrow';
1120
+ const UpArrow = 'UpArrow';
1121
+ const RightArrow = 'RightArrow';
1122
+ const DownArrow = 'DownArrow';
1111
1123
  const Insert = 'Insert';
1112
1124
  const Delete = 'Delete';
1113
1125
  const Digit0 = '0';
@@ -1192,16 +1204,16 @@ const getKeyCodeString = keyCode => {
1192
1204
  return Digit8;
1193
1205
  case Digit9$1:
1194
1206
  return Digit9;
1195
- case DownArrow$2:
1196
- return DownArrow$1;
1197
- case End$2:
1198
- return End$1;
1207
+ case DownArrow$1:
1208
+ return DownArrow;
1209
+ case End$1:
1210
+ return End;
1199
1211
  case Enter$1:
1200
1212
  return Enter;
1201
1213
  case Equal$1:
1202
1214
  return Equal;
1203
- case Escape$2:
1204
- return Escape$1;
1215
+ case Escape$1:
1216
+ return Escape;
1205
1217
  case F1$1:
1206
1218
  return F1;
1207
1219
  case F2$1:
@@ -1214,8 +1226,8 @@ const getKeyCodeString = keyCode => {
1214
1226
  return F5;
1215
1227
  case F6$1:
1216
1228
  return F6;
1217
- case Home$2:
1218
- return Home$1;
1229
+ case Home$1:
1230
+ return Home;
1219
1231
  case Insert$1:
1220
1232
  return Insert;
1221
1233
  case KeyA$1:
@@ -1270,8 +1282,8 @@ const getKeyCodeString = keyCode => {
1270
1282
  return KeyY;
1271
1283
  case KeyZ$1:
1272
1284
  return KeyZ;
1273
- case LeftArrow$2:
1274
- return LeftArrow$1;
1285
+ case LeftArrow$1:
1286
+ return LeftArrow;
1275
1287
  case Minus$1:
1276
1288
  return Minus;
1277
1289
  case PageDown$1:
@@ -1280,16 +1292,16 @@ const getKeyCodeString = keyCode => {
1280
1292
  return PageUp;
1281
1293
  case Plus$1:
1282
1294
  return Plus;
1283
- case RightArrow$2:
1284
- return RightArrow$1;
1285
- case Space$2:
1286
- return Space$1;
1295
+ case RightArrow$1:
1296
+ return RightArrow;
1297
+ case Space$1:
1298
+ return Space;
1287
1299
  case Star$1:
1288
1300
  return Star;
1289
1301
  case Tab$1:
1290
1302
  return Tab;
1291
- case UpArrow$2:
1292
- return UpArrow$1;
1303
+ case UpArrow$1:
1304
+ return UpArrow;
1293
1305
  default:
1294
1306
  return Unknown;
1295
1307
  }
@@ -1328,6 +1340,9 @@ const Electron$1 = 2;
1328
1340
 
1329
1341
  const RendererWorker = 1;
1330
1342
 
1343
+ const FocusSelector = 'Viewlet.focusSelector';
1344
+ const SetDom2 = 'Viewlet.setDom2';
1345
+
1331
1346
  const FocusTitleBarMenuBar = 26;
1332
1347
 
1333
1348
  const rpcs = Object.create(null);
@@ -1489,6 +1504,7 @@ const createDefaultState = (uid = DEFAULT_UID) => ({
1489
1504
  commandCenterEnabled: false,
1490
1505
  commandMap: {},
1491
1506
  controlsOverlayEnabled: false,
1507
+ focused: false,
1492
1508
  focusedIndex: -1,
1493
1509
  height: 30,
1494
1510
  iconWidth: 30,
@@ -1547,7 +1563,7 @@ const CheckForUpdates = 'Check For Updates';
1547
1563
  const ClearRecentlyOpened = 'Clear Recently Opened';
1548
1564
  const Close = 'Close';
1549
1565
  const Exit = 'Exit';
1550
- const MenuBar$1 = 'Menu Bar';
1566
+ const MenuBar = 'Menu Bar';
1551
1567
  const CommandCenter = 'Command Center';
1552
1568
  const Edit$1 = 'Edit';
1553
1569
  const File$2 = 'File';
@@ -1619,7 +1635,7 @@ const close$1 = () => {
1619
1635
  return i18nString(Close);
1620
1636
  };
1621
1637
  const menuBar = () => {
1622
- return i18nString(MenuBar$1);
1638
+ return i18nString(MenuBar);
1623
1639
  };
1624
1640
  const commandCenter = () => {
1625
1641
  return i18nString(CommandCenter);
@@ -1713,6 +1729,7 @@ const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled,
1713
1729
  commandCenterEnabled: false,
1714
1730
  commandMap: {},
1715
1731
  controlsOverlayEnabled,
1732
+ focused: false,
1716
1733
  focusedIndex: -1,
1717
1734
  height,
1718
1735
  iconWidth: 30,
@@ -1740,11 +1757,16 @@ const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled,
1740
1757
  const RenderEntries = 1;
1741
1758
  const RenderFocusedIndex = 2;
1742
1759
  const RenderMenus = 3;
1760
+ const RenderFocusContext = 4;
1743
1761
 
1744
- const isEqual$3 = (oldState, newState) => {
1762
+ const isEqual$4 = (oldState, newState) => {
1745
1763
  return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
1746
1764
  };
1747
1765
 
1766
+ const isEqual$3 = (oldState, newState) => {
1767
+ return oldState.focused === newState.focused;
1768
+ };
1769
+
1748
1770
  const isEqual$2 = (oldState, newState) => {
1749
1771
  return oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
1750
1772
  };
@@ -1753,8 +1775,8 @@ const isEqual$1 = (oldState, newState) => {
1753
1775
  return oldState.menus === newState.menus;
1754
1776
  };
1755
1777
 
1756
- const modules$1 = [isEqual$3, isEqual$2, isEqual$1];
1757
- const numbers$1 = [RenderEntries, RenderFocusedIndex, RenderMenus];
1778
+ const modules$1 = [isEqual$4, isEqual$2, isEqual$1, isEqual$3];
1779
+ const numbers$1 = [RenderEntries, RenderFocusedIndex, RenderMenus, RenderFocusContext];
1758
1780
 
1759
1781
  const diff = (oldState, newState) => {
1760
1782
  const diffResult = [];
@@ -1797,8 +1819,8 @@ const diff3 = uid => {
1797
1819
  return diffResult;
1798
1820
  };
1799
1821
 
1800
- const Separator$2 = 1;
1801
- const None$1 = 0;
1822
+ const Separator$1 = 1;
1823
+ const None = 0;
1802
1824
  const SubMenu$1 = 4;
1803
1825
  const Checked = 2;
1804
1826
  const Unchecked = 3;
@@ -1901,7 +1923,7 @@ const selectAllOccurrences = () => {
1901
1923
 
1902
1924
  const menuEntrySeparator = {
1903
1925
  command: '',
1904
- flags: Separator$2,
1926
+ flags: Separator$1,
1905
1927
  id: 'separator',
1906
1928
  label: ''
1907
1929
  };
@@ -1909,37 +1931,37 @@ const menuEntrySeparator = {
1909
1931
  const getMenuEntries$c = () => {
1910
1932
  return [{
1911
1933
  command: /* TODO */'-1',
1912
- flags: None$1,
1934
+ flags: None,
1913
1935
  id: 'undo',
1914
1936
  label: undo()
1915
1937
  }, {
1916
1938
  command: /* TODO */'-1',
1917
- flags: None$1,
1939
+ flags: None,
1918
1940
  id: 'redo',
1919
1941
  label: redo()
1920
1942
  }, menuEntrySeparator, {
1921
1943
  command: /* Editor.cut */'Editor.cut',
1922
- flags: None$1,
1944
+ flags: None,
1923
1945
  id: 'cut',
1924
1946
  label: cut()
1925
1947
  }, {
1926
1948
  command: /* Editor.copy */'Editor.copy',
1927
- flags: None$1,
1949
+ flags: None,
1928
1950
  id: 'copy',
1929
1951
  label: copy()
1930
1952
  }, {
1931
1953
  command: /* Editor.paste */'Editor.paste',
1932
- flags: None$1,
1954
+ flags: None,
1933
1955
  id: 'paste',
1934
1956
  label: paste()
1935
1957
  }, menuEntrySeparator, {
1936
1958
  command: /* Editor.toggleLineComment */'Editor.toggleLineComment',
1937
- flags: None$1,
1959
+ flags: None,
1938
1960
  id: 'toggle-line-comment',
1939
1961
  label: toggleLineComment()
1940
1962
  }, {
1941
1963
  command: /* Editor.toggleBlockComment */'Editor.toggleBlockComment',
1942
- flags: None$1,
1964
+ flags: None,
1943
1965
  id: 'toggle-block-comment',
1944
1966
  label: toggleBlockComment()
1945
1967
  }];
@@ -1996,17 +2018,17 @@ const View = 16;
1996
2018
  const getMenuEntries$b = platform => {
1997
2019
  const entries = [{
1998
2020
  command: '-1',
1999
- flags: None$1,
2021
+ flags: None,
2000
2022
  id: 'newFile',
2001
2023
  label: newFile()
2002
2024
  }, {
2003
2025
  command: 'Window.openNew',
2004
- flags: None$1,
2026
+ flags: None,
2005
2027
  id: 'newWindow',
2006
2028
  label: newWindow()
2007
2029
  }, menuEntrySeparator, {
2008
2030
  command: 'Dialog.openFile',
2009
- flags: None$1,
2031
+ flags: None,
2010
2032
  id: 'openFile',
2011
2033
  label: openFile()
2012
2034
  }, {
@@ -2021,12 +2043,12 @@ const getMenuEntries$b = platform => {
2021
2043
  label: openRecent()
2022
2044
  }, menuEntrySeparator, {
2023
2045
  command: 'Main.save',
2024
- flags: None$1,
2046
+ flags: None,
2025
2047
  id: 'save',
2026
2048
  label: save()
2027
2049
  }, {
2028
2050
  command: 'Main.saveAll',
2029
- flags: None$1,
2051
+ flags: None,
2030
2052
  id: 'saveAll',
2031
2053
  label: saveAll()
2032
2054
  }];
@@ -2071,7 +2093,7 @@ const getMenuEntries$9 = async platform => {
2071
2093
  if (platform !== Web) {
2072
2094
  entries.push({
2073
2095
  command: 'Developer.toggleDeveloperTools',
2074
- flags: None$1,
2096
+ flags: None,
2075
2097
  id: 'toggleDeveloperTools',
2076
2098
  label: toggleDeveloperTools()
2077
2099
  }, {
@@ -2094,7 +2116,7 @@ const getMenuEntries$9 = async platform => {
2094
2116
  }
2095
2117
  entries.push({
2096
2118
  command: 'About.showAbout',
2097
- flags: None$1,
2119
+ flags: None,
2098
2120
  id: 'about',
2099
2121
  label: about()
2100
2122
  });
@@ -2135,7 +2157,7 @@ const toMenuItem = folder => {
2135
2157
  return {
2136
2158
  args: [folder],
2137
2159
  command: 'Workspace.setPath',
2138
- flags: None$1,
2160
+ flags: None,
2139
2161
  label
2140
2162
  };
2141
2163
  };
@@ -2148,12 +2170,12 @@ const getMenuEntries$8 = async () => {
2148
2170
  }
2149
2171
  items.push({
2150
2172
  command: 'QuickPick.showRecent',
2151
- flags: None$1,
2173
+ flags: None,
2152
2174
  id: 'more',
2153
2175
  label: moreDot()
2154
2176
  }, menuEntrySeparator, {
2155
2177
  command: 'RecentlyOpened.clearRecentlyOpened',
2156
- flags: None$1,
2178
+ flags: None,
2157
2179
  id: 'clearRecentlyOpened',
2158
2180
  label: clearRecentlyOpened()
2159
2181
  });
@@ -2167,72 +2189,72 @@ const getMenuEntries$7 = () => {
2167
2189
  const getMenuEntries$6 = () => {
2168
2190
  return [{
2169
2191
  command: 'Editor.selectAll',
2170
- flags: None$1,
2192
+ flags: None,
2171
2193
  id: 'selectAll',
2172
2194
  label: selectAll()
2173
2195
  }, {
2174
2196
  command: 'Editor.expandSelection',
2175
- flags: None$1,
2197
+ flags: None,
2176
2198
  id: 'expandSelection',
2177
2199
  label: expandSelection()
2178
2200
  }, {
2179
2201
  command: 'Editor.shrinkSelection',
2180
- flags: None$1,
2202
+ flags: None,
2181
2203
  id: 'shrinkSelection',
2182
2204
  label: shrinkSelection()
2183
2205
  }, menuEntrySeparator, {
2184
2206
  command: 'Editor.copyLineUp',
2185
- flags: None$1,
2207
+ flags: None,
2186
2208
  id: 'copyLineUp',
2187
2209
  label: copyLineUp()
2188
2210
  }, {
2189
2211
  command: 'Editor.copyLineDown',
2190
- flags: None$1,
2212
+ flags: None,
2191
2213
  id: 'copyLineDown',
2192
2214
  label: copyLineDown()
2193
2215
  }, {
2194
2216
  command: 'Editor.moveLineUp',
2195
- flags: None$1,
2217
+ flags: None,
2196
2218
  id: 'moveLineUp',
2197
2219
  label: moveLineUp()
2198
2220
  }, {
2199
2221
  command: 'Editor.moveLineDown',
2200
- flags: None$1,
2222
+ flags: None,
2201
2223
  id: 'moveLineDown',
2202
2224
  label: moveLineDown()
2203
2225
  }, {
2204
2226
  command: 'Editor.duplicateSelection',
2205
- flags: None$1,
2227
+ flags: None,
2206
2228
  id: 'duplicateSelection',
2207
2229
  label: duplicateSelection()
2208
2230
  }, menuEntrySeparator, {
2209
2231
  command: 'Editor.addCursorAbove',
2210
- flags: None$1,
2232
+ flags: None,
2211
2233
  id: 'addCursorAbove',
2212
2234
  label: addCursorAbove()
2213
2235
  }, {
2214
2236
  command: 'Editor.addCursorBelow',
2215
- flags: None$1,
2237
+ flags: None,
2216
2238
  id: 'addCursorBelow',
2217
2239
  label: addCursorBelow()
2218
2240
  }, {
2219
2241
  command: 'Editor.addCursorsToLineEnds',
2220
- flags: None$1,
2242
+ flags: None,
2221
2243
  id: 'addCursorsToLineEnds',
2222
2244
  label: addCursorsToLineEnds()
2223
2245
  }, {
2224
2246
  command: 'Editor.addNextOccurrence',
2225
- flags: None$1,
2247
+ flags: None,
2226
2248
  id: 'addNextOccurrence',
2227
2249
  label: addNextOccurrence()
2228
2250
  }, {
2229
2251
  command: 'Editor.addPreviousOccurrence',
2230
- flags: None$1,
2252
+ flags: None,
2231
2253
  id: 'addPreviousOccurrence',
2232
2254
  label: addPreviousOccurrence()
2233
2255
  }, {
2234
2256
  command: 'Editor.selectAllOccurrences',
2235
- flags: None$1,
2257
+ flags: None,
2236
2258
  id: 'selectAllOccurrences',
2237
2259
  label: selectAllOccurrences()
2238
2260
  }];
@@ -2242,7 +2264,7 @@ const getMenuEntries$5 = () => {
2242
2264
  return [{
2243
2265
  args: ['Terminal'],
2244
2266
  command: 'Layout.togglePanel',
2245
- flags: None$1,
2267
+ flags: None,
2246
2268
  id: 'newTerminal',
2247
2269
  label: i18nString(NewTerminal)
2248
2270
  }];
@@ -2298,32 +2320,32 @@ const getMenuEntries$4 = () => {
2298
2320
  const getMenuEntries$3 = () => {
2299
2321
  return [{
2300
2322
  command: '',
2301
- flags: None$1,
2323
+ flags: None,
2302
2324
  id: File$1,
2303
2325
  label: file()
2304
2326
  }, {
2305
2327
  command: '',
2306
- flags: None$1,
2328
+ flags: None,
2307
2329
  id: Edit,
2308
2330
  label: edit()
2309
2331
  }, {
2310
2332
  command: '',
2311
- flags: None$1,
2333
+ flags: None,
2312
2334
  id: Selection,
2313
2335
  label: selection()
2314
2336
  }, {
2315
2337
  command: '',
2316
- flags: None$1,
2338
+ flags: None,
2317
2339
  id: View,
2318
2340
  label: view()
2319
2341
  }, {
2320
2342
  command: '',
2321
- flags: None$1,
2343
+ flags: None,
2322
2344
  id: Go,
2323
2345
  label: go()
2324
2346
  }, {
2325
2347
  command: '',
2326
- flags: None$1,
2348
+ flags: None,
2327
2349
  id: Help$1,
2328
2350
  label: help()
2329
2351
  }];
@@ -2411,7 +2433,7 @@ const FileMenu = 'fileMenu';
2411
2433
  const EditMenu = 'editMenu';
2412
2434
 
2413
2435
  // based on https://www.electronjs.org/docs/latest/api/menu-item#new-menuitemoptions
2414
- const Separator$1 = 'separator';
2436
+ const Separator = 'separator';
2415
2437
  const SubMenu = 'submenu';
2416
2438
 
2417
2439
  const toElectronMenuItem = entry => {
@@ -2476,9 +2498,9 @@ const toElectronMenuItem = entry => {
2476
2498
  };
2477
2499
  }
2478
2500
  switch (entry.flags) {
2479
- case Separator$2:
2501
+ case Separator$1:
2480
2502
  return {
2481
- type: Separator$1
2503
+ type: Separator
2482
2504
  };
2483
2505
  case SubMenu$1:
2484
2506
  return {
@@ -2553,29 +2575,6 @@ const hydrate = async state => {
2553
2575
  };
2554
2576
  };
2555
2577
 
2556
- const Menu$1 = 'menu';
2557
- const MenuBar = 'menubar';
2558
- const MenuItem$1 = 'menuitem';
2559
- const MenuItemCheckBox = 'menuitemcheckbox';
2560
- const None = 'none';
2561
- const Separator = 'separator';
2562
-
2563
- const Button = 1;
2564
- const Div = 4;
2565
- const Span = 8;
2566
- const Text = 12;
2567
- const I = 16;
2568
- const Img = 17;
2569
-
2570
- const Escape = 8;
2571
- const Space = 9;
2572
- const End = 255;
2573
- const Home = 12;
2574
- const LeftArrow = 13;
2575
- const UpArrow = 14;
2576
- const RightArrow = 15;
2577
- const DownArrow = 16;
2578
-
2579
2578
  const mergeClassNames = (...classNames) => {
2580
2579
  return classNames.filter(Boolean).join(' ');
2581
2580
  };
@@ -2586,44 +2585,44 @@ const px = value => {
2586
2585
 
2587
2586
  const text = data => {
2588
2587
  return {
2589
- type: Text,
2588
+ childCount: 0,
2590
2589
  text: data,
2591
- childCount: 0
2590
+ type: Text
2592
2591
  };
2593
2592
  };
2594
2593
 
2595
2594
  const getKeyBindings = () => {
2596
2595
  return [{
2597
2596
  command: 'TitleBar.handleKeyArrowDown',
2598
- key: DownArrow,
2597
+ key: DownArrow$1,
2599
2598
  when: FocusTitleBarMenuBar
2600
2599
  }, {
2601
2600
  command: 'TitleBar.handleKeyArrowUp',
2602
- key: UpArrow,
2601
+ key: UpArrow$1,
2603
2602
  when: FocusTitleBarMenuBar
2604
2603
  }, {
2605
2604
  command: 'TitleBar.handleKeyArrowRight',
2606
- key: RightArrow,
2605
+ key: RightArrow$1,
2607
2606
  when: FocusTitleBarMenuBar
2608
2607
  }, {
2609
2608
  command: 'TitleBar.handleKeyArrowLeft',
2610
- key: LeftArrow,
2609
+ key: LeftArrow$1,
2611
2610
  when: FocusTitleBarMenuBar
2612
2611
  }, {
2613
2612
  command: 'TitleBar.handleKeySpace',
2614
- key: Space,
2613
+ key: Space$1,
2615
2614
  when: FocusTitleBarMenuBar
2616
2615
  }, {
2617
2616
  command: 'TitleBar.handleKeyHome',
2618
- key: Home,
2617
+ key: Home$1,
2619
2618
  when: FocusTitleBarMenuBar
2620
2619
  }, {
2621
2620
  command: 'TitleBar.handleKeyEnd',
2622
- key: End,
2621
+ key: End$1,
2623
2622
  when: FocusTitleBarMenuBar
2624
2623
  }, {
2625
2624
  command: 'TitleBar.handleKeyEscape',
2626
- key: Escape,
2625
+ key: Escape$1,
2627
2626
  when: FocusTitleBarMenuBar
2628
2627
  }];
2629
2628
  };
@@ -2732,7 +2731,7 @@ const getMenuHeight = items => {
2732
2731
  let height = CONTEXT_MENU_PADDING;
2733
2732
  for (const item of items) {
2734
2733
  switch (item.flags) {
2735
- case Separator$2:
2734
+ case Separator$1:
2736
2735
  height += CONTEXT_MENU_SEPARATOR_HEIGHT;
2737
2736
  break;
2738
2737
  default:
@@ -2789,7 +2788,7 @@ const getIndexToFocusPrevious = menu => {
2789
2788
  const canBeFocused = item => {
2790
2789
  switch (item.flags) {
2791
2790
  case Disabled:
2792
- case Separator$2:
2791
+ case Separator$1:
2793
2792
  return false;
2794
2793
  default:
2795
2794
  return true;
@@ -3084,7 +3083,7 @@ const renderFocusedIndex = (oldState, newState) => {
3084
3083
  if (newState.focusedIndex === -1) {
3085
3084
  return [];
3086
3085
  }
3087
- return ['Viewlet.focusSelector', '.ViewletTitleBarMenuBar'];
3086
+ return [FocusSelector, '.ViewletTitleBarMenuBar'];
3088
3087
  };
3089
3088
 
3090
3089
  const MaskIconCheck = 'MaskIconCheck';
@@ -3195,7 +3194,7 @@ const getMenuItemsNoopDom = () => {
3195
3194
  const separator = {
3196
3195
  childCount: 1,
3197
3196
  className: MenuItemSeparator,
3198
- role: Separator,
3197
+ role: Separator$2,
3199
3198
  type: Div
3200
3199
  };
3201
3200
  const separatorLine = {
@@ -3255,10 +3254,10 @@ const getMenuItemRenderer = flags => {
3255
3254
  case Disabled:
3256
3255
  return getMenuItemDisabledDom;
3257
3256
  case Ignore:
3258
- case None$1:
3257
+ case None:
3259
3258
  case RestoreFocus:
3260
3259
  return getMenuItemDefaultDom;
3261
- case Separator$2:
3260
+ case Separator$1:
3262
3261
  return getMenuItemSeparatorDom;
3263
3262
  case SubMenu$1:
3264
3263
  return getMenuItemSubMenuDom;
@@ -3353,7 +3352,7 @@ const getIconVirtualDom = (icon, type = Div) => {
3353
3352
  return {
3354
3353
  childCount: 0,
3355
3354
  className: `MaskIcon MaskIcon${icon}`,
3356
- role: None,
3355
+ role: None$1,
3357
3356
  type
3358
3357
  };
3359
3358
  };
@@ -3370,7 +3369,7 @@ const createTitleBarButton = button => {
3370
3369
  childCount: 1,
3371
3370
  className: `TitleBarButton TitleBarButton${id}`,
3372
3371
  onClick,
3373
- type: Button
3372
+ type: Button$1
3374
3373
  }, getIconVirtualDom(icon, I)];
3375
3374
  return dom;
3376
3375
  };
@@ -3427,7 +3426,7 @@ const getItemVirtualDom = item => {
3427
3426
  name: label,
3428
3427
  // TODO have separate name attribute
3429
3428
  role: MenuItem$1,
3430
- type: Button
3429
+ type: Button$1
3431
3430
  }, ...(isFocused ? [{
3432
3431
  childCount: 1,
3433
3432
  className: TitleBarTopLevelEntryLabel,
@@ -3453,7 +3452,7 @@ const getTitleBarMenuBarVirtualDom = (menuBarEnabled, visibleItems, focusedIndex
3453
3452
  onMouseDown: HandleClick,
3454
3453
  onPointerOut: HandlePointerOut,
3455
3454
  onPointerOver: HandlePointerOver,
3456
- role: MenuBar,
3455
+ role: MenuBar$1,
3457
3456
  tabIndex: 0,
3458
3457
  type: Div
3459
3458
  }, ...getTitleBarMenuBarItemsVirtualDom(visibleItems)];
@@ -3462,7 +3461,7 @@ const getTitleBarMenuBarVirtualDom = (menuBarEnabled, visibleItems, focusedIndex
3462
3461
  const parentNode = {
3463
3462
  childCount: 1,
3464
3463
  className: 'TitleBarTitle',
3465
- type: Div$1
3464
+ type: Div
3466
3465
  };
3467
3466
  const getTitleVirtualDom = (titleBarTitleEnabled, title) => {
3468
3467
  if (!titleBarTitleEnabled) {
@@ -3530,7 +3529,7 @@ const getTitleBarVirtualDom = state => {
3530
3529
  if (platform === Electron$1 && !titleBarStyleCustom) {
3531
3530
  return [{
3532
3531
  childCount: 0,
3533
- type: Div$1
3532
+ type: Div
3534
3533
  }];
3535
3534
  }
3536
3535
  const iconSrc = getIcon(assetDir);
@@ -3542,13 +3541,13 @@ const getTitleBarVirtualDom = state => {
3542
3541
  className: 'Viewlet TitleBar',
3543
3542
  id: 'TitleBar',
3544
3543
  role: ContentInfo,
3545
- type: Div$1
3544
+ type: Div
3546
3545
  }, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getTitleVirtualDom(titleBarTitleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
3547
3546
  };
3548
3547
 
3549
3548
  const renderTitleBar = (oldState, newState) => {
3550
3549
  const dom = getTitleBarVirtualDom(newState);
3551
- return ['Viewlet.setDom2', newState.uid, dom];
3550
+ return [SetDom2, newState.uid, dom];
3552
3551
  };
3553
3552
 
3554
3553
  const getRenderer3 = diffType => {
@@ -3587,7 +3586,7 @@ const renderEventListeners = () => {
3587
3586
  params: ['handleClickMinimize']
3588
3587
  }, {
3589
3588
  name: HandleContextMenu,
3590
- params: ['handleContextMenu', Button$1, ClientX, ClientY]
3589
+ params: ['handleContextMenu', Button, ClientX, ClientY]
3591
3590
  }, {
3592
3591
  name: HandleClickClose,
3593
3592
  params: ['handleClickClose']
@@ -3605,7 +3604,7 @@ const renderEventListeners = () => {
3605
3604
  params: ['handleMenuMouseOver', ClientX, ClientY]
3606
3605
  }, {
3607
3606
  name: HandleClick,
3608
- params: ['handleClickAt', Button$1, ClientX, ClientY]
3607
+ params: ['handleClickAt', Button, ClientX, ClientY]
3609
3608
  }, {
3610
3609
  name: HandlePointerOut,
3611
3610
  params: ['handlePointerOut', ClientX, ClientY]
@@ -3801,7 +3800,10 @@ const setFocus = async focusKey => {
3801
3800
 
3802
3801
  const handleFocus = async state => {
3803
3802
  await setFocus(FocusTitleBarMenuBar);
3804
- return state;
3803
+ return {
3804
+ ...state,
3805
+ focused: true
3806
+ };
3805
3807
  };
3806
3808
 
3807
3809
  const handleFocusOut = async state => {
@@ -4131,7 +4133,7 @@ const handleMenuClick = async (state, level, index) => {
4131
4133
  switch (item.flags) {
4132
4134
  case Ignore:
4133
4135
  return selectIndexIgnore(state, item);
4134
- case None$1:
4136
+ case None:
4135
4137
  return selectIndexNone(state, item);
4136
4138
  case RestoreFocus:
4137
4139
  return selectIndexRestoreFocus(state, item);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",