@lvce-editor/extension-search-view 2.7.0 → 2.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.
@@ -1139,7 +1139,7 @@ const handleInput = async (state, value) => {
1139
1139
  placeholder: searchExtensionsInMarketPlace()
1140
1140
  };
1141
1141
  }
1142
- const listHeight = getListHeight(state.items.length, state.itemHeight, state.height);
1142
+ const listHeight = getListHeight(items.length, itemHeight, height);
1143
1143
  const total = items.length;
1144
1144
  const contentHeight = total * itemHeight;
1145
1145
  const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
@@ -1176,8 +1176,8 @@ const clearSearchResults = state => {
1176
1176
  return handleInput(state, '');
1177
1177
  };
1178
1178
 
1179
- const closeSuggest = () => {
1180
- // TODO
1179
+ const closeSuggest = state => {
1180
+ return state;
1181
1181
  };
1182
1182
 
1183
1183
  const states = Object.create(null);
@@ -1216,7 +1216,9 @@ const create = (id, uri, x, y, width, height, platform, assetDir) => {
1216
1216
  size: 0,
1217
1217
  width,
1218
1218
  x,
1219
- y
1219
+ y,
1220
+ focused: false,
1221
+ inputSource: 0
1220
1222
  };
1221
1223
  set$1(id, state, state);
1222
1224
  };
@@ -1227,31 +1229,31 @@ const RenderScrollBar = 5;
1227
1229
  const RenderMessage = 6;
1228
1230
 
1229
1231
  const diffType$4 = RenderItems;
