Remove everything electron from the repository

Tauri.app will take its place.
This commit is contained in:
Tor Hveem 2023-02-18 14:59:39 +01:00
parent 7effd0d216
commit 3d3377b686
11 changed files with 5 additions and 1686 deletions

4
.gitignore vendored
View File

@ -1,10 +1,6 @@
bower_components/
node_modules/
# Electron stuff
fonts/
Glowing\ Bear-*/
# local build products
build/

View File

@ -16,7 +16,6 @@ Now point your browser to the [Glowing Bear](https://www.glowing-bear.org)! If y
You can run Glowing Bear in many ways:
* like any other webpage
* Electron app for Windows, Linux and macOS. ```npm install; npm install electron-packager; npm run build-electron-{windows, darwin, linux}``` (choose your platform from the list, e.g. `build-electron-darwin` for macOS)
* Chrome app ("Tools", then "Create application shortcuts")
* Android Chrome app, a full-screen experience ("Add to homescreen").

View File

@ -1,25 +0,0 @@
# Common flags for electron-packager on all platforms
ELECTRON_COMMON=./build "Glowing Bear" --overwrite --version-string.FileDescription="Glowing Bear" --ignore=node_modules --ignore=test --ignore=bower_components
build:
npm run build
# copy dependencies from bower_components to the correct place
#copylocal:
# find bower_components \( -name "*min.js" -o -name "*min.css" \) -exec cp {} 3rdparty \;
# cp -r bower_components/bootstrap/fonts .
# modify index.html to use local files
#uselocal: copylocal
# sed -i.bak 's,https://cdnjs.cloudflare.com/ajax/libs/[^\"]*/,3rdparty/,g' index.html
# sed -i.bak 's, integrity=\".*\" crossorigin=\"anonymous\",,' index.html
# build the electron app for various platforms
build-electron-windows: build
electron-packager ${ELECTRON_COMMON} --platform=win32 --arch=ia32 --electron-version=9.0.5 --icon=assets/img/favicon.ico --asar=true
build-electron-darwin: build
electron-packager ${ELECTRON_COMMON} --platform=darwin --arch=x64 --electron-version=9.0.5 --icon=assets/img/glowing-bear.icns
build-electron-linux: build
electron-packager ${ELECTRON_COMMON} --platform=linux --arch=x64 --electron-version=9.0.5 --icon=assets/img/favicon.ico

1487
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,6 @@
"version": "0.10.0",
"description": "A web client for Weechat",
"repository": "https://github.com/glowing-bear/glowing-bear",
"main": "electron-main.js",
"license": "GPLv3",
"devDependencies": {
"@babel/core": "^7.16.12",
@ -13,7 +12,6 @@
"angular-mocks": "^1.8.3",
"babel-loader": "^8.2.3",
"copy-webpack-plugin": "^10.2.1",
"electron-packager": "^17.1.1",
"html-webpack-plugin": "^5.5.0",
"jasmine-core": "^3.99.0",
"jshint": "^2.13.3",
@ -40,9 +38,6 @@
"update-webdriver": "webdriver-manager update",
"preprotractor": "npm run update-webdriver",
"protractor": "protractor test/protractor-conf.js",
"build-electron-windows": "make -f electron.makefile build-electron-windows",
"build-electron-darwin": "make -f electron.makefile build-electron-darwin",
"build-electron-linux": "make -f electron.makefile build-electron-linux",
"tauri": "tauri"
},
"dependencies": {

View File

@ -1,19 +0,0 @@
/**
* Global functions for electron app
*/
var ipc = require('electron').ipcRenderer;
// Set app bagde
var setElectronBadge = function(value) {
// Check ipc
if (ipc && typeof ipc.send === 'function') {
// Send new badge value
ipc.send('badge', value);
}
};
// Export global variables and functions
global.setElectronBadge = setElectronBadge;
// Let Glowing Bear know it's running as an electron app
window.is_electron = 1;

View File

@ -1,126 +0,0 @@
// Modules to control application life and create native browser window
const {app, BrowserWindow, shell, ipcMain} = require('electron');
const path = require('path');
const fs = require('fs');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
// We use this to store some tiny amount of preferences specific to electron
// things like window bounds and location
const initPath = "init.json";
function createWindow () {
let data;
// read saved state from file (e.g. window bounds)
try {
data = JSON.parse(fs.readFileSync(initPath, 'utf8'));
}
catch(e) {
console.log('Unable to read init.json: ', e);
}
// Create the browser window.
const bounds = (data && data.bounds) ? data.bounds : {width: 1280, height:800 };
mainWindow = new BrowserWindow({
width: bounds.width,
height: bounds.height,
webPreferences: {
preload: path.join(__dirname, 'electron-globals.js')
}
});
// Remember window position
if (data && data.bounds.x && data.bounds.y) {
mainWindow.x = data.bounds.x;
mainWindow.y = data.bounds.y;
}
mainWindow.setMenu(null);
mainWindow.setMenuBarVisibility(false);
mainWindow.setAutoHideMenuBar(true);
// and load the index.html of the app.
mainWindow.loadFile('index.html');
// Open the DevTools.
// mainWindow.webContents.openDevTools()
var handleLink = (e, url) => {
if(url != mainWindow.webContents.getURL()) {
e.preventDefault();
shell.openExternal(url);
}
};
mainWindow.webContents.on('will-navigate', handleLink);
mainWindow.webContents.on('new-window', handleLink);
// Emitted when the window is closing.
mainWindow.on('close', function () {
let data = {
bounds: mainWindow.getBounds()
};
try {
fs.writeFileSync(initPath, JSON.stringify(data));
} catch (e) {
console.log('Unable to save save init.json: ', e);
}
});
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
app.on('browser-window-focus', function() {
setTimeout(function() { mainWindow.webContents.focus(); }, 0);
setTimeout(function() { mainWindow.webContents.executeJavaScript("document.getElementById(\"sendMessage\").focus()"); }, 0);
});
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', function() {
createWindow();
});
// Listen for badge changes
ipcMain.on('badge', function(event, arg) {
if (process.platform === "darwin") {
app.dock.setBadge(String(arg));
}
else if (process.platform === "win32") {
let n = parseInt(arg, 10);
// Only show notifications with number
if (isNaN(n)) {
return;
}
if (n > 0) {
mainWindow.setOverlayIcon(__dirname + '/assets/img/favicon.ico', String(arg));
} else {
mainWindow.setOverlayIcon(null, '');
}
}
});
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') app.quit();
});
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) createWindow();
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

