Skip to content

Commit d27dee6

Browse files
Initial commit
0 parents  commit d27dee6

11 files changed

+406
-0
lines changed

.gitignore

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
.DS_Store
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# TypeScript cache
43+
*.tsbuildinfo
44+
45+
# Optional npm cache directory
46+
.npm
47+
48+
# Optional eslint cache
49+
.eslintcache
50+
51+
# Optional REPL history
52+
.node_repl_history
53+
54+
# Output of 'npm pack'
55+
*.tgz
56+
57+
# Yarn Integrity file
58+
.yarn-integrity
59+
60+
# dotenv environment variables file
61+
.env
62+
.env.test
63+
64+
# parcel-bundler cache (https://parceljs.org/)
65+
.cache
66+
67+
# next.js build output
68+
.next
69+
70+
# nuxt.js build output
71+
.nuxt
72+
73+
# vuepress build output
74+
.vuepress/dist
75+
76+
# Serverless directories
77+
.serverless/
78+
79+
# FuseBox cache
80+
.fusebox/
81+
82+
# DynamoDB Local files
83+
.dynamodb/
84+
85+
# Webpack
86+
.webpack/
87+
88+
# Vite
89+
.vite/
90+
91+
# Electron-Forge
92+
out/

forge.config.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
module.exports = {
2+
packagerConfig: {
3+
asar: true,
4+
},
5+
rebuildConfig: {},
6+
makers: [
7+
{
8+
name: '@electron-forge/maker-squirrel',
9+
config: {},
10+
},
11+
{
12+
name: '@electron-forge/maker-zip',
13+
platforms: ['darwin'],
14+
},
15+
{
16+
name: '@electron-forge/maker-deb',
17+
config: {},
18+
},
19+
{
20+
name: '@electron-forge/maker-rpm',
21+
config: {},
22+
},
23+
],
24+
plugins: [
25+
{
26+
name: '@electron-forge/plugin-auto-unpack-natives',
27+
config: {},
28+
},
29+
{
30+
name: '@electron-forge/plugin-webpack',
31+
config: {
32+
mainConfig: './webpack.main.config.js',
33+
renderer: {
34+
config: './webpack.renderer.config.js',
35+
entryPoints: [
36+
{
37+
html: './src/index.html',
38+
js: './src/renderer.js',
39+
name: 'main_window',
40+
preload: {
41+
js: './src/preload.js',
42+
},
43+
},
44+
],
45+
},
46+
},
47+
},
48+
],
49+
};

package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "peerviewer",
3+
"productName": "peerviewer",
4+
"version": "1.0.0",
5+
"description": "My Electron application description",
6+
"main": ".webpack/main",
7+
"scripts": {
8+
"start": "electron-forge start",
9+
"package": "electron-forge package",
10+
"make": "electron-forge make",
11+
"publish": "electron-forge publish",
12+
"lint": "echo \"No linting configured\""
13+
},
14+
"keywords": [],
15+
"author": {
16+
"name": "Thomas Farstrike",
17+
"email": "thomasverstreken@protonmail.com"
18+
},
19+
"license": "MIT",
20+
"devDependencies": {
21+
"@electron-forge/cli": "^7.1.0",
22+
"@electron-forge/maker-deb": "^7.1.0",
23+
"@electron-forge/maker-rpm": "^7.1.0",
24+
"@electron-forge/maker-squirrel": "^7.1.0",
25+
"@electron-forge/maker-zip": "^7.1.0",
26+
"@electron-forge/plugin-auto-unpack-natives": "^7.1.0",
27+
"@electron-forge/plugin-webpack": "^7.1.0",
28+
"@vercel/webpack-asset-relocator-loader": "^1.7.3",
29+
"css-loader": "^6.8.1",
30+
"electron": "27.1.2",
31+
"node-loader": "^2.0.0",
32+
"style-loader": "^3.3.3"
33+
},
34+
"dependencies": {
35+
"electron-squirrel-startup": "^1.0.0",
36+
"path-browserify": "^1.0.1"
37+
}
38+
}

src/index.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
body {
2+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
3+
Arial, sans-serif;
4+
margin: auto;
5+
max-width: 38rem;
6+
padding: 2rem;
7+
}

src/index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>Hello World!</title>
6+
7+
</head>
8+
<body>
9+
<h1>💖 Hello World!</h1>
10+
<p>Welcome to your Electron application.</p>
11+
<button onclick="runShellCommand()">Run Shell Command</button>
12+
<script>
13+
const { ipcRenderer } = require('electron');
14+
//const { ipcRenderer } = window.require('electron');
15+
16+
function runShellCommand() {
17+
ipcRenderer.send('run-command', 'zenity --info --text blaaa');
18+
console.log("done");
19+
}
20+
</script>
21+
22+
</body>
23+
</html>

