@lvce-editor/activity-bar-worker 1.28.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,
@@ -1173,12 +1407,19 @@ const getIndexFromPosition = (y, eventX, eventY, itemHeight, itemCount, height)
1173
1407
  return index;
1174
1408
  };
1175
1409
 
1176
- const show$1 = async (x, y, id, ...args) => {
1177
- 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);
1178
1413
  };
1179
1414
 
1180
- const handleClickAdditionalViews = async (state, x, y, viewletId) => {
1181
- 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
+ });
1182
1423
  return state;
1183
1424
  };
1184
1425
 
@@ -1211,8 +1452,13 @@ const handleClickOther = async (state, x, y, viewletId) => {
1211
1452
  return state;
1212
1453
  };
1213
1454
 
1214
- const handleClickSettings = async (state, x, y, viewletId) => {
1215
- 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
+ });
1216
1462
  return state;
1217
1463
  };
1218
1464
 
@@ -1232,7 +1478,7 @@ const handleClickIndex = async (state, button, index, x, y) => {
1232
1478
  case 'Settings':
1233
1479
  return handleClickSettings(state, x, y);
1234
1480
  case 'Additional Views':
1235
- return handleClickAdditionalViews(state, x, y);
1481
+ return handleClickAdditionalViews(state, x, y, viewletId);
1236
1482
  default:
1237
1483
  return handleClickOther(state, x, y, viewletId);
1238
1484
  }
@@ -1249,65 +1495,16 @@ const handleClick = async (state, button, eventX, eventY) => {
1249
1495
  return handleClickIndex(state, button, index, eventX, eventY);
1250
1496
  };
1251
1497
 
1252
- const handleContextMenu = async (state, button, x, y) => {
1253
- 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
+ });
1254
1505
  return state;
1255
1506
  };
1256
1507
 
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
1508
  const DebugAlt2 = 'DebugAlt2';
1312
1509
  const Extensions$1 = 'Extensions';
1313
1510
  const Files = 'Files';
@@ -1316,15 +1513,6 @@ const SettingsGear = 'SettingsGear';
1316
1513
  const SourceControl$1 = 'SourceControl';
1317
1514
  const Ellipsis = 'Ellipsis';
1318
1515
 
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
1516
  const getFilteredActivityBarItems = (items, height, itemHeight) => {
1329
1517
  const numberOfVisibleItems = getNumberOfVisibleItems({
1330
1518
  height,
@@ -1502,7 +1690,7 @@ const getActivityBarItems = () => {
1502
1690
  // Bottom
1503
1691
  {
1504
1692
  id: 'Settings',
1505
- title: settings(),
1693
+ title: settings$1(),
1506
1694
  icon: SettingsGear,
1507
1695
  flags: Button | Enabled | MarginTop,
1508
1696
  keyShortcuts: ''
@@ -1524,6 +1712,7 @@ const loadContent = async (state, savedState) => {
1524
1712
  currentViewletId: Explorer,
1525
1713
  filteredItems,
1526
1714
  selectedIndex: explorerIndex,
1715
+ sideBarLocation: Left,
1527
1716
  sideBarVisible: true
1528
1717
  };
1529
1718
  };
@@ -1647,7 +1836,7 @@ const getActivityBarItemInProgressDom = item => {
1647
1836
  }, {
1648
1837
  type: Div,
1649
1838
  className: mergeClassNames(Icon, `MaskIcon${icon}`),
1650
- role: None,
1839
+ role: None$1,
1651
1840
  childCount: 0
1652
1841
  }, ...getBadgeVirtualDom()];
1653
1842
  };
@@ -1682,7 +1871,7 @@ const getActivityBarItemWithBadgeDom = item => {
1682
1871
  }, {
1683
1872
  type: Div,
1684
1873
  className: mergeClassNames(Icon, `MaskIcon${icon}`),
1685
- role: None,
1874
+ role: None$1,
1686
1875
  childCount: 0
1687
1876
  }, {
1688
1877
  type: Div,
@@ -1695,7 +1884,7 @@ const getIconVirtualDom = (icon, type = Div) => {
1695
1884
  return {
1696
1885
  type,
1697
1886
  className: `MaskIcon MaskIcon${icon}`,
1698
- role: None,
1887
+ role: None$1,
1699
1888
  childCount: 0
1700
1889
  };
1701
1890
  };
@@ -1864,21 +2053,23 @@ const commandMap = {
1864
2053
  'ActivityBar.focusFirst': wrapCommand(focusFirst),
1865
2054
  'ActivityBar.focusIndex': wrapCommand(focusIndex),
1866
2055
  'ActivityBar.focusLast': wrapCommand(focusLast),
1867
- 'ActivityBar.handleUpdateStateChange': wrapCommand(handleUpdateStateChange),
1868
2056
  'ActivityBar.focusNext': wrapCommand(focusNext),
1869
2057
  'ActivityBar.focusNone': wrapCommand(focusNone),
1870
2058
  'ActivityBar.getCommandIds': getCommandIds,
1871
2059
  'ActivityBar.getKeyBindings': getKeyBindings,
2060
+ 'ActivityBar.getMenuEntries': getMenuEntries,
2061
+ 'ActivityBar.getMenuEntryIds': getMenuEntryIds,
1872
2062
  'ActivityBar.handleBlur': wrapCommand(handleBlur),
1873
2063
  'ActivityBar.handleClick': wrapCommand(handleClick),
1874
2064
  'ActivityBar.handleClickIndex': wrapCommand(handleClickIndex),
1875
2065
  'ActivityBar.handleContextMenu': wrapCommand(handleContextMenu),
1876
- 'ActivityBar.resize': wrapCommand(handleResize),
1877
2066
  'ActivityBar.handleSideBarHidden': wrapCommand(handleSideBarHidden),
1878
2067
  'ActivityBar.handleSideBarViewletChange': wrapCommand(handleSideBarViewletChange),
2068
+ 'ActivityBar.handleUpdateStateChange': wrapCommand(handleUpdateStateChange),
1879
2069
  'ActivityBar.loadContent': wrapCommand(loadContent),
1880
2070
  'ActivityBar.render2': render2,
1881
2071
  'ActivityBar.renderEventListeners': renderEventListeners,
2072
+ 'ActivityBar.resize': wrapCommand(handleResize),
1882
2073
  'ActivityBar.saveState': wrapGetter(saveState),
1883
2074
  'ActivityBar.terminate': terminate,
1884
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.28.0",
3
+ "version": "1.29.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",