From d353c68a751f5154739b1374a2ad58bb126e3e00 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 1 Jul 2021 09:11:42 +0100 Subject: [PATCH] Convert preload.js to Typescript so that it gets copied to `lib` where we expect it --- src/{preload.js => preload.ts} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename src/{preload.js => preload.ts} (86%) diff --git a/src/preload.js b/src/preload.ts similarity index 86% rename from src/preload.js rename to src/preload.ts index 64849f5..491e8b9 100644 --- a/src/preload.js +++ b/src/preload.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -const { ipcRenderer, desktopCapturer, contextBridge } = require('electron'); +import { ipcRenderer, desktopCapturer, contextBridge, IpcRendererEvent, SourcesOptions } from 'electron'; // Expose only expected IPC wrapper APIs to the renderer process to avoid // handing out generalised messaging access. @@ -39,21 +39,21 @@ const CHANNELS = [ contextBridge.exposeInMainWorld( "electron", { - on(channel, listener) { + on(channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void) { if (!CHANNELS.includes(channel)) { console.error(`Unknown IPC channel ${channel} ignored`); return; } ipcRenderer.on(channel, listener); }, - send(channel, ...args) { + send(channel: string, ...args: any[]) { if (!CHANNELS.includes(channel)) { console.error(`Unknown IPC channel ${channel} ignored`); return; } ipcRenderer.send(channel, ...args); }, - async getDesktopCapturerSources(options) { + async getDesktopCapturerSources(options: SourcesOptions) { const sources = await desktopCapturer.getSources(options); const desktopCapturerSources = [];