feat: migrate from electron-webpack to electron-forge

Electron upgrade : 10.1.3 => 13.1.7
Angular upgrade : 10.1.3 => 12.1.2
This commit is contained in:
Amadou Ada DIENE
2021-07-19 12:34:50 +02:00
parent 433dfeb7f5
commit 4fa2999961
83 changed files with 73637 additions and 13521 deletions

View File

@@ -0,0 +1,3 @@
preload.ts is the only file that matters in this directory.
The others files are not needed at all, but they are required for electron forge webpack config.

View File

@@ -0,0 +1,6 @@
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
margin: auto;
max-width: 38rem;
padding: 2rem;
}

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>💖 Hello World!</h1>
<p>Welcome to your Electron application.</p>
</body>
</html>

View File

@@ -0,0 +1,31 @@
/**
* This file will automatically be loaded by webpack and run in the "renderer" context.
* To learn more about the differences between the "main" and the "renderer" context in
* Electron, visit:
*
* https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
*
* By default, Node.js integration in this file is disabled. When enabling Node.js integration
* in a renderer process, please be aware of potential security implications. You can read
* more about security risks here:
*
* https://electronjs.org/docs/tutorial/security
*
* To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration`
* flag:
*
* ```
* // Create the browser window.
* mainWindow = new BrowserWindow({
* width: 800,
* height: 600,
* webPreferences: {
* nodeIntegration: true
* }
* });
* ```
*/
import './index.css';
console.log('👋 This message is being logged by "renderer.js", included via webpack');

View File

@@ -0,0 +1,32 @@
// To secure user platform when running renderer process stuff,
// Node.JS and Electron APIs are only available in this script
import { contextBridge, ipcRenderer } from "electron";
import { WindowApi, WindowApiConst } from "shared-lib";
// So we expose protected methods that allow the renderer process
// to use the ipcRenderer without exposing the entire object
const windowApi: WindowApi = {
send: (channel: any, ...data: any) => {
if (WindowApiConst.SENDING_SAFE_CHANNELS.includes(channel)) {
ipcRenderer.send(channel, ...data);
}
},
receive: (channel: string, func: (...data: any) => void) => {
if (WindowApiConst.RECEIVING_SAFE_CHANNELS.includes(channel)) {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(channel, (event, ...args) => func(...args));
}
},
};
declare const window: any;
if (process.env.X_NODE_ENV === "e2e-test") {
// Injecting windowApi directly
window.api = windowApi;
} else {
// ContextBridge API can only be used when contextIsolation is enabled
// which is normally the case except in e2e test mode
contextBridge.exposeInMainWorld("api", windowApi);
}
console.log("The preload script has been injected successfully.");