Skip to content

Commit b6ff148

Browse files
author
Lokua
committed
feat: working well enough
1 parent 9a25332 commit b6ff148

File tree

12 files changed

+176
-234
lines changed

12 files changed

+176
-234
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
dist
1212
dist-ssr
1313
*.local
14+
release
1415

1516
# Editor directories and files
1617
.vscode/*

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ any MIDI output on your system.
1212
![Light Theme](./assets/vmc-light.png)
1313

1414
![Dark Theme](./assets/vmc-dark.png)
15+
16+
# Status
17+
18+
The app is working locally as well as when built on a Mac. It is not quite at v1
19+
in my opinion but is good enough.

dist-electron/main.js

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,35 @@
1-
import { app, BrowserWindow } from "electron";
2-
import { fileURLToPath } from "node:url";
3-
import path from "node:path";
4-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
5-
process.env.APP_ROOT = path.join(__dirname, "..");
6-
const VITE_DEV_SERVER_URL = process.env.VITE_DEV_SERVER_URL;
7-
const MAIN_DIST = path.join(process.env.APP_ROOT, "dist-electron");
8-
const RENDERER_DIST = path.join(process.env.APP_ROOT, "dist");
9-
process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL ? path.join(process.env.APP_ROOT, "public") : RENDERER_DIST;
10-
let win;
11-
function createWindow() {
12-
win = new BrowserWindow({
13-
icon: path.join(process.env.VITE_PUBLIC, "electron-vite.svg"),
1+
import { app as n, BrowserWindow as t } from "electron";
2+
import { fileURLToPath as a } from "node:url";
3+
import o from "node:path";
4+
const s = o.dirname(a(import.meta.url));
5+
process.env.APP_ROOT = o.join(s, "..");
6+
const i = process.env.VITE_DEV_SERVER_URL, m = o.join(process.env.APP_ROOT, "dist-electron"), r = o.join(process.env.APP_ROOT, "dist");
7+
process.env.VITE_PUBLIC = i ? o.join(process.env.APP_ROOT, "public") : r;
8+
let e;
9+
function c() {
10+
e = new t({
11+
icon: o.join(process.env.VITE_PUBLIC, "icons/vmc.png"),
1412
width: 700,
1513
height: 580,
1614
minWidth: 600,
1715
minHeight: 580,
1816
maxHeight: 580,
1917
webPreferences: {
20-
preload: path.join(__dirname, "preload.mjs")
18+
preload: o.join(s, "preload.mjs")
2119
}
22-
});
23-
win.webContents.on("did-finish-load", () => {
24-
win == null ? void 0 : win.webContents.send("main-process-message", (/* @__PURE__ */ new Date()).toLocaleString());
25-
});
26-
if (VITE_DEV_SERVER_URL) {
27-
win.loadURL(VITE_DEV_SERVER_URL);
28-
} else {
29-
win.loadFile(path.join(RENDERER_DIST, "index.html"));
30-
}
20+
}), e.webContents.on("did-finish-load", () => {
21+
e == null || e.webContents.send("main-process-message", (/* @__PURE__ */ new Date()).toLocaleString());
22+
}), i ? e.loadURL(i) : e.loadFile(o.join(r, "index.html"));
3123
}
32-
app.on("window-all-closed", () => {
33-
if (process.platform !== "darwin") {
34-
app.quit();
35-
win = null;
36-
}
24+
n.on("window-all-closed", () => {
25+
process.platform !== "darwin" && (n.quit(), e = null);
3726
});
38-
app.on("activate", () => {
39-
if (BrowserWindow.getAllWindows().length === 0) {
40-
createWindow();
41-
}
27+
n.on("activate", () => {
28+
t.getAllWindows().length === 0 && c();
4229
});
43-
app.whenReady().then(createWindow);
30+
n.whenReady().then(c);
4431
export {
45-
MAIN_DIST,
46-
RENDERER_DIST,
47-
VITE_DEV_SERVER_URL
32+
m as MAIN_DIST,
33+
r as RENDERER_DIST,
34+
i as VITE_DEV_SERVER_URL
4835
};

dist-electron/preload.mjs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1 @@
1-
"use strict";
2-
const electron = require("electron");
3-
electron.contextBridge.exposeInMainWorld("ipcRenderer", {
4-
on(...args) {
5-
const [channel, listener] = args;
6-
return electron.ipcRenderer.on(channel, (event, ...args2) => listener(event, ...args2));
7-
},
8-
off(...args) {
9-
const [channel, ...omit] = args;
10-
return electron.ipcRenderer.off(channel, ...omit);
11-
},
12-
send(...args) {
13-
const [channel, ...omit] = args;
14-
return electron.ipcRenderer.send(channel, ...omit);
15-
},
16-
invoke(...args) {
17-
const [channel, ...omit] = args;
18-
return electron.ipcRenderer.invoke(channel, ...omit);
19-
}
20-
// You can expose other APTs you need here.
21-
// ...
22-
});
1+
"use strict";const o=require("electron");o.contextBridge.exposeInMainWorld("ipcRenderer",{on(...e){const[n,r]=e;return o.ipcRenderer.on(n,(t,...c)=>r(t,...c))},off(...e){const[n,...r]=e;return o.ipcRenderer.off(n,...r)},send(...e){const[n,...r]=e;return o.ipcRenderer.send(n,...r)},invoke(...e){const[n,...r]=e;return o.ipcRenderer.invoke(n,...r)}});

electron-builder.json5

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,35 @@
11
// @see - https://www.electron.build/configuration/configuration
22
{
3-
"$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json",
4-
"appId": "YourAppID",
5-
"asar": true,
6-
"productName": "YourAppName",
7-
"directories": {
8-
"output": "release/${version}"
3+
$schema: 'https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json',
4+
appId: 'com.lokua.vmc',
5+
asar: true,
6+
productName: 'VMC',
7+
directories: {
8+
output: 'release/${version}',
99
},
10-
"files": [
11-
"dist",
12-
"dist-electron"
13-
],
14-
"mac": {
15-
"target": [
16-
"dmg"
17-
],
18-
"artifactName": "${productName}-Mac-${version}-Installer.${ext}"
10+
files: ['dist', 'dist-electron'],
11+
icon: 'public/icons/vmc',
12+
mac: {
13+
target: ['dmg'],
14+
artifactName: '${productName}-Mac-${version}-Installer.${ext}',
1915
},
20-
"win": {
21-
"target": [
16+
win: {
17+
target: [
2218
{
23-
"target": "nsis",
24-
"arch": [
25-
"x64"
26-
]
27-
}
19+
target: 'nsis',
20+
arch: ['x64'],
21+
},
2822
],
29-
"artifactName": "${productName}-Windows-${version}-Setup.${ext}"
23+
artifactName: '${productName}-Windows-${version}-Setup.${ext}',
3024
},
31-
"nsis": {
32-
"oneClick": false,
33-
"perMachine": false,
34-
"allowToChangeInstallationDirectory": true,
35-
"deleteAppDataOnUninstall": false
25+
nsis: {
26+
oneClick: false,
27+
perMachine: false,
28+
allowToChangeInstallationDirectory: true,
29+
deleteAppDataOnUninstall: false,
30+
},
31+
linux: {
32+
target: ['AppImage'],
33+
artifactName: '${productName}-Linux-${version}.${ext}',
3634
},
37-
"linux": {
38-
"target": [
39-
"AppImage"
40-
],
41-
"artifactName": "${productName}-Linux-${version}.${ext}"
42-
}
4335
}

electron/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let win: BrowserWindow | null
3030

3131
function createWindow() {
3232
win = new BrowserWindow({
33-
icon: path.join(process.env.VITE_PUBLIC, 'electron-vite.svg'),
33+
icon: path.join(process.env.VITE_PUBLIC, 'icons/vmc.png'),
3434
width: 700,
3535
height: 580,
3636
minWidth: 600,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"private": true,
44
"version": "0.0.0",
55
"type": "module",
6+
"main": "dist-electron/main.js",
67
"scripts": {
78
"start": "vite",
89
"build": "tsc && vite build && electron-builder",
@@ -28,6 +29,5 @@
2829
"electron-builder": "^24.13.3",
2930
"vite-plugin-electron": "^0.28.6",
3031
"vite-plugin-electron-renderer": "^0.14.5"
31-
},
32-
"main": "dist-electron/main.js"
32+
}
3333
}

public/icons/vmc.icns

349 KB
Binary file not shown.

public/icons/vmc.ico

24.4 KB
Binary file not shown.

public/icons/vmc.png

49.6 KB
Loading

0 commit comments

Comments
 (0)