@lvce-editor/text-search-worker 3.6.0 → 3.8.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.
@@ -1059,7 +1059,9 @@ const UiStrings = {
1059
1059
  ReplacedOneOccurrenceInOneFile: "Replaced 1 occurrence across 1 file with '{PH1}'",
1060
1060
  ToggleReplace: 'Toggle Replace',
1061
1061
  UseRegularExpression: 'Use Regular Expression',
1062
- ViewAsTree: 'View as Tree'
1062
+ ViewAsTree: 'View as Tree',
1063
+ FilesToInclude: 'Files to Include',
1064
+ FilesToExclude: 'Files to Exclude'
1063
1065
  };
1064
1066
  const noResults = () => {
1065
1067
  return i18nString(UiStrings.NoResults);
@@ -1151,6 +1153,12 @@ const viewAsTree = () => {
1151
1153
  const collapseAll = () => {
1152
1154
  return i18nString(UiStrings.CollapseAll);
1153
1155
  };
1156
+ const filesToInclude = () => {
1157
+ return i18nString(UiStrings.FilesToInclude);
1158
+ };
1159
+ const filesToExclude = () => {
1160
+ return i18nString(UiStrings.FilesToExclude);
1161
+ };
1154
1162
 
1155
1163
  const getStatusMessage = (resultCount, fileResultCount) => {
1156
1164
  number(resultCount);
@@ -1340,9 +1348,6 @@ const hasMatchWholeWord = flags => {
1340
1348
  const hasMatchCase = flags => {
1341
1349
  return (flags & MatchCase) === MatchCase;
1342
1350
  };
1343
- const hasDetailsExpanded = flags => {
1344
- return (flags & DetailsExpanded) === DetailsExpanded;
1345
- };
1346
1351
 
1347
1352
  const focusSearchValueNext = state => {
1348
1353
  if (hasReplaceExpanded(state.flags)) {
@@ -1357,6 +1362,7 @@ const Status = 'status';
1357
1362
  const Tree = 'tree';
1358
1363
  const TreeItem$1 = 'treeitem';
1359
1364
  const ToolBar = 'toolbar';
1365
+ const Button$2 = 'button';
1360
1366
 
1361
1367
  const Actions = 'Actions';
1362
1368
  const Badge = 'Badge';
@@ -1369,6 +1375,7 @@ const Grow = 'Grow';
1369
1375
  const Highlight = 'Highlight';
1370
1376
  const HighlightDeleted = 'HighlightDeleted';
1371
1377
  const HighlightInserted = 'HighlightInserted';
1378
+ const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1372
1379
  const IconButton = 'IconButton';
1373
1380
  const Label = 'Label';
1374
1381
  const List = 'List';
@@ -1376,6 +1383,7 @@ const MaskIcon = 'MaskIcon';
1376
1383
  const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1377
1384
  const MaskIconChevronDown = 'MaskIconChevronDown';
1378
1385
  const MaskIconChevronRight = 'MaskIconChevronRight';
1386
+ const MaskIconEllipsis = 'MaskIconEllipsis';
1379
1387
  const MaskIconPreserveCase = 'MaskIconPreserveCase';
1380
1388
  const MaskIconRegex = 'MaskIconRegex';
1381
1389
  const MaskIconReplaceAll = 'MaskIconReplaceAll';
@@ -1395,6 +1403,7 @@ const SearchRemove = 'SearchRemove';
1395
1403
  const SearchToggleButton = 'SearchToggleButton';
1396
1404
  const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1397
1405
  const SourceControlBadge = 'SourceControlBadge';
1406
+ const ToggleDetails = 'ToggleDetails';
1398
1407
  const TreeItem = 'TreeItem';
1399
1408
  const TreeItemActive = 'TreeItemActive';
1400
1409
  const Viewlet = 'Viewlet';
@@ -1404,7 +1413,6 @@ const Button$1 = 1;
1404
1413
 
1405
1414
  const Button = 1;
1406
1415
  const Div = 4;
1407
- const Input = 6;
1408
1416
  const Span = 8;
1409
1417
  const Text = 12;
1410
1418
  const Img = 17;
@@ -1602,6 +1610,48 @@ const HandleHeaderClick = 'handleHeaderClick';
1602
1610
  const HandleHeaderFocusIn = 'handleHeaderFocusIn';
1603
1611
  const HandleListBlur = 'handleListBlur';
1604
1612
 
1613
+ const getSearchDetailsToggleVirtualDom = () => {
1614
+ return [{
1615
+ type: Div,
1616
+ className: ToggleDetails,
1617
+ role: Button$2,
1618
+ tabIndex: 0,
1619
+ ariaLabel: 'Toggle Search Details',
1620
+ title: 'Toggle Search Details',
1621
+ childCount: 1
1622
+ }, {
1623
+ type: Div,
1624
+ className: mergeClassNames(MaskIcon, MaskIconEllipsis),
1625
+ childCount: 0
1626
+ }];
1627
+ };
1628
+
1629
+ const text = data => {
1630
+ return {
1631
+ type: Text,
1632
+ text: data,
1633
+ childCount: 0
1634
+ };
1635
+ };
1636
+
1637
+ const getSearchMessageVirtualDom = message => {
1638
+ return [{
1639
+ type: Div,
1640
+ className: ViewletSearchMessage,
1641
+ role: Status,
1642
+ tabIndex: 0,
1643
+ childCount: 1
1644
+ }, text(message)];
1645
+ };
1646
+
1647
+ const getSearchHeaderDetailsCollapsedVirtualDom = message => {
1648
+ return [{
1649
+ type: Div,
1650
+ className: SearchHeaderDetails,
1651
+ childCount: 2
1652
+ }, ...getSearchMessageVirtualDom(message), ...getSearchDetailsToggleVirtualDom()];
1653
+ };
1654
+
1605
1655
  const getSearchFieldButtonVirtualDom = button => {
1606
1656
  const {
1607
1657
  icon,
@@ -1669,28 +1719,23 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
1669
1719
  return dom;
1670
1720
  };
1671
1721
 
1672
- const text = data => {
1673
- return {
1674
- type: Text,
1675
- text: data,
1676
- childCount: 0
1677
- };
1722
+ const getSearchHeaderDetailsExpandedVirtualDom = message => {
1723
+ return [{
1724
+ type: Div,
1725
+ className: SearchHeaderDetailsExpanded,
1726
+ childCount: 6
1727
+ }, ...getSearchDetailsToggleVirtualDom(), text(filesToInclude()), ...getSearchFieldVirtualDom('files-to-include-value', 'Include', 'handleIncludeInput', [], []), text(filesToExclude()), ...getSearchFieldVirtualDom('files-to-exclude-value', 'Exclude', 'handleExcludeInput', [], []), ...getSearchMessageVirtualDom(message)];
1678
1728
  };
1679
1729
 
1680
- const getSearchHeaderVirtualDom = flags => {
1681
- const dom = [{
1682
- type: Div,
1683
- className: SearchHeader,
1684
- role: None,
1685
- childCount: hasDetailsExpanded(flags) ? 3 : 2,
1686
- onClick: HandleHeaderClick,
1687
- onFocusIn: HandleHeaderFocusIn
1688
- }, {
1689
- type: Div,
1690
- className: SearchHeaderTop,
1691
- role: None,
1692
- childCount: 2
1693
- }, {
1730
+ const getSearchHeaderDetailsVirtualDom = (flags, message) => {
1731
+ if (flags & DetailsExpanded) {
1732
+ return getSearchHeaderDetailsExpandedVirtualDom(message);
1733
+ }
1734
+ return getSearchHeaderDetailsCollapsedVirtualDom(message);
1735
+ };
1736
+
1737
+ const getSearchToggleVirtualDom = flags => {
1738
+ return [{
1694
1739
  type: Button,
1695
1740
  className: mergeClassNames(IconButton, SearchToggleButton, hasReplaceExpanded(flags) ? SearchToggleButtonExpanded : ''),
1696
1741
  title: toggleReplace$1(),
@@ -1702,7 +1747,16 @@ const getSearchHeaderVirtualDom = flags => {
1702
1747
  type: Div,
1703
1748
  className: mergeClassNames(MaskIcon, hasReplaceExpanded(flags) ? MaskIconChevronDown : MaskIconChevronRight),
1704
1749
  childCount: 0
1705
- }, {
1750
+ }];
1751
+ };
1752
+
1753
+ const getSearchHeaderTopVirtualDom = flags => {
1754
+ const dom = [{
1755
+ type: Div,
1756
+ className: SearchHeaderTop,
1757
+ role: None,
1758
+ childCount: 2
1759
+ }, ...getSearchToggleVirtualDom(flags), {
1706
1760
  type: Div,
1707
1761
  className: SearchHeaderTopRight,
1708
1762
  role: None,
@@ -1731,21 +1785,18 @@ const getSearchHeaderVirtualDom = flags => {
1731
1785
  title: replaceAll$1()
1732
1786
  }]));
1733
1787
  }
1734
- if (hasDetailsExpanded(flags)) {
1735
- // @ts-ignore
1736
- dom[0].childCount++;
1737
- dom.push({
1738
- type: Div,
1739
- className: SearchHeaderDetails,
1740
- childCount: 4
1741
- }, text('files to include'), {
1742
- type: Input,
1743
- childCount: 0
1744
- }, text('files to exclude'), {
1745
- type: Input,
1746
- childCount: 0
1747
- });
1748
- }
1788
+ return dom;
1789
+ };
1790
+
1791
+ const getSearchHeaderVirtualDom = (flags, message) => {
1792
+ const dom = [{
1793
+ type: Div,
1794
+ className: SearchHeader,
1795
+ role: None,
1796
+ childCount: 2,
1797
+ onClick: HandleHeaderClick,
1798
+ onFocusIn: HandleHeaderFocusIn
1799
+ }, ...getSearchHeaderTopVirtualDom(flags), ...getSearchHeaderDetailsVirtualDom(flags, message)];
1749
1800
  return dom;
1750
1801
  };
1751
1802
 
@@ -1886,22 +1937,8 @@ const getSearchResultVirtualDom = rowInfo => {
1886
1937
  return dom;
1887
1938
  };
1888
1939
 
1889
- const getSearchResultsVirtualDom = visibleItems => {
1890
- return visibleItems.flatMap(getSearchResultVirtualDom);
1891
- };
1892
-
1893
- const getSearchVirtualDom = (visibleItems, flags, message, focusOutline) => {
1894
- const dom = [{
1895
- type: Div,
1896
- className: mergeClassNames(Viewlet, Search$1),
1897
- childCount: 2
1898
- }, ...getSearchHeaderVirtualDom(flags), {
1899
- type: Div,
1900
- className: ViewletSearchMessage,
1901
- role: Status,
1902
- tabIndex: 0,
1903
- childCount: 1
1904
- }, text(message), {
1940
+ const getSearchResultsVirtualDom = (visibleItems, focusOutline) => {
1941
+ return [{
1905
1942
  type: Div,
1906
1943
  className: mergeClassNames(Viewlet, List, focusOutline ? FocusOutline : Empty),
1907
1944
  role: Tree,
@@ -1909,7 +1946,15 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline) => {
1909
1946
  childCount: visibleItems.length,
1910
1947
  onClick: HandleClick,
1911
1948
  onBlur: HandleListBlur
1912
- }, ...getSearchResultsVirtualDom(visibleItems)];
1949
+ }, ...visibleItems.flatMap(getSearchResultVirtualDom)];
1950
+ };
1951
+
1952
+ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline) => {
1953
+ const dom = [{
1954
+ type: Div,
1955
+ className: mergeClassNames(Viewlet, Search$1),
1956
+ childCount: 2
1957
+ }, ...getSearchHeaderVirtualDom(flags, message), ...getSearchResultsVirtualDom(visibleItems, focusOutline)];
1913
1958
  return dom;
1914
1959
  };
1915
1960
 
@@ -2729,6 +2774,22 @@ const handleReplaceInput = (state, value, inputSource = Script) => {
2729
2774
  });
2730
2775
  };
2731
2776
 
2777
+ const getInputHandler = name => {
2778
+ switch (name) {
2779
+ case 'search-value':
2780
+ return handleInput;
2781
+ case 'replacement-value':
2782
+ return handleReplaceInput;
2783
+ default:
2784
+ throw new Error(`unknown input handler: ${name}`);
2785
+ }
2786
+ };
2787
+
2788
+ const handleSharedInput = (state, name, value, inputSource = Script) => {
2789
+ const fn = getInputHandler(name);
2790
+ return fn(state, value, inputSource);
2791
+ };
2792
+
2732
2793
  const first = () => {
2733
2794
  return 0;
2734
2795
  };
@@ -2841,29 +2902,29 @@ const focusNextPage = state => {
2841
2902
  return focusIndex(state, indexNextPage);
2842
2903
  };
2843
2904
 
2844
- const focusPreviousPage = state => {
2905
+ const focusPrevious = state => {
2845
2906
  const {
2846
2907
  focusedIndex,
2847
- minLineY,
2848
- maxLineY
2908
+ items
2849
2909
  } = state;
2850
2910
  if (focusedIndex === 0 || focusedIndex === -1) {
2851
2911
  return state;
2852
2912
  }
2853
- const indexPreviousPage = Math.max(minLineY - (maxLineY - minLineY) + 1, 0);
2854
- return focusIndex(state, indexPreviousPage);
2913
+ const previousIndex = previous(items, focusedIndex);
2914
+ return focusIndex(state, previousIndex);
2855
2915
  };
2856
2916
 
2857
- const focusPrevious = state => {
2917
+ const focusPreviousPage = state => {
2858
2918
  const {
2859
2919
  focusedIndex,
2860
- items
2920
+ minLineY,
2921
+ maxLineY
2861
2922
  } = state;
2862
2923
  if (focusedIndex === 0 || focusedIndex === -1) {
2863
2924
  return state;
2864
2925
  }
2865
- const previousIndex = previous(items, focusedIndex);
2866
- return focusIndex(state, previousIndex);
2926
+ const indexPreviousPage = Math.max(minLineY - (maxLineY - minLineY) + 1, 0);
2927
+ return focusIndex(state, indexPreviousPage);
2867
2928
  };
2868
2929
 
2869
2930
  const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
@@ -2872,19 +2933,6 @@ const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
2872
2933
  return index;
2873
2934
  };
2874
2935
 
2875
- const openUri = async (path, focus = true, props = {}) => {
2876
- await invoke$1(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
2877
- };
2878
-
2879
- const getFileIndex = (items, index) => {
2880
- for (let i = index; i >= 0; i--) {
2881
- const item = items[i];
2882
- if (item.type === File$1) {
2883
- return i;
2884
- }
2885
- }
2886
- return -1;
2887
- };
2888
2936
  const selectIndexFile = (state, searchResult, index) => {
2889
2937
  const {
2890
2938
  collapsedPaths
@@ -2898,6 +2946,20 @@ const selectIndexFile = (state, searchResult, index) => {
2898
2946
  listFocused: true
2899
2947
  };
2900
2948
  };
2949
+
2950
+ const openUri = async (path, focus = true, props = {}) => {
2951
+ await invoke$1(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
2952
+ };
2953
+
2954
+ const getFileIndex = (items, index) => {
2955
+ for (let i = index; i >= 0; i--) {
2956
+ const item = items[i];
2957
+ if (item.type === File$1) {
2958
+ return i;
2959
+ }
2960
+ }
2961
+ return -1;
2962
+ };
2901
2963
  const selectIndexPreview = async (state, searchResult, index) => {
2902
2964
  const {
2903
2965
  items
@@ -2922,6 +2984,7 @@ const selectIndexPreview = async (state, searchResult, index) => {
2922
2984
  listFocused: false
2923
2985
  };
2924
2986
  };
2987
+
2925
2988
  const selectIndex = async (state, index) => {
2926
2989
  if (index === -1) {
2927
2990
  return {
@@ -2963,9 +3026,6 @@ const handleScrollBarCaptureLost = state => {
2963
3026
  };
2964
3027
 
2965
3028
  const clamp = (num, min, max) => {
2966
- number(num);
2967
- number(min);
2968
- number(max);
2969
3029
  return Math.min(Math.max(num, min), max);
2970
3030
  };
2971
3031
 
@@ -3377,6 +3437,10 @@ const toggleSearchFlag = (state, flag) => {
3377
3437
  };
3378
3438
  };
3379
3439
 
3440
+ const toggleDetailsExpanded = state => {
3441
+ return toggleSearchFlag(state, DetailsExpanded);
3442
+ };
3443
+
3380
3444
  const toggleMatchCase = state => {
3381
3445
  return toggleSearchFlag(state, MatchCase);
3382
3446
  };
@@ -3477,6 +3541,7 @@ const commandMap = {
3477
3541
  'TextSearch.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
3478
3542
  'TextSearch.handleScrollBarClick': wrapCommand(handleScrollBarClick),
3479
3543
  'TextSearch.handleScrollBarMove': wrapCommand(handleScrollBarMove),
3544
+ 'TextSearch.handleSharedInput': wrapCommand(handleSharedInput),
3480
3545
  'TextSearch.handleWheel': wrapCommand(handleWheel),
3481
3546
  'TextSearch.loadContent': wrapCommand(loadContent),
3482
3547
  'TextSearch.refresh': wrapCommand(refresh),
@@ -3488,6 +3553,7 @@ const commandMap = {
3488
3553
  'TextSearch.togglePreserveCase': wrapCommand(togglePreserveCase),
3489
3554
  'TextSearch.toggleReplace': wrapCommand(toggleReplace),
3490
3555
  'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
3556
+ 'TextSearch.toggleSearchDetails': wrapCommand(toggleDetailsExpanded),
3491
3557
  // not wrapped
3492
3558
  'TextSearch.create': create,
3493
3559
  'TextSearch.render': doRender,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "description": "Text Search Worker",
5
5
  "main": "dist/textSearchWorkerMain.js",
6
6
  "type": "module",