@lvce-editor/text-search-worker 6.2.0 → 6.3.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.
- package/dist/textSearchWorkerMain.js +133 -63
- package/package.json +1 -1
|
@@ -1306,6 +1306,7 @@ const File$1 = 1;
|
|
|
1306
1306
|
const Match$1 = 2;
|
|
1307
1307
|
|
|
1308
1308
|
const FocusElementByName = 'Viewlet.focusElementByName';
|
|
1309
|
+
const SetCss = 'Viewlet.setCss';
|
|
1309
1310
|
const SetDom2 = 'Viewlet.setDom2';
|
|
1310
1311
|
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1311
1312
|
const SetValueByName = 'Viewlet.setValueByName';
|
|
@@ -2187,6 +2188,10 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
2187
2188
|
return state;
|
|
2188
2189
|
};
|
|
2189
2190
|
|
|
2191
|
+
const isEqual$7 = (oldState, newState) => {
|
|
2192
|
+
return oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.headerHeight === newState.headerHeight && oldState.itemHeight === newState.itemHeight && oldState.items === newState.items;
|
|
2193
|
+
};
|
|
2194
|
+
|
|
2190
2195
|
const RenderItems = 1;
|
|
2191
2196
|
const RenderFocus = 2;
|
|
2192
2197
|
const RenderValue = 3;
|
|
@@ -2196,6 +2201,7 @@ const RenderExcludeValue = 6;
|
|
|
2196
2201
|
const RenderFocusContext = 7;
|
|
2197
2202
|
const RenderSelections = 8;
|
|
2198
2203
|
const RenderIncremental = 9;
|
|
2204
|
+
const RenderCss = 10;
|
|
2199
2205
|
|
|
2200
2206
|
const isEqual$6 = (oldState, newState) => {
|
|
2201
2207
|
return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
|
|
@@ -2225,8 +2231,8 @@ const isEqual = (oldState, newState) => {
|
|
|
2225
2231
|
return oldState.value === newState.value || newState.inputSource === User;
|
|
2226
2232
|
};
|
|
2227
2233
|
|
|
2228
|
-
const modules = [isEqual$2, isEqual$5, isEqual$3, isEqual$6, isEqual$1, isEqual, isEqual$4];
|
|
2229
|
-
const numbers = [RenderIncremental, RenderFocus, RenderIncludeValue, RenderExcludeValue, RenderReplaceValue, RenderValue, RenderFocusContext];
|
|
2234
|
+
const modules = [isEqual$2, isEqual$5, isEqual$3, isEqual$6, isEqual$1, isEqual, isEqual$4, isEqual$7];
|
|
2235
|
+
const numbers = [RenderIncremental, RenderFocus, RenderIncludeValue, RenderExcludeValue, RenderReplaceValue, RenderValue, RenderFocusContext, RenderCss];
|
|
2230
2236
|
|
|
2231
2237
|
const diff = (oldState, newState) => {
|
|
2232
2238
|
const diffResult = [];
|
|
@@ -4828,50 +4834,6 @@ const removeCurrent = async state => {
|
|
|
4828
4834
|
return removeIndex(state, actualIndex);
|
|
4829
4835
|
};
|
|
4830
4836
|
|
|
4831
|
-
const getFocusSelector = focusKey => {
|
|
4832
|
-
switch (focusKey) {
|
|
4833
|
-
case FocusIgnoreFiles:
|
|
4834
|
-
return UseExcludeSettings;
|
|
4835
|
-
case FocusSearchExcludeInput:
|
|
4836
|
-
return FilesToExclude;
|
|
4837
|
-
case FocusSearchIncludeInput:
|
|
4838
|
-
return FilesToInclude;
|
|
4839
|
-
case FocusSearchInput:
|
|
4840
|
-
return SearchValue;
|
|
4841
|
-
case FocusSearchMatchCase:
|
|
4842
|
-
return MatchCase;
|
|
4843
|
-
case FocusSearchOpenEditors:
|
|
4844
|
-
return SearchOnlyOpenEditors;
|
|
4845
|
-
case FocusSearchPreserveCase:
|
|
4846
|
-
return PreserveCase;
|
|
4847
|
-
case FocusSearchRegex:
|
|
4848
|
-
return UseRegularExpression;
|
|
4849
|
-
case FocusSearchReplaceAll:
|
|
4850
|
-
return ReplaceAll;
|
|
4851
|
-
case FocusSearchReplaceInput:
|
|
4852
|
-
return ReplaceValue;
|
|
4853
|
-
case FocusSearchResults:
|
|
4854
|
-
return '.Tree';
|
|
4855
|
-
case FocusSearchWholeWord:
|
|
4856
|
-
return MatchWholeWord;
|
|
4857
|
-
case FocusToggleDetails:
|
|
4858
|
-
return ToggleSearchDetails;
|
|
4859
|
-
case FocusToggleReplace:
|
|
4860
|
-
return ToggleReplace;
|
|
4861
|
-
default:
|
|
4862
|
-
return '';
|
|
4863
|
-
}
|
|
4864
|
-
};
|
|
4865
|
-
|
|
4866
|
-
const renderFocus = (oldState, newState) => {
|
|
4867
|
-
const selector = getFocusSelector(newState.focus);
|
|
4868
|
-
return [FocusElementByName, newState.uid, selector];
|
|
4869
|
-
};
|
|
4870
|
-
|
|
4871
|
-
const renderFocusContext = (oldState, newState) => {
|
|
4872
|
-
return [SetFocusContext, newState.uid, FocusSearch, newState.focus];
|
|
4873
|
-
};
|
|
4874
|
-
|
|
4875
4837
|
const None = 0;
|
|
4876
4838
|
const Collapsed = 1;
|
|
4877
4839
|
const Expanded = 2;
|
|
@@ -4886,6 +4848,12 @@ const getMatchCount = (results, startIndex) => {
|
|
|
4886
4848
|
return results.length - startIndex - 1;
|
|
4887
4849
|
};
|
|
4888
4850
|
|
|
4851
|
+
const defaultIndent = 12;
|
|
4852
|
+
const baseIndent = 16;
|
|
4853
|
+
const getTreeItemIndent = depth => {
|
|
4854
|
+
return baseIndent + depth * defaultIndent;
|
|
4855
|
+
};
|
|
4856
|
+
|
|
4889
4857
|
const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, originalResults) => {
|
|
4890
4858
|
const path = text;
|
|
4891
4859
|
const absolutePath = getRelativePath(path);
|
|
@@ -4894,12 +4862,15 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
|
|
|
4894
4862
|
const matchCount = getMatchCount(originalResults, index);
|
|
4895
4863
|
const expanded = collapsedPaths.includes(path) ? Collapsed : Expanded;
|
|
4896
4864
|
const badgeText = `${matchCount}`;
|
|
4865
|
+
const depth = 0;
|
|
4866
|
+
const indent = getTreeItemIndent(depth);
|
|
4897
4867
|
return {
|
|
4898
4868
|
badgeText,
|
|
4899
|
-
depth
|
|
4869
|
+
depth,
|
|
4900
4870
|
expanded,
|
|
4901
4871
|
focused,
|
|
4902
4872
|
icon: fileIcons[relativeIndex],
|
|
4873
|
+
indent,
|
|
4903
4874
|
matchLength: 0,
|
|
4904
4875
|
matchStart: 0,
|
|
4905
4876
|
posInSet,
|
|
@@ -4911,12 +4882,15 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
|
|
|
4911
4882
|
};
|
|
4912
4883
|
|
|
4913
4884
|
const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, posInSet, start, focused) => {
|
|
4885
|
+
const depth = 1;
|
|
4886
|
+
const indent = getTreeItemIndent(depth);
|
|
4914
4887
|
return {
|
|
4915
4888
|
badgeText: '',
|
|
4916
|
-
depth
|
|
4889
|
+
depth,
|
|
4917
4890
|
expanded: None,
|
|
4918
4891
|
focused,
|
|
4919
4892
|
icon: '',
|
|
4893
|
+
indent,
|
|
4920
4894
|
matchLength: searchTermLength,
|
|
4921
4895
|
matchStart: start,
|
|
4922
4896
|
posInSet,
|
|
@@ -5007,6 +4981,106 @@ const createViewModel = state => {
|
|
|
5007
4981
|
};
|
|
5008
4982
|
};
|
|
5009
4983
|
|
|
4984
|
+
const getIndentRule = indent => {
|
|
4985
|
+
return `.Indent-${indent} {
|
|
4986
|
+
padding-left: ${indent}px;
|
|
4987
|
+
}`;
|
|
4988
|
+
};
|
|
4989
|
+
const getIndentRightRule = indentRight => {
|
|
4990
|
+
return `.IndentRight-${indentRight} {
|
|
4991
|
+
padding-right: ${indentRight}px;
|
|
4992
|
+
}`;
|
|
4993
|
+
};
|
|
4994
|
+
const getTreeItemsTopRule = treeItemsTop => {
|
|
4995
|
+
const roundedTreeItemsTop = Math.round(treeItemsTop);
|
|
4996
|
+
return `.TreeItemsTop-${roundedTreeItemsTop} {
|
|
4997
|
+
top: ${roundedTreeItemsTop}px;
|
|
4998
|
+
}`;
|
|
4999
|
+
};
|
|
5000
|
+
const getCss = (top, uniqueIndents, uniqueIndentRights, scrollBarHeight, scrollBarY, treeItemsTop) => {
|
|
5001
|
+
const rules = [`.Search {
|
|
5002
|
+
--ScrollBarHeight: ${scrollBarHeight}px;
|
|
5003
|
+
--ScrollBarTop: ${scrollBarY}px;
|
|
5004
|
+
--TreeItemsTop: ${top}px;
|
|
5005
|
+
}
|
|
5006
|
+
`, ...uniqueIndents.map(getIndentRule), ...uniqueIndentRights.map(getIndentRightRule), getTreeItemsTopRule(treeItemsTop)];
|
|
5007
|
+
return rules.join('\n');
|
|
5008
|
+
};
|
|
5009
|
+
|
|
5010
|
+
const getUnique = items => {
|
|
5011
|
+
const seens = [];
|
|
5012
|
+
for (const item of items) {
|
|
5013
|
+
if (!seens.includes(item)) {
|
|
5014
|
+
seens.push(item);
|
|
5015
|
+
}
|
|
5016
|
+
}
|
|
5017
|
+
return seens;
|
|
5018
|
+
};
|
|
5019
|
+
|
|
5020
|
+
const getUniqueIndents = indents => {
|
|
5021
|
+
const uniqueIndents = getUnique(indents);
|
|
5022
|
+
return uniqueIndents;
|
|
5023
|
+
};
|
|
5024
|
+
|
|
5025
|
+
const PaddingRight = 12;
|
|
5026
|
+
|
|
5027
|
+
const renderCss = (oldState, newState) => {
|
|
5028
|
+
const {
|
|
5029
|
+
uid
|
|
5030
|
+
} = newState;
|
|
5031
|
+
const viewModel = createViewModel(newState);
|
|
5032
|
+
const indents = viewModel.displayResults.map(item => item.indent);
|
|
5033
|
+
const uniqueIndents = getUniqueIndents(indents);
|
|
5034
|
+
const uniqueIndentRights = [PaddingRight];
|
|
5035
|
+
const treeItemsTop = viewModel.itemHeight === 0 ? 0 : Math.round(-(viewModel.deltaY % viewModel.itemHeight));
|
|
5036
|
+
const css = getCss(0, uniqueIndents, uniqueIndentRights, viewModel.scrollBarHeight, viewModel.scrollBarY, treeItemsTop);
|
|
5037
|
+
return [SetCss, uid, css];
|
|
5038
|
+
};
|
|
5039
|
+
|
|
5040
|
+
const getFocusSelector = focusKey => {
|
|
5041
|
+
switch (focusKey) {
|
|
5042
|
+
case FocusIgnoreFiles:
|
|
5043
|
+
return UseExcludeSettings;
|
|
5044
|
+
case FocusSearchExcludeInput:
|
|
5045
|
+
return FilesToExclude;
|
|
5046
|
+
case FocusSearchIncludeInput:
|
|
5047
|
+
return FilesToInclude;
|
|
5048
|
+
case FocusSearchInput:
|
|
5049
|
+
return SearchValue;
|
|
5050
|
+
case FocusSearchMatchCase:
|
|
5051
|
+
return MatchCase;
|
|
5052
|
+
case FocusSearchOpenEditors:
|
|
5053
|
+
return SearchOnlyOpenEditors;
|
|
5054
|
+
case FocusSearchPreserveCase:
|
|
5055
|
+
return PreserveCase;
|
|
5056
|
+
case FocusSearchRegex:
|
|
5057
|
+
return UseRegularExpression;
|
|
5058
|
+
case FocusSearchReplaceAll:
|
|
5059
|
+
return ReplaceAll;
|
|
5060
|
+
case FocusSearchReplaceInput:
|
|
5061
|
+
return ReplaceValue;
|
|
5062
|
+
case FocusSearchResults:
|
|
5063
|
+
return '.Tree';
|
|
5064
|
+
case FocusSearchWholeWord:
|
|
5065
|
+
return MatchWholeWord;
|
|
5066
|
+
case FocusToggleDetails:
|
|
5067
|
+
return ToggleSearchDetails;
|
|
5068
|
+
case FocusToggleReplace:
|
|
5069
|
+
return ToggleReplace;
|
|
5070
|
+
default:
|
|
5071
|
+
return '';
|
|
5072
|
+
}
|
|
5073
|
+
};
|
|
5074
|
+
|
|
5075
|
+
const renderFocus = (oldState, newState) => {
|
|
5076
|
+
const selector = getFocusSelector(newState.focus);
|
|
5077
|
+
return [FocusElementByName, newState.uid, selector];
|
|
5078
|
+
};
|
|
5079
|
+
|
|
5080
|
+
const renderFocusContext = (oldState, newState) => {
|
|
5081
|
+
return [SetFocusContext, newState.uid, FocusSearch, newState.focus];
|
|
5082
|
+
};
|
|
5083
|
+
|
|
5010
5084
|
const HandleClick = 1;
|
|
5011
5085
|
const HandleListContextMenu = 2;
|
|
5012
5086
|
const HandleHeaderContextMenu = 3;
|
|
@@ -5033,7 +5107,7 @@ const getSearchDetailsToggleVirtualDom = () => {
|
|
|
5033
5107
|
return [{
|
|
5034
5108
|
ariaLabel: toggleSearchDetails(),
|
|
5035
5109
|
childCount: 1,
|
|
5036
|
-
className: ToggleDetails,
|
|
5110
|
+
className: mergeClassNames(ToggleDetails, IconButton),
|
|
5037
5111
|
name: ToggleSearchDetails,
|
|
5038
5112
|
onClick: HandleButtonClick,
|
|
5039
5113
|
role: Button$3,
|
|
@@ -5512,17 +5586,14 @@ const getLabelVirtualDom = (displayText, matchLength, matchStart, replacement) =
|
|
|
5512
5586
|
const highlight = displayText.slice(matchStart, matchStart + matchLength);
|
|
5513
5587
|
const after = displayText.slice(matchStart + matchLength);
|
|
5514
5588
|
if (replacement) {
|
|
5515
|
-
|
|
5589
|
+
const replacementPreview = replacement.split(/\r\n|\r|\n/, 1)[0];
|
|
5590
|
+
return [label4, text(before), deleted, text(highlight), inserted, text(replacementPreview), text(after)];
|
|
5516
5591
|
}
|
|
5517
5592
|
return [label3, text(before), highlighted, text(highlight), text(after)];
|
|
5518
5593
|
}
|
|
5519
5594
|
return [label1, text(displayText)];
|
|
5520
5595
|
};
|
|
5521
5596
|
|
|
5522
|
-
const getPaddingLeft = depth => {
|
|
5523
|
-
return `${Number(depth) + 1}rem`; // TODO use classname and dynamic css
|
|
5524
|
-
};
|
|
5525
|
-
|
|
5526
5597
|
const getChildCount = (icon, expanded, badgeText) => {
|
|
5527
5598
|
let childCount = 0;
|
|
5528
5599
|
if (expanded) {
|
|
@@ -5563,8 +5634,6 @@ const getSearchResultClassName = focused => {
|
|
|
5563
5634
|
return TreeItem;
|
|
5564
5635
|
};
|
|
5565
5636
|
|
|
5566
|
-
const PaddingRight = '12px';
|
|
5567
|
-
|
|
5568
5637
|
const getSearchResultVirtualDom = rowInfo => {
|
|
5569
5638
|
const {
|
|
5570
5639
|
badgeText,
|
|
@@ -5572,6 +5641,7 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
5572
5641
|
expanded,
|
|
5573
5642
|
focused,
|
|
5574
5643
|
icon,
|
|
5644
|
+
indent,
|
|
5575
5645
|
matchLength,
|
|
5576
5646
|
matchStart,
|
|
5577
5647
|
posInSet,
|
|
@@ -5580,6 +5650,7 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
5580
5650
|
text: displayText,
|
|
5581
5651
|
title
|
|
5582
5652
|
} = rowInfo;
|
|
5653
|
+
const className = `${getSearchResultClassName(focused)} Indent-${indent} IndentRight-${PaddingRight}`;
|
|
5583
5654
|
const childCount = getChildCount(icon, expanded, badgeText);
|
|
5584
5655
|
const dom = [{
|
|
5585
5656
|
ariaDescription: '',
|
|
@@ -5589,9 +5660,7 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
5589
5660
|
ariaPosInSet: posInSet,
|
|
5590
5661
|
ariaSetSize: setSize,
|
|
5591
5662
|
childCount,
|
|
5592
|
-
className
|
|
5593
|
-
paddingLeft: getPaddingLeft(depth),
|
|
5594
|
-
paddingRight: PaddingRight,
|
|
5663
|
+
className,
|
|
5595
5664
|
role: TreeItem$1,
|
|
5596
5665
|
title,
|
|
5597
5666
|
type: Div
|
|
@@ -5600,17 +5669,16 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
5600
5669
|
};
|
|
5601
5670
|
|
|
5602
5671
|
const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
|
|
5603
|
-
const pixelOffset = deltaY % itemHeight;
|
|
5672
|
+
const pixelOffset = itemHeight === 0 ? 0 : deltaY % itemHeight;
|
|
5673
|
+
const treeItemsTop = Math.round(-pixelOffset);
|
|
5604
5674
|
return [{
|
|
5605
5675
|
childCount: visibleItems.length,
|
|
5606
|
-
className: TreeItems$1
|
|
5676
|
+
className: `${TreeItems$1} TreeItemsTop-${treeItemsTop}`,
|
|
5607
5677
|
id: TreeItems,
|
|
5608
5678
|
onBlur: HandleListBlur,
|
|
5609
5679
|
onClick: HandleClick,
|
|
5610
5680
|
onContextMenu: HandleListContextMenu,
|
|
5611
5681
|
onWheel: HandleWheel,
|
|
5612
|
-
top: `${-pixelOffset}px`,
|
|
5613
|
-
// TODO use dynamic css instead
|
|
5614
5682
|
type: Div
|
|
5615
5683
|
}, ...visibleItems.flatMap(getSearchResultVirtualDom)];
|
|
5616
5684
|
};
|
|
@@ -5680,6 +5748,8 @@ const renderExcludeValue = (oldState, newState) => {
|
|
|
5680
5748
|
|
|
5681
5749
|
const getRenderer = diffType => {
|
|
5682
5750
|
switch (diffType) {
|
|
5751
|
+
case RenderCss:
|
|
5752
|
+
return renderCss;
|
|
5683
5753
|
case RenderExcludeValue:
|
|
5684
5754
|
return renderExcludeValue;
|
|
5685
5755
|
case RenderFocus:
|