@lvce-editor/file-search-worker 8.0.0 → 8.2.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
|
@@ -1026,6 +1026,49 @@ const createMockRpc = ({
|
|
|
1026
1026
|
return mockRpc;
|
|
1027
1027
|
};
|
|
1028
1028
|
|
|
1029
|
+
const commandMapRef = {};
|
|
1030
|
+
|
|
1031
|
+
const handleMessagePort = async port => {
|
|
1032
|
+
await create$4({
|
|
1033
|
+
commandMap: commandMapRef,
|
|
1034
|
+
isMessagePortOpen: true,
|
|
1035
|
+
messagePort: port
|
|
1036
|
+
});
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1040
|
+
const getProtocol = uri => {
|
|
1041
|
+
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1042
|
+
if (protocolMatch) {
|
|
1043
|
+
return protocolMatch[1];
|
|
1044
|
+
}
|
|
1045
|
+
return '';
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
const state = Object.create(null);
|
|
1049
|
+
const register = modules => {
|
|
1050
|
+
Object.assign(state, modules);
|
|
1051
|
+
};
|
|
1052
|
+
const getFn = protocol => {
|
|
1053
|
+
return state[protocol];
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
const searchFile$4 = async (path, value, prepare, assetDir) => {
|
|
1057
|
+
const protocol = getProtocol(path);
|
|
1058
|
+
const fn = getFn(protocol);
|
|
1059
|
+
if (!fn) {
|
|
1060
|
+
throw new Error(`No search handler registered for protocol: ${protocol}`);
|
|
1061
|
+
}
|
|
1062
|
+
const result = await fn(path, value, prepare, assetDir);
|
|
1063
|
+
return result;
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
const commandMap = {
|
|
1067
|
+
'FileSearch.handleMessagePort': handleMessagePort,
|
|
1068
|
+
'FileSearch.searchFile': searchFile$4,
|
|
1069
|
+
'SearchFile.searchFile': searchFile$4
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1029
1072
|
const rpcs = Object.create(null);
|
|
1030
1073
|
const set$2 = (id, rpc) => {
|
|
1031
1074
|
rpcs[id] = rpc;
|
|
@@ -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
|
};
|