@lvce-editor/source-control-worker 1.2.0 → 1.3.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 +288 -144
- package/package.json +1 -1
|
@@ -1161,7 +1161,7 @@ const Directory = 3;
|
|
|
1161
1161
|
const DirectoryExpanded = 4;
|
|
1162
1162
|
const File = 7;
|
|
1163
1163
|
|
|
1164
|
-
const getFileIcon = ({
|
|
1164
|
+
const getFileIcon$1 = ({
|
|
1165
1165
|
name
|
|
1166
1166
|
}) => {
|
|
1167
1167
|
return '';
|
|
@@ -1218,7 +1218,7 @@ const getDisplayItemsGroup = (group, isExpanded) => {
|
|
|
1218
1218
|
detail: folderName,
|
|
1219
1219
|
posInSet: i + 1,
|
|
1220
1220
|
setSize: length,
|
|
1221
|
-
icon: getFileIcon({
|
|
1221
|
+
icon: getFileIcon$1({
|
|
1222
1222
|
name: file
|
|
1223
1223
|
}),
|
|
1224
1224
|
decorationIcon: icon,
|
|
@@ -1232,6 +1232,7 @@ const getDisplayItemsGroup = (group, isExpanded) => {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
return displayItems;
|
|
1234
1234
|
};
|
|
1235
|
+
|
|
1235
1236
|
const getDisplayItems = (allGroups, isExpanded) => {
|
|
1236
1237
|
const displayItems = [];
|
|
1237
1238
|
for (const group of allGroups) {
|
|
@@ -1241,12 +1242,121 @@ const getDisplayItems = (allGroups, isExpanded) => {
|
|
|
1241
1242
|
return displayItems;
|
|
1242
1243
|
};
|
|
1243
1244
|
|
|
1245
|
+
const getIconsCached = (dirents, fileIconCache) => {
|
|
1246
|
+
return dirents.map(dirent => fileIconCache[dirent]);
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1249
|
+
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
1250
|
+
const missingRequests = [];
|
|
1251
|
+
for (const dirent of dirents) {
|
|
1252
|
+
if (!(dirent.file in fileIconCache)) {
|
|
1253
|
+
missingRequests.push({
|
|
1254
|
+
type: dirent.type,
|
|
1255
|
+
name: dirent.label,
|
|
1256
|
+
path: dirent.file
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
return missingRequests;
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
const getPath = item => {
|
|
1264
|
+
return item.file;
|
|
1265
|
+
};
|
|
1266
|
+
|
|
1267
|
+
const getPaths = items => {
|
|
1268
|
+
return items.map(getPath);
|
|
1269
|
+
};
|
|
1270
|
+
|
|
1271
|
+
const getFileIcon = async name => {
|
|
1272
|
+
return invoke$1('IconTheme.getFileIcon', {
|
|
1273
|
+
name
|
|
1274
|
+
});
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1277
|
+
const getFolderIcon = async name => {
|
|
1278
|
+
return invoke$1('IconTheme.getFolderIcon', {
|
|
1279
|
+
name
|
|
1280
|
+
});
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
const requestFileIcons = async requests => {
|
|
1284
|
+
const promises = requests.map(request => request.type === File ? getFileIcon(request.name) : getFolderIcon(request.name));
|
|
1285
|
+
return Promise.all(promises);
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1288
|
+
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
1289
|
+
if (missingRequests.length === 0) {
|
|
1290
|
+
return iconCache;
|
|
1291
|
+
}
|
|
1292
|
+
const newFileIconCache = {
|
|
1293
|
+
...iconCache
|
|
1294
|
+
};
|
|
1295
|
+
for (let i = 0; i < missingRequests.length; i++) {
|
|
1296
|
+
const request = missingRequests[i];
|
|
1297
|
+
const icon = newIcons[i];
|
|
1298
|
+
newFileIconCache[request.path] = icon;
|
|
1299
|
+
}
|
|
1300
|
+
return newFileIconCache;
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
const getFileIcons = async (dirents, fileIconCache) => {
|
|
1304
|
+
const missingRequests = getMissingIconRequests(dirents, fileIconCache);
|
|
1305
|
+
const newIcons = await requestFileIcons(missingRequests);
|
|
1306
|
+
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
1307
|
+
const paths = getPaths(dirents);
|
|
1308
|
+
const icons = getIconsCached(paths, newFileIconCache);
|
|
1309
|
+
return {
|
|
1310
|
+
icons,
|
|
1311
|
+
newFileIconCache
|
|
1312
|
+
};
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1244
1315
|
const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
1245
1316
|
const contentHeight = itemsLength * itemHeight;
|
|
1246
1317
|
const finalDeltaY = Math.max(contentHeight - height, 0);
|
|
1247
1318
|
return finalDeltaY;
|
|
1248
1319
|
};
|
|
1249
1320
|
|
|
1321
|
+
const getGroups$2 = (providerId, path) => {
|
|
1322
|
+
return executeProvider({
|
|
1323
|
+
event: 'none',
|
|
1324
|
+
method: SourceControlGetGroups,
|
|
1325
|
+
params: [providerId, path]
|
|
1326
|
+
// noProviderFoundMessage: 'No source control provider found',
|
|
1327
|
+
});
|
|
1328
|
+
};
|
|
1329
|
+
const getEnabledProviderIds$1 = (scheme, root) => {
|
|
1330
|
+
return executeProvider({
|
|
1331
|
+
event: `onSourceControl:${scheme}`,
|
|
1332
|
+
method: SourceControlGetEnabledProviderIds,
|
|
1333
|
+
params: [scheme, root]
|
|
1334
|
+
// noProviderFoundMessage: 'No source control provider found',
|
|
1335
|
+
});
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
const getEnabledProviderIds = (scheme, root) => {
|
|
1339
|
+
string(scheme);
|
|
1340
|
+
string(root);
|
|
1341
|
+
return getEnabledProviderIds$1(scheme, root);
|
|
1342
|
+
};
|
|
1343
|
+
const getGroups$1 = (providerId, root) => {
|
|
1344
|
+
return getGroups$2(providerId, root);
|
|
1345
|
+
};
|
|
1346
|
+
|
|
1347
|
+
const getGroups = async enabledProviderIds => {
|
|
1348
|
+
const allGroups = [];
|
|
1349
|
+
for (const providerId of enabledProviderIds) {
|
|
1350
|
+
// @ts-ignore
|
|
1351
|
+
const groups = await getGroups$1(providerId);
|
|
1352
|
+
allGroups.push(...groups);
|
|
1353
|
+
}
|
|
1354
|
+
return {
|
|
1355
|
+
allGroups,
|
|
1356
|
+
gitRoot: ''
|
|
1357
|
+
};
|
|
1358
|
+
};
|
|
1359
|
+
|
|
1250
1360
|
const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
1251
1361
|
number(itemsLength);
|
|
1252
1362
|
number(itemHeight);
|
|
@@ -1290,32 +1400,6 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
|
1290
1400
|
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
1291
1401
|
};
|
|
1292
1402
|
|
|
1293
|
-
const getGroups$2 = (providerId, path) => {
|
|
1294
|
-
return executeProvider({
|
|
1295
|
-
event: 'none',
|
|
1296
|
-
method: SourceControlGetGroups,
|
|
1297
|
-
params: [providerId, path]
|
|
1298
|
-
// noProviderFoundMessage: 'No source control provider found',
|
|
1299
|
-
});
|
|
1300
|
-
};
|
|
1301
|
-
const getEnabledProviderIds$1 = (scheme, root) => {
|
|
1302
|
-
return executeProvider({
|
|
1303
|
-
event: `onSourceControl:${scheme}`,
|
|
1304
|
-
method: SourceControlGetEnabledProviderIds,
|
|
1305
|
-
params: [scheme, root]
|
|
1306
|
-
// noProviderFoundMessage: 'No source control provider found',
|
|
1307
|
-
});
|
|
1308
|
-
};
|
|
1309
|
-
|
|
1310
|
-
const getEnabledProviderIds = (scheme, root) => {
|
|
1311
|
-
string(scheme);
|
|
1312
|
-
string(root);
|
|
1313
|
-
return getEnabledProviderIds$1(scheme, root);
|
|
1314
|
-
};
|
|
1315
|
-
const getGroups$1 = (providerId, root) => {
|
|
1316
|
-
return getGroups$2(providerId, root);
|
|
1317
|
-
};
|
|
1318
|
-
|
|
1319
1403
|
const getExtensions = async () => {
|
|
1320
1404
|
return invoke('Extensions.getExtensions');
|
|
1321
1405
|
};
|
|
@@ -1350,18 +1434,6 @@ const getSourceControlActions = async (providerId, groupId, type) => {
|
|
|
1350
1434
|
return value;
|
|
1351
1435
|
};
|
|
1352
1436
|
|
|
1353
|
-
const getGroups = async enabledProviderIds => {
|
|
1354
|
-
const allGroups = [];
|
|
1355
|
-
for (const providerId of enabledProviderIds) {
|
|
1356
|
-
// @ts-ignore
|
|
1357
|
-
const groups = await getGroups$1(providerId);
|
|
1358
|
-
allGroups.push(...groups);
|
|
1359
|
-
}
|
|
1360
|
-
return {
|
|
1361
|
-
allGroups,
|
|
1362
|
-
gitRoot: ''
|
|
1363
|
-
};
|
|
1364
|
-
};
|
|
1365
1437
|
const getNewButtons = async (displayItems, providerId, buttonIndex) => {
|
|
1366
1438
|
if (buttonIndex === -1) {
|
|
1367
1439
|
return [];
|
|
@@ -1378,7 +1450,8 @@ const loadContent = async state => {
|
|
|
1378
1450
|
itemHeight,
|
|
1379
1451
|
height,
|
|
1380
1452
|
minimumSliderSize,
|
|
1381
|
-
workspacePath
|
|
1453
|
+
workspacePath,
|
|
1454
|
+
fileIconCache
|
|
1382
1455
|
} = state;
|
|
1383
1456
|
const root = workspacePath;
|
|
1384
1457
|
const scheme = getProtocol(root);
|
|
@@ -1398,6 +1471,10 @@ const loadContent = async state => {
|
|
|
1398
1471
|
const numberOfVisible = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1399
1472
|
const maxLineY = Math.min(numberOfVisible, total);
|
|
1400
1473
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
1474
|
+
const {
|
|
1475
|
+
icons,
|
|
1476
|
+
newFileIconCache
|
|
1477
|
+
} = await getFileIcons(items, fileIconCache);
|
|
1401
1478
|
return {
|
|
1402
1479
|
...state,
|
|
1403
1480
|
allGroups,
|
|
@@ -1410,7 +1487,9 @@ const loadContent = async state => {
|
|
|
1410
1487
|
splitButtonEnabled,
|
|
1411
1488
|
maxLineY,
|
|
1412
1489
|
scrollBarHeight,
|
|
1413
|
-
finalDeltaY
|
|
1490
|
+
finalDeltaY,
|
|
1491
|
+
icons,
|
|
1492
|
+
fileIconCache: newFileIconCache
|
|
1414
1493
|
};
|
|
1415
1494
|
};
|
|
1416
1495
|
|
|
@@ -1434,10 +1513,10 @@ const show = async (x, y, id, ...args) => {
|
|
|
1434
1513
|
return invoke$1('ContextMenu.show', x, y, id, ...args);
|
|
1435
1514
|
};
|
|
1436
1515
|
|
|
1437
|
-
const SourceControl = 22;
|
|
1516
|
+
const SourceControl$1 = 22;
|
|
1438
1517
|
|
|
1439
1518
|
const handleContextMenu = async (state, button, x, y) => {
|
|
1440
|
-
await show(x, y, SourceControl);
|
|
1519
|
+
await show(x, y, SourceControl$1);
|
|
1441
1520
|
return state;
|
|
1442
1521
|
};
|
|
1443
1522
|
|
|
@@ -1482,17 +1561,6 @@ const initialize = async () => {
|
|
|
1482
1561
|
set(ExtensionHostWorker, extensionHostRpc);
|
|
1483
1562
|
};
|
|
1484
1563
|
|
|
1485
|
-
const HandleClick = 'handleClick';
|
|
1486
|
-
const HandleContextMenu = 'handleContextMenu';
|
|
1487
|
-
const HandleMouseOut = 'handleMouseOut';
|
|
1488
|
-
const HandleMouseOver = 'handleMouseOver';
|
|
1489
|
-
const HandleWheel = 'handleWheel';
|
|
1490
|
-
|
|
1491
|
-
const None = 'none';
|
|
1492
|
-
const ToolBar = 'toolbar';
|
|
1493
|
-
const Tree = 'tree';
|
|
1494
|
-
const TreeItem$1 = 'treeitem';
|
|
1495
|
-
|
|
1496
1564
|
const Actions = 'Actions';
|
|
1497
1565
|
const Chevron = 'Chevron';
|
|
1498
1566
|
const ChevronRight = 'ChevronRight';
|
|
@@ -1504,6 +1572,7 @@ const Label = 'Label';
|
|
|
1504
1572
|
const LabelDetail = 'LabelDetail';
|
|
1505
1573
|
const MaskIcon = 'MaskIcon';
|
|
1506
1574
|
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
1575
|
+
const SourceControl = 'SourceControl';
|
|
1507
1576
|
const SourceControlBadge = 'SourceControlBadge';
|
|
1508
1577
|
const SourceControlButton = 'SourceControlButton';
|
|
1509
1578
|
const SourceControlHeader = 'SourceControlHeader';
|
|
@@ -1516,9 +1585,46 @@ const SplitButtonDropDown = 'SplitButtonDropDown';
|
|
|
1516
1585
|
const SplitButtonDropDownDisabled = 'SplitButtonDropDownDisabled';
|
|
1517
1586
|
const SplitButtonSeparator = 'SplitButtonSeparator';
|
|
1518
1587
|
const StrikeThrough = 'StrikeThrough';
|
|
1519
|
-
const TreeItem = 'TreeItem';
|
|
1588
|
+
const TreeItem$1 = 'TreeItem';
|
|
1589
|
+
const Viewlet = 'Viewlet';
|
|
1520
1590
|
|
|
1521
|
-
const
|
|
1591
|
+
const HandleClick = 'handleClick';
|
|
1592
|
+
const HandleClickAt = 'handleClickAt';
|
|
1593
|
+
const HandleContextMenu = 'handleContextMenu';
|
|
1594
|
+
const HandleFocus = 'handleFocus';
|
|
1595
|
+
const HandleInput = 'handleInput';
|
|
1596
|
+
const HandleMouseOut = 'handleMouseOut';
|
|
1597
|
+
const HandleMouseOver = 'handleMouseOver';
|
|
1598
|
+
const HandleWheel = 'handleWheel';
|
|
1599
|
+
|
|
1600
|
+
const None = 'none';
|
|
1601
|
+
const ToolBar = 'toolbar';
|
|
1602
|
+
const Tree = 'tree';
|
|
1603
|
+
const TreeItem = 'treeitem';
|
|
1604
|
+
|
|
1605
|
+
const SourceControlInput$1 = 'SourceControlInput';
|
|
1606
|
+
|
|
1607
|
+
const emptyObject = {};
|
|
1608
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1609
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
1610
|
+
if (placeholders === emptyObject) {
|
|
1611
|
+
return key;
|
|
1612
|
+
}
|
|
1613
|
+
const replacer = (match, rest) => {
|
|
1614
|
+
return placeholders[rest];
|
|
1615
|
+
};
|
|
1616
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1617
|
+
};
|
|
1618
|
+
|
|
1619
|
+
const MessageEnterToCommitOnMaster = `Message (Enter) to commit on 'master'`;
|
|
1620
|
+
const SourceControlInput = 'Source Control Input';
|
|
1621
|
+
|
|
1622
|
+
const messageEnterToCommitOnMaster = () => {
|
|
1623
|
+
return i18nString(MessageEnterToCommitOnMaster);
|
|
1624
|
+
};
|
|
1625
|
+
const sourceControlInput = () => {
|
|
1626
|
+
return i18nString(SourceControlInput);
|
|
1627
|
+
};
|
|
1522
1628
|
|
|
1523
1629
|
const Button$1 = 1;
|
|
1524
1630
|
const Div = 4;
|
|
@@ -1526,32 +1632,27 @@ const Input = 6;
|
|
|
1526
1632
|
const Span = 8;
|
|
1527
1633
|
const Img = 17;
|
|
1528
1634
|
|
|
1529
|
-
const
|
|
1530
|
-
const text = data => {
|
|
1531
|
-
return {
|
|
1532
|
-
type: Text,
|
|
1533
|
-
text: data,
|
|
1534
|
-
childCount: 0
|
|
1535
|
-
};
|
|
1536
|
-
};
|
|
1537
|
-
|
|
1538
|
-
const getBadgeVirtualDom = (className, count) => {
|
|
1635
|
+
const getSourceControlHeaderVirtualDom = () => {
|
|
1539
1636
|
return [{
|
|
1540
1637
|
type: Div,
|
|
1541
|
-
className:
|
|
1638
|
+
className: SourceControlHeader,
|
|
1542
1639
|
childCount: 1
|
|
1543
|
-
},
|
|
1640
|
+
}, {
|
|
1641
|
+
type: Input,
|
|
1642
|
+
className: InputBox,
|
|
1643
|
+
ariaLabel: sourceControlInput(),
|
|
1644
|
+
autocapitalize: 'off',
|
|
1645
|
+
autocorrect: 'off',
|
|
1646
|
+
childCount: 0,
|
|
1647
|
+
name: SourceControlInput$1,
|
|
1648
|
+
onFocus: HandleFocus,
|
|
1649
|
+
onInput: HandleInput,
|
|
1650
|
+
placeholder: messageEnterToCommitOnMaster(),
|
|
1651
|
+
spellcheck: false
|
|
1652
|
+
}];
|
|
1544
1653
|
};
|
|
1545
1654
|
|
|
1546
|
-
const
|
|
1547
|
-
return {
|
|
1548
|
-
type: Img,
|
|
1549
|
-
className: FileIcon,
|
|
1550
|
-
src: icon,
|
|
1551
|
-
role: None,
|
|
1552
|
-
childCount: 0
|
|
1553
|
-
};
|
|
1554
|
-
};
|
|
1655
|
+
const emptySourceControlButtons = [];
|
|
1555
1656
|
|
|
1556
1657
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
1557
1658
|
return {
|
|
@@ -1562,16 +1663,6 @@ const getIconVirtualDom = (icon, type = Div) => {
|
|
|
1562
1663
|
};
|
|
1563
1664
|
};
|
|
1564
1665
|
|
|
1565
|
-
const PaddingLeft = '1rem';
|
|
1566
|
-
const PaddingRight = '12px';
|
|
1567
|
-
|
|
1568
|
-
const getLabelClassName = decorationStrikeThrough => {
|
|
1569
|
-
let className = Label + ' Grow';
|
|
1570
|
-
if (decorationStrikeThrough) {
|
|
1571
|
-
className += ` ${StrikeThrough}`;
|
|
1572
|
-
}
|
|
1573
|
-
return className;
|
|
1574
|
-
};
|
|
1575
1666
|
const addButtons = (dom, buttons) => {
|
|
1576
1667
|
if (buttons === emptySourceControlButtons) {
|
|
1577
1668
|
return;
|
|
@@ -1591,6 +1682,38 @@ const addButtons = (dom, buttons) => {
|
|
|
1591
1682
|
}, getIconVirtualDom(icon, Span));
|
|
1592
1683
|
}
|
|
1593
1684
|
};
|
|
1685
|
+
|
|
1686
|
+
const mergeClassNames = (...classNames) => {
|
|
1687
|
+
return classNames.filter(Boolean).join(' ');
|
|
1688
|
+
};
|
|
1689
|
+
const Text = 12;
|
|
1690
|
+
const text = data => {
|
|
1691
|
+
return {
|
|
1692
|
+
type: Text,
|
|
1693
|
+
text: data,
|
|
1694
|
+
childCount: 0
|
|
1695
|
+
};
|
|
1696
|
+
};
|
|
1697
|
+
|
|
1698
|
+
const getBadgeVirtualDom = (className, count) => {
|
|
1699
|
+
return [{
|
|
1700
|
+
type: Div,
|
|
1701
|
+
className: `Badge ${className}`,
|
|
1702
|
+
childCount: 1
|
|
1703
|
+
}, text(`${count}`)];
|
|
1704
|
+
};
|
|
1705
|
+
|
|
1706
|
+
const getLabelClassName = decorationStrikeThrough => {
|
|
1707
|
+
let className = Label + ' Grow';
|
|
1708
|
+
if (decorationStrikeThrough) {
|
|
1709
|
+
className += ` ${StrikeThrough}`;
|
|
1710
|
+
}
|
|
1711
|
+
return className;
|
|
1712
|
+
};
|
|
1713
|
+
|
|
1714
|
+
const PaddingLeft = '1rem';
|
|
1715
|
+
const PaddingRight = '12px';
|
|
1716
|
+
|
|
1594
1717
|
const createItemDirectory = item => {
|
|
1595
1718
|
const {
|
|
1596
1719
|
posInSet,
|
|
@@ -1605,8 +1728,8 @@ const createItemDirectory = item => {
|
|
|
1605
1728
|
const labelClassName = getLabelClassName(decorationStrikeThrough);
|
|
1606
1729
|
const dom = [{
|
|
1607
1730
|
type: Div,
|
|
1608
|
-
className: TreeItem,
|
|
1609
|
-
role: TreeItem
|
|
1731
|
+
className: TreeItem$1,
|
|
1732
|
+
role: TreeItem,
|
|
1610
1733
|
ariaExpanded: type === DirectoryExpanded,
|
|
1611
1734
|
ariaPosInSet: posInSet,
|
|
1612
1735
|
ariaSetSize: setSize,
|
|
@@ -1626,6 +1749,28 @@ const createItemDirectory = item => {
|
|
|
1626
1749
|
dom.push(...getBadgeVirtualDom(SourceControlBadge, badgeCount));
|
|
1627
1750
|
return dom;
|
|
1628
1751
|
};
|
|
1752
|
+
|
|
1753
|
+
const getFileIconVirtualDom = icon => {
|
|
1754
|
+
return {
|
|
1755
|
+
type: Img,
|
|
1756
|
+
className: FileIcon,
|
|
1757
|
+
src: icon,
|
|
1758
|
+
role: None,
|
|
1759
|
+
childCount: 0
|
|
1760
|
+
};
|
|
1761
|
+
};
|
|
1762
|
+
|
|
1763
|
+
const chevron = {
|
|
1764
|
+
type: Div,
|
|
1765
|
+
className: Chevron,
|
|
1766
|
+
childCount: 1
|
|
1767
|
+
};
|
|
1768
|
+
const getIconsDom = (icon, fileIcon) => {
|
|
1769
|
+
if (icon === ChevronRight) {
|
|
1770
|
+
return [chevron, getIconVirtualDom(icon)];
|
|
1771
|
+
}
|
|
1772
|
+
return [getFileIconVirtualDom(fileIcon)];
|
|
1773
|
+
};
|
|
1629
1774
|
const createItemOther = item => {
|
|
1630
1775
|
const {
|
|
1631
1776
|
posInSet,
|
|
@@ -1637,28 +1782,22 @@ const createItemOther = item => {
|
|
|
1637
1782
|
decorationIconTitle,
|
|
1638
1783
|
decorationStrikeThrough,
|
|
1639
1784
|
detail,
|
|
1640
|
-
buttons
|
|
1785
|
+
buttons,
|
|
1786
|
+
fileIcon
|
|
1641
1787
|
} = item;
|
|
1642
1788
|
const labelClassName = getLabelClassName(decorationStrikeThrough);
|
|
1643
|
-
/**
|
|
1644
|
-
* @type {any[]}
|
|
1645
|
-
*/
|
|
1646
1789
|
const dom = [];
|
|
1647
1790
|
dom.push({
|
|
1648
1791
|
type: Div,
|
|
1649
|
-
className: TreeItem,
|
|
1650
|
-
role: TreeItem
|
|
1792
|
+
className: TreeItem$1,
|
|
1793
|
+
role: TreeItem,
|
|
1651
1794
|
ariaPosInSet: posInSet,
|
|
1652
1795
|
ariaSetSize: setSize,
|
|
1653
1796
|
title: file,
|
|
1654
1797
|
childCount: 3,
|
|
1655
1798
|
paddingLeft: '1rem',
|
|
1656
1799
|
paddingRight: '12px'
|
|
1657
|
-
}, ...(icon
|
|
1658
|
-
type: Div,
|
|
1659
|
-
className: Chevron,
|
|
1660
|
-
childCount: 1
|
|
1661
|
-
}, getIconVirtualDom(icon)] : [getFileIconVirtualDom(icon)]));
|
|
1800
|
+
}, ...getIconsDom(icon, fileIcon));
|
|
1662
1801
|
const labelDom = {
|
|
1663
1802
|
type: Div,
|
|
1664
1803
|
className: labelClassName,
|
|
@@ -1683,6 +1822,7 @@ const createItemOther = item => {
|
|
|
1683
1822
|
});
|
|
1684
1823
|
return dom;
|
|
1685
1824
|
};
|
|
1825
|
+
|
|
1686
1826
|
const getSourceControlItemVirtualDom = item => {
|
|
1687
1827
|
switch (item.type) {
|
|
1688
1828
|
case DirectoryExpanded:
|
|
@@ -1721,46 +1861,9 @@ const getSourceControlItemsVirtualDom$1 = (hasItems, buttonText) => {
|
|
|
1721
1861
|
return dom;
|
|
1722
1862
|
};
|
|
1723
1863
|
|
|
1724
|
-
const emptyObject = {};
|
|
1725
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1726
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
1727
|
-
if (placeholders === emptyObject) {
|
|
1728
|
-
return key;
|
|
1729
|
-
}
|
|
1730
|
-
const replacer = (match, rest) => {
|
|
1731
|
-
return placeholders[rest];
|
|
1732
|
-
};
|
|
1733
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1734
|
-
};
|
|
1735
|
-
|
|
1736
|
-
const MessageEnterToCommitOnMaster = `Message (Enter) to commit on 'master'`;
|
|
1737
|
-
const SourceControlInput = 'Source Control Input';
|
|
1738
|
-
|
|
1739
|
-
const messageEnterToCommitOnMaster = () => {
|
|
1740
|
-
return i18nString(MessageEnterToCommitOnMaster);
|
|
1741
|
-
};
|
|
1742
|
-
const sourceControlInput = () => {
|
|
1743
|
-
return i18nString(SourceControlInput);
|
|
1744
|
-
};
|
|
1745
|
-
|
|
1746
1864
|
const getSourceControlItemsVirtualDom = (items, splitButtonEnabled) => {
|
|
1747
1865
|
const dom = [];
|
|
1748
|
-
dom.push(
|
|
1749
|
-
type: Div,
|
|
1750
|
-
className: SourceControlHeader,
|
|
1751
|
-
childCount: 1
|
|
1752
|
-
}, {
|
|
1753
|
-
type: Input,
|
|
1754
|
-
className: InputBox,
|
|
1755
|
-
spellcheck: false,
|
|
1756
|
-
autocapitalize: 'off',
|
|
1757
|
-
autocorrect: 'off',
|
|
1758
|
-
placeholder: messageEnterToCommitOnMaster(),
|
|
1759
|
-
ariaLabel: sourceControlInput(),
|
|
1760
|
-
childCount: 0,
|
|
1761
|
-
onInput: 'handleInput',
|
|
1762
|
-
onFocus: 'handleFocus'
|
|
1763
|
-
});
|
|
1866
|
+
dom.push(...getSourceControlHeaderVirtualDom());
|
|
1764
1867
|
if (splitButtonEnabled) {
|
|
1765
1868
|
const hasItems = items.length > 0;
|
|
1766
1869
|
dom.push(...getSourceControlItemsVirtualDom$1(hasItems, 'Commit'));
|
|
@@ -1777,7 +1880,7 @@ const getSourceControlItemsVirtualDom = (items, splitButtonEnabled) => {
|
|
|
1777
1880
|
const getSourceControlVirtualDom = (items, splitButtonEnabled) => {
|
|
1778
1881
|
const dom = [{
|
|
1779
1882
|
type: Div,
|
|
1780
|
-
className:
|
|
1883
|
+
className: mergeClassNames(Viewlet, SourceControl),
|
|
1781
1884
|
tabIndex: 0,
|
|
1782
1885
|
onClick: HandleClick,
|
|
1783
1886
|
onContextMenu: HandleContextMenu,
|
|
@@ -1789,21 +1892,23 @@ const getSourceControlVirtualDom = (items, splitButtonEnabled) => {
|
|
|
1789
1892
|
return dom;
|
|
1790
1893
|
};
|
|
1791
1894
|
|
|
1792
|
-
const getVisibleSourceControlItems = (items, minLineY, maxLineY, buttons, buttonIndex) => {
|
|
1895
|
+
const getVisibleSourceControlItems = (items, minLineY, maxLineY, buttons, buttonIndex, icons) => {
|
|
1793
1896
|
const visible = [];
|
|
1794
1897
|
for (let i = minLineY; i < maxLineY; i++) {
|
|
1795
1898
|
const item = items[i];
|
|
1796
1899
|
const itemButtons = i === buttonIndex ? buttons : emptySourceControlButtons;
|
|
1900
|
+
const fileIcon = icons[i - minLineY];
|
|
1797
1901
|
visible.push({
|
|
1798
1902
|
...item,
|
|
1799
|
-
buttons: itemButtons
|
|
1903
|
+
buttons: itemButtons,
|
|
1904
|
+
fileIcon
|
|
1800
1905
|
});
|
|
1801
1906
|
}
|
|
1802
1907
|
return visible;
|
|
1803
1908
|
};
|
|
1804
1909
|
|
|
1805
1910
|
const renderItems = (oldState, newState) => {
|
|
1806
|
-
const visible = getVisibleSourceControlItems(newState.items, newState.minLineY, newState.maxLineY, newState.buttons, newState.buttonIndex);
|
|
1911
|
+
const visible = getVisibleSourceControlItems(newState.items, newState.minLineY, newState.maxLineY, newState.buttons, newState.buttonIndex, newState.icons);
|
|
1807
1912
|
const dom = getSourceControlVirtualDom(visible, newState.splitButtonEnabled);
|
|
1808
1913
|
return ['Viewlet.setDom2', dom];
|
|
1809
1914
|
};
|
|
@@ -1885,6 +1990,26 @@ const renderEventListeners = () => {
|
|
|
1885
1990
|
name: HandleWheel,
|
|
1886
1991
|
params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
|
|
1887
1992
|
passive: true
|
|
1993
|
+
}, {
|
|
1994
|
+
name: HandleFocus,
|
|
1995
|
+
params: ['handleFocus']
|
|
1996
|
+
}, {
|
|
1997
|
+
name: HandleClickAt,
|
|
1998
|
+
params: ['handleClickAt', 'event.clientX', 'event.clientY']
|
|
1999
|
+
}, {
|
|
2000
|
+
name: HandleMouseOver,
|
|
2001
|
+
params: ['handleMouseOver', 'event.clientX', 'event.clientY']
|
|
2002
|
+
}, {
|
|
2003
|
+
name: HandleInput,
|
|
2004
|
+
params: ['handleInput', 'event.target.value']
|
|
2005
|
+
}, {
|
|
2006
|
+
name: HandleContextMenu,
|
|
2007
|
+
params: ['handleContextMenu', 'event.button', 'event.clientX', 'event.clientY'],
|
|
2008
|
+
preventDefault: true
|
|
2009
|
+
}, {
|
|
2010
|
+
name: HandleWheel,
|
|
2011
|
+
params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
|
|
2012
|
+
passive: true
|
|
1888
2013
|
}];
|
|
1889
2014
|
};
|
|
1890
2015
|
|
|
@@ -1910,6 +2035,24 @@ const terminate = () => {
|
|
|
1910
2035
|
globalThis.close();
|
|
1911
2036
|
};
|
|
1912
2037
|
|
|
2038
|
+
const updateIcons = async state => {
|
|
2039
|
+
const {
|
|
2040
|
+
items,
|
|
2041
|
+
minLineY,
|
|
2042
|
+
maxLineY
|
|
2043
|
+
} = state;
|
|
2044
|
+
const visible = items.slice(minLineY, maxLineY);
|
|
2045
|
+
const {
|
|
2046
|
+
icons,
|
|
2047
|
+
newFileIconCache
|
|
2048
|
+
} = await getFileIcons(visible, Object.create(null));
|
|
2049
|
+
return {
|
|
2050
|
+
...state,
|
|
2051
|
+
icons,
|
|
2052
|
+
fileIconCache: newFileIconCache
|
|
2053
|
+
};
|
|
2054
|
+
};
|
|
2055
|
+
|
|
1913
2056
|
const commandMap = {
|
|
1914
2057
|
'Initialize.initialize': initialize,
|
|
1915
2058
|
'SourceControl.create2': create2,
|
|
@@ -1922,7 +2065,8 @@ const commandMap = {
|
|
|
1922
2065
|
'SourceControl.renderActions2': renderActions,
|
|
1923
2066
|
'SourceControl.renderEventListeners': renderEventListeners,
|
|
1924
2067
|
'SourceControl.saveState': saveState,
|
|
1925
|
-
'SourceControl.terminate': terminate
|
|
2068
|
+
'SourceControl.terminate': terminate,
|
|
2069
|
+
'SourceControl.updateIcons': wrapCommand(updateIcons)
|
|
1926
2070
|
};
|
|
1927
2071
|
|
|
1928
2072
|
const listen = async () => {
|