@lvce-editor/source-control-worker 2.15.0 → 2.16.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 +168 -58
- package/package.json +1 -1
|
@@ -1557,6 +1557,15 @@ const getContextId = (groupId, type) => {
|
|
|
1557
1557
|
return groupId;
|
|
1558
1558
|
};
|
|
1559
1559
|
|
|
1560
|
+
const defaultIndent = 16; // 1rem = 16px
|
|
1561
|
+
|
|
1562
|
+
const getTreeItemIndent = type => {
|
|
1563
|
+
if (type === Directory || type === DirectoryExpanded) {
|
|
1564
|
+
return 0;
|
|
1565
|
+
}
|
|
1566
|
+
return defaultIndent;
|
|
1567
|
+
};
|
|
1568
|
+
|
|
1560
1569
|
const getVisibleSourceControlItems = (items, minLineY, maxLineY, actionsCache, fileIconCache) => {
|
|
1561
1570
|
const visible = [];
|
|
1562
1571
|
for (let i = minLineY; i < maxLineY; i++) {
|
|
@@ -1564,10 +1573,12 @@ const getVisibleSourceControlItems = (items, minLineY, maxLineY, actionsCache, f
|
|
|
1564
1573
|
const contextId = getContextId(item.groupId, item.type);
|
|
1565
1574
|
const buttons = actionsCache[contextId] || emptySourceControlButtons;
|
|
1566
1575
|
const fileIcon = fileIconCache[item.label] || '';
|
|
1576
|
+
const indent = getTreeItemIndent(item.type);
|
|
1567
1577
|
visible.push({
|
|
1568
1578
|
...item,
|
|
1569
1579
|
buttons,
|
|
1570
|
-
fileIcon
|
|
1580
|
+
fileIcon,
|
|
1581
|
+
indent
|
|
1571
1582
|
});
|
|
1572
1583
|
}
|
|
1573
1584
|
return visible;
|
|
@@ -1644,6 +1655,9 @@ const StageChanges = 'Stage Changes';
|
|
|
1644
1655
|
const AddToGitignore = 'Add to gitignore';
|
|
1645
1656
|
const RevealInExplorerView = 'Reveal in Explorer View';
|
|
1646
1657
|
const OpenContainingFolder = 'Open Containing Folder';
|
|
1658
|
+
const ViewAsTree$1 = 'View As Tree';
|
|
1659
|
+
const CommitAndPush$1 = 'Commit and Push';
|
|
1660
|
+
const Refresh$2 = 'Refresh';
|
|
1647
1661
|
const MessageEnterToCommitOnMaster = `Message (Enter) to commit on 'master'`;
|
|
1648
1662
|
const SourceControlInput$1 = 'Source Control Input';
|
|
1649
1663
|
|
|
@@ -1671,6 +1685,15 @@ const revealInExplorerView = () => {
|
|
|
1671
1685
|
const openContainingFolder = () => {
|
|
1672
1686
|
return i18nString(OpenContainingFolder);
|
|
1673
1687
|
};
|
|
1688
|
+
const viewAsTree$1 = () => {
|
|
1689
|
+
return i18nString(ViewAsTree$1);
|
|
1690
|
+
};
|
|
1691
|
+
const commitAndPush = () => {
|
|
1692
|
+
return i18nString(CommitAndPush$1);
|
|
1693
|
+
};
|
|
1694
|
+
const refresh$1 = () => {
|
|
1695
|
+
return i18nString(Refresh$2);
|
|
1696
|
+
};
|
|
1674
1697
|
const messageEnterToCommitOnMaster = () => {
|
|
1675
1698
|
return i18nString(MessageEnterToCommitOnMaster);
|
|
1676
1699
|
};
|
|
@@ -1829,7 +1852,9 @@ const create2 = (id, uri, x, y, width, height, workspacePath) => {
|
|
|
1829
1852
|
viewMode: 1,
|
|
1830
1853
|
iconDefinitions: [],
|
|
1831
1854
|
decorationIcons: [],
|
|
1832
|
-
focus: 0
|
|
1855
|
+
focus: 0,
|
|
1856
|
+
isVisible: true,
|
|
1857
|
+
badgeCount: 0
|
|
1833
1858
|
};
|
|
1834
1859
|
set(id, state, state);
|
|
1835
1860
|
};
|
|
@@ -1878,6 +1903,10 @@ const diff2 = uid => {
|
|
|
1878
1903
|
return result;
|
|
1879
1904
|
};
|
|
1880
1905
|
|
|
1906
|
+
const getBadgeCount = state => {
|
|
1907
|
+
return state.badgeCount;
|
|
1908
|
+
};
|
|
1909
|
+
|
|
1881
1910
|
const getInfo = uid => {
|
|
1882
1911
|
const {
|
|
1883
1912
|
newState
|
|
@@ -1957,38 +1986,10 @@ const getMenuIds = () => {
|
|
|
1957
1986
|
return [SourceControl$1];
|
|
1958
1987
|
};
|
|
1959
1988
|
|
|
1960
|
-
const
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
params: [id, ...args]
|
|
1965
|
-
});
|
|
1966
|
-
};
|
|
1967
|
-
|
|
1968
|
-
const handleButtonClick = async (state, clickedIndex) => {
|
|
1969
|
-
const {
|
|
1970
|
-
visibleItems
|
|
1971
|
-
} = state;
|
|
1972
|
-
const item = visibleItems[clickedIndex];
|
|
1973
|
-
const button = item.buttons[clickedIndex];
|
|
1974
|
-
if (!button) {
|
|
1975
|
-
return state;
|
|
1976
|
-
}
|
|
1977
|
-
await executeCommand(button.command, item.file);
|
|
1978
|
-
const newState = await loadContent(state, {});
|
|
1979
|
-
return newState;
|
|
1980
|
-
};
|
|
1981
|
-
|
|
1982
|
-
const getIndex = (state, eventX, eventY) => {
|
|
1983
|
-
const {
|
|
1984
|
-
headerHeight,
|
|
1985
|
-
y,
|
|
1986
|
-
itemHeight
|
|
1987
|
-
} = state;
|
|
1988
|
-
const relativeY = eventY - y - headerHeight;
|
|
1989
|
-
const index = Math.floor(relativeY / itemHeight);
|
|
1990
|
-
return index;
|
|
1991
|
-
};
|
|
1989
|
+
const SourceControlInput = 'SourceControlInput';
|
|
1990
|
+
const ViewAsTree = 'ViewAsTree';
|
|
1991
|
+
const CommitAndPush = 'CommitAndPush';
|
|
1992
|
+
const Refresh$1 = 'Refresh';
|
|
1992
1993
|
|
|
1993
1994
|
const refresh = async state => {
|
|
1994
1995
|
const {
|
|
@@ -2033,6 +2034,61 @@ const refresh = async state => {
|
|
|
2033
2034
|
};
|
|
2034
2035
|
};
|
|
2035
2036
|
|
|
2037
|
+
const viewAsTree = state => {
|
|
2038
|
+
return {
|
|
2039
|
+
...state,
|
|
2040
|
+
viewMode: Tree
|
|
2041
|
+
};
|
|
2042
|
+
};
|
|
2043
|
+
|
|
2044
|
+
const handleActionClick = async (state, actionName) => {
|
|
2045
|
+
switch (actionName) {
|
|
2046
|
+
case Refresh$1:
|
|
2047
|
+
return refresh(state);
|
|
2048
|
+
case ViewAsTree:
|
|
2049
|
+
return viewAsTree(state);
|
|
2050
|
+
case CommitAndPush:
|
|
2051
|
+
warn(`[source-control-worker] CommitAndPush action not yet implemented`);
|
|
2052
|
+
return state;
|
|
2053
|
+
default:
|
|
2054
|
+
warn(`[source-control-worker] Unknown action name: ${actionName}`);
|
|
2055
|
+
return state;
|
|
2056
|
+
}
|
|
2057
|
+
};
|
|
2058
|
+
|
|
2059
|
+
const executeCommand = (id, ...args) => {
|
|
2060
|
+
return executeProvider({
|
|
2061
|
+
event: `onCommand:${id}`,
|
|
2062
|
+
method: CommandExecute,
|
|
2063
|
+
params: [id, ...args]
|
|
2064
|
+
});
|
|
2065
|
+
};
|
|
2066
|
+
|
|
2067
|
+
const handleButtonClick = async (state, clickedIndex) => {
|
|
2068
|
+
const {
|
|
2069
|
+
visibleItems
|
|
2070
|
+
} = state;
|
|
2071
|
+
const item = visibleItems[clickedIndex];
|
|
2072
|
+
const button = item.buttons[clickedIndex];
|
|
2073
|
+
if (!button) {
|
|
2074
|
+
return state;
|
|
2075
|
+
}
|
|
2076
|
+
await executeCommand(button.command, item.file);
|
|
2077
|
+
const newState = await loadContent(state, {});
|
|
2078
|
+
return newState;
|
|
2079
|
+
};
|
|
2080
|
+
|
|
2081
|
+
const getIndex = (state, eventX, eventY) => {
|
|
2082
|
+
const {
|
|
2083
|
+
headerHeight,
|
|
2084
|
+
y,
|
|
2085
|
+
itemHeight
|
|
2086
|
+
} = state;
|
|
2087
|
+
const relativeY = eventY - y - headerHeight;
|
|
2088
|
+
const index = Math.floor(relativeY / itemHeight);
|
|
2089
|
+
return index;
|
|
2090
|
+
};
|
|
2091
|
+
|
|
2036
2092
|
const handleClickSourceControlButtons = async (state, index, name) => {
|
|
2037
2093
|
const {
|
|
2038
2094
|
visibleItems
|
|
@@ -2324,12 +2380,35 @@ const initialize = async () => {
|
|
|
2324
2380
|
set$1(textRpc);
|
|
2325
2381
|
};
|
|
2326
2382
|
|
|
2383
|
+
const getUnique = items => {
|
|
2384
|
+
const seens = [];
|
|
2385
|
+
for (const item of items) {
|
|
2386
|
+
if (!seens.includes(item)) {
|
|
2387
|
+
seens.push(item);
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
return seens;
|
|
2391
|
+
};
|
|
2392
|
+
|
|
2393
|
+
const getIndentRule = indent => {
|
|
2394
|
+
return `.Indent-${indent} {
|
|
2395
|
+
padding-left: ${indent}px;
|
|
2396
|
+
}`;
|
|
2397
|
+
};
|
|
2327
2398
|
const renderCss = (oldState, newState) => {
|
|
2328
2399
|
const {
|
|
2329
2400
|
id,
|
|
2330
|
-
inputBoxHeight
|
|
2401
|
+
inputBoxHeight,
|
|
2402
|
+
visibleItems
|
|
2331
2403
|
} = newState;
|
|
2332
|
-
const
|
|
2404
|
+
const indents = visibleItems.map(item => item.indent);
|
|
2405
|
+
const uniqueIndents = getUnique(indents);
|
|
2406
|
+
const indentRules = uniqueIndents.map(getIndentRule).join('\n');
|
|
2407
|
+
const css = indentRules ? `:root {
|
|
2408
|
+
--SourceControlInputHeight: ${inputBoxHeight}px;
|
|
2409
|
+
}
|
|
2410
|
+
${indentRules}
|
|
2411
|
+
` : `:root {
|
|
2333
2412
|
--SourceControlInputHeight: ${inputBoxHeight}px;
|
|
2334
2413
|
}
|
|
2335
2414
|
`;
|
|
@@ -2381,8 +2460,6 @@ const HandleMouseOver = 7;
|
|
|
2381
2460
|
const HandleMouseOverAt = 8;
|
|
2382
2461
|
const HandleWheel = 9;
|
|
2383
2462
|
|
|
2384
|
-
const SourceControlInput = 'SourceControlInput';
|
|
2385
|
-
|
|
2386
2463
|
const getSourceControlInputDom = inputPlaceholder => {
|
|
2387
2464
|
return [{
|
|
2388
2465
|
type: TextArea,
|
|
@@ -2461,7 +2538,12 @@ const getLabelClassName = decorationStrikeThrough => {
|
|
|
2461
2538
|
return classNameDefault;
|
|
2462
2539
|
};
|
|
2463
2540
|
|
|
2464
|
-
const
|
|
2541
|
+
const getTreeItemClassName = indent => {
|
|
2542
|
+
let className = TreeItem;
|
|
2543
|
+
className = mergeClassNames(className, `Indent-${indent}`);
|
|
2544
|
+
return className;
|
|
2545
|
+
};
|
|
2546
|
+
|
|
2465
2547
|
const PaddingRight = '12px';
|
|
2466
2548
|
|
|
2467
2549
|
const createItemDirectory = item => {
|
|
@@ -2473,21 +2555,21 @@ const createItemDirectory = item => {
|
|
|
2473
2555
|
badgeCount,
|
|
2474
2556
|
decorationStrikeThrough,
|
|
2475
2557
|
type,
|
|
2476
|
-
buttons
|
|
2558
|
+
buttons,
|
|
2559
|
+
indent
|
|
2477
2560
|
} = item;
|
|
2478
2561
|
const labelClassName = getLabelClassName(decorationStrikeThrough);
|
|
2479
2562
|
const buttonsDom = getButtonsVirtualDom(buttons);
|
|
2480
2563
|
const hasButtons = buttons.length;
|
|
2564
|
+
const treeItemClassName = getTreeItemClassName(indent);
|
|
2481
2565
|
return [{
|
|
2482
2566
|
type: Div,
|
|
2483
|
-
className:
|
|
2567
|
+
className: treeItemClassName,
|
|
2484
2568
|
role: TreeItem$1,
|
|
2485
2569
|
ariaExpanded: type === DirectoryExpanded,
|
|
2486
2570
|
ariaPosInSet: posInSet,
|
|
2487
2571
|
ariaSetSize: setSize,
|
|
2488
2572
|
childCount: 3 + (hasButtons ? 1 : 0),
|
|
2489
|
-
paddingLeft: PaddingLeft,
|
|
2490
|
-
// TODO classname for indent / padding
|
|
2491
2573
|
paddingRight: PaddingRight
|
|
2492
2574
|
}, {
|
|
2493
2575
|
type: Div,
|
|
@@ -2533,21 +2615,22 @@ const createItemOther = item => {
|
|
|
2533
2615
|
decorationStrikeThrough,
|
|
2534
2616
|
detail,
|
|
2535
2617
|
buttons,
|
|
2536
|
-
fileIcon
|
|
2618
|
+
fileIcon,
|
|
2619
|
+
indent
|
|
2537
2620
|
} = item;
|
|
2538
2621
|
const labelClassName = getLabelClassName(decorationStrikeThrough);
|
|
2539
2622
|
const dom = [];
|
|
2540
2623
|
const hasButtons = buttons.length;
|
|
2541
2624
|
const buttonsDom = getButtonsVirtualDom(buttons);
|
|
2625
|
+
const treeItemClassName = getTreeItemClassName(indent);
|
|
2542
2626
|
dom.push({
|
|
2543
2627
|
type: Div,
|
|
2544
|
-
className:
|
|
2628
|
+
className: treeItemClassName,
|
|
2545
2629
|
role: TreeItem$1,
|
|
2546
2630
|
ariaPosInSet: posInSet,
|
|
2547
2631
|
ariaSetSize: setSize,
|
|
2548
2632
|
title: file,
|
|
2549
2633
|
childCount: 3 + (hasButtons ? 1 : 0),
|
|
2550
|
-
paddingLeft: '1rem',
|
|
2551
2634
|
paddingRight: '12px'
|
|
2552
2635
|
}, ...getIconsDom(icon, fileIcon));
|
|
2553
2636
|
const labelDom = {
|
|
@@ -2700,18 +2783,43 @@ const render2 = (uid, diffResult) => {
|
|
|
2700
2783
|
|
|
2701
2784
|
const Button = 1;
|
|
2702
2785
|
|
|
2786
|
+
const Check = 'Check';
|
|
2787
|
+
const ListFlat = 'ListFlat';
|
|
2788
|
+
const Refresh = 'Refresh';
|
|
2789
|
+
|
|
2790
|
+
const getActions = () => {
|
|
2791
|
+
return [{
|
|
2792
|
+
type: Button,
|
|
2793
|
+
id: viewAsTree$1(),
|
|
2794
|
+
name: ViewAsTree,
|
|
2795
|
+
icon: ListFlat,
|
|
2796
|
+
command: ''
|
|
2797
|
+
}, {
|
|
2798
|
+
type: Button,
|
|
2799
|
+
id: commitAndPush(),
|
|
2800
|
+
name: CommitAndPush,
|
|
2801
|
+
icon: Check,
|
|
2802
|
+
command: ''
|
|
2803
|
+
}, {
|
|
2804
|
+
type: Button,
|
|
2805
|
+
id: refresh$1(),
|
|
2806
|
+
name: Refresh$1,
|
|
2807
|
+
icon: Refresh,
|
|
2808
|
+
command: ''
|
|
2809
|
+
}];
|
|
2810
|
+
};
|
|
2811
|
+
|
|
2703
2812
|
const getActionButtonVirtualDom = action => {
|
|
2704
2813
|
const {
|
|
2705
2814
|
id,
|
|
2706
2815
|
icon,
|
|
2707
|
-
|
|
2816
|
+
label
|
|
2708
2817
|
} = action;
|
|
2709
2818
|
return [{
|
|
2710
2819
|
type: Button$2,
|
|
2711
2820
|
className: IconButton,
|
|
2712
2821
|
title: id,
|
|
2713
|
-
|
|
2714
|
-
// TODO remove this
|
|
2822
|
+
name: label,
|
|
2715
2823
|
childCount: 1
|
|
2716
2824
|
}, getIconVirtualDom(icon)];
|
|
2717
2825
|
};
|
|
@@ -2719,7 +2827,14 @@ const getActionButtonVirtualDom = action => {
|
|
|
2719
2827
|
const getActionVirtualDom = action => {
|
|
2720
2828
|
switch (action.type) {
|
|
2721
2829
|
case Button:
|
|
2722
|
-
|
|
2830
|
+
{
|
|
2831
|
+
const actionButton = {
|
|
2832
|
+
id: action.id,
|
|
2833
|
+
icon: action.icon,
|
|
2834
|
+
label: action.name
|
|
2835
|
+
};
|
|
2836
|
+
return getActionButtonVirtualDom(actionButton);
|
|
2837
|
+
}
|
|
2723
2838
|
default:
|
|
2724
2839
|
return [];
|
|
2725
2840
|
}
|
|
@@ -2735,7 +2850,7 @@ const getActionsVirtualDom = actions => {
|
|
|
2735
2850
|
};
|
|
2736
2851
|
|
|
2737
2852
|
const renderActions = state => {
|
|
2738
|
-
const actions =
|
|
2853
|
+
const actions = getActions();
|
|
2739
2854
|
const dom = getActionsVirtualDom(actions);
|
|
2740
2855
|
return dom;
|
|
2741
2856
|
};
|
|
@@ -2818,18 +2933,12 @@ const viewAsList = state => {
|
|
|
2818
2933
|
};
|
|
2819
2934
|
};
|
|
2820
2935
|
|
|
2821
|
-
const viewAsTree = state => {
|
|
2822
|
-
return {
|
|
2823
|
-
...state,
|
|
2824
|
-
viewMode: Tree
|
|
2825
|
-
};
|
|
2826
|
-
};
|
|
2827
|
-
|
|
2828
2936
|
const commandMap = {
|
|
2829
2937
|
'Initialize.initialize': initialize,
|
|
2830
2938
|
'SourceControl.acceptInput': wrapCommand(acceptInput),
|
|
2831
2939
|
'SourceControl.create2': create2,
|
|
2832
2940
|
'SourceControl.diff2': diff2,
|
|
2941
|
+
'SourceControl.getBadgeCount': wrapGetter(getBadgeCount),
|
|
2833
2942
|
'SourceControl.getCommandIds': getCommandIds,
|
|
2834
2943
|
'SourceControl.getEnabledProviderIds': getEnabledProviderIds,
|
|
2835
2944
|
'SourceControl.getFileDecorations': getFileDecorations,
|
|
@@ -2837,6 +2946,7 @@ const commandMap = {
|
|
|
2837
2946
|
'SourceControl.getKeyBindings': getKeyBindings,
|
|
2838
2947
|
'SourceControl.getMenuEntries2': wrapGetter(getMenuEntries2),
|
|
2839
2948
|
'SourceControl.getMenuIds': getMenuIds,
|
|
2949
|
+
'SourceControl.handleActionClick': wrapCommand(handleActionClick),
|
|
2840
2950
|
'SourceControl.handleButtonClick': wrapCommand(handleButtonClick),
|
|
2841
2951
|
'SourceControl.handleClickAt': wrapCommand(handleClickAt),
|
|
2842
2952
|
'SourceControl.handleClickSourceControlButtons': wrapCommand(handleClickSourceControlButtons),
|