@lvce-editor/source-control-worker 1.22.0 → 2.0.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 +118 -44
- package/package.json +1 -1
|
@@ -1619,7 +1619,11 @@ const create2 = (id, uri, x, y, width, height, workspacePath) => {
|
|
|
1619
1619
|
inputFontSize: 13,
|
|
1620
1620
|
inputFontWeight: 400,
|
|
1621
1621
|
inputLetterSpacing: 0,
|
|
1622
|
-
inputLineHeight:
|
|
1622
|
+
inputLineHeight: 20,
|
|
1623
|
+
inputBoxMaxHeight: 214,
|
|
1624
|
+
history: [],
|
|
1625
|
+
viewMode: 1,
|
|
1626
|
+
iconDefinitions: []
|
|
1623
1627
|
};
|
|
1624
1628
|
set$1(id, state, state);
|
|
1625
1629
|
};
|
|
@@ -1717,7 +1721,7 @@ const pathBaseName = path => {
|
|
|
1717
1721
|
return path.slice(path.lastIndexOf('/') + 1);
|
|
1718
1722
|
};
|
|
1719
1723
|
|
|
1720
|
-
const getDisplayItemsGroup = (group, expandedGroups) => {
|
|
1724
|
+
const getDisplayItemsGroup = (group, expandedGroups, iconDefinitions) => {
|
|
1721
1725
|
const displayItems = [];
|
|
1722
1726
|
const {
|
|
1723
1727
|
id,
|
|
@@ -1758,6 +1762,10 @@ const getDisplayItemsGroup = (group, expandedGroups) => {
|
|
|
1758
1762
|
} = item;
|
|
1759
1763
|
const baseName = pathBaseName(file);
|
|
1760
1764
|
const folderName = file.slice(0, -baseName.length - 1);
|
|
1765
|
+
let actualDecorationIcon = icon;
|
|
1766
|
+
if (typeof icon === 'number') {
|
|
1767
|
+
actualDecorationIcon = iconDefinitions[icon];
|
|
1768
|
+
}
|
|
1761
1769
|
displayItems.push({
|
|
1762
1770
|
file,
|
|
1763
1771
|
label: baseName,
|
|
@@ -1767,7 +1775,7 @@ const getDisplayItemsGroup = (group, expandedGroups) => {
|
|
|
1767
1775
|
icon: getFileIcon({
|
|
1768
1776
|
name: file
|
|
1769
1777
|
}),
|
|
1770
|
-
decorationIcon:
|
|
1778
|
+
decorationIcon: actualDecorationIcon,
|
|
1771
1779
|
decorationIconTitle: iconTitle,
|
|
1772
1780
|
decorationStrikeThrough: strikeThrough,
|
|
1773
1781
|
type: File,
|
|
@@ -1779,10 +1787,10 @@ const getDisplayItemsGroup = (group, expandedGroups) => {
|
|
|
1779
1787
|
return displayItems;
|
|
1780
1788
|
};
|
|
1781
1789
|
|
|
1782
|
-
const getDisplayItems = (allGroups, expandedGroups) => {
|
|
1790
|
+
const getDisplayItems = (allGroups, expandedGroups, iconDefinitions) => {
|
|
1783
1791
|
const displayItems = [];
|
|
1784
1792
|
for (const group of allGroups) {
|
|
1785
|
-
const groupDisplayItems = getDisplayItemsGroup(group, expandedGroups);
|
|
1793
|
+
const groupDisplayItems = getDisplayItemsGroup(group, expandedGroups, iconDefinitions);
|
|
1786
1794
|
displayItems.push(...groupDisplayItems);
|
|
1787
1795
|
}
|
|
1788
1796
|
return displayItems;
|
|
@@ -1870,6 +1878,11 @@ const getEnabledProviderIds$1 = (scheme, root) => {
|
|
|
1870
1878
|
// noProviderFoundMessage: 'No source control provider found',
|
|
1871
1879
|
});
|
|
1872
1880
|
};
|
|
1881
|
+
const getIconDefinitions$1 = async providerId => {
|
|
1882
|
+
// @ts-ignore
|
|
1883
|
+
const result = await invoke$1('ExtensionHostSourceControl.getIconDefinitions', providerId);
|
|
1884
|
+
return result;
|
|
1885
|
+
};
|
|
1873
1886
|
|
|
1874
1887
|
const getFileBefore = (providerId, file) => {
|
|
1875
1888
|
return getFileBefore$1(providerId, file);
|
|
@@ -1882,6 +1895,16 @@ const getEnabledProviderIds = (scheme, root) => {
|
|
|
1882
1895
|
const getGroups$1 = (providerId, root) => {
|
|
1883
1896
|
return getGroups$2(providerId, root);
|
|
1884
1897
|
};
|
|
1898
|
+
const getIconDefinitions = async providerIds => {
|
|
1899
|
+
try {
|
|
1900
|
+
if (providerIds.length === 0) {
|
|
1901
|
+
return [];
|
|
1902
|
+
}
|
|
1903
|
+
return await getIconDefinitions$1(providerIds[0]);
|
|
1904
|
+
} catch {
|
|
1905
|
+
return [];
|
|
1906
|
+
}
|
|
1907
|
+
};
|
|
1885
1908
|
|
|
1886
1909
|
const getGroups = async enabledProviderIds => {
|
|
1887
1910
|
const allGroups = [];
|
|
@@ -1896,6 +1919,28 @@ const getGroups = async enabledProviderIds => {
|
|
|
1896
1919
|
};
|
|
1897
1920
|
};
|
|
1898
1921
|
|
|
1922
|
+
const getTextHeight = async (input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight) => {
|
|
1923
|
+
try {
|
|
1924
|
+
const actualInput = '\n' + input;
|
|
1925
|
+
// TODO line height could also be like 1.5
|
|
1926
|
+
const lineHeightPx = `${lineHeight}px`;
|
|
1927
|
+
// @ts-ignore
|
|
1928
|
+
const height = await invoke$2(`MeasureTextHeight.measureTextBlockHeight`, actualInput, fontFamily, fontSize, lineHeightPx, width);
|
|
1929
|
+
return height;
|
|
1930
|
+
} catch {
|
|
1931
|
+
// fallback
|
|
1932
|
+
const lines = input.split('\n');
|
|
1933
|
+
const lineCount = lines.length;
|
|
1934
|
+
const inputHeight = lineCount * lineHeight;
|
|
1935
|
+
return inputHeight;
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
|
|
1939
|
+
const getInputHeight = async (input, width, fontFamily, fontWeight, fontSize, letterSpacing, lineHeight) => {
|
|
1940
|
+
const height = await getTextHeight(input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight);
|
|
1941
|
+
return height;
|
|
1942
|
+
};
|
|
1943
|
+
|
|
1899
1944
|
const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
1900
1945
|
number(itemsLength);
|
|
1901
1946
|
number(itemHeight);
|
|
@@ -1984,6 +2029,19 @@ const restoreExpandedGroups = groups => {
|
|
|
1984
2029
|
}, Object.create(null));
|
|
1985
2030
|
};
|
|
1986
2031
|
|
|
2032
|
+
const getRestoredInputValue = savedState => {
|
|
2033
|
+
if (savedState && typeof savedState === 'object' && 'inputValue' in savedState && typeof savedState['inputValue'] === 'string') {
|
|
2034
|
+
return savedState.inputValue;
|
|
2035
|
+
}
|
|
2036
|
+
return '';
|
|
2037
|
+
};
|
|
2038
|
+
const restoreState = savedState => {
|
|
2039
|
+
const inputValue = getRestoredInputValue(savedState);
|
|
2040
|
+
return {
|
|
2041
|
+
inputValue
|
|
2042
|
+
};
|
|
2043
|
+
};
|
|
2044
|
+
|
|
1987
2045
|
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
1988
2046
|
if (size >= contentSize) {
|
|
1989
2047
|
return 0;
|
|
@@ -2013,24 +2071,36 @@ const sourceControlInput = () => {
|
|
|
2013
2071
|
return i18nString(SourceControlInput$1);
|
|
2014
2072
|
};
|
|
2015
2073
|
|
|
2016
|
-
const loadContent = async state => {
|
|
2074
|
+
const loadContent = async (state, savedState) => {
|
|
2017
2075
|
const {
|
|
2018
2076
|
itemHeight,
|
|
2019
2077
|
height,
|
|
2020
2078
|
minimumSliderSize,
|
|
2021
2079
|
workspacePath,
|
|
2022
|
-
fileIconCache
|
|
2080
|
+
fileIconCache,
|
|
2081
|
+
width,
|
|
2082
|
+
inputFontFamily,
|
|
2083
|
+
inputFontSize,
|
|
2084
|
+
inputFontWeight,
|
|
2085
|
+
inputLetterSpacing,
|
|
2086
|
+
inputLineHeight
|
|
2023
2087
|
} = state;
|
|
2024
2088
|
const root = workspacePath;
|
|
2025
2089
|
const scheme = getProtocol(root);
|
|
2090
|
+
const {
|
|
2091
|
+
inputValue
|
|
2092
|
+
} = restoreState(savedState);
|
|
2026
2093
|
const enabledProviderIds = await getEnabledProviderIds(scheme, root);
|
|
2094
|
+
const iconDefinitions = await getIconDefinitions(enabledProviderIds);
|
|
2027
2095
|
const {
|
|
2028
2096
|
allGroups,
|
|
2029
2097
|
gitRoot
|
|
2030
2098
|
} = await getGroups(enabledProviderIds);
|
|
2031
2099
|
const expandedGroups = restoreExpandedGroups(allGroups);
|
|
2032
|
-
const displayItems = getDisplayItems(allGroups, expandedGroups);
|
|
2100
|
+
const displayItems = getDisplayItems(allGroups, expandedGroups, iconDefinitions);
|
|
2033
2101
|
const actionsCache = await requestSourceActions();
|
|
2102
|
+
|
|
2103
|
+
// TODO make preferences async and more functional
|
|
2034
2104
|
const splitButtonEnabled = get();
|
|
2035
2105
|
const total = displayItems.length;
|
|
2036
2106
|
const contentHeight = total * itemHeight;
|
|
@@ -2043,6 +2113,7 @@ const loadContent = async state => {
|
|
|
2043
2113
|
const visibleItems = getVisibleSourceControlItems(displayItems, minLineY, maxLineY, actionsCache, newFileIconCache);
|
|
2044
2114
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
2045
2115
|
const inputPlaceholder = messageEnterToCommitOnMaster();
|
|
2116
|
+
const inputBoxHeight = await getInputHeight(inputValue, width, inputFontFamily, inputFontSize, inputFontWeight, inputLetterSpacing, inputLineHeight);
|
|
2046
2117
|
return {
|
|
2047
2118
|
...state,
|
|
2048
2119
|
actionsCache,
|
|
@@ -2051,7 +2122,9 @@ const loadContent = async state => {
|
|
|
2051
2122
|
fileIconCache: newFileIconCache,
|
|
2052
2123
|
finalDeltaY,
|
|
2053
2124
|
gitRoot,
|
|
2125
|
+
inputBoxHeight,
|
|
2054
2126
|
inputPlaceholder,
|
|
2127
|
+
inputValue,
|
|
2055
2128
|
items: displayItems,
|
|
2056
2129
|
maxLineY,
|
|
2057
2130
|
root,
|
|
@@ -2071,7 +2144,7 @@ const handleButtonClick = async (state, clickedIndex) => {
|
|
|
2071
2144
|
return state;
|
|
2072
2145
|
}
|
|
2073
2146
|
await executeCommand(button.command, item.file);
|
|
2074
|
-
const newState = await loadContent(state);
|
|
2147
|
+
const newState = await loadContent(state, {});
|
|
2075
2148
|
return newState;
|
|
2076
2149
|
};
|
|
2077
2150
|
|
|
@@ -2099,14 +2172,15 @@ const refresh = async state => {
|
|
|
2099
2172
|
fileIconCache,
|
|
2100
2173
|
enabledProviderIds,
|
|
2101
2174
|
splitButtonEnabled,
|
|
2102
|
-
actionsCache
|
|
2175
|
+
actionsCache,
|
|
2176
|
+
iconDefinitions
|
|
2103
2177
|
} = state;
|
|
2104
2178
|
const {
|
|
2105
2179
|
allGroups,
|
|
2106
2180
|
gitRoot
|
|
2107
2181
|
} = await getGroups(enabledProviderIds);
|
|
2108
2182
|
const expandedGroups = restoreExpandedGroups(allGroups);
|
|
2109
|
-
const displayItems = getDisplayItems(allGroups, expandedGroups);
|
|
2183
|
+
const displayItems = getDisplayItems(allGroups, expandedGroups, iconDefinitions);
|
|
2110
2184
|
const total = displayItems.length;
|
|
2111
2185
|
const contentHeight = total * itemHeight;
|
|
2112
2186
|
const listHeight = getListHeight(total, itemHeight, height);
|
|
@@ -2159,9 +2233,10 @@ const updateVisibleItems = async (state, expandedGroups) => {
|
|
|
2159
2233
|
height,
|
|
2160
2234
|
actionsCache,
|
|
2161
2235
|
fileIconCache,
|
|
2162
|
-
allGroups
|
|
2236
|
+
allGroups,
|
|
2237
|
+
iconDefinitions
|
|
2163
2238
|
} = state;
|
|
2164
|
-
const displayItems = getDisplayItems(allGroups, expandedGroups);
|
|
2239
|
+
const displayItems = getDisplayItems(allGroups, expandedGroups, iconDefinitions);
|
|
2165
2240
|
const total = displayItems.length;
|
|
2166
2241
|
const listHeight = getListHeight(total, itemHeight, height);
|
|
2167
2242
|
const numberOfVisible = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
@@ -2274,27 +2349,6 @@ const handleFocus = async state => {
|
|
|
2274
2349
|
return state;
|
|
2275
2350
|
};
|
|
2276
2351
|
|
|
2277
|
-
const getTextHeight = async (input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight) => {
|
|
2278
|
-
try {
|
|
2279
|
-
// TODO line height could also be like 1.5
|
|
2280
|
-
const lineHeightPx = `${lineHeight}px`;
|
|
2281
|
-
// @ts-ignore
|
|
2282
|
-
const height = await invoke$2(`MeasureTextHeight.measureTextBlockHeight`, input, fontFamily, fontSize, lineHeightPx, width);
|
|
2283
|
-
return height;
|
|
2284
|
-
} catch {
|
|
2285
|
-
// fallback
|
|
2286
|
-
const lines = input.split('\n');
|
|
2287
|
-
const lineCount = lines.length;
|
|
2288
|
-
const inputHeight = lineCount * lineHeight;
|
|
2289
|
-
return inputHeight;
|
|
2290
|
-
}
|
|
2291
|
-
};
|
|
2292
|
-
|
|
2293
|
-
const getInputHeight = async (input, width, fontFamily, fontWeight, fontSize, letterSpacing, lineHeight) => {
|
|
2294
|
-
const height = await getTextHeight(input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight);
|
|
2295
|
-
return height;
|
|
2296
|
-
};
|
|
2297
|
-
|
|
2298
2352
|
const handleInput = async (state, value, inputSource = User) => {
|
|
2299
2353
|
const {
|
|
2300
2354
|
width,
|
|
@@ -2530,12 +2584,13 @@ const getButtonsVirtualDom = buttons => {
|
|
|
2530
2584
|
}, ...buttons.flatMap(getButtonVirtualDom)];
|
|
2531
2585
|
};
|
|
2532
2586
|
|
|
2587
|
+
const classNameDefault = mergeClassNames(Label, Grow);
|
|
2588
|
+
const classNameStrikeThrough = mergeClassNames(classNameDefault, StrikeThrough);
|
|
2533
2589
|
const getLabelClassName = decorationStrikeThrough => {
|
|
2534
|
-
let className = mergeClassNames(Label, Grow);
|
|
2535
2590
|
if (decorationStrikeThrough) {
|
|
2536
|
-
|
|
2591
|
+
return classNameStrikeThrough;
|
|
2537
2592
|
}
|
|
2538
|
-
return
|
|
2593
|
+
return classNameDefault;
|
|
2539
2594
|
};
|
|
2540
2595
|
|
|
2541
2596
|
const PaddingLeft = '1rem';
|
|
@@ -2564,6 +2619,7 @@ const createItemDirectory = item => {
|
|
|
2564
2619
|
ariaSetSize: setSize,
|
|
2565
2620
|
childCount: 3 + (hasButtons ? 1 : 0),
|
|
2566
2621
|
paddingLeft: PaddingLeft,
|
|
2622
|
+
// TODO classname for indent / padding
|
|
2567
2623
|
paddingRight: PaddingRight
|
|
2568
2624
|
}, {
|
|
2569
2625
|
type: Div,
|
|
@@ -2679,11 +2735,11 @@ const getSplitButtonVirtualDom = (hasItems, splitButtonEnabled, buttonText) => {
|
|
|
2679
2735
|
}
|
|
2680
2736
|
return [{
|
|
2681
2737
|
type: Div,
|
|
2682
|
-
className:
|
|
2738
|
+
className: mergeClassNames(SplitButton, hasItems ? '' : SplitButtonDisabled),
|
|
2683
2739
|
childCount: 3
|
|
2684
2740
|
}, {
|
|
2685
2741
|
type: Div,
|
|
2686
|
-
className:
|
|
2742
|
+
className: mergeClassNames(SplitButtonContent, hasItems ? '' : SplitButtonContentDisabled),
|
|
2687
2743
|
childCount: 1,
|
|
2688
2744
|
tabIndex: 0
|
|
2689
2745
|
}, text(buttonText), {
|
|
@@ -2692,12 +2748,12 @@ const getSplitButtonVirtualDom = (hasItems, splitButtonEnabled, buttonText) => {
|
|
|
2692
2748
|
childCount: 0
|
|
2693
2749
|
}, {
|
|
2694
2750
|
type: Div,
|
|
2695
|
-
className:
|
|
2751
|
+
className: mergeClassNames(SplitButtonDropDown, hasItems ? '' : SplitButtonDropDownDisabled),
|
|
2696
2752
|
childCount: 1,
|
|
2697
2753
|
tabIndex: 0
|
|
2698
2754
|
}, {
|
|
2699
2755
|
type: Div,
|
|
2700
|
-
className:
|
|
2756
|
+
className: mergeClassNames(MaskIcon, MaskIconChevronDown),
|
|
2701
2757
|
childCount: 0
|
|
2702
2758
|
}];
|
|
2703
2759
|
};
|
|
@@ -2855,14 +2911,16 @@ const saveState = uid => {
|
|
|
2855
2911
|
const {
|
|
2856
2912
|
root,
|
|
2857
2913
|
maxLineY,
|
|
2858
|
-
expandedGroups
|
|
2914
|
+
expandedGroups,
|
|
2915
|
+
inputValue
|
|
2859
2916
|
} = newState;
|
|
2860
2917
|
return {
|
|
2861
2918
|
root,
|
|
2862
2919
|
minLineY: 0,
|
|
2863
2920
|
maxLineY,
|
|
2864
2921
|
deltaY: 0,
|
|
2865
|
-
expandedGroups
|
|
2922
|
+
expandedGroups,
|
|
2923
|
+
inputValue
|
|
2866
2924
|
};
|
|
2867
2925
|
};
|
|
2868
2926
|
|
|
@@ -2881,6 +2939,20 @@ const updateIcons = async state => {
|
|
|
2881
2939
|
};
|
|
2882
2940
|
};
|
|
2883
2941
|
|
|
2942
|
+
const viewAsList = state => {
|
|
2943
|
+
return {
|
|
2944
|
+
...state,
|
|
2945
|
+
viewMode: 1
|
|
2946
|
+
};
|
|
2947
|
+
};
|
|
2948
|
+
|
|
2949
|
+
const viewAsTree = state => {
|
|
2950
|
+
return {
|
|
2951
|
+
...state,
|
|
2952
|
+
viewMode: 2
|
|
2953
|
+
};
|
|
2954
|
+
};
|
|
2955
|
+
|
|
2884
2956
|
const commandMap = {
|
|
2885
2957
|
'Initialize.initialize': initialize,
|
|
2886
2958
|
'SourceControl.create2': create2,
|
|
@@ -2908,7 +2980,9 @@ const commandMap = {
|
|
|
2908
2980
|
'SourceControl.selectIndex': wrapCommand(selectIndex),
|
|
2909
2981
|
'SourceControl.setDeltaY': wrapCommand(setDeltaY),
|
|
2910
2982
|
'SourceControl.terminate': terminate,
|
|
2911
|
-
'SourceControl.updateIcons': wrapCommand(updateIcons)
|
|
2983
|
+
'SourceControl.updateIcons': wrapCommand(updateIcons),
|
|
2984
|
+
'SourceControl.viewAsList': wrapCommand(viewAsList),
|
|
2985
|
+
'SourceControl.viewAsTree': wrapCommand(viewAsTree)
|
|
2912
2986
|
};
|
|
2913
2987
|
|
|
2914
2988
|
const listen = async () => {
|