@vueuse/electron 10.2.1 → 10.3.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 (3) hide show
  1. package/index.d.cts +140 -0
  2. package/index.d.mts +140 -0
  3. package/package.json +3 -4
package/index.d.cts ADDED
@@ -0,0 +1,140 @@
1
+ import { IpcRendererEvent, IpcRenderer, WebFrame } from 'electron';
2
+ import { Ref } from 'vue-demi';
3
+ import { MaybeRef } from '@vueuse/shared';
4
+
5
+ type IpcRendererListener = (event: IpcRendererEvent, ...args: any[]) => void;
6
+
7
+ /**
8
+ * Result from useIpcRenderer
9
+ *
10
+ * @see https://www.electronjs.org/docs/api/ipc-renderer
11
+ */
12
+ interface UseIpcRendererReturn {
13
+ /**
14
+ * Listens to channel, when a new message arrives listener would be called with listener(event, args...).
15
+ * [ipcRenderer.removeListener](https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener) automatically on unmounted.
16
+ *
17
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereronchannel-listener
18
+ */
19
+ on(channel: string, listener: IpcRendererListener): IpcRenderer;
20
+ /**
21
+ * Adds a one time listener function for the event. This listener is invoked only the next time a message is sent to channel, after which it is removed.
22
+ *
23
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereroncechannel-listener
24
+ */
25
+ once(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): IpcRenderer;
26
+ /**
27
+ * Removes the specified listener from the listener array for the specified channel.
28
+ *
29
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener
30
+ */
31
+ removeListener(channel: string, listener: (...args: any[]) => void): IpcRenderer;
32
+ /**
33
+ * Removes all listeners, or those of the specified channel.
34
+ *
35
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovealllistenerschannel
36
+ */
37
+ removeAllListeners(channel: string): IpcRenderer;
38
+ /**
39
+ * Send an asynchronous message to the main process via channel, along with arguments.
40
+ *
41
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendchannel-args
42
+ */
43
+ send(channel: string, ...args: any[]): void;
44
+ /**
45
+ * Returns Promise<any> - Resolves with the response from the main process.
46
+ * Send a message to the main process via channel and expect a result ~~asynchronously~~.
47
+ * As composition-api, it makes asynchronous operations look like synchronous.
48
+ *
49
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args
50
+ */
51
+ invoke<T>(channel: string, ...args: any[]): Ref<T | null>;
52
+ /**
53
+ * Returns any - The value sent back by the ipcMain handler.
54
+ * Send a message to the main process via channel and expect a result synchronously.
55
+ *
56
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendsyncchannel-args
57
+ */
58
+ sendSync<T>(channel: string, ...args: any[]): Ref<T | null>;
59
+ /**
60
+ * Send a message to the main process, optionally transferring ownership of zero or more MessagePort objects.
61
+ *
62
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererpostmessagechannel-message-transfer
63
+ */
64
+ postMessage(channel: string, message: any, transfer?: MessagePort[]): void;
65
+ /**
66
+ * Sends a message to a window with webContentsId via channel.
67
+ *
68
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendtowebcontentsid-channel-args
69
+ */
70
+ sendTo(webContentsId: number, channel: string, ...args: any[]): void;
71
+ /**
72
+ * Like ipcRenderer.send but the event will be sent to the <webview> element in the host page instead of the main process.
73
+ *
74
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendtohostchannel-args
75
+ */
76
+ sendToHost(channel: string, ...args: any[]): void;
77
+ }
78
+ /**
79
+ * Get the `ipcRenderer` module with all APIs.
80
+ *
81
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendtohostchannel-args
82
+ * @see https://vueuse.org/useIpcRenderer
83
+ */
84
+ declare function useIpcRenderer(ipcRenderer?: IpcRenderer): UseIpcRendererReturn;
85
+
86
+ /**
87
+ * Returns Promise<any> - Resolves with the response from the main process.
88
+ *
89
+ * Send a message to the main process via channel and expect a result ~~asynchronously~~. As composition-api, it makes asynchronous operations look like synchronous.
90
+ *
91
+ * You need to provide `ipcRenderer` to this function.
92
+ *
93
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args
94
+ * @see https://vueuse.org/useIpcRendererInvoke
95
+ */
96
+ declare function useIpcRendererInvoke<T>(ipcRenderer: IpcRenderer, channel: string, ...args: any[]): Ref<T | null>;
97
+ /**
98
+ * Returns Promise<any> - Resolves with the response from the main process.
99
+ *
100
+ * Send a message to the main process via channel and expect a result ~~asynchronously~~. As composition-api, it makes asynchronous operations look like synchronous.
101
+ *
102
+ * `ipcRenderer` will be automatically gotten.
103
+ *
104
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args
105
+ * @see https://vueuse.org/useIpcRendererInvoke
106
+ */
107
+ declare function useIpcRendererInvoke<T>(channel: string, ...args: any[]): Ref<T | null>;
108
+
109
+ /**
110
+ * Listens to channel, when a new message arrives listener would be called with listener(event, args...).
111
+ * [ipcRenderer.removeListener](https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener) automatically on unmounted.
112
+ *
113
+ * You need to provide `ipcRenderer` to this function.
114
+ *
115
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereronchannel-listener
116
+ * @see https://vueuse.org/useIpcRendererOn
117
+ */
118
+ declare function useIpcRendererOn(ipcRenderer: IpcRenderer, channel: string, listener: IpcRendererListener): IpcRenderer;
119
+ /**
120
+ * Listens to channel, when a new message arrives listener would be called with listener(event, args...).
121
+ * [ipcRenderer.removeListener](https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener) automatically on unmounted.
122
+ *
123
+ * `ipcRenderer` will be automatically gotten.
124
+ *
125
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereronchannel-listener
126
+ * @see https://vueuse.org/useIpcRendererOn
127
+ */
128
+ declare function useIpcRendererOn(channel: string, listener: IpcRendererListener): IpcRenderer;
129
+
130
+ declare function useZoomFactor(factor: MaybeRef<number>): Ref<number>;
131
+ declare function useZoomFactor(webFrame: WebFrame, factor: MaybeRef<number>): Ref<number>;
132
+ declare function useZoomFactor(webFrame: WebFrame): Ref<number>;
133
+ declare function useZoomFactor(): Ref<number>;
134
+
135
+ declare function useZoomLevel(level: MaybeRef<number>): Ref<number>;
136
+ declare function useZoomLevel(webFrame: WebFrame, level: MaybeRef<number>): Ref<number>;
137
+ declare function useZoomLevel(webFrame: WebFrame): Ref<number>;
138
+ declare function useZoomLevel(): Ref<number>;
139
+
140
+ export { UseIpcRendererReturn, useIpcRenderer, useIpcRendererInvoke, useIpcRendererOn, useZoomFactor, useZoomLevel };
package/index.d.mts ADDED
@@ -0,0 +1,140 @@
1
+ import { IpcRendererEvent, IpcRenderer, WebFrame } from 'electron';
2
+ import { Ref } from 'vue-demi';
3
+ import { MaybeRef } from '@vueuse/shared';
4
+
5
+ type IpcRendererListener = (event: IpcRendererEvent, ...args: any[]) => void;
6
+
7
+ /**
8
+ * Result from useIpcRenderer
9
+ *
10
+ * @see https://www.electronjs.org/docs/api/ipc-renderer
11
+ */
12
+ interface UseIpcRendererReturn {
13
+ /**
14
+ * Listens to channel, when a new message arrives listener would be called with listener(event, args...).
15
+ * [ipcRenderer.removeListener](https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener) automatically on unmounted.
16
+ *
17
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereronchannel-listener
18
+ */
19
+ on(channel: string, listener: IpcRendererListener): IpcRenderer;
20
+ /**
21
+ * Adds a one time listener function for the event. This listener is invoked only the next time a message is sent to channel, after which it is removed.
22
+ *
23
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereroncechannel-listener
24
+ */
25
+ once(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): IpcRenderer;
26
+ /**
27
+ * Removes the specified listener from the listener array for the specified channel.
28
+ *
29
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener
30
+ */
31
+ removeListener(channel: string, listener: (...args: any[]) => void): IpcRenderer;
32
+ /**
33
+ * Removes all listeners, or those of the specified channel.
34
+ *
35
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovealllistenerschannel
36
+ */
37
+ removeAllListeners(channel: string): IpcRenderer;
38
+ /**
39
+ * Send an asynchronous message to the main process via channel, along with arguments.
40
+ *
41
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendchannel-args
42
+ */
43
+ send(channel: string, ...args: any[]): void;
44
+ /**
45
+ * Returns Promise<any> - Resolves with the response from the main process.
46
+ * Send a message to the main process via channel and expect a result ~~asynchronously~~.
47
+ * As composition-api, it makes asynchronous operations look like synchronous.
48
+ *
49
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args
50
+ */
51
+ invoke<T>(channel: string, ...args: any[]): Ref<T | null>;
52
+ /**
53
+ * Returns any - The value sent back by the ipcMain handler.
54
+ * Send a message to the main process via channel and expect a result synchronously.
55
+ *
56
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendsyncchannel-args
57
+ */
58
+ sendSync<T>(channel: string, ...args: any[]): Ref<T | null>;
59
+ /**
60
+ * Send a message to the main process, optionally transferring ownership of zero or more MessagePort objects.
61
+ *
62
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererpostmessagechannel-message-transfer
63
+ */
64
+ postMessage(channel: string, message: any, transfer?: MessagePort[]): void;
65
+ /**
66
+ * Sends a message to a window with webContentsId via channel.
67
+ *
68
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendtowebcontentsid-channel-args
69
+ */
70
+ sendTo(webContentsId: number, channel: string, ...args: any[]): void;
71
+ /**
72
+ * Like ipcRenderer.send but the event will be sent to the <webview> element in the host page instead of the main process.
73
+ *
74
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendtohostchannel-args
75
+ */
76
+ sendToHost(channel: string, ...args: any[]): void;
77
+ }
78
+ /**
79
+ * Get the `ipcRenderer` module with all APIs.
80
+ *
81
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendtohostchannel-args
82
+ * @see https://vueuse.org/useIpcRenderer
83
+ */
84
+ declare function useIpcRenderer(ipcRenderer?: IpcRenderer): UseIpcRendererReturn;
85
+
86
+ /**
87
+ * Returns Promise<any> - Resolves with the response from the main process.
88
+ *
89
+ * Send a message to the main process via channel and expect a result ~~asynchronously~~. As composition-api, it makes asynchronous operations look like synchronous.
90
+ *
91
+ * You need to provide `ipcRenderer` to this function.
92
+ *
93
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args
94
+ * @see https://vueuse.org/useIpcRendererInvoke
95
+ */
96
+ declare function useIpcRendererInvoke<T>(ipcRenderer: IpcRenderer, channel: string, ...args: any[]): Ref<T | null>;
97
+ /**
98
+ * Returns Promise<any> - Resolves with the response from the main process.
99
+ *
100
+ * Send a message to the main process via channel and expect a result ~~asynchronously~~. As composition-api, it makes asynchronous operations look like synchronous.
101
+ *
102
+ * `ipcRenderer` will be automatically gotten.
103
+ *
104
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args
105
+ * @see https://vueuse.org/useIpcRendererInvoke
106
+ */
107
+ declare function useIpcRendererInvoke<T>(channel: string, ...args: any[]): Ref<T | null>;
108
+
109
+ /**
110
+ * Listens to channel, when a new message arrives listener would be called with listener(event, args...).
111
+ * [ipcRenderer.removeListener](https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener) automatically on unmounted.
112
+ *
113
+ * You need to provide `ipcRenderer` to this function.
114
+ *
115
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereronchannel-listener
116
+ * @see https://vueuse.org/useIpcRendererOn
117
+ */
118
+ declare function useIpcRendererOn(ipcRenderer: IpcRenderer, channel: string, listener: IpcRendererListener): IpcRenderer;
119
+ /**
120
+ * Listens to channel, when a new message arrives listener would be called with listener(event, args...).
121
+ * [ipcRenderer.removeListener](https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener) automatically on unmounted.
122
+ *
123
+ * `ipcRenderer` will be automatically gotten.
124
+ *
125
+ * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereronchannel-listener
126
+ * @see https://vueuse.org/useIpcRendererOn
127
+ */
128
+ declare function useIpcRendererOn(channel: string, listener: IpcRendererListener): IpcRenderer;
129
+
130
+ declare function useZoomFactor(factor: MaybeRef<number>): Ref<number>;
131
+ declare function useZoomFactor(webFrame: WebFrame, factor: MaybeRef<number>): Ref<number>;
132
+ declare function useZoomFactor(webFrame: WebFrame): Ref<number>;
133
+ declare function useZoomFactor(): Ref<number>;
134
+
135
+ declare function useZoomLevel(level: MaybeRef<number>): Ref<number>;
136
+ declare function useZoomLevel(webFrame: WebFrame, level: MaybeRef<number>): Ref<number>;
137
+ declare function useZoomLevel(webFrame: WebFrame): Ref<number>;
138
+ declare function useZoomLevel(): Ref<number>;
139
+
140
+ export { UseIpcRendererReturn, useIpcRenderer, useIpcRendererInvoke, useIpcRendererOn, useZoomFactor, useZoomLevel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueuse/electron",
3
- "version": "10.2.1",
3
+ "version": "10.3.0",
4
4
  "description": "Electron renderer process modules for VueUse",
5
5
  "author": "Archer Gu<https://github.com/ArcherGu>",
6
6
  "license": "MIT",
@@ -24,7 +24,6 @@
24
24
  "sideEffects": false,
25
25
  "exports": {
26
26
  ".": {
27
- "types": "./index.d.ts",
28
27
  "require": "./index.cjs",
29
28
  "import": "./index.mjs"
30
29
  },
@@ -32,12 +31,12 @@
32
31
  },
33
32
  "main": "./index.cjs",
34
33
  "module": "./index.mjs",
35
- "types": "./index.d.ts",
34
+ "types": "./index.d.cts",
36
35
  "peerDependencies": {
37
36
  "electron": ">=9.0.0"
38
37
  },
39
38
  "dependencies": {
40
- "@vueuse/shared": "10.2.1",
39
+ "@vueuse/shared": "10.3.0",
41
40
  "vue-demi": ">=0.14.5"
42
41
  },
43
42
  "devDependencies": {