@lvce-editor/text-search-worker 3.30.0 → 3.32.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.
@@ -1652,14 +1652,15 @@ const focusSearchValueNext = state => {
1652
1652
  return focusMatchCase$1(state);
1653
1653
  };
1654
1654
 
1655
+ const Alert = 'alert';
1656
+ const Button$2 = 'button';
1655
1657
  const CheckBox = 'checkbox';
1656
1658
  const None$1 = 'none';
1659
+ const ScrollBar$1 = 'scrollbar';
1657
1660
  const Status = 'status';
1658
- const Tree = 'tree';
1659
- const TreeItem$1 = 'treeitem';
1660
1661
  const ToolBar = 'toolbar';
1661
- const Button$2 = 'button';
1662
- const Alert = 'alert';
1662
+ const Tree$1 = 'tree';
1663
+ const TreeItem$1 = 'treeitem';
1663
1664
 
1664
1665
  const Actions = 'Actions';
1665
1666
  const Badge = 'Badge';
@@ -1670,16 +1671,13 @@ const FileIcon = 'FileIcon';
1670
1671
  const FocusOutline = 'FocusOutline';
1671
1672
  const Grow = 'Grow';
1672
1673
  const Highlight = 'Highlight';
1673
- const ScrollBarThumb = 'ScrollBarThumb';
1674
1674
  const HighlightDeleted = 'HighlightDeleted';
1675
- const ScrollBar = 'ScrollBar';
1676
1675
  const HighlightInserted = 'HighlightInserted';
1677
1676
  const IconButton = 'IconButton';
1678
1677
  const Label = 'Label';
1679
1678
  const List = 'List';
1680
1679
  const MaskIcon = 'MaskIcon';
1681
1680
  const MaskIconBook = 'MaskIconBook';
1682
- const ScrollBarVertical = 'ScrollBarVertical';
1683
1681
  const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1684
1682
  const MaskIconChevronDown = 'MaskIconChevronDown';
1685
1683
  const MaskIconChevronRight = 'MaskIconChevronRight';
@@ -1690,6 +1688,9 @@ const MaskIconRegex = 'MaskIconRegex';
1690
1688
  const MaskIconReplaceAll = 'MaskIconReplaceAll';
1691
1689
  const MaskIconWholeWord = 'MaskIconWholeWord';
1692
1690
  const MultilineInputBox = 'MultilineInputBox';
1691
+ const ScrollBar = 'ScrollBar';
1692
+ const ScrollBarThumb = 'ScrollBarThumb';
1693
+ const ScrollBarVertical = 'ScrollBarVertical';
1693
1694
  const Search$1 = 'Search';
1694
1695
  const SearchField = 'SearchField';
1695
1696
  const SearchFieldButton = 'SearchFieldButton';
@@ -1710,8 +1711,10 @@ const SearchToggleButton = 'SearchToggleButton';
1710
1711
  const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1711
1712
  const SourceControlBadge = 'SourceControlBadge';
1712
1713
  const ToggleDetails = 'ToggleDetails';
1714
+ const Tree = 'Tree';
1713
1715
  const TreeItem = 'TreeItem';
1714
1716
  const TreeItemActive = 'TreeItemActive';
1717
+ const TreeItems$1 = 'TreeItems';
1715
1718
  const Viewlet = 'Viewlet';
1716
1719
  const ViewletSearchMessage = 'ViewletSearchMessage';
1717
1720
 
@@ -1908,7 +1911,7 @@ const getAbsolutePath = relativePath => {
1908
1911
  return `/${relativePath}`; // TODO support windows paths
1909
1912
  };
1910
1913
 
