@lvce-editor/extension-host-helper-process 0.15.15 → 0.15.17

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.15.15",
3
+ "version": "0.15.17",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1 @@
1
+ export const Message = 1
@@ -0,0 +1,21 @@
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,27 +1,12 @@
1
- import * as IpcChildWithElectronUtilityProcess from '../IpcChildWithElectronUtilityProcess/IpcChildWithElectronUtilityProcess.js'
1
+ import * as FirstUtilityProcessEventType from '../FirstUtilityProcessEventType/FirstUtilityProcessEventType.js'
2
+ import * as getFirstUtilityProcessEvent from '../GetFirstUtilityProcessEvent/GetFirstUtilityProcessEvent.js'
2
3
  import * as IpcChildType from '../IpcChildType/IpcChildType.js'
3
-
4
- const waitForFirstMessage = async (parentPort) => {
5
- const { type, event } = await new Promise((resolve) => {
6
- const cleanup = (value) => {
7
- parentPort.off('message', handleMessage)
8
- resolve(value)
9
- }
10
- const handleMessage = (event) => {
11
- cleanup({ type: 'message', event })
12
- }
13
- parentPort.on('message', handleMessage)
14
- })
15
- return {
16
- type,
17
- event,
18
- }
19
- }
4
+ import * as IpcChildWithElectronUtilityProcess from '../IpcChildWithElectronUtilityProcess/IpcChildWithElectronUtilityProcess.js'
20
5
 
21
6
  export const listen = async () => {
22
7
  const parentPort = IpcChildWithElectronUtilityProcess.listen()
23
- const { type, event } = await waitForFirstMessage(parentPort)
24
- if (type !== 'message') {
8
+ const { type, event } = await getFirstUtilityProcessEvent.getFirstUtilityProcessEvent(parentPort)
9
+ if (type !== FirstUtilityProcessEventType.Message) {
25
10
  throw new Error('expected message event')
26
11
  }
27
12
  const { ports } = event