@lvce-editor/text-search-worker 4.4.0 → 4.6.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.
@@ -1076,7 +1076,7 @@ const FocusSearchWholeWord = 34;
1076
1076
  const FocusToggleDetails = 1010;
1077
1077
  const FocusToggleReplace = 1020;
1078
1078
 
1079
- const clearSearchResults = state => {
1079
+ const clearSearchResults$1 = state => {
1080
1080
  return {
1081
1081
  ...state,
1082
1082
  value: '',
@@ -1089,6 +1089,10 @@ const clearSearchResults = state => {
1089
1089
  };
1090
1090
  };
1091
1091
 
1092
+ const collapseAll$1 = async state => {
1093
+ return state;
1094
+ };
1095
+
1092
1096
  const PreserveCase$2 = 1 << 0; // 1
1093
1097
  const UseRegularExpression$2 = 1 << 1; // 2
1094
1098
  const ReplaceExpanded = 1 << 2; // 4
@@ -1255,6 +1259,7 @@ const RenderValue = 3;
1255
1259
  const RenderReplaceValue = 4;
1256
1260
  const RenderIncludeValue = 5;
1257
1261
  const RenderExcludeValue = 6;
1262
+ const RenderFocusContext = 7;
1258
1263
 
1259
1264
  const diffType$5 = RenderExcludeValue;
1260
1265
  const isEqual$5 = (oldState, newState) => {
@@ -1327,25 +1332,32 @@ const i18nString = (key, placeholders = emptyObject) => {
1327
1332
  return key.replaceAll(RE_PLACEHOLDER, replacer);
1328
1333
  };
1329
1334
 
1335
+ const ClearSearchResults = 'Clear Search Results';
1336
+ const CollapseAll$1 = 'Collapse All';
1330
1337
  const ConfirmReplaceManyOccurrencesInManyFiles = "Replace {PH1} occurrences across {PH2} files with '{PH3}'";
1331
1338
  const ConfirmReplaceManyOccurrencesInManyFilesNoValue = 'Replace {PH1} occurrences across {PH2} files';
1332
1339
  const ConfirmReplaceManyOccurrencesInOneFile = "Replace {PH1} occurrences across 1 file with '{PH2}'";
1333
1340
  const ConfirmReplaceManyOccurrencesInOneFileNoValue = 'Replace {PH1} occurrences across 1 file';
1334
1341
  const ConfirmReplaceOneOccurrenceInOneFile = "Replace 1 occurrence across 1 file with '{PH1}'";
1335
1342
  const ConfirmReplaceOneOccurrenceInOneFileNoValue = 'Replace 1 occurrence across 1 file';
1343
+ const Exclude = 'Exclude';
1336
1344
  const FilesToExclude$1 = 'Files to Exclude';
1337
1345
  const FilesToInclude$1 = 'Files to Include';
1346
+ const Include = 'Include';
1338
1347
  const ManyResultsInManyFiles = '{PH1} results in {PH2} files';
1339
1348
  const ManyResultsInOneFile = '{PH1} results in 1 file';
1340
1349
  const MatchCase$1 = 'Match Case';
1341
1350
  const MatchWholeWord$1 = 'Match Whole Word';
1342
1351
  const NoResults = 'No results found';
1343
1352
  const Oneresult = '1 result in 1 file';
1353
+ const OpenNewSearchEditor = 'Open New Search Editor';
1344
1354
  const PreserveCase$1 = 'Preserve Case';
1355
+ const Refresh$1 = 'Refresh';
1345
1356
  const Replace = 'Replace';
1346
1357
  const ReplaceAll$1 = 'Replace All';
1347
1358
  const ReplacedManyOccurrencesInManyFiles = "Replaced {PH1} occurrences across {PH2} files with '{PH3}'";
1348
1359
  const ReplacedOneOccurrenceInOneFile = "Replaced 1 occurrence across 1 file with '{PH1}'";
1360
+ const ReplaceForHistory = 'Replace (⇅ for history)';
1349
1361
  const Search$2 = 'Search';
1350
1362
  const SearchForHistory = 'Search (⇅ for history)';
1351
1363
  const SearchOnlyOpenEditors$1 = 'Search Only Open Editors';
@@ -1353,6 +1365,7 @@ const ToggleReplace$1 = 'Toggle Replace';
1353
1365
  const ToggleSearchDetails$1 = 'Toggle Search Details';
1354
1366
  const UseExcludeSettings$1 = 'Use Exclude Settings';
1355
1367
  const UseRegularExpression$1 = 'Use Regular Expression';
1368
+ const ViewAsTree = 'View as Tree';
1356
1369
 
1357
1370
  const noResults = () => {
1358
1371
  return i18nString(NoResults);
@@ -1445,9 +1458,30 @@ const replaceAll$1 = () => {
1445
1458
  const replace = () => {
1446
1459
  return i18nString(Replace);
1447
1460
  };
1461
+ const refresh$1 = () => {
1462
+ return i18nString(Refresh$1);
1463
+ };
1464
+ const clearSearchResults = () => {
1465
+ return i18nString(ClearSearchResults);
1466
+ };
1467
+ const openNewSearchEditor = () => {
1468
+ return i18nString(OpenNewSearchEditor);
1469
+ };
1470
+ const viewAsTree$1 = () => {
1471
+ return i18nString(ViewAsTree);
1472
+ };
1473
+ const collapseAll = () => {
1474
+ return i18nString(CollapseAll$1);
1475
+ };
1448
1476
  const filesToInclude = () => {
1449
1477
  return i18nString(FilesToInclude$1);
1450
1478
  };
1479
+ const include = () => {
1480
+ return i18nString(Include);
1481
+ };
1482
+ const exclude = () => {
1483
+ return i18nString(Exclude);
1484
+ };
1451
1485
  const filesToExclude = () => {
1452
1486
  return i18nString(FilesToExclude$1);
1453
1487
  };
@@ -1463,6 +1497,9 @@ const searchForHistory = () => {
1463
1497
  const search = () => {
1464
1498
  return i18nString(Search$2);
1465
1499
  };
1500
+ const replaceForHistory = () => {
1501
+ return i18nString(ReplaceForHistory);
1502
+ };
1466
1503
 
1467
1504
  const getStatusMessage = (resultCount, fileResultCount) => {
1468
1505
  if (resultCount === 0) {
@@ -1745,7 +1782,7 @@ const focusSearchValueNext = state => {
1745
1782
  return focusMatchCase$1(state);
1746
1783
  };
1747
1784
 
1748
- const commandIds = ['clearSearchResults', 'collapseDetails', 'copy', 'dismissItem', 'expandDetails', 'focusFirst', 'focusIndex', 'focusLast', 'focusMatchCase', 'focusMatchCasePrevious', 'focusMatchWholeWord', 'focusNext', 'focusNextInput', 'focusNextPage', 'focusPreserveCasePrevious', 'focusPrevious', 'focusPreviousInput', 'focusPreviousPage', 'focusRegex', 'focusRegexNext', 'focusReplaceAll', 'focusReplaceValue', 'focusReplaceValueNext', 'focusReplaceValuePrevious', 'focusSearchValue', 'focusSearchValueNext', 'handleClick', 'handleClickAt', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleContextMenuMouseAt', 'handleExcludeInput', 'handleFocusIn', 'handleHeaderClick', 'handleHeaderFocusIn', 'handleHeaderFocusOut', 'handleIconThemeChange', 'handleIconThemeChange', 'handleIncludeInput', 'handleInput', 'handleInput2', 'handleListBlur', 'handleListFocus', 'handleReplaceInput', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleScrollBarThumbPointerMove', 'handleTouchEnd', 'handleTouchMove', 'handleTouchStart', 'handleUpdate', 'handleWheel', 'nextHistoryResult', 'previousHistoryResult', 'refresh', 'replaceAll', 'scrollDown', 'selectIndex', 'submit', 'toggleMatchCase', 'toggleMatchWholeWord', 'togglePreserveCase', 'toggleReplace', 'toggleSearchDetails', 'toggleUseRegularExpression'];
1785
+ const commandIds = ['clearSearchResults', 'collapseAll', 'collapseDetails', 'copy', 'dismissItem', 'expandDetails', 'focusFirst', 'focusIndex', 'focusLast', 'focusMatchCase', 'focusMatchCasePrevious', 'focusMatchWholeWord', 'focusNext', 'focusNextInput', 'focusNextPage', 'focusPreserveCasePrevious', 'focusPrevious', 'focusPreviousInput', 'focusPreviousPage', 'focusRegex', 'focusRegexNext', 'focusReplaceAll', 'focusReplaceValue', 'focusReplaceValueNext', 'focusReplaceValuePrevious', 'focusSearchValue', 'focusSearchValueNext', 'handleClick', 'handleClickAt', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleContextMenuMouseAt', 'handleExcludeInput', 'handleFocusIn', 'handleHeaderClick', 'handleHeaderFocusIn', 'handleHeaderFocusOut', 'handleIconThemeChange', 'handleIconThemeChange', 'handleIncludeInput', 'handleInput', 'handleInput2', 'handleListBlur', 'handleListFocus', 'handleReplaceInput', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleScrollBarThumbPointerMove', 'handleTouchEnd', 'handleTouchMove', 'handleTouchStart', 'handleUpdate', 'handleWheel', 'nextHistoryResult', 'previousHistoryResult', 'refresh', 'replaceAll', 'scrollDown', 'selectIndex', 'submit', 'toggleMatchCase', 'toggleMatchWholeWord', 'togglePreserveCase', 'toggleReplace', 'toggleSearchDetails', 'toggleUseRegularExpression', 'viewAsTree'];
1749
1786
 
1750
1787
  const getCommandIds = () => {
1751
1788
  return commandIds;
@@ -2386,6 +2423,8 @@ const getClickHandler = name => {
2386
2423
  return toggleUseIgnoreFiles;
2387
2424
  case SearchValue:
2388
2425
  return focusSearchValue$1;
2426
+ case ReplaceValue:
2427
+ return focusReplaceValue$1;
2389
2428
  default:
2390
2429
  return noop;
2391
2430
  }
@@ -2858,13 +2897,17 @@ const selectIndexPreview = async (state, searchResult, index) => {
2858
2897
  const fileResult = items[fileIndex];
2859
2898
  const relativePath = getRelativePath(fileResult.text);
2860
2899
  const absolutePath = `${workspacePath}${relativePath}`;
2900
+ if (state.focus !== FocusSearchResults) {
2901
+ await setFocus(FocusSearchResults);
2902
+ }
2861
2903
  await openUri(absolutePath, true, {
2862
2904
  selections: new Uint32Array([lineNumber, 0, lineNumber, 0])
2863
2905
  });
2864
2906
  return {
2865
2907
  ...state,
2866
2908
  listFocusedIndex: index,
2867
- listFocused: false
2909
+ listFocused: false,
2910
+ focus: FocusSearchResults
2868
2911
  };
2869
2912
  };
2870
2913
 
@@ -3075,6 +3118,10 @@ const renderFocus = (oldState, newState) => {
3075
3118
  return ['Viewlet.focusElementByName', newState.uid, selector];
3076
3119
  };
3077
3120
 
3121
+ const renderFocusContext = (oldState, newState) => {
3122
+ return ['Viewlet.setFocusContext', newState.focus];
3123
+ };
3124
+
3078
3125
  const None$1 = 0;
3079
3126
  const Collapsed = 1;
3080
3127
  const Expanded = 2;
@@ -3726,6 +3773,8 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
3726
3773
  const getSearchHeaderDetailsExpandedVirtualDom = (flags, message) => {
3727
3774
  const includeButtons = getInputActionsInclude(flags);
3728
3775
  const excludeButtons = getInputActionsExclude(flags);
3776
+ const includePlaceholder = include();
3777
+ const excludePlaceholder = exclude();
3729
3778
  return [{
3730
3779
  type: Div,
3731
3780
  className: SearchHeaderDetailsExpanded,
@@ -3738,11 +3787,11 @@ const getSearchHeaderDetailsExpandedVirtualDom = (flags, message) => {
3738
3787
  type: H4,
3739
3788
  className: SearchHeaderDetailsHeading,
3740
3789
  childCount: 1
3741
- }, text(filesToInclude()), ...getSearchFieldVirtualDom(FilesToInclude, 'Include', HandleInput2, includeButtons.inside, includeButtons.outside), {
3790
+ }, text(filesToInclude()), ...getSearchFieldVirtualDom(FilesToInclude, includePlaceholder, HandleInput2, includeButtons.inside, includeButtons.outside), {
3742
3791
  type: H4,
3743
3792
  className: SearchHeaderDetailsHeading,
3744
3793
  childCount: 1
3745
- }, text(filesToExclude()), ...getSearchFieldVirtualDom(FilesToExclude, 'Exclude', HandleInput2, excludeButtons.inside, excludeButtons.outside), ...getSearchMessageVirtualDom(message, false)];
3794
+ }, text(filesToExclude()), ...getSearchFieldVirtualDom(FilesToExclude, excludePlaceholder, HandleInput2, excludeButtons.inside, excludeButtons.outside), ...getSearchMessageVirtualDom(message, false)];
3746
3795
  };
3747
3796
 
3748
3797
  const getSearchHeaderDetailsVirtualDom = (flags, message) => {
@@ -3795,6 +3844,13 @@ const getInputActionsReplace = (flags, matchCount) => {
3795
3844
  };
3796
3845
  };
3797
3846
 
3847
+ const getReplacePlaceholder = focus => {
3848
+ if (focus === FocusSearchReplaceInput) {
3849
+ return replaceForHistory();
3850
+ }
3851
+ return replace();
3852
+ };
3853
+
3798
3854
  const getSearchPlaceholder = focus => {
3799
3855
  if (focus === FocusSearchInput) {
3800
3856
  return searchForHistory();
@@ -3802,19 +3858,19 @@ const getSearchPlaceholder = focus => {
3802
3858
  return search();
3803
3859
  };
3804
3860
 
3805
- const getSearchToggleVirtualDom = flags => {
3861
+ const getSearchToggleVirtualDom = replaceExpanded => {
3806
3862
  return [{
3807
3863
  type: Button$1,
3808
- className: mergeClassNames(IconButton, SearchToggleButton, flags & ReplaceExpanded ? SearchToggleButtonExpanded : ''),
3864
+ className: mergeClassNames(IconButton, SearchToggleButton, replaceExpanded ? SearchToggleButtonExpanded : ''),
3809
3865
  title: toggleReplace$1(),
3810
3866
  ariaLabel: toggleReplace$1(),
3811
- ariaExpanded: Boolean(flags & ReplaceExpanded),
3867
+ ariaExpanded: Boolean(replaceExpanded),
3812
3868
  childCount: 1,
3813
3869
  'data-command': 'toggleReplace',
3814
3870
  name: ToggleReplace
3815
3871
  }, {
3816
3872
  type: Div,
3817
- className: mergeClassNames(MaskIcon, flags & ReplaceExpanded ? MaskIconChevronDown : MaskIconChevronRight),
3873
+ className: mergeClassNames(MaskIcon, replaceExpanded ? MaskIconChevronDown : MaskIconChevronRight),
3818
3874
  childCount: 0
3819
3875
  }];
3820
3876
  };
@@ -3822,20 +3878,22 @@ const getSearchToggleVirtualDom = flags => {
3822
3878
  const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount, focus) => {
3823
3879
  const inputActions = getInputActionsInput(flags);
3824
3880
  const replaceActions = getInputActionsReplace(flags, matchCount);
3825
- const placeholder = getSearchPlaceholder(focus);
3881
+ const searchPlaceholder = getSearchPlaceholder(focus);
3882
+ const replacePlaceholder = getReplacePlaceholder(focus);
3883
+ const replaceExpanded = flags & ReplaceExpanded;
3826
3884
  const dom = [{
3827
3885
  type: Div,
3828
3886
  className: SearchHeaderTop,
3829
3887
  role: None,
3830
3888
  childCount: 2
3831
- }, ...getSearchToggleVirtualDom(flags), {
3889
+ }, ...getSearchToggleVirtualDom(replaceExpanded), {
3832
3890
  type: Div,
3833
3891
  className: SearchHeaderTopRight,
3834
3892
  role: None,
3835
- childCount: flags & ReplaceExpanded ? 2 : 1
3836
- }, ...getSearchFieldVirtualDom(SearchValue, placeholder, HandleInput2, inputActions.inside, inputActions.outside, '', Boolean(searchInputErrorMessage))];
3893
+ childCount: replaceExpanded ? 2 : 1
3894
+ }, ...getSearchFieldVirtualDom(SearchValue, searchPlaceholder, HandleInput2, inputActions.inside, inputActions.outside, '', Boolean(searchInputErrorMessage))];
3837
3895
  if (flags & ReplaceExpanded) {
3838
- dom.push(...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleInput2, replaceActions.inside, replaceActions.outside));
3896
+ dom.push(...getSearchFieldVirtualDom(ReplaceValue, replacePlaceholder, HandleInput2, replaceActions.inside, replaceActions.outside));
3839
3897
  }
3840
3898
  return dom;
3841
3899
  };
@@ -4050,6 +4108,7 @@ const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
4050
4108
  onClick: HandleClick,
4051
4109
  onBlur: HandleListBlur,
4052
4110
  onWheel: HandleWheel,
4111
+ onContextMenu: HandleContextMenu,
4053
4112
  id: TreeItems,
4054
4113
  top: `${-pixelOffset}px`
4055
4114
  }, ...visibleItems.flatMap(getSearchResultVirtualDom)];
@@ -4109,6 +4168,8 @@ const getRenderer = diffType => {
4109
4168
  return renderExcludeValue;
4110
4169
  case RenderItems:
4111
4170
  return renderItems;
4171
+ case RenderFocusContext:
4172
+ return renderFocusContext;
4112
4173
  default:
4113
4174
  throw new Error('unknown renderer');
4114
4175
  }
@@ -4177,15 +4238,43 @@ const getActionsVirtualDom = actions => {
4177
4238
  }, ...actions.flatMap(getActionVirtualDom)];
4178
4239
  };
4179
4240
 
4241
+ const ClearAll = 'ClearAll';
4242
+ const CollapseAll = 'CollapseAll';
4243
+ const ListFlat = 'ListFlat';
4244
+ const NewFile = 'NewFile';
4245
+ const Refresh = 'Refresh';
4246
+
4247
+ const getActions = () => {
4248
+ return [{
4249
+ type: Button,
4250
+ id: refresh$1(),
4251
+ icon: Refresh,
4252
+ command: 'refresh'
4253
+ }, {
4254
+ type: Button,
4255
+ id: clearSearchResults(),
4256
+ icon: ClearAll,
4257
+ command: 'clearSearchResults'
4258
+ }, {
4259
+ type: Button,
4260
+ id: openNewSearchEditor(),
4261
+ icon: NewFile,
4262
+ command: ''
4263
+ }, {
4264
+ type: Button,
4265
+ id: viewAsTree$1(),
4266
+ icon: ListFlat,
4267
+ command: ''
4268
+ }, {
4269
+ type: Button,
4270
+ id: collapseAll(),
4271
+ icon: CollapseAll,
4272
+ command: ''
4273
+ }];
4274
+ };
4275
+
4180
4276
  const renderActions = uid => {
4181
- const {
4182
- oldState,
4183
- newState
4184
- } = get(uid);
4185
- if (oldState === newState) {
4186
- return [];
4187
- }
4188
- const actions = [];
4277
+ const actions = getActions();
4189
4278
  const dom = getActionsVirtualDom(actions);
4190
4279
  return dom;
4191
4280
  };
@@ -4441,6 +4530,10 @@ const terminate = () => {
4441
4530
  globalThis.close();
4442
4531
  };
4443
4532
 
4533
+ const viewAsTree = async state => {
4534
+ return state;
4535
+ };
4536
+
4444
4537
  const Keyboard = -1;
4445
4538
 
4446
4539
  const show = async (x, y, id, ...args) => {
@@ -4501,8 +4594,9 @@ const wrapCommand = fn => {
4501
4594
  };
4502
4595
 
4503
4596
  const commandMap = {
4504
- 'TextSearch.clearSearchResults': wrapCommand(clearSearchResults),
4597
+ 'TextSearch.clearSearchResults': wrapCommand(clearSearchResults$1),
4505
4598
  'TextSearch.collapseDetails': wrapCommand(collapseDetails),
4599
+ 'TextSearch.collapseAll': wrapCommand(collapseAll$1),
4506
4600
  'TextSearch.copy': wrapCommand(copy),
4507
4601
  'TextSearch.diff2': diff2,
4508
4602
  'TextSearch.dismissItem': wrapCommand(dismissItem),
@@ -4529,8 +4623,8 @@ const commandMap = {
4529
4623
  'TextSearch.focusReplaceValuePrevious': wrapCommand(focusReplaceValuePrevious),
4530
4624
  'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
4531
4625
  'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
4532
- 'TextSearch.getCommandIds': getCommandIds,
4533
4626
  'TextSearch.handleClickAt': wrapCommand(handleClickAt),
4627
+ 'TextSearch.viewAsTree': wrapCommand(viewAsTree),
4534
4628
  'TextSearch.handleContextMenu': wrapCommand(handleContextMenu),
4535
4629
  'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
4536
4630
  'TextSearch.handleFocusIn': wrapCommand(handleFocusIn),
@@ -4553,7 +4647,6 @@ const commandMap = {
4553
4647
  'TextSearch.nextHistoryResult': wrapCommand(nextHistoryResult),
4554
4648
  'TextSearch.previousHistoryResult': wrapCommand(previousHistoryResult),
4555
4649
  'TextSearch.refresh': wrapCommand(refresh),
4556
- 'TextSearch.renderActions': renderActions,
4557
4650
  'TextSearch.replaceAll': wrapCommand(replaceAll),
4558
4651
  'TextSearch.selectIndex': wrapCommand(selectIndex),
4559
4652
  'TextSearch.submit': wrapCommand(submit),
@@ -4567,6 +4660,7 @@ const commandMap = {
4567
4660
  'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
4568
4661
  // not wrapped
4569
4662
  'TextSearch.create': create,
4663
+ 'TextSearch.getCommandIds': getCommandIds,
4570
4664
  'TextSearch.getKeyBindings': getKeyBindings,
4571
4665
  'TextSearch.render2': render2,
4572
4666
  'TextSearch.renderEventListeners': renderEventListeners,
@@ -4574,6 +4668,7 @@ const commandMap = {
4574
4668
  'TextSearch.restoreState': restoreState,
4575
4669
  'TextSearch.saveState': saveState,
4576
4670
  'TextSearch.terminate': terminate,
4671
+ 'TextSearch.renderActions': renderActions,
4577
4672
  // TODO needed?
4578
4673
  'TextSearch.replaceAllAndPrompt': replaceAllAndPrompt,
4579
4674
  'TextSearch.textSearch': textSearch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "4.4.0",
3
+ "version": "4.6.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"