1911
- const getDisplayResult = (results, fileIcons, itemHeight, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY) => {
1914
+ const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY) => {
1912
1915
  const result = results[i];
1913
1916
  const {
1914
1917
  type,
@@ -1917,7 +1920,6 @@ const getDisplayResult = (results, fileIcons, itemHeight, i, setSize, searchTerm
1917
1920
  start
1918
1921
  } = result;
1919
1922
  const posInSet = i + 1;
1920
- const top = i * itemHeight;
1921
1923
  const focused = i === focusedIndex;
1922
1924
  const relativeIndex = i - minLineY;
1923
1925
  switch (type) {
@@ -1932,7 +1934,6 @@ const getDisplayResult = (results, fileIcons, itemHeight, i, setSize, searchTerm
1932
1934
  icon: fileIcons[relativeIndex],
1933
1935
  posInSet,
1934
1936
  setSize,
1935
- top,
1936
1937
  lineNumber,
1937
1938
  matchStart: 0,
1938
1939
  matchLength: 0,
@@ -1949,7 +1950,6 @@ const getDisplayResult = (results, fileIcons, itemHeight, i, setSize, searchTerm
1949
1950
  icon: '',
1950
1951
  posInSet,
1951
1952
  setSize,
1952
- top,
1953
1953
  lineNumber,
1954
1954
  matchStart: start,
1955
1955
  matchLength: searchTermLength,
@@ -1969,7 +1969,7 @@ const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLine
1969
1969
  const setSize = resultCount;
1970
1970
  const searchTermLength = searchTerm.length;
1971
1971
  for (let i = minLineY; i < maxLineY; i++) {
1972
- const displayResult = getDisplayResult(results, fileIcons, itemHeight, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY);
1972
+ const displayResult = getDisplayResult(results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY);
1973
1973
  displayResults.push(displayResult);
1974
1974
  }
1975
1975
  return displayResults;
@@ -1977,12 +1977,13 @@ const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLine
1977
1977
 
1978
1978
  const HandleClick = 'handleClick';
1979
1979
  const HandleExcludeInput = 'handleExcludeInput';
1980
- const HandleHeaderClick = 'handleHeaderClick';
1980
+ const HandleHeaderClick2 = 'handleHeaderClick2';
1981
1981
  const HandleHeaderFocusIn = 'handleHeaderFocusIn';
1982
1982
  const HandleIncludeInput = 'handleIncludeInput';
1983
1983
  const HandleInput = 'handleInput';
1984
1984
  const HandleListBlur = 'handleListBlur';
1985
1985
  const HandleReplaceInput = 'handleReplaceInput';
1986
+ const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
1986
1987
  const HandleWheel = 'handleWheel';
1987
1988
 
1988
1989
  const FilesToExclude = 'FilesToExclude';
@@ -2080,7 +2081,7 @@ const getSearchFieldButtonVirtualDom = button => {
2080
2081
  name
2081
2082
  } = button;
2082
2083
  return [{
2083
- type: Div,
2084
+ type: Button,
2084
2085
  className: mergeClassNames(SearchFieldButton, checked ? SearchFieldButtonChecked : ''),
2085
2086
  name,
2086
2087
  title,
@@ -2089,7 +2090,7 @@ const getSearchFieldButtonVirtualDom = button => {
2089
2090
  tabIndex: 0,
2090
2091
  childCount: 1
2091
2092
  }, {
2092
- type: Div,
2093
+ type: Span,
2093
2094
  className: mergeClassNames(MaskIcon, icon),
2094
2095
  childCount: 0
2095
2096
  }];
@@ -2258,7 +2259,7 @@ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage) => {
2258
2259
  className: SearchHeader,
2259
2260
  role: None$1,
2260
2261
  childCount: 2,
2261
- onClick: HandleHeaderClick,
2262
+ onClick: HandleHeaderClick2,
2262
2263
  onFocusIn: HandleHeaderFocusIn
2263
2264
  }, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage), ...getSearchHeaderDetailsVirtualDom(flags, message)];
2264
2265
  return dom;
@@ -2276,14 +2277,20 @@ const getSearchInputErrorVirtualDom = errorMessage => {
2276
2277
  }, text(errorMessage)];
2277
2278
  };
2278
2279
 
2279
- const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY) => {
2280
+ const TreeItems = 'TreeItems';
2281
+
2282
+ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) => {
2280
2283
  if (scrollBarHeight === 0) {
2281
2284
  return [];
2282
2285
  }
2283
2286
  return [{
2284
2287
  type: Div,
2285
2288
  className: mergeClassNames(ScrollBar, ScrollBarVertical),
2286
- childCount: 1
2289
+ childCount: 1,
2290
+ onPointerDown: HandleScrollBarPointerDown,
2291
+ role: ScrollBar$1,
2292
+ ariaControls: TreeItems,
2293
+ ariaValueNow: scrollBarValue
2287
2294
  }, {
2288
2295
  type: Div,
2289
2296
  className: ScrollBarThumb,
@@ -2448,28 +2455,39 @@ const getSearchResultVirtualDom = rowInfo => {
2448
2455
  return dom;
2449
2456
  };
2450
2457
 
2451
- const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight, scrollBarY) => {
2452
- const scrollBarDomNodes = scrollbarHeight === 0 ? 0 : 1;
2458
+ const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
2459
+ const pixelOffset = deltaY % itemHeight;
2453
2460
  return [{
2454
2461
  type: Div,
2455
- className: mergeClassNames(Viewlet, List, focusOutline ? FocusOutline : Empty),
2456
- role: Tree,
2457
- tabIndex: 0,
2458
- childCount: visibleItems.length + scrollBarDomNodes,
2462
+ className: TreeItems$1,
2463
+ childCount: visibleItems.length,
2459
2464
  onClick: HandleClick,
2460
2465
  onBlur: HandleListBlur,
2461
- onWheel: HandleWheel
2462
- }, ...visibleItems.flatMap(getSearchResultVirtualDom), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY)];
2466
+ onWheel: HandleWheel,
2467
+ id: TreeItems,
2468
+ top: `${-pixelOffset}px`
2469
+ }, ...visibleItems.flatMap(getSearchResultVirtualDom)];
2463
2470
  };
