@lvce-editor/ipc 13.1.0 → 13.2.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +48 -28
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,36 +1,56 @@
1
- interface Ipc extends EventTarget {
1
+ interface Ipc<T = any> extends EventTarget {
2
2
  readonly send: (message: any) => void
3
3
  readonly sendAndTransfer: (message: any, transfer: any) => void
4
- readonly dispose: () => void
5
- readonly isDisposed: () => void
4
+ readonly dispose: () => void | Promise<void>
5
+ readonly isDisposed: () => boolean
6
6
  }
7
7
 
8
- interface IpcChild {
9
- readonly listen: any
10
- readonly wrap: (rawIpc: any) => Ipc
8
+ interface IpcChild<WrapOptions = any, ListenOptions = any> {
9
+ readonly listen: (listenOptions: ListenOptions) => Promise<WrapOptions> | WrapOptions
10
+ readonly wrap: (rawIpc: WrapOptions) => Ipc<WrapOptions>
11
11
  }
12
12
 
13
- export const IpcChildWithElectronMessagePort: IpcChild
14
- export const IpcChildWithElectronUtilityProcess: IpcChild
15
- export const IpcChildWithNodeForkedProcess: IpcChild
16
- export const IpcChildWithWebSocket: IpcChild
17
- export const IpcChildWithNodeWorker: IpcChild
18
- export const IpcChildWithRendererProcess2: IpcChild
19
- export const IpcChildWithModuleWorkerAndMessagePort: IpcChild
20
- export const IpcChildWithModuleWorker: IpcChild
21
- export const IpcChildWithMessagePort: IpcChild
22
- export const IpcChildWithElectronWindow: IpcChild
23
-
24
- interface IpcParent {
25
- readonly create: any
26
- readonly wrap: (rawIpc: any) => Ipc
13
+ interface IpcParent<T = any> {
14
+ readonly create: (options: any) => Promise<T>
15
+ readonly wrap: (rawIpc: T) => Ipc<T>
27
16
  }
28
17
 
29
- export const IpcParentWithElectronUtilityProcess: IpcParent
30
- export const IpcParentWithNodeForkedProcess: IpcParent
31
- export const IpcParentWithNodeWorker: IpcParent
32
- export const IpcParentWithElectronMessagePort: IpcParent
33
- export const IpcParentWithMessagePort: IpcParent
34
- export const IpcParentWithWebSocket: IpcParent
35
- export const IpcParentWithModuleWorker: IpcParent
36
- export const IpcParentWithModuleWorkerAndWorkaroundForChromeDevtoolsBug: IpcParent
18
+ interface IpcChildWithMessagePortListenOptions {
19
+ readonly port: MessagePort
20
+ }
21
+
22
+ // MessagePort specific implementations
23
+ export const IpcChildWithMessagePort: IpcChild<MessagePort, IpcChildWithMessagePortListenOptions>
24
+ export const IpcParentWithMessagePort: IpcParent<MessagePort>
25
+
26
+ interface IpcChildWithElectronMessagePortListenOptions {
27
+ readonly messagePort: import('electron').MessagePortMain
28
+ }
29
+
30
+ interface IpcChildWithElectronUtilityProcessListenOptions {}
31
+
32
+ interface IpcChildWithElectronWindowListenOptions {}
33
+
34
+ // Electron specific implementations
35
+ export const IpcChildWithElectronMessagePort: IpcChild<import('electron').MessagePortMain, IpcChildWithElectronMessagePortListenOptions>
36
+ export const IpcChildWithElectronUtilityProcess: IpcChild<import('electron').MessagePortMain, IpcChildWithElectronUtilityProcessListenOptions>
37
+ export const IpcChildWithElectronWindow: IpcChild<Window, IpcChildWithElectronWindowListenOptions>
38
+
39
+ // Node specific implementations
40
+ export const IpcChildWithNodeWorker: IpcChild<import('worker_threads').MessagePort>
41
+ export const IpcChildWithNodeForkedProcess: IpcChild<import('child_process').ChildProcess>
42
+ export const IpcChildWithWebSocket: IpcChild<WebSocket>
43
+
44
+ // Web specific implementations
45
+ export const IpcChildWithModuleWorker: IpcChild<Worker>
46
+ export const IpcChildWithModuleWorkerAndMessagePort: IpcChild<MessagePort>
47
+ export const IpcChildWithRendererProcess2: IpcChild<MessagePort>
48
+
49
+ // Parent implementations
50
+ export const IpcParentWithElectronUtilityProcess: IpcParent<import('electron').MessagePortMain>
51
+ export const IpcParentWithNodeForkedProcess: IpcParent<import('child_process').ChildProcess>
52
+ export const IpcParentWithNodeWorker: IpcParent<import('worker_threads').Worker>
53
+ export const IpcParentWithElectronMessagePort: IpcParent<Electron.MessagePortMain>
54
+ export const IpcParentWithWebSocket: IpcParent<WebSocket>
55
+ export const IpcParentWithModuleWorker: IpcParent<Worker>
56
+ export const IpcParentWithModuleWorkerAndWorkaroundForChromeDevtoolsBug: IpcParent<Worker>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/ipc",
3
- "version": "13.1.0",
3
+ "version": "13.2.0",
4
4
  "description": "Inter Process Communication for Lvce Editor",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",