From 76008e8abd3e89eda16d39260e93e570d44cff7f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 12 Apr 2017 18:13:25 +0100 Subject: [PATCH 1/8] Remember and Recall window layout so that position+size persist Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- electron/src/electron-main.js | 16 +++++++++++++++- package.json | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/electron/src/electron-main.js b/electron/src/electron-main.js index 33b44ce9d1..8dd5e81333 100644 --- a/electron/src/electron-main.js +++ b/electron/src/electron-main.js @@ -30,6 +30,8 @@ const tray = require('./tray'); const VectorMenu = require('./vectormenu'); +const windowStateKeeper = require('electron-window-state'); + let vectorConfig = {}; try { vectorConfig = require('../../webapp/config.json'); @@ -186,11 +188,21 @@ electron.app.on('ready', () => { process.platform == 'win32' ? 'ico' : 'png' ); + // Load the previous window state with fallback to defaults + let mainWindowState = windowStateKeeper({ + defaultWidth: 1024, + defaultHeight: 768, + }); + mainWindow = new electron.BrowserWindow({ icon: icon_path, - width: 1024, height: 768, show: false, autoHideMenuBar: true, + + x: mainWindowState.x, + y: mainWindowState.y, + width: mainWindowState.width, + height: mainWindowState.height, }); mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`); electron.Menu.setApplicationMenu(VectorMenu); @@ -226,6 +238,8 @@ electron.app.on('ready', () => { onLinkContextMenu(ev, params); } }); + + mainWindowState.manage(mainWindow); }); electron.app.on('window-all-closed', () => { diff --git a/package.json b/package.json index 28cde3895a..35ffb87b78 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,7 @@ "css-raw-loader": "^0.1.1", "electron-builder": "^11.2.4", "electron-builder-squirrel-windows": "^11.2.1", + "electron-window-state": "^4.1.0", "emojione": "^2.2.7", "eslint": "^3.14.0", "eslint-config-google": "^0.7.1", From 3fb54029d7dff8b66f48d6a50ce4ac92ed268373 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 13 Apr 2017 13:39:15 +0100 Subject: [PATCH 2/8] Fix packaged functionality Improve dependency management for Electron main process deps Dependencies in /electron/package.json will be installed through a script in /package.json and will be bundled via electron-builder Does not affect standard webapp whatsoever Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .gitignore | 1 + electron/package.json | 6 ++++++ package.json | 11 ++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 electron/package.json diff --git a/.gitignore b/.gitignore index c28df64c65..86baa127f7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /key.pem /lib /node_modules +/electron/node_modules /packages/ /webapp /.npmrc diff --git a/electron/package.json b/electron/package.json new file mode 100644 index 0000000000..e6e7e2a42d --- /dev/null +++ b/electron/package.json @@ -0,0 +1,6 @@ +{ + "description": "Electron main process dependencies", + "dependencies": { + "electron-window-state": "^4.1.0" + } +} diff --git a/package.json b/package.json index 35ffb87b78..dc1e3bea96 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "build": "node scripts/babelcheck.js && npm run build:res && npm run build:bundle", "build:dev": "node scripts/babelcheck.js && npm run build:res && npm run build:bundle:dev", "dist": "scripts/package.sh", + "postinstall": "cd electron && npm i", "start:res": "node scripts/copy-res.js -w", "start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-file=bundles/_dev_/[name].js -w --progress", "start:js:prod": "NODE_ENV=production webpack-dev-server -w --progress", @@ -96,7 +97,6 @@ "css-raw-loader": "^0.1.1", "electron-builder": "^11.2.4", "electron-builder-squirrel-windows": "^11.2.1", - "electron-window-state": "^4.1.0", "emojione": "^2.2.7", "eslint": "^3.14.0", "eslint-config-google": "^0.7.1", @@ -145,6 +145,7 @@ "dereference": true, "//files": "We bundle everything, so we only need to include webapp/", "files": [ + "electron/node_modules/**", "electron/src/**", "electron/img/**", "webapp/**", @@ -159,10 +160,10 @@ }, "win": { "target": "squirrel" + }, + "directories": { + "buildResources": "electron/build", + "output": "electron/dist" } - }, - "directories": { - "buildResources": "electron/build", - "output": "electron/dist" } } From 9e2324fb69342897d3a95fa4bf8a9d95dae66be0 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 23 Apr 2017 22:50:58 +0100 Subject: [PATCH 3/8] don't hook on postinstall, current dev cycle uses (abuses) npm i to build so no point making it take longer than it has to for the devs only testing webapp build:electron - hook npm run install:electron install:electron - run npm i for the electron deps electron - start the app locally for testing add to README Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- README.md | 1 + package.json | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d7ab81b8a..7bef64783d 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ To run as a desktop app: ``` npm install electron + npm run install:electron node_modules/.bin/electron . ``` diff --git a/package.json b/package.json index dc1e3bea96..a64d0d9ea3 100644 --- a/package.json +++ b/package.json @@ -32,11 +32,12 @@ "build:compile": "babel --source-maps -d lib src", "build:bundle": "NODE_ENV=production webpack -p --progress", "build:bundle:dev": "webpack --optimize-occurence-order --progress", - "build:electron": "npm run clean && npm run build && build -wml --ia32 --x64", + "build:electron": "npm run clean && npm run build && npm run install:electron && build -wml --ia32 --x64", "build": "node scripts/babelcheck.js && npm run build:res && npm run build:bundle", "build:dev": "node scripts/babelcheck.js && npm run build:res && npm run build:bundle:dev", "dist": "scripts/package.sh", - "postinstall": "cd electron && npm i", + "install:electron": "cd electron && npm i", + "electron": "npm run install:electron && electron .", "start:res": "node scripts/copy-res.js -w", "start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-file=bundles/_dev_/[name].js -w --progress", "start:js:prod": "NODE_ENV=production webpack-dev-server -w --progress", From f54708227e0eb624dc178992c134519e42c43dfa Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 5 May 2017 16:54:55 +0100 Subject: [PATCH 4/8] Proper two package.json format, release.sh bumps 2nd json ver too Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- electron/package.json | 6 +++++- package.json | 14 ++++++++------ release.sh | 13 +++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/electron/package.json b/electron/package.json index e6e7e2a42d..0fff99f522 100644 --- a/electron/package.json +++ b/electron/package.json @@ -1,5 +1,9 @@ { - "description": "Electron main process dependencies", + "name": "riot-web", + "main": "src/electron-main.js", + "version": "0.0.0", + "description": "A feature-rich client for Matrix.org", + "author": "Vector Creations Ltd.", "dependencies": { "electron-window-state": "^4.1.0" } diff --git a/package.json b/package.json index a64d0d9ea3..e801ed5d07 100644 --- a/package.json +++ b/package.json @@ -146,11 +146,12 @@ "dereference": true, "//files": "We bundle everything, so we only need to include webapp/", "files": [ - "electron/node_modules/**", - "electron/src/**", - "electron/img/**", - "webapp/**", - "package.json" + "node_modules/**", + "src/**", + "img/**" + ], + "extraResources": [ + "webapp/**/*" ], "linux": { "target": "deb", @@ -164,7 +165,8 @@ }, "directories": { "buildResources": "electron/build", - "output": "electron/dist" + "output": "electron/dist", + "app": "electron" } } } diff --git a/release.sh b/release.sh index e8c68b9024..a3225150b6 100755 --- a/release.sh +++ b/release.sh @@ -9,4 +9,17 @@ set -e cd `dirname $0` + +# bump Electron's package.json first +release="${1#v}" +tag="v${release}" +echo "electron npm version" + +cd electron +npm version --no-git-tag-version "$release" +git commit package.json -m "$tag" + + +cd .. + exec ./node_modules/matrix-js-sdk/release.sh -z "$@" From 8a5020718936368d556c438a1f1b1691414c884c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 5 May 2017 16:57:18 +0100 Subject: [PATCH 5/8] Change shebang to bash for string manipulations Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.sh b/release.sh index a3225150b6..9d02e98e93 100755 --- a/release.sh +++ b/release.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Script to perform a release of vector-web. # From 499b04c25467fd4f6550568232a6d89797dcbe47 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 5 May 2017 17:01:32 +0100 Subject: [PATCH 6/8] Only install electron deps when we're bundling/running electron Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e801ed5d07..548c95d2fc 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "build": "node scripts/babelcheck.js && npm run build:res && npm run build:bundle", "build:dev": "node scripts/babelcheck.js && npm run build:res && npm run build:bundle:dev", "dist": "scripts/package.sh", - "install:electron": "cd electron && npm i", + "install:electron": "install-app-deps", "electron": "npm run install:electron && electron .", "start:res": "node scripts/copy-res.js -w", "start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-file=bundles/_dev_/[name].js -w --progress", From 1ed1080bf3fa8be1ef2325ad854b68893330bb90 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 5 May 2017 17:05:03 +0100 Subject: [PATCH 7/8] Update README with npm run electron Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 7bef64783d..55463a376e 100644 --- a/README.md +++ b/README.md @@ -135,8 +135,7 @@ To run as a desktop app: ``` npm install electron - npm run install:electron - node_modules/.bin/electron . + npm run electron ``` To build packages, use electron-builder. This is configured to output: From 309afdb813e1413a95de1ed248cdc5f78e7a7fd1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 5 May 2017 17:08:50 +0100 Subject: [PATCH 8/8] no point installing deps here, builder will do it for us Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d0161610d8..b01c1aa0c0 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "build:compile": "babel --source-maps -d lib src", "build:bundle": "cross-env NODE_ENV=production webpack -p --progress", "build:bundle:dev": "webpack --optimize-occurence-order --progress", - "build:electron": "npm run clean && npm run build && npm run install:electron && build -wml --ia32 --x64", + "build:electron": "npm run clean && npm run build && build -wml --ia32 --x64", "build": "npm run build:res && npm run build:bundle", "build:dev": "npm run build:res && npm run build:bundle:dev", "dist": "scripts/package.sh",