@lvce-editor/text-search-worker 3.42.0 → 3.43.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 +125 -83
- package/package.json +1 -1
|
@@ -3675,106 +3675,148 @@ const refresh = state => {
|
|
|
3675
3675
|
return handleUpdate(state, {});
|
|
3676
3676
|
};
|
|
3677
3677
|
|
|
3678
|
-
const
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3678
|
+
const RenderItems = 1;
|
|
3679
|
+
const RenderFocus = 2;
|
|
3680
|
+
const RenderValue = 3;
|
|
3681
|
+
const RenderReplaceValue = 4;
|
|
3682
|
+
const RenderIncludeValue = 5;
|
|
3683
|
+
const RenderExcludeValue = 6;
|
|
3684
|
+
|
|
3685
|
+
const renderItems = (oldState, newState) => {
|
|
3686
|
+
const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex, newState.collapsedPaths, newState.items);
|
|
3687
|
+
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3688
|
+
const scrollBarValue = newState.deltaY / newState.finalDeltaY * 100;
|
|
3689
|
+
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, newState.scrollBarHeight);
|
|
3690
|
+
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY, scrollBarValue, newState.deltaY, newState.itemHeight, newState.matchCount);
|
|
3691
|
+
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3692
|
+
};
|
|
3693
|
+
const renderFocus = (oldState, newState) => {
|
|
3694
|
+
return oldState.focus === newState.focus || newState.focusSource === User;
|
|
3695
|
+
};
|
|
3696
|
+
const renderValue = (oldState, newState) => {
|
|
3697
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.value, `[name="${SearchValue}"]`];
|
|
3698
|
+
};
|
|
3699
|
+
const renderReplacement = (oldState, newState) => {
|
|
3700
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, `[name=${ReplaceValue}]`];
|
|
3701
|
+
};
|
|
3702
|
+
const renderIncludeValue = (oldState, newState) => {
|
|
3703
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.includeValue, `[name=${FilesToInclude}]`];
|
|
3704
|
+
};
|
|
3705
|
+
const renderExcludeValue = (oldState, newState) => {
|
|
3706
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, `[name=${FilesToExclude}]`];
|
|
3707
|
+
};
|
|
3708
|
+
const getRenderer = diffType => {
|
|
3709
|
+
switch (diffType) {
|
|
3710
|
+
case RenderValue:
|
|
3711
|
+
return renderValue;
|
|
3712
|
+
case RenderFocus:
|
|
3713
|
+
return renderFocus;
|
|
3714
|
+
case RenderReplaceValue:
|
|
3715
|
+
return renderReplacement;
|
|
3716
|
+
case RenderIncludeValue:
|
|
3717
|
+
return renderIncludeValue;
|
|
3718
|
+
case RenderExcludeValue:
|
|
3719
|
+
return renderExcludeValue;
|
|
3720
|
+
case RenderItems:
|
|
3721
|
+
return renderItems;
|
|
3706
3722
|
default:
|
|
3707
|
-
|
|
3723
|
+
throw new Error('unknown renderer');
|
|
3708
3724
|
}
|
|
3709
3725
|
};
|
|
3710
3726
|
|
|
3711
|
-
const
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex, newState.collapsedPaths, newState.items);
|
|
3717
|
-
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3718
|
-
const scrollBarValue = newState.deltaY / newState.finalDeltaY * 100;
|
|
3719
|
-
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, newState.scrollBarHeight);
|
|
3720
|
-
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY, scrollBarValue, newState.deltaY, newState.itemHeight, newState.matchCount);
|
|
3721
|
-
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3727
|
+
const applyRender = (oldState, newState, diffResult) => {
|
|
3728
|
+
const commands = [];
|
|
3729
|
+
for (const item of diffResult) {
|
|
3730
|
+
const fn = getRenderer(item);
|
|
3731
|
+
commands.push(fn(oldState, newState));
|
|
3722
3732
|
}
|
|
3733
|
+
return commands;
|
|
3723
3734
|
};
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
apply(oldState, newState) {
|
|
3729
|
-
const name = newState.focusSource === User ? '' : getFocusSelector(newState.focus);
|
|
3730
|
-
return ['Viewlet.focusElementByName', newState.uid, name];
|
|
3731
|
-
}
|
|
3735
|
+
|
|
3736
|
+
const diffType$5 = RenderExcludeValue;
|
|
3737
|
+
const isEqual$5 = (oldState, newState) => {
|
|
3738
|
+
return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
|
|
3732
3739
|
};
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.value, `[name="${SearchValue}"]`];
|
|
3739
|
-
}
|
|
3740
|
+
|
|
3741
|
+
const DiffExcludeValue = {
|
|
3742
|
+
__proto__: null,
|
|
3743
|
+
diffType: diffType$5,
|
|
3744
|
+
isEqual: isEqual$5
|
|
3740
3745
|
};
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
apply(oldState, newState) {
|
|
3746
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, `[name=${ReplaceValue}]`];
|
|
3747
|
-
}
|
|
3746
|
+
|
|
3747
|
+
const diffType$4 = RenderFocus;
|
|
3748
|
+
const isEqual$4 = (oldState, newState) => {
|
|
3749
|
+
return oldState.focus === newState.focus || newState.focusSource === User;
|
|
3748
3750
|
};
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3751
|
+
|
|
3752
|
+
const DiffFocus = {
|
|
3753
|
+
__proto__: null,
|
|
3754
|
+
diffType: diffType$4,
|
|
3755
|
+
isEqual: isEqual$4
|
|
3756
|
+
};
|
|
3757
|
+
|
|
3758
|
+
const diffType$3 = RenderIncludeValue;
|
|
3759
|
+
const isEqual$3 = (oldState, newState) => {
|
|
3760
|
+
return oldState.includeValue === newState.includeValue || newState.inputSource === User;
|
|
3761
|
+
};
|
|
3762
|
+
|
|
3763
|
+
const DiffIncludeValue = {
|
|
3764
|
+
__proto__: null,
|
|
3765
|
+
diffType: diffType$3,
|
|
3766
|
+
isEqual: isEqual$3
|
|
3767
|
+
};
|
|
3768
|
+
|
|
3769
|
+
const diffType$2 = RenderItems;
|
|
3770
|
+
const isEqual$2 = (oldState, newState) => {
|
|
3771
|
+
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;
|
|
3772
|
+
};
|
|
3773
|
+
|
|
3774
|
+
const DiffItems = {
|
|
3775
|
+
__proto__: null,
|
|
3776
|
+
diffType: diffType$2,
|
|
3777
|
+
isEqual: isEqual$2
|
|
3778
|
+
};
|
|
3779
|
+
|
|
3780
|
+
const diffType$1 = RenderReplaceValue;
|
|
3781
|
+
const isEqual$1 = (oldState, newState) => {
|
|
3782
|
+
return oldState.replacement === newState.replacement || newState.inputSource === User;
|
|
3783
|
+
};
|
|
3784
|
+
|
|
3785
|
+
const DiffReplaceValue = {
|
|
3786
|
+
__proto__: null,
|
|
3787
|
+
diffType: diffType$1,
|
|
3788
|
+
isEqual: isEqual$1
|
|
3789
|
+
};
|
|
3790
|
+
|
|
3791
|
+
const diffType = RenderValue;
|
|
3792
|
+
const isEqual = (oldState, newState) => {
|
|
3793
|
+
return oldState.value === newState.value || newState.inputSource === User;
|
|
3756
3794
|
};
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3795
|
+
|
|
3796
|
+
const DiffValue = {
|
|
3797
|
+
__proto__: null,
|
|
3798
|
+
diffType,
|
|
3799
|
+
isEqual
|
|
3800
|
+
};
|
|
3801
|
+
|
|
3802
|
+
const modules = [DiffItems, DiffFocus, DiffIncludeValue, DiffExcludeValue, DiffReplaceValue, DiffValue];
|
|
3803
|
+
const diff$1 = (oldState, newState) => {
|
|
3804
|
+
const diffResult = [];
|
|
3805
|
+
for (const module of modules) {
|
|
3806
|
+
if (!module.isEqual(oldState, newState)) {
|
|
3807
|
+
diffResult.push(module.diffType);
|
|
3808
|
+
}
|
|
3763
3809
|
}
|
|
3810
|
+
return diffResult;
|
|
3764
3811
|
};
|
|
3765
|
-
|
|
3812
|
+
|
|
3766
3813
|
const doRender = uid => {
|
|
3767
3814
|
const {
|
|
3768
3815
|
oldState,
|
|
3769
3816
|
newState
|
|
3770
3817
|
} = get(uid);
|
|
3771
|
-
const
|
|
3772
|
-
|
|
3773
|
-
if (!fn.isEqual(oldState, newState)) {
|
|
3774
|
-
commands.push(fn.apply(oldState, newState));
|
|
3775
|
-
}
|
|
3776
|
-
}
|
|
3777
|
-
return commands;
|
|
3818
|
+
const diffResult = diff$1(oldState, newState);
|
|
3819
|
+
return applyRender(oldState, newState, diffResult);
|
|
3778
3820
|
};
|
|
3779
3821
|
|
|
3780
3822
|
const renderEventListeners = () => {
|