@lvce-editor/source-control-worker 2.13.0 → 2.15.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.
@@ -1048,6 +1048,7 @@ const TargetValue = 'event.target.value';
1048
1048
  const Enter = 3;
1049
1049
 
1050
1050
  const User = 1;
1051
+ const Script = 2;
1051
1052
 
1052
1053
  const CtrlCmd = 1 << 11 >>> 0;
1053
1054
 
@@ -1062,6 +1063,7 @@ const IconThemeWorker = 7009;
1062
1063
 
1063
1064
  const SetCss = 'Viewlet.setCss';
1064
1065
  const SetDom2 = 'Viewlet.setDom2';
1066
+ const SetFocusContext = 'Viewlet.setFocusContext';
1065
1067
  const SetValueByName = 'Viewlet.setValueByName';
1066
1068
 
1067
1069
  const List = 1;
@@ -1227,269 +1229,6 @@ const terminate = () => {
1227
1229
  globalThis.close();
1228
1230
  };
1229
1231
 
1230
- const {
1231
- get: get$1,
1232
- set,
1233
- wrapCommand,
1234
- getCommandIds,
1235
- registerCommands,
1236
- wrapGetter
1237
- } = create();
1238
-
1239
- const create2 = (id, uri, x, y, width, height, workspacePath) => {
1240
- const state = {
1241
- actionsCache: Object.create(null),
1242
- allGroups: [],
1243
- deltaY: 0,
1244
- enabledProviderIds: [],
1245
- fileIconCache: Object.create(null),
1246
- finalDeltaY: 0,
1247
- gitRoot: '',
1248
- handleOffset: 0,
1249
- headerHeight: 40,
1250
- // TODO
1251
- height,
1252
- id,
1253
- index: [],
1254
- inputValue: '',
1255
- expandedGroups: Object.create(null),
1256
- itemHeight: 20,
1257
- items: [],
1258
- maxLineY: 0,
1259
- merge: [],
1260
- minimumSliderSize: 20,
1261
- inputBoxHeight: 30,
1262
- minLineY: 0,
1263
- providerId: '',
1264
- root: '',
1265
- scrollBarActive: false,
1266
- scrollBarHeight: 0,
1267
- splitButtonEnabled: false,
1268
- untracked: [],
1269
- visibleItems: [],
1270
- width,
1271
- workingTree: [],
1272
- workspacePath,
1273
- x,
1274
- y,
1275
- inputPlaceholder: '',
1276
- inputSource: 0,
1277
- maxInputLines: 5,
1278
- inputFontFamily: 'system-ui, Ubuntu, "Droid Sans", sans-serif',
1279
- inputFontSize: 13,
1280
- inputFontWeight: 400,
1281
- inputLetterSpacing: 0,
1282
- inputLineHeight: 20,
1283
- inputBoxMaxHeight: 214,
1284
- history: [],
1285
- viewMode: 1,
1286
- iconDefinitions: [],
1287
- decorationIcons: []
1288
- };
1289
- set(id, state, state);
1290
- };
1291
-
1292
- const isEqual$2 = (oldState, newState) => {
1293
- return oldState.inputBoxHeight === newState.inputBoxHeight;
1294
- };
1295
-
1296
- const isEqual$1 = (oldState, newState) => {
1297
- return oldState.allGroups === newState.allGroups && oldState.deltaY === newState.deltaY && oldState.items === newState.items && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.visibleItems === newState.visibleItems;
1298
- };
1299
-
1300
- const RenderItems = 4;
1301
- const RenderValue = 8;
1302
- const RenderCss = 10;
1303
-
1304
- const isEqual = (oldState, newState) => {
1305
- return newState.inputSource === User || oldState.inputValue === newState.inputValue;
1306
- };
1307
-
1308
- const modules = [isEqual$1, isEqual, isEqual$2];
1309
- const numbers = [RenderItems, RenderValue, RenderCss];
1310
-
1311
- const diff = (oldState, newState) => {
1312
- const diffResult = [];
1313
- for (let i = 0; i < modules.length; i++) {
1314
- const fn = modules[i];
1315
- if (!fn(oldState, newState)) {
1316
- diffResult.push(numbers[i]);
1317
- }
1318
- }
1319
- return diffResult;
1320
- };
1321
-
1322
- const diff2 = uid => {
1323
- const {
1324
- oldState,
1325
- newState
1326
- } = get$1(uid);
1327
- const result = diff(oldState, newState);
1328
- return result;
1329
- };
1330
-
1331
- const getInfo = uid => {
1332
- const {
1333
- newState
1334
- } = get$1(uid);
1335
- return newState.allGroups;
1336
- };
1337
-
1338
- const mergeClassNames = (...classNames) => {
1339
- return classNames.filter(Boolean).join(' ');
1340
- };
1341
-
1342
- const text = data => {
1343
- return {
1344
- type: Text,
1345
- text: data,
1346
- childCount: 0
1347
- };
1348
- };
1349
-
1350
- const getKeyBindings = () => {
1351
- return [{
1352
- key: CtrlCmd | Enter,
1353
- command: 'Source Control.acceptInput',
1354
- when: FocusSourceControlInput
1355
- }];
1356
- };
1357
-
1358
- const emptyObject = {};
1359
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1360
- const i18nString = (key, placeholders = emptyObject) => {
1361
- if (placeholders === emptyObject) {
1362
- return key;
1363
- }
1364
- const replacer = (match, rest) => {
1365
- return placeholders[rest];
1366
- };
1367
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1368
- };
1369
-
1370
- const OpenChanges = 'Open Changes';
1371
- const OpenFile = 'Open File';
1372
- const OpenFileHead = 'Open File (HEAD)';
1373
- const DiscardChanges = 'Discard Changes';
1374
- const StageChanges = 'Stage Changes';
1375
- const AddToGitignore = 'Add to gitignore';
1376
- const RevealInExplorerView = 'Reveal in Explorer View';
1377
- const OpenContainingFolder = 'Open Containing Folder';
1378
- const MessageEnterToCommitOnMaster = `Message (Enter) to commit on 'master'`;
1379
- const SourceControlInput$1 = 'Source Control Input';
1380
-
1381
- const openChanges = () => {
1382
- return i18nString(OpenChanges);
1383
- };
1384
- const openFile = () => {
1385
- return i18nString(OpenFile);
1386
- };
1387
- const openFileHead = () => {
1388
- return i18nString(OpenFileHead);
1389
- };
1390
- const discardChanges = () => {
1391
- return i18nString(DiscardChanges);
1392
- };
1393
- const stageChanges = () => {
1394
- return i18nString(StageChanges);
1395
- };
1396
- const addToGitignore = () => {
1397
- return i18nString(AddToGitignore);
1398
- };
1399
- const revealInExplorerView = () => {
1400
- return i18nString(RevealInExplorerView);
1401
- };
1402
- const openContainingFolder = () => {
1403
- return i18nString(OpenContainingFolder);
1404
- };
1405
- const messageEnterToCommitOnMaster = () => {
1406
- return i18nString(MessageEnterToCommitOnMaster);
1407
- };
1408
- const sourceControlInput = () => {
1409
- return i18nString(SourceControlInput$1);
1410
- };
1411
-
1412
- const getMenuEntries = () => {
1413
- return [{
1414
- label: openChanges(),
1415
- flags: None,
1416
- command: /* TODO */'-1',
1417
- id: ''
1418
- }, {
1419
- label: openFile(),
1420
- flags: None,
1421
- command: /* TODO */'-1',
1422
- id: ''
1423
- }, {
1424
- label: openFileHead(),
1425
- flags: None,
1426
- command: /* TODO */'-1',
1427
- id: ''
1428
- }, {
1429
- label: discardChanges(),
1430
- flags: None,
1431
- command: /* TODO */'-1',
1432
- id: ''
1433
- }, {
1434
- label: stageChanges(),
1435
- flags: None,
1436
- command: /* TODO */'-1',
1437
- id: ''
1438
- }, {
1439
- label: addToGitignore(),
1440
- flags: None,
1441
- command: /* TODO */'-1',
1442
- id: ''
1443
- }, {
1444
- label: revealInExplorerView(),
1445
- flags: None,
1446
- command: /* TODO */'-1',
1447
- id: ''
1448
- }, {
1449
- label: openContainingFolder(),
1450
- flags: None,
1451
- command: /* TODO */'-1',
1452
- id: ''
1453
- }];
1454
- };
1455
-
1456
- const getMenuEntries2 = state => {
1457
- return getMenuEntries();
1458
- };
1459
-
1460
- const getMenuIds = () => {
1461
- return [SourceControl$1];
1462
- };
1463
-
1464
- const activateByEvent = event => {
1465
- return activateByEvent$1(event);
1466
- };
1467
-
1468
- const executeProvider = async ({
1469
- event,
1470
- method,
1471
- params
1472
- }) => {
1473
- await activateByEvent(event);
1474
- // @ts-ignore
1475
- const result = await invoke$1(method, ...params);
1476
- return result;
1477
- };
1478
-
1479
- const CommandExecute = 'ExtensionHostCommand.executeCommand';
1480
- const SourceControlGetFileDecorations = 'ExtensionHostSourceControl.getFileDecorations';
1481
- const SourceControlGetEnabledProviderIds = 'ExtensionHostSourceControl.getEnabledProviderIds';
1482
- const SourceControlGetFileBefore = 'ExtensionHostSourceControl.getFileBefore';
1483
- const SourceControlGetGroups = 'ExtensionHostSourceControl.getGroups';
1484
-
1485
- const executeCommand = (id, ...args) => {
1486
- return executeProvider({
1487
- event: `onCommand:${id}`,
1488
- method: CommandExecute,
1489
- params: [id, ...args]
1490
- });
1491
- };
1492
-
1493
1232
  const getActualDecorationIcon = (iconDefinitions, icon) => {
1494
1233
  if (typeof icon === 'number') {
1495
1234
  const value = iconDefinitions[icon];
@@ -1642,6 +1381,36 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
1642
1381
  return finalDeltaY;
1643
1382
  };
1644
1383
 
1384
+ const activateByEvent = event => {
1385
+ return activateByEvent$1(event);
1386
+ };
1387
+
1388
+ const executeProvider = async ({
1389
+ event,
1390
+ method,
1391
+ params
1392
+ }) => {
1393
+ await activateByEvent(event);
1394
+ // @ts-ignore
1395
+ const result = await invoke$1(method, ...params);
1396
+ return result;
1397
+ };
1398
+
1399
+ const CommandExecute = 'ExtensionHostCommand.executeCommand';
1400
+ const SourceControlAcceptInput = 'ExtensionHostSourceControl.acceptInput';
1401
+ const SourceControlGetFileDecorations = 'ExtensionHostSourceControl.getFileDecorations';
1402
+ const SourceControlGetEnabledProviderIds = 'ExtensionHostSourceControl.getEnabledProviderIds';
1403
+ const SourceControlGetFileBefore = 'ExtensionHostSourceControl.getFileBefore';
1404
+ const SourceControlGetGroups = 'ExtensionHostSourceControl.getGroups';
1405
+
1406
+ const acceptInput$2 = async (providerId, text) => {
1407
+ return executeProvider({
1408
+ event: 'none',
1409
+ method: SourceControlAcceptInput,
1410
+ params: [providerId, text]
1411
+ // noProviderFoundMessage: 'No source control provider found',
1412
+ });
1413
+ };
1645
1414
  const getFileDecorations$1 = (providerId, uris) => {
1646
1415
  return executeProvider({
1647
1416
  event: 'none',
@@ -1679,6 +1448,11 @@ const getIconDefinitions$1 = async providerId => {
1679
1448
  return result;
1680
1449
  };
1681
1450
 
1451
+ const acceptInput$1 = (providerId, text) => {
1452
+ string(providerId);
1453
+ string(text);
1454
+ return acceptInput$2(providerId, text);
1455
+ };
1682
1456
  const getFileDecorations = (providerId, uris) => {
1683
1457
  return getFileDecorations$1(providerId, uris);
1684
1458
  };
@@ -1799,7 +1573,7 @@ const getVisibleSourceControlItems = (items, minLineY, maxLineY, actionsCache, f
1799
1573
  return visible;
1800
1574
  };
1801
1575
 
1802
- const get = key => {
1576
+ const get$1 = key => {
1803
1577
  return getPreference(key);
1804
1578
  };
1805
1579
 
@@ -1819,35 +1593,89 @@ const requestSourceActions = async () => {
1819
1593
  }
1820
1594
  return newCache;
1821
1595
  };
1822
-
1823
- /* eslint-disable unicorn/no-array-reduce */
1824
- const restoreExpandedGroups = groups => {
1825
- return groups.map(group => group.id).reduce((total, current) => {
1826
- return {
1827
- ...total,
1828
- [current]: true
1829
- };
1830
- }, Object.create(null));
1596
+
1597
+ /* eslint-disable unicorn/no-array-reduce */
1598
+ const restoreExpandedGroups = groups => {
1599
+ return groups.map(group => group.id).reduce((total, current) => {
1600
+ return {
1601
+ ...total,
1602
+ [current]: true
1603
+ };
1604
+ }, Object.create(null));
1605
+ };
1606
+
1607
+ const getRestoredInputValue = savedState => {
1608
+ if (savedState && typeof savedState === 'object' && 'inputValue' in savedState && typeof savedState['inputValue'] === 'string') {
1609
+ return savedState.inputValue;
1610
+ }
1611
+ return '';
1612
+ };
1613
+ const restoreState = savedState => {
1614
+ const inputValue = getRestoredInputValue(savedState);
1615
+ return {
1616
+ inputValue
1617
+ };
1618
+ };
1619
+
1620
+ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1621
+ if (size >= contentSize) {
1622
+ return 0;
1623
+ }
1624
+ return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
1625
+ };
1626
+
1627
+ const emptyObject = {};
1628
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1629
+ const i18nString = (key, placeholders = emptyObject) => {
1630
+ if (placeholders === emptyObject) {
1631
+ return key;
1632
+ }
1633
+ const replacer = (match, rest) => {
1634
+ return placeholders[rest];
1635
+ };
1636
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1637
+ };
1638
+
1639
+ const OpenChanges = 'Open Changes';
1640
+ const OpenFile = 'Open File';
1641
+ const OpenFileHead = 'Open File (HEAD)';
1642
+ const DiscardChanges = 'Discard Changes';
1643
+ const StageChanges = 'Stage Changes';
1644
+ const AddToGitignore = 'Add to gitignore';
1645
+ const RevealInExplorerView = 'Reveal in Explorer View';
1646
+ const OpenContainingFolder = 'Open Containing Folder';
1647
+ const MessageEnterToCommitOnMaster = `Message (Enter) to commit on 'master'`;
1648
+ const SourceControlInput$1 = 'Source Control Input';
1649
+
1650
+ const openChanges = () => {
1651
+ return i18nString(OpenChanges);
1652
+ };
1653
+ const openFile = () => {
1654
+ return i18nString(OpenFile);
1655
+ };
1656
+ const openFileHead = () => {
1657
+ return i18nString(OpenFileHead);
1658
+ };
1659
+ const discardChanges = () => {
1660
+ return i18nString(DiscardChanges);
1661
+ };
1662
+ const stageChanges = () => {
1663
+ return i18nString(StageChanges);
1664
+ };
1665
+ const addToGitignore = () => {
1666
+ return i18nString(AddToGitignore);
1831
1667
  };
1832
-
1833
- const getRestoredInputValue = savedState => {
1834
- if (savedState && typeof savedState === 'object' && 'inputValue' in savedState && typeof savedState['inputValue'] === 'string') {
1835
- return savedState.inputValue;
1836
- }
1837
- return '';
1668
+ const revealInExplorerView = () => {
1669
+ return i18nString(RevealInExplorerView);
1838
1670
  };
1839
- const restoreState = savedState => {
1840
- const inputValue = getRestoredInputValue(savedState);
1841
- return {
1842
- inputValue
1843
- };
1671
+ const openContainingFolder = () => {
1672
+ return i18nString(OpenContainingFolder);
1844
1673
  };
1845
-
1846
- const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1847
- if (size >= contentSize) {
1848
- return 0;
1849
- }
1850
- return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
1674
+ const messageEnterToCommitOnMaster = () => {
1675
+ return i18nString(MessageEnterToCommitOnMaster);
1676
+ };
1677
+ const sourceControlInput = () => {
1678
+ return i18nString(SourceControlInput$1);
1851
1679
  };
1852
1680
 
1853
1681
  const loadContent = async (state, savedState) => {
@@ -1880,7 +1708,7 @@ const loadContent = async (state, savedState) => {
1880
1708
  const actionsCache = await requestSourceActions();
1881
1709
 
1882
1710
  // TODO make preferences async and more functional
1883
- const splitButtonEnabled = await get('sourceControl.splitButtonEnabled');
1711
+ const splitButtonEnabled = await get$1('sourceControl.splitButtonEnabled');
1884
1712
  const total = displayItems.length;
1885
1713
  const contentHeight = total * itemHeight;
1886
1714
  const listHeight = getListHeight(total, itemHeight, height);
@@ -1915,6 +1743,228 @@ const loadContent = async (state, savedState) => {
1915
1743
  };
1916
1744
  };
1917
1745
 
1746
+ const info = (...args) => {
1747
+ // @ts-ignore
1748
+ // eslint-disable-next-line no-console
1749
+ console.info(...args);
1750
+ };
1751
+ const warn = (...args) => {
1752
+ // @ts-ignore
1753
+ console.warn(...args);
1754
+ };
1755
+
1756
+ const acceptInput = async state => {
1757
+ const {
1758
+ inputValue,
1759
+ enabledProviderIds
1760
+ } = state;
1761
+ if (enabledProviderIds.length === 0) {
1762
+ info('[ViewletSourceControl] no source control provider found');
1763
+ return state;
1764
+ }
1765
+ const providerId = enabledProviderIds[0];
1766
+ await acceptInput$1(providerId, inputValue);
1767
+ const newState = await loadContent(state, {});
1768
+ return {
1769
+ ...newState,
1770
+ inputValue: ''
1771
+ };
1772
+ };
1773
+
1774
+ const {
1775
+ get,
1776
+ set,
1777
+ wrapCommand,
1778
+ getCommandIds,
1779
+ registerCommands,
1780
+ wrapGetter
1781
+ } = create();
1782
+
1783
+ const create2 = (id, uri, x, y, width, height, workspacePath) => {
1784
+ const state = {
1785
+ actionsCache: Object.create(null),
1786
+ allGroups: [],
1787
+ deltaY: 0,
1788
+ enabledProviderIds: [],
1789
+ fileIconCache: Object.create(null),
1790
+ finalDeltaY: 0,
1791
+ gitRoot: '',
1792
+ handleOffset: 0,
1793
+ headerHeight: 40,
1794
+ // TODO
1795
+ height,
1796
+ id,
1797
+ index: [],
1798
+ inputValue: '',
1799
+ expandedGroups: Object.create(null),
1800
+ itemHeight: 20,
1801
+ items: [],
1802
+ maxLineY: 0,
1803
+ merge: [],
1804
+ minimumSliderSize: 20,
1805
+ inputBoxHeight: 30,
1806
+ minLineY: 0,
1807
+ providerId: '',
1808
+ root: '',
1809
+ scrollBarActive: false,
1810
+ scrollBarHeight: 0,
1811
+ splitButtonEnabled: false,
1812
+ untracked: [],
1813
+ visibleItems: [],
1814
+ width,
1815
+ workingTree: [],
1816
+ workspacePath,
1817
+ x,
1818
+ y,
1819
+ inputPlaceholder: '',
1820
+ inputSource: 0,
1821
+ maxInputLines: 5,
1822
+ inputFontFamily: 'system-ui, Ubuntu, "Droid Sans", sans-serif',
1823
+ inputFontSize: 13,
1824
+ inputFontWeight: 400,
1825
+ inputLetterSpacing: 0,
1826
+ inputLineHeight: 20,
1827
+ inputBoxMaxHeight: 214,
1828
+ history: [],
1829
+ viewMode: 1,
1830
+ iconDefinitions: [],
1831
+ decorationIcons: [],
1832
+ focus: 0
1833
+ };
1834
+ set(id, state, state);
1835
+ };
1836
+
1837
+ const isEqual$3 = (oldState, newState) => {
1838
+ return oldState.inputBoxHeight === newState.inputBoxHeight;
1839
+ };
1840
+
1841
+ const isEqual$2 = (oldState, newState) => {
1842
+ return oldState.focus === newState.focus;
1843
+ };
1844
+
1845
+ const isEqual$1 = (oldState, newState) => {
1846
+ return oldState.allGroups === newState.allGroups && oldState.deltaY === newState.deltaY && oldState.items === newState.items && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.visibleItems === newState.visibleItems;
1847
+ };
1848
+
1849
+ const RenderItems = 4;
1850
+ const RenderFocusContext = 7;
1851
+ const RenderValue = 8;
1852
+ const RenderCss = 10;
1853
+
1854
+ const isEqual = (oldState, newState) => {
1855
+ return newState.inputSource === User || oldState.inputValue === newState.inputValue;
1856
+ };
1857
+
1858
+ const modules = [isEqual$1, isEqual, isEqual$3, isEqual$2];
1859
+ const numbers = [RenderItems, RenderValue, RenderCss, RenderFocusContext];
1860
+
1861
+ const diff = (oldState, newState) => {
1862
+ const diffResult = [];
1863
+ for (let i = 0; i < modules.length; i++) {
1864
+ const fn = modules[i];
1865
+ if (!fn(oldState, newState)) {
1866
+ diffResult.push(numbers[i]);
1867
+ }
1868
+ }
1869
+ return diffResult;
1870
+ };
1871
+
1872
+ const diff2 = uid => {
1873
+ const {
1874
+ oldState,
1875
+ newState
1876
+ } = get(uid);
1877
+ const result = diff(oldState, newState);
1878
+ return result;
1879
+ };
1880
+
1881
+ const getInfo = uid => {
1882
+ const {
1883
+ newState
1884
+ } = get(uid);
1885
+ return newState.allGroups;
1886
+ };
1887
+
1888
+ const mergeClassNames = (...classNames) => {
1889
+ return classNames.filter(Boolean).join(' ');
1890
+ };
1891
+
1892
+ const text = data => {
1893
+ return {
1894
+ type: Text,
1895
+ text: data,
1896
+ childCount: 0
1897
+ };
1898
+ };
1899
+
1900
+ const getKeyBindings = () => {
1901
+ return [{
1902
+ key: CtrlCmd | Enter,
1903
+ command: 'Source Control.acceptInput',
1904
+ when: FocusSourceControlInput
1905
+ }];
1906
+ };
1907
+
1908
+ const getMenuEntries = () => {
1909
+ return [{
1910
+ label: openChanges(),
1911
+ flags: None,
1912
+ command: /* TODO */'-1',
1913
+ id: ''
1914
+ }, {
1915
+ label: openFile(),
1916
+ flags: None,
1917
+ command: /* TODO */'-1',
1918
+ id: ''
1919
+ }, {
1920
+ label: openFileHead(),
1921
+ flags: None,
1922
+ command: /* TODO */'-1',
1923
+ id: ''
1924
+ }, {
1925
+ label: discardChanges(),
1926
+ flags: None,
1927
+ command: /* TODO */'-1',
1928
+ id: ''
1929
+ }, {
1930
+ label: stageChanges(),
1931
+ flags: None,
1932
+ command: /* TODO */'-1',
1933
+ id: ''
1934
+ }, {
1935
+ label: addToGitignore(),
1936
+ flags: None,
1937
+ command: /* TODO */'-1',
1938
+ id: ''
1939
+ }, {
1940
+ label: revealInExplorerView(),
1941
+ flags: None,
1942
+ command: /* TODO */'-1',
1943
+ id: ''
1944
+ }, {
1945
+ label: openContainingFolder(),
1946
+ flags: None,
1947
+ command: /* TODO */'-1',
1948
+ id: ''
1949
+ }];
1950
+ };
1951
+
1952
+ const getMenuEntries2 = state => {
1953
+ return getMenuEntries();
1954
+ };
1955
+
1956
+ const getMenuIds = () => {
1957
+ return [SourceControl$1];
1958
+ };
1959
+
1960
+ const executeCommand = (id, ...args) => {
1961
+ return executeProvider({
1962
+ event: `onCommand:${id}`,
1963
+ method: CommandExecute,
1964
+ params: [id, ...args]
1965
+ });
1966
+ };
1967
+
1918
1968
  const handleButtonClick = async (state, clickedIndex) => {
1919
1969
  const {
1920
1970
  visibleItems
@@ -1940,11 +1990,6 @@ const getIndex = (state, eventX, eventY) => {
1940
1990
  return index;
1941
1991
  };
1942
1992
 
1943
- const warn = (...args) => {
1944
- // @ts-ignore
1945
- console.warn(...args);
1946
- };
1947
-
1948
1993
  const refresh = async state => {
1949
1994
  const {
1950
1995
  itemHeight,
@@ -2135,8 +2180,12 @@ const handleContextMenu = async (state, button, x, y) => {
2135
2180
  return state;
2136
2181
  };
2137
2182
 
2138
- const handleFocus = async state => {
2139
- return state;
2183
+ const handleInputFocus = async state => {
2184
+ return {
2185
+ ...state,
2186
+ focus: FocusSourceControlInput,
2187
+ inputSource: Script
2188
+ };
2140
2189
  };
2141
2190
 
2142
2191
  const handleInput = async (state, value, inputSource = User) => {
@@ -2157,6 +2206,11 @@ const handleInput = async (state, value, inputSource = User) => {
2157
2206
  };
2158
2207
  };
2159
2208
 
2209
+ const handleInputBlur = async state => {
2210
+ // TODO reset focus
2211
+ return state;
2212
+ };
2213
+
2160
2214
  const handleMessagePort = async port => {
2161
2215
  await PlainMessagePortRpc.create({
2162
2216
  commandMap: {},
@@ -2282,6 +2336,14 @@ const renderCss = (oldState, newState) => {
2282
2336
  return [SetCss, id, css];
2283
2337
  };
2284
2338
 
2339
+ const renderFocusContext = (oldState, newState) => {
2340
+ const {
2341
+ id,
2342
+ focus
2343
+ } = newState;
2344
+ return [SetFocusContext, id, focus];
2345
+ };
2346
+
2285
2347
  const Actions = 'Actions';
2286
2348
  const SourceControlButtons = 'SourceControlButtons';
2287
2349
  const Grow = 'Grow';
@@ -2607,6 +2669,8 @@ const getRenderer = diffType => {
2607
2669
  return renderValue;
2608
2670
  case RenderCss:
2609
2671
  return renderCss;
2672
+ case RenderFocusContext:
2673
+ return renderFocusContext;
2610
2674
  default:
2611
2675
  throw new Error('unknown renderer');
2612
2676
  }
@@ -2628,7 +2692,7 @@ const render2 = (uid, diffResult) => {
2628
2692
  const {
2629
2693
  oldState,
2630
2694
  newState
2631
- } = get$1(uid);
2695
+ } = get(uid);
2632
2696
  set(uid, newState, newState);
2633
2697
  const commands = applyRender(oldState, newState, diffResult);
2634
2698
  return commands;
@@ -2712,7 +2776,7 @@ const renderEventListeners = () => {
2712
2776
 
2713
2777
  const saveState = uid => {
2714
2778
  number(uid);
2715
- const value = get$1(uid);
2779
+ const value = get(uid);
2716
2780
  const {
2717
2781
  newState
2718
2782
  } = value;
@@ -2763,6 +2827,7 @@ const viewAsTree = state => {
2763
2827
 
2764
2828
  const commandMap = {
2765
2829
  'Initialize.initialize': initialize,
2830
+ 'SourceControl.acceptInput': wrapCommand(acceptInput),
2766
2831
  'SourceControl.create2': create2,
2767
2832
  'SourceControl.diff2': diff2,
2768
2833
  'SourceControl.getCommandIds': getCommandIds,
@@ -2776,8 +2841,9 @@ const commandMap = {
2776
2841
  'SourceControl.handleClickAt': wrapCommand(handleClickAt),
2777
2842
  'SourceControl.handleClickSourceControlButtons': wrapCommand(handleClickSourceControlButtons),
2778
2843
  'SourceControl.handleContextMenu': wrapCommand(handleContextMenu),
2779
- 'SourceControl.handleFocus': wrapCommand(handleFocus),
2844
+ 'SourceControl.handleFocus': wrapCommand(handleInputFocus),
2780
2845
  'SourceControl.handleInput': wrapCommand(handleInput),
2846
+ 'SourceControl.handleInputBlur': wrapCommand(handleInputBlur),
2781
2847
  'SourceControl.handleMessagePort': handleMessagePort,
2782
2848
  'SourceControl.handleMouseOut': wrapCommand(handleMouseOut),
2783
2849
  'SourceControl.handleMouseOutAt': wrapCommand(handleMouseOutAt),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/source-control-worker",
3
- "version": "2.13.0",
3
+ "version": "2.15.0",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"