@lvce-editor/extension-host-helper-process 0.53.5 → 0.53.7
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 +2 -4
- package/src/parts/CommandMapRef/CommandMapRef.js +1 -0
- package/src/parts/Listen/Listen.js +3 -1
- package/src/parts/LoadFile/LoadFile.js +5 -5
- package/src/parts/Command/Command.js +0 -10
- package/src/parts/CommandNotFoundError/CommandNotFoundError.js +0 -9
- package/src/parts/CommandState/CommandState.js +0 -43
- package/src/parts/FirstUtilityProcessEventType/FirstUtilityProcessEventType.js +0 -1
- package/src/parts/GetFirstUtilityProcessEvent/GetFirstUtilityProcessEvent.js +0 -21
- package/src/parts/GetUtilityProcessPortData/GetUtilityProcessPortData.js +0 -10
- package/src/parts/HandleIpc/HandleIpc.js +0 -10
- package/src/parts/HandleMessage/HandleMessage.js +0 -19
- package/src/parts/IsMessagePortMain/IsMessagePortMain.js +0 -3
- package/src/parts/JsonRpc/JsonRpc.js +0 -1
- package/src/parts/PrintPrettyError/PrintPrettyError.js +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/extension-host-helper-process",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,9 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@lvce-editor/assert": "^1.3.0",
|
|
20
|
-
"@lvce-editor/
|
|
21
|
-
"@lvce-editor/json-rpc": "^6.2.0",
|
|
22
|
-
"@lvce-editor/rpc": "^4.1.0",
|
|
20
|
+
"@lvce-editor/rpc": "^4.2.0",
|
|
23
21
|
"@lvce-editor/verror": "^1.7.0",
|
|
24
22
|
"execa": "^9.5.3",
|
|
25
23
|
"got": "^14.4.7",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const commandMapRef = {}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as CommandMap from '../CommandMap/CommandMap.js'
|
|
2
2
|
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
3
3
|
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
4
|
+
import * as CommandMapRef from '../CommandMapRef/CommandMapRef.js'
|
|
4
5
|
|
|
5
6
|
export const listen = async (argv) => {
|
|
7
|
+
Object.assign(CommandMapRef.commandMapRef, CommandMap.commandMap)
|
|
6
8
|
await IpcChild.listen({
|
|
7
9
|
method: IpcChildType.Auto(argv),
|
|
8
|
-
commandMap:
|
|
10
|
+
commandMap: CommandMapRef.commandMapRef,
|
|
9
11
|
})
|
|
10
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as CommandState from '../CommandState/CommandState.js'
|
|
3
|
-
import * as ImportScript from '../ImportScript/ImportScript.js'
|
|
1
|
+
import * as Command from '@lvce-editor/command'
|
|
4
2
|
import * as Assert from '../Assert/Assert.js'
|
|
3
|
+
import * as ImportScript from '../ImportScript/ImportScript.js'
|
|
4
|
+
import { VError } from '../VError/VError.js'
|
|
5
5
|
|
|
6
6
|
export const loadFile = async (path) => {
|
|
7
7
|
try {
|
|
@@ -9,9 +9,9 @@ export const loadFile = async (path) => {
|
|
|
9
9
|
const module = await ImportScript.importScript(path)
|
|
10
10
|
if (module && module.commandMap) {
|
|
11
11
|
const commandMap = module.commandMap
|
|
12
|
-
|
|
12
|
+
Command.register(commandMap)
|
|
13
13
|
} else if (module && module.execute) {
|
|
14
|
-
|
|
14
|
+
throw new Error(`execute function is not supported anymore. Use commandMap instead`)
|
|
15
15
|
} else {
|
|
16
16
|
throw new Error(`missing export const execute function`)
|
|
17
17
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CommandNotFoundError } from '../CommandNotFoundError/CommandNotFoundError.js'
|
|
2
|
-
import * as CommandState from '../CommandState/CommandState.js'
|
|
3
|
-
|
|
4
|
-
export const execute = (command, ...args) => {
|
|
5
|
-
const fn = CommandState.getCommand(command)
|
|
6
|
-
if (!fn) {
|
|
7
|
-
throw new CommandNotFoundError(command)
|
|
8
|
-
}
|
|
9
|
-
return fn(...args)
|
|
10
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import { VError } from '../VError/VError.js'
|
|
3
|
-
|
|
4
|
-
export const state = {
|
|
5
|
-
commands: Object.create(null),
|
|
6
|
-
/**
|
|
7
|
-
* @type {any}
|
|
8
|
-
*/
|
|
9
|
-
execute: undefined,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const registerCommand = (key, fn) => {
|
|
13
|
-
try {
|
|
14
|
-
Assert.string(key)
|
|
15
|
-
Assert.fn(fn)
|
|
16
|
-
state.commands[key] = fn
|
|
17
|
-
} catch (error) {
|
|
18
|
-
throw new VError(error, `Failed to register command ${key}`)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const registerCommands = (commandMap) => {
|
|
23
|
-
for (const [key, value] of Object.entries(commandMap)) {
|
|
24
|
-
registerCommand(key, value)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const getCommand = (key) => {
|
|
29
|
-
const { commands, execute } = state
|
|
30
|
-
if (key in commands) {
|
|
31
|
-
return commands[key]
|
|
32
|
-
}
|
|
33
|
-
if (execute) {
|
|
34
|
-
return (...args) => {
|
|
35
|
-
return execute(key, ...args)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return undefined
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const setExecute = (fn) => {
|
|
42
|
-
state.execute = fn
|
|
43
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const Message = 1
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as FirstUtilityProcessEventType from '../FirstUtilityProcessEventType/FirstUtilityProcessEventType.js'
|
|
2
|
-
|
|
3
|
-
export const getFirstUtilityProcessEvent = async (parentPort) => {
|
|
4
|
-
const { type, event } = await new Promise((resolve) => {
|
|
5
|
-
const cleanup = (value) => {
|
|
6
|
-
parentPort.off('message', handleMessage)
|
|
7
|
-
resolve(value)
|
|
8
|
-
}
|
|
9
|
-
const handleMessage = (event) => {
|
|
10
|
-
cleanup({
|
|
11
|
-
type: FirstUtilityProcessEventType.Message,
|
|
12
|
-
event,
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
parentPort.on('message', handleMessage)
|
|
16
|
-
})
|
|
17
|
-
return {
|
|
18
|
-
type,
|
|
19
|
-
event,
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -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 {
|
|
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, prettyError) => {
|
|
10
|
-
// this is handled by shared process
|
|
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'
|