@lvce-editor/extension-search-view 3.9.0 → 4.1.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.
@@ -427,7 +427,7 @@ const create$4 = (method, params) => {
427
427
  };
428
428
  };
429
429
  const callbacks = Object.create(null);
430
- const set$2 = (id, fn) => {
430
+ const set$4 = (id, fn) => {
431
431
  callbacks[id] = fn;
432
432
  };
433
433
  const get$2 = id => {
@@ -446,7 +446,7 @@ const registerPromise = () => {
446
446
  resolve,
447
447
  promise
448
448
  } = Promise.withResolvers();
449
- set$2(id, resolve);
449
+ set$4(id, resolve);
450
450
  return {
451
451
  id,
452
452
  promise
@@ -526,7 +526,8 @@ const splitLines = lines => {
526
526
  return lines.split(NewLine);
527
527
  };
528
528
  const getCurrentStack = () => {
529
- const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
529
+ const stackLinesToSkip = 3;
530
+ const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
530
531
  return currentStack;
531
532
  };
532
533
  const getNewLineIndex = (string, startIndex = undefined) => {
@@ -790,13 +791,19 @@ const send = (transport, method, ...params) => {
790
791
  const message = create$4(method, params);
791
792
  transport.send(message);
792
793
  };
793
- const invoke$1 = (ipc, method, ...params) => {
794
+ const invoke$2 = (ipc, method, ...params) => {
794
795
  return invokeHelper(ipc, method, params, false);
795
796
  };
796
- const invokeAndTransfer = (ipc, method, ...params) => {
797
+ const invokeAndTransfer$1 = (ipc, method, ...params) => {
797
798
  return invokeHelper(ipc, method, params, true);
798
799
  };
799
800
 
801
+ class CommandNotFoundError extends Error {
802
+ constructor(command) {
803
+ super(`Command not found ${command}`);
804
+ this.name = 'CommandNotFoundError';
805
+ }
806
+ }
800
807
  const commands = Object.create(null);
801
808
  const register = commandMap => {
802
809
  Object.assign(commands, commandMap);
@@ -807,7 +814,7 @@ const getCommand = key => {
807
814
  const execute = (command, ...args) => {
808
815
  const fn = getCommand(command);
809
816
  if (!fn) {
810
- throw new Error(`command not found ${command}`);
817
+ throw new CommandNotFoundError(command);
811
818
  }
812
819
  return fn(...args);
813
820
  };
@@ -823,10 +830,10 @@ const createRpc = ipc => {
823
830
  send(ipc, method, ...params);
824
831
  },
825
832
  invoke(method, ...params) {
826
- return invoke$1(ipc, method, ...params);
833
+ return invoke$2(ipc, method, ...params);
827
834
  },
828
835
  invokeAndTransfer(method, ...params) {
829
- return invokeAndTransfer(ipc, method, ...params);
836
+ return invokeAndTransfer$1(ipc, method, ...params);
830
837
  },
831
838
  async dispose() {
832
839
  await ipc?.dispose();
@@ -878,9 +885,30 @@ const WebWorkerRpcClient = {
878
885
  __proto__: null,
879
886
  create: create$3
880
887
  };
888
+ const createMockRpc = ({
889
+ commandMap
890
+ }) => {
891
+ const invocations = [];
892
+ const invoke = (method, ...params) => {
893
+ invocations.push([method, ...params]);
894
+ const command = commandMap[method];
895
+ return command(...params);
896
+ };
897
+ const mockRpc = {
898
+ invoke,
899
+ invokeAndTransfer: invoke,
900
+ invocations
901
+ };
902
+ return mockRpc;
903
+ };
881
904
 
905
+ const toCommandId$1 = key => {
906
+ const dotIndex = key.indexOf('.');
907
+ return key.slice(dotIndex + 1);
908
+ };
882
909
  const create$2 = () => {
883
910
  const states = Object.create(null);
911
+ const commandMapRef = {};
884
912
  return {
885
913
  get(uid) {
886
914
  return states[uid];
@@ -921,6 +949,15 @@ const create$2 = () => {
921
949
  };
922
950
  return wrapped;
923
951
  },
952
+ wrapGetter(fn) {
953
+ const wrapped = (uid, ...args) => {
954
+ const {
955
+ newState
956
+ } = states[uid];
957
+ return fn(newState, ...args);
958
+ };
959
+ return wrapped;
960
+ },
924
961
  diff(uid, modules, numbers) {
925
962
  const {
926
963
  oldState,
@@ -934,6 +971,14 @@ const create$2 = () => {
934
971
  }
935
972
  }
936
973
  return diffResult;
974
+ },
975
+ getCommandIds() {
976
+ const keys = Object.keys(commandMapRef);
977
+ const ids = keys.map(toCommandId$1);
978
+ return ids;
979
+ },
980
+ registerCommands(commandMap) {
981
+ Object.assign(commandMapRef, commandMap);
937
982
  }
938
983
  };
939
984
  };
@@ -967,7 +1012,7 @@ const Disable = 'Disable';
967
1012
  const InstallAnotherVersion = 'Install Another Version';
968
1013
  const SearchExtensionsInMarketplace = 'Search Extensions in Marketplace';
969
1014
  const ViewsAndMoreActions = 'Views and more Actions...';
970
- const Extensions = 'Extensions';
1015
+ const Extensions$2 = 'Extensions';
971
1016
  const Copy = 'Copy';
972
1017
  const CopyExtensionId = 'CopyExtensionId';
973
1018
 
@@ -981,7 +1026,7 @@ const refresh = () => {
981
1026
  return i18nString(Refresh$1);
982
1027
  };
983
1028
  const extensions = () => {
984
- return i18nString(Extensions);
1029
+ return i18nString(Extensions$2);
985
1030
  };
986
1031
  const clearExtensionSearchResults = () => {
987
1032
  return i18nString(ClearExtensionSearchResults);
@@ -1008,9 +1053,9 @@ const viewsAndMoreActions = () => {
1008
1053
  return i18nString(ViewsAndMoreActions);
1009
1054
  };
1010
1055
 
1011
- const None$2 = 0;
1012
- const Input = 1;
1013
- const List$1 = 2;
1056
+ const None$3 = 0;
1057
+ const Input$1 = 1;
1058
+ const List$2 = 2;
1014
1059
 
1015
1060
  const getFinalDeltaY = (height, itemHeight, itemsLength) => {
1016
1061
  const contentHeight = itemsLength * itemHeight;
@@ -1128,7 +1173,7 @@ const matchesParsedValue = (extension, parsedValue) => {
1128
1173
  };
1129
1174
 
1130
1175
  const toSorted = (array, compare) => {
1131
- return [...array].sort(compare);
1176
+ return array.toSorted(compare);
1132
1177
  };
1133
1178
 
1134
1179
  const compareExtension = (extensionA, extensionB) => {
@@ -1181,7 +1226,7 @@ const handleInput = async (state, value) => {
1181
1226
  allExtensions,
1182
1227
  deltaY: 0,
1183
1228
  finalDeltaY: 0,
1184
- focus: Input,
1229
+ focus: Input$1,
1185
1230
  items,
1186
1231
  maxLineY: 0,
1187
1232
  message: noExtensionsFound(),
@@ -1237,9 +1282,10 @@ const closeSuggest = state => {
1237
1282
 
1238
1283
  const {
1239
1284
  get: get$1,
1240
- set: set$1,
1241
- dispose: dispose$1,
1242
- wrapCommand
1285
+ set: set$3,
1286
+ dispose: dispose$2,
1287
+ wrapCommand,
1288
+ wrapGetter
1243
1289
  } = create$2();
1244
1290
 
1245
1291
  const create$1 = (id, uri, x, y, width, height, platform, assetDir) => {
@@ -1275,27 +1321,18 @@ const create$1 = (id, uri, x, y, width, height, platform, assetDir) => {
1275
1321
  x,
1276
1322
  y
1277
1323
  };
1278
- set$1(id, state, state);
1279
- };
1280
-
1281
- const isEqual$5 = (oldState, newState) => {
1282
- return true;
1283
- };
1284
-
1285
- const isEqual$4 = (oldState, newState) => {
1286
- return oldState.placeholder === newState.placeholder;
1287
- };
1288
-
1289
- const isEqual$3 = (oldState, newState) => {
1290
- return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.focusedIndex === newState.focusedIndex && oldState.message === newState.message && oldState.inputActions === newState.inputActions && oldState.placeholder === newState.placeholder;
1324
+ set$3(id, state, state);
1291
1325
  };
1292
1326
 
1293
1327
  const isEqual$2 = (oldState, newState) => {
1294
- return oldState.message === newState.message;
1328
+ if (!newState.focus) {
1329
+ return true;
1330
+ }
1331
+ return oldState.focus === newState.focus;
1295
1332
  };
1296
1333
 
1297
1334
  const isEqual$1 = (oldState, newState) => {
1298
- return oldState.negativeMargin === newState.negativeMargin && oldState.deltaY === newState.deltaY && oldState.height === newState.height && oldState.finalDeltaY === newState.finalDeltaY && oldState.items.length === newState.items.length && oldState.scrollBarActive === newState.scrollBarActive;
1335
+ return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.focusedIndex === newState.focusedIndex && oldState.message === newState.message && oldState.inputActions === newState.inputActions && oldState.placeholder === newState.placeholder;
1299
1336
  };
1300
1337
 
1301
1338
  const User = 1;
@@ -1311,9 +1348,10 @@ const RenderItems = 4;
1311
1348
  const RenderScrollBar = 5;
1312
1349
  const RenderMessage = 6;
1313
1350
  const RenderSearchValue = 7;
1351
+ const RenderFocusContext = 8;
1314
1352
 
1315
- const modules = [isEqual$1, isEqual$2, isEqual$4, isEqual$3, isEqual$5, isEqual];
1316
- const numbers = [RenderScrollBar, RenderMessage, RenderHeader, RenderItems, RenderFocus, RenderSearchValue];
1353
+ const modules = [isEqual$1, isEqual$2, isEqual, isEqual$2];
1354
+ const numbers = [RenderItems, RenderFocus, RenderSearchValue, RenderFocusContext];
1317
1355
 
1318
1356
  const diff2 = uid => {
1319
1357
  const {
@@ -1330,8 +1368,8 @@ const diff2 = uid => {
1330
1368
  return diffResult;
1331
1369
  };
1332
1370
 
1333
- const dispose = uid => {
1334
- dispose$1(uid);
1371
+ const dispose$1 = uid => {
1372
+ dispose$2(uid);
1335
1373
  };
1336
1374
 
1337
1375
  // TODO optimize this function to return the minimum number
@@ -1545,8 +1583,9 @@ const DownArrow = 16;
1545
1583
  const CtrlCmd = 1 << 11 >>> 0;
1546
1584
 
1547
1585
  const FocusExtensions = 15;
1586
+ const FocusExtensionsInput = 7000;
1548
1587
 
1549
- const getKeyBindings = () => {
1588
+ const getKeyBindings$1 = () => {
1550
1589
  return [{
1551
1590
  key: Home,
1552
1591
  command: 'Extensions.focusFirst',
@@ -1590,33 +1629,33 @@ const getKeyBindings = () => {
1590
1629
  }];
1591
1630
  };
1592
1631
 
1593
- const None$1 = 0;
1632
+ const None$2 = 0;
1594
1633
 
1595
1634
  const getMenuEntries = () => {
1596
1635
  return [{
1597
1636
  id: 'enable',
1598
1637
  label: enable(),
1599
- flags: None$1,
1638
+ flags: None$2,
1600
1639
  command: 'SearchExtensions.enable'
1601
1640
  }, {
1602
1641
  id: 'disable',
1603
1642
  label: disable(),
1604
- flags: None$1,
1643
+ flags: None$2,
1605
1644
  command: 'SearchExtensions.disable'
1606
1645
  }, {
1607
1646
  id: 'installAnotherVersion',
1608
1647
  label: installAnotherVersion(),
1609
- flags: None$1,
1648
+ flags: None$2,
1610
1649
  command: 'SearchExtensions.installAnotherVersion'
1611
1650
  }, {
1612
1651
  id: 'copy',
1613
1652
  label: copy(),
1614
- flags: None$1,
1653
+ flags: None$2,
1615
1654
  command: 'SearchExtensions.copy'
1616
1655
  }, {
1617
1656
  id: 'copyExtensionId',
1618
1657
  label: copyExtensionId(),
1619
- flags: None$1,
1658
+ flags: None$2,
1620
1659
  command: 'SearchExtensions.copyExtensionId'
1621
1660
  }];
1622
1661
  };
@@ -1624,7 +1663,7 @@ const getMenuEntries = () => {
1624
1663
  const handleBlur = state => {
1625
1664
  return {
1626
1665
  ...state,
1627
- focus: None$2
1666
+ focus: None$3
1628
1667
  };
1629
1668
  };
1630
1669
 
@@ -1632,16 +1671,25 @@ const getExtensionDetailUri = extensionId => {
1632
1671
  return `extension-detail://${extensionId}`;
1633
1672
  };
1634
1673
 
1674
+ const None$1 = 'none';
1675
+
1676
+ const Button = 1;
1677
+ const Div = 4;
1678
+ const Input = 6;
1679
+ const Text = 12;
1680
+ const Img = 17;
1681
+
1682
+ const DebugWorker = 55;
1683
+ const RendererWorker$1 = 1;
1684
+
1635
1685
  const rpcs = Object.create(null);
1636
- const set$g = (id, rpc) => {
1686
+ const set$2 = (id, rpc) => {
1637
1687
  rpcs[id] = rpc;
1638
1688
  };
1639
1689
  const get = id => {
1640
1690
  return rpcs[id];
1641
1691
  };
1642
1692
 
1643
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
1644
-
1645
1693
  const create = rpcId => {
1646
1694
  return {
1647
1695
  // @ts-ignore
@@ -1657,7 +1705,7 @@ const create = rpcId => {
1657
1705
  return rpc.invokeAndTransfer(method, ...params);
1658
1706
  },
1659
1707
  set(rpc) {
1660
- set$g(rpcId, rpc);
1708
+ set$2(rpcId, rpc);
1661
1709
  },
1662
1710
  async dispose() {
1663
1711
  const rpc = get(rpcId);
@@ -1665,43 +1713,362 @@ const create = rpcId => {
1665
1713
  }
1666
1714
  };
1667
1715
  };
1668
- const RendererWorker$1 = 1;
1716
+
1669
1717
  const {
1670
- invoke: invoke$3,
1671
- set: set$3} = create(RendererWorker$1);
1718
+ invoke: invoke$1,
1719
+ invokeAndTransfer,
1720
+ set: set$1,
1721
+ dispose
1722
+ } = create(RendererWorker$1);
1723
+ const searchFileHtml = async uri => {
1724
+ return invoke$1('ExtensionHost.searchFileWithHtml', uri);
1725
+ };
1726
+ const getFilePathElectron = async file => {
1727
+ return invoke$1('FileSystemHandle.getFilePathElectron', file);
1728
+ };
1672
1729
  const showContextMenu$1 = async (x, y, id, ...args) => {
1673
- return invoke$3('ContextMenu.show', x, y, id, ...args);
1730
+ return invoke$1('ContextMenu.show', x, y, id, ...args);
1731
+ };
1732
+ const getElectronVersion = async () => {
1733
+ return invoke$1('Process.getElectronVersion');
1734
+ };
1735
+ const applyBulkReplacement = async bulkEdits => {
1736
+ await invoke$1('BulkReplacement.applyBulkReplacement', bulkEdits);
1737
+ };
1738
+ const setColorTheme = async id => {
1739
+ // @ts-ignore
1740
+ return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1741
+ };
1742
+ const getNodeVersion = async () => {
1743
+ return invoke$1('Process.getNodeVersion');
1744
+ };
1745
+ const getChromeVersion = async () => {
1746
+ return invoke$1('Process.getChromeVersion');
1747
+ };
1748
+ const getV8Version = async () => {
1749
+ return invoke$1('Process.getV8Version');
1750
+ };
1751
+ const getFileHandles = async fileIds => {
1752
+ const files = await invoke$1('FileSystemHandle.getFileHandles', fileIds);
1753
+ return files;
1754
+ };
1755
+ const setWorkspacePath = async path => {
1756
+ await invoke$1('Workspace.setPath', path);
1757
+ };
1758
+ const registerWebViewInterceptor = async (id, port) => {
1759
+ await invokeAndTransfer('WebView.registerInterceptor', id, port);
1760
+ };
1761
+ const unregisterWebViewInterceptor = async id => {
1762
+ await invoke$1('WebView.unregisterInterceptor', id);
1763
+ };
1764
+ const sendMessagePortToEditorWorker = async (port, rpcId) => {
1765
+ const command = 'HandleMessagePort.handleMessagePort';
1766
+ // @ts-ignore
1767
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1768
+ };
1769
+ const sendMessagePortToErrorWorker = async (port, rpcId) => {
1770
+ const command = 'Errors.handleMessagePort';
1771
+ // @ts-ignore
1772
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
1773
+ };
1774
+ const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
1775
+ const command = 'Markdown.handleMessagePort';
1776
+ // @ts-ignore
1777
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
1778
+ };
1779
+ const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
1780
+ const command = 'FileSystem.handleMessagePort';
1781
+ // @ts-ignore
1782
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1783
+ };
1784
+ const readFile = async uri => {
1785
+ return invoke$1('FileSystem.readFile', uri);
1786
+ };
1787
+ const getWebViewSecret = async key => {
1788
+ // @ts-ignore
1789
+ return invoke$1('WebView.getSecret', key);
1674
1790
  };
1675
- const setFocus$2 = key => {
1676
- return invoke$3('Focus.setFocus', key);
1791
+ const setWebViewPort = async (uid, port, origin, portType) => {
1792
+ return invokeAndTransfer('WebView.setPort', uid, port, origin, portType);
1793
+ };
1794
+ const setFocus = key => {
1795
+ return invoke$1('Focus.setFocus', key);
1796
+ };
1797
+ const getFileIcon = async options => {
1798
+ return invoke$1('IconTheme.getFileIcon', options);
1799
+ };
1800
+ const getColorThemeNames = async () => {
1801
+ return invoke$1('ColorTheme.getColorThemeNames');
1802
+ };
1803
+ const disableExtension = async id => {
1804
+ // @ts-ignore
1805
+ return invoke$1('ExtensionManagement.disable', id);
1806
+ };
1807
+ const enableExtension = async id => {
1808
+ // @ts-ignore
1809
+ return invoke$1('ExtensionManagement.enable', id);
1810
+ };
1811
+ const handleDebugChange = async params => {
1812
+ // @ts-ignore
1813
+ return invoke$1('Run And Debug.handleChange', params);
1814
+ };
1815
+ const getFolderIcon = async options => {
1816
+ return invoke$1('IconTheme.getFolderIcon', options);
1817
+ };
1818
+ const closeWidget = async widgetId => {
1819
+ return invoke$1('Viewlet.closeWidget', widgetId);
1820
+ };
1821
+ const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1822
+ const command = 'HandleMessagePort.handleMessagePort2';
1823
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1824
+ };
1825
+ const sendMessagePortToSearchProcess = async port => {
1826
+ await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
1827
+ };
1828
+ const confirm = async (message, options) => {
1829
+ // @ts-ignore
1830
+ const result = await invoke$1('ConfirmPrompt.prompt', message, options);
1831
+ return result;
1832
+ };
1833
+ const getRecentlyOpened = async () => {
1834
+ return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
1835
+ };
1836
+ const getKeyBindings = async () => {
1837
+ return invoke$1('KeyBindingsInitial.getKeyBindings');
1838
+ };
1839
+ const writeClipBoardText = async text => {
1840
+ await invoke$1('ClipBoard.writeText', /* text */text);
1841
+ };
1842
+ const writeClipBoardImage = async blob => {
1843
+ // @ts-ignore
1844
+ await invoke$1('ClipBoard.writeImage', /* text */blob);
1845
+ };
1846
+ const searchFileMemory = async uri => {
1847
+ // @ts-ignore
1848
+ return invoke$1('ExtensionHost.searchFileWithMemory', uri);
1849
+ };
1850
+ const searchFileFetch = async uri => {
1851
+ return invoke$1('ExtensionHost.searchFileWithFetch', uri);
1852
+ };
1853
+ const showMessageBox = async options => {
1854
+ return invoke$1('ElectronDialog.showMessageBox', options);
1855
+ };
1856
+ const handleDebugResumed = async params => {
1857
+ await invoke$1('Run And Debug.handleResumed', params);
1858
+ };
1859
+ const openWidget = async name => {
1860
+ await invoke$1('Viewlet.openWidget', name);
1861
+ };
1862
+ const getIcons = async requests => {
1863
+ const icons = await invoke$1('IconTheme.getIcons', requests);
1864
+ return icons;
1865
+ };
1866
+ const activateByEvent = event => {
1867
+ return invoke$1('ExtensionHostManagement.activateByEvent', event);
1868
+ };
1869
+ const setAdditionalFocus = focusKey => {
1870
+ // @ts-ignore
1871
+ return invoke$1('Focus.setAdditionalFocus', focusKey);
1872
+ };
1873
+ const getActiveEditorId = () => {
1874
+ // @ts-ignore
1875
+ return invoke$1('GetActiveEditor.getActiveEditorId');
1876
+ };
1877
+ const getWorkspacePath = () => {
1878
+ return invoke$1('Workspace.getPath');
1879
+ };
1880
+ const sendMessagePortToRendererProcess = async port => {
1881
+ const command = 'HandleMessagePort.handleMessagePort';
1882
+ // @ts-ignore
1883
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1884
+ };
1885
+ const getPreference = async key => {
1886
+ return await invoke$1('Preferences.get', key);
1887
+ };
1888
+ const getAllExtensions$2 = async () => {
1889
+ return invoke$1('ExtensionManagement.getAllExtensions');
1890
+ };
1891
+ const rerenderEditor = async key => {
1892
+ // @ts-ignore
1893
+ return invoke$1('Editor.rerender', key);
1894
+ };
1895
+ const handleDebugPaused = async params => {
1896
+ await invoke$1('Run And Debug.handlePaused', params);
1677
1897
  };
1678
1898
  const openUri$2 = async (uri, focus, options) => {
1679
- await invoke$3('Main.openUri', uri, focus, options);
1899
+ await invoke$1('Main.openUri', uri, focus, options);
1900
+ };
1901
+ const sendMessagePortToSyntaxHighlightingWorker = async port => {
1902
+ await invokeAndTransfer(
1903
+ // @ts-ignore
1904
+ 'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
1905
+ };
1906
+ const handleDebugScriptParsed = async script => {
1907
+ await invoke$1('Run And Debug.handleScriptParsed', script);
1908
+ };
1909
+ const getWindowId = async () => {
1910
+ return invoke$1('GetWindowId.getWindowId');
1911
+ };
1912
+ const getBlob = async uri => {
1913
+ // @ts-ignore
1914
+ return invoke$1('FileSystem.getBlob', uri);
1915
+ };
1916
+ const getExtensionCommands = async () => {
1917
+ return invoke$1('ExtensionHost.getCommands');
1918
+ };
1919
+ const showErrorDialog = async errorInfo => {
1920
+ // @ts-ignore
1921
+ await invoke$1('ErrorHandling.showErrorDialog', errorInfo);
1922
+ };
1923
+ const getFolderSize = async uri => {
1924
+ // @ts-ignore
1925
+ return await invoke$1('FileSystem.getFolderSize', uri);
1926
+ };
1927
+ const getExtension = async id => {
1928
+ // @ts-ignore
1929
+ return invoke$1('ExtensionManagement.getExtension', id);
1930
+ };
1931
+ const getMarkdownDom = async html => {
1932
+ // @ts-ignore
1933
+ return invoke$1('Markdown.getVirtualDom', html);
1934
+ };
1935
+ const renderMarkdown = async (markdown, options) => {
1936
+ // @ts-ignore
1937
+ return invoke$1('Markdown.renderMarkdown', markdown, options);
1938
+ };
1939
+ const openNativeFolder = async uri => {
1940
+ // @ts-ignore
1941
+ await invoke$1('OpenNativeFolder.openNativeFolder', uri);
1942
+ };
1943
+ const uninstallExtension = async id => {
1944
+ return invoke$1('ExtensionManagement.uninstall', id);
1945
+ };
1946
+ const installExtension = async id => {
1947
+ // @ts-ignore
1948
+ return invoke$1('ExtensionManagement.install', id);
1949
+ };
1950
+ const openExtensionSearch = async () => {
1951
+ // @ts-ignore
1952
+ return invoke$1('SideBar.openViewlet', 'Extensions');
1953
+ };
1954
+ const setExtensionsSearchValue = async searchValue => {
1955
+ // @ts-ignore
1956
+ return invoke$1('Extensions.handleInput', searchValue);
1957
+ };
1958
+ const openExternal = async uri => {
1959
+ // @ts-ignore
1960
+ await invoke$1('Open.openExternal', uri);
1680
1961
  };
1681
- const RendererWorker$2 = {
1962
+ const openUrl = async uri => {
1963
+ // @ts-ignore
1964
+ await invoke$1('Open.openUrl', uri);
1965
+ };
1966
+ const getAllPreferences = async () => {
1967
+ // @ts-ignore
1968
+ return invoke$1('Preferences.getAll');
1969
+ };
1970
+ const showSaveFilePicker = async () => {
1971
+ // @ts-ignore
1972
+ return invoke$1('FilePicker.showSaveFilePicker');
1973
+ };
1974
+ const getLogsDir = async () => {
1975
+ // @ts-ignore
1976
+ return invoke$1('PlatformPaths.getLogsDir');
1977
+ };
1978
+ const registerMockRpc = commandMap => {
1979
+ const mockRpc = createMockRpc({
1980
+ commandMap
1981
+ });
1982
+ set$1(mockRpc);
1983
+ return mockRpc;
1984
+ };
1985
+
1986
+ const RendererWorker = {
1682
1987
  __proto__: null,
1683
- invoke: invoke$3,
1988
+ activateByEvent,
1989
+ applyBulkReplacement,
1990
+ closeWidget,
1991
+ confirm,
1992
+ disableExtension,
1993
+ dispose,
1994
+ enableExtension,
1995
+ getActiveEditorId,
1996
+ getAllExtensions: getAllExtensions$2,
1997
+ getAllPreferences,
1998
+ getBlob,
1999
+ getChromeVersion,
2000
+ getColorThemeNames,
2001
+ getElectronVersion,
2002
+ getExtension,
2003
+ getExtensionCommands,
2004
+ getFileHandles,
2005
+ getFileIcon,
2006
+ getFilePathElectron,
2007
+ getFolderIcon,
2008
+ getFolderSize,
2009
+ getIcons,
2010
+ getKeyBindings,
2011
+ getLogsDir,
2012
+ getMarkdownDom,
2013
+ getNodeVersion,
2014
+ getPreference,
2015
+ getRecentlyOpened,
2016
+ getV8Version,
2017
+ getWebViewSecret,
2018
+ getWindowId,
2019
+ getWorkspacePath,
2020
+ handleDebugChange,
2021
+ handleDebugPaused,
2022
+ handleDebugResumed,
2023
+ handleDebugScriptParsed,
2024
+ installExtension,
2025
+ invoke: invoke$1,
2026
+ invokeAndTransfer,
2027
+ openExtensionSearch,
2028
+ openExternal,
2029
+ openNativeFolder,
1684
2030
  openUri: openUri$2,
1685
- set: set$3,
1686
- setFocus: setFocus$2,
1687
- showContextMenu: showContextMenu$1};
2031
+ openUrl,
2032
+ openWidget,
2033
+ readFile,
2034
+ registerMockRpc,
2035
+ registerWebViewInterceptor,
2036
+ renderMarkdown,
2037
+ rerenderEditor,
2038
+ searchFileFetch,
2039
+ searchFileHtml,
2040
+ searchFileMemory,
2041
+ sendMessagePortToEditorWorker,
2042
+ sendMessagePortToErrorWorker,
2043
+ sendMessagePortToExtensionHostWorker,
2044
+ sendMessagePortToFileSystemWorker,
2045
+ sendMessagePortToMarkdownWorker,
2046
+ sendMessagePortToRendererProcess,
2047
+ sendMessagePortToSearchProcess,
2048
+ sendMessagePortToSyntaxHighlightingWorker,
2049
+ set: set$1,
2050
+ setAdditionalFocus,
2051
+ setColorTheme,
2052
+ setExtensionsSearchValue,
2053
+ setFocus,
2054
+ setWebViewPort,
2055
+ setWorkspacePath,
2056
+ showContextMenu: showContextMenu$1,
2057
+ showErrorDialog,
2058
+ showMessageBox,
2059
+ showSaveFilePicker,
2060
+ uninstallExtension,
2061
+ unregisterWebViewInterceptor,
2062
+ writeClipBoardImage,
2063
+ writeClipBoardText
2064
+ };
1688
2065
 
1689
2066
  const {
1690
2067
  invoke,
1691
2068
  set,
1692
2069
  showContextMenu,
1693
- setFocus: setFocus$1,
1694
2070
  openUri: openUri$1
1695
- } = RendererWorker$2;
1696
-
1697
- const RendererWorker = {
1698
- __proto__: null,
1699
- invoke,
1700
- openUri: openUri$1,
1701
- set,
1702
- setFocus: setFocus$1,
1703
- showContextMenu
1704
- };
2071
+ } = RendererWorker;
1705
2072
 
1706
2073
  const openUri = async uri => {
1707
2074
  return openUri$1(uri);
@@ -1719,7 +2086,7 @@ const handleClick = async (state, index) => {
1719
2086
  const partialNewState = focusIndex(state, actualIndex);
1720
2087
  const newState = {
1721
2088
  ...partialNewState,
1722
- focus: List$1
2089
+ focus: List$2
1723
2090
  };
1724
2091
  return newState;
1725
2092
  };
@@ -1731,13 +2098,6 @@ const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, headerHeight) =>
1731
2098
  return index;
1732
2099
  };
1733
2100
 
1734
- const selectIndex = (state, index) => {
1735
- return {
1736
- ...state,
1737
- focusedIndex: index
1738
- };
1739
- };
1740
-
1741
2101
  const handleClickAt = async (state, eventX, eventY) => {
1742
2102
  const {
1743
2103
  x,
@@ -1747,7 +2107,7 @@ const handleClickAt = async (state, eventX, eventY) => {
1747
2107
  headerHeight
1748
2108
  } = state;
1749
2109
  const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, headerHeight);
1750
- return selectIndex(state, index);
2110
+ return handleClick(state, index);
1751
2111
  };
1752
2112
 
1753
2113
  const handleClickCurrent = state => {
@@ -1788,13 +2148,11 @@ const handleEnable = (state, id) => {
1788
2148
  return state;
1789
2149
  };
1790
2150
 
1791
- const {
1792
- setFocus
1793
- } = RendererWorker;
1794
-
1795
2151
  const handleFocus = async state => {
1796
- await setFocus(FocusExtensions);
1797
- return state;
2152
+ return {
2153
+ ...state,
2154
+ focus: List$2
2155
+ };
1798
2156
  };
1799
2157
 
1800
2158
  // TODO show error / warning when installment fails / times out
@@ -1874,6 +2232,7 @@ const setDeltaY = (state, value) => {
1874
2232
  };
1875
2233
 
1876
2234
  const handleScrollBarClick = (state, eventY) => {
2235
+ // TODO move this to list
1877
2236
  const {
1878
2237
  y,
1879
2238
  deltaY,
@@ -1965,6 +2324,8 @@ const HandlePointerDown = 'handlePointerDown';
1965
2324
  const HandleScrollBarMove = 'handleScrollBarMove';
1966
2325
  const HandleScrollBarPointerCaptureLost = 'handleScrollBarPointerCaptureLost';
1967
2326
  const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
2327
+ const HandleTouchEnd = 'handleTouchEnd';
2328
+ const HandleTouchMove = 'handleTouchMove';
1968
2329
  const HandleTouchStart = 'handleTouchStart';
1969
2330
  const HandleWheel = 'handleWheel';
1970
2331
 
@@ -2149,6 +2510,55 @@ const openSuggest = state => {
2149
2510
  return state;
2150
2511
  };
2151
2512
 
2513
+ const Extensions$1 = 'extensions';
2514
+
2515
+ const getSelector = focus => {
2516
+ switch (focus) {
2517
+ case Input$1:
2518
+ return `[name="${Extensions$1}"]`;
2519
+ case List$2:
2520
+ return '.ListItems';
2521
+ default:
2522
+ return '';
2523
+ }
2524
+ };
2525
+ const renderFocus = newState => {
2526
+ const {
2527
+ uid,
2528
+ focus
2529
+ } = newState;
2530
+ if (!focus) {
2531
+ return [];
2532
+ }
2533
+ const selector = getSelector(focus);
2534
+ return ['Viewlet.focusSelector', uid, selector];
2535
+ };
2536
+
2537
+ const renderFocusContext = newState => {
2538
+ const {
2539
+ uid
2540
+ } = newState;
2541
+ if (newState.focus === Input$1) {
2542
+ return ['Viewlet.setFocusContext', uid, FocusExtensionsInput];
2543
+ }
2544
+ if (newState.focus === List$2) {
2545
+ return ['Viewlet.setFocusContext', uid, FocusExtensions];
2546
+ }
2547
+ return [];
2548
+ };
2549
+
2550
+ const mergeClassNames = (...classNames) => {
2551
+ return classNames.filter(Boolean).join(' ');
2552
+ };
2553
+
2554
+ const text = data => {
2555
+ return {
2556
+ type: Text,
2557
+ text: data,
2558
+ childCount: 0
2559
+ };
2560
+ };
2561
+
2152
2562
  const Actions = 'Actions';
2153
2563
  const ExtensionActions = 'ExtensionActions';
2154
2564
  const ExtensionActive = 'ExtensionActive';
@@ -2160,10 +2570,14 @@ const ExtensionListItemDetail = 'ExtensionListItemDetail';
2160
2570
  const ExtensionListItemFooter = 'ExtensionListItemFooter';
2161
2571
  const ExtensionListItemIcon = 'ExtensionListItemIcon';
2162
2572
  const ExtensionListItemName = 'ExtensionListItemName';
2573
+ const Extensions = 'Extensions';
2163
2574
  const IconButton = 'IconButton';
2575
+ const List$1 = 'List';
2164
2576
  const ListItems = 'ListItems';
2165
2577
  const MaskIcon = 'MaskIcon';
2166
2578
  const MultilineInputBox = 'MultilineInputBox';
2579
+ const ScrollBar = 'ScrollBar';
2580
+ const ScrollBarSmall = 'ScrollBarSmall';
2167
2581
  const ScrollBarThumb = 'ScrollBarThumb';
2168
2582
  const ScrollBarThumbActive = 'ScrollBarThumbActive';
2169
2583
  const SearchField = 'SearchField';
@@ -2171,29 +2585,13 @@ const SearchFieldButton = 'SearchFieldButton';
2171
2585
  const SearchFieldButtons = 'SearchFieldButtons';
2172
2586
  const SearchFieldContainer = 'SearchFieldContainer';
2173
2587
  const SearchFieldDisabled = 'SearchFieldDisabled';
2588
+ const Viewlet = 'Viewlet';
2174
2589
 
2175
2590
  const List = 'list';
2176
2591
  const ListItem = 'listitem';
2177
2592
  const None = 'none';
2178
2593
  const ToolBar = 'toolbar';
2179
2594
 
2180
- const mergeClassNames = (...classNames) => {
2181
- return classNames.filter(Boolean).join(' ');
2182
- };
2183
- const Text = 12;
2184
- const text = data => {
2185
- return {
2186
- type: Text,
2187
- text: data,
2188
- childCount: 0
2189
- };
2190
- };
2191
-
2192
- const Div = 4;
2193
- const Img = 17;
2194
- const TextArea = 62;
2195
- const Button = 1;
2196
-
2197
2595
  const getClassName$1 = enabled => {
2198
2596
  if (enabled) {
2199
2597
  return SearchFieldButton;
@@ -2229,7 +2627,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
2229
2627
  role: None,
2230
2628
  childCount: 2
2231
2629
  }, {
2232
- type: TextArea,
2630
+ type: Input,
2233
2631
  className: MultilineInputBox,
2234
2632
  spellcheck: false,
2235
2633
  autocapitalize: 'off',
@@ -2352,10 +2750,14 @@ const getExtensionsListVirtualDom = visibleExtensions => {
2352
2750
  tabIndex: 0,
2353
2751
  ariaLabel: extensions(),
2354
2752
  role: List,
2355
- oncontextmenu: HandleContextMenu,
2356
- onpointerdown: HandlePointerDown,
2357
- ontouchstart: HandleTouchStart,
2358
- onwheelpassive: HandleWheel,
2753
+ onContextmenu: HandleContextMenu,
2754
+ onContextMenu: HandleContextMenu,
2755
+ onFocus: HandleFocus,
2756
+ onPointerDown: HandlePointerDown,
2757
+ onTouchEnd: HandleTouchEnd,
2758
+ onTouchMove: HandleTouchMove,
2759
+ onTouchStart: HandleTouchStart,
2760
+ onWheel: HandleWheel,
2359
2761
  childCount: visibleExtensions.length
2360
2762
  }, ...visibleExtensions.flatMap(getExtensionListItemVirtualDom)];
2361
2763
  return dom;
@@ -2367,6 +2769,36 @@ const getExtensionsVirtualDom = visibleExtensions => {
2367
2769
  return dom;
2368
2770
  };
2369
2771
 
2772
+ const px = value => {
2773
+ return `${value}px`;
2774
+ };
2775
+ const position = (x, y) => {
2776
+ return `${x}px ${y}px`;
2777
+ };
2778
+
2779
+ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
2780
+ const shouldShowScrollbar = scrollBarHeight > 0;
2781
+ if (!shouldShowScrollbar) {
2782
+ return [];
2783
+ }
2784
+ // TODO move the dynamic css into a css adopted stylesheet
2785
+ const heightString = px(scrollBarHeight);
2786
+ const translateString = position(0, scrollBarTop);
2787
+ return [{
2788
+ type: Div,
2789
+ className: mergeClassNames(ScrollBar, ScrollBarSmall),
2790
+ onPointerDown: HandleScrollBarPointerDown,
2791
+ // TODO support pointercapture event
2792
+ childCount: 1
2793
+ }, {
2794
+ type: Div,
2795
+ className: ScrollBarThumb,
2796
+ childCount: 0,
2797
+ height: heightString,
2798
+ translate: translateString
2799
+ }];
2800
+ };
2801
+
2370
2802
  const getVisibleItem = (item, setSize, itemHeight, minLineY, relative, i, focusedIndex) => {
2371
2803
  // TODO use normal parameters
2372
2804
  const {
@@ -2408,28 +2840,50 @@ const getVisible = state => {
2408
2840
  return visible;
2409
2841
  };
2410
2842
 
2411
- const renderItems = newState => {
2412
- // TODO render extensions incrementally when scrolling
2413
- const visibleExtensions = getVisible(newState);
2414
- const dom = getExtensionsVirtualDom(visibleExtensions);
2415
- return ['setExtensionsDom', dom];
2843
+ const getContentVirtualDom = (visibleExtensions, message, scrollBarHeight, scrollBarY) => {
2844
+ if (message) {
2845
+ return [{
2846
+ type: Div,
2847
+ childCount: 1
2848
+ }, text(message)];
2849
+ }
2850
+ return [{
2851
+ type: Div,
2852
+ className: mergeClassNames(Viewlet, List$1),
2853
+ childCount: 2
2854
+ }, ...getExtensionsVirtualDom(visibleExtensions), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarY)];
2855
+ };
2856
+ const getExtensionsViewVirtualDom = state => {
2857
+ const visibleExtensions = getVisible(state);
2858
+ const {
2859
+ placeholder,
2860
+ inputActions,
2861
+ message,
2862
+ scrollBarHeight,
2863
+ scrollBarY
2864
+ } = state;
2865
+ return [{
2866
+ type: Div,
2867
+ className: mergeClassNames(Viewlet, Extensions),
2868
+ childCount: 2,
2869
+ ariaLive: 'polite',
2870
+ ariaBusy: false,
2871
+ role: None$1
2872
+ }, ...getExtensionHeaderVirtualDom(placeholder, inputActions), ...getContentVirtualDom(visibleExtensions, message, scrollBarHeight, scrollBarY)];
2873
+ };
2874
+
2875
+ const renderItems2 = newState => {
2876
+ const dom = getExtensionsViewVirtualDom(newState);
2877
+ return ['Viewlet.setDom2', newState.uid, dom];
2416
2878
  };
2417
2879
 
2418
2880
  const SetMessage = 'setMessage';
2419
2881
  const SetScrollBar = 'setScrollBar';
2420
- const SetSearchValue = 'setSearchValue';
2421
2882
 
2422
2883
  const renderMessage = newState => {
2423
2884
  return [/* method */SetMessage, /* message */newState.message];
2424
2885
  };
2425
2886
 
2426
- const px = value => {
2427
- return `${value}px`;
2428
- };
2429
- const position = (x, y) => {
2430
- return `${x}px ${y}px`;
2431
- };
2432
-
2433
2887
  const renderScrollBar = newState => {
2434
2888
  const listHeight = getListHeight(newState.items.length, newState.itemHeight, newState.height);
2435
2889
  const total = newState.items.length;
@@ -2447,13 +2901,13 @@ const renderScrollBar = newState => {
2447
2901
  };
2448
2902
 
2449
2903
  const renderSearchValue = newState => {
2450
- return [/* method */SetSearchValue, '', newState.searchValue];
2904
+ return [/* method */'Viewlet.setValueByName', newState.uid, Extensions$1, newState.searchValue];
2451
2905
  };
2452
2906
 
2453
2907
  const getRenderer = diffType => {
2454
2908
  switch (diffType) {
2455
2909
  case RenderItems:
2456
- return renderItems;
2910
+ return renderItems2;
2457
2911
  case RenderMessage:
2458
2912
  return renderMessage;
2459
2913
  case RenderScrollBar:
@@ -2462,6 +2916,10 @@ const getRenderer = diffType => {
2462
2916
  return renderSearchValue;
2463
2917
  case RenderHeader:
2464
2918
  return renderHeader;
2919
+ case RenderFocus:
2920
+ return renderFocus;
2921
+ case RenderFocusContext:
2922
+ return renderFocusContext;
2465
2923
  default:
2466
2924
  throw new Error('unknown renderer');
2467
2925
  }
@@ -2471,7 +2929,7 @@ const applyRender = (oldState, newState, diffResult) => {
2471
2929
  const commands = [];
2472
2930
  for (const item of diffResult) {
2473
2931
  const fn = getRenderer(item);
2474
- commands.push(fn(newState));
2932
+ commands.push(fn(newState, oldState));
2475
2933
  }
2476
2934
  return commands;
2477
2935
  };
@@ -2481,7 +2939,7 @@ const render3 = (uid, diffResult) => {
2481
2939
  oldState,
2482
2940
  newState
2483
2941
  } = get$1(uid);
2484
- set$1(uid, newState, newState);
2942
+ set$3(uid, newState, newState);
2485
2943
  const commands = applyRender(oldState, newState, diffResult);
2486
2944
  return commands;
2487
2945
  };
@@ -2580,14 +3038,11 @@ const renderEventListeners = () => {
2580
3038
  }];
2581
3039
  };
2582
3040
 
2583
- const saveState = uid => {
2584
- const {
2585
- newState
2586
- } = get$1(uid);
3041
+ const saveState = state => {
2587
3042
  const {
2588
3043
  searchValue,
2589
3044
  deltaY
2590
- } = newState;
3045
+ } = state;
2591
3046
  return {
2592
3047
  searchValue,
2593
3048
  deltaY
@@ -2603,6 +3058,13 @@ const scrollDown = state => {
2603
3058
  return setDeltaY(state, newDeltaY);
2604
3059
  };
2605
3060
 
3061
+ const selectIndex = (state, index) => {
3062
+ return {
3063
+ ...state,
3064
+ focusedIndex: index
3065
+ };
3066
+ };
3067
+
2606
3068
  const toggleSuggest = state => {
2607
3069
  return state;
2608
3070
  };
@@ -2612,7 +3074,7 @@ const commandMap = {
2612
3074
  'SearchExtensions.closeSuggest': wrapCommand(closeSuggest),
2613
3075
  'SearchExtensions.create': create$1,
2614
3076
  'SearchExtensions.diff2': diff2,
2615
- 'SearchExtensions.dispose': dispose,
3077
+ 'SearchExtensions.dispose': dispose$1,
2616
3078
  'SearchExtensions.focusFirst': wrapCommand(focusFirst),
2617
3079
  'SearchExtensions.focusIndex': wrapCommand(focusIndex),
2618
3080
  'SearchExtensions.focusLast': wrapCommand(focusLast),
@@ -2622,7 +3084,7 @@ const commandMap = {
2622
3084
  'SearchExtensions.focusPrevious': wrapCommand(focusPrevious),
2623
3085
  'SearchExtensions.getActions': getActions,
2624
3086
  'SearchExtensions.getCommandIds': getCommandIds,
2625
- 'SearchExtensions.getKeyBindings': getKeyBindings,
3087
+ 'SearchExtensions.getKeyBindings': getKeyBindings$1,
2626
3088
  'SearchExtensions.getMenuEntries': getMenuEntries,
2627
3089
  'SearchExtensions.handleBlur': wrapCommand(handleBlur),
2628
3090
  'SearchExtensions.handleClick': wrapCommand(handleClick),
@@ -2647,7 +3109,7 @@ const commandMap = {
2647
3109
  'SearchExtensions.renderActions': renderActions,
2648
3110
  'SearchExtensions.renderEventListeners': renderEventListeners,
2649
3111
  'SearchExtensions.restoreState': restoreState,
2650
- 'SearchExtensions.saveState': saveState,
3112
+ 'SearchExtensions.saveState': wrapGetter(saveState),
2651
3113
  'SearchExtensions.scrollDown': wrapCommand(scrollDown),
2652
3114
  'SearchExtensions.searchExtensions': searchExtensions,
2653
3115
  'SearchExtensions.selectIndex': wrapCommand(selectIndex),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "3.9.0",
3
+ "version": "4.1.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",