@lvce-editor/source-control-worker 1.3.0 → 1.5.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.
@@ -1051,7 +1051,6 @@ const create2 = (id, uri, x, y, width, height, workspacePath) => {
1051
1051
  untracked: [],
1052
1052
  workingTree: [],
1053
1053
  inputValue: '',
1054
- displayItems: [],
1055
1054
  buttonIndex: -1,
1056
1055
  enabledProviderIds: [],
1057
1056
  isExpanded: true,
@@ -1062,7 +1061,10 @@ const create2 = (id, uri, x, y, width, height, workspacePath) => {
1062
1061
  gitRoot: '',
1063
1062
  itemHeight: 20,
1064
1063
  minimumSliderSize: 20,
1065
- workspacePath
1064
+ workspacePath,
1065
+ headerHeight: 40,
1066
+ // TODO
1067
+ actionsCache: Object.create(null)
1066
1068
  };
1067
1069
  set$1(id, state, state);
1068
1070
  };
@@ -1071,7 +1073,7 @@ const RenderItems = 4;
1071
1073
 
1072
1074
  const diffType = RenderItems;
1073
1075
  const isEqual = (oldState, newState) => {
1074
- return oldState.allGroups === newState.allGroups && oldState.displayItems === newState.displayItems && oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.buttonIndex === newState.buttonIndex && oldState.buttons === newState.buttons;
1076
+ return oldState.allGroups === newState.allGroups && oldState.items === newState.items && oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.buttonIndex === newState.buttonIndex && oldState.buttons === newState.buttons;
1075
1077
  };
1076
1078
 
1077
1079
  const modules = [isEqual];
@@ -1097,7 +1099,7 @@ const diff2 = uid => {
1097
1099
  return result;
1098
1100
  };
1099
1101
 
1100
- const commandIds = ['acceptInput', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'handleClick', 'handleClickAt', 'handleIconThemeChange', 'handleWheel'];
1102
+ const commandIds = ['acceptInput', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'handleClick', 'handleClickAt', 'handleFocus', 'handleIconThemeChange', 'handleMouseOut', 'handleMouseOutAt', 'handleMouseOver', 'handleMouseOverAt', 'handleWheel', 'selectIndex'];
1101
1103
 
