@lvce-editor/activity-bar-worker 1.25.0 → 1.26.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.
@@ -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: 0,
1018
+ width,
1019
+ height,
1019
1020
  x,
1020
1021
  y,
1021
1022
  sideBarVisible: false,
@@ -1023,7 +1024,8 @@ 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: []
1027
1029
  };
1028
1030
  set(id, state, state);
1029
1031
  return state;
@@ -1233,10 +1235,6 @@ const handleContextMenu = async (state, button, x, y) => {
1233
1235
  return state;
1234
1236
  };
1235
1237
 
1236
- const handleResize = state => {
1237
- return state;
1238
- };
1239
-
1240
1238
  const Tab = 1;
1241
1239
  const Button = 1 << 1;
1242
1240
  const Progress = 1 << 2;
@@ -1245,6 +1243,109 @@ const Selected = 1 << 4;
1245
1243
  const Focused = 1 << 5;
1246
1244
  const MarginTop = 1 << 6;
1247
1245
 
1246
+ const emptyObject = {};
1247
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1248
+ const i18nString = (key, placeholders = emptyObject) => {
1249
+ if (placeholders === emptyObject) {
1250
+ return key;
1251
+ }
1252
+ const replacer = (match, rest) => {
1253
+ return placeholders[rest];
1254
+ };
1255
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1256
+ };
1257
+
1258
+ const Explorer$1 = 'Explorer';
1259
+ const Search$2 = 'Search';
1260
+ const SourceControl$2 = 'Source Control';
1261
+ const RunAndDebug$1 = 'Run and Debug';
1262
+ const Extensions$2 = 'Extensions';
1263
+ const Settings = 'Settings';
1264
+ const AdditionalViews = 'Additional Views';
1265
+ const ActivityBar$2 = 'Activity Bar';
1266
+
1267
+ const explorer = () => {
1268
+ return i18nString(Explorer$1);
1269
+ };
1270
+ const search = () => {
1271
+ return i18nString(Search$2);
1272
+ };
1273
+ const sourceControl = () => {
1274
+ return i18nString(SourceControl$2);
1275
+ };
1276
+ const runAndDebug = () => {
1277
+ return i18nString(RunAndDebug$1);
1278
+ };
1279
+ const extensions = () => {
1280
+ return i18nString(Extensions$2);
1281
+ };
1282
+ const settings = () => {
1283
+ return i18nString(Settings);
1284
+ };
1285
+ const additionalViews = () => {
1286
+ return i18nString(AdditionalViews);
1287
+ };
1288
+ const activityBar = () => {
1289
+ return i18nString(ActivityBar$2);
1290
+ };
1291
+
1292
+ const DebugAlt2 = 'DebugAlt2';
1293
+ const Extensions$1 = 'Extensions';
1294
+ const Files = 'Files';
1295
+ const Search$1 = 'Search';
1296
+ const SettingsGear = 'SettingsGear';
1297
+ const SourceControl$1 = 'SourceControl';
1298
+ const Ellipsis = 'Ellipsis';
1299
+
1300
+ const getNumberOfVisibleItems = state => {
1301
+ const {
1302
+ height,
1303
+ itemHeight
1304
+ } = state;
1305
+ const numberOfVisibleItemsTop = Math.floor(height / itemHeight);
1306
+ return numberOfVisibleItemsTop;
1307
+ };
1308
+
1309
+ const getFilteredActivityBarItems = (items, height, itemHeight) => {
1310
+ const numberOfVisibleItems = getNumberOfVisibleItems({
1311
+ height,
1312
+ itemHeight
1313
+ });
1314
+ if (numberOfVisibleItems >= items.length) {
1315
+ return items;
1316
+ }
1317
+ const showMoreItem = {
1318
+ id: 'Additional Views',
1319
+ title: additionalViews(),
1320
+ icon: Ellipsis,
1321
+ flags: Button,
1322
+ keyShortcuts: ''
1323
+ };
1324
+ return [...items.slice(0, numberOfVisibleItems - 2), showMoreItem, items.at(-1)];
1325
+ };
1326
+
1327
+ const handleResize = (state, dimensions) => {
1328
+ const {
1329
+ activityBarItems,
1330
+ itemHeight
1331
+ } = state;
1332
+ const {
1333
+ x,
1334
+ y,
1335
+ width,
1336
+ height
1337
+ } = dimensions;
1338
+ const filteredItems = getFilteredActivityBarItems(activityBarItems, height, itemHeight);
1339
+ return {
1340
+ ...state,
1341
+ x,
1342
+ y,
1343
+ width,
1344
+ height,
1345
+ filteredItems
1346
+ };
1347
+ };
1348
+
1248
1349
  const setFlag = (item, flag, enabled) => {
1249
1350
  return {
1250
1351
  ...item,
@@ -1335,55 +1436,6 @@ const handleUpdateStateChange = async (state, config) => {
1335
1436
  };
1336
1437
  };
1337
1438
 
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];
1346
- };
1347
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1348
- };
1349
-
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
1439
  const Explorer = 'Explorer';
1388
1440
  const Extensions = 'Extensions';
1389
1441
  const RunAndDebug = 'Run And Debug';
@@ -1792,7 +1844,7 @@ const commandMap = {
1792
1844
  'ActivityBar.handleClick': wrapCommand(handleClick),
1793
1845
  'ActivityBar.handleClickIndex': wrapCommand(handleClickIndex),
1794
1846
  'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
1795
- 'ActivityBar.handleResize': wrapCommand(handleResize),
1847
+ 'ActivityBar.resize': wrapCommand(handleResize),
1796
1848
  'ActivityBar.handleSideBarHidden': wrapCommand(handleSideBarHidden),
1797
1849
  'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
1798
1850
  'ActivityBar.loadContent': wrapCommand(loadContent),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "1.25.0",
3
+ "version": "1.26.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",