2464
2471
 
2465
- const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY) => {
2472
+ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight) => {
2473
+ const scrollBarDomNodes = scrollbarHeight === 0 ? 0 : 1;
2474
+ return [{
2475
+ type: Div,
2476
+ className: mergeClassNames(Viewlet, List, Tree, focusOutline ? FocusOutline : Empty),
2477
+ role: Tree$1,
2478
+ tabIndex: 0,
2479
+ childCount: 1 + scrollBarDomNodes
2480
+ }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
2481
+ };
2482
+
2483
+ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight) => {
2466
2484
  const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
2467
2485
  const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
2468
2486
  return [{
2469
2487
  type: Div,
2470
2488
  className: mergeClassNames(Viewlet, Search$1),
2471
2489
  childCount
2472
- }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY)];
2490
+ }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
2473
2491
  };
2474
2492
 
2475
2493
  const handleError = error => {
@@ -3038,31 +3056,22 @@ const toggleUseRegularExpression = state => {
3038
3056
  const getClickHandler = name => {
3039
3057
  switch (name) {
3040
3058
  case MatchCase:
3041
- // @ts-ignore
3042
3059
  return toggleMatchCase;
3043
3060
  case ToggleReplace:
3044
- // @ts-ignore
3045
3061
  return toggleReplace;
3046
3062
  case UseRegularExpression:
3047
- // @ts-ignore
3048
3063
  return toggleUseRegularExpression;
3049
3064
  case ReplaceAll:
3050
- // @ts-ignore
3051
3065
  return replaceAll;
3052
3066
  case MatchWholeWord:
3053
- // @ts-ignore
3054
3067
  return toggleMatchWholeWord;
3055
3068
  case PreserveCase:
3056
- // @ts-ignore
3057
3069
  return togglePreserveCase;
3058
3070
  case ToggleSearchDetails:
3059
- // @ts-ignore
3060
3071
  return toggleDetailsExpanded;
3061
3072
  case SearchOnlyOpenEditors:
3062
- // @ts-ignore
3063
3073
  return toggleOpenEditors;
3064
3074
  case UseExcludeSettings:
3065
- // @ts-ignore
3066
3075
  return toggleUseIgnoreFiles;
3067
3076
  case SearchValue:
3068
3077
  case ReplaceValue:
@@ -3275,9 +3284,12 @@ const focusPreviousPage = state => {
3275
3284
  return focusIndex(state, indexPreviousPage);
3276
3285
  };
3277
3286
 
3278
- const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight) => {
3287
+ const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight, itemCount) => {
3279
3288
  const relativeY = eventY - y - topHeight + deltaY;
3280
3289
  const index = Math.floor(relativeY / itemHeight);
3290
+ if (index >= itemCount) {
3291
+ return -1;
3292
+ }
3281
3293
  return index;
3282
3294
  };
3283
3295
 
@@ -3406,9 +3418,9 @@ const selectIndex = async (state, index) => {
3406
3418
  };
3407
3419
  }
3408
3420
  const {
3409
- items
3421
+ listItems
3410
3422
  } = state;
3411
- const searchResult = items[index];
3423
+ const searchResult = listItems[index];
3412
3424
  const fn = getSelectHandler(searchResult.type);
3413
3425
  return fn(state, searchResult, index);
3414
3426
  };
@@ -3419,10 +3431,11 @@ const handleClickAt = (state, eventX, eventY) => {
3419
3431
  y,
3420
3432
  itemHeight,
3421
3433
  deltaY,
3422
- flags
3434
+ flags,
3435
+ listItems
3423
3436
  } = state;
3424
3437
  const topHeight = getTopHeight(flags);
3425
- const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight);
3438
+ const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
3426
3439
  return selectIndex(state, index);
3427
3440
  };
3428
3441
 
