@lvce-editor/text-search-worker 5.6.0 → 5.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.
@@ -1143,6 +1143,9 @@ const createMockRpc = ({
1143
1143
  const invoke = (method, ...params) => {
1144
1144
  invocations.push([method, ...params]);
1145
1145
  const command = commandMap[method];
1146
+ if (!command) {
1147
+ throw new Error(`command ${method} not found`);
1148
+ }
1146
1149
  return command(...params);
1147
1150
  };
1148
1151
  const mockRpc = {
@@ -1465,6 +1468,11 @@ const sendMessagePortToMarkdownWorker = async (port, rpcId) => {
1465
1468
  // @ts-ignore
1466
1469
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
1467
1470
  };
1471
+ const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1472
+ const command = 'IconTheme.handleMessagePort';
1473
+ // @ts-ignore
1474
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1475
+ };
1468
1476
  const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
1469
1477
  const command = 'FileSystem.handleMessagePort';
1470
1478
  // @ts-ignore
@@ -1731,6 +1739,7 @@ const RendererWorker = {
1731
1739
  sendMessagePortToErrorWorker,
1732
1740
  sendMessagePortToExtensionHostWorker,
1733
1741
  sendMessagePortToFileSystemWorker,
1742
+ sendMessagePortToIconThemeWorker,
1734
1743
  sendMessagePortToMarkdownWorker,
1735
1744
  sendMessagePortToRendererProcess,
1736
1745
  sendMessagePortToSearchProcess: sendMessagePortToSearchProcess$1,
@@ -1805,7 +1814,9 @@ const minimumSliderSize = 20;
1805
1814
  const {
1806
1815
  get: get$1,
1807
1816
  set,
1808
- wrapCommand
1817
+ wrapCommand,
1818
+ registerCommands,
1819
+ getCommandIds
1809
1820
  } = create$3();
1810
1821
 
1811
1822
  const List = 1;
@@ -1881,7 +1892,10 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
1881
1892
  incrementalSearch: false,
1882
1893
  searchId: '',
1883
1894
  useChevrons: true,
1884
- useFileIcons: true
1895
+ useFileIcons: true,
1896
+ limitHit: false,
1897
+ limitHitWarning: '',
1898
+ limit: 20_000
1885
1899
  };
1886
1900
  set(uid, state, state);
1887
1901
  return state;
@@ -2004,6 +2018,7 @@ const ToggleSearchDetails$1 = 'Toggle Search Details';
2004
2018
  const UseExcludeSettings$1 = 'Use Exclude Settings';
2005
2019
  const UseRegularExpression$1 = 'Use Regular Expression';
2006
2020
  const ViewAsTree = 'View as Tree';
2021
+ const TheResultSetOnlyContainsASubSetOfMatches = 'The result set only contains a subset of all matches. Be more specific in your search to narrow down the results.';
2007
2022
 
2008
2023
  const noResults = () => {
2009
2024
  return i18nString(NoResults);
@@ -2096,6 +2111,9 @@ const replaceAll$1 = () => {
2096
2111
  const replace = () => {
2097
2112
  return i18nString(Replace);
2098
2113
  };
2114
+ const theResultSetOnlyContainsASubSetOfMatches = () => {
2115
+ return i18nString(TheResultSetOnlyContainsASubSetOfMatches);
2116
+ };
2099
2117
  const refresh$1 = () => {
2100
2118
  return i18nString(Refresh$1);
2101
2119
  };
@@ -2415,12 +2433,6 @@ const focusSearchValueNext = state => {
2415
2433
  return focusMatchCase$1(state);
2416
2434
  };
2417
2435
 
2418
- const commandIds = ['clearSearchResults', 'collapseAll', 'collapseDetails', 'copy', 'dismissItem', 'dispose', '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', 'handleHeaderContextMenu', 'handleHeaderFocusIn', 'handleHeaderFocusOut', 'handleIconThemeChange', 'handleIconThemeChange', 'handleIncludeInput', 'handleInput', 'handleInput2', 'handleListBlur', 'handleListFocus', 'handleReplaceInput', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleScrollBarThumbPointerMove', 'handleTouchEnd', 'handleTouchMove', 'handleTouchStart', 'handleUpdate', 'handleWheel', 'nextHistoryResult', 'previousHistoryResult', 'refresh', 'replaceAll', 'rerender', 'scrollDown', 'selectIndex', 'submit', 'toggleMatchCase', 'toggleMatchWholeWord', 'togglePreserveCase', 'toggleReplace', 'toggleSearchDetails', 'toggleUseRegularExpression', 'viewAsTree'];
2419
-
2420
- const getCommandIds = () => {
2421
- return commandIds;
2422
- };
2423
-
2424
2436
  const Tab = 2;
2425
2437
  const Enter = 3;
2426
2438
  const End = 255;
@@ -2637,11 +2649,15 @@ const handleUpdateFull = async (state, update) => {
2637
2649
  includeValue,
2638
2650
  excludeValue,
2639
2651
  assetDir,
2640
- platform
2652
+ platform,
2653
+ limit
2641
2654
  } = partialNewState;
2642
2655
  const root = state.workspacePath;
2643
2656
  const scheme = getProtocol(root);
2644
- const results = await textSearch$6(root, value, {
2657
+ const {
2658
+ results,
2659
+ limitHit
2660
+ } = await textSearch$6(root, value, {
2645
2661
  threads,
2646
2662
  isCaseSensitive: Boolean(flags & MatchCase$2),
2647
2663
  useRegularExpression: Boolean(flags & UseRegularExpression$2),
@@ -2652,7 +2668,8 @@ const handleUpdateFull = async (state, update) => {
2652
2668
  query: value,
2653
2669
  scheme,
2654
2670
  flags,
2655
- matchWholeWord: Boolean(flags & MatchWholeWord$2)
2671
+ matchWholeWord: Boolean(flags & MatchWholeWord$2),
2672
+ limit
2656
2673
  }, assetDir, platform);
2657
2674
  if (!Array.isArray(results)) {
2658
2675
  throw new TypeError('results must be of type array');
@@ -2671,23 +2688,29 @@ const handleUpdateFull = async (state, update) => {
2671
2688
  const finalDeltaY = Math.max(contentHeight - listHeight, 0);
2672
2689
  const visible = results.slice(0, maxLineY);
2673
2690
  const icons = await getFileIcons(visible);
2691
+
2692
+ // TODO add info message if limit was hit
2693
+
2694
+ const limitHitWarning = limitHit ? theResultSetOnlyContainsASubSetOfMatches() : '';
2674
2695
  return {
2675
2696
  ...partialNewState,
2676
- minLineY: 0,
2677
2697
  deltaY: 0,
2678
- value,
2698
+ fileCount,
2699
+ finalDeltaY,
2700
+ icons,
2679
2701
  items: results,
2702
+ limitHit,
2703
+ limitHitWarning,
2680
2704
  listItems: results,
2681
- message,
2705
+ loaded: true,
2706
+ matchCount: resultCount,
2682
2707
  maxLineY: maxLineY,
2708
+ message,
2709
+ minLineY: 0,
2683
2710
  scrollBarHeight,
2684
- finalDeltaY,
2711
+ searchInputErrorMessage: '',
2685
2712
  threads,
2686
- fileCount,
2687
- matchCount: resultCount,
2688
- loaded: true,
2689
- icons,
2690
- searchInputErrorMessage: ''
2713
+ value
2691
2714
  };
2692
2715
  };
2693
2716
 
@@ -2786,6 +2809,7 @@ const handleUpdateIncremental = async (state, update) => {
2786
2809
  threads,
2787
2810
  includeValue,
2788
2811
  excludeValue,
2812
+ limit,
2789
2813
  uid,
2790
2814
  assetDir,
2791
2815
  platform
@@ -2813,7 +2837,8 @@ const handleUpdateIncremental = async (state, update) => {
2813
2837
  query: value,
2814
2838
  scheme,
2815
2839
  flags,
2816
- matchWholeWord: Boolean(flags & MatchWholeWord$2)
2840
+ matchWholeWord: Boolean(flags & MatchWholeWord$2),
2841
+ limit
2817
2842
  }, assetDir, platform, searchId, uid);
2818
2843
  return state;
2819
2844
  };
@@ -3901,6 +3926,8 @@ const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLine
3901
3926
  };
3902
3927
 
3903
3928
  const createViewModel = state => {
3929
+ // TODO add viewmodel to state, not needing to have separate states and making it easier to compare
3930
+ // visible items in diff
3904
3931
  const {
3905
3932
  listItems,
3906
3933
  itemHeight,
@@ -4415,6 +4442,26 @@ const getSearchHeaderDetailsVirtualDom = (flags, message) => {
4415
4442
  return getSearchHeaderDetailsCollapsedVirtualDom(message);
4416
4443
  };
4417
4444
 
4445
+ const SearchWarningMessage = 'SearchWarningMessage';
4446
+
4447
+ const getSearchHeaderLimitHitVirtualDom = limitHitWarning => {
4448
+ if (!limitHitWarning) {
4449
+ // TODO remove unused dom node
4450
+ return [{
4451
+ type: Div,
4452
+ childCount: 0
4453
+ }];
4454
+ }
4455
+ const dom = [{
4456
+ type: Div,
4457
+ className: SearchWarningMessage,
4458
+ childCount: 1
4459
+ },
4460
+ // TODO warning triangle here
4461
+ text(limitHitWarning)];
4462
+ return dom;
4463
+ };
4464
+
4418
4465
  const getInputActionsInput = flags => {
4419
4466
  const inside = [{
4420
4467
  icon: MaskIconCaseSensitive,
@@ -4516,14 +4563,14 @@ const parentNode = {
4516
4563
  type: Div,
4517
4564
  className: SearchHeader,
4518
4565
  role: None,
4519
- childCount: 2,
4566
+ childCount: 3,
4520
4567
  onClick: HandleHeaderClick2,
4521
4568
  onFocusIn: HandleHeaderFocusIn,
4522
4569
  onFocusOut: HandleHeaderFocusOut,
4523
4570
  onContextMenu: HandleHeaderContextMenu
4524
4571
  };
4525
- const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount, focus) => {
4526
- const dom = [parentNode, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage, matchCount, focus), ...getSearchHeaderDetailsVirtualDom(flags, message)];
4572
+ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount, focus, limitHitWarning) => {
4573
+ const dom = [parentNode, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage, matchCount, focus), ...getSearchHeaderDetailsVirtualDom(flags, message), ...getSearchHeaderLimitHitVirtualDom(limitHitWarning)];
4527
4574
  return dom;
4528
4575
  };
4529
4576
 
@@ -4770,19 +4817,19 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
4770
4817
  }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
4771
4818
  };
4772
4819
 
4773
- const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, focus = 0) => {
4820
+ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0) => {
4774
4821
  const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
4775
4822
  const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
4776
4823
  return [{
4777
4824
  type: Div,
4778
4825
  className: mergeClassNames(Viewlet, Search$2),
4779
4826
  childCount
4780
- }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount, focus), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
4827
+ }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount, focus, limitHitWarning), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
4781
4828
  };
4782
4829
 
4783
4830
  const renderItems = (oldState, newState) => {
4784
4831
  const viewModel = createViewModel(newState);
4785
- const dom = getSearchVirtualDom(viewModel.displayResults, viewModel.flags, viewModel.message, viewModel.focusOutline, viewModel.searchInputErrorMessage, viewModel.scrollBarHeight, viewModel.scrollBarY, viewModel.scrollBarValue, viewModel.deltaY, viewModel.itemHeight, viewModel.matchCount, viewModel.focus);
4832
+ const dom = getSearchVirtualDom(viewModel.displayResults, viewModel.flags, viewModel.message, viewModel.focusOutline, viewModel.searchInputErrorMessage, viewModel.scrollBarHeight, viewModel.scrollBarY, viewModel.scrollBarValue, viewModel.deltaY, viewModel.itemHeight, viewModel.matchCount, newState.limitHitWarning, viewModel.focus);
4786
4833
  return ['Viewlet.setDom2', newState.uid, dom];
4787
4834
  };
4788
4835
 
@@ -4984,7 +5031,7 @@ const getDom = state => {
4984
5031
  const focusOutline = state.listFocused && state.listFocusedIndex === -1;
4985
5032
  const scrollBarValue = state.deltaY / state.finalDeltaY * 100;
4986
5033
  const scrollBarY = getScrollBarY$1(state.deltaY, state.finalDeltaY, state.height - state.headerHeight, state.scrollBarHeight);
4987
- const dom = getSearchVirtualDom(displayResults, state.flags, state.message, focusOutline, state.searchInputErrorMessage, state.scrollBarHeight, scrollBarY, scrollBarValue, state.deltaY, state.itemHeight, state.matchCount, state.focus);
5034
+ const dom = getSearchVirtualDom(displayResults, state.flags, state.message, focusOutline, state.searchInputErrorMessage, state.scrollBarHeight, scrollBarY, scrollBarValue, state.deltaY, state.itemHeight, state.matchCount, state.limitHitWarning, state.focus);
4988
5035
  return dom;
4989
5036
  };
4990
5037
 
@@ -5165,6 +5212,12 @@ const focusReplaceAll = state => {
5165
5212
  return focusElement(state, FocusSearchReplaceAll);
5166
5213
  };
5167
5214
 
5215
+ const setLimit = (state, limit) => {
5216
+ return handleUpdate(state, {
5217
+ limit
5218
+ });
5219
+ };
5220
+
5168
5221
  const getNewHistory = (history, newValue) => {
5169
5222
  const newHistory = [...history, newValue];
5170
5223
  const maxHistoryLength = 100;
@@ -5294,6 +5347,7 @@ const commandMap = {
5294
5347
  'TextSearch.toggleUseIgnoreFiles': wrapCommand(toggleUseIgnoreFiles),
5295
5348
  'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
5296
5349
  'TextSearch.viewAsTree': wrapCommand(viewAsTree),
5350
+ 'TextSearch.setLimit': wrapCommand(setLimit),
5297
5351
  // not wrapped
5298
5352
  'TextSearch.initialize': initialize,
5299
5353
  'TextSearch.create': create,
@@ -5314,20 +5368,44 @@ const commandMap = {
5314
5368
  const textSearch$5 = async (scheme, root, query) => {
5315
5369
  string(scheme);
5316
5370
  string(query);
5317
- const result = await invoke$1('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query);
5318
- return result;
5371
+ const results = await invoke$1('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query);
5372
+ return {
5373
+ results,
5374
+ limitHit: false
5375
+ };
5319
5376
  };
5320
5377
 
5321
5378
  const textSearch$4 = async (scheme, root, query, options, assetDir) => {
5322
- return invoke$1('ExtensionHostTextSearch.textSearchFetch', scheme, root, query, options, assetDir);
5379
+ const results = await invoke$1('ExtensionHostTextSearch.textSearchFetch', scheme, root, query, options, assetDir);
5380
+ return {
5381
+ results,
5382
+ limitHit: false
5383
+ };
5323
5384
  };
5324
5385
 
5325
5386
  const textSearch$3 = async (scheme, root, query) => {
5326
- return invoke$1('ExtensionHostTextSearch.textSearchHtml', scheme, root, query);
5387
+ const results = await invoke$1('ExtensionHostTextSearch.textSearchHtml', scheme, root, query);
5388
+ return {
5389
+ results,
5390
+ limitHit: false
5391
+ };
5327
5392
  };
5328
5393
 
5329
5394
  const textSearch$2 = async (scheme, root, query, options, assetDir) => {
5330
- return invoke$1('ExtensionHostTextSearch.textSearchMemory', scheme, root, query, options, assetDir);
5395
+ try {
5396
+ // @ts-ignore
5397
+ const result = await invoke$1('ExtensionHostTextSearch.textSearchMemory2', scheme, root, query, options, assetDir);
5398
+ if (!result || !result.results) {
5399
+ throw new Error(`new api not supported`);
5400
+ }
5401
+ return result;
5402
+ } catch {
5403
+ const results = await invoke$1('ExtensionHostTextSearch.textSearchMemory', scheme, root, query, options, assetDir);
5404
+ return {
5405
+ results,
5406
+ limitHit: false
5407
+ };
5408
+ }
5331
5409
  };
5332
5410
 
5333
5411
  const textSearch$1 = async (scheme, root, query, options, assetDir, platform) => {
@@ -5341,14 +5419,18 @@ const textSearch$1 = async (scheme, root, query, options, assetDir, platform) =>
5341
5419
  };
5342
5420
  if (platform === Remote || platform === Electron) {
5343
5421
  const result = await invoke('TextSearch.search', actualOptions);
5344
- // TODO api is weird
5345
- // @ts-ignore
5346
- return result.results;
5422
+ return {
5423
+ results: result.results,
5424
+ limitHit: result.limitHit
5425
+ };
5347
5426
  }
5348
5427
  // TODO always create search process messageport rpc to have one api, in web can send the messageport to renderer worker
5349
- const results = await invoke$1('SearchProcess.invoke', 'TextSearch.search', actualOptions);
5428
+ const result = await invoke$1('SearchProcess.invoke', 'TextSearch.search', actualOptions);
5350
5429
  // TODO api is weird
5351
- return results.results;
5430
+ return {
5431
+ results: result.results,
5432
+ limitHit: result.limitHit
5433
+ };
5352
5434
  };
5353
5435
 
5354
5436
  const textSearch = async (scheme, root, query) => {
@@ -5364,11 +5446,16 @@ const textSearch = async (scheme, root, query) => {
5364
5446
  }]]);
5365
5447
  }
5366
5448
  }
5367
- return results;
5449
+ return {
5450
+ results,
5451
+ limitHit: false
5452
+ };
5368
5453
  };
5369
5454
 
5370
5455
  const textSearchProviderMap = {
5371
5456
  '': textSearch$1,
5457
+ // TODO deprecate/remove workspaces without scheme
5458
+ file: textSearch$1,
5372
5459
  web: textSearch,
5373
5460
  fetch: textSearch$4,
5374
5461
  html: textSearch$3,
@@ -5377,6 +5464,7 @@ const textSearchProviderMap = {
5377
5464
  };
5378
5465
 
5379
5466
  const listen = async () => {
5467
+ registerCommands(commandMap);
5380
5468
  add(textSearchProviderMap);
5381
5469
  const rpc = await WebWorkerRpcClient.create({
5382
5470
  commandMap: commandMap
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "5.6.0",
3
+ "version": "5.8.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"