@lvce-editor/source-control-worker 2.15.0 → 2.17.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 +174 -59
- 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
|
`;
|
|
@@ -2380,8 +2459,7 @@ const HandleMouseOutAt = 6;
|
|
|
2380
2459
|
const HandleMouseOver = 7;
|
|
2381
2460
|
const HandleMouseOverAt = 8;
|
|
2382
2461
|
const HandleWheel = 9;
|
|
2383
|
-
|
|
2384
|
-
const SourceControlInput = 'SourceControlInput';
|
|
2462
|
+
const HandleClickAction = 10;
|
|
2385
2463
|
|
|
2386
2464
|
const getSourceControlInputDom = inputPlaceholder => {
|
|
2387
2465
|
return [{
|
|
@@ -2461,7 +2539,12 @@ const getLabelClassName = decorationStrikeThrough => {
|
|
|
2461
2539
|
return classNameDefault;
|
|
2462
2540
|
};
|
|
2463
2541
|
|
|
2464
|
-
const
|
|
2542
|
+
const getTreeItemClassName = indent => {
|
|
2543
|
+
let className = TreeItem;
|
|
2544
|
+
className = mergeClassNames(className, `Indent-${indent}`);
|
|
2545
|
+
return className;
|
|
2546
|
+
};
|
|
2547
|
+
|
|
2465
2548
|
const PaddingRight = '12px';
|
|
2466
2549
|
|
|
2467
2550
|
const createItemDirectory = item => {
|
|
@@ -2473,21 +2556,21 @@ const createItemDirectory = item => {
|
|
|
2473
2556
|
badgeCount,
|
|
2474
2557
|
decorationStrikeThrough,
|
|
2475
2558
|
type,
|
|
2476
|
-
buttons
|
|
2559
|
+
buttons,
|
|
2560
|
+
indent
|
|
2477
2561
|
} = item;
|
|
2478
2562
|
const labelClassName = getLabelClassName(decorationStrikeThrough);
|
|
2479
2563
|
const buttonsDom = getButtonsVirtualDom(buttons);
|
|
2480
2564
|
const hasButtons = buttons.length;
|
|
2565
|
+
const treeItemClassName = getTreeItemClassName(indent);
|
|
2481
2566
|
return [{
|
|
2482
2567
|
type: Div,
|
|
2483
|
-
className:
|
|
2568
|
+
className: treeItemClassName,
|
|
2484
2569
|
role: TreeItem$1,
|
|
2485
2570
|
ariaExpanded: type === DirectoryExpanded,
|
|
2486
2571
|
ariaPosInSet: posInSet,
|
|
2487
2572
|
ariaSetSize: setSize,
|
|
2488
2573
|
childCount: 3 + (hasButtons ? 1 : 0),
|
|
2489
|
-
paddingLeft: PaddingLeft,
|
|
2490
|
-
// TODO classname for indent / padding
|
|
2491
2574
|
paddingRight: PaddingRight
|
|
2492
2575
|
}, {
|
|
2493
2576
|
type: Div,
|
|
@@ -2533,21 +2616,22 @@ const createItemOther = item => {
|
|
|
2533
2616
|
decorationStrikeThrough,
|
|
2534
2617
|
detail,
|
|
2535
2618
|
buttons,
|
|
2536
|
-
fileIcon
|
|
2619
|
+
fileIcon,
|
|
2620
|
+
indent
|
|
2537
2621
|
} = item;
|
|
2538
2622
|
const labelClassName = getLabelClassName(decorationStrikeThrough);
|
|
2539
2623
|
const dom = [];
|
|
2540
2624
|
const hasButtons = buttons.length;
|
|
2541
2625
|
const buttonsDom = getButtonsVirtualDom(buttons);
|
|
2626
|
+
const treeItemClassName = getTreeItemClassName(indent);
|
|
2542
2627
|
dom.push({
|
|
2543
2628
|
type: Div,
|
|
2544
|
-
className:
|
|
2629
|
+
className: treeItemClassName,
|
|
2545
2630
|
role: TreeItem$1,
|
|
2546
2631
|
ariaPosInSet: posInSet,
|
|
2547
2632
|
ariaSetSize: setSize,
|
|
2548
2633
|
title: file,
|
|
2549
2634
|
childCount: 3 + (hasButtons ? 1 : 0),
|
|
2550
|
-
paddingLeft: '1rem',
|
|
2551
2635
|
paddingRight: '12px'
|
|
2552
2636
|
}, ...getIconsDom(icon, fileIcon));
|
|
2553
2637
|
const labelDom = {
|
|
@@ -2700,18 +2784,43 @@ const render2 = (uid, diffResult) => {
|
|
|
2700
2784
|
|
|
2701
2785
|
const Button = 1;
|
|
2702
2786
|
|
|
2787
|
+
const Check = 'Check';
|
|
2788
|
+
const ListFlat = 'ListFlat';
|
|
2789
|
+
const Refresh = 'Refresh';
|
|
2790
|
+
|
|
2791
|
+
const getActions = () => {
|
|
2792
|
+
return [{
|
|
2793
|
+
type: Button,
|
|
2794
|
+
id: viewAsTree$1(),
|
|
2795
|
+
name: ViewAsTree,
|
|
2796
|
+
icon: ListFlat,
|
|
2797
|
+
command: ''
|
|
2798
|
+
}, {
|
|
2799
|
+
type: Button,
|
|
2800
|
+
id: commitAndPush(),
|
|
2801
|
+
name: CommitAndPush,
|
|
2802
|
+
icon: Check,
|
|
2803
|
+
command: ''
|
|
2804
|
+
}, {
|
|
2805
|
+
type: Button,
|
|
2806
|
+
id: refresh$1(),
|
|
2807
|
+
name: Refresh$1,
|
|
2808
|
+
icon: Refresh,
|
|
2809
|
+
command: ''
|
|
2810
|
+
}];
|
|
2811
|
+
};
|
|
2812
|
+
|
|
2703
2813
|
const getActionButtonVirtualDom = action => {
|
|
2704
2814
|
const {
|
|
2705
2815
|
id,
|
|
2706
2816
|
icon,
|
|
2707
|
-
|
|
2817
|
+
label
|
|
2708
2818
|
} = action;
|
|
2709
2819
|
return [{
|
|
2710
2820
|
type: Button$2,
|
|
2711
2821
|
className: IconButton,
|
|
2712
2822
|
title: id,
|
|
2713
|
-
|
|
2714
|
-
// TODO remove this
|
|
2823
|
+
name: label,
|
|
2715
2824
|
childCount: 1
|
|
2716
2825
|
}, getIconVirtualDom(icon)];
|
|
2717
2826
|
};
|
|
@@ -2719,7 +2828,14 @@ const getActionButtonVirtualDom = action => {
|
|
|
2719
2828
|
const getActionVirtualDom = action => {
|
|
2720
2829
|
switch (action.type) {
|
|
2721
2830
|
case Button:
|
|
2722
|
-
|
|
2831
|
+
{
|
|
2832
|
+
const actionButton = {
|
|
2833
|
+
id: action.id,
|
|
2834
|
+
icon: action.icon,
|
|
2835
|
+
label: action.name
|
|
2836
|
+
};
|
|
2837
|
+
return getActionButtonVirtualDom(actionButton);
|
|
2838
|
+
}
|
|
2723
2839
|
default:
|
|
2724
2840
|
return [];
|
|
2725
2841
|
}
|
|
@@ -2730,12 +2846,13 @@ const getActionsVirtualDom = actions => {
|
|
|
2730
2846
|
type: Div,
|
|
2731
2847
|
className: Actions,
|
|
2732
2848
|
role: ToolBar,
|
|
2733
|
-
childCount: actions.length
|
|
2849
|
+
childCount: actions.length,
|
|
2850
|
+
onClick: HandleClickAction
|
|
2734
2851
|
}, ...actions.flatMap(getActionVirtualDom)];
|
|
2735
2852
|
};
|
|
2736
2853
|
|
|
2737
2854
|
const renderActions = state => {
|
|
2738
|
-
const actions =
|
|
2855
|
+
const actions = getActions();
|
|
2739
2856
|
const dom = getActionsVirtualDom(actions);
|
|
2740
2857
|
return dom;
|
|
2741
2858
|
};
|
|
@@ -2771,6 +2888,9 @@ const renderEventListeners = () => {
|
|
|
2771
2888
|
name: HandleWheel,
|
|
2772
2889
|
params: ['handleWheel', DeltaMode, DeltaY],
|
|
2773
2890
|
passive: true
|
|
2891
|
+
}, {
|
|
2892
|
+
name: HandleClickAction,
|
|
2893
|
+
params: ['handleActionClick', TargetName]
|
|
2774
2894
|
}];
|
|
2775
2895
|
};
|
|
2776
2896
|
|
|
@@ -2818,18 +2938,12 @@ const viewAsList = state => {
|
|
|
2818
2938
|
};
|
|
2819
2939
|
};
|
|
2820
2940
|
|
|
2821
|
-
const viewAsTree = state => {
|
|
2822
|
-
return {
|
|
2823
|
-
...state,
|
|
2824
|
-
viewMode: Tree
|
|
2825
|
-
};
|
|
2826
|
-
};
|
|
2827
|
-
|
|
2828
2941
|
const commandMap = {
|
|
2829
2942
|
'Initialize.initialize': initialize,
|
|
2830
2943
|
'SourceControl.acceptInput': wrapCommand(acceptInput),
|
|
2831
2944
|
'SourceControl.create2': create2,
|
|
2832
2945
|
'SourceControl.diff2': diff2,
|
|
2946
|
+
'SourceControl.getBadgeCount': wrapGetter(getBadgeCount),
|
|
2833
2947
|
'SourceControl.getCommandIds': getCommandIds,
|
|
2834
2948
|
'SourceControl.getEnabledProviderIds': getEnabledProviderIds,
|
|
2835
2949
|
'SourceControl.getFileDecorations': getFileDecorations,
|
|
@@ -2837,6 +2951,7 @@ const commandMap = {
|
|
|
2837
2951
|
'SourceControl.getKeyBindings': getKeyBindings,
|
|
2838
2952
|
'SourceControl.getMenuEntries2': wrapGetter(getMenuEntries2),
|
|
2839
2953
|
'SourceControl.getMenuIds': getMenuIds,
|
|
2954
|
+
'SourceControl.handleActionClick': wrapCommand(handleActionClick),
|
|
2840
2955
|
'SourceControl.handleButtonClick': wrapCommand(handleButtonClick),
|
|
2841
2956
|
'SourceControl.handleClickAt': wrapCommand(handleClickAt),
|
|
2842
2957
|
'SourceControl.handleClickSourceControlButtons': wrapCommand(handleClickSourceControlButtons),
|