@lvce-editor/search-process 3.2.0 → 4.0.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/package.json +7 -6
- package/src/parts/HandleElectronMessagePort/HandleElectronMessagePort.js +1 -3
- package/src/parts/HandleWebSocket/HandleWebSocket.js +1 -3
- package/src/parts/IpcChild/IpcChild.js +2 -9
- package/src/parts/IpcChildModule/IpcChildModule.js +11 -11
- package/src/parts/Listen/Listen.js +5 -3
- package/src/parts/Main/Main.js +0 -3
- package/src/parts/Callback/Callback.js +0 -1
- package/src/parts/Command/Command.js +0 -9
- package/src/parts/CommandState/CommandState.js +0 -17
- package/src/parts/HandleIpc/HandleIpc.js +0 -10
- package/src/parts/HandleMessage/HandleMessage.js +0 -19
- package/src/parts/JsonRpc/JsonRpc.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/search-process",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Search Process",
|
|
5
5
|
"main": "src/searchProcessMain.js",
|
|
6
6
|
"bin": "./bin/searchProcess.js",
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@lvce-editor/assert": "^1.3.0",
|
|
22
|
-
"@lvce-editor/
|
|
23
|
-
"@lvce-editor/
|
|
24
|
-
"@lvce-editor/
|
|
25
|
-
"
|
|
22
|
+
"@lvce-editor/rpc": "^1.10.1",
|
|
23
|
+
"@lvce-editor/ipc": "^11.4.0",
|
|
24
|
+
"@lvce-editor/json-rpc": "^5.2.0",
|
|
25
|
+
"@lvce-editor/verror": "^1.6.0",
|
|
26
|
+
"execa": "^9.5.1"
|
|
26
27
|
},
|
|
27
28
|
"optionalDependencies": {
|
|
28
|
-
"@lvce-editor/ripgrep": "^1.
|
|
29
|
+
"@lvce-editor/ripgrep": "^1.4.0"
|
|
29
30
|
},
|
|
30
31
|
"xo": {
|
|
31
32
|
"rules": {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import * as HandleIpc from '../HandleIpc/HandleIpc.js'
|
|
3
2
|
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
4
3
|
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
5
4
|
|
|
6
5
|
export const handleElectronMessagePort = async (messagePort, ...params) => {
|
|
7
6
|
Assert.object(messagePort)
|
|
8
|
-
|
|
7
|
+
await IpcChild.listen({
|
|
9
8
|
method: IpcChildType.ElectronMessagePort,
|
|
10
9
|
messagePort,
|
|
11
10
|
})
|
|
12
|
-
HandleIpc.handleIpc(ipc)
|
|
13
11
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import * as HandleIpc from '../HandleIpc/HandleIpc.js'
|
|
3
2
|
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
4
3
|
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
5
4
|
|
|
6
5
|
export const handleWebSocket = async (handle, request) => {
|
|
7
6
|
Assert.object(handle)
|
|
8
7
|
Assert.object(request)
|
|
9
|
-
|
|
8
|
+
await IpcChild.listen({
|
|
10
9
|
method: IpcChildType.WebSocket,
|
|
11
10
|
request,
|
|
12
11
|
handle,
|
|
13
12
|
})
|
|
14
|
-
HandleIpc.handleIpc(ipc)
|
|
15
13
|
}
|
|
@@ -3,13 +3,6 @@ import * as IpcChildModule from '../IpcChildModule/IpcChildModule.js'
|
|
|
3
3
|
export const listen = async ({ method, ...params }) => {
|
|
4
4
|
const module = await IpcChildModule.getModule(method)
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
if (module.signal) {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
module.signal(rawIpc)
|
|
11
|
-
}
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
const ipc = module.wrap(rawIpc)
|
|
14
|
-
return ipc
|
|
6
|
+
const rpc = await module.listen(params)
|
|
7
|
+
return rpc
|
|
15
8
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@lvce-editor/
|
|
2
|
+
ElectronMessagePortRpcClient,
|
|
3
|
+
ElectronUtilityProcessRpcClient,
|
|
4
|
+
NodeForkedProcessRpcClient,
|
|
5
|
+
NodeWebSocketRpcClient,
|
|
6
|
+
NodeWorkerRpcClient,
|
|
7
|
+
} from '@lvce-editor/rpc'
|
|
8
8
|
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
9
9
|
|
|
10
10
|
export const getModule = (method) => {
|
|
11
11
|
switch (method) {
|
|
12
12
|
case IpcChildType.NodeForkedProcess:
|
|
13
|
-
return
|
|
13
|
+
return NodeForkedProcessRpcClient
|
|
14
14
|
case IpcChildType.NodeWorker:
|
|
15
|
-
return
|
|
15
|
+
return NodeWorkerRpcClient
|
|
16
16
|
case IpcChildType.ElectronUtilityProcess:
|
|
17
|
-
return
|
|
17
|
+
return ElectronUtilityProcessRpcClient
|
|
18
18
|
case IpcChildType.ElectronMessagePort:
|
|
19
|
-
return
|
|
19
|
+
return ElectronMessagePortRpcClient
|
|
20
20
|
case IpcChildType.WebSocket:
|
|
21
|
-
return
|
|
21
|
+
return NodeWebSocketRpcClient
|
|
22
22
|
default:
|
|
23
23
|
throw new Error('unexpected ipc type')
|
|
24
24
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as CommandMap from '../CommandMap/CommandMap.ts'
|
|
2
2
|
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
3
3
|
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
4
4
|
|
|
5
5
|
export const listen = async () => {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
await IpcChild.listen({
|
|
7
|
+
method: IpcChildType.Auto(),
|
|
8
|
+
commandMap: CommandMap.commandMap,
|
|
9
|
+
})
|
|
8
10
|
}
|
package/src/parts/Main/Main.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import * as CommandMap from '../CommandMap/CommandMap.js'
|
|
2
|
-
import * as CommandState from '../CommandState/CommandState.js'
|
|
3
1
|
import * as Listen from '../Listen/Listen.js'
|
|
4
2
|
|
|
5
3
|
export const main = async () => {
|
|
6
|
-
CommandState.registerCommands(CommandMap.commandMap)
|
|
7
4
|
await Listen.listen()
|
|
8
5
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { resolve } from '@lvce-editor/json-rpc'
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const state = {
|
|
2
|
-
commands: Object.create(null),
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
const registerCommand = (key, fn) => {
|
|
6
|
-
state.commands[key] = fn
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const registerCommands = (commandMap) => {
|
|
10
|
-
for (const [key, value] of Object.entries(commandMap)) {
|
|
11
|
-
registerCommand(key, value)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const getCommand = (key) => {
|
|
16
|
-
return state.commands[key]
|
|
17
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as HandleMessage from '../HandleMessage/HandleMessage.js'
|
|
2
|
-
|
|
3
|
-
export const handleIpc = (ipc) => {
|
|
4
|
-
if ('addEventListener' in ipc) {
|
|
5
|
-
ipc.addEventListener('message', HandleMessage.handleMessage)
|
|
6
|
-
} else if ('on' in ipc) {
|
|
7
|
-
// deprecated
|
|
8
|
-
ipc.on('message', HandleMessage.handleMessage)
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as Callback from '../Callback/Callback.js'
|
|
2
|
-
import * as Command from '../Command/Command.js'
|
|
3
|
-
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
|
|
4
|
-
|
|
5
|
-
const preparePrettyError = (error) => {
|
|
6
|
-
return error
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const logError = (error) => {
|
|
10
|
-
console.error(error)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const requiresSocket = () => {
|
|
14
|
-
return false
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const handleMessage = (event) => {
|
|
18
|
-
return JsonRpc.handleJsonRpcMessage(event.target, event.data, Command.execute, Callback.resolve, preparePrettyError, logError, requiresSocket)
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@lvce-editor/json-rpc'
|