@lvce-editor/status-bar-worker 3.15.2 → 3.16.1
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/statusBarWorkerMain.js +220 -184
- package/package.json +1 -1
|
@@ -1397,31 +1397,6 @@ const handleContextMenu = async (state, button, x, y) => {
|
|
|
1397
1397
|
return state;
|
|
1398
1398
|
};
|
|
1399
1399
|
|
|
1400
|
-
const handleExtensionManagementChange = async () => {
|
|
1401
|
-
for (const uid of getKeys()) {
|
|
1402
|
-
await invoke$1('Viewlet.executeViewletCommand', uid, 'handleItemsChanged');
|
|
1403
|
-
}
|
|
1404
|
-
};
|
|
1405
|
-
|
|
1406
|
-
const handleNotificationCountChangedAll = async count => {
|
|
1407
|
-
for (const uid of getKeys()) {
|
|
1408
|
-
await invoke$1('Viewlet.executeViewletCommand', uid, 'handleNotificationCountChanged', count);
|
|
1409
|
-
}
|
|
1410
|
-
};
|
|
1411
|
-
|
|
1412
|
-
const commandMap$1 = {
|
|
1413
|
-
'StatusBar.handleChange': handleExtensionManagementChange,
|
|
1414
|
-
'StatusBar.handleNotificationCountChanged': handleNotificationCountChangedAll
|
|
1415
|
-
};
|
|
1416
|
-
|
|
1417
|
-
const handleExtensionManagementMessagePort = async port => {
|
|
1418
|
-
const rpc = await create$2({
|
|
1419
|
-
commandMap: commandMap$1,
|
|
1420
|
-
messagePort: port
|
|
1421
|
-
});
|
|
1422
|
-
set$3(rpc);
|
|
1423
|
-
};
|
|
1424
|
-
|
|
1425
1400
|
const getAriaLabel = count => {
|
|
1426
1401
|
if (count === 0) {
|
|
1427
1402
|
return 'No Notifications';
|
|
@@ -1627,165 +1602,6 @@ const handleItemsChanged = async state => {
|
|
|
1627
1602
|
return handleExtensionsChanged(state);
|
|
1628
1603
|
};
|
|
1629
1604
|
|
|
1630
|
-
const state = {
|
|
1631
|
-
connected: false
|
|
1632
|
-
};
|
|
1633
|
-
const isConnected = () => {
|
|
1634
|
-
const {
|
|
1635
|
-
connected
|
|
1636
|
-
} = state;
|
|
1637
|
-
return connected;
|
|
1638
|
-
};
|
|
1639
|
-
const invoke = (method, ...params) => {
|
|
1640
|
-
return invoke$2(method, ...params);
|
|
1641
|
-
};
|
|
1642
|
-
const set = rpc => {
|
|
1643
|
-
set$2(rpc);
|
|
1644
|
-
state.connected = true;
|
|
1645
|
-
};
|
|
1646
|
-
|
|
1647
|
-
const handleMessagePort = async port => {
|
|
1648
|
-
const rpc = await create$2({
|
|
1649
|
-
commandMap: {},
|
|
1650
|
-
messagePort: port
|
|
1651
|
-
});
|
|
1652
|
-
set(rpc);
|
|
1653
|
-
};
|
|
1654
|
-
|
|
1655
|
-
const handleNotificationCountChanged = (state, count) => {
|
|
1656
|
-
const {
|
|
1657
|
-
statusBarItemsRight
|
|
1658
|
-
} = state;
|
|
1659
|
-
const notificationsEnabled = statusBarItemsRight.some(item => item.name === Notifications);
|
|
1660
|
-
if (!notificationsEnabled) {
|
|
1661
|
-
return state;
|
|
1662
|
-
}
|
|
1663
|
-
const [notificationItem] = getNotificationsStatusBarItem(true, count);
|
|
1664
|
-
if (!notificationItem) {
|
|
1665
|
-
return state;
|
|
1666
|
-
}
|
|
1667
|
-
return {
|
|
1668
|
-
...state,
|
|
1669
|
-
statusBarItemsRight: statusBarItemsRight.map(item => item.name === Notifications ? notificationItem : item)
|
|
1670
|
-
};
|
|
1671
|
-
};
|
|
1672
|
-
|
|
1673
|
-
const handleProblemsSummaryChange = (state, summary) => {
|
|
1674
|
-
const {
|
|
1675
|
-
errorCount: oldErrorCount,
|
|
1676
|
-
statusBarItemsLeft: oldStatusBarItemsLeft,
|
|
1677
|
-
warningCount: oldWarningCount
|
|
1678
|
-
} = state;
|
|
1679
|
-
const errorCount = summary.hasEditor ? summary.errorCount : 0;
|
|
1680
|
-
const warningCount = summary.hasEditor ? summary.warningCount : 0;
|
|
1681
|
-
if (oldErrorCount === errorCount && oldWarningCount === warningCount) {
|
|
1682
|
-
return state;
|
|
1683
|
-
}
|
|
1684
|
-
const problemsItem = getProblemsStatusBarItem(errorCount, warningCount, true)[0];
|
|
1685
|
-
const statusBarItemsLeft = oldStatusBarItemsLeft.map(item => item.name === Problems ? problemsItem : item);
|
|
1686
|
-
return {
|
|
1687
|
-
...state,
|
|
1688
|
-
errorCount,
|
|
1689
|
-
statusBarItemsLeft,
|
|
1690
|
-
warningCount
|
|
1691
|
-
};
|
|
1692
|
-
};
|
|
1693
|
-
|
|
1694
|
-
const initialize = async () => {};
|
|
1695
|
-
|
|
1696
|
-
const getIndex = (items, item) => {
|
|
1697
|
-
for (let i = 0; i < items.length; i++) {
|
|
1698
|
-
if (items[i].name === item.name) {
|
|
1699
|
-
return i;
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
return -1;
|
|
1703
|
-
};
|
|
1704
|
-
|
|
1705
|
-
const updateArray = (items, newItem) => {
|
|
1706
|
-
const index = getIndex(items, newItem);
|
|
1707
|
-
const before = items.slice(0, index);
|
|
1708
|
-
const after = items.slice(index + 1);
|
|
1709
|
-
return [...before, newItem, ...after];
|
|
1710
|
-
};
|
|
1711
|
-
|
|
1712
|
-
const itemLeftUpdate = (state, newItem) => {
|
|
1713
|
-
return {
|
|
1714
|
-
...state,
|
|
1715
|
-
statusBarItemsLeft: updateArray([...state.statusBarItemsLeft], newItem)
|
|
1716
|
-
};
|
|
1717
|
-
};
|
|
1718
|
-
|
|
1719
|
-
const itemRightCreate = (state, newItem) => {
|
|
1720
|
-
const {
|
|
1721
|
-
statusBarItemsRight
|
|
1722
|
-
} = state;
|
|
1723
|
-
const newStatusBarItemsRight = [...statusBarItemsRight, newItem];
|
|
1724
|
-
return {
|
|
1725
|
-
...state,
|
|
1726
|
-
statusBarItemsRight: newStatusBarItemsRight
|
|
1727
|
-
};
|
|
1728
|
-
};
|
|
1729
|
-
|
|
1730
|
-
const itemRightUpdate = (state, newItem) => {
|
|
1731
|
-
const {
|
|
1732
|
-
statusBarItemsRight
|
|
1733
|
-
} = state;
|
|
1734
|
-
const newStatusBarItemsRight = updateArray([...statusBarItemsRight], newItem);
|
|
1735
|
-
return {
|
|
1736
|
-
...state,
|
|
1737
|
-
statusBarItemsRight: newStatusBarItemsRight
|
|
1738
|
-
};
|
|
1739
|
-
};
|
|
1740
|
-
|
|
1741
|
-
const get = async key => {
|
|
1742
|
-
return getPreference(key);
|
|
1743
|
-
};
|
|
1744
|
-
|
|
1745
|
-
const getBooleanPreference = async key => {
|
|
1746
|
-
const value = await get(key);
|
|
1747
|
-
return value ?? true;
|
|
1748
|
-
};
|
|
1749
|
-
const loadStatusBarPreferences = async () => {
|
|
1750
|
-
const [itemsVisible, builtinNotificationsEnabled, builtinProblemsEnabled] = await Promise.all([getBooleanPreference('statusBar.itemsVisible'), getBooleanPreference('statusBar.builtinNotificationsEnabled'), getBooleanPreference('statusBar.builtinProblemsEnabled')]);
|
|
1751
|
-
return {
|
|
1752
|
-
builtinNotificationsEnabled,
|
|
1753
|
-
builtinProblemsEnabled,
|
|
1754
|
-
itemsVisible
|
|
1755
|
-
};
|
|
1756
|
-
};
|
|
1757
|
-
|
|
1758
|
-
const loadContent = async state => {
|
|
1759
|
-
const {
|
|
1760
|
-
assetDir,
|
|
1761
|
-
errorCount,
|
|
1762
|
-
platform,
|
|
1763
|
-
warningCount
|
|
1764
|
-
} = state;
|
|
1765
|
-
const {
|
|
1766
|
-
builtinNotificationsEnabled,
|
|
1767
|
-
builtinProblemsEnabled,
|
|
1768
|
-
itemsVisible
|
|
1769
|
-
} = await loadStatusBarPreferences();
|
|
1770
|
-
const statusBarItems = await getStatusBarItems({
|
|
1771
|
-
assetDir,
|
|
1772
|
-
builtinNotificationsEnabled: builtinNotificationsEnabled,
|
|
1773
|
-
builtinProblemsEnabled: builtinProblemsEnabled,
|
|
1774
|
-
errorCount,
|
|
1775
|
-
platform,
|
|
1776
|
-
showItems: itemsVisible,
|
|
1777
|
-
warningCount
|
|
1778
|
-
});
|
|
1779
|
-
return {
|
|
1780
|
-
...state,
|
|
1781
|
-
errorCount: 0,
|
|
1782
|
-
initial: false,
|
|
1783
|
-
statusBarItemsLeft: statusBarItems.filter(item => item.name !== Notifications),
|
|
1784
|
-
statusBarItemsRight: statusBarItems.filter(item => item.name === Notifications),
|
|
1785
|
-
warningCount: 0
|
|
1786
|
-
};
|
|
1787
|
-
};
|
|
1788
|
-
|
|
1789
1605
|
const mergeClassNames = (...classNames) => {
|
|
1790
1606
|
return classNames.filter(Boolean).join(' ');
|
|
1791
1607
|
};
|
|
@@ -1930,6 +1746,23 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
1930
1746
|
return commands;
|
|
1931
1747
|
};
|
|
1932
1748
|
|
|
1749
|
+
const state = {
|
|
1750
|
+
connected: false
|
|
1751
|
+
};
|
|
1752
|
+
const isConnected = () => {
|
|
1753
|
+
const {
|
|
1754
|
+
connected
|
|
1755
|
+
} = state;
|
|
1756
|
+
return connected;
|
|
1757
|
+
};
|
|
1758
|
+
const invoke = (method, ...params) => {
|
|
1759
|
+
return invoke$2(method, ...params);
|
|
1760
|
+
};
|
|
1761
|
+
const set = rpc => {
|
|
1762
|
+
set$2(rpc);
|
|
1763
|
+
state.connected = true;
|
|
1764
|
+
};
|
|
1765
|
+
|
|
1933
1766
|
const renderDirect = async (uid, commands) => {
|
|
1934
1767
|
const rendererWorkerCommands = commands.filter(command => command[0] === SetFocusContext);
|
|
1935
1768
|
const rendererProcessCommands = commands.filter(command => command[0] !== SetFocusContext);
|
|
@@ -1949,6 +1782,209 @@ const render2 = (uid, diffResult) => {
|
|
|
1949
1782
|
return renderDirect(uid, commands);
|
|
1950
1783
|
};
|
|
1951
1784
|
|
|
1785
|
+
const renderOutOfBand = async uid => {
|
|
1786
|
+
if (!isConnected()) {
|
|
1787
|
+
return;
|
|
1788
|
+
}
|
|
1789
|
+
const diffResult = diff2(uid);
|
|
1790
|
+
if (diffResult.length === 0) {
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
const commands = await render2(uid, diffResult);
|
|
1794
|
+
if (commands.length === 0) {
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
await invoke('Viewlet.sendMultiple', commands);
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
const handleExtensionManagementChange = async () => {
|
|
1801
|
+
for (const uid of getKeys()) {
|
|
1802
|
+
const {
|
|
1803
|
+
newState,
|
|
1804
|
+
oldState
|
|
1805
|
+
} = get$3(uid);
|
|
1806
|
+
const newerState = await handleItemsChanged(newState);
|
|
1807
|
+
if (newState === newerState || oldState === newerState) {
|
|
1808
|
+
continue;
|
|
1809
|
+
}
|
|
1810
|
+
set$5(uid, oldState, {
|
|
1811
|
+
...newState,
|
|
1812
|
+
...newerState
|
|
1813
|
+
});
|
|
1814
|
+
await renderOutOfBand(uid);
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
|
|
1818
|
+
const handleNotificationCountChanged = (state, count) => {
|
|
1819
|
+
const {
|
|
1820
|
+
statusBarItemsRight
|
|
1821
|
+
} = state;
|
|
1822
|
+
const notificationsEnabled = statusBarItemsRight.some(item => item.name === Notifications);
|
|
1823
|
+
if (!notificationsEnabled) {
|
|
1824
|
+
return state;
|
|
1825
|
+
}
|
|
1826
|
+
const [notificationItem] = getNotificationsStatusBarItem(true, count);
|
|
1827
|
+
if (!notificationItem) {
|
|
1828
|
+
return state;
|
|
1829
|
+
}
|
|
1830
|
+
return {
|
|
1831
|
+
...state,
|
|
1832
|
+
statusBarItemsRight: statusBarItemsRight.map(item => item.name === Notifications ? notificationItem : item)
|
|
1833
|
+
};
|
|
1834
|
+
};
|
|
1835
|
+
|
|
1836
|
+
const handleNotificationCountChangedAll = async count => {
|
|
1837
|
+
for (const uid of getKeys()) {
|
|
1838
|
+
const {
|
|
1839
|
+
newState,
|
|
1840
|
+
oldState
|
|
1841
|
+
} = get$3(uid);
|
|
1842
|
+
const newerState = handleNotificationCountChanged(newState, count);
|
|
1843
|
+
if (newState === newerState || oldState === newerState) {
|
|
1844
|
+
continue;
|
|
1845
|
+
}
|
|
1846
|
+
set$5(uid, oldState, newerState);
|
|
1847
|
+
await renderOutOfBand(uid);
|
|
1848
|
+
}
|
|
1849
|
+
};
|
|
1850
|
+
|
|
1851
|
+
const commandMap$1 = {
|
|
1852
|
+
'StatusBar.handleChange': handleExtensionManagementChange,
|
|
1853
|
+
'StatusBar.handleNotificationCountChanged': handleNotificationCountChangedAll
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1856
|
+
const handleExtensionManagementMessagePort = async port => {
|
|
1857
|
+
const rpc = await create$2({
|
|
1858
|
+
commandMap: commandMap$1,
|
|
1859
|
+
messagePort: port
|
|
1860
|
+
});
|
|
1861
|
+
set$3(rpc);
|
|
1862
|
+
};
|
|
1863
|
+
|
|
1864
|
+
const handleMessagePort = async port => {
|
|
1865
|
+
const rpc = await create$2({
|
|
1866
|
+
commandMap: {},
|
|
1867
|
+
messagePort: port
|
|
1868
|
+
});
|
|
1869
|
+
set(rpc);
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1872
|
+
const handleProblemsSummaryChange = (state, summary) => {
|
|
1873
|
+
const {
|
|
1874
|
+
errorCount: oldErrorCount,
|
|
1875
|
+
statusBarItemsLeft: oldStatusBarItemsLeft,
|
|
1876
|
+
warningCount: oldWarningCount
|
|
1877
|
+
} = state;
|
|
1878
|
+
const errorCount = summary.hasEditor ? summary.errorCount : 0;
|
|
1879
|
+
const warningCount = summary.hasEditor ? summary.warningCount : 0;
|
|
1880
|
+
if (oldErrorCount === errorCount && oldWarningCount === warningCount) {
|
|
1881
|
+
return state;
|
|
1882
|
+
}
|
|
1883
|
+
const problemsItem = getProblemsStatusBarItem(errorCount, warningCount, true)[0];
|
|
1884
|
+
const statusBarItemsLeft = oldStatusBarItemsLeft.map(item => item.name === Problems ? problemsItem : item);
|
|
1885
|
+
return {
|
|
1886
|
+
...state,
|
|
1887
|
+
errorCount,
|
|
1888
|
+
statusBarItemsLeft,
|
|
1889
|
+
warningCount
|
|
1890
|
+
};
|
|
1891
|
+
};
|
|
1892
|
+
|
|
1893
|
+
const initialize = async () => {};
|
|
1894
|
+
|
|
1895
|
+
const getIndex = (items, item) => {
|
|
1896
|
+
for (let i = 0; i < items.length; i++) {
|
|
1897
|
+
if (items[i].name === item.name) {
|
|
1898
|
+
return i;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return -1;
|
|
1902
|
+
};
|
|
1903
|
+
|
|
1904
|
+
const updateArray = (items, newItem) => {
|
|
1905
|
+
const index = getIndex(items, newItem);
|
|
1906
|
+
const before = items.slice(0, index);
|
|
1907
|
+
const after = items.slice(index + 1);
|
|
1908
|
+
return [...before, newItem, ...after];
|
|
1909
|
+
};
|
|
1910
|
+
|
|
1911
|
+
const itemLeftUpdate = (state, newItem) => {
|
|
1912
|
+
return {
|
|
1913
|
+
...state,
|
|
1914
|
+
statusBarItemsLeft: updateArray([...state.statusBarItemsLeft], newItem)
|
|
1915
|
+
};
|
|
1916
|
+
};
|
|
1917
|
+
|
|
1918
|
+
const itemRightCreate = (state, newItem) => {
|
|
1919
|
+
const {
|
|
1920
|
+
statusBarItemsRight
|
|
1921
|
+
} = state;
|
|
1922
|
+
const newStatusBarItemsRight = [...statusBarItemsRight, newItem];
|
|
1923
|
+
return {
|
|
1924
|
+
...state,
|
|
1925
|
+
statusBarItemsRight: newStatusBarItemsRight
|
|
1926
|
+
};
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1929
|
+
const itemRightUpdate = (state, newItem) => {
|
|
1930
|
+
const {
|
|
1931
|
+
statusBarItemsRight
|
|
1932
|
+
} = state;
|
|
1933
|
+
const newStatusBarItemsRight = updateArray([...statusBarItemsRight], newItem);
|
|
1934
|
+
return {
|
|
1935
|
+
...state,
|
|
1936
|
+
statusBarItemsRight: newStatusBarItemsRight
|
|
1937
|
+
};
|
|
1938
|
+
};
|
|
1939
|
+
|
|
1940
|
+
const get = async key => {
|
|
1941
|
+
return getPreference(key);
|
|
1942
|
+
};
|
|
1943
|
+
|
|
1944
|
+
const getBooleanPreference = async key => {
|
|
1945
|
+
const value = await get(key);
|
|
1946
|
+
return value ?? true;
|
|
1947
|
+
};
|
|
1948
|
+
const loadStatusBarPreferences = async () => {
|
|
1949
|
+
const [itemsVisible, builtinNotificationsEnabled, builtinProblemsEnabled] = await Promise.all([getBooleanPreference('statusBar.itemsVisible'), getBooleanPreference('statusBar.builtinNotificationsEnabled'), getBooleanPreference('statusBar.builtinProblemsEnabled')]);
|
|
1950
|
+
return {
|
|
1951
|
+
builtinNotificationsEnabled,
|
|
1952
|
+
builtinProblemsEnabled,
|
|
1953
|
+
itemsVisible
|
|
1954
|
+
};
|
|
1955
|
+
};
|
|
1956
|
+
|
|
1957
|
+
const loadContent = async state => {
|
|
1958
|
+
const {
|
|
1959
|
+
assetDir,
|
|
1960
|
+
errorCount,
|
|
1961
|
+
platform,
|
|
1962
|
+
warningCount
|
|
1963
|
+
} = state;
|
|
1964
|
+
const {
|
|
1965
|
+
builtinNotificationsEnabled,
|
|
1966
|
+
builtinProblemsEnabled,
|
|
1967
|
+
itemsVisible
|
|
1968
|
+
} = await loadStatusBarPreferences();
|
|
1969
|
+
const statusBarItems = await getStatusBarItems({
|
|
1970
|
+
assetDir,
|
|
1971
|
+
builtinNotificationsEnabled: builtinNotificationsEnabled,
|
|
1972
|
+
builtinProblemsEnabled: builtinProblemsEnabled,
|
|
1973
|
+
errorCount,
|
|
1974
|
+
platform,
|
|
1975
|
+
showItems: itemsVisible,
|
|
1976
|
+
warningCount
|
|
1977
|
+
});
|
|
1978
|
+
return {
|
|
1979
|
+
...state,
|
|
1980
|
+
errorCount: 0,
|
|
1981
|
+
initial: false,
|
|
1982
|
+
statusBarItemsLeft: statusBarItems.filter(item => item.name !== Notifications),
|
|
1983
|
+
statusBarItemsRight: statusBarItems.filter(item => item.name === Notifications),
|
|
1984
|
+
warningCount: 0
|
|
1985
|
+
};
|
|
1986
|
+
};
|
|
1987
|
+
|
|
1952
1988
|
const renderEventListeners = () => {
|
|
1953
1989
|
return [{
|
|
1954
1990
|
name: HandleContextMenu,
|