@lvce-editor/file-search-worker 3.3.0 → 3.4.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 +64 -59
- package/package.json +6 -6
|
@@ -128,33 +128,38 @@ const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
|
128
128
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
129
129
|
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
130
130
|
const NewLine$1 = '\n';
|
|
131
|
-
const
|
|
132
|
-
return lines.
|
|
131
|
+
const joinLines$1 = lines => {
|
|
132
|
+
return lines.join(NewLine$1);
|
|
133
133
|
};
|
|
134
|
-
const
|
|
135
|
-
|
|
134
|
+
const RE_AT = /^\s+at/;
|
|
135
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
136
|
+
const isNormalStackLine = line => {
|
|
137
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
136
138
|
};
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
const getDetails = lines => {
|
|
140
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
141
|
+
if (index === -1) {
|
|
142
|
+
return {
|
|
143
|
+
actualMessage: joinLines$1(lines),
|
|
144
|
+
rest: []
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
let lastIndex = index - 1;
|
|
148
|
+
while (++lastIndex < lines.length) {
|
|
149
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
141
153
|
return {
|
|
142
|
-
|
|
143
|
-
|
|
154
|
+
actualMessage: lines[index - 1],
|
|
155
|
+
rest: lines.slice(index, lastIndex)
|
|
144
156
|
};
|
|
145
157
|
};
|
|
146
|
-
const
|
|
147
|
-
return lines.
|
|
158
|
+
const splitLines$2 = lines => {
|
|
159
|
+
return lines.split(NewLine$1);
|
|
148
160
|
};
|
|
149
|
-
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
150
|
-
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
151
161
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
152
162
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
153
|
-
const RE_AT = /^\s+at/;
|
|
154
|
-
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
155
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
156
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
157
|
-
};
|
|
158
163
|
const isMessageCodeBlockStartIndex = line => {
|
|
159
164
|
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
160
165
|
};
|
|
@@ -169,51 +174,46 @@ const getMessageCodeBlock = stderr => {
|
|
|
169
174
|
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
170
175
|
return relevantMessage;
|
|
171
176
|
};
|
|
172
|
-
const
|
|
173
|
-
|
|
177
|
+
const isModuleNotFoundMessage = line => {
|
|
178
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
179
|
+
};
|
|
180
|
+
const getModuleNotFoundError = stderr => {
|
|
181
|
+
const lines = splitLines$2(stderr);
|
|
182
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
183
|
+
const message = lines[messageIndex];
|
|
174
184
|
return {
|
|
175
|
-
message
|
|
176
|
-
code:
|
|
185
|
+
message,
|
|
186
|
+
code: ERR_MODULE_NOT_FOUND
|
|
177
187
|
};
|
|
178
188
|
};
|
|
179
|
-
const
|
|
189
|
+
const isModuleNotFoundError = stderr => {
|
|
180
190
|
if (!stderr) {
|
|
181
191
|
return false;
|
|
182
192
|
}
|
|
183
|
-
return stderr.includes('
|
|
184
|
-
};
|
|
185
|
-
const getModuleSyntaxError = () => {
|
|
186
|
-
return {
|
|
187
|
-
message: `ES Modules are not supported in electron`,
|
|
188
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
189
|
-
};
|
|
193
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
190
194
|
};
|
|
191
|
-
const
|
|
195
|
+
const isModulesSyntaxError = stderr => {
|
|
192
196
|
if (!stderr) {
|
|
193
197
|
return false;
|
|
194
198
|
}
|
|
195
|
-
return stderr.includes('
|
|
199
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
196
200
|
};
|
|
197
|
-
const
|
|
198
|
-
|
|
201
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
202
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
203
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
204
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
199
205
|
};
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
if (index === -1) {
|
|
203
|
-
return {
|
|
204
|
-
actualMessage: joinLines$1(lines),
|
|
205
|
-
rest: []
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
let lastIndex = index - 1;
|
|
209
|
-
while (++lastIndex < lines.length) {
|
|
210
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
206
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
207
|
+
const message = getMessageCodeBlock(stderr);
|
|
214
208
|
return {
|
|
215
|
-
|
|
216
|
-
|
|
209
|
+
message: `Incompatible native node module: ${message}`,
|
|
210
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
const getModuleSyntaxError = () => {
|
|
214
|
+
return {
|
|
215
|
+
message: `ES Modules are not supported in electron`,
|
|
216
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
217
217
|
};
|
|
218
218
|
};
|
|
219
219
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -274,7 +274,7 @@ const listen$7 = () => {
|
|
|
274
274
|
}
|
|
275
275
|
return globalThis;
|
|
276
276
|
};
|
|
277
|
-
const signal$
|
|
277
|
+
const signal$8 = global => {
|
|
278
278
|
global.postMessage(readyMessage);
|
|
279
279
|
};
|
|
280
280
|
class IpcChildWithModuleWorker extends Ipc {
|
|
@@ -300,7 +300,7 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
300
300
|
this._rawIpc.addEventListener('message', callback);
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
const wrap$
|
|
303
|
+
const wrap$f = global => {
|
|
304
304
|
return new IpcChildWithModuleWorker(global);
|
|
305
305
|
};
|
|
306
306
|
const withResolvers = () => {
|
|
@@ -328,8 +328,8 @@ const waitForFirstMessage = async port => {
|
|
|
328
328
|
};
|
|
329
329
|
const listen$6 = async () => {
|
|
330
330
|
const parentIpcRaw = listen$7();
|
|
331
|
-
signal$
|
|
332
|
-
const parentIpc = wrap$
|
|
331
|
+
signal$8(parentIpcRaw);
|
|
332
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
333
333
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
334
334
|
if (firstMessage.method !== 'initialize') {
|
|
335
335
|
throw new IpcError('unexpected first message');
|
|
@@ -371,13 +371,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
371
371
|
this._rawIpc.start();
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
|
-
const wrap$
|
|
374
|
+
const wrap$e = port => {
|
|
375
375
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
376
376
|
};
|
|
377
377
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
378
378
|
__proto__: null,
|
|
379
379
|
listen: listen$6,
|
|
380
|
-
wrap: wrap$
|
|
380
|
+
wrap: wrap$e
|
|
381
381
|
};
|
|
382
382
|
|
|
383
383
|
const Two = '2.0';
|
|
@@ -743,6 +743,8 @@ const execute$1 = (command, ...args) => {
|
|
|
743
743
|
|
|
744
744
|
const createRpc = ipc => {
|
|
745
745
|
const rpc = {
|
|
746
|
+
// @ts-ignore
|
|
747
|
+
ipc,
|
|
746
748
|
/**
|
|
747
749
|
* @deprecated
|
|
748
750
|
*/
|
|
@@ -769,7 +771,8 @@ const logError = () => {
|
|
|
769
771
|
};
|
|
770
772
|
const handleMessage = event => {
|
|
771
773
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
772
|
-
|
|
774
|
+
const actualExecute = event?.target?.execute || execute$1;
|
|
775
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
773
776
|
};
|
|
774
777
|
const handleIpc = ipc => {
|
|
775
778
|
if ('addEventListener' in ipc) {
|
|
@@ -1878,6 +1881,8 @@ const fromAsync = async asyncIterable => {
|
|
|
1878
1881
|
* retrieve the child handles
|
|
1879
1882
|
*
|
|
1880
1883
|
*/
|
|
1884
|
+
|
|
1885
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
1881
1886
|
const getChildHandles = async handle => {
|
|
1882
1887
|
// @ts-ignore
|
|
1883
1888
|
const handles = await fromAsync(handle.values());
|
|
@@ -2246,7 +2251,7 @@ const searchFile$1 = async (path, value, prepare) => {
|
|
|
2246
2251
|
const options = {
|
|
2247
2252
|
ripGrepArgs,
|
|
2248
2253
|
searchPath: path,
|
|
2249
|
-
limit:
|
|
2254
|
+
limit: 9_999_999
|
|
2250
2255
|
};
|
|
2251
2256
|
const stdout = await invoke('SearchFile.searchFile', options);
|
|
2252
2257
|
const lines = splitLines(stdout);
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/file-search-worker",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "dist/fileSearchWorkerMain.js",
|
|
6
|
-
"type": "module",
|
|
7
5
|
"keywords": [
|
|
8
6
|
"text-search"
|
|
9
7
|
],
|
|
10
|
-
"author": "Lvce Editor",
|
|
11
|
-
"license": "MIT",
|
|
12
8
|
"repository": {
|
|
13
9
|
"type": "git",
|
|
14
10
|
"url": "git+https://github.com/lvce-editor/file-search-worker.git"
|
|
15
|
-
}
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Lvce Editor",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/fileSearchWorkerMain.js"
|
|
16
16
|
}
|