@lvce-editor/extension-host-helper-process 0.11.2 → 0.11.3
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
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Command from '../Command/Command.js'
|
|
2
|
+
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
|
|
3
|
+
|
|
4
|
+
export const getResponse = async (message) => {
|
|
5
|
+
try {
|
|
6
|
+
const result = await Command.invoke(message.method, ...message.params)
|
|
7
|
+
return {
|
|
8
|
+
jsonrpc: JsonRpc.Version,
|
|
9
|
+
id: message.id,
|
|
10
|
+
result,
|
|
11
|
+
}
|
|
12
|
+
} catch (error) {
|
|
13
|
+
if (
|
|
14
|
+
error &&
|
|
15
|
+
error instanceof Error &&
|
|
16
|
+
error.message &&
|
|
17
|
+
error.message.startsWith('method not found')
|
|
18
|
+
) {
|
|
19
|
+
return {
|
|
20
|
+
jsonrpc: JsonRpc.Version,
|
|
21
|
+
id: message.id,
|
|
22
|
+
error: {
|
|
23
|
+
code: JsonRpc.ErrorMethodNotFound,
|
|
24
|
+
message: error.message,
|
|
25
|
+
data: error.stack,
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
jsonrpc: JsonRpc.Version,
|
|
31
|
+
id: message.id,
|
|
32
|
+
error,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/parts/Rpc/Rpc.js
CHANGED
|
@@ -1,43 +1,9 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
|
|
1
|
+
import * as GetResponse from '../GetResponse/GetResponse.js'
|
|
3
2
|
|
|
4
|
-
const getResponse = async (message) => {
|
|
5
|
-
try {
|
|
6
|
-
const result = await Command.invoke(message.method, ...message.params)
|
|
7
|
-
return {
|
|
8
|
-
jsonrpc: JsonRpc.Version,
|
|
9
|
-
id: message.id,
|
|
10
|
-
result,
|
|
11
|
-
}
|
|
12
|
-
} catch (error) {
|
|
13
|
-
if (
|
|
14
|
-
error &&
|
|
15
|
-
error instanceof Error &&
|
|
16
|
-
error.message &&
|
|
17
|
-
error.message.startsWith('method not found')
|
|
18
|
-
) {
|
|
19
|
-
return {
|
|
20
|
-
jsonrpc: JsonRpc.Version,
|
|
21
|
-
id: message.id,
|
|
22
|
-
error: {
|
|
23
|
-
code: JsonRpc.ErrorMethodNotFound,
|
|
24
|
-
message: error.message,
|
|
25
|
-
data: error.stack,
|
|
26
|
-
},
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
jsonrpc: JsonRpc.Version,
|
|
31
|
-
id: message.id,
|
|
32
|
-
error,
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
3
|
export const listen = (ipc) => {
|
|
37
4
|
const handleMessage = async (message) => {
|
|
38
5
|
if ('method' in message) {
|
|
39
|
-
const response = await getResponse(message)
|
|
40
|
-
console.log({ response })
|
|
6
|
+
const response = await GetResponse.getResponse(message)
|
|
41
7
|
ipc.send(response)
|
|
42
8
|
}
|
|
43
9
|
}
|