@lvce-editor/extension-search-view 4.13.0 → 5.1.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.
@@ -1066,10 +1066,11 @@ const create$2 = () => {
1066
1066
  wrapCommand(fn) {
1067
1067
  const wrapped = async (uid, ...args) => {
1068
1068
  const {
1069
+ oldState,
1069
1070
  newState
1070
1071
  } = states[uid];
1071
1072
  const newerState = await fn(newState, ...args);
1072
- if (newState === newerState) {
1073
+ if (oldState === newerState || newState === newerState) {
1073
1074
  return;
1074
1075
  }
1075
1076
  const latest = states[uid];
@@ -1134,11 +1135,13 @@ const TargetValue = 'event.target.value';
1134
1135
 
1135
1136
  const Script$1 = 2;
1136
1137
 
1138
+ const ManageExtension$1 = 8;
1139
+
1137
1140
  const LeftClick = 0;
1138
1141
 
1139
1142
  const DebugWorker = 55;
1140
1143
  const ExtensionHostWorker = 44;
1141
- const RendererWorker$2 = 1;
1144
+ const RendererWorker$1 = 1;
1142
1145
 
1143
1146
  const None$2 = 0;
1144
1147
  const Input = 1;
@@ -1266,17 +1269,17 @@ const Ellipsis = 'Ellipsis';
1266
1269
  const getInputActions = hasValue => {
1267
1270
  const clearEnabled = hasValue;
1268
1271
  const actions = [{
1269
- onClick: HandleClearSearchResults,
1272
+ enabled: clearEnabled,
1270
1273
  icon: `MaskIcon${ClearAll}`,
1274
+ onClick: HandleClearSearchResults,
1271
1275
  title: clearExtensionSearchResults(),
1272
- type: Button,
1273
- enabled: clearEnabled
1276
+ type: Button
1274
1277
  }, {
1278
+ enabled: true,
1275
1279
  icon: `MaskIcon${Filter}`,
1276
- title: filter(),
1277
- type: Button,
1278
1280
  onClick: HandleClickFilter,
1279
- enabled: true
1281
+ title: filter(),
1282
+ type: Button
1280
1283
  }];
1281
1284
  return actions;
1282
1285
  };
@@ -1380,16 +1383,16 @@ const parseValue = value => {
1380
1383
  });
1381
1384
  const isLocal = enabled || builtin || disabled || outdated || installed;
1382
1385
  return {
1383
- query: replaced,
1384
- enabled,
1385
1386
  builtin,
1387
+ category,
1386
1388
  disabled,
1387
- outdated,
1388
- installed,
1389
+ enabled,
1389
1390
  id,
1390
- sort,
1391
+ installed,
1391
1392
  isLocal,
1392
- category
1393
+ outdated,
1394
+ query: replaced,
1395
+ sort
1393
1396
  };
1394
1397
  };
1395
1398
 
@@ -1470,12 +1473,12 @@ const handleChange = async (state, update) => {
1470
1473
  const inputActions = getInputActions(hasValue);
1471
1474
  const {
1472
1475
  allExtensions,
1476
+ assetDir,
1477
+ headerHeight,
1478
+ height,
1473
1479
  itemHeight,
1474
1480
  minimumSliderSize,
1475
- height,
1476
- platform,
1477
- assetDir,
1478
- headerHeight
1481
+ platform
1479
1482
  } = state;
1480
1483
  // TODO cancel ongoing requests
1481
1484
  // TODO handle errors
@@ -1487,15 +1490,15 @@ const handleChange = async (state, update) => {
1487
1490
  deltaY: 0,
1488
1491
  finalDeltaY: 0,
1489
1492
  focus: Input,
1493
+ inputActions,
1494
+ inputSource,
1490
1495
  items,
1491
1496
  maxLineY: 0,
1492
1497
  message: noExtensionsFound(),
1493
1498
  minLineY: 0,
1494
1499
  placeholder: searchExtensionsInMarketPlace(),
1495
1500
  scrollBarHeight: 0,
1496
- searchValue: value,
1497
- inputSource,
1498
- inputActions
1501
+ searchValue: value
1499
1502
  };
1500
1503
  }
1501
1504
  const total = items.length;
@@ -1511,6 +1514,8 @@ const handleChange = async (state, update) => {
1511
1514
  allExtensions,
1512
1515
  deltaY: 0,
1513
1516
  finalDeltaY,
1517
+ inputActions,
1518
+ inputSource,
1514
1519
  items,
1515
1520
  maxLineY,
1516
1521
  message: '',
@@ -1518,9 +1523,7 @@ const handleChange = async (state, update) => {
1518
1523
  placeholder: searchExtensionsInMarketPlace(),
1519
1524
  scrollBarHeight,
1520
1525
  scrollBarY,
1521
- searchValue: value,
1522
- inputSource,
1523
- inputActions
1526
+ searchValue: value
1524
1527
  };
1525
1528
 
1526
1529
  // TODO handle out of order responses (a bit complicated)
@@ -1539,8 +1542,8 @@ const clearSearchResults = state => {
1539
1542
  return handleChange(state, {
1540
1543
  ...state,
1541
1544
  focus: Input,
1542
- searchValue: '',
1543
- inputSource: Script$1
1545
+ inputSource: Script$1,
1546
+ searchValue: ''
1544
1547
  });
1545
1548
  };
1546
1549
 
@@ -1623,19 +1626,23 @@ const {
1623
1626
  invokeAndTransfer,
1624
1627
  set: set$3,
1625
1628
  dispose: dispose$2
1626
- } = create$1(RendererWorker$2);
1629
+ } = create$1(RendererWorker$1);
1627
1630
  const searchFileHtml = async uri => {
1628
1631
  return invoke$2('ExtensionHost.searchFileWithHtml', uri);
1629
1632
  };
1630
1633
  const getFilePathElectron = async file => {
1631
1634
  return invoke$2('FileSystemHandle.getFilePathElectron', file);
1632
1635
  };
1633
- const showContextMenu$1 = async (x, y, id, ...args) => {
1636
+ const showContextMenu = async (x, y, id, ...args) => {
1634
1637
  return invoke$2('ContextMenu.show', x, y, id, ...args);
1635
1638
  };
1636
1639
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1640
+ number(uid);
1641
+ number(menuId);
1642
+ number(x);
1643
+ number(y);
1637
1644
  // @ts-ignore
1638
- await RendererWorker.invoke('ContextMenu.show2', uid, menuId, x, y, args);
1645
+ await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
1639
1646
  };
1640
1647
  const getElectronVersion = async () => {
1641
1648
  return invoke$2('Process.getElectronVersion');
@@ -1752,6 +1759,9 @@ const getKeyBindings$1 = async () => {
1752
1759
  const writeClipBoardText = async text => {
1753
1760
  await invoke$2('ClipBoard.writeText', /* text */text);
1754
1761
  };
1762
+ const readClipBoardText = async () => {
1763
+ return invoke$2('ClipBoard.readText');
1764
+ };
1755
1765
  const writeClipBoardImage = async blob => {
1756
1766
  // @ts-ignore
1757
1767
  await invoke$2('ClipBoard.writeImage', /* text */blob);
@@ -1795,6 +1805,16 @@ const sendMessagePortToRendererProcess = async port => {
1795
1805
  // @ts-ignore
1796
1806
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command, DebugWorker);
1797
1807
  };
1808
+ const sendMessagePortToTextMeasurementWorker = async port => {
1809
+ const command = 'TextMeasurement.handleMessagePort';
1810
+ // @ts-ignore
1811
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
1812
+ };
1813
+ const sendMessagePortToSourceControlWorker = async port => {
1814
+ const command = 'SourceControl.handleMessagePort';
1815
+ // @ts-ignore
1816
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToSourceControlWorker', port, command, 0);
1817
+ };
1798
1818
  const getPreference = async key => {
1799
1819
  return await invoke$2('Preferences.get', key);
1800
1820
  };
@@ -1896,7 +1916,7 @@ const registerMockRpc = commandMap => {
1896
1916
  return mockRpc;
1897
1917
  };
1898
1918
 
1899
- const RendererWorker$1 = {
1919
+ const RendererWorker = {
1900
1920
  __proto__: null,
1901
1921
  activateByEvent,
1902
1922
  applyBulkReplacement,
@@ -1943,6 +1963,7 @@ const RendererWorker$1 = {
1943
1963
  openUri: openUri$2,
1944
1964
  openUrl,
1945
1965
  openWidget,
1966
+ readClipBoardText,
1946
1967
  readFile,
1947
1968
  registerMockRpc,
1948
1969
  registerWebViewInterceptor,
@@ -1959,7 +1980,9 @@ const RendererWorker$1 = {
1959
1980
  sendMessagePortToMarkdownWorker,
1960
1981
  sendMessagePortToRendererProcess,
1961
1982
  sendMessagePortToSearchProcess,
1983
+ sendMessagePortToSourceControlWorker,
1962
1984
  sendMessagePortToSyntaxHighlightingWorker,
1985
+ sendMessagePortToTextMeasurementWorker,
1963
1986
  set: set$3,
1964
1987
  setAdditionalFocus,
1965
1988
  setColorTheme,
@@ -1967,7 +1990,7 @@ const RendererWorker$1 = {
1967
1990
  setFocus,
1968
1991
  setWebViewPort,
1969
1992
  setWorkspacePath,
1970
- showContextMenu: showContextMenu$1,
1993
+ showContextMenu,
1971
1994
  showContextMenu2,
1972
1995
  showErrorDialog,
1973
1996
  showMessageBox,
@@ -1980,8 +2003,8 @@ const RendererWorker$1 = {
1980
2003
 
1981
2004
  const getFocusedItem = state => {
1982
2005
  const {
1983
- items,
1984
- focusedIndex
2006
+ focusedIndex,
2007
+ items
1985
2008
  } = state;
1986
2009
  if (focusedIndex === -1) {
1987
2010
  return undefined;
@@ -2011,10 +2034,10 @@ const stringifyRow = row => {
2011
2034
  };
2012
2035
  const getExtensionInfoText = extension => {
2013
2036
  const {
2014
- name: name$1,
2037
+ description: description$1,
2015
2038
  id: id$1,
2016
- publisher: publisher$1,
2017
- description: description$1
2039
+ name: name$1,
2040
+ publisher: publisher$1
2018
2041
  } = extension;
2019
2042
  const version$1 = ''; // TODO
2020
2043
  const marketplaceLink$1 = ''; // TODO
@@ -2053,14 +2076,14 @@ const copyExtensionInfo = async state => {
2053
2076
  };
2054
2077
 
2055
2078
  const {
2056
- get,
2057
- set: set$2,
2079
+ diff,
2058
2080
  dispose: dispose$1,
2059
- wrapCommand,
2081
+ get,
2060
2082
  getCommandIds,
2061
2083
  registerCommands,
2062
- wrapGetter,
2063
- diff
2084
+ set: set$2,
2085
+ wrapCommand,
2086
+ wrapGetter
2064
2087
  } = create$2();
2065
2088
 
2066
2089
  const create = (id, uri, x, y, width, height, platform, assetDir) => {
@@ -2308,15 +2331,15 @@ const focusPreviousPage = state => {
2308
2331
 
2309
2332
  const getActions = () => {
2310
2333
  return [{
2311
- type: Button,
2312
- id: refresh(),
2334
+ command: '',
2313
2335
  icon: Refresh,
2314
- command: ''
2336
+ id: refresh(),
2337
+ type: Button
2315
2338
  }, {
2316
- type: Button,
2317
- id: viewsAndMoreActions(),
2339
+ command: '',
2318
2340
  icon: Ellipsis,
2319
- command: ''
2341
+ id: viewsAndMoreActions(),
2342
+ type: Button
2320
2343
  }];
2321
2344
  };
2322
2345
 
@@ -2336,44 +2359,44 @@ const FocusExtensionsInput = 7000;
2336
2359
 
2337
2360
  const getKeyBindings = () => {
2338
2361
  return [{
2339
- key: Home,
2340
2362
  command: 'Extensions.focusFirst',
2363
+ key: Home,
2341
2364
  when: FocusExtensions
2342
2365
  }, {
2343
- key: End,
2344
2366
  command: 'Extensions.focusLast',
2367
+ key: End,
2345
2368
  when: FocusExtensions
2346
2369
  }, {
2347
- key: PageUp,
2348
2370
  command: 'Extensions.focusPreviousPage',
2371
+ key: PageUp,
2349
2372
  when: FocusExtensions
2350
2373
  }, {
2351
- key: PageDown,
2352
2374
  command: 'Extensions.focusNextPage',
2375
+ key: PageDown,
2353
2376
  when: FocusExtensions
2354
2377
  }, {
2355
- key: UpArrow,
2356
2378
  command: 'Extensions.focusPrevious',
2379
+ key: UpArrow,
2357
2380
  when: FocusExtensions
2358
2381
  }, {
2359
- key: DownArrow,
2360
2382
  command: 'Extensions.focusNext',
2383
+ key: DownArrow,
2361
2384
  when: FocusExtensions
2362
2385
  }, {
2363
- key: Space,
2364
2386
  command: 'Extensions.handleClickCurrentButKeepFocus',
2387
+ key: Space,
2365
2388
  when: FocusExtensions
2366
2389
  }, {
2367
- key: Enter,
2368
2390
  command: 'Extensions.handleClickCurrent',
2391
+ key: Enter,
2369
2392
  when: FocusExtensions
2370
2393
  }, {
2371
- key: CtrlCmd | Space,
2372
2394
  command: 'Extensions.toggleSuggest',
2395
+ key: CtrlCmd | Space,
2373
2396
  when: FocusExtensions
2374
2397
  }, {
2375
- key: CtrlCmd | DownArrow,
2376
2398
  command: 'Extensions.scrollDown',
2399
+ key: CtrlCmd | DownArrow,
2377
2400
  when: FocusExtensions
2378
2401
  }];
2379
2402
  };
@@ -2382,33 +2405,41 @@ const None$1 = 0;
2382
2405
 
2383
2406
  const getMenuEntries = () => {
2384
2407
  return [{
2385
- id: 'enable',
2386
- label: enable(),
2408
+ command: 'SearchExtensions.enable',
2387
2409
  flags: None$1,
2388
- command: 'SearchExtensions.enable'
2410
+ id: 'enable',
2411
+ label: enable()
2389
2412
  }, {
2390
- id: 'disable',
2391
- label: disable(),
2413
+ command: 'SearchExtensions.disable',
2392
2414
  flags: None$1,
2393
- command: 'SearchExtensions.disable'
2415
+ id: 'disable',
2416
+ label: disable()
2394
2417
  }, {
2395
- id: 'installAnotherVersion',
2396
- label: installAnotherVersion(),
2418
+ command: 'SearchExtensions.installAnotherVersion',
2397
2419
  flags: None$1,
2398
- command: 'SearchExtensions.installAnotherVersion'
2420
+ id: 'installAnotherVersion',
2421
+ label: installAnotherVersion()
2399
2422
  }, {
2400
- id: 'copy',
2401
- label: copy(),
2423
+ command: 'Extensions.copyExtensionInfo',
2402
2424
  flags: None$1,
2403
- command: 'Extensions.copyExtensionInfo'
2425
+ id: 'copy',
2426
+ label: copy()
2404
2427
  }, {
2405
- id: 'copyExtensionId',
2406
- label: copyExtensionId$1(),
2428
+ command: 'Extensions.copyExtensionId',
2407
2429
  flags: None$1,
2408
- command: 'Extensions.copyExtensionId'
2430
+ id: 'copyExtensionId',
2431
+ label: copyExtensionId$1()
2409
2432
  }];
2410
2433
  };
2411
2434
 
2435
+ const getMenuEntries2 = state => {
2436
+ return getMenuEntries();
2437
+ };
2438
+
2439
+ const getMenuIds = () => {
2440
+ return [ManageExtension$1];
2441
+ };
2442
+
2412
2443
  const handleBlur = state => {
2413
2444
  return {
2414
2445
  ...state,
@@ -2422,11 +2453,9 @@ const getExtensionDetailUri = extensionId => {
2422
2453
 
2423
2454
  const {
2424
2455
  invoke: invoke$1,
2425
- set: set$1,
2426
- showContextMenu,
2427
2456
  openUri: openUri$1,
2428
- sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1
2429
- } = RendererWorker$1;
2457
+ sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
2458
+ set: set$1} = RendererWorker;
2430
2459
 
2431
2460
  const openUri = async uri => {
2432
2461
  return openUri$1(uri);
@@ -2473,11 +2502,11 @@ const handleClickAt = async (state, button, eventX, eventY) => {
2473
2502
  return state;
2474
2503
  }
2475
2504
  const {
2476
- x,
2477
- y,
2478
- itemHeight,
2479
2505
  deltaY,
2480
- headerHeight
2506
+ headerHeight,
2507
+ itemHeight,
2508
+ x,
2509
+ y
2481
2510
  } = state;
2482
2511
  const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, headerHeight);
2483
2512
  return handleClick(state, index);
@@ -2497,18 +2526,20 @@ const handleClickCurrentButKeepFocus = state => {
2497
2526
  return handleClick(state, focusedIndex);
2498
2527
  };
2499
2528
 
2500
- const show = async (x, y, id) => {
2501
- number(x);
2502
- number(y);
2503
- number(id);
2504
- await showContextMenu(x, y, id);
2529
+ const show2 = async (uid, menuId, x, y, args) => {
2530
+ await showContextMenu2(uid, menuId, x, y, args);
2505
2531
  };
2506
2532
 
2507
2533
  const ManageExtension = 8;
2508
2534
 
2509
2535
  const handleContextMenu = async (state, button, x, y) => {
2510
2536
  // TODO use focused index when when context menu button is -1 (keyboard)
2511
- await show(x, y, ManageExtension);
2537
+ const {
2538
+ uid
2539
+ } = state;
2540
+ await show2(uid, ManageExtension, x, y, {
2541
+ menuId: ManageExtension
2542
+ });
2512
2543
  return state;
2513
2544
  };
2514
2545
 
@@ -2534,8 +2565,8 @@ const handleHeaderContextMenu = async state => {
2534
2565
 
2535
2566
  const handleInput = async (state, value, inputSource = User) => {
2536
2567
  return handleChange(state, {
2537
- searchValue: value,
2538
- inputSource
2568
+ inputSource,
2569
+ searchValue: value
2539
2570
  });
2540
2571
  };
2541
2572
 
@@ -2557,21 +2588,21 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
2557
2588
  if (relativeY <= halfScrollBarHeight) {
2558
2589
  // clicked at top
2559
2590
  return {
2560
- percent: 0,
2561
- handleOffset: relativeY
2591
+ handleOffset: relativeY,
2592
+ percent: 0
2562
2593
  };
2563
2594
  }
2564
2595
  if (relativeY <= height - halfScrollBarHeight) {
2565
2596
  // clicked in middle
2566
2597
  return {
2567
- percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight),
2568
- handleOffset: halfScrollBarHeight
2598
+ handleOffset: halfScrollBarHeight,
2599
+ percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight)
2569
2600
  };
2570
2601
  }
2571
2602
  // clicked at bottom
2572
2603
  return {
2573
- percent: 1,
2574
- handleOffset: scrollBarHeight - height + relativeY
2604
+ handleOffset: scrollBarHeight - height + relativeY,
2605
+ percent: 1
2575
2606
  };
2576
2607
  };
2577
2608
 
@@ -2586,11 +2617,11 @@ const setDeltaY = (state, value) => {
2586
2617
  object(state);
2587
2618
  number(value);
2588
2619
  const {
2589
- itemHeight,
2590
- finalDeltaY,
2591
2620
  deltaY,
2592
- height,
2621
+ finalDeltaY,
2593
2622
  headerHeight,
2623
+ height,
2624
+ itemHeight,
2594
2625
  items,
2595
2626
  minimumSliderSize
2596
2627
  } = state;
@@ -2609,8 +2640,8 @@ const setDeltaY = (state, value) => {
2609
2640
  return {
2610
2641
  ...state,
2611
2642
  deltaY: newDeltaY,
2612
- minLineY,
2613
2643
  maxLineY,
2644
+ minLineY,
2614
2645
  scrollBarY
2615
2646
  };
2616
2647
  };
@@ -2618,12 +2649,12 @@ const setDeltaY = (state, value) => {
2618
2649
  const handleScrollBarClick = (state, eventY) => {
2619
2650
  // TODO move this to list
2620
2651
  const {
2621
- y,
2622
2652
  deltaY,
2623
- headerHeight,
2624
2653
  finalDeltaY,
2654
+ headerHeight,
2655
+ height,
2625
2656
  scrollBarHeight,
2626
- height
2657
+ y
2627
2658
  } = state;
2628
2659
  const contentHeight = height - headerHeight;
2629
2660
  const relativeY = eventY - y - headerHeight;
@@ -2637,8 +2668,8 @@ const handleScrollBarClick = (state, eventY) => {
2637
2668
  };
2638
2669
  }
2639
2670
  const {
2640
- percent,
2641
- handleOffset
2671
+ handleOffset,
2672
+ percent
2642
2673
  } = getNewDeltaPercent(contentHeight, scrollBarHeight, relativeY);
2643
2674
  const newDeltaY = percent * finalDeltaY;
2644
2675
  return {
@@ -2658,12 +2689,12 @@ const getNewPercent = (contentHeight, scrollBarHeight, relativeY) => {
2658
2689
  };
2659
2690
  const handleScrollBarMove = (state, eventY) => {
2660
2691
  const {
2661
- y,
2662
- headerHeight,
2663
- handleOffset,
2664
2692
  finalDeltaY,
2693
+ handleOffset,
2694
+ headerHeight,
2665
2695
  height,
2666
- scrollBarHeight
2696
+ scrollBarHeight,
2697
+ y
2667
2698
  } = state;
2668
2699
  const relativeY = eventY - y - headerHeight - handleOffset;
2669
2700
  const contentHeight = height - headerHeight;
@@ -2700,8 +2731,9 @@ const createExtensionHostWorkerRpc = async () => {
2700
2731
  };
2701
2732
 
2702
2733
  const {
2703
- set,
2704
- invoke} = ExtensionHost;
2734
+ invoke,
2735
+ set
2736
+ } = ExtensionHost;
2705
2737
 
2706
2738
  const initializeExtensionHostWorker = async () => {
2707
2739
  const rpc = await createExtensionHostWorkerRpc();
@@ -2843,13 +2875,13 @@ const getPublisher = extension => {
2843
2875
 
2844
2876
  const normalizeExtension$1 = (extension, platform, assetDir) => {
2845
2877
  return {
2878
+ categories: getCategories(extension),
2879
+ description: getDescription(extension),
2880
+ icon: getIcon(extension, platform, assetDir),
2846
2881
  id: getId$1(extension),
2847
2882
  name: getName(extension),
2848
- description: getDescription(extension),
2849
- uri: '',
2850
2883
  publisher: getPublisher(extension),
2851
- icon: getIcon(extension, platform, assetDir),
2852
- categories: getCategories(extension)
2884
+ uri: ''
2853
2885
  };
2854
2886
  };
2855
2887
 
@@ -2878,20 +2910,20 @@ const restoreState = savedState => {
2878
2910
  const searchValue = getSavedValue(savedState);
2879
2911
  const savedDeltaY = getSavedDeltaY(savedState);
2880
2912
  return {
2881
- searchValue,
2882
- deltaY: savedDeltaY
2913
+ deltaY: savedDeltaY,
2914
+ searchValue
2883
2915
  };
2884
2916
  };
2885
2917
 
2886
2918
  const loadContent = async (state, savedState) => {
2887
2919
  const {
2888
- width,
2920
+ assetDir,
2889
2921
  platform,
2890
- assetDir
2922
+ width
2891
2923
  } = state;
2892
2924
  const {
2893
- searchValue,
2894
- deltaY
2925
+ deltaY,
2926
+ searchValue
2895
2927
  } = restoreState(savedState);
2896
2928
  // TODO just get local extensions on demand (not when query string is already different)
2897
2929
  const allExtensions = await getAllExtensions(platform);
@@ -2900,9 +2932,9 @@ const loadContent = async (state, savedState) => {
2900
2932
  const updatedState = await handleInput({
2901
2933
  ...state,
2902
2934
  allExtensions: normalized,
2903
- size,
2935
+ deltaY,
2904
2936
  inputSource: Script,
2905
- deltaY
2937
+ size
2906
2938
  }, searchValue, Script);
2907
2939
  return updatedState;
2908
2940
  };
@@ -2925,8 +2957,8 @@ const getSelector = focus => {
2925
2957
  };
2926
2958
  const renderFocus = newState => {
2927
2959
  const {
2928
- uid,
2929
- focus
2960
+ focus,
2961
+ uid
2930
2962
  } = newState;
2931
2963
  if (!focus) {
2932
2964
  return [];
@@ -2990,56 +3022,56 @@ const getClassName$1 = enabled => {
2990
3022
  };
2991
3023
  const getSearchFieldButtonVirtualDom = button => {
2992
3024
  const {
2993
- icon,
2994
- title,
2995
3025
  enabled,
2996
- onClick
3026
+ icon,
3027
+ onClick,
3028
+ title
2997
3029
  } = button;
2998
3030
  return [{
2999
- type: Button$2,
3031
+ childCount: 1,
3000
3032
  className: getClassName$1(enabled),
3001
- title,
3033
+ onClick,
3002
3034
  tabIndex: 0,
3003
- childCount: 1,
3004
- onClick
3035
+ title,
3036
+ type: Button$2
3005
3037
  }, {
3006
- type: Div,
3038
+ childCount: 0,
3007
3039
  className: mergeClassNames(MaskIcon, icon),
3008
- childCount: 0
3040
+ type: Div
3009
3041
  }];
3010
3042
  };
3011
3043
 
3012
3044
  const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, outsideButtons, onFocus = '') => {
3013
3045
  // TODO avoid mutation
3014
3046
  const dom = [{
3015
- type: Div,
3047
+ childCount: 2,
3016
3048
  className: SearchField,
3017
3049
  role: None,
3018
- childCount: 2
3050
+ type: Div
3019
3051
  }, {
3020
- type: Input$1,
3021
- inputType: 'search',
3022
- className: MultilineInputBox,
3023
- spellcheck: false,
3024
3052
  autocapitalize: 'off',
3025
- autocorrect: 'off',
3026
3053
  autocomplete: 'off',
3027
- placeholder,
3054
+ autocorrect: 'off',
3055
+ childCount: 0,
3056
+ className: MultilineInputBox,
3057
+ inputType: 'search',
3028
3058
  name,
3029
- onInput,
3030
3059
  onFocus,
3031
- childCount: 0
3060
+ onInput,
3061
+ placeholder,
3062
+ spellcheck: false,
3063
+ type: Input$1
3032
3064
  }, {
3033
- type: Div,
3065
+ childCount: insideButtons.length,
3034
3066
  className: SearchFieldButtons,
3035
- childCount: insideButtons.length
3067
+ type: Div
3036
3068
  }, ...insideButtons.flatMap(getSearchFieldButtonVirtualDom)];
3037
3069
  if (outsideButtons.length > 0) {
3038
3070
  dom.unshift({
3039
- type: Div,
3071
+ childCount: 1 + outsideButtons.length,
3040
3072
  className: SearchFieldContainer,
3041
3073
  role: None,
3042
- childCount: 1 + outsideButtons.length
3074
+ type: Div
3043
3075
  });
3044
3076
  dom.push(...outsideButtons.flatMap(getSearchFieldButtonVirtualDom));
3045
3077
  }
@@ -3047,10 +3079,10 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
3047
3079
  };
3048
3080
 
3049
3081
  const parentNode = {
3050
- type: Div,
3051
- className: ExtensionHeader,
3052
3082
  childCount: 1,
3053
- onContextMenu: HandleHeaderContextMenu
3083
+ className: ExtensionHeader,
3084
+ onContextMenu: HandleHeaderContextMenu,
3085
+ type: Div
3054
3086
  };
3055
3087
  const getExtensionHeaderVirtualDom = (placeholder, actions) => {
3056
3088
  return [parentNode, ...getSearchFieldVirtualDom(Extensions$1, placeholder, HandleExtensionsInput, actions, [])];
@@ -3065,29 +3097,29 @@ const renderHeader = newState => {
3065
3097
  const Extension = 'Extension';
3066
3098
 
3067
3099
  const listItemDetail = {
3068
- type: Div,
3100
+ childCount: 3,
3069
3101
  className: ExtensionListItemDetail,
3070
- childCount: 3
3102
+ type: Div
3071
3103
  };
3072
3104
  const listItemName = {
3073
- type: Div,
3105
+ childCount: 1,
3074
3106
  className: ExtensionListItemName,
3075
- childCount: 1
3107
+ type: Div
3076
3108
  };
3077
3109
  const listItemDescription = {
3078
- type: Div,
3110
+ childCount: 1,
3079
3111
  className: ExtensionListItemDescription,
3080
- childCount: 1
3112
+ type: Div
3081
3113
  };
3082
3114
  const listItemFooter = {
3083
- type: Div,
3115
+ childCount: 2,
3084
3116
  className: ExtensionListItemFooter,
3085
- childCount: 2
3117
+ type: Div
3086
3118
  };
3087
3119
  const listItemAuthorName = {
3088
- type: Div,
3120
+ childCount: 1,
3089
3121
  className: ExtensionListItemAuthorName,
3090
- childCount: 1
3122
+ type: Div
3091
3123
  };
3092
3124
  const getClassName = focused => {
3093
3125
  if (focused) {
@@ -3103,46 +3135,44 @@ const getId = focused => {
3103
3135
  };
3104
3136
  const getExtensionListItemVirtualDom = extension => {
3105
3137
  const {
3106
- posInSet,
3107
- setSize,
3108
- top,
3138
+ description,
3139
+ focused,
3109
3140
  icon,
3110
3141
  name,
3111
- description,
3142
+ posInSet,
3112
3143
  publisher,
3113
- focused
3144
+ setSize,
3145
+ top
3114
3146
  } = extension;
3115
3147
  const dom = [{
3116
- type: Div,
3117
- role: ListItem,
3148
+ ariaPosInSet: posInSet,
3118
3149
  ariaRoleDescription: Extension,
3150
+ ariaSetSize: setSize,
3151
+ childCount: 2,
3119
3152
  className: getClassName(focused),
3120
3153
  id: getId(focused),
3121
- ariaPosInSet: posInSet,
3122
- ariaSetSize: setSize,
3154
+ role: ListItem,
3123
3155
  top,
3124
- childCount: 2
3156
+ type: Div
3125
3157
  }, {
3126
- type: Img,
3127
- src: icon,
3158
+ childCount: 0,
3128
3159
  className: ExtensionListItemIcon,
3129
3160
  role: None,
3130
- childCount: 0
3161
+ src: icon,
3162
+ type: Img
3131
3163
  }, listItemDetail, listItemName, text(name), listItemDescription, text(description), listItemFooter, listItemAuthorName, text(publisher), {
3132
- type: Div,
3164
+ childCount: 0,
3133
3165
  className: ExtensionActions,
3134
- childCount: 0
3166
+ type: Div
3135
3167
  }];
3136
3168
  return dom;
3137
3169
  };
3138
3170
 
3139
3171
  const getExtensionsListVirtualDom = visibleExtensions => {
3140
3172
  const dom = [{
3141
- type: Div,
3142
- className: ListItems,
3143
- tabIndex: 0,
3144
3173
  ariaLabel: extensions(),
3145
- role: List,
3174
+ childCount: visibleExtensions.length,
3175
+ className: ListItems,
3146
3176
  onContextmenu: HandleContextMenu,
3147
3177
  onContextMenu: HandleContextMenu,
3148
3178
  onFocus: HandleFocus,
@@ -3151,7 +3181,9 @@ const getExtensionsListVirtualDom = visibleExtensions => {
3151
3181
  onTouchMove: HandleTouchMove,
3152
3182
  onTouchStart: HandleTouchStart,
3153
3183
  onWheel: HandleWheel,
3154
- childCount: visibleExtensions.length
3184
+ role: List,
3185
+ tabIndex: 0,
3186
+ type: Div
3155
3187
  }, ...visibleExtensions.flatMap(getExtensionListItemVirtualDom)];
3156
3188
  return dom;
3157
3189
  };
@@ -3178,50 +3210,50 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
3178
3210
  const heightString = px(scrollBarHeight);
3179
3211
  const translateString = position(0, scrollBarTop);
3180
3212
  return [{
3181
- type: Div,
3213
+ childCount: 1,
3182
3214
  className: mergeClassNames(ScrollBar, ScrollBarSmall),
3183
3215
  onPointerDown: HandleScrollBarPointerDown,
3184
3216
  // TODO support pointercapture event
3185
- childCount: 1
3217
+ type: Div
3186
3218
  }, {
3187
- type: Div,
3188
- className: ScrollBarThumb,
3189
3219
  childCount: 0,
3220
+ className: ScrollBarThumb,
3190
3221
  height: heightString,
3191
- translate: translateString
3222
+ translate: translateString,
3223
+ type: Div
3192
3224
  }];
3193
3225
  };
3194
3226
 
3195
3227
  const getVisibleItem = (item, setSize, itemHeight, minLineY, relative, i, focusedIndex) => {
3196
3228
  // TODO use normal parameters
3197
3229
  const {
3198
- publisher,
3199
3230
  description,
3200
3231
  icon,
3201
3232
  id,
3202
- name
3233
+ name,
3234
+ publisher
3203
3235
  } = item;
3204
3236
  return {
3205
- setSize,
3206
- posInSet: i + 1,
3207
- top: (i - minLineY) * itemHeight - relative,
3208
- focused: i === focusedIndex,
3209
- publisher,
3210
3237
  description,
3238
+ focused: i === focusedIndex,
3211
3239
  icon,
3212
3240
  id,
3213
- name
3241
+ name,
3242
+ posInSet: i + 1,
3243
+ publisher,
3244
+ setSize,
3245
+ top: (i - minLineY) * itemHeight - relative
3214
3246
  };
3215
3247
  };
3216
3248
 
3217
3249
  const getVisible = state => {
3218
3250
  const {
3219
- minLineY,
3220
- maxLineY,
3221
- items,
3222
- itemHeight,
3223
3251
  deltaY,
3224
- focusedIndex
3252
+ focusedIndex,
3253
+ itemHeight,
3254
+ items,
3255
+ maxLineY,
3256
+ minLineY
3225
3257
  } = state;
3226
3258
  const setSize = items.length;
3227
3259
  const visible = [];
@@ -3236,32 +3268,32 @@ const getVisible = state => {
3236
3268
  const getContentVirtualDom = (visibleExtensions, message, scrollBarHeight, scrollBarY) => {
3237
3269
  if (message) {
3238
3270
  return [{
3239
- type: Div,
3240
- childCount: 1
3271
+ childCount: 1,
3272
+ type: Div
3241
3273
  }, text(message)];
3242
3274
  }
3243
3275
  return [{
3244
- type: Div,
3276
+ childCount: 2,
3245
3277
  className: mergeClassNames(Viewlet, List$1),
3246
- childCount: 2
3278
+ type: Div
3247
3279
  }, ...getExtensionsVirtualDom(visibleExtensions), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarY)];
3248
3280
  };
3249
3281
  const getExtensionsViewVirtualDom = state => {
3250
3282
  const visibleExtensions = getVisible(state);
3251
3283
  const {
3252
- placeholder,
3253
3284
  inputActions,
3254
3285
  message,
3286
+ placeholder,
3255
3287
  scrollBarHeight,
3256
3288
  scrollBarY
3257
3289
  } = state;
3258
3290
  return [{
3259
- type: Div,
3260
- className: mergeClassNames(Viewlet, Extensions),
3261
- childCount: 2,
3262
- ariaLive: 'polite',
3263
3291
  ariaBusy: false,
3264
- role: None$3
3292
+ ariaLive: 'polite',
3293
+ childCount: 2,
3294
+ className: mergeClassNames(Viewlet, Extensions),
3295
+ role: None$3,
3296
+ type: Div
3265
3297
  }, ...getExtensionHeaderVirtualDom(placeholder, inputActions), ...getContentVirtualDom(visibleExtensions, message, scrollBarHeight, scrollBarY)];
3266
3298
  };
3267
3299
 
@@ -3299,6 +3331,12 @@ const renderSearchValue = newState => {
3299
3331
 
3300
3332
  const getRenderer = diffType => {
3301
3333
  switch (diffType) {
3334
+ case RenderFocus:
3335
+ return renderFocus;
3336
+ case RenderFocusContext:
3337
+ return renderFocusContext;
3338
+ case RenderHeader:
3339
+ return renderHeader;
3302
3340
  case RenderItems:
3303
3341
  return renderItems2;
3304
3342
  case RenderMessage:
@@ -3307,12 +3345,6 @@ const getRenderer = diffType => {
3307
3345
  return renderScrollBar;
3308
3346
  case RenderSearchValue:
3309
3347
  return renderSearchValue;
3310
- case RenderHeader:
3311
- return renderHeader;
3312
- case RenderFocus:
3313
- return renderFocus;
3314
- case RenderFocusContext:
3315
- return renderFocusContext;
3316
3348
  default:
3317
3349
  throw new Error('unknown renderer');
3318
3350
  }
@@ -3329,8 +3361,8 @@ const applyRender = (oldState, newState, diffResult) => {
3329
3361
 
3330
3362
  const render3 = (uid, diffResult) => {
3331
3363
  const {
3332
- oldState,
3333
- newState
3364
+ newState,
3365
+ oldState
3334
3366
  } = get(uid);
3335
3367
  set$2(uid, newState, newState);
3336
3368
  const commands = applyRender(oldState, newState, diffResult);
@@ -3339,23 +3371,23 @@ const render3 = (uid, diffResult) => {
3339
3371
 
3340
3372
  const getIconVirtualDom = (icon, type = Div) => {
3341
3373
  return {
3342
- type,
3374
+ childCount: 0,
3343
3375
  className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
3344
3376
  role: None,
3345
- childCount: 0
3377
+ type
3346
3378
  };
3347
3379
  };
3348
3380
 
3349
3381
  const getActionButtonVirtualDom = action => {
3350
3382
  const {
3351
- id,
3352
- icon
3383
+ icon,
3384
+ id
3353
3385
  } = action;
3354
3386
  return [{
3355
- type: Button$2,
3387
+ childCount: 1,
3356
3388
  className: IconButton,
3357
3389
  title: id,
3358
- childCount: 1
3390
+ type: Button$2
3359
3391
  }, getIconVirtualDom(icon)];
3360
3392
  };
3361
3393
 
@@ -3370,17 +3402,17 @@ const getActionVirtualDom = action => {
3370
3402
 
3371
3403
  const getActionsVirtualDom = actions => {
3372
3404
  return [{
3373
- type: Div,
3405
+ childCount: actions.length,
3374
3406
  className: Actions,
3375
3407
  role: ToolBar,
3376
- childCount: actions.length
3408
+ type: Div
3377
3409
  }, ...actions.flatMap(getActionVirtualDom)];
3378
3410
  };
3379
3411
 
3380
3412
  const renderActions = uid => {
3381
3413
  const {
3382
- oldState,
3383
- newState
3414
+ newState,
3415
+ oldState
3384
3416
  } = get(uid);
3385
3417
  if (oldState === newState) {
3386
3418
  return [];
@@ -3435,16 +3467,16 @@ const renderEventListeners = () => {
3435
3467
 
3436
3468
  const resize = async (state, dimensions) => {
3437
3469
  const {
3438
- items,
3439
- itemHeight,
3440
3470
  headerHeight,
3471
+ itemHeight,
3472
+ items,
3441
3473
  minimumSliderSize
3442
3474
  } = state;
3443
3475
  const {
3444
- x,
3445
- y,
3476
+ height,
3446
3477
  width,
3447
- height
3478
+ x,
3479
+ y
3448
3480
  } = dimensions;
3449
3481
  const total = items.length;
3450
3482
  const listHeight = getListHeight(total, itemHeight, height);
@@ -3469,19 +3501,19 @@ const resize = async (state, dimensions) => {
3469
3501
 
3470
3502
  const saveState = state => {
3471
3503
  const {
3472
- searchValue,
3473
- deltaY
3504
+ deltaY,
3505
+ searchValue
3474
3506
  } = state;
3475
3507
  return {
3476
- searchValue,
3477
- deltaY
3508
+ deltaY,
3509
+ searchValue
3478
3510
  };
3479
3511
  };
3480
3512
 
3481
3513
  const scrollDown = state => {
3482
3514
  const {
3483
- finalDeltaY,
3484
- deltaY
3515
+ deltaY,
3516
+ finalDeltaY
3485
3517
  } = state;
3486
3518
  const newDeltaY = Math.min(deltaY + 20, finalDeltaY);
3487
3519
  return setDeltaY(state, newDeltaY);
@@ -3510,7 +3542,6 @@ const commandMap = {
3510
3542
  'SearchExtensions.focusIndex': wrapCommand(focusIndex),
3511
3543
  'SearchExtensions.focusLast': wrapCommand(focusLast),
3512
3544
  'SearchExtensions.focusNext': wrapCommand(focusNext),
3513
- 'SearchExtensions.handleHeaderContextMenu': wrapCommand(handleHeaderContextMenu),
3514
3545
  'SearchExtensions.focusNextPage': wrapCommand(focusNextPage),
3515
3546
  'SearchExtensions.focusPrevious': wrapCommand(focusPrevious),
3516
3547
  'SearchExtensions.focusPreviousPage': wrapCommand(focusPreviousPage),
@@ -3518,6 +3549,8 @@ const commandMap = {
3518
3549
  'SearchExtensions.getCommandIds': getCommandIds,
3519
3550
  'SearchExtensions.getKeyBindings': getKeyBindings,
3520
3551
  'SearchExtensions.getMenuEntries': getMenuEntries,
3552
+ 'SearchExtensions.getMenuEntries2': wrapGetter(getMenuEntries2),
3553
+ 'SearchExtensions.getMenuIds': getMenuIds,
3521
3554
  'SearchExtensions.handleBlur': wrapCommand(handleBlur),
3522
3555
  'SearchExtensions.handleClick': wrapCommand(handleClick),
3523
3556
  'SearchExtensions.handleClickAt': wrapCommand(handleClickAt),
@@ -3527,6 +3560,7 @@ const commandMap = {
3527
3560
  'SearchExtensions.handleDisable': wrapCommand(handleDisable),
3528
3561
  'SearchExtensions.handleEnable': wrapCommand(handleEnable),
3529
3562
  'SearchExtensions.handleFocus': wrapCommand(handleFocus),
3563
+ 'SearchExtensions.handleHeaderContextMenu': wrapCommand(handleHeaderContextMenu),
3530
3564
  'SearchExtensions.handleInput': wrapCommand(handleInput),
3531
3565
  'SearchExtensions.handleInstall': wrapCommand(handleInstall),
3532
3566
  'SearchExtensions.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
@@ -3541,6 +3575,7 @@ const commandMap = {
3541
3575
  'SearchExtensions.render3': render3,
3542
3576
  'SearchExtensions.renderActions': renderActions,
3543
3577
  'SearchExtensions.renderEventListeners': renderEventListeners,
3578
+ 'SearchExtensions.resize': wrapCommand(resize),
3544
3579
  'SearchExtensions.restoreState': restoreState,
3545
3580
  'SearchExtensions.saveState': wrapGetter(saveState),
3546
3581
  'SearchExtensions.scrollDown': wrapCommand(scrollDown),
@@ -3548,8 +3583,7 @@ const commandMap = {
3548
3583
  'SearchExtensions.selectIndex': wrapCommand(selectIndex),
3549
3584
  'SearchExtensions.setDeltaY': wrapCommand(setDeltaY),
3550
3585
  'SearchExtensions.terminate': terminate,
3551
- 'SearchExtensions.toggleSuggest': wrapCommand(toggleSuggest),
3552
- 'SearchExtensions.resize': wrapCommand(resize)
3586
+ 'SearchExtensions.toggleSuggest': wrapCommand(toggleSuggest)
3553
3587
  };
3554
3588
 
3555
3589
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "4.13.0",
3
+ "version": "5.1.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "repository": {
6
6
  "type": "git",