@lvce-editor/activity-bar-worker 1.27.0 → 1.29.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.
@@ -838,7 +838,7 @@ const WebWorkerRpcClient = {
838
838
  };
839
839
 
840
840
  const Button$2 = 'button';
841
- const None = 'none';
841
+ const None$1 = 'none';
842
842
  const Tab$1 = 'tab';
843
843
  const ToolBar = 'toolbar';
844
844
 
@@ -862,6 +862,11 @@ const ActivityBar$3 = 1;
862
862
  const Settings$1 = 12;
863
863
  const ActivityBarAdditionalViews = 17;
864
864
 
865
+ const Separator = 1;
866
+ const None = 0;
867
+ const Checked = 2;
868
+ const Unchecked = 3;
869
+
865
870
  const LeftClick = 0;
866
871
 
867
872
  const RendererWorker = 1;
@@ -908,9 +913,6 @@ const create$2 = rpcId => {
908
913
  const {
909
914
  invoke,
910
915
  set: set$1} = create$2(RendererWorker);
911
- const showContextMenu = async (x, y, id, ...args) => {
912
- return invoke('ContextMenu.show', x, y, id, ...args);
913
- };
914
916
 
915
917
  const toCommandId = key => {
916
918
  const dotIndex = key.indexOf('.');
@@ -1026,7 +1028,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
1026
1028
  updateState: '',
1027
1029
  updateProgress: 0,
1028
1030
  filteredItems: [],
1029
- numberOfVisibleItems: 0
1031
+ numberOfVisibleItems: 0,
1032
+ sideBarLocation: 0
1030
1033
  };
1031
1034
  set(id, state, state);
1032
1035
  return state;
@@ -1137,6 +1140,237 @@ const getKeyBindings = () => {
1137
1140
  }];
1138
1141
  };
1139
1142
 
