// electron-builder beforePack: stellt sicher, dass die native koffi-Binary der Zielplattform in node_modules liegt. // npm installiert nur die Binary der Build-Plattform – beim Cross-Build (z. B. Windows-Paket auf Linux) fehlt sie sonst, // und RDP im Tab fällt mit "koffi nicht verfügbar" auf ein externes Fenster zurück. const fs = require('fs'); const path = require('path'); const { execSync } = require('child_process'); const { Arch } = require('electron-builder'); module.exports = async (context) => { const platform = context.electronPlatformName; const arch = Arch[context.arch]; const pkg = `@koromix/koffi-${platform}-${arch}`; const root = path.join(__dirname, '..'); if (fs.existsSync(path.join(root, 'node_modules', pkg))) return; const { version } = require(path.join(root, 'node_modules', 'koffi', 'package.json')); console.log(` • koffi-Binary für ${platform}-${arch} fehlt – installiere ${pkg}@${version}`); execSync(`npm install --no-save --force ${pkg}@${version}`, { cwd: root, stdio: 'inherit' }); if (!fs.existsSync(path.join(root, 'node_modules', pkg))) throw new Error(`${pkg} konnte nicht installiert werden`); };