Initial commit
This commit is contained in:
commit
c4626edee4
19 changed files with 11968 additions and 0 deletions
16
.eslintrc.json
Normal file
16
.eslintrc.json
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
35
.gitignore
vendored
Normal file
35
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Vite files
|
||||||
|
vite.config.js.timestamp-*
|
||||||
|
vite.config.ts.timestamp-*
|
||||||
|
.vite/
|
||||||
|
|
||||||
59
forge.config.ts
Normal file
59
forge.config.ts
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
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 { VitePlugin } from '@electron-forge/plugin-vite';
|
||||||
|
import { FusesPlugin } from '@electron-forge/plugin-fuses';
|
||||||
|
import { FuseV1Options, FuseVersion } from '@electron/fuses';
|
||||||
|
|
||||||
|
const config: ForgeConfig = {
|
||||||
|
packagerConfig: {
|
||||||
|
asar: true,
|
||||||
|
},
|
||||||
|
rebuildConfig: {},
|
||||||
|
makers: [
|
||||||
|
new MakerSquirrel({}),
|
||||||
|
new MakerZIP({}, ['darwin']),
|
||||||
|
new MakerRpm({}),
|
||||||
|
new MakerDeb({}),
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
new VitePlugin({
|
||||||
|
// `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
|
||||||
|
// If you are familiar with Vite configuration, it will look really familiar.
|
||||||
|
build: [
|
||||||
|
{
|
||||||
|
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
|
||||||
|
entry: 'src/main.ts',
|
||||||
|
config: 'vite.main.config.ts',
|
||||||
|
target: 'main',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
entry: 'src/preload.ts',
|
||||||
|
config: 'vite.preload.config.ts',
|
||||||
|
target: 'preload',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
renderer: [
|
||||||
|
{
|
||||||
|
name: 'main_window',
|
||||||
|
config: 'vite.renderer.config.ts',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
// Fuses are used to enable/disable various Electron functionality
|
||||||
|
// at package time, before code signing the application
|
||||||
|
new FusesPlugin({
|
||||||
|
version: FuseVersion.V1,
|
||||||
|
[FuseV1Options.RunAsNode]: false,
|
||||||
|
[FuseV1Options.EnableCookieEncryption]: true,
|
||||||
|
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
|
||||||
|
[FuseV1Options.EnableNodeCliInspectArguments]: false,
|
||||||
|
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
|
||||||
|
[FuseV1Options.OnlyLoadAppFromAsar]: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
1
forge.env.d.ts
vendored
Normal file
1
forge.env.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/// <reference types="@electron-forge/plugin-vite/forge-vite-env" />
|
||||||
22
index.html
Normal file
22
index.html
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||||
|
<meta
|
||||||
|
http-equiv="Content-Security-Policy"
|
||||||
|
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' ws://localhost:*;">
|
||||||
|
<meta
|
||||||
|
http-equiv="X-Content-Security-Policy"
|
||||||
|
content="default-src 'self'; script-src 'self'"
|
||||||
|
/>
|
||||||
|
<title>Hello from Electron renderer!</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hello from Electron renderer!</h1>
|
||||||
|
<p>👋</p>
|
||||||
|
|
||||||
|
<p id="info"></p>
|
||||||
|
<script type="module" src="/src/renderer.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
30
main.js
Normal file
30
main.js
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
const { app, BrowserWindow, ipcMain } = require('electron/main');
|
||||||
|
const path = require('node:path');
|
||||||
|
|
||||||
|
console.log('Hello from Electron 👋');
|
||||||
|
|
||||||
|
function createWindow() {
|
||||||
|
const win = new BrowserWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
webPreferences: {
|
||||||
|
preload: path.join(__dirname, 'preload.js'),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
win.loadFile('index.html');
|
||||||
|
// or use ctrl+shift+i
|
||||||
|
win.webContents.openDevTools();
|
||||||
|
// win.loadURL('chrome://gpu');
|
||||||
|
}
|
||||||
|
|
||||||
|
app.whenReady().then(() => {
|
||||||
|
ipcMain.handle('ping', () => 'pong');
|
||||||
|
createWindow();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
// when not on mac
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
11588
package-lock.json
generated
Normal file
11588
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
39
package.json
Normal file
39
package.json
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"name": "electron-test",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"author": "",
|
||||||
|
"type": "commonjs",
|
||||||
|
"main": ".vite/build/main.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "electron-forge start",
|
||||||
|
"package": "electron-forge package",
|
||||||
|
"make": "electron-forge make",
|
||||||
|
"publish": "electron-forge publish",
|
||||||
|
"lint": "eslint --ext .ts,.tsx ."
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@electron-forge/cli": "^7.11.1",
|
||||||
|
"@electron-forge/maker-deb": "^7.11.1",
|
||||||
|
"@electron-forge/maker-rpm": "^7.11.1",
|
||||||
|
"@electron-forge/maker-squirrel": "^7.11.1",
|
||||||
|
"@electron-forge/maker-zip": "^7.11.1",
|
||||||
|
"@electron-forge/plugin-auto-unpack-natives": "^7.11.1",
|
||||||
|
"@electron-forge/plugin-fuses": "^7.11.1",
|
||||||
|
"@electron-forge/plugin-vite": "^7.11.1",
|
||||||
|
"@electron/fuses": "^1.8.0",
|
||||||
|
"@types/electron-squirrel-startup": "^1.0.2",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
||||||
|
"@typescript-eslint/parser": "^8.54.0",
|
||||||
|
"electron": "^40.1.0",
|
||||||
|
"eslint": "^9.39.2",
|
||||||
|
"eslint-plugin-import": "^2.32.0",
|
||||||
|
"sass-embedded": "^1.97.3",
|
||||||
|
"typescript": "^5.9.3",
|
||||||
|
"vite": "^7.3.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"electron-squirrel-startup": "^1.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
9
preload.js
Normal file
9
preload.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
const { contextBridge, ipcRenderer } = require('electron');
|
||||||
|
|
||||||
|
contextBridge.exposeInMainWorld('versions', {
|
||||||
|
node() { return process.versions.node; },
|
||||||
|
chrome() { return process.versions.chrome; },
|
||||||
|
electron() { return process.versions.electron; },
|
||||||
|
ping() { return ipcRenderer.invoke('ping'); }
|
||||||
|
});
|
||||||
|
|
||||||
15
renderer.js
Normal file
15
renderer.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
console.log("hello world! yooo");
|
||||||
|
|
||||||
|
const information = document.getElementById('info');
|
||||||
|
information.innerText = `This app is using Chrome (v${versions.chrome()}), Node.js (v${versions.node()}), and Electron (v${versions.electron()})`;
|
||||||
|
|
||||||
|
async function func() {
|
||||||
|
const response = await versions.ping();
|
||||||
|
console.log(response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
func().then(x => {
|
||||||
|
console.log("is this working? ", x);
|
||||||
|
});
|
||||||
|
|
||||||
8
src/index.scss
Normal file
8
src/index.scss
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
body {
|
||||||
|
font-family:
|
||||||
|
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
|
||||||
|
sans-serif;
|
||||||
|
margin: auto;
|
||||||
|
max-width: 38rem;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
50
src/main.ts
Normal file
50
src/main.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
import { app, BrowserWindow, ipcMain } from 'electron';
|
||||||
|
import path from 'node:path';
|
||||||
|
import started from 'electron-squirrel-startup';
|
||||||
|
|
||||||
|
console.log('Hello from Electron 👋');
|
||||||
|
|
||||||
|
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||||
|
if (started) {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function createWindow() {
|
||||||
|
const mainWindow = new BrowserWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
webPreferences: {
|
||||||
|
preload: path.join(__dirname, 'preload.js'),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// and load the index.html of the app.
|
||||||
|
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
|
||||||
|
mainWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL);
|
||||||
|
} else {
|
||||||
|
mainWindow.loadFile(
|
||||||
|
path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// or use ctrl+shift+i
|
||||||
|
mainWindow.webContents.openDevTools();
|
||||||
|
// mainWindow.loadURL('chrome://gpu');
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method will be called when Electron has finished
|
||||||
|
// initialization and is ready to create browser windows.
|
||||||
|
// Some APIs can only be used after this event occurs.
|
||||||
|
app.on('ready', () => {
|
||||||
|
ipcMain.handle('ping', () => 'pong');
|
||||||
|
createWindow();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
|
// for applications and their menu bar to stay active until the user quits
|
||||||
|
// explicitly with Cmd + Q.
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
11
src/preload.ts
Normal file
11
src/preload.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
// See the Electron documentation for details on how to use preload scripts:
|
||||||
|
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
|
||||||
|
import { contextBridge, ipcRenderer } from 'electron';
|
||||||
|
|
||||||
|
contextBridge.exposeInMainWorld('versions', {
|
||||||
|
node() { return process.versions.node; },
|
||||||
|
chrome() { return process.versions.chrome; },
|
||||||
|
electron() { return process.versions.electron; },
|
||||||
|
ping() { return ipcRenderer.invoke('ping'); }
|
||||||
|
});
|
||||||
|
|
||||||
45
src/renderer.ts
Normal file
45
src/renderer.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
/**
|
||||||
|
* This file will automatically be loaded by vite 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/process-model
|
||||||
|
*
|
||||||
|
* 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.ts` and enable the `nodeIntegration`
|
||||||
|
* flag:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* // Create the browser window.
|
||||||
|
* mainWindow = new BrowserWindow({
|
||||||
|
* width: 800,
|
||||||
|
* height: 600,
|
||||||
|
* webPreferences: {
|
||||||
|
* nodeIntegration: true
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
|
||||||
|
import './index.scss';
|
||||||
|
|
||||||
|
console.log("hello world! yooo");
|
||||||
|
|
||||||
|
const information = document.getElementById('info');
|
||||||
|
information.innerText = `This app is using Chrome (v${versions.chrome()}), Node.js (v${versions.node()}), and Electron (v${versions.electron()})`;
|
||||||
|
|
||||||
|
async function func() {
|
||||||
|
const response = await versions.ping();
|
||||||
|
console.log(response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
func().then(x => {
|
||||||
|
console.log("is this working? ", x);
|
||||||
|
});
|
||||||
|
|
||||||
12
tmp_repl/tmp_repl.md
Normal file
12
tmp_repl/tmp_repl.md
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
|
||||||
|
npm run start
|
||||||
|
|
||||||
|
|
||||||
|
npm install -D @electron-forge/cli @electron-forge/maker-deb @electron-forge/maker-rpm @electron-forge/maker-squirrel @electron-forge/maker-zip @electron-forge/plugin-auto-unpack-natives @electron-forge/plugin-fuses @electron-forge/plugin-vite @electron/fuses @types/electron-squirrel-startup @typescript-eslint/eslint-plugin @typescript-eslint/parser electron eslint eslint-plugin-import typescript vite
|
||||||
|
|
||||||
|
npm install electron-squirrel-startup
|
||||||
|
|
||||||
|
npm install -D sass-embedded
|
||||||
|
|
||||||
|
|
||||||
15
tsconfig.json
Normal file
15
tsconfig.json
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "commonjs",
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"outDir": "dist",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"resolveJsonModule": true
|
||||||
|
}
|
||||||
|
}
|
||||||
4
vite.main.config.ts
Normal file
4
vite.main.config.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
|
// https://vitejs.dev/config
|
||||||
|
export default defineConfig({});
|
||||||
4
vite.preload.config.ts
Normal file
4
vite.preload.config.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
|
// https://vitejs.dev/config
|
||||||
|
export default defineConfig({});
|
||||||
5
vite.renderer.config.ts
Normal file
5
vite.renderer.config.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
|
// https://vitejs.dev/config
|
||||||
|
export default defineConfig({});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue