@lvce-editor/source-control-worker 1.5.0 → 1.6.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.
- package/dist/sourceControlWorkerMain.js +87 -151
- package/package.json +1 -1
|
@@ -1030,41 +1030,39 @@ const {
|
|
|
1030
1030
|
|
|
1031
1031
|
const create2 = (id, uri, x, y, width, height, workspacePath) => {
|
|
1032
1032
|
const state = {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
items: [],
|
|
1036
|
-
x,
|
|
1037
|
-
y,
|
|
1038
|
-
width,
|
|
1039
|
-
height,
|
|
1033
|
+
actionsCache: Object.create(null),
|
|
1034
|
+
allGroups: [],
|
|
1040
1035
|
deltaY: 0,
|
|
1041
|
-
|
|
1042
|
-
maxLineY: 0,
|
|
1036
|
+
enabledProviderIds: [],
|
|
1043
1037
|
fileIconCache: Object.create(null),
|
|
1044
|
-
icons: [],
|
|
1045
1038
|
finalDeltaY: 0,
|
|
1039
|
+
gitRoot: '',
|
|
1046
1040
|
handleOffset: 0,
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1041
|
+
headerHeight: 40,
|
|
1042
|
+
// TODO
|
|
1043
|
+
height,
|
|
1044
|
+
id,
|
|
1050
1045
|
index: [],
|
|
1051
|
-
untracked: [],
|
|
1052
|
-
workingTree: [],
|
|
1053
1046
|
inputValue: '',
|
|
1054
|
-
buttonIndex: -1,
|
|
1055
|
-
enabledProviderIds: [],
|
|
1056
1047
|
isExpanded: true,
|
|
1057
|
-
buttons: [],
|
|
1058
|
-
providerId: '',
|
|
1059
|
-
splitButtonEnabled: false,
|
|
1060
|
-
allGroups: [],
|
|
1061
|
-
gitRoot: '',
|
|
1062
1048
|
itemHeight: 20,
|
|
1049
|
+
items: [],
|
|
1050
|
+
maxLineY: 0,
|
|
1051
|
+
merge: [],
|
|
1063
1052
|
minimumSliderSize: 20,
|
|
1053
|
+
minLineY: 0,
|
|
1054
|
+
providerId: '',
|
|
1055
|
+
root: '',
|
|
1056
|
+
scrollBarActive: false,
|
|
1057
|
+
scrollBarHeight: 0,
|
|
1058
|
+
splitButtonEnabled: false,
|
|
1059
|
+
untracked: [],
|
|
1060
|
+
visibleItems: [],
|
|
1061
|
+
width,
|
|
1062
|
+
workingTree: [],
|
|
1064
1063
|
workspacePath,
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
actionsCache: Object.create(null)
|
|
1064
|
+
x,
|
|
1065
|
+
y
|
|
1068
1066
|
};
|
|
1069
1067
|
set$1(id, state, state);
|
|
1070
1068
|
};
|
|
@@ -1073,7 +1071,7 @@ const RenderItems = 4;
|
|
|
1073
1071
|
|
|
1074
1072
|
const diffType = RenderItems;
|
|
1075
1073
|
const isEqual = (oldState, newState) => {
|
|
1076
|
-
return oldState.allGroups === newState.allGroups && oldState.
|
|
1074
|
+
return oldState.allGroups === newState.allGroups && oldState.visibleItems === newState.visibleItems && oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY;
|
|
1077
1075
|
};
|
|
1078
1076
|
|
|
1079
1077
|
const modules = [isEqual];
|
|
@@ -1245,10 +1243,6 @@ const getDisplayItems = (allGroups, isExpanded) => {
|
|
|
1245
1243
|
return displayItems;
|
|
1246
1244
|
};
|
|
1247
1245
|
|
|
1248
|
-
const getIconsCached = (dirents, fileIconCache) => {
|
|
1249
|
-
return dirents.map(dirent => fileIconCache[dirent]);
|
|
1250
|
-
};
|
|
1251
|
-
|
|
1252
1246
|
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
1253
1247
|
const missingRequests = [];
|
|
1254
1248
|
for (const dirent of dirents) {
|
|
@@ -1263,14 +1257,6 @@ const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
|
1263
1257
|
return missingRequests;
|
|
1264
1258
|
};
|
|
1265
1259
|
|
|
1266
|
-
const getPath = item => {
|
|
1267
|
-
return item.file;
|
|
1268
|
-
};
|
|
1269
|
-
|
|
1270
|
-
const getPaths = items => {
|
|
1271
|
-
return items.map(getPath);
|
|
1272
|
-
};
|
|
1273
|
-
|
|
1274
1260
|
const getFileIcon = async name => {
|
|
1275
1261
|
return invoke$1('IconTheme.getFileIcon', {
|
|
1276
1262
|
name
|
|
@@ -1307,12 +1293,7 @@ const getFileIcons = async (dirents, fileIconCache) => {
|
|
|
1307
1293
|
const missingRequests = getMissingIconRequests(dirents, fileIconCache);
|
|
1308
1294
|
const newIcons = await requestFileIcons(missingRequests);
|
|
1309
1295
|
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
1310
|
-
|
|
1311
|
-
const icons = getIconsCached(paths, newFileIconCache);
|
|
1312
|
-
return {
|
|
1313
|
-
icons,
|
|
1314
|
-
newFileIconCache
|
|
1315
|
-
};
|
|
1296
|
+
return newFileIconCache;
|
|
1316
1297
|
};
|
|
1317
1298
|
|
|
1318
1299
|
const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
@@ -1382,59 +1363,6 @@ const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
|
1382
1363
|
return Math.min(totalHeight, maxHeight);
|
|
1383
1364
|
};
|
|
1384
1365
|
|
|
1385
|
-
const getExtensions = async () => {
|
|
1386
|
-
return invoke('Extensions.getExtensions');
|
|
1387
|
-
};
|
|
1388
|
-
|
|
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
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
return newCache;
|
|
1400
|
-
};
|
|
1401
|
-
|
|
1402
|
-
const state = {
|
|
1403
|
-
cache: Object.create(null)
|
|
1404
|
-
};
|
|
1405
|
-
const getContextId = (groupId, type) => {
|
|
1406
|
-
if (type === File) {
|
|
1407
|
-
return `${groupId}-item`;
|
|
1408
|
-
}
|
|
1409
|
-
return groupId;
|
|
1410
|
-
};
|
|
1411
|
-
const ensureActions = async () => {
|
|
1412
|
-
if (Object.keys(state.cache).length > 0) {
|
|
1413
|
-
return;
|
|
1414
|
-
}
|
|
1415
|
-
const newCache = await requestSourceActions();
|
|
1416
|
-
state.cache = newCache;
|
|
1417
|
-
};
|
|
1418
|
-
const getSourceControlActions = async (providerId, groupId, type) => {
|
|
1419
|
-
string(groupId);
|
|
1420
|
-
await ensureActions();
|
|
1421
|
-
const contextId = getContextId(groupId, type);
|
|
1422
|
-
const value = state.cache[contextId] || [];
|
|
1423
|
-
return value;
|
|
1424
|
-
};
|
|
1425
|
-
|
|
1426
|
-
const getNewButtons = async (displayItems, providerId, buttonIndex, actionsCache) => {
|
|
1427
|
-
if (buttonIndex === -1) {
|
|
1428
|
-
return [];
|
|
1429
|
-
}
|
|
1430
|
-
const item = displayItems[buttonIndex];
|
|
1431
|
-
if (!item) {
|
|
1432
|
-
return [];
|
|
1433
|
-
}
|
|
1434
|
-
const actions = await getSourceControlActions(providerId, item.groupId, item.type);
|
|
1435
|
-
return actions;
|
|
1436
|
-
};
|
|
1437
|
-
|
|
1438
1366
|
// TODO optimize this function to return the minimum number
|
|
1439
1367
|
// of visible items needed, e.g. when not scrolled 5 items with
|
|
1440
1368
|
// 20px fill 100px but when scrolled 6 items are needed
|
|
@@ -1456,10 +1384,52 @@ const getProtocol = uri => {
|
|
|
1456
1384
|
return Disk;
|
|
1457
1385
|
};
|
|
1458
1386
|
|
|
1387
|
+
const emptySourceControlButtons = [];
|
|
1388
|
+
|
|
1389
|
+
const getContextId = (groupId, type) => {
|
|
1390
|
+
if (type === File) {
|
|
1391
|
+
return `${groupId}-item`;
|
|
1392
|
+
}
|
|
1393
|
+
return groupId;
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
const getVisibleSourceControlItems = (items, minLineY, maxLineY, actionsCache, fileIconCache) => {
|
|
1397
|
+
const visible = [];
|
|
1398
|
+
for (let i = minLineY; i < maxLineY; i++) {
|
|
1399
|
+
const item = items[i];
|
|
1400
|
+
const contextId = getContextId(item.groupId, item.type);
|
|
1401
|
+
const buttons = actionsCache[contextId] || emptySourceControlButtons;
|
|
1402
|
+
const fileIcon = fileIconCache[item.file] || '';
|
|
1403
|
+
visible.push({
|
|
1404
|
+
...item,
|
|
1405
|
+
buttons,
|
|
1406
|
+
fileIcon
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
return visible;
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1459
1412
|
const get = key => {
|
|
1460
1413
|
return false;
|
|
1461
1414
|
};
|
|
1462
1415
|
|
|
1416
|
+
const getExtensions = async () => {
|
|
1417
|
+
return invoke('Extensions.getExtensions');
|
|
1418
|
+
};
|
|
1419
|
+
|
|
1420
|
+
const requestSourceActions = async () => {
|
|
1421
|
+
const extensions = await getExtensions();
|
|
1422
|
+
const newCache = Object.create(null);
|
|
1423
|
+
for (const extension of extensions) {
|
|
1424
|
+
if (extension && extension['source-control-actions']) {
|
|
1425
|
+
for (const [key, value] of Object.entries(extension['source-control-actions'])) {
|
|
1426
|
+
newCache[key] = value;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
return newCache;
|
|
1431
|
+
};
|
|
1432
|
+
|
|
1463
1433
|
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
1464
1434
|
if (size >= contentSize) {
|
|
1465
1435
|
return 0;
|
|
@@ -1473,9 +1443,8 @@ const loadContent = async state => {
|
|
|
1473
1443
|
height,
|
|
1474
1444
|
minimumSliderSize,
|
|
1475
1445
|
workspacePath,
|
|
1476
|
-
fileIconCache
|
|
1477
|
-
|
|
1478
|
-
buttonIndex} = state;
|
|
1446
|
+
fileIconCache
|
|
1447
|
+
} = state;
|
|
1479
1448
|
const root = workspacePath;
|
|
1480
1449
|
const scheme = getProtocol(root);
|
|
1481
1450
|
const enabledProviderIds = await getEnabledProviderIds(scheme, root);
|
|
@@ -1484,46 +1453,43 @@ const loadContent = async state => {
|
|
|
1484
1453
|
gitRoot
|
|
1485
1454
|
} = await getGroups(enabledProviderIds);
|
|
1486
1455
|
const isExpanded = true;
|
|
1487
|
-
const
|
|
1488
|
-
const
|
|
1456
|
+
const displayItems = getDisplayItems(allGroups, isExpanded);
|
|
1457
|
+
const cache = await requestSourceActions();
|
|
1489
1458
|
const splitButtonEnabled = get();
|
|
1490
|
-
const total =
|
|
1459
|
+
const total = displayItems.length;
|
|
1491
1460
|
const contentHeight = total * itemHeight;
|
|
1492
1461
|
const listHeight = getListHeight(total, itemHeight, height);
|
|
1493
1462
|
const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
|
|
1494
1463
|
const numberOfVisible = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1464
|
+
const minLineY = 0;
|
|
1495
1465
|
const maxLineY = Math.min(numberOfVisible, total);
|
|
1466
|
+
const slicedItems = displayItems.slice(minLineY, maxLineY);
|
|
1467
|
+
const newFileIconCache = await getFileIcons(slicedItems, fileIconCache);
|
|
1468
|
+
const visibleItems = getVisibleSourceControlItems(displayItems, minLineY, maxLineY, cache, newFileIconCache);
|
|
1496
1469
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
1497
|
-
const {
|
|
1498
|
-
icons,
|
|
1499
|
-
newFileIconCache
|
|
1500
|
-
} = await getFileIcons(items, fileIconCache);
|
|
1501
1470
|
return {
|
|
1502
1471
|
...state,
|
|
1503
1472
|
allGroups,
|
|
1504
1473
|
gitRoot,
|
|
1505
|
-
items,
|
|
1474
|
+
items: displayItems,
|
|
1475
|
+
visibleItems,
|
|
1506
1476
|
enabledProviderIds,
|
|
1507
1477
|
isExpanded,
|
|
1508
|
-
buttons,
|
|
1509
1478
|
root,
|
|
1510
1479
|
splitButtonEnabled,
|
|
1511
1480
|
maxLineY,
|
|
1512
1481
|
scrollBarHeight,
|
|
1513
1482
|
finalDeltaY,
|
|
1514
|
-
icons,
|
|
1515
1483
|
fileIconCache: newFileIconCache
|
|
1516
1484
|
};
|
|
1517
1485
|
};
|
|
1518
1486
|
|
|
1519
1487
|
const handleButtonClick = async (state, clickedIndex) => {
|
|
1520
1488
|
const {
|
|
1521
|
-
|
|
1522
|
-
buttons,
|
|
1523
|
-
items
|
|
1489
|
+
visibleItems
|
|
1524
1490
|
} = state;
|
|
1525
|
-
const
|
|
1526
|
-
const
|
|
1491
|
+
const item = visibleItems[clickedIndex];
|
|
1492
|
+
const button = item.buttons[clickedIndex];
|
|
1527
1493
|
if (!button) {
|
|
1528
1494
|
return state;
|
|
1529
1495
|
}
|
|
@@ -1645,9 +1611,7 @@ const handleMouseOut = (state, index) => {
|
|
|
1645
1611
|
} = state;
|
|
1646
1612
|
if (index === -1 || index > items.length) {
|
|
1647
1613
|
return {
|
|
1648
|
-
...state
|
|
1649
|
-
buttonIndex: -1,
|
|
1650
|
-
buttons: []
|
|
1614
|
+
...state
|
|
1651
1615
|
};
|
|
1652
1616
|
}
|
|
1653
1617
|
return state;
|
|
@@ -1660,22 +1624,14 @@ const handleMouseOutAt = (state, eventX, eventY) => {
|
|
|
1660
1624
|
|
|
1661
1625
|
const handleMouseOver = async (state, index) => {
|
|
1662
1626
|
const {
|
|
1663
|
-
items
|
|
1664
|
-
providerId,
|
|
1665
|
-
buttonIndex
|
|
1627
|
+
items
|
|
1666
1628
|
} = state;
|
|
1667
|
-
if (index === buttonIndex) {
|
|
1668
|
-
return state;
|
|
1669
|
-
}
|
|
1670
1629
|
const item = items[index];
|
|
1671
1630
|
if (!item) {
|
|
1672
1631
|
return state;
|
|
1673
1632
|
}
|
|
1674
|
-
const actions = await getSourceControlActions(providerId, item.groupId, item.type);
|
|
1675
1633
|
return {
|
|
1676
|
-
...state
|
|
1677
|
-
buttonIndex: index,
|
|
1678
|
-
buttons: actions
|
|
1634
|
+
...state
|
|
1679
1635
|
};
|
|
1680
1636
|
};
|
|
1681
1637
|
|
|
@@ -1838,8 +1794,6 @@ const getBadgeVirtualDom = (className, count) => {
|
|
|
1838
1794
|
}, text(`${count}`)];
|
|
1839
1795
|
};
|
|
1840
1796
|
|
|
1841
|
-
const emptySourceControlButtons = [];
|
|
1842
|
-
|
|
1843
1797
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
1844
1798
|
return {
|
|
1845
1799
|
type,
|
|
@@ -2061,23 +2015,8 @@ const getSourceControlVirtualDom = (items, splitButtonEnabled) => {
|
|
|
2061
2015
|
return dom;
|
|
2062
2016
|
};
|
|
2063
2017
|
|
|
2064
|
-
const getVisibleSourceControlItems = (items, minLineY, maxLineY, buttons, buttonIndex, icons) => {
|
|
2065
|
-
const visible = [];
|
|
2066
|
-
for (let i = minLineY; i < maxLineY; i++) {
|
|
2067
|
-
const item = items[i];
|
|
2068
|
-
const itemButtons = i === buttonIndex ? buttons : emptySourceControlButtons;
|
|
2069
|
-
const fileIcon = icons[i - minLineY];
|
|
2070
|
-
visible.push({
|
|
2071
|
-
...item,
|
|
2072
|
-
buttons: itemButtons,
|
|
2073
|
-
fileIcon
|
|
2074
|
-
});
|
|
2075
|
-
}
|
|
2076
|
-
return visible;
|
|
2077
|
-
};
|
|
2078
|
-
|
|
2079
2018
|
const renderItems = (oldState, newState) => {
|
|
2080
|
-
const visible =
|
|
2019
|
+
const visible = newState.visibleItems;
|
|
2081
2020
|
const dom = getSourceControlVirtualDom(visible, newState.splitButtonEnabled);
|
|
2082
2021
|
return ['Viewlet.setDom2', dom];
|
|
2083
2022
|
};
|
|
@@ -2219,13 +2158,10 @@ const updateIcons = async state => {
|
|
|
2219
2158
|
maxLineY
|
|
2220
2159
|
} = state;
|
|
2221
2160
|
const visible = items.slice(minLineY, maxLineY);
|
|
2222
|
-
const
|
|
2223
|
-
|
|
2224
|
-
newFileIconCache
|
|
2225
|
-
} = await getFileIcons(visible, Object.create(null));
|
|
2161
|
+
const newFileIconCache = await getFileIcons(visible, Object.create(null));
|
|
2162
|
+
// TODO update visible items
|
|
2226
2163
|
return {
|
|
2227
2164
|
...state,
|
|
2228
|
-
icons,
|
|
2229
2165
|
fileIconCache: newFileIconCache
|
|
2230
2166
|
};
|
|
2231
2167
|
};
|