@lvce-editor/status-bar-worker 2.5.0 → 3.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/statusBarWorkerMain.js +135 -123
- package/package.json +1 -1
|
@@ -121,8 +121,9 @@ const terminate = () => {
|
|
|
121
121
|
const {
|
|
122
122
|
get: get$3,
|
|
123
123
|
getCommandIds,
|
|
124
|
+
getKeys: getKeys$1,
|
|
124
125
|
registerCommands,
|
|
125
|
-
set: set$
|
|
126
|
+
set: set$4,
|
|
126
127
|
wrapCommand,
|
|
127
128
|
wrapGetter
|
|
128
129
|
} = create$a();
|
|
@@ -138,7 +139,7 @@ const create$9 = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
138
139
|
uid,
|
|
139
140
|
warningCount: 0
|
|
140
141
|
};
|
|
141
|
-
set$
|
|
142
|
+
set$4(uid, state, state);
|
|
142
143
|
};
|
|
143
144
|
|
|
144
145
|
const isEqual = (oldState, newState) => {
|
|
@@ -1212,7 +1213,7 @@ const createMockRpc = ({
|
|
|
1212
1213
|
};
|
|
1213
1214
|
|
|
1214
1215
|
const rpcs = Object.create(null);
|
|
1215
|
-
const set$
|
|
1216
|
+
const set$3 = (id, rpc) => {
|
|
1216
1217
|
rpcs[id] = rpc;
|
|
1217
1218
|
};
|
|
1218
1219
|
const get$1 = id => {
|
|
@@ -1245,7 +1246,7 @@ const create = rpcId => {
|
|
|
1245
1246
|
const mockRpc = createMockRpc({
|
|
1246
1247
|
commandMap
|
|
1247
1248
|
});
|
|
1248
|
-
set$
|
|
1249
|
+
set$3(rpcId, mockRpc);
|
|
1249
1250
|
// @ts-ignore
|
|
1250
1251
|
mockRpc[Symbol.dispose] = () => {
|
|
1251
1252
|
remove(rpcId);
|
|
@@ -1254,7 +1255,7 @@ const create = rpcId => {
|
|
|
1254
1255
|
return mockRpc;
|
|
1255
1256
|
},
|
|
1256
1257
|
set(rpc) {
|
|
1257
|
-
set$
|
|
1258
|
+
set$3(rpcId, rpc);
|
|
1258
1259
|
}
|
|
1259
1260
|
};
|
|
1260
1261
|
};
|
|
@@ -1273,15 +1274,21 @@ const Reference = 100;
|
|
|
1273
1274
|
const TargetName = 'event.target.name';
|
|
1274
1275
|
|
|
1275
1276
|
const ExtensionHostWorker = 44;
|
|
1277
|
+
const ExtensionManagementWorker = 9006;
|
|
1276
1278
|
const RendererWorker = 1;
|
|
1277
1279
|
|
|
1278
1280
|
const SetDom2 = 'Viewlet.setDom2';
|
|
1279
1281
|
const SetPatches = 'Viewlet.setPatches';
|
|
1280
1282
|
|
|
1283
|
+
const {
|
|
1284
|
+
invoke: invoke$2,
|
|
1285
|
+
set: set$2
|
|
1286
|
+
} = create(ExtensionHostWorker);
|
|
1287
|
+
|
|
1281
1288
|
const {
|
|
1282
1289
|
invoke: invoke$1,
|
|
1283
1290
|
set: set$1
|
|
1284
|
-
} = create(
|
|
1291
|
+
} = create(ExtensionManagementWorker);
|
|
1285
1292
|
|
|
1286
1293
|
const {
|
|
1287
1294
|
invoke,
|
|
@@ -1292,9 +1299,6 @@ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
|
|
|
1292
1299
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1293
1300
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
1294
1301
|
};
|
|
1295
|
-
const activateByEvent$1 = (event, assetDir, platform) => {
|
|
1296
|
-
return invoke('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
|
|
1297
|
-
};
|
|
1298
1302
|
const getPreference = async key => {
|
|
1299
1303
|
return await invoke('Preferences.get', key);
|
|
1300
1304
|
};
|
|
@@ -1305,7 +1309,7 @@ const handleClickExtensionStatusBarItem = async name => {
|
|
|
1305
1309
|
|
|
1306
1310
|
try {
|
|
1307
1311
|
// @ts-ignore
|
|
1308
|
-
await invoke$
|
|
1312
|
+
await invoke$2(`ExtensionHostStatusBar.executeCommand`, name);
|
|
1309
1313
|
} catch (error) {
|
|
1310
1314
|
console.error(new VError(error, `Failed to execute status bar command: ${name}`));
|
|
1311
1315
|
}
|
|
@@ -1358,8 +1362,10 @@ const OnStatusBarItem = 'onStatusBarItem';
|
|
|
1358
1362
|
const GetStatusBarItems = 'ExtensionHost.getStatusBarItems2';
|
|
1359
1363
|
|
|
1360
1364
|
const activateByEvent = (event, assetDir, platform) => {
|
|
1361
|
-
|
|
1362
|
-
|
|
1365
|
+
return invoke$1('Extensions.activateByEvent', event, assetDir, platform);
|
|
1366
|
+
};
|
|
1367
|
+
const getStatusBarItems$2 = () => {
|
|
1368
|
+
return invoke$1('Extensions.getStatusBarItems');
|
|
1363
1369
|
};
|
|
1364
1370
|
|
|
1365
1371
|
const executeProviders = async ({
|
|
@@ -1374,7 +1380,7 @@ const executeProviders = async ({
|
|
|
1374
1380
|
}) => {
|
|
1375
1381
|
await activateByEvent(event, assetDir, platform);
|
|
1376
1382
|
// @ts-ignore
|
|
1377
|
-
const result = await invoke$
|
|
1383
|
+
const result = await invoke$2(method, ...params);
|
|
1378
1384
|
return result;
|
|
1379
1385
|
};
|
|
1380
1386
|
|
|
@@ -1382,7 +1388,7 @@ const combineResults = results => {
|
|
|
1382
1388
|
return results.flat();
|
|
1383
1389
|
};
|
|
1384
1390
|
const getStatusBarItems$1 = (assetDir, platform) => {
|
|
1385
|
-
|
|
1391
|
+
const legacyItems = executeProviders({
|
|
1386
1392
|
assetDir,
|
|
1387
1393
|
combineResults,
|
|
1388
1394
|
event: OnStatusBarItem,
|
|
@@ -1392,6 +1398,8 @@ const getStatusBarItems$1 = (assetDir, platform) => {
|
|
|
1392
1398
|
params: [],
|
|
1393
1399
|
platform
|
|
1394
1400
|
});
|
|
1401
|
+
const isolatedItems = getStatusBarItems$2();
|
|
1402
|
+
return Promise.all([legacyItems, isolatedItems]).then(combineResults);
|
|
1395
1403
|
};
|
|
1396
1404
|
|
|
1397
1405
|
const getNotificationsStatusBarItem = enabled => {
|
|
@@ -1530,7 +1538,6 @@ const getStatusBarItems = async ({
|
|
|
1530
1538
|
return [];
|
|
1531
1539
|
}
|
|
1532
1540
|
await activateByEvent('onStatusBarItem', assetDir, platform);
|
|
1533
|
-
await activateByEvent('onSourceControl', assetDir, platform);
|
|
1534
1541
|
const extensionStatusBarItems = await getStatusBarItems$1(assetDir, platform);
|
|
1535
1542
|
const uiStatusBarItems = toUiStatusBarItems(extensionStatusBarItems);
|
|
1536
1543
|
const extraItems = await getBuiltinStatusBarItems(errorCount, warningCount, {
|
|
@@ -1567,6 +1574,36 @@ const handleItemsChanged = async state => {
|
|
|
1567
1574
|
return handleExtensionsChanged(state);
|
|
1568
1575
|
};
|
|
1569
1576
|
|
|
1577
|
+
const handleExtensionManagementChange = async () => {
|
|
1578
|
+
const uids = getKeys$1();
|
|
1579
|
+
for (const uid of uids) {
|
|
1580
|
+
const {
|
|
1581
|
+
newState,
|
|
1582
|
+
oldState
|
|
1583
|
+
} = get$3(uid);
|
|
1584
|
+
const newerState = await handleItemsChanged(newState);
|
|
1585
|
+
if (newState === newerState || oldState === newerState) {
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1588
|
+
set$4(uid, oldState, {
|
|
1589
|
+
...newState,
|
|
1590
|
+
...newerState
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
const commandMap$1 = {
|
|
1596
|
+
'StatusBar.handleChange': handleExtensionManagementChange
|
|
1597
|
+
};
|
|
1598
|
+
|
|
1599
|
+
const handleExtensionManagementMessagePort = async port => {
|
|
1600
|
+
const rpc = await create$4({
|
|
1601
|
+
commandMap: commandMap$1,
|
|
1602
|
+
messagePort: port
|
|
1603
|
+
});
|
|
1604
|
+
set$1(rpc);
|
|
1605
|
+
};
|
|
1606
|
+
|
|
1570
1607
|
const id = 7201;
|
|
1571
1608
|
const sendMessagePortToExtensionHostWorker = async port => {
|
|
1572
1609
|
await sendMessagePortToExtensionHostWorker$1(port, id);
|
|
@@ -1577,7 +1614,7 @@ const initializeExtensionHostWorker = async () => {
|
|
|
1577
1614
|
commandMap: {},
|
|
1578
1615
|
send: sendMessagePortToExtensionHostWorker
|
|
1579
1616
|
});
|
|
1580
|
-
set$
|
|
1617
|
+
set$2(rpc);
|
|
1581
1618
|
};
|
|
1582
1619
|
|
|
1583
1620
|
const initialize = async () => {
|
|
@@ -1819,11 +1856,78 @@ const treeToArray = node => {
|
|
|
1819
1856
|
return result;
|
|
1820
1857
|
};
|
|
1821
1858
|
|
|
1859
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
1860
|
+
if (currentChildIndex === -1) {
|
|
1861
|
+
patches.push({
|
|
1862
|
+
type: NavigateChild,
|
|
1863
|
+
index
|
|
1864
|
+
});
|
|
1865
|
+
return index;
|
|
1866
|
+
}
|
|
1867
|
+
if (currentChildIndex !== index) {
|
|
1868
|
+
patches.push({
|
|
1869
|
+
type: NavigateSibling,
|
|
1870
|
+
index
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
return index;
|
|
1874
|
+
};
|
|
1875
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
1876
|
+
if (currentChildIndex >= 0) {
|
|
1877
|
+
patches.push({
|
|
1878
|
+
type: NavigateParent
|
|
1879
|
+
});
|
|
1880
|
+
}
|
|
1881
|
+
return -1;
|
|
1882
|
+
};
|
|
1883
|
+
const addTree = (newNode, patches) => {
|
|
1884
|
+
patches.push({
|
|
1885
|
+
type: Add,
|
|
1886
|
+
nodes: treeToArray(newNode)
|
|
1887
|
+
});
|
|
1888
|
+
};
|
|
1889
|
+
const replaceTree = (newNode, patches) => {
|
|
1890
|
+
patches.push({
|
|
1891
|
+
type: Replace,
|
|
1892
|
+
nodes: treeToArray(newNode)
|
|
1893
|
+
});
|
|
1894
|
+
};
|
|
1895
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
1896
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1897
|
+
if (nodePatches === null) {
|
|
1898
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
1899
|
+
replaceTree(newNode, patches);
|
|
1900
|
+
return nextChildIndex;
|
|
1901
|
+
}
|
|
1902
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
1903
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
1904
|
+
return currentChildIndex;
|
|
1905
|
+
}
|
|
1906
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
1907
|
+
if (nodePatches.length > 0) {
|
|
1908
|
+
patches.push(...nodePatches);
|
|
1909
|
+
}
|
|
1910
|
+
if (hasChildrenToCompare) {
|
|
1911
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
1912
|
+
}
|
|
1913
|
+
return nextChildIndex;
|
|
1914
|
+
};
|
|
1915
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
1916
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1917
|
+
if (nodePatches === null) {
|
|
1918
|
+
replaceTree(newNode, patches);
|
|
1919
|
+
return;
|
|
1920
|
+
}
|
|
1921
|
+
if (nodePatches.length > 0) {
|
|
1922
|
+
patches.push(...nodePatches);
|
|
1923
|
+
}
|
|
1924
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
1925
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1822
1928
|
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
1823
1929
|
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
1824
|
-
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
1825
1930
|
let currentChildIndex = -1;
|
|
1826
|
-
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
1827
1931
|
const indicesToRemove = [];
|
|
1828
1932
|
for (let i = 0; i < maxLength; i++) {
|
|
1829
1933
|
const oldNode = oldChildren[i];
|
|
@@ -1832,88 +1936,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
1832
1936
|
continue;
|
|
1833
1937
|
}
|
|
1834
1938
|
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
|
|
1939
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
1940
|
+
addTree(newNode, patches);
|
|
1941
|
+
continue;
|
|
1942
|
+
}
|
|
1943
|
+
if (!newNode) {
|
|
1906
1944
|
indicesToRemove.push(i);
|
|
1945
|
+
continue;
|
|
1907
1946
|
}
|
|
1947
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
1908
1948
|
}
|
|
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
|
|
1949
|
+
navigateToParent(patches, currentChildIndex);
|
|
1917
1950
|
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
1918
1951
|
patches.push({
|
|
1919
1952
|
type: RemoveChild,
|
|
@@ -1922,33 +1955,11 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
1922
1955
|
}
|
|
1923
1956
|
};
|
|
1924
1957
|
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
1958
|
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);
|
|
1959
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
1960
|
+
return;
|
|
1951
1961
|
}
|
|
1962
|
+
diffChildren(oldTree, newTree, patches);
|
|
1952
1963
|
};
|
|
1953
1964
|
|
|
1954
1965
|
const removeTrailingNavigationPatches = patches => {
|
|
@@ -2114,7 +2125,7 @@ const render2 = (uid, diffResult) => {
|
|
|
2114
2125
|
newState,
|
|
2115
2126
|
oldState
|
|
2116
2127
|
} = get$3(uid);
|
|
2117
|
-
set$
|
|
2128
|
+
set$4(uid, newState, newState);
|
|
2118
2129
|
const commands = applyRender(oldState, newState, diffResult);
|
|
2119
2130
|
return commands;
|
|
2120
2131
|
};
|
|
@@ -2155,6 +2166,7 @@ const commandMap = {
|
|
|
2155
2166
|
'StatusBar.handleChange': wrapCommand(handleItemsChanged),
|
|
2156
2167
|
'StatusBar.handleClick': wrapCommand(handleClick),
|
|
2157
2168
|
'StatusBar.handleContextMenu': wrapCommand(handleContextMenu),
|
|
2169
|
+
'StatusBar.handleExtensionManagementMessagePort': handleExtensionManagementMessagePort,
|
|
2158
2170
|
'StatusBar.handleExtensionsChanged': wrapCommand(handleExtensionsChanged),
|
|
2159
2171
|
'StatusBar.handleItemsChanged': wrapCommand(handleItemsChanged),
|
|
2160
2172
|
'StatusBar.initialize': initialize,
|