@lvce-editor/title-bar-worker 3.19.0 → 3.21.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.
@@ -518,6 +518,27 @@ const IpcParentWithMessagePort$1 = {
518
518
  wrap: wrap$5
519
519
  };
520
520
 
521
+ class CommandNotFoundError extends Error {
522
+ constructor(command) {
523
+ super(`Command not found ${command}`);
524
+ this.name = 'CommandNotFoundError';
525
+ }
526
+ }
527
+ const commands = Object.create(null);
528
+ const register = commandMap => {
529
+ Object.assign(commands, commandMap);
530
+ };
531
+ const getCommand = key => {
532
+ return commands[key];
533
+ };
534
+ const execute = (command, ...args) => {
535
+ const fn = getCommand(command);
536
+ if (!fn) {
537
+ throw new CommandNotFoundError(command);
538
+ }
539
+ return fn(...args);
540
+ };
541
+
521
542
  const Two$1 = '2.0';
522
543
  const callbacks = Object.create(null);
523
544
  const get$2 = id => {
@@ -542,12 +563,12 @@ const getErrorConstructor = (message, type) => {
542
563
  switch (type) {
543
564
  case DomException:
544
565
  return DOMException;
545
- case TypeError$1:
546
- return TypeError;
547
- case SyntaxError$1:
548
- return SyntaxError;
549
566
  case ReferenceError$1:
550
567
  return ReferenceError;
568
+ case SyntaxError$1:
569
+ return SyntaxError;
570
+ case TypeError$1:
571
+ return TypeError;
551
572
  default:
552
573
  return Error;
553
574
  }
@@ -703,27 +724,27 @@ const getErrorProperty = (error, prettyError) => {
703
724
  if (error && error.code === E_COMMAND_NOT_FOUND) {
704
725
  return {
705
726
  code: MethodNotFound,
706
- message: error.message,
707
- data: error.stack
727
+ data: error.stack,
728
+ message: error.message
708
729
  };
709
730
  }
710
731
  return {
711
732
  code: Custom,
712
- message: prettyError.message,
713
733
  data: {
714
- stack: getStack(prettyError),
715
- codeFrame: prettyError.codeFrame,
716
- type: getErrorType(prettyError),
717
734
  code: prettyError.code,
718
- name: prettyError.name
719
- }
735
+ codeFrame: prettyError.codeFrame,
736
+ name: prettyError.name,
737
+ stack: getStack(prettyError),
738
+ type: getErrorType(prettyError)
739
+ },
740
+ message: prettyError.message
720
741
  };
721
742
  };
722
743
  const create$1$1 = (id, error) => {
723
744
  return {
724
- jsonrpc: Two$1,
745
+ error,
725
746
  id,
726
- error
747
+ jsonrpc: Two$1
727
748
  };
728
749
  };
729
750
  const getErrorResponse = (id, error, preparePrettyError, logError) => {
@@ -732,27 +753,27 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
732
753
  const errorProperty = getErrorProperty(error, prettyError);
733
754
  return create$1$1(id, errorProperty);
734
755
  };
735
- const create$4 = (message, result) => {
756
+ const create$9 = (message, result) => {
736
757
  return {
737
- jsonrpc: Two$1,
738
758
  id: message.id,
759
+ jsonrpc: Two$1,
739
760
  result: result ?? null
740
761
  };
741
762
  };
742
763
  const getSuccessResponse = (message, result) => {
743
764
  const resultProperty = result ?? null;
744
- return create$4(message, resultProperty);
765
+ return create$9(message, resultProperty);
745
766
  };
746
767
  const getErrorResponseSimple = (id, error) => {
747
768
  return {
748
- jsonrpc: Two$1,
749
- id,
750
769
  error: {
751
770
  code: Custom,
771
+ data: error,
752
772
  // @ts-ignore
753
- message: error.message,
754
- data: error
755
- }
773
+ message: error.message
774
+ },
775
+ id,
776
+ jsonrpc: Two$1
756
777
  };
757
778
  };
758
779
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
@@ -782,35 +803,35 @@ const normalizeParams = args => {
782
803
  if (args.length === 1) {
783
804
  const options = args[0];
784
805
  return {
806
+ execute: options.execute,
785
807
  ipc: options.ipc,
808
+ logError: options.logError || defaultLogError,
786
809
  message: options.message,
787
- execute: options.execute,
788
- resolve: options.resolve || defaultResolve,
789
810
  preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
790
- logError: options.logError || defaultLogError,
791
- requiresSocket: options.requiresSocket || defaultRequiresSocket
811
+ requiresSocket: options.requiresSocket || defaultRequiresSocket,
812
+ resolve: options.resolve || defaultResolve
792
813
  };
793
814
  }
794
815
  return {
816
+ execute: args[2],
795
817
  ipc: args[0],
818
+ logError: args[5],
796
819
  message: args[1],
797
- execute: args[2],
798
- resolve: args[3],
799
820
  preparePrettyError: args[4],
800
- logError: args[5],
801
- requiresSocket: args[6]
821
+ requiresSocket: args[6],
822
+ resolve: args[3]
802
823
  };
803
824
  };
804
825
  const handleJsonRpcMessage = async (...args) => {
805
826
  const options = normalizeParams(args);
806
827
  const {
807
- message,
808
- ipc,
809
828
  execute,
810
- resolve,
811
- preparePrettyError,
829
+ ipc,
812
830
  logError,
813
- requiresSocket
831
+ message,
832
+ preparePrettyError,
833
+ requiresSocket,
834
+ resolve
814
835
  } = options;
815
836
  if ('id' in message) {
816
837
  if ('method' in message) {
@@ -833,36 +854,17 @@ const handleJsonRpcMessage = async (...args) => {
833
854
  throw new JsonRpcError('unexpected message');
834
855
  };
835
856
 
836
- class CommandNotFoundError extends Error {
837
- constructor(command) {
838
- super(`Command not found ${command}`);
839
- this.name = 'CommandNotFoundError';
840
- }
841
- }
842
- const commands = Object.create(null);
843
- const register = commandMap => {
844
- Object.assign(commands, commandMap);
845
- };
846
- const getCommand = key => {
847
- return commands[key];
848
- };
849
- const execute = (command, ...args) => {
850
- const fn = getCommand(command);
851
- if (!fn) {
852
- throw new CommandNotFoundError(command);
853
- }
854
- return fn(...args);
855
- };
856
-
857
857
  const Two = '2.0';
858
- const create$t = (method, params) => {
858
+
859
+ const create$8 = (method, params) => {
859
860
  return {
860
861
  jsonrpc: Two,
861
862
  method,
862
863
  params
863
864
  };
864
865
  };
865
- const create$s = (id, method, params) => {
866
+
867
+ const create$7 = (id, method, params) => {
866
868
  const message = {
867
869
  id,
868
870
  jsonrpc: Two,
@@ -871,15 +873,14 @@ const create$s = (id, method, params) => {
871
873
  };
872
874
  return message;
873
875
  };
876
+
874
877
  let id = 0;
875
- const create$r = () => {
878
+ const create$6 = () => {
876
879
  return ++id;
877
880
  };
878
881
 
879
- /* eslint-disable n/no-unsupported-features/es-syntax */
880
-
881
882
  const registerPromise = map => {
882
- const id = create$r();
883
+ const id = create$6();
883
884
  const {
884
885
  promise,
885
886
  resolve
@@ -891,13 +892,12 @@ const registerPromise = map => {
891
892
  };
892
893
  };
893
894
 
894
- // @ts-ignore
895
895
  const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
896
896
  const {
897
897
  id,
898
898
  promise
899
899
  } = registerPromise(callbacks);
900
- const message = create$s(id, method, params);
900
+ const message = create$7(id, method, params);
901
901
  if (useSendAndTransfer && ipc.sendAndTransfer) {
902
902
  ipc.sendAndTransfer(message);
903
903
  } else {
@@ -933,12 +933,13 @@ const createRpc = ipc => {
933
933
  * @deprecated
934
934
  */
935
935
  send(method, ...params) {
936
- const message = create$t(method, params);
936
+ const message = create$8(method, params);
937
937
  ipc.send(message);
938
938
  }
939
939
  };
940
940
  return rpc;
941
941
  };
942
+
942
943
  const requiresSocket = () => {
943
944
  return false;
944
945
  };
@@ -953,6 +954,7 @@ const handleMessage = event => {
953
954
  const actualExecute = event?.target?.execute || execute;
954
955
  return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
955
956
  };
957
+
956
958
  const handleIpc = ipc => {
957
959
  if ('addEventListener' in ipc) {
958
960
  ipc.addEventListener('message', handleMessage);
@@ -961,6 +963,7 @@ const handleIpc = ipc => {
961
963
  ipc.on('message', handleMessage);
962
964
  }
963
965
  };
966
+
964
967
  const listen$1 = async (module, options) => {
965
968
  const rawIpc = await module.listen(options);
966
969
  if (module.signal) {
@@ -969,6 +972,7 @@ const listen$1 = async (module, options) => {
969
972
  const ipc = module.wrap(rawIpc);
970
973
  return ipc;
971
974
  };
975
+
972
976
  const create$5 = async ({
973
977
  commandMap,
974
978
  isMessagePortOpen = true,
@@ -986,7 +990,8 @@ const create$5 = async ({
986
990
  messagePort.start();
987
991
  return rpc;
988
992
  };
989
- const create$3 = async ({
993
+
994
+ const create$4 = async ({
990
995
  commandMap,
991
996
  isMessagePortOpen,
992
997
  send
@@ -1002,11 +1007,8 @@ const create$3 = async ({
1002
1007
  messagePort: port2
1003
1008
  });
1004
1009
  };
1005
- const TransferMessagePortRpcParent = {
1006
- __proto__: null,
1007
- create: create$3
1008
- };
1009
- const create$2$1 = async ({
1010
+
1011
+ const create$3 = async ({
1010
1012
  commandMap
1011
1013
  }) => {
1012
1014
  // TODO create a commandMap per rpc instance
@@ -1016,10 +1018,7 @@ const create$2$1 = async ({
1016
1018
  const rpc = createRpc(ipc);
1017
1019
  return rpc;
1018
1020
  };
1019
- const WebWorkerRpcClient = {
1020
- __proto__: null,
1021
- create: create$2$1
1022
- };
1021
+
1023
1022
  const createMockRpc = ({
1024
1023
  commandMap
1025
1024
  }) => {
@@ -1040,6 +1039,54 @@ const createMockRpc = ({
1040
1039
  return mockRpc;
1041
1040
  };
1042
1041
 
1042
+ const rpcs = Object.create(null);
1043
+ const set$2 = (id, rpc) => {
1044
+ rpcs[id] = rpc;
1045
+ };
1046
+ const get$1 = id => {
1047
+ return rpcs[id];
1048
+ };
1049
+ const remove = id => {
1050
+ delete rpcs[id];
1051
+ };
1052
+
1053
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
1054
+ const create$2 = rpcId => {
1055
+ return {
1056
+ async dispose() {
1057
+ const rpc = get$1(rpcId);
1058
+ await rpc.dispose();
1059
+ },
1060
+ // @ts-ignore
1061
+ invoke(method, ...params) {
1062
+ const rpc = get$1(rpcId);
1063
+ // @ts-ignore
1064
+ return rpc.invoke(method, ...params);
1065
+ },
1066
+ // @ts-ignore
1067
+ invokeAndTransfer(method, ...params) {
1068
+ const rpc = get$1(rpcId);
1069
+ // @ts-ignore
1070
+ return rpc.invokeAndTransfer(method, ...params);
1071
+ },
1072
+ registerMockRpc(commandMap) {
1073
+ const mockRpc = createMockRpc({
1074
+ commandMap
1075
+ });
1076
+ set$2(rpcId, mockRpc);
1077
+ // @ts-ignore
1078
+ mockRpc[Symbol.dispose] = () => {
1079
+ remove(rpcId);
1080
+ };
1081
+ // @ts-ignore
1082
+ return mockRpc;
1083
+ },
1084
+ set(rpc) {
1085
+ set$2(rpcId, rpc);
1086
+ }
1087
+ };
1088
+ };
1089
+
1043
1090
  const ContentInfo = 'contentinfo';
1044
1091
  const Menu$1 = 'menu';
1045
1092
  const MenuBar$1 = 'menubar';
@@ -1337,7 +1384,7 @@ const OpenRecent$1 = 9;
1337
1384
  const Run$2 = 10;
1338
1385
  const Selection$2 = 11;
1339
1386
  const Terminal$2 = 14;
1340
- const TitleBar$2 = 15;
1387
+ const TitleBar$3 = 15;
1341
1388
  const View$2 = 16;
1342
1389
  const TitleBarContextMenu = 90;
1343
1390
 
@@ -1365,54 +1412,6 @@ const SetFocusContext = 'Viewlet.setFocusContext';
1365
1412
 
1366
1413
  const FocusTitleBarMenuBar = 26;
1367
1414
 
1368
- const rpcs = Object.create(null);
1369
- const set$2 = (id, rpc) => {
1370
- rpcs[id] = rpc;
1371
- };
1372
- const get$1 = id => {
1373
- return rpcs[id];
1374
- };
1375
- const remove = id => {
1376
- delete rpcs[id];
1377
- };
1378
-
1379
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
1380
- const create$2 = rpcId => {
1381
- return {
1382
- async dispose() {
1383
- const rpc = get$1(rpcId);
1384
- await rpc.dispose();
1385
- },
1386
- // @ts-ignore
1387
- invoke(method, ...params) {
1388
- const rpc = get$1(rpcId);
1389
- // @ts-ignore
1390
- return rpc.invoke(method, ...params);
1391
- },
1392
- // @ts-ignore
1393
- invokeAndTransfer(method, ...params) {
1394
- const rpc = get$1(rpcId);
1395
- // @ts-ignore
1396
- return rpc.invokeAndTransfer(method, ...params);
1397
- },
1398
- registerMockRpc(commandMap) {
1399
- const mockRpc = createMockRpc({
1400
- commandMap
1401
- });
1402
- set$2(rpcId, mockRpc);
1403
- // @ts-ignore
1404
- mockRpc[Symbol.dispose] = () => {
1405
- remove(rpcId);
1406
- };
1407
- // @ts-ignore
1408
- return mockRpc;
1409
- },
1410
- set(rpc) {
1411
- set$2(rpcId, rpc);
1412
- }
1413
- };
1414
- };
1415
-
1416
1415
  const {
1417
1416
  invoke,
1418
1417
  invokeAndTransfer,
@@ -1482,7 +1481,7 @@ const create$1 = () => {
1482
1481
  },
1483
1482
  getKeys() {
1484
1483
  return Object.keys(states).map(key => {
1485
- return Number.parseInt(key);
1484
+ return Number.parseFloat(key);
1486
1485
  });
1487
1486
  },
1488
1487
  registerCommands(commandMap) {
@@ -1524,6 +1523,37 @@ const create$1 = () => {
1524
1523
  return fn(newState, ...args);
1525
1524
  };
1526
1525
  return wrapped;
1526
+ },
1527
+ wrapLoadContent(fn) {
1528
+ const wrapped = async (uid, ...args) => {
1529
+ const {
1530
+ newState,
1531
+ oldState
1532
+ } = states[uid];
1533
+ const result = await fn(newState, ...args);
1534
+ const {
1535
+ error,
1536
+ state
1537
+ } = result;
1538
+ if (oldState === state || newState === state) {
1539
+ return {
1540
+ error
1541
+ };
1542
+ }
1543
+ const latestOld = states[uid];
1544
+ const latestNew = {
1545
+ ...latestOld.newState,
1546
+ ...state
1547
+ };
1548
+ states[uid] = {
1549
+ newState: latestNew,
1550
+ oldState: latestOld.oldState
1551
+ };
1552
+ return {
1553
+ error
1554
+ };
1555
+ };
1556
+ return wrapped;
1527
1557
  }
1528
1558
  };
1529
1559
  };
@@ -1536,7 +1566,9 @@ const Electron = 2;
1536
1566
  const Remote = 3;
1537
1567
 
1538
1568
  const DEFAULT_UID = 1;
1569
+ const DEFAULT_APP_NAME = 'Lvce Editor';
1539
1570
  const createDefaultState = (uid = DEFAULT_UID) => ({
1571
+ appName: DEFAULT_APP_NAME,
1540
1572
  assetDir: '',
1541
1573
  buttons: [],
1542
1574
  commandCenterEnabled: false,
@@ -1585,6 +1617,7 @@ const HandlePointerOver = 8;
1585
1617
  const HandleMenuClick = 9;
1586
1618
  const HandleMenuMouseOver = 10;
1587
1619
  const HandleContextMenu = 11;
1620
+ const HandleTitleBarContextMenu = 12;
1588
1621
 
1589
1622
  const emptyObject = {};
1590
1623
  const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
@@ -1599,14 +1632,19 @@ const i18nString = (key, placeholders = emptyObject) => {
1599
1632
  };
1600
1633
 
1601
1634
  const About = 'About';
1635
+ const Appearance = 'Appearance';
1636
+ const Chat = 'Chat';
1602
1637
  const CheckForUpdates = 'Check For Updates';
1603
1638
  const ClearRecentlyOpened = 'Clear Recently Opened';
1604
1639
  const Close = 'Close';
1605
1640
  const Exit = 'Exit';
1606
- const TitleBar$1 = 'Title Bar';
1641
+ const TitleBar$2 = 'Title Bar';
1607
1642
  const MenuBar = 'Menu Bar';
1608
1643
  const CommandCenter = 'Command Center';
1644
+ const CommandPalette = 'Command Palette';
1609
1645
  const Edit$1 = 'Edit';
1646
+ const EditorLayout = 'Editor Layout';
1647
+ const Explorer = 'Explorer';
1610
1648
  const File$2 = 'File';
1611
1649
  const Go$1 = 'Go';
1612
1650
  const Help$2 = 'Help';
@@ -1614,12 +1652,19 @@ const Maximize = 'Maximize';
1614
1652
  const Minimize = 'Minimize';
1615
1653
  const MoreDot = 'More ...';
1616
1654
  const NewTerminal = 'New Terminal';
1655
+ const OpenView = 'Open View';
1617
1656
  const OpenProcessExplorer = 'Open Process Explorer';
1657
+ const Output = 'Output';
1658
+ const Problems = 'Problems';
1618
1659
  const Run$1 = 'Run';
1660
+ const Search = 'Search';
1619
1661
  const Selection$1 = 'Selection';
1662
+ const SourceControl = 'Source Control';
1620
1663
  const Terminal$1 = 'Terminal';
1621
1664
  const ToggleDeveloperTools = 'Toggle Developer Tools';
1622
1665
  const View$1 = 'View';
1666
+ const WordWrap = 'Word Wrap';
1667
+ const Extensions = 'Extensions';
1623
1668
  const AddCursorAbove = 'Add Cursor Above';
1624
1669
  const AddCursorBelow = 'Add Cursor Below';
1625
1670
  const AddCursorsToLineEnds = 'Add Cursors to Line ends';
@@ -1676,7 +1721,7 @@ const close$1 = () => {
1676
1721
  return i18nString(Close);
1677
1722
  };
1678
1723
  const titleBar = () => {
1679
- return i18nString(TitleBar$1);
1724
+ return i18nString(TitleBar$2);
1680
1725
  };
1681
1726
  const menuBar = () => {
1682
1727
  return i18nString(MenuBar);
@@ -1872,8 +1917,14 @@ const getMenuEntriesTitleBarContextMenu = async state => {
1872
1917
  };
1873
1918
 
1874
1919
  const MenuIdTitleBarContextMenu = 50;
1920
+ const MenuIdAppearance = 'appearance';
1921
+ const MenuIdEditorLayout = 'editorLayout';
1875
1922
  const getMenuIds = () => {
1876
- return [Edit$2, File$3, Go$2, Help$3, OpenRecent$1, Run$2, Selection$2, Terminal$2, TitleBar$2, View$2, MenuIdTitleBarContextMenu, TitleBarContextMenu];
1923
+ return [Edit$2, File$3, Go$2, Help$3, OpenRecent$1, Run$2, Selection$2, Terminal$2, TitleBar$3, View$2, MenuIdTitleBarContextMenu, TitleBarContextMenu];
1924
+ };
1925
+
1926
+ const getMenuEntries$e = () => {
1927
+ return [];
1877
1928
  };
1878
1929
 
1879
1930
  const cut = () => {
@@ -1947,7 +1998,7 @@ const menuEntrySeparator = {
1947
1998
  label: ''
1948
1999
  };
1949
2000
 
1950
- const getMenuEntries$c = () => {
2001
+ const getMenuEntries$d = () => {
1951
2002
  return [{
1952
2003
  command: /* TODO */'-1',
1953
2004
  flags: None,
@@ -1986,6 +2037,10 @@ const getMenuEntries$c = () => {
1986
2037
  }];
1987
2038
  };
1988
2039
 
2040
+ const getMenuEntries$c = () => {
2041
+ return [];
2042
+ };
2043
+
1989
2044
  /**
1990
2045
  * @enum {string}
1991
2046
  */
@@ -2031,7 +2086,7 @@ const OpenRecent = 9;
2031
2086
  const Run = 10;
2032
2087
  const Selection = 11;
2033
2088
  const Terminal = 14;
2034
- const TitleBar = 15;
2089
+ const TitleBar$1 = 15;
2035
2090
  const View = 16;
2036
2091
 
2037
2092
  const getMenuEntries$b = platform => {
@@ -2384,13 +2439,84 @@ const getMenuEntries$2 = async platform => {
2384
2439
  };
2385
2440
 
2386
2441
  const getMenuEntries$1 = () => {
2387
- return [];
2442
+ return [{
2443
+ command: 'Command.openCommandPalette',
2444
+ flags: None,
2445
+ id: 'commandPalette',
2446
+ label: i18nString(CommandPalette)
2447
+ }, {
2448
+ command: 'View.openView',
2449
+ flags: None,
2450
+ id: 'openView',
2451
+ label: i18nString(OpenView)
2452
+ }, menuEntrySeparator, {
2453
+ command: '',
2454
+ flags: SubMenu$1,
2455
+ id: 'appearance',
2456
+ label: i18nString(Appearance)
2457
+ }, {
2458
+ command: '',
2459
+ flags: SubMenu$1,
2460
+ id: 'editorLayout',
2461
+ label: i18nString(EditorLayout)
2462
+ }, menuEntrySeparator, {
2463
+ command: 'Explorer.focus',
2464
+ flags: None,
2465
+ id: 'explorer',
2466
+ label: i18nString(Explorer)
2467
+ }, {
2468
+ command: 'Search.focus',
2469
+ flags: None,
2470
+ id: 'search',
2471
+ label: i18nString(Search)
2472
+ }, {
2473
+ command: 'SourceControl.focus',
2474
+ flags: None,
2475
+ id: 'sourceControl',
2476
+ label: i18nString(SourceControl)
2477
+ }, {
2478
+ command: 'Run.focus',
2479
+ flags: None,
2480
+ id: 'run',
2481
+ label: i18nString(Run$1)
2482
+ }, {
2483
+ command: 'Extensions.focus',
2484
+ flags: None,
2485
+ id: 'extensions',
2486
+ label: i18nString(Extensions)
2487
+ }, menuEntrySeparator, {
2488
+ command: 'Chat.focus',
2489
+ flags: None,
2490
+ id: 'chat',
2491
+ label: i18nString(Chat)
2492
+ }, menuEntrySeparator, {
2493
+ command: 'Problems.toggle',
2494
+ flags: None,
2495
+ id: 'problems',
2496
+ label: i18nString(Problems)
2497
+ }, {
2498
+ command: 'Output.toggle',
2499
+ flags: None,
2500
+ id: 'output',
2501
+ label: i18nString(Output)
2502
+ }, {
2503
+ args: ['Terminal'],
2504
+ command: 'Layout.togglePanel',
2505
+ flags: None,
2506
+ id: 'terminal',
2507
+ label: i18nString(Terminal$1)
2508
+ }, {
2509
+ command: 'Editor.toggleWordWrap',
2510
+ flags: None,
2511
+ id: 'wordWrap',
2512
+ label: i18nString(WordWrap)
2513
+ }];
2388
2514
  };
2389
2515
 
2390
2516
  const getMenuEntries2 = async (state, props) => {
2391
2517
  switch (props.menuId) {
2392
2518
  case Edit$2:
2393
- return getMenuEntries$c();
2519
+ return getMenuEntries$d();
2394
2520
  case File$3:
2395
2521
  return getMenuEntries$b(props.platform);
2396
2522
  case Go$2:
@@ -2405,13 +2531,19 @@ const getMenuEntries2 = async (state, props) => {
2405
2531
  return getMenuEntries$6();
2406
2532
  case Terminal$2:
2407
2533
  return getMenuEntries$5();
2408
- case TitleBar$2:
2534
+ case TitleBar$3:
2409
2535
  return getMenuEntries$2(props.platform);
2410
2536
  case TitleBarContextMenu:
2411
2537
  case MenuIdTitleBarContextMenu:
2412
2538
  return getMenuEntriesTitleBarContextMenu(state);
2413
2539
  case View$2:
2414
2540
  return getMenuEntries$1();
2541
+ // @ts-ignore
2542
+ case MenuIdAppearance:
2543
+ return getMenuEntries$e();
2544
+ // @ts-ignore
2545
+ case MenuIdEditorLayout:
2546
+ return getMenuEntries$c();
2415
2547
  default:
2416
2548
  return [];
2417
2549
  }
@@ -2537,7 +2669,6 @@ const toElectronMenuItem = entry => {
2537
2669
  const toElectronMenuInternal = (commandMap, map, id, electronMenu) => {
2538
2670
  object(commandMap);
2539
2671
  object(map);
2540
- number(id);
2541
2672
  array(electronMenu);
2542
2673
  const entries = map[id];
2543
2674
  array(entries);
@@ -2549,7 +2680,7 @@ const toElectronMenuInternal = (commandMap, map, id, electronMenu) => {
2549
2680
  };
2550
2681
  }
2551
2682
  const electronEntry = toElectronMenuItem(entry);
2552
- if (entry.flags === SubMenu$2) {
2683
+ if (entry.flags === SubMenu$2 && entry.id !== undefined && map[entry.id]) {
2553
2684
  toElectronMenuInternal(commandMap, map, entry.id, electronEntry.submenu);
2554
2685
  }
2555
2686
  electronMenu.push(electronEntry);
@@ -2583,7 +2714,7 @@ const hydrate = async state => {
2583
2714
  const {
2584
2715
  commandMap,
2585
2716
  electronMenu
2586
- } = toElectronMenu(map, TitleBar);
2717
+ } = toElectronMenu(map, TitleBar$1);
2587
2718
  await setItems(electronMenu);
2588
2719
  // TODO get all menu items
2589
2720
  // TODO send menu items to electron
@@ -2952,6 +3083,10 @@ const handlePointerOver = (state, name) => {
2952
3083
  return handleMouseOver(state, index);
2953
3084
  };
2954
3085
 
3086
+ const handleTitleBarContextMenu = async state => {
3087
+ return state;
3088
+ };
3089
+
2955
3090
  /**
2956
3091
  * Parses a title template string and replaces special variables with their values.
2957
3092
  * Supported variables:
@@ -2989,11 +3124,9 @@ const getTitle = (workspaceUri, titleTemplate, appName) => {
2989
3124
  return parseTitleTemplate(titleTemplate, folderName, appName);
2990
3125
  };
2991
3126
 
2992
- const APP_NAME$2 = 'Lvce Editor';
2993
-
2994
3127
  // TODO in the future, it could also be a multi-root workspace
2995
3128
  const handleWorkspaceChange = async (state, uri) => {
2996
- const title = getTitle(uri, state.titleTemplate, APP_NAME$2);
3129
+ const title = getTitle(uri, state.titleTemplate, state.appName);
2997
3130
  return {
2998
3131
  ...state,
2999
3132
  title,
@@ -3031,7 +3164,7 @@ const getFontString = (fontWeight, fontSize, fontFamily) => {
3031
3164
  };
3032
3165
 
3033
3166
  const launchTextMeasurementWorker = async () => {
3034
- const rpc = await TransferMessagePortRpcParent.create({
3167
+ const rpc = await create$4({
3035
3168
  commandMap: {},
3036
3169
  async send(port) {
3037
3170
  await sendMessagePortToTextMeasurementWorker(port);
@@ -3104,7 +3237,6 @@ const getWorkspaceUri = () => {
3104
3237
  return invoke('Workspace.getUri');
3105
3238
  };
3106
3239
 
3107
- const APP_NAME$1 = 'Lvce Editor';
3108
3240
  const loadContent2 = async state => {
3109
3241
  const {
3110
3242
  controlsOverlayEnabled,
@@ -3120,7 +3252,7 @@ const loadContent2 = async state => {
3120
3252
  const withWidths = await addWidths(titleBarEntries, labelPadding, labelFontWeight, labelFontSize, labelFontFamily, labelLetterSpacing);
3121
3253
  const buttons = getTitleBarButtons(platform, controlsOverlayEnabled, titleBarStyleCustom);
3122
3254
  const workspaceUri = await getWorkspaceUri();
3123
- const title = getTitle(workspaceUri, state.titleTemplate, APP_NAME$1);
3255
+ const title = getTitle(workspaceUri, state.titleTemplate, state.appName);
3124
3256
  const iconWidth = 30;
3125
3257
 
3126
3258
  // TODO load preferences here
@@ -3163,6 +3295,7 @@ const MenuItemSeparator = 'MenuItemSeparator';
3163
3295
  const MenuItemSeparatorLine = 'MenuItemSeparatorLine';
3164
3296
  const MenuItemSubMenu = 'MenuItemSubMenu';
3165
3297
  const MenuItemSubMenuArrowRight = 'MenuItemSubMenuArrowRight';
3298
+ const TitleBar = 'TitleBar';
3166
3299
  const TitleBarButtons = 'TitleBarButtons';
3167
3300
  const TitleBarEntryActive = 'TitleBarEntryActive';
3168
3301
  const TitleBarIcon = 'TitleBarIcon';
@@ -3604,8 +3737,9 @@ const getTitleBarVirtualDom = state => {
3604
3737
  return [{
3605
3738
  ariaLabel: titleBar(),
3606
3739
  childCount: 4,
3607
- className: 'Viewlet TitleBar',
3740
+ className: mergeClassNames(Viewlet, TitleBar),
3608
3741
  id: 'TitleBar',
3742
+ onContextMenu: HandleTitleBarContextMenu,
3609
3743
  role: ContentInfo,
3610
3744
  type: Div
3611
3745
  }, ...getTitleBarIconVirtualDom(titleBarIconEnabled, iconSrc), ...getTitleBarMenuBarVirtualDom(titleBarMenuBarEnabled, visibleEntries, focusedIndex), ...getTitleVirtualDom(titleBarTitleEnabled, title), ...getTitleBarButtonsVirtualDom(titleBarButtonsEnabled, titleBarButtons)];
@@ -3655,6 +3789,10 @@ const renderEventListeners = () => {
3655
3789
  }, {
3656
3790
  name: HandleContextMenu,
3657
3791
  params: ['handleContextMenu', Button, ClientX, ClientY]
3792
+ }, {
3793
+ name: HandleTitleBarContextMenu,
3794
+ params: ['handleTitleBarContextMenu'],
3795
+ preventDefault: true
3658
3796
  }, {
3659
3797
  name: HandleClickClose,
3660
3798
  params: ['handleClickClose']
@@ -3723,9 +3861,8 @@ const setPlatform = (state, platform) => {
3723
3861
  };
3724
3862
  };
3725
3863
 
3726
- const APP_NAME = 'Lvce Editor';
3727
3864
  const setTitleTemplate = (state, titleTemplate) => {
3728
- const title = getTitle(state.workspaceUri, titleTemplate, APP_NAME);
3865
+ const title = getTitle(state.workspaceUri, titleTemplate, state.appName);
3729
3866
  return {
3730
3867
  ...state,
3731
3868
  title,
@@ -3957,7 +4094,7 @@ const handleKeyArrowLeft = ifElse(handleKeyArrowLeftMenuOpen, handleKeyArrowLeft
3957
4094
  const getFn = id => {
3958
4095
  switch (id) {
3959
4096
  case Edit$2:
3960
- return getMenuEntries$c;
4097
+ return getMenuEntries$d;
3961
4098
  case File$3:
3962
4099
  return getMenuEntries$b;
3963
4100
  case Go$2:
@@ -3972,10 +4109,14 @@ const getFn = id => {
3972
4109
  return getMenuEntries$6;
3973
4110
  case Terminal$2:
3974
4111
  return getMenuEntries$5;
3975
- case TitleBar$2:
4112
+ case TitleBar$3:
3976
4113
  return getMenuEntries$2;
3977
4114
  case View$2:
3978
4115
  return getMenuEntries$1;
4116
+ case MenuIdAppearance:
4117
+ return getMenuEntries$e;
4118
+ case MenuIdEditorLayout:
4119
+ return getMenuEntries$c;
3979
4120
  default:
3980
4121
  return undefined;
3981
4122
  }
@@ -4359,6 +4500,7 @@ const commandMap = {
4359
4500
  'TitleBar.handleMouseOver': wrapCommand(handleMouseOver),
4360
4501
  'TitleBar.handlePointerOut': wrapCommand(handlePointerOut),
4361
4502
  'TitleBar.handlePointerOver': wrapCommand(handlePointerOver),
4503
+ 'TitleBar.handleTitleBarContextMenu': wrapCommand(handleTitleBarContextMenu),
4362
4504
  'TitleBar.handleWorkspaceChange': wrapCommand(handleWorkspaceChange),
4363
4505
  'TitleBar.hideCommandCenter': wrapCommand(hideCommandCenter),
4364
4506
  'TitleBar.hideMenuBar': wrapCommand(hideMenuBar),
@@ -4379,7 +4521,7 @@ const commandMap = {
4379
4521
 
4380
4522
  const listen = async () => {
4381
4523
  registerCommands(commandMap);
4382
- const rpc = await WebWorkerRpcClient.create({
4524
+ const rpc = await create$3({
4383
4525
  commandMap: commandMap
4384
4526
  });
4385
4527
  set$1(rpc);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "3.19.0",
3
+ "version": "3.21.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",