2025-06-01 18:49:18 +00:00
|
|
|
const { app, ipcMain } = require('electron');
|
2025-05-28 02:10:45 +00:00
|
|
|
|
2025-06-15 22:47:11 +00:00
|
|
|
app.commandLine.appendSwitch('disable-renderer-backgrounding');
|
|
|
|
app.commandLine.appendSwitch('disable-background-timer-throttling');
|
|
|
|
app.commandLine.appendSwitch('disable-backgrounding-occluded-windows');
|
|
|
|
|
2025-05-28 02:10:45 +00:00
|
|
|
const { newton } = require('./app');
|
|
|
|
|
|
|
|
|
2025-06-15 22:47:11 +00:00
|
|
|
|
2025-06-14 07:07:12 +00:00
|
|
|
let window = null;
|
|
|
|
|
2025-05-28 02:10:45 +00:00
|
|
|
|
2025-06-15 22:47:11 +00:00
|
|
|
|
2025-05-28 02:10:45 +00:00
|
|
|
const loadHandlers = () => {
|
2025-06-01 18:49:18 +00:00
|
|
|
ipcMain.handle('getLspConfigData', (eve) => newton.fs.getLspConfigData());
|
2025-06-13 03:56:03 +00:00
|
|
|
ipcMain.handle('getFileContents', (eve, path) => newton.fs.getFileContents(path));
|
2025-06-01 18:49:18 +00:00
|
|
|
ipcMain.handle('openFiles', (eve, startPath) => newton.fs.openFiles(startPath));
|
|
|
|
ipcMain.handle('saveFile', (eve, path, content) => newton.fs.saveFile(path, content));
|
2025-06-13 03:56:03 +00:00
|
|
|
ipcMain.handle('closeFile', (eve, path) => newton.fs.closeFile(path));
|
2025-06-01 18:49:18 +00:00
|
|
|
ipcMain.handle('saveFileAs', (eve, content) => newton.fs.saveFileAs(content));
|
2025-05-28 02:10:45 +00:00
|
|
|
}
|
|
|
|
|
2025-06-14 07:07:12 +00:00
|
|
|
const createWindow = () => {
|
|
|
|
window = newton.createWindow(
|
|
|
|
newton.args.getStartType(),
|
|
|
|
newton.args.debugMode(),
|
|
|
|
newton.args.getArgs(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2025-06-01 18:49:18 +00:00
|
|
|
|
2025-06-14 07:07:12 +00:00
|
|
|
app.whenReady().then(async () => {
|
2025-06-09 03:21:24 +00:00
|
|
|
newton.args.loadArgs();
|
2025-06-14 07:07:12 +00:00
|
|
|
|
|
|
|
if ( !await newton.ipc.isIPCServerUp() ) {
|
|
|
|
newton.ipc.loadIPCServer();
|
|
|
|
} else {
|
|
|
|
console.log("IPCServer: Is loaded... sending files to existing app.");
|
2025-06-15 23:15:39 +00:00
|
|
|
newton.ipc.sendFilesToIPC(
|
2025-06-14 07:07:12 +00:00
|
|
|
newton.args.getArgs()
|
|
|
|
);
|
|
|
|
app.quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
newton.settings.loadsettings();
|
2025-06-13 03:56:03 +00:00
|
|
|
newton.fs.loadFilesWatcher();
|
2025-06-14 07:07:12 +00:00
|
|
|
|
2025-05-28 02:10:45 +00:00
|
|
|
loadHandlers();
|
2025-06-14 07:07:12 +00:00
|
|
|
createWindow();
|
2025-06-01 18:49:18 +00:00
|
|
|
|
|
|
|
newton.fs.setWindow(window);
|
2025-06-15 05:43:33 +00:00
|
|
|
newton.ipc.setWindow(window);
|
2025-06-14 07:07:12 +00:00
|
|
|
|
2025-06-08 04:38:42 +00:00
|
|
|
});
|
2025-05-28 02:10:45 +00:00
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
2025-06-14 07:07:12 +00:00
|
|
|
createWindow();
|
2025-05-28 02:10:45 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
app.quit()
|
|
|
|
};
|
2025-06-08 04:38:42 +00:00
|
|
|
|
|
|
|
newton.settings.saveConfig();
|
|
|
|
});
|
2025-05-28 02:10:45 +00:00
|
|
|
|
|
|
|
process.on('uncaughtException', (error) => {
|
|
|
|
if (error.message != null) {
|
|
|
|
console.log(error.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error.stack != null) {
|
|
|
|
console.log(error.stack);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
process.on('unhandledRejection', function(error = {}) {
|
|
|
|
if (error.message != null) {
|
|
|
|
console.log(error.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error.stack != null) {
|
|
|
|
console.log(error.stack);
|
|
|
|
}
|
2025-06-15 20:50:38 +00:00
|
|
|
});
|