@lvce-editor/ipc 1.0.1 → 2.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/README.md +5 -4
- package/dist/index.js +7 -4
- package/dist/parts/GetUtilityProcessPortData/GetUtilityProcessPortData.js +10 -0
- package/package.json +1 -1
- package/dist/parts/IpcChild/IpcChild.js +0 -9
- package/dist/parts/IpcChildModule/IpcChildModule.js +0 -10
- package/dist/parts/IpcChildType/IpcChildType.js +0 -5
- package/dist/parts/IpcParent/IpcParent.js +0 -25
- package/dist/parts/IpcParentModule/IpcParentModule.js +0 -14
- package/dist/parts/IpcParentType/IpcParentType.js +0 -3
package/README.md
CHANGED
|
@@ -5,13 +5,14 @@ Inter Process Communiction for use in Lvce Editor.
|
|
|
5
5
|
### Usage
|
|
6
6
|
|
|
7
7
|
```js
|
|
8
|
-
import
|
|
8
|
+
import * as IpcParentWithElectronUtilityProcess from '@lvce-editor/ipc/dist/parts/IpcParentWithElectronUtilityProcess/IpcParentWithElectronUtilityProcess.js'
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
path: '/test/worker.js',
|
|
10
|
+
const rawIpc = await IpcParentWithElectronUtilityProcess.create({
|
|
11
|
+
path: '/test/utility-process.js',
|
|
13
12
|
})
|
|
14
13
|
|
|
14
|
+
const ipc = IpcParentWithElectronUtilityProcess.wrap(rawIpc)
|
|
15
|
+
|
|
15
16
|
ipc.send({
|
|
16
17
|
jsonrpc: '2.0',
|
|
17
18
|
method: 'readFile',
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export * as
|
|
2
|
-
export * as
|
|
3
|
-
export * as
|
|
4
|
-
export * as
|
|
1
|
+
export * as IpcChildWithElectronMessagePort from './parts/IpcChildWithElectronMessagePort/IpcChildWithElectronMessagePort.js'
|
|
2
|
+
export * as IpcChildWithElectronUtilityProcess from './parts/IpcChildWithElectronUtilityProcess/IpcChildWithElectronUtilityProcess.js'
|
|
3
|
+
export * as IpcChildWithNodeForkedProcess from './parts/IpcChildWithNodeForkedProcess/IpcChildWithNodeForkedProcess.js'
|
|
4
|
+
export * as IpcChildWithWebSocket from './parts/IpcChildWithWebSocket/IpcChildWithWebSocket.js'
|
|
5
|
+
export * as IpcParentWithElectronUtilityProcess from './parts/IpcParentWithElectronUtilityProcess/IpcParentWithElectronUtilityProcess.js'
|
|
6
|
+
export * as IpcParentWithNodeForkedProcess from './parts/IpcParentWithNodeForkedProcess/IpcParentWithNodeForkedProcess.js'
|
|
7
|
+
export * as IpcParentWithNodeWorker from './parts/IpcParentWithNodeWorker/IpcParentWithNodeWorker.js'
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as IpcChildModule from '../IpcChildModule/IpcChildModule.js'
|
|
2
|
-
|
|
3
|
-
export const listen = async ({ method, ...params }) => {
|
|
4
|
-
const module = await IpcChildModule.getModule(method)
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const rawIpc = await module.listen(params)
|
|
7
|
-
const ipc = module.wrap(rawIpc)
|
|
8
|
-
return ipc
|
|
9
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
2
|
-
|
|
3
|
-
export const getModule = (method) => {
|
|
4
|
-
switch (method) {
|
|
5
|
-
case IpcChildType.ElectronMessagePort:
|
|
6
|
-
return import('../IpcChildWithElectronMessagePort/IpcChildWithElectronMessagePort.js')
|
|
7
|
-
default:
|
|
8
|
-
throw new Error('unexpected ipc type')
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as IpcParentModule from '../IpcParentModule/IpcParentModule.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {*} param0
|
|
6
|
-
* @returns {Promise<any>}
|
|
7
|
-
*/
|
|
8
|
-
export const create = async ({ method, ...options }) => {
|
|
9
|
-
const module = await IpcParentModule.getModule(method)
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
const rawIpc = await module.create(options)
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
if (module.effects) {
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
module.effects({
|
|
16
|
-
rawIpc,
|
|
17
|
-
...options,
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
if (options.noReturn) {
|
|
21
|
-
return undefined
|
|
22
|
-
}
|
|
23
|
-
const ipc = module.wrap(rawIpc)
|
|
24
|
-
return ipc
|
|
25
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as IpcParentType from '../IpcParentType/IpcParentType.js'
|
|
2
|
-
|
|
3
|
-
export const getModule = (method) => {
|
|
4
|
-
switch (method) {
|
|
5
|
-
case IpcParentType.NodeWorker:
|
|
6
|
-
return import('../IpcParentWithNodeWorker/IpcParentWithNodeWorker.js')
|
|
7
|
-
case IpcParentType.NodeForkedProcess:
|
|
8
|
-
return import('../IpcParentWithNodeForkedProcess/IpcParentWithNodeForkedProcess.js')
|
|
9
|
-
case IpcParentType.ElectronUtilityProcess:
|
|
10
|
-
return import('../IpcParentWithElectronUtilityProcess/IpcParentWithElectronUtilityProcess.js')
|
|
11
|
-
default:
|
|
12
|
-
throw new Error(`unexpected ipc type ${method}`)
|
|
13
|
-
}
|
|
14
|
-
}
|