@lvce-editor/file-search-worker 8.0.0 → 8.1.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/fileSearchWorkerMain.js +44 -33
- package/package.json +1 -1
|
@@ -1006,6 +1006,49 @@ const create$1 = async ({
|
|
|
1006
1006
|
return rpc;
|
|
1007
1007
|
};
|
|
1008
1008
|
|
|
1009
|
+
const commandMapRef = {};
|
|
1010
|
+
|
|
1011
|
+
const handleMessagePort = async port => {
|
|
1012
|
+
await create$4({
|
|
1013
|
+
commandMap: commandMapRef,
|
|
1014
|
+
isMessagePortOpen: true,
|
|
1015
|
+
messagePort: port
|
|
1016
|
+
});
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1020
|
+
const getProtocol = uri => {
|
|
1021
|
+
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1022
|
+
if (protocolMatch) {
|
|
1023
|
+
return protocolMatch[1];
|
|
1024
|
+
}
|
|
1025
|
+
return '';
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
const state = Object.create(null);
|
|
1029
|
+
const register = modules => {
|
|
1030
|
+
Object.assign(state, modules);
|
|
1031
|
+
};
|
|
1032
|
+
const getFn = protocol => {
|
|
1033
|
+
return state[protocol];
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
const searchFile$4 = async (path, value, prepare, assetDir) => {
|
|
1037
|
+
const protocol = getProtocol(path);
|
|
1038
|
+
const fn = getFn(protocol);
|
|
1039
|
+
if (!fn) {
|
|
1040
|
+
throw new Error(`No search handler registered for protocol: ${protocol}`);
|
|
1041
|
+
}
|
|
1042
|
+
const result = await fn(path, value, prepare, assetDir);
|
|
1043
|
+
return result;
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
const commandMap = {
|
|
1047
|
+
'FileSearch.handleMessagePort': handleMessagePort,
|
|
1048
|
+
'FileSearch.searchFile': searchFile$4,
|
|
1049
|
+
'SearchFile.searchFile': searchFile$4
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1009
1052
|
const createMockRpc = ({
|
|
1010
1053
|
commandMap
|
|
1011
1054
|
}) => {
|
|
@@ -1101,39 +1144,6 @@ const initializeEditorWorker = async () => {
|
|
|
1101
1144
|
set$1(rpc);
|
|
1102
1145
|
};
|
|
1103
1146
|
|
|
1104
|
-
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1105
|
-
const getProtocol = uri => {
|
|
1106
|
-
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1107
|
-
if (protocolMatch) {
|
|
1108
|
-
return protocolMatch[1];
|
|
1109
|
-
}
|
|
1110
|
-
return '';
|
|
1111
|
-
};
|
|
1112
|
-
|
|
1113
|
-
const state = Object.create(null);
|
|
1114
|
-
const register = modules => {
|
|
1115
|
-
Object.assign(state, modules);
|
|
1116
|
-
};
|
|
1117
|
-
const getFn = protocol => {
|
|
1118
|
-
return state[protocol];
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
|
-
const searchFile$4 = async (path, value, prepare, assetDir) => {
|
|
1122
|
-
const protocol = getProtocol(path);
|
|
1123
|
-
// TODO call different providers depending on protocol
|
|
1124
|
-
const fn = getFn(protocol);
|
|
1125
|
-
if (!fn) {
|
|
1126
|
-
throw new Error(`No search handler registered for protocol: ${protocol}`);
|
|
1127
|
-
}
|
|
1128
|
-
const result = await fn(path, value, prepare, assetDir);
|
|
1129
|
-
return result;
|
|
1130
|
-
};
|
|
1131
|
-
|
|
1132
|
-
const commandMap = {
|
|
1133
|
-
'FileSearch.searchFile': searchFile$4,
|
|
1134
|
-
'SearchFile.searchFile': searchFile$4
|
|
1135
|
-
};
|
|
1136
|
-
|
|
1137
1147
|
const initializeRendererWorker = async () => {
|
|
1138
1148
|
const rpc = await create$1({
|
|
1139
1149
|
commandMap: commandMap
|
|
@@ -1201,6 +1211,7 @@ const searchModules = {
|
|
|
1201
1211
|
};
|
|
1202
1212
|
|
|
1203
1213
|
const listen = async () => {
|
|
1214
|
+
Object.assign(commandMapRef, commandMap);
|
|
1204
1215
|
register(searchModules);
|
|
1205
1216
|
await Promise.all([initializeRendererWorker(), initializeEditorWorker()]);
|
|
1206
1217
|
};
|