@@ -3455,6 +3468,8 @@ const setDeltaY = (state, value) => {
3455
3468
  // TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
3456
3469
  const minLineY = Math.floor(newDeltaY / itemHeight);
3457
3470
  const maxLineY = minLineY + getNumberOfVisibleItems(listHeight, itemHeight);
3471
+
3472
+ // TODO update icons
3458
3473
  return {
3459
3474
  ...state,
3460
3475
  deltaY: newDeltaY,
@@ -3636,13 +3651,14 @@ const getFocusSelector = focusKey => {
3636
3651
 
3637
3652
  const renderItems = {
3638
3653
  isEqual(oldState, newState) {
3639
- return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons && oldState.searchInputErrorMessage === newState.searchInputErrorMessage;
3654
+ return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons && oldState.searchInputErrorMessage === newState.searchInputErrorMessage && oldState.deltaY === newState.deltaY;
3640
3655
  },
3641
3656
  apply(oldState, newState) {
3642
3657
  const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex, newState.collapsedPaths);
3643
3658
  const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
3659
+ const scrollBarValue = newState.deltaY / newState.finalDeltaY * 100;
3644
3660
  const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, newState.scrollBarHeight);
3645
- const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY);
3661
+ const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY, scrollBarValue, newState.deltaY, newState.itemHeight);
3646
3662
  return ['Viewlet.setDom2', newState.uid, dom];
3647
3663
  }
3648
3664
  };
@@ -3652,7 +3668,7 @@ const renderFocus = {
3652
3668
  },
3653
3669
  apply(oldState, newState) {
3654
3670
  const name = newState.focusSource === User ? '' : getFocusSelector(newState.focus);
3655
- return ['Viewlet.focusElementByName', name];
3671
+ return ['Viewlet.focusElementByName', newState.uid, name];
3656
3672
  }
3657
3673
  };
3658
3674
  const renderValue = {
@@ -3762,10 +3778,6 @@ const saveState = uid => {
3762
3778
  };
3763
3779
  };
3764
3780
 
3765
- const setFocus = async focusKey => {
3766
- await invoke$2('Focus.setFocus', focusKey);
3767
- };
3768
-
3769
3781
  const focusElement = (state, focusKey) => {
3770
3782
  return {
3771
3783
  ...state,
@@ -3774,6 +3786,10 @@ const focusElement = (state, focusKey) => {
3774
3786
  };
3775
3787
  };
3776
3788
 
3789
+ const setFocus = async focusKey => {
3790
+ await invoke$2('Focus.setFocus', focusKey);
3791
+ };
3792
+
3777
3793
  const getSearchFocusKey = key => {
3778
3794
  switch (key) {
3779
3795
  case SearchValue:
@@ -3800,11 +3816,26 @@ const getSearchFocusKey = key => {
3800
3816
  return FocusSearchOpenEditors;
3801
3817
  case UseExcludeSettings:
3802
3818
  return FocusIgnoreFiles;
3819
+ case ToggleReplace:
3820
+ return FocusToggleReplace;
3803
3821
  default:
3804
3822
  return Empty$1;
3805
3823
  }
3806
3824
  };
3807
3825
 
3826
+ const handleFocusIn = (state, key) => {
3827
+ const focusKey = getSearchFocusKey(key);
3828
+ if (state.focus === focusKey) {
3829
+ return state;
3830
+ }
3831
+ void setFocus(FocusSearch);
3832
+ return {
3833
+ ...state,
3834
+ focus: focusKey,
3835
+ focusSource: User
3836
+ };
3837
+ };
3838
+
3808
3839
  const focusSearchValue = state => {
3809
3840
  return focusElement(state, FocusSearchInput);
3810
3841
  };
@@ -3844,18 +3875,6 @@ const focusRegex = state => {
3844
3875
  const focusReplaceAll = state => {
3845
3876
  return focusElement(state, FocusSearchReplaceAll);
3846
3877
  };
3847
- const handleFocusIn = (state, key) => {
3848
- const focusKey = getSearchFocusKey(key);
3849
- if (state.focus === focusKey) {
3850
- return state;
3851
- }
3852
- void setFocus(FocusSearch);
3853
- return {
3854
- ...state,
3855
- focus: focusKey,
3856
- focusSource: User
3857
- };
3858
- };
3859
3878
 
3860
3879
  const submit = state => {
3861
3880
  return handleUpdate(state, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "3.30.0",
3
+ "version": "3.32.0",
4
4
  "description": "Text Search Worker",
5
5
  "main": "dist/textSearchWorkerMain.js",
6
6
  "type": "module",