@lvce-editor/status-bar-worker 3.16.0 → 3.16.2

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.
@@ -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,215 @@ 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 {
1790
+ newState
1791
+ } = get$3(uid);
1792
+ if (newState.initial) {
1793
+ return;
1794
+ }
1795
+ const diffResult = diff2(uid);
1796
+ if (diffResult.length === 0) {
1797
+ return;
1798
+ }
1799
+ const commands = await render2(uid, diffResult);
1800
+ if (commands.length === 0) {
1801
+ return;
1802
+ }
1803
+ await invoke('Viewlet.sendMultiple', commands);
1804
+ };
1805
+
1806
+ const handleExtensionManagementChange = async () => {
1807
+ for (const uid of getKeys()) {
1808
+ const {
1809
+ newState,
1810
+ oldState
1811
+ } = get$3(uid);
1812
+ const newerState = await handleItemsChanged(newState);
1813
+ if (newState === newerState || oldState === newerState) {
1814
+ continue;
1815
+ }
1816
+ set$5(uid, oldState, {
1817
+ ...newState,
1818
+ ...newerState
1819
+ });
1820
+ await renderOutOfBand(uid);
1821
+ }
1822
+ };
1823
+
1824
+ const handleNotificationCountChanged = (state, count) => {
1825
+ const {
1826
+ statusBarItemsRight
1827
+ } = state;
1828
+ const notificationsEnabled = statusBarItemsRight.some(item => item.name === Notifications);
1829
+ if (!notificationsEnabled) {
1830
+ return state;
1831
+ }
1832
+ const [notificationItem] = getNotificationsStatusBarItem(true, count);
1833
+ if (!notificationItem) {
1834
+ return state;
1835
+ }
1836
+ return {
1837
+ ...state,
1838
+ statusBarItemsRight: statusBarItemsRight.map(item => item.name === Notifications ? notificationItem : item)
1839
+ };
1840
+ };
1841
+
1842
+ const handleNotificationCountChangedAll = async count => {
1843
+ for (const uid of getKeys()) {
1844
+ const {
1845
+ newState,
1846
+ oldState
1847
+ } = get$3(uid);
1848
+ const newerState = handleNotificationCountChanged(newState, count);
1849
+ if (newState === newerState || oldState === newerState) {
1850
+ continue;
1851
+ }
1852
+ set$5(uid, oldState, newerState);
1853
+ await renderOutOfBand(uid);
1854
+ }
1855
+ };
1856
+
1857
+ const commandMap$1 = {
1858
+ 'StatusBar.handleChange': handleExtensionManagementChange,
1859
+ 'StatusBar.handleNotificationCountChanged': handleNotificationCountChangedAll
1860
+ };
1861
+
1862
+ const handleExtensionManagementMessagePort = async port => {
1863
+ const rpc = await create$2({
1864
+ commandMap: commandMap$1,
1865
+ messagePort: port
1866
+ });
1867
+ set$3(rpc);
1868
+ };
1869
+
1870
+ const handleMessagePort = async port => {
1871
+ const rpc = await create$2({
1872
+ commandMap: {},
1873
+ messagePort: port
1874
+ });
1875
+ set(rpc);
1876
+ };
1877
+
1878
+ const handleProblemsSummaryChange = (state, summary) => {
1879
+ const {
1880
+ errorCount: oldErrorCount,
1881
+ statusBarItemsLeft: oldStatusBarItemsLeft,
1882
+ warningCount: oldWarningCount
1883
+ } = state;
1884
+ const errorCount = summary.hasEditor ? summary.errorCount : 0;
1885
+ const warningCount = summary.hasEditor ? summary.warningCount : 0;
1886
+ if (oldErrorCount === errorCount && oldWarningCount === warningCount) {
1887
+ return state;
1888
+ }
1889
+ const problemsItem = getProblemsStatusBarItem(errorCount, warningCount, true)[0];
1890
+ const statusBarItemsLeft = oldStatusBarItemsLeft.map(item => item.name === Problems ? problemsItem : item);
1891
+ return {
1892
+ ...state,
1893
+ errorCount,
1894
+ statusBarItemsLeft,
1895
+ warningCount
1896
+ };
1897
+ };
1898
+
1899
+ const initialize = async () => {};
1900
+
1901
+ const getIndex = (items, item) => {
1902
+ for (let i = 0; i < items.length; i++) {
1903
+ if (items[i].name === item.name) {
1904
+ return i;
1905
+ }
1906
+ }
1907
+ return -1;
1908
+ };
1909
+
1910
+ const updateArray = (items, newItem) => {
1911
+ const index = getIndex(items, newItem);
1912
+ const before = items.slice(0, index);
1913
+ const after = items.slice(index + 1);
1914
+ return [...before, newItem, ...after];
1915
+ };
1916
+
1917
+ const itemLeftUpdate = (state, newItem) => {
1918
+ return {
1919
+ ...state,
1920
+ statusBarItemsLeft: updateArray([...state.statusBarItemsLeft], newItem)
1921
+ };
1922
+ };
1923
+
1924
+ const itemRightCreate = (state, newItem) => {
1925
+ const {
1926
+ statusBarItemsRight
1927
+ } = state;
1928
+ const newStatusBarItemsRight = [...statusBarItemsRight, newItem];
1929
+ return {
1930
+ ...state,
1931
+ statusBarItemsRight: newStatusBarItemsRight
1932
+ };
1933
+ };
1934
+
1935
+ const itemRightUpdate = (state, newItem) => {
1936
+ const {
1937
+ statusBarItemsRight
1938
+ } = state;
1939
+ const newStatusBarItemsRight = updateArray([...statusBarItemsRight], newItem);
1940
+ return {
1941
+ ...state,
1942
+ statusBarItemsRight: newStatusBarItemsRight
1943
+ };
1944
+ };
1945
+
1946
+ const get = async key => {
1947
+ return getPreference(key);
1948
+ };
1949
+
1950
+ const getBooleanPreference = async key => {
1951
+ const value = await get(key);
1952
+ return value ?? true;
1953
+ };
1954
+ const loadStatusBarPreferences = async () => {
1955
+ const [itemsVisible, builtinNotificationsEnabled, builtinProblemsEnabled] = await Promise.all([getBooleanPreference('statusBar.itemsVisible'), getBooleanPreference('statusBar.builtinNotificationsEnabled'), getBooleanPreference('statusBar.builtinProblemsEnabled')]);
1956
+ return {
1957
+ builtinNotificationsEnabled,
1958
+ builtinProblemsEnabled,
1959
+ itemsVisible
1960
+ };
1961
+ };
1962
+
1963
+ const loadContent = async state => {
1964
+ const {
1965
+ assetDir,
1966
+ errorCount,
1967
+ platform,
1968
+ warningCount
1969
+ } = state;
1970
+ const {
1971
+ builtinNotificationsEnabled,
1972
+ builtinProblemsEnabled,
1973
+ itemsVisible
1974
+ } = await loadStatusBarPreferences();
1975
+ const statusBarItems = await getStatusBarItems({
1976
+ assetDir,
1977
+ builtinNotificationsEnabled: builtinNotificationsEnabled,
1978
+ builtinProblemsEnabled: builtinProblemsEnabled,
1979
+ errorCount,
1980
+ platform,
1981
+ showItems: itemsVisible,
1982
+ warningCount
1983
+ });
1984
+ return {
1985
+ ...state,
1986
+ errorCount: 0,
1987
+ initial: false,
1988
+ statusBarItemsLeft: statusBarItems.filter(item => item.name !== Notifications),
1989
+ statusBarItemsRight: statusBarItems.filter(item => item.name === Notifications),
1990
+ warningCount: 0
1991
+ };
1992
+ };
1993
+
1952
1994
  const renderEventListeners = () => {
1953
1995
  return [{
1954
1996
  name: HandleContextMenu,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "3.16.0",
3
+ "version": "3.16.2",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",