@lvce-editor/source-control-worker 2.9.0 → 2.11.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.
@@ -1018,7 +1018,7 @@ const WebWorkerRpcClient = {
1018
1018
  create: create$2
1019
1019
  };
1020
1020
 
1021
- const None = 'none';
1021
+ const None$1 = 'none';
1022
1022
  const ToolBar = 'toolbar';
1023
1023
  const Tree$1 = 'tree';
1024
1024
  const TreeItem$1 = 'treeitem';
@@ -1049,6 +1049,8 @@ const User = 1;
1049
1049
 
1050
1050
  const SourceControl$1 = 22;
1051
1051
 
1052
+ const None = 0;
1053
+
1052
1054
  const ExtensionHostWorker = 44;
1053
1055
  const RendererWorker = 1;
1054
1056
  const SourceControlWorker = 66;
@@ -1100,8 +1102,13 @@ const {
1100
1102
  invoke,
1101
1103
  invokeAndTransfer,
1102
1104
  set: set$1} = create$1(RendererWorker);
1103
- const showContextMenu = async (x, y, id, ...args) => {
1104
- return invoke('ContextMenu.show', x, y, id, ...args);
1105
+ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1106
+ number(uid);
1107
+ number(menuId);
1108
+ number(x);
1109
+ number(y);
1110
+ // @ts-ignore
1111
+ await invoke('ContextMenu.show2', uid, menuId, x, y, args);
1105
1112
  };
