@lvce-editor/text-search-worker 3.41.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 +135 -103
- package/package.json +1 -1
|
@@ -473,7 +473,6 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
473
473
|
}
|
|
474
474
|
return promise;
|
|
475
475
|
};
|
|
476
|
-
const Message$1 = 3;
|
|
477
476
|
const create$5$1 = async ({
|
|
478
477
|
messagePort,
|
|
479
478
|
isMessagePortOpen
|
|
@@ -481,24 +480,9 @@ const create$5$1 = async ({
|
|
|
481
480
|
if (!isMessagePort(messagePort)) {
|
|
482
481
|
throw new IpcError('port must be of type MessagePort');
|
|
483
482
|
}
|
|
484
|
-
|
|
483
|
+
{
|
|
485
484
|
return messagePort;
|
|
486
485
|
}
|
|
487
|
-
const eventPromise = getFirstEvent(messagePort, {
|
|
488
|
-
message: Message$1
|
|
489
|
-
});
|
|
490
|
-
messagePort.start();
|
|
491
|
-
const {
|
|
492
|
-
type,
|
|
493
|
-
event
|
|
494
|
-
} = await eventPromise;
|
|
495
|
-
if (type !== Message$1) {
|
|
496
|
-
throw new IpcError('Failed to wait for ipc message');
|
|
497
|
-
}
|
|
498
|
-
if (event.data !== readyMessage) {
|
|
499
|
-
throw new IpcError('unexpected first message');
|
|
500
|
-
}
|
|
501
|
-
return messagePort;
|
|
502
486
|
};
|
|
503
487
|
const signal$1 = messagePort => {
|
|
504
488
|
messagePort.start();
|
|
@@ -936,12 +920,12 @@ const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
|
936
920
|
return invokeHelper(ipc, method, params, true);
|
|
937
921
|
};
|
|
938
922
|
|
|
939
|
-
const commands = Object.create(null);
|
|
923
|
+
const commands$1 = Object.create(null);
|
|
940
924
|
const register = commandMap => {
|
|
941
|
-
Object.assign(commands, commandMap);
|
|
925
|
+
Object.assign(commands$1, commandMap);
|
|
942
926
|
};
|
|
943
927
|
const getCommand = key => {
|
|
944
|
-
return commands[key];
|
|
928
|
+
return commands$1[key];
|
|
945
929
|
};
|
|
946
930
|
const execute = (command, ...args) => {
|
|
947
931
|
const fn = getCommand(command);
|
|
@@ -1778,6 +1762,11 @@ const getActionsVirtualDom = actions => {
|
|
|
1778
1762
|
}, ...actions.flatMap(getActionVirtualDom)];
|
|
1779
1763
|
};
|
|
1780
1764
|
|
|
1765
|
+
const commands = ['clearSearchResults', 'copy', 'dismissItem', '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', 'handleIconThemeChange', 'handleIconThemeChange', 'handleIncludeInput', 'handleInput', 'handleListBlur', 'handleListFocus', 'handleReplaceInput', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleScrollBarThumbPointerMove', 'handleTouchEnd', 'handleTouchMove', 'handleTouchStart', 'handleUpdate', 'handleWheel', 'refresh', 'replaceAll', 'scrollDown', 'selectIndex', 'submit', 'toggleMatchCase', 'toggleMatchWholeWord', 'togglePreserveCase', 'toggleReplace', 'toggleSearchDetails', 'toggleUseRegularExpression'];
|
|
1766
|
+
const getCommandIds = () => {
|
|
1767
|
+
return commands;
|
|
1768
|
+
};
|
|
1769
|
+
|
|
1781
1770
|
const getFlags = uid => {
|
|
1782
1771
|
const {
|
|
1783
1772
|
newState
|
|
@@ -3686,106 +3675,148 @@ const refresh = state => {
|
|
|
3686
3675
|
return handleUpdate(state, {});
|
|
3687
3676
|
};
|
|
3688
3677
|
|
|
3689
|
-
const
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
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;
|
|
3717
3722
|
default:
|
|
3718
|
-
|
|
3723
|
+
throw new Error('unknown renderer');
|
|
3719
3724
|
}
|
|
3720
3725
|
};
|
|
3721
3726
|
|
|
3722
|
-
const
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
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);
|
|
3728
|
-
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3729
|
-
const scrollBarValue = newState.deltaY / newState.finalDeltaY * 100;
|
|
3730
|
-
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, newState.scrollBarHeight);
|
|
3731
|
-
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY, scrollBarValue, newState.deltaY, newState.itemHeight, newState.matchCount);
|
|
3732
|
-
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));
|
|
3733
3732
|
}
|
|
3733
|
+
return commands;
|
|
3734
3734
|
};
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
apply(oldState, newState) {
|
|
3740
|
-
const name = newState.focusSource === User ? '' : getFocusSelector(newState.focus);
|
|
3741
|
-
return ['Viewlet.focusElementByName', newState.uid, name];
|
|
3742
|
-
}
|
|
3735
|
+
|
|
3736
|
+
const diffType$5 = RenderExcludeValue;
|
|
3737
|
+
const isEqual$5 = (oldState, newState) => {
|
|
3738
|
+
return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
|
|
3743
3739
|
};
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.value, `[name="${SearchValue}"]`];
|
|
3750
|
-
}
|
|
3740
|
+
|
|
3741
|
+
const DiffExcludeValue = {
|
|
3742
|
+
__proto__: null,
|
|
3743
|
+
diffType: diffType$5,
|
|
3744
|
+
isEqual: isEqual$5
|
|
3751
3745
|
};
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
apply(oldState, newState) {
|
|
3757
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, `[name=${ReplaceValue}]`];
|
|
3758
|
-
}
|
|
3746
|
+
|
|
3747
|
+
const diffType$4 = RenderFocus;
|
|
3748
|
+
const isEqual$4 = (oldState, newState) => {
|
|
3749
|
+
return oldState.focus === newState.focus || newState.focusSource === User;
|
|
3759
3750
|
};
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
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;
|
|
3767
3783
|
};
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
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;
|
|
3794
|
+
};
|
|
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
|
+
}
|
|
3774
3809
|
}
|
|
3810
|
+
return diffResult;
|
|
3775
3811
|
};
|
|
3776
|
-
|
|
3812
|
+
|
|
3777
3813
|
const doRender = uid => {
|
|
3778
3814
|
const {
|
|
3779
3815
|
oldState,
|
|
3780
3816
|
newState
|
|
3781
3817
|
} = get(uid);
|
|
3782
|
-
const
|
|
3783
|
-
|
|
3784
|
-
if (!fn.isEqual(oldState, newState)) {
|
|
3785
|
-
commands.push(fn.apply(oldState, newState));
|
|
3786
|
-
}
|
|
3787
|
-
}
|
|
3788
|
-
return commands;
|
|
3818
|
+
const diffResult = diff$1(oldState, newState);
|
|
3819
|
+
return applyRender(oldState, newState, diffResult);
|
|
3789
3820
|
};
|
|
3790
3821
|
|
|
3791
3822
|
const renderEventListeners = () => {
|
|
@@ -4426,6 +4457,7 @@ const commandMap = {
|
|
|
4426
4457
|
'TextSearch.focusPreviousInput': wrapCommand(focusPreviousInput),
|
|
4427
4458
|
'TextSearch.focusPreviousPage': wrapCommand(focusPreviousPage),
|
|
4428
4459
|
'TextSearch.focusRegex': wrapCommand(focusRegex),
|
|
4460
|
+
'TextSearch.getCommandIds': getCommandIds,
|
|
4429
4461
|
'TextSearch.focusRegexNext': wrapCommand(focusRegexNext),
|
|
4430
4462
|
'TextSearch.focusReplaceAll': wrapCommand(focusReplaceAll),
|
|
4431
4463
|
'TextSearch.focusReplaceValue': wrapCommand(focusReplaceValue$1),
|