@lvce-editor/extension-search-view 3.8.0 → 3.9.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.
|
@@ -1008,6 +1008,10 @@ const viewsAndMoreActions = () => {
|
|
|
1008
1008
|
return i18nString(ViewsAndMoreActions);
|
|
1009
1009
|
};
|
|
1010
1010
|
|
|
1011
|
+
const None$2 = 0;
|
|
1012
|
+
const Input = 1;
|
|
1013
|
+
const List$1 = 2;
|
|
1014
|
+
|
|
1011
1015
|
const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
1012
1016
|
const contentHeight = itemsLength * itemHeight;
|
|
1013
1017
|
const finalDeltaY = Math.max(contentHeight - height, 0);
|
|
@@ -1039,6 +1043,12 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
|
1039
1043
|
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
1040
1044
|
};
|
|
1041
1045
|
|
|
1046
|
+
const getScrollBarOffset$1 = (delta, finalDelta, size, scrollBarSize) => {
|
|
1047
|
+
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
1048
|
+
return scrollBarOffset;
|
|
1049
|
+
};
|
|
1050
|
+
const getScrollBarY$1 = getScrollBarOffset$1;
|
|
1051
|
+
|
|
1042
1052
|
const Installed = '@installed';
|
|
1043
1053
|
const Enabled = '@enabled';
|
|
1044
1054
|
const Disabled = '@disabled';
|
|
@@ -1159,7 +1169,8 @@ const handleInput = async (state, value) => {
|
|
|
1159
1169
|
minimumSliderSize,
|
|
1160
1170
|
height,
|
|
1161
1171
|
platform,
|
|
1162
|
-
assetDir
|
|
1172
|
+
assetDir,
|
|
1173
|
+
headerHeight
|
|
1163
1174
|
} = state;
|
|
1164
1175
|
// TODO cancel ongoing requests
|
|
1165
1176
|
// TODO handle errors
|
|
@@ -1167,16 +1178,17 @@ const handleInput = async (state, value) => {
|
|
|
1167
1178
|
if (items.length === 0) {
|
|
1168
1179
|
return {
|
|
1169
1180
|
...state,
|
|
1170
|
-
items,
|
|
1171
|
-
minLineY: 0,
|
|
1172
|
-
deltaY: 0,
|
|
1173
1181
|
allExtensions,
|
|
1174
|
-
|
|
1175
|
-
scrollBarHeight: 0,
|
|
1182
|
+
deltaY: 0,
|
|
1176
1183
|
finalDeltaY: 0,
|
|
1184
|
+
focus: Input,
|
|
1185
|
+
items,
|
|
1186
|
+
maxLineY: 0,
|
|
1177
1187
|
message: noExtensionsFound(),
|
|
1178
|
-
|
|
1179
|
-
placeholder: searchExtensionsInMarketPlace()
|
|
1188
|
+
minLineY: 0,
|
|
1189
|
+
placeholder: searchExtensionsInMarketPlace(),
|
|
1190
|
+
scrollBarHeight: 0,
|
|
1191
|
+
searchValue: value
|
|
1180
1192
|
};
|
|
1181
1193
|
}
|
|
1182
1194
|
const total = items.length;
|
|
@@ -1186,18 +1198,20 @@ const handleInput = async (state, value) => {
|
|
|
1186
1198
|
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
1187
1199
|
const maxLineY = Math.min(numberOfVisible, total);
|
|
1188
1200
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
1201
|
+
const scrollBarY = getScrollBarY$1(0, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
1189
1202
|
return {
|
|
1190
1203
|
...state,
|
|
1191
|
-
items,
|
|
1192
|
-
minLineY: 0,
|
|
1193
|
-
deltaY: 0,
|
|
1194
1204
|
allExtensions,
|
|
1195
|
-
|
|
1196
|
-
scrollBarHeight,
|
|
1205
|
+
deltaY: 0,
|
|
1197
1206
|
finalDeltaY,
|
|
1207
|
+
items,
|
|
1208
|
+
maxLineY,
|
|
1198
1209
|
message: '',
|
|
1199
|
-
|
|
1200
|
-
placeholder: searchExtensionsInMarketPlace()
|
|
1210
|
+
minLineY: 0,
|
|
1211
|
+
placeholder: searchExtensionsInMarketPlace(),
|
|
1212
|
+
scrollBarHeight,
|
|
1213
|
+
scrollBarY,
|
|
1214
|
+
searchValue: value
|
|
1201
1215
|
};
|
|
1202
1216
|
|
|
1203
1217
|
// TODO handle out of order responses (a bit complicated)
|
|
@@ -1234,10 +1248,14 @@ const create$1 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1234
1248
|
assetDir,
|
|
1235
1249
|
deltaY: 0,
|
|
1236
1250
|
finalDeltaY: 0,
|
|
1251
|
+
focus: 0,
|
|
1252
|
+
focused: false,
|
|
1237
1253
|
focusedIndex: 0,
|
|
1238
1254
|
handleOffset: 0,
|
|
1239
1255
|
headerHeight: 41,
|
|
1240
1256
|
height,
|
|
1257
|
+
inputActions: [],
|
|
1258
|
+
inputSource: 0,
|
|
1241
1259
|
itemHeight: 72,
|
|
1242
1260
|
items: [],
|
|
1243
1261
|
maxLineY: 0,
|
|
@@ -1249,44 +1267,33 @@ const create$1 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1249
1267
|
platform,
|
|
1250
1268
|
scrollBarActive: false,
|
|
1251
1269
|
scrollBarHeight: 0,
|
|
1270
|
+
scrollBarY: 0,
|
|
1252
1271
|
searchValue: '',
|
|
1253
1272
|
size: 0,
|
|
1273
|
+
uid: id,
|
|
1254
1274
|
width,
|
|
1255
1275
|
x,
|
|
1256
|
-
y
|
|
1257
|
-
focused: false,
|
|
1258
|
-
inputSource: 0
|
|
1276
|
+
y
|
|
1259
1277
|
};
|
|
1260
1278
|
set$1(id, state, state);
|
|
1261
1279
|
};
|
|
1262
1280
|
|
|
1263
|
-
const RenderHeader = 1;
|
|
1264
|
-
const RenderItems = 4;
|
|
1265
|
-
const RenderScrollBar = 5;
|
|
1266
|
-
const RenderMessage = 6;
|
|
1267
|
-
const RenderSearchValue = 7;
|
|
1268
|
-
|
|
1269
|
-
const diffType$5 = RenderItems;
|
|
1270
1281
|
const isEqual$5 = (oldState, newState) => {
|
|
1271
1282
|
return true;
|
|
1272
1283
|
};
|
|
1273
1284
|
|
|
1274
|
-
const diffType$4 = RenderHeader;
|
|
1275
1285
|
const isEqual$4 = (oldState, newState) => {
|
|
1276
1286
|
return oldState.placeholder === newState.placeholder;
|
|
1277
1287
|
};
|
|
1278
1288
|
|
|
1279
|
-
const diffType$3 = RenderItems;
|
|
1280
1289
|
const isEqual$3 = (oldState, newState) => {
|
|
1281
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.focusedIndex === newState.focusedIndex;
|
|
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;
|
|
1282
1291
|
};
|
|
1283
1292
|
|
|
1284
|
-
const diffType$2 = RenderMessage;
|
|
1285
1293
|
const isEqual$2 = (oldState, newState) => {
|
|
1286
1294
|
return oldState.message === newState.message;
|
|
1287
1295
|
};
|
|
1288
1296
|
|
|
1289
|
-
const diffType$1 = RenderScrollBar;
|
|
1290
1297
|
const isEqual$1 = (oldState, newState) => {
|
|
1291
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;
|
|
1292
1299
|
};
|
|
@@ -1294,13 +1301,19 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1294
1301
|
const User = 1;
|
|
1295
1302
|
const Script = 2;
|
|
1296
1303
|
|
|
1297
|
-
const diffType = RenderSearchValue;
|
|
1298
1304
|
const isEqual = (oldState, newState) => {
|
|
1299
1305
|
return newState.inputSource === User || oldState.searchValue === newState.searchValue;
|
|
1300
1306
|
};
|
|
1301
1307
|
|
|
1308
|
+
const RenderHeader = 1;
|
|
1309
|
+
const RenderFocus = 2;
|
|
1310
|
+
const RenderItems = 4;
|
|
1311
|
+
const RenderScrollBar = 5;
|
|
1312
|
+
const RenderMessage = 6;
|
|
1313
|
+
const RenderSearchValue = 7;
|
|
1314
|
+
|
|
1302
1315
|
const modules = [isEqual$1, isEqual$2, isEqual$4, isEqual$3, isEqual$5, isEqual];
|
|
1303
|
-
const numbers = [
|
|
1316
|
+
const numbers = [RenderScrollBar, RenderMessage, RenderHeader, RenderItems, RenderFocus, RenderSearchValue];
|
|
1304
1317
|
|
|
1305
1318
|
const diff2 = uid => {
|
|
1306
1319
|
const {
|
|
@@ -1327,32 +1340,53 @@ const dispose = uid => {
|
|
|
1327
1340
|
const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
1328
1341
|
return Math.ceil(listHeight / itemHeight) + 1;
|
|
1329
1342
|
};
|
|
1343
|
+
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
1344
|
+
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
1345
|
+
return scrollBarOffset;
|
|
1346
|
+
};
|
|
1347
|
+
const getScrollBarY = getScrollBarOffset;
|
|
1330
1348
|
const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
1349
|
+
const {
|
|
1350
|
+
finalDeltaY,
|
|
1351
|
+
height,
|
|
1352
|
+
headerHeight,
|
|
1353
|
+
scrollBarHeight
|
|
1354
|
+
} = state;
|
|
1331
1355
|
const newMaxLineY = Math.min(index + 1, itemsLength);
|
|
1332
1356
|
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1333
1357
|
const newMinLineY = Math.max(newMaxLineY - fittingItems, 0);
|
|
1334
1358
|
const newDeltaY = itemsLength < fittingItems ? 0 : newMinLineY * itemHeight - listHeight % itemHeight + itemHeight;
|
|
1359
|
+
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
1335
1360
|
return {
|
|
1336
1361
|
...state,
|
|
1337
1362
|
focusedIndex: index,
|
|
1338
1363
|
minLineY: newMinLineY,
|
|
1339
1364
|
maxLineY: newMaxLineY,
|
|
1340
1365
|
focused: true,
|
|
1341
|
-
deltaY: newDeltaY
|
|
1366
|
+
deltaY: newDeltaY,
|
|
1367
|
+
scrollBarY
|
|
1342
1368
|
};
|
|
1343
1369
|
};
|
|
1344
1370
|
const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
1371
|
+
const {
|
|
1372
|
+
finalDeltaY,
|
|
1373
|
+
height,
|
|
1374
|
+
headerHeight,
|
|
1375
|
+
scrollBarHeight
|
|
1376
|
+
} = state;
|
|
1345
1377
|
const newMinLineY = index;
|
|
1346
1378
|
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1347
1379
|
const newMaxLineY = Math.min(newMinLineY + fittingItems, itemsLength);
|
|
1348
1380
|
const newDeltaY = newMinLineY * itemHeight;
|
|
1381
|
+
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
1349
1382
|
return {
|
|
1350
1383
|
...state,
|
|
1351
1384
|
focusedIndex: index,
|
|
1352
1385
|
minLineY: newMinLineY,
|
|
1353
1386
|
maxLineY: newMaxLineY,
|
|
1354
1387
|
focused: true,
|
|
1355
|
-
deltaY: newDeltaY
|
|
1388
|
+
deltaY: newDeltaY,
|
|
1389
|
+
scrollBarY
|
|
1356
1390
|
};
|
|
1357
1391
|
};
|
|
1358
1392
|
const focusIndex = (state, index) => {
|
|
@@ -1487,10 +1521,16 @@ const getActions = () => {
|
|
|
1487
1521
|
}];
|
|
1488
1522
|
};
|
|
1489
1523
|
|
|
1490
|
-
const
|
|
1524
|
+
const commandMapRef = {};
|
|
1491
1525
|
|
|
1526
|
+
const toCommandId = key => {
|
|
1527
|
+
const dotIndex = key.indexOf('.');
|
|
1528
|
+
return key.slice(dotIndex + 1);
|
|
1529
|
+
};
|
|
1492
1530
|
const getCommandIds = () => {
|
|
1493
|
-
|
|
1531
|
+
const keys = Object.keys(commandMapRef);
|
|
1532
|
+
const ids = keys.map(toCommandId);
|
|
1533
|
+
return ids;
|
|
1494
1534
|
};
|
|
1495
1535
|
|
|
1496
1536
|
const Enter = 3;
|
|
@@ -1582,7 +1622,14 @@ const getMenuEntries = () => {
|
|
|
1582
1622
|
};
|
|
1583
1623
|
|
|
1584
1624
|
const handleBlur = state => {
|
|
1585
|
-
return
|
|
1625
|
+
return {
|
|
1626
|
+
...state,
|
|
1627
|
+
focus: None$2
|
|
1628
|
+
};
|
|
1629
|
+
};
|
|
1630
|
+
|
|
1631
|
+
const getExtensionDetailUri = extensionId => {
|
|
1632
|
+
return `extension-detail://${extensionId}`;
|
|
1586
1633
|
};
|
|
1587
1634
|
|
|
1588
1635
|
const rpcs = Object.create(null);
|
|
@@ -1667,13 +1714,19 @@ const handleClick = async (state, index) => {
|
|
|
1667
1714
|
} = state;
|
|
1668
1715
|
const actualIndex = index + minLineY;
|
|
1669
1716
|
const extension = items[actualIndex];
|
|
1670
|
-
const uri =
|
|
1717
|
+
const uri = getExtensionDetailUri(extension.id);
|
|
1671
1718
|
await openUri(uri);
|
|
1672
|
-
|
|
1719
|
+
const partialNewState = focusIndex(state, actualIndex);
|
|
1720
|
+
const newState = {
|
|
1721
|
+
...partialNewState,
|
|
1722
|
+
focus: List$1
|
|
1723
|
+
};
|
|
1724
|
+
return newState;
|
|
1673
1725
|
};
|
|
1674
1726
|
|
|
1675
|
-
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
|
|
1676
|
-
const
|
|
1727
|
+
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, headerHeight) => {
|
|
1728
|
+
const relativeDeltaY = deltaY % itemHeight;
|
|
1729
|
+
const relativeY = eventY - y - headerHeight + relativeDeltaY;
|
|
1677
1730
|
const index = Math.floor(relativeY / itemHeight);
|
|
1678
1731
|
return index;
|
|
1679
1732
|
};
|
|
@@ -1690,9 +1743,10 @@ const handleClickAt = async (state, eventX, eventY) => {
|
|
|
1690
1743
|
x,
|
|
1691
1744
|
y,
|
|
1692
1745
|
itemHeight,
|
|
1693
|
-
deltaY
|
|
1746
|
+
deltaY,
|
|
1747
|
+
headerHeight
|
|
1694
1748
|
} = state;
|
|
1695
|
-
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight);
|
|
1749
|
+
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, headerHeight);
|
|
1696
1750
|
return selectIndex(state, index);
|
|
1697
1751
|
};
|
|
1698
1752
|
|
|
@@ -1779,12 +1833,6 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
1779
1833
|
};
|
|
1780
1834
|
};
|
|
1781
1835
|
|
|
1782
|
-
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
1783
|
-
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
1784
|
-
return scrollBarOffset;
|
|
1785
|
-
};
|
|
1786
|
-
const getScrollBarY = getScrollBarOffset;
|
|
1787
|
-
|
|
1788
1836
|
const clamp = (num, min, max) => {
|
|
1789
1837
|
number(num);
|
|
1790
1838
|
number(min);
|
|
@@ -1800,7 +1848,9 @@ const setDeltaY = (state, value) => {
|
|
|
1800
1848
|
finalDeltaY,
|
|
1801
1849
|
deltaY,
|
|
1802
1850
|
height,
|
|
1803
|
-
headerHeight
|
|
1851
|
+
headerHeight,
|
|
1852
|
+
items,
|
|
1853
|
+
minimumSliderSize
|
|
1804
1854
|
} = state;
|
|
1805
1855
|
const listHeight = height - headerHeight;
|
|
1806
1856
|
const newDeltaY = clamp(value, 0, finalDeltaY);
|
|
@@ -1810,11 +1860,16 @@ const setDeltaY = (state, value) => {
|
|
|
1810
1860
|
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
1811
1861
|
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
1812
1862
|
const maxLineY = minLineY + getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
1863
|
+
const total = items.length;
|
|
1864
|
+
const contentHeight = total * itemHeight;
|
|
1865
|
+
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
|
|
1866
|
+
const scrollBarY = getScrollBarY$1(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
1813
1867
|
return {
|
|
1814
1868
|
...state,
|
|
1815
1869
|
deltaY: newDeltaY,
|
|
1816
1870
|
minLineY,
|
|
1817
|
-
maxLineY
|
|
1871
|
+
maxLineY,
|
|
1872
|
+
scrollBarY
|
|
1818
1873
|
};
|
|
1819
1874
|
};
|
|
1820
1875
|
|
|
@@ -1829,7 +1884,7 @@ const handleScrollBarClick = (state, eventY) => {
|
|
|
1829
1884
|
} = state;
|
|
1830
1885
|
const contentHeight = height - headerHeight;
|
|
1831
1886
|
const relativeY = eventY - y - headerHeight;
|
|
1832
|
-
const currentScrollBarY = getScrollBarY(deltaY, finalDeltaY, contentHeight, scrollBarHeight);
|
|
1887
|
+
const currentScrollBarY = getScrollBarY$1(deltaY, finalDeltaY, contentHeight, scrollBarHeight);
|
|
1833
1888
|
const diff = relativeY - currentScrollBarY;
|
|
1834
1889
|
if (diff >= 0 && diff < scrollBarHeight) {
|
|
1835
1890
|
return {
|
|
@@ -1901,6 +1956,36 @@ const getAllExtensions = platform => {
|
|
|
1901
1956
|
return getAllExtensions$1(platform);
|
|
1902
1957
|
};
|
|
1903
1958
|
|
|
1959
|
+
const HandleClearSearchResults = 'handleClearSearchResults';
|
|
1960
|
+
const HandleClickFilter = 'handleClickFilter';
|
|
1961
|
+
const HandleContextMenu = 'handleContextMenu';
|
|
1962
|
+
const HandleExtensionsInput = 'handleExtensionsInput';
|
|
1963
|
+
const HandleFocus = 'handleFocus';
|
|
1964
|
+
const HandlePointerDown = 'handlePointerDown';
|
|
1965
|
+
const HandleScrollBarMove = 'handleScrollBarMove';
|
|
1966
|
+
const HandleScrollBarPointerCaptureLost = 'handleScrollBarPointerCaptureLost';
|
|
1967
|
+
const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
|
|
1968
|
+
const HandleTouchStart = 'handleTouchStart';
|
|
1969
|
+
const HandleWheel = 'handleWheel';
|
|
1970
|
+
|
|
1971
|
+
const getInputActions = newState => {
|
|
1972
|
+
const clearEnabled = newState.searchValue.length > 0;
|
|
1973
|
+
const actions = [{
|
|
1974
|
+
onClick: HandleClearSearchResults,
|
|
1975
|
+
icon: `MaskIcon${ClearAll}`,
|
|
1976
|
+
title: clearExtensionSearchResults(),
|
|
1977
|
+
type: Button$1,
|
|
1978
|
+
enabled: clearEnabled
|
|
1979
|
+
}, {
|
|
1980
|
+
icon: `MaskIcon${Filter}`,
|
|
1981
|
+
title: filter(),
|
|
1982
|
+
type: Button$1,
|
|
1983
|
+
onClick: HandleClickFilter,
|
|
1984
|
+
enabled: true
|
|
1985
|
+
}];
|
|
1986
|
+
return actions;
|
|
1987
|
+
};
|
|
1988
|
+
|
|
1904
1989
|
const Small = 1;
|
|
1905
1990
|
const Normal = 2;
|
|
1906
1991
|
const Large = 3;
|
|
@@ -2018,37 +2103,46 @@ const getSavedValue = savedState => {
|
|
|
2018
2103
|
}
|
|
2019
2104
|
return '';
|
|
2020
2105
|
};
|
|
2106
|
+
const getSavedDeltaY = savedState => {
|
|
2107
|
+
if (savedState && typeof savedState === 'object' && 'deltaY' in savedState && typeof savedState.deltaY === 'number' && !Number.isNaN(savedState.deltaY)) {
|
|
2108
|
+
return savedState.deltaY;
|
|
2109
|
+
}
|
|
2110
|
+
return 0;
|
|
2111
|
+
};
|
|
2021
2112
|
|
|
2022
2113
|
const restoreState = savedState => {
|
|
2023
2114
|
const searchValue = getSavedValue(savedState);
|
|
2115
|
+
const savedDeltaY = getSavedDeltaY(savedState);
|
|
2024
2116
|
return {
|
|
2025
|
-
searchValue
|
|
2117
|
+
searchValue,
|
|
2118
|
+
deltaY: savedDeltaY
|
|
2026
2119
|
};
|
|
2027
2120
|
};
|
|
2028
2121
|
|
|
2029
|
-
const loadContent = async (
|
|
2030
|
-
const {
|
|
2031
|
-
newState
|
|
2032
|
-
} = get$1(uid);
|
|
2122
|
+
const loadContent = async (state, savedState) => {
|
|
2033
2123
|
const {
|
|
2034
2124
|
width,
|
|
2035
2125
|
platform,
|
|
2036
2126
|
assetDir
|
|
2037
|
-
} =
|
|
2127
|
+
} = state;
|
|
2038
2128
|
const {
|
|
2039
|
-
searchValue
|
|
2129
|
+
searchValue,
|
|
2130
|
+
deltaY
|
|
2040
2131
|
} = restoreState(savedState);
|
|
2041
2132
|
// TODO just get local extensions on demand (not when query string is already different)
|
|
2042
2133
|
const allExtensions = await getAllExtensions(platform);
|
|
2043
2134
|
const size = getViewletSize(width);
|
|
2044
2135
|
const normalized = normalizeExtension(allExtensions, platform, assetDir);
|
|
2136
|
+
const inputActions = getInputActions(state);
|
|
2045
2137
|
const updatedState = await handleInput({
|
|
2046
|
-
...
|
|
2138
|
+
...state,
|
|
2047
2139
|
allExtensions: normalized,
|
|
2048
2140
|
size,
|
|
2049
|
-
inputSource: Script
|
|
2141
|
+
inputSource: Script,
|
|
2142
|
+
inputActions,
|
|
2143
|
+
deltaY
|
|
2050
2144
|
}, searchValue);
|
|
2051
|
-
|
|
2145
|
+
return updatedState;
|
|
2052
2146
|
};
|
|
2053
2147
|
|
|
2054
2148
|
const openSuggest = state => {
|
|
@@ -2078,14 +2172,6 @@ const SearchFieldButtons = 'SearchFieldButtons';
|
|
|
2078
2172
|
const SearchFieldContainer = 'SearchFieldContainer';
|
|
2079
2173
|
const SearchFieldDisabled = 'SearchFieldDisabled';
|
|
2080
2174
|
|
|
2081
|
-
const HandleContextMenu = 'handleContextMenu';
|
|
2082
|
-
const HandlePointerDown = 'handlePointerDown';
|
|
2083
|
-
const HandleTouchStart = 'handleTouchStart';
|
|
2084
|
-
const HandleWheel = 'handleWheel';
|
|
2085
|
-
const HandleExtensionsInput = 'handleExtensionsInput';
|
|
2086
|
-
const HandleClearSearchResults = 'handleClearSearchResults';
|
|
2087
|
-
const HandleClickFilter = 'handleClickFilter';
|
|
2088
|
-
|
|
2089
2175
|
const List = 'list';
|
|
2090
2176
|
const ListItem = 'listitem';
|
|
2091
2177
|
const None = 'none';
|
|
@@ -2179,24 +2265,6 @@ const getExtensionHeaderVirtualDom = (placeholder, actions) => {
|
|
|
2179
2265
|
return [parentNode, ...getSearchFieldVirtualDom('extensions', placeholder, HandleExtensionsInput, actions, [])];
|
|
2180
2266
|
};
|
|
2181
2267
|
|
|
2182
|
-
const getInputActions = newState => {
|
|
2183
|
-
const clearEnabled = newState.searchValue.length > 0;
|
|
2184
|
-
const actions = [{
|
|
2185
|
-
onClick: HandleClearSearchResults,
|
|
2186
|
-
icon: `MaskIcon${ClearAll}`,
|
|
2187
|
-
title: clearExtensionSearchResults(),
|
|
2188
|
-
type: Button$1,
|
|
2189
|
-
enabled: clearEnabled
|
|
2190
|
-
}, {
|
|
2191
|
-
icon: `MaskIcon${Filter}`,
|
|
2192
|
-
title: filter(),
|
|
2193
|
-
type: Button$1,
|
|
2194
|
-
onClick: HandleClickFilter,
|
|
2195
|
-
enabled: true
|
|
2196
|
-
}];
|
|
2197
|
-
return actions;
|
|
2198
|
-
};
|
|
2199
|
-
|
|
2200
2268
|
const renderHeader = newState => {
|
|
2201
2269
|
const actions = getInputActions(newState);
|
|
2202
2270
|
const dom = getExtensionHeaderVirtualDom(newState.placeholder, actions);
|
|
@@ -2367,7 +2435,7 @@ const renderScrollBar = newState => {
|
|
|
2367
2435
|
const total = newState.items.length;
|
|
2368
2436
|
const contentHeight = total * newState.itemHeight;
|
|
2369
2437
|
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, newState.minimumSliderSize);
|
|
2370
|
-
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, scrollBarHeight);
|
|
2438
|
+
const scrollBarY = getScrollBarY$1(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, scrollBarHeight);
|
|
2371
2439
|
const roundedScrollBarY = Math.round(scrollBarY);
|
|
2372
2440
|
const heightString = px(scrollBarHeight);
|
|
2373
2441
|
const translateString = position(0, roundedScrollBarY);
|
|
@@ -2478,19 +2546,37 @@ const renderEventListeners = () => {
|
|
|
2478
2546
|
name: HandleContextMenu,
|
|
2479
2547
|
params: ['handleContextMenu', 'event.button', 'event.clientX', 'event.clientY'],
|
|
2480
2548
|
preventDefault: true
|
|
2549
|
+
}, {
|
|
2550
|
+
name: HandlePointerDown,
|
|
2551
|
+
params: ['handleClickAt', 'event.clientX', 'event.clientY'],
|
|
2552
|
+
preventDefault: true
|
|
2553
|
+
}, {
|
|
2554
|
+
name: HandleScrollBarPointerDown,
|
|
2555
|
+
params: ['handleScrollBarClick', 'event.clientY'],
|
|
2556
|
+
preventDefault: true,
|
|
2557
|
+
trackPointerEvents: [HandleScrollBarMove, HandleScrollBarPointerCaptureLost]
|
|
2558
|
+
}, {
|
|
2559
|
+
name: HandleScrollBarMove,
|
|
2560
|
+
params: ['handleScrollBarMove', 'event.clientY']
|
|
2561
|
+
}, {
|
|
2562
|
+
name: HandleScrollBarPointerCaptureLost,
|
|
2563
|
+
params: ['handleScrollBarCaptureLost']
|
|
2481
2564
|
}, {
|
|
2482
2565
|
name: HandleWheel,
|
|
2483
2566
|
params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
|
|
2484
2567
|
passive: true
|
|
2485
2568
|
}, {
|
|
2486
2569
|
name: HandleExtensionsInput,
|
|
2487
|
-
params: ['
|
|
2570
|
+
params: ['handleInput', 'event.target.value', User]
|
|
2488
2571
|
}, {
|
|
2489
2572
|
name: HandleClearSearchResults,
|
|
2490
2573
|
params: ['clearSearchResults']
|
|
2491
2574
|
}, {
|
|
2492
2575
|
name: HandleClickFilter,
|
|
2493
2576
|
params: ['handleClickFilter']
|
|
2577
|
+
}, {
|
|
2578
|
+
name: HandleFocus,
|
|
2579
|
+
params: ['handleFocus']
|
|
2494
2580
|
}];
|
|
2495
2581
|
};
|
|
2496
2582
|
|
|
@@ -2499,10 +2585,12 @@ const saveState = uid => {
|
|
|
2499
2585
|
newState
|
|
2500
2586
|
} = get$1(uid);
|
|
2501
2587
|
const {
|
|
2502
|
-
searchValue
|
|
2588
|
+
searchValue,
|
|
2589
|
+
deltaY
|
|
2503
2590
|
} = newState;
|
|
2504
2591
|
return {
|
|
2505
|
-
searchValue
|
|
2592
|
+
searchValue,
|
|
2593
|
+
deltaY
|
|
2506
2594
|
};
|
|
2507
2595
|
};
|
|
2508
2596
|
|
|
@@ -2553,7 +2641,7 @@ const commandMap = {
|
|
|
2553
2641
|
'SearchExtensions.handleScrollBarThumbPointerMove': wrapCommand(handleScrollBarMove),
|
|
2554
2642
|
'SearchExtensions.handleUninstall': wrapCommand(handleUninstall),
|
|
2555
2643
|
'SearchExtensions.handleWheel': wrapCommand(handleWheel),
|
|
2556
|
-
'SearchExtensions.loadContent': loadContent,
|
|
2644
|
+
'SearchExtensions.loadContent': wrapCommand(loadContent),
|
|
2557
2645
|
'SearchExtensions.openSuggest': wrapCommand(openSuggest),
|
|
2558
2646
|
'SearchExtensions.render3': render3,
|
|
2559
2647
|
'SearchExtensions.renderActions': renderActions,
|
|
@@ -2569,8 +2657,9 @@ const commandMap = {
|
|
|
2569
2657
|
};
|
|
2570
2658
|
|
|
2571
2659
|
const listen = async () => {
|
|
2660
|
+
Object.assign(commandMapRef, commandMap);
|
|
2572
2661
|
const rpc = await WebWorkerRpcClient.create({
|
|
2573
|
-
commandMap:
|
|
2662
|
+
commandMap: commandMapRef
|
|
2574
2663
|
});
|
|
2575
2664
|
set(rpc);
|
|
2576
2665
|
};
|