1102
1104
  const getCommandIds = () => {
1103
1105
  return commandIds;
@@ -1147,6 +1149,7 @@ const executeProvider = async ({
1147
1149
 
1148
1150
  const CommandExecute = 'ExtensionHostCommand.executeCommand';
1149
1151
  const SourceControlGetEnabledProviderIds = 'ExtensionHostSourceControl.getEnabledProviderIds';
1152
+ const SourceControlGetFileBefore = 'ExtensionHostSourceControl.GetFileBefore';
1150
1153
  const SourceControlGetGroups = 'ExtensionHostSourceControl.getGroups';
1151
1154
 
1152
1155
  const executeCommand = (id, ...args) => {
@@ -1183,8 +1186,8 @@ const getDisplayItemsGroup = (group, isExpanded) => {
1183
1186
  throw new Error('Source control group is missing an items property');
1184
1187
  }
1185
1188
  const length = items.length;
1186
- const type = DirectoryExpanded ;
1187
- const icon = 'ChevronDown' ;
1189
+ const type = isExpanded ? DirectoryExpanded : Directory;
1190
+ const icon = isExpanded ? 'ChevronDown' : 'ChevronRight';
1188
1191
  if (length > 0) {
1189
1192
  displayItems.push({
1190
1193
  file: '',
@@ -1201,7 +1204,7 @@ const getDisplayItemsGroup = (group, isExpanded) => {
1201
1204
  groupId: id
1202
1205
  });
1203
1206
  }
1204
- {
1207
+ if (isExpanded) {
1205
1208
  for (let i = 0; i < length; i++) {
1206
1209
  const item = items[i];
1207
1210
  const {
@@ -1236,7 +1239,7 @@ const getDisplayItemsGroup = (group, isExpanded) => {
1236
1239
  const getDisplayItems = (allGroups, isExpanded) => {
1237
1240
  const displayItems = [];
1238
1241
  for (const group of allGroups) {
1239
- const groupDisplayItems = getDisplayItemsGroup(group);
1242
+ const groupDisplayItems = getDisplayItemsGroup(group, isExpanded);
1240
1243
  displayItems.push(...groupDisplayItems);
1241
1244
  }
1242
1245
  return displayItems;
@@ -1318,6 +1321,14 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
1318
1321
  return finalDeltaY;
1319
1322
  };
1320
1323
 
1324
+ const getFileBefore$1 = (providerId, path) => {
1325
+ return executeProvider({
1326
+ event: 'none',
1327
+ method: SourceControlGetFileBefore,
1328
+ params: [providerId, path]
1329
+ // noProviderFoundMessage: 'No source control provider found',
1330
+ });
1331
+ };
1321
1332
  const getGroups$2 = (providerId, path) => {
1322
1333
  return executeProvider({
1323
1334
  event: 'none',
@@ -1335,6 +1346,9 @@ const getEnabledProviderIds$1 = (scheme, root) => {
1335
1346
  });
1336
1347
  };
1337
1348
 
1349
+ const getFileBefore = (providerId, file) => {
1350
+ return getFileBefore$1(providerId, file);
1351
+ };
1338
1352
  const getEnabledProviderIds = (scheme, root) => {
1339
1353
  string(scheme);
1340
1354
  string(root);
@@ -1368,40 +1382,21 @@ const getListHeight = (itemsLength, itemHeight, maxHeight) => {
1368
1382
  return Math.min(totalHeight, maxHeight);
1369
1383
  };
1370
1384
 
1371
- // TODO optimize this function to return the minimum number
1372
- // of visible items needed, e.g. when not scrolled 5 items with
1373
- // 20px fill 100px but when scrolled 6 items are needed
1374
- const getNumberOfVisibleItems = (listHeight, itemHeight) => {
1375
- return Math.ceil(listHeight / itemHeight) + 1;
1376
- };
1377
-
1378
- const Disk = 'file';
1379
-
1380
- const RE_PROTOCOL = /^([a-z-]+):\/\//;
1381
- const getProtocol = uri => {
1382
- if (!uri) {
1383
- return Disk;
1384
- }
1385
- const protocolMatch = uri.match(RE_PROTOCOL);
1386
- if (protocolMatch) {
1387
- return protocolMatch[1];
1388
- }
1389
- return Disk;
1390
- };
1391
-
1392
- const get = key => {
1393
- return false;
1385
+ const getExtensions = async () => {
1386
+ return invoke('Extensions.getExtensions');
1394
1387
  };
1395
1388
 
1396
- const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1397
- if (size >= contentSize) {
1398
- return 0;
1389
+ const requestSourceActions = async () => {
1390
+ const extensions = await getExtensions();
1391
+ const newCache = Object.create(null);
1392
+ for (const extension of extensions) {
1393
+ if (extension && extension['source-control-actions']) {
1394
+ for (const [key, value] of Object.entries(extension['source-control-actions'])) {
1395
+ newCache.cache[key] = value;
1396
+ }
1397
+ }
1399
1398
  }
1400
- return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
1401
- };
1402
-
1403
- const getExtensions = async () => {
1404
- return invoke('Extensions.getExtensions');
1399
+ return newCache;
1405
1400
  };
1406
1401
 
1407
1402
  const state = {
@@ -1417,14 +1412,8 @@ const ensureActions = async () => {
1417
1412
  if (Object.keys(state.cache).length > 0) {
1418
1413
  return;
1419
1414
  }
1420
- const extensions = await getExtensions();
1421
- for (const extension of extensions) {
1422
- if (extension && extension['source-control-actions']) {
1423
- for (const [key, value] of Object.entries(extension['source-control-actions'])) {
1424
- state.cache[key] = value;
1425
- }
1426
- }
1427
- }
1415
+ const newCache = await requestSourceActions();
1416
+ state.cache = newCache;
1428
1417
  };
1429
1418
  const getSourceControlActions = async (providerId, groupId, type) => {
1430
1419
  string(groupId);
@@ -1434,7 +1423,7 @@ const getSourceControlActions = async (providerId, groupId, type) => {
1434
1423
  return value;
1435
1424
  };
1436
1425
 
1437
- const getNewButtons = async (displayItems, providerId, buttonIndex) => {
1426
+ const getNewButtons = async (displayItems, providerId, buttonIndex, actionsCache) => {
1438
1427
  if (buttonIndex === -1) {
1439
1428
  return [];
1440
1429
  }
@@ -1445,14 +1434,48 @@ const getNewButtons = async (displayItems, providerId, buttonIndex) => {
1445
1434
  const actions = await getSourceControlActions(providerId, item.groupId, item.type);
1446
1435
  return actions;
1447
1436
  };
1437
+
1438
+ // TODO optimize this function to return the minimum number
1439
+ // of visible items needed, e.g. when not scrolled 5 items with
1440
+ // 20px fill 100px but when scrolled 6 items are needed
1441
+ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
1442
+ return Math.ceil(listHeight / itemHeight) + 1;
1443
+ };
1444
+
1445
+ const Disk = 'file';
1446
+
1447
+ const RE_PROTOCOL = /^([a-z-]+):\/\//;
1448
+ const getProtocol = uri => {
1449
+ if (!uri) {
1450
+ return Disk;
1451
+ }
1452
+ const protocolMatch = uri.match(RE_PROTOCOL);
1453
+ if (protocolMatch) {
1454
+ return protocolMatch[1];
1455
+ }
1456
+ return Disk;
1457
+ };
1458
+
1459
+ const get = key => {
1460
+ return false;
1461
+ };
1462
+
1463
+ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1464
+ if (size >= contentSize) {
1465
+ return 0;
1466
+ }
1467
+ return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
1468
+ };
1469
+
1448
1470
  const loadContent = async state => {
1449
1471
  const {
1450
1472
  itemHeight,
1451
1473
  height,
1452
1474
  minimumSliderSize,
1453
1475
  workspacePath,
1454
- fileIconCache
1455
- } = state;
1476
+ fileIconCache,
1477
+ providerId,
1478
+ buttonIndex} = state;
1456
1479
  const root = workspacePath;
1457
1480
  const scheme = getProtocol(root);
1458
1481
  const enabledProviderIds = await getEnabledProviderIds(scheme, root);
@@ -1461,8 +1484,8 @@ const loadContent = async state => {
1461
1484
  gitRoot
1462
1485
  } = await getGroups(enabledProviderIds);
1463
1486
  const isExpanded = true;
1464
- const items = getDisplayItems(allGroups);
1465
- const buttons = await getNewButtons(items, state.providerId, state.buttonIndex);
1487
+ const items = getDisplayItems(allGroups, isExpanded);
1488
+ const buttons = await getNewButtons(items, providerId, buttonIndex);
1466
1489
  const splitButtonEnabled = get();
1467
1490
  const total = items.length;
1468
1491
  const contentHeight = total * itemHeight;
@@ -1509,6 +1532,98 @@ const handleButtonClick = async (state, clickedIndex) => {
1509
1532
  return newState;
1510
1533
  };
1511
1534
 
1535
+ const getIndex = (state, eventX, eventY) => {
1536
+ const {
1537
+ headerHeight,
1538
+ y,
1539
+ itemHeight
1540
+ } = state;
1541
+ const relativeY = eventY - y - headerHeight;
1542
+ const index = Math.floor(relativeY / itemHeight);
1543
+ return index;
1544
+ };
1545
+
1546
+ const handleClickDirectory = async (state, item) => {
1547
+ const {
1548
+ allGroups
1549
+ } = state;
1550
+ const isExpanded = true;
1551
+ const displayItems = getDisplayItems(allGroups, isExpanded);
1552
+ const newMaxLineY = displayItems.length;
1553
+ return {
1554
+ ...state,
1555
+ items: displayItems,
1556
+ isExpanded,
1557
+ maxLineY: newMaxLineY
1558
+ };
1559
+ };
1560
+
1561
+ const handleClickDirectoryExpanded = async (state, item) => {
1562
+ const {
1563
+ allGroups,
1564
+ maxLineY
1565
+ } = state;
1566
+ const isExpanded = false;
1567
+ const displayItems = getDisplayItems(allGroups, isExpanded);
1568
+ const newMaxLineY = Math.min(displayItems.length, maxLineY);
1569
+ return {
1570
+ ...state,
1571
+ items: displayItems,
1572
+ isExpanded,
1573
+ maxLineY: newMaxLineY
1574
+ };
1575
+ };
1576
+
1577
+ const readFile = async (uri, encoding = 'utf8') => {
1578
+ const content = await invoke$1('FileSystem.readFile', uri);
1579
+ return content;
1580
+ };
1581
+
1582
+ const openUri = uri => {
1583
+ return invoke$1('Main.openUri', uri);
1584
+ };
1585
+
1586
+ const handleClickFile = async (state, item) => {
1587
+ const {
1588
+ enabledProviderIds,
1589
+ root
1590
+ } = state;
1591
+ const providerId = enabledProviderIds[0];
1592
+ const absolutePath = `${root}/${item.file}`;
1593
+ // TODO handle error
1594
+ const [fileBefore] = await Promise.all([getFileBefore(providerId, item.file), readFile(absolutePath)]);
1595
+ {
1596
+ await openUri(`inline-diff://data://${fileBefore}<->${absolutePath}`);
1597
+ }
1598
+ return state;
1599
+ };
1600
+
1601
+ const selectIndex = async (state, index) => {
1602
+ const {
1603
+ items
1604
+ } = state;
1605
+ if (index < 0 || index >= items.length) {
1606
+ return state;
1607
+ }
1608
+ const item = items[index];
1609
+ switch (item.type) {
1610
+ case Directory:
1611
+ return handleClickDirectory(state);
1612
+ case DirectoryExpanded:
1613
+ return handleClickDirectoryExpanded(state);
1614
+ case File:
1615
+ return handleClickFile(state, item);
1616
+ default:
1617
+ console.warn(`unknown item type: ${item.type}`);
1618
+ return state;
1619
+ }
1620
+ };
1621
+
1622
+ const handleClickAt = async (state, eventX, eventY) => {
1623
+ const index = getIndex(state, eventX, eventY);
1624
+ return selectIndex(state, index);
1625
+ };
1626
+
1512
1627
  const show = async (x, y, id, ...args) => {
1513
1628
  return invoke$1('ContextMenu.show', x, y, id, ...args);
1514
1629
  };
@@ -1520,6 +1635,55 @@ const handleContextMenu = async (state, button, x, y) => {
1520
1635
  return state;
1521
1636
  };
1522
1637
 
1638
+ const handleFocus = async state => {
1639
+ return state;
1640
+ };
1641
+
1642
+ const handleMouseOut = (state, index) => {
1643
+ const {
1644
+ items
1645
+ } = state;
1646
+ if (index === -1 || index > items.length) {
1647
+ return {
1648
+ ...state,
1649
+ buttonIndex: -1,
1650
+ buttons: []
1651
+ };
1652
+ }
1653
+ return state;
1654
+ };
1655
+
1656
+ const handleMouseOutAt = (state, eventX, eventY) => {
1657
+ const index = getIndex(state, eventX, eventY);
1658
+ return handleMouseOut(state, index);
1659
+ };
1660
+
1661
+ const handleMouseOver = async (state, index) => {
1662
+ const {
1663
+ items,
1664
+ providerId,
1665
+ buttonIndex
1666
+ } = state;
1667
+ if (index === buttonIndex) {
1668
+ return state;
1669
+ }
1670
+ const item = items[index];
1671
+ if (!item) {
1672
+ return state;
1673
+ }
1674
+ const actions = await getSourceControlActions(providerId, item.groupId, item.type);
1675
+ return {
1676
+ ...state,
1677
+ buttonIndex: index,
1678
+ buttons: actions
1679
+ };
1680
+ };
1681
+
1682
+ const handleMouseOverAt = async (state, eventX, eventY) => {
1683
+ const index = getIndex(state, eventX, eventY);
1684
+ return handleMouseOver(state, index);
1685
+ };
1686
+
1523
1687
  const getPortTuple = () => {
1524
1688
  const {
1525
1689
  port1,
@@ -1562,6 +1726,7 @@ const initialize = async () => {
1562
1726
  };
1563
1727
 
1564
1728
  const Actions = 'Actions';
1729
+ const Grow = 'Grow';
1565
1730
  const Chevron = 'Chevron';
1566
1731
  const ChevronRight = 'ChevronRight';
1567
1732
  const DecorationIcon = 'DecorationIcon';
@@ -1588,20 +1753,16 @@ const StrikeThrough = 'StrikeThrough';
1588
1753
  const TreeItem$1 = 'TreeItem';
1589
1754
  const Viewlet = 'Viewlet';
1590
1755
 
1591
- const HandleClick = 'handleClick';
1592
1756
  const HandleClickAt = 'handleClickAt';
1593
1757
  const HandleContextMenu = 'handleContextMenu';
1594
1758
  const HandleFocus = 'handleFocus';
1595
1759
  const HandleInput = 'handleInput';
1596
1760
  const HandleMouseOut = 'handleMouseOut';
1761
+ const HandleMouseOutAt = 'handleMouseOutAt';
1597
1762
  const HandleMouseOver = 'handleMouseOver';
1763
+ const HandleMouseOverAt = 'handleMouseOverAt';
1598
1764
  const HandleWheel = 'handleWheel';
1599
1765
 
1600
- const None = 'none';
1601
- const ToolBar = 'toolbar';
1602
- const Tree = 'tree';
1603
- const TreeItem = 'treeitem';
1604
-
1605
1766
  const SourceControlInput$1 = 'SourceControlInput';
1606
1767
 
1607
1768
  const emptyObject = {};
@@ -1652,36 +1813,10 @@ const getSourceControlHeaderVirtualDom = () => {
1652
1813
  }];
1653
1814
  };
1654
1815
 
1655
- const emptySourceControlButtons = [];
1656
-
1657
- const getIconVirtualDom = (icon, type = Div) => {
1658
- return {
1659
- type,
1660
- className: `MaskIcon MaskIcon${icon}`,
1661
- role: None,
1662
- childCount: 0
1663
- };
1664
- };
1665
-
1666
- const addButtons = (dom, buttons) => {
1667
- if (buttons === emptySourceControlButtons) {
1668
- return;
1669
- }
1670
- dom[0].childCount += buttons.length;
1671
- for (const button of buttons) {
1672
- const {
1673
- icon,
1674
- label
1675
- } = button;
1676
- dom.push({
1677
- type: Button$1,
1678
- className: SourceControlButton,
1679
- title: label,
1680
- ariaLabel: label,
1681
- childCount: 1
1682
- }, getIconVirtualDom(icon, Span));
1683
- }
1684
- };
1816
+ const None = 'none';
1817
+ const ToolBar = 'toolbar';
1818
+ const Tree = 'tree';
1819
+ const TreeItem = 'treeitem';
1685
1820
 
1686
1821
  const mergeClassNames = (...classNames) => {
1687
1822
  return classNames.filter(Boolean).join(' ');
@@ -1703,10 +1838,46 @@ const getBadgeVirtualDom = (className, count) => {
1703
1838
  }, text(`${count}`)];
1704
1839
  };
1705
1840
 
1841
+ const emptySourceControlButtons = [];
1842
+
1843
+ const getIconVirtualDom = (icon, type = Div) => {
1844
+ return {
1845
+ type,
1846
+ className: `MaskIcon MaskIcon${icon}`,
1847
+ role: None,
1848
+ childCount: 0
1849
+ };
1850
+ };
1851
+
1852
+ const getButtonVirtualDom = button => {
1853
+ const {
1854
+ icon,
1855
+ label
1856
+ } = button;
1857
+ return [{
1858
+ type: Button$1,
1859
+ className: SourceControlButton,
1860
+ title: label,
1861
+ ariaLabel: label,
1862
+ childCount: 1
1863
+ }, getIconVirtualDom(icon, Span)];
1864
+ };
1865
+
1866
+ const getButtonsVirtualDom = buttons => {
1867
+ if (buttons === emptySourceControlButtons) {
1868
+ return [];
1869
+ }
1870
+ return [{
1871
+ type: Div,
1872
+ className: 'SourceControlButtons',
1873
+ childCount: buttons.length
1874
+ }, ...buttons.flatMap(getButtonVirtualDom)];
1875
+ };
1876
+
1706
1877
  const getLabelClassName = decorationStrikeThrough => {
1707
- let className = Label + ' Grow';
1878
+ let className = mergeClassNames(Label, Grow);
1708
1879
  if (decorationStrikeThrough) {
1709
- className += ` ${StrikeThrough}`;
1880
+ className = mergeClassNames(className, StrikeThrough);
1710
1881
  }
1711
1882
  return className;
1712
1883
  };
@@ -1726,28 +1897,27 @@ const createItemDirectory = item => {
1726
1897
  buttons
1727
1898
  } = item;
1728
1899
  const labelClassName = getLabelClassName(decorationStrikeThrough);
1729
- const dom = [{
1900
+ const buttonsDom = getButtonsVirtualDom(buttons);
1901
+ const hasButtons = buttons.length;
1902
+ return [{
1730
1903
  type: Div,
1731
1904
  className: TreeItem$1,
1732
1905
  role: TreeItem,
1733
1906
  ariaExpanded: type === DirectoryExpanded,
1734
1907
  ariaPosInSet: posInSet,
1735
1908
  ariaSetSize: setSize,
1736
- childCount: 3,
1909
+ childCount: 3 + (hasButtons ? 1 : 0),
1737
1910
  paddingLeft: PaddingLeft,
1738
1911
  paddingRight: PaddingRight
1739
1912
  }, {
1740
1913
  type: Div,
1741
- className: `${Chevron} MaskIcon${icon}`,
1914
+ className: mergeClassNames(Chevron, `MaskIcon${icon}`),
1742
1915
  childCount: 0
1743
1916
  }, {
1744
1917
  type: Div,
1745
1918
  className: labelClassName,
1746
1919
  childCount: 1
1747
- }, text(label)];
1748
- addButtons(dom, buttons);
1749
- dom.push(...getBadgeVirtualDom(SourceControlBadge, badgeCount));
1750
- return dom;
1920
+ }, text(label), ...buttonsDom, ...getBadgeVirtualDom(SourceControlBadge, badgeCount)];
1751
1921
  };
1752
1922
 
1753
1923
  const getFileIconVirtualDom = icon => {
@@ -1787,6 +1957,8 @@ const createItemOther = item => {
1787
1957
  } = item;
1788
1958
  const labelClassName = getLabelClassName(decorationStrikeThrough);
1789
1959
  const dom = [];
1960
+ const hasButtons = buttons.length;
1961
+ const buttonsDom = getButtonsVirtualDom(buttons);
1790
1962
  dom.push({
1791
1963
  type: Div,
1792
1964
  className: TreeItem$1,
@@ -1794,7 +1966,7 @@ const createItemOther = item => {
1794
1966
  ariaPosInSet: posInSet,
1795
1967
  ariaSetSize: setSize,
1796
1968
  title: file,
1797
- childCount: 3,
1969
+ childCount: 3 + (hasButtons ? 1 : 0),
1798
1970
  paddingLeft: '1rem',
1799
1971
  paddingRight: '12px'
1800
1972
  }, ...getIconsDom(icon, fileIcon));
@@ -1812,7 +1984,7 @@ const createItemOther = item => {
1812
1984
  childCount: 1
1813
1985
  }, text(detail));
1814
1986
  }
1815
- addButtons(dom, buttons);
1987
+ dom.push(...buttonsDom);
1816
1988
  dom.push({
1817
1989
  type: Img,
1818
1990
  className: DecorationIcon,
@@ -1833,9 +2005,23 @@ const getSourceControlItemVirtualDom = item => {
1833
2005
  }
1834
2006
  };
1835
2007
 
1836
- const getSourceControlItemsVirtualDom$1 = (hasItems, buttonText) => {
1837
- const dom = [];
1838
- dom.push({
2008
+ const getSourceControlListVirtualDom = items => {
2009
+ return [{
2010
+ type: Div,
2011
+ className: SourceControlItems,
2012
+ role: Tree,
2013
+ childCount: items.length,
2014
+ onClick: HandleClickAt,
2015
+ onPointerOver: HandleMouseOverAt,
2016
+ onPointerOut: HandleMouseOutAt
2017
+ }, ...items.flatMap(getSourceControlItemVirtualDom)];
2018
+ };
2019
+
2020
+ const getSplitButtonVirtualDom = (hasItems, splitButtonEnabled, buttonText) => {
2021
+ if (!splitButtonEnabled || !hasItems) {
2022
+ return [];
2023
+ }
2024
+ return [{
1839
2025
  type: Div,
1840
2026
  className: `${SplitButton} ${hasItems ? '' : SplitButtonDisabled}`,
1841
2027
  childCount: 3
@@ -1857,38 +2043,21 @@ const getSourceControlItemsVirtualDom$1 = (hasItems, buttonText) => {
1857
2043
  type: Div,
1858
2044
  className: `${MaskIcon} ${MaskIconChevronDown}`,
1859
2045
  childCount: 0
1860
- });
1861
- return dom;
1862
- };
1863
-
1864
- const getSourceControlItemsVirtualDom = (items, splitButtonEnabled) => {
1865
- const dom = [];
1866
- dom.push(...getSourceControlHeaderVirtualDom());
1867
- if (splitButtonEnabled) {
1868
- const hasItems = items.length > 0;
1869
- dom.push(...getSourceControlItemsVirtualDom$1(hasItems, 'Commit'));
1870
- }
1871
- dom.push({
1872
- type: Div,
1873
- className: SourceControlItems,
1874
- role: Tree,
1875
- childCount: items.length
1876
- }, ...items.flatMap(getSourceControlItemVirtualDom));
1877
- return dom;
2046
+ }];
1878
2047
  };
1879
2048
 
1880
2049
  const getSourceControlVirtualDom = (items, splitButtonEnabled) => {
2050
+ const hasItems = items.length > 0;
1881
2051
  const dom = [{
1882
2052
  type: Div,
1883
2053
  className: mergeClassNames(Viewlet, SourceControl),
1884
2054
  tabIndex: 0,
1885
- onClick: HandleClick,
1886
2055
  onContextMenu: HandleContextMenu,
1887
2056
  onMouseOver: HandleMouseOver,
1888
2057
  onMouseOut: HandleMouseOut,
1889
2058
  onWheel: HandleWheel,
1890
2059
  childCount: splitButtonEnabled ? 3 : 2
1891
- }, ...getSourceControlItemsVirtualDom(items, splitButtonEnabled)];
2060
+ }, ...getSourceControlHeaderVirtualDom(), ...getSplitButtonVirtualDom(hasItems, splitButtonEnabled, 'Commit'), ...getSourceControlListVirtualDom(items)];
1892
2061
  return dom;
1893
2062
  };
1894
2063
 
@@ -1996,9 +2165,15 @@ const renderEventListeners = () => {
1996
2165
  }, {
1997
2166
  name: HandleClickAt,
1998
2167
  params: ['handleClickAt', 'event.clientX', 'event.clientY']
2168
+ }, {
2169
+ name: HandleMouseOverAt,
2170
+ params: ['handleMouseOverAt', 'event.clientX', 'event.clientY']
1999
2171
  }, {
2000
2172
  name: HandleMouseOver,
2001
2173
  params: ['handleMouseOver', 'event.clientX', 'event.clientY']
2174
+ }, {
2175
+ name: HandleMouseOutAt,
2176
+ params: ['handleMouseOutAt', 'event.clientX', 'event.clientY']
2002
2177
  }, {
2003
2178
  name: HandleInput,
2004
2179
  params: ['handleInput', 'event.target.value']
@@ -2021,13 +2196,15 @@ const saveState = uid => {
2021
2196
  } = value;
2022
2197
  const {
2023
2198
  root,
2024
- maxLineY
2199
+ maxLineY,
2200
+ isExpanded
2025
2201
  } = newState;
2026
2202
  return {
2027
2203
  root,
2028
2204
  minLineY: 0,
2029
2205
  maxLineY,
2030
- deltaY: 0
2206
+ deltaY: 0,
2207
+ isExpanded
2031
2208
  };
2032
2209
  };
2033
2210
 
@@ -2059,12 +2236,19 @@ const commandMap = {
2059
2236
  'SourceControl.diff2': diff2,
2060
2237
  'SourceControl.getCommandIds': getCommandIds,
2061
2238
  'SourceControl.handleButtonClick': wrapCommand(handleButtonClick),
2239
+ 'SourceControl.handleClickAt': wrapCommand(handleClickAt),
2062
2240
  'SourceControl.handleContextMenu': wrapCommand(handleContextMenu),
2241
+ 'SourceControl.handleFocus': wrapCommand(handleFocus),
2242
+ 'SourceControl.handleMouseOut': wrapCommand(handleMouseOut),
2243
+ 'SourceControl.handleMouseOutAt': wrapCommand(handleMouseOutAt),
2244
+ 'SourceControl.handleMouseOver': wrapCommand(handleMouseOver),
2245
+ 'SourceControl.handleMouseOverAt': wrapCommand(handleMouseOverAt),
2063
2246
  'SourceControl.loadContent': wrapCommand(loadContent),
2064
2247
  'SourceControl.render2': render2,
2065
2248
  'SourceControl.renderActions2': renderActions,
2066
2249
  'SourceControl.renderEventListeners': renderEventListeners,
2067
2250
  'SourceControl.saveState': saveState,
2251
+ 'SourceControl.selectIndex': wrapCommand(selectIndex),
2068
2252
  'SourceControl.terminate': terminate,
2069
2253
  'SourceControl.updateIcons': wrapCommand(updateIcons)
2070
2254
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/source-control-worker",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"