From 7ac027041a29e03375457736498c2b943865c624 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 13 Jan 2023 12:23:27 -0400 Subject: [PATCH 001/103] 1.2.2 -> 2.0.0 --- package.json | 2 +- src/config/app.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 95f2be6..29529bf 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": true, "name": "random-browser", "productName": "Random Browser", - "version": "1.2.2", + "version": "2.0.0", "description": "Just a random browser...", "main": "build/index.js", "scripts": { diff --git a/src/config/app.json b/src/config/app.json index 11f88d2..63cb415 100644 --- a/src/config/app.json +++ b/src/config/app.json @@ -1,3 +1,3 @@ { - "version": "v1.2.2" + "version": "v2.0.0" } \ No newline at end of file From e6c0eafdd215f7a25c78a4f31c641c4b7ecf1f28 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 13 Jan 2023 12:26:31 -0400 Subject: [PATCH 002/103] changes to tests --- .github/workflows/integrate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index dde5de7..ed64761 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -1,4 +1,4 @@ -name: Build Test +name: build on: push: @@ -9,7 +9,7 @@ on: branches: [ main ] jobs: - test_pull_request: + test_build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 3a68c5d659e7352c1011088b8279d6ed1765ee04 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 13 Jan 2023 13:32:38 -0400 Subject: [PATCH 003/103] new custom frame --- src/index.ts | 1 + src/public/css/index.css | 34 ++++++++++++++++++++++++++++++++-- src/public/index.html | 14 ++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index d189c6e..641af88 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,6 +18,7 @@ app.on('ready', () => { nodeIntegration: true, contextIsolation: false }, + frame: false, show: false }); Menu.setApplicationMenu(null); diff --git a/src/public/css/index.css b/src/public/css/index.css index 83943b1..119ff61 100644 --- a/src/public/css/index.css +++ b/src/public/css/index.css @@ -24,6 +24,36 @@ body:has(:focus) { height: 100vh; } +.frame { + position: fixed; + -webkit-app-region: drag; + width: 100%; + display: flex; + justify-content: right; + align-items: center; + background: #101010; + padding: 8px 0; +} + +.frame #buttons { + padding: 0 6px; +} + +.frame #buttons button { + font-size: 1.6rem; + cursor: pointer; + background: transparent; + color: #606060; + border: none; + margin: 0 4px; + -webkit-app-region: no-drag; + transition: 250ms all; +} + +.frame #buttons button:hover { + color: #ffffff; +} + #legend { font-family: 'Raleway', sans-serif; font-size: 2.8rem; @@ -104,7 +134,7 @@ body:has(:focus) { #about-btn { position: absolute; - top: 0; + top: 40px; left: 0; font-size: 2.3rem; background: transparent; @@ -126,7 +156,7 @@ body:has(:focus) { #background-btn { position: absolute; - top: 0; + top: 40px; right: 0; font-size: 2.3rem; background: transparent; diff --git a/src/public/index.html b/src/public/index.html index 8cfa1df..6aaecdc 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -10,6 +10,20 @@ +
+
+ + + +
+
+
From 9816b1c55284c5ad895394aebbc8143c336648c4 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 13 Jan 2023 13:45:34 -0400 Subject: [PATCH 004/103] custom frame logics done --- src/index.ts | 15 +++++++++++++++ src/public/js/index.js | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/index.ts b/src/index.ts index 641af88..367e3da 100644 --- a/src/index.ts +++ b/src/index.ts @@ -79,6 +79,21 @@ function selectBackground() { } /* IPC */ +ipcMain.on('minimize-main', (event) => { + // Minimize the main window + main.minimize(); +}); + +ipcMain.on('maximize-main', (event) => { + // Maximize the main window + main.maximize(); +}); + +ipcMain.on('close-main', (event) => { + // Close the main window + main.close(); +}); + ipcMain.on('new-search', (event, search: string) => { if (search.trim() == '') return; diff --git a/src/public/js/index.js b/src/public/js/index.js index 1cdd578..563a7c8 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -1,5 +1,20 @@ const { ipcRenderer } = require('electron'); +/* Window Frame */ + +// Minimzize button +document.getElementById('minimize').addEventListener('click', () => { + ipcRenderer.send('minimize-main'); +}); +// Maximize button +document.getElementById('maximize').addEventListener('click', () => { + ipcRenderer.send('maximize-main'); +}); +// Close button +document.getElementById('close').addEventListener('click', () => { + ipcRenderer.send('close-main'); +}); + /* Configs */ ipcRenderer.on('update-background', (event, file) => { console.log(`Updating background image to ${file}`); From e5064b639c9ab4f9c26adaeca7507f3d7f228696 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 13 Jan 2023 13:56:41 -0400 Subject: [PATCH 005/103] working on new tab system --- src/tabs/BrowserTab.ts | 15 +++++++++++++++ src/tabs/TabsManager.ts | 7 +++++++ 2 files changed, 22 insertions(+) create mode 100644 src/tabs/BrowserTab.ts create mode 100644 src/tabs/TabsManager.ts diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts new file mode 100644 index 0000000..50b1d08 --- /dev/null +++ b/src/tabs/BrowserTab.ts @@ -0,0 +1,15 @@ +export default class BrowserTab { + #url : string; + constructor(url: string) { + this.#url = url; + } + + initTab() { + fetch(this.#url) + .then((res) => res.text()) + .then((res) => console.log(res)) + .catch((err) => { + console.error(`${err}`); + }); + } +} \ No newline at end of file diff --git a/src/tabs/TabsManager.ts b/src/tabs/TabsManager.ts new file mode 100644 index 0000000..bf34569 --- /dev/null +++ b/src/tabs/TabsManager.ts @@ -0,0 +1,7 @@ +import BrowserTab from "./BrowserTab.js"; + +export default class TabsManager { + static createTab(url: string, title?: string) : BrowserTab { + return new BrowserTab(url); + } +} \ No newline at end of file From d14575cdddd6ed5aa410ae913c83ff9e6ef0b2c5 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 13 Jan 2023 14:04:12 -0400 Subject: [PATCH 006/103] Revert "working on new tab system" --- src/tabs/BrowserTab.ts | 15 --------------- src/tabs/TabsManager.ts | 7 ------- 2 files changed, 22 deletions(-) delete mode 100644 src/tabs/BrowserTab.ts delete mode 100644 src/tabs/TabsManager.ts diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts deleted file mode 100644 index 50b1d08..0000000 --- a/src/tabs/BrowserTab.ts +++ /dev/null @@ -1,15 +0,0 @@ -export default class BrowserTab { - #url : string; - constructor(url: string) { - this.#url = url; - } - - initTab() { - fetch(this.#url) - .then((res) => res.text()) - .then((res) => console.log(res)) - .catch((err) => { - console.error(`${err}`); - }); - } -} \ No newline at end of file diff --git a/src/tabs/TabsManager.ts b/src/tabs/TabsManager.ts deleted file mode 100644 index bf34569..0000000 --- a/src/tabs/TabsManager.ts +++ /dev/null @@ -1,7 +0,0 @@ -import BrowserTab from "./BrowserTab.js"; - -export default class TabsManager { - static createTab(url: string, title?: string) : BrowserTab { - return new BrowserTab(url); - } -} \ No newline at end of file From c566cece00e54d51e2cfd2e7bb6551460fd5c274 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 13 Jan 2023 14:30:01 -0400 Subject: [PATCH 007/103] create new tab button --- src/index.ts | 4 ++++ src/public/index.html | 9 ++++++--- src/public/js/index.js | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 367e3da..d4b759e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -79,6 +79,10 @@ function selectBackground() { } /* IPC */ +ipcMain.on('new-tab', (event) => { + console.log(`[OK] create new tab`); +}); + ipcMain.on('minimize-main', (event) => { // Minimize the main window main.minimize(); diff --git a/src/public/index.html b/src/public/index.html index 6aaecdc..6268f01 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -12,13 +12,16 @@
- + - -
diff --git a/src/public/js/index.js b/src/public/js/index.js index 563a7c8..cf090b9 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -1,7 +1,10 @@ const { ipcRenderer } = require('electron'); /* Window Frame */ - +// New Tab Button +document.getElementById('new-tab').addEventListener('click', () => { + ipcRenderer.send('new-tab'); +}); // Minimzize button document.getElementById('minimize').addEventListener('click', () => { ipcRenderer.send('minimize-main'); From 6064cc1fa8518de90305af0928b0d5c664dcd287 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 13 Jan 2023 15:02:13 -0400 Subject: [PATCH 008/103] create tab instance --- src/index.ts | 2 ++ src/public/js/index.js | 5 +++++ src/tabs/BrowserTab.ts | 15 +++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/tabs/BrowserTab.ts diff --git a/src/index.ts b/src/index.ts index d4b759e..264b4cb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import { app, BrowserWindow, ipcMain, Menu, MenuItemConstructorOptions } from 'electron'; +import BrowserTab from './tabs/BrowserTab.js'; import configs from './config/app.json'; import './config/user.json'; import fs from 'fs'; @@ -81,6 +82,7 @@ function selectBackground() { /* IPC */ ipcMain.on('new-tab', (event) => { console.log(`[OK] create new tab`); + main.webContents.send('new-tab', new BrowserTab(`https://yisusgaming.github.io`, 0).build()); }); ipcMain.on('minimize-main', (event) => { diff --git a/src/public/js/index.js b/src/public/js/index.js index cf090b9..06a0d7e 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -1,5 +1,10 @@ const { ipcRenderer } = require('electron'); +/* Tabs */ +ipcRenderer.on('new-tab', (event, tab) => { + alert(tab); +}); + /* Window Frame */ // New Tab Button document.getElementById('new-tab').addEventListener('click', () => { diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts new file mode 100644 index 0000000..ca0954c --- /dev/null +++ b/src/tabs/BrowserTab.ts @@ -0,0 +1,15 @@ +export default class BrowserTab { + #HTML : string; + #url : string; + #id : number; + constructor(url: string, id: number) { + this.#url = url; + this.#id = id + this.#HTML = `
Tab ${id + 1}
`; + } + + build() { + console.log(`[OK] build for tab ${this.#id}:${this.#url}`); + return this.#HTML; + } +} \ No newline at end of file From 913c506d2d70a1ddc65e9f3b6eb7f9083424dab5 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 5 Feb 2023 10:39:27 -0400 Subject: [PATCH 009/103] tab manager --- src/tabs/TabManager.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/tabs/TabManager.ts diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts new file mode 100644 index 0000000..ebc4437 --- /dev/null +++ b/src/tabs/TabManager.ts @@ -0,0 +1,19 @@ +import BrowserTab from "./BrowserTab.js"; + +class TabManager { + #tabs: BrowserTab[]; + #activeTab: number + constructor() { + this.#tabs = []; + this.#activeTab = 0; + } + + createNewTab(url: string, id: number) : BrowserTab { + let tab = new BrowserTab(url, id); + this.#tabs.push(tab); + + return tab; + } +} + +export default new TabManager(); \ No newline at end of file From 6d961cbef1a2486f7df429d79783ec8bbf70ab9d Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 5 Feb 2023 10:57:36 -0400 Subject: [PATCH 010/103] auto generate the tab id --- src/tabs/TabManager.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index ebc4437..a0e0c84 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -8,12 +8,17 @@ class TabManager { this.#activeTab = 0; } - createNewTab(url: string, id: number) : BrowserTab { - let tab = new BrowserTab(url, id); + createNewTab(url: string) : BrowserTab { + let id = this.#tabs.length - 1; + let tab = new BrowserTab(url, id >= 0 ? id : 0); this.#tabs.push(tab); return tab; } + + updateActiveTab(tabId: number) { + this.#activeTab = tabId; + } } export default new TabManager(); \ No newline at end of file From 83356cbe31e279c31aabda5fe571dc0c5a2e0234 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 5 Feb 2023 11:02:19 -0400 Subject: [PATCH 011/103] use tab manager at index.ts --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 264b4cb..db92ab4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import { app, BrowserWindow, ipcMain, Menu, MenuItemConstructorOptions } from 'electron'; -import BrowserTab from './tabs/BrowserTab.js'; +import TabManager from './tabs/TabManager.js'; import configs from './config/app.json'; import './config/user.json'; import fs from 'fs'; @@ -82,7 +82,7 @@ function selectBackground() { /* IPC */ ipcMain.on('new-tab', (event) => { console.log(`[OK] create new tab`); - main.webContents.send('new-tab', new BrowserTab(`https://yisusgaming.github.io`, 0).build()); + main.webContents.send('new-tab', TabManager.createNewTab('https://yisusgaming.github.io').build()); }); ipcMain.on('minimize-main', (event) => { From a60b098f7d6213b0e839a9101ca2b030c3903f50 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 5 Feb 2023 11:21:59 -0400 Subject: [PATCH 012/103] refactor: set main window as the parent of backgroundSelect window --- src/index.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index db92ab4..0b9f1b4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,15 +33,6 @@ app.on('ready', () => { main.webContents.send('update-background', configs.background); }); - main.on('close', () => { - if (backgroundSelect != null) { - try { - backgroundSelect.close(); - } catch(err) { - console.log(`[FAILED] close background select window [->] ${err}.`); - } - } - }); }); function searchWindow(url: string) { @@ -73,7 +64,8 @@ function selectBackground() { contextIsolation: false }, minimizable: false, - maximizable: false + maximizable: false, + parent: main }); backgroundSelect.setMenu(null); backgroundSelect.loadFile(path.join(publicPath, 'background.html')); From b4b14178fba2d4923769fed5357064bddcdde09a Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 5 Feb 2023 12:15:20 -0400 Subject: [PATCH 013/103] removed all new tab logics This logic has been removed in order to create the new tab behavior. Using BrowserWindows and modals. --- src/index.ts | 6 ------ src/public/index.html | 3 --- src/public/js/index.js | 9 --------- 3 files changed, 18 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0b9f1b4..c879c83 100644 --- a/src/index.ts +++ b/src/index.ts @@ -71,12 +71,6 @@ function selectBackground() { backgroundSelect.loadFile(path.join(publicPath, 'background.html')); } -/* IPC */ -ipcMain.on('new-tab', (event) => { - console.log(`[OK] create new tab`); - main.webContents.send('new-tab', TabManager.createNewTab('https://yisusgaming.github.io').build()); -}); - ipcMain.on('minimize-main', (event) => { // Minimize the main window main.minimize(); diff --git a/src/public/index.html b/src/public/index.html index 6268f01..454b7b4 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -12,9 +12,6 @@
- diff --git a/src/public/js/index.js b/src/public/js/index.js index 06a0d7e..9eb1432 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -1,15 +1,6 @@ const { ipcRenderer } = require('electron'); -/* Tabs */ -ipcRenderer.on('new-tab', (event, tab) => { - alert(tab); -}); - /* Window Frame */ -// New Tab Button -document.getElementById('new-tab').addEventListener('click', () => { - ipcRenderer.send('new-tab'); -}); // Minimzize button document.getElementById('minimize').addEventListener('click', () => { ipcRenderer.send('minimize-main'); From bf316307cd266b5c691ff98f4e64af0b3f87441e Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 5 Feb 2023 12:24:58 -0400 Subject: [PATCH 014/103] changelog --- changelog.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog.txt diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 0000000..ca4eca9 --- /dev/null +++ b/changelog.txt @@ -0,0 +1,6 @@ +[1.2.2 -> 2.0.0] => { + Features => { + [DONE] Custom App Frame. + [WORKING] New Tab System. + } +} \ No newline at end of file From d816fdf099cb91bb9a14d068fdb54f2fd3f69c68 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 5 Feb 2023 12:50:03 -0400 Subject: [PATCH 015/103] changes to search window Some changes that should allow the implementation of the new tab system --- src/index.ts | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/index.ts b/src/index.ts index c879c83..0bd0af3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,22 +38,14 @@ app.on('ready', () => { function searchWindow(url: string) { searchWin = new BrowserWindow({ title: `Searching ${url}...`, - minimizable: false + parent: main, + modal: true, + frame: false, + width: main.getSize()[0], + height: main.getSize()[1], + resizable: false }); searchWin.loadURL(url); - - const menuTemplate: Array = [ - { - label: 'Refresh', - role: 'reload' - }, - { - label: 'Inspect', - role: 'toggleDevTools' - } - ] - - searchWin.setMenu(Menu.buildFromTemplate(menuTemplate)); } function selectBackground() { From 02209a59f026cde0ebb8304cc1d3900d894fca51 Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 9 Feb 2023 13:08:03 -0400 Subject: [PATCH 016/103] fixed random browser's page link --- changelog.txt | 3 +++ src/public/js/index.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index ca4eca9..e5e9fbb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,4 +3,7 @@ [DONE] Custom App Frame. [WORKING] New Tab System. } + Fixes => { + [DONE] Fixed Random Browser's Page Link. + } } \ No newline at end of file diff --git a/src/public/js/index.js b/src/public/js/index.js index 9eb1432..19c0f20 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -22,7 +22,7 @@ ipcRenderer.on('update-background', (event, file) => { /* Learn Page */ document.getElementById('about-btn').addEventListener('click', (event) => { - ipcRenderer.send('new-search', 'https://yisusgaming.github.io/random-browser'); + ipcRenderer.send('new-search', 'https://yisusgaming.github.io/random-browser-page'); }); /* Browser Background */ From 9779444dda0fff17c6acbb5235408861bad33b55 Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 9 Feb 2023 13:35:51 -0400 Subject: [PATCH 017/103] better tabModal alignment --- src/index.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0bd0af3..24a5ffe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,7 @@ const userConfigPath = path.join(__dirname, 'config', 'user.json'); console.log(`Looking for user's configs in ${userConfigPath}`); let main : BrowserWindow; -let searchWin : BrowserWindow; +let tabModal : BrowserWindow; let backgroundSelect : BrowserWindow; app.on('ready', () => { main = new BrowserWindow({ @@ -35,17 +35,19 @@ app.on('ready', () => { }); }); -function searchWindow(url: string) { - searchWin = new BrowserWindow({ +function spawnTab(url: string) { + tabModal = new BrowserWindow({ title: `Searching ${url}...`, parent: main, modal: true, frame: false, width: main.getSize()[0], height: main.getSize()[1], + x: main.getBounds().x, + y: main.getBounds().y, resizable: false }); - searchWin.loadURL(url); + tabModal.loadURL(url); } function selectBackground() { @@ -83,14 +85,14 @@ ipcMain.on('new-search', (event, search: string) => { if (/[*.*]/g.test(search)) { if (search.startsWith('https://') || search.startsWith('http://')) { - searchWindow(search); + spawnTab(search); return; } - searchWindow(`https://${search}`); + spawnTab(`https://${search}`); return; } - searchWindow(`https://google.com/search?q=${search}`); + spawnTab(`https://google.com/search?q=${search}`); }); ipcMain.on('new-background-image', (event) => { From 2dc934405af13a4346dde9d44bfdd96c4248eb6c Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 9 Feb 2023 17:06:15 -0400 Subject: [PATCH 018/103] implemented a logger Implemented a logger class that should help printing all logs in one format while keeping them organized. --- src/index.ts | 7 +++++-- src/logs/Logger.ts | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/logs/Logger.ts diff --git a/src/index.ts b/src/index.ts index 24a5ffe..79f0e41 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,16 @@ import { app, BrowserWindow, ipcMain, Menu, MenuItemConstructorOptions } from 'electron'; -import TabManager from './tabs/TabManager.js'; +import Logger from './logs/Logger.js'; import configs from './config/app.json'; import './config/user.json'; import fs from 'fs'; import path from 'path'; +const logger = new Logger(configs.version); // Instance of the logger class for future console logs. + const publicPath = path.join(__dirname, 'public'); const userConfigPath = path.join(__dirname, 'config', 'user.json'); -console.log(`Looking for user's configs in ${userConfigPath}`); +// console.log(`Looking for user's configs in ${userConfigPath}`); +logger.logMessage(`Looking for user's configs in ${userConfigPath}`); let main : BrowserWindow; let tabModal : BrowserWindow; diff --git a/src/logs/Logger.ts b/src/logs/Logger.ts new file mode 100644 index 0000000..73497da --- /dev/null +++ b/src/logs/Logger.ts @@ -0,0 +1,33 @@ +export default class Logger { + private browserVersion: string; + + /** + * The logger class. + * + * Use this print messages to stdout and stderr. + * @param browserVersion Random Browser's current version allocated in app.json + */ + constructor(browserVersion: string) { + this.browserVersion = browserVersion; + } + + logMessage(msg: string): void { + console.log(`[LOG:${this.browserVersion}] => ${msg}`); + } + + logWarning(warn: string): void { + console.warn(`[WARNING!] => ${warn} | ${this.browserVersion}`); + } + + logError(err: string | Error, origin: { file: string; line: number }): void { + if (typeof err == 'string') { + console.error( + `[ERR!] => ${err} | ${this.browserVersion} [${origin.file}:${origin.line}]` + ); + } else { + console.error( + `[ERR!] => ${err.name}: ${err.message} | ${this.browserVersion} [${origin.file}:${origin.line}]` + ); + } + } +} From 47ca94fc3e080db27f6ab0abcddc038b1b3e4ad6 Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 9 Feb 2023 17:18:24 -0400 Subject: [PATCH 019/103] well documented logger --- src/logs/Logger.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/logs/Logger.ts b/src/logs/Logger.ts index 73497da..2990724 100644 --- a/src/logs/Logger.ts +++ b/src/logs/Logger.ts @@ -1,24 +1,36 @@ +/** + * The logger class. + * @since v2.0.0 + * + * Prints messages to `stdout` and `stderr`. + */ export default class Logger { private browserVersion: string; /** - * The logger class. - * - * Use this print messages to stdout and stderr. - * @param browserVersion Random Browser's current version allocated in app.json + * @param browserVersion Random Browser's current version allocated in `app.json` */ constructor(browserVersion: string) { this.browserVersion = browserVersion; } + /** + * Prints a message to the `stdout`. + */ logMessage(msg: string): void { console.log(`[LOG:${this.browserVersion}] => ${msg}`); } + /** + * Prints a warning to the `stderr`. + */ logWarning(warn: string): void { console.warn(`[WARNING!] => ${warn} | ${this.browserVersion}`); } + /** + * Prints an string or an Error to stderr. + */ logError(err: string | Error, origin: { file: string; line: number }): void { if (typeof err == 'string') { console.error( From 5cd346c524274ffaccec3f4f5eb04160b9ab86a9 Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 9 Feb 2023 17:29:02 -0400 Subject: [PATCH 020/103] some more logs --- src/index.ts | 2 ++ src/logs/Logger.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 79f0e41..df4fd96 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,6 +16,7 @@ let main : BrowserWindow; let tabModal : BrowserWindow; let backgroundSelect : BrowserWindow; app.on('ready', () => { + logger.logMessage(`App is ready.`); main = new BrowserWindow({ title: 'Random Browser - Loading...', webPreferences: { @@ -28,6 +29,7 @@ app.on('ready', () => { Menu.setApplicationMenu(null); main.loadFile(path.join(publicPath, 'index.html')); main.on('ready-to-show', () => { + logger.logMessage(`Main window ready to show.`); main.show(); main.maximize(); diff --git a/src/logs/Logger.ts b/src/logs/Logger.ts index 2990724..d3af72e 100644 --- a/src/logs/Logger.ts +++ b/src/logs/Logger.ts @@ -29,7 +29,7 @@ export default class Logger { } /** - * Prints an string or an Error to stderr. + * Prints an `string` or an `Error` to `stderr`. */ logError(err: string | Error, origin: { file: string; line: number }): void { if (typeof err == 'string') { From bf24451d00161d225f15068832d1dfa50ab57acd Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 9 Feb 2023 17:50:15 -0400 Subject: [PATCH 021/103] better looking tab modal --- src/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/index.ts b/src/index.ts index df4fd96..076505f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -52,6 +52,14 @@ function spawnTab(url: string) { y: main.getBounds().y, resizable: false }); + + // Center the tab modal if the main window is maximized to make sure it fills all the screen. + if (main.isMaximized()) { + tabModal.setBounds({ + x: 0, + y: 0 + }); + } tabModal.loadURL(url); } From 5c2f6abc191eb323dbb77d5689924d89cd5245a8 Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 9 Feb 2023 18:26:54 -0400 Subject: [PATCH 022/103] working with new tab system --- src/index.ts | 23 +++--------------- src/tabs/BrowserTab.ts | 54 +++++++++++++++++++++++++++++++++--------- src/tabs/TabManager.ts | 21 +++++++--------- 3 files changed, 55 insertions(+), 43 deletions(-) diff --git a/src/index.ts b/src/index.ts index 076505f..9db25d8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import { app, BrowserWindow, ipcMain, Menu, MenuItemConstructorOptions } from 'electron'; import Logger from './logs/Logger.js'; +import TabManager from './tabs/TabManager.js'; import configs from './config/app.json'; import './config/user.json'; import fs from 'fs'; @@ -41,26 +42,8 @@ app.on('ready', () => { }); function spawnTab(url: string) { - tabModal = new BrowserWindow({ - title: `Searching ${url}...`, - parent: main, - modal: true, - frame: false, - width: main.getSize()[0], - height: main.getSize()[1], - x: main.getBounds().x, - y: main.getBounds().y, - resizable: false - }); - - // Center the tab modal if the main window is maximized to make sure it fills all the screen. - if (main.isMaximized()) { - tabModal.setBounds({ - x: 0, - y: 0 - }); - } - tabModal.loadURL(url); + // Create a new tab and right after build it so the tab shows up. + tabModal = TabManager.createTab(url, main).build(); } function selectBackground() { diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index ca0954c..65b7e0e 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -1,15 +1,47 @@ +import { BrowserWindow } from 'electron'; + +/** + * The BrowserTab class. + * This class shouldn't be instanced directly. Use `TabManager.createTab` instead. + */ export default class BrowserTab { - #HTML : string; - #url : string; - #id : number; - constructor(url: string, id: number) { - this.#url = url; - this.#id = id - this.#HTML = `
Tab ${id + 1}
`; + private url: string; + private parent: BrowserWindow; + + /** + * @param url The URL the tab is pointing to. + * @param parent The parent of this modal. It should be the main browser's window. + */ + constructor(url: string, parent: BrowserWindow) { + this.url = url; + this.parent = parent; } - build() { - console.log(`[OK] build for tab ${this.#id}:${this.#url}`); - return this.#HTML; + /** + * Builds, shows and returns the tab modal. + */ + public build(): BrowserWindow { + let tabModal = new BrowserWindow({ + title: `Searching ${this.url}...`, + parent: this.parent, + modal: true, + frame: false, + width: this.parent.getSize()[0], + height: this.parent.getSize()[1], + x: this.parent.getBounds().x, + y: this.parent.getBounds().y, + resizable: false, + }); + + // Center the tab modal if the main window is maximized to make sure it fills all the screen. + if (this.parent.isMaximized()) { + tabModal.setBounds({ + x: 0, + y: 0, + }); + } + tabModal.loadURL(this.url); + + return tabModal; } -} \ No newline at end of file +} diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index a0e0c84..23c72e2 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -1,24 +1,21 @@ +import { BrowserWindow } from "electron"; import BrowserTab from "./BrowserTab.js"; class TabManager { - #tabs: BrowserTab[]; - #activeTab: number + private tabs: BrowserTab[]; constructor() { - this.#tabs = []; - this.#activeTab = 0; + this.tabs = []; } - createNewTab(url: string) : BrowserTab { - let id = this.#tabs.length - 1; - let tab = new BrowserTab(url, id >= 0 ? id : 0); - this.#tabs.push(tab); + /** + * Creates a new tab and stores it in a list of tabs. + */ + public createTab(url: string, parent: BrowserWindow): BrowserTab { + let tab = new BrowserTab(url, parent); + this.tabs.push(tab); return tab; } - - updateActiveTab(tabId: number) { - this.#activeTab = tabId; - } } export default new TabManager(); \ No newline at end of file From 4753b5ec5e7702c7c66232c109ea79c86a7ff5c4 Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 9 Feb 2023 19:19:57 -0400 Subject: [PATCH 023/103] working on tab menubar + done tab id system --- src/tabs/BrowserTab.ts | 33 +++++++++++++++++++++++++++++++-- src/tabs/TabManager.ts | 9 +++++---- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index 65b7e0e..adf481a 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -1,4 +1,4 @@ -import { BrowserWindow } from 'electron'; +import { BrowserWindow, Menu, MenuItemConstructorOptions } from 'electron'; /** * The BrowserTab class. @@ -7,14 +7,42 @@ import { BrowserWindow } from 'electron'; export default class BrowserTab { private url: string; private parent: BrowserWindow; + private tabId: number; /** * @param url The URL the tab is pointing to. * @param parent The parent of this modal. It should be the main browser's window. + * @param tabId A zero-based id that identifies this tab. Provided automatically if the tab instance was created with `TabManager.createTab`. */ - constructor(url: string, parent: BrowserWindow) { + constructor(url: string, parent: BrowserWindow, tabId: number) { this.url = url; this.parent = parent; + this.tabId = tabId; + } + + private tabMenu(): Menu { + let template: MenuItemConstructorOptions[] = [ + { + label: `Tab ${this.tabId + 1}` + }, + { + type: 'separator' + }, + { + label: 'Close Tab', + role: 'close' + }, + { + label: 'Refresh Page', + role: 'reload' + }, + { + label: 'Inspect page', + role: 'toggleDevTools' + } + ]; + + return Menu.buildFromTemplate(template); } /** @@ -32,6 +60,7 @@ export default class BrowserTab { y: this.parent.getBounds().y, resizable: false, }); + tabModal.setMenu(this.tabMenu()); // Center the tab modal if the main window is maximized to make sure it fills all the screen. if (this.parent.isMaximized()) { diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index 23c72e2..470bec8 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -1,5 +1,5 @@ -import { BrowserWindow } from "electron"; -import BrowserTab from "./BrowserTab.js"; +import { BrowserWindow } from 'electron'; +import BrowserTab from './BrowserTab.js'; class TabManager { private tabs: BrowserTab[]; @@ -11,11 +11,12 @@ class TabManager { * Creates a new tab and stores it in a list of tabs. */ public createTab(url: string, parent: BrowserWindow): BrowserTab { - let tab = new BrowserTab(url, parent); + let tabId = this.tabs.length; + let tab = new BrowserTab(url, parent, tabId); this.tabs.push(tab); return tab; } } -export default new TabManager(); \ No newline at end of file +export default new TabManager(); From 6cbf7ef2f3a88167888d867f4fb2936ce4ae7ef4 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 10 Feb 2023 12:50:19 -0400 Subject: [PATCH 024/103] tab context menu --- src/tabs/BrowserTab.ts | 60 +++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index adf481a..358e734 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -22,23 +22,58 @@ export default class BrowserTab { private tabMenu(): Menu { let template: MenuItemConstructorOptions[] = [ - { - label: `Tab ${this.tabId + 1}` - }, { type: 'separator' }, { - label: 'Close Tab', - role: 'close' + label: 'Page Actions', + submenu: [ + { + role: 'copy' + }, + { + role: 'cut' + }, + { + role: 'paste' + }, + { + role: 'undo' + }, + { + role: 'redo' + }, + { + label: 'Inspect', + role: 'toggleDevTools' + } + ] }, { - label: 'Refresh Page', - role: 'reload' + type: 'separator' }, { - label: 'Inspect page', - role: 'toggleDevTools' + label: `Tab ${this.tabId + 1} Controls`, + submenu: [ + { + label: 'Close Tab', + role: 'close' + }, + { + label: 'Zoom', + submenu: [ + { + role: 'zoomIn' + }, + { + role: 'zoomOut' + }, + { + role: 'resetZoom' + } + ] + } + ] } ]; @@ -60,7 +95,12 @@ export default class BrowserTab { y: this.parent.getBounds().y, resizable: false, }); - tabModal.setMenu(this.tabMenu()); + + tabModal.webContents.addListener('context-menu', () => { + this.tabMenu().popup({ + window: tabModal + }); + }); // Center the tab modal if the main window is maximized to make sure it fills all the screen. if (this.parent.isMaximized()) { From efd028471ebe8b73c8fb8b51f84889ec70f4f955 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 10 Feb 2023 13:04:35 -0400 Subject: [PATCH 025/103] trying to work with html in tabs --- src/index.ts | 2 +- src/public/tab.html | 0 src/tabs/BrowserTab.ts | 7 +++++-- src/tabs/TabManager.ts | 8 ++++++-- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 src/public/tab.html diff --git a/src/index.ts b/src/index.ts index 9db25d8..5c44798 100644 --- a/src/index.ts +++ b/src/index.ts @@ -43,7 +43,7 @@ app.on('ready', () => { function spawnTab(url: string) { // Create a new tab and right after build it so the tab shows up. - tabModal = TabManager.createTab(url, main).build(); + tabModal = TabManager.createTab(url, path.join(publicPath, 'tab.html'), main).build(); } function selectBackground() { diff --git a/src/public/tab.html b/src/public/tab.html new file mode 100644 index 0000000..e69de29 diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index 358e734..5cbef58 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -6,16 +6,19 @@ import { BrowserWindow, Menu, MenuItemConstructorOptions } from 'electron'; */ export default class BrowserTab { private url: string; + private tabHtmlPath: string; private parent: BrowserWindow; private tabId: number; /** * @param url The URL the tab is pointing to. + * @param tabHtmlPath The path to the `tab.html` file. * @param parent The parent of this modal. It should be the main browser's window. * @param tabId A zero-based id that identifies this tab. Provided automatically if the tab instance was created with `TabManager.createTab`. */ - constructor(url: string, parent: BrowserWindow, tabId: number) { + constructor(url: string, tabHtmlPath: string, parent: BrowserWindow, tabId: number) { this.url = url; + this.tabHtmlPath = tabHtmlPath; this.parent = parent; this.tabId = tabId; } @@ -109,7 +112,7 @@ export default class BrowserTab { y: 0, }); } - tabModal.loadURL(this.url); + tabModal.loadFile(this.tabHtmlPath); return tabModal; } diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index 470bec8..1f60a63 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -9,10 +9,14 @@ class TabManager { /** * Creates a new tab and stores it in a list of tabs. + * @param url The URL the tab is pointing to. + * @param tabHtmlPath The path to the `tab.html` file. + * @param parent The parent of this modal. It should be the main browser's window. + * @param tabId A zero-based id that identifies this tab. */ - public createTab(url: string, parent: BrowserWindow): BrowserTab { + public createTab(url: string, tabHtmlPath: string, parent: BrowserWindow): BrowserTab { let tabId = this.tabs.length; - let tab = new BrowserTab(url, parent, tabId); + let tab = new BrowserTab(url, tabHtmlPath, parent, tabId); this.tabs.push(tab); return tab; From eb5bff38295c6c9d4d29c8787ad50145e36fe56b Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 10 Feb 2023 13:13:47 -0400 Subject: [PATCH 026/103] Revert "trying to work with html in tabs" This reverts commit efd028471ebe8b73c8fb8b51f84889ec70f4f955. --- src/index.ts | 2 +- src/public/tab.html | 0 src/tabs/BrowserTab.ts | 7 ++----- src/tabs/TabManager.ts | 8 ++------ 4 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 src/public/tab.html diff --git a/src/index.ts b/src/index.ts index 5c44798..9db25d8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -43,7 +43,7 @@ app.on('ready', () => { function spawnTab(url: string) { // Create a new tab and right after build it so the tab shows up. - tabModal = TabManager.createTab(url, path.join(publicPath, 'tab.html'), main).build(); + tabModal = TabManager.createTab(url, main).build(); } function selectBackground() { diff --git a/src/public/tab.html b/src/public/tab.html deleted file mode 100644 index e69de29..0000000 diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index 5cbef58..358e734 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -6,19 +6,16 @@ import { BrowserWindow, Menu, MenuItemConstructorOptions } from 'electron'; */ export default class BrowserTab { private url: string; - private tabHtmlPath: string; private parent: BrowserWindow; private tabId: number; /** * @param url The URL the tab is pointing to. - * @param tabHtmlPath The path to the `tab.html` file. * @param parent The parent of this modal. It should be the main browser's window. * @param tabId A zero-based id that identifies this tab. Provided automatically if the tab instance was created with `TabManager.createTab`. */ - constructor(url: string, tabHtmlPath: string, parent: BrowserWindow, tabId: number) { + constructor(url: string, parent: BrowserWindow, tabId: number) { this.url = url; - this.tabHtmlPath = tabHtmlPath; this.parent = parent; this.tabId = tabId; } @@ -112,7 +109,7 @@ export default class BrowserTab { y: 0, }); } - tabModal.loadFile(this.tabHtmlPath); + tabModal.loadURL(this.url); return tabModal; } diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index 1f60a63..470bec8 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -9,14 +9,10 @@ class TabManager { /** * Creates a new tab and stores it in a list of tabs. - * @param url The URL the tab is pointing to. - * @param tabHtmlPath The path to the `tab.html` file. - * @param parent The parent of this modal. It should be the main browser's window. - * @param tabId A zero-based id that identifies this tab. */ - public createTab(url: string, tabHtmlPath: string, parent: BrowserWindow): BrowserTab { + public createTab(url: string, parent: BrowserWindow): BrowserTab { let tabId = this.tabs.length; - let tab = new BrowserTab(url, tabHtmlPath, parent, tabId); + let tab = new BrowserTab(url, parent, tabId); this.tabs.push(tab); return tab; From c09ffdae4ad13c59c2f1a7878a5c2fd17c089225 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 10 Feb 2023 13:39:30 -0400 Subject: [PATCH 027/103] store visited urls in array --- src/tabs/BrowserTab.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index 358e734..d6420f6 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -8,6 +8,8 @@ export default class BrowserTab { private url: string; private parent: BrowserWindow; private tabId: number; + private visitedUrls: string[]; + private currentUrl: number; /** * @param url The URL the tab is pointing to. @@ -18,6 +20,8 @@ export default class BrowserTab { this.url = url; this.parent = parent; this.tabId = tabId; + this.visitedUrls = []; + this.currentUrl = 0; } private tabMenu(): Menu { @@ -102,6 +106,16 @@ export default class BrowserTab { }); }); + tabModal.webContents.addListener('did-navigate', (event, url) => { + this.visitedUrls.push(url); + let index = this.visitedUrls.lastIndexOf(url); + // If index is equal or greater than 0 use index, + // otherwise, use 0. + this.currentUrl = index >= 0 ? index : 0; + + console.log(this.visitedUrls, this.currentUrl); + }); + // Center the tab modal if the main window is maximized to make sure it fills all the screen. if (this.parent.isMaximized()) { tabModal.setBounds({ From 4d10784c8b62f200b4b73191cf5236ab17606567 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 10 Feb 2023 14:18:05 -0400 Subject: [PATCH 028/103] some new features in tabs Added 'Go to First' feature; it goes back to the first search in the tab. Added 'Go Back' feature; it goes back one search in the tab. Added 'Go Forwards' feature; it goes forwards one search in the tab. --- src/tabs/BrowserTab.ts | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index d6420f6..ebcff08 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -24,8 +24,36 @@ export default class BrowserTab { this.currentUrl = 0; } - private tabMenu(): Menu { + /** + * @param window The window that owns this menu. + */ + private tabMenu(window: BrowserWindow): Menu { let template: MenuItemConstructorOptions[] = [ + { + label: 'Go to First', + click: () => { + this.currentUrl = 0; + window.loadURL(this.visitedUrls[this.currentUrl]); + } + }, + { + label: 'Go Back', + click: () => { + if (this.currentUrl <= 0) return; + + this.currentUrl--; + window.loadURL(this.visitedUrls[this.currentUrl]); + } + }, + { + label: 'Go Forwards', + click: () => { + if (this.currentUrl + 1 >= this.visitedUrls.length) return; + + this.currentUrl++; + window.loadURL(this.visitedUrls[this.currentUrl]); + } + }, { type: 'separator' }, @@ -101,13 +129,15 @@ export default class BrowserTab { }); tabModal.webContents.addListener('context-menu', () => { - this.tabMenu().popup({ + this.tabMenu(tabModal).popup({ window: tabModal }); }); tabModal.webContents.addListener('did-navigate', (event, url) => { - this.visitedUrls.push(url); + if (this.visitedUrls.lastIndexOf(url) == -1) { + this.visitedUrls.push(url); + } let index = this.visitedUrls.lastIndexOf(url); // If index is equal or greater than 0 use index, // otherwise, use 0. From 16cdbd2a38bcac43dca2a531a59217832dff8074 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 19 Mar 2023 15:50:22 -0400 Subject: [PATCH 029/103] added one more feature to the logger --- src/index.ts | 5 ++++- src/logs/Logger.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 9db25d8..9cfcbcb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,10 @@ import './config/user.json'; import fs from 'fs'; import path from 'path'; -const logger = new Logger(configs.version); // Instance of the logger class for future console logs. +// Instance of the logger class for future console logs. +// Also exports the instance for use in other files +// without the need of reinstance the class again. +export const logger = new Logger(configs.version); const publicPath = path.join(__dirname, 'public'); const userConfigPath = path.join(__dirname, 'config', 'user.json'); diff --git a/src/logs/Logger.ts b/src/logs/Logger.ts index d3af72e..43be05a 100644 --- a/src/logs/Logger.ts +++ b/src/logs/Logger.ts @@ -21,6 +21,15 @@ export default class Logger { console.log(`[LOG:${this.browserVersion}] => ${msg}`); } + /** + * Prints a message to the `stdout` with a label + * saying it should be removed before the app + * gets to production. + */ + tempLogMessage(msg: string): void { + console.log(`The following log is temporal and should be removed before production.\n[TEMPORAL LOG:${this.browserVersion}] => ${msg}`); + } + /** * Prints a warning to the `stderr`. */ From f7cc1b7f4e86a75f808d7dfc62d60a48236a9f83 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 19 Mar 2023 16:37:28 -0400 Subject: [PATCH 030/103] give the user information about the current page zoom --- src/tabs/BrowserTab.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index ebcff08..0724d0b 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -92,7 +92,7 @@ export default class BrowserTab { role: 'close' }, { - label: 'Zoom', + label: `Zoom (${Math.floor(window.webContents.zoomFactor * 100)}%)`, submenu: [ { role: 'zoomIn' From 93b1a92030188ecbd6e343114cf13e4853fd4816 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 19 Mar 2023 16:55:46 -0400 Subject: [PATCH 031/103] tabs container Currently starting with the UI for tabs. --- src/public/index.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/public/index.html b/src/public/index.html index 454b7b4..e1439bb 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -11,6 +11,12 @@
+
+
+

Tab 1

+ +
+
+
From f8f4cbc4c408f4bbbc73c8ec3c3a8400c5228315 Mon Sep 17 00:00:00 2001 From: Yisus Date: Mon, 3 Apr 2023 08:42:33 -0400 Subject: [PATCH 036/103] send tab builded signal to the tab's parent --- src/tabs/BrowserTab.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index 0724d0b..68a5a93 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -154,6 +154,7 @@ export default class BrowserTab { }); } tabModal.loadURL(this.url); + this.parent.webContents.send('tab-builded', this.tabId); return tabModal; } From 16ac456891950f7eefffb767f481f373c1da1ddd Mon Sep 17 00:00:00 2001 From: Yisus Date: Mon, 3 Apr 2023 08:58:11 -0400 Subject: [PATCH 037/103] update tabs in the UI dynamically --- src/public/index.html | 9 +-------- src/public/js/index.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/public/index.html b/src/public/index.html index c9ca3ce..713ee0f 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -11,14 +11,7 @@
-
-
-

Tab 1

- -
-
+
+
`; + tabsContainer.innerHTML += tabTemplate; +}); + /* Configs */ ipcRenderer.on('update-background', (event, file) => { console.log(`Updating background image to ${file}`); From 134b8903e3fc6cc89d28565b4070e49a8b7bdd68 Mon Sep 17 00:00:00 2001 From: Yisus Date: Mon, 3 Apr 2023 09:10:46 -0400 Subject: [PATCH 038/103] expose tab id --- src/tabs/BrowserTab.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index 68a5a93..82bbf87 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -24,6 +24,10 @@ export default class BrowserTab { this.currentUrl = 0; } + public get TabId() : number { + return this.tabId; + } + /** * @param window The window that owns this menu. */ From c123f61c1e05c9b162fe114b931d32b29586b3a4 Mon Sep 17 00:00:00 2001 From: Yisus Date: Mon, 3 Apr 2023 09:12:34 -0400 Subject: [PATCH 039/103] deleteTab function --- src/tabs/TabManager.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index 470bec8..ce2eb71 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -17,6 +17,13 @@ class TabManager { return tab; } + + public deleteTab(tabId: number) { + this.tabs.filter((tab) => { + tab.TabId != tabId; + }); + console.log(this.tabs); + } } export default new TabManager(); From d7ae1288a2080245a5b92e8abc068732c28f416f Mon Sep 17 00:00:00 2001 From: Yisus Date: Mon, 3 Apr 2023 09:13:24 -0400 Subject: [PATCH 040/103] some docs --- src/tabs/TabManager.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index ce2eb71..af68ce4 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -18,6 +18,9 @@ class TabManager { return tab; } + /** + * Deletes a tab from the tab list. + */ public deleteTab(tabId: number) { this.tabs.filter((tab) => { tab.TabId != tabId; From fbaf1c8fbfb6bf4074f2ae80edb2ce5e43931962 Mon Sep 17 00:00:00 2001 From: Yisus Date: Mon, 3 Apr 2023 09:58:22 -0400 Subject: [PATCH 041/103] done: delete tabs Now the user can delete tabs --- src/index.ts | 4 ++++ src/public/js/index.js | 8 +++++++- src/tabs/TabManager.ts | 6 ++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9cfcbcb..8c49e3a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -79,6 +79,10 @@ ipcMain.on('close-main', (event) => { main.close(); }); +ipcMain.on('tab-deleted', (event, tabId: number) => { + TabManager.deleteTab(tabId); +}); + ipcMain.on('new-search', (event, search: string) => { if (search.trim() == '') return; diff --git a/src/public/js/index.js b/src/public/js/index.js index 65d6299..799396e 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -20,11 +20,17 @@ ipcRenderer.on('tab-builded', (event, tabId) => { const tabTemplate = `

Tab ${tabId + 1}

-
`; tabsContainer.innerHTML += tabTemplate; + document.querySelectorAll('#delete-tab-btn').forEach(( /** @type {HTMLButtonElement} */ btn) => { + btn.onclick = () => { + btn.parentElement.remove(); + ipcRenderer.send('tab-deleted', Number(btn.dataset.tabId)); + } + }); }); /* Configs */ diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index af68ce4..c3cbdb6 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -22,8 +22,10 @@ class TabManager { * Deletes a tab from the tab list. */ public deleteTab(tabId: number) { - this.tabs.filter((tab) => { - tab.TabId != tabId; + this.tabs = this.tabs.filter((tab) => { + console.log(`${tab.TabId} != ${tabId}`); + console.log(tab.TabId != tabId); + return tab.TabId != tabId; }); console.log(this.tabs); } From ac753458078d2451778b9ee0ed62986856e4a12c Mon Sep 17 00:00:00 2001 From: Yisus Date: Mon, 3 Apr 2023 10:00:23 -0400 Subject: [PATCH 042/103] removed debug logs --- src/tabs/TabManager.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index c3cbdb6..6c76e42 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -23,11 +23,8 @@ class TabManager { */ public deleteTab(tabId: number) { this.tabs = this.tabs.filter((tab) => { - console.log(`${tab.TabId} != ${tabId}`); - console.log(tab.TabId != tabId); return tab.TabId != tabId; }); - console.log(this.tabs); } } From 1cb2d181732100031fd8e59f8e4427c095f75d9e Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 6 Apr 2023 15:30:24 -0400 Subject: [PATCH 043/103] fixed minor typo --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 8c49e3a..20025eb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,7 @@ import path from 'path'; // Instance of the logger class for future console logs. // Also exports the instance for use in other files -// without the need of reinstance the class again. +// without the need to reinstance the class again. export const logger = new Logger(configs.version); const publicPath = path.join(__dirname, 'public'); From 4aa58cb7cf76dbfca9722159a29db946436eaa56 Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 6 Apr 2023 15:40:33 -0400 Subject: [PATCH 044/103] open tab event --- src/index.ts | 4 ++++ src/public/js/index.js | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 20025eb..8096641 100644 --- a/src/index.ts +++ b/src/index.ts @@ -79,6 +79,10 @@ ipcMain.on('close-main', (event) => { main.close(); }); +ipcMain.on('open-tab', (event, tabId: number) => { + logger.logMessage(`Open tab with id ${tabId}`); +}); + ipcMain.on('tab-deleted', (event, tabId: number) => { TabManager.deleteTab(tabId); }); diff --git a/src/public/js/index.js b/src/public/js/index.js index 799396e..f7d0380 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -19,18 +19,23 @@ document.getElementById('close').addEventListener('click', () => { ipcRenderer.on('tab-builded', (event, tabId) => { const tabTemplate = `
-

Tab ${tabId + 1}

-
`; tabsContainer.innerHTML += tabTemplate; - document.querySelectorAll('#delete-tab-btn').forEach(( /** @type {HTMLButtonElement} */ btn) => { + document.querySelectorAll('.delete-tab-btn').forEach(( /** @type {HTMLButtonElement} */ btn) => { btn.onclick = () => { btn.parentElement.remove(); ipcRenderer.send('tab-deleted', Number(btn.dataset.tabId)); } }); + document.querySelectorAll(".tab-title").forEach(( /** @type {HTMLParagraphElement} */ title) => { + title.onclick = () => { + ipcRenderer.send('open-tab', Number(title.dataset.tabId)); + }; + }); }); /* Configs */ From 8d10d2512a3f44d6a38de18e6d67ba715833b6d8 Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 6 Apr 2023 16:29:51 -0400 Subject: [PATCH 045/103] only build new tabs --- src/public/js/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/public/js/index.js b/src/public/js/index.js index f7d0380..9c00ba9 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -17,6 +17,14 @@ document.getElementById('close').addEventListener('click', () => { /* Tabs */ ipcRenderer.on('tab-builded', (event, tabId) => { + /** @type {NodeListOf

Tab ${tabId + 1}

From 89b7fd011eb79acb08b9016fc4841bab406c8b70 Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 6 Apr 2023 16:32:40 -0400 Subject: [PATCH 046/103] added openTab function --- src/tabs/TabManager.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index 6c76e42..75d7f48 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -1,5 +1,6 @@ import { BrowserWindow } from 'electron'; import BrowserTab from './BrowserTab.js'; +import { logger } from '../index.js'; class TabManager { private tabs: BrowserTab[]; @@ -18,10 +19,26 @@ class TabManager { return tab; } + /** + * Opens a tab, previously created and stored in the + * tabs array. + */ + public openTab(tabId: number): void { + let tab = this.tabs[tabId]; + if (tab) { + tab.build(); + } else { + logger.logError(`TAB NOT FOUND. Tab id ${tabId} was not found.`, { + file: 'TabManager.ts', + line: 27 + }); + } + } + /** * Deletes a tab from the tab list. */ - public deleteTab(tabId: number) { + public deleteTab(tabId: number): void { this.tabs = this.tabs.filter((tab) => { return tab.TabId != tabId; }); From 3b67872398c0ea31714704c8b1a3d6b6dddcf2dd Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 6 Apr 2023 16:53:06 -0400 Subject: [PATCH 047/103] reworked openTab and deleteTab --- src/tabs/TabManager.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index 75d7f48..95a6740 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -24,7 +24,10 @@ class TabManager { * tabs array. */ public openTab(tabId: number): void { - let tab = this.tabs[tabId]; + let tabIndex = this.tabs.findIndex((val, index) => { + return val.TabId == tabId; + }); + let tab = this.tabs[tabIndex]; if (tab) { tab.build(); } else { @@ -39,9 +42,7 @@ class TabManager { * Deletes a tab from the tab list. */ public deleteTab(tabId: number): void { - this.tabs = this.tabs.filter((tab) => { - return tab.TabId != tabId; - }); + this.tabs.splice(tabId, 1); } } From 12d757ae7fa0a7946fd0a1a72e8051f4d084841d Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 6 Apr 2023 16:55:26 -0400 Subject: [PATCH 048/103] open tab --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 8096641..be76d30 100644 --- a/src/index.ts +++ b/src/index.ts @@ -80,7 +80,7 @@ ipcMain.on('close-main', (event) => { }); ipcMain.on('open-tab', (event, tabId: number) => { - logger.logMessage(`Open tab with id ${tabId}`); + TabManager.openTab(tabId); }); ipcMain.on('tab-deleted', (event, tabId: number) => { From 936685398dd460da4b1b2b7d846096712c4a9ce3 Mon Sep 17 00:00:00 2001 From: Yisus Date: Thu, 6 Apr 2023 17:14:25 -0400 Subject: [PATCH 049/103] updated changelog --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index d7357f7..2187a09 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,7 @@ [2.0.0] => { Features => { [DONE] Custom App Frame. - [WORKING] New Tab System. + [DONE] New Tab System. [PLANNED] New Settings Menu. [PLANNED] New Sidebar. [PLANNED] Search History. From c495781323a552e08a15e4100adfb42f743c2e06 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 7 Apr 2023 14:38:33 -0400 Subject: [PATCH 050/103] fixed: tabs were not deleting correctly --- src/tabs/TabManager.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index 95a6740..8816d4d 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -15,6 +15,8 @@ class TabManager { let tabId = this.tabs.length; let tab = new BrowserTab(url, parent, tabId); this.tabs.push(tab); + console.log("createTab:"); + console.log(this.tabs); return tab; } @@ -42,7 +44,11 @@ class TabManager { * Deletes a tab from the tab list. */ public deleteTab(tabId: number): void { - this.tabs.splice(tabId, 1); + console.log("deleteTab:"); + this.tabs = this.tabs.filter((tab, index) => { + return tab.TabId != tabId; + }); + console.log(this.tabs); } } From 264321e1784bc965c832f3ed23636db1f64c6701 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 7 Apr 2023 14:38:56 -0400 Subject: [PATCH 051/103] better tab UI --- src/public/css/index.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/public/css/index.css b/src/public/css/index.css index 4e74a0d..15c6e7d 100644 --- a/src/public/css/index.css +++ b/src/public/css/index.css @@ -50,12 +50,18 @@ body:has(:focus) { max-width: 100px; margin: 0 4px; background: #202020; + transition: 250ms; } .tab p { + cursor: pointer; font-family: 'Raleway', sans-serif; } +.tab:has(p:hover) { + background: #505050; +} + .tab button { background: transparent; border: none; From 420c265a986120c29bad46ed109a97352685d525 Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 7 Apr 2023 14:46:42 -0400 Subject: [PATCH 052/103] removed debug logs --- src/tabs/TabManager.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/tabs/TabManager.ts b/src/tabs/TabManager.ts index 8816d4d..4390a51 100644 --- a/src/tabs/TabManager.ts +++ b/src/tabs/TabManager.ts @@ -15,8 +15,6 @@ class TabManager { let tabId = this.tabs.length; let tab = new BrowserTab(url, parent, tabId); this.tabs.push(tab); - console.log("createTab:"); - console.log(this.tabs); return tab; } @@ -44,11 +42,9 @@ class TabManager { * Deletes a tab from the tab list. */ public deleteTab(tabId: number): void { - console.log("deleteTab:"); this.tabs = this.tabs.filter((tab, index) => { return tab.TabId != tabId; }); - console.log(this.tabs); } } From 67837069d8457a63d50c42056f22368457f8065d Mon Sep 17 00:00:00 2001 From: Yisus Date: Fri, 7 Apr 2023 15:04:02 -0400 Subject: [PATCH 053/103] removed user themes --- src/public/css/user.css | 0 src/public/index.html | 2 -- 2 files changed, 2 deletions(-) delete mode 100644 src/public/css/user.css diff --git a/src/public/css/user.css b/src/public/css/user.css deleted file mode 100644 index e69de29..0000000 diff --git a/src/public/index.html b/src/public/index.html index 713ee0f..1fb7acf 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -6,8 +6,6 @@ Random Browser - -
From bb81479d7a2fbe9f7b918687f5a42b6f48147555 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 8 Apr 2023 17:19:59 -0400 Subject: [PATCH 054/103] updated changelog --- changelog.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 2187a09..8e5847b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Features => { [DONE] Custom App Frame. [DONE] New Tab System. + [PLANNED] Download Progress Bar. [PLANNED] New Settings Menu. [PLANNED] New Sidebar. [PLANNED] Search History. @@ -10,4 +11,4 @@ Fixes => { [DONE] Fixed Random Browser's Page Link. } -} \ No newline at end of file +} From 240224bf0717dde28cf3e46c19c19cafec48e9f2 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 8 Apr 2023 17:34:23 -0400 Subject: [PATCH 055/103] downloaded browser assets --- src/public/assets/icons/circle-check-solid.svg | 1 + src/public/assets/icons/circle-xmark-solid.svg | 1 + src/public/assets/icons/image-solid.svg | 1 + src/public/assets/icons/sliders-solid.svg | 1 + src/public/assets/icons/square-minus-solid.svg | 1 + src/public/assets/icons/square-plus-solid.svg | 1 + src/public/assets/icons/square-xmark-solid.svg | 1 + 7 files changed, 7 insertions(+) create mode 100644 src/public/assets/icons/circle-check-solid.svg create mode 100644 src/public/assets/icons/circle-xmark-solid.svg create mode 100644 src/public/assets/icons/image-solid.svg create mode 100644 src/public/assets/icons/sliders-solid.svg create mode 100644 src/public/assets/icons/square-minus-solid.svg create mode 100644 src/public/assets/icons/square-plus-solid.svg create mode 100644 src/public/assets/icons/square-xmark-solid.svg diff --git a/src/public/assets/icons/circle-check-solid.svg b/src/public/assets/icons/circle-check-solid.svg new file mode 100644 index 0000000..e30cd69 --- /dev/null +++ b/src/public/assets/icons/circle-check-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/public/assets/icons/circle-xmark-solid.svg b/src/public/assets/icons/circle-xmark-solid.svg new file mode 100644 index 0000000..6445fc0 --- /dev/null +++ b/src/public/assets/icons/circle-xmark-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/public/assets/icons/image-solid.svg b/src/public/assets/icons/image-solid.svg new file mode 100644 index 0000000..1b5822d --- /dev/null +++ b/src/public/assets/icons/image-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/public/assets/icons/sliders-solid.svg b/src/public/assets/icons/sliders-solid.svg new file mode 100644 index 0000000..abe6649 --- /dev/null +++ b/src/public/assets/icons/sliders-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/public/assets/icons/square-minus-solid.svg b/src/public/assets/icons/square-minus-solid.svg new file mode 100644 index 0000000..5acbaa0 --- /dev/null +++ b/src/public/assets/icons/square-minus-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/public/assets/icons/square-plus-solid.svg b/src/public/assets/icons/square-plus-solid.svg new file mode 100644 index 0000000..4a0a4c0 --- /dev/null +++ b/src/public/assets/icons/square-plus-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/public/assets/icons/square-xmark-solid.svg b/src/public/assets/icons/square-xmark-solid.svg new file mode 100644 index 0000000..ac3c819 --- /dev/null +++ b/src/public/assets/icons/square-xmark-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file From 2ea2d6f652e818ae422f50fff9c44f1d99711dd4 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 13:53:05 -0400 Subject: [PATCH 056/103] updated changelog --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index 8e5847b..b7b1002 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Features => { [DONE] Custom App Frame. [DONE] New Tab System. + [PLANNED] Initial App Loader. [PLANNED] Download Progress Bar. [PLANNED] New Settings Menu. [PLANNED] New Sidebar. From cec1dc8b89136827f70393d167475652c69df053 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 13:59:22 -0400 Subject: [PATCH 057/103] working on feature 3 --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index b7b1002..ed573b1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,7 +2,7 @@ Features => { [DONE] Custom App Frame. [DONE] New Tab System. - [PLANNED] Initial App Loader. + [WORKING] Initial App Loader. [PLANNED] Download Progress Bar. [PLANNED] New Settings Menu. [PLANNED] New Sidebar. From 2e909211c221fbe61002112584bd19856d459b64 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 14:16:24 -0400 Subject: [PATCH 058/103] loader behavior done --- src/index.ts | 20 ++++++++++++++++++++ src/public/loader.html | 13 +++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/public/loader.html diff --git a/src/index.ts b/src/index.ts index be76d30..5c918b2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,8 +19,10 @@ logger.logMessage(`Looking for user's configs in ${userConfigPath}`); let main : BrowserWindow; let tabModal : BrowserWindow; let backgroundSelect : BrowserWindow; +let appLoader : BrowserWindow; app.on('ready', () => { logger.logMessage(`App is ready.`); + spawnAppLoader(); main = new BrowserWindow({ title: 'Random Browser - Loading...', webPreferences: { @@ -35,6 +37,7 @@ app.on('ready', () => { main.on('ready-to-show', () => { logger.logMessage(`Main window ready to show.`); main.show(); + appLoader.destroy(); main.maximize(); const rawConfig = fs.readFileSync(userConfigPath, { encoding: 'utf-8' }); @@ -44,6 +47,23 @@ app.on('ready', () => { }); }); +function spawnAppLoader() { + logger.logMessage("App loader spawned."); + appLoader = new BrowserWindow({ + title: 'Random Browser - Loading...', + closable: false, + maximizable: false, + resizable: false, + height: 400, + width: 320 + }); + appLoader.loadFile(path.join(publicPath, 'loader.html')); + appLoader.on('closed', () => { + logger.logMessage("App loader closed."); + main.flashFrame(true); + }); +} + function spawnTab(url: string) { // Create a new tab and right after build it so the tab shows up. tabModal = TabManager.createTab(url, main).build(); diff --git a/src/public/loader.html b/src/public/loader.html new file mode 100644 index 0000000..c19c4e0 --- /dev/null +++ b/src/public/loader.html @@ -0,0 +1,13 @@ + + + + + + + Random Browser - Loading... + + +

Hold on!

+

Getting everything set up...

+ + \ No newline at end of file From 9575c2a2945270ee8c845b21e812d49a46552fd8 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 14:18:38 -0400 Subject: [PATCH 059/103] reused assets folder --- src/public/assets/icon/icon.ico | Bin 0 -> 16958 bytes src/public/assets/icons/circle-check-solid.svg | 1 - src/public/assets/icons/circle-xmark-solid.svg | 1 - src/public/assets/icons/image-solid.svg | 1 - src/public/assets/icons/sliders-solid.svg | 1 - src/public/assets/icons/square-minus-solid.svg | 1 - src/public/assets/icons/square-plus-solid.svg | 1 - src/public/assets/icons/square-xmark-solid.svg | 1 - 8 files changed, 7 deletions(-) create mode 100644 src/public/assets/icon/icon.ico delete mode 100644 src/public/assets/icons/circle-check-solid.svg delete mode 100644 src/public/assets/icons/circle-xmark-solid.svg delete mode 100644 src/public/assets/icons/image-solid.svg delete mode 100644 src/public/assets/icons/sliders-solid.svg delete mode 100644 src/public/assets/icons/square-minus-solid.svg delete mode 100644 src/public/assets/icons/square-plus-solid.svg delete mode 100644 src/public/assets/icons/square-xmark-solid.svg diff --git a/src/public/assets/icon/icon.ico b/src/public/assets/icon/icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..874fbbdee0178dceec00a49182e5055724e68308 GIT binary patch literal 16958 zcmeHNc~n)$8GqQt)1Ia_ZS5Z%t0oeqD(C?fcn^3Bh^(?cS)Qm6#RU{ZQK`ETH)1qZ zG@>@uxTCn^j<}t~CB~#_o7S9^SnE+!H7-Hm&b_zacVVvc?z;~j@<8-(IUnE5yty;q z?>FD~&Ab7P#sz*11`Yh~u5mYMG{4hmH0~hKq?reT?b2hYQ|-Uo8E9vqoq=`++8JnP z;Ds~b0v4dW>W_=rtB+eju-D{`F@8sPCL3<;9d3FIQjN05V!FR8+3@A+h(RR_2KF9i zar^ZzUjaf~`giI4R<_@OJ@ZU{wR22=EO$$XJIu@0iM0ukR!O{=)B6*a5~xs`9W9_;VyOwe50|IM3rEKcVf}%h zG_bF>4RGL+Z}9oTQJjwSn-}CKtcvm{yTCX0r3MM7#)p&3^<13Jj9@tsa|ZMbdx0Fd zEDP0Lb_7#%`n(gY+(V85@dG$zCvwwb&AHREeu(&PR#H)S&ylsnzXvzD4wS7>G1q0ou!t9 zYB^d~YD2F#2ec#y^=mJD5Ub~uxN*&C+s>3AX^qxFzou|78~B>8_qADH7U#mjTA2&B z9m}(fzIOqCi=B^Bz51-cc{UF-*{uD>1UgKReu8-& z+rSU3zBjP_8Y}1N2VH3i{4)&w5?Q=zW#nd;B}ia>9(iH={wXR@!l;G=-vj@C?zOKU zQ|R5f^Dmsu!OAGVgDj4Q%3EQ*DLyrSL5@}d50t05kki%jIvt~_I&r{T8P3MPBgJ&L zA;g*KhtX|>y^|T&>RbtXh=4f){fYL$SVBK32=%Yc z)%(^ceIVS!E!rvIVUP*F{o?4ncfPzTvQPEH`{K3YMZ$r%!)3odIw_t2eu46EGB1hp zV19HjC^3cP#$I*`=vVz|J%AgBk6of{7)bJ zPyBqt5|R2l?T7l%*eG&3f4Iy8@;j z0>p>SSsP>O!vte3I~SIbH@c_J3HBP}Ec~N=JQL_#O8iy#zmwJAxEHj2XJRzEZaQntY)YfCS8#~k{ zR^!JiTH2!?S zIC5cW7I${R=o%U~s4=G=7#(3V1|3UH<6fHS*Dump_zfD(k6|7`d6s48E}IZbSnO=M zBF~~4|0i;XVV;n3r6c-SPJ+Wc#Cf`PaTb0U2hTq>aHb)6u3>SrWsGB7a~3;WMjoKQ zl|LVZ9D(~K?iCGk@W;A50&(IH2j!r0z#G0xfW0Ml(Jr37a=?AB0Sgd^GNS19* zrSqXq_54F$XXA(QI_yXedW!4M;^&@LiI<8C zBL;Iv(n7d-I*%-BZwqLbWs$-6Z(skXj2{aRDzA(CMh~^(0Px$K&y@I@QpbH_cdE5d zsl1PC-=PI?%R>(D+ud+w-)>Rhd6@$&SDrgg@mu-5ijB0N)AeHGfXT9elsmZ^bVO)roKi$iw#sg5OW=`2za% zez-F$8y!wQ$uryKVnb?Bek(w8c#1?%H{VT@##Y_==4&es9^JYj9-TT0eO~$j03m>Y< zD)c`IB0rVauGX^n*)n^lgmI5~|MK)i{D`{Y`iGq zL3eFa#)ban%==h883zB;oZP2}Da*&RXui?+uOPR9ho|de^i^Vn*#n;|@ZLuBfMJ(r8 z5cOrmhJOId0qKplgB}R790b1*vg;02iHp^35o2REf$bQ_|3MJX`5+e<3$HacS6lrY zY##@552UFNV!sF?`AA#E=ZIZ^VF<{lAWGkcCe;Tohu4F=wCk?M3*dE?-J2CIk`^=?si9h<>4Xj6YcxMXT?wZ<)boHm z)X3pn$Rw!s^|~AEl30fq;q_;_qcn^(5DX{jN>;J|U4>G+Xm;e9( literal 0 HcmV?d00001 diff --git a/src/public/assets/icons/circle-check-solid.svg b/src/public/assets/icons/circle-check-solid.svg deleted file mode 100644 index e30cd69..0000000 --- a/src/public/assets/icons/circle-check-solid.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/public/assets/icons/circle-xmark-solid.svg b/src/public/assets/icons/circle-xmark-solid.svg deleted file mode 100644 index 6445fc0..0000000 --- a/src/public/assets/icons/circle-xmark-solid.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/public/assets/icons/image-solid.svg b/src/public/assets/icons/image-solid.svg deleted file mode 100644 index 1b5822d..0000000 --- a/src/public/assets/icons/image-solid.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/public/assets/icons/sliders-solid.svg b/src/public/assets/icons/sliders-solid.svg deleted file mode 100644 index abe6649..0000000 --- a/src/public/assets/icons/sliders-solid.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/public/assets/icons/square-minus-solid.svg b/src/public/assets/icons/square-minus-solid.svg deleted file mode 100644 index 5acbaa0..0000000 --- a/src/public/assets/icons/square-minus-solid.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/public/assets/icons/square-plus-solid.svg b/src/public/assets/icons/square-plus-solid.svg deleted file mode 100644 index 4a0a4c0..0000000 --- a/src/public/assets/icons/square-plus-solid.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/public/assets/icons/square-xmark-solid.svg b/src/public/assets/icons/square-xmark-solid.svg deleted file mode 100644 index ac3c819..0000000 --- a/src/public/assets/icons/square-xmark-solid.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From 8d746ebf9e8db80b25cfc510aee8151b41b054df Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 14:25:25 -0400 Subject: [PATCH 060/103] added important comment --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 5c918b2..79aa129 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,7 +37,8 @@ app.on('ready', () => { main.on('ready-to-show', () => { logger.logMessage(`Main window ready to show.`); main.show(); - appLoader.destroy(); + // ! Make sure to destoy appLoader on production. + // appLoader.destroy(); main.maximize(); const rawConfig = fs.readFileSync(userConfigPath, { encoding: 'utf-8' }); From d4be3133258d90cc3c8c1d1379cd0f6674b81a26 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 14:34:56 -0400 Subject: [PATCH 061/103] loader styles --- src/public/css/loader.css | 18 ++++++++++++++++++ src/public/loader.html | 6 ++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/public/css/loader.css diff --git a/src/public/css/loader.css b/src/public/css/loader.css new file mode 100644 index 0000000..1e0b032 --- /dev/null +++ b/src/public/css/loader.css @@ -0,0 +1,18 @@ +@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@100;200;300;400;500;600;700&display=swap'); + +* { + margin: 0; + padding: 0; +} + +body { + height: 100vh; + width: 100vw; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-family: 'Raleway', sans-serif; + background: #202020; + color: #ffffff; +} \ No newline at end of file diff --git a/src/public/loader.html b/src/public/loader.html index c19c4e0..fe7078b 100644 --- a/src/public/loader.html +++ b/src/public/loader.html @@ -5,9 +5,11 @@ Random Browser - Loading... + -

Hold on!

-

Getting everything set up...

+ Random Browser Icon. If it's not visible, check your internet connection. +

Please wait,

+

Loading the browser...

\ No newline at end of file From ffebffb9406dd55c2d3be0c3797618e2c403b6dd Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 14:37:21 -0400 Subject: [PATCH 062/103] removed frame from app loader window --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 79aa129..ba8ffbf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,7 +37,7 @@ app.on('ready', () => { main.on('ready-to-show', () => { logger.logMessage(`Main window ready to show.`); main.show(); - // ! Make sure to destoy appLoader on production. + // ! Make sure to destoy appLoader in production. // appLoader.destroy(); main.maximize(); @@ -52,6 +52,7 @@ function spawnAppLoader() { logger.logMessage("App loader spawned."); appLoader = new BrowserWindow({ title: 'Random Browser - Loading...', + frame: false, closable: false, maximizable: false, resizable: false, From 57418a02dd230a414677a96bada29cbfc77ea95e Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 15:02:07 -0400 Subject: [PATCH 063/103] finished loader styles --- src/public/css/loader.css | 29 +++++++++++++++++++++++++++++ src/public/loader.html | 3 +++ 2 files changed, 32 insertions(+) diff --git a/src/public/css/loader.css b/src/public/css/loader.css index 1e0b032..c046089 100644 --- a/src/public/css/loader.css +++ b/src/public/css/loader.css @@ -6,8 +6,10 @@ } body { + position: relative; height: 100vh; width: 100vw; + -webkit-app-region: drag; display: flex; flex-direction: column; align-items: center; @@ -15,4 +17,31 @@ body { font-family: 'Raleway', sans-serif; background: #202020; color: #ffffff; +} + +.button-wrap { + position: fixed; + padding: 5px; + top: 0; + left: 0; +} + +.button-wrap button { + -webkit-app-region: no-drag; + background-color: transparent; + color: white; + border: 2px solid #505050; + padding: 6px; + cursor: pointer; + transition: 250ms; +} + +.button-wrap button:hover { + background: #505050; +} + +img, +h1, +p { + -webkit-app-region: no-drag; } \ No newline at end of file diff --git a/src/public/loader.html b/src/public/loader.html index fe7078b..fc608c3 100644 --- a/src/public/loader.html +++ b/src/public/loader.html @@ -8,6 +8,9 @@ +
+ +
Random Browser Icon. If it's not visible, check your internet connection.

Please wait,

Loading the browser...

From 858c95f12988a6d27c403056246e77465117e655 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 15:26:29 -0400 Subject: [PATCH 064/103] enabled node integration for loader window --- src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.ts b/src/index.ts index ba8ffbf..4a87427 100644 --- a/src/index.ts +++ b/src/index.ts @@ -51,6 +51,10 @@ app.on('ready', () => { function spawnAppLoader() { logger.logMessage("App loader spawned."); appLoader = new BrowserWindow({ + webPreferences: { + nodeIntegration: true, + contextIsolation: false + }, title: 'Random Browser - Loading...', frame: false, closable: false, From 438c9a3e9570e5578246b29187dcaee1fc57e35b Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 15:30:38 -0400 Subject: [PATCH 065/103] ipc: apploader-reference --- src/index.ts | 4 ++++ src/public/js/loader.js | 5 +++++ src/public/loader.html | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 src/public/js/loader.js diff --git a/src/index.ts b/src/index.ts index 4a87427..84f01bd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -161,4 +161,8 @@ ipcMain.on('clear-background', (event) => { backgroundSelect.close(); main.webContents.send('update-background', ''); main.loadFile(path.join(publicPath, 'index.html')); +}); + +ipcMain.on('apploader-reference', (event) => { + appLoader.webContents.send('apploader-reference', appLoader); }); \ No newline at end of file diff --git a/src/public/js/loader.js b/src/public/js/loader.js new file mode 100644 index 0000000..c36ee7a --- /dev/null +++ b/src/public/js/loader.js @@ -0,0 +1,5 @@ +const { ipcRenderer } = require('electron'); + +document.getElementById('background-load-btn').addEventListener('click', () => { + ipcRenderer.send('apploader-reference'); +}); \ No newline at end of file diff --git a/src/public/loader.html b/src/public/loader.html index fc608c3..b39fcb1 100644 --- a/src/public/loader.html +++ b/src/public/loader.html @@ -14,5 +14,7 @@ Random Browser Icon. If it's not visible, check your internet connection.

Please wait,

Loading the browser...

+ + \ No newline at end of file From 51b533262403bf9afa9b3536b3b7411b25f59df0 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 15:42:56 -0400 Subject: [PATCH 066/103] load on background --- src/index.ts | 4 ++-- src/public/js/loader.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 84f01bd..df1fd45 100644 --- a/src/index.ts +++ b/src/index.ts @@ -163,6 +163,6 @@ ipcMain.on('clear-background', (event) => { main.loadFile(path.join(publicPath, 'index.html')); }); -ipcMain.on('apploader-reference', (event) => { - appLoader.webContents.send('apploader-reference', appLoader); +ipcMain.on('minimize-apploader', (event) => { + appLoader.minimize(); }); \ No newline at end of file diff --git a/src/public/js/loader.js b/src/public/js/loader.js index c36ee7a..9cd0bdc 100644 --- a/src/public/js/loader.js +++ b/src/public/js/loader.js @@ -1,5 +1,5 @@ const { ipcRenderer } = require('electron'); document.getElementById('background-load-btn').addEventListener('click', () => { - ipcRenderer.send('apploader-reference'); + ipcRenderer.send('minimize-apploader'); }); \ No newline at end of file From 76a487d28f3df7627bf410fb756ff004839f8fe2 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 15 Apr 2023 15:44:08 -0400 Subject: [PATCH 067/103] feature 3 done --- changelog.txt | 2 +- src/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index ed573b1..f0bec9d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,7 +2,7 @@ Features => { [DONE] Custom App Frame. [DONE] New Tab System. - [WORKING] Initial App Loader. + [DONE] Initial App Loader. [PLANNED] Download Progress Bar. [PLANNED] New Settings Menu. [PLANNED] New Sidebar. diff --git a/src/index.ts b/src/index.ts index df1fd45..9553e7e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,7 +38,7 @@ app.on('ready', () => { logger.logMessage(`Main window ready to show.`); main.show(); // ! Make sure to destoy appLoader in production. - // appLoader.destroy(); + appLoader.destroy(); main.maximize(); const rawConfig = fs.readFileSync(userConfigPath, { encoding: 'utf-8' }); From e13821bb4ac58fa94b3aeb1caf98ad8b4bdc7910 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 16 Apr 2023 14:20:34 -0400 Subject: [PATCH 068/103] working on feature 4 --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index f0bec9d..c20e9d5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,7 +3,7 @@ [DONE] Custom App Frame. [DONE] New Tab System. [DONE] Initial App Loader. - [PLANNED] Download Progress Bar. + [WORKING] Download Progress Bar. [PLANNED] New Settings Menu. [PLANNED] New Sidebar. [PLANNED] Search History. From ae9729b7d76e2eb5082949e2266b62c46502b0d2 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 16 Apr 2023 14:26:10 -0400 Subject: [PATCH 069/103] download handler --- src/tabs/downloads/DownloadHandler.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/tabs/downloads/DownloadHandler.ts diff --git a/src/tabs/downloads/DownloadHandler.ts b/src/tabs/downloads/DownloadHandler.ts new file mode 100644 index 0000000..d4c08f5 --- /dev/null +++ b/src/tabs/downloads/DownloadHandler.ts @@ -0,0 +1,7 @@ +class DownloadHandler { + public handleDownload(): void { + + } +} + +export default new DownloadHandler(); \ No newline at end of file From 9f435d241ee3e269a44d28c9dfb100655a29b51d Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 16 Apr 2023 14:33:59 -0400 Subject: [PATCH 070/103] will-download event --- src/tabs/BrowserTab.ts | 7 ++++++- src/tabs/downloads/DownloadHandler.ts | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index 82bbf87..590002a 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -1,4 +1,5 @@ -import { BrowserWindow, Menu, MenuItemConstructorOptions } from 'electron'; +import { BrowserWindow, Menu, MenuItemConstructorOptions, webContents } from 'electron'; +import DownloadHandler from './downloads/DownloadHandler.js'; /** * The BrowserTab class. @@ -150,6 +151,10 @@ export default class BrowserTab { console.log(this.visitedUrls, this.currentUrl); }); + tabModal.webContents.session.on('will-download', (event, item, webContents) => { + DownloadHandler.handleDownload(event, item, webContents, tabModal); + }); + // Center the tab modal if the main window is maximized to make sure it fills all the screen. if (this.parent.isMaximized()) { tabModal.setBounds({ diff --git a/src/tabs/downloads/DownloadHandler.ts b/src/tabs/downloads/DownloadHandler.ts index d4c08f5..e969091 100644 --- a/src/tabs/downloads/DownloadHandler.ts +++ b/src/tabs/downloads/DownloadHandler.ts @@ -1,5 +1,11 @@ +import { BrowserWindow, DownloadItem, Event, WebContents } from "electron"; + class DownloadHandler { - public handleDownload(): void { + /** + * Handles downloads in tabs, + * this function should be called in a `will-download` electron event. + */ + public handleDownload(event: Event, item: DownloadItem, webContents: WebContents, tab: BrowserWindow): void { } } From f922e284a884d1b0ad6aeccd19f4aa4be6ab2bf2 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 16 Apr 2023 16:13:02 -0400 Subject: [PATCH 071/103] added reload feature to tabs --- src/tabs/BrowserTab.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index 590002a..19d20fd 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -96,6 +96,9 @@ export default class BrowserTab { label: 'Close Tab', role: 'close' }, + { + role: 'reload' + }, { label: `Zoom (${Math.floor(window.webContents.zoomFactor * 100)}%)`, submenu: [ From 971cf4acde68e7ab26db2c04a63c7be317b64338 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 29 Apr 2023 17:03:37 -0400 Subject: [PATCH 072/103] handling downloads with logs --- src/tabs/downloads/DownloadHandler.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tabs/downloads/DownloadHandler.ts b/src/tabs/downloads/DownloadHandler.ts index e969091..90390be 100644 --- a/src/tabs/downloads/DownloadHandler.ts +++ b/src/tabs/downloads/DownloadHandler.ts @@ -1,4 +1,5 @@ import { BrowserWindow, DownloadItem, Event, WebContents } from "electron"; +import { logger } from "../../index.js"; class DownloadHandler { /** @@ -6,7 +7,26 @@ class DownloadHandler { * this function should be called in a `will-download` electron event. */ public handleDownload(event: Event, item: DownloadItem, webContents: WebContents, tab: BrowserWindow): void { + logger.logMessage(`Download triggered.`); + item.on('updated', (event, state) => { + if (state == 'interrupted') { + logger.logWarning("Donwload interrupted but can be resumed."); + } else if (state == 'progressing') { + if (item.isPaused()) { + logger.logMessage("Download paused."); + } else { + logger.logMessage(`Download progress:\n${item.getReceivedBytes()} bytes out of ${item.getTotalBytes()}`); + } + } + }); + item.once('done', (event, state) => { + if (state == 'completed') { + logger.logMessage(`Download completed succesfully.`); + } else { + logger.logWarning(`Download failed: ${state}`); + } + }); } } From 63401405b9217a2d4164917f99c2ad3cdd750f3a Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 29 Apr 2023 17:38:33 -0400 Subject: [PATCH 073/103] browser window for downloads --- src/index.ts | 24 ++++++++++++++++++++++++ src/public/download.html | 0 2 files changed, 24 insertions(+) create mode 100644 src/public/download.html diff --git a/src/index.ts b/src/index.ts index 9553e7e..dabc3fa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,6 +20,7 @@ let main : BrowserWindow; let tabModal : BrowserWindow; let backgroundSelect : BrowserWindow; let appLoader : BrowserWindow; +let downloadWindow : BrowserWindow; app.on('ready', () => { logger.logMessage(`App is ready.`); spawnAppLoader(); @@ -75,6 +76,29 @@ function spawnTab(url: string) { tabModal = TabManager.createTab(url, main).build(); } +/** + * Spanws the download window. It contains + * information such as filename and download progress, as well + * contains some actions like cancel, pause, and resume download. + */ +export function spawnDownloadWindow() { + downloadWindow = new BrowserWindow({ + webPreferences: { + nodeIntegration: true, + contextIsolation: false + }, + title: 'Download', + parent: main, + minimizable: false, + maximizable: false, + closable: false, + resizable: false, + height: 480, + width: 600 + }); + main.loadFile(path.join(publicPath, 'download.html')); +} + function selectBackground() { backgroundSelect = new BrowserWindow({ title: "Change Browser's Background", diff --git a/src/public/download.html b/src/public/download.html new file mode 100644 index 0000000..e69de29 From 946dd628c5e9310f68882a34dbc04b1b992cdbb4 Mon Sep 17 00:00:00 2001 From: Yisus Date: Tue, 11 Jul 2023 01:25:48 -0400 Subject: [PATCH 074/103] passing download item --- src/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index dabc3fa..086c3c2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, ipcMain, Menu, MenuItemConstructorOptions } from 'electron'; +import { app, BrowserWindow, ipcMain, Menu, DownloadItem } from 'electron'; import Logger from './logs/Logger.js'; import TabManager from './tabs/TabManager.js'; import configs from './config/app.json'; @@ -78,10 +78,12 @@ function spawnTab(url: string) { /** * Spanws the download window. It contains - * information such as filename and download progress, as well + * information such as filename and download progress, also * contains some actions like cancel, pause, and resume download. + * + * @param item The item being downloaded. */ -export function spawnDownloadWindow() { +export function spawnDownloadWindow(item: DownloadItem) { downloadWindow = new BrowserWindow({ webPreferences: { nodeIntegration: true, @@ -96,7 +98,8 @@ export function spawnDownloadWindow() { height: 480, width: 600 }); - main.loadFile(path.join(publicPath, 'download.html')); + downloadWindow.loadFile(path.join(publicPath, 'download.html')); + downloadWindow.webContents.send('download-item', item); } function selectBackground() { From ef08422ca58117983e5ada3721c7890d5ea418d5 Mon Sep 17 00:00:00 2001 From: Yisus Date: Tue, 11 Jul 2023 23:36:08 -0400 Subject: [PATCH 075/103] deleted browser window for downloads Planning a different approach for displaying downloads. --- src/index.ts | 30 ++---------------------------- src/public/download.html | 0 2 files changed, 2 insertions(+), 28 deletions(-) delete mode 100644 src/public/download.html diff --git a/src/index.ts b/src/index.ts index 086c3c2..39fba68 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,7 +20,6 @@ let main : BrowserWindow; let tabModal : BrowserWindow; let backgroundSelect : BrowserWindow; let appLoader : BrowserWindow; -let downloadWindow : BrowserWindow; app.on('ready', () => { logger.logMessage(`App is ready.`); spawnAppLoader(); @@ -33,7 +32,8 @@ app.on('ready', () => { frame: false, show: false }); - Menu.setApplicationMenu(null); + // ! Make sure to set the application menu to null in production. + // Menu.setApplicationMenu(null); main.loadFile(path.join(publicPath, 'index.html')); main.on('ready-to-show', () => { logger.logMessage(`Main window ready to show.`); @@ -76,32 +76,6 @@ function spawnTab(url: string) { tabModal = TabManager.createTab(url, main).build(); } -/** - * Spanws the download window. It contains - * information such as filename and download progress, also - * contains some actions like cancel, pause, and resume download. - * - * @param item The item being downloaded. - */ -export function spawnDownloadWindow(item: DownloadItem) { - downloadWindow = new BrowserWindow({ - webPreferences: { - nodeIntegration: true, - contextIsolation: false - }, - title: 'Download', - parent: main, - minimizable: false, - maximizable: false, - closable: false, - resizable: false, - height: 480, - width: 600 - }); - downloadWindow.loadFile(path.join(publicPath, 'download.html')); - downloadWindow.webContents.send('download-item', item); -} - function selectBackground() { backgroundSelect = new BrowserWindow({ title: "Change Browser's Background", diff --git a/src/public/download.html b/src/public/download.html deleted file mode 100644 index e69de29..0000000 From 2e676c19242298c7418e69581e580af01bf041bf Mon Sep 17 00:00:00 2001 From: Yisus Date: Wed, 12 Jul 2023 00:03:47 -0400 Subject: [PATCH 076/103] added download menu Added in replacement of the old 'about button' --- src/public/css/index.css | 6 +++--- src/public/index.html | 2 +- src/public/js/index.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/public/css/index.css b/src/public/css/index.css index 15c6e7d..d836a2a 100644 --- a/src/public/css/index.css +++ b/src/public/css/index.css @@ -188,7 +188,7 @@ body:has(:focus) { padding: 5px; } -#about-btn { +#downloads-btn { position: absolute; top: 40px; left: 0; @@ -202,11 +202,11 @@ body:has(:focus) { transition: all 250ms; } -#about-btn:hover { +#downloads-btn:hover { color: #ffffff; } -#about-btn:active { +#downloads-btn:active { color: #000000; } diff --git a/src/public/index.html b/src/public/index.html index 1fb7acf..b34d1a6 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -23,7 +23,7 @@
- +

Random Browser

diff --git a/src/public/js/index.js b/src/public/js/index.js index 9c00ba9..c0052c7 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -52,9 +52,9 @@ ipcRenderer.on('update-background', (event, file) => { updateBackground(file); }); -/* Learn Page */ -document.getElementById('about-btn').addEventListener('click', (event) => { - ipcRenderer.send('new-search', 'https://yisusgaming.github.io/random-browser-page'); +/* Downloads Menu */ +document.getElementById('downloads-btn').addEventListener('mouseover', (event) => { + alert('download menu'); }); /* Browser Background */ From 2079b986f253675c3c3a58f4318d00e741af1d85 Mon Sep 17 00:00:00 2001 From: Yisus Date: Wed, 12 Jul 2023 23:55:05 -0400 Subject: [PATCH 077/103] download menu created --- src/public/css/index.css | 24 ++++++++++++++++++++++++ src/public/index.html | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/src/public/css/index.css b/src/public/css/index.css index d836a2a..04037b9 100644 --- a/src/public/css/index.css +++ b/src/public/css/index.css @@ -210,6 +210,30 @@ body:has(:focus) { color: #000000; } +#downloads-menu { + position: absolute; + display: none; + justify-content: center; + align-items: center; + font-family: 'Raleway', sans-serif; + background: #303030; + color: #ffffff; + width: 320px; + height: 200px; + padding: 8px; + top: 68px; + left: 20px; + overflow-y: scroll; +} + +#downloads-menu::-webkit-scrollbar { + width: 4px; +} + +#downloads-menu::-webkit-scrollbar-thumb { + background: white; +} + #background-btn { position: absolute; top: 40px; diff --git a/src/public/index.html b/src/public/index.html index b34d1a6..72dbde2 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -25,6 +25,14 @@ + +
+

No active downloads.

+
    + +
+
+

Random Browser

- -
-

No active downloads.

-
-

Random Browser

diff --git a/src/public/js/index.js b/src/public/js/index.js index 3cde820..2dbd0e2 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -56,27 +56,6 @@ ipcRenderer.on('update-background', (event, file) => { updateBackground(file); }); -/* Downloads Menu */ -document.getElementById('downloads-btn').addEventListener('mouseover', (event) => { - const menu = document.getElementById('downloads-menu'); - menu.style.display = 'flex'; - menu.addEventListener('mouseleave', (event) => { - menu.style.display = 'none'; - }); -}); - -/* Download Handler */ -ipcRenderer.on('active-downloads-update', (event, /** @type {Array<{id: number, filename: string}>} */ downloads) => { - const downloadMenu = document.getElementById('downloads-menu'); - - if (downloads.length <= 0) { - downloadMenu.innerHTML = `

No active downloads.

`; - return; - } - - downloadMenu.innerHTML = `There is ${downloads.length} active downloads.`; -}); - /* Browser Background */ document.getElementById('background-btn').addEventListener('click', (event) => { ipcRenderer.send('new-background-image'); @@ -106,4 +85,4 @@ function updateBackground(file) { const parsedUrl = new URL(file); document.body.style.backgroundSize = 'cover'; document.body.style.backgroundImage = `url('${parsedUrl.toString()}')`; -} \ No newline at end of file +} diff --git a/src/tabs/downloads/DownloadHandler.ts b/src/tabs/downloads/DownloadHandler.ts index bf090d6..c2bda36 100644 --- a/src/tabs/downloads/DownloadHandler.ts +++ b/src/tabs/downloads/DownloadHandler.ts @@ -1,5 +1,12 @@ import { BrowserWindow, DownloadItem, Event, WebContents } from "electron"; -import { logger, mainWindowGateway } from "../../index.js"; +import { logger } from "../../index.js"; + +export interface Download { + id: number; + filename: string, + totalBytes: number, + receivedBytes: number +} /** * DownloadHandler class @@ -9,7 +16,7 @@ import { logger, mainWindowGateway } from "../../index.js"; */ class DownloadHandler { - private activeDownloads: Array<{id: number, filename: string}> = []; + private activeDownloads: Download[] = []; /** * Handles downloads in tabs, @@ -17,13 +24,13 @@ class DownloadHandler { */ public handleDownload(event: Event, item: DownloadItem, webContents: WebContents, tab: BrowserWindow): void { logger.logMessage(`Download triggered.`); - + this.activeDownloads.push({ id: this.generateId(), - filename: item.getFilename() + filename: item.getFilename(), + totalBytes: item.getTotalBytes(), + receivedBytes: item.getReceivedBytes() }); - logger.logMessage(`${this.activeDownloads}`); - mainWindowGateway('active-downloads-update', this.activeDownloads); item.on('updated', (event, state) => { if (state == 'interrupted') { From f0347de4295278c2948516585996236f770b9f91 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 30 Sep 2023 22:44:57 -0400 Subject: [PATCH 092/103] changes to update background --- src/public/js/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/public/js/index.js b/src/public/js/index.js index 2dbd0e2..36656e3 100644 --- a/src/public/js/index.js +++ b/src/public/js/index.js @@ -79,10 +79,12 @@ ipcRenderer.on('app-version', (event, version) => { }); /** - * @param {string} file + * @param {string} url */ -function updateBackground(file) { - const parsedUrl = new URL(file); +function updateBackground(url) { + if (url.trim() == "") return; + + const parsedUrl = new URL(url); document.body.style.backgroundSize = 'cover'; document.body.style.backgroundImage = `url('${parsedUrl.toString()}')`; } From 32320c01d324007e8646ab53456995bd2d3c362b Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 30 Sep 2023 23:08:48 -0400 Subject: [PATCH 093/103] pexport publicPath --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 85e967c..5693aa2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, ipcMain, Menu, DownloadItem } from 'electron'; +import { app, BrowserWindow, ipcMain, Menu } from 'electron'; import Logger from './logs/Logger.js'; import TabManager from './tabs/TabManager.js'; import configs from './config/app.json'; @@ -11,7 +11,7 @@ import path from 'path'; // without the need to reinstance the class again. export const logger = new Logger(configs.version); -const publicPath = path.join(__dirname, 'public'); +export const publicPath = path.join(__dirname, 'public'); const userConfigPath = path.join(__dirname, 'config', 'user.json'); // console.log(`Looking for user's configs in ${userConfigPath}`); logger.logMessage(`Looking for user's configs in ${userConfigPath}`); From 31d68a93e1a115393bec70eb8ad90400823613f7 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 30 Sep 2023 23:25:44 -0400 Subject: [PATCH 094/103] new download handling --- src/public/download.html | 1 + src/tabs/BrowserTab.ts | 2 +- src/tabs/downloads/DownloadHandler.ts | 58 ++++++++++++--------------- 3 files changed, 28 insertions(+), 33 deletions(-) create mode 100644 src/public/download.html diff --git a/src/public/download.html b/src/public/download.html new file mode 100644 index 0000000..916e6a3 --- /dev/null +++ b/src/public/download.html @@ -0,0 +1 @@ +

Download

\ No newline at end of file diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index 50ea57b..e6fecb8 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -162,7 +162,7 @@ export default class BrowserTab { spawnTab(details.url); // Opening a tab with the destroyed window's url. }); tabModal.webContents.session.on('will-download', (event, item, webContents) => { - DownloadHandler.handleDownload(event, item, webContents, tabModal); + new DownloadHandler(item, tabModal); }); // Center the tab modal if the main window is maximized to make sure it fills all the screen. diff --git a/src/tabs/downloads/DownloadHandler.ts b/src/tabs/downloads/DownloadHandler.ts index c2bda36..04df18f 100644 --- a/src/tabs/downloads/DownloadHandler.ts +++ b/src/tabs/downloads/DownloadHandler.ts @@ -1,11 +1,14 @@ -import { BrowserWindow, DownloadItem, Event, WebContents } from "electron"; -import { logger } from "../../index.js"; +import { DownloadItem, BrowserWindow } from "electron"; +import { logger, publicPath } from "../../index.js"; + +import path from 'path'; export interface Download { id: number; filename: string, totalBytes: number, - receivedBytes: number + receivedBytes: number, + item: DownloadItem } /** @@ -14,25 +17,31 @@ export interface Download { * * Handles downloads, typically triggered in tabs. */ -class DownloadHandler { - - private activeDownloads: Download[] = []; - +export default class DownloadHandler { /** - * Handles downloads in tabs, - * this function should be called in a `will-download` electron event. + * Creates a new DownloadHandler for an specific download. + * Once a DownloadHandler is constructed, it automatically + * starts handling it. This creates a window where the progress + * is shown to the user, and other things. + * + * @param {DownloadItem} item The item being downloaded. */ - public handleDownload(event: Event, item: DownloadItem, webContents: WebContents, tab: BrowserWindow): void { + constructor(item: DownloadItem, tab: BrowserWindow) { logger.logMessage(`Download triggered.`); - this.activeDownloads.push({ - id: this.generateId(), - filename: item.getFilename(), - totalBytes: item.getTotalBytes(), - receivedBytes: item.getReceivedBytes() + let downloadModal = new BrowserWindow({ + title: 'Downloading...', + parent: tab, + modal: true, + resizable: false, + height: 180, + width: 280 }); + downloadModal.loadFile(path.join(publicPath, "download.html")); - item.on('updated', (event, state) => { + logger.logMessage(`Spawned download modal.`); + + item.on('updated', (_event, state) => { if (state == 'interrupted') { // logger.logWarning("Donwload interrupted but can be resumed."); } else if (state == 'progressing') { @@ -44,7 +53,7 @@ class DownloadHandler { } }); - item.once('done', (event, state) => { + item.once('done', (_event, state) => { if (state == 'completed') { logger.logMessage(`Download completed succesfully.`); } else { @@ -52,19 +61,4 @@ class DownloadHandler { } }); } - - /** - * Generates an unique ID for a download. - */ - private generateId(): number { - let ids : Array = []; - this.activeDownloads.forEach((download) => { - ids.push(download.id); - }); - - ids.sort(); // Sort in a way that the bigger ID is the last element of the array. - return ids.pop()! + 1 || 0; // Return the last element of the array (bigger id) + 1, or return 0 if the array is empty. - } } - -export default new DownloadHandler(); \ No newline at end of file From 29ae094442ce887c3b679071f921e1f64ae46596 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 1 Oct 2023 00:56:48 -0400 Subject: [PATCH 095/103] download ui --- src/public/download.html | 24 +++++++++++++++++++++++- src/public/js/download.js | 20 ++++++++++++++++++++ src/tabs/downloads/DownloadHandler.ts | 22 +++++++++++++++++----- 3 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 src/public/js/download.js diff --git a/src/public/download.html b/src/public/download.html index 916e6a3..63fb2c4 100644 --- a/src/public/download.html +++ b/src/public/download.html @@ -1 +1,23 @@ -

Download

\ No newline at end of file + + + + + + Downloading... + + +
+
+

Dowloading file...

+

Status: ?

+

Progress: ?

+

0 bytes out of ? bytes

+
+ + + +
+ + + + diff --git a/src/public/js/download.js b/src/public/js/download.js new file mode 100644 index 0000000..41379e9 --- /dev/null +++ b/src/public/js/download.js @@ -0,0 +1,20 @@ +const { ipcRenderer } = require('electron'); + +const title = document.getElementById('download-title'); +const status = document.getElementById('download-status'); +const progress = document.getElementById('download-progress'); +const progressBytes = document.getElementById('download-bytes'); + +/* Updates */ +ipcRenderer.on('title-update', (_event, newTitle) => { + title.innerText = newTitle; +}); + +ipcRenderer.on('status-update', (_event, newStatus) => { + status.innerText = newStatus; +}); + +ipcRenderer.on('progress-update', (_event, newProgress, newByteProgress) => { + progress.innerText = newProgress; + progressBytes.innerText = newByteProgress; +}); diff --git a/src/tabs/downloads/DownloadHandler.ts b/src/tabs/downloads/DownloadHandler.ts index 04df18f..6c63332 100644 --- a/src/tabs/downloads/DownloadHandler.ts +++ b/src/tabs/downloads/DownloadHandler.ts @@ -20,6 +20,7 @@ export interface Download { export default class DownloadHandler { /** * Creates a new DownloadHandler for an specific download. + * * Once a DownloadHandler is constructed, it automatically * starts handling it. This creates a window where the progress * is shown to the user, and other things. @@ -34,21 +35,30 @@ export default class DownloadHandler { parent: tab, modal: true, resizable: false, - height: 180, - width: 280 + height: 440, + width: 480, + webPreferences: { + nodeIntegration: true, + contextIsolation: false + } }); downloadModal.loadFile(path.join(publicPath, "download.html")); + downloadModal.webContents.send('title-update', `${item.getFilename()}...`); logger.logMessage(`Spawned download modal.`); item.on('updated', (_event, state) => { if (state == 'interrupted') { - // logger.logWarning("Donwload interrupted but can be resumed."); + downloadModal.webContents.send('status-update', 'Status: Interrupted.'); } else if (state == 'progressing') { if (item.isPaused()) { - // logger.logMessage("Download paused."); + downloadModal.webContents.send('status-update', 'Status: Paused.'); } else { - // logger.logMessage(`Download progress:\n${item.getReceivedBytes()} bytes out of ${item.getTotalBytes()}`); + downloadModal.webContents.send('status-update', 'Status: Downloading.'); + downloadModal.webContents.send('progress-update', + `${Math.round((item.getReceivedBytes() / item.getTotalBytes()) * 100)}%`, + `${item.getReceivedBytes()} bytes out of ${item.getTotalBytes()} bytes.` + ); } } }); @@ -56,7 +66,9 @@ export default class DownloadHandler { item.once('done', (_event, state) => { if (state == 'completed') { logger.logMessage(`Download completed succesfully.`); + downloadModal.webContents.send('status-update', 'Status: Completed.'); } else { + downloadModal.webContents.send('status-update', `Status: Failed, ${state}.`); logger.logWarning(`Download failed: ${state}`); } }); From 16b4879c6091bfdc76887aaa1304f35431ef2bbe Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 1 Oct 2023 02:31:38 -0400 Subject: [PATCH 096/103] download ui styles --- src/public/css/download.css | 78 +++++++++++++++++++++++++++ src/public/download.html | 9 ++-- src/tabs/downloads/DownloadHandler.ts | 11 ++-- 3 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 src/public/css/download.css diff --git a/src/public/css/download.css b/src/public/css/download.css new file mode 100644 index 0000000..6dc8084 --- /dev/null +++ b/src/public/css/download.css @@ -0,0 +1,78 @@ +@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@100;200;300;400;500;600;700&display=swap'); + +* { + margin: 0; + padding: 0; +} + +body { + position: relative; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + font-family: 'Raleway', sans-serif; + background: #202020; + color: #ffffff; +} + +.frame { + padding: 20px; + border: #303030 2px solid; + border-radius: 8px; +} + +#download-info { + display: flex; + flex-direction: column; + justify-content: center; + text-align: center; + align-items: center; + margin-bottom: 10px; +} + +.btns { + display: flex; + justify-content: center; + align-items: center; +} + +button { + background: transparent; + color: #ffffff; + padding: 8px; + margin: 0 4px; + border-radius: 8px; + border: #ffffff 2px solid; + cursor: pointer; + transition: 250ms; +} + +button#btn-resume { + border-color: #101060; +} + +button#btn-resume:hover { + background: #101060; +} + +button#btn-pause { + border-color: #dddd00; +} + +button#btn-pause:hover { + background: #dddd00; +} + +button#btn-cancel { + border-color: #dd0020; +} + +button#btn-cancel:hover { + background: #dd0020; +} + +button:disabled { + cursor: not-allowed; + opacity: .7; +} diff --git a/src/public/download.html b/src/public/download.html index 63fb2c4..655b473 100644 --- a/src/public/download.html +++ b/src/public/download.html @@ -4,6 +4,7 @@ Downloading... +
@@ -13,9 +14,11 @@

Status: ?

Progress: ?

0 bytes out of ? bytes

- - - +
+ + + +
diff --git a/src/tabs/downloads/DownloadHandler.ts b/src/tabs/downloads/DownloadHandler.ts index 6c63332..ed3f657 100644 --- a/src/tabs/downloads/DownloadHandler.ts +++ b/src/tabs/downloads/DownloadHandler.ts @@ -33,21 +33,20 @@ export default class DownloadHandler { let downloadModal = new BrowserWindow({ title: 'Downloading...', parent: tab, - modal: true, resizable: false, - height: 440, - width: 480, + height: 300, + width: 400, webPreferences: { nodeIntegration: true, contextIsolation: false } }); downloadModal.loadFile(path.join(publicPath, "download.html")); - downloadModal.webContents.send('title-update', `${item.getFilename()}...`); - logger.logMessage(`Spawned download modal.`); + logger.logMessage(`Spawned download window.`); item.on('updated', (_event, state) => { + downloadModal.webContents.send('title-update', `${item.getFilename()}...`); if (state == 'interrupted') { downloadModal.webContents.send('status-update', 'Status: Interrupted.'); } else if (state == 'progressing') { @@ -56,7 +55,7 @@ export default class DownloadHandler { } else { downloadModal.webContents.send('status-update', 'Status: Downloading.'); downloadModal.webContents.send('progress-update', - `${Math.round((item.getReceivedBytes() / item.getTotalBytes()) * 100)}%`, + `Progress: ${Math.round((item.getReceivedBytes() / item.getTotalBytes()) * 100)}%`, `${item.getReceivedBytes()} bytes out of ${item.getTotalBytes()} bytes.` ); } From bd096d6843db6141d0cbde115e6b60fb323090c9 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 1 Oct 2023 03:31:28 -0400 Subject: [PATCH 097/103] download ui button actions --- src/public/js/download.js | 31 +++++++++++++++++++++++++++ src/tabs/downloads/DownloadHandler.ts | 24 ++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/public/js/download.js b/src/public/js/download.js index 41379e9..4c43cd4 100644 --- a/src/public/js/download.js +++ b/src/public/js/download.js @@ -5,6 +5,13 @@ const status = document.getElementById('download-status'); const progress = document.getElementById('download-progress'); const progressBytes = document.getElementById('download-bytes'); +/** @type {HTMLButtonElement} */ +const resumeBtn = document.getElementById('btn-resume'); +/** @type {HTMLButtonElement} */ +const pauseBtn = document.getElementById('btn-pause'); +/** @type {HTMLButtonElement} */ +const cancelBtn = document.getElementById('btn-cancel'); + /* Updates */ ipcRenderer.on('title-update', (_event, newTitle) => { title.innerText = newTitle; @@ -18,3 +25,27 @@ ipcRenderer.on('progress-update', (_event, newProgress, newByteProgress) => { progress.innerText = newProgress; progressBytes.innerText = newByteProgress; }); + +resumeBtn.addEventListener('click', () => { + if (resumeBtn.disabled) return; + + ipcRenderer.send('download-resume'); + resumeBtn.disabled = true; + pauseBtn.disabled = false; +}); + +pauseBtn.addEventListener('click', () => { + if (pauseBtn.disabled) return; + + ipcRenderer.send('download-pause'); + pauseBtn.disabled = true; + resumeBtn.disabled = false; +}); + +cancelBtn.addEventListener('click', () => { + if (cancelBtn.disabled) return; + + ipcRenderer.send('download-cancel'); + resumeBtn.disabled = true; + pauseBtn.disabled = true; +}); diff --git a/src/tabs/downloads/DownloadHandler.ts b/src/tabs/downloads/DownloadHandler.ts index ed3f657..77a4db3 100644 --- a/src/tabs/downloads/DownloadHandler.ts +++ b/src/tabs/downloads/DownloadHandler.ts @@ -1,4 +1,4 @@ -import { DownloadItem, BrowserWindow } from "electron"; +import { DownloadItem, BrowserWindow, dialog } from "electron"; import { logger, publicPath } from "../../index.js"; import path from 'path'; @@ -30,6 +30,10 @@ export default class DownloadHandler { constructor(item: DownloadItem, tab: BrowserWindow) { logger.logMessage(`Download triggered.`); + tab.on('close', () => { + item.cancel(); + }); + let downloadModal = new BrowserWindow({ title: 'Downloading...', parent: tab, @@ -41,10 +45,28 @@ export default class DownloadHandler { contextIsolation: false } }); + downloadModal.on('close', () => {item.cancel(); return;}); downloadModal.loadFile(path.join(publicPath, "download.html")); logger.logMessage(`Spawned download window.`); + downloadModal.webContents.ipc.on('download-resume', () => { + if (item.canResume()) { + item.resume(); + return; + } + + dialog.showErrorBox("Can't resume", "Download can't be resumed."); + }); + + downloadModal.webContents.ipc.on('download-pause', () => { + item.pause(); + }); + + downloadModal.webContents.ipc.on('download-cancel', () => { + item.cancel(); + }); + item.on('updated', (_event, state) => { downloadModal.webContents.send('title-update', `${item.getFilename()}...`); if (state == 'interrupted') { From 632c504887802323aa33ceca46b9cf667516bcb9 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sun, 1 Oct 2023 04:14:22 -0400 Subject: [PATCH 098/103] changed parent for download ui + some other changes --- src/tabs/BrowserTab.ts | 2 +- src/tabs/downloads/DownloadHandler.ts | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/tabs/BrowserTab.ts b/src/tabs/BrowserTab.ts index e6fecb8..049b088 100644 --- a/src/tabs/BrowserTab.ts +++ b/src/tabs/BrowserTab.ts @@ -162,7 +162,7 @@ export default class BrowserTab { spawnTab(details.url); // Opening a tab with the destroyed window's url. }); tabModal.webContents.session.on('will-download', (event, item, webContents) => { - new DownloadHandler(item, tabModal); + new DownloadHandler(item, this.parent); }); // Center the tab modal if the main window is maximized to make sure it fills all the screen. diff --git a/src/tabs/downloads/DownloadHandler.ts b/src/tabs/downloads/DownloadHandler.ts index 77a4db3..2f6c832 100644 --- a/src/tabs/downloads/DownloadHandler.ts +++ b/src/tabs/downloads/DownloadHandler.ts @@ -25,18 +25,15 @@ export default class DownloadHandler { * starts handling it. This creates a window where the progress * is shown to the user, and other things. * - * @param {DownloadItem} item The item being downloaded. + * @param item The item being downloaded. + * @param parent The parent for this handler's progress window. */ - constructor(item: DownloadItem, tab: BrowserWindow) { + constructor(item: DownloadItem, parent: BrowserWindow) { logger.logMessage(`Download triggered.`); - tab.on('close', () => { - item.cancel(); - }); - - let downloadModal = new BrowserWindow({ + let downloadModal: BrowserWindow = new BrowserWindow({ title: 'Downloading...', - parent: tab, + parent: parent, resizable: false, height: 300, width: 400, @@ -45,7 +42,19 @@ export default class DownloadHandler { contextIsolation: false } }); - downloadModal.on('close', () => {item.cancel(); return;}); + + parent.on('close', () => { + item.cancel(); + downloadModal.destroy(); + return; + }); + + downloadModal.on('close', () => { + item.cancel(); + downloadModal.destroy(); + return; + }); + downloadModal.loadFile(path.join(publicPath, "download.html")); logger.logMessage(`Spawned download window.`); From 16f9f2c3fed964e328f459b204ba0c152784dcb0 Mon Sep 17 00:00:00 2001 From: Yisus Date: Mon, 16 Oct 2023 20:57:31 -0400 Subject: [PATCH 099/103] updated project status --- changelog.txt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/changelog.txt b/changelog.txt index dfcaa42..be0130d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,12 +3,8 @@ [DONE] Custom App Frame. [DONE] New Tab System. [DONE] Initial App Loader. - [WORKING] Download Progress Bar. - [PLANNED] New Settings Menu. - [PLANNED] Search History. - } - Changes => { - [PLANNED] Clean all cookies and sessions on exit. + [DONE] Download Progress Bar. + [DELAYED->v3.0.0] New Settings Menu. } Fixes => { [DONE] Fixed Random Browser's Page Link. From 2a0539632108aca81b41d1b25505aeb839ba06f6 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 23 Dec 2023 06:43:55 -0400 Subject: [PATCH 100/103] fixes and changes --- README.md | 2 +- src/index.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index c21e914..da58254 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Build Test](https://github.com/YisusGaming/random-browser/actions/workflows/integrate.yml/badge.svg?branch=main)](https://github.com/YisusGaming/random-browser/actions/workflows/integrate.yml) -| Cotents | Link | +| Contents | Link | |--------|------| |Installation|[Go](#installation)| |Development setup |[Go](#development-setup)| diff --git a/src/index.ts b/src/index.ts index 5693aa2..2382c87 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,7 +40,6 @@ app.on('ready', () => { main.show(); // ! Make sure to destoy appLoader in production. appLoader.destroy(); - main.maximize(); const rawConfig = fs.readFileSync(userConfigPath, { encoding: 'utf-8' }); const configs = JSON.parse(rawConfig); From 63346b68d9a835830ab0434c968bc57c293f1ce2 Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 23 Dec 2023 06:55:58 -0400 Subject: [PATCH 101/103] set up for production --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 2382c87..79890e0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,7 +33,7 @@ app.on('ready', () => { show: false }); // ! Make sure to set the application menu to null in production. - // Menu.setApplicationMenu(null); + Menu.setApplicationMenu(null); main.loadFile(path.join(publicPath, 'index.html')); main.on('ready-to-show', () => { logger.logMessage(`Main window ready to show.`); From 6296450e18fb6fcf8aaebf78d078da67802cf49f Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 23 Dec 2023 07:55:01 -0400 Subject: [PATCH 102/103] dev note... --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index da58254..3f6e192 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ +# DEV NOTE: + +Hey! It's been a long while since I last updated Random Browser. It's currently December 23th 2023, v2.0.0 is finally out, or at least, it'll be soon. + +Since the first line of code, Random Browser was just an experiment and I didn't even plan to update it... + +But here we are, Random Browser's last release is out. + +This version of Random Browser won't receive new features, just small bug fixes (if any). + +Note how I said "this version", though. I've been planning to migrate the entire projet to a different framework or programming language. + +We'll see... +

Random Browser

From df78264e20bc1ab5919c5c4ef181b8a63c9ff27c Mon Sep 17 00:00:00 2001 From: Yisus Date: Sat, 23 Dec 2023 08:03:02 -0400 Subject: [PATCH 103/103] packaging... --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index ab63e41..5af8913 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,7 @@ "build": "tsc", "start:dev": "nodemon build/index.js", "build:dev": "tsc -w", - "pack-mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=assets/icons/icon.icns --prune=true --out=dist", - "pack-win": "electron-packager . random-browser --overwrite --asar=false --platform=win32 --arch=ia32 --icon=assets/icons/icon.ico --prune=true --out=dist --version-string.CompanyName=YisusGaming --version-string.FileDescription=\"Just a random browser...\" --version-string.ProductName=\"Random Browser\"", - "pack-linux": "electron-packager . random-browser --overwrite --asar=false --platform=linux --arch=x64 --icon=assets/icons/1024x1024.png --prune=true --out=dist" + "pack-win": "electron-packager . random-browser --overwrite --asar=false --platform=win32 --arch=ia32 --icon=assets/icons/icon.ico --prune=true --out=dist --version-string.CompanyName=YisusGaming --version-string.FileDescription=\"Just a random browser...\" --version-string.ProductName=\"Random Browser\"" }, "repository": "https://github.com/YisusGaming/random-browser", "author": "YisusGaming",