@lvce-editor/source-control-worker 1.8.0 → 1.10.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.
@@ -1097,7 +1097,7 @@ const diff2 = uid => {
1097
1097
  return result;
1098
1098
  };
1099
1099
 
1100
- const commandIds = ['acceptInput', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'handleClick', 'handleClickAt', 'handleFocus', 'handleIconThemeChange', 'handleMouseOut', 'handleMouseOutAt', 'handleMouseOver', 'handleMouseOverAt', 'handleWheel', 'selectIndex'];
1100
+ const commandIds = ['acceptInput', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'refresh', 'handleClickSourceControlButtons', 'handleClick', 'handleClickAt', 'handleFocus', 'handleIconThemeChange', 'handleMouseOut', 'handleMouseOutAt', 'handleMouseOver', 'handleMouseOverAt', 'handleWheel', 'selectIndex'];
1101
1101
 
1102
1102
  const getCommandIds = () => {
1103
1103
  return commandIds;
@@ -1173,7 +1173,7 @@ const executeProvider = async ({
1173
1173
 
1174
1174
  const CommandExecute = 'ExtensionHostCommand.executeCommand';
1175
1175
  const SourceControlGetEnabledProviderIds = 'ExtensionHostSourceControl.getEnabledProviderIds';
1176
- const SourceControlGetFileBefore = 'ExtensionHostSourceControl.GetFileBefore';
1176
+ const SourceControlGetFileBefore = 'ExtensionHostSourceControl.getFileBefore';
1177
1177
  const SourceControlGetGroups = 'ExtensionHostSourceControl.getGroups';
1178
1178
 
1179
1179
  const executeCommand = (id, ...args) => {
@@ -1531,6 +1531,65 @@ const getIndex = (state, eventX, eventY) => {
1531
1531
  return index;
1532
1532
  };
1533
1533
 
1534
+ const refresh = async state => {
1535
+ const {
1536
+ itemHeight,
1537
+ height,
1538
+ minimumSliderSize,
1539
+ fileIconCache,
1540
+ enabledProviderIds,
1541
+ splitButtonEnabled,
1542
+ actionsCache
1543
+ } = state;
1544
+ const {
1545
+ allGroups,
1546
+ gitRoot
1547
+ } = await getGroups(enabledProviderIds);
1548
+ const isExpanded = true;
1549
+ const displayItems = getDisplayItems(allGroups, isExpanded);
1550
+ const total = displayItems.length;
1551
+ const contentHeight = total * itemHeight;
1552
+ const listHeight = getListHeight(total, itemHeight, height);
1553
+ const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
1554
+ const numberOfVisible = getNumberOfVisibleItems(listHeight, itemHeight);
1555
+ const minLineY = 0;
1556
+ const maxLineY = Math.min(numberOfVisible, total);
1557
+ const visibleItems = getVisibleSourceControlItems(displayItems, minLineY, maxLineY, actionsCache, fileIconCache);
1558
+ const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
1559
+ return {
1560
+ ...state,
1561
+ allGroups,
1562
+ gitRoot,
1563
+ items: displayItems,
1564
+ visibleItems,
1565
+ enabledProviderIds,
1566
+ isExpanded,
1567
+ splitButtonEnabled,
1568
+ maxLineY,
1569
+ scrollBarHeight,
1570
+ finalDeltaY,
1571
+ actionsCache
1572
+ };
1573
+ };
1574
+
1575
+ const handleClickSourceControlButtons = async (state, index, name) => {
1576
+ const {
1577
+ visibleItems
1578
+ } = state;
1579
+ const item = visibleItems[index];
1580
+ if (!item) {
1581
+ return state;
1582
+ }
1583
+ const button = item.buttons.find(button => button.label === name);
1584
+ if (!button) {
1585
+ return state;
1586
+ }
1587
+ const file = item.file;
1588
+ await executeCommand(button.command, file);
1589
+ const newState = await refresh(state);
1590
+ return newState;
1591
+ };
1592
+
1534
1593
  const updateVisibleItems = async (state, isExpanded) => {
1535
1594
  const {
1536
1595
  allGroups,
@@ -1618,8 +1677,11 @@ const selectIndex = async (state, index) => {
1618
1677
  }
1619
1678
  };
1620
1679
 
1621
- const handleClickAt = async (state, eventX, eventY) => {
1680
+ const handleClickAt = async (state, eventX, eventY, name) => {
1622
1681
  const index = getIndex(state, eventX, eventY);
1682
+ if (name) {
1683
+ return handleClickSourceControlButtons(state, index, name);
1684
+ }
1623
1685
  return selectIndex(state, index);
1624
1686
  };
1625
1687
 
@@ -1713,11 +1775,11 @@ const getPortTuple = () => {
1713
1775
  };
1714
1776
  };
1715
1777
 
1716
- const DebugWorker = 55;
1778
+ const SourceControlWorker = 66;
1717
1779
 
1718
1780
  const sendMessagePortToExtensionHostWorker = async port => {
1719
1781
  const command = 'HandleMessagePort.handleMessagePort2';
1720
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, DebugWorker);
1782
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, SourceControlWorker);
1721
1783
  };
1722
1784
 
1723
1785
  const createExtensionHostRpc = async () => {
@@ -1743,6 +1805,7 @@ const initialize = async () => {
1743
1805
  };
1744
1806
 
1745
1807
  const Actions = 'Actions';
1808
+ const SourceControlButtons = 'SourceControlButtons';
1746
1809
  const Grow = 'Grow';
1747
1810
  const Chevron = 'Chevron';
1748
1811
  const ChevronRight = 'ChevronRight';
@@ -1874,7 +1937,8 @@ const getButtonVirtualDom = button => {
1874
1937
  className: SourceControlButton,
1875
1938
  title: label,
1876
1939
  ariaLabel: label,
1877
- childCount: 1
1940
+ childCount: 1,
1941
+ name: label
1878
1942
  }, getIconVirtualDom(icon, Span)];
1879
1943
  };
1880
1944
 
@@ -1884,7 +1948,7 @@ const getButtonsVirtualDom = buttons => {
1884
1948
  }
1885
1949
  return [{
1886
1950
  type: Div,
1887
- className: 'SourceControlButtons',
1951
+ className: SourceControlButtons,
1888
1952
  childCount: buttons.length
1889
1953
  }, ...buttons.flatMap(getButtonVirtualDom)];
1890
1954
  };
@@ -2164,7 +2228,7 @@ const renderEventListeners = () => {
2164
2228
  params: ['handleFocus']
2165
2229
  }, {
2166
2230
  name: HandleClickAt,
2167
- params: ['handleClickAt', 'event.clientX', 'event.clientY']
2231
+ params: ['handleClickAt', 'event.clientX', 'event.clientY', 'event.target.name']
2168
2232
  }, {
2169
2233
  name: HandleMouseOverAt,
2170
2234
  params: ['handleMouseOverAt', 'event.clientX', 'event.clientY']
@@ -2234,20 +2298,22 @@ const commandMap = {
2234
2298
  'SourceControl.getCommandIds': getCommandIds,
2235
2299
  'SourceControl.handleButtonClick': wrapCommand(handleButtonClick),
2236
2300
  'SourceControl.handleClickAt': wrapCommand(handleClickAt),
2301
+ 'SourceControl.handleClickSourceControlButtons': wrapCommand(handleClickSourceControlButtons),
2237
2302
  'SourceControl.handleContextMenu': wrapCommand(handleContextMenu),
2238
2303
  'SourceControl.handleFocus': wrapCommand(handleFocus),
2239
2304
  'SourceControl.handleMouseOut': wrapCommand(handleMouseOut),
2240
2305
  'SourceControl.handleMouseOutAt': wrapCommand(handleMouseOutAt),
2241
2306
  'SourceControl.handleMouseOver': wrapCommand(handleMouseOver),
2242
2307
  'SourceControl.handleMouseOverAt': wrapCommand(handleMouseOverAt),
2243
- 'SourceControl.setDeltaY': wrapCommand(setDeltaY),
2244
2308
  'SourceControl.handleWheel': wrapCommand(handleWheel),
2245
2309
  'SourceControl.loadContent': wrapCommand(loadContent),
2310
+ 'SourceControl.refresh': wrapCommand(refresh),
2246
2311
  'SourceControl.render2': render2,
2247
2312
  'SourceControl.renderActions2': renderActions,
2248
2313
  'SourceControl.renderEventListeners': renderEventListeners,
2249
2314
  'SourceControl.saveState': saveState,
2250
2315
  'SourceControl.selectIndex': wrapCommand(selectIndex),
2316
+ 'SourceControl.setDeltaY': wrapCommand(setDeltaY),
2251
2317
  'SourceControl.terminate': terminate,
2252
2318
  'SourceControl.updateIcons': wrapCommand(updateIcons)
2253
2319
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/source-control-worker",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"