@lvce-editor/shared-process 0.27.2 → 0.28.1
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/package.json +7 -9
- package/src/parts/ClipBoard/ClipBoard.js +5 -19
- package/src/parts/Exec/Exec.js +1 -10
- package/src/parts/GetTypeFromUrl/GetTypeFromUrl.js +1 -0
- package/src/parts/GetTypeScriptPath/GetTypeScriptPath.js +2 -1
- package/src/parts/HandleIpcSearchProcess/HandleIpcSearchProcess.js +23 -1
- package/src/parts/HandleMessagePortForSearchProcess/HandleMessagePortForSearchProcess.js +4 -7
- package/src/parts/HandleWebSocketForSearchProcess/HandleWebSocketForSearchProcess.js +5 -0
- package/src/parts/HandleWebSocketForUnknown/HandleWebSocketForUnknown.js +3 -7
- package/src/parts/HandleWebSocketModule/HandleWebSocketModule.js +2 -0
- package/src/parts/IsElectron/IsElectron.js +1 -3
- package/src/parts/LaunchNetworkProcess/LaunchNetworkProcess.js +4 -2
- package/src/parts/LaunchSearchProcess/LaunchSearchProcess.js +4 -2
- package/src/parts/LaunchTypeScriptCompileProcess/LaunchTypeScriptCompileProcess.js +17 -0
- package/src/parts/Module/Module.js +0 -8
- package/src/parts/ModuleId/ModuleId.js +0 -4
- package/src/parts/ModuleMap/ModuleMap.js +0 -8
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/ProtocolType/ProtocolType.js +1 -0
- package/src/parts/RebuildNodePty/RebuildNodePty.js +3 -22
- package/src/parts/SearchProcessPath/SearchProcessPath.js +1 -3
- package/src/parts/SymLink/SymLink.js +3 -3
- package/src/parts/TranspileTypeScript/TranspileTypeScript.js +3 -19
- package/src/parts/Trash/Trash.js +1 -1
- package/src/parts/TypeScriptCompileProcess/TypeScriptCompileProcess.js +18 -0
- package/src/parts/TypeScriptCompileProcessPath/TypeScriptCompileProcessPath.js +1 -0
- package/src/parts/Workspace/Workspace.js +1 -1
- package/src/parts/ClipBoard/ClipBoardGnome.js +0 -57
- package/src/parts/ClipBoard/ClipBoardNoop.js +0 -12
- package/src/parts/ClipBoard/ClipBoardWindows.js +0 -20
- package/src/parts/CollectTextSearchStdout/CollectTextSearchStdout.js +0 -93
- package/src/parts/ElectronClipBoard/ElectronClipBoard.ipc.js +0 -5
- package/src/parts/ElectronClipBoard/ElectronClipBoard.js +0 -4
- package/src/parts/IncrementalTextSearch/IncrementalTextSearch.js +0 -46
- package/src/parts/IncrementalTextSearch/IncremetalTextSearch.ipc.js +0 -5
- package/src/parts/ParseRipGrepLines/ParseRipGrepLines.js +0 -10
- package/src/parts/RebuildForElectron/RebuildForElectron.js +0 -18
- package/src/parts/RebuildForNode/RebuildForNode.js +0 -16
- package/src/parts/RipGrep/RipGrep.js +0 -38
- package/src/parts/RipGrepParsedLineType/RipGrepParsedLineType.js +0 -4
- package/src/parts/RipGrepPath/RipGrepPath.js +0 -1
- package/src/parts/SearchFile/SearchFile.ipc.js +0 -5
- package/src/parts/SearchFile/SearchFile.js +0 -34
- package/src/parts/TextSearch/TextSearch.ipc.js +0 -5
- package/src/parts/TextSearch/TextSearch.js +0 -27
- package/src/parts/TextSearchError/TextSearchError.js +0 -15
- package/src/parts/TextSearchResultType/TextSearchResultType.js +0 -2
- package/src/parts/ToTextSearchResult/ToTextSearchResult.js +0 -24
- package/src/parts/WebSocketServer/WebSocketServer.ipc.js +0 -5
- package/src/parts/WebSocketServer/WebSocketServer.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -18,26 +18,24 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lvce-editor/assert": "^1.2.0",
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.
|
|
22
|
-
"@lvce-editor/ipc": "^8.0
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.28.1",
|
|
22
|
+
"@lvce-editor/ipc": "^8.2.0",
|
|
23
23
|
"@lvce-editor/json-rpc": "^1.3.0",
|
|
24
24
|
"@lvce-editor/jsonc-parser": "^1.2.0",
|
|
25
|
-
"@lvce-editor/network-process": "0.27.2",
|
|
26
25
|
"@lvce-editor/pretty-error": "^1.5.0",
|
|
27
|
-
"@lvce-editor/pty-host": "0.
|
|
26
|
+
"@lvce-editor/pty-host": "0.28.1",
|
|
28
27
|
"@lvce-editor/verror": "^1.2.0",
|
|
29
|
-
"@lvce-editor/web-socket-server": "^1.1.0",
|
|
30
28
|
"debug": "^4.3.4",
|
|
31
|
-
"execa": "^8.0.1",
|
|
32
29
|
"exit-hook": "^4.0.0",
|
|
33
30
|
"is-object": "^1.0.2",
|
|
34
31
|
"xdg-basedir": "^5.1.0"
|
|
35
32
|
},
|
|
36
33
|
"optionalDependencies": {
|
|
37
|
-
"@lvce-editor/ripgrep": "^1.1.0",
|
|
38
34
|
"open": "^10.1.0",
|
|
39
35
|
"tail": "^2.2.6",
|
|
40
36
|
"tmp-promise": "^3.0.3",
|
|
41
|
-
"trash": "^8.1.1"
|
|
37
|
+
"trash": "^8.1.1",
|
|
38
|
+
"@lvce-editor/network-process": "0.28.1",
|
|
39
|
+
"@lvce-editor/search-process": "0.28.1"
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const desktop = Desktop.getDesktop();
|
|
5
|
-
switch (desktop) {
|
|
6
|
-
case DesktopType.Gnome:
|
|
7
|
-
return import('./ClipBoardGnome.js');
|
|
8
|
-
case DesktopType.Windows:
|
|
9
|
-
return import('./ClipBoardWindows.js');
|
|
10
|
-
default:
|
|
11
|
-
return import('./ClipBoardNoop.js');
|
|
12
|
-
}
|
|
1
|
+
import * as NetworkProcess from '../NetworkProcess/NetworkProcess.js';
|
|
2
|
+
export const readFiles = () => {
|
|
3
|
+
return NetworkProcess.invoke('ClipBoard.readFiles');
|
|
13
4
|
};
|
|
14
|
-
export const
|
|
15
|
-
|
|
16
|
-
return clipboard.readFiles();
|
|
17
|
-
};
|
|
18
|
-
export const writeFiles = async (type, files) => {
|
|
19
|
-
const clipboard = await getClipboard();
|
|
20
|
-
await clipboard.writeFiles(type, files);
|
|
5
|
+
export const writeFiles = (type, files) => {
|
|
6
|
+
return NetworkProcess.invoke('ClipBoard.writeFiles', type, files);
|
|
21
7
|
};
|
package/src/parts/Exec/Exec.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { execa } from 'execa';
|
|
2
|
-
import * as Assert from '../Assert/Assert.js';
|
|
3
1
|
/**
|
|
4
2
|
*
|
|
5
3
|
* @param {string} command
|
|
@@ -8,12 +6,5 @@ import * as Assert from '../Assert/Assert.js';
|
|
|
8
6
|
* @returns
|
|
9
7
|
*/
|
|
10
8
|
export const exec = async (command, args, options) => {
|
|
11
|
-
|
|
12
|
-
Assert.array(args);
|
|
13
|
-
Assert.object(options);
|
|
14
|
-
const { stdout, stderr } = await execa(command, args, options);
|
|
15
|
-
return {
|
|
16
|
-
stdout,
|
|
17
|
-
stderr,
|
|
18
|
-
};
|
|
9
|
+
throw new Error('deprecated');
|
|
19
10
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import * as IsBuiltServer from '../IsBuiltServer/IsBuiltServer.js';
|
|
3
3
|
import * as PlatformPaths from '../PlatformPaths/PlatformPaths.js';
|
|
4
|
+
import * as Platform from '../Platform/Platform.js';
|
|
4
5
|
import { pathToFileURL } from 'node:url';
|
|
5
6
|
export const getTypeScriptUri = () => {
|
|
6
|
-
if (IsBuiltServer.isBuiltServer) {
|
|
7
|
+
if (!Platform.isProduction || IsBuiltServer.isBuiltServer) {
|
|
7
8
|
return 'typescript';
|
|
8
9
|
}
|
|
9
10
|
const typescriptPath = join(PlatformPaths.getBuiltinExtensionsPath(), 'builtin.language-features-typescript', 'node', 'node_modules', 'typescript', 'lib', 'typescript.js');
|
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import * as SearchProcess from '../SearchProcess/SearchProcess.js';
|
|
2
|
+
export const targetWebSocket = () => {
|
|
3
|
+
return SearchProcess.getOrCreate();
|
|
4
|
+
};
|
|
5
|
+
export const upgradeWebSocket = (handle, message) => {
|
|
6
|
+
return {
|
|
7
|
+
type: 'send',
|
|
8
|
+
method: 'HandleWebSocket.handleWebSocket',
|
|
9
|
+
params: [message],
|
|
10
|
+
transfer: handle,
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export const targetMessagePort = () => {
|
|
14
|
+
return SearchProcess.getOrCreate();
|
|
15
|
+
};
|
|
16
|
+
export const upgradeMessagePort = (port) => {
|
|
17
|
+
return {
|
|
18
|
+
type: 'send',
|
|
19
|
+
method: 'HandleElectronMessagePort.handleElectronMessagePort',
|
|
20
|
+
params: [],
|
|
21
|
+
transfer: [port],
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Assert.object(port);
|
|
6
|
-
const ipc = await SearchProcess.getOrCreate();
|
|
7
|
-
await JsonRpc.invokeAndTransfer(ipc, [port], 'HandleElectronMessagePort.handleElectronMessagePort');
|
|
1
|
+
import * as HandleIncomingIpc from '../HandleIncomingIpc/HandleIncomingIpc.js';
|
|
2
|
+
import * as IpcId from '../IpcId/IpcId.js';
|
|
3
|
+
export const handleMessagePortForSearchProcess = (port) => {
|
|
4
|
+
return HandleIncomingIpc.handleIncomingIpc(IpcId.SearchProcess, port, {});
|
|
8
5
|
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import * as Logger from '../Logger/Logger.js';
|
|
2
|
+
import * as DestroySocket from '../DestroySocket/DestroySocket.js';
|
|
2
3
|
export const handleWebSocket = (message, handle, protocol) => {
|
|
3
|
-
Logger.warn(`[shared-process] unsupported sec-websocket-
|
|
4
|
-
|
|
5
|
-
handle.destroy();
|
|
6
|
-
}
|
|
7
|
-
catch {
|
|
8
|
-
// ignore
|
|
9
|
-
}
|
|
4
|
+
Logger.warn(`[shared-process] unsupported sec-websocket-protocol ${protocol}`);
|
|
5
|
+
DestroySocket.destroySocket(handle);
|
|
10
6
|
};
|
|
@@ -11,6 +11,8 @@ export const load = (protocol) => {
|
|
|
11
11
|
return import('../HandleWebSocketForExtensionHostHelperProcess/HandleWebSocketForExtensionHostHelperProcess.js');
|
|
12
12
|
case ProtocolType.TerminalProcess:
|
|
13
13
|
return import('../HandleWebSocketForTerminalProcess/HandleWebSocketForTerminalProcess.js');
|
|
14
|
+
case ProtocolType.SearchProcess:
|
|
15
|
+
return import('../HandleWebSocketForSearchProcess/HandleWebSocketForSearchProcess.js');
|
|
14
16
|
default:
|
|
15
17
|
return import('../HandleWebSocketForUnknown/HandleWebSocketForUnknown.js');
|
|
16
18
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import * as NetworkProcessPath from '../NetworkProcessPath/NetworkProcessPath.js';
|
|
2
1
|
import * as HandleIpc from '../HandleIpc/HandleIpc.js';
|
|
3
2
|
import * as IpcParent from '../IpcParent/IpcParent.js';
|
|
4
3
|
import * as IpcParentType from '../IpcParentType/IpcParentType.js';
|
|
4
|
+
import * as IsElectron from '../IsElectron/IsElectron.js';
|
|
5
|
+
import * as NetworkProcessPath from '../NetworkProcessPath/NetworkProcessPath.js';
|
|
5
6
|
export const launchNetworkProcess = async () => {
|
|
7
|
+
const method = IsElectron.isElectron ? IpcParentType.ElectronUtilityProcess : IpcParentType.NodeForkedProcess;
|
|
6
8
|
const networkProcess = await IpcParent.create({
|
|
7
|
-
method
|
|
9
|
+
method,
|
|
8
10
|
path: NetworkProcessPath.networkProcessPath,
|
|
9
11
|
argv: [],
|
|
10
12
|
stdio: 'inherit',
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import * as SearchProcessPath from '../SearchProcessPath/SearchProcessPath.js';
|
|
2
1
|
import * as HandleIpc from '../HandleIpc/HandleIpc.js';
|
|
3
2
|
import * as IpcParent from '../IpcParent/IpcParent.js';
|
|
4
3
|
import * as IpcParentType from '../IpcParentType/IpcParentType.js';
|
|
4
|
+
import * as IsElectron from '../IsElectron/IsElectron.js';
|
|
5
|
+
import * as SearchProcessPath from '../SearchProcessPath/SearchProcessPath.js';
|
|
5
6
|
export const launchSearchProcess = async () => {
|
|
7
|
+
const method = IsElectron.isElectron ? IpcParentType.ElectronUtilityProcess : IpcParentType.NodeForkedProcess;
|
|
6
8
|
const searchProcess = await IpcParent.create({
|
|
7
|
-
method
|
|
9
|
+
method,
|
|
8
10
|
path: SearchProcessPath.searchProcessPath,
|
|
9
11
|
argv: [],
|
|
10
12
|
stdio: 'inherit',
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as HandleIpc from '../HandleIpc/HandleIpc.js';
|
|
2
|
+
import * as IpcParent from '../IpcParent/IpcParent.js';
|
|
3
|
+
import * as IpcParentType from '../IpcParentType/IpcParentType.js';
|
|
4
|
+
import * as IsElectron from '../IsElectron/IsElectron.js';
|
|
5
|
+
import * as TypeScriptCompileProcessPath from '../TypeScriptCompileProcessPath/TypeScriptCompileProcessPath.js';
|
|
6
|
+
export const launchTypeScriptCompileProcess = async () => {
|
|
7
|
+
const method = IsElectron.isElectron ? IpcParentType.ElectronUtilityProcess : IpcParentType.NodeForkedProcess;
|
|
8
|
+
const typescriptCompileProcess = await IpcParent.create({
|
|
9
|
+
method,
|
|
10
|
+
path: TypeScriptCompileProcessPath.typescriptCompileProcessPath,
|
|
11
|
+
argv: [],
|
|
12
|
+
stdio: 'inherit',
|
|
13
|
+
name: 'TypeScript Compile Process',
|
|
14
|
+
});
|
|
15
|
+
HandleIpc.handleIpc(typescriptCompileProcess);
|
|
16
|
+
return typescriptCompileProcess;
|
|
17
|
+
};
|
|
@@ -67,8 +67,6 @@ export const load = (moduleId) => {
|
|
|
67
67
|
return import('../HandleNodeMessagePort/HandleNodeMessagePort.ipc.js');
|
|
68
68
|
case ModuleId.HandleWebSocket:
|
|
69
69
|
return import('../HandleWebSocket/HandleWebSocket.ipc.js');
|
|
70
|
-
case ModuleId.IncrementalTextSearch:
|
|
71
|
-
return import('../IncrementalTextSearch/IncremetalTextSearch.ipc.js');
|
|
72
70
|
case ModuleId.InstallExtension:
|
|
73
71
|
return import('../InstallExtension/InstallExtension.ipc.js');
|
|
74
72
|
case ModuleId.IsAutoUpdateSupported:
|
|
@@ -97,16 +95,10 @@ export const load = (moduleId) => {
|
|
|
97
95
|
return import('../RebuildNodePty/RebuildNodePty.ipc.js');
|
|
98
96
|
case ModuleId.RecentlyOpened:
|
|
99
97
|
return import('../RecentlyOpened/RecentlyOpened.ipc.js');
|
|
100
|
-
case ModuleId.SearchFile:
|
|
101
|
-
return import('../SearchFile/SearchFile.ipc.js');
|
|
102
98
|
case ModuleId.Terminal:
|
|
103
99
|
return import('../Terminal/Terminal.ipc.js');
|
|
104
100
|
case ModuleId.TextDocument:
|
|
105
101
|
return import('../TextDocument/TextDocument.ipc.js');
|
|
106
|
-
case ModuleId.Search:
|
|
107
|
-
return import('../TextSearch/TextSearch.ipc.js');
|
|
108
|
-
case ModuleId.WebSocketServer:
|
|
109
|
-
return import('../WebSocketServer/WebSocketServer.ipc.js');
|
|
110
102
|
case ModuleId.Workspace:
|
|
111
103
|
return import('../Workspace/Workspace.ipc.js');
|
|
112
104
|
case ModuleId.ElectronNet:
|
|
@@ -9,12 +9,9 @@ export const Platform = 8;
|
|
|
9
9
|
export const Preferences = 9;
|
|
10
10
|
export const RecentlyOpened = 10;
|
|
11
11
|
export const GetWindowId = 377;
|
|
12
|
-
export const Search = 11;
|
|
13
12
|
export const ElectronWindowProcessExplorer = 12;
|
|
14
|
-
export const SearchFile = 13;
|
|
15
13
|
export const Terminal = 14;
|
|
16
14
|
export const TextDocument = 15;
|
|
17
|
-
export const WebSocketServer = 16;
|
|
18
15
|
export const Workspace = 17;
|
|
19
16
|
export const ChromeExtension = 18;
|
|
20
17
|
export const Download = 19;
|
|
@@ -36,7 +33,6 @@ export const HandleNodeMessagePort = 33;
|
|
|
36
33
|
export const GetTerminalSpawnOptions = 34;
|
|
37
34
|
export const HandleCliArgs = 35;
|
|
38
35
|
export const ListProcessesWithMemoryUsage = 36;
|
|
39
|
-
export const IncrementalTextSearch = 37;
|
|
40
36
|
export const Performance = 38;
|
|
41
37
|
export const Crash = 39;
|
|
42
38
|
export const ElectronWindowAbout = 40;
|
|
@@ -156,8 +156,6 @@ export const getModuleId = (commandId) => {
|
|
|
156
156
|
return ModuleId.HandleNodeMessagePort;
|
|
157
157
|
case 'HandleWebSocket.handleWebSocket':
|
|
158
158
|
return ModuleId.HandleWebSocket;
|
|
159
|
-
case 'IncrementalTextSearch.start':
|
|
160
|
-
return ModuleId.IncrementalTextSearch;
|
|
161
159
|
case 'InstallExtension.installExtension':
|
|
162
160
|
return ModuleId.InstallExtension;
|
|
163
161
|
case 'IsAutoUpdateSupported.isAutoUpdateSupported':
|
|
@@ -221,10 +219,6 @@ export const getModuleId = (commandId) => {
|
|
|
221
219
|
return ModuleId.RebuildNodePty;
|
|
222
220
|
case 'RecentlyOpened.addPath':
|
|
223
221
|
return ModuleId.RecentlyOpened;
|
|
224
|
-
case 'TextSearch.search':
|
|
225
|
-
return ModuleId.Search;
|
|
226
|
-
case 'SearchFile.searchFile':
|
|
227
|
-
return ModuleId.SearchFile;
|
|
228
222
|
case 'Terminal.create':
|
|
229
223
|
case 'Terminal.dispose':
|
|
230
224
|
case 'Terminal.resize':
|
|
@@ -232,8 +226,6 @@ export const getModuleId = (commandId) => {
|
|
|
232
226
|
return ModuleId.Terminal;
|
|
233
227
|
case 4820:
|
|
234
228
|
return ModuleId.TextDocument;
|
|
235
|
-
case 'WebSocketServer.handleUpgrade':
|
|
236
|
-
return ModuleId.WebSocketServer;
|
|
237
229
|
case 'ElectronWindow.close':
|
|
238
230
|
case 'ElectronWindow.focus':
|
|
239
231
|
case 'ElectronWindow.getZoom':
|
|
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
|
|
|
41
41
|
export const getSetupName = () => {
|
|
42
42
|
return 'Lvce-Setup';
|
|
43
43
|
};
|
|
44
|
-
export const version = '0.
|
|
45
|
-
export const commit = '
|
|
46
|
-
export const date = '2024-05-
|
|
44
|
+
export const version = '0.28.1';
|
|
45
|
+
export const commit = '50a3401';
|
|
46
|
+
export const date = '2024-05-03T21:44:26.000Z';
|
|
47
47
|
export const getVersion = () => {
|
|
48
48
|
return version;
|
|
49
49
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const ExtensionHost = 'extension-host';
|
|
2
2
|
export const ExtensionHostHelperProcess = 'extension-host-helper-process';
|
|
3
|
+
export const SearchProcess = 'search-process';
|
|
3
4
|
export const SharedProcess = 'shared-process';
|
|
4
5
|
export const TerminalProcess = 'terminal-process';
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { VError } from '../VError/VError.js';
|
|
5
|
-
const getPtyHostPath = () => {
|
|
6
|
-
return Path.join(Root.root, 'packages', 'pty-host');
|
|
7
|
-
};
|
|
8
|
-
const getModule = () => {
|
|
9
|
-
if (IsElectron.isElectron()) {
|
|
10
|
-
return import('../RebuildForElectron/RebuildForElectron.js');
|
|
11
|
-
}
|
|
12
|
-
return import('../RebuildForNode/RebuildForNode.js');
|
|
13
|
-
};
|
|
14
|
-
export const rebuildNodePty = async () => {
|
|
15
|
-
try {
|
|
16
|
-
const ptyHostPath = getPtyHostPath();
|
|
17
|
-
const module = await getModule();
|
|
18
|
-
await module.rebuild(ptyHostPath);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
throw new VError(error, `Failed to rebuild node-pty`);
|
|
22
|
-
}
|
|
1
|
+
import * as NetworkProcess from '../NetworkProcess/NetworkProcess.js';
|
|
2
|
+
export const rebuildNodePty = () => {
|
|
3
|
+
return NetworkProcess.invoke('RebuildNodePty.rebuildNodePty');
|
|
23
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const createSymLink =
|
|
3
|
-
|
|
1
|
+
import * as NetworkProcess from '../NetworkProcess/NetworkProcess.js';
|
|
2
|
+
export const createSymLink = (target, path) => {
|
|
3
|
+
return NetworkProcess.invoke('Symlink.createSymLink', target, path);
|
|
4
4
|
};
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import * as LoadTypeScript from '../LoadTypeScript/LoadTypeScript.js';
|
|
5
|
-
export const transpileTypeScript = async (code) => {
|
|
6
|
-
try {
|
|
7
|
-
Assert.string(code);
|
|
8
|
-
const typescriptUri = GetTypeScriptPath.getTypeScriptUri();
|
|
9
|
-
const typescript = await LoadTypeScript.loadTypeScript(typescriptUri);
|
|
10
|
-
const newContent = await typescript.transpileModule(code, {
|
|
11
|
-
compilerOptions: {
|
|
12
|
-
target: 'esnext',
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
return newContent;
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
throw new VError(error, `Failed to transpile typescript`);
|
|
19
|
-
}
|
|
1
|
+
import * as TypeScriptCompileProcess from '../TypeScriptCompileProcess/TypeScriptCompileProcess.js';
|
|
2
|
+
export const transpileTypeScript = (code) => {
|
|
3
|
+
return TypeScriptCompileProcess.invoke('TranspileTypeScript.transpileTypeScript', code);
|
|
20
4
|
};
|
package/src/parts/Trash/Trash.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as IsElectron from '../IsElectron/IsElectron.js';
|
|
2
2
|
import { VError } from '../VError/VError.js';
|
|
3
3
|
const getModule = () => {
|
|
4
|
-
if (IsElectron.isElectron
|
|
4
|
+
if (IsElectron.isElectron) {
|
|
5
5
|
return import('../TrashElectron/TrashElectron.js');
|
|
6
6
|
}
|
|
7
7
|
return import('../TrashNode/TrashNode.js');
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as JsonRpc from '../JsonRpc/JsonRpc.js';
|
|
2
|
+
import * as LaunchTypeScriptCompileProcess from '../LaunchTypeScriptCompileProcess/LaunchTypeScriptCompileProcess.js';
|
|
3
|
+
export const state = {
|
|
4
|
+
/**
|
|
5
|
+
* @type {any}
|
|
6
|
+
*/
|
|
7
|
+
ipc: undefined,
|
|
8
|
+
};
|
|
9
|
+
export const getOrCreate = async () => {
|
|
10
|
+
if (!state.ipc) {
|
|
11
|
+
state.ipc = LaunchTypeScriptCompileProcess.launchTypeScriptCompileProcess();
|
|
12
|
+
}
|
|
13
|
+
return state.ipc;
|
|
14
|
+
};
|
|
15
|
+
export const invoke = async (method, ...params) => {
|
|
16
|
+
const ipc = await getOrCreate();
|
|
17
|
+
return JsonRpc.invoke(ipc, method, ...params);
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { typescriptCompileProcessPath } from '@lvce-editor/typescript-compile-process';
|
|
@@ -37,7 +37,7 @@ const toUri = (path) => {
|
|
|
37
37
|
return pathToFileURL(path).toString();
|
|
38
38
|
};
|
|
39
39
|
export const resolveRoot = async () => {
|
|
40
|
-
if (IsElectron.isElectron
|
|
40
|
+
if (IsElectron.isElectron) {
|
|
41
41
|
const argv = await ParentIpc.invoke('Process.getArgv');
|
|
42
42
|
const relevantArgv = argv.slice(2);
|
|
43
43
|
const last = relevantArgv.at(-1);
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// see https://www.cyberciti.biz/faq/how-do-i-copy-a-file-to-the-clipboard-in-linux
|
|
2
|
-
// see also http://manpages.ubuntu.com/manpages/bionic/man1/xclip.1.html
|
|
3
|
-
// on gnome, get current selection targets with `xclip -selection clipboard -t TARGETS -o`
|
|
4
|
-
import * as Exec from '../Exec/Exec.js';
|
|
5
|
-
import * as JoinLines from '../JoinLines/JoinLines.js';
|
|
6
|
-
import * as SplitLines from '../SplitLines/SplitLines.js';
|
|
7
|
-
import { VError } from '../VError/VError.js';
|
|
8
|
-
const removePrefix = (file) => {
|
|
9
|
-
if (file.startsWith('file://')) {
|
|
10
|
-
return file.slice('file://'.length);
|
|
11
|
-
}
|
|
12
|
-
return file;
|
|
13
|
-
};
|
|
14
|
-
const addPrefix = (file) => {
|
|
15
|
-
return `file://${file}`;
|
|
16
|
-
};
|
|
17
|
-
export const readFiles = async () => {
|
|
18
|
-
let result;
|
|
19
|
-
try {
|
|
20
|
-
result = await Exec.exec('xclip', ['-selection', 'clipboard', '-o', '-t', 'x-special/gnome-copied-files'], {});
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
if (error &&
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
error.stderr === 'Error: target x-special/gnome-copied-files not available') {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
30
|
-
const [type, ...files] = SplitLines.splitLines(result.stdout);
|
|
31
|
-
const actualFiles = files.map(removePrefix);
|
|
32
|
-
return {
|
|
33
|
-
source: 'gnomeCopiedFiles',
|
|
34
|
-
type,
|
|
35
|
-
files: actualFiles,
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export const writeFiles = async (type, files) => {
|
|
39
|
-
const filesWithPrefix = files.map(addPrefix);
|
|
40
|
-
const gnomeCopiedFilesContent = JoinLines.joinLines([type, ...filesWithPrefix]);
|
|
41
|
-
const uriListContent = JoinLines.joinLines(filesWithPrefix);
|
|
42
|
-
const plainContent = JoinLines.joinLines(files);
|
|
43
|
-
try {
|
|
44
|
-
await Exec.exec('xclip', ['-i', '-selection', 'clipboard', '-t', 'x-special/gnome-copied-files'], {
|
|
45
|
-
input: gnomeCopiedFilesContent,
|
|
46
|
-
});
|
|
47
|
-
await Exec.exec('xclip', ['-i', '-selection', 'clipboard', '-t', 'text/uri-list'], {
|
|
48
|
-
input: uriListContent,
|
|
49
|
-
});
|
|
50
|
-
await Exec.exec('xclip', ['-i', '-selection', 'clipboard', '-t', 'text/plain'], {
|
|
51
|
-
input: plainContent,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
throw new VError(error, 'Failed to copy files to clipboard');
|
|
56
|
-
}
|
|
57
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as Desktop from '../Desktop/Desktop.js';
|
|
2
|
-
export const readFiles = async () => {
|
|
3
|
-
return {
|
|
4
|
-
source: 'notSupported',
|
|
5
|
-
type: 'none',
|
|
6
|
-
files: [],
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
export const writeFiles = (type, files) => {
|
|
10
|
-
const desktop = Desktop.getDesktop();
|
|
11
|
-
console.info(`writing files to clipboard is not yet supported on ${desktop}`);
|
|
12
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import clipboardEx from 'electron-clipboard-ex';
|
|
3
|
-
import { VError } from '../VError/VError.js';
|
|
4
|
-
export const readFiles = async () => {
|
|
5
|
-
const filePaths = clipboardEx.readFilePaths();
|
|
6
|
-
console.log(filePaths);
|
|
7
|
-
return {
|
|
8
|
-
source: 'electron-clipboard-ex',
|
|
9
|
-
type: 'copy', // TODO can't be sure on this
|
|
10
|
-
files: filePaths,
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export const writeFiles = async (type, files) => {
|
|
14
|
-
try {
|
|
15
|
-
clipboardEx.writeFilePaths(files);
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
throw new VError(error, 'Failed to copy files to clipboard');
|
|
19
|
-
}
|
|
20
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Writable } from 'node:stream';
|
|
2
|
-
import { pipeline } from 'node:stream/promises';
|
|
3
|
-
import * as EncodingType from '../EncodingType/EncodingType.js';
|
|
4
|
-
import * as GetNewLineIndex from '../GetNewLineIndex/GetNewLineIndex.js';
|
|
5
|
-
import * as RipGrepParsedLineType from '../RipGrepParsedLineType/RipGrepParsedLineType.js';
|
|
6
|
-
import * as TextSearchResultType from '../TextSearchResultType/TextSearchResultType.js';
|
|
7
|
-
import * as ToTextSearchResult from '../ToTextSearchResult/ToTextSearchResult.js';
|
|
8
|
-
// TODO update vscode-ripgrep when https://github.com/mhinz/vim-grepper/issues/244, https://github.com/BurntSushi/ripgrep/issues/1892 is fixed
|
|
9
|
-
// need to use '.' as last argument for ripgrep
|
|
10
|
-
// issue 1 https://github.com/nvim-telescope/telescope.nvim/pull/908/files
|
|
11
|
-
// issue 2 https://github.com/BurntSushi/ripgrep/issues/1892
|
|
12
|
-
// remove workaround when ripgrep is fixed
|
|
13
|
-
// TODO stats flag might not be necessary
|
|
14
|
-
// TODO update client
|
|
15
|
-
// TODO not always run nice, maybe configure nice via flag/options
|
|
16
|
-
export const collectStdout = async (childProcess, maxSearchResults, charsBefore, charsAfter) => {
|
|
17
|
-
const allSearchResults = Object.create(null);
|
|
18
|
-
let buffer = '';
|
|
19
|
-
let stats = {};
|
|
20
|
-
let limitHit = false;
|
|
21
|
-
let numberOfResults = 0;
|
|
22
|
-
childProcess.stdout.setEncoding(EncodingType.Utf8);
|
|
23
|
-
const handleLine = (line) => {
|
|
24
|
-
const parsedLine = JSON.parse(line);
|
|
25
|
-
const { type, data } = parsedLine;
|
|
26
|
-
switch (type) {
|
|
27
|
-
case RipGrepParsedLineType.Begin:
|
|
28
|
-
allSearchResults[data.path.text] = [
|
|
29
|
-
{
|
|
30
|
-
type: TextSearchResultType.File,
|
|
31
|
-
start: 0,
|
|
32
|
-
end: 0,
|
|
33
|
-
lineNumber: 0,
|
|
34
|
-
text: data.path.text,
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
break;
|
|
38
|
-
case RipGrepParsedLineType.Match:
|
|
39
|
-
const remaining = maxSearchResults - numberOfResults;
|
|
40
|
-
const matches = ToTextSearchResult.toTextSearchResult(parsedLine, remaining, charsBefore, charsAfter);
|
|
41
|
-
numberOfResults += matches.length;
|
|
42
|
-
allSearchResults[data.path.text].push(...matches);
|
|
43
|
-
break;
|
|
44
|
-
case RipGrepParsedLineType.Summary:
|
|
45
|
-
stats = data;
|
|
46
|
-
break;
|
|
47
|
-
default:
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const handleData = (chunk) => {
|
|
52
|
-
let newLineIndex = GetNewLineIndex.getNewLineIndex(chunk);
|
|
53
|
-
const dataString = buffer + chunk;
|
|
54
|
-
if (newLineIndex === -1) {
|
|
55
|
-
buffer = dataString;
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
newLineIndex += buffer.length;
|
|
59
|
-
let previousIndex = 0;
|
|
60
|
-
while (newLineIndex >= 0) {
|
|
61
|
-
const line = dataString.slice(previousIndex, newLineIndex);
|
|
62
|
-
handleLine(line);
|
|
63
|
-
previousIndex = newLineIndex + 1;
|
|
64
|
-
newLineIndex = GetNewLineIndex.getNewLineIndex(dataString, previousIndex);
|
|
65
|
-
}
|
|
66
|
-
buffer = dataString.slice(previousIndex);
|
|
67
|
-
if (numberOfResults > maxSearchResults) {
|
|
68
|
-
limitHit = true;
|
|
69
|
-
childProcess.kill();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
await pipeline(childProcess.stdout, new Writable({
|
|
73
|
-
decodeStrings: false,
|
|
74
|
-
construct(callback) {
|
|
75
|
-
callback();
|
|
76
|
-
},
|
|
77
|
-
write(chunk, encoding, callback) {
|
|
78
|
-
try {
|
|
79
|
-
handleData(chunk);
|
|
80
|
-
callback();
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
callback(error);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
}));
|
|
87
|
-
const results = Object.values(allSearchResults).flat(1);
|
|
88
|
-
return {
|
|
89
|
-
results,
|
|
90
|
-
stats,
|
|
91
|
-
limitHit,
|
|
92
|
-
};
|
|
93
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import * as RipGrep from '../RipGrep/RipGrep.js';
|
|
2
|
-
const connectProcess = (ipc, id, childProcess) => {
|
|
3
|
-
let count = 0;
|
|
4
|
-
const cleanup = () => {
|
|
5
|
-
childProcess.kill();
|
|
6
|
-
};
|
|
7
|
-
childProcess.stdout.on('data', (data) => {
|
|
8
|
-
count++;
|
|
9
|
-
if (count > 20) {
|
|
10
|
-
cleanup();
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
// console.log({ data: data.toString() })
|
|
14
|
-
ipc.send({
|
|
15
|
-
jsonrpc: '2.0',
|
|
16
|
-
method: 'IncrementalTextSearch.handleData',
|
|
17
|
-
params: [id, data.toString()],
|
|
18
|
-
});
|
|
19
|
-
// emitter.dispatchEvent(new Event('data', x))
|
|
20
|
-
});
|
|
21
|
-
childProcess.on('exit', () => {
|
|
22
|
-
ipc.send({
|
|
23
|
-
jsonrpc: '2.0',
|
|
24
|
-
method: 'IncrementalTextSearch.handleExit',
|
|
25
|
-
params: [id],
|
|
26
|
-
});
|
|
27
|
-
// emitter.dispatchEvent(new Event('exit'))
|
|
28
|
-
});
|
|
29
|
-
childProcess.on('error', () => {
|
|
30
|
-
ipc.send({
|
|
31
|
-
jsonrpc: '2.0',
|
|
32
|
-
method: 'IncrementalTextSearch.handleError',
|
|
33
|
-
params: [id],
|
|
34
|
-
});
|
|
35
|
-
// emitter.dispatchEvent(new Event('error'))
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
export const start = async (ipc, id, { searchDir = '', maxSearchResults = 20_000, ripGrepArgs = [] } = {}) => {
|
|
39
|
-
console.log({ ipc });
|
|
40
|
-
const emitter = new EventTarget();
|
|
41
|
-
const childProcess = RipGrep.spawn(ripGrepArgs, {
|
|
42
|
-
cwd: searchDir,
|
|
43
|
-
});
|
|
44
|
-
console.log('start', { searchDir, ripGrepArgs, id });
|
|
45
|
-
connectProcess(ipc, id, childProcess);
|
|
46
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as EncodingType from '../EncodingType/EncodingType.js';
|
|
2
|
-
export const parseRipGrepLines = (parsedLineData) => {
|
|
3
|
-
if (parsedLineData.lines.text) {
|
|
4
|
-
return parsedLineData.lines.text;
|
|
5
|
-
}
|
|
6
|
-
if (parsedLineData.lines.bytes) {
|
|
7
|
-
return Buffer.from(parsedLineData.lines.bytes, EncodingType.Base64).toString();
|
|
8
|
-
}
|
|
9
|
-
throw new Error(`unable to parse line data`);
|
|
10
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { VError } from '@lvce-editor/verror';
|
|
2
|
-
import * as Exec from '../Exec/Exec.js';
|
|
3
|
-
import * as GetElectronRebuildPath from '../GetElectronRebuildPath/GetElectronRebuildPath.js';
|
|
4
|
-
/**
|
|
5
|
-
* @param {string} cwd
|
|
6
|
-
*/
|
|
7
|
-
export const rebuild = async (cwd) => {
|
|
8
|
-
try {
|
|
9
|
-
const electronRebuildPath = GetElectronRebuildPath.getElectronRebuildPath();
|
|
10
|
-
await Exec.exec(electronRebuildPath, [], {
|
|
11
|
-
cwd,
|
|
12
|
-
stdio: 'inherit',
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
throw new VError(error, `Failed to rebuild native module`);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { VError } from '@lvce-editor/verror';
|
|
2
|
-
import * as Exec from '../Exec/Exec.js';
|
|
3
|
-
/**
|
|
4
|
-
* @param {string} cwd
|
|
5
|
-
*/
|
|
6
|
-
export const rebuild = async (cwd) => {
|
|
7
|
-
try {
|
|
8
|
-
await Exec.exec('npm', ['rebuild'], {
|
|
9
|
-
cwd,
|
|
10
|
-
stdio: 'inherit',
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
throw new VError(error, `Failed to rebuild native module`);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as NodeChildProcess from 'node:child_process';
|
|
2
|
-
import * as Assert from '../Assert/Assert.js';
|
|
3
|
-
import * as Env from '../Env/Env.js';
|
|
4
|
-
import * as Exec from '../Exec/Exec.js';
|
|
5
|
-
import * as RgPath from '../RipGrepPath/RipGrepPath.js';
|
|
6
|
-
import { VError } from '../VError/VError.js';
|
|
7
|
-
export const ripGrepPath = Env.getRipGrepPath() || RgPath.rgPath;
|
|
8
|
-
export const spawn = (args, options) => {
|
|
9
|
-
try {
|
|
10
|
-
const childProcess = NodeChildProcess.spawn(RgPath.rgPath, args, options);
|
|
11
|
-
return {
|
|
12
|
-
childProcess,
|
|
13
|
-
on(event, listener) {
|
|
14
|
-
this.childProcess.on(event, listener);
|
|
15
|
-
},
|
|
16
|
-
off(event, listener) {
|
|
17
|
-
this.childProcess.off(event, listener);
|
|
18
|
-
},
|
|
19
|
-
once(event, listener) {
|
|
20
|
-
this.childProcess.once(event, listener);
|
|
21
|
-
},
|
|
22
|
-
stdout: childProcess.stdout,
|
|
23
|
-
stderr: childProcess.stderr,
|
|
24
|
-
kill() {
|
|
25
|
-
this.childProcess.kill();
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
throw new VError(error, `Failed to spawn ripgrep`);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export const exec = async (args, options) => {
|
|
34
|
-
Assert.array(args);
|
|
35
|
-
Assert.object(options);
|
|
36
|
-
const { stdout, stderr } = await Exec.exec(ripGrepPath, args, options);
|
|
37
|
-
return { stdout, stderr };
|
|
38
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { rgPath } from '@lvce-editor/ripgrep';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as Assert from '../Assert/Assert.js';
|
|
2
|
-
import * as Character from '../Character/Character.js';
|
|
3
|
-
import * as IsEnoentError from '../IsEnoentError/IsEnoentError.js';
|
|
4
|
-
import * as LimitString from '../LimitString/LimitString.js';
|
|
5
|
-
import * as Logger from '../Logger/Logger.js';
|
|
6
|
-
import * as RipGrep from '../RipGrep/RipGrep.js';
|
|
7
|
-
// TODO don't necessarily need ripgrep to list all the files,
|
|
8
|
-
// maybe also a faster c program can do it
|
|
9
|
-
// another option would be to cache the results in renderer-worker and
|
|
10
|
-
// do a delta comparison, so the first time it would send 100kB
|
|
11
|
-
// but the second time only a few hundred bytes of changes
|
|
12
|
-
export const searchFile = async ({ searchPath = '', limit = 100, ripGrepArgs = [] }) => {
|
|
13
|
-
try {
|
|
14
|
-
Assert.string(searchPath);
|
|
15
|
-
Assert.array(ripGrepArgs);
|
|
16
|
-
Assert.number(limit);
|
|
17
|
-
const { stdout, stderr } = await RipGrep.exec(ripGrepArgs, {
|
|
18
|
-
cwd: searchPath,
|
|
19
|
-
});
|
|
20
|
-
return LimitString.limitString(stdout, limit);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
if (IsEnoentError.isEnoentError(error)) {
|
|
24
|
-
Logger.info(`[shared-process] ripgrep could not be found at "${RipGrep.ripGrepPath}"`);
|
|
25
|
-
return Character.EmptyString;
|
|
26
|
-
}
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
if (error && error.stderr === Character.EmptyString) {
|
|
29
|
-
return Character.EmptyString;
|
|
30
|
-
}
|
|
31
|
-
Logger.error(error);
|
|
32
|
-
return Character.EmptyString;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as CollectTextSearchStdout from '../CollectTextSearchStdout/CollectTextSearchStdout.js';
|
|
2
|
-
import * as ProcessExitEventType from '../ProcessExitEventType/ProcessExitEventType.js';
|
|
3
|
-
import * as RipGrep from '../RipGrep/RipGrep.js';
|
|
4
|
-
import { TextSearchError } from '../TextSearchError/TextSearchError.js';
|
|
5
|
-
import * as WaitForProcessToExit from '../WaitForProcessToExit/WaitForProcessToExit.js';
|
|
6
|
-
// TODO update vscode-ripgrep when https://github.com/mhinz/vim-grepper/issues/244, https://github.com/BurntSushi/ripgrep/issues/1892 is fixed
|
|
7
|
-
// need to use '.' as last argument for ripgrep
|
|
8
|
-
// issue 1 https://github.com/nvim-telescope/telescope.nvim/pull/908/files
|
|
9
|
-
// issue 2 https://github.com/BurntSushi/ripgrep/issues/1892
|
|
10
|
-
// remove workaround when ripgrep is fixed
|
|
11
|
-
// TODO stats flag might not be necessary
|
|
12
|
-
// TODO update client
|
|
13
|
-
// TODO not always run nice, maybe configure nice via flag/options
|
|
14
|
-
export const search = async ({ searchDir = '', maxSearchResults = 20_000, ripGrepArgs = [] } = {}) => {
|
|
15
|
-
const charsBefore = 26;
|
|
16
|
-
const charsAfter = 50;
|
|
17
|
-
const childProcess = RipGrep.spawn(ripGrepArgs, {
|
|
18
|
-
cwd: searchDir,
|
|
19
|
-
});
|
|
20
|
-
const pipeLinePromise = CollectTextSearchStdout.collectStdout(childProcess, maxSearchResults, charsBefore, charsAfter);
|
|
21
|
-
const closePromise = WaitForProcessToExit.waitForProcessToExit(childProcess);
|
|
22
|
-
const [pipeLineResult, exitResult] = await Promise.all([pipeLinePromise, closePromise]);
|
|
23
|
-
if (exitResult.type === ProcessExitEventType.Error) {
|
|
24
|
-
throw new TextSearchError(exitResult.event);
|
|
25
|
-
}
|
|
26
|
-
return pipeLineResult;
|
|
27
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js';
|
|
2
|
-
import * as IsEnoentError from '../IsEnoentError/IsEnoentError.js';
|
|
3
|
-
export class TextSearchError extends Error {
|
|
4
|
-
constructor(cause) {
|
|
5
|
-
if (IsEnoentError.isEnoentError(cause)) {
|
|
6
|
-
super(`ripgrep path not found: ${cause}`);
|
|
7
|
-
this.code = ErrorCodes.E_RIP_GREP_NOT_FOUND;
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
super(`ripgrep process error: ${cause}`);
|
|
11
|
-
this.code = cause.code;
|
|
12
|
-
}
|
|
13
|
-
this.name = 'TextSearchError';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as ParseRipGrepLines from '../ParseRipGrepLines/ParseRipGrepLines.js';
|
|
2
|
-
import * as TextSearchResultType from '../TextSearchResultType/TextSearchResultType.js';
|
|
3
|
-
export const toTextSearchResult = (parsedLine, remaining, charsBefore, charsAfter) => {
|
|
4
|
-
const results = [];
|
|
5
|
-
const parsedLineData = parsedLine.data;
|
|
6
|
-
const lines = ParseRipGrepLines.parseRipGrepLines(parsedLineData);
|
|
7
|
-
const lineNumber = parsedLineData.line_number;
|
|
8
|
-
const { submatches } = parsedLineData;
|
|
9
|
-
const linesLength = lines.length;
|
|
10
|
-
for (const submatch of submatches) {
|
|
11
|
-
const previewStart = Math.max(submatch.start - charsBefore, 0);
|
|
12
|
-
const actualStart = previewStart;
|
|
13
|
-
const previewEnd = Math.min(submatch.end + charsAfter, linesLength);
|
|
14
|
-
const previewText = lines.slice(actualStart, previewEnd);
|
|
15
|
-
results.push({
|
|
16
|
-
type: TextSearchResultType.Match,
|
|
17
|
-
start: submatch.start - actualStart,
|
|
18
|
-
end: submatch.end - actualStart,
|
|
19
|
-
lineNumber,
|
|
20
|
-
text: previewText,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return results;
|
|
24
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@lvce-editor/web-socket-server';
|