@lvce-editor/extension-host-helper-process 0.29.2 → 0.29.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-host-helper-process",
3
- "version": "0.29.2",
3
+ "version": "0.29.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -16,8 +16,6 @@ export const getModule = (method) => {
16
16
  return IpcChildWithElectronMessagePort
17
17
  case IpcChildType.ElectronUtilityProcess:
18
18
  return IpcChildWithElectronUtilityProcess
19
- case IpcChildType.ElectronUtilityProcessMessagePort:
20
- return import('../IpcChildWithElectronUtilityProcessMessagePort/IpcChildWithElectronUtilityProcessMessagePort.js')
21
19
  default:
22
20
  throw new Error('unexpected ipc type')
23
21
  }
@@ -1,39 +0,0 @@
1
- import * as GetUtilityProcessPortData from '../GetUtilityProcessPortData/GetUtilityProcessPortData.js'
2
- import { IpcError } from '../IpcError/IpcError.js'
3
- import * as IsMessagePortMain from '../IsMessagePortMain/IsMessagePortMain.js'
4
-
5
- export const listen = ({ messagePort }) => {
6
- if (!IsMessagePortMain.isMessagePortMain(messagePort)) {
7
- throw new IpcError('port must be of type MessagePortMain')
8
- }
9
- return messagePort
10
- }
11
-
12
- export const wrap = (messagePort) => {
13
- return {
14
- messagePort,
15
- on(event, listener) {
16
- if (event === 'message') {
17
- const wrappedListener = (event) => {
18
- const actualData = GetUtilityProcessPortData.getUtilityProcessPortData(event)
19
- listener(actualData)
20
- }
21
- this.messagePort.on(event, wrappedListener)
22
- } else {
23
- throw new Error('unsupported event type')
24
- }
25
- },
26
- off(event, listener) {
27
- this.messagePort.off(event, listener)
28
- },
29
- send(message) {
30
- this.messagePort.postMessage(message)
31
- },
32
- dispose() {
33
- this.messagePort.close()
34
- },
35
- start() {
36
- this.messagePort.start()
37
- },
38
- }
39
- }
@@ -1,8 +0,0 @@
1
- import { IpcChildWithElectronUtilityProcess } from '@lvce-editor/ipc'
2
-
3
- export const listen = IpcChildWithElectronUtilityProcess.listen
4
-
5
- export const wrap = IpcChildWithElectronUtilityProcess.wrap
6
-
7
- // @ts-ignore
8
- export const signal = IpcChildWithElectronUtilityProcess.signal
@@ -1,53 +0,0 @@
1
- import * as FirstUtilityProcessEventType from '../FirstUtilityProcessEventType/FirstUtilityProcessEventType.js'
2
- import * as getFirstUtilityProcessEvent from '../GetFirstUtilityProcessEvent/GetFirstUtilityProcessEvent.js'
3
- import * as IpcChildType from '../IpcChildType/IpcChildType.js'
4
- import * as IpcChildWithElectronUtilityProcess from '../IpcChildWithElectronUtilityProcess/IpcChildWithElectronUtilityProcess.js'
5
-
6
- // TODO remove this and use HandleElectronMessagePort function instead
7
- export const listen = async () => {
8
- const parentPort = IpcChildWithElectronUtilityProcess.listen()
9
- const { type, event } = await getFirstUtilityProcessEvent.getFirstUtilityProcessEvent(parentPort)
10
- if (type !== FirstUtilityProcessEventType.Message) {
11
- throw new Error('expected message event')
12
- }
13
- const { ports } = event
14
- if (ports.length === 0) {
15
- throw new Error(`expected message port to be passed`)
16
- }
17
- const port = ports[0]
18
- port.start()
19
- return port
20
- }
21
-
22
- export const wrap = (port) => {
23
- return {
24
- type: IpcChildType.ElectronUtilityProcessMessagePort,
25
- port,
26
- on(event, listener) {
27
- switch (event) {
28
- case 'message':
29
- const wrappedListener = (event) => {
30
- const syntheticEvent = {
31
- data: event.data,
32
- target: this,
33
- }
34
- listener(syntheticEvent)
35
- }
36
- this.port.on(event, wrappedListener)
37
- break
38
- default:
39
- this.port.on(event, listener)
40
- break
41
- }
42
- },
43
- off(event, listener) {
44
- this.port.off(event, listener)
45
- },
46
- send(message) {
47
- this.port.postMessage(message)
48
- },
49
- dispose() {
50
- this.port.close()
51
- },
52
- }
53
- }
@@ -1,46 +0,0 @@
1
- import { IpcError } from '../IpcError/IpcError.js'
2
-
3
- export const listen = async () => {
4
- if (!process.send) {
5
- throw new IpcError('process ipc is not available')
6
- }
7
- process.send('ready')
8
- return process
9
- }
10
-
11
- const getActualData = (message, handle) => {
12
- if (handle) {
13
- return {
14
- ...message,
15
- params: [...message.params, handle],
16
- }
17
- }
18
- return message
19
- }
20
-
21
- export const wrap = (process) => {
22
- return {
23
- process,
24
- send(message) {
25
- this.process.send(message)
26
- },
27
- on(event, listener) {
28
- if (event === 'message') {
29
- const wrappedListener = (message, handle) => {
30
- const actualData = getActualData(message, handle)
31
- listener(actualData)
32
- }
33
- this.process.on(event, wrappedListener)
34
- }
35
- },
36
- off(event, listener) {
37
- switch (event) {
38
- case 'message':
39
- this.process.off('message', listener)
40
- break
41
- default:
42
- throw new Error('unknown event listener type')
43
- }
44
- },
45
- }
46
- }
@@ -1,5 +0,0 @@
1
- import { IpcChildWithWebSocket } from '@lvce-editor/ipc'
2
-
3
- export const listen = IpcChildWithWebSocket.listen
4
-
5
- export const wrap = IpcChildWithWebSocket.wrap