src/main.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
const { app, BrowserWindow, ipcMain } = require('electron');
2+
const { exec } = require('child_process');
3+
//const path = require('path');
4+
5+
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
6+
/*
7+
if (require('electron-squirrel-startup')) {
8+
app.quit();
9+
}
10+
*/
11+
12+
const createWindow = () => {
13+
// Create the browser window.
14+
const mainWindow = new BrowserWindow({
15+
width: 800,
16+
height: 600,
17+
webPreferences: {
18+
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
19+
nodeIntegration: true,
20+
contextIsolation: false
21+
},
22+
});
23+
24+
// and load the index.html of the app.
25+
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
26+
27+
// Open the DevTools.
28+
mainWindow.webContents.openDevTools();
29+
};
30+
31+
// This method will be called when Electron has finished
32+
// initialization and is ready to create browser windows.
33+
// Some APIs can only be used after this event occurs.
34+
app.on('ready', createWindow);
35+
36+
// Quit when all windows are closed, except on macOS. There, it's common
37+
// for applications and their menu bar to stay active until the user quits
38+
// explicitly with Cmd + Q.
39+
app.on('window-all-closed', () => {
40+
if (process.platform !== 'darwin') {
41+
app.quit();
42+
}
43+
});
44+
45+
app.on('activate', () => {
46+
// On OS X it's common to re-create a window in the app when the
47+
// dock icon is clicked and there are no other windows open.
48+
if (BrowserWindow.getAllWindows().length === 0) {
49+
createWindow();
50+
}
51+
});
52+
53+
// In this file you can include the rest of your app's specific main process
54+
// code. You can also put them in separate files and import them here.
55+
56+
// Listen for the 'run-node-code' message from the renderer process
57+
ipcMain.on('run-command', (event) => {
58+
const { exec } = require('child_process');
59+
60+
exec('zenity --info --text bla', (error, stdout, stderr) => {
61+
if (error) {
62+
console.error(`error: ${error.message}`);
63+
return;
64+
}
65+
66+
if (stderr) {
67+
console.error(`stderr: ${stderr}`);
68+
return;
69+
}
70+
71+
console.log(`stdout:\n${stdout}`);
72+
});
73+
74+
// Execute your Node.js code here
75+
const result = 'Node.js code executed successfully!';
76+
77+
// Send a response back to the renderer process
78+
event.reply('node-code-result', result);
79+
});

src/preload.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// See the Electron documentation for details on how to use preload scripts:
2+
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
3+
4+
console.log("running preload");
5+
//window.ipcRenderer = window.require('electron').ipcRenderer;

src/renderer.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* This file will automatically be loaded by webpack and run in the "renderer" context.
3+
* To learn more about the differences between the "main" and the "renderer" context in
4+
* Electron, visit:
5+
*
6+
* https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
7+
*
8+
* By default, Node.js integration in this file is disabled. When enabling Node.js integration
9+
* in a renderer process, please be aware of potential security implications. You can read
10+
* more about security risks here:
11+
*
12+
* https://electronjs.org/docs/tutorial/security
13+
*
14+
* To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration`
15+
* flag:
16+
*
17+
* ```
18+
* // Create the browser window.
19+
* mainWindow = new BrowserWindow({
20+
* width: 800,
21+
* height: 600,
22+
* webPreferences: {
23+
* nodeIntegration: true
24+
* }
25+
* });
26+
* ```
27+
*/
28+
29+
import './index.css';
30+
31+
console.log('👋 This message is being logged by "renderer.js", included via webpack');
32+
33+
/*
34+
// renderer.js
35+
const { ipcRenderer } = window.require('electron');
36+
37+
document.getElementById('runNodeCodeButton').addEventListener('click', () => {
38+
// Send a message to the main process to run Node.js code
39+
//window.ipcRenderer.send('run-node-code');
40+
ipcRenderer.send('run-node-code');
41+
});
42+
*/
43+
44+
/*
45+
46+
// Listen for the response from the main process
47+
ipcRenderer.on('node-code-result', (event, result) => {
48+
console.log(result);
49+
// Handle the result as needed in the renderer process
50+
});
51+
52+
*/

webpack.main.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
/**
3+
* This is the main entry point for your application, it's the first file
4+
* that runs in the main process.
5+
*/
6+
entry: './src/main.js',
7+
// Put your normal webpack config below here
8+
module: {
9+
rules: require('./webpack.rules'),
10+
},
11+
};

webpack.renderer.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const rules = require('./webpack.rules');
2+
3+
rules.push({
4+
test: /\.css$/,
5+
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
6+
});
7+
8+
module.exports = {
9+
// Put your normal webpack config below here
10+
module: {
11+
rules,
12+
},
13+
};
14+
15+

0 commit comments

Comments
 (0)