// Modules to control application life and create native browser window const { app, BrowserWindow, desktopCapturer, session } = require('electron') const path = require('node:path') function createWindow () { const mainWindow = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: path.join(__dirname, 'preload.js') } }) mainWindow.loadFile('index.html') } app.whenReady().then(() => { createWindow() session.defaultSession.setDisplayMediaRequestHandler((req, callback) => { desktopCapturer.getSources({ types: ['screen', 'window'] }).then((sources) => { callback({ video: sources[0] }) }).catch((err) => { console.log('Error: ', err); }) // If we should use the system picker // Note: this is currently experimental }, { useSystemPicker: true }) // }) app.on('activate', function () { if (BrowserWindow.getAllWindows().length === 0) createWindow() }) }) app.on('window-all-closed', function () { if (process.platform !== 'darwin') app.quit() })