From 1bd28fcbc4c1e0e6a19f2122a8dcffdadc5c0f0d Mon Sep 17 00:00:00 2001 From: patrikx3 Date: Tue, 21 Jan 2025 15:41:13 +0100 Subject: [PATCH] r0b08x [chore] 1/21/2025, 3:41:13 PM --- README.md | 4 +- artifacts/arm.md | 2 +- artifacts/flavor.md | 2 +- artifacts/new-language.md | 2 +- artifacts/npm.md | 2 +- change-log.2019.md | 2 +- change-log.2020.md | 2 +- change-log.2021.md | 2 +- change-log.2022.md | 2 +- change-log.2023.md | 2 +- change-log.2024.md | 2 +- change-log.md | 7 +- package.json | 6 +- src/electron/main/app-events.js | 78 +++++++++++++++++++--- src/electron/main/create/window/onenote.js | 24 ++++--- 15 files changed, 105 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 9484a493..326e95e1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ -# 📚 P3X OneNote Linux v2025.4.123 +# 📚 P3X OneNote Linux v2025.4.124 @@ -320,7 +320,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/artifacts/arm.md b/artifacts/arm.md index cb82d667..22d3348d 100644 --- a/artifacts/arm.md +++ b/artifacts/arm.md @@ -64,7 +64,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/artifacts/flavor.md b/artifacts/flavor.md index 2f331eca..e6e5c92a 100644 --- a/artifacts/flavor.md +++ b/artifacts/flavor.md @@ -54,7 +54,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/artifacts/new-language.md b/artifacts/new-language.md index 89daa89a..648c7ea5 100644 --- a/artifacts/new-language.md +++ b/artifacts/new-language.md @@ -55,7 +55,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/artifacts/npm.md b/artifacts/npm.md index 2e2f5ed6..8bebf358 100644 --- a/artifacts/npm.md +++ b/artifacts/npm.md @@ -68,7 +68,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/change-log.2019.md b/change-log.2019.md index f68fa0f9..5ffca77d 100644 --- a/change-log.2019.md +++ b/change-log.2019.md @@ -222,7 +222,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/change-log.2020.md b/change-log.2020.md index 03a46c0a..9c30cbea 100644 --- a/change-log.2020.md +++ b/change-log.2020.md @@ -184,7 +184,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/change-log.2021.md b/change-log.2021.md index c8717a09..9de36327 100644 --- a/change-log.2021.md +++ b/change-log.2021.md @@ -216,7 +216,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/change-log.2022.md b/change-log.2022.md index f2142d28..5cd14a10 100644 --- a/change-log.2022.md +++ b/change-log.2022.md @@ -91,7 +91,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/change-log.2023.md b/change-log.2023.md index b842f628..c06223ea 100644 --- a/change-log.2023.md +++ b/change-log.2023.md @@ -115,7 +115,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/change-log.2024.md b/change-log.2024.md index 652044a3..e6e82fb3 100644 --- a/change-log.2024.md +++ b/change-log.2024.md @@ -150,7 +150,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/change-log.md b/change-log.md index 4e7923a8..e8e2202b 100644 --- a/change-log.md +++ b/change-log.md @@ -7,6 +7,11 @@ ## Change log +### v2025.4.124 +Released on 01/21/2025 +* FEATURE/BUGFIX: Saving the position of the window as it was years ago + + ### v2025.4.101 Released on 01/05/2025 * CHORE: Update all packages. @@ -66,7 +71,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht --- -[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.123 +[**P3X-ONENOTE**](https://corifeus.com/onenote) Build v2025.4.124 [![NPM](https://img.shields.io/npm/v/p3x-onenote.svg)](https://www.npmjs.com/package/p3x-onenote) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/package.json b/package.json index 013b38bc..12e62cde 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p3x-onenote", - "version": "2025.4.123", + "version": "2025.4.124", "description": "📚 P3X OneNote Linux", "main": "src/electron/app.js", "corifeus": { @@ -66,10 +66,10 @@ "angular-material": "1.2.5", "angular-messages": "1.8.3", "corifeus-utils": "2025.4.120", - "electron": "^34.0.0", "electron-store": "8.2.0", "electron-updater": "6.3.9", - "semver": "7.6.3" + "semver": "7.6.3", + "electron": "^34.0.0" }, "devDependencies": { "corifeus-builder": "2025.4.128", diff --git a/src/electron/main/app-events.js b/src/electron/main/app-events.js index 5c306f72..3efba089 100644 --- a/src/electron/main/app-events.js +++ b/src/electron/main/app-events.js @@ -1,12 +1,77 @@ -const {app} = require('electron') +const { app, powerMonitor } = require('electron'); +const path = require('path') -app.on('ready', global.p3x.onenote.createWindow.onenote); +let isInSuspended = false; -app.on('window-all-closed', function () { +const { net } = require('electron'); +function waitForNetworkConnectivity(callback, retries = 60, interval = 1000) { + let attempts = 0; + + function checkNetwork() { + const request = net.request('https://www.bing.com'); // Use any lightweight URL + request.on('response', () => { + console.log('Network is available'); + callback(); + }); + request.on('error', () => { + if (attempts < retries) { + attempts++; + console.log(`Waiting for network (${attempts}/${retries})...`); + setTimeout(checkNetwork, interval); + } else { + console.error('Network unavailable after retries.'); + callback(); + } + }); + request.end(); + } + + checkNetwork(); +} + +app.on('ready', () => { + console.log('P3X-OneNote is ready'); + + // Create the main window + global.p3x.onenote.createWindow.onenote(); + + + /* + // Handle power events + powerMonitor.on('suspend', () => { + if (isInSuspended) { + return + } + isInSuspended = true; + console.log('System is suspending...'); + // Close the window when the system goes to sleep + //if (global.p3x.onenote.window.onenote) { + // global.p3x.onenote.window.onenote.loadURL('about:blank'); + // global.p3x.onenote.window.onenote.hide(); + //} + }); -// if (process.platform !== 'darwin') { + powerMonitor.on('resume', () => { + if (!isInSuspended) { + return + } + isInSuspended = false; + console.log('System has resumed...'); + + global.p3x.onenote.window.onenote.loadURL(`about:blank`); + waitForNetworkConnectivity(() => { + const url = path.join(app.getAppPath(), 'src/electron/window/onenote/index.html'); + console.log('resume url', url) + global.p3x.onenote.window.onenote.loadURL(`file://${url}`); + }); + }); + */ +}); + +app.on('window-all-closed', function () { + if (!isInSuspended) { app.quit(); -// } + } }); app.on('activate', function () { @@ -15,8 +80,6 @@ app.on('activate', function () { } }); - -//FIXME: webview new-window changed app.on('web-contents-created', function (webContentsCreatedEvent, contents) { if (contents.getType() === 'webview') { contents.on('new-window', function (newWindowEvent, url) { @@ -24,4 +87,3 @@ app.on('web-contents-created', function (webContentsCreatedEvent, contents) { }); } }); - diff --git a/src/electron/main/create/window/onenote.js b/src/electron/main/create/window/onenote.js index e10efde5..9b514642 100644 --- a/src/electron/main/create/window/onenote.js +++ b/src/electron/main/create/window/onenote.js @@ -1,10 +1,11 @@ const {BrowserWindow, app} = require('electron'); +const remoteMain = require("@electron/remote/main") +remoteMain.initialize() function createWindow() { - const remoteMain = require("@electron/remote/main") - remoteMain.initialize() + global.p3x.onenote.window.onenote = new BrowserWindow({ icon: global.p3x.onenote.iconFile, @@ -18,9 +19,13 @@ function createWindow() { nodeIntegrationInSubFrames: true, contextIsolation: false, webviewTag: true, + enableRemoteModule: true, } }); - global.p3x.onenote.window.onenote.loadURL(`file://${__dirname}/../../../window/onenote/index.html`); + const path = require('path') + const loadUrl = path.join(app.getAppPath(), 'src/electron/window/onenote/index.html'); + console.log('loadUrl', loadUrl) + global.p3x.onenote.window.onenote.loadURL(`file://${loadUrl}`); global.p3x.onenote.window.onenote.webContents.on("did-attach-webview", (_, contents) => { contents.setWindowOpenHandler((details) => { @@ -84,27 +89,26 @@ function createWindow() { }) }); + if (!process.argv.includes('--minimized')) { - //const windowBounds = global.p3x.onenote.conf.get('window-bounds'); + const windowBounds = global.p3x.onenote.conf.get('window-bounds'); const maximized = global.p3x.onenote.conf.get('maximized'); if (maximized === true) { global.p3x.onenote.window.onenote.maximize() } - + else if (windowBounds !== null && windowBounds !== undefined) { + global.p3x.onenote.window.onenote.setBounds(windowBounds); + } + } - /* - else if (windowBounds !== null && windowBounds !== undefined) { - global.p3x.onenote.window.onenote.setBounds(windowBounds); - } global.p3x.onenote.window.onenote.on('close', () => { if (global.p3x.onenote.conf.get('maximized') !== true) { global.p3x.onenote.conf.set('window-bounds', global.p3x.onenote.window.onenote.getBounds()) } }) - */ global.p3x.onenote.window.onenote.on('maximize', () => { global.p3x.onenote.conf.set('maximized', true)