@lvce-editor/title-bar-worker 3.10.0 → 3.12.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,10 @@ const Electron$1 = 2;
1328
1340
 
1329
1341
  const RendererWorker = 1;
1330
1342
 
1343
+ const FocusSelector = 'Viewlet.focusSelector';
1344
+ const SetDom2 = 'Viewlet.setDom2';
1345
+ const SetFocusContext = 'Viewlet.setFocusContext';
1346
+
1331
1347
  const FocusTitleBarMenuBar = 26;
1332
1348
 
1333
1349
  const rpcs = Object.create(null);
@@ -1489,6 +1505,7 @@ const createDefaultState = (uid = DEFAULT_UID) => ({
1489
1505
  commandCenterEnabled: false,
1490
1506
  commandMap: {},
1491
1507
  controlsOverlayEnabled: false,
1508
+ focused: false,
1492
1509
  focusedIndex: -1,
1493
1510
  height: 30,
1494
1511
  iconWidth: 30,
@@ -1547,7 +1564,7 @@ const CheckForUpdates = 'Check For Updates';
1547
1564
  const ClearRecentlyOpened = 'Clear Recently Opened';
1548
1565
  const Close = 'Close';
1549
1566
  const Exit = 'Exit';
1550
- const MenuBar$1 = 'Menu Bar';
1567
+ const MenuBar = 'Menu Bar';
1551
1568
  const CommandCenter = 'Command Center';
1552
1569
  const Edit$1 = 'Edit';
1553
1570
  const File$2 = 'File';
@@ -1619,7 +1636,7 @@ const close$1 = () => {
1619
1636
  return i18nString(Close);
1620
1637
  };
1621
1638
  const menuBar = () => {
1622
- return i18nString(MenuBar$1);
1639
+ return i18nString(MenuBar);
1623
1640
  };
1624
1641
  const commandCenter = () => {
1625
1642
  return i18nString(CommandCenter);
@@ -1713,6 +1730,7 @@ const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled,
1713
1730
  commandCenterEnabled: false,
1714
1731
  commandMap: {},
1715
1732
  controlsOverlayEnabled,
1733
+ focused: false,
1716
1734
  focusedIndex: -1,
1717
1735
  height,
1718
1736
  iconWidth: 30,
@@ -1737,50 +1755,29 @@ const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled,
1737
1755
  set(id, state, state);
1738
1756
  };
1739
1757
 
1740
- const RenderEntries = 1;
1741
- const RenderFocusedIndex = 2;
1742
- const RenderMenus = 3;
1743
-
1744
1758
  const isEqual$3 = (oldState, newState) => {
1745
1759
  return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
1746
1760
  };
1747
1761
 
1748
1762
  const isEqual$2 = (oldState, newState) => {
1749
- return oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
1763
+ return oldState.focused || !newState.focused;
1750
1764
  };
1751
1765
 
1752
1766
  const isEqual$1 = (oldState, newState) => {
1753
- return oldState.menus === newState.menus;
1754
- };
1755
-
1756
- const modules$1 = [isEqual$3, isEqual$2, isEqual$1];
1757
- const numbers$1 = [RenderEntries, RenderFocusedIndex, RenderMenus];
1758
-
1759
- const diff = (oldState, newState) => {
1760
- const diffResult = [];
1761
- for (let i = 0; i < modules$1.length; i++) {
1762
- const fn = modules$1[i];
1763
- if (!fn(oldState, newState)) {
1764
- diffResult.push(numbers$1[i]);
1765
- }
1766
- }
1767
- return diffResult;
1768
- };
1769
-
1770
- const diff2 = uid => {
1771
- const {
1772
- newState,
1773
- oldState
1774
- } = get(uid);
1775
- return diff(oldState, newState);
1767
+ return oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen;
1776
1768
  };
1777
1769
 
1778
1770
  const isEqual = (oldState, newState) => {
1779
- return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.assetDir === newState.assetDir && oldState.titleBarIconEnabled === newState.titleBarIconEnabled && oldState.title === newState.title && oldState.titleBarTitleEnabled === newState.titleBarTitleEnabled && oldState.platform === newState.platform && oldState.controlsOverlayEnabled === newState.controlsOverlayEnabled && oldState.titleBarStyleCustom === newState.titleBarStyleCustom && oldState.titleBarButtonsEnabled === newState.titleBarButtonsEnabled && oldState.titleBarButtons === newState.titleBarButtons;
1771
+ return oldState.menus === newState.menus;
1780
1772
  };
1781
1773
 
1782
- const modules = [isEqual, isEqual$2, isEqual$1];
1783
- const numbers = [RenderEntries, RenderFocusedIndex, RenderMenus];
1774
+ const RenderEntries = 1;
1775
+ const RenderFocusedIndex = 2;
1776
+ const RenderMenus = 3;
1777
+ const RenderFocusContext = 4;
1778
+
1779
+ const modules = [isEqual$3, isEqual$1, isEqual, isEqual$2];
1780
+ const numbers = [RenderEntries, RenderFocusedIndex, RenderMenus, RenderFocusContext];
1784
1781
 
1785
1782
  const diff3 = uid => {
1786
1783
  const {
@@ -1797,8 +1794,8 @@ const diff3 = uid => {
1797
1794
  return diffResult;
1798
1795
  };
1799
1796
 
1800
- const Separator$2 = 1;
1801
- const None$1 = 0;
1797
+ const Separator$1 = 1;
1798
+ const None = 0;
1802
1799
  const SubMenu$1 = 4;
1803
1800
  const Checked = 2;
1804
1801
  const Unchecked = 3;
@@ -1901,7 +1898,7 @@ const selectAllOccurrences = () => {
1901
1898
 
1902
1899
  const menuEntrySeparator = {
1903
1900
  command: '',
1904
- flags: Separator$2,
1901
+ flags: Separator$1,
1905
1902
  id: 'separator',
1906
1903
  label: ''
1907
1904
  };
@@ -1909,37 +1906,37 @@ const menuEntrySeparator = {
1909
1906
  const getMenuEntries$c = () => {
1910
1907
  return [{
1911
1908
  command: /* TODO */'-1',
1912
- flags: None$1,
1909
+ flags: None,
1913
1910
  id: 'undo',
1914
1911
  label: undo()
1915
1912
  }, {
1916
1913
  command: /* TODO */'-1',
1917
- flags: None$1,
1914
+ flags: None,
1918
1915
  id: 'redo',
1919
1916
  label: redo()
1920
1917
  }, menuEntrySeparator, {
1921
1918
  command: /* Editor.cut */'Editor.cut',
1922
- flags: None$1,
1919
+ flags: None,
1923
1920
  id: 'cut',
1924
1921
  label: cut()
1925
1922
  }, {
1926
1923
  command: /* Editor.copy */'Editor.copy',
1927
- flags: None$1,
1924
+ flags: None,
1928
1925
  id: 'copy',
1929
1926
  label: copy()
1930
1927
  }, {
1931
1928
  command: /* Editor.paste */'Editor.paste',
1932
- flags: None$1,
1929
+ flags: None,
1933
1930
  id: 'paste',
1934
1931
  label: paste()
1935
1932
  }, menuEntrySeparator, {
1936
1933
  command: /* Editor.toggleLineComment */'Editor.toggleLineComment',
1937
- flags: None$1,
1934
+ flags: None,
1938
1935
  id: 'toggle-line-comment',
1939
1936
  label: toggleLineComment()
1940
1937
  }, {
1941
1938
  command: /* Editor.toggleBlockComment */'Editor.toggleBlockComment',
1942
- flags: None$1,
1939
+ flags: None,
1943
1940
  id: 'toggle-block-comment',
1944
1941
  label: toggleBlockComment()
1945
1942
  }];
@@ -1996,17 +1993,17 @@ const View = 16;
1996
1993
  const getMenuEntries$b = platform => {
1997
1994
  const entries = [{
1998
1995
  command: '-1',
1999
- flags: None$1,
1996
+ flags: None,
2000
1997
  id: 'newFile',
2001
1998
  label: newFile()
2002
1999
  }, {
2003
2000
  command: 'Window.openNew',
2004
- flags: None$1,
2001
+ flags: None,
2005
2002
  id: 'newWindow',
2006
2003
  label: newWindow()
2007
2004
  }, menuEntrySeparator, {
2008
2005
  command: 'Dialog.openFile',
2009
- flags: None$1,
2006
+ flags: None,
2010
2007
  id: 'openFile',
2011
2008
  label: openFile()
2012
2009
  }, {
@@ -2021,12 +2018,12 @@ const getMenuEntries$b = platform => {
2021
2018
  label: openRecent()
2022
2019
  }, menuEntrySeparator, {
2023
2020
  command: 'Main.save',
2024
- flags: None$1,
2021
+ flags: None,
2025
2022
  id: 'save',
2026
2023
  label: save()
2027
2024
  }, {
2028
2025
  command: 'Main.saveAll',
2029
- flags: None$1,
2026
+ flags: None,
2030
2027
  id: 'saveAll',
2031
2028
  label: saveAll()
2032
2029
  }];
@@ -2071,7 +2068,7 @@ const getMenuEntries$9 = async platform => {
2071
2068
  if (platform !== Web) {
2072
2069
  entries.push({
2073
2070
  command: 'Developer.toggleDeveloperTools',
2074
- flags: None$1,
2071
+ flags: None,
2075
2072
  id: 'toggleDeveloperTools',
2076
2073
  label: toggleDeveloperTools()
2077
2074
  }, {
@@ -2094,7 +2091,7 @@ const getMenuEntries$9 = async platform => {
2094
2091
  }
2095
2092
  entries.push({
2096
2093
  command: 'About.showAbout',
2097
- flags: None$1,
2094
+ flags: None,
2098
2095
  id: 'about',
2099
2096
  label: about()
2100
2097
  });
@@ -2135,7 +2132,7 @@ const toMenuItem = folder => {
2135
2132
  return {
2136
2133
  args: [folder],
2137
2134
  command: 'Workspace.setPath',
2138
- flags: None$1,
2135
+ flags: None,
2139
2136
  label
2140
2137
  };
2141
2138
  };
@@ -2148,12 +2145,12 @@ const getMenuEntries$8 = async () => {
2148
2145
  }
2149
2146
  items.push({
2150
2147
  command: 'QuickPick.showRecent',
2151
- flags: None$1,
2148
+ flags: None,
2152
2149
  id: 'more',
2153
2150
  label: moreDot()
2154
2151
  }, menuEntrySeparator, {
2155
2152
  command: 'RecentlyOpened.clearRecentlyOpened',
2156
- flags: None$1,
2153
+ flags: None,
2157
2154
  id: 'clearRecentlyOpened',
2158
2155
  label: clearRecentlyOpened()
2159
2156
  });
@@ -2167,72 +2164,72 @@ const getMenuEntries$7 = () => {
2167
2164
  const getMenuEntries$6 = () => {
2168
2165
  return [{
2169
2166
  command: 'Editor.selectAll',
2170
- flags: None$1,
2167
+ flags: None,
2171
2168
  id: 'selectAll',
2172
2169
  label: selectAll()
2173
2170
  }, {
2174
2171
  command: 'Editor.expandSelection',
2175
- flags: None$1,
2172
+ flags: None,
2176
2173
  id: 'expandSelection',
2177
2174
  label: expandSelection()
2178
2175
  }, {
2179
2176
  command: 'Editor.shrinkSelection',
2180
- flags: None$1,
2177
+ flags: None,
2181
2178
  id: 'shrinkSelection',
2182
2179
  label: shrinkSelection()
2183
2180
  }, menuEntrySeparator, {
2184
2181
  command: 'Editor.copyLineUp',
2185
- flags: None$1,
2182
+ flags: None,
2186
2183
  id: 'copyLineUp',
2187
2184
  label: copyLineUp()
2188
2185
  }, {
2189
2186
  command: 'Editor.copyLineDown',
2190
- flags: None$1,
2187
+ flags: None,
2191
2188
  id: 'copyLineDown',
2192
2189
  label: copyLineDown()
2193
2190
  }, {
2194
2191
  command: 'Editor.moveLineUp',
2195
- flags: None$1,
2192
+ flags: None,
2196
2193
  id: 'moveLineUp',
2197
2194
  label: moveLineUp()
2198
2195
  }, {
2199
2196
  command: 'Editor.moveLineDown',
2200
- flags: None$1,
2197
+ flags: None,
2201
2198
  id: 'moveLineDown',
2202
2199
  label: moveLineDown()
2203
2200
  }, {
2204
2201
  command: 'Editor.duplicateSelection',
2205
- flags: None$1,
2202
+ flags: None,
2206
2203
  id: 'duplicateSelection',
2207
2204
  label: duplicateSelection()
2208
2205
  }, menuEntrySeparator, {
2209
2206
  command: 'Editor.addCursorAbove',
2210
- flags: None$1,
2207
+ flags: None,
2211
2208
  id: 'addCursorAbove',
2212
2209
  label: addCursorAbove()
2213
2210
  }, {
2214
2211
  command: 'Editor.addCursorBelow',
2215
- flags: None$1,
2212
+ flags: None,
2216
2213
  id: 'addCursorBelow',
2217
2214
  label: addCursorBelow()
2218
2215
  }, {
2219
2216
  command: 'Editor.addCursorsToLineEnds',
2220
- flags: None$1,
2217
+ flags: None,
2221
2218
  id: 'addCursorsToLineEnds',
2222
2219
  label: addCursorsToLineEnds()
2223
2220
  }, {
2224
2221
  command: 'Editor.addNextOccurrence',
2225
- flags: None$1,
2222
+ flags: None,
2226
2223
  id: 'addNextOccurrence',
2227
2224
  label: addNextOccurrence()
2228
2225
  }, {
2229
2226
  command: 'Editor.addPreviousOccurrence',
2230
- flags: None$1,
2227
+ flags: None,
2231
2228
  id: 'addPreviousOccurrence',
2232
2229
  label: addPreviousOccurrence()
2233
2230
  }, {
2234
2231
  command: 'Editor.selectAllOccurrences',
2235
- flags: None$1,
2232
+ flags: None,
2236
2233
  id: 'selectAllOccurrences',
2237
2234
  label: selectAllOccurrences()
2238
2235
  }];
@@ -2242,7 +2239,7 @@ const getMenuEntries$5 = () => {
2242
2239
  return [{
2243
2240
  args: ['Terminal'],
2244
2241
  command: 'Layout.togglePanel',
2245
- flags: None$1,
2242
+ flags: None,
2246
2243
  id: 'newTerminal',
2247
2244
  label: i18nString(NewTerminal)
2248
2245
  }];
@@ -2298,32 +2295,32 @@ const getMenuEntries$4 = () => {
2298
2295
  const getMenuEntries$3 = () => {
2299
2296
  return [{
2300
2297
  command: '',
2301
- flags: None$1,
2298
+ flags: None,
2302
2299
  id: File$1,
2303
2300
  label: file()
2304
2301
  }, {
2305
2302
  command: '',
2306
- flags: None$1,
2303
+ flags: None,
2307
2304
  id: Edit,
2308
2305
  label: edit()
2309
2306
  }, {
2310
2307
  command: '',
2311
- flags: None$1,
2308
+ flags: None,
2312
2309
  id: Selection,
2313
2310
  label: selection()
2314
2311
  }, {
2315
2312
  command: '',
2316
- flags: None$1,
2313
+ flags: None,
2317
2314
  id: View,
2318
2315
  label: view()
2319
2316
  }, {
2320
2317
  command: '',
2321
- flags: None$1,
2318
+ flags: None,
2322
2319
  id: Go,
2323
2320
  label: go()
2324
2321
  }, {
2325
2322
  command: '',
2326
- flags: None$1,
2323
+ flags: None,
2327
2324
  id: Help$1,
2328
2325
  label: help()
2329
2326
  }];
@@ -2411,7 +2408,7 @@ const FileMenu = 'fileMenu';
2411
2408
  const EditMenu = 'editMenu';
2412
2409
 
2413
2410
  // based on https://www.electronjs.org/docs/latest/api/menu-item#new-menuitemoptions
2414
- const Separator$1 = 'separator';
2411
+ const Separator = 'separator';
2415
2412
  const SubMenu = 'submenu';
2416
2413
 
2417
2414
  const toElectronMenuItem = entry => {
@@ -2476,9 +2473,9 @@ const toElectronMenuItem = entry => {
2476
2473
  };
2477
2474
  }
2478
2475
  switch (entry.flags) {
2479
- case Separator$2:
2476
+ case Separator$1:
2480
2477
  return {
2481
- type: Separator$1
2478
+ type: Separator
2482
2479
  };
2483
2480
  case SubMenu$1:
2484
2481
  return {
@@ -2553,29 +2550,6 @@ const hydrate = async state => {
2553
2550
  };
2554
2551
  };
2555
2552
 
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
2553
  const mergeClassNames = (...classNames) => {
2580
2554
  return classNames.filter(Boolean).join(' ');
2581
2555
  };
@@ -2586,44 +2560,44 @@ const px = value => {
2586
2560
 
2587
2561
  const text = data => {
2588
2562
  return {
2589
- type: Text,
2563
+ childCount: 0,
2590
2564
  text: data,
2591
- childCount: 0
2565
+ type: Text
2592
2566
  };
2593
2567
  };
2594
2568
 
2595
2569
  const getKeyBindings = () => {
2596
2570
  return [{
2597
2571
  command: 'TitleBar.handleKeyArrowDown',
2598
- key: DownArrow,
2572
+ key: DownArrow$1,
2599
2573
  when: FocusTitleBarMenuBar
2600
2574
  }, {
2601
2575
  command: 'TitleBar.handleKeyArrowUp',
2602
- key: UpArrow,
2576
+ key: UpArrow$1,
2603
2577
  when: FocusTitleBarMenuBar
2604
2578
  }, {
2605
2579
  command: 'TitleBar.handleKeyArrowRight',
2606
- key: RightArrow,
2580
+ key: RightArrow$1,
2607
2581
  when: FocusTitleBarMenuBar
2608
2582
  }, {
2609
2583
  command: 'TitleBar.handleKeyArrowLeft',
2610
- key: LeftArrow,
2584
+ key: LeftArrow$1,
2611
2585
  when: FocusTitleBarMenuBar
2612
2586
  }, {
2613
2587
  command: 'TitleBar.handleKeySpace',
2614
- key: Space,
2588
+ key: Space$1,
2615
2589
  when: FocusTitleBarMenuBar
2616
2590
  }, {
2617
2591
  command: 'TitleBar.handleKeyHome',
2618
- key: Home,
2592
+ key: Home$1,
2619
2593
  when: FocusTitleBarMenuBar
2620
2594
  }, {
2621
2595
  command: 'TitleBar.handleKeyEnd',
2622
- key: End,
2596
+ key: End$1,
2623
2597
  when: FocusTitleBarMenuBar
2624
2598
  }, {
2625
2599
  command: 'TitleBar.handleKeyEscape',
2626
- key: Escape,
2600
+ key: Escape$1,
2627
2601
  when: FocusTitleBarMenuBar
2628
2602
  }];
2629
2603
  };
@@ -2732,7 +2706,7 @@ const getMenuHeight = items => {
2732
2706
  let height = CONTEXT_MENU_PADDING;
2733
2707
  for (const item of items) {
2734
2708
  switch (item.flags) {
2735
- case Separator$2:
2709
+ case Separator$1:
2736
2710
  height += CONTEXT_MENU_SEPARATOR_HEIGHT;
2737
2711
  break;
2738
2712
  default:
@@ -2789,7 +2763,7 @@ const getIndexToFocusPrevious = menu => {
2789
2763
  const canBeFocused = item => {
2790
2764
  switch (item.flags) {
2791
2765
  case Disabled:
2792
- case Separator$2:
2766
+ case Separator$1:
2793
2767
  return false;
2794
2768
  default:
2795
2769
  return true;
@@ -2986,7 +2960,6 @@ const measureTextWidths2 = async (texts, fontWeight, fontSize, fontFamily, lette
2986
2960
  await using rpc = await launchTextMeasurementWorker();
2987
2961
  const isMonospaceFont = false;
2988
2962
  const charWidth = 0;
2989
- // @ts-ignore
2990
2963
  const result = await rpc.invoke('TextMeasurement.measureTextWidths', texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth);
2991
2964
  return result;
2992
2965
  };
@@ -3080,11 +3053,18 @@ const loadContent2 = async state => {
3080
3053
  };
3081
3054
  };
3082
3055
 
3056
+ const renderFocusContext = (oldState, newState) => {
3057
+ const {
3058
+ uid
3059
+ } = newState;
3060
+ return [SetFocusContext, uid, FocusTitleBarMenuBar];
3061
+ };
3062
+
3083
3063
  const renderFocusedIndex = (oldState, newState) => {
3084
3064
  if (newState.focusedIndex === -1) {
3085
3065
  return [];
3086
3066
  }
3087
- return ['Viewlet.focusSelector', '.ViewletTitleBarMenuBar'];
3067
+ return [FocusSelector, '.ViewletTitleBarMenuBar'];
3088
3068
  };
3089
3069
 
3090
3070
  const MaskIconCheck = 'MaskIconCheck';
@@ -3195,7 +3175,7 @@ const getMenuItemsNoopDom = () => {
3195
3175
  const separator = {
3196
3176
  childCount: 1,
3197
3177
  className: MenuItemSeparator,
3198
- role: Separator,
3178
+ role: Separator$2,
3199
3179
  type: Div
3200
3180
  };
3201
3181
  const separatorLine = {
@@ -3255,10 +3235,10 @@ const getMenuItemRenderer = flags => {
3255
3235
  case Disabled:
3256
3236
  return getMenuItemDisabledDom;
3257
3237
  case Ignore:
3258
- case None$1:
3238
+ case None:
3259
3239
  case RestoreFocus:
3260
3240
  return getMenuItemDefaultDom;
3261
- case Separator$2:
3241
+ case Separator$1:
3262
3242
  return getMenuItemSeparatorDom;
3263
3243
  case SubMenu$1:
3264
3244
  return getMenuItemSubMenuDom;
@@ -3353,7 +3333,7 @@ const getIconVirtualDom = (icon, type = Div) => {
3353
3333
  return {
3354
3334
  childCount: 0,
3355
3335
  className: `MaskIcon MaskIcon${icon}`,
3356
- role: None,
3336
+ role: None$1,
3357
3337
  type
3358
3338
  };
3359
3339
  };
@@ -3370,7 +3350,7 @@ const createTitleBarButton = button => {
3370
3350
  childCount: 1,
3371
3351
  className: `TitleBarButton TitleBarButton${id}`,
3372
3352
  onClick,
3373
- type: Button
3353
+ type: Button$1
3374
3354
  }, getIconVirtualDom(icon, I)];
3375
3355
  return dom;
3376
3356
  };
@@ -3427,7 +3407,7 @@ const getItemVirtualDom = item => {
3427
3407
  name: label,
3428
3408
  // TODO have separate name attribute
3429
3409
  role: MenuItem$1,
3430
- type: Button
3410
+ type: Button$1
3431
3411
  }, ...(isFocused ? [{
3432
3412
  childCount: 1,
3433
3413
  className: TitleBarTopLevelEntryLabel,
@@ -3453,7 +3433,7 @@ const getTitleBarMenuBarVirtualDom = (menuBarEnabled, visibleItems, focusedIndex
3453
3433
  onMouseDown: HandleClick,
3454
3434
  onPointerOut: HandlePointerOut,
3455
3435
  onPointerOver: HandlePointerOver,
3456
- role: MenuBar,
3436
+ role: MenuBar$1,
3457
3437
  tabIndex: 0,
3458
3438
  type: Div
3459
3439
  }, ...getTitleBarMenuBarItemsVirtualDom(visibleItems)];
@@ -3462,7 +3442,7 @@ const getTitleBarMenuBarVirtualDom = (menuBarEnabled, visibleItems, focusedIndex
3462
3442
  const parentNode = {
3463
3443
  childCount: 1,
3464
3444
  className: 'TitleBarTitle',
3465
- type: Div$1
3445
+ type: Div
3466
3446
  };
3467
3447
  const getTitleVirtualDom = (titleBarTitleEnabled, title) => {
3468
3448
  if (!titleBarTitleEnabled) {
@@ -3530,7 +3510,7 @@ const getTitleBarVirtualDom = state => {
3530
3510
  if (platform === Electron$1 && !titleBarStyleCustom) {
3531
3511
  return [{
3532
3512
  childCount: 0,
3533
- type: Div$1
3513
+ type: Div
3534
3514
  }];
3535
3515
  }
3536
3516
  const iconSrc = getIcon(assetDir);
@@ -3542,19 +3522,21 @@ const getTitleBarVirtualDom = state => {
3542
3522
  className: 'Viewlet TitleBar',
3543
3523
  id: 'TitleBar',
3544
3524
  role: ContentInfo,
3545
- type: Div$1
3525
+ type: Div
3546
3526
  }, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getTitleVirtualDom(titleBarTitleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
3547
3527
  };
3548
3528
 
3549
3529
  const renderTitleBar = (oldState, newState) => {
3550
3530
  const dom = getTitleBarVirtualDom(newState);
3551
- return ['Viewlet.setDom2', newState.uid, dom];
3531
+ return [SetDom2, newState.uid, dom];
3552
3532
  };
3553
3533
 
3554
3534
  const getRenderer3 = diffType => {
3555
3535
  switch (diffType) {
3556
3536
  case RenderEntries:
3557
3537
  return renderTitleBar;
3538
+ case RenderFocusContext:
3539
+ return renderFocusContext;
3558
3540
  case RenderFocusedIndex:
3559
3541
  return renderFocusedIndex;
3560
3542
  case RenderMenus:
@@ -3587,7 +3569,7 @@ const renderEventListeners = () => {
3587
3569
  params: ['handleClickMinimize']
3588
3570
  }, {
3589
3571
  name: HandleContextMenu,
3590
- params: ['handleContextMenu', Button$1, ClientX, ClientY]
3572
+ params: ['handleContextMenu', Button, ClientX, ClientY]
3591
3573
  }, {
3592
3574
  name: HandleClickClose,
3593
3575
  params: ['handleClickClose']
@@ -3605,7 +3587,7 @@ const renderEventListeners = () => {
3605
3587
  params: ['handleMenuMouseOver', ClientX, ClientY]
3606
3588
  }, {
3607
3589
  name: HandleClick,
3608
- params: ['handleClickAt', Button$1, ClientX, ClientY]
3590
+ params: ['handleClickAt', Button, ClientX, ClientY]
3609
3591
  }, {
3610
3592
  name: HandlePointerOut,
3611
3593
  params: ['handlePointerOut', ClientX, ClientY]
@@ -3795,13 +3777,11 @@ const handleClickAt = async (state, button, eventX, eventY) => {
3795
3777
  return handleClick(state, button, index);
3796
3778
  };
3797
3779
 
3798
- const setFocus = async focusKey => {
3799
- await invoke('Focus.setFocus', focusKey);
3800
- };
3801
-
3802
3780
  const handleFocus = async state => {
3803
- await setFocus(FocusTitleBarMenuBar);
3804
- return state;
3781
+ return {
3782
+ ...state,
3783
+ focused: true
3784
+ };
3805
3785
  };
3806
3786
 
3807
3787
  const handleFocusOut = async state => {
@@ -4131,7 +4111,7 @@ const handleMenuClick = async (state, level, index) => {
4131
4111
  switch (item.flags) {
4132
4112
  case Ignore:
4133
4113
  return selectIndexIgnore(state, item);
4134
- case None$1:
4114
+ case None:
4135
4115
  return selectIndexNone(state, item);
4136
4116
  case RestoreFocus:
4137
4117
  return selectIndexRestoreFocus(state, item);
@@ -4246,7 +4226,6 @@ const commandMap = {
4246
4226
  'TitleBar.closeMenu': closeMenu,
4247
4227
  'TitleBar.create': create,
4248
4228
  'TitleBar.create3': create3,
4249
- 'TitleBar.diff2': diff2,
4250
4229
  'TitleBar.diff3': diff3,
4251
4230
  'TitleBar.focus': wrapCommand(focus),
4252
4231
  'TitleBar.focusFirst': wrapCommand(focusFirst),
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.12.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",