@lvce-editor/status-bar-worker 3.2.0 → 3.2.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 +11 -280
- package/package.json +1 -1
|
@@ -121,7 +121,7 @@ const terminate = () => {
|
|
|
121
121
|
const {
|
|
122
122
|
get: get$3,
|
|
123
123
|
getCommandIds,
|
|
124
|
-
getKeys
|
|
124
|
+
getKeys,
|
|
125
125
|
registerCommands,
|
|
126
126
|
set: set$4,
|
|
127
127
|
wrapCommand,
|
|
@@ -249,7 +249,7 @@ class AssertionError extends Error {
|
|
|
249
249
|
const Object$1 = 1;
|
|
250
250
|
const Number$1 = 2;
|
|
251
251
|
const Array$1 = 3;
|
|
252
|
-
const String = 4;
|
|
252
|
+
const String$1 = 4;
|
|
253
253
|
const Boolean$1 = 5;
|
|
254
254
|
const Function = 6;
|
|
255
255
|
const Null = 7;
|
|
@@ -261,7 +261,7 @@ const getType = value => {
|
|
|
261
261
|
case 'function':
|
|
262
262
|
return Function;
|
|
263
263
|
case 'string':
|
|
264
|
-
return String;
|
|
264
|
+
return String$1;
|
|
265
265
|
case 'object':
|
|
266
266
|
if (value === null) {
|
|
267
267
|
return Null;
|
|
@@ -1312,7 +1312,6 @@ const Button$1 = 1;
|
|
|
1312
1312
|
const Div = 4;
|
|
1313
1313
|
const Span = 8;
|
|
1314
1314
|
const Text = 12;
|
|
1315
|
-
const Reference = 100;
|
|
1316
1315
|
|
|
1317
1316
|
const Button = 'event.button';
|
|
1318
1317
|
const ClientX = 'event.clientX';
|
|
@@ -1324,7 +1323,6 @@ const ExtensionManagementWorker = 9006;
|
|
|
1324
1323
|
const RendererWorker = 1;
|
|
1325
1324
|
|
|
1326
1325
|
const SetDom2 = 'Viewlet.setDom2';
|
|
1327
|
-
const SetPatches = 'Viewlet.setPatches';
|
|
1328
1326
|
|
|
1329
1327
|
const {
|
|
1330
1328
|
invoke: invoke$2,
|
|
@@ -1357,12 +1355,8 @@ const getPreference = async key => {
|
|
|
1357
1355
|
};
|
|
1358
1356
|
|
|
1359
1357
|
const handleClickExtensionStatusBarItem = async name => {
|
|
1360
|
-
// TODO maybe relay this to extension management worker,
|
|
1361
|
-
// and it forwards it to the right extension host?
|
|
1362
|
-
|
|
1363
1358
|
try {
|
|
1364
|
-
|
|
1365
|
-
await invoke$2(`ExtensionHostStatusBar.executeCommand`, name);
|
|
1359
|
+
await invoke$1('Extensions.executeCommand', name);
|
|
1366
1360
|
} catch (error) {
|
|
1367
1361
|
console.error(new VError(error, `Failed to execute status bar command: ${name}`));
|
|
1368
1362
|
}
|
|
@@ -1449,7 +1443,7 @@ const executeProviders = async ({
|
|
|
1449
1443
|
const combineResults = results => {
|
|
1450
1444
|
return results.flat();
|
|
1451
1445
|
};
|
|
1452
|
-
const getStatusBarItems$1 = (assetDir, platform) => {
|
|
1446
|
+
const getStatusBarItems$1 = async (assetDir, platform) => {
|
|
1453
1447
|
const legacyItems = executeProviders({
|
|
1454
1448
|
assetDir,
|
|
1455
1449
|
combineResults,
|
|
@@ -1461,7 +1455,8 @@ const getStatusBarItems$1 = (assetDir, platform) => {
|
|
|
1461
1455
|
platform
|
|
1462
1456
|
});
|
|
1463
1457
|
const isolatedItems = getStatusBarItems$2();
|
|
1464
|
-
|
|
1458
|
+
const results = await Promise.all([legacyItems, isolatedItems]);
|
|
1459
|
+
return combineResults(results);
|
|
1465
1460
|
};
|
|
1466
1461
|
|
|
1467
1462
|
const getNotificationsStatusBarItem = enabled => {
|
|
@@ -1514,13 +1509,13 @@ const getProblemsStatusBarItem = (errorCount, warningCount, enabled) => {
|
|
|
1514
1509
|
value: ProblemsErrorIcon
|
|
1515
1510
|
}, {
|
|
1516
1511
|
type: 'text',
|
|
1517
|
-
value:
|
|
1512
|
+
value: String(errorCount)
|
|
1518
1513
|
}, {
|
|
1519
1514
|
type: 'icon',
|
|
1520
1515
|
value: ProblemsWarningIcon
|
|
1521
1516
|
}, {
|
|
1522
1517
|
type: 'text',
|
|
1523
|
-
value:
|
|
1518
|
+
value: String(warningCount)
|
|
1524
1519
|
}],
|
|
1525
1520
|
name: Problems,
|
|
1526
1521
|
tooltip: 'Problems'
|
|
@@ -1637,7 +1632,7 @@ const handleItemsChanged = async state => {
|
|
|
1637
1632
|
};
|
|
1638
1633
|
|
|
1639
1634
|
const handleExtensionManagementChange = async () => {
|
|
1640
|
-
const uids = getKeys
|
|
1635
|
+
const uids = getKeys();
|
|
1641
1636
|
for (const uid of uids) {
|
|
1642
1637
|
const {
|
|
1643
1638
|
newState,
|
|
@@ -1788,267 +1783,6 @@ const text = data => {
|
|
|
1788
1783
|
};
|
|
1789
1784
|
};
|
|
1790
1785
|
|
|
1791
|
-
const SetText = 1;
|
|
1792
|
-
const Replace = 2;
|
|
1793
|
-
const SetAttribute = 3;
|
|
1794
|
-
const RemoveAttribute = 4;
|
|
1795
|
-
const Add = 6;
|
|
1796
|
-
const NavigateChild = 7;
|
|
1797
|
-
const NavigateParent = 8;
|
|
1798
|
-
const RemoveChild = 9;
|
|
1799
|
-
const NavigateSibling = 10;
|
|
1800
|
-
const SetReferenceNodeUid = 11;
|
|
1801
|
-
|
|
1802
|
-
const isKey = key => {
|
|
1803
|
-
return key !== 'type' && key !== 'childCount';
|
|
1804
|
-
};
|
|
1805
|
-
|
|
1806
|
-
const getKeys = node => {
|
|
1807
|
-
const keys = Object.keys(node).filter(isKey);
|
|
1808
|
-
return keys;
|
|
1809
|
-
};
|
|
1810
|
-
|
|
1811
|
-
const arrayToTree = nodes => {
|
|
1812
|
-
const result = [];
|
|
1813
|
-
let i = 0;
|
|
1814
|
-
while (i < nodes.length) {
|
|
1815
|
-
const node = nodes[i];
|
|
1816
|
-
const {
|
|
1817
|
-
children,
|
|
1818
|
-
nodesConsumed
|
|
1819
|
-
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
1820
|
-
result.push({
|
|
1821
|
-
node,
|
|
1822
|
-
children
|
|
1823
|
-
});
|
|
1824
|
-
i += 1 + nodesConsumed;
|
|
1825
|
-
}
|
|
1826
|
-
return result;
|
|
1827
|
-
};
|
|
1828
|
-
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
1829
|
-
if (childCount === 0) {
|
|
1830
|
-
return {
|
|
1831
|
-
children: [],
|
|
1832
|
-
nodesConsumed: 0
|
|
1833
|
-
};
|
|
1834
|
-
}
|
|
1835
|
-
const children = [];
|
|
1836
|
-
let i = startIndex;
|
|
1837
|
-
let remaining = childCount;
|
|
1838
|
-
let totalConsumed = 0;
|
|
1839
|
-
while (remaining > 0 && i < nodes.length) {
|
|
1840
|
-
const node = nodes[i];
|
|
1841
|
-
const nodeChildCount = node.childCount || 0;
|
|
1842
|
-
const {
|
|
1843
|
-
children: nodeChildren,
|
|
1844
|
-
nodesConsumed
|
|
1845
|
-
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
1846
|
-
children.push({
|
|
1847
|
-
node,
|
|
1848
|
-
children: nodeChildren
|
|
1849
|
-
});
|
|
1850
|
-
const nodeSize = 1 + nodesConsumed;
|
|
1851
|
-
i += nodeSize;
|
|
1852
|
-
totalConsumed += nodeSize;
|
|
1853
|
-
remaining--;
|
|
1854
|
-
}
|
|
1855
|
-
return {
|
|
1856
|
-
children,
|
|
1857
|
-
nodesConsumed: totalConsumed
|
|
1858
|
-
};
|
|
1859
|
-
};
|
|
1860
|
-
|
|
1861
|
-
const compareNodes = (oldNode, newNode) => {
|
|
1862
|
-
const patches = [];
|
|
1863
|
-
// Check if node type changed - return null to signal incompatible nodes
|
|
1864
|
-
// (caller should handle this with a Replace operation)
|
|
1865
|
-
if (oldNode.type !== newNode.type) {
|
|
1866
|
-
return null;
|
|
1867
|
-
}
|
|
1868
|
-
// Handle reference nodes - special handling for uid changes
|
|
1869
|
-
if (oldNode.type === Reference) {
|
|
1870
|
-
if (oldNode.uid !== newNode.uid) {
|
|
1871
|
-
patches.push({
|
|
1872
|
-
type: SetReferenceNodeUid,
|
|
1873
|
-
uid: newNode.uid
|
|
1874
|
-
});
|
|
1875
|
-
}
|
|
1876
|
-
return patches;
|
|
1877
|
-
}
|
|
1878
|
-
// Handle text nodes
|
|
1879
|
-
if (oldNode.type === Text && newNode.type === Text) {
|
|
1880
|
-
if (oldNode.text !== newNode.text) {
|
|
1881
|
-
patches.push({
|
|
1882
|
-
type: SetText,
|
|
1883
|
-
value: newNode.text
|
|
1884
|
-
});
|
|
1885
|
-
}
|
|
1886
|
-
return patches;
|
|
1887
|
-
}
|
|
1888
|
-
// Compare attributes
|
|
1889
|
-
const oldKeys = getKeys(oldNode);
|
|
1890
|
-
const newKeys = getKeys(newNode);
|
|
1891
|
-
// Check for attribute changes
|
|
1892
|
-
for (const key of newKeys) {
|
|
1893
|
-
if (oldNode[key] !== newNode[key]) {
|
|
1894
|
-
patches.push({
|
|
1895
|
-
type: SetAttribute,
|
|
1896
|
-
key,
|
|
1897
|
-
value: newNode[key]
|
|
1898
|
-
});
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
// Check for removed attributes
|
|
1902
|
-
for (const key of oldKeys) {
|
|
1903
|
-
if (!(key in newNode)) {
|
|
1904
|
-
patches.push({
|
|
1905
|
-
type: RemoveAttribute,
|
|
1906
|
-
key
|
|
1907
|
-
});
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
return patches;
|
|
1911
|
-
};
|
|
1912
|
-
|
|
1913
|
-
const treeToArray = node => {
|
|
1914
|
-
const result = [node.node];
|
|
1915
|
-
for (const child of node.children) {
|
|
1916
|
-
result.push(...treeToArray(child));
|
|
1917
|
-
}
|
|
1918
|
-
return result;
|
|
1919
|
-
};
|
|
1920
|
-
|
|
1921
|
-
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
1922
|
-
if (currentChildIndex === -1) {
|
|
1923
|
-
patches.push({
|
|
1924
|
-
type: NavigateChild,
|
|
1925
|
-
index
|
|
1926
|
-
});
|
|
1927
|
-
return index;
|
|
1928
|
-
}
|
|
1929
|
-
if (currentChildIndex !== index) {
|
|
1930
|
-
patches.push({
|
|
1931
|
-
type: NavigateSibling,
|
|
1932
|
-
index
|
|
1933
|
-
});
|
|
1934
|
-
}
|
|
1935
|
-
return index;
|
|
1936
|
-
};
|
|
1937
|
-
const navigateToParent = (patches, currentChildIndex) => {
|
|
1938
|
-
if (currentChildIndex >= 0) {
|
|
1939
|
-
patches.push({
|
|
1940
|
-
type: NavigateParent
|
|
1941
|
-
});
|
|
1942
|
-
}
|
|
1943
|
-
return -1;
|
|
1944
|
-
};
|
|
1945
|
-
const addTree = (newNode, patches) => {
|
|
1946
|
-
patches.push({
|
|
1947
|
-
type: Add,
|
|
1948
|
-
nodes: treeToArray(newNode)
|
|
1949
|
-
});
|
|
1950
|
-
};
|
|
1951
|
-
const replaceTree = (newNode, patches) => {
|
|
1952
|
-
patches.push({
|
|
1953
|
-
type: Replace,
|
|
1954
|
-
nodes: treeToArray(newNode)
|
|
1955
|
-
});
|
|
1956
|
-
};
|
|
1957
|
-
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
1958
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1959
|
-
if (nodePatches === null) {
|
|
1960
|
-
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
1961
|
-
replaceTree(newNode, patches);
|
|
1962
|
-
return nextChildIndex;
|
|
1963
|
-
}
|
|
1964
|
-
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
1965
|
-
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
1966
|
-
return currentChildIndex;
|
|
1967
|
-
}
|
|
1968
|
-
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
1969
|
-
if (nodePatches.length > 0) {
|
|
1970
|
-
patches.push(...nodePatches);
|
|
1971
|
-
}
|
|
1972
|
-
if (hasChildrenToCompare) {
|
|
1973
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
1974
|
-
}
|
|
1975
|
-
return nextChildIndex;
|
|
1976
|
-
};
|
|
1977
|
-
const diffRootNode = (oldNode, newNode, patches) => {
|
|
1978
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1979
|
-
if (nodePatches === null) {
|
|
1980
|
-
replaceTree(newNode, patches);
|
|
1981
|
-
return;
|
|
1982
|
-
}
|
|
1983
|
-
if (nodePatches.length > 0) {
|
|
1984
|
-
patches.push(...nodePatches);
|
|
1985
|
-
}
|
|
1986
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
1987
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
1988
|
-
}
|
|
1989
|
-
};
|
|
1990
|
-
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
1991
|
-
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
1992
|
-
let currentChildIndex = -1;
|
|
1993
|
-
const indicesToRemove = [];
|
|
1994
|
-
for (let i = 0; i < maxLength; i++) {
|
|
1995
|
-
const oldNode = oldChildren[i];
|
|
1996
|
-
const newNode = newChildren[i];
|
|
1997
|
-
if (!oldNode && !newNode) {
|
|
1998
|
-
continue;
|
|
1999
|
-
}
|
|
2000
|
-
if (!oldNode) {
|
|
2001
|
-
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
2002
|
-
addTree(newNode, patches);
|
|
2003
|
-
continue;
|
|
2004
|
-
}
|
|
2005
|
-
if (!newNode) {
|
|
2006
|
-
indicesToRemove.push(i);
|
|
2007
|
-
continue;
|
|
2008
|
-
}
|
|
2009
|
-
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
2010
|
-
}
|
|
2011
|
-
navigateToParent(patches, currentChildIndex);
|
|
2012
|
-
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
2013
|
-
patches.push({
|
|
2014
|
-
type: RemoveChild,
|
|
2015
|
-
index: indicesToRemove[j]
|
|
2016
|
-
});
|
|
2017
|
-
}
|
|
2018
|
-
};
|
|
2019
|
-
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
2020
|
-
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
2021
|
-
diffRootNode(oldTree[0], newTree[0], patches);
|
|
2022
|
-
return;
|
|
2023
|
-
}
|
|
2024
|
-
diffChildren(oldTree, newTree, patches);
|
|
2025
|
-
};
|
|
2026
|
-
|
|
2027
|
-
const removeTrailingNavigationPatches = patches => {
|
|
2028
|
-
// Find the last non-navigation patch
|
|
2029
|
-
let lastNonNavigationIndex = -1;
|
|
2030
|
-
for (let i = patches.length - 1; i >= 0; i--) {
|
|
2031
|
-
const patch = patches[i];
|
|
2032
|
-
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
2033
|
-
lastNonNavigationIndex = i;
|
|
2034
|
-
break;
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
// Return patches up to and including the last non-navigation patch
|
|
2038
|
-
return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
|
|
2039
|
-
};
|
|
2040
|
-
|
|
2041
|
-
const diffTree = (oldNodes, newNodes) => {
|
|
2042
|
-
// Step 1: Convert flat arrays to tree structures
|
|
2043
|
-
const oldTree = arrayToTree(oldNodes);
|
|
2044
|
-
const newTree = arrayToTree(newNodes);
|
|
2045
|
-
// Step 3: Compare the trees
|
|
2046
|
-
const patches = [];
|
|
2047
|
-
diffTrees(oldTree, newTree, patches, []);
|
|
2048
|
-
// Remove trailing navigation patches since they serve no purpose
|
|
2049
|
-
return removeTrailingNavigationPatches(patches);
|
|
2050
|
-
};
|
|
2051
|
-
|
|
2052
1786
|
const HandleContextMenu = 2;
|
|
2053
1787
|
const HandleClick = 11;
|
|
2054
1788
|
|
|
@@ -2153,10 +1887,7 @@ const renderItems = (oldState, newState) => {
|
|
|
2153
1887
|
};
|
|
2154
1888
|
|
|
2155
1889
|
const renderIncremental = (oldState, newState) => {
|
|
2156
|
-
|
|
2157
|
-
const newDom = renderItems(newState, newState)[2];
|
|
2158
|
-
const patches = diffTree(oldDom, newDom);
|
|
2159
|
-
return [SetPatches, newState.uid, patches];
|
|
1890
|
+
return renderItems(oldState, newState);
|
|
2160
1891
|
};
|
|
2161
1892
|
|
|
2162
1893
|
const getRenderer = diffType => {
|