@lvce-editor/title-bar-worker 4.8.0 → 4.9.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.
@@ -63,7 +63,7 @@ class AssertionError extends Error {
63
63
  const Object$1 = 1;
64
64
  const Number$1 = 2;
65
65
  const Array$1 = 3;
66
- const String = 4;
66
+ const String$1 = 4;
67
67
  const Boolean$1 = 5;
68
68
  const Function = 6;
69
69
  const Null = 7;
@@ -75,7 +75,7 @@ const getType = value => {
75
75
  case 'function':
76
76
  return Function;
77
77
  case 'string':
78
- return String;
78
+ return String$1;
79
79
  case 'object':
80
80
  if (value === null) {
81
81
  return Null;
@@ -151,7 +151,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
151
151
  for (const property of Object.values(value)) {
152
152
  walkValue(property, transferrables, isTransferrable);
153
153
  }
154
- return;
155
154
  }
156
155
  };
157
156
  const getTransferrables = value => {
@@ -305,7 +304,14 @@ class IpcError extends VError {
305
304
  const cause = new Error(message);
306
305
  // @ts-ignore
307
306
  cause.code = code;
308
- cause.stack = stack;
307
+ if (stack) {
308
+ Object.defineProperty(cause, 'stack', {
309
+ configurable: true,
310
+ enumerable: false,
311
+ value: stack,
312
+ writable: true
313
+ });
314
+ }
309
315
  super(cause, betterMessage);
310
316
  } else {
311
317
  super(betterMessage);
@@ -609,8 +615,10 @@ const getCurrentStack = () => {
609
615
  const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
610
616
  return currentStack;
611
617
  };
612
- const getNewLineIndex = (string, startIndex = undefined) => {
613
- return string.indexOf(NewLine, startIndex);
618
+ const getNewLineIndex = (string, startIndex) => {
619
+ {
620
+ return string.indexOf(NewLine);
621
+ }
614
622
  };
615
623
  const getParentStack = error => {
616
624
  let parentStack = error.stack || error.data || error.message || '';
@@ -621,55 +629,77 @@ const getParentStack = error => {
621
629
  };
622
630
  const MethodNotFound = -32601;
623
631
  const Custom = -32001;
632
+ const restoreExistingError = (error, currentStack) => {
633
+ if (typeof error.stack === 'string') {
634
+ error.stack = error.stack + NewLine + currentStack;
635
+ }
636
+ return error;
637
+ };
638
+ const restoreMethodNotFoundError = (error, currentStack) => {
639
+ const restoredError = new JsonRpcError(error.message);
640
+ const parentStack = getParentStack(error);
641
+ restoredError.stack = parentStack + NewLine + currentStack;
642
+ return restoredError;
643
+ };
644
+ const restoreStackFromData = (restoredError, error, currentStack) => {
645
+ if (error.data.stack && error.data.type && error.message) {
646
+ restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
647
+ return;
648
+ }
649
+ if (error.data.stack) {
650
+ restoredError.stack = error.data.stack;
651
+ }
652
+ };
653
+ const applyDataProperties = (restoredError, error) => {
654
+ if (!error.data) {
655
+ return;
656
+ }
657
+ restoreStackFromData(restoredError, error, getCurrentStack());
658
+ if (error.data.codeFrame) {
659
+ // @ts-ignore
660
+ restoredError.codeFrame = error.data.codeFrame;
661
+ }
662
+ if (error.data.code) {
663
+ // @ts-ignore
664
+ restoredError.code = error.data.code;
665
+ }
666
+ if (error.data.type) {
667
+ // @ts-ignore
668
+ restoredError.name = error.data.type;
669
+ }
670
+ };
671
+ const applyDirectProperties = (restoredError, error) => {
672
+ if (error.stack) {
673
+ const lowerStack = restoredError.stack || '';
674
+ const indexNewLine = getNewLineIndex(lowerStack);
675
+ const parentStack = getParentStack(error);
676
+ // @ts-ignore
677
+ restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
678
+ }
679
+ if (error.codeFrame) {
680
+ // @ts-ignore
681
+ restoredError.codeFrame = error.codeFrame;
682
+ }
683
+ };
684
+ const restoreMessageError = (error, _currentStack) => {
685
+ const restoredError = constructError(error.message, error.type, error.name);
686
+ if (error.data) {
687
+ applyDataProperties(restoredError, error);
688
+ } else {
689
+ applyDirectProperties(restoredError, error);
690
+ }
691
+ return restoredError;
692
+ };
624
693
  const restoreJsonRpcError = error => {
625
694
  const currentStack = getCurrentStack();
626
695
  if (error && error instanceof Error) {
627
- if (typeof error.stack === 'string') {
628
- error.stack = error.stack + NewLine + currentStack;
629
- }
630
- return error;
696
+ return restoreExistingError(error, currentStack);
631
697
  }
632
698
  if (error && error.code && error.code === MethodNotFound) {
633
- const restoredError = new JsonRpcError(error.message);
634
- const parentStack = getParentStack(error);
635
- restoredError.stack = parentStack + NewLine + currentStack;
636
- return restoredError;
699
+ return restoreMethodNotFoundError(error, currentStack);
637
700
  }
638
701
  if (error && error.message) {
639
- const restoredError = constructError(error.message, error.type, error.name);
640
- if (error.data) {
641
- if (error.data.stack && error.data.type && error.message) {
642
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
643
- } else if (error.data.stack) {
644
- restoredError.stack = error.data.stack;
645
- }
646
- if (error.data.codeFrame) {
647
- // @ts-ignore
648
- restoredError.codeFrame = error.data.codeFrame;
649
- }
650
- if (error.data.code) {
651
- // @ts-ignore
652
- restoredError.code = error.data.code;
653
- }
654
- if (error.data.type) {
655
- // @ts-ignore
656
- restoredError.name = error.data.type;
657
- }
658
- } else {
659
- if (error.stack) {
660
- const lowerStack = restoredError.stack || '';
661
- // @ts-ignore
662
- const indexNewLine = getNewLineIndex(lowerStack);
663
- const parentStack = getParentStack(error);
664
- // @ts-ignore
665
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
666
- }
667
- if (error.codeFrame) {
668
- // @ts-ignore
669
- restoredError.codeFrame = error.codeFrame;
670
- }
671
- }
672
- return restoredError;
702
+ return restoreMessageError(error);
673
703
  }
674
704
  if (typeof error === 'string') {
675
705
  return new Error(`JsonRpc Error: ${error}`);
@@ -1095,12 +1125,174 @@ const MenuItemCheckBox = 'menuitemcheckbox';
1095
1125
  const None$1 = 'none';
1096
1126
  const Separator$2 = 'separator';
1097
1127
 
1128
+ const Audio = 0;
1098
1129
  const Button$1 = 1;
1130
+ const Col = 2;
1131
+ const ColGroup = 3;
1099
1132
  const Div = 4;
1133
+ const H1 = 5;
1134
+ const Input = 6;
1135
+ const Kbd = 7;
1100
1136
  const Span = 8;
1137
+ const Table = 9;
1138
+ const TBody = 10;
1139
+ const Td = 11;
1101
1140
  const Text = 12;
1141
+ const Th = 13;
1142
+ const THead = 14;
1143
+ const Tr = 15;
1102
1144
  const I = 16;
1103
1145
  const Img = 17;
1146
+ const Root = 0;
1147
+ const Ins = 20;
1148
+ const Del = 21;
1149
+ const H2 = 22;
1150
+ const H3 = 23;
1151
+ const H4 = 24;
1152
+ const H5 = 25;
1153
+ const H6 = 26;
1154
+ const Article = 27;
1155
+ const Aside = 28;
1156
+ const Footer = 29;
1157
+ const Header = 30;
1158
+ const Nav = 40;
1159
+ const Section = 41;
1160
+ const Search$1 = 42;
1161
+ const Dd = 43;
1162
+ const Dl = 44;
1163
+ const Figcaption = 45;
1164
+ const Figure = 46;
1165
+ const Hr = 47;
1166
+ const Li = 48;
1167
+ const Ol = 49;
1168
+ const P = 50;
1169
+ const Pre = 51;
1170
+ const A = 53;
1171
+ const Abbr = 54;
1172
+ const Br = 55;
1173
+ const Cite = 56;
1174
+ const Data = 57;
1175
+ const Time = 58;
1176
+ const Tfoot = 59;
1177
+ const Ul = 60;
1178
+ const Video = 61;
1179
+ const TextArea = 62;
1180
+ const Select = 63;
1181
+ const Option = 64;
1182
+ const Code = 65;
1183
+ const Label = 66;
1184
+ const Dt = 67;
1185
+ const Iframe = 68;
1186
+ const Main = 69;
1187
+ const Strong = 70;
1188
+ const Em = 71;
1189
+ const Style = 72;
1190
+ const Html = 73;
1191
+ const Head = 74;
1192
+ const Title = 75;
1193
+ const Meta = 76;
1194
+ const Canvas = 77;
1195
+ const Form = 78;
1196
+ const BlockQuote = 79;
1197
+ const Quote = 80;
1198
+ const Circle = 81;
1199
+ const Defs = 82;
1200
+ const Ellipse = 83;
1201
+ const G = 84;
1202
+ const Line = 85;
1203
+ const Path = 86;
1204
+ const Polygon = 87;
1205
+ const Polyline = 88;
1206
+ const Rect = 89;
1207
+ const Svg = 90;
1208
+ const Use = 91;
1209
+ const Reference = 100;
1210
+
1211
+ const VirtualDomElements = {
1212
+ __proto__: null,
1213
+ A,
1214
+ Abbr,
1215
+ Article,
1216
+ Aside,
1217
+ Audio,
1218
+ BlockQuote,
1219
+ Br,
1220
+ Button: Button$1,
1221
+ Canvas,
1222
+ Circle,
1223
+ Cite,
1224
+ Code,
1225
+ Col,
1226
+ ColGroup,
1227
+ Data,
1228
+ Dd,
1229
+ Defs,
1230
+ Del,
1231
+ Div,
1232
+ Dl,
1233
+ Dt,
1234
+ Ellipse,
1235
+ Em,
1236
+ Figcaption,
1237
+ Figure,
1238
+ Footer,
1239
+ Form,
1240
+ G,
1241
+ H1,
1242
+ H2,
1243
+ H3,
1244
+ H4,
1245
+ H5,
1246
+ H6,
1247
+ Head,
1248
+ Header,
1249
+ Hr,
1250
+ Html,
1251
+ I,
1252
+ Iframe,
1253
+ Img,
1254
+ Input,
1255
+ Ins,
1256
+ Kbd,
1257
+ Label,
1258
+ Li,
1259
+ Line,
1260
+ Main,
1261
+ Meta,
1262
+ Nav,
1263
+ Ol,
1264
+ Option,
1265
+ P,
1266
+ Path,
1267
+ Polygon,
1268
+ Polyline,
1269
+ Pre,
1270
+ Quote,
1271
+ Rect,
1272
+ Reference,
1273
+ Root,
1274
+ Search: Search$1,
1275
+ Section,
1276
+ Select,
1277
+ Span,
1278
+ Strong,
1279
+ Style,
1280
+ Svg,
1281
+ TBody,
1282
+ THead,
1283
+ Table,
1284
+ Td,
1285
+ Text,
1286
+ TextArea,
1287
+ Tfoot,
1288
+ Th,
1289
+ Time,
1290
+ Title,
1291
+ Tr,
1292
+ Ul,
1293
+ Use,
1294
+ Video
1295
+ };
1104
1296
 
1105
1297
  const Button = 'event.button';
1106
1298
  const ClientX = 'event.clientX';
@@ -1381,10 +1573,67 @@ const toCommandId = key => {
1381
1573
  return key.slice(dotIndex + 1);
1382
1574
  };
1383
1575
  const create$1 = () => {
1576
+ const commandQueues = new Map();
1577
+ const generations = Object.create(null);
1384
1578
  const states = Object.create(null);
1385
1579
  const commandMapRef = {};
1580
+ const getGeneration = uid => generations[uid] || 0;
1581
+ const isCurrentGeneration = (uid, generation) => {
1582
+ return states[uid] !== undefined && getGeneration(uid) === generation;
1583
+ };
1584
+ const updateState = (uid, generation, fallbackState, updater) => {
1585
+ if (!isCurrentGeneration(uid, generation)) {
1586
+ return Promise.resolve(fallbackState);
1587
+ }
1588
+ const current = states[uid];
1589
+ const updatedState = updater(current.newState);
1590
+ if (updatedState !== current.newState) {
1591
+ states[uid] = {
1592
+ newState: updatedState,
1593
+ oldState: current.oldState,
1594
+ scheduledState: updatedState
1595
+ };
1596
+ }
1597
+ return Promise.resolve(updatedState);
1598
+ };
1599
+ const createAsyncCommandContext = (uid, generation) => {
1600
+ let latestState = states[uid].newState;
1601
+ return {
1602
+ getState: () => {
1603
+ if (isCurrentGeneration(uid, generation)) {
1604
+ latestState = states[uid].newState;
1605
+ }
1606
+ return latestState;
1607
+ },
1608
+ updateState: async updater => {
1609
+ latestState = await updateState(uid, generation, latestState, updater);
1610
+ return latestState;
1611
+ }
1612
+ };
1613
+ };
1614
+ const enqueueCommand = async (uid, command) => {
1615
+ const previous = commandQueues.get(uid) || Promise.resolve();
1616
+ const run = async () => {
1617
+ try {
1618
+ await previous;
1619
+ } catch {
1620
+ // The previous caller receives its error; later commands must still run.
1621
+ }
1622
+ await command();
1623
+ };
1624
+ const current = run();
1625
+ commandQueues.set(uid, current);
1626
+ try {
1627
+ await current;
1628
+ } finally {
1629
+ if (commandQueues.get(uid) === current) {
1630
+ commandQueues.delete(uid);
1631
+ }
1632
+ }
1633
+ };
1386
1634
  return {
1387
1635
  clear() {
1636
+ commandQueues.clear();
1388
1637
  for (const key of Object.keys(states)) {
1389
1638
  delete states[key];
1390
1639
  }
@@ -1404,6 +1653,7 @@ const create$1 = () => {
1404
1653
  return diffResult;
1405
1654
  },
1406
1655
  dispose(uid) {
1656
+ commandQueues.delete(uid);
1407
1657
  delete states[uid];
1408
1658
  },
1409
1659
  get(uid) {
@@ -1421,14 +1671,27 @@ const create$1 = () => {
1421
1671
  Object.assign(commandMapRef, commandMap);
1422
1672
  },
1423
1673
  set(uid, oldState, newState, scheduledState) {
1674
+ const current = states[uid];
1675
+ if (!current || oldState === newState && newState !== current.newState) {
1676
+ generations[uid] = getGeneration(uid) + 1;
1677
+ }
1424
1678
  states[uid] = {
1425
1679
  newState,
1426
1680
  oldState,
1427
1681
  scheduledState: scheduledState ?? newState
1428
1682
  };
1429
1683
  },
1684
+ wrapAsyncCommand(fn) {
1685
+ const wrapped = async (uid, ...args) => {
1686
+ const generation = getGeneration(uid);
1687
+ const context = createAsyncCommandContext(uid, generation);
1688
+ await fn(context, ...args);
1689
+ };
1690
+ return wrapped;
1691
+ },
1430
1692
  wrapCommand(fn) {
1431
1693
  const wrapped = async (uid, ...args) => {
1694
+ const generation = getGeneration(uid);
1432
1695
  const {
1433
1696
  newState,
1434
1697
  oldState
@@ -1437,6 +1700,9 @@ const create$1 = () => {
1437
1700
  if (oldState === newerState || newState === newerState) {
1438
1701
  return;
1439
1702
  }
1703
+ if (!isCurrentGeneration(uid, generation)) {
1704
+ return;
1705
+ }
1440
1706
  const latestOld = states[uid];
1441
1707
  const latestNew = {
1442
1708
  ...latestOld.newState,
@@ -1461,6 +1727,7 @@ const create$1 = () => {
1461
1727
  },
1462
1728
  wrapLoadContent(fn) {
1463
1729
  const wrapped = async (uid, ...args) => {
1730
+ const generation = getGeneration(uid);
1464
1731
  const {
1465
1732
  newState,
1466
1733
  oldState
@@ -1475,6 +1742,11 @@ const create$1 = () => {
1475
1742
  error
1476
1743
  };
1477
1744
  }
1745
+ if (!isCurrentGeneration(uid, generation)) {
1746
+ return {
1747
+ error
1748
+ };
1749
+ }
1478
1750
  const latestOld = states[uid];
1479
1751
  const latestNew = {
1480
1752
  ...latestOld.newState,
@@ -1490,6 +1762,51 @@ const create$1 = () => {
1490
1762
  };
1491
1763
  };
1492
1764
  return wrapped;
1765
+ },
1766
+ wrapSerialAsyncCommand(fn) {
1767
+ const wrapped = async (uid, ...args) => {
1768
+ await enqueueCommand(uid, async () => {
1769
+ if (!states[uid]) {
1770
+ return;
1771
+ }
1772
+ const generation = getGeneration(uid);
1773
+ const context = createAsyncCommandContext(uid, generation);
1774
+ await fn(context, ...args);
1775
+ });
1776
+ };
1777
+ return wrapped;
1778
+ },
1779
+ wrapSerialCommand(fn) {
1780
+ const wrapped = async (uid, ...args) => {
1781
+ await enqueueCommand(uid, async () => {
1782
+ if (!states[uid]) {
1783
+ return;
1784
+ }
1785
+ const generation = getGeneration(uid);
1786
+ const {
1787
+ newState,
1788
+ oldState
1789
+ } = states[uid];
1790
+ const newerState = await fn(newState, ...args);
1791
+ if (oldState === newerState || newState === newerState) {
1792
+ return;
1793
+ }
1794
+ if (!isCurrentGeneration(uid, generation)) {
1795
+ return;
1796
+ }
1797
+ const latestOld = states[uid];
1798
+ const latestNew = {
1799
+ ...latestOld.newState,
1800
+ ...newerState
1801
+ };
1802
+ states[uid] = {
1803
+ newState: latestNew,
1804
+ oldState: latestOld.oldState,
1805
+ scheduledState: latestNew
1806
+ };
1807
+ });
1808
+ };
1809
+ return wrapped;
1493
1810
  }
1494
1811
  };
1495
1812
  };
@@ -1559,15 +1876,15 @@ const HandleContextMenu = 11;
1559
1876
  const HandleTitleBarContextMenu = 12;
1560
1877
 
1561
1878
  const emptyObject = {};
1562
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1563
1879
  const i18nString = (key, placeholders = emptyObject) => {
1564
1880
  if (placeholders === emptyObject) {
1565
1881
  return key;
1566
1882
  }
1567
- const replacer = (match, rest) => {
1568
- return placeholders[rest];
1569
- };
1570
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1883
+ let result = key;
1884
+ for (const [placeholder, replacement] of Object.entries(placeholders)) {
1885
+ result = result.split(`{${placeholder}}`).join(String(replacement));
1886
+ }
1887
+ return result;
1571
1888
  };
1572
1889
 
1573
1890
  const About = 'About';
@@ -1580,6 +1897,7 @@ const TitleBar$2 = 'Title Bar';
1580
1897
  const MenuBar = 'Menu Bar';
1581
1898
  const CommandCenter = 'Command Center';
1582
1899
  const CommandPalette = 'Command Palette';
1900
+ const LayoutControls = 'Layout Controls';
1583
1901
  const Edit$1 = 'Edit';
1584
1902
  const EditorLayout = 'Editor Layout';
1585
1903
  const FlipLayout = 'Flip Layout';
@@ -1688,6 +2006,9 @@ const menuBar = () => {
1688
2006
  const commandCenter = () => {
1689
2007
  return i18nString(CommandCenter);
1690
2008
  };
2009
+ const layoutControls = () => {
2010
+ return i18nString(LayoutControls);
2011
+ };
1691
2012
  const copy$1 = () => {
1692
2013
  return i18nString(Copy$1);
1693
2014
  };
@@ -1804,7 +2125,7 @@ const create3 = (id, uri, x, y, width, height, platform, controlsOverlayEnabled,
1804
2125
  };
1805
2126
 
1806
2127
  const isEqual$3 = (oldState, newState) => {
1807
- return oldState.titleBarEntries === newState.titleBarEntries && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.title === newState.title && oldState.workspaceUri === newState.workspaceUri;
2128
+ return oldState.titleBarEntries === newState.titleBarEntries && oldState.titleBarMenuBarEnabled === newState.titleBarMenuBarEnabled && oldState.width === newState.width && oldState.focusedIndex === newState.focusedIndex && oldState.isMenuOpen === newState.isMenuOpen && oldState.title === newState.title && oldState.workspaceUri === newState.workspaceUri;
1808
2129
  };
1809
2130
 
1810
2131
  const isEqual$2 = (oldState, newState) => {
@@ -1854,16 +2175,19 @@ const Ignore = 7;
1854
2175
  const getMenuEntriesTitleBarContextMenu = async state => {
1855
2176
  const {
1856
2177
  commandCenterEnabled,
1857
- titleBarMenuBarEnabled
2178
+ titleBarMenuBarEnabled,
2179
+ uid
1858
2180
  } = state;
1859
2181
  // TODO checked state should be depending on whether or not that feature is currently visible or not
1860
2182
  return [{
1861
- command: titleBarMenuBarEnabled ? 'TitleBar.hideMenuBar' : 'TitleBar.showMenuBar',
2183
+ args: [uid, titleBarMenuBarEnabled ? 'hideMenuBar' : 'showMenuBar'],
2184
+ command: 'Viewlet.executeViewletCommand',
1862
2185
  flags: titleBarMenuBarEnabled ? Checked : Unchecked,
1863
2186
  id: 'MenuBar',
1864
2187
  label: menuBar()
1865
2188
  }, {
1866
- command: commandCenterEnabled ? 'TitleBar.hideCommandCenter' : 'TitleBar.showCommandCenter',
2189
+ args: [uid, commandCenterEnabled ? 'hideCommandCenter' : 'showCommandCenter'],
2190
+ command: 'Viewlet.executeViewletCommand',
1867
2191
  flags: commandCenterEnabled ? Checked : Unchecked,
1868
2192
  id: 'Command center',
1869
2193
  label: commandCenter()
@@ -1871,7 +2195,7 @@ const getMenuEntriesTitleBarContextMenu = async state => {
1871
2195
  command: '',
1872
2196
  flags: Checked,
1873
2197
  id: 'layout controls',
1874
- label: 'layout controls'
2198
+ label: layoutControls()
1875
2199
  }];
1876
2200
  };
1877
2201
 
@@ -1902,6 +2226,15 @@ const menuEntrySeparator = {
1902
2226
  const notImplementedArgs$1 = [{
1903
2227
  message: 'not implemented'
1904
2228
  }];
2229
+ const sideBarLeft = 1;
2230
+ const sideBarRight = 2;
2231
+ const getSideBarPosition = async () => {
2232
+ try {
2233
+ return await invoke('Layout.getSideBarPosition');
2234
+ } catch {
2235
+ return sideBarRight;
2236
+ }
2237
+ };
1905
2238
  const entry = (id, label, keyboardShortCut = '') => {
1906
2239
  return {
1907
2240
  args: notImplementedArgs$1,
@@ -1931,14 +2264,16 @@ const commandEntry = (id, label, command, keyboardShortCut = '', flags = None) =
1931
2264
  label
1932
2265
  };
1933
2266
  };
1934
- const getMenuEntries$e = () => {
2267
+ const getMenuEntries$e = async sideBarPosition => {
2268
+ const currentSideBarPosition = sideBarPosition ?? (await getSideBarPosition());
2269
+ const movePrimarySideBarEntry = currentSideBarPosition === sideBarLeft ? commandEntry('movePrimarySideBarRight', 'Move Primary Side Bar Right', 'Layout.moveSideBarRight') : commandEntry('movePrimarySideBarLeft', 'Move Primary Side Bar Left', 'Layout.moveSideBarLeft');
1935
2270
  return [{
1936
2271
  command: 'Window.toggleFullScreen',
1937
2272
  flags: None,
1938
2273
  id: 'fullScreen',
1939
2274
  keyboardShortCut: 'F11',
1940
2275
  label: fullScreen()
1941
- }, entry('zenMode', 'Zen Mode', 'Ctrl+K Z'), entry('centeredLayout', 'Centered Layout'), menuEntrySeparator, checkedEntry('menuBar', 'Menu Bar'), commandEntry('primarySideBar', 'Primary Side Bar', 'Layout.toggleSideBar', 'Ctrl+B'), commandEntry('secondarySideBar', 'Secondary Side Bar', 'Layout.toggleSecondarySideBar', 'Ctrl+Alt+B'), commandEntry('statusBar', 'Status Bar', 'Layout.toggleStatusBar', '', Checked), commandEntry('panel', 'Panel', 'Layout.togglePanel', 'Ctrl+J', Checked), menuEntrySeparator, commandEntry('movePrimarySideBarLeft', 'Move Primary Side Bar Left', 'Layout.moveSideBarLeft'), entry('activityBarPosition', 'Activity Bar Position'), entry('panelPosition', 'Panel Position'), entry('alignPanel', 'Align Panel'), entry('tabBar', 'Tab Bar'), entry('editorActionsPosition', 'Editor Actions Position'), menuEntrySeparator, entry('minimap', 'Minimap'), entry('breadcrumbs', 'Breadcrumbs'), entry('stickyScroll', 'Sticky Scroll'), entry('renderWhitespace', 'Render Whitespace'), checkedEntry('renderControlCharacters', 'Render Control Characters'), menuEntrySeparator, commandEntry('zoomIn', 'Zoom In', 'Window.zoomIn', 'Ctrl+='), commandEntry('zoomOut', 'Zoom Out', 'Window.zoomOut', 'Ctrl+-'), commandEntry('resetZoom', 'Reset Zoom', 'Window.zoomReset', 'Ctrl+NumPad0')];
2276
+ }, entry('zenMode', 'Zen Mode', 'Ctrl+K Z'), entry('centeredLayout', 'Centered Layout'), menuEntrySeparator, checkedEntry('menuBar', 'Menu Bar'), commandEntry('primarySideBar', 'Primary Side Bar', 'Layout.toggleSideBar', 'Ctrl+B'), commandEntry('secondarySideBar', 'Secondary Side Bar', 'Layout.toggleSecondarySideBar', 'Ctrl+Alt+B'), commandEntry('statusBar', 'Status Bar', 'Layout.toggleStatusBar', '', Checked), commandEntry('panel', 'Panel', 'Layout.togglePanel', 'Ctrl+J', Checked), menuEntrySeparator, movePrimarySideBarEntry, entry('activityBarPosition', 'Activity Bar Position'), entry('panelPosition', 'Panel Position'), entry('alignPanel', 'Align Panel'), entry('tabBar', 'Tab Bar'), entry('editorActionsPosition', 'Editor Actions Position'), menuEntrySeparator, entry('minimap', 'Minimap'), entry('breadcrumbs', 'Breadcrumbs'), entry('stickyScroll', 'Sticky Scroll'), entry('renderWhitespace', 'Render Whitespace'), checkedEntry('renderControlCharacters', 'Render Control Characters'), menuEntrySeparator, commandEntry('zoomIn', 'Zoom In', 'Window.zoomIn', 'Ctrl+='), commandEntry('zoomOut', 'Zoom Out', 'Window.zoomOut', 'Ctrl+-'), commandEntry('resetZoom', 'Reset Zoom', 'Window.zoomReset', 'Ctrl+NumPad0')];
1942
2277
  };
1943
2278
 
1944
2279
  const cut = () => {
@@ -2286,7 +2621,18 @@ const getMenuEntries$a = () => {
2286
2621
  flags: SubMenu$1,
2287
2622
  id: MenuIdSwitchGroup,
2288
2623
  label: 'Switch Group'
2289
- }, menuEntrySeparator, notImplementedEntry('goToFile', 'Go to File...'), notImplementedEntry('goToSymbolInWorkspace', 'Go to Symbol in Workspace...'), menuEntrySeparator, notImplementedEntry('goToSymbolInEditor', 'Go to Symbol in Editor...'), notImplementedEntry('goToDefinition', 'Go to Definition'), notImplementedEntry('goToDeclaration', 'Go to Declaration'), notImplementedEntry('goToTypeDefinition', 'Go to Type Definition'), notImplementedEntry('goToImplementations', 'Go to Implementations'), notImplementedEntry('goToReferences', 'Go to References'), menuEntrySeparator, notImplementedEntry('goToLineColumn', 'Go to Line/Column...'), notImplementedEntry('goToBracket', 'Go to Bracket'), menuEntrySeparator, notImplementedEntry('nextProblem', 'Next Problem'), notImplementedEntry('previousProblem', 'Previous Problem'), menuEntrySeparator, notImplementedEntry('nextChange', 'Next Change'), notImplementedEntry('previousChange', 'Previous Change')];
2624
+ }, menuEntrySeparator, {
2625
+ command: 'QuickPick.showFile',
2626
+ flags: None,
2627
+ id: 'goToFile',
2628
+ label: 'Go to File...'
2629
+ }, {
2630
+ args: ['workspace-symbol'],
2631
+ command: 'QuickPick.show',
2632
+ flags: None,
2633
+ id: 'goToSymbolInWorkspace',
2634
+ label: 'Go to Symbol in Workspace...'
2635
+ }, menuEntrySeparator, notImplementedEntry('goToSymbolInEditor', 'Go to Symbol in Editor...'), notImplementedEntry('goToDefinition', 'Go to Definition'), notImplementedEntry('goToDeclaration', 'Go to Declaration'), notImplementedEntry('goToTypeDefinition', 'Go to Type Definition'), notImplementedEntry('goToImplementations', 'Go to Implementations'), notImplementedEntry('goToReferences', 'Go to References'), menuEntrySeparator, notImplementedEntry('goToLineColumn', 'Go to Line/Column...'), notImplementedEntry('goToBracket', 'Go to Bracket'), menuEntrySeparator, notImplementedEntry('nextProblem', 'Next Problem'), notImplementedEntry('previousProblem', 'Previous Problem'), menuEntrySeparator, notImplementedEntry('nextChange', 'Next Change'), notImplementedEntry('previousChange', 'Previous Change')];
2290
2636
  };
2291
2637
  const getMenuEntriesSwitchEditor = () => {
2292
2638
  return [notImplementedEntry('nextEditor', 'Next Editor', 'Ctrl+PageDown'), notImplementedEntry('previousEditor', 'Previous Editor', 'Ctrl+PageUp'), menuEntrySeparator, notImplementedEntry('nextUsedEditor', 'Next Used Editor'), notImplementedEntry('previousUsedEditor', 'Previous Used Editor'), menuEntrySeparator, notImplementedEntry('nextEditorInGroup', 'Next Editor in Group', 'Ctrl+K Ctrl+PageDown'), notImplementedEntry('previousEditorInGroup', 'Previous Editor in Group', 'Ctrl+K Ctrl+PageUp'), notImplementedEntry('nextUsedEditorInGroup', 'Next Used Editor in Group'), notImplementedEntry('previousUsedEditorInGroup', 'Previous Used Editor in Group')];
@@ -2951,6 +3297,8 @@ const text = data => {
2951
3297
  };
2952
3298
  };
2953
3299
 
3300
+ new Set(Object.values(VirtualDomElements));
3301
+
2954
3302
  const getKeyBindings = () => {
2955
3303
  return [{
2956
3304
  command: 'TitleBar.handleKeyArrowDown',
@@ -3941,6 +4289,7 @@ const getTitleBarMenuBarVirtualDom = (menuBarEnabled, visibleItems, focusedIndex
3941
4289
  ariaActivedescendant: focusedIndex === -1 ? '' : activeId,
3942
4290
  childCount: visibleItems.length,
3943
4291
  className: mergeClassNames(Viewlet, TitleBarMenuBar),
4292
+ onContextMenu: HandleContextMenu,
3944
4293
  onFocusIn: HandleFocusIn,
3945
4294
  onFocusOut: HandleFocusOut,
3946
4295
  onMouseDown: HandleClick,
@@ -3988,9 +4337,10 @@ const getTitleBarVirtualDom = state => {
3988
4337
  }
3989
4338
  const iconSrc = getIcon(assetDir);
3990
4339
  const visibleEntries = getVisibleTitleBarEntries(titleBarEntries, width, focusedIndex, isMenuOpen);
4340
+ const childCount = Number(titleBarIconEnabled) + Number(titleBarMenuBarEnabled) + Number(titleBarTitleEnabled) + Number(titleBarButtonsEnabled);
3991
4341
  return [{
3992
4342
  ariaLabel: titleBar(),
3993
- childCount: 4,
4343
+ childCount,
3994
4344
  className: mergeClassNames(Viewlet, TitleBar),
3995
4345
  id: 'TitleBar',
3996
4346
  onContextMenu: HandleTitleBarContextMenu,
@@ -4042,7 +4392,8 @@ const renderEventListeners = () => {
4042
4392
  params: ['handleClickMinimize']
4043
4393
  }, {
4044
4394
  name: HandleContextMenu,
4045
- params: ['handleContextMenu', Button, ClientX, ClientY]
4395
+ params: ['handleContextMenu', Button, ClientX, ClientY],
4396
+ preventDefault: true
4046
4397
  }, {
4047
4398
  name: HandleTitleBarContextMenu,
4048
4399
  params: ['handleTitleBarContextMenu'],
@@ -4570,8 +4921,9 @@ const selectIndexNone = async (state, item) => {
4570
4921
 
4571
4922
  const selectIndexRestoreFocus = async (state, item) => {
4572
4923
  await executeMenuItemCommand(item);
4924
+ const latestState = get(state.uid)?.newState ?? state;
4573
4925
  return {
4574
- ...state,
4926
+ ...latestState,
4575
4927
  isMenuOpen: false,
4576
4928
  menus: []
4577
4929
  };
@@ -4738,7 +5090,7 @@ const toggleMenu = async state => {
4738
5090
  };
4739
5091
 
4740
5092
  const commandMap = {
4741
- 'TitleBar.closeMenu': closeMenu,
5093
+ 'TitleBar.closeMenu': wrapCommand(closeMenu),
4742
5094
  'TitleBar.create': create,
4743
5095
  'TitleBar.create3': create3,
4744
5096
  'TitleBar.diff3': diff3,
@@ -4752,7 +5104,7 @@ const commandMap = {
4752
5104
  'TitleBar.getCommandIds': getCommandIds,
4753
5105
  'TitleBar.getCommands': getCommandIds,
4754
5106
  'TitleBar.getKeyBindings': getKeyBindings,
4755
- 'TitleBar.getMenuEntries2': getMenuEntries2,
5107
+ 'TitleBar.getMenuEntries2': wrapGetter(getMenuEntries2),
4756
5108
  'TitleBar.getMenuIds': getMenuIds,
4757
5109
  'TitleBar.handleButtonsClick': handleClick$1,
4758
5110
  'TitleBar.handleClick': wrapCommand(handleClick),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/title-bar-worker",
3
- "version": "4.8.0",
3
+ "version": "4.9.0",
4
4
  "description": "Title Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",