@lvce-editor/text-search-worker 5.19.0 → 5.20.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 +101 -43
- package/package.json +1 -1
|
@@ -602,7 +602,7 @@ const set$5 = (id, fn) => {
|
|
|
602
602
|
const get$3 = id => {
|
|
603
603
|
return callbacks[id];
|
|
604
604
|
};
|
|
605
|
-
const remove$
|
|
605
|
+
const remove$2 = id => {
|
|
606
606
|
delete callbacks[id];
|
|
607
607
|
};
|
|
608
608
|
let id = 0;
|
|
@@ -787,7 +787,7 @@ const resolve = (id, response) => {
|
|
|
787
787
|
return;
|
|
788
788
|
}
|
|
789
789
|
fn(response);
|
|
790
|
-
remove$
|
|
790
|
+
remove$2(id);
|
|
791
791
|
};
|
|
792
792
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
793
793
|
const getErrorType = prettyError => {
|
|
@@ -1328,6 +1328,8 @@ const DeltaY = 'event.deltaY';
|
|
|
1328
1328
|
const TargetName = 'event.target.name';
|
|
1329
1329
|
const TargetValue = 'event.target.value';
|
|
1330
1330
|
|
|
1331
|
+
const Script$1 = 2;
|
|
1332
|
+
|
|
1331
1333
|
const Search$1 = 18;
|
|
1332
1334
|
|
|
1333
1335
|
const None$1 = 0;
|
|
@@ -1338,10 +1340,12 @@ const Electron = 2;
|
|
|
1338
1340
|
const Remote = 3;
|
|
1339
1341
|
|
|
1340
1342
|
const DebugWorker = 55;
|
|
1341
|
-
const RendererWorker$
|
|
1343
|
+
const RendererWorker$2 = 1;
|
|
1342
1344
|
const SearchProcess = 77;
|
|
1343
1345
|
const IconThemeWorker = 7009;
|
|
1344
1346
|
|
|
1347
|
+
const Match$1 = 2;
|
|
1348
|
+
|
|
1345
1349
|
const FocusElementByName = 'Viewlet.focusElementByName';
|
|
1346
1350
|
const SetDom2 = 'Viewlet.setDom2';
|
|
1347
1351
|
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
@@ -1706,7 +1710,7 @@ const {
|
|
|
1706
1710
|
invokeAndTransfer,
|
|
1707
1711
|
set: set$2,
|
|
1708
1712
|
dispose
|
|
1709
|
-
} = create$2(RendererWorker$
|
|
1713
|
+
} = create$2(RendererWorker$2);
|
|
1710
1714
|
const searchFileHtml = async uri => {
|
|
1711
1715
|
return invoke$2('ExtensionHost.searchFileWithHtml', uri);
|
|
1712
1716
|
};
|
|
@@ -1716,6 +1720,10 @@ const getFilePathElectron = async file => {
|
|
|
1716
1720
|
const showContextMenu$1 = async (x, y, id, ...args) => {
|
|
1717
1721
|
return invoke$2('ContextMenu.show', x, y, id, ...args);
|
|
1718
1722
|
};
|
|
1723
|
+
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1724
|
+
// @ts-ignore
|
|
1725
|
+
await RendererWorker.invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1726
|
+
};
|
|
1719
1727
|
const getElectronVersion = async () => {
|
|
1720
1728
|
return invoke$2('Process.getElectronVersion');
|
|
1721
1729
|
};
|
|
@@ -1945,7 +1953,7 @@ const openExtensionSearch = async () => {
|
|
|
1945
1953
|
};
|
|
1946
1954
|
const setExtensionsSearchValue = async searchValue => {
|
|
1947
1955
|
// @ts-ignore
|
|
1948
|
-
return invoke$2('Extensions.handleInput', searchValue);
|
|
1956
|
+
return invoke$2('Extensions.handleInput', searchValue, Script$1);
|
|
1949
1957
|
};
|
|
1950
1958
|
const openExternal = async uri => {
|
|
1951
1959
|
// @ts-ignore
|
|
@@ -1975,7 +1983,7 @@ const registerMockRpc = commandMap => {
|
|
|
1975
1983
|
return mockRpc;
|
|
1976
1984
|
};
|
|
1977
1985
|
|
|
1978
|
-
const RendererWorker = {
|
|
1986
|
+
const RendererWorker$1 = {
|
|
1979
1987
|
__proto__: null,
|
|
1980
1988
|
activateByEvent,
|
|
1981
1989
|
applyBulkReplacement: applyBulkReplacement$1,
|
|
@@ -2047,6 +2055,7 @@ const RendererWorker = {
|
|
|
2047
2055
|
setWebViewPort,
|
|
2048
2056
|
setWorkspacePath,
|
|
2049
2057
|
showContextMenu: showContextMenu$1,
|
|
2058
|
+
showContextMenu2,
|
|
2050
2059
|
showErrorDialog,
|
|
2051
2060
|
showMessageBox,
|
|
2052
2061
|
showSaveFilePicker,
|
|
@@ -2087,7 +2096,7 @@ const {
|
|
|
2087
2096
|
sendMessagePortToSearchProcess,
|
|
2088
2097
|
set: set$1,
|
|
2089
2098
|
showContextMenu,
|
|
2090
|
-
writeClipBoardText} = RendererWorker;
|
|
2099
|
+
writeClipBoardText} = RendererWorker$1;
|
|
2091
2100
|
|
|
2092
2101
|
const copy = async state => {
|
|
2093
2102
|
const {
|
|
@@ -2203,7 +2212,9 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
2203
2212
|
limitHit: false,
|
|
2204
2213
|
limitHitWarning: '',
|
|
2205
2214
|
limit: 20_000,
|
|
2206
|
-
fileIconCache: {}
|
|
2215
|
+
fileIconCache: {},
|
|
2216
|
+
removeButtonWidth: 20,
|
|
2217
|
+
removeButtonRight: 0
|
|
2207
2218
|
};
|
|
2208
2219
|
set(uid, state, state);
|
|
2209
2220
|
return state;
|
|
@@ -2276,7 +2287,7 @@ const diff2 = uid => {
|
|
|
2276
2287
|
|
|
2277
2288
|
// based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
|
|
2278
2289
|
|
|
2279
|
-
const remove = (array, index, deleteCount) => {
|
|
2290
|
+
const remove$1 = (array, index, deleteCount) => {
|
|
2280
2291
|
return array.toSpliced(index, deleteCount);
|
|
2281
2292
|
};
|
|
2282
2293
|
|
|
@@ -2309,6 +2320,7 @@ const Include = 'Include';
|
|
|
2309
2320
|
const ManyResultsInManyFiles = '{PH1} results in {PH2} files';
|
|
2310
2321
|
const ManyResultsInOneFile = '{PH1} results in 1 file';
|
|
2311
2322
|
const MatchCase$1 = 'Match Case';
|
|
2323
|
+
const Remove$1 = 'Remove';
|
|
2312
2324
|
const MatchWholeWord$1 = 'Match Whole Word';
|
|
2313
2325
|
const NoResults = 'No results found';
|
|
2314
2326
|
const Oneresult = '1 result in 1 file';
|
|
@@ -2342,6 +2354,9 @@ const toggleReplace$1 = () => {
|
|
|
2342
2354
|
const matchCase = () => {
|
|
2343
2355
|
return i18nString(MatchCase$1);
|
|
2344
2356
|
};
|
|
2357
|
+
const remove = () => {
|
|
2358
|
+
return i18nString(Remove$1);
|
|
2359
|
+
};
|
|
2345
2360
|
const preserveCase = () => {
|
|
2346
2361
|
return i18nString(PreserveCase$1);
|
|
2347
2362
|
};
|
|
@@ -2549,7 +2564,7 @@ const removeItemFromItems = (items, index, matchCount, fileCount) => {
|
|
|
2549
2564
|
newFileCount,
|
|
2550
2565
|
newMatchCount
|
|
2551
2566
|
} = getRemoveIndices(items, index, matchCount, fileCount);
|
|
2552
|
-
const newItems = remove(items, startIndex, removeCount);
|
|
2567
|
+
const newItems = remove$1(items, startIndex, removeCount);
|
|
2553
2568
|
return {
|
|
2554
2569
|
newItems,
|
|
2555
2570
|
newFocusedIndex,
|
|
@@ -2827,6 +2842,10 @@ const getSearchResultKeyBindings = () => {
|
|
|
2827
2842
|
key: CtrlCmd | KeyC,
|
|
2828
2843
|
command: 'Search.copy',
|
|
2829
2844
|
when: FocusSearchResults
|
|
2845
|
+
}, {
|
|
2846
|
+
key: Delete,
|
|
2847
|
+
command: 'Search.removeCurrent',
|
|
2848
|
+
when: FocusSearchResults
|
|
2830
2849
|
}];
|
|
2831
2850
|
};
|
|
2832
2851
|
|
|
@@ -2891,11 +2910,7 @@ const handleUpdateError = async (state, update, error) => {
|
|
|
2891
2910
|
};
|
|
2892
2911
|
};
|
|
2893
2912
|
|
|
2894
|
-
const
|
|
2895
|
-
return dirents.map(dirent => fileIconCache[dirent]);
|
|
2896
|
-
};
|
|
2897
|
-
|
|
2898
|
-
const getFileName$1 = text => {
|
|
2913
|
+
const getFilePath = text => {
|
|
2899
2914
|
// TODO make api stricter so that results always have the same shape
|
|
2900
2915
|
if (text.startsWith('./')) {
|
|
2901
2916
|
return text.slice(2);
|
|
@@ -2903,27 +2918,46 @@ const getFileName$1 = text => {
|
|
|
2903
2918
|
return text;
|
|
2904
2919
|
};
|
|
2905
2920
|
|
|
2906
|
-
const
|
|
2907
|
-
|
|
2908
|
-
|
|
2921
|
+
const getIconsCached = (dirents, fileIconCache) => {
|
|
2922
|
+
return dirents.map(dirent => {
|
|
2923
|
+
if (dirent.type === Match$1) {
|
|
2924
|
+
return '';
|
|
2925
|
+
}
|
|
2926
|
+
const path = getFilePath(dirent.text);
|
|
2927
|
+
return fileIconCache[path];
|
|
2928
|
+
});
|
|
2929
|
+
};
|
|
2930
|
+
|
|
2931
|
+
const getFileName = path => {
|
|
2932
|
+
const slashIndex = path.lastIndexOf('/');
|
|
2933
|
+
if (slashIndex === -1) {
|
|
2934
|
+
return '';
|
|
2909
2935
|
}
|
|
2910
|
-
return
|
|
2936
|
+
return path.slice(slashIndex + 1);
|
|
2911
2937
|
};
|
|
2912
|
-
|
|
2938
|
+
|
|
2939
|
+
const isFile = match => {
|
|
2940
|
+
return match.type === File;
|
|
2941
|
+
};
|
|
2942
|
+
|
|
2943
|
+
const getMissingDirents = (searchResults, fileIconCache) => {
|
|
2913
2944
|
const missingDirents = [];
|
|
2914
|
-
|
|
2915
|
-
|
|
2945
|
+
const files = searchResults.filter(isFile);
|
|
2946
|
+
for (const file of files) {
|
|
2947
|
+
const uri = getFilePath(file.text);
|
|
2916
2948
|
if (!(uri in fileIconCache)) {
|
|
2917
|
-
missingDirents.push(
|
|
2949
|
+
missingDirents.push(file);
|
|
2918
2950
|
}
|
|
2919
2951
|
}
|
|
2920
2952
|
return missingDirents;
|
|
2921
2953
|
};
|
|
2922
2954
|
const toIconRequest = item => {
|
|
2955
|
+
const filePath = getFilePath(item.text);
|
|
2956
|
+
const fileName = getFileName(filePath);
|
|
2923
2957
|
return {
|
|
2924
2958
|
type: File$1,
|
|
2925
|
-
name:
|
|
2926
|
-
path:
|
|
2959
|
+
name: fileName,
|
|
2960
|
+
path: filePath
|
|
2927
2961
|
};
|
|
2928
2962
|
};
|
|
2929
2963
|
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
@@ -2977,8 +3011,7 @@ const getFileIcons = async (items, fileIconCache) => {
|
|
|
2977
3011
|
const missingRequests = getMissingIconRequests(items, fileIconCache);
|
|
2978
3012
|
const newIcons = await requestFileIcons(missingRequests);
|
|
2979
3013
|
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
2980
|
-
const
|
|
2981
|
-
const icons = getIconsCached(paths, newFileIconCache);
|
|
3014
|
+
const icons = getIconsCached(items, newFileIconCache);
|
|
2982
3015
|
return {
|
|
2983
3016
|
icons,
|
|
2984
3017
|
newFileIconCache
|
|
@@ -3354,6 +3387,7 @@ const ToggleReplace = 'ToggleReplace';
|
|
|
3354
3387
|
const ToggleSearchDetails = 'ToggleSearchDetails';
|
|
3355
3388
|
const UseExcludeSettings = 'UseExcludeSettings';
|
|
3356
3389
|
const UseRegularExpression = 'UseRegularExpression';
|
|
3390
|
+
const Remove = 'Remove';
|
|
3357
3391
|
|
|
3358
3392
|
const noop = state => {
|
|
3359
3393
|
return state;
|
|
@@ -3391,7 +3425,7 @@ const getReplaceElements = (items, workspacePath, replacement) => {
|
|
|
3391
3425
|
} = match;
|
|
3392
3426
|
if (type === File) {
|
|
3393
3427
|
changes = [];
|
|
3394
|
-
const fileName =
|
|
3428
|
+
const fileName = getFilePath(text);
|
|
3395
3429
|
const absolutePath = `${workspacePath}/${fileName}`;
|
|
3396
3430
|
element = {
|
|
3397
3431
|
uri: absolutePath,
|
|
@@ -4071,7 +4105,7 @@ const toggleCollapsedPath = (collapsedPaths, path) => {
|
|
|
4071
4105
|
return [...collapsedPaths, path];
|
|
4072
4106
|
};
|
|
4073
4107
|
|
|
4074
|
-
const selectIndexFile = async (state, searchResult, index) => {
|
|
4108
|
+
const selectIndexFile = async (state, searchResult, index, isRemove) => {
|
|
4075
4109
|
const {
|
|
4076
4110
|
collapsedPaths,
|
|
4077
4111
|
items,
|
|
@@ -4130,7 +4164,7 @@ const getRelativePath = relativePath => {
|
|
|
4130
4164
|
return `/${relativePath}`; // TODO support windows paths
|
|
4131
4165
|
};
|
|
4132
4166
|
|
|
4133
|
-
const selectIndexPreview = async (state, searchResult, index) => {
|
|
4167
|
+
const selectIndexPreview = async (state, searchResult, index, isRemove) => {
|
|
4134
4168
|
const {
|
|
4135
4169
|
items,
|
|
4136
4170
|
workspacePath
|
|
@@ -4168,7 +4202,7 @@ const getSelectHandler = type => {
|
|
|
4168
4202
|
}
|
|
4169
4203
|
};
|
|
4170
4204
|
|
|
4171
|
-
const selectIndex = async (state, index) => {
|
|
4205
|
+
const selectIndex = async (state, index, isRemoveButton = false) => {
|
|
4172
4206
|
if (index === -1) {
|
|
4173
4207
|
return {
|
|
4174
4208
|
...state,
|
|
@@ -4181,10 +4215,10 @@ const selectIndex = async (state, index) => {
|
|
|
4181
4215
|
} = state;
|
|
4182
4216
|
const searchResult = listItems[index];
|
|
4183
4217
|
const fn = getSelectHandler(searchResult.type);
|
|
4184
|
-
return fn(state, searchResult, index);
|
|
4218
|
+
return fn(state, searchResult, index, isRemoveButton);
|
|
4185
4219
|
};
|
|
4186
4220
|
|
|
4187
|
-
const handleClickAt = async (state, eventX, eventY) => {
|
|
4221
|
+
const handleClickAt = async (state, eventX, eventY, name) => {
|
|
4188
4222
|
const {
|
|
4189
4223
|
x,
|
|
4190
4224
|
y,
|
|
@@ -4195,7 +4229,8 @@ const handleClickAt = async (state, eventX, eventY) => {
|
|
|
4195
4229
|
} = state;
|
|
4196
4230
|
const topHeight = getTopHeight(flags);
|
|
4197
4231
|
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
|
|
4198
|
-
|
|
4232
|
+
const isRemoveButton = name === Remove;
|
|
4233
|
+
return selectIndex(state, index, isRemoveButton);
|
|
4199
4234
|
};
|
|
4200
4235
|
|
|
4201
4236
|
const handleListPointerDown = async (state, button) => {
|
|
@@ -4364,6 +4399,24 @@ const refresh = state => {
|
|
|
4364
4399
|
return handleUpdate(state, {});
|
|
4365
4400
|
};
|
|
4366
4401
|
|
|
4402
|
+
const removeCurrent = async state => {
|
|
4403
|
+
// TODO
|
|
4404
|
+
// 1. get focused index
|
|
4405
|
+
// 2. if it is -1, do nothing
|
|
4406
|
+
// 3. get search result at focused index
|
|
4407
|
+
// 4. call removeIndex with state, searchResult, index
|
|
4408
|
+
return {
|
|
4409
|
+
...state
|
|
4410
|
+
};
|
|
4411
|
+
};
|
|
4412
|
+
|
|
4413
|
+
const removeIndex = async (state, searchResult, index) => {
|
|
4414
|
+
// TODO
|
|
4415
|
+
return {
|
|
4416
|
+
...state
|
|
4417
|
+
};
|
|
4418
|
+
};
|
|
4419
|
+
|
|
4367
4420
|
const getFocusSelector = focusKey => {
|
|
4368
4421
|
switch (focusKey) {
|
|
4369
4422
|
case FocusSearchInput:
|
|
@@ -5071,17 +5124,20 @@ const getChildCount = (icon, expanded, badgeText) => {
|
|
|
5071
5124
|
return childCount;
|
|
5072
5125
|
};
|
|
5073
5126
|
|
|
5127
|
+
const closeIcon = {
|
|
5128
|
+
type: Div,
|
|
5129
|
+
className: CloseMaskIcon,
|
|
5130
|
+
childCount: 0
|
|
5131
|
+
};
|
|
5074
5132
|
const getSearchRemoveVirtualDom = () => {
|
|
5075
|
-
|
|
5133
|
+
const title = remove();
|
|
5076
5134
|
const dom = [{
|
|
5077
|
-
type:
|
|
5135
|
+
type: Button$2,
|
|
5078
5136
|
className: SearchRemove,
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
childCount: 0
|
|
5084
|
-
}];
|
|
5137
|
+
name: Remove,
|
|
5138
|
+
childCount: 1,
|
|
5139
|
+
title
|
|
5140
|
+
}, closeIcon];
|
|
5085
5141
|
return dom;
|
|
5086
5142
|
};
|
|
5087
5143
|
|
|
@@ -5328,7 +5384,7 @@ const renderEventListeners = () => {
|
|
|
5328
5384
|
params: ['handleReplaceInput', TargetValue]
|
|
5329
5385
|
}, {
|
|
5330
5386
|
name: HandleClick,
|
|
5331
|
-
params: ['handleClickAt', ClientX, ClientY]
|
|
5387
|
+
params: ['handleClickAt', ClientX, ClientY, TargetName]
|
|
5332
5388
|
}, {
|
|
5333
5389
|
name: HandleListPointerDown,
|
|
5334
5390
|
params: ['handleListPointerDown', Button$1]
|
|
@@ -5599,6 +5655,7 @@ const commandMap = {
|
|
|
5599
5655
|
'TextSearch.clearSearchResults': wrapCommand(clearSearchResults$1),
|
|
5600
5656
|
'TextSearch.collapseAll': wrapCommand(collapseAll$1),
|
|
5601
5657
|
'TextSearch.collapseDetails': wrapCommand(collapseDetails),
|
|
5658
|
+
'TextSearch.removeCurrent': wrapCommand(removeCurrent),
|
|
5602
5659
|
'TextSearch.copy': wrapCommand(copy),
|
|
5603
5660
|
'TextSearch.copyPath': wrapCommand(copyPath$1),
|
|
5604
5661
|
'TextSearch.diff2': diff2,
|
|
@@ -5653,6 +5710,7 @@ const commandMap = {
|
|
|
5653
5710
|
'TextSearch.nextHistoryResult': wrapCommand(nextHistoryResult),
|
|
5654
5711
|
'TextSearch.previousHistoryResult': wrapCommand(previousHistoryResult),
|
|
5655
5712
|
'TextSearch.refresh': wrapCommand(refresh),
|
|
5713
|
+
'TextSearch.removeIndex': wrapCommand(removeIndex),
|
|
5656
5714
|
'TextSearch.replaceAll': wrapCommand(replaceAll),
|
|
5657
5715
|
'TextSearch.rerender': rerender,
|
|
5658
5716
|
'TextSearch.selectIndex': wrapCommand(selectIndex),
|