@lvce-editor/activity-bar-worker 1.25.0 → 1.27.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/activityBarWorkerMain.js +133 -73
- package/package.json +1 -1
|
@@ -1015,7 +1015,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
1015
1015
|
focused: false,
|
|
1016
1016
|
focusedIndex: -1,
|
|
1017
1017
|
scrollBarHeight: 0,
|
|
1018
|
-
width
|
|
1018
|
+
width,
|
|
1019
|
+
height,
|
|
1019
1020
|
x,
|
|
1020
1021
|
y,
|
|
1021
1022
|
sideBarVisible: false,
|
|
@@ -1023,17 +1024,16 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
1023
1024
|
selectedIndex: -1,
|
|
1024
1025
|
itemHeight: 48,
|
|
1025
1026
|
updateState: '',
|
|
1026
|
-
updateProgress: 0
|
|
1027
|
+
updateProgress: 0,
|
|
1028
|
+
filteredItems: [],
|
|
1029
|
+
numberOfVisibleItems: 0
|
|
1027
1030
|
};
|
|
1028
1031
|
set(id, state, state);
|
|
1029
1032
|
return state;
|
|
1030
1033
|
};
|
|
1031
1034
|
|
|
1032
1035
|
const isEqual$2 = (oldState, newState) => {
|
|
1033
|
-
|
|
1034
|
-
// maybe only when items change, and even then not
|
|
1035
|
-
// always, but only when it affects the css
|
|
1036
|
-
return false;
|
|
1036
|
+
return oldState.itemHeight === newState.itemHeight;
|
|
1037
1037
|
};
|
|
1038
1038
|
|
|
1039
1039
|
const isEqual$1 = (oldState, newState) => {
|
|
@@ -1041,7 +1041,7 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1041
1041
|
};
|
|
1042
1042
|
|
|
1043
1043
|
const isEqual = (oldState, newState) => {
|
|
1044
|
-
return oldState.
|
|
1044
|
+
return oldState.activityBarItems === newState.activityBarItems && oldState.filteredItems === newState.filteredItems && oldState.focusedIndex === newState.focusedIndex && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
|
|
1045
1045
|
};
|
|
1046
1046
|
|
|
1047
1047
|
const RenderItems = 4;
|
|
@@ -1204,9 +1204,9 @@ const handleClickIndex = async (state, button, index, x, y) => {
|
|
|
1204
1204
|
return state;
|
|
1205
1205
|
}
|
|
1206
1206
|
const {
|
|
1207
|
-
|
|
1207
|
+
filteredItems
|
|
1208
1208
|
} = state;
|
|
1209
|
-
const item =
|
|
1209
|
+
const item = filteredItems[index];
|
|
1210
1210
|
const viewletId = item.id;
|
|
1211
1211
|
switch (viewletId) {
|
|
1212
1212
|
case 'Settings':
|
|
@@ -1220,11 +1220,11 @@ const handleClickIndex = async (state, button, index, x, y) => {
|
|
|
1220
1220
|
|
|
1221
1221
|
const handleClick = async (state, button, eventX, eventY) => {
|
|
1222
1222
|
const {
|
|
1223
|
-
|
|
1223
|
+
filteredItems,
|
|
1224
1224
|
itemHeight,
|
|
1225
1225
|
y
|
|
1226
1226
|
} = state;
|
|
1227
|
-
const index = getIndexFromPosition(y, eventX, eventY, itemHeight,
|
|
1227
|
+
const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems.length);
|
|
1228
1228
|
return handleClickIndex(state, button, index, eventX, eventY);
|
|
1229
1229
|
};
|
|
1230
1230
|
|
|
@@ -1233,10 +1233,6 @@ const handleContextMenu = async (state, button, x, y) => {
|
|
|
1233
1233
|
return state;
|
|
1234
1234
|
};
|
|
1235
1235
|
|
|
1236
|
-
const handleResize = state => {
|
|
1237
|
-
return state;
|
|
1238
|
-
};
|
|
1239
|
-
|
|
1240
1236
|
const Tab = 1;
|
|
1241
1237
|
const Button = 1 << 1;
|
|
1242
1238
|
const Progress = 1 << 2;
|
|
@@ -1245,6 +1241,109 @@ const Selected = 1 << 4;
|
|
|
1245
1241
|
const Focused = 1 << 5;
|
|
1246
1242
|
const MarginTop = 1 << 6;
|
|
1247
1243
|
|
|
1244
|
+
const emptyObject = {};
|
|
1245
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1246
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
1247
|
+
if (placeholders === emptyObject) {
|
|
1248
|
+
return key;
|
|
1249
|
+
}
|
|
1250
|
+
const replacer = (match, rest) => {
|
|
1251
|
+
return placeholders[rest];
|
|
1252
|
+
};
|
|
1253
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1254
|
+
};
|
|
1255
|
+
|
|
1256
|
+
const Explorer$1 = 'Explorer';
|
|
1257
|
+
const Search$2 = 'Search';
|
|
1258
|
+
const SourceControl$2 = 'Source Control';
|
|
1259
|
+
const RunAndDebug$1 = 'Run and Debug';
|
|
1260
|
+
const Extensions$2 = 'Extensions';
|
|
1261
|
+
const Settings = 'Settings';
|
|
1262
|
+
const AdditionalViews = 'Additional Views';
|
|
1263
|
+
const ActivityBar$2 = 'Activity Bar';
|
|
1264
|
+
|
|
1265
|
+
const explorer = () => {
|
|
1266
|
+
return i18nString(Explorer$1);
|
|
1267
|
+
};
|
|
1268
|
+
const search = () => {
|
|
1269
|
+
return i18nString(Search$2);
|
|
1270
|
+
};
|
|
1271
|
+
const sourceControl = () => {
|
|
1272
|
+
return i18nString(SourceControl$2);
|
|
1273
|
+
};
|
|
1274
|
+
const runAndDebug = () => {
|
|
1275
|
+
return i18nString(RunAndDebug$1);
|
|
1276
|
+
};
|
|
1277
|
+
const extensions = () => {
|
|
1278
|
+
return i18nString(Extensions$2);
|
|
1279
|
+
};
|
|
1280
|
+
const settings = () => {
|
|
1281
|
+
return i18nString(Settings);
|
|
1282
|
+
};
|
|
1283
|
+
const additionalViews = () => {
|
|
1284
|
+
return i18nString(AdditionalViews);
|
|
1285
|
+
};
|
|
1286
|
+
const activityBar = () => {
|
|
1287
|
+
return i18nString(ActivityBar$2);
|
|
1288
|
+
};
|
|
1289
|
+
|
|
1290
|
+
const DebugAlt2 = 'DebugAlt2';
|
|
1291
|
+
const Extensions$1 = 'Extensions';
|
|
1292
|
+
const Files = 'Files';
|
|
1293
|
+
const Search$1 = 'Search';
|
|
1294
|
+
const SettingsGear = 'SettingsGear';
|
|
1295
|
+
const SourceControl$1 = 'SourceControl';
|
|
1296
|
+
const Ellipsis = 'Ellipsis';
|
|
1297
|
+
|
|
1298
|
+
const getNumberOfVisibleItems = state => {
|
|
1299
|
+
const {
|
|
1300
|
+
height,
|
|
1301
|
+
itemHeight
|
|
1302
|
+
} = state;
|
|
1303
|
+
const numberOfVisibleItemsTop = Math.floor(height / itemHeight);
|
|
1304
|
+
return numberOfVisibleItemsTop;
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1307
|
+
const getFilteredActivityBarItems = (items, height, itemHeight) => {
|
|
1308
|
+
const numberOfVisibleItems = getNumberOfVisibleItems({
|
|
1309
|
+
height,
|
|
1310
|
+
itemHeight
|
|
1311
|
+
});
|
|
1312
|
+
if (numberOfVisibleItems >= items.length) {
|
|
1313
|
+
return items;
|
|
1314
|
+
}
|
|
1315
|
+
const showMoreItem = {
|
|
1316
|
+
id: 'Additional Views',
|
|
1317
|
+
title: additionalViews(),
|
|
1318
|
+
icon: Ellipsis,
|
|
1319
|
+
flags: Button,
|
|
1320
|
+
keyShortcuts: ''
|
|
1321
|
+
};
|
|
1322
|
+
return [...items.slice(0, numberOfVisibleItems - 2), showMoreItem, items.at(-1)];
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1325
|
+
const handleResize = (state, dimensions) => {
|
|
1326
|
+
const {
|
|
1327
|
+
activityBarItems,
|
|
1328
|
+
itemHeight
|
|
1329
|
+
} = state;
|
|
1330
|
+
const {
|
|
1331
|
+
x,
|
|
1332
|
+
y,
|
|
1333
|
+
width,
|
|
1334
|
+
height
|
|
1335
|
+
} = dimensions;
|
|
1336
|
+
const filteredItems = getFilteredActivityBarItems(activityBarItems, height, itemHeight);
|
|
1337
|
+
return {
|
|
1338
|
+
...state,
|
|
1339
|
+
x,
|
|
1340
|
+
y,
|
|
1341
|
+
width,
|
|
1342
|
+
height,
|
|
1343
|
+
filteredItems
|
|
1344
|
+
};
|
|
1345
|
+
};
|
|
1346
|
+
|
|
1248
1347
|
const setFlag = (item, flag, enabled) => {
|
|
1249
1348
|
return {
|
|
1250
1349
|
...item,
|
|
@@ -1284,15 +1383,19 @@ const markSelected = (items, selectedIndex) => {
|
|
|
1284
1383
|
|
|
1285
1384
|
const handleSideBarViewletChange = (state, id, ...args) => {
|
|
1286
1385
|
const {
|
|
1287
|
-
activityBarItems
|
|
1386
|
+
activityBarItems,
|
|
1387
|
+
height,
|
|
1388
|
+
itemHeight
|
|
1288
1389
|
} = state;
|
|
1289
1390
|
const index = findIndex(activityBarItems, id);
|
|
1290
1391
|
const newActivityBarItems = markSelected(activityBarItems, index);
|
|
1392
|
+
const filteredItems = getFilteredActivityBarItems(newActivityBarItems, height, itemHeight);
|
|
1291
1393
|
return {
|
|
1292
1394
|
...state,
|
|
1293
1395
|
selectedIndex: index,
|
|
1294
1396
|
currentViewletId: id,
|
|
1295
1397
|
activityBarItems: newActivityBarItems,
|
|
1398
|
+
filteredItems,
|
|
1296
1399
|
sideBarVisible: true
|
|
1297
1400
|
};
|
|
1298
1401
|
};
|
|
@@ -1324,66 +1427,17 @@ const getNewItems = (items, state) => {
|
|
|
1324
1427
|
};
|
|
1325
1428
|
const handleUpdateStateChange = async (state, config) => {
|
|
1326
1429
|
const {
|
|
1327
|
-
|
|
1430
|
+
filteredItems
|
|
1328
1431
|
} = state;
|
|
1329
|
-
const newItems = getNewItems(
|
|
1432
|
+
const newItems = getNewItems(filteredItems, config.state);
|
|
1330
1433
|
return {
|
|
1331
1434
|
...state,
|
|
1332
1435
|
updateState: config.state,
|
|
1333
1436
|
updateProgress: config.progress,
|
|
1334
|
-
|
|
1335
|
-
};
|
|
1336
|
-
};
|
|
1337
|
-
|
|
1338
|
-
const emptyObject = {};
|
|
1339
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1340
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
1341
|
-
if (placeholders === emptyObject) {
|
|
1342
|
-
return key;
|
|
1343
|
-
}
|
|
1344
|
-
const replacer = (match, rest) => {
|
|
1345
|
-
return placeholders[rest];
|
|
1437
|
+
filteredItems: newItems
|
|
1346
1438
|
};
|
|
1347
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1348
1439
|
};
|
|
1349
1440
|
|
|
1350
|
-
const Explorer$1 = 'Explorer';
|
|
1351
|
-
const Search$2 = 'Search';
|
|
1352
|
-
const SourceControl$2 = 'Source Control';
|
|
1353
|
-
const RunAndDebug$1 = 'Run and Debug';
|
|
1354
|
-
const Extensions$2 = 'Extensions';
|
|
1355
|
-
const Settings = 'Settings';
|
|
1356
|
-
const ActivityBar$2 = 'Activity Bar';
|
|
1357
|
-
|
|
1358
|
-
const explorer = () => {
|
|
1359
|
-
return i18nString(Explorer$1);
|
|
1360
|
-
};
|
|
1361
|
-
const search = () => {
|
|
1362
|
-
return i18nString(Search$2);
|
|
1363
|
-
};
|
|
1364
|
-
const sourceControl = () => {
|
|
1365
|
-
return i18nString(SourceControl$2);
|
|
1366
|
-
};
|
|
1367
|
-
const runAndDebug = () => {
|
|
1368
|
-
return i18nString(RunAndDebug$1);
|
|
1369
|
-
};
|
|
1370
|
-
const extensions = () => {
|
|
1371
|
-
return i18nString(Extensions$2);
|
|
1372
|
-
};
|
|
1373
|
-
const settings = () => {
|
|
1374
|
-
return i18nString(Settings);
|
|
1375
|
-
};
|
|
1376
|
-
const activityBar = () => {
|
|
1377
|
-
return i18nString(ActivityBar$2);
|
|
1378
|
-
};
|
|
1379
|
-
|
|
1380
|
-
const DebugAlt2 = 'DebugAlt2';
|
|
1381
|
-
const Extensions$1 = 'Extensions';
|
|
1382
|
-
const Files = 'Files';
|
|
1383
|
-
const Search$1 = 'Search';
|
|
1384
|
-
const SettingsGear = 'SettingsGear';
|
|
1385
|
-
const SourceControl$1 = 'SourceControl';
|
|
1386
|
-
|
|
1387
1441
|
const Explorer = 'Explorer';
|
|
1388
1442
|
const Extensions = 'Extensions';
|
|
1389
1443
|
const RunAndDebug = 'Run And Debug';
|
|
@@ -1435,15 +1489,21 @@ const getActivityBarItems = () => {
|
|
|
1435
1489
|
};
|
|
1436
1490
|
|
|
1437
1491
|
const loadContent = async (state, savedState) => {
|
|
1492
|
+
const {
|
|
1493
|
+
itemHeight,
|
|
1494
|
+
height
|
|
1495
|
+
} = state;
|
|
1438
1496
|
const items = getActivityBarItems();
|
|
1439
1497
|
const explorerIndex = 0;
|
|
1440
1498
|
const itemsWithSelected = markSelected(items, explorerIndex);
|
|
1499
|
+
const filteredItems = getFilteredActivityBarItems(itemsWithSelected, height, itemHeight);
|
|
1441
1500
|
return {
|
|
1442
1501
|
...state,
|
|
1443
1502
|
activityBarItems: itemsWithSelected,
|
|
1444
|
-
sideBarVisible: true,
|
|
1445
1503
|
currentViewletId: Explorer,
|
|
1446
|
-
|
|
1504
|
+
filteredItems,
|
|
1505
|
+
selectedIndex: explorerIndex,
|
|
1506
|
+
sideBarVisible: true
|
|
1447
1507
|
};
|
|
1448
1508
|
};
|
|
1449
1509
|
|
|
@@ -1690,9 +1750,9 @@ const getActivityBarVirtualDom = visibleItems => {
|
|
|
1690
1750
|
const renderItems = (oldState, newState) => {
|
|
1691
1751
|
const {
|
|
1692
1752
|
uid,
|
|
1693
|
-
|
|
1753
|
+
filteredItems
|
|
1694
1754
|
} = newState;
|
|
1695
|
-
const dom = getActivityBarVirtualDom(
|
|
1755
|
+
const dom = getActivityBarVirtualDom(filteredItems);
|
|
1696
1756
|
return [SetDom2, uid, dom];
|
|
1697
1757
|
};
|
|
1698
1758
|
|
|
@@ -1792,7 +1852,7 @@ const commandMap = {
|
|
|
1792
1852
|
'ActivityBar.handleClick': wrapCommand(handleClick),
|
|
1793
1853
|
'ActivityBar.handleClickIndex': wrapCommand(handleClickIndex),
|
|
1794
1854
|
'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
|
|
1795
|
-
'ActivityBar.
|
|
1855
|
+
'ActivityBar.resize': wrapCommand(handleResize),
|
|
1796
1856
|
'ActivityBar.handleSideBarHidden': wrapCommand(handleSideBarHidden),
|
|
1797
1857
|
'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
|
|
1798
1858
|
'ActivityBar.loadContent': wrapCommand(loadContent),
|