@lvce-editor/text-search-worker 3.15.0 → 3.16.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 +159 -34
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
const Two = '2.0';
|
|
2
|
-
const create$4 = (method, params) => {
|
|
2
|
+
const create$4$1 = (method, params) => {
|
|
3
3
|
return {
|
|
4
4
|
jsonrpc: Two,
|
|
5
5
|
method,
|
|
6
6
|
params
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
|
-
const state$
|
|
9
|
+
const state$4 = {
|
|
10
10
|
callbacks: Object.create(null)
|
|
11
11
|
};
|
|
12
12
|
const set$1 = (id, fn) => {
|
|
13
|
-
state$
|
|
13
|
+
state$4.callbacks[id] = fn;
|
|
14
14
|
};
|
|
15
15
|
const get$1 = id => {
|
|
16
|
-
return state$
|
|
16
|
+
return state$4.callbacks[id];
|
|
17
17
|
};
|
|
18
18
|
const remove$1 = id => {
|
|
19
|
-
delete state$
|
|
19
|
+
delete state$4.callbacks[id];
|
|
20
20
|
};
|
|
21
21
|
let id = 0;
|
|
22
22
|
const create$3$1 = () => {
|
|
@@ -47,7 +47,7 @@ const resolve = (id, response) => {
|
|
|
47
47
|
fn(response);
|
|
48
48
|
remove$1(id);
|
|
49
49
|
};
|
|
50
|
-
const create$2$
|
|
50
|
+
const create$2$2 = (method, params) => {
|
|
51
51
|
const {
|
|
52
52
|
id,
|
|
53
53
|
promise
|
|
@@ -326,7 +326,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
326
326
|
const {
|
|
327
327
|
message,
|
|
328
328
|
promise
|
|
329
|
-
} = create$2$
|
|
329
|
+
} = create$2$2(method, params);
|
|
330
330
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
331
331
|
ipc.sendAndTransfer(message);
|
|
332
332
|
} else {
|
|
@@ -336,13 +336,13 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
336
336
|
return unwrapJsonRpcResult(responseMessage);
|
|
337
337
|
};
|
|
338
338
|
const send = (transport, method, ...params) => {
|
|
339
|
-
const message = create$4(method, params);
|
|
339
|
+
const message = create$4$1(method, params);
|
|
340
340
|
transport.send(message);
|
|
341
341
|
};
|
|
342
|
-
const invoke$
|
|
342
|
+
const invoke$3 = (ipc, method, ...params) => {
|
|
343
343
|
return invokeHelper(ipc, method, params, false);
|
|
344
344
|
};
|
|
345
|
-
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
345
|
+
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
346
346
|
return invokeHelper(ipc, method, params, true);
|
|
347
347
|
};
|
|
348
348
|
|
|
@@ -743,6 +743,7 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
743
743
|
listen: listen$1$1,
|
|
744
744
|
wrap: wrap$4
|
|
745
745
|
};
|
|
746
|
+
const Message$1 = 3;
|
|
746
747
|
const addListener = (emitter, type, callback) => {
|
|
747
748
|
if ('addEventListener' in emitter) {
|
|
748
749
|
emitter.addEventListener(type, callback);
|
|
@@ -781,6 +782,58 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
781
782
|
}
|
|
782
783
|
return promise;
|
|
783
784
|
};
|
|
785
|
+
const create$2$1 = async ({
|
|
786
|
+
messagePort,
|
|
787
|
+
isMessagePortOpen
|
|
788
|
+
}) => {
|
|
789
|
+
if (!isMessagePort(messagePort)) {
|
|
790
|
+
throw new IpcError('port must be of type MessagePort');
|
|
791
|
+
}
|
|
792
|
+
if (isMessagePortOpen) {
|
|
793
|
+
return messagePort;
|
|
794
|
+
}
|
|
795
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
796
|
+
message: Message$1
|
|
797
|
+
});
|
|
798
|
+
messagePort.start();
|
|
799
|
+
const event = await eventPromise;
|
|
800
|
+
// @ts-ignore
|
|
801
|
+
if (event.data !== readyMessage) {
|
|
802
|
+
throw new IpcError('unexpected first message');
|
|
803
|
+
}
|
|
804
|
+
return messagePort;
|
|
805
|
+
};
|
|
806
|
+
const signal = messagePort => {
|
|
807
|
+
messagePort.start();
|
|
808
|
+
};
|
|
809
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
810
|
+
constructor(port) {
|
|
811
|
+
super(port);
|
|
812
|
+
}
|
|
813
|
+
getData = getData$1;
|
|
814
|
+
send(message) {
|
|
815
|
+
this._rawIpc.postMessage(message);
|
|
816
|
+
}
|
|
817
|
+
sendAndTransfer(message) {
|
|
818
|
+
throw new Error('not implemented');
|
|
819
|
+
}
|
|
820
|
+
dispose() {
|
|
821
|
+
this._rawIpc.close();
|
|
822
|
+
}
|
|
823
|
+
onMessage(callback) {
|
|
824
|
+
this._rawIpc.addEventListener('message', callback);
|
|
825
|
+
}
|
|
826
|
+
onClose(callback) {}
|
|
827
|
+
}
|
|
828
|
+
const wrap$2 = messagePort => {
|
|
829
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
830
|
+
};
|
|
831
|
+
const IpcParentWithMessagePort$1 = {
|
|
832
|
+
__proto__: null,
|
|
833
|
+
create: create$2$1,
|
|
834
|
+
signal,
|
|
835
|
+
wrap: wrap$2
|
|
836
|
+
};
|
|
784
837
|
const Open = 1;
|
|
785
838
|
const Close = 2;
|
|
786
839
|
const stringifyCompact = value => {
|
|
@@ -802,7 +855,7 @@ const waitForWebSocketToBeOpen = webSocket => {
|
|
|
802
855
|
close: Close
|
|
803
856
|
});
|
|
804
857
|
};
|
|
805
|
-
const create$
|
|
858
|
+
const create$4 = async ({
|
|
806
859
|
webSocket
|
|
807
860
|
}) => {
|
|
808
861
|
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
@@ -837,7 +890,7 @@ const wrap$1 = webSocket => {
|
|
|
837
890
|
};
|
|
838
891
|
const IpcParentWithWebSocket$1 = {
|
|
839
892
|
__proto__: null,
|
|
840
|
-
create: create$
|
|
893
|
+
create: create$4,
|
|
841
894
|
wrap: wrap$1
|
|
842
895
|
};
|
|
843
896
|
|
|
@@ -850,10 +903,10 @@ const createRpc = ipc => {
|
|
|
850
903
|
send(ipc, method, ...params);
|
|
851
904
|
},
|
|
852
905
|
invoke(method, ...params) {
|
|
853
|
-
return invoke$
|
|
906
|
+
return invoke$3(ipc, method, ...params);
|
|
854
907
|
},
|
|
855
908
|
invokeAndTransfer(method, ...params) {
|
|
856
|
-
return invokeAndTransfer(ipc, method, ...params);
|
|
909
|
+
return invokeAndTransfer$1(ipc, method, ...params);
|
|
857
910
|
}
|
|
858
911
|
};
|
|
859
912
|
return rpc;
|
|
@@ -873,6 +926,26 @@ const handleMessage = event => {
|
|
|
873
926
|
const handleIpc = ipc => {
|
|
874
927
|
ipc.addEventListener('message', handleMessage);
|
|
875
928
|
};
|
|
929
|
+
const create$2 = async ({
|
|
930
|
+
commandMap,
|
|
931
|
+
messagePort,
|
|
932
|
+
isMessagePortOpen
|
|
933
|
+
}) => {
|
|
934
|
+
// TODO create a commandMap per rpc instance
|
|
935
|
+
register(commandMap);
|
|
936
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
937
|
+
messagePort,
|
|
938
|
+
isMessagePortOpen
|
|
939
|
+
});
|
|
940
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
941
|
+
handleIpc(ipc);
|
|
942
|
+
const rpc = createRpc(ipc);
|
|
943
|
+
return rpc;
|
|
944
|
+
};
|
|
945
|
+
const MessagePortRpcParent = {
|
|
946
|
+
__proto__: null,
|
|
947
|
+
create: create$2
|
|
948
|
+
};
|
|
876
949
|
const create$1$1 = async ({
|
|
877
950
|
commandMap,
|
|
878
951
|
webSocket
|
|
@@ -899,7 +972,7 @@ const listen$1 = async () => {
|
|
|
899
972
|
const ipc = module.wrap(rawIpc);
|
|
900
973
|
return ipc;
|
|
901
974
|
};
|
|
902
|
-
const create$
|
|
975
|
+
const create$3 = async ({
|
|
903
976
|
commandMap
|
|
904
977
|
}) => {
|
|
905
978
|
// TODO create a commandMap per rpc instance
|
|
@@ -911,7 +984,7 @@ const create$2 = async ({
|
|
|
911
984
|
};
|
|
912
985
|
const WebWorkerRpcClient = {
|
|
913
986
|
__proto__: null,
|
|
914
|
-
create: create$
|
|
987
|
+
create: create$3
|
|
915
988
|
};
|
|
916
989
|
|
|
917
990
|
const Empty$1 = 0;
|
|
@@ -947,16 +1020,21 @@ const clearSearchResults$1 = state => {
|
|
|
947
1020
|
};
|
|
948
1021
|
};
|
|
949
1022
|
|
|
950
|
-
const state$
|
|
1023
|
+
const state$3 = {
|
|
951
1024
|
rpc: undefined
|
|
952
1025
|
};
|
|
953
|
-
const invoke$
|
|
954
|
-
const rpc = state$
|
|
1026
|
+
const invoke$2 = (method, ...params) => {
|
|
1027
|
+
const rpc = state$3.rpc;
|
|
955
1028
|
// @ts-ignore
|
|
956
1029
|
return rpc.invoke(method, ...params);
|
|
957
1030
|
};
|
|
1031
|
+
const invokeAndTransfer = (method, ...params) => {
|
|
1032
|
+
const rpc = state$3.rpc;
|
|
1033
|
+
// @ts-ignore
|
|
1034
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1035
|
+
};
|
|
958
1036
|
const setRpc = rpc => {
|
|
959
|
-
state$
|
|
1037
|
+
state$3.rpc = rpc;
|
|
960
1038
|
};
|
|
961
1039
|
|
|
962
1040
|
const copy = async state => {
|
|
@@ -968,7 +1046,7 @@ const copy = async state => {
|
|
|
968
1046
|
return state;
|
|
969
1047
|
}
|
|
970
1048
|
const item = items[listFocusedIndex];
|
|
971
|
-
await invoke$
|
|
1049
|
+
await invoke$2('ClipBoard.writeText', item.text);
|
|
972
1050
|
return state;
|
|
973
1051
|
};
|
|
974
1052
|
|
|
@@ -2249,7 +2327,7 @@ const getFileIcons = async files => {
|
|
|
2249
2327
|
if (file.type === Match) {
|
|
2250
2328
|
continue;
|
|
2251
2329
|
}
|
|
2252
|
-
promises.push(invoke$
|
|
2330
|
+
promises.push(invoke$2('IconTheme.getFileIcon', {
|
|
2253
2331
|
name: file.text
|
|
2254
2332
|
}));
|
|
2255
2333
|
}
|
|
@@ -2388,7 +2466,7 @@ const getProtocol$1 = uri => {
|
|
|
2388
2466
|
const textSearch$5 = async (scheme, root, query) => {
|
|
2389
2467
|
string(scheme);
|
|
2390
2468
|
string(query);
|
|
2391
|
-
const result = await invoke$
|
|
2469
|
+
const result = await invoke$2('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query);
|
|
2392
2470
|
return result;
|
|
2393
2471
|
};
|
|
2394
2472
|
|
|
@@ -2812,7 +2890,7 @@ replaceTraps(oldTraps => ({
|
|
|
2812
2890
|
}
|
|
2813
2891
|
}));
|
|
2814
2892
|
|
|
2815
|
-
const state$
|
|
2893
|
+
const state$2 = {
|
|
2816
2894
|
databases: Object.create(null),
|
|
2817
2895
|
eventId: 0,
|
|
2818
2896
|
dbVersion: 1,
|
|
@@ -2823,7 +2901,7 @@ const state$1 = {
|
|
|
2823
2901
|
|
|
2824
2902
|
const getHandleDb = async () => {
|
|
2825
2903
|
// @ts-ignore
|
|
2826
|
-
const db = await openDB('handle', state$
|
|
2904
|
+
const db = await openDB('handle', state$2.dbVersion, {
|
|
2827
2905
|
async upgrade(db) {
|
|
2828
2906
|
if (!db.objectStoreNames.contains('file-handles-store')) {
|
|
2829
2907
|
await db.createObjectStore('file-handles-store', {});
|
|
@@ -2941,6 +3019,7 @@ const getRipGrepArgs = ({
|
|
|
2941
3019
|
return ripGrepArgs;
|
|
2942
3020
|
};
|
|
2943
3021
|
|
|
3022
|
+
const Electron = 2;
|
|
2944
3023
|
const Remote = 3;
|
|
2945
3024
|
|
|
2946
3025
|
const Https = 'https:';
|
|
@@ -2975,13 +3054,56 @@ const launchSearchProcess = async () => {
|
|
|
2975
3054
|
return rpc;
|
|
2976
3055
|
};
|
|
2977
3056
|
|
|
3057
|
+
const state$1 = {
|
|
3058
|
+
rpc: undefined
|
|
3059
|
+
};
|
|
3060
|
+
const getOrCreate$1 = () => {
|
|
3061
|
+
if (!state$1.rpc) {
|
|
3062
|
+
// @ts-ignore
|
|
3063
|
+
state$1.rpc = launchSearchProcess();
|
|
3064
|
+
}
|
|
3065
|
+
return state$1.rpc;
|
|
3066
|
+
};
|
|
3067
|
+
|
|
3068
|
+
const invoke$1 = async (method, ...params) => {
|
|
3069
|
+
const rpc = await getOrCreate$1();
|
|
3070
|
+
return rpc.invoke(method, ...params);
|
|
3071
|
+
};
|
|
3072
|
+
|
|
3073
|
+
const getPortTuple = () => {
|
|
3074
|
+
const {
|
|
3075
|
+
port1,
|
|
3076
|
+
port2
|
|
3077
|
+
} = new MessageChannel();
|
|
3078
|
+
return {
|
|
3079
|
+
port1,
|
|
3080
|
+
port2
|
|
3081
|
+
};
|
|
3082
|
+
};
|
|
3083
|
+
|
|
3084
|
+
const launchSearchProcessElectron = async () => {
|
|
3085
|
+
const {
|
|
3086
|
+
port1,
|
|
3087
|
+
port2
|
|
3088
|
+
} = getPortTuple();
|
|
3089
|
+
const rpcPromise = MessagePortRpcParent.create({
|
|
3090
|
+
messagePort: port2,
|
|
3091
|
+
commandMap: {},
|
|
3092
|
+
isMessagePortOpen: true
|
|
3093
|
+
});
|
|
3094
|
+
await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port1, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
|
|
3095
|
+
port2.start();
|
|
3096
|
+
const rpc = await rpcPromise;
|
|
3097
|
+
return rpc;
|
|
3098
|
+
};
|
|
3099
|
+
|
|
2978
3100
|
const state = {
|
|
2979
3101
|
rpc: undefined
|
|
2980
3102
|
};
|
|
2981
3103
|
const getOrCreate = () => {
|
|
2982
3104
|
if (!state.rpc) {
|
|
2983
3105
|
// @ts-ignore
|
|
2984
|
-
state.rpc =
|
|
3106
|
+
state.rpc = launchSearchProcessElectron();
|
|
2985
3107
|
}
|
|
2986
3108
|
return state.rpc;
|
|
2987
3109
|
};
|
|
@@ -3001,11 +3123,15 @@ const textSearch$2 = async (scheme, root, query, options, assetDir, platform) =>
|
|
|
3001
3123
|
searchDir: root
|
|
3002
3124
|
};
|
|
3003
3125
|
if (platform === Remote) {
|
|
3004
|
-
const result = await invoke('TextSearch.search', actualOptions);
|
|
3126
|
+
const result = await invoke$1('TextSearch.search', actualOptions);
|
|
3005
3127
|
// TODO api is weird
|
|
3006
3128
|
return result.results;
|
|
3007
3129
|
}
|
|
3008
|
-
|
|
3130
|
+
if (platform === Electron) {
|
|
3131
|
+
const result = await invoke('TextSearch.search', actualOptions);
|
|
3132
|
+
return result.results;
|
|
3133
|
+
}
|
|
3134
|
+
const results = await invoke$2('SearchProcess.invoke', 'TextSearch.search', actualOptions);
|
|
3009
3135
|
// TODO api is weird
|
|
3010
3136
|
return results.results;
|
|
3011
3137
|
};
|
|
@@ -3398,7 +3524,7 @@ const selectIndexFile = (state, searchResult, index) => {
|
|
|
3398
3524
|
};
|
|
3399
3525
|
|
|
3400
3526
|
const openUri = async (path, focus = true, props = {}) => {
|
|
3401
|
-
await invoke$
|
|
3527
|
+
await invoke$2(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
|
|
3402
3528
|
};
|
|
3403
3529
|
|
|
3404
3530
|
const getFileIndex = (items, index) => {
|
|
@@ -3421,7 +3547,6 @@ const selectIndexPreview = async (state, searchResult, index) => {
|
|
|
3421
3547
|
const {
|
|
3422
3548
|
lineNumber
|
|
3423
3549
|
} = searchResult;
|
|
3424
|
-
// console.log({ searchResult })
|
|
3425
3550
|
const fileResult = items[fileIndex];
|
|
3426
3551
|
const path = getAbsolutePath(fileResult.text);
|
|
3427
3552
|
string(path);
|
|
@@ -3790,7 +3915,7 @@ const replaceAll = async state => {
|
|
|
3790
3915
|
files,
|
|
3791
3916
|
ranges
|
|
3792
3917
|
} = getBulkReplacementEdits(workspacePath, items);
|
|
3793
|
-
await invoke$
|
|
3918
|
+
await invoke$2('BulkReplacement.applyBulkReplacement', files, ranges, replacement);
|
|
3794
3919
|
return state;
|
|
3795
3920
|
};
|
|
3796
3921
|
|
|
@@ -3822,7 +3947,7 @@ const replaceAllAndPrompt = async (workspacePath, items, replacement, matchCount
|
|
|
3822
3947
|
const confirmTitle = replaceAll$1();
|
|
3823
3948
|
const confirmAccept = replace();
|
|
3824
3949
|
const confirmText = getReplaceAllConfirmText(matchCount, fileCount, replacement);
|
|
3825
|
-
const shouldReplace = await invoke$
|
|
3950
|
+
const shouldReplace = await invoke$2('ConfirmPrompt.prompt', confirmText, {
|
|
3826
3951
|
title: confirmTitle,
|
|
3827
3952
|
confirmMessage: confirmAccept
|
|
3828
3953
|
});
|
|
@@ -3863,7 +3988,7 @@ const focusElement = (state, focusKey) => {
|
|
|
3863
3988
|
};
|
|
3864
3989
|
|
|
3865
3990
|
const setFocus = async focusKey => {
|
|
3866
|
-
await invoke$
|
|
3991
|
+
await invoke$2('Focus.setFocus', focusKey);
|
|
3867
3992
|
};
|
|
3868
3993
|
|
|
3869
3994
|
const getSearchFocusKey = key => {
|
|
@@ -4022,7 +4147,7 @@ const show = async (x, y, id, ...args) => {
|
|
|
4022
4147
|
number(y);
|
|
4023
4148
|
number(id);
|
|
4024
4149
|
// TODO
|
|
4025
|
-
await invoke$
|
|
4150
|
+
await invoke$2('ContextMenu.show', x, y, id, ...args);
|
|
4026
4151
|
};
|
|
4027
4152
|
|
|
4028
4153
|
const Search = 18;
|