@lvce-editor/extension-search-view 2.0.0 → 2.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.
@@ -905,6 +905,13 @@ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
905
905
  return Math.ceil(listHeight / itemHeight) + 1;
906
906
  };
907
907
 
908
+ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
909
+ if (size >= contentSize) {
910
+ return 0;
911
+ }
912
+ return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
913
+ };
914
+
908
915
  const Web = 1;
909
916
  const Electron = 2;
910
917
  const Remote = 3;
@@ -935,19 +942,6 @@ const getPlatform = () => {
935
942
  };
936
943
  const platform = getPlatform();
937
944
 
938
- const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
939
- if (size >= contentSize) {
940
- return 0;
941
- }
942
- return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
943
- };
944
-
945
- const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
946
- const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
947
- return scrollBarOffset;
948
- };
949
- const getScrollBarY = getScrollBarOffset;
950
-
951
945
  const Installed = '@installed';
952
946
  const Enabled = '@enabled';
953
947
  const Disabled = '@disabled';
@@ -998,7 +992,7 @@ const parseValue = value => {
998
992
 
999
993
  const assetDir = '';
1000
994
 
1001
- const getRemoteUrl = (extension, platform$1) => {
995
+ const getRemoteUrl = (extension, platform) => {
1002
996
  if (platform === Remote || platform === Electron) {
1003
997
  if (extension.builtin) {
1004
998
  return `${assetDir}/extensions/${extension.id}/${extension.icon}`;
@@ -1031,21 +1025,7 @@ const getIcon = (extension, platform) => {
1031
1025
  }
1032
1026
  return ExtensionDefaultIcon;
1033
1027
  }
1034
- return getRemoteUrl(extension);
1035
- };
1036
- const RE_PUBLISHER = /^[a-z\d-]+/;
1037
-
1038
- // TODO handle case when extension is of type number|array|null|string
1039
- const getPublisher = extension => {
1040
- if (!extension || !extension.id) {
1041
- return 'n/a';
1042
- }
1043
- // TODO handle case when id is not of type string -> should not crash application
1044
- const match = extension.id.match(RE_PUBLISHER);
1045
- if (!match) {
1046
- return 'n/a';
1047
- }
1048
- return match[0];
1028
+ return getRemoteUrl(extension, platform);
1049
1029
  };
1050
1030
  const getName = extension => {
1051
1031
  if (extension && extension.name) {
@@ -1069,6 +1049,21 @@ const getId = extension => {
1069
1049
  return extension.id;
1070
1050
  };
1071
1051
 
1052
+ const RE_PUBLISHER = /^[a-z\d-]+/;
1053
+
1054
+ // TODO handle case when extension is of type number|array|null|string
1055
+ const getPublisher = extension => {
1056
+ if (!extension || !extension.id) {
1057
+ return 'n/a';
1058
+ }
1059
+ // TODO handle case when id is not of type string -> should not crash application
1060
+ const match = extension.id.match(RE_PUBLISHER);
1061
+ if (!match) {
1062
+ return 'n/a';
1063
+ }
1064
+ return match[0];
1065
+ };
1066
+
1072
1067
  const matchesParsedValue = (extension, parsedValue) => {
1073
1068
  if (extension && typeof extension.name === 'string') {
1074
1069
  const extensionNameLower = extension.name.toLowerCase();
@@ -1101,7 +1096,7 @@ const getExtensions = async (extensions, parsedValue, platform) => {
1101
1096
  name: getName(extension),
1102
1097
  id: getId(extension),
1103
1098
  publisher: getPublisher(extension),
1104
- icon: getIcon(extension),
1099
+ icon: getIcon(extension, platform),
1105
1100
  description: getDescription(extension)
1106
1101
  });
1107
1102
  }
@@ -1445,6 +1440,7 @@ const getVisibleItem = (item, setSize, itemHeight, minLineY, relative, i, focuse
1445
1440
  focused: i === focusedIndex
1446
1441
  };
1447
1442
  };
1443
+
1448
1444
  const getVisible = state => {
1449
1445
  const {
1450
1446
  minLineY,
@@ -1478,6 +1474,12 @@ const SetMessage = 'setMessage';
1478
1474
  const SetScrollBar = 'setScrollBar';
1479
1475
  const SetSearchValue = 'setSearchValue';
1480
1476
 
1477
+ const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
1478
+ const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
1479
+ return scrollBarOffset;
1480
+ };
1481
+ const getScrollBarY = getScrollBarOffset;
1482
+
1481
1483
  const getListHeight = state => {
1482
1484
  const {
1483
1485
  height,
@@ -1563,11 +1565,21 @@ const doRender = (oldState, newState) => {
1563
1565
  return commands;
1564
1566
  };
1565
1567
 
1568
+ const saveState = state => {
1569
+ const {
1570
+ searchValue
1571
+ } = state;
1572
+ return {
1573
+ searchValue
1574
+ };
1575
+ };
1576
+
1566
1577
  const commandMap = {
1567
1578
  'SearchExtensions.clearSearchResults': clearSearchResults,
1568
1579
  'SearchExtensions.getKeyBindings': getKeyBindings,
1569
1580
  'SearchExtensions.render': doRender,
1570
- 'SearchExtensions.searchExtensions': searchExtensions
1581
+ 'SearchExtensions.searchExtensions': searchExtensions,
1582
+ 'SearchExtensions.saveState': saveState
1571
1583
  };
1572
1584
 
1573
1585
  const RendererWorker = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",