1106
1113
  const readFile$1 = async uri => {
1107
1114
  return invoke('FileSystem.readFile', uri);
@@ -1113,6 +1120,9 @@ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1113
1120
  const activateByEvent$1 = event => {
1114
1121
  return invoke('ExtensionHostManagement.activateByEvent', event);
1115
1122
  };
1123
+ const getPreference = async key => {
1124
+ return await invoke('Preferences.get', key);
1125
+ };
1116
1126
  const openUri$1 = async (uri, focus, options) => {
1117
1127
  await invoke('Main.openUri', uri, focus, options);
1118
1128
  };
@@ -1310,6 +1320,112 @@ const getInfo = uid => {
1310
1320
  return newState.allGroups;
1311
1321
  };
1312
1322
 
1323
+ const emptyObject = {};
1324
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1325
+ const i18nString = (key, placeholders = emptyObject) => {
1326
+ if (placeholders === emptyObject) {
1327
+ return key;
1328
+ }
1329
+ const replacer = (match, rest) => {
1330
+ return placeholders[rest];
1331
+ };
1332
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1333
+ };
1334
+
1335
+ const OpenChanges = 'Open Changes';
1336
+ const OpenFile = 'Open File';
1337
+ const OpenFileHead = 'Open File (HEAD)';
1338
+ const DiscardChanges = 'Discard Changes';
1339
+ const StageChanges = 'Stage Changes';
1340
+ const AddToGitignore = 'Add to gitignore';
1341
+ const RevealInExplorerView = 'Reveal in Explorer View';
1342
+ const OpenContainingFolder = 'Open Containing Folder';
1343
+ const MessageEnterToCommitOnMaster = `Message (Enter) to commit on 'master'`;
1344
+ const SourceControlInput$1 = 'Source Control Input';
1345
+
1346
+ const openChanges = () => {
1347
+ return i18nString(OpenChanges);
1348
+ };
1349
+ const openFile = () => {
1350
+ return i18nString(OpenFile);
1351
+ };
1352
+ const openFileHead = () => {
1353
+ return i18nString(OpenFileHead);
1354
+ };
1355
+ const discardChanges = () => {
1356
+ return i18nString(DiscardChanges);
1357
+ };
1358
+ const stageChanges = () => {
1359
+ return i18nString(StageChanges);
1360
+ };
1361
+ const addToGitignore = () => {
1362
+ return i18nString(AddToGitignore);
1363
+ };
1364
+ const revealInExplorerView = () => {
1365
+ return i18nString(RevealInExplorerView);
1366
+ };
1367
+ const openContainingFolder = () => {
1368
+ return i18nString(OpenContainingFolder);
1369
+ };
1370
+ const messageEnterToCommitOnMaster = () => {
1371
+ return i18nString(MessageEnterToCommitOnMaster);
1372
+ };
1373
+ const sourceControlInput = () => {
1374
+ return i18nString(SourceControlInput$1);
1375
+ };
1376
+
1377
+ const getMenuEntries = () => {
1378
+ return [{
1379
+ label: openChanges(),
1380
+ flags: None,
1381
+ command: /* TODO */'-1',
1382
+ id: ''
1383
+ }, {
1384
+ label: openFile(),
1385
+ flags: None,
1386
+ command: /* TODO */'-1',
1387
+ id: ''
1388
+ }, {
1389
+ label: openFileHead(),
1390
+ flags: None,
1391
+ command: /* TODO */'-1',
1392
+ id: ''
1393
+ }, {
1394
+ label: discardChanges(),
1395
+ flags: None,
1396
+ command: /* TODO */'-1',
1397
+ id: ''
1398
+ }, {
1399
+ label: stageChanges(),
1400
+ flags: None,
1401
+ command: /* TODO */'-1',
1402
+ id: ''
1403
+ }, {
1404
+ label: addToGitignore(),
1405
+ flags: None,
1406
+ command: /* TODO */'-1',
1407
+ id: ''
1408
+ }, {
1409
+ label: revealInExplorerView(),
1410
+ flags: None,
1411
+ command: /* TODO */'-1',
1412
+ id: ''
1413
+ }, {
1414
+ label: openContainingFolder(),
1415
+ flags: None,
1416
+ command: /* TODO */'-1',
1417
+ id: ''
1418
+ }];
1419
+ };
1420
+
1421
+ const getMenuEntries2 = state => {
1422
+ return getMenuEntries();
1423
+ };
1424
+
1425
+ const getMenuIds = () => {
1426
+ return [SourceControl$1];
1427
+ };
1428
+
1313
1429
  const activateByEvent = event => {
1314
1430
  return activateByEvent$1(event);
1315
1431
  };
@@ -1371,7 +1487,9 @@ const getDisplayItemsGroup = (group, expandedGroups, iconDefinitions) => {
1371
1487
  if (!items) {
1372
1488
  throw new Error('Source control group is missing an items property');
1373
1489
  }
1374
- const length = items.length;
1490
+ const {
1491
+ length
1492
+ } = items;
1375
1493
  const isExpanded = expandedGroups[id] || false;
1376
1494
  const type = isExpanded ? DirectoryExpanded : Directory;
1377
1495
  const icon = isExpanded ? 'ChevronDown' : 'ChevronRight';
@@ -1644,7 +1762,7 @@ const getVisibleSourceControlItems = (items, minLineY, maxLineY, actionsCache, f
1644
1762
  };
1645
1763
 
1646
1764
  const get = key => {
1647
- return false;
1765
+ return getPreference(key);
1648
1766
  };
1649
1767
 
1650
1768
  const getExtensions = async () => {
@@ -1694,28 +1812,6 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1694
1812
  return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
1695
1813
  };
1696
1814
 
1697
- const emptyObject = {};
1698
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1699
- const i18nString = (key, placeholders = emptyObject) => {
1700
- if (placeholders === emptyObject) {
1701
- return key;
1702
- }
1703
- const replacer = (match, rest) => {
1704
- return placeholders[rest];
1705
- };
1706
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1707
- };
1708
-
1709
- const MessageEnterToCommitOnMaster = `Message (Enter) to commit on 'master'`;
1710
- const SourceControlInput$1 = 'Source Control Input';
1711
-
1712
- const messageEnterToCommitOnMaster = () => {
1713
- return i18nString(MessageEnterToCommitOnMaster);
1714
- };
1715
- const sourceControlInput = () => {
1716
- return i18nString(SourceControlInput$1);
1717
- };
1718
-
1719
1815
  const loadContent = async (state, savedState) => {
1720
1816
  const {
1721
1817
  itemHeight,
@@ -1746,7 +1842,7 @@ const loadContent = async (state, savedState) => {
1746
1842
  const actionsCache = await requestSourceActions();
1747
1843
 
1748
1844
  // TODO make preferences async and more functional
1749
- const splitButtonEnabled = get();
1845
+ const splitButtonEnabled = await get('sourceControl.splitButtonEnabled');
1750
1846
  const total = displayItems.length;
1751
1847
  const contentHeight = total * itemHeight;
1752
1848
  const listHeight = getListHeight(total, itemHeight, height);
@@ -1868,7 +1964,9 @@ const handleClickSourceControlButtons = async (state, index, name) => {
1868
1964
  warn(`[source-control-worker] Button not found ${name}`);
1869
1965
  return state;
1870
1966
  }
1871
- const file = item.file;
1967
+ const {
1968
+ file
1969
+ } = item;
1872
1970
  await executeCommand(button.command, file);
1873
1971
  const newState = await refresh(state);
1874
1972
  return newState;
@@ -1983,12 +2081,17 @@ const handleClickAt = async (state, eventX, eventY, name) => {
1983
2081
  return selectIndex(state, index);
1984
2082
  };
1985
2083
 
1986
- const show = async (x, y, id, ...args) => {
1987
- return showContextMenu(x, y, id, ...args);
2084
+ const show2 = async (uid, menuId, x, y, args) => {
2085
+ await showContextMenu2(uid, menuId, x, y, args);
1988
2086
  };
1989
2087
 
1990
2088
  const handleContextMenu = async (state, button, x, y) => {
1991
- await show(x, y, SourceControl$1);
2089
+ const {
2090
+ id
2091
+ } = state;
2092
+ await show2(id, SourceControl$1, x, y, {
2093
+ menuId: SourceControl$1
2094
+ });
1992
2095
  return state;
1993
2096
  };
1994
2097
 
@@ -2207,7 +2310,7 @@ const getIconVirtualDom = (icon, type = Div) => {
2207
2310
  return {
2208
2311
  type,
2209
2312
  className: `MaskIcon MaskIcon${icon}`,
2210
- role: None,
2313
+ role: None$1,
2211
2314
  childCount: 0
2212
2315
  };
2213
2316
  };
@@ -2291,7 +2394,7 @@ const getFileIconVirtualDom = icon => {
2291
2394
  type: Img,
2292
2395
  className: FileIcon,
2293
2396
  src: icon,
2294
- role: None,
2397
+ role: None$1,
2295
2398
  childCount: 0
2296
2399
  };
2297
2400
  };
@@ -2614,9 +2717,11 @@ const commandMap = {
2614
2717
  'SourceControl.create2': create2,
2615
2718
  'SourceControl.diff2': diff2,
2616
2719
  'SourceControl.getCommandIds': getCommandIds,
2720
+ 'SourceControl.getMenuIds': getMenuIds,
2617
2721
  'SourceControl.getEnabledProviderIds': getEnabledProviderIds,
2618
2722
  'SourceControl.getFileDecorations': getFileDecorations,
2619
2723
  'SourceControl.getInfo': getInfo,
2724
+ 'SourceControl.getMenuEntries2': wrapGetter(getMenuEntries2),
2620
2725
  'SourceControl.handleButtonClick': wrapCommand(handleButtonClick),
2621
2726
  'SourceControl.handleClickAt': wrapCommand(handleClickAt),
2622
2727
  'SourceControl.handleClickSourceControlButtons': wrapCommand(handleClickSourceControlButtons),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/source-control-worker",
3
- "version": "2.9.0",
3
+ "version": "2.11.0",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"