@lvce-editor/extension-search-view 2.2.0 → 2.4.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.
- package/dist/extensionSearchViewWorkerMain.js +598 -178
- package/package.json +1 -1
|
@@ -898,7 +898,7 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
|
898
898
|
return finalDeltaY;
|
|
899
899
|
};
|
|
900
900
|
|
|
901
|
-
const getListHeight
|
|
901
|
+
const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
902
902
|
number(itemsLength);
|
|
903
903
|
number(itemHeight);
|
|
904
904
|
number(maxHeight);
|
|
@@ -923,36 +923,6 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
|
923
923
|
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
924
924
|
};
|
|
925
925
|
|
|
926
|
-
const Web = 1;
|
|
927
|
-
const Electron = 2;
|
|
928
|
-
const Remote = 3;
|
|
929
|
-
const Test = 4;
|
|
930
|
-
|
|
931
|
-
// TODO treeshake this function out
|
|
932
|
-
|
|
933
|
-
/**
|
|
934
|
-
* @returns {number}
|
|
935
|
-
*/
|
|
936
|
-
const getPlatform = () => {
|
|
937
|
-
// @ts-ignore
|
|
938
|
-
if (typeof PLATFORM !== 'undefined') {
|
|
939
|
-
// @ts-ignore
|
|
940
|
-
return PLATFORM;
|
|
941
|
-
}
|
|
942
|
-
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {
|
|
943
|
-
return Test;
|
|
944
|
-
}
|
|
945
|
-
// TODO find a better way to pass runtime environment
|
|
946
|
-
if (typeof name !== 'undefined' && name.endsWith('(Electron)')) {
|
|
947
|
-
return Electron;
|
|
948
|
-
}
|
|
949
|
-
if (typeof name !== 'undefined' && name.endsWith('(Web)')) {
|
|
950
|
-
return Web;
|
|
951
|
-
}
|
|
952
|
-
return Remote;
|
|
953
|
-
};
|
|
954
|
-
const platform = getPlatform();
|
|
955
|
-
|
|
956
926
|
const Installed = '@installed';
|
|
957
927
|
const Enabled = '@enabled';
|
|
958
928
|
const Disabled = '@disabled';
|
|
@@ -1001,9 +971,11 @@ const parseValue = value => {
|
|
|
1001
971
|
};
|
|
1002
972
|
};
|
|
1003
973
|
|
|
1004
|
-
const
|
|
974
|
+
const Web = 1;
|
|
975
|
+
const Electron = 2;
|
|
976
|
+
const Remote = 3;
|
|
1005
977
|
|
|
1006
|
-
const getRemoteUrl = (extension, platform) => {
|
|
978
|
+
const getRemoteUrl = (extension, platform, assetDir) => {
|
|
1007
979
|
if (platform === Remote || platform === Electron) {
|
|
1008
980
|
if (extension.builtin) {
|
|
1009
981
|
return `${assetDir}/extensions/${extension.id}/${extension.icon}`;
|
|
@@ -1013,9 +985,15 @@ const getRemoteUrl = (extension, platform) => {
|
|
|
1013
985
|
return '';
|
|
1014
986
|
};
|
|
1015
987
|
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1018
|
-
|
|
988
|
+
const getExtensionDefaultIcon = assetDir => {
|
|
989
|
+
return `${assetDir}/icons/extensionDefaultIcon.png`;
|
|
990
|
+
};
|
|
991
|
+
const getExtensionLanguageBasicsIcon = assetDir => {
|
|
992
|
+
return `${assetDir}/icons/language-icon.svg`;
|
|
993
|
+
};
|
|
994
|
+
const getExtensionThemeIcon = assetDir => {
|
|
995
|
+
return `${assetDir}/icons/theme-icon.png`;
|
|
996
|
+
};
|
|
1019
997
|
|
|
1020
998
|
const isLanguageBasicsExtension = extension => {
|
|
1021
999
|
return extension.name && extension.name.startsWith('Language Basics');
|
|
@@ -1023,20 +1001,20 @@ const isLanguageBasicsExtension = extension => {
|
|
|
1023
1001
|
const isThemeExtension = extension => {
|
|
1024
1002
|
return extension.name && extension.name.endsWith(' Theme');
|
|
1025
1003
|
};
|
|
1026
|
-
const getIcon = (extension, platform) => {
|
|
1004
|
+
const getIcon = (extension, platform, assetDir) => {
|
|
1027
1005
|
if (!extension) {
|
|
1028
|
-
return
|
|
1006
|
+
return getExtensionDefaultIcon(assetDir);
|
|
1029
1007
|
}
|
|
1030
1008
|
if (!extension.path || !extension.icon) {
|
|
1031
1009
|
if (isLanguageBasicsExtension(extension)) {
|
|
1032
|
-
return
|
|
1010
|
+
return getExtensionLanguageBasicsIcon(assetDir);
|
|
1033
1011
|
}
|
|
1034
1012
|
if (isThemeExtension(extension)) {
|
|
1035
|
-
return
|
|
1013
|
+
return getExtensionThemeIcon(assetDir);
|
|
1036
1014
|
}
|
|
1037
|
-
return
|
|
1015
|
+
return getExtensionDefaultIcon(assetDir);
|
|
1038
1016
|
}
|
|
1039
|
-
return getRemoteUrl(extension, platform);
|
|
1017
|
+
return getRemoteUrl(extension, platform, assetDir);
|
|
1040
1018
|
};
|
|
1041
1019
|
const getName = extension => {
|
|
1042
1020
|
if (extension && extension.name) {
|
|
@@ -1090,6 +1068,12 @@ const matchesParsedValue = (extension, parsedValue) => {
|
|
|
1090
1068
|
const toSorted = (array, compare) => {
|
|
1091
1069
|
return [...array].sort(compare);
|
|
1092
1070
|
};
|
|
1071
|
+
const isLastIndex = (array, index) => {
|
|
1072
|
+
return index === array.length - 1;
|
|
1073
|
+
};
|
|
1074
|
+
const lastIndex = array => {
|
|
1075
|
+
return array.length - 1;
|
|
1076
|
+
};
|
|
1093
1077
|
|
|
1094
1078
|
const compareExtension = (extensionA, extensionB) => {
|
|
1095
1079
|
return extensionA.name.localeCompare(extensionB.name) || extensionA.id.localeCompare(extensionB.id);
|
|
@@ -1099,7 +1083,7 @@ const sortExtensions = extensions => {
|
|
|
1099
1083
|
return toSorted(extensions, compareExtension);
|
|
1100
1084
|
};
|
|
1101
1085
|
|
|
1102
|
-
const getExtensions = async (extensions, parsedValue, platform) => {
|
|
1086
|
+
const getExtensions = async (extensions, parsedValue, platform, assetDir = '') => {
|
|
1103
1087
|
const filteredExtensions = [];
|
|
1104
1088
|
for (const extension of extensions) {
|
|
1105
1089
|
if (matchesParsedValue(extension, parsedValue)) {
|
|
@@ -1107,7 +1091,7 @@ const getExtensions = async (extensions, parsedValue, platform) => {
|
|
|
1107
1091
|
name: getName(extension),
|
|
1108
1092
|
id: getId(extension),
|
|
1109
1093
|
publisher: getPublisher(extension),
|
|
1110
|
-
icon: getIcon(extension, platform),
|
|
1094
|
+
icon: getIcon(extension, platform, assetDir),
|
|
1111
1095
|
description: getDescription(extension)
|
|
1112
1096
|
});
|
|
1113
1097
|
}
|
|
@@ -1116,10 +1100,10 @@ const getExtensions = async (extensions, parsedValue, platform) => {
|
|
|
1116
1100
|
return sortedExtensions;
|
|
1117
1101
|
};
|
|
1118
1102
|
|
|
1119
|
-
const searchExtensions = async (extensions, value, platform
|
|
1103
|
+
const searchExtensions = async (extensions, value, platform, assetDir) => {
|
|
1120
1104
|
try {
|
|
1121
1105
|
const parsedValue = parseValue(value);
|
|
1122
|
-
const filteredExtensions = await getExtensions(extensions, parsedValue, platform
|
|
1106
|
+
const filteredExtensions = await getExtensions(extensions, parsedValue, platform, assetDir);
|
|
1123
1107
|
return filteredExtensions;
|
|
1124
1108
|
} catch (error) {
|
|
1125
1109
|
throw new VError(error, 'Failed to search for extensions');
|
|
@@ -1134,11 +1118,12 @@ const handleInput = async (state, value) => {
|
|
|
1134
1118
|
itemHeight,
|
|
1135
1119
|
minimumSliderSize,
|
|
1136
1120
|
height,
|
|
1137
|
-
platform
|
|
1121
|
+
platform,
|
|
1122
|
+
assetDir
|
|
1138
1123
|
} = state;
|
|
1139
1124
|
// TODO cancel ongoing requests
|
|
1140
1125
|
// TODO handle errors
|
|
1141
|
-
const items = await searchExtensions(allExtensions, value, platform
|
|
1126
|
+
const items = await searchExtensions(allExtensions, value, platform, assetDir);
|
|
1142
1127
|
if (items.length === 0) {
|
|
1143
1128
|
return {
|
|
1144
1129
|
...state,
|
|
@@ -1154,8 +1139,7 @@ const handleInput = async (state, value) => {
|
|
|
1154
1139
|
placeholder: searchExtensionsInMarketPlace()
|
|
1155
1140
|
};
|
|
1156
1141
|
}
|
|
1157
|
-
|
|
1158
|
-
const listHeight = getListHeight$1(state);
|
|
1142
|
+
const listHeight = getListHeight(state.items.length, state.itemHeight, state.height);
|
|
1159
1143
|
const total = items.length;
|
|
1160
1144
|
const contentHeight = total * itemHeight;
|
|
1161
1145
|
const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
|
|
@@ -1228,26 +1212,47 @@ const create = (id, uri, x, y, width, height, platform) => {
|
|
|
1228
1212
|
width,
|
|
1229
1213
|
size: 0,
|
|
1230
1214
|
negativeMargin: 0,
|
|
1231
|
-
scrollBarActive: false
|
|
1215
|
+
scrollBarActive: false,
|
|
1216
|
+
x,
|
|
1217
|
+
y,
|
|
1218
|
+
handleOffset: 0,
|
|
1219
|
+
assetDir: ''
|
|
1232
1220
|
};
|
|
1233
1221
|
set$1(id, state, state);
|
|
1234
1222
|
};
|
|
1235
1223
|
|
|
1224
|
+
const RenderHeader = 1;
|
|
1236
1225
|
const RenderItems = 4;
|
|
1237
1226
|
const RenderScrollBar = 5;
|
|
1227
|
+
const RenderMessage = 6;
|
|
1238
1228
|
|
|
1239
|
-
const diffType$
|
|
1240
|
-
const isEqual$
|
|
1229
|
+
const diffType$4 = RenderItems;
|
|
1230
|
+
const isEqual$4 = (oldState, newState) => {
|
|
1241
1231
|
return true;
|
|
1242
1232
|
};
|
|
1243
1233
|
|
|
1234
|
+
const diffType$3 = RenderHeader;
|
|
1235
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1236
|
+
return oldState.placeholder === newState.placeholder;
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
const diffType$2 = RenderItems;
|
|
1240
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1241
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.focusedIndex === newState.focusedIndex;
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
const diffType$1 = RenderMessage;
|
|
1245
|
+
const isEqual$1 = (oldState, newState) => {
|
|
1246
|
+
return oldState.message === newState.message;
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1244
1249
|
const diffType = RenderScrollBar;
|
|
1245
1250
|
const isEqual = (oldState, newState) => {
|
|
1246
1251
|
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;
|
|
1247
1252
|
};
|
|
1248
1253
|
|
|
1249
|
-
const modules = [isEqual$1, isEqual];
|
|
1250
|
-
const numbers = [diffType$1, diffType];
|
|
1254
|
+
const modules = [isEqual$4, isEqual, isEqual$1, isEqual$3, isEqual$2];
|
|
1255
|
+
const numbers = [diffType$4, diffType, diffType$1, diffType$3, diffType$2];
|
|
1251
1256
|
|
|
1252
1257
|
const diff = (oldState, newState) => {
|
|
1253
1258
|
const diffResult = [];
|
|
@@ -1325,7 +1330,66 @@ const focusIndex = (state, index) => {
|
|
|
1325
1330
|
};
|
|
1326
1331
|
};
|
|
1327
1332
|
|
|
1328
|
-
const
|
|
1333
|
+
const first = () => {
|
|
1334
|
+
return 0;
|
|
1335
|
+
};
|
|
1336
|
+
const last = items => {
|
|
1337
|
+
return items.length - 1;
|
|
1338
|
+
};
|
|
1339
|
+
const next = (items, index) => {
|
|
1340
|
+
return (index + 1) % items.length;
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
const focusFirst = state => {
|
|
1344
|
+
const firstIndex = first();
|
|
1345
|
+
return focusIndex(state, firstIndex);
|
|
1346
|
+
};
|
|
1347
|
+
|
|
1348
|
+
const focusLast = state => {
|
|
1349
|
+
const {
|
|
1350
|
+
items
|
|
1351
|
+
} = state;
|
|
1352
|
+
const lastIndex = last(items);
|
|
1353
|
+
return focusIndex(state, lastIndex);
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
const focusNext = state => {
|
|
1357
|
+
const {
|
|
1358
|
+
focusedIndex,
|
|
1359
|
+
items
|
|
1360
|
+
} = state;
|
|
1361
|
+
const nextIndex = next(items, focusedIndex);
|
|
1362
|
+
return focusIndex(state, nextIndex);
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
const focusNextPage = async state => {
|
|
1366
|
+
const {
|
|
1367
|
+
focusedIndex,
|
|
1368
|
+
items,
|
|
1369
|
+
maxLineY,
|
|
1370
|
+
minLineY
|
|
1371
|
+
} = state;
|
|
1372
|
+
if (isLastIndex(items, focusedIndex)) {
|
|
1373
|
+
return state;
|
|
1374
|
+
}
|
|
1375
|
+
const indexNextPage = Math.min(maxLineY + (maxLineY - minLineY) - 2, lastIndex(items));
|
|
1376
|
+
return focusIndex(state, indexNextPage);
|
|
1377
|
+
};
|
|
1378
|
+
|
|
1379
|
+
const focusPreviousPage = async state => {
|
|
1380
|
+
const {
|
|
1381
|
+
focusedIndex,
|
|
1382
|
+
minLineY,
|
|
1383
|
+
maxLineY
|
|
1384
|
+
} = state;
|
|
1385
|
+
if (focusedIndex === 0 || focusedIndex === -1) {
|
|
1386
|
+
return state;
|
|
1387
|
+
}
|
|
1388
|
+
const indexPreviousPage = Math.max(minLineY - (maxLineY - minLineY) + 1, 0);
|
|
1389
|
+
return focusIndex(state, indexPreviousPage);
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
const Button$2 = 1;
|
|
1329
1393
|
|
|
1330
1394
|
const ClearAll = 'ClearAll';
|
|
1331
1395
|
const Filter = 'Filter';
|
|
@@ -1334,12 +1398,12 @@ const Ellipsis = 'Ellipsis';
|
|
|
1334
1398
|
|
|
1335
1399
|
const getActions = () => {
|
|
1336
1400
|
return [{
|
|
1337
|
-
type: Button,
|
|
1401
|
+
type: Button$2,
|
|
1338
1402
|
id: refresh(),
|
|
1339
1403
|
icon: Refresh,
|
|
1340
1404
|
command: ''
|
|
1341
1405
|
}, {
|
|
1342
|
-
type: Button,
|
|
1406
|
+
type: Button$2,
|
|
1343
1407
|
id: viewsAndMoreActions(),
|
|
1344
1408
|
icon: Ellipsis,
|
|
1345
1409
|
command: ''
|
|
@@ -1439,6 +1503,20 @@ const handleClick = async (state, index) => {
|
|
|
1439
1503
|
return focusIndex(state, actualIndex);
|
|
1440
1504
|
};
|
|
1441
1505
|
|
|
1506
|
+
const handleClickCurrent = state => {
|
|
1507
|
+
const {
|
|
1508
|
+
focusedIndex
|
|
1509
|
+
} = state;
|
|
1510
|
+
return handleClick(state, focusedIndex);
|
|
1511
|
+
};
|
|
1512
|
+
|
|
1513
|
+
const handleClickCurrentButKeepFocus = state => {
|
|
1514
|
+
const {
|
|
1515
|
+
focusedIndex
|
|
1516
|
+
} = state;
|
|
1517
|
+
return handleClick(state, focusedIndex);
|
|
1518
|
+
};
|
|
1519
|
+
|
|
1442
1520
|
const show = async (x, y, id) => {
|
|
1443
1521
|
number(x);
|
|
1444
1522
|
number(y);
|
|
@@ -1462,8 +1540,12 @@ const handleEnable = (state, id) => {
|
|
|
1462
1540
|
// TODO
|
|
1463
1541
|
};
|
|
1464
1542
|
|
|
1465
|
-
const
|
|
1466
|
-
|
|
1543
|
+
const setFocus = async focusId => {
|
|
1544
|
+
await invoke('Focus.setFocus', focusId);
|
|
1545
|
+
};
|
|
1546
|
+
|
|
1547
|
+
const handleFocus = async () => {
|
|
1548
|
+
await setFocus(FocusExtensions);
|
|
1467
1549
|
};
|
|
1468
1550
|
|
|
1469
1551
|
// TODO show error / warning when installment fails / times out
|
|
@@ -1471,11 +1553,147 @@ const handleInstall = async (state, id) => {
|
|
|
1471
1553
|
// TODO
|
|
1472
1554
|
};
|
|
1473
1555
|
|
|
1556
|
+
const handleScrollBarCaptureLost = state => {
|
|
1557
|
+
return {
|
|
1558
|
+
...state,
|
|
1559
|
+
scrollBarActive: false
|
|
1560
|
+
};
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1563
|
+
const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
1564
|
+
const halfScrollBarHeight = scrollBarHeight / 2;
|
|
1565
|
+
if (relativeY <= halfScrollBarHeight) {
|
|
1566
|
+
// clicked at top
|
|
1567
|
+
return {
|
|
1568
|
+
percent: 0,
|
|
1569
|
+
handleOffset: relativeY
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
if (relativeY <= height - halfScrollBarHeight) {
|
|
1573
|
+
// clicked in middle
|
|
1574
|
+
return {
|
|
1575
|
+
percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight),
|
|
1576
|
+
handleOffset: halfScrollBarHeight
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
// clicked at bottom
|
|
1580
|
+
return {
|
|
1581
|
+
percent: 1,
|
|
1582
|
+
handleOffset: scrollBarHeight - height + relativeY
|
|
1583
|
+
};
|
|
1584
|
+
};
|
|
1585
|
+
|
|
1586
|
+
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
1587
|
+
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
1588
|
+
return scrollBarOffset;
|
|
1589
|
+
};
|
|
1590
|
+
const getScrollBarY = getScrollBarOffset;
|
|
1591
|
+
|
|
1592
|
+
const clamp = (num, min, max) => {
|
|
1593
|
+
number(num);
|
|
1594
|
+
number(min);
|
|
1595
|
+
number(max);
|
|
1596
|
+
return Math.min(Math.max(num, min), max);
|
|
1597
|
+
};
|
|
1598
|
+
|
|
1599
|
+
const setDeltaY = (state, value) => {
|
|
1600
|
+
object(state);
|
|
1601
|
+
number(value);
|
|
1602
|
+
const {
|
|
1603
|
+
itemHeight,
|
|
1604
|
+
finalDeltaY,
|
|
1605
|
+
deltaY,
|
|
1606
|
+
height,
|
|
1607
|
+
headerHeight
|
|
1608
|
+
} = state;
|
|
1609
|
+
const listHeight = height - headerHeight;
|
|
1610
|
+
const newDeltaY = clamp(value, 0, finalDeltaY);
|
|
1611
|
+
if (deltaY === newDeltaY) {
|
|
1612
|
+
return state;
|
|
1613
|
+
}
|
|
1614
|
+
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
1615
|
+
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
1616
|
+
const maxLineY = minLineY + getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1617
|
+
return {
|
|
1618
|
+
...state,
|
|
1619
|
+
deltaY: newDeltaY,
|
|
1620
|
+
minLineY,
|
|
1621
|
+
maxLineY
|
|
1622
|
+
};
|
|
1623
|
+
};
|
|
1624
|
+
|
|
1625
|
+
const handleScrollBarClick = (state, eventY) => {
|
|
1626
|
+
const {
|
|
1627
|
+
y,
|
|
1628
|
+
deltaY,
|
|
1629
|
+
headerHeight,
|
|
1630
|
+
finalDeltaY,
|
|
1631
|
+
scrollBarHeight,
|
|
1632
|
+
height
|
|
1633
|
+
} = state;
|
|
1634
|
+
const contentHeight = height - headerHeight;
|
|
1635
|
+
const relativeY = eventY - y - headerHeight;
|
|
1636
|
+
const currentScrollBarY = getScrollBarY(deltaY, finalDeltaY, contentHeight, scrollBarHeight);
|
|
1637
|
+
const diff = relativeY - currentScrollBarY;
|
|
1638
|
+
if (diff >= 0 && diff < scrollBarHeight) {
|
|
1639
|
+
return {
|
|
1640
|
+
...state,
|
|
1641
|
+
handleOffset: diff,
|
|
1642
|
+
scrollBarActive: true
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
const {
|
|
1646
|
+
percent,
|
|
1647
|
+
handleOffset
|
|
1648
|
+
} = getNewDeltaPercent(contentHeight, scrollBarHeight, relativeY);
|
|
1649
|
+
const newDeltaY = percent * finalDeltaY;
|
|
1650
|
+
return {
|
|
1651
|
+
...setDeltaY(state, newDeltaY),
|
|
1652
|
+
handleOffset,
|
|
1653
|
+
scrollBarActive: true
|
|
1654
|
+
};
|
|
1655
|
+
};
|
|
1656
|
+
|
|
1657
|
+
const getNewPercent = (contentHeight, scrollBarHeight, relativeY) => {
|
|
1658
|
+
if (relativeY <= contentHeight - scrollBarHeight / 2) {
|
|
1659
|
+
// clicked in middle
|
|
1660
|
+
return relativeY / (contentHeight - scrollBarHeight);
|
|
1661
|
+
}
|
|
1662
|
+
// clicked at bottom
|
|
1663
|
+
return 1;
|
|
1664
|
+
};
|
|
1665
|
+
const handleScrollBarMove = (state, eventY) => {
|
|
1666
|
+
const {
|
|
1667
|
+
y,
|
|
1668
|
+
headerHeight,
|
|
1669
|
+
handleOffset,
|
|
1670
|
+
finalDeltaY,
|
|
1671
|
+
height,
|
|
1672
|
+
scrollBarHeight
|
|
1673
|
+
} = state;
|
|
1674
|
+
const relativeY = eventY - y - headerHeight - handleOffset;
|
|
1675
|
+
const contentHeight = height - headerHeight;
|
|
1676
|
+
const newPercent = getNewPercent(contentHeight, scrollBarHeight, relativeY);
|
|
1677
|
+
const newDeltaY = newPercent * finalDeltaY;
|
|
1678
|
+
return setDeltaY(state, newDeltaY);
|
|
1679
|
+
};
|
|
1680
|
+
|
|
1681
|
+
// TODO show error / warning when installment fails / times out
|
|
1682
|
+
const handleUninstall = async (state, id) => {
|
|
1683
|
+
// TODO
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
const handleWheel = (state, deltaMode, deltaY) => {
|
|
1687
|
+
number(deltaMode);
|
|
1688
|
+
number(deltaY);
|
|
1689
|
+
return setDeltaY(state, state.deltaY + deltaY);
|
|
1690
|
+
};
|
|
1691
|
+
|
|
1474
1692
|
const getAllExtensions = async platform => {
|
|
1475
1693
|
if (platform === Web) {
|
|
1476
1694
|
return [];
|
|
1477
1695
|
}
|
|
1478
|
-
return
|
|
1696
|
+
return invoke('ExtensionManagement.getAllExtensions');
|
|
1479
1697
|
};
|
|
1480
1698
|
|
|
1481
1699
|
const Small = 1;
|
|
@@ -1531,6 +1749,7 @@ const openSuggest = () => {
|
|
|
1531
1749
|
// TODO
|
|
1532
1750
|
};
|
|
1533
1751
|
|
|
1752
|
+
const Actions = 'Actions';
|
|
1534
1753
|
const ExtensionActions = 'ExtensionActions';
|
|
1535
1754
|
const ExtensionActive = 'ExtensionActive';
|
|
1536
1755
|
const ExtensionHeader = 'ExtensionHeader';
|
|
@@ -1539,8 +1758,10 @@ const ExtensionListItemAuthorName = 'ExtensionListItemAuthorName';
|
|
|
1539
1758
|
const ExtensionListItemDescription = 'ExtensionListItemDescription';
|
|
1540
1759
|
const ExtensionListItemDetail = 'ExtensionListItemDetail';
|
|
1541
1760
|
const ExtensionListItemFooter = 'ExtensionListItemFooter';
|
|
1761
|
+
const MaskIcon = 'MaskIcon';
|
|
1542
1762
|
const ExtensionListItemIcon = 'ExtensionListItemIcon';
|
|
1543
1763
|
const ExtensionListItemName = 'ExtensionListItemName';
|
|
1764
|
+
const IconButton = 'IconButton';
|
|
1544
1765
|
const ListItems = 'ListItems';
|
|
1545
1766
|
const MultilineInputBox = 'MultilineInputBox';
|
|
1546
1767
|
const ScrollBarThumb = 'ScrollBarThumb';
|
|
@@ -1553,11 +1774,12 @@ const CheckBox = 'checkbox';
|
|
|
1553
1774
|
const List = 'list';
|
|
1554
1775
|
const ListItem = 'listitem';
|
|
1555
1776
|
const None = 'none';
|
|
1777
|
+
const ToolBar = 'toolbar';
|
|
1556
1778
|
|
|
1557
|
-
const Div = 4;
|
|
1558
|
-
const
|
|
1559
|
-
const
|
|
1560
|
-
const
|
|
1779
|
+
const Div$1 = 4;
|
|
1780
|
+
const Img$1 = 17;
|
|
1781
|
+
const TextArea$1 = 62;
|
|
1782
|
+
const Button$1 = 1;
|
|
1561
1783
|
|
|
1562
1784
|
const getSearchFieldButtonVirtualDom = button => {
|
|
1563
1785
|
const {
|
|
@@ -1566,7 +1788,7 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
1566
1788
|
title
|
|
1567
1789
|
} = button;
|
|
1568
1790
|
return [{
|
|
1569
|
-
type: Div,
|
|
1791
|
+
type: Div$1,
|
|
1570
1792
|
className: `SearchFieldButton ${checked ? 'SearchFieldButtonChecked' : ''}`,
|
|
1571
1793
|
title,
|
|
1572
1794
|
role: CheckBox,
|
|
@@ -1574,7 +1796,7 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
1574
1796
|
tabIndex: 0,
|
|
1575
1797
|
childCount: 1
|
|
1576
1798
|
}, {
|
|
1577
|
-
type: Div,
|
|
1799
|
+
type: Div$1,
|
|
1578
1800
|
className: `MaskIcon ${icon}`,
|
|
1579
1801
|
childCount: 0
|
|
1580
1802
|
}];
|
|
@@ -1582,12 +1804,12 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
1582
1804
|
|
|
1583
1805
|
const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, outsideButtons, onFocus = '') => {
|
|
1584
1806
|
const dom = [{
|
|
1585
|
-
type: Div,
|
|
1807
|
+
type: Div$1,
|
|
1586
1808
|
className: SearchField,
|
|
1587
1809
|
role: None,
|
|
1588
1810
|
childCount: 2
|
|
1589
1811
|
}, {
|
|
1590
|
-
type: TextArea,
|
|
1812
|
+
type: TextArea$1,
|
|
1591
1813
|
className: MultilineInputBox,
|
|
1592
1814
|
spellcheck: false,
|
|
1593
1815
|
autocapitalize: 'off',
|
|
@@ -1598,13 +1820,13 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
1598
1820
|
onFocus,
|
|
1599
1821
|
childCount: 0
|
|
1600
1822
|
}, {
|
|
1601
|
-
type: Div,
|
|
1823
|
+
type: Div$1,
|
|
1602
1824
|
className: SearchFieldButtons,
|
|
1603
1825
|
childCount: insideButtons.length
|
|
1604
1826
|
}, ...insideButtons.flatMap(getSearchFieldButtonVirtualDom)];
|
|
1605
1827
|
if (outsideButtons.length > 0) {
|
|
1606
1828
|
dom.unshift({
|
|
1607
|
-
type: Div,
|
|
1829
|
+
type: Div$1,
|
|
1608
1830
|
className: SearchFieldContainer,
|
|
1609
1831
|
role: None,
|
|
1610
1832
|
childCount: 1 + outsideButtons.length
|
|
@@ -1616,12 +1838,27 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
1616
1838
|
|
|
1617
1839
|
const getExtensionHeaderVirtualDom = (placeholder, actions) => {
|
|
1618
1840
|
return [{
|
|
1619
|
-
type: Div,
|
|
1841
|
+
type: Div$1,
|
|
1620
1842
|
className: ExtensionHeader,
|
|
1621
1843
|
childCount: 1
|
|
1622
1844
|
}, ...getSearchFieldVirtualDom('extensions', placeholder, 'handleExtensionsInput', actions, [])];
|
|
1623
1845
|
};
|
|
1624
1846
|
|
|
1847
|
+
const renderHeader$1 = newState => {
|
|
1848
|
+
const actions = [{
|
|
1849
|
+
type: Button$2,
|
|
1850
|
+
title: clearExtensionSearchResults(),
|
|
1851
|
+
icon: `MaskIcon${ClearAll}`,
|
|
1852
|
+
command: 'Extensions.clearSearchResults'
|
|
1853
|
+
}, {
|
|
1854
|
+
type: Button$2,
|
|
1855
|
+
title: filter(),
|
|
1856
|
+
icon: `MaskIcon${Filter}`
|
|
1857
|
+
}];
|
|
1858
|
+
const dom = getExtensionHeaderVirtualDom(newState.placeholder, actions);
|
|
1859
|
+
return ['setHeaderDom', dom];
|
|
1860
|
+
};
|
|
1861
|
+
|
|
1625
1862
|
const HandleContextMenu = 'handleContextMenu';
|
|
1626
1863
|
const HandlePointerDown = 'handlePointerDown';
|
|
1627
1864
|
const HandleTouchStart = 'handleTouchStart';
|
|
@@ -1629,7 +1866,134 @@ const HandleWheel = 'handleWheel';
|
|
|
1629
1866
|
|
|
1630
1867
|
const Extension = 'Extension';
|
|
1631
1868
|
|
|
1632
|
-
|
|
1869
|
+
var __defProp = Object.defineProperty;
|
|
1870
|
+
var __export = (target, all) => {
|
|
1871
|
+
for (var name in all) __defProp(target, name, {
|
|
1872
|
+
get: all[name],
|
|
1873
|
+
enumerable: true
|
|
1874
|
+
});
|
|
1875
|
+
};
|
|
1876
|
+
|
|
1877
|
+
// src/parts/MergeClassNames/MergeClassNames.ts
|
|
1878
|
+
var mergeClassNames = (...classNames) => {
|
|
1879
|
+
return classNames.filter(Boolean).join(" ");
|
|
1880
|
+
};
|
|
1881
|
+
|
|
1882
|
+
// src/parts/VirtualDomElements/VirtualDomElements.ts
|
|
1883
|
+
var VirtualDomElements_exports = {};
|
|
1884
|
+
__export(VirtualDomElements_exports, {
|
|
1885
|
+
A: () => A,
|
|
1886
|
+
Abbr: () => Abbr,
|
|
1887
|
+
Article: () => Article,
|
|
1888
|
+
Aside: () => Aside,
|
|
1889
|
+
Audio: () => Audio,
|
|
1890
|
+
Br: () => Br,
|
|
1891
|
+
Button: () => Button,
|
|
1892
|
+
Cite: () => Cite,
|
|
1893
|
+
Col: () => Col,
|
|
1894
|
+
ColGroup: () => ColGroup,
|
|
1895
|
+
Data: () => Data,
|
|
1896
|
+
Dd: () => Dd,
|
|
1897
|
+
Del: () => Del,
|
|
1898
|
+
Div: () => Div,
|
|
1899
|
+
Dl: () => Dl,
|
|
1900
|
+
Figcaption: () => Figcaption,
|
|
1901
|
+
Figure: () => Figure,
|
|
1902
|
+
Footer: () => Footer,
|
|
1903
|
+
H1: () => H1,
|
|
1904
|
+
H2: () => H2,
|
|
1905
|
+
H3: () => H3,
|
|
1906
|
+
H4: () => H4,
|
|
1907
|
+
H5: () => H5,
|
|
1908
|
+
H6: () => H6,
|
|
1909
|
+
Header: () => Header,
|
|
1910
|
+
Hr: () => Hr,
|
|
1911
|
+
I: () => I,
|
|
1912
|
+
Img: () => Img,
|
|
1913
|
+
Input: () => Input,
|
|
1914
|
+
Ins: () => Ins,
|
|
1915
|
+
Kbd: () => Kbd,
|
|
1916
|
+
Li: () => Li,
|
|
1917
|
+
Nav: () => Nav,
|
|
1918
|
+
Ol: () => Ol,
|
|
1919
|
+
Option: () => Option,
|
|
1920
|
+
P: () => P,
|
|
1921
|
+
Pre: () => Pre,
|
|
1922
|
+
Root: () => Root,
|
|
1923
|
+
Search: () => Search,
|
|
1924
|
+
Section: () => Section,
|
|
1925
|
+
Select: () => Select,
|
|
1926
|
+
Span: () => Span,
|
|
1927
|
+
TBody: () => TBody,
|
|
1928
|
+
THead: () => THead,
|
|
1929
|
+
Table: () => Table,
|
|
1930
|
+
Td: () => Td,
|
|
1931
|
+
Text: () => Text,
|
|
1932
|
+
TextArea: () => TextArea,
|
|
1933
|
+
Tfoot: () => Tfoot,
|
|
1934
|
+
Th: () => Th,
|
|
1935
|
+
Time: () => Time,
|
|
1936
|
+
Tr: () => Tr,
|
|
1937
|
+
Ul: () => Ul,
|
|
1938
|
+
Video: () => Video
|
|
1939
|
+
});
|
|
1940
|
+
var Audio = 0;
|
|
1941
|
+
var Button = 1;
|
|
1942
|
+
var Col = 2;
|
|
1943
|
+
var ColGroup = 3;
|
|
1944
|
+
var Div = 4;
|
|
1945
|
+
var H1 = 5;
|
|
1946
|
+
var Input = 6;
|
|
1947
|
+
var Kbd = 7;
|
|
1948
|
+
var Span = 8;
|
|
1949
|
+
var Table = 9;
|
|
1950
|
+
var TBody = 10;
|
|
1951
|
+
var Td = 11;
|
|
1952
|
+
var Text = 12;
|
|
1953
|
+
var Th = 13;
|
|
1954
|
+
var THead = 14;
|
|
1955
|
+
var Tr = 15;
|
|
1956
|
+
var I = 16;
|
|
1957
|
+
var Img = 17;
|
|
1958
|
+
var Root = 0;
|
|
1959
|
+
var Ins = 20;
|
|
1960
|
+
var Del = 21;
|
|
1961
|
+
var H2 = 22;
|
|
1962
|
+
var H3 = 23;
|
|
1963
|
+
var H4 = 24;
|
|
1964
|
+
var H5 = 25;
|
|
1965
|
+
var H6 = 26;
|
|
1966
|
+
var Article = 27;
|
|
1967
|
+
var Aside = 28;
|
|
1968
|
+
var Footer = 29;
|
|
1969
|
+
var Header = 30;
|
|
1970
|
+
var Nav = 40;
|
|
1971
|
+
var Section = 41;
|
|
1972
|
+
var Search = 42;
|
|
1973
|
+
var Dd = 43;
|
|
1974
|
+
var Dl = 44;
|
|
1975
|
+
var Figcaption = 45;
|
|
1976
|
+
var Figure = 46;
|
|
1977
|
+
var Hr = 47;
|
|
1978
|
+
var Li = 48;
|
|
1979
|
+
var Ol = 49;
|
|
1980
|
+
var P = 50;
|
|
1981
|
+
var Pre = 51;
|
|
1982
|
+
var A = 53;
|
|
1983
|
+
var Abbr = 54;
|
|
1984
|
+
var Br = 55;
|
|
1985
|
+
var Cite = 56;
|
|
1986
|
+
var Data = 57;
|
|
1987
|
+
var Time = 58;
|
|
1988
|
+
var Tfoot = 59;
|
|
1989
|
+
var Ul = 60;
|
|
1990
|
+
var Video = 61;
|
|
1991
|
+
var TextArea = 62;
|
|
1992
|
+
var Select = 63;
|
|
1993
|
+
var Option = 64;
|
|
1994
|
+
|
|
1995
|
+
// src/parts/Text/Text.ts
|
|
1996
|
+
var text = data => {
|
|
1633
1997
|
return {
|
|
1634
1998
|
type: Text,
|
|
1635
1999
|
text: data,
|
|
@@ -1638,27 +2002,27 @@ const text = data => {
|
|
|
1638
2002
|
};
|
|
1639
2003
|
|
|
1640
2004
|
const listItemDetail = {
|
|
1641
|
-
type: Div,
|
|
2005
|
+
type: Div$1,
|
|
1642
2006
|
className: ExtensionListItemDetail,
|
|
1643
2007
|
childCount: 3
|
|
1644
2008
|
};
|
|
1645
2009
|
const listItemName = {
|
|
1646
|
-
type: Div,
|
|
2010
|
+
type: Div$1,
|
|
1647
2011
|
className: ExtensionListItemName,
|
|
1648
2012
|
childCount: 1
|
|
1649
2013
|
};
|
|
1650
2014
|
const listItemDescription = {
|
|
1651
|
-
type: Div,
|
|
2015
|
+
type: Div$1,
|
|
1652
2016
|
className: ExtensionListItemDescription,
|
|
1653
2017
|
childCount: 1
|
|
1654
2018
|
};
|
|
1655
2019
|
const listItemFooter = {
|
|
1656
|
-
type: Div,
|
|
2020
|
+
type: Div$1,
|
|
1657
2021
|
className: ExtensionListItemFooter,
|
|
1658
2022
|
childCount: 2
|
|
1659
2023
|
};
|
|
1660
2024
|
const listItemAuthorName = {
|
|
1661
|
-
type: Div,
|
|
2025
|
+
type: Div$1,
|
|
1662
2026
|
className: ExtensionListItemAuthorName,
|
|
1663
2027
|
childCount: 1
|
|
1664
2028
|
};
|
|
@@ -1674,7 +2038,7 @@ const getExtensionListItemVirtualDom = extension => {
|
|
|
1674
2038
|
focused
|
|
1675
2039
|
} = extension;
|
|
1676
2040
|
const dom = [{
|
|
1677
|
-
type: Div,
|
|
2041
|
+
type: Div$1,
|
|
1678
2042
|
role: ListItem,
|
|
1679
2043
|
ariaRoleDescription: Extension,
|
|
1680
2044
|
className: ExtensionListItem,
|
|
@@ -1683,13 +2047,13 @@ const getExtensionListItemVirtualDom = extension => {
|
|
|
1683
2047
|
top,
|
|
1684
2048
|
childCount: 2
|
|
1685
2049
|
}, {
|
|
1686
|
-
type: Img,
|
|
2050
|
+
type: Img$1,
|
|
1687
2051
|
src: icon,
|
|
1688
2052
|
className: ExtensionListItemIcon,
|
|
1689
2053
|
role: None,
|
|
1690
2054
|
childCount: 0
|
|
1691
2055
|
}, listItemDetail, listItemName, text(name), listItemDescription, text(description), listItemFooter, listItemAuthorName, text(publisher), {
|
|
1692
|
-
type: Div,
|
|
2056
|
+
type: Div$1,
|
|
1693
2057
|
className: ExtensionActions,
|
|
1694
2058
|
childCount: 0
|
|
1695
2059
|
}];
|
|
@@ -1702,7 +2066,7 @@ const getExtensionListItemVirtualDom = extension => {
|
|
|
1702
2066
|
|
|
1703
2067
|
const getExtensionsListVirtualDom = visibleExtensions => {
|
|
1704
2068
|
const dom = [{
|
|
1705
|
-
type: Div,
|
|
2069
|
+
type: Div$1,
|
|
1706
2070
|
className: ListItems,
|
|
1707
2071
|
tabIndex: 0,
|
|
1708
2072
|
ariaLabel: extensions(),
|
|
@@ -1751,68 +2115,60 @@ const getVisible = state => {
|
|
|
1751
2115
|
return visible;
|
|
1752
2116
|
};
|
|
1753
2117
|
|
|
1754
|
-
const
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
const
|
|
1758
|
-
return
|
|
2118
|
+
const renderItems = newState => {
|
|
2119
|
+
// TODO render extensions incrementally when scrolling
|
|
2120
|
+
const visibleExtensions = getVisible(newState);
|
|
2121
|
+
const dom = getExtensionsVirtualDom(visibleExtensions);
|
|
2122
|
+
return ['setExtensionsDom', dom];
|
|
1759
2123
|
};
|
|
1760
2124
|
|
|
1761
2125
|
const SetMessage = 'setMessage';
|
|
1762
2126
|
const SetScrollBar = 'setScrollBar';
|
|
1763
2127
|
const SetSearchValue = 'setSearchValue';
|
|
1764
2128
|
|
|
1765
|
-
const
|
|
1766
|
-
|
|
1767
|
-
return scrollBarOffset;
|
|
2129
|
+
const renderMessage$1 = newState => {
|
|
2130
|
+
return [/* method */SetMessage, /* message */newState.message];
|
|
1768
2131
|
};
|
|
1769
|
-
const getScrollBarY = getScrollBarOffset;
|
|
1770
2132
|
|
|
1771
|
-
const
|
|
1772
|
-
|
|
1773
|
-
height,
|
|
1774
|
-
headerHeight
|
|
1775
|
-
} = state;
|
|
1776
|
-
return height - headerHeight;
|
|
2133
|
+
const px = value => {
|
|
2134
|
+
return `${value}px`;
|
|
1777
2135
|
};
|
|
2136
|
+
const position = (x, y) => {
|
|
2137
|
+
return `${x}px ${y}px`;
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2140
|
+
const renderScrollBar$1 = newState => {
|
|
2141
|
+
const listHeight = getListHeight(newState.items.length, newState.itemHeight, newState.height);
|
|
2142
|
+
const total = newState.items.length;
|
|
2143
|
+
const contentHeight = total * newState.itemHeight;
|
|
2144
|
+
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, newState.minimumSliderSize);
|
|
2145
|
+
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, scrollBarHeight);
|
|
2146
|
+
const roundedScrollBarY = Math.round(scrollBarY);
|
|
2147
|
+
const heightString = px(scrollBarHeight);
|
|
2148
|
+
const translateString = position(0, roundedScrollBarY);
|
|
2149
|
+
let className = ScrollBarThumb;
|
|
2150
|
+
if (newState.scrollBarActive) {
|
|
2151
|
+
className += ' ' + ScrollBarThumbActive;
|
|
2152
|
+
}
|
|
2153
|
+
return [/* method */SetScrollBar, translateString, heightString, className];
|
|
2154
|
+
};
|
|
2155
|
+
|
|
1778
2156
|
const renderExtensions = {
|
|
1779
|
-
isEqual
|
|
1780
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.focusedIndex === newState.focusedIndex;
|
|
1781
|
-
},
|
|
2157
|
+
isEqual: isEqual$2,
|
|
1782
2158
|
apply(oldState, newState) {
|
|
1783
|
-
|
|
1784
|
-
const visibleExtensions = getVisible(newState);
|
|
1785
|
-
const dom = getExtensionsVirtualDom(visibleExtensions);
|
|
1786
|
-
return ['setExtensionsDom', dom];
|
|
2159
|
+
return renderItems(newState);
|
|
1787
2160
|
}
|
|
1788
2161
|
};
|
|
1789
2162
|
const renderScrollBar = {
|
|
1790
|
-
isEqual
|
|
1791
|
-
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;
|
|
1792
|
-
},
|
|
2163
|
+
isEqual: isEqual,
|
|
1793
2164
|
apply(oldState, newState) {
|
|
1794
|
-
|
|
1795
|
-
const listHeight = getListHeight(newState);
|
|
1796
|
-
const total = newState.items.length;
|
|
1797
|
-
const contentHeight = total * newState.itemHeight;
|
|
1798
|
-
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, newState.minimumSliderSize);
|
|
1799
|
-
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, scrollBarHeight);
|
|
1800
|
-
const roundedScrollBarY = Math.round(scrollBarY);
|
|
1801
|
-
const heightString = px(scrollBarHeight);
|
|
1802
|
-
const translateString = position(0, roundedScrollBarY);
|
|
1803
|
-
let className = ScrollBarThumb;
|
|
1804
|
-
if (newState.scrollBarActive) {
|
|
1805
|
-
className += ' ' + ScrollBarThumbActive;
|
|
1806
|
-
}
|
|
1807
|
-
return [/* method */SetScrollBar, translateString, heightString, className];
|
|
2165
|
+
return renderScrollBar$1(newState);
|
|
1808
2166
|
}
|
|
1809
2167
|
};
|
|
1810
2168
|
const renderMessage = {
|
|
1811
|
-
isEqual
|
|
1812
|
-
return oldState.message === newState.message;
|
|
1813
|
-
},
|
|
2169
|
+
isEqual: isEqual$1,
|
|
1814
2170
|
apply(oldState, newState) {
|
|
1815
|
-
return
|
|
2171
|
+
return renderMessage$1(newState);
|
|
1816
2172
|
}
|
|
1817
2173
|
};
|
|
1818
2174
|
const renderSearchValue = {
|
|
@@ -1824,22 +2180,9 @@ const renderSearchValue = {
|
|
|
1824
2180
|
}
|
|
1825
2181
|
};
|
|
1826
2182
|
const renderHeader = {
|
|
1827
|
-
isEqual
|
|
1828
|
-
return oldState.placeholder === newState.placeholder;
|
|
1829
|
-
},
|
|
2183
|
+
isEqual: isEqual$3,
|
|
1830
2184
|
apply(oldState, newState) {
|
|
1831
|
-
|
|
1832
|
-
type: Button,
|
|
1833
|
-
title: clearExtensionSearchResults(),
|
|
1834
|
-
icon: `MaskIcon${ClearAll}`,
|
|
1835
|
-
command: 'Extensions.clearSearchResults'
|
|
1836
|
-
}, {
|
|
1837
|
-
type: Button,
|
|
1838
|
-
title: filter(),
|
|
1839
|
-
icon: `MaskIcon${Filter}`
|
|
1840
|
-
}];
|
|
1841
|
-
const dom = getExtensionHeaderVirtualDom(newState.placeholder, actions);
|
|
1842
|
-
return ['setHeaderDom', dom];
|
|
2185
|
+
return renderHeader$1(newState);
|
|
1843
2186
|
}
|
|
1844
2187
|
};
|
|
1845
2188
|
const render = [renderScrollBar, renderMessage, renderExtensions, renderSearchValue, renderHeader];
|
|
@@ -1853,6 +2196,73 @@ const doRender = (oldState, newState) => {
|
|
|
1853
2196
|
return commands;
|
|
1854
2197
|
};
|
|
1855
2198
|
|
|
2199
|
+
const getIconVirtualDom = (icon, type = Div$1) => {
|
|
2200
|
+
return {
|
|
2201
|
+
type,
|
|
2202
|
+
className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
|
|
2203
|
+
role: None,
|
|
2204
|
+
childCount: 0
|
|
2205
|
+
};
|
|
2206
|
+
};
|
|
2207
|
+
|
|
2208
|
+
const getActionButtonVirtualDom = action => {
|
|
2209
|
+
const {
|
|
2210
|
+
id,
|
|
2211
|
+
icon,
|
|
2212
|
+
command
|
|
2213
|
+
} = action;
|
|
2214
|
+
return [{
|
|
2215
|
+
type: Button$1,
|
|
2216
|
+
className: IconButton,
|
|
2217
|
+
title: id,
|
|
2218
|
+
'data-command': command,
|
|
2219
|
+
childCount: 1
|
|
2220
|
+
}, getIconVirtualDom(icon)];
|
|
2221
|
+
};
|
|
2222
|
+
|
|
2223
|
+
const getActionVirtualDom = action => {
|
|
2224
|
+
switch (action.type) {
|
|
2225
|
+
case Button$2:
|
|
2226
|
+
return getActionButtonVirtualDom(action);
|
|
2227
|
+
default:
|
|
2228
|
+
return [];
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
|
|
2232
|
+
const getActionsVirtualDom = actions => {
|
|
2233
|
+
return [{
|
|
2234
|
+
type: Div$1,
|
|
2235
|
+
className: Actions,
|
|
2236
|
+
role: ToolBar,
|
|
2237
|
+
childCount: actions.length
|
|
2238
|
+
}, ...actions.flatMap(getActionVirtualDom)];
|
|
2239
|
+
};
|
|
2240
|
+
|
|
2241
|
+
const renderActions = uid => {
|
|
2242
|
+
const {
|
|
2243
|
+
oldState,
|
|
2244
|
+
newState
|
|
2245
|
+
} = get$1(uid);
|
|
2246
|
+
if (oldState === newState) {
|
|
2247
|
+
return [];
|
|
2248
|
+
}
|
|
2249
|
+
const actions = [];
|
|
2250
|
+
const dom = getActionsVirtualDom(actions);
|
|
2251
|
+
return dom;
|
|
2252
|
+
};
|
|
2253
|
+
|
|
2254
|
+
const renderEventListeners = () => {
|
|
2255
|
+
return [{
|
|
2256
|
+
name: HandleContextMenu,
|
|
2257
|
+
params: ['handleContextMenu', 'event.button', 'event.clientX', 'event.clientY'],
|
|
2258
|
+
preventDefault: true
|
|
2259
|
+
}, {
|
|
2260
|
+
name: HandleWheel,
|
|
2261
|
+
params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
|
|
2262
|
+
passive: true
|
|
2263
|
+
}];
|
|
2264
|
+
};
|
|
2265
|
+
|
|
1856
2266
|
const saveState = state => {
|
|
1857
2267
|
const {
|
|
1858
2268
|
searchValue
|
|
@@ -1862,36 +2272,19 @@ const saveState = state => {
|
|
|
1862
2272
|
};
|
|
1863
2273
|
};
|
|
1864
2274
|
|
|
1865
|
-
const
|
|
1866
|
-
number(num);
|
|
1867
|
-
number(min);
|
|
1868
|
-
number(max);
|
|
1869
|
-
return Math.min(Math.max(num, min), max);
|
|
1870
|
-
};
|
|
1871
|
-
|
|
1872
|
-
const setDeltaY = (state, value) => {
|
|
1873
|
-
object(state);
|
|
1874
|
-
number(value);
|
|
2275
|
+
const scrollDown = state => {
|
|
1875
2276
|
const {
|
|
1876
|
-
itemHeight,
|
|
1877
2277
|
finalDeltaY,
|
|
1878
|
-
deltaY
|
|
1879
|
-
height,
|
|
1880
|
-
headerHeight
|
|
2278
|
+
deltaY
|
|
1881
2279
|
} = state;
|
|
1882
|
-
const
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
1888
|
-
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
1889
|
-
const maxLineY = minLineY + getNumberOfVisibleItems(listHeight, itemHeight);
|
|
2280
|
+
const newDeltaY = Math.min(deltaY + 20, finalDeltaY);
|
|
2281
|
+
return setDeltaY(state, newDeltaY);
|
|
2282
|
+
};
|
|
2283
|
+
|
|
2284
|
+
const selectIndex = (state, index) => {
|
|
1890
2285
|
return {
|
|
1891
2286
|
...state,
|
|
1892
|
-
|
|
1893
|
-
minLineY,
|
|
1894
|
-
maxLineY
|
|
2287
|
+
focusedIndex: index
|
|
1895
2288
|
};
|
|
1896
2289
|
};
|
|
1897
2290
|
|
|
@@ -1899,28 +2292,55 @@ const toggleSuggest = () => {
|
|
|
1899
2292
|
// TODO
|
|
1900
2293
|
};
|
|
1901
2294
|
|
|
2295
|
+
const wrapCommand = fn => {
|
|
2296
|
+
const wrapped = async (uid, ...args) => {
|
|
2297
|
+
const {
|
|
2298
|
+
newState
|
|
2299
|
+
} = get$1(uid);
|
|
2300
|
+
const newerState = await fn(newState, ...args);
|
|
2301
|
+
set$1(uid, newState, newerState);
|
|
2302
|
+
};
|
|
2303
|
+
return wrapped;
|
|
2304
|
+
};
|
|
2305
|
+
|
|
1902
2306
|
const commandMap = {
|
|
1903
|
-
'SearchExtensions.clearSearchResults': clearSearchResults,
|
|
1904
|
-
'SearchExtensions.closeSuggest': closeSuggest,
|
|
2307
|
+
'SearchExtensions.clearSearchResults': wrapCommand(clearSearchResults),
|
|
2308
|
+
'SearchExtensions.closeSuggest': wrapCommand(closeSuggest),
|
|
1905
2309
|
'SearchExtensions.create': create,
|
|
1906
2310
|
'SearchExtensions.diff': diff,
|
|
1907
|
-
'SearchExtensions.
|
|
2311
|
+
'SearchExtensions.focusFirst': wrapCommand(focusFirst),
|
|
2312
|
+
'SearchExtensions.focusIndex': wrapCommand(focusIndex),
|
|
2313
|
+
'SearchExtensions.focusLast': wrapCommand(focusLast),
|
|
2314
|
+
'SearchExtensions.focusNext': wrapCommand(focusNext),
|
|
2315
|
+
'SearchExtensions.focusNextPage': wrapCommand(focusNextPage),
|
|
2316
|
+
'SearchExtensions.focusPreviousPage': wrapCommand(focusPreviousPage),
|
|
1908
2317
|
'SearchExtensions.getActions': getActions,
|
|
1909
2318
|
'SearchExtensions.getKeyBindings': getKeyBindings,
|
|
1910
|
-
'SearchExtensions.handleBlur': handleBlur,
|
|
1911
|
-
'SearchExtensions.
|
|
1912
|
-
'SearchExtensions.
|
|
1913
|
-
'SearchExtensions.
|
|
1914
|
-
'SearchExtensions.
|
|
1915
|
-
'SearchExtensions.
|
|
1916
|
-
'SearchExtensions.
|
|
2319
|
+
'SearchExtensions.handleBlur': wrapCommand(handleBlur),
|
|
2320
|
+
'SearchExtensions.renderEventListeners': renderEventListeners,
|
|
2321
|
+
'SearchExtensions.handleClick': wrapCommand(handleClick),
|
|
2322
|
+
'SearchExtensions.handleClickCurrent': wrapCommand(handleClickCurrent),
|
|
2323
|
+
'SearchExtensions.handleClickCurrentButKeepFocus': wrapCommand(handleClickCurrentButKeepFocus),
|
|
2324
|
+
'SearchExtensions.renderActions': renderActions,
|
|
2325
|
+
'SearchExtensions.handleContextMenu': wrapCommand(handleContextMenu),
|
|
2326
|
+
'SearchExtensions.handleDisable': wrapCommand(handleDisable),
|
|
2327
|
+
'SearchExtensions.handleEnable': wrapCommand(handleEnable),
|
|
2328
|
+
'SearchExtensions.handleFocus': wrapCommand(handleFocus),
|
|
2329
|
+
'SearchExtensions.handleInstall': wrapCommand(handleInstall),
|
|
2330
|
+
'SearchExtensions.handleScrollBarCaptureLos': wrapCommand(handleScrollBarCaptureLost),
|
|
2331
|
+
'SearchExtensions.handleScrollBarClick': wrapCommand(handleScrollBarClick),
|
|
2332
|
+
'SearchExtensions.handleScrollBarMove': wrapCommand(handleScrollBarMove),
|
|
2333
|
+
'SearchExtensions.handleUninstall': wrapCommand(handleUninstall),
|
|
2334
|
+
'SearchExtensions.handleWheel': wrapCommand(handleWheel),
|
|
1917
2335
|
'SearchExtensions.loadContent': loadContent,
|
|
1918
|
-
'SearchExtensions.openSuggest': openSuggest,
|
|
2336
|
+
'SearchExtensions.openSuggest': wrapCommand(openSuggest),
|
|
1919
2337
|
'SearchExtensions.render': doRender,
|
|
1920
2338
|
'SearchExtensions.saveState': saveState,
|
|
2339
|
+
'SearchExtensions.scrollDown': wrapCommand(scrollDown),
|
|
1921
2340
|
'SearchExtensions.searchExtensions': searchExtensions,
|
|
1922
|
-
'SearchExtensions.
|
|
1923
|
-
'SearchExtensions.
|
|
2341
|
+
'SearchExtensions.selectIndex': wrapCommand(selectIndex),
|
|
2342
|
+
'SearchExtensions.setDeltaY': wrapCommand(setDeltaY),
|
|
2343
|
+
'SearchExtensions.toggleSuggest': wrapCommand(toggleSuggest)
|
|
1924
2344
|
};
|
|
1925
2345
|
|
|
1926
2346
|
const listen = async () => {
|