1143
+ const Tab = 1;
1144
+ const Button = 1 << 1;
1145
+ const Progress = 1 << 2;
1146
+ const Enabled = 1 << 3;
1147
+ const Selected = 1 << 4;
1148
+ const Focused = 1 << 5;
1149
+ const MarginTop = 1 << 6;
1150
+
1151
+ const emptyObject = {};
1152
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1153
+ const i18nString = (key, placeholders = emptyObject) => {
1154
+ if (placeholders === emptyObject) {
1155
+ return key;
1156
+ }
1157
+ const replacer = (match, rest) => {
1158
+ return placeholders[rest];
1159
+ };
1160
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1161
+ };
1162
+
1163
+ const Explorer$1 = 'Explorer';
1164
+ const Search$2 = 'Search';
1165
+ const SourceControl$2 = 'Source Control';
1166
+ const RunAndDebug$1 = 'Run and Debug';
1167
+ const Extensions$2 = 'Extensions';
1168
+ const Settings = 'Settings';
1169
+ const AdditionalViews = 'Additional Views';
1170
+ const ActivityBar$2 = 'Activity Bar';
1171
+ const MoveSideBarLeft = 'Move Side Bar Left';
1172
+ const MoveSideBarRight = 'Move Side Bar Right';
1173
+ const HideActivityBar = 'Hide Activity Bar';
1174
+
1175
+ const explorer = () => {
1176
+ return i18nString(Explorer$1);
1177
+ };
1178
+ const search = () => {
1179
+ return i18nString(Search$2);
1180
+ };
1181
+ const sourceControl = () => {
1182
+ return i18nString(SourceControl$2);
1183
+ };
1184
+ const runAndDebug = () => {
1185
+ return i18nString(RunAndDebug$1);
1186
+ };
1187
+ const extensions = () => {
1188
+ return i18nString(Extensions$2);
1189
+ };
1190
+ const settings$1 = () => {
1191
+ return i18nString(Settings);
1192
+ };
1193
+ const additionalViews = () => {
1194
+ return i18nString(AdditionalViews);
1195
+ };
1196
+ const activityBar = () => {
1197
+ return i18nString(ActivityBar$2);
1198
+ };
1199
+ const moveSideBarRight = () => {
1200
+ return i18nString(MoveSideBarRight);
1201
+ };
1202
+ const moveSideBarLeft = () => {
1203
+ return i18nString(MoveSideBarLeft);
1204
+ };
1205
+ const hideActivityBar = () => {
1206
+ return i18nString(HideActivityBar);
1207
+ };
1208
+
1209
+ const Left = 1;
1210
+ const Right = 2;
1211
+
1212
+ const menuEntryMoveSideBar = sideBarLocation => {
1213
+ switch (sideBarLocation) {
1214
+ case Left:
1215
+ return {
1216
+ id: 'moveSideBarRight',
1217
+ label: moveSideBarRight(),
1218
+ flags: None,
1219
+ command: 'Layout.moveSideBarRight'
1220
+ };
1221
+ case Right:
1222
+ return {
1223
+ id: 'moveSideBarLeft',
1224
+ label: moveSideBarLeft(),
1225
+ flags: None,
1226
+ command: 'Layout.moveSideBarLeft'
1227
+ };
1228
+ default:
1229
+ throw new Error('unexpected side bar location');
1230
+ }
1231
+ };
1232
+
1233
+ const menuEntrySeparator = {
1234
+ id: 'separator',
1235
+ label: '',
1236
+ flags: Separator,
1237
+ command: ''
1238
+ };
1239
+
1240
+ const toContextMenuItem$1 = activityBarItem => {
1241
+ const isEnabled = activityBarItem.flags & Enabled;
1242
+ return {
1243
+ label: activityBarItem.id,
1244
+ id: '',
1245
+ // TODO
1246
+ flags: isEnabled ? Checked : Unchecked,
1247
+ command: ''
1248
+ };
1249
+ };
1250
+ const getMenuEntriesActivityBar = state => {
1251
+ const {
1252
+ activityBarItems,
1253
+ sideBarLocation
1254
+ } = state;
1255
+ return [...activityBarItems.map(toContextMenuItem$1), menuEntrySeparator, menuEntryMoveSideBar(sideBarLocation), {
1256
+ id: 'hideActivityBar',
1257
+ label: hideActivityBar(),
1258
+ flags: None,
1259
+ command: 'Layout.hideActivityBar'
1260
+ }];
1261
+ };
1262
+
1263
+ const getNumberOfVisibleItems = state => {
1264
+ const {
1265
+ height,
1266
+ itemHeight
1267
+ } = state;
1268
+ const numberOfVisibleItemsTop = Math.floor(height / itemHeight);
1269
+ return numberOfVisibleItemsTop;
1270
+ };
1271
+ const getHiddenItems = state => {
1272
+ const numberOfVisibleItems = getNumberOfVisibleItems(state);
1273
+ const items = state.activityBarItems;
1274
+ if (numberOfVisibleItems >= items.length) {
1275
+ return [];
1276
+ }
1277
+ return state.activityBarItems.slice(numberOfVisibleItems - 2, -1);
1278
+ };
1279
+
1280
+ const toContextMenuItem = activityBarItem => {
1281
+ return {
1282
+ label: activityBarItem.id,
1283
+ id: '8000',
1284
+ // TODO
1285
+ flags: None,
1286
+ command: '-1' // TODO
1287
+ };
1288
+ };
1289
+ const getMenuEntriesAdditionalViews = state => {
1290
+ const hiddenActivityBarItems = getHiddenItems(state);
1291
+ return hiddenActivityBarItems.map(toContextMenuItem);
1292
+ };
1293
+
1294
+ /**
1295
+ * @enum {string}
1296
+ */
1297
+ const UiStrings = {
1298
+ CheckForUpdates: 'Check For Updates',
1299
+ ColorTheme: 'Color Theme',
1300
+ CommandPalette: 'Command Palette',
1301
+ KeyboardShortcuts: 'Keyboard Shortcuts',
1302
+ Settings: 'Settings'};
1303
+ const checkForUpdates = () => {
1304
+ return i18nString(UiStrings.CheckForUpdates);
1305
+ };
1306
+ const commandPalette = () => {
1307
+ return i18nString(UiStrings.CommandPalette);
1308
+ };
1309
+ const settings = () => {
1310
+ return i18nString(UiStrings.Settings);
1311
+ };
1312
+ const keyboardShortcuts = () => {
1313
+ return i18nString(UiStrings.KeyboardShortcuts);
1314
+ };
1315
+ const colorTheme = () => {
1316
+ return i18nString(UiStrings.ColorTheme);
1317
+ };
1318
+
1319
+ const keyBindingsUri = 'app://keybindings';
1320
+ const getMenuEntriesSettings = () => {
1321
+ return [{
1322
+ id: 'commandPalette',
1323
+ label: commandPalette(),
1324
+ flags: None,
1325
+ command: 'QuickPick.showEverything'
1326
+ }, menuEntrySeparator, {
1327
+ id: 'settings',
1328
+ label: settings(),
1329
+ flags: None,
1330
+ command: 'Preferences.openSettingsJson'
1331
+ }, {
1332
+ id: 'keyboardShortcuts',
1333
+ label: keyboardShortcuts(),
1334
+ flags: None,
1335
+ command: 'Main.openUri',
1336
+ args: [keyBindingsUri]
1337
+ }, {
1338
+ id: 'colorTheme',
1339
+ label: colorTheme(),
1340
+ flags: None,
1341
+ command: 'QuickPick.showColorTheme'
1342
+ }, menuEntrySeparator, {
1343
+ id: 'checkForUpdates',
1344
+ label: checkForUpdates(),
1345
+ flags: None,
1346
+ command: /* TODO */'-1'
1347
+ }];
1348
+ };
1349
+
1350
+ const getMenuEntries = id => {
1351
+ const tuple = get(id);
1352
+ if (!tuple) {
1353
+ return [];
1354
+ }
1355
+ const {
1356
+ newState
1357
+ } = tuple;
1358
+ switch (id) {
1359
+ case ActivityBar$3:
1360
+ return getMenuEntriesActivityBar(newState);
1361
+ case ActivityBarAdditionalViews:
1362
+ return getMenuEntriesAdditionalViews(newState);
1363
+ case Settings$1:
1364
+ return getMenuEntriesSettings();
1365
+ default:
1366
+ return [];
1367
+ }
1368
+ };
1369
+
1370
+ const getMenuEntryIds = () => {
1371
+ return [ActivityBar$3, ActivityBarAdditionalViews, Settings$1];
1372
+ };
1373
+
1140
1374
  const handleBlur = state => {
1141
1375
  return {
1142
1376
  ...state,
@@ -1144,21 +1378,48 @@ const handleBlur = state => {
1144
1378
  };
1145
1379
  };
1146
1380
 
1147
- const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount) => {
1381
+ const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount, height) => {
1382
+ if (itemCount === 0) {
1383
+ return -1;
1384
+ }
1385
+ // If there's only one item, treat it as a top item (not Settings at bottom)
1386
+ if (itemCount === 1) {
1387
+ const relativeY = eventY - y;
1388
+ const index = Math.floor(relativeY / itemHeight);
1389
+ if (index < 0 || index >= itemCount) {
1390
+ return -1;
1391
+ }
1392
+ return index;
1393
+ }
1394
+ // Settings is always at the bottom (last item) when there are multiple items
1395
+ const settingsBottomY = y + height;
1396
+ const settingsTopY = settingsBottomY - itemHeight;
1397
+ // Check if click is in the Settings area (bottom)
1398
+ if (eventY >= settingsTopY && eventY < settingsBottomY) {
1399
+ return itemCount - 1;
1400
+ }
1401
+ // Otherwise, calculate index from top items
1148
1402
  const relativeY = eventY - y;
1149
1403
  const index = Math.floor(relativeY / itemHeight);
1150
- if (index < 0 || index >= itemCount) {
1404
+ if (index < 0 || index >= itemCount - 1) {
1151
1405
  return -1;
1152
1406
  }
1153
1407
  return index;
1154
1408
  };
1155
1409
 
1156
- const show$1 = async (x, y, id, ...args) => {
1157
- await showContextMenu(x, y, id, args);
1410
+ const show2 = async (uid, menuId, x, y, args) => {
1411
+ // @ts-ignore
1412
+ await invoke('ContextMenu.show2', uid, menuId, x, y, args);
1158
1413
  };
1159
1414
 
1160
- const handleClickAdditionalViews = async (state, x, y, viewletId) => {
1161
- await show$1(x, y, ActivityBarAdditionalViews);
1415
+ const handleClickAdditionalViews = async (state, eventX, eventY, viewletId) => {
1416
+ const {
1417
+ uid
1418
+ } = state;
1419
+ await show2(uid, ActivityBarAdditionalViews, eventX, eventY, {
1420
+ menuId: ActivityBarAdditionalViews,
1421
+ viewletId
1422
+ });
1162
1423
  return state;
1163
1424
  };
1164
1425
 
@@ -1191,8 +1452,13 @@ const handleClickOther = async (state, x, y, viewletId) => {
1191
1452
  return state;
1192
1453
  };
1193
1454
 
1194
- const handleClickSettings = async (state, x, y, viewletId) => {
1195
- await show$1(x, y, Settings$1);
1455
+ const handleClickSettings = async (state, eventX, eventY, viewletId) => {
1456
+ const {
1457
+ uid
1458
+ } = state;
1459
+ await show2(uid, Settings$1, eventX, eventY, {
1460
+ menuId: Settings$1
1461
+ });
1196
1462
  return state;
1197
1463
  };
1198
1464
 
@@ -1212,7 +1478,7 @@ const handleClickIndex = async (state, button, index, x, y) => {
1212
1478
  case 'Settings':
1213
1479
  return handleClickSettings(state, x, y);
1214
1480
  case 'Additional Views':
1215
- return handleClickAdditionalViews(state, x, y);
1481
+ return handleClickAdditionalViews(state, x, y, viewletId);
1216
1482
  default:
1217
1483
  return handleClickOther(state, x, y, viewletId);
1218
1484
  }
@@ -1222,71 +1488,23 @@ const handleClick = async (state, button, eventX, eventY) => {
1222
1488
  const {
1223
1489
  filteredItems,
1224
1490
  itemHeight,
1225
- y
1491
+ y,
1492
+ height
1226
1493
  } = state;
1227
- const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems.length);
1494
+ const index = getIndexFromPosition(y, eventX, eventY, itemHeight, filteredItems.length, height);
1228
1495
  return handleClickIndex(state, button, index, eventX, eventY);
1229
1496
  };
1230
1497
 
1231
- const handleContextMenu = async (state, button, x, y) => {
1232
- await show$1(x, y, ActivityBar$3);
1498
+ const handleContextMenu = async (state, button, eventX, eventY) => {
1499
+ const {
1500
+ uid
1501
+ } = state;
1502
+ await show2(uid, ActivityBar$3, eventX, eventY, {
1503
+ menuId: ActivityBar$3
1504
+ });
1233
1505
  return state;
1234
1506
  };
1235
1507
 
1236
- const Tab = 1;
1237
- const Button = 1 << 1;
1238
- const Progress = 1 << 2;
1239
- const Enabled = 1 << 3;
1240
- const Selected = 1 << 4;
1241
- const Focused = 1 << 5;
1242
- const MarginTop = 1 << 6;
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
1508
  const DebugAlt2 = 'DebugAlt2';
1291
1509
  const Extensions$1 = 'Extensions';
1292
1510
  const Files = 'Files';
@@ -1295,15 +1513,6 @@ const SettingsGear = 'SettingsGear';
1295
1513
  const SourceControl$1 = 'SourceControl';
1296
1514
  const Ellipsis = 'Ellipsis';
1297
1515
 
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
1516
  const getFilteredActivityBarItems = (items, height, itemHeight) => {
1308
1517
  const numberOfVisibleItems = getNumberOfVisibleItems({
1309
1518
  height,
@@ -1481,7 +1690,7 @@ const getActivityBarItems = () => {
1481
1690
  // Bottom
1482
1691
  {
1483
1692
  id: 'Settings',
1484
- title: settings(),
1693
+ title: settings$1(),
1485
1694
  icon: SettingsGear,
1486
1695
  flags: Button | Enabled | MarginTop,
1487
1696
  keyShortcuts: ''
@@ -1503,6 +1712,7 @@ const loadContent = async (state, savedState) => {
1503
1712
  currentViewletId: Explorer,
1504
1713
  filteredItems,
1505
1714
  selectedIndex: explorerIndex,
1715
+ sideBarLocation: Left,
1506
1716
  sideBarVisible: true
1507
1717
  };
1508
1718
  };
@@ -1626,7 +1836,7 @@ const getActivityBarItemInProgressDom = item => {
1626
1836
  }, {
1627
1837
  type: Div,
1628
1838
  className: mergeClassNames(Icon, `MaskIcon${icon}`),
1629
- role: None,
1839
+ role: None$1,
1630
1840
  childCount: 0
1631
1841
  }, ...getBadgeVirtualDom()];
1632
1842
  };
@@ -1661,7 +1871,7 @@ const getActivityBarItemWithBadgeDom = item => {
1661
1871
  }, {
1662
1872
  type: Div,
1663
1873
  className: mergeClassNames(Icon, `MaskIcon${icon}`),
1664
- role: None,
1874
+ role: None$1,
1665
1875
  childCount: 0
1666
1876
  }, {
1667
1877
  type: Div,
@@ -1674,7 +1884,7 @@ const getIconVirtualDom = (icon, type = Div) => {
1674
1884
  return {
1675
1885
  type,
1676
1886
  className: `MaskIcon MaskIcon${icon}`,
1677
- role: None,
1887
+ role: None$1,
1678
1888
  childCount: 0
1679
1889
  };
1680
1890
  };
@@ -1843,21 +2053,23 @@ const commandMap = {
1843
2053
  'ActivityBar.focusFirst': wrapCommand(focusFirst),
1844
2054
  'ActivityBar.focusIndex': wrapCommand(focusIndex),
1845
2055
  'ActivityBar.focusLast': wrapCommand(focusLast),
1846
- 'ActivityBar.handleUpdateStateChange': wrapCommand(handleUpdateStateChange),
1847
2056
  'ActivityBar.focusNext': wrapCommand(focusNext),
1848
2057
  'ActivityBar.focusNone': wrapCommand(focusNone),
1849
2058
  'ActivityBar.getCommandIds': getCommandIds,
1850
2059
  'ActivityBar.getKeyBindings': getKeyBindings,
2060
+ 'ActivityBar.getMenuEntries': getMenuEntries,
2061
+ 'ActivityBar.getMenuEntryIds': getMenuEntryIds,
1851
2062
  'ActivityBar.handleBlur': wrapCommand(handleBlur),
1852
2063
  'ActivityBar.handleClick': wrapCommand(handleClick),
1853
2064
  'ActivityBar.handleClickIndex': wrapCommand(handleClickIndex),
1854
2065
  'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
1855
- 'ActivityBar.resize': wrapCommand(handleResize),
1856
2066
  'ActivityBar.handleSideBarHidden': wrapCommand(handleSideBarHidden),
1857
2067
  'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
2068
+ 'ActivityBar.handleUpdateStateChange': wrapCommand(handleUpdateStateChange),
1858
2069
  'ActivityBar.loadContent': wrapCommand(loadContent),
1859
2070
  'ActivityBar.render2': render2,
1860
2071
  'ActivityBar.renderEventListeners': renderEventListeners,
2072
+ 'ActivityBar.resize': wrapCommand(handleResize),
1861
2073
  'ActivityBar.saveState': wrapGetter(saveState),
1862
2074
  'ActivityBar.terminate': terminate,
1863
2075
  'ActivityBar.toggleActivityBarItem': wrapCommand(toggleActivityBarItem)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "1.27.0",
3
+ "version": "1.29.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",