@lvce-editor/text-search-worker 5.19.0 → 5.21.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 +108 -50
- 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;
|
|
@@ -2228,7 +2239,7 @@ const isEqual$5 = (oldState, newState) => {
|
|
|
2228
2239
|
};
|
|
2229
2240
|
|
|
2230
2241
|
const isEqual$4 = (oldState, newState) => {
|
|
2231
|
-
return oldState.focus === newState.focus;
|
|
2242
|
+
return oldState.focus === newState.focus && oldState.focused === newState.focused;
|
|
2232
2243
|
};
|
|
2233
2244
|
|
|
2234
2245
|
const diffType$3 = RenderIncludeValue;
|
|
@@ -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
|
|
|
@@ -2834,23 +2853,24 @@ const getKeyBindings = () => {
|
|
|
2834
2853
|
return [...getSearchHeaderKeyBindings(), ...getSearchResultKeyBindings()];
|
|
2835
2854
|
};
|
|
2836
2855
|
|
|
2837
|
-
const getMenuEntryIds = () => {
|
|
2838
|
-
return [Search$1];
|
|
2839
|
-
};
|
|
2840
2856
|
const getMenuEntries = () => {
|
|
2841
2857
|
return [{
|
|
2842
2858
|
id: 'dismiss',
|
|
2843
2859
|
label: dismiss(),
|
|
2844
2860
|
flags: None$1,
|
|
2845
|
-
command:
|
|
2861
|
+
command: 'Search.removeCurrent'
|
|
2846
2862
|
}, {
|
|
2847
2863
|
id: 'copyPath',
|
|
2848
2864
|
label: copyPath(),
|
|
2849
2865
|
flags: None$1,
|
|
2850
|
-
command:
|
|
2866
|
+
command: 'Search.copyPath'
|
|
2851
2867
|
}];
|
|
2852
2868
|
};
|
|
2853
2869
|
|
|
2870
|
+
const getMenuEntryIds = () => {
|
|
2871
|
+
return [Search$1];
|
|
2872
|
+
};
|
|
2873
|
+
|
|
2854
2874
|
const handleError = error => {
|
|
2855
2875
|
console.error(`[text-search-worker] ${error}`);
|
|
2856
2876
|
};
|
|
@@ -2891,11 +2911,7 @@ const handleUpdateError = async (state, update, error) => {
|
|
|
2891
2911
|
};
|
|
2892
2912
|
};
|
|
2893
2913
|
|
|
2894
|
-
const
|
|
2895
|
-
return dirents.map(dirent => fileIconCache[dirent]);
|
|
2896
|
-
};
|
|
2897
|
-
|
|
2898
|
-
const getFileName$1 = text => {
|
|
2914
|
+
const getFilePath = text => {
|
|
2899
2915
|
// TODO make api stricter so that results always have the same shape
|
|
2900
2916
|
if (text.startsWith('./')) {
|
|
2901
2917
|
return text.slice(2);
|
|
@@ -2903,27 +2919,46 @@ const getFileName$1 = text => {
|
|
|
2903
2919
|
return text;
|
|
2904
2920
|
};
|
|
2905
2921
|
|
|
2906
|
-
const
|
|
2907
|
-
|
|
2908
|
-
|
|
2922
|
+
const getIconsCached = (dirents, fileIconCache) => {
|
|
2923
|
+
return dirents.map(dirent => {
|
|
2924
|
+
if (dirent.type === Match$1) {
|
|
2925
|
+
return '';
|
|
2926
|
+
}
|
|
2927
|
+
const path = getFilePath(dirent.text);
|
|
2928
|
+
return fileIconCache[path];
|
|
2929
|
+
});
|
|
2930
|
+
};
|
|
2931
|
+
|
|
2932
|
+
const getFileName = path => {
|
|
2933
|
+
const slashIndex = path.lastIndexOf('/');
|
|
2934
|
+
if (slashIndex === -1) {
|
|
2935
|
+
return path;
|
|
2909
2936
|
}
|
|
2910
|
-
return
|
|
2937
|
+
return path.slice(slashIndex + 1);
|
|
2911
2938
|
};
|
|
2912
|
-
|
|
2939
|
+
|
|
2940
|
+
const isFile = match => {
|
|
2941
|
+
return match.type === File;
|
|
2942
|
+
};
|
|
2943
|
+
|
|
2944
|
+
const getMissingDirents = (searchResults, fileIconCache) => {
|
|
2913
2945
|
const missingDirents = [];
|
|
2914
|
-
|
|
2915
|
-
|
|
2946
|
+
const files = searchResults.filter(isFile);
|
|
2947
|
+
for (const file of files) {
|
|
2948
|
+
const uri = getFilePath(file.text);
|
|
2916
2949
|
if (!(uri in fileIconCache)) {
|
|
2917
|
-
missingDirents.push(
|
|
2950
|
+
missingDirents.push(file);
|
|
2918
2951
|
}
|
|
2919
2952
|
}
|
|
2920
2953
|
return missingDirents;
|
|
2921
2954
|
};
|
|
2922
2955
|
const toIconRequest = item => {
|
|
2956
|
+
const filePath = getFilePath(item.text);
|
|
2957
|
+
const fileName = getFileName(filePath);
|
|
2923
2958
|
return {
|
|
2924
2959
|
type: File$1,
|
|
2925
|
-
name:
|
|
2926
|
-
path:
|
|
2960
|
+
name: fileName,
|
|
2961
|
+
path: filePath
|
|
2927
2962
|
};
|
|
2928
2963
|
};
|
|
2929
2964
|
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
@@ -2977,8 +3012,7 @@ const getFileIcons = async (items, fileIconCache) => {
|
|
|
2977
3012
|
const missingRequests = getMissingIconRequests(items, fileIconCache);
|
|
2978
3013
|
const newIcons = await requestFileIcons(missingRequests);
|
|
2979
3014
|
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
2980
|
-
const
|
|
2981
|
-
const icons = getIconsCached(paths, newFileIconCache);
|
|
3015
|
+
const icons = getIconsCached(items, newFileIconCache);
|
|
2982
3016
|
return {
|
|
2983
3017
|
icons,
|
|
2984
3018
|
newFileIconCache
|
|
@@ -3354,6 +3388,7 @@ const ToggleReplace = 'ToggleReplace';
|
|
|
3354
3388
|
const ToggleSearchDetails = 'ToggleSearchDetails';
|
|
3355
3389
|
const UseExcludeSettings = 'UseExcludeSettings';
|
|
3356
3390
|
const UseRegularExpression = 'UseRegularExpression';
|
|
3391
|
+
const Remove = 'Remove';
|
|
3357
3392
|
|
|
3358
3393
|
const noop = state => {
|
|
3359
3394
|
return state;
|
|
@@ -3391,7 +3426,7 @@ const getReplaceElements = (items, workspacePath, replacement) => {
|
|
|
3391
3426
|
} = match;
|
|
3392
3427
|
if (type === File) {
|
|
3393
3428
|
changes = [];
|
|
3394
|
-
const fileName =
|
|
3429
|
+
const fileName = getFilePath(text);
|
|
3395
3430
|
const absolutePath = `${workspacePath}/${fileName}`;
|
|
3396
3431
|
element = {
|
|
3397
3432
|
uri: absolutePath,
|
|
@@ -4071,7 +4106,7 @@ const toggleCollapsedPath = (collapsedPaths, path) => {
|
|
|
4071
4106
|
return [...collapsedPaths, path];
|
|
4072
4107
|
};
|
|
4073
4108
|
|
|
4074
|
-
const selectIndexFile = async (state, searchResult, index) => {
|
|
4109
|
+
const selectIndexFile = async (state, searchResult, index, isRemove) => {
|
|
4075
4110
|
const {
|
|
4076
4111
|
collapsedPaths,
|
|
4077
4112
|
items,
|
|
@@ -4130,7 +4165,7 @@ const getRelativePath = relativePath => {
|
|
|
4130
4165
|
return `/${relativePath}`; // TODO support windows paths
|
|
4131
4166
|
};
|
|
4132
4167
|
|
|
4133
|
-
const selectIndexPreview = async (state, searchResult, index) => {
|
|
4168
|
+
const selectIndexPreview = async (state, searchResult, index, isRemove) => {
|
|
4134
4169
|
const {
|
|
4135
4170
|
items,
|
|
4136
4171
|
workspacePath
|
|
@@ -4168,7 +4203,7 @@ const getSelectHandler = type => {
|
|
|
4168
4203
|
}
|
|
4169
4204
|
};
|
|
4170
4205
|
|
|
4171
|
-
const selectIndex = async (state, index) => {
|
|
4206
|
+
const selectIndex = async (state, index, isRemoveButton = false) => {
|
|
4172
4207
|
if (index === -1) {
|
|
4173
4208
|
return {
|
|
4174
4209
|
...state,
|
|
@@ -4181,10 +4216,10 @@ const selectIndex = async (state, index) => {
|
|
|
4181
4216
|
} = state;
|
|
4182
4217
|
const searchResult = listItems[index];
|
|
4183
4218
|
const fn = getSelectHandler(searchResult.type);
|
|
4184
|
-
return fn(state, searchResult, index);
|
|
4219
|
+
return fn(state, searchResult, index, isRemoveButton);
|
|
4185
4220
|
};
|
|
4186
4221
|
|
|
4187
|
-
const handleClickAt = async (state, eventX, eventY) => {
|
|
4222
|
+
const handleClickAt = async (state, eventX, eventY, name) => {
|
|
4188
4223
|
const {
|
|
4189
4224
|
x,
|
|
4190
4225
|
y,
|
|
@@ -4195,7 +4230,8 @@ const handleClickAt = async (state, eventX, eventY) => {
|
|
|
4195
4230
|
} = state;
|
|
4196
4231
|
const topHeight = getTopHeight(flags);
|
|
4197
4232
|
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
|
|
4198
|
-
|
|
4233
|
+
const isRemoveButton = name === Remove;
|
|
4234
|
+
return selectIndex(state, index, isRemoveButton);
|
|
4199
4235
|
};
|
|
4200
4236
|
|
|
4201
4237
|
const handleListPointerDown = async (state, button) => {
|
|
@@ -4364,6 +4400,24 @@ const refresh = state => {
|
|
|
4364
4400
|
return handleUpdate(state, {});
|
|
4365
4401
|
};
|
|
4366
4402
|
|
|
4403
|
+
const removeCurrent = async state => {
|
|
4404
|
+
// TODO
|
|
4405
|
+
// 1. get focused index
|
|
4406
|
+
// 2. if it is -1, do nothing
|
|
4407
|
+
// 3. get search result at focused index
|
|
4408
|
+
// 4. call removeIndex with state, searchResult, index
|
|
4409
|
+
return {
|
|
4410
|
+
...state
|
|
4411
|
+
};
|
|
4412
|
+
};
|
|
4413
|
+
|
|
4414
|
+
const removeIndex = async (state, searchResult, index) => {
|
|
4415
|
+
// TODO
|
|
4416
|
+
return {
|
|
4417
|
+
...state
|
|
4418
|
+
};
|
|
4419
|
+
};
|
|
4420
|
+
|
|
4367
4421
|
const getFocusSelector = focusKey => {
|
|
4368
4422
|
switch (focusKey) {
|
|
4369
4423
|
case FocusSearchInput:
|
|
@@ -5071,17 +5125,20 @@ const getChildCount = (icon, expanded, badgeText) => {
|
|
|
5071
5125
|
return childCount;
|
|
5072
5126
|
};
|
|
5073
5127
|
|
|
5128
|
+
const closeIcon = {
|
|
5129
|
+
type: Div,
|
|
5130
|
+
className: CloseMaskIcon,
|
|
5131
|
+
childCount: 0
|
|
5132
|
+
};
|
|
5074
5133
|
const getSearchRemoveVirtualDom = () => {
|
|
5075
|
-
|
|
5134
|
+
const title = remove();
|
|
5076
5135
|
const dom = [{
|
|
5077
|
-
type:
|
|
5136
|
+
type: Button$2,
|
|
5078
5137
|
className: SearchRemove,
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
childCount: 0
|
|
5084
|
-
}];
|
|
5138
|
+
name: Remove,
|
|
5139
|
+
childCount: 1,
|
|
5140
|
+
title
|
|
5141
|
+
}, closeIcon];
|
|
5085
5142
|
return dom;
|
|
5086
5143
|
};
|
|
5087
5144
|
|
|
@@ -5328,7 +5385,7 @@ const renderEventListeners = () => {
|
|
|
5328
5385
|
params: ['handleReplaceInput', TargetValue]
|
|
5329
5386
|
}, {
|
|
5330
5387
|
name: HandleClick,
|
|
5331
|
-
params: ['handleClickAt', ClientX, ClientY]
|
|
5388
|
+
params: ['handleClickAt', ClientX, ClientY, TargetName]
|
|
5332
5389
|
}, {
|
|
5333
5390
|
name: HandleListPointerDown,
|
|
5334
5391
|
params: ['handleListPointerDown', Button$1]
|
|
@@ -5558,7 +5615,6 @@ const viewAsTree = async state => {
|
|
|
5558
5615
|
const Keyboard = -1;
|
|
5559
5616
|
|
|
5560
5617
|
const show = async (x, y, id, ...args) => {
|
|
5561
|
-
// TODO ask renderer worker to show context menu
|
|
5562
5618
|
number(x);
|
|
5563
5619
|
number(y);
|
|
5564
5620
|
number(id);
|
|
@@ -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),
|