@lvce-editor/activity-bar-worker 1.28.0 → 1.30.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,240 @@ 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, options) => {
1351
+ const tuple = get(id);
1352
+ if (!tuple) {
1353
+ return [];
1354
+ }
1355
+ const {
1356
+ newState
1357
+ } = tuple;
1358
+ const {
1359
+ menuId
1360
+ } = options;
1361
+ switch (menuId) {
1362
+ case ActivityBar$3:
1363
+ return getMenuEntriesActivityBar(newState);
1364
+ case ActivityBarAdditionalViews:
1365
+ return getMenuEntriesAdditionalViews(newState);
1366
+ case Settings$1:
1367
+ return getMenuEntriesSettings();
1368
+ default:
1369
+ return [];
1370
+ }
1371
+ };
1372
+
1373
+ const getMenuEntryIds = () => {
1374
+ return [ActivityBar$3, ActivityBarAdditionalViews, Settings$1];
1375
+ };
1376
+
1140
1377
  const handleBlur = state => {
1141
1378
  return {
1142
1379
  ...state,
@@ -1173,12 +1410,19 @@ const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount, height)
1173
1410
  return index;
1174
1411
  };
1175
1412
 
1176
- const show$1 = async (x, y, id, ...args) => {
1177
- await showContextMenu(x, y, id, args);
1413
+ const show2 = async (uid, menuId, x, y, args) => {
1414
+ // @ts-ignore
1415
+ await invoke('ContextMenu.show2', uid, menuId, x, y, args);
1178
1416
  };
1179
1417
 
1180
- const handleClickAdditionalViews = async (state, x, y, viewletId) => {
1181
- await show$1(x, y, ActivityBarAdditionalViews);
1418
+ const handleClickAdditionalViews = async (state, eventX, eventY, viewletId) => {
1419
+ const {
1420
+ uid
1421
+ } = state;
1422
+ await show2(uid, ActivityBarAdditionalViews, eventX, eventY, {
1423
+ menuId: ActivityBarAdditionalViews,
1424
+ viewletId
1425
+ });
1182
1426
  return state;
1183
1427
  };
1184
1428
 
@@ -1211,8 +1455,13 @@ const handleClickOther = async (state, x, y, viewletId) => {
1211
1455
  return state;
1212
1456
  };
1213
1457
 
1214
- const handleClickSettings = async (state, x, y, viewletId) => {
1215
- await show$1(x, y, Settings$1);
1458
+ const handleClickSettings = async (state, eventX, eventY, viewletId) => {
1459
+ const {
1460
+ uid
1461
+ } = state;
1462
+ await show2(uid, Settings$1, eventX, eventY, {
1463
+ menuId: Settings$1
1464
+ });
1216
1465
  return state;
1217
1466
  };
1218
1467
 
@@ -1232,7 +1481,7 @@ const handleClickIndex = async (state, button, index, x, y) => {
1232
1481
  case 'Settings':
1233
1482
  return handleClickSettings(state, x, y);
1234
1483
  case 'Additional Views':
1235
- return handleClickAdditionalViews(state, x, y);
1484
+ return handleClickAdditionalViews(state, x, y, viewletId);
1236
1485
  default:
1237
1486
  return handleClickOther(state, x, y, viewletId);
1238
1487
  }
@@ -1249,65 +1498,16 @@ const handleClick = async (state, button, eventX, eventY) => {
1249
1498
  return handleClickIndex(state, button, index, eventX, eventY);
1250
1499
  };
1251
1500
 
1252
- const handleContextMenu = async (state, button, x, y) => {
1253
- await show$1(x, y, ActivityBar$3);
1501
+ const handleContextMenu = async (state, button, eventX, eventY) => {
1502
+ const {
1503
+ uid
1504
+ } = state;
1505
+ await show2(uid, ActivityBar$3, eventX, eventY, {
1506
+ menuId: ActivityBar$3
1507
+ });
1254
1508
  return state;
1255
1509
  };
1256
1510
 
1257
- const Tab = 1;
1258
- const Button = 1 << 1;
1259
- const Progress = 1 << 2;
1260
- const Enabled = 1 << 3;
1261
- const Selected = 1 << 4;
1262
- const Focused = 1 << 5;
1263
- const MarginTop = 1 << 6;
1264
-
1265
- const emptyObject = {};
1266
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1267
- const i18nString = (key, placeholders = emptyObject) => {
1268
- if (placeholders === emptyObject) {
1269
- return key;
1270
- }
1271
- const replacer = (match, rest) => {
1272
- return placeholders[rest];
1273
- };
1274
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1275
- };
1276
-
1277
- const Explorer$1 = 'Explorer';
1278
- const Search$2 = 'Search';
1279
- const SourceControl$2 = 'Source Control';
1280
- const RunAndDebug$1 = 'Run and Debug';
1281
- const Extensions$2 = 'Extensions';
1282
- const Settings = 'Settings';
1283
- const AdditionalViews = 'Additional Views';
1284
- const ActivityBar$2 = 'Activity Bar';
1285
-
1286
- const explorer = () => {
1287
- return i18nString(Explorer$1);
1288
- };
1289
- const search = () => {
1290
- return i18nString(Search$2);
1291
- };
1292
- const sourceControl = () => {
1293
- return i18nString(SourceControl$2);
1294
- };
1295
- const runAndDebug = () => {
1296
- return i18nString(RunAndDebug$1);
1297
- };
1298
- const extensions = () => {
1299
- return i18nString(Extensions$2);
1300
- };
1301
- const settings = () => {
1302
- return i18nString(Settings);
1303
- };
1304
- const additionalViews = () => {
1305
- return i18nString(AdditionalViews);
1306
- };
1307
- const activityBar = () => {
1308
- return i18nString(ActivityBar$2);
1309
- };
1310
-
1311
1511
  const DebugAlt2 = 'DebugAlt2';
1312
1512
  const Extensions$1 = 'Extensions';
1313
1513
  const Files = 'Files';
@@ -1316,15 +1516,6 @@ const SettingsGear = 'SettingsGear';
1316
1516
  const SourceControl$1 = 'SourceControl';
1317
1517
  const Ellipsis = 'Ellipsis';
1318
1518
 
1319
- const getNumberOfVisibleItems = state => {
1320
- const {
1321
- height,
1322
- itemHeight
1323
- } = state;
1324
- const numberOfVisibleItemsTop = Math.floor(height / itemHeight);
1325
- return numberOfVisibleItemsTop;
1326
- };
1327
-
1328
1519
  const getFilteredActivityBarItems = (items, height, itemHeight) => {
1329
1520
  const numberOfVisibleItems = getNumberOfVisibleItems({
1330
1521
  height,
@@ -1502,7 +1693,7 @@ const getActivityBarItems = () => {
1502
1693
  // Bottom
1503
1694
  {
1504
1695
  id: 'Settings',
1505
- title: settings(),
1696
+ title: settings$1(),
1506
1697
  icon: SettingsGear,
1507
1698
  flags: Button | Enabled | MarginTop,
1508
1699
  keyShortcuts: ''
@@ -1524,6 +1715,7 @@ const loadContent = async (state, savedState) => {
1524
1715
  currentViewletId: Explorer,
1525
1716
  filteredItems,
1526
1717
  selectedIndex: explorerIndex,
1718
+ sideBarLocation: Left,
1527
1719
  sideBarVisible: true
1528
1720
  };
1529
1721
  };
@@ -1647,7 +1839,7 @@ const getActivityBarItemInProgressDom = item => {
1647
1839
  }, {
1648
1840
  type: Div,
1649
1841
  className: mergeClassNames(Icon, `MaskIcon${icon}`),
1650
- role: None,
1842
+ role: None$1,
1651
1843
  childCount: 0
1652
1844
  }, ...getBadgeVirtualDom()];
1653
1845
  };
@@ -1682,7 +1874,7 @@ const getActivityBarItemWithBadgeDom = item => {
1682
1874
  }, {
1683
1875
  type: Div,
1684
1876
  className: mergeClassNames(Icon, `MaskIcon${icon}`),
1685
- role: None,
1877
+ role: None$1,
1686
1878
  childCount: 0
1687
1879
  }, {
1688
1880
  type: Div,
@@ -1695,7 +1887,7 @@ const getIconVirtualDom = (icon, type = Div) => {
1695
1887
  return {
1696
1888
  type,
1697
1889
  className: `MaskIcon MaskIcon${icon}`,
1698
- role: None,
1890
+ role: None$1,
1699
1891
  childCount: 0
1700
1892
  };
1701
1893
  };
@@ -1864,21 +2056,23 @@ const commandMap = {
1864
2056
  'ActivityBar.focusFirst': wrapCommand(focusFirst),
1865
2057
  'ActivityBar.focusIndex': wrapCommand(focusIndex),
1866
2058
  'ActivityBar.focusLast': wrapCommand(focusLast),
1867
- 'ActivityBar.handleUpdateStateChange': wrapCommand(handleUpdateStateChange),
1868
2059
  'ActivityBar.focusNext': wrapCommand(focusNext),
1869
2060
  'ActivityBar.focusNone': wrapCommand(focusNone),
1870
2061
  'ActivityBar.getCommandIds': getCommandIds,
1871
2062
  'ActivityBar.getKeyBindings': getKeyBindings,
2063
+ 'ActivityBar.getMenuEntries': getMenuEntries,
2064
+ 'ActivityBar.getMenuEntryIds': getMenuEntryIds,
1872
2065
  'ActivityBar.handleBlur': wrapCommand(handleBlur),
1873
2066
  'ActivityBar.handleClick': wrapCommand(handleClick),
1874
2067
  'ActivityBar.handleClickIndex': wrapCommand(handleClickIndex),
1875
2068
  'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
1876
- 'ActivityBar.resize': wrapCommand(handleResize),
1877
2069
  'ActivityBar.handleSideBarHidden': wrapCommand(handleSideBarHidden),
1878
2070
  'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
2071
+ 'ActivityBar.handleUpdateStateChange': wrapCommand(handleUpdateStateChange),
1879
2072
  'ActivityBar.loadContent': wrapCommand(loadContent),
1880
2073
  'ActivityBar.render2': render2,
1881
2074
  'ActivityBar.renderEventListeners': renderEventListeners,
2075
+ 'ActivityBar.resize': wrapCommand(handleResize),
1882
2076
  'ActivityBar.saveState': wrapGetter(saveState),
1883
2077
  'ActivityBar.terminate': terminate,
1884
2078
  '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.28.0",
3
+ "version": "1.30.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",