@lvce-editor/extension-search-view 2.12.0 → 3.0.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.
|
@@ -912,7 +912,7 @@ const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
|
912
912
|
// TODO optimize this function to return the minimum number
|
|
913
913
|
// of visible items needed, e.g. when not scrolled 5 items with
|
|
914
914
|
// 20px fill 100px but when scrolled 6 items are needed
|
|
915
|
-
const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
915
|
+
const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
|
|
916
916
|
return Math.ceil(listHeight / itemHeight) + 1;
|
|
917
917
|
};
|
|
918
918
|
|
|
@@ -1004,12 +1004,6 @@ const matchesParsedValue = (extension, parsedValue) => {
|
|
|
1004
1004
|
const toSorted = (array, compare) => {
|
|
1005
1005
|
return [...array].sort(compare);
|
|
1006
1006
|
};
|
|
1007
|
-
const isLastIndex = (array, index) => {
|
|
1008
|
-
return index === array.length - 1;
|
|
1009
|
-
};
|
|
1010
|
-
const lastIndex = array => {
|
|
1011
|
-
return array.length - 1;
|
|
1012
|
-
};
|
|
1013
1007
|
|
|
1014
1008
|
const compareExtension = (extensionA, extensionB) => {
|
|
1015
1009
|
return extensionA.name.localeCompare(extensionB.name) || extensionA.id.localeCompare(extensionB.id);
|
|
@@ -1073,7 +1067,7 @@ const handleInput = async (state, value) => {
|
|
|
1073
1067
|
const total = items.length;
|
|
1074
1068
|
const contentHeight = total * itemHeight;
|
|
1075
1069
|
const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
|
|
1076
|
-
const numberOfVisible = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1070
|
+
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
1077
1071
|
const maxLineY = Math.min(numberOfVisible, total);
|
|
1078
1072
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
1079
1073
|
return {
|
|
@@ -1163,31 +1157,31 @@ const RenderMessage = 6;
|
|
|
1163
1157
|
const RenderSearchValue = 7;
|
|
1164
1158
|
|
|
1165
1159
|
const diffType$4 = RenderItems;
|
|
1166
|
-
const isEqual$
|
|
1160
|
+
const isEqual$4 = (oldState, newState) => {
|
|
1167
1161
|
return true;
|
|
1168
1162
|
};
|
|
1169
1163
|
|
|
1170
1164
|
const diffType$3 = RenderHeader;
|
|
1171
|
-
const isEqual$
|
|
1165
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1172
1166
|
return oldState.placeholder === newState.placeholder;
|
|
1173
1167
|
};
|
|
1174
1168
|
|
|
1175
1169
|
const diffType$2 = RenderItems;
|
|
1176
|
-
const isEqual$
|
|
1170
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1177
1171
|
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.focusedIndex === newState.focusedIndex;
|
|
1178
1172
|
};
|
|
1179
1173
|
|
|
1180
1174
|
const diffType$1 = RenderMessage;
|
|
1181
|
-
const isEqual$
|
|
1175
|
+
const isEqual$1 = (oldState, newState) => {
|
|
1182
1176
|
return oldState.message === newState.message;
|
|
1183
1177
|
};
|
|
1184
1178
|
|
|
1185
1179
|
const diffType = RenderScrollBar;
|
|
1186
|
-
const isEqual
|
|
1180
|
+
const isEqual = (oldState, newState) => {
|
|
1187
1181
|
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;
|
|
1188
1182
|
};
|
|
1189
1183
|
|
|
1190
|
-
const modules = [isEqual
|
|
1184
|
+
const modules = [isEqual, isEqual$1, isEqual$3, isEqual$2, isEqual$4];
|
|
1191
1185
|
const numbers = [diffType, diffType$1, diffType$3, diffType$2, diffType$4];
|
|
1192
1186
|
|
|
1193
1187
|
const diff = (oldState, newState) => {
|
|
@@ -1214,6 +1208,12 @@ const dispose = uid => {
|
|
|
1214
1208
|
remove(uid);
|
|
1215
1209
|
};
|
|
1216
1210
|
|
|
1211
|
+
// TODO optimize this function to return the minimum number
|
|
1212
|
+
// of visible items needed, e.g. when not scrolled 5 items with
|
|
1213
|
+
// 20px fill 100px but when scrolled 6 items are needed
|
|
1214
|
+
const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
1215
|
+
return Math.ceil(listHeight / itemHeight) + 1;
|
|
1216
|
+
};
|
|
1217
1217
|
const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
1218
1218
|
const newMaxLineY = Math.min(index + 1, itemsLength);
|
|
1219
1219
|
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
@@ -1228,7 +1228,6 @@ const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength)
|
|
|
1228
1228
|
deltaY: newDeltaY
|
|
1229
1229
|
};
|
|
1230
1230
|
};
|
|
1231
|
-
|
|
1232
1231
|
const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
1233
1232
|
const newMinLineY = index;
|
|
1234
1233
|
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
@@ -1243,7 +1242,6 @@ const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) =
|
|
|
1243
1242
|
deltaY: newDeltaY
|
|
1244
1243
|
};
|
|
1245
1244
|
};
|
|
1246
|
-
|
|
1247
1245
|
const focusIndex = (state, index) => {
|
|
1248
1246
|
const {
|
|
1249
1247
|
itemHeight,
|
|
@@ -1278,7 +1276,6 @@ const focusIndex = (state, index) => {
|
|
|
1278
1276
|
focused: true
|
|
1279
1277
|
};
|
|
1280
1278
|
};
|
|
1281
|
-
|
|
1282
1279
|
const first = () => {
|
|
1283
1280
|
return 0;
|
|
1284
1281
|
};
|
|
@@ -1288,12 +1285,10 @@ const last = items => {
|
|
|
1288
1285
|
const next = (items, index) => {
|
|
1289
1286
|
return (index + 1) % items.length;
|
|
1290
1287
|
};
|
|
1291
|
-
|
|
1292
1288
|
const focusFirst = state => {
|
|
1293
1289
|
const firstIndex = first();
|
|
1294
1290
|
return focusIndex(state, firstIndex);
|
|
1295
1291
|
};
|
|
1296
|
-
|
|
1297
1292
|
const focusLast = state => {
|
|
1298
1293
|
const {
|
|
1299
1294
|
items
|
|
@@ -1301,7 +1296,6 @@ const focusLast = state => {
|
|
|
1301
1296
|
const lastIndex = last(items);
|
|
1302
1297
|
return focusIndex(state, lastIndex);
|
|
1303
1298
|
};
|
|
1304
|
-
|
|
1305
1299
|
const focusNext = state => {
|
|
1306
1300
|
const {
|
|
1307
1301
|
focusedIndex,
|
|
@@ -1311,6 +1305,14 @@ const focusNext = state => {
|
|
|
1311
1305
|
return focusIndex(state, nextIndex);
|
|
1312
1306
|
};
|
|
1313
1307
|
|
|
1308
|
+
// based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
|
|
1309
|
+
|
|
1310
|
+
const isLastIndex = (array, index) => {
|
|
1311
|
+
return index === array.length - 1;
|
|
1312
|
+
};
|
|
1313
|
+
const lastIndex = array => {
|
|
1314
|
+
return array.length - 1;
|
|
1315
|
+
};
|
|
1314
1316
|
const focusNextPage = state => {
|
|
1315
1317
|
const {
|
|
1316
1318
|
focusedIndex,
|
|
@@ -1324,7 +1326,6 @@ const focusNextPage = state => {
|
|
|
1324
1326
|
const indexNextPage = Math.min(maxLineY + (maxLineY - minLineY) - 2, lastIndex(items));
|
|
1325
1327
|
return focusIndex(state, indexNextPage);
|
|
1326
1328
|
};
|
|
1327
|
-
|
|
1328
1329
|
const focusPreviousPage = state => {
|
|
1329
1330
|
const {
|
|
1330
1331
|
focusedIndex,
|
|
@@ -1595,7 +1596,7 @@ const setDeltaY = (state, value) => {
|
|
|
1595
1596
|
}
|
|
1596
1597
|
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
1597
1598
|
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
1598
|
-
const maxLineY = minLineY + getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1599
|
+
const maxLineY = minLineY + getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
1599
1600
|
return {
|
|
1600
1601
|
...state,
|
|
1601
1602
|
deltaY: newDeltaY,
|
|
@@ -1700,7 +1701,6 @@ const getViewletSize = width => {
|
|
|
1700
1701
|
return Large;
|
|
1701
1702
|
};
|
|
1702
1703
|
|
|
1703
|
-
const User = 1;
|
|
1704
1704
|
const Script = 2;
|
|
1705
1705
|
|
|
1706
1706
|
const getRemoteUrl = (extension, platform, assetDir) => {
|
|
@@ -1843,10 +1843,6 @@ const openSuggest = state => {
|
|
|
1843
1843
|
return state;
|
|
1844
1844
|
};
|
|
1845
1845
|
|
|
1846
|
-
const isEqual = (oldState, newState) => {
|
|
1847
|
-
return newState.inputSource === User || oldState.searchValue === newState.searchValue;
|
|
1848
|
-
};
|
|
1849
|
-
|
|
1850
1846
|
const Actions = 'Actions';
|
|
1851
1847
|
const ExtensionActions = 'ExtensionActions';
|
|
1852
1848
|
const ExtensionActive = 'ExtensionActive';
|
|
@@ -1942,7 +1938,7 @@ const getExtensionHeaderVirtualDom = (placeholder, actions) => {
|
|
|
1942
1938
|
}, ...getSearchFieldVirtualDom('extensions', placeholder, 'handleExtensionsInput', actions, [])];
|
|
1943
1939
|
};
|
|
1944
1940
|
|
|
1945
|
-
const renderHeader
|
|
1941
|
+
const renderHeader = newState => {
|
|
1946
1942
|
const actions = [{
|
|
1947
1943
|
type: Button$2,
|
|
1948
1944
|
title: clearExtensionSearchResults(),
|
|
@@ -2236,7 +2232,7 @@ const SetMessage = 'setMessage';
|
|
|
2236
2232
|
const SetScrollBar = 'setScrollBar';
|
|
2237
2233
|
const SetSearchValue = 'setSearchValue';
|
|
2238
2234
|
|
|
2239
|
-
const renderMessage
|
|
2235
|
+
const renderMessage = newState => {
|
|
2240
2236
|
return [/* method */SetMessage, /* message */newState.message];
|
|
2241
2237
|
};
|
|
2242
2238
|
|
|
@@ -2247,7 +2243,7 @@ const position = (x, y) => {
|
|
|
2247
2243
|
return `${x}px ${y}px`;
|
|
2248
2244
|
};
|
|
2249
2245
|
|
|
2250
|
-
const renderScrollBar
|
|
2246
|
+
const renderScrollBar = newState => {
|
|
2251
2247
|
const listHeight = getListHeight(newState.items.length, newState.itemHeight, newState.height);
|
|
2252
2248
|
const total = newState.items.length;
|
|
2253
2249
|
const contentHeight = total * newState.itemHeight;
|
|
@@ -2263,55 +2259,6 @@ const renderScrollBar$1 = newState => {
|
|
|
2263
2259
|
return [/* method */SetScrollBar, translateString, heightString, className];
|
|
2264
2260
|
};
|
|
2265
2261
|
|
|
2266
|
-
const renderExtensions = {
|
|
2267
|
-
isEqual: isEqual$3,
|
|
2268
|
-
apply(oldState, newState) {
|
|
2269
|
-
return renderItems(newState);
|
|
2270
|
-
}
|
|
2271
|
-
};
|
|
2272
|
-
const renderScrollBar = {
|
|
2273
|
-
isEqual: isEqual$1,
|
|
2274
|
-
apply(oldState, newState) {
|
|
2275
|
-
return renderScrollBar$1(newState);
|
|
2276
|
-
}
|
|
2277
|
-
};
|
|
2278
|
-
const renderMessage = {
|
|
2279
|
-
isEqual: isEqual$2,
|
|
2280
|
-
apply(oldState, newState) {
|
|
2281
|
-
return renderMessage$1(newState);
|
|
2282
|
-
}
|
|
2283
|
-
};
|
|
2284
|
-
const renderSearchValue$1 = {
|
|
2285
|
-
isEqual: isEqual,
|
|
2286
|
-
apply(oldState, newState) {
|
|
2287
|
-
return [/* method */SetSearchValue, oldState.searchValue, newState.searchValue];
|
|
2288
|
-
}
|
|
2289
|
-
};
|
|
2290
|
-
const renderHeader = {
|
|
2291
|
-
isEqual: isEqual$4,
|
|
2292
|
-
apply(oldState, newState) {
|
|
2293
|
-
return renderHeader$1(newState);
|
|
2294
|
-
}
|
|
2295
|
-
};
|
|
2296
|
-
const render = [renderScrollBar, renderMessage, renderExtensions, renderHeader, renderSearchValue$1];
|
|
2297
|
-
const doRender = (oldState, newState) => {
|
|
2298
|
-
const commands = [];
|
|
2299
|
-
for (const item of render) {
|
|
2300
|
-
if (!item.isEqual(oldState, newState)) {
|
|
2301
|
-
commands.push(item.apply(oldState, newState));
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
return commands;
|
|
2305
|
-
};
|
|
2306
|
-
|
|
2307
|
-
const render2 = uid => {
|
|
2308
|
-
const {
|
|
2309
|
-
oldState,
|
|
2310
|
-
newState
|
|
2311
|
-
} = get$1(uid);
|
|
2312
|
-
return doRender(oldState, newState);
|
|
2313
|
-
};
|
|
2314
|
-
|
|
2315
2262
|
const renderSearchValue = newState => {
|
|
2316
2263
|
return [/* method */SetSearchValue, '', newState.searchValue];
|
|
2317
2264
|
};
|
|
@@ -2321,13 +2268,13 @@ const getRenderer = diffType => {
|
|
|
2321
2268
|
case RenderItems:
|
|
2322
2269
|
return renderItems;
|
|
2323
2270
|
case RenderMessage:
|
|
2324
|
-
return renderMessage
|
|
2271
|
+
return renderMessage;
|
|
2325
2272
|
case RenderScrollBar:
|
|
2326
|
-
return renderScrollBar
|
|
2273
|
+
return renderScrollBar;
|
|
2327
2274
|
case RenderSearchValue:
|
|
2328
2275
|
return renderSearchValue;
|
|
2329
2276
|
case RenderHeader:
|
|
2330
|
-
return renderHeader
|
|
2277
|
+
return renderHeader;
|
|
2331
2278
|
default:
|
|
2332
2279
|
throw new Error('unknown renderer');
|
|
2333
2280
|
}
|
|
@@ -2502,11 +2449,7 @@ const commandMap = {
|
|
|
2502
2449
|
'SearchExtensions.selectIndex': wrapCommand(selectIndex),
|
|
2503
2450
|
'SearchExtensions.setDeltaY': wrapCommand(setDeltaY),
|
|
2504
2451
|
'SearchExtensions.terminate': terminate,
|
|
2505
|
-
'SearchExtensions.toggleSuggest': wrapCommand(toggleSuggest)
|
|
2506
|
-
// deprecated
|
|
2507
|
-
'SearchExtensions.diff': diff,
|
|
2508
|
-
'SearchExtensions.render': doRender,
|
|
2509
|
-
'SearchExtensions.render2': render2
|
|
2452
|
+
'SearchExtensions.toggleSuggest': wrapCommand(toggleSuggest)
|
|
2510
2453
|
};
|
|
2511
2454
|
|
|
2512
2455
|
const listen = async () => {
|