@lvce-editor/extension-search-view 3.7.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.
- package/dist/extensionSearchViewWorkerMain.js +284 -170
- package/package.json +1 -1
|
@@ -879,7 +879,70 @@ const WebWorkerRpcClient = {
|
|
|
879
879
|
create: create$3
|
|
880
880
|
};
|
|
881
881
|
|
|
882
|
-
const
|
|
882
|
+
const create$2 = () => {
|
|
883
|
+
const states = Object.create(null);
|
|
884
|
+
return {
|
|
885
|
+
get(uid) {
|
|
886
|
+
return states[uid];
|
|
887
|
+
},
|
|
888
|
+
set(uid, oldState, newState) {
|
|
889
|
+
states[uid] = {
|
|
890
|
+
oldState,
|
|
891
|
+
newState
|
|
892
|
+
};
|
|
893
|
+
},
|
|
894
|
+
dispose(uid) {
|
|
895
|
+
delete states[uid];
|
|
896
|
+
},
|
|
897
|
+
getKeys() {
|
|
898
|
+
return Object.keys(states).map(key => {
|
|
899
|
+
return Number.parseInt(key);
|
|
900
|
+
});
|
|
901
|
+
},
|
|
902
|
+
clear() {
|
|
903
|
+
for (const key of Object.keys(states)) {
|
|
904
|
+
delete states[key];
|
|
905
|
+
}
|
|
906
|
+
},
|
|
907
|
+
wrapCommand(fn) {
|
|
908
|
+
const wrapped = async (uid, ...args) => {
|
|
909
|
+
const {
|
|
910
|
+
newState
|
|
911
|
+
} = states[uid];
|
|
912
|
+
const newerState = await fn(newState, ...args);
|
|
913
|
+
if (newState === newerState) {
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
const latest = states[uid];
|
|
917
|
+
states[uid] = {
|
|
918
|
+
oldState: latest.oldState,
|
|
919
|
+
newState: newerState
|
|
920
|
+
};
|
|
921
|
+
};
|
|
922
|
+
return wrapped;
|
|
923
|
+
},
|
|
924
|
+
diff(uid, modules, numbers) {
|
|
925
|
+
const {
|
|
926
|
+
oldState,
|
|
927
|
+
newState
|
|
928
|
+
} = states[uid];
|
|
929
|
+
const diffResult = [];
|
|
930
|
+
for (let i = 0; i < modules.length; i++) {
|
|
931
|
+
const fn = modules[i];
|
|
932
|
+
if (!fn(oldState, newState)) {
|
|
933
|
+
diffResult.push(numbers[i]);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
return diffResult;
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
};
|
|
940
|
+
const terminate = () => {
|
|
941
|
+
globalThis.close();
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
const handleError = async (error, notify = true, prefix = '') => {
|
|
945
|
+
// @ts-ignore
|
|
883
946
|
console.error(error);
|
|
884
947
|
};
|
|
885
948
|
|
|
@@ -945,6 +1008,10 @@ const viewsAndMoreActions = () => {
|
|
|
945
1008
|
return i18nString(ViewsAndMoreActions);
|
|
946
1009
|
};
|
|
947
1010
|
|
|
1011
|
+
const None$2 = 0;
|
|
1012
|
+
const Input = 1;
|
|
1013
|
+
const List$1 = 2;
|
|
1014
|
+
|
|
948
1015
|
const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
949
1016
|
const contentHeight = itemsLength * itemHeight;
|
|
950
1017
|
const finalDeltaY = Math.max(contentHeight - height, 0);
|
|
@@ -976,6 +1043,12 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
|
976
1043
|
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
977
1044
|
};
|
|
978
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
|
+
|
|
979
1052
|
const Installed = '@installed';
|
|
980
1053
|
const Enabled = '@enabled';
|
|
981
1054
|
const Disabled = '@disabled';
|
|
@@ -1096,7 +1169,8 @@ const handleInput = async (state, value) => {
|
|
|
1096
1169
|
minimumSliderSize,
|
|
1097
1170
|
height,
|
|
1098
1171
|
platform,
|
|
1099
|
-
assetDir
|
|
1172
|
+
assetDir,
|
|
1173
|
+
headerHeight
|
|
1100
1174
|
} = state;
|
|
1101
1175
|
// TODO cancel ongoing requests
|
|
1102
1176
|
// TODO handle errors
|
|
@@ -1104,16 +1178,17 @@ const handleInput = async (state, value) => {
|
|
|
1104
1178
|
if (items.length === 0) {
|
|
1105
1179
|
return {
|
|
1106
1180
|
...state,
|
|
1107
|
-
items,
|
|
1108
|
-
minLineY: 0,
|
|
1109
|
-
deltaY: 0,
|
|
1110
1181
|
allExtensions,
|
|
1111
|
-
|
|
1112
|
-
scrollBarHeight: 0,
|
|
1182
|
+
deltaY: 0,
|
|
1113
1183
|
finalDeltaY: 0,
|
|
1184
|
+
focus: Input,
|
|
1185
|
+
items,
|
|
1186
|
+
maxLineY: 0,
|
|
1114
1187
|
message: noExtensionsFound(),
|
|
1115
|
-
|
|
1116
|
-
placeholder: searchExtensionsInMarketPlace()
|
|
1188
|
+
minLineY: 0,
|
|
1189
|
+
placeholder: searchExtensionsInMarketPlace(),
|
|
1190
|
+
scrollBarHeight: 0,
|
|
1191
|
+
searchValue: value
|
|
1117
1192
|
};
|
|
1118
1193
|
}
|
|
1119
1194
|
const total = items.length;
|
|
@@ -1123,24 +1198,27 @@ const handleInput = async (state, value) => {
|
|
|
1123
1198
|
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
1124
1199
|
const maxLineY = Math.min(numberOfVisible, total);
|
|
1125
1200
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
1201
|
+
const scrollBarY = getScrollBarY$1(0, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
1126
1202
|
return {
|
|
1127
1203
|
...state,
|
|
1128
|
-
items,
|
|
1129
|
-
minLineY: 0,
|
|
1130
|
-
deltaY: 0,
|
|
1131
1204
|
allExtensions,
|
|
1132
|
-
|
|
1133
|
-
scrollBarHeight,
|
|
1205
|
+
deltaY: 0,
|
|
1134
1206
|
finalDeltaY,
|
|
1207
|
+
items,
|
|
1208
|
+
maxLineY,
|
|
1135
1209
|
message: '',
|
|
1136
|
-
|
|
1137
|
-
placeholder: searchExtensionsInMarketPlace()
|
|
1210
|
+
minLineY: 0,
|
|
1211
|
+
placeholder: searchExtensionsInMarketPlace(),
|
|
1212
|
+
scrollBarHeight,
|
|
1213
|
+
scrollBarY,
|
|
1214
|
+
searchValue: value
|
|
1138
1215
|
};
|
|
1139
1216
|
|
|
1140
1217
|
// TODO handle out of order responses (a bit complicated)
|
|
1141
1218
|
// for now just assume everything comes back in order
|
|
1142
1219
|
} catch (error) {
|
|
1143
|
-
|
|
1220
|
+
// TODO send error to error worker
|
|
1221
|
+
await handleError(error);
|
|
1144
1222
|
return {
|
|
1145
1223
|
...state,
|
|
1146
1224
|
searchValue: value,
|
|
@@ -1157,65 +1235,6 @@ const closeSuggest = state => {
|
|
|
1157
1235
|
return state;
|
|
1158
1236
|
};
|
|
1159
1237
|
|
|
1160
|
-
const create$2 = () => {
|
|
1161
|
-
const states = Object.create(null);
|
|
1162
|
-
return {
|
|
1163
|
-
get(uid) {
|
|
1164
|
-
return states[uid];
|
|
1165
|
-
},
|
|
1166
|
-
set(uid, oldState, newState) {
|
|
1167
|
-
states[uid] = {
|
|
1168
|
-
oldState,
|
|
1169
|
-
newState
|
|
1170
|
-
};
|
|
1171
|
-
},
|
|
1172
|
-
dispose(uid) {
|
|
1173
|
-
delete states[uid];
|
|
1174
|
-
},
|
|
1175
|
-
getKeys() {
|
|
1176
|
-
return Object.keys(states).map(key => {
|
|
1177
|
-
return Number.parseInt(key);
|
|
1178
|
-
});
|
|
1179
|
-
},
|
|
1180
|
-
clear() {
|
|
1181
|
-
for (const key of Object.keys(states)) {
|
|
1182
|
-
delete states[key];
|
|
1183
|
-
}
|
|
1184
|
-
},
|
|
1185
|
-
wrapCommand(fn) {
|
|
1186
|
-
const wrapped = async (uid, ...args) => {
|
|
1187
|
-
const {
|
|
1188
|
-
newState
|
|
1189
|
-
} = states[uid];
|
|
1190
|
-
const newerState = await fn(newState, ...args);
|
|
1191
|
-
if (newState === newerState) {
|
|
1192
|
-
return;
|
|
1193
|
-
}
|
|
1194
|
-
const latest = states[uid];
|
|
1195
|
-
states[uid] = {
|
|
1196
|
-
oldState: latest.oldState,
|
|
1197
|
-
newState: newerState
|
|
1198
|
-
};
|
|
1199
|
-
};
|
|
1200
|
-
return wrapped;
|
|
1201
|
-
},
|
|
1202
|
-
diff(uid, modules, numbers) {
|
|
1203
|
-
const {
|
|
1204
|
-
oldState,
|
|
1205
|
-
newState
|
|
1206
|
-
} = states[uid];
|
|
1207
|
-
const diffResult = [];
|
|
1208
|
-
for (let i = 0; i < modules.length; i++) {
|
|
1209
|
-
const fn = modules[i];
|
|
1210
|
-
if (!fn(oldState, newState)) {
|
|
1211
|
-
diffResult.push(numbers[i]);
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
return diffResult;
|
|
1215
|
-
}
|
|
1216
|
-
};
|
|
1217
|
-
};
|
|
1218
|
-
|
|
1219
1238
|
const {
|
|
1220
1239
|
get: get$1,
|
|
1221
1240
|
set: set$1,
|
|
@@ -1229,10 +1248,14 @@ const create$1 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1229
1248
|
assetDir,
|
|
1230
1249
|
deltaY: 0,
|
|
1231
1250
|
finalDeltaY: 0,
|
|
1251
|
+
focus: 0,
|
|
1252
|
+
focused: false,
|
|
1232
1253
|
focusedIndex: 0,
|
|
1233
1254
|
handleOffset: 0,
|
|
1234
1255
|
headerHeight: 41,
|
|
1235
1256
|
height,
|
|
1257
|
+
inputActions: [],
|
|
1258
|
+
inputSource: 0,
|
|
1236
1259
|
itemHeight: 72,
|
|
1237
1260
|
items: [],
|
|
1238
1261
|
maxLineY: 0,
|
|
@@ -1244,44 +1267,33 @@ const create$1 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1244
1267
|
platform,
|
|
1245
1268
|
scrollBarActive: false,
|
|
1246
1269
|
scrollBarHeight: 0,
|
|
1270
|
+
scrollBarY: 0,
|
|
1247
1271
|
searchValue: '',
|
|
1248
1272
|
size: 0,
|
|
1273
|
+
uid: id,
|
|
1249
1274
|
width,
|
|
1250
1275
|
x,
|
|
1251
|
-
y
|
|
1252
|
-
focused: false,
|
|
1253
|
-
inputSource: 0
|
|
1276
|
+
y
|
|
1254
1277
|
};
|
|
1255
1278
|
set$1(id, state, state);
|
|
1256
1279
|
};
|
|
1257
1280
|
|
|
1258
|
-
const RenderHeader = 1;
|
|
1259
|
-
const RenderItems = 4;
|
|
1260
|
-
const RenderScrollBar = 5;
|
|
1261
|
-
const RenderMessage = 6;
|
|
1262
|
-
const RenderSearchValue = 7;
|
|
1263
|
-
|
|
1264
|
-
const diffType$5 = RenderItems;
|
|
1265
1281
|
const isEqual$5 = (oldState, newState) => {
|
|
1266
1282
|
return true;
|
|
1267
1283
|
};
|
|
1268
1284
|
|
|
1269
|
-
const diffType$4 = RenderHeader;
|
|
1270
1285
|
const isEqual$4 = (oldState, newState) => {
|
|
1271
1286
|
return oldState.placeholder === newState.placeholder;
|
|
1272
1287
|
};
|
|
1273
1288
|
|
|
1274
|
-
const diffType$3 = RenderItems;
|
|
1275
1289
|
const isEqual$3 = (oldState, newState) => {
|
|
1276
|
-
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;
|
|
1277
1291
|
};
|
|
1278
1292
|
|
|
1279
|
-
const diffType$2 = RenderMessage;
|
|
1280
1293
|
const isEqual$2 = (oldState, newState) => {
|
|
1281
1294
|
return oldState.message === newState.message;
|
|
1282
1295
|
};
|
|
1283
1296
|
|
|
1284
|
-
const diffType$1 = RenderScrollBar;
|
|
1285
1297
|
const isEqual$1 = (oldState, newState) => {
|
|
1286
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;
|
|
1287
1299
|
};
|
|
@@ -1289,13 +1301,19 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
1289
1301
|
const User = 1;
|
|
1290
1302
|
const Script = 2;
|
|
1291
1303
|
|
|
1292
|
-
const diffType = RenderSearchValue;
|
|
1293
1304
|
const isEqual = (oldState, newState) => {
|
|
1294
1305
|
return newState.inputSource === User || oldState.searchValue === newState.searchValue;
|
|
1295
1306
|
};
|
|
1296
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
|
+
|
|
1297
1315
|
const modules = [isEqual$1, isEqual$2, isEqual$4, isEqual$3, isEqual$5, isEqual];
|
|
1298
|
-
const numbers = [
|
|
1316
|
+
const numbers = [RenderScrollBar, RenderMessage, RenderHeader, RenderItems, RenderFocus, RenderSearchValue];
|
|
1299
1317
|
|
|
1300
1318
|
const diff2 = uid => {
|
|
1301
1319
|
const {
|
|
@@ -1322,32 +1340,53 @@ const dispose = uid => {
|
|
|
1322
1340
|
const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
1323
1341
|
return Math.ceil(listHeight / itemHeight) + 1;
|
|
1324
1342
|
};
|
|
1343
|
+
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
1344
|
+
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
1345
|
+
return scrollBarOffset;
|
|
1346
|
+
};
|
|
1347
|
+
const getScrollBarY = getScrollBarOffset;
|
|
1325
1348
|
const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
1349
|
+
const {
|
|
1350
|
+
finalDeltaY,
|
|
1351
|
+
height,
|
|
1352
|
+
headerHeight,
|
|
1353
|
+
scrollBarHeight
|
|
1354
|
+
} = state;
|
|
1326
1355
|
const newMaxLineY = Math.min(index + 1, itemsLength);
|
|
1327
1356
|
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1328
1357
|
const newMinLineY = Math.max(newMaxLineY - fittingItems, 0);
|
|
1329
1358
|
const newDeltaY = itemsLength < fittingItems ? 0 : newMinLineY * itemHeight - listHeight % itemHeight + itemHeight;
|
|
1359
|
+
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
1330
1360
|
return {
|
|
1331
1361
|
...state,
|
|
1332
1362
|
focusedIndex: index,
|
|
1333
1363
|
minLineY: newMinLineY,
|
|
1334
1364
|
maxLineY: newMaxLineY,
|
|
1335
1365
|
focused: true,
|
|
1336
|
-
deltaY: newDeltaY
|
|
1366
|
+
deltaY: newDeltaY,
|
|
1367
|
+
scrollBarY
|
|
1337
1368
|
};
|
|
1338
1369
|
};
|
|
1339
1370
|
const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
1371
|
+
const {
|
|
1372
|
+
finalDeltaY,
|
|
1373
|
+
height,
|
|
1374
|
+
headerHeight,
|
|
1375
|
+
scrollBarHeight
|
|
1376
|
+
} = state;
|
|
1340
1377
|
const newMinLineY = index;
|
|
1341
1378
|
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1342
1379
|
const newMaxLineY = Math.min(newMinLineY + fittingItems, itemsLength);
|
|
1343
1380
|
const newDeltaY = newMinLineY * itemHeight;
|
|
1381
|
+
const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
1344
1382
|
return {
|
|
1345
1383
|
...state,
|
|
1346
1384
|
focusedIndex: index,
|
|
1347
1385
|
minLineY: newMinLineY,
|
|
1348
1386
|
maxLineY: newMaxLineY,
|
|
1349
1387
|
focused: true,
|
|
1350
|
-
deltaY: newDeltaY
|
|
1388
|
+
deltaY: newDeltaY,
|
|
1389
|
+
scrollBarY
|
|
1351
1390
|
};
|
|
1352
1391
|
};
|
|
1353
1392
|
const focusIndex = (state, index) => {
|
|
@@ -1482,10 +1521,16 @@ const getActions = () => {
|
|
|
1482
1521
|
}];
|
|
1483
1522
|
};
|
|
1484
1523
|
|
|
1485
|
-
const
|
|
1524
|
+
const commandMapRef = {};
|
|
1486
1525
|
|
|
1526
|
+
const toCommandId = key => {
|
|
1527
|
+
const dotIndex = key.indexOf('.');
|
|
1528
|
+
return key.slice(dotIndex + 1);
|
|
1529
|
+
};
|
|
1487
1530
|
const getCommandIds = () => {
|
|
1488
|
-
|
|
1531
|
+
const keys = Object.keys(commandMapRef);
|
|
1532
|
+
const ids = keys.map(toCommandId);
|
|
1533
|
+
return ids;
|
|
1489
1534
|
};
|
|
1490
1535
|
|
|
1491
1536
|
const Enter = 3;
|
|
@@ -1577,7 +1622,14 @@ const getMenuEntries = () => {
|
|
|
1577
1622
|
};
|
|
1578
1623
|
|
|
1579
1624
|
const handleBlur = state => {
|
|
1580
|
-
return
|
|
1625
|
+
return {
|
|
1626
|
+
...state,
|
|
1627
|
+
focus: None$2
|
|
1628
|
+
};
|
|
1629
|
+
};
|
|
1630
|
+
|
|
1631
|
+
const getExtensionDetailUri = extensionId => {
|
|
1632
|
+
return `extension-detail://${extensionId}`;
|
|
1581
1633
|
};
|
|
1582
1634
|
|
|
1583
1635
|
const rpcs = Object.create(null);
|
|
@@ -1615,20 +1667,44 @@ const create = rpcId => {
|
|
|
1615
1667
|
};
|
|
1616
1668
|
const RendererWorker$1 = 1;
|
|
1617
1669
|
const {
|
|
1618
|
-
invoke: invoke$
|
|
1670
|
+
invoke: invoke$3,
|
|
1619
1671
|
set: set$3} = create(RendererWorker$1);
|
|
1620
|
-
const
|
|
1672
|
+
const showContextMenu$1 = async (x, y, id, ...args) => {
|
|
1673
|
+
return invoke$3('ContextMenu.show', x, y, id, ...args);
|
|
1674
|
+
};
|
|
1675
|
+
const setFocus$2 = key => {
|
|
1676
|
+
return invoke$3('Focus.setFocus', key);
|
|
1677
|
+
};
|
|
1678
|
+
const openUri$2 = async (uri, focus, options) => {
|
|
1679
|
+
await invoke$3('Main.openUri', uri, focus, options);
|
|
1680
|
+
};
|
|
1681
|
+
const RendererWorker$2 = {
|
|
1621
1682
|
__proto__: null,
|
|
1622
|
-
invoke: invoke$
|
|
1623
|
-
|
|
1683
|
+
invoke: invoke$3,
|
|
1684
|
+
openUri: openUri$2,
|
|
1685
|
+
set: set$3,
|
|
1686
|
+
setFocus: setFocus$2,
|
|
1687
|
+
showContextMenu: showContextMenu$1};
|
|
1624
1688
|
|
|
1625
1689
|
const {
|
|
1626
1690
|
invoke,
|
|
1627
|
-
set
|
|
1628
|
-
|
|
1691
|
+
set,
|
|
1692
|
+
showContextMenu,
|
|
1693
|
+
setFocus: setFocus$1,
|
|
1694
|
+
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
|
+
};
|
|
1629
1705
|
|
|
1630
1706
|
const openUri = async uri => {
|
|
1631
|
-
return
|
|
1707
|
+
return openUri$1(uri);
|
|
1632
1708
|
};
|
|
1633
1709
|
|
|
1634
1710
|
const handleClick = async (state, index) => {
|
|
@@ -1638,13 +1714,19 @@ const handleClick = async (state, index) => {
|
|
|
1638
1714
|
} = state;
|
|
1639
1715
|
const actualIndex = index + minLineY;
|
|
1640
1716
|
const extension = items[actualIndex];
|
|
1641
|
-
const uri =
|
|
1717
|
+
const uri = getExtensionDetailUri(extension.id);
|
|
1642
1718
|
await openUri(uri);
|
|
1643
|
-
|
|
1719
|
+
const partialNewState = focusIndex(state, actualIndex);
|
|
1720
|
+
const newState = {
|
|
1721
|
+
...partialNewState,
|
|
1722
|
+
focus: List$1
|
|
1723
|
+
};
|
|
1724
|
+
return newState;
|
|
1644
1725
|
};
|
|
1645
1726
|
|
|
1646
|
-
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
|
|
1647
|
-
const
|
|
1727
|
+
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, headerHeight) => {
|
|
1728
|
+
const relativeDeltaY = deltaY % itemHeight;
|
|
1729
|
+
const relativeY = eventY - y - headerHeight + relativeDeltaY;
|
|
1648
1730
|
const index = Math.floor(relativeY / itemHeight);
|
|
1649
1731
|
return index;
|
|
1650
1732
|
};
|
|
@@ -1661,9 +1743,10 @@ const handleClickAt = async (state, eventX, eventY) => {
|
|
|
1661
1743
|
x,
|
|
1662
1744
|
y,
|
|
1663
1745
|
itemHeight,
|
|
1664
|
-
deltaY
|
|
1746
|
+
deltaY,
|
|
1747
|
+
headerHeight
|
|
1665
1748
|
} = state;
|
|
1666
|
-
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight);
|
|
1749
|
+
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, headerHeight);
|
|
1667
1750
|
return selectIndex(state, index);
|
|
1668
1751
|
};
|
|
1669
1752
|
|
|
@@ -1685,7 +1768,7 @@ const show = async (x, y, id) => {
|
|
|
1685
1768
|
number(x);
|
|
1686
1769
|
number(y);
|
|
1687
1770
|
number(id);
|
|
1688
|
-
await
|
|
1771
|
+
await showContextMenu(x, y, id);
|
|
1689
1772
|
};
|
|
1690
1773
|
|
|
1691
1774
|
const ManageExtension = 8;
|
|
@@ -1705,9 +1788,9 @@ const handleEnable = (state, id) => {
|
|
|
1705
1788
|
return state;
|
|
1706
1789
|
};
|
|
1707
1790
|
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1710
|
-
};
|
|
1791
|
+
const {
|
|
1792
|
+
setFocus
|
|
1793
|
+
} = RendererWorker;
|
|
1711
1794
|
|
|
1712
1795
|
const handleFocus = async state => {
|
|
1713
1796
|
await setFocus(FocusExtensions);
|
|
@@ -1750,12 +1833,6 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
1750
1833
|
};
|
|
1751
1834
|
};
|
|
1752
1835
|
|
|
1753
|
-
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
1754
|
-
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
1755
|
-
return scrollBarOffset;
|
|
1756
|
-
};
|
|
1757
|
-
const getScrollBarY = getScrollBarOffset;
|
|
1758
|
-
|
|
1759
1836
|
const clamp = (num, min, max) => {
|
|
1760
1837
|
number(num);
|
|
1761
1838
|
number(min);
|
|
@@ -1771,7 +1848,9 @@ const setDeltaY = (state, value) => {
|
|
|
1771
1848
|
finalDeltaY,
|
|
1772
1849
|
deltaY,
|
|
1773
1850
|
height,
|
|
1774
|
-
headerHeight
|
|
1851
|
+
headerHeight,
|
|
1852
|
+
items,
|
|
1853
|
+
minimumSliderSize
|
|
1775
1854
|
} = state;
|
|
1776
1855
|
const listHeight = height - headerHeight;
|
|
1777
1856
|
const newDeltaY = clamp(value, 0, finalDeltaY);
|
|
@@ -1781,11 +1860,16 @@ const setDeltaY = (state, value) => {
|
|
|
1781
1860
|
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
1782
1861
|
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
1783
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);
|
|
1784
1867
|
return {
|
|
1785
1868
|
...state,
|
|
1786
1869
|
deltaY: newDeltaY,
|
|
1787
1870
|
minLineY,
|
|
1788
|
-
maxLineY
|
|
1871
|
+
maxLineY,
|
|
1872
|
+
scrollBarY
|
|
1789
1873
|
};
|
|
1790
1874
|
};
|
|
1791
1875
|
|
|
@@ -1800,7 +1884,7 @@ const handleScrollBarClick = (state, eventY) => {
|
|
|
1800
1884
|
} = state;
|
|
1801
1885
|
const contentHeight = height - headerHeight;
|
|
1802
1886
|
const relativeY = eventY - y - headerHeight;
|
|
1803
|
-
const currentScrollBarY = getScrollBarY(deltaY, finalDeltaY, contentHeight, scrollBarHeight);
|
|
1887
|
+
const currentScrollBarY = getScrollBarY$1(deltaY, finalDeltaY, contentHeight, scrollBarHeight);
|
|
1804
1888
|
const diff = relativeY - currentScrollBarY;
|
|
1805
1889
|
if (diff >= 0 && diff < scrollBarHeight) {
|
|
1806
1890
|
return {
|
|
@@ -1872,6 +1956,36 @@ const getAllExtensions = platform => {
|
|
|
1872
1956
|
return getAllExtensions$1(platform);
|
|
1873
1957
|
};
|
|
1874
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
|
+
|
|
1875
1989
|
const Small = 1;
|
|
1876
1990
|
const Normal = 2;
|
|
1877
1991
|
const Large = 3;
|
|
@@ -1989,37 +2103,46 @@ const getSavedValue = savedState => {
|
|
|
1989
2103
|
}
|
|
1990
2104
|
return '';
|
|
1991
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
|
+
};
|
|
1992
2112
|
|
|
1993
2113
|
const restoreState = savedState => {
|
|
1994
2114
|
const searchValue = getSavedValue(savedState);
|
|
2115
|
+
const savedDeltaY = getSavedDeltaY(savedState);
|
|
1995
2116
|
return {
|
|
1996
|
-
searchValue
|
|
2117
|
+
searchValue,
|
|
2118
|
+
deltaY: savedDeltaY
|
|
1997
2119
|
};
|
|
1998
2120
|
};
|
|
1999
2121
|
|
|
2000
|
-
const loadContent = async (
|
|
2001
|
-
const {
|
|
2002
|
-
newState
|
|
2003
|
-
} = get$1(uid);
|
|
2122
|
+
const loadContent = async (state, savedState) => {
|
|
2004
2123
|
const {
|
|
2005
2124
|
width,
|
|
2006
2125
|
platform,
|
|
2007
2126
|
assetDir
|
|
2008
|
-
} =
|
|
2127
|
+
} = state;
|
|
2009
2128
|
const {
|
|
2010
|
-
searchValue
|
|
2129
|
+
searchValue,
|
|
2130
|
+
deltaY
|
|
2011
2131
|
} = restoreState(savedState);
|
|
2012
2132
|
// TODO just get local extensions on demand (not when query string is already different)
|
|
2013
2133
|
const allExtensions = await getAllExtensions(platform);
|
|
2014
2134
|
const size = getViewletSize(width);
|
|
2015
2135
|
const normalized = normalizeExtension(allExtensions, platform, assetDir);
|
|
2136
|
+
const inputActions = getInputActions(state);
|
|
2016
2137
|
const updatedState = await handleInput({
|
|
2017
|
-
...
|
|
2138
|
+
...state,
|
|
2018
2139
|
allExtensions: normalized,
|
|
2019
2140
|
size,
|
|
2020
|
-
inputSource: Script
|
|
2141
|
+
inputSource: Script,
|
|
2142
|
+
inputActions,
|
|
2143
|
+
deltaY
|
|
2021
2144
|
}, searchValue);
|
|
2022
|
-
|
|
2145
|
+
return updatedState;
|
|
2023
2146
|
};
|
|
2024
2147
|
|
|
2025
2148
|
const openSuggest = state => {
|
|
@@ -2049,14 +2172,6 @@ const SearchFieldButtons = 'SearchFieldButtons';
|
|
|
2049
2172
|
const SearchFieldContainer = 'SearchFieldContainer';
|
|
2050
2173
|
const SearchFieldDisabled = 'SearchFieldDisabled';
|
|
2051
2174
|
|
|
2052
|
-
const HandleContextMenu = 'handleContextMenu';
|
|
2053
|
-
const HandlePointerDown = 'handlePointerDown';
|
|
2054
|
-
const HandleTouchStart = 'handleTouchStart';
|
|
2055
|
-
const HandleWheel = 'handleWheel';
|
|
2056
|
-
const HandleExtensionsInput = 'handleExtensionsInput';
|
|
2057
|
-
const HandleClearSearchResults = 'handleClearSearchResults';
|
|
2058
|
-
const HandleClickFilter = 'handleClickFilter';
|
|
2059
|
-
|
|
2060
2175
|
const List = 'list';
|
|
2061
2176
|
const ListItem = 'listitem';
|
|
2062
2177
|
const None = 'none';
|
|
@@ -2150,24 +2265,6 @@ const getExtensionHeaderVirtualDom = (placeholder, actions) => {
|
|
|
2150
2265
|
return [parentNode, ...getSearchFieldVirtualDom('extensions', placeholder, HandleExtensionsInput, actions, [])];
|
|
2151
2266
|
};
|
|
2152
2267
|
|
|
2153
|
-
const getInputActions = newState => {
|
|
2154
|
-
const clearEnabled = newState.searchValue.length > 0;
|
|
2155
|
-
const actions = [{
|
|
2156
|
-
onClick: HandleClearSearchResults,
|
|
2157
|
-
icon: `MaskIcon${ClearAll}`,
|
|
2158
|
-
title: clearExtensionSearchResults(),
|
|
2159
|
-
type: Button$1,
|
|
2160
|
-
enabled: clearEnabled
|
|
2161
|
-
}, {
|
|
2162
|
-
icon: `MaskIcon${Filter}`,
|
|
2163
|
-
title: filter(),
|
|
2164
|
-
type: Button$1,
|
|
2165
|
-
onClick: HandleClickFilter,
|
|
2166
|
-
enabled: true
|
|
2167
|
-
}];
|
|
2168
|
-
return actions;
|
|
2169
|
-
};
|
|
2170
|
-
|
|
2171
2268
|
const renderHeader = newState => {
|
|
2172
2269
|
const actions = getInputActions(newState);
|
|
2173
2270
|
const dom = getExtensionHeaderVirtualDom(newState.placeholder, actions);
|
|
@@ -2338,7 +2435,7 @@ const renderScrollBar = newState => {
|
|
|
2338
2435
|
const total = newState.items.length;
|
|
2339
2436
|
const contentHeight = total * newState.itemHeight;
|
|
2340
2437
|
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, newState.minimumSliderSize);
|
|
2341
|
-
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);
|
|
2342
2439
|
const roundedScrollBarY = Math.round(scrollBarY);
|
|
2343
2440
|
const heightString = px(scrollBarHeight);
|
|
2344
2441
|
const translateString = position(0, roundedScrollBarY);
|
|
@@ -2449,19 +2546,37 @@ const renderEventListeners = () => {
|
|
|
2449
2546
|
name: HandleContextMenu,
|
|
2450
2547
|
params: ['handleContextMenu', 'event.button', 'event.clientX', 'event.clientY'],
|
|
2451
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']
|
|
2452
2564
|
}, {
|
|
2453
2565
|
name: HandleWheel,
|
|
2454
2566
|
params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
|
|
2455
2567
|
passive: true
|
|
2456
2568
|
}, {
|
|
2457
2569
|
name: HandleExtensionsInput,
|
|
2458
|
-
params: ['
|
|
2570
|
+
params: ['handleInput', 'event.target.value', User]
|
|
2459
2571
|
}, {
|
|
2460
2572
|
name: HandleClearSearchResults,
|
|
2461
2573
|
params: ['clearSearchResults']
|
|
2462
2574
|
}, {
|
|
2463
2575
|
name: HandleClickFilter,
|
|
2464
2576
|
params: ['handleClickFilter']
|
|
2577
|
+
}, {
|
|
2578
|
+
name: HandleFocus,
|
|
2579
|
+
params: ['handleFocus']
|
|
2465
2580
|
}];
|
|
2466
2581
|
};
|
|
2467
2582
|
|
|
@@ -2470,10 +2585,12 @@ const saveState = uid => {
|
|
|
2470
2585
|
newState
|
|
2471
2586
|
} = get$1(uid);
|
|
2472
2587
|
const {
|
|
2473
|
-
searchValue
|
|
2588
|
+
searchValue,
|
|
2589
|
+
deltaY
|
|
2474
2590
|
} = newState;
|
|
2475
2591
|
return {
|
|
2476
|
-
searchValue
|
|
2592
|
+
searchValue,
|
|
2593
|
+
deltaY
|
|
2477
2594
|
};
|
|
2478
2595
|
};
|
|
2479
2596
|
|
|
@@ -2486,10 +2603,6 @@ const scrollDown = state => {
|
|
|
2486
2603
|
return setDeltaY(state, newDeltaY);
|
|
2487
2604
|
};
|
|
2488
2605
|
|
|
2489
|
-
const terminate = () => {
|
|
2490
|
-
globalThis.close();
|
|
2491
|
-
};
|
|
2492
|
-
|
|
2493
2606
|
const toggleSuggest = state => {
|
|
2494
2607
|
return state;
|
|
2495
2608
|
};
|
|
@@ -2528,7 +2641,7 @@ const commandMap = {
|
|
|
2528
2641
|
'SearchExtensions.handleScrollBarThumbPointerMove': wrapCommand(handleScrollBarMove),
|
|
2529
2642
|
'SearchExtensions.handleUninstall': wrapCommand(handleUninstall),
|
|
2530
2643
|
'SearchExtensions.handleWheel': wrapCommand(handleWheel),
|
|
2531
|
-
'SearchExtensions.loadContent': loadContent,
|
|
2644
|
+
'SearchExtensions.loadContent': wrapCommand(loadContent),
|
|
2532
2645
|
'SearchExtensions.openSuggest': wrapCommand(openSuggest),
|
|
2533
2646
|
'SearchExtensions.render3': render3,
|
|
2534
2647
|
'SearchExtensions.renderActions': renderActions,
|
|
@@ -2544,8 +2657,9 @@ const commandMap = {
|
|
|
2544
2657
|
};
|
|
2545
2658
|
|
|
2546
2659
|
const listen = async () => {
|
|
2660
|
+
Object.assign(commandMapRef, commandMap);
|
|
2547
2661
|
const rpc = await WebWorkerRpcClient.create({
|
|
2548
|
-
commandMap:
|
|
2662
|
+
commandMap: commandMapRef
|
|
2549
2663
|
});
|
|
2550
2664
|
set(rpc);
|
|
2551
2665
|
};
|