@lvce-editor/status-bar-worker 3.18.0 → 3.20.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 +131 -36
- package/package.json +1 -1
|
@@ -119,11 +119,11 @@ const terminate = () => {
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
const {
|
|
122
|
-
get: get$
|
|
122
|
+
get: get$5,
|
|
123
123
|
getCommandIds,
|
|
124
124
|
getKeys,
|
|
125
125
|
registerCommands,
|
|
126
|
-
set: set$
|
|
126
|
+
set: set$7,
|
|
127
127
|
wrapCommand,
|
|
128
128
|
wrapGetter
|
|
129
129
|
} = create$8();
|
|
@@ -139,7 +139,7 @@ const create$7 = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
139
139
|
uid,
|
|
140
140
|
warningCount: 0
|
|
141
141
|
};
|
|
142
|
-
set$
|
|
142
|
+
set$7(uid, state, state);
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
const isEqual = (oldState, newState) => {
|
|
@@ -167,7 +167,7 @@ const diff2 = uid => {
|
|
|
167
167
|
const {
|
|
168
168
|
newState,
|
|
169
169
|
oldState
|
|
170
|
-
} = get$
|
|
170
|
+
} = get$5(uid);
|
|
171
171
|
const result = diff(oldState, newState);
|
|
172
172
|
return result;
|
|
173
173
|
};
|
|
@@ -721,7 +721,7 @@ const execute = (command, ...args) => {
|
|
|
721
721
|
|
|
722
722
|
const Two$1 = '2.0';
|
|
723
723
|
const callbacks = Object.create(null);
|
|
724
|
-
const get$
|
|
724
|
+
const get$4 = id => {
|
|
725
725
|
return callbacks[id];
|
|
726
726
|
};
|
|
727
727
|
const remove$1 = id => {
|
|
@@ -911,7 +911,7 @@ const warn = (...args) => {
|
|
|
911
911
|
console.warn(...args);
|
|
912
912
|
};
|
|
913
913
|
const resolve = (id, response) => {
|
|
914
|
-
const fn = get$
|
|
914
|
+
const fn = get$4(id);
|
|
915
915
|
if (!fn) {
|
|
916
916
|
console.log(response);
|
|
917
917
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -1244,10 +1244,10 @@ const createMockRpc = ({
|
|
|
1244
1244
|
};
|
|
1245
1245
|
|
|
1246
1246
|
const rpcs = Object.create(null);
|
|
1247
|
-
const set$
|
|
1247
|
+
const set$6 = (id, rpc) => {
|
|
1248
1248
|
rpcs[id] = rpc;
|
|
1249
1249
|
};
|
|
1250
|
-
const get$
|
|
1250
|
+
const get$3 = id => {
|
|
1251
1251
|
return rpcs[id];
|
|
1252
1252
|
};
|
|
1253
1253
|
const remove = id => {
|
|
@@ -1258,18 +1258,18 @@ const remove = id => {
|
|
|
1258
1258
|
const create = rpcId => {
|
|
1259
1259
|
return {
|
|
1260
1260
|
async dispose() {
|
|
1261
|
-
const rpc = get$
|
|
1261
|
+
const rpc = get$3(rpcId);
|
|
1262
1262
|
await rpc.dispose();
|
|
1263
1263
|
},
|
|
1264
1264
|
// @ts-ignore
|
|
1265
1265
|
invoke(method, ...params) {
|
|
1266
|
-
const rpc = get$
|
|
1266
|
+
const rpc = get$3(rpcId);
|
|
1267
1267
|
// @ts-ignore
|
|
1268
1268
|
return rpc.invoke(method, ...params);
|
|
1269
1269
|
},
|
|
1270
1270
|
// @ts-ignore
|
|
1271
1271
|
invokeAndTransfer(method, ...params) {
|
|
1272
|
-
const rpc = get$
|
|
1272
|
+
const rpc = get$3(rpcId);
|
|
1273
1273
|
// @ts-ignore
|
|
1274
1274
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1275
1275
|
},
|
|
@@ -1277,7 +1277,7 @@ const create = rpcId => {
|
|
|
1277
1277
|
const mockRpc = createMockRpc({
|
|
1278
1278
|
commandMap
|
|
1279
1279
|
});
|
|
1280
|
-
set$
|
|
1280
|
+
set$6(rpcId, mockRpc);
|
|
1281
1281
|
// @ts-ignore
|
|
1282
1282
|
mockRpc[Symbol.dispose] = () => {
|
|
1283
1283
|
remove(rpcId);
|
|
@@ -1286,7 +1286,7 @@ const create = rpcId => {
|
|
|
1286
1286
|
return mockRpc;
|
|
1287
1287
|
},
|
|
1288
1288
|
set(rpc) {
|
|
1289
|
-
set$
|
|
1289
|
+
set$6(rpcId, rpc);
|
|
1290
1290
|
}
|
|
1291
1291
|
};
|
|
1292
1292
|
};
|
|
@@ -1315,17 +1315,17 @@ const SetFocusContext = 'Viewlet.setFocusContext';
|
|
|
1315
1315
|
|
|
1316
1316
|
const {
|
|
1317
1317
|
invoke: invoke$3,
|
|
1318
|
-
set: set$
|
|
1318
|
+
set: set$5
|
|
1319
1319
|
} = create(ExtensionManagementWorker);
|
|
1320
1320
|
|
|
1321
1321
|
const {
|
|
1322
1322
|
invoke: invoke$2,
|
|
1323
|
-
set: set$
|
|
1323
|
+
set: set$4
|
|
1324
1324
|
} = create(RendererProcess);
|
|
1325
1325
|
|
|
1326
1326
|
const {
|
|
1327
1327
|
invoke: invoke$1,
|
|
1328
|
-
set: set$
|
|
1328
|
+
set: set$3
|
|
1329
1329
|
} = create(RendererWorker);
|
|
1330
1330
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1331
1331
|
number(uid);
|
|
@@ -1357,8 +1357,18 @@ const handleClickProblems = async () => {
|
|
|
1357
1357
|
await invoke$1('Panel.toggleView', 'Problems');
|
|
1358
1358
|
};
|
|
1359
1359
|
|
|
1360
|
+
const EditorEncoding = 'EditorEncoding';
|
|
1361
|
+
const EditorIndentation = 'EditorIndentation';
|
|
1362
|
+
const EditorLanguage = 'EditorLanguage';
|
|
1363
|
+
const EditorPosition = 'EditorPosition';
|
|
1360
1364
|
const Notifications = 'Notifications';
|
|
1361
1365
|
const Problems = 'Problems';
|
|
1366
|
+
const isEditorStatus = name => {
|
|
1367
|
+
return [EditorEncoding, EditorIndentation, EditorLanguage, EditorPosition].includes(name);
|
|
1368
|
+
};
|
|
1369
|
+
const isRight = name => {
|
|
1370
|
+
return name === Notifications || isEditorStatus(name);
|
|
1371
|
+
};
|
|
1362
1372
|
|
|
1363
1373
|
const handleClick = async (state, name) => {
|
|
1364
1374
|
if (!name) {
|
|
@@ -1376,7 +1386,7 @@ const handleClick = async (state, name) => {
|
|
|
1376
1386
|
await handleClickNotification();
|
|
1377
1387
|
} else if (item.name === Problems) {
|
|
1378
1388
|
await handleClickProblems();
|
|
1379
|
-
} else {
|
|
1389
|
+
} else if (!isEditorStatus(item.name)) {
|
|
1380
1390
|
await handleClickExtensionStatusBarItem(name);
|
|
1381
1391
|
}
|
|
1382
1392
|
// TODO
|
|
@@ -1397,6 +1407,31 @@ const handleContextMenu = async (state, button, x, y) => {
|
|
|
1397
1407
|
return state;
|
|
1398
1408
|
};
|
|
1399
1409
|
|
|
1410
|
+
const textItem = (name, text, ariaLabel, tooltip) => ({
|
|
1411
|
+
ariaLabel,
|
|
1412
|
+
command: '',
|
|
1413
|
+
elements: [{
|
|
1414
|
+
type: 'text',
|
|
1415
|
+
value: text
|
|
1416
|
+
}],
|
|
1417
|
+
name,
|
|
1418
|
+
tooltip
|
|
1419
|
+
});
|
|
1420
|
+
const getEditorStatusBarItems = status => {
|
|
1421
|
+
if (!status) {
|
|
1422
|
+
return [];
|
|
1423
|
+
}
|
|
1424
|
+
const {
|
|
1425
|
+
column,
|
|
1426
|
+
encoding,
|
|
1427
|
+
languageId,
|
|
1428
|
+
line,
|
|
1429
|
+
tabSize
|
|
1430
|
+
} = status;
|
|
1431
|
+
const encodingLabel = encoding === 'utf8' ? ['UTF', '8'].join('-') : encoding;
|
|
1432
|
+
return [textItem(EditorPosition, `Ln ${line}, Col ${column}`, `Line ${line}, Column ${column}`, 'Go to Line/Column'), textItem(EditorIndentation, `Spaces: ${tabSize}`, `Spaces: ${tabSize}`, 'Select Indentation'), textItem(EditorEncoding, encodingLabel, `Encoding: ${encodingLabel}`, 'Select Encoding'), textItem(EditorLanguage, languageId, `Language: ${languageId}`, 'Select Language Mode')];
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1400
1435
|
const getAriaLabel = count => {
|
|
1401
1436
|
if (count === 0) {
|
|
1402
1437
|
return 'No Notifications';
|
|
@@ -1472,11 +1507,12 @@ const getProblemsStatusBarItem = (errorCount, warningCount, enabled) => {
|
|
|
1472
1507
|
};
|
|
1473
1508
|
|
|
1474
1509
|
const getBuiltinStatusBarItems = async (errorCount, warningCount, {
|
|
1510
|
+
editorStatus,
|
|
1475
1511
|
notificationCount = 0,
|
|
1476
1512
|
notificationsEnabled = true,
|
|
1477
1513
|
problemsEnabled = true
|
|
1478
1514
|
} = {}) => {
|
|
1479
|
-
return [...getNotificationsStatusBarItem(notificationsEnabled, notificationCount), ...getProblemsStatusBarItem(errorCount, warningCount, problemsEnabled)];
|
|
1515
|
+
return [...getEditorStatusBarItems(editorStatus), ...getNotificationsStatusBarItem(notificationsEnabled, notificationCount), ...getProblemsStatusBarItem(errorCount, warningCount, problemsEnabled)];
|
|
1480
1516
|
};
|
|
1481
1517
|
|
|
1482
1518
|
const getExtensionStatusBarItems = async (assetDir, platform) => {
|
|
@@ -1556,6 +1592,7 @@ const getStatusBarItems = async ({
|
|
|
1556
1592
|
assetDir,
|
|
1557
1593
|
builtinNotificationsEnabled = true,
|
|
1558
1594
|
builtinProblemsEnabled = true,
|
|
1595
|
+
editorStatus,
|
|
1559
1596
|
errorCount,
|
|
1560
1597
|
platform,
|
|
1561
1598
|
showItems,
|
|
@@ -1568,6 +1605,7 @@ const getStatusBarItems = async ({
|
|
|
1568
1605
|
const notificationCount = await getNotificationCount();
|
|
1569
1606
|
const uiStatusBarItems = toUiStatusBarItems(extensionStatusBarItems);
|
|
1570
1607
|
const extraItems = await getBuiltinStatusBarItems(errorCount, warningCount, {
|
|
1608
|
+
editorStatus,
|
|
1571
1609
|
notificationCount,
|
|
1572
1610
|
notificationsEnabled: builtinNotificationsEnabled,
|
|
1573
1611
|
problemsEnabled: builtinProblemsEnabled
|
|
@@ -1754,8 +1792,8 @@ const isConnected = () => {
|
|
|
1754
1792
|
const invoke = (method, ...params) => {
|
|
1755
1793
|
return invoke$2(method, ...params);
|
|
1756
1794
|
};
|
|
1757
|
-
const set$
|
|
1758
|
-
set$
|
|
1795
|
+
const set$2 = rpc => {
|
|
1796
|
+
set$4(rpc);
|
|
1759
1797
|
state.connected = true;
|
|
1760
1798
|
};
|
|
1761
1799
|
|
|
@@ -1769,8 +1807,8 @@ const render2 = (uid, diffResult) => {
|
|
|
1769
1807
|
const {
|
|
1770
1808
|
newState,
|
|
1771
1809
|
oldState
|
|
1772
|
-
} = get$
|
|
1773
|
-
set$
|
|
1810
|
+
} = get$5(uid);
|
|
1811
|
+
set$7(uid, newState, newState);
|
|
1774
1812
|
const commands = applyRender(oldState, newState, diffResult);
|
|
1775
1813
|
if (!isConnected()) {
|
|
1776
1814
|
return commands;
|
|
@@ -1784,7 +1822,7 @@ const renderOutOfBand = async uid => {
|
|
|
1784
1822
|
}
|
|
1785
1823
|
const {
|
|
1786
1824
|
newState
|
|
1787
|
-
} = get$
|
|
1825
|
+
} = get$5(uid);
|
|
1788
1826
|
if (newState.initial) {
|
|
1789
1827
|
return;
|
|
1790
1828
|
}
|
|
@@ -1804,12 +1842,12 @@ const handleExtensionManagementChange = async () => {
|
|
|
1804
1842
|
const {
|
|
1805
1843
|
newState,
|
|
1806
1844
|
oldState
|
|
1807
|
-
} = get$
|
|
1845
|
+
} = get$5(uid);
|
|
1808
1846
|
const newerState = await handleItemsChanged(newState);
|
|
1809
1847
|
if (newState === newerState || oldState === newerState) {
|
|
1810
1848
|
continue;
|
|
1811
1849
|
}
|
|
1812
|
-
set$
|
|
1850
|
+
set$7(uid, oldState, {
|
|
1813
1851
|
...newState,
|
|
1814
1852
|
...newerState
|
|
1815
1853
|
});
|
|
@@ -1836,25 +1874,25 @@ const handleNotificationCountChanged = (state, count) => {
|
|
|
1836
1874
|
};
|
|
1837
1875
|
|
|
1838
1876
|
let latestCount;
|
|
1839
|
-
const get$
|
|
1877
|
+
const get$2 = () => {
|
|
1840
1878
|
return latestCount;
|
|
1841
1879
|
};
|
|
1842
|
-
const set = count => {
|
|
1880
|
+
const set$1 = count => {
|
|
1843
1881
|
latestCount = count;
|
|
1844
1882
|
};
|
|
1845
1883
|
|
|
1846
1884
|
const handleNotificationCountChangedAll = async count => {
|
|
1847
|
-
set(count);
|
|
1885
|
+
set$1(count);
|
|
1848
1886
|
for (const uid of getKeys()) {
|
|
1849
1887
|
const {
|
|
1850
1888
|
newState,
|
|
1851
1889
|
oldState
|
|
1852
|
-
} = get$
|
|
1890
|
+
} = get$5(uid);
|
|
1853
1891
|
const newerState = handleNotificationCountChanged(newState, count);
|
|
1854
1892
|
if (newState === newerState || oldState === newerState) {
|
|
1855
1893
|
continue;
|
|
1856
1894
|
}
|
|
1857
|
-
set$
|
|
1895
|
+
set$7(uid, oldState, newerState);
|
|
1858
1896
|
await renderOutOfBand(uid);
|
|
1859
1897
|
}
|
|
1860
1898
|
};
|
|
@@ -1869,7 +1907,60 @@ const handleExtensionManagementMessagePort = async port => {
|
|
|
1869
1907
|
commandMap: commandMap$1,
|
|
1870
1908
|
messagePort: port
|
|
1871
1909
|
});
|
|
1872
|
-
set$
|
|
1910
|
+
set$5(rpc);
|
|
1911
|
+
};
|
|
1912
|
+
|
|
1913
|
+
let editorStatus;
|
|
1914
|
+
const get$1 = () => editorStatus;
|
|
1915
|
+
const set = value => {
|
|
1916
|
+
editorStatus = value;
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1919
|
+
const equals = (oldStatus, newStatus) => {
|
|
1920
|
+
if (!oldStatus || !newStatus) {
|
|
1921
|
+
return oldStatus === newStatus;
|
|
1922
|
+
}
|
|
1923
|
+
return oldStatus.column === newStatus.column && oldStatus.encoding === newStatus.encoding && oldStatus.languageId === newStatus.languageId && oldStatus.line === newStatus.line && oldStatus.tabSize === newStatus.tabSize;
|
|
1924
|
+
};
|
|
1925
|
+
const updateItems = (items, status) => {
|
|
1926
|
+
const remainingItems = items.filter(item => !isEditorStatus(item.name));
|
|
1927
|
+
const editorItems = getEditorStatusBarItems(status);
|
|
1928
|
+
if (editorItems.length === 0) {
|
|
1929
|
+
return remainingItems;
|
|
1930
|
+
}
|
|
1931
|
+
const notificationIndex = remainingItems.findIndex(item => item.name === Notifications);
|
|
1932
|
+
const insertIndex = notificationIndex === -1 ? remainingItems.length : notificationIndex;
|
|
1933
|
+
return [...remainingItems.slice(0, insertIndex), ...editorItems, ...remainingItems.slice(insertIndex)];
|
|
1934
|
+
};
|
|
1935
|
+
const handleEditorStatusChanged = (state, editorStatus) => {
|
|
1936
|
+
const {
|
|
1937
|
+
editorStatus: oldEditorStatus,
|
|
1938
|
+
statusBarItemsRight
|
|
1939
|
+
} = state;
|
|
1940
|
+
if (equals(oldEditorStatus, editorStatus)) {
|
|
1941
|
+
return state;
|
|
1942
|
+
}
|
|
1943
|
+
return {
|
|
1944
|
+
...state,
|
|
1945
|
+
editorStatus,
|
|
1946
|
+
statusBarItemsRight: updateItems(statusBarItemsRight, editorStatus)
|
|
1947
|
+
};
|
|
1948
|
+
};
|
|
1949
|
+
|
|
1950
|
+
const handleEditorStatusChangedAll = async editorStatus => {
|
|
1951
|
+
set(editorStatus);
|
|
1952
|
+
for (const uid of getKeys()) {
|
|
1953
|
+
const {
|
|
1954
|
+
newState,
|
|
1955
|
+
oldState
|
|
1956
|
+
} = get$5(uid);
|
|
1957
|
+
const newerState = handleEditorStatusChanged(newState, editorStatus);
|
|
1958
|
+
if (newState === newerState || oldState === newerState) {
|
|
1959
|
+
continue;
|
|
1960
|
+
}
|
|
1961
|
+
set$7(uid, oldState, newerState);
|
|
1962
|
+
await renderOutOfBand(uid);
|
|
1963
|
+
}
|
|
1873
1964
|
};
|
|
1874
1965
|
|
|
1875
1966
|
const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
|
|
@@ -1883,12 +1974,13 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
|
|
|
1883
1974
|
};
|
|
1884
1975
|
const rpc = await create$2({
|
|
1885
1976
|
commandMap: {
|
|
1977
|
+
'StatusBar.handleEditorStatusChanged': handleEditorStatusChangedAll,
|
|
1886
1978
|
'Viewlet.executeViewletCommand': executeViewletCommand
|
|
1887
1979
|
},
|
|
1888
1980
|
messagePort: port
|
|
1889
1981
|
});
|
|
1890
1982
|
if (setAsRendererProcess) {
|
|
1891
|
-
set$
|
|
1983
|
+
set$2(rpc);
|
|
1892
1984
|
}
|
|
1893
1985
|
};
|
|
1894
1986
|
|
|
@@ -1984,6 +2076,7 @@ const loadContent = async state => {
|
|
|
1984
2076
|
platform,
|
|
1985
2077
|
warningCount
|
|
1986
2078
|
} = state;
|
|
2079
|
+
const editorStatus = get$1();
|
|
1987
2080
|
const {
|
|
1988
2081
|
builtinNotificationsEnabled,
|
|
1989
2082
|
builtinProblemsEnabled,
|
|
@@ -1993,6 +2086,7 @@ const loadContent = async state => {
|
|
|
1993
2086
|
assetDir,
|
|
1994
2087
|
builtinNotificationsEnabled: builtinNotificationsEnabled,
|
|
1995
2088
|
builtinProblemsEnabled: builtinProblemsEnabled,
|
|
2089
|
+
editorStatus,
|
|
1996
2090
|
errorCount,
|
|
1997
2091
|
platform,
|
|
1998
2092
|
showItems: itemsVisible,
|
|
@@ -2000,13 +2094,14 @@ const loadContent = async state => {
|
|
|
2000
2094
|
});
|
|
2001
2095
|
const loadedState = {
|
|
2002
2096
|
...state,
|
|
2097
|
+
editorStatus,
|
|
2003
2098
|
errorCount: 0,
|
|
2004
2099
|
initial: false,
|
|
2005
|
-
statusBarItemsLeft: statusBarItems.filter(item => item.name
|
|
2006
|
-
statusBarItemsRight: statusBarItems.filter(item => item.name
|
|
2100
|
+
statusBarItemsLeft: statusBarItems.filter(item => !isRight(item.name)),
|
|
2101
|
+
statusBarItemsRight: statusBarItems.filter(item => isRight(item.name)),
|
|
2007
2102
|
warningCount: 0
|
|
2008
2103
|
};
|
|
2009
|
-
const latestNotificationCount = get$
|
|
2104
|
+
const latestNotificationCount = get$2();
|
|
2010
2105
|
if (latestNotificationCount === undefined) {
|
|
2011
2106
|
return loadedState;
|
|
2012
2107
|
}
|
|
@@ -2072,7 +2167,7 @@ const initializeRenderWorker = async () => {
|
|
|
2072
2167
|
const rpc = await create$1({
|
|
2073
2168
|
commandMap: commandMap
|
|
2074
2169
|
});
|
|
2075
|
-
set$
|
|
2170
|
+
set$3(rpc);
|
|
2076
2171
|
};
|
|
2077
2172
|
|
|
2078
2173
|
const listen = async () => {
|