@lvce-editor/status-bar-worker 2.5.0 → 2.6.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/statusBarWorkerMain.js +87 -107
- package/package.json +1 -1
|
@@ -1361,6 +1361,10 @@ const activateByEvent = (event, assetDir, platform) => {
|
|
|
1361
1361
|
// @ts-ignore
|
|
1362
1362
|
return activateByEvent$1(event, assetDir, platform);
|
|
1363
1363
|
};
|
|
1364
|
+
const getStatusBarItems$2 = () => {
|
|
1365
|
+
// @ts-ignore
|
|
1366
|
+
return invoke('ExtensionHostManagement.getStatusBarItems');
|
|
1367
|
+
};
|
|
1364
1368
|
|
|
1365
1369
|
const executeProviders = async ({
|
|
1366
1370
|
assetDir,
|
|
@@ -1382,7 +1386,7 @@ const combineResults = results => {
|
|
|
1382
1386
|
return results.flat();
|
|
1383
1387
|
};
|
|
1384
1388
|
const getStatusBarItems$1 = (assetDir, platform) => {
|
|
1385
|
-
|
|
1389
|
+
const legacyItems = executeProviders({
|
|
1386
1390
|
assetDir,
|
|
1387
1391
|
combineResults,
|
|
1388
1392
|
event: OnStatusBarItem,
|
|
@@ -1392,6 +1396,8 @@ const getStatusBarItems$1 = (assetDir, platform) => {
|
|
|
1392
1396
|
params: [],
|
|
1393
1397
|
platform
|
|
1394
1398
|
});
|
|
1399
|
+
const isolatedItems = getStatusBarItems$2();
|
|
1400
|
+
return Promise.all([legacyItems, isolatedItems]).then(combineResults);
|
|
1395
1401
|
};
|
|
1396
1402
|
|
|
1397
1403
|
const getNotificationsStatusBarItem = enabled => {
|
|
@@ -1819,11 +1825,78 @@ const treeToArray = node => {
|
|
|
1819
1825
|
return result;
|
|
1820
1826
|
};
|
|
1821
1827
|
|
|
1828
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
1829
|
+
if (currentChildIndex === -1) {
|
|
1830
|
+
patches.push({
|
|
1831
|
+
type: NavigateChild,
|
|
1832
|
+
index
|
|
1833
|
+
});
|
|
1834
|
+
return index;
|
|
1835
|
+
}
|
|
1836
|
+
if (currentChildIndex !== index) {
|
|
1837
|
+
patches.push({
|
|
1838
|
+
type: NavigateSibling,
|
|
1839
|
+
index
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
return index;
|
|
1843
|
+
};
|
|
1844
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
1845
|
+
if (currentChildIndex >= 0) {
|
|
1846
|
+
patches.push({
|
|
1847
|
+
type: NavigateParent
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
return -1;
|
|
1851
|
+
};
|
|
1852
|
+
const addTree = (newNode, patches) => {
|
|
1853
|
+
patches.push({
|
|
1854
|
+
type: Add,
|
|
1855
|
+
nodes: treeToArray(newNode)
|
|
1856
|
+
});
|
|
1857
|
+
};
|
|
1858
|
+
const replaceTree = (newNode, patches) => {
|
|
1859
|
+
patches.push({
|
|
1860
|
+
type: Replace,
|
|
1861
|
+
nodes: treeToArray(newNode)
|
|
1862
|
+
});
|
|
1863
|
+
};
|
|
1864
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
1865
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1866
|
+
if (nodePatches === null) {
|
|
1867
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
1868
|
+
replaceTree(newNode, patches);
|
|
1869
|
+
return nextChildIndex;
|
|
1870
|
+
}
|
|
1871
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
1872
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
1873
|
+
return currentChildIndex;
|
|
1874
|
+
}
|
|
1875
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
1876
|
+
if (nodePatches.length > 0) {
|
|
1877
|
+
patches.push(...nodePatches);
|
|
1878
|
+
}
|
|
1879
|
+
if (hasChildrenToCompare) {
|
|
1880
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
1881
|
+
}
|
|
1882
|
+
return nextChildIndex;
|
|
1883
|
+
};
|
|
1884
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
1885
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1886
|
+
if (nodePatches === null) {
|
|
1887
|
+
replaceTree(newNode, patches);
|
|
1888
|
+
return;
|
|
1889
|
+
}
|
|
1890
|
+
if (nodePatches.length > 0) {
|
|
1891
|
+
patches.push(...nodePatches);
|
|
1892
|
+
}
|
|
1893
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
1894
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
1822
1897
|
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
1823
1898
|
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
1824
|
-
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
1825
1899
|
let currentChildIndex = -1;
|
|
1826
|
-
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
1827
1900
|
const indicesToRemove = [];
|
|
1828
1901
|
for (let i = 0; i < maxLength; i++) {
|
|
1829
1902
|
const oldNode = oldChildren[i];
|
|
@@ -1832,88 +1905,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
1832
1905
|
continue;
|
|
1833
1906
|
}
|
|
1834
1907
|
if (!oldNode) {
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
});
|
|
1841
|
-
currentChildIndex = -1;
|
|
1842
|
-
}
|
|
1843
|
-
// Flatten the entire subtree so renderInternal can handle it
|
|
1844
|
-
const flatNodes = treeToArray(newNode);
|
|
1845
|
-
patches.push({
|
|
1846
|
-
type: Add,
|
|
1847
|
-
nodes: flatNodes
|
|
1848
|
-
});
|
|
1849
|
-
} else if (newNode) {
|
|
1850
|
-
// Compare nodes to see if we need any patches
|
|
1851
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1852
|
-
// If nodePatches is null, the node types are incompatible - need to replace
|
|
1853
|
-
if (nodePatches === null) {
|
|
1854
|
-
// Navigate to this child
|
|
1855
|
-
if (currentChildIndex === -1) {
|
|
1856
|
-
patches.push({
|
|
1857
|
-
type: NavigateChild,
|
|
1858
|
-
index: i
|
|
1859
|
-
});
|
|
1860
|
-
currentChildIndex = i;
|
|
1861
|
-
} else if (currentChildIndex !== i) {
|
|
1862
|
-
patches.push({
|
|
1863
|
-
type: NavigateSibling,
|
|
1864
|
-
index: i
|
|
1865
|
-
});
|
|
1866
|
-
currentChildIndex = i;
|
|
1867
|
-
}
|
|
1868
|
-
// Replace the entire subtree
|
|
1869
|
-
const flatNodes = treeToArray(newNode);
|
|
1870
|
-
patches.push({
|
|
1871
|
-
type: Replace,
|
|
1872
|
-
nodes: flatNodes
|
|
1873
|
-
});
|
|
1874
|
-
// After replace, we're at the new element (same position)
|
|
1875
|
-
continue;
|
|
1876
|
-
}
|
|
1877
|
-
// Check if we need to recurse into children
|
|
1878
|
-
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
1879
|
-
// Only navigate to this element if we need to do something
|
|
1880
|
-
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
1881
|
-
// Navigate to this child if not already there
|
|
1882
|
-
if (currentChildIndex === -1) {
|
|
1883
|
-
patches.push({
|
|
1884
|
-
type: NavigateChild,
|
|
1885
|
-
index: i
|
|
1886
|
-
});
|
|
1887
|
-
currentChildIndex = i;
|
|
1888
|
-
} else if (currentChildIndex !== i) {
|
|
1889
|
-
patches.push({
|
|
1890
|
-
type: NavigateSibling,
|
|
1891
|
-
index: i
|
|
1892
|
-
});
|
|
1893
|
-
currentChildIndex = i;
|
|
1894
|
-
}
|
|
1895
|
-
// Apply node patches (these apply to the current element, not children)
|
|
1896
|
-
if (nodePatches.length > 0) {
|
|
1897
|
-
patches.push(...nodePatches);
|
|
1898
|
-
}
|
|
1899
|
-
// Compare children recursively
|
|
1900
|
-
if (hasChildrenToCompare) {
|
|
1901
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
1902
|
-
}
|
|
1903
|
-
}
|
|
1904
|
-
} else {
|
|
1905
|
-
// Remove old node - collect the index for later removal
|
|
1908
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
1909
|
+
addTree(newNode, patches);
|
|
1910
|
+
continue;
|
|
1911
|
+
}
|
|
1912
|
+
if (!newNode) {
|
|
1906
1913
|
indicesToRemove.push(i);
|
|
1914
|
+
continue;
|
|
1907
1915
|
}
|
|
1916
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
1908
1917
|
}
|
|
1909
|
-
|
|
1910
|
-
if (currentChildIndex >= 0) {
|
|
1911
|
-
patches.push({
|
|
1912
|
-
type: NavigateParent
|
|
1913
|
-
});
|
|
1914
|
-
}
|
|
1915
|
-
// Add remove patches in reverse order (highest index first)
|
|
1916
|
-
// This ensures indices remain valid as we remove
|
|
1918
|
+
navigateToParent(patches, currentChildIndex);
|
|
1917
1919
|
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
1918
1920
|
patches.push({
|
|
1919
1921
|
type: RemoveChild,
|
|
@@ -1922,33 +1924,11 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
1922
1924
|
}
|
|
1923
1925
|
};
|
|
1924
1926
|
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
1925
|
-
// At the root level (path.length === 0), we're already AT the element
|
|
1926
|
-
// So we compare the root node directly, then compare its children
|
|
1927
1927
|
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
// Compare root nodes
|
|
1931
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1932
|
-
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
1933
|
-
if (nodePatches === null) {
|
|
1934
|
-
const flatNodes = treeToArray(newNode);
|
|
1935
|
-
patches.push({
|
|
1936
|
-
type: Replace,
|
|
1937
|
-
nodes: flatNodes
|
|
1938
|
-
});
|
|
1939
|
-
return;
|
|
1940
|
-
}
|
|
1941
|
-
if (nodePatches.length > 0) {
|
|
1942
|
-
patches.push(...nodePatches);
|
|
1943
|
-
}
|
|
1944
|
-
// Compare children
|
|
1945
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
1946
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
1947
|
-
}
|
|
1948
|
-
} else {
|
|
1949
|
-
// Non-root level or multiple root elements - use the regular comparison
|
|
1950
|
-
diffChildren(oldTree, newTree, patches);
|
|
1928
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
1929
|
+
return;
|
|
1951
1930
|
}
|
|
1931
|
+
diffChildren(oldTree, newTree, patches);
|
|
1952
1932
|
};
|
|
1953
1933
|
|
|
1954
1934
|
const removeTrailingNavigationPatches = patches => {
|