-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create IPC module and refractored systemInfo and updateInfo
- Loading branch information
Showing
11 changed files
with
165 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class IPC { | ||
constructor(channels) { | ||
this.nameAPI = "api"; | ||
this.validSendChannel = {}; | ||
this.validReceiveChannel = []; | ||
this.nameAPI = channels.nameAPI; | ||
this.validSendChannel = channels.validSendChannel; | ||
this.validReceiveChannel = channels.validReceiveChannel; | ||
} | ||
get channels() { | ||
return { | ||
nameAPI: this.nameAPI, | ||
validSendChannel: this.validSendChannel, | ||
validReceiveChannel: this.validReceiveChannel | ||
}; | ||
} | ||
initIpcMain(ipcMain, mainWindow) { | ||
if (mainWindow) { | ||
Object.keys(this.validSendChannel).forEach(key => { | ||
ipcMain.on(key, async (event, message) => { | ||
this.validSendChannel[key](mainWindow, event, message); | ||
}); | ||
}); | ||
} | ||
} | ||
} | ||
exports.default = IPC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"description": "Memento: how to use Svelte with Electron and TypeScript", | ||
"author": "Samuele de Tomasi <[email protected]>", | ||
"license": "MIT", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"nodemon": "nodemon", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { BrowserWindow, IpcMain } from "electron"; | ||
import { APIChannels, SendChannels } from "./channelsInterface"; | ||
|
||
export default class IPC { | ||
nameAPI: string = "api"; | ||
validSendChannel: SendChannels = {}; | ||
validReceiveChannel: string[] = []; | ||
|
||
constructor(channels: APIChannels) { | ||
this.nameAPI = channels.nameAPI; | ||
this.validSendChannel = channels.validSendChannel; | ||
this.validReceiveChannel = channels.validReceiveChannel; | ||
} | ||
|
||
get channels():APIChannels { | ||
return { | ||
nameAPI: this.nameAPI, | ||
validSendChannel: this.validSendChannel, | ||
validReceiveChannel: this.validReceiveChannel | ||
} | ||
} | ||
|
||
initIpcMain(ipcMain:IpcMain, mainWindow: BrowserWindow) { | ||
if (mainWindow) { | ||
Object.keys(this.validSendChannel).forEach(key => { | ||
ipcMain.on(key, async( event, message) => { | ||
this.validSendChannel[key](mainWindow, event, message); | ||
}); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { generateContextBridge } from "./IPC/General/contextBridge" | ||
|
||
import * as systemInfo from "./IPC/systemInfo"; | ||
import * as updaterInfo from "./IPC/updaterInfo"; | ||
import systemInfo from "./IPC/systemInfo"; | ||
import updaterInfo from './IPC/updaterInfo'; | ||
|
||
generateContextBridge([systemInfo.channels, updaterInfo.channels]); | ||
generateContextBridge([systemInfo, updaterInfo]); |