Electron-Prototyp: eigenes App-Fenster statt Tauri/WebKitGTK

Ersetzt den Tauri-Webview-Weg testweise durch eine Electron-Shell (randlos,
ohne native Menüleiste, wie chromium-shell.sh), damit die WASM/WebGPU-Engine
zuverlässig laeuft statt in WebKitGTK. Rust-Backend nicht noetig, da
compute_joins einen TS-Fallback hat. npm run electron zum Starten.
This commit is contained in:
2026-07-02 23:51:23 +02:00
parent 27e41077b1
commit 34317e53f4
5 changed files with 254 additions and 7 deletions
+48
View File
@@ -0,0 +1,48 @@
// electron-main.js — Electron-Prototyp-Shell für die CAD-App.
//
// Ersetzt WebKitGTK (Tauri-Linux-Webview) durch Chromium, damit WebGPU
// (render2d-WASM-Engine, ?engine=wasm) zuverlässig läuft. Kein Rust-Backend
// nötig: compute_joins hat einen TS-Fallback (src/compute/index.ts).
const { app, BrowserWindow, Menu } = require("electron");
// Randloses App-Fenster wie chromium-shell.sh (--app=…): keine native
// Menüleiste (File/Edit/View/Window), kein Fensterrahmen.
Menu.setApplicationMenu(null);
// Gleiche Flags wie scripts/chromium-shell.sh — WebGPU liegt unter Linux
// hinter --enable-unsafe-webgpu, und WebGPU braucht das Vulkan-Backend.
app.commandLine.appendSwitch("enable-unsafe-webgpu");
app.commandLine.appendSwitch("enable-features", "Vulkan");
const DEV_URL = "http://localhost:5187";
const isDev = !app.isPackaged;
function createWindow() {
const win = new BrowserWindow({
width: 1600,
height: 1000,
frame: false,
autoHideMenuBar: true,
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
},
});
if (isDev) {
win.loadURL(DEV_URL);
} else {
win.loadFile(require("node:path").join(__dirname, "..", "dist", "index.html"));
}
}
app.whenReady().then(createWindow);
app.on("window-all-closed", () => {
if (process.platform !== "darwin") app.quit();
});
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# electron-shell.sh — startet die CAD-Oberfläche im Electron-Prototyp-Fenster.
#
# Wie chromium-shell.sh: stellt sicher, dass der Vite-Dev-Server läuft, startet
# ihn sonst selbst und beendet ihn wieder, sobald das Electron-Fenster schliesst.
set -u
PORT=5187
URL="http://localhost:${PORT}"
server_is_up() {
curl --silent --fail --max-time 1 --output /dev/null "${URL}"
}
DEV_SERVER_PID=""
if server_is_up; then
echo "electron-shell: Dev-Server läuft bereits auf ${URL}."
else
echo "electron-shell: starte Vite-Dev-Server (Port ${PORT}) …"
npm run dev >/tmp/cad-electron-shell-dev.log 2>&1 &
DEV_SERVER_PID=$!
ATTEMPTS=0
MAX_ATTEMPTS=60
until server_is_up; do
ATTEMPTS=$((ATTEMPTS + 1))
if [ "${ATTEMPTS}" -ge "${MAX_ATTEMPTS}" ]; then
echo "electron-shell: Dev-Server antwortet nach ${MAX_ATTEMPTS}s nicht, Abbruch." >&2
kill "${DEV_SERVER_PID}" 2>/dev/null
exit 1
fi
sleep 1
done
echo "electron-shell: Dev-Server bereit."
fi
cleanup() {
if [ -n "${DEV_SERVER_PID}" ]; then
echo "electron-shell: beende selbst gestarteten Dev-Server (PID ${DEV_SERVER_PID}) …"
kill "${DEV_SERVER_PID}" 2>/dev/null
wait "${DEV_SERVER_PID}" 2>/dev/null
fi
}
trap cleanup EXIT
echo "electron-shell: öffne Electron-Fenster …"
npx electron "$(dirname "$0")/electron-main.cjs"