@lvce-editor/extension-search-view 3.9.0 → 4.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.
@@ -967,7 +967,7 @@ const Disable = 'Disable';
967
967
  const InstallAnotherVersion = 'Install Another Version';
968
968
  const SearchExtensionsInMarketplace = 'Search Extensions in Marketplace';
969
969
  const ViewsAndMoreActions = 'Views and more Actions...';
970
- const Extensions = 'Extensions';
970
+ const Extensions$2 = 'Extensions';
971
971
  const Copy = 'Copy';
972
972
  const CopyExtensionId = 'CopyExtensionId';
973
973
 
@@ -981,7 +981,7 @@ const refresh = () => {
981
981
  return i18nString(Refresh$1);
982
982
  };
983
983
  const extensions = () => {
984
- return i18nString(Extensions);
984
+ return i18nString(Extensions$2);
985
985
  };
986
986
  const clearExtensionSearchResults = () => {
987
987
  return i18nString(ClearExtensionSearchResults);
@@ -1008,9 +1008,9 @@ const viewsAndMoreActions = () => {
1008
1008
  return i18nString(ViewsAndMoreActions);
1009
1009
  };
1010
1010
 
1011
- const None$2 = 0;
1011
+ const None$3 = 0;
1012
1012
  const Input = 1;
1013
- const List$1 = 2;
1013
+ const List$2 = 2;
1014
1014
 
1015
1015
  const getFinalDeltaY = (height, itemHeight, itemsLength) => {
1016
1016
  const contentHeight = itemsLength * itemHeight;
@@ -1278,24 +1278,15 @@ const create$1 = (id, uri, x, y, width, height, platform, assetDir) => {
1278
1278
  set$1(id, state, state);
1279
1279
  };
1280
1280
 
1281
- const isEqual$5 = (oldState, newState) => {
1282
- return true;
1283
- };
1284
-
1285
- const isEqual$4 = (oldState, newState) => {
1286
- return oldState.placeholder === newState.placeholder;
1287
- };
1288
-
1289
- const isEqual$3 = (oldState, newState) => {
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;
1291
- };
1292
-
1293
1281
  const isEqual$2 = (oldState, newState) => {
1294
- return oldState.message === newState.message;
1282
+ if (!newState.focus) {
1283
+ return true;
1284
+ }
1285
+ return oldState.focus === newState.focus;
1295
1286
  };
1296
1287
 
1297
1288
  const isEqual$1 = (oldState, newState) => {
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;
1289
+ 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;
1299
1290
  };
1300
1291
 
1301
1292
  const User = 1;
@@ -1311,9 +1302,10 @@ const RenderItems = 4;
1311
1302
  const RenderScrollBar = 5;
1312
1303
  const RenderMessage = 6;
1313
1304
  const RenderSearchValue = 7;
1305
+ const RenderFocusContext = 8;
1314
1306
 
1315
- const modules = [isEqual$1, isEqual$2, isEqual$4, isEqual$3, isEqual$5, isEqual];
1316
- const numbers = [RenderScrollBar, RenderMessage, RenderHeader, RenderItems, RenderFocus, RenderSearchValue];
1307
+ const modules = [isEqual$1, isEqual$2, isEqual, isEqual$2];
1308
+ const numbers = [RenderItems, RenderFocus, RenderSearchValue, RenderFocusContext];
1317
1309
 
1318
1310
  const diff2 = uid => {
1319
1311
  const {
@@ -1545,6 +1537,7 @@ const DownArrow = 16;
1545
1537
  const CtrlCmd = 1 << 11 >>> 0;
1546
1538
 
1547
1539
  const FocusExtensions = 15;
1540
+ const FocusExtensionsInput = 7000;
1548
1541
 
1549
1542
  const getKeyBindings = () => {
1550
1543
  return [{
@@ -1590,33 +1583,33 @@ const getKeyBindings = () => {
1590
1583
  }];
1591
1584
  };
1592
1585
 
1593
- const None$1 = 0;
1586
+ const None$2 = 0;
1594
1587
 
1595
1588
  const getMenuEntries = () => {
1596
1589
  return [{
1597
1590
  id: 'enable',
1598
1591
  label: enable(),
1599
- flags: None$1,
1592
+ flags: None$2,
1600
1593
  command: 'SearchExtensions.enable'
1601
1594
  }, {
1602
1595
  id: 'disable',
1603
1596
  label: disable(),
1604
- flags: None$1,
1597
+ flags: None$2,
1605
1598
  command: 'SearchExtensions.disable'
1606
1599
  }, {
1607
1600
  id: 'installAnotherVersion',
1608
1601
  label: installAnotherVersion(),
1609
- flags: None$1,
1602
+ flags: None$2,
1610
1603
  command: 'SearchExtensions.installAnotherVersion'
1611
1604
  }, {
1612
1605
  id: 'copy',
1613
1606
  label: copy(),
1614
- flags: None$1,
1607
+ flags: None$2,
1615
1608
  command: 'SearchExtensions.copy'
1616
1609
  }, {
1617
1610
  id: 'copyExtensionId',
1618
1611
  label: copyExtensionId(),
1619
- flags: None$1,
1612
+ flags: None$2,
1620
1613
  command: 'SearchExtensions.copyExtensionId'
1621
1614
  }];
1622
1615
  };
@@ -1624,7 +1617,7 @@ const getMenuEntries = () => {
1624
1617
  const handleBlur = state => {
1625
1618
  return {
1626
1619
  ...state,
1627
- focus: None$2
1620
+ focus: None$3
1628
1621
  };
1629
1622
  };
1630
1623
 
@@ -1672,36 +1665,22 @@ const {
1672
1665
  const showContextMenu$1 = async (x, y, id, ...args) => {
1673
1666
  return invoke$3('ContextMenu.show', x, y, id, ...args);
1674
1667
  };
1675
- const setFocus$2 = key => {
1676
- return invoke$3('Focus.setFocus', key);
1677
- };
1678
1668
  const openUri$2 = async (uri, focus, options) => {
1679
1669
  await invoke$3('Main.openUri', uri, focus, options);
1680
1670
  };
1681
- const RendererWorker$2 = {
1671
+ const RendererWorker = {
1682
1672
  __proto__: null,
1683
1673
  invoke: invoke$3,
1684
1674
  openUri: openUri$2,
1685
1675
  set: set$3,
1686
- setFocus: setFocus$2,
1687
1676
  showContextMenu: showContextMenu$1};
1688
1677
 
1689
1678
  const {
1690
1679
  invoke,
1691
1680
  set,
1692
1681
  showContextMenu,
1693
- setFocus: setFocus$1,
1694
1682
  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
- };
1683
+ } = RendererWorker;
1705
1684
 
1706
1685
  const openUri = async uri => {
1707
1686
  return openUri$1(uri);
@@ -1719,7 +1698,7 @@ const handleClick = async (state, index) => {
1719
1698
  const partialNewState = focusIndex(state, actualIndex);
1720
1699
  const newState = {
1721
1700
  ...partialNewState,
1722
- focus: List$1
1701
+ focus: List$2
1723
1702
  };
1724
1703
  return newState;
1725
1704
  };
@@ -1731,13 +1710,6 @@ const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, headerHeight) =>
1731
1710
  return index;
1732
1711
  };
1733
1712
 
1734
- const selectIndex = (state, index) => {
1735
- return {
1736
- ...state,
1737
- focusedIndex: index
1738
- };
1739
- };
1740
-
1741
1713
  const handleClickAt = async (state, eventX, eventY) => {
1742
1714
  const {
1743
1715
  x,
@@ -1747,7 +1719,7 @@ const handleClickAt = async (state, eventX, eventY) => {
1747
1719
  headerHeight
1748
1720
  } = state;
1749
1721
  const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, headerHeight);
1750
- return selectIndex(state, index);
1722
+ return handleClick(state, index);
1751
1723
  };
1752
1724
 
1753
1725
  const handleClickCurrent = state => {
@@ -1788,13 +1760,11 @@ const handleEnable = (state, id) => {
1788
1760
  return state;
1789
1761
  };
1790
1762
 
1791
- const {
1792
- setFocus
1793
- } = RendererWorker;
1794
-
1795
1763
  const handleFocus = async state => {
1796
- await setFocus(FocusExtensions);
1797
- return state;
1764
+ return {
1765
+ ...state,
1766
+ focus: List$2
1767
+ };
1798
1768
  };
1799
1769
 
1800
1770
  // TODO show error / warning when installment fails / times out
@@ -1874,6 +1844,7 @@ const setDeltaY = (state, value) => {
1874
1844
  };
1875
1845
 
1876
1846
  const handleScrollBarClick = (state, eventY) => {
1847
+ // TODO move this to list
1877
1848
  const {
1878
1849
  y,
1879
1850
  deltaY,
@@ -1965,6 +1936,8 @@ const HandlePointerDown = 'handlePointerDown';
1965
1936
  const HandleScrollBarMove = 'handleScrollBarMove';
1966
1937
  const HandleScrollBarPointerCaptureLost = 'handleScrollBarPointerCaptureLost';
1967
1938
  const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
1939
+ const HandleTouchEnd = 'handleTouchEnd';
1940
+ const HandleTouchMove = 'handleTouchMove';
1968
1941
  const HandleTouchStart = 'handleTouchStart';
1969
1942
  const HandleWheel = 'handleWheel';
1970
1943
 
@@ -2149,6 +2122,40 @@ const openSuggest = state => {
2149
2122
  return state;
2150
2123
  };
2151
2124
 
2125
+ const Extensions$1 = 'extensions';
2126
+
2127
+ const getSelector = focus => {
2128
+ switch (focus) {
2129
+ case Input:
2130
+ return `[name="${Extensions$1}"]`;
2131
+ case List$2:
2132
+ return '.ListItems';
2133
+ default:
2134
+ return '';
2135
+ }
2136
+ };
2137
+ const renderFocus = newState => {
2138
+ const {
2139
+ uid,
2140
+ focus
2141
+ } = newState;
2142
+ if (!focus) {
2143
+ return [];
2144
+ }
2145
+ const selector = getSelector(focus);
2146
+ return ['Viewlet.focusSelector', uid, selector];
2147
+ };
2148
+
2149
+ const renderFocusContext = newState => {
2150
+ if (newState.focus === Input) {
2151
+ return ['Viewlet.setFocusContext', FocusExtensionsInput];
2152
+ }
2153
+ if (newState.focus === List$2) {
2154
+ return ['Viewlet.setFocusContext', FocusExtensions];
2155
+ }
2156
+ return [];
2157
+ };
2158
+
2152
2159
  const Actions = 'Actions';
2153
2160
  const ExtensionActions = 'ExtensionActions';
2154
2161
  const ExtensionActive = 'ExtensionActive';
@@ -2160,10 +2167,14 @@ const ExtensionListItemDetail = 'ExtensionListItemDetail';
2160
2167
  const ExtensionListItemFooter = 'ExtensionListItemFooter';
2161
2168
  const ExtensionListItemIcon = 'ExtensionListItemIcon';
2162
2169
  const ExtensionListItemName = 'ExtensionListItemName';
2170
+ const Extensions = 'Extensions';
2163
2171
  const IconButton = 'IconButton';
2172
+ const List$1 = 'List';
2164
2173
  const ListItems = 'ListItems';
2165
2174
  const MaskIcon = 'MaskIcon';
2166
2175
  const MultilineInputBox = 'MultilineInputBox';
2176
+ const ScrollBar = 'ScrollBar';
2177
+ const ScrollBarSmall = 'ScrollBarSmall';
2167
2178
  const ScrollBarThumb = 'ScrollBarThumb';
2168
2179
  const ScrollBarThumbActive = 'ScrollBarThumbActive';
2169
2180
  const SearchField = 'SearchField';
@@ -2171,16 +2182,25 @@ const SearchFieldButton = 'SearchFieldButton';
2171
2182
  const SearchFieldButtons = 'SearchFieldButtons';
2172
2183
  const SearchFieldContainer = 'SearchFieldContainer';
2173
2184
  const SearchFieldDisabled = 'SearchFieldDisabled';
2185
+ const Viewlet = 'Viewlet';
2174
2186
 
2175
2187
  const List = 'list';
2176
2188
  const ListItem = 'listitem';
2177
- const None = 'none';
2189
+ const None$1 = 'none';
2178
2190
  const ToolBar = 'toolbar';
2179
2191
 
2192
+ const None = 'none';
2193
+ const AriaRoles = {
2194
+ __proto__: null,
2195
+ None};
2180
2196
  const mergeClassNames = (...classNames) => {
2181
2197
  return classNames.filter(Boolean).join(' ');
2182
2198
  };
2199
+ const Div$1 = 4;
2183
2200
  const Text = 12;
2201
+ const VirtualDomElements = {
2202
+ __proto__: null,
2203
+ Div: Div$1};
2184
2204
  const text = data => {
2185
2205
  return {
2186
2206
  type: Text,
@@ -2226,7 +2246,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
2226
2246
  const dom = [{
2227
2247
  type: Div,
2228
2248
  className: SearchField,
2229
- role: None,
2249
+ role: None$1,
2230
2250
  childCount: 2
2231
2251
  }, {
2232
2252
  type: TextArea,
@@ -2248,7 +2268,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
2248
2268
  dom.unshift({
2249
2269
  type: Div,
2250
2270
  className: SearchFieldContainer,
2251
- role: None,
2271
+ role: None$1,
2252
2272
  childCount: 1 + outsideButtons.length
2253
2273
  });
2254
2274
  dom.push(...outsideButtons.flatMap(getSearchFieldButtonVirtualDom));
@@ -2335,7 +2355,7 @@ const getExtensionListItemVirtualDom = extension => {
2335
2355
  type: Img,
2336
2356
  src: icon,
2337
2357
  className: ExtensionListItemIcon,
2338
- role: None,
2358
+ role: None$1,
2339
2359
  childCount: 0
2340
2360
  }, listItemDetail, listItemName, text(name), listItemDescription, text(description), listItemFooter, listItemAuthorName, text(publisher), {
2341
2361
  type: Div,
@@ -2352,10 +2372,14 @@ const getExtensionsListVirtualDom = visibleExtensions => {
2352
2372
  tabIndex: 0,
2353
2373
  ariaLabel: extensions(),
2354
2374
  role: List,
2355
- oncontextmenu: HandleContextMenu,
2356
- onpointerdown: HandlePointerDown,
2357
- ontouchstart: HandleTouchStart,
2358
- onwheelpassive: HandleWheel,
2375
+ onContextmenu: HandleContextMenu,
2376
+ onContextMenu: HandleContextMenu,
2377
+ onFocus: HandleFocus,
2378
+ onPointerDown: HandlePointerDown,
2379
+ onTouchEnd: HandleTouchEnd,
2380
+ onTouchMove: HandleTouchMove,
2381
+ onTouchStart: HandleTouchStart,
2382
+ onWheel: HandleWheel,
2359
2383
  childCount: visibleExtensions.length
2360
2384
  }, ...visibleExtensions.flatMap(getExtensionListItemVirtualDom)];
2361
2385
  return dom;
@@ -2367,6 +2391,36 @@ const getExtensionsVirtualDom = visibleExtensions => {
2367
2391
  return dom;
2368
2392
  };
2369
2393
 
2394
+ const px = value => {
2395
+ return `${value}px`;
2396
+ };
2397
+ const position = (x, y) => {
2398
+ return `${x}px ${y}px`;
2399
+ };
2400
+
2401
+ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
2402
+ const shouldShowScrollbar = scrollBarHeight > 0;
2403
+ if (!shouldShowScrollbar) {
2404
+ return [];
2405
+ }
2406
+ // TODO move the dynamic css into a css adopted stylesheet
2407
+ const heightString = px(scrollBarHeight);
2408
+ const translateString = position(0, scrollBarTop);
2409
+ return [{
2410
+ type: Div,
2411
+ className: mergeClassNames(ScrollBar, ScrollBarSmall),
2412
+ onPointerDown: HandleScrollBarPointerDown,
2413
+ // TODO support pointercapture event
2414
+ childCount: 1
2415
+ }, {
2416
+ type: Div,
2417
+ className: ScrollBarThumb,
2418
+ childCount: 0,
2419
+ height: heightString,
2420
+ translate: translateString
2421
+ }];
2422
+ };
2423
+
2370
2424
  const getVisibleItem = (item, setSize, itemHeight, minLineY, relative, i, focusedIndex) => {
2371
2425
  // TODO use normal parameters
2372
2426
  const {
@@ -2408,28 +2462,50 @@ const getVisible = state => {
2408
2462
  return visible;
2409
2463
  };
2410
2464
 
2411
- const renderItems = newState => {
2412
- // TODO render extensions incrementally when scrolling
2413
- const visibleExtensions = getVisible(newState);
2414
- const dom = getExtensionsVirtualDom(visibleExtensions);
2415
- return ['setExtensionsDom', dom];
2465
+ const getContentVirtualDom = (visibleExtensions, message, scrollBarHeight, scrollBarY) => {
2466
+ if (message) {
2467
+ return [{
2468
+ type: VirtualDomElements.Div,
2469
+ childCount: 1
2470
+ }, text(message)];
2471
+ }
2472
+ return [{
2473
+ type: VirtualDomElements.Div,
2474
+ className: mergeClassNames(Viewlet, List$1),
2475
+ childCount: 2
2476
+ }, ...getExtensionsVirtualDom(visibleExtensions), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarY)];
2477
+ };
2478
+ const getExtensionsViewVirtualDom = state => {
2479
+ const visibleExtensions = getVisible(state);
2480
+ const {
2481
+ placeholder,
2482
+ inputActions,
2483
+ message,
2484
+ scrollBarHeight,
2485
+ scrollBarY
2486
+ } = state;
2487
+ return [{
2488
+ type: VirtualDomElements.Div,
2489
+ className: mergeClassNames(Viewlet, Extensions),
2490
+ childCount: 2,
2491
+ ariaLive: 'polite',
2492
+ ariaBusy: false,
2493
+ role: AriaRoles.None
2494
+ }, ...getExtensionHeaderVirtualDom(placeholder, inputActions), ...getContentVirtualDom(visibleExtensions, message, scrollBarHeight, scrollBarY)];
2495
+ };
2496
+
2497
+ const renderItems2 = newState => {
2498
+ const dom = getExtensionsViewVirtualDom(newState);
2499
+ return ['Viewlet.setDom2', newState.uid, dom];
2416
2500
  };
2417
2501
 
2418
2502
  const SetMessage = 'setMessage';
2419
2503
  const SetScrollBar = 'setScrollBar';
2420
- const SetSearchValue = 'setSearchValue';
2421
2504
 
2422
2505
  const renderMessage = newState => {
2423
2506
  return [/* method */SetMessage, /* message */newState.message];
2424
2507
  };
2425
2508
 
2426
- const px = value => {
2427
- return `${value}px`;
2428
- };
2429
- const position = (x, y) => {
2430
- return `${x}px ${y}px`;
2431
- };
2432
-
2433
2509
  const renderScrollBar = newState => {
2434
2510
  const listHeight = getListHeight(newState.items.length, newState.itemHeight, newState.height);
2435
2511
  const total = newState.items.length;
@@ -2447,13 +2523,13 @@ const renderScrollBar = newState => {
2447
2523
  };
2448
2524
 
2449
2525
  const renderSearchValue = newState => {
2450
- return [/* method */SetSearchValue, '', newState.searchValue];
2526
+ return [/* method */'Viewlet.setValueByName', newState.uid, Extensions$1, newState.searchValue];
2451
2527
  };
2452
2528
 
2453
2529
  const getRenderer = diffType => {
2454
2530
  switch (diffType) {
2455
2531
  case RenderItems:
2456
- return renderItems;
2532
+ return renderItems2;
2457
2533
  case RenderMessage:
2458
2534
  return renderMessage;
2459
2535
  case RenderScrollBar:
@@ -2462,6 +2538,10 @@ const getRenderer = diffType => {
2462
2538
  return renderSearchValue;
2463
2539
  case RenderHeader:
2464
2540
  return renderHeader;
2541
+ case RenderFocus:
2542
+ return renderFocus;
2543
+ case RenderFocusContext:
2544
+ return renderFocusContext;
2465
2545
  default:
2466
2546
  throw new Error('unknown renderer');
2467
2547
  }
@@ -2471,7 +2551,7 @@ const applyRender = (oldState, newState, diffResult) => {
2471
2551
  const commands = [];
2472
2552
  for (const item of diffResult) {
2473
2553
  const fn = getRenderer(item);
2474
- commands.push(fn(newState));
2554
+ commands.push(fn(newState, oldState));
2475
2555
  }
2476
2556
  return commands;
2477
2557
  };
@@ -2490,7 +2570,7 @@ const getIconVirtualDom = (icon, type = Div) => {
2490
2570
  return {
2491
2571
  type,
2492
2572
  className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
2493
- role: None,
2573
+ role: None$1,
2494
2574
  childCount: 0
2495
2575
  };
2496
2576
  };
@@ -2603,6 +2683,13 @@ const scrollDown = state => {
2603
2683
  return setDeltaY(state, newDeltaY);
2604
2684
  };
2605
2685
 
2686
+ const selectIndex = (state, index) => {
2687
+ return {
2688
+ ...state,
2689
+ focusedIndex: index
2690
+ };
2691
+ };
2692
+
2606
2693
  const toggleSuggest = state => {
2607
2694
  return state;
2608
2695
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "3.9.0",
3
+ "version": "4.0.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",