View File

@ -298,12 +298,6 @@ chown -R <strong>username</strong>:<strong>username</strong> ~<strong>username</
<div id="collapseFour" class="panel-collapse collapse">
<div class="panel-body">
<p>You don&apos;t need to install anything to use Glowing Bear, it works with any modern browser. Start using it right now at the top of the page! However, there are a few ways to improve integration with your operating system.</p>
<h3>Electron</h3>
<p>Glowing Bear supports the electron shell. You&apos;ll have to build it yourself, though. Run the following commands, choosing your platform from the list in the last command: <pre>git clone https://github.com/glowing-bear/glowing-bear
cd glowing-bear
npm install
npm install electron-packager
npm run build-electron-{windows, darwin, linux}</pre>
<h3>Chrome</h3>
<p>To install Glowing Bear as an app in Chrome for Android, select <kbd>Menu - Add to home screen</kbd>. In the desktop version of Chrome, click <kbd>Menu - More tools - Create application shortcuts</kbd>.</p>
<h3>Firefox Browser</h3>

View File

@ -113,8 +113,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Show a TLS warning if GB was loaded over an unencrypted connection,
// except for local instances (local files, testing)
$scope.show_tls_warning = (["https:", "file:"].indexOf(window.location.protocol) === -1) &&
(["localhost", "127.0.0.1", "::1"].indexOf(window.location.hostname) === -1) &&
!window.is_electron;
(["localhost", "127.0.0.1", "::1"].indexOf(window.location.hostname) === -1)
$rootScope.isWindowFocused = function() {
if (typeof $scope.documentHidden === "undefined") {

View File

@ -24,8 +24,8 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
}
}
// Check for serviceWorker support, and also disable serviceWorker if we're running in electron process, since that's just problematic and not necessary, since gb then already is in a separate process
if ('serviceWorker' in navigator && window.is_electron !== 1 && !utils.isTauri()) {
// Check for serviceWorker support, and also disable serviceWorker if we're running in tauri process, since that's just problematic and not necessary, since gb then already is in a separate process
if ('serviceWorker' in navigator && !utils.isTauri()) {
$log.info('Service Worker is supported');
navigator.serviceWorker.register('serviceworker.js').then(function(reg) {
$log.info('Service Worker install:', reg);
@ -167,15 +167,9 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
}
};
// Update app badge (electron only)
// Update app badge (tauri? only)
var updateBadge = function(value) {
// Send new value to preloaded global function
// if it exists
if (typeof setElectronBadge === 'function') {
setElectronBadge(value);
}
// leaving this a placeholder for future tauri badge operations
};
/* Function gets called from bufferLineAdded code if user should be notified */

View File

@ -37,7 +37,6 @@ module.exports = {
"**/*.png",
"directives/*.html",
"serviceworker.js",
"electron-*.js",
"../package.json",
"manifest.json",
"manifest.webapp",