-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c25ddac
Showing
40 changed files
with
9,190 additions
and
0 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,16 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:import/recommended", | ||
"plugin:import/electron", | ||
"plugin:import/typescript" | ||
], | ||
"parser": "@typescript-eslint/parser" | ||
} |
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,89 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
.DS_Store | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# Webpack | ||
.webpack/ | ||
|
||
# Electron-Forge | ||
out/ |
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,22 @@ | ||
# Awesome Electron-Forge Boilerplate | ||
|
||
I created this boilerplate to start an Electron application using most popular tools: | ||
|
||
- [electron-forge](https://github.com/electron/forge) as base project | ||
- [electron-store](https://github.com/sindresorhus/electron-store) to be able to persist settings | ||
- [electron-log](https://github.com/megahertz/electron-log) to be able to show and persist logs | ||
- [@lpfreelance/electron-bridge](https://github.com/poirierlouis/electron-bridge) to be able to follow best security practices for Electron with easy! | ||
- [@timfish/webpack-asset-relocator-loader](https://github.com/poirierlouis/electron-bridge), fork of Vercel package to be able to include native_modules to the main process that works with Electron. | ||
|
||
Moreover the `webpack.(main|renderer).config.ts` files have been modified to be able to support electron-bridge (see [this](https://github.com/poirierlouis/electron-bridge/issues/3)) | ||
|
||
## Use this boilerplate | ||
|
||
To use this boilerplate for your next project use the Github UI to "Use as template" or just fork the repo. | ||
|
||
## Development | ||
|
||
- Install package: `yarn` | ||
- Generate bridge files from schema: `yarn run generate-schema` | ||
- Run dev mode: `yarn start` | ||
- Package app: `yarn run package` |
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,40 @@ | ||
import type { ForgeConfig } from "@electron-forge/shared-types"; | ||
import { MakerSquirrel } from "@electron-forge/maker-squirrel"; | ||
import { MakerZIP } from "@electron-forge/maker-zip"; | ||
import { MakerDeb } from "@electron-forge/maker-deb"; | ||
import { MakerRpm } from "@electron-forge/maker-rpm"; | ||
import { WebpackPlugin } from "@electron-forge/plugin-webpack"; | ||
|
||
import { mainConfig } from "./webpack.main.config"; | ||
import { rendererConfig } from "./webpack.renderer.config"; | ||
|
||
const config: ForgeConfig = { | ||
packagerConfig: {}, | ||
rebuildConfig: {}, | ||
makers: [ | ||
new MakerSquirrel({}), | ||
new MakerZIP({}, ["darwin"]), | ||
new MakerRpm({}), | ||
new MakerDeb({}), | ||
], | ||
plugins: [ | ||
new WebpackPlugin({ | ||
mainConfig, | ||
renderer: { | ||
config: rendererConfig, | ||
entryPoints: [ | ||
{ | ||
html: "./src/renderer/index.html", | ||
js: "./src/renderer/renderer.ts", | ||
name: "main_window", | ||
preload: { | ||
js: "./src/renderer/preload.ts", | ||
}, | ||
}, | ||
], | ||
}, | ||
}), | ||
], | ||
}; | ||
|
||
export default config; |
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,66 @@ | ||
{ | ||
"name": "forge-receiver", | ||
"productName": "forge-receiver", | ||
"version": "1.0.0", | ||
"description": "My Electron application description", | ||
"main": ".webpack/main", | ||
"scripts": { | ||
"generate-schema": "eb generate ./src/bridges/bridge.config.json", | ||
"start": "electron-forge start --inspect-electron", | ||
"package": "electron-forge package", | ||
"make": "electron-forge make", | ||
"publish": "electron-forge publish", | ||
"lint": "eslint --ext .ts,.tsx ." | ||
}, | ||
"keywords": [], | ||
"author": { | ||
"name": "Carmelo", | ||
"email": "[email protected]" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@electron-forge/cli": "^6.0.5", | ||
"@electron-forge/maker-deb": "^6.0.5", | ||
"@electron-forge/maker-rpm": "^6.0.5", | ||
"@electron-forge/maker-squirrel": "^6.0.5", | ||
"@electron-forge/maker-zip": "^6.0.5", | ||
"@electron-forge/plugin-webpack": "^6.0.5", | ||
"@lpfreelance/electron-bridge-cli": "^1.0.2", | ||
"@marshallofsound/webpack-asset-relocator-loader": "^0.5.0", | ||
"@timfish/webpack-asset-relocator-loader": "^0.1.0", | ||
"@types/react": "^18.0.28", | ||
"@types/react-dom": "^18.0.11", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"@typescript-eslint/parser": "^5.0.0", | ||
"@vercel/webpack-asset-relocator-loader": "1.7.3", | ||
"css-loader": "^6.0.0", | ||
"electron": "23.1.2", | ||
"eslint": "^8.0.1", | ||
"eslint-plugin-import": "^2.25.0", | ||
"fork-ts-checker-webpack-plugin": "^7.2.13", | ||
"node-loader": "^2.0.0", | ||
"style-loader": "^3.0.0", | ||
"ts-loader": "^9.2.2", | ||
"ts-node": "^10.0.0", | ||
"typescript": "~4.5.4" | ||
}, | ||
"dependencies": { | ||
"@emotion/react": "^11.10.6", | ||
"@emotion/styled": "^11.10.6", | ||
"@fontsource/public-sans": "^4.5.12", | ||
"@fortawesome/fontawesome-svg-core": "^6.3.0", | ||
"@fortawesome/free-regular-svg-icons": "^6.3.0", | ||
"@fortawesome/free-solid-svg-icons": "^6.3.0", | ||
"@fortawesome/react-fontawesome": "^0.2.0", | ||
"@lpfreelance/electron-bridge": "^1.0.2", | ||
"@mui/joy": "^5.0.0-alpha.69", | ||
"electron-log": "^5.0.0-beta.19", | ||
"electron-squirrel-startup": "^1.0.0", | ||
"electron-store": "^8.1.0", | ||
"node-opcua": "^2.91.1", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"serialport": "^10.5.0", | ||
"tiny-typed-emitter": "^2.1.0" | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"base": ".", | ||
"tsconfig": "tsconfig.json", | ||
"schemas": "src/bridges/schemas/", | ||
"output": "src/bridges/generated/", | ||
"main": false, | ||
"verbose": true | ||
} |
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,27 @@ | ||
import {Bridge} from "@lpfreelance/electron-bridge/main"; | ||
import {ipcMain} from "electron"; | ||
import {LogFunctions} from "electron-log"; | ||
import {MainApplication} from "../../../main/main-app"; | ||
|
||
export class ApplicationBridge implements Bridge { | ||
constructor(private app: MainApplication, private log: LogFunctions) { | ||
} | ||
|
||
public register(): void { | ||
ipcMain.handle('eb.application.start', async () => { | ||
this.log.info("start"); | ||
this.app.start(); | ||
return true; | ||
}); | ||
ipcMain.handle('eb.application.stop', async () => { | ||
this.log.info("stop"); | ||
this.app.stop(); | ||
return true; | ||
}); | ||
} | ||
|
||
public release(): void { | ||
ipcMain.removeHandler('eb.application.start'); | ||
ipcMain.removeHandler('eb.application.stop'); | ||
} | ||
} |
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,15 @@ | ||
import {Bridge} from "@lpfreelance/electron-bridge/main"; | ||
import {ipcMain, IpcMainInvokeEvent} from "electron"; | ||
|
||
export class TestBridge implements Bridge { | ||
public register(): void { | ||
ipcMain.handle('eb.test.showOpenDialog', async (_: IpcMainInvokeEvent) => { | ||
console.log("showOpenDialog"); | ||
return true; | ||
}); | ||
} | ||
|
||
public release(): void { | ||
ipcMain.removeHandler('eb.test.showOpenDialog'); | ||
} | ||
} |
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,22 @@ | ||
import {Bridge} from "@lpfreelance/electron-bridge/main"; | ||
import {ipcMain} from "electron"; | ||
import {LogFunctions} from "electron-log"; | ||
import {SerialPortModule} from "../../../main/serial"; | ||
|
||
export class SerialPortBridge implements Bridge { | ||
constructor(private log: LogFunctions) { | ||
} | ||
|
||
public register(): void { | ||
ipcMain.handle('eb.serialPort.refreshSerial', async () => { | ||
this.log.info("refreshSerial"); | ||
return SerialPortModule.listPorts().then((ports) => | ||
ports.map((port) => port.path) | ||
); | ||
}); | ||
} | ||
|
||
public release(): void { | ||
ipcMain.removeHandler('eb.serialPort.refreshSerial'); | ||
} | ||
} |
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,38 @@ | ||
import {Bridge} from "@lpfreelance/electron-bridge/main"; | ||
import {ipcMain, IpcMainInvokeEvent} from "electron"; | ||
import {LogFunctions} from "electron-log"; | ||
import Store from "electron-store"; | ||
import {StoreType} from "../../../store/settings.store"; | ||
|
||
export class SettingsBridge implements Bridge { | ||
constructor(private store: Store<StoreType>, private log: LogFunctions) { | ||
} | ||
|
||
public register(): void { | ||
ipcMain.handle('eb.settings.getAll', async () => { | ||
this.log.info("getAll"); | ||
return this.store.store; | ||
}); | ||
ipcMain.handle('eb.settings.setStore', async (_: IpcMainInvokeEvent, newStore: StoreType) => { | ||
this.log.info("setStore", newStore); | ||
this.store.store = newStore; | ||
return true; | ||
}); | ||
ipcMain.handle('eb.settings.getKey', async (_: IpcMainInvokeEvent, key: keyof StoreType) => { | ||
this.log.info("getKey", key); | ||
return this.store.get(key); | ||
}); | ||
ipcMain.handle('eb.settings.setKey', async (_: IpcMainInvokeEvent, key: keyof StoreType, value: any) => { | ||
this.log.info("setKey", key, value); | ||
this.store.set(key, value); | ||
return true; | ||
}); | ||
} | ||
|
||
public release(): void { | ||
ipcMain.removeHandler('eb.settings.getAll'); | ||
ipcMain.removeHandler('eb.settings.setStore'); | ||
ipcMain.removeHandler('eb.settings.getKey'); | ||
ipcMain.removeHandler('eb.settings.setKey'); | ||
} | ||
} |
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,15 @@ | ||
import {BridgeModule} from "@lpfreelance/electron-bridge/preload"; | ||
import {ipcRenderer} from "electron"; | ||
|
||
export const ApplicationModule: BridgeModule = { | ||
name: 'application', | ||
readonly: true, | ||
api: { | ||
start: async () => { | ||
return await ipcRenderer.invoke('eb.application.start'); | ||
}, | ||
stop: async () => { | ||
return await ipcRenderer.invoke('eb.application.stop'); | ||
} | ||
} | ||
}; |
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,12 @@ | ||
import {BridgeModule} from "@lpfreelance/electron-bridge/preload"; | ||
import {ipcRenderer} from "electron"; | ||
|
||
export const TestModule: BridgeModule = { | ||
name: 'test', | ||
readonly: true, | ||
api: { | ||
showOpenDialog: async (options: any) => { | ||
return await ipcRenderer.invoke('eb.test.showOpenDialog', options); | ||
} | ||
} | ||
}; |
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,12 @@ | ||
import {BridgeModule} from "@lpfreelance/electron-bridge/preload"; | ||
import {ipcRenderer} from "electron"; | ||
|
||
export const SerialPortModule: BridgeModule = { | ||
name: 'serialPort', | ||
readonly: true, | ||
api: { | ||
refreshSerial: async () => { | ||
return await ipcRenderer.invoke('eb.serialPort.refreshSerial'); | ||
} | ||
} | ||
}; |
Oops, something went wrong.