1230
- const isEqual$4 = (oldState, newState) => {
1232
+ const isEqual$5 = (oldState, newState) => {
1231
1233
  return true;
1232
1234
  };
1233
1235
 
1234
1236
  const diffType$3 = RenderHeader;
1235
- const isEqual$3 = (oldState, newState) => {
1237
+ const isEqual$4 = (oldState, newState) => {
1236
1238
  return oldState.placeholder === newState.placeholder;
1237
1239
  };
1238
1240
 
1239
1241
  const diffType$2 = RenderItems;
1240
- const isEqual$2 = (oldState, newState) => {
1242
+ const isEqual$3 = (oldState, newState) => {
1241
1243
  return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY && oldState.focusedIndex === newState.focusedIndex;
1242
1244
  };
1243
1245
 
1244
1246
  const diffType$1 = RenderMessage;
1245
- const isEqual$1 = (oldState, newState) => {
1247
+ const isEqual$2 = (oldState, newState) => {
1246
1248
  return oldState.message === newState.message;
1247
1249
  };
1248
1250
 
1249
1251
  const diffType = RenderScrollBar;
1250
- const isEqual = (oldState, newState) => {
1252
+ const isEqual$1 = (oldState, newState) => {
1251
1253
  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;
1252
1254
  };
1253
1255
 
1254
- const modules = [isEqual$4, isEqual, isEqual$1, isEqual$3, isEqual$2];
1256
+ const modules = [isEqual$5, isEqual$1, isEqual$2, isEqual$4, isEqual$3];
1255
1257
  const numbers = [diffType$4, diffType, diffType$1, diffType$3, diffType$2];
1256
1258
 
1257
1259
  const diff = (oldState, newState) => {
@@ -1362,7 +1364,7 @@ const focusNext = state => {
1362
1364
  return focusIndex(state, nextIndex);
1363
1365
  };
1364
1366
 
1365
- const focusNextPage = async state => {
1367
+ const focusNextPage = state => {
1366
1368
  const {
1367
1369
  focusedIndex,
1368
1370
  items,
@@ -1376,7 +1378,7 @@ const focusNextPage = async state => {
1376
1378
  return focusIndex(state, indexNextPage);
1377
1379
  };
1378
1380
 
1379
- const focusPreviousPage = async state => {
1381
+ const focusPreviousPage = state => {
1380
1382
  const {
1381
1383
  focusedIndex,
1382
1384
  minLineY,
@@ -1509,6 +1511,30 @@ const handleClick = async (state, index) => {
1509
1511
  return focusIndex(state, actualIndex);
1510
1512
  };
1511
1513
 
1514
+ const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
1515
+ const relativeY = eventY - y + deltaY;
1516
+ const index = Math.floor(relativeY / itemHeight);
1517
+ return index;
1518
+ };
1519
+
1520
+ const selectIndex = (state, index) => {
1521
+ return {
1522
+ ...state,
1523
+ focusedIndex: index
1524
+ };
1525
+ };
1526
+
1527
+ const handleClickAt = async (state, eventX, eventY) => {
1528
+ const {
1529
+ x,
1530
+ y,
1531
+ itemHeight,
1532
+ deltaY
1533
+ } = state;
1534
+ const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight);
1535
+ return selectIndex(state, index);
1536
+ };
1537
+
1512
1538
  const handleClickCurrent = state => {
1513
1539
  const {
1514
1540
  focusedIndex
@@ -1539,11 +1565,12 @@ const handleContextMenu = async (state, button, x, y) => {
1539
1565
  };
1540
1566
 
1541
1567
  const handleDisable = (state, id) => {
1568
+ return state;
1542
1569
  // TODO
1543
1570
  };
1544
1571
 
1545
1572
  const handleEnable = (state, id) => {
1546
- // TODO
1573
+ return state;
1547
1574
  };
1548
1575
 
1549
1576
  const setFocus = async focusId => {
@@ -1557,6 +1584,7 @@ const handleFocus = async state => {
1557
1584
 
1558
1585
  // TODO show error / warning when installment fails / times out
1559
1586
  const handleInstall = async (state, id) => {
1587
+ return state;
1560
1588
  // TODO
1561
1589
  };
1562
1590
 
@@ -1687,7 +1715,7 @@ const handleScrollBarMove = (state, eventY) => {
1687
1715
 
1688
1716
  // TODO show error / warning when installment fails / times out
1689
1717
  const handleUninstall = async (state, id) => {
1690
- // TODO
1718
+ return state;
1691
1719
  };
1692
1720
 
1693
1721
  const handleWheel = (state, deltaMode, deltaY) => {
@@ -1717,12 +1745,16 @@ const getViewletSize = width => {
1717
1745
  return Large;
1718
1746
  };
1719
1747
 
1748
+ const User = 1;
1749
+ const Script = 2;
1750
+
1720
1751
  const getSavedValue = savedState => {
1721
1752
  if (savedState && typeof savedState === 'object' && 'searchValue' in savedState && typeof savedState.searchValue === 'string') {
1722
1753
  return savedState.searchValue;
1723
1754
  }
1724
1755
  return '';
1725
1756
  };
1757
+
1726
1758
  const restoreState = savedState => {
1727
1759
  const searchValue = getSavedValue(savedState);
1728
1760
  return {
@@ -1747,13 +1779,18 @@ const loadContent = async (uid, savedState) => {
1747
1779
  const updatedState = await handleInput({
1748
1780
  ...newState,
1749
1781
  allExtensions,
1750
- size
1782
+ size,
1783
+ inputSource: Script
1751
1784
  }, searchValue);
1752
1785
  set$1(uid, newState, updatedState);
1753
1786
  };
1754
1787
 
1755
- const openSuggest = () => {
1756
- // TODO
1788
+ const openSuggest = state => {
1789
+ return state;
1790
+ };
1791
+
1792
+ const isEqual = (oldState, newState) => {
1793
+ return newState.inputSource === User || oldState.searchValue === newState.searchValue;
1757
1794
  };
1758
1795
 
1759
1796
  const Actions = 'Actions';
@@ -2161,38 +2198,36 @@ const renderScrollBar$1 = newState => {
2161
2198
  };
2162
2199
 
2163
2200
  const renderExtensions = {
2164
- isEqual: isEqual$2,
2201
+ isEqual: isEqual$3,
2165
2202
  apply(oldState, newState) {
2166
2203
  return renderItems(newState);
2167
2204
  }
2168
2205
  };
2169
2206
  const renderScrollBar = {
2170
- isEqual: isEqual,
2207
+ isEqual: isEqual$1,
2171
2208
  apply(oldState, newState) {
2172
2209
  return renderScrollBar$1(newState);
2173
2210
  }
2174
2211
  };
2175
2212
  const renderMessage = {
2176
- isEqual: isEqual$1,
2213
+ isEqual: isEqual$2,
2177
2214
  apply(oldState, newState) {
2178
2215
  return renderMessage$1(newState);
2179
2216
  }
2180
2217
  };
2181
2218
  const renderSearchValue = {
2182
- isEqual(oldState, newState) {
2183
- return oldState.searchValue === newState.searchValue;
2184
- },
2219
+ isEqual: isEqual,
2185
2220
  apply(oldState, newState) {
2186
2221
  return [/* method */SetSearchValue, oldState.searchValue, newState.searchValue];
2187
2222
  }
2188
2223
  };
2189
2224
  const renderHeader = {
2190
- isEqual: isEqual$3,
2225
+ isEqual: isEqual$4,
2191
2226
  apply(oldState, newState) {
2192
2227
  return renderHeader$1(newState);
2193
2228
  }
2194
2229
  };
2195
- const render = [renderScrollBar, renderMessage, renderExtensions, renderSearchValue, renderHeader];
2230
+ const render = [renderScrollBar, renderMessage, renderExtensions, renderHeader, renderSearchValue];
2196
2231
  const doRender = (oldState, newState) => {
2197
2232
  const commands = [];
2198
2233
  for (const item of render) {
@@ -2278,10 +2313,13 @@ const renderEventListeners = () => {
2278
2313
  }];
2279
2314
  };
2280
2315
 
2281
- const saveState = state => {
2316
+ const saveState = uid => {
2317
+ const {
2318
+ newState
2319
+ } = get$1(uid);
2282
2320
  const {
2283
2321
  searchValue
2284
- } = state;
2322
+ } = newState;
2285
2323
  return {
2286
2324
  searchValue
2287
2325
  };
@@ -2296,15 +2334,12 @@ const scrollDown = state => {
2296
2334
  return setDeltaY(state, newDeltaY);
2297
2335
  };
2298
2336
 
2299
- const selectIndex = (state, index) => {
2300
- return {
2301
- ...state,
2302
- focusedIndex: index
2303
- };
2337
+ const terminate = () => {
2338
+ globalThis.close();
2304
2339
  };
2305
2340
 
2306
- const toggleSuggest = () => {
2307
- // TODO
2341
+ const toggleSuggest = state => {
2342
+ return state;
2308
2343
  };
2309
2344
 
2310
2345
  const wrapCommand = fn => {
@@ -2324,22 +2359,25 @@ const commandMap = {
2324
2359
  'SearchExtensions.create': create,
2325
2360
  'SearchExtensions.diff': diff,
2326
2361
  'SearchExtensions.focusFirst': wrapCommand(focusFirst),
2362
+ 'SearchExtensions.terminate': terminate,
2327
2363
  'SearchExtensions.focusIndex': wrapCommand(focusIndex),
2328
2364
  'SearchExtensions.focusLast': wrapCommand(focusLast),
2329
2365
  'SearchExtensions.focusNext': wrapCommand(focusNext),
2330
2366
  'SearchExtensions.focusNextPage': wrapCommand(focusNextPage),
2331
2367
  'SearchExtensions.focusPreviousPage': wrapCommand(focusPreviousPage),
2332
2368
  'SearchExtensions.getActions': getActions,
2369
+ 'SearchExtensions.getCommandIds': getCommandIds,
2333
2370
  'SearchExtensions.getKeyBindings': getKeyBindings,
2334
2371
  'SearchExtensions.handleBlur': wrapCommand(handleBlur),
2335
- 'SearchExtensions.handleInput': wrapCommand(handleInput),
2336
2372
  'SearchExtensions.handleClick': wrapCommand(handleClick),
2373
+ 'SearchExtensions.handleClickAt': wrapCommand(handleClickAt),
2337
2374
  'SearchExtensions.handleClickCurrent': wrapCommand(handleClickCurrent),
2338
2375
  'SearchExtensions.handleClickCurrentButKeepFocus': wrapCommand(handleClickCurrentButKeepFocus),
2339
2376
  'SearchExtensions.handleContextMenu': wrapCommand(handleContextMenu),
2340
2377
  'SearchExtensions.handleDisable': wrapCommand(handleDisable),
2341
2378
  'SearchExtensions.handleEnable': wrapCommand(handleEnable),
2342
2379
  'SearchExtensions.handleFocus': wrapCommand(handleFocus),
2380
+ 'SearchExtensions.handleInput': wrapCommand(handleInput),
2343
2381
  'SearchExtensions.handleInstall': wrapCommand(handleInstall),
2344
2382
  'SearchExtensions.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
2345
2383
  'SearchExtensions.handleScrollBarClick': wrapCommand(handleScrollBarClick),
@@ -2347,7 +2385,6 @@ const commandMap = {
2347
2385
  'SearchExtensions.handleUninstall': wrapCommand(handleUninstall),
2348
2386
  'SearchExtensions.handleWheel': wrapCommand(handleWheel),
2349
2387
  'SearchExtensions.loadContent': loadContent,
2350
- 'SearchExtensions.getCommandIds': getCommandIds,
2351
2388
  'SearchExtensions.openSuggest': wrapCommand(openSuggest),
2352
2389
  'SearchExtensions.render': doRender,
2353
2390
  'SearchExtensions.render2': render2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",