From 80b00fc80a1afbe416a6aa652eaba2b050ba9470 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Mon, 25 Dec 2017 20:37:11 -0300 Subject: [PATCH 01/14] add brew update --- build/install_deps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build/install_deps.sh b/build/install_deps.sh index 29b7dd723..0bdd6df01 100755 --- a/build/install_deps.sh +++ b/build/install_deps.sh @@ -42,6 +42,7 @@ if $LINUX; then $INSTALL build-essential libssl-dev libffi-dev libgmp3-dev python2.7-dev libsecret-1-dev curl elif $OSX && ! cmd_exists brew ; then /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew update fi From 7068ebaf57ed00f316b313b26574f788f513d280 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Tue, 26 Dec 2017 11:13:33 -0300 Subject: [PATCH 02/14] Clean .gitignore --- .gitignore | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 023767f02..ff60ee9e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,30 +1,5 @@ /node_modules -/LBRY-darwin-x64 /dist - -/src/main/dist -/src/main/locales -/src/main/node_modules -/src/renderer/dist -/build/venv /build/daemon.ver -/lbry-app-venv -/lbry-app -/lbry-venv /static/daemon/lbrynet* -/static/locales -/daemon/build -/daemon/venv -/daemon/requirements.txt -/.idea - -*.pyc -*.iml -.#* - -build/daemon.zip -.vimrc - -package-lock.json - -.DS_Store +/static/locales \ No newline at end of file From a212b8d908d2bf1a3b5e38ee7d8e732b0a84d152 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Tue, 2 Jan 2018 08:59:28 -0300 Subject: [PATCH 03/14] Setup productName and comply package name with npm/yarn rules --- electron-builder.json | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/electron-builder.json b/electron-builder.json index 9e0a8f86b..c3b878d30 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -1,5 +1,6 @@ { "appId": "io.lbry.LBRY", + "productName": "LBRY", "mac": { "category": "public.app-category.entertainment" }, diff --git a/package.json b/package.json index dc656400d..7623bf5b8 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "LBRY", + "name": "lbry-app", "version": "0.19.1", "description": "A browser for the LBRY network, a digital marketplace controlled by its users.", "homepage": "https://lbry.io/", From 8b37ec6b7292f5ccf48fc13a62c01e31d98ca947 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Mon, 8 Jan 2018 00:46:22 -0300 Subject: [PATCH 04/14] Comply naming with Airbnb guide --- src/main/index.js | 64 +++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 6c83391ff..67c7c3175 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,13 +1,13 @@ /* eslint-disable no-console */ // Module imports -import Path from 'path'; -import Url from 'url'; +import path from 'path'; +import url from 'url'; import Jayson from 'jayson'; -import Semver from 'semver'; -import Https from 'https'; -import Keytar from 'keytar'; +import SemVer from 'semver'; +import https from 'https'; +import keytar from 'keytar'; import ChildProcess from 'child_process'; -import Assert from 'assert'; +import assert from 'assert'; import { app, BrowserWindow, globalShortcut, ipcMain, Menu, Tray } from 'electron'; import mainMenu from './menu/mainMenu'; @@ -18,9 +18,9 @@ export { contextMenu as Default } from './menu/contextMenu'; const isDevelopment = process.env.NODE_ENV === 'development'; // Misc constants -const LATEST_RELEASE_API_URL = 'https://api.github.com/repos/lbryio/lbry-app/releases/latest'; -const DAEMON_PATH = process.env.LBRY_DAEMON || Path.join(__static, 'daemon/lbrynet-daemon'); -const rendererUrl = isDevelopment +const latestReleaseAPIURL = 'https://api.github.com/repos/lbryio/lbry-app/releases/latest'; +const daemonPath = process.env.LBRY_DAEMON || path.join(__static, 'daemon/lbrynet-daemon'); +const rendererURL = isDevelopment ? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}` : `file://${__dirname}/index.html`; @@ -47,7 +47,7 @@ let readyToQuit = false; // If we receive a URI to open from an external app but there's no window to // sendCredits it to, it's cached in this variable. -let openUri = null; +let openURI = null; // Set this to true to minimize on clicking close // false for normal action @@ -56,7 +56,7 @@ let minimize = true; // Keep the tray also, it is getting GC'd if put in createTray() let tray = null; -function processRequestedUri(uri) { +function processRequestedURI(URI) { // Windows normalizes URIs when they're passed in from other apps. On Windows, // this function tries to restore the original URI that was typed. // - If the URI has no path, Windows adds a trailing slash. LBRY URIs @@ -67,9 +67,9 @@ function processRequestedUri(uri) { // On Linux and Mac, we just return the URI as given. if (process.platform === 'win32') { - return uri.replace(/\/$/, '').replace('/#', '#'); + return URI.replace(/\/$/, '').replace('/#', '#'); } - return uri; + return URI; } /* @@ -163,11 +163,11 @@ function createWindow() { if (isDevelopment) { window.webContents.openDevTools(); } - window.loadURL(rendererUrl); - if (openUri) { + window.loadURL(rendererURL); + if (openURI) { // We stored and received a URI that an external app requested before we had a window object window.webContents.on('did-finish-load', () => { - window.webContents.send('open-uri-requested', openUri); + window.webContents.send('open-uri-requested', openURI); }); } @@ -224,9 +224,9 @@ function createTray() { if (process.platform === 'darwin') { // Using @2x for mac retina screens so the icon isn't blurry // file name needs to include "Template" at the end for dark menu bar - iconPath = Path.join(__static, '/img/fav/macTemplate@2x.png'); + iconPath = path.join(__static, '/img/fav/macTemplate@2x.png'); } else { - iconPath = Path.join(__static, '/img/fav/32x32.png'); + iconPath = path.join(__static, '/img/fav/32x32.png'); } tray = new Tray(iconPath); @@ -237,10 +237,10 @@ function createTray() { }); } -function handleOpenUriRequested(uri) { +function handleOpenURIRequested(URI) { if (!rendererWindow) { // Window not created yet, so store up requested URI for when it is - openUri = processRequestedUri(uri); + openURI = processRequestedURI(URI); } else { if (rendererWindow.isMinimized()) { rendererWindow.restore(); @@ -249,7 +249,7 @@ function handleOpenUriRequested(uri) { } rendererWindow.focus(); - rendererWindow.webContents.send('open-uri-requested', processRequestedUri(uri)); + rendererWindow.webContents.send('open-uri-requested', processRequestedURI(URI)); } } @@ -283,10 +283,10 @@ function handleDaemonSubprocessExited() { } function launchDaemon() { - Assert(!daemonSubprocess, 'Tried to launch daemon twice'); + assert(!daemonSubprocess, 'Tried to launch daemon twice'); - console.log('Launching daemon:', DAEMON_PATH); - daemonSubprocess = ChildProcess.spawn(DAEMON_PATH); + console.log('Launching daemon:', daemonPath); + daemonSubprocess = ChildProcess.spawn(daemonPath); // Need to handle the data event instead of attaching to // process.stdout because the latter doesn't work. I believe on // windows it buffers stdout and we don't get any meaningful output @@ -301,7 +301,7 @@ function launchDaemon() { const isSecondaryInstance = app.makeSingleInstance(argv => { if (argv.length >= 2) { - handleOpenUriRequested(argv[1]); // This will handle restoring and focusing the window + handleOpenURIRequested(argv[1]); // This will handle restoring and focusing the window } else if (rendererWindow) { if (rendererWindow.isMinimized()) { rendererWindow.restore(); @@ -444,11 +444,11 @@ app.on('activate', () => { }); if (process.platform === 'darwin') { - app.on('open-url', (event, uri) => { - handleOpenUriRequested(uri); + app.on('open-url', (event, URI) => { + handleOpenURIRequested(URI); }); } else if (process.argv.length >= 2) { - handleOpenUriRequested(process.argv[1]); + handleOpenURIRequested(process.argv[1]); } ipcMain.on('upgrade', (event, installerPath) => { @@ -486,7 +486,7 @@ ipcMain.on('version-info-requested', () => { }, }; - const req = Https.get(Object.assign(opts, Url.parse(LATEST_RELEASE_API_URL)), res => { + const req = https.get(Object.assign(opts, url.parse(latestReleaseAPIURL)), res => { res.on('data', data => { result += data; }); @@ -498,7 +498,7 @@ ipcMain.on('version-info-requested', () => { rendererWindow.webContents.send('version-info-received', null); } } else { - const upgradeAvailable = Semver.gt(formatRc(remoteVersion), formatRc(localVersion)); + const upgradeAvailable = SemVer.gt(formatRc(remoteVersion), formatRc(localVersion)); if (rendererWindow) { rendererWindow.webContents.send('version-info-received', { remoteVersion, @@ -519,11 +519,11 @@ ipcMain.on('version-info-requested', () => { }); ipcMain.on('get-auth-token', event => { - Keytar.getPassword('LBRY', 'auth_token').then(token => { + keytar.getPassword('LBRY', 'auth_token').then(token => { event.sender.send('auth-token-response', token ? token.toString().trim() : null); }); }); ipcMain.on('set-auth-token', (event, token) => { - Keytar.setPassword('LBRY', 'auth_token', token ? token.toString().trim() : null); + keytar.setPassword('LBRY', 'auth_token', token ? token.toString().trim() : null); }); From aeb43ff1a06f06624d7c110bb37a1fff6039c806 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Mon, 8 Jan 2018 00:57:05 -0300 Subject: [PATCH 05/14] Replace keytar with keytar-prebuild for resolving https://github.com/atom/node-keytar/issues/39 --- README.md | 37 +++---------------------------------- package.json | 2 +- src/main/index.js | 2 +- yarn.lock | 34 +++++++++++++++++++++++++++++----- 4 files changed, 34 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index be41950c6..0f2882544 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,11 @@ development and testing purposes. * [Git](https://git-scm.com/downloads) * [Node.js](https://nodejs.org/en/download/) * [Yarn](https://yarnpkg.com/en/docs/install) -* `yarn --add-python-to-path install --global --production windows-build-tools` (Windows only) ### One-time Setup 1. Clone this repo -2. `DEPS=true ./build.sh` +2. `./build.sh` This will download and install the LBRY app and its dependencies, including [the LBRY daemon](https://github.com/lbryio/lbry) and command line utilities like `node` and `yarn`. @@ -61,40 +60,10 @@ The app can be run from the sources using the following command: ### On Windows -#### Windows Dependency - -1. Download and install `git` from github.io - (configure to use command prompt integration) -2. Download and install `npm` and `node` from - nodejs.org -3. Download and install `python 2.7` from - python.org -4. Download and Install `Microsoft Visual C++ Compiler for Python 2.7` from - Microsoft -5. Download and install `.NET Framework 2.0 Software Development Kit (SDK) (x64)` from - Microsoft (may need - to extract setup.exe and install manually by running install.exe as Administrator) - #### One-time Setup -1. Open a command prompt as administrator and run the following: - -``` -npm install --global --production windows-build-tools -exit -``` - -2. Open a command prompt in the root of the project and run the following: - -``` -python -m pip install -r build\requirements.txt -npm install -g yarn -yarn install -yarn build -``` - -3. Download the lbry daemon and CLI [binaries](https://github.com/lbryio/lbry/releases) and place - them in `static\daemon`. +Download the lbry daemon and CLI [binaries](https://github.com/lbryio/lbry/releases) and place them +in `static\daemon`. ### Build diff --git a/package.json b/package.json index b12e46b70..41826463d 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "install": "^0.10.2", "jayson": "^2.0.2", "jshashes": "^1.0.7", - "keytar": "^4.0.3", + "keytar-prebuild": "^4.0.4", "localforage": "^1.5.0", "npm": "^5.5.1", "qrcode.react": "^0.7.2", diff --git a/src/main/index.js b/src/main/index.js index ad6812c5a..0042f8139 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -5,7 +5,7 @@ import url from 'url'; import Jayson from 'jayson'; import SemVer from 'semver'; import https from 'https'; -import keytar from 'keytar'; +import keytar from 'keytar-prebuild'; import ChildProcess from 'child_process'; import assert from 'assert'; import { app, BrowserWindow, globalShortcut, ipcMain, Menu, Tray } from 'electron'; diff --git a/yarn.lock b/yarn.lock index 35e76177e..bc55f3292 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5085,11 +5085,12 @@ keypress@0.1.x: version "0.1.0" resolved "https://registry.yarnpkg.com/keypress/-/keypress-0.1.0.tgz#4a3188d4291b66b4f65edb99f806aa9ae293592a" -keytar@^4.0.3: - version "4.1.0" - resolved "https://registry.yarnpkg.com/keytar/-/keytar-4.1.0.tgz#9e3933e489d656de1a868e1293709313044989d7" +keytar-prebuild@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/keytar-prebuild/-/keytar-prebuild-4.0.4.tgz#eb6354c68f2b3609dc325ef8709844632652d602" dependencies: - nan "2.5.1" + nan "2.7.0" + prebuild-install "^2.2.2" killable@^1.0.0: version "1.0.0" @@ -5822,7 +5823,11 @@ mute-stream@0.0.7, mute-stream@~0.0.4: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" -nan@2.5.1, nan@^2.3.0, nan@^2.3.2: +nan@2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46" + +nan@^2.3.0, nan@^2.3.2: version "2.5.1" resolved "https://registry.yarnpkg.com/nan/-/nan-2.5.1.tgz#d5b01691253326a97a2bbee9e61c55d8d60351e2" @@ -6937,6 +6942,25 @@ postcss@^6.0.1: source-map "^0.6.1" supports-color "^4.4.0" +prebuild-install@^2.2.2: + version "2.4.1" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.4.1.tgz#c28ba1d1eedc17fbd6b3229a657ffc0fba479b49" + dependencies: + expand-template "^1.0.2" + github-from-package "0.0.0" + minimist "^1.2.0" + mkdirp "^0.5.1" + node-abi "^2.1.1" + noop-logger "^0.1.1" + npmlog "^4.0.1" + os-homedir "^1.0.1" + pump "^1.0.1" + rc "^1.1.6" + simple-get "^1.4.2" + tar-fs "^1.13.0" + tunnel-agent "^0.6.0" + xtend "4.0.1" + prebuild-install@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.3.0.tgz#19481247df728b854ab57b187ce234211311b485" From d39bd9dda78de4d6f47118aeefac2e54b0fed7de Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Mon, 8 Jan 2018 01:33:51 -0300 Subject: [PATCH 06/14] Upgrade Electron version --- yarn.lock | 95 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 43 deletions(-) diff --git a/yarn.lock b/yarn.lock index bc55f3292..464678fb4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -95,8 +95,8 @@ component-url "^0.2.1" "@types/node@^7.0.18": - version "7.0.43" - resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c" + version "7.0.52" + resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.52.tgz#8990d3350375542b0c21a83cd0331e6a8fc86716" "@types/webpack-env@^1.13.2": version "1.13.2" @@ -182,7 +182,7 @@ ajv@^4.9.1: co "^4.6.0" json-stable-stringify "^1.0.1" -ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5, ajv@^5.2.3: +ajv@^5.0.0, ajv@^5.1.5, ajv@^5.2.3: version "5.5.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.0.tgz#eb2840746e9dc48bd5e063a36e3fd400c5eab5a9" dependencies: @@ -191,6 +191,15 @@ ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5, ajv@^5.2.3: fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.3.0" +ajv@^5.1.0, ajv@^5.5.1: + version "5.5.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + ajv@^5.3.0: version "5.5.1" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.1.tgz#b38bb8876d9e86bee994956a04e721e88b248eb2" @@ -200,15 +209,6 @@ ajv@^5.3.0: fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.3.0" -ajv@^5.5.1: - version "5.5.2" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" - dependencies: - co "^4.6.0" - fast-deep-equal "^1.0.0" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.3.0" - align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -2200,7 +2200,7 @@ core-js@^2.4.0, core-js@^2.5.0: version "2.5.1" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.1.tgz#ae6874dc66937789b80754ff5428df66819ca50b" -core-util-is@~1.0.0: +core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -2446,19 +2446,13 @@ debug@*, debug@^3.0.0, debug@^3.0.1, debug@^3.1.0: dependencies: ms "2.0.0" -debug@2, debug@2.6.9, debug@^2.1.3, debug@^2.6.6: +debug@2, debug@2.6.9, debug@^2.1.3, debug@^2.2.0, debug@^2.6.6: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: ms "2.0.0" -debug@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" - dependencies: - ms "0.7.1" - -debug@^2.2.0, debug@^2.6.8: +debug@^2.6.8: version "2.6.8" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: @@ -2911,8 +2905,8 @@ electron-webpack@^1.11.0: yargs "^10.0.3" electron@^1.7.9: - version "1.7.9" - resolved "https://registry.yarnpkg.com/electron/-/electron-1.7.9.tgz#add54e9f8f83ed02f6519ec10135f698b19336cf" + version "1.7.10" + resolved "https://registry.yarnpkg.com/electron/-/electron-1.7.10.tgz#3a3e83d965fd7fafe473be8ddf8f472561b6253d" dependencies: "@types/node" "^7.0.18" electron-download "^3.0.1" @@ -3062,10 +3056,14 @@ es6-promise@^3.0.2: version "3.3.1" resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.3.1.tgz#a08cdde84ccdbf34d027a1451bc91d4bcd28a613" -es6-promise@^4.0.3, es6-promise@^4.0.5: +es6-promise@^4.0.3: version "4.1.0" resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.1.0.tgz#dda03ca8f9f89bc597e689842929de7ba8cebdf0" +es6-promise@^4.0.5: + version "4.2.2" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.2.tgz#f722d7769af88bd33bc13ec6605e1f92966b82d9" + es6-promisify@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-3.0.0.tgz#22226b92957317f965247edfde9295f83efebe86" @@ -3490,17 +3488,21 @@ extract-text-webpack-plugin@^3.0.2: webpack-sources "^1.0.1" extract-zip@^1.0.3: - version "1.6.5" - resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.5.tgz#99a06735b6ea20ea9b705d779acffcc87cff0440" + version "1.6.6" + resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.6.tgz#1290ede8d20d0872b429fd3f351ca128ec5ef85c" dependencies: concat-stream "1.6.0" - debug "2.2.0" + debug "2.6.9" mkdirp "0.5.0" yauzl "2.4.1" -extsprintf@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" eyes@0.1.8: version "0.1.8" @@ -5049,13 +5051,13 @@ jsonpointer@^4.0.0: resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" jsprim@^1.2.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918" + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" dependencies: assert-plus "1.0.0" - extsprintf "1.0.2" + extsprintf "1.3.0" json-schema "0.2.3" - verror "1.3.6" + verror "1.10.0" jstransform@^11.0.3: version "11.0.3" @@ -5793,10 +5795,6 @@ mp4-stream@^2.0.0: next-event "^1.0.0" readable-stream "^2.0.3" -ms@0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" - ms@2.0.0, ms@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -7267,7 +7265,7 @@ rc-progress@^2.0.6: babel-runtime "6.x" prop-types "^15.5.8" -rc@^1.0.1, rc@^1.1.2, rc@^1.1.6, rc@^1.1.7, rc@^1.2.1: +rc@^1.0.1, rc@^1.1.6, rc@^1.1.7, rc@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" dependencies: @@ -7276,6 +7274,15 @@ rc@^1.0.1, rc@^1.1.2, rc@^1.1.6, rc@^1.1.7, rc@^1.2.1: minimist "^1.2.0" strip-json-comments "~2.0.1" +rc@^1.1.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.2.tgz#d8ce9cb57e8d64d9c7badd9876c7c34cbe3c7077" + dependencies: + deep-extend "~0.4.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + react-addons-create-fragment@^15.0.0: version "15.6.2" resolved "https://registry.yarnpkg.com/react-addons-create-fragment/-/react-addons-create-fragment-15.6.2.tgz#a394de7c2c7becd6b5475ba1b97ac472ce7c74f8" @@ -9008,11 +9015,13 @@ vendors@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/vendors/-/vendors-1.0.1.tgz#37ad73c8ee417fb3d580e785312307d274847f22" -verror@1.3.6: - version "1.3.6" - resolved "https://registry.yarnpkg.com/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" dependencies: - extsprintf "1.0.2" + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" videostream@^2.3.0: version "2.4.2" From 33d58347224d39205952dc05f75b6e336892d825 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Mon, 8 Jan 2018 02:16:31 -0300 Subject: [PATCH 07/14] Fix Electron linting errors (https://github.com/lbryio/lbry-app/issues/397) --- src/main/index.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index 0042f8139..0afbb15a7 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -8,7 +8,7 @@ import https from 'https'; import keytar from 'keytar-prebuild'; import ChildProcess from 'child_process'; import assert from 'assert'; -import { app, BrowserWindow, globalShortcut, ipcMain, Menu, Tray } from 'electron'; +import { app, BrowserWindow, globalShortcut, ipcMain, Menu, Tray, dialog } from 'electron'; import mainMenu from './menu/mainMenu'; import contextMenu from './menu/contextMenu'; @@ -170,6 +170,10 @@ function createWindow() { }); } + window.webContents.on('crashed', () => { + safeQuit(); + }); + window.removeAllListeners(); window.on('close', event => { @@ -211,6 +215,23 @@ function createWindow() { window.webContents.send('window-is-focused', null); }); + window.on('unresponsive', () => { + dialog.showMessageBox( + window, + { + type: 'warning', + buttons: ['Wait', 'Quit'], + title: 'LBRY Unresponsive', + defaultId: 1, + message: 'LBRY is not responding. Would you like to quit?', + cancelId: 0, + }, + buttonIndex => { + if (buttonIndex === 1) safeQuit(); + } + ); + }); + mainMenu(); return window; @@ -527,4 +548,9 @@ ipcMain.on('set-auth-token', (event, token) => { keytar.setPassword('LBRY', 'auth_token', token ? token.toString().trim() : null); }); +process.on('uncaughtException', error => { + console.error(error); + safeQuit(); +}); + export { contextMenu }; From 9d7f3f3b3079dded8990f6155f53b59578dfd9f4 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Mon, 8 Jan 2018 18:36:34 -0300 Subject: [PATCH 08/14] Add necessary deployment .gitignore rules --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ff60ee9e3..91e5403cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ /node_modules /dist /build/daemon.ver +/build/venv +*.pyc /static/daemon/lbrynet* -/static/locales \ No newline at end of file +/static/locales + + From 9f1d59764b97ec8716d1b030e8a785390f6ecb1f Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Mon, 8 Jan 2018 18:39:11 -0300 Subject: [PATCH 09/14] Move brew update to correct place --- build/install_deps.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build/install_deps.sh b/build/install_deps.sh index 0bdd6df01..c31b010f0 100755 --- a/build/install_deps.sh +++ b/build/install_deps.sh @@ -40,9 +40,12 @@ set -eu if $LINUX; then INSTALL="$SUDO apt-get install --no-install-recommends -y" $INSTALL build-essential libssl-dev libffi-dev libgmp3-dev python2.7-dev libsecret-1-dev curl -elif $OSX && ! cmd_exists brew ; then - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - brew update +elif $OSX; then + if ! cmd_exists brew; then + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + else + brew update + fi fi From 6298ae404b1336657b6ca4e5c8e3941e2821d5e3 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 13 Jan 2018 19:56:37 +1100 Subject: [PATCH 10/14] Fix CONTRIBUTING.md level issues links --- CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 578abc5f7..c1a3914e7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,11 +38,11 @@ To make contributing as easy and rewarding of possible, we have instituted the f | Level | Description | | --------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -| [**level 0**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level+0%22+no%3Aassignee) | Typos and text edits -- a tech-savvy non-programmer can fix these | -| [**level 1**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level+1%22+no%3Aassignee) | Programming issues that require little knowledge of how the LBRY app works | -| [**level 2**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level+2%22+no%3Aassignee) | Issues of average difficulty that require the developer to dig into how the app works a little bit | -| [**level 3**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level+3%22+no%3Aassignee) | Issues that are likely too tricky to be level 2 or require more thinking outside of the box | -| [**level 4**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level+4%22+no%3Aassignee) | Big features or really hard issues | +| [**level 0**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level%3A+0%22+no%3Aassignee) | Typos and text edits -- a tech-savvy non-programmer can fix these | +| [**level 1**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level%3A+1%22+no%3Aassignee) | Programming issues that require little knowledge of how the LBRY app works | +| [**level 2**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level%3A+2%22+no%3Aassignee) | Issues of average difficulty that require the developer to dig into how the app works a little bit | +| [**level 3**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level%3A+3%22+no%3Aassignee) | Issues that are likely too tricky to be level 2 or require more thinking outside of the box | +| [**level 4**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level%3A+4%22+no%3Aassignee) | Big features or really hard issues | The process of ranking issues is highly subjective. The purpose of sorting issues like this is to give contributors a general idea about the type of issues they are looking at. It could very well be From 0edf895baf3ad4496651344c78c37056cf4dfe25 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Mon, 15 Jan 2018 10:41:58 -0300 Subject: [PATCH 11/14] Add dependencies installation instructions for build script --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f2882544..7eabde706 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ development and testing purposes. ### One-time Setup 1. Clone this repo -2. `./build.sh` +2. `DEPS=true ./build.sh` This will download and install the LBRY app and its dependencies, including [the LBRY daemon](https://github.com/lbryio/lbry) and command line utilities like `node` and `yarn`. From 6a3a3b6f80b55c0896015c4576a1acb4217fa8c6 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Mon, 15 Jan 2018 14:29:02 -0300 Subject: [PATCH 12/14] Rename app as LBRY --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b2655a648..19b6f126d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "lbry-app", + "name": "LBRY", "version": "0.19.4", "description": "A browser for the LBRY network, a digital marketplace controlled by its users.", "homepage": "https://lbry.io/", From fd64ae58feac86ae91dc32a87a8eca8e1201b1dc Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Wed, 17 Jan 2018 23:13:08 -0300 Subject: [PATCH 13/14] Refactor main process --- src/main/Daemon.js | 64 ++ src/main/Tray.js | 63 ++ src/main/createWindow.js | 100 +++ src/main/index.js | 568 ++++-------------- src/main/menu/contextMenu.js | 20 - src/main/menu/mainMenu.js | 138 ----- src/main/menu/setupBarMenu.js | 89 +++ src/main/menu/setupContextMenu.js | 26 + src/renderer/index.js | 9 +- static/img/tray/default/tray.png | Bin 0 -> 2002 bytes static/img/tray/mac/trayTemplate.png | Bin 0 -> 1414 bytes static/img/tray/mac/trayTemplate@2x.png | Bin 0 -> 3331 bytes static/img/tray/windows/tray.ico | Bin 0 -> 4414 bytes static/img/untitled folder/trayTemplate.png | Bin 0 -> 1408 bytes .../img/untitled folder/trayTemplate@2x.png | Bin 0 -> 1784 bytes webpack.renderer.additions.js | 4 +- 16 files changed, 450 insertions(+), 631 deletions(-) create mode 100644 src/main/Daemon.js create mode 100644 src/main/Tray.js create mode 100644 src/main/createWindow.js delete mode 100644 src/main/menu/contextMenu.js delete mode 100644 src/main/menu/mainMenu.js create mode 100644 src/main/menu/setupBarMenu.js create mode 100644 src/main/menu/setupContextMenu.js create mode 100644 static/img/tray/default/tray.png create mode 100644 static/img/tray/mac/trayTemplate.png create mode 100644 static/img/tray/mac/trayTemplate@2x.png create mode 100644 static/img/tray/windows/tray.ico create mode 100644 static/img/untitled folder/trayTemplate.png create mode 100644 static/img/untitled folder/trayTemplate@2x.png diff --git a/src/main/Daemon.js b/src/main/Daemon.js new file mode 100644 index 000000000..b97d4714f --- /dev/null +++ b/src/main/Daemon.js @@ -0,0 +1,64 @@ +/* eslint-disable no-console */ +import path from 'path'; +import { spawn, execSync } from 'child_process'; + +export default class Daemon { + static path = process.env.LBRY_DAEMON || path.join(__static, 'daemon/lbrynet-daemon'); + subprocess; + handlers; + + constructor() { + this.handlers = []; + } + + launch() { + // Kill any running daemon + if (process.platform === 'win32') { + try { + execSync('taskkill /im lbrynet-daemon.exe /t /f'); + } catch (error) { + console.warn(error.message); + } + } else { + try { + execSync('pkill lbrynet-daemon'); + } catch (error) { + console.warn(error.message); + } + } + + console.log('Launching daemon:', Daemon.path); + this.subprocess = spawn(Daemon.path); + + this.subprocess.stdout.on('data', data => console.log(`Daemon: ${data}`)); + this.subprocess.stderr.on('data', data => console.error(`Daemon: ${data}`)); + this.subprocess.on('exit', () => this.fire('exit')); + this.subprocess.on('error', error => console.error(`Daemon: ${error}`)); + } + + quit() { + if (process.platform === 'win32') { + try { + execSync(`taskkill /pid ${this.subprocess.pid} /t /f`); + } catch (error) { + console.error(error.message); + } + } else { + this.subprocess.kill(); + } + } + + // Follows the publish/subscribe pattern + + // Subscribe method + on(event, handler, context = handler) { + this.handlers.push({ event, handler: handler.bind(context) }); + } + + // Publish method + fire(event, args) { + this.handlers.forEach(topic => { + if (topic.event === event) topic.handler(args); + }); + } +} diff --git a/src/main/Tray.js b/src/main/Tray.js new file mode 100644 index 000000000..6937dda42 --- /dev/null +++ b/src/main/Tray.js @@ -0,0 +1,63 @@ +import { app, Menu, Tray as ElectronTray } from 'electron'; +import path from 'path'; +import createWindow from './createWindow'; + +export default class Tray { + window; + updateAttachedWindow; + tray; + + constructor(window, updateAttachedWindow) { + this.window = window; + this.updateAttachedWindow = updateAttachedWindow; + } + + create() { + let iconPath; + switch (process.platform) { + case 'darwin': { + iconPath = path.join(__static, '/img/tray/mac/trayTemplate.png'); + break; + } + case 'win32': { + iconPath = path.join(__static, '/img/tray/windows/tray.ico'); + break; + } + default: { + iconPath = path.join(__static, '/img/tray/default/tray.png'); + } + } + + this.tray = new ElectronTray(iconPath); + + this.tray.on('double-click', () => { + if (!this.window || this.window.isDestroyed()) { + this.window = createWindow(); + this.updateAttachedWindow(this.window); + } else { + this.window.show(); + this.window.focus(); + } + }); + + this.tray.setToolTip('LBRY App'); + + const template = [ + { + label: `Open ${app.getName()}`, + click: () => { + if (!this.window || this.window.isDestroyed()) { + this.window = createWindow(); + this.updateAttachedWindow(this.window); + } else { + this.window.show(); + this.window.focus(); + } + }, + }, + { role: 'quit' }, + ]; + const contextMenu = Menu.buildFromTemplate(template); + this.tray.setContextMenu(contextMenu); + } +} diff --git a/src/main/createWindow.js b/src/main/createWindow.js new file mode 100644 index 000000000..6809761f3 --- /dev/null +++ b/src/main/createWindow.js @@ -0,0 +1,100 @@ +import { app, BrowserWindow, dialog } from 'electron'; +import setupBarMenu from './menu/setupBarMenu'; +import setupContextMenu from './menu/setupContextMenu'; + +export default deepLinkingURIArg => { + let windowConfiguration = { + backgroundColor: '#155B4A', + minWidth: 800, + minHeight: 600, + autoHideMenuBar: true, + show: false, + }; + + // Disable renderer process's webSecurity on development to enable CORS. + windowConfiguration = + process.env.NODE_ENV === 'development' + ? { + ...windowConfiguration, + webPreferences: { + webSecurity: false, + }, + } + : windowConfiguration; + + const rendererURL = + process.env.NODE_ENV === 'development' + ? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}` + : `file://${__dirname}/index.html`; + + let window = new BrowserWindow(windowConfiguration); + + window.maximize(); + + window.loadURL(rendererURL); + + let deepLinkingURI; + // Protocol handler for win32 + if ( + !deepLinkingURIArg && + process.platform === 'win32' && + String(process.argv[1]).startsWith('lbry') + ) { + // Keep only command line / deep linked arguments + // Windows normalizes URIs when they're passed in from other apps. On Windows, this tries to + // restore the original URI that was typed. + // - If the URI has no path, Windows adds a trailing slash. LBRY URIs can't have a slash with no + // path, so we just strip it off. + // - In a URI with a claim ID, like lbry://channel#claimid, Windows interprets the hash mark as + // an anchor and converts it to lbry://channel/#claimid. We remove the slash here as well. + deepLinkingURI = process.argv[1].replace(/\/$/, '').replace('/#', '#'); + } else { + deepLinkingURI = deepLinkingURIArg; + } + + setupBarMenu(); + setupContextMenu(window); + + window.on('closed', () => { + window = null; + }); + + window.on('focus', () => { + window.webContents.send('window-is-focused', null); + }); + + window.on('unresponsive', () => { + dialog.showMessageBox( + window, + { + type: 'warning', + buttons: ['Wait', 'Quit'], + title: 'LBRY Unresponsive', + defaultId: 1, + message: 'LBRY is not responding. Would you like to quit?', + cancelId: 0, + }, + buttonIndex => { + if (buttonIndex === 1) app.quit(); + } + ); + }); + + window.once('ready-to-show', () => { + window.show(); + }); + + window.webContents.on('did-finish-load', () => { + window.webContents.send('open-uri-requested', deepLinkingURI, true); + window.webContents.session.setUserAgent(`LBRY/${app.getVersion()}`); + if (process.env.NODE_ENV === 'development') { + window.webContents.openDevTools(); + } + }); + + window.webContents.on('crashed', () => { + window = null; + }); + + return window; +}; diff --git a/src/main/index.js b/src/main/index.js index 0afbb15a7..135611b69 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,510 +1,127 @@ /* eslint-disable no-console */ // Module imports -import path from 'path'; -import url from 'url'; -import Jayson from 'jayson'; -import SemVer from 'semver'; -import https from 'https'; import keytar from 'keytar-prebuild'; -import ChildProcess from 'child_process'; -import assert from 'assert'; -import { app, BrowserWindow, globalShortcut, ipcMain, Menu, Tray, dialog } from 'electron'; -import mainMenu from './menu/mainMenu'; -import contextMenu from './menu/contextMenu'; +import SemVer from 'semver'; +import url from 'url'; +import https from 'https'; +import { shell, app, ipcMain, dialog } from 'electron'; +import Daemon from './Daemon'; +import Tray from './Tray'; +import createWindow from './createWindow'; -const localVersion = app.getVersion(); - -// Debug configs -const isDevelopment = process.env.NODE_ENV === 'development'; - -// Misc constants -const latestReleaseAPIURL = 'https://api.github.com/repos/lbryio/lbry-app/releases/latest'; -const daemonPath = process.env.LBRY_DAEMON || path.join(__static, 'daemon/lbrynet-daemon'); -const rendererURL = isDevelopment - ? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}` - : `file://${__dirname}/index.html`; - -const client = Jayson.client.http({ - host: 'localhost', - port: 5279, - path: '/', - timeout: 1000, -}); - -// 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. +// Keep a global reference, if you don't, they will be closed automatically when the JavaScript +// object is garbage collected. let rendererWindow; -// Also keep the daemon subprocess alive -let daemonSubprocess; +// eslint-disable-next-line no-unused-vars +let tray; +let daemon; -// This is set to true right before we try to shut the daemon subprocess -- -// if it dies when we didn't ask it to shut down, we want to alert the user. -let daemonStopRequested = false; +let isQuitting; -// When a quit is attempted, we cancel the quit, do some preparations, then -// this is set to true and app.quit() is called again to quit for real. -let readyToQuit = false; +const updateRendererWindow = window => { + rendererWindow = window; +}; -// If we receive a URI to open from an external app but there's no window to -// sendCredits it to, it's cached in this variable. -let openURI = null; +const installExtensions = async () => { + // eslint-disable-next-line import/no-extraneous-dependencies,global-require + const installer = require('electron-devtools-installer'); + // eslint-disable-next-line import/no-extraneous-dependencies,global-require + const devtronExtension = require('devtron'); + const forceDownload = !!process.env.UPGRADE_EXTENSIONS; + const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS']; -// Set this to true to minimize on clicking close -// false for normal action -let minimize = true; - -// Keep the tray also, it is getting GC'd if put in createTray() -let tray = null; - -function processRequestedURI(URI) { - // Windows normalizes URIs when they're passed in from other apps. On Windows, - // this function tries to restore the original URI that was typed. - // - If the URI has no path, Windows adds a trailing slash. LBRY URIs - // can't have a slash with no path, so we just strip it off. - // - In a URI with a claim ID, like lbry://channel#claimid, Windows - // interprets the hash mark as an anchor and converts it to - // lbry://channel/#claimid. We remove the slash here as well. - // On Linux and Mac, we just return the URI as given. - - if (process.platform === 'win32') { - return URI.replace(/\/$/, '').replace('/#', '#'); - } - return URI; -} - -/* - * Replacement for Electron's shell.openItem. The Electron version doesn't - * reliably work from the main process, and we need to be able to run it - * when no windows are open. - */ -function openItem(fullPath) { - const subprocOptions = { - detached: true, - stdio: 'ignore', - }; - - let child; - if (process.platform === 'darwin') { - child = ChildProcess.spawn('open', [fullPath], subprocOptions); - } else if (process.platform === 'linux') { - child = ChildProcess.spawn('xdg-open', [fullPath], subprocOptions); - } else if (process.platform === 'win32') { - child = ChildProcess.spawn(fullPath, Object.assign({}, subprocOptions, { shell: true })); - } - - // Causes child process reference to be garbage collected, allowing main process to exit - child.unref(); -} -/* - * Quits by first killing the daemon, the calling quitting for real. - */ -export function safeQuit() { - minimize = false; - app.quit(); -} - -function getMenuTemplate() { - function getToggleItem() { - if (rendererWindow.isVisible() && rendererWindow.isFocused()) { - return { - label: 'Hide LBRY App', - click: () => rendererWindow.hide(), - }; - } - return { - label: 'Show LBRY App', - click: () => rendererWindow.show(), - }; - } - - return [ - getToggleItem(), - { - label: 'Quit', - click: () => safeQuit(), - }, - ]; -} - -// This needs to be done as for linux the context menu doesn't update automatically(docs) -function updateTray() { - const trayContextMenu = Menu.buildFromTemplate(getMenuTemplate()); - if (tray) { - tray.setContextMenu(trayContextMenu); - } else { - console.log('How did update tray get called without a tray?'); - } -} - -function createWindow() { - // Disable renderer process's webSecurity on development to enable CORS. - let windowConfiguration = { - backgroundColor: '#155B4A', - minWidth: 800, - minHeight: 600, - autoHideMenuBar: true, - }; - - windowConfiguration = isDevelopment - ? { - ...windowConfiguration, - webPreferences: { - webSecurity: false, - }, - } - : windowConfiguration; - - let window = new BrowserWindow(windowConfiguration); - - window.webContents.session.setUserAgent(`LBRY/${localVersion}`); - - window.maximize(); - if (isDevelopment) { - window.webContents.openDevTools(); - } - window.loadURL(rendererURL); - if (openURI) { - // We stored and received a URI that an external app requested before we had a window object - window.webContents.on('did-finish-load', () => { - window.webContents.send('open-uri-requested', openURI, true); - }); - } - - window.webContents.on('crashed', () => { - safeQuit(); - }); - - window.removeAllListeners(); - - window.on('close', event => { - if (minimize) { - event.preventDefault(); - window.hide(); - } - }); - - window.on('closed', () => { - window = null; - }); - - window.on('hide', () => { - // Checks what to show in the tray icon menu - if (minimize) updateTray(); - }); - - window.on('show', () => { - // Checks what to show in the tray icon menu - if (minimize) updateTray(); - }); - - window.on('blur', () => { - // Checks what to show in the tray icon menu - if (minimize) updateTray(); - - // Unregisters Alt+F4 shortcut - globalShortcut.unregister('Alt+F4'); - }); - - window.on('focus', () => { - // Checks what to show in the tray icon menu - if (minimize) updateTray(); - - // Registers shortcut for closing(quitting) the app - globalShortcut.register('Alt+F4', () => safeQuit()); - - window.webContents.send('window-is-focused', null); - }); - - window.on('unresponsive', () => { - dialog.showMessageBox( - window, - { - type: 'warning', - buttons: ['Wait', 'Quit'], - title: 'LBRY Unresponsive', - defaultId: 1, - message: 'LBRY is not responding. Would you like to quit?', - cancelId: 0, - }, - buttonIndex => { - if (buttonIndex === 1) safeQuit(); - } - ); - }); - - mainMenu(); - - return window; -} - -function createTray() { - // Minimize to tray logic follows: - // Set the tray icon - let iconPath; - if (process.platform === 'darwin') { - // Using @2x for mac retina screens so the icon isn't blurry - // file name needs to include "Template" at the end for dark menu bar - iconPath = path.join(__static, '/img/fav/macTemplate@2x.png'); - } else { - iconPath = path.join(__static, '/img/fav/32x32.png'); - } - - tray = new Tray(iconPath); - tray.setToolTip('LBRY App'); - tray.setTitle('LBRY'); - tray.on('double-click', () => { - rendererWindow.show(); - }); -} - -function handleOpenURIRequested(URI) { - if (!rendererWindow) { - // Window not created yet, so store up requested URI for when it is - openURI = processRequestedURI(URI); - } else { - if (rendererWindow.isMinimized()) { - rendererWindow.restore(); - } else if (!rendererWindow.isVisible()) { - rendererWindow.show(); - } - - rendererWindow.focus(); - rendererWindow.webContents.send('open-uri-requested', processRequestedURI(URI)); - } -} - -/* - * Quits without any preparation. When a quit is requested (either through the - * interface or through app.quit()), we abort the quit, try to shut down the daemon, - * and then call this to quit for real. - */ -function quitNow() { - readyToQuit = true; - safeQuit(); -} - -function handleDaemonSubprocessExited() { - console.log('The daemon has exited.'); - daemonSubprocess = null; - if (!daemonStopRequested) { - // We didn't request to stop the daemon, so display a - // warning and schedule a quit. - // - // TODO: maybe it would be better to restart the daemon? - if (rendererWindow) { - console.log('Did not request daemon stop, so quitting in 5 seconds.'); - rendererWindow.loadURL(`file://${__static}/warning.html`); - setTimeout(quitNow, 5000); - } else { - console.log('Did not request daemon stop, so quitting.'); - quitNow(); - } - } -} - -function launchDaemon() { - assert(!daemonSubprocess, 'Tried to launch daemon twice'); - - console.log('Launching daemon:', daemonPath); - daemonSubprocess = ChildProcess.spawn(daemonPath); - // Need to handle the data event instead of attaching to - // process.stdout because the latter doesn't work. I believe on - // windows it buffers stdout and we don't get any meaningful output - daemonSubprocess.stdout.on('data', buf => { - console.log(String(buf).trim()); - }); - daemonSubprocess.stderr.on('data', buf => { - console.log(String(buf).trim()); - }); - daemonSubprocess.on('exit', handleDaemonSubprocessExited); -} - -const isSecondaryInstance = app.makeSingleInstance(argv => { - if (argv.length >= 2) { - handleOpenURIRequested(argv[1]); // This will handle restoring and focusing the window - } else if (rendererWindow) { - if (rendererWindow.isMinimized()) { - rendererWindow.restore(); - } else if (!rendererWindow.isVisible()) { - rendererWindow.show(); - } - rendererWindow.focus(); - } -}); - -if (isSecondaryInstance) { - // We're not in the original process, so quit - quitNow(); -} - -function launchDaemonIfNotRunning() { - // Check if the daemon is already running. If we get - // an error its because its not running - console.log('Checking for lbrynet daemon'); - client.request('status', [], err => { - if (err) { - console.log('lbrynet daemon needs to be launched'); - launchDaemon(); - } else { - console.log('lbrynet daemon is already running'); - } - }); -} - -// Taken from webtorrent-desktop -function checkLinuxTraySupport(cb) { - // Check that we're on Ubuntu (or another debian system) and that we have - // libappindicator1. - ChildProcess.exec('dpkg --get-selections libappindicator1', (err, stdout) => { - if (err) return cb(err); - // Unfortunately there's no cleaner way, as far as I can tell, to check - // whether a debian package is installed: - if (stdout.endsWith('\tinstall\n')) { - return cb(null); - } - return cb(new Error('debian package not installed')); - }); -} - -// When a quit is attempted, this is called. It attempts to shutdown the daemon, -// then calls quitNow() to quit for real. -function shutdownDaemonAndQuit(evenIfNotStartedByApp = false) { - function doShutdown() { - console.log('Shutting down daemon'); - daemonStopRequested = true; - client.request('daemon_stop', [], err => { - if (err) { - console.log(`received error when stopping lbrynet-daemon. Error message: ${err.message}\n`); - console.log('You will need to manually kill the daemon.'); - } else { - console.log('Successfully stopped daemon via RPC call.'); - quitNow(); - } - }); - } - - if (daemonSubprocess) { - doShutdown(); - } else if (!evenIfNotStartedByApp) { - console.log('Not killing lbrynet-daemon because app did not start it'); - quitNow(); - } else { - doShutdown(); - } - - // Is it safe to start the installer before the daemon finishes running? - // If not, we should wait until the daemon is closed before we start the install. -} - -if (isDevelopment) { - import('devtron') - .then(({ install }) => { - install(); - console.log('Added Extension: Devtron'); - }) - .catch(error => { - console.error(error); - }); - import('electron-devtools-installer') - .then(({ default: installExtension, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS }) => { - app.on('ready', () => { - [REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS].forEach(extension => { - installExtension(extension) - .then(name => console.log(`Added Extension: ${name}`)) - .catch(err => console.log('An error occurred: ', err)); - }); - }); - }) - .catch(error => { - console.error(error); - }); -} + return Promise.all( + extensions.map( + name => installer.default(installer[name], forceDownload), + devtronExtension.install() + ) + ).catch(console.log); +}; app.setAsDefaultProtocolClient('lbry'); +app.setName('LBRY'); -app.on('ready', () => { - launchDaemonIfNotRunning(); - if (process.platform === 'linux') { - checkLinuxTraySupport(err => { - if (!err) createTray(); - else minimize = false; - }); - } else { - createTray(); +app.on('ready', async () => { + daemon = new Daemon(); + daemon.on('exit', () => { + daemon = null; + if (!isQuitting) { + dialog.showErrorBox( + 'Daemon has Exited', + 'The daemon may have encountered an unexpected error, or another daemon instance is already running.' + ); + app.quit(); + } + }); + daemon.launch(); + if (process.env.NODE_ENV === 'development') { + await installExtensions(); } rendererWindow = createWindow(); -}); - -// Quit when all windows are closed. -app.on('window-all-closed', () => { - // 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('before-quit', event => { - if (!readyToQuit) { - // We need to shutdown the daemon before we're ready to actually quit. This - // event will be triggered re-entrantly once preparation is done. - event.preventDefault(); - shutdownDaemonAndQuit(); - } else { - console.log('Quitting.'); - } + tray = new Tray(rendererWindow, updateRendererWindow); + tray.create(); }); app.on('activate', () => { // 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 (rendererWindow === null) { - createWindow(); - } + if (!rendererWindow) rendererWindow = createWindow(); }); -if (process.platform === 'darwin') { - app.on('open-url', (event, URI) => { - handleOpenURIRequested(URI); +app.on('will-quit', () => { + isQuitting = true; + if (daemon) daemon.quit(); +}); + +// https://electronjs.org/docs/api/app#event-will-finish-launching +app.on('will-finish-launching', () => { + // Protocol handler for macOS + app.on('open-url', (event, URL) => { + event.preventDefault(); + if (rendererWindow && !rendererWindow.isDestroyed()) { + rendererWindow.webContents.send('open-uri-requested', URL); + rendererWindow.show(); + rendererWindow.focus(); + } else { + rendererWindow = createWindow(URL); + } }); -} else if (process.argv.length >= 2) { - handleOpenURIRequested(process.argv[1]); -} +}); + +app.on('window-all-closed', () => { + // Subscribe to event so the app doesn't quit when closing the window. +}); ipcMain.on('upgrade', (event, installerPath) => { app.on('quit', () => { console.log('Launching upgrade installer at', installerPath); // This gets triggered called after *all* other quit-related events, so // we'll only get here if we're fully prepared and quitting for real. - openItem(installerPath); + shell.openItem(installerPath); }); - - if (rendererWindow) { - rendererWindow.loadURL(`file://${__static}/upgrade.html`); - } - - shutdownDaemonAndQuit(true); - // wait for daemon to shut down before upgrading // what to do if no shutdown in a long time? console.log('Update downloaded to', installerPath); console.log( 'The app will close, and you will be prompted to install the latest version of LBRY.' ); console.log('After the install is complete, please reopen the app.'); + app.quit(); }); ipcMain.on('version-info-requested', () => { function formatRc(ver) { - // Adds dash if needed to make RC suffix semver friendly + // Adds dash if needed to make RC suffix SemVer friendly return ver.replace(/([^-])rc/, '$1-rc'); } - let result = ''; + const localVersion = app.getVersion(); + const latestReleaseAPIURL = 'https://api.github.com/repos/lbryio/lbry-app/releases/latest'; const opts = { headers: { 'User-Agent': `LBRY/${localVersion}`, }, }; + let result = ''; const req = https.get(Object.assign(opts, url.parse(latestReleaseAPIURL)), res => { res.on('data', data => { @@ -549,8 +166,33 @@ ipcMain.on('set-auth-token', (event, token) => { }); process.on('uncaughtException', error => { - console.error(error); - safeQuit(); + dialog.showErrorBox('Error Encountered', `Caught error: ${error}`); + isQuitting = true; + if (daemon) daemon.quit(); + app.exit(1); }); -export { contextMenu }; +// Force single instance application +const isSecondInstance = app.makeSingleInstance(argv => { + // Protocol handler for win32 + // argv: An array of the second instance’s (command line / deep linked) arguments + + let URI; + if (process.platform === 'win32' && String(argv[1]).startsWith('lbry')) { + // Keep only command line / deep linked arguments + URI = argv[1].replace(/\/$/, '').replace('/#', '#'); + } + + if (rendererWindow && !rendererWindow.isDestroyed()) { + rendererWindow.webContents.send('open-uri-requested', URI); + + rendererWindow.show(); + rendererWindow.focus(); + } else { + rendererWindow = createWindow(URI); + } +}); + +if (isSecondInstance) { + app.exit(); +} diff --git a/src/main/menu/contextMenu.js b/src/main/menu/contextMenu.js deleted file mode 100644 index e24885ec2..000000000 --- a/src/main/menu/contextMenu.js +++ /dev/null @@ -1,20 +0,0 @@ -import { Menu } from 'electron'; - -const contextMenuTemplate = [{ role: 'cut' }, { role: 'copy' }, { role: 'paste' }]; - -export default (win, posX, posY, showDevItems) => { - const template = contextMenuTemplate.slice(); - if (showDevItems) { - template.push({ - type: 'separator', - }); - template.push({ - label: 'Inspect Element', - click() { - win.inspectElement(posX, posY); - }, - }); - } - - Menu.buildFromTemplate(template).popup(win); -}; diff --git a/src/main/menu/mainMenu.js b/src/main/menu/mainMenu.js deleted file mode 100644 index 879ce8206..000000000 --- a/src/main/menu/mainMenu.js +++ /dev/null @@ -1,138 +0,0 @@ -import { app, Menu, shell } from 'electron'; -import { safeQuit } from '../index'; - -const baseTemplate = [ - { - label: 'File', - submenu: [ - { - label: 'Quit', - accelerator: 'CommandOrControl+Q', - click: () => safeQuit(), - }, - ], - }, - { - label: 'Edit', - submenu: [ - { - role: 'undo', - }, - { - role: 'redo', - }, - { - type: 'separator', - }, - { - role: 'cut', - }, - { - role: 'copy', - }, - { - role: 'paste', - }, - { - role: 'selectall', - }, - ], - }, - { - label: 'View', - submenu: [ - { - role: 'reload', - }, - { - label: 'Developer', - submenu: [ - { - role: 'forcereload', - }, - { - role: 'toggledevtools', - }, - ], - }, - { - type: 'separator', - }, - { - role: 'togglefullscreen', - }, - ], - }, - { - role: 'help', - submenu: [ - { - label: 'Learn More', - click(item, focusedWindow) { - if (focusedWindow) { - focusedWindow.webContents.send('open-menu', '/help'); - } - }, - }, - { - label: 'Frequently Asked Questions', - click() { - shell.openExternal('https://lbry.io/faq'); - }, - }, - { - type: 'separator', - }, - { - label: 'Report Issue', - click() { - shell.openExternal('https://lbry.io/faq/contributing#report-a-bug'); - }, - }, - { - type: 'separator', - }, - { - label: 'Developer API Guide', - click() { - shell.openExternal('https://lbry.io/quickstart'); - }, - }, - ], - }, -]; - -const macOSAppMenuTemplate = { - label: app.getName(), - submenu: [ - { - role: 'about', - }, - { - type: 'separator', - }, - { - role: 'hide', - }, - { - role: 'hideothers', - }, - { - role: 'unhide', - }, - { - type: 'separator', - }, - { - role: 'quit', - }, - ], -}; - -export default () => { - const template = baseTemplate.slice(); - if (process.platform === 'darwin') { - template.unshift(macOSAppMenuTemplate); - } - Menu.setApplicationMenu(Menu.buildFromTemplate(template)); -}; diff --git a/src/main/menu/setupBarMenu.js b/src/main/menu/setupBarMenu.js new file mode 100644 index 000000000..14c4e74db --- /dev/null +++ b/src/main/menu/setupBarMenu.js @@ -0,0 +1,89 @@ +import { app, Menu, shell } from 'electron'; + +export default () => { + const template = [ + { + label: 'Edit', + submenu: [ + { role: 'undo' }, + { role: 'redo' }, + { type: 'separator' }, + { role: 'cut' }, + { role: 'copy' }, + { role: 'paste' }, + ], + }, + { + label: 'View', + submenu: [ + { role: 'reload' }, + { + label: 'Developer', + submenu: [{ role: 'forcereload' }, { role: 'toggledevtools' }], + }, + { type: 'separator' }, + { role: 'togglefullscreen' }, + ], + }, + { + role: 'window', + submenu: [{ role: 'minimize' }, { role: 'close' }], + }, + { + role: 'help', + submenu: [ + { + label: 'Learn More', + click: (menuItem, browserWindow) => { + if (browserWindow) { + browserWindow.webContents.send('open-menu', '/help'); + } else { + shell.openExternal('https://lbry.io/faq'); + } + }, + }, + { + label: 'Frequently Asked Questions', + click: () => { + shell.openExternal('https://lbry.io/faq'); + }, + }, + { type: 'separator' }, + { + label: 'Report Issue', + click: () => { + shell.openExternal('https://github.com/lbryio/lbry-app/issues/new'); + }, + }, + { type: 'separator' }, + { + label: 'Developer API Guide', + click: () => { + shell.openExternal('https://lbry.io/quickstart'); + }, + }, + ], + }, + ]; + + const darwinTemplateAddition = { + label: app.getName(), + submenu: [ + { role: 'about' }, + { type: 'separator' }, + { role: 'services', submenu: [] }, + { type: 'separator' }, + { role: 'hide' }, + { role: 'hideothers' }, + { type: 'separator' }, + { role: 'quit' }, + ], + }; + + if (process.platform === 'darwin') { + template.unshift(darwinTemplateAddition); + } + + const menu = Menu.buildFromTemplate(template); + Menu.setApplicationMenu(menu); +}; diff --git a/src/main/menu/setupContextMenu.js b/src/main/menu/setupContextMenu.js new file mode 100644 index 000000000..01f540d81 --- /dev/null +++ b/src/main/menu/setupContextMenu.js @@ -0,0 +1,26 @@ +// @flow +import { Menu, BrowserWindow } from 'electron'; + +export default (rendererWindow: BrowserWindow) => { + rendererWindow.webContents.on('context-menu', (e, params) => { + const { x, y } = params; + + const template = [{ role: 'cut' }, { role: 'copy' }, { role: 'paste' }]; + + const developmentTemplateAddition = [ + { type: 'separator' }, + { + label: 'Inspect element', + click: () => { + rendererWindow.inspectElement(x, y); + }, + }, + ]; + + if (process.env.NODE_ENV === 'development') { + template.push(...developmentTemplateAddition); + } + + Menu.buildFromTemplate(template).popup(); + }); +}; diff --git a/src/renderer/index.js b/src/renderer/index.js index fd6dcc1f7..06621e9de 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -1,3 +1,4 @@ +/* eslint-disable react/jsx-filename-extension */ import amplitude from 'amplitude-js'; import App from 'component/app'; import SnackBar from 'component/snackBar'; @@ -5,7 +6,6 @@ import SplashScreen from 'component/splash'; import * as ACTIONS from 'constants/action_types'; import { ipcRenderer, remote, shell } from 'electron'; import lbry from 'lbry'; -/* eslint-disable react/jsx-filename-extension */ import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; @@ -17,13 +17,6 @@ import 'scss/all.scss'; import store from 'store'; import app from './app'; -const { contextMenu } = remote.require('./main.js'); - -window.addEventListener('contextmenu', event => { - contextMenu(remote.getCurrentWindow(), event.x, event.y, app.env === 'development'); - event.preventDefault(); -}); - ipcRenderer.on('open-uri-requested', (event, uri, newSession) => { if (uri && uri.startsWith('lbry://')) { if (uri.startsWith('lbry://?verify=')) { diff --git a/static/img/tray/default/tray.png b/static/img/tray/default/tray.png new file mode 100644 index 0000000000000000000000000000000000000000..5fe694194f612d1eb4b0cdc817129558eec9ba1f GIT binary patch literal 2002 zcmV;@2QB!CP)4Tx062|}Rb6NtRTMtEb7vzY&QokOg>Hg1+lHrgWS zWcKdPn90sKGrRqvPeo9CG3uKX#J{(IASm?@+di}}l?o-=)F3E6wD^Ni=!>T7nL9I? zX}YoAW$t|Qo$sD|?zw001?ah|SeB6#0T!CBEf+H4bBB+JJu8rehoBb*p;u8ID_yBf z0ya+zcePvJL&AGs+11_tpRKn>9TgyPA7ZoSs0)aX0r00)%XR^J`jH<$>RKN5V(7Oq zK*TS4xZz{h!*f1C3ECFkK$#7nA@pGN!$;%jYvwjAKwmYb0gKL(K8 z-kPtb5${A?tlI~wzMrJ6wTdBr=Y%%%EaEMQ&o}4FQ^DA)s*}Z>!FI&AHCpoWI|RUq zx?7s@$8!5^Q=anY%X@i5{QA6kNcMelpE>R6eCYFpmMsVTrI(b06~u#xf1yS} z_UGdMvD``!0~u->P=lA4?YN`hilQ|3tHka)7T{2CGqw zjZfMwx$5irQN_*|e4l)UHmiYuz74Yp1t^#>hrJ3-SOXDcC_o0^7T9R1gAN8V6s;5) zieI5-7aQlmJn}lUna#nz!j%5V$X|o`xX!dHWQRV27P1=rj;t2bW$~+pTw@bIek?Zv zKPDL<64`^#UNTAck#RBsB6*5DP4<%UA_FqU$I>2EH_cM;u)Q~SI+rg`Rn{L_AC5qq~L$#SMj%U z$6Cz0vP{G5Y*=%5RT^yu;}-DInZ=349rJPVM6C3K^oO)8y(fJr{l>k`ead~!ea?NsT>_Ci%bnxC;Vy6=b6>{xYV#Ue-+LB$ z7`JEXmTRm^AtP)R9u{)KHsMiWGV&)32xCG~*nyU<>-!d;FP=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})=M##^;%P2j)KA>Coxv9T8X$NOI?)|m6l?D)Li_K zo(8kIpDC2%SyMAMtXXZDC=~Lhei2#_;OCdZF-kvHbMgbde#?c+Wpiq3YY`DX8)=Ln zz~3KQoermzMJ%}ypNE8C$F~`nF?9;^m4&!?r3_J#kw}$F)PdgK*%;0Fpvzp%jUWHQ z-A6_+maNvTkLv0xG7scX+{P5zlYM|%+S**@Ha5R-%@vjRDJeCbWIJ}!z3S>Zma~mW z&36O6Hrx;7%?8UJ1Dh@JS!?UI!jel-x(8L5Iei+|#>YXaDnb48=MallnIxiwJal#C z{!iT-5Kl8bd?;WiCuueqZv67wQG5KREtGXwPMt<$86$uHbMyo{c#nbb7(pWYW!_|E kr?d5tvIob1w1;%yKhLfpFGiK?C;$Ke07*qoM6N<$g58hooB#j- literal 0 HcmV?d00001 diff --git a/static/img/tray/mac/trayTemplate.png b/static/img/tray/mac/trayTemplate.png new file mode 100644 index 0000000000000000000000000000000000000000..f1e30e1ca0dfc3628757d2d9903da0af9edeb330 GIT binary patch literal 1414 zcmeAS@N?(olHy`uVBq!ia0vp^Vn8gw!3HFS-uA08Ffe*&hD4M^`1)8S=jZArrsOB3 z>Q&?x0Oc7NZ0suv5|gu2OB9k)(=+pImEP~(ucVNfVyhHx>TBRz;GCL~=}}db8eHWU zl3bOYY?-2DZ^va*VFffGH?<^Dp&~aYuh^=>Rtapb6_5=Q)>l#hD=EpgRdNJbs1V^B zpx~Tel&WB=XQrEMXl$WiZmDNzYH49)qN8ABU}&aqV5x6tqHADiWngJ#V5k5EN_Jcd zHbp6ERzWUqP|JWkTcwPWk^(Dz{qpj1y>er{{GxPyLrY6beFGzXBO_g)3f+GstHC4cr<%VVoUUs zG4bG-%;Kx$#BQsz(zDC*#X<=VFNKvZ+a1-Mn%O!7Z<%oBM|7nw_O z%8Jf4I~KxiWN|}^Ih8Y?Azc3Oe)02-h2|V=GXf^>2~Yo)HA!r<)%pG(r|K3g`89dZ zZO_I7P7E&PC*B*V33Nz0{@$ANH}u=Ht4inNOpfK0oqNB&>k;GP)%rD2`&LeVXqvog zyM};A$8HH>M-NU8p>1dUXU_gxY^AqPe^be=>hiXkj%O4EdM?UOb=|7u?bbfI?tQ7P zOzih#d;E_yOyIcYbZ2vtXv$i~i+u@?Q?l)3{>(`ATzls9*Ly!7yL6{3CK(tyeMn$p z;<$Hp17z;5znh@8ck2h2mEE@IW;wfg{1sllO-8KC?T&`Jwr-hnYf*L9Pmu zCipZ6O<-wYSt8UBy1>J!z`;OFWNRS5sfBdD-psg@pZ{nZmwzsg+V||_grzUV-hMgx z?u(Iz;K4N29D@~`T{={D6meWTsM)~Nu!8L%pJTMc)$obOHJSfLZ1|_D_4Q_3NrKob zDa-mvbE_jAMR@kGb1?`yad6x_%+4==NQs}3LynO_us+AvR66}+Ja^%xw(rSn^PXo* zZ{3$NVgL4flI=wnGrzQ3e|}iNZhSZ3fo=J+&t(ep`499uh0pHV6XPy0J6dU$+9Jub zH?GW{{d@LS{?BKZ-aRd>9lqvqM}Mn8*s;t_>o=rXFWKSfQY~@dQP&+I(~onv{d%*) z+$Ql<*3Ssv*bMXR_S<*AeRX>6-&Xv2{!SZvkH`J%CG-2(=6||!gu6E^*(~JO+%5C} z<=hhVne={z_r1G0TW2`hN4E4<|dowX9=Of(~&S z#y|PFP3N7xRg6TO=BccBA^v*VufHeXx*@5_I^%s@-+xBg7U!4uUrrAJ6`!82elF{r G5}E+Y;#QIX literal 0 HcmV?d00001 diff --git a/static/img/tray/mac/trayTemplate@2x.png b/static/img/tray/mac/trayTemplate@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d709f995c279bf5d594aa1277c3cf2d932839bcc GIT binary patch literal 3331 zcmX|^cQhO78^;r3(^8{GT@fx?B(W>Rj0#27mfAZt5=3K93meZ!e@{&>h^`K&b~xe;5a>;C2Zsj+1cf5P zk&u75h_mz0YZwIlPYJ;v3DN&42zD^H1RLT)yuoTvbwy7lm8)P4O{kKZ=2c}?1+X$) zNgW2)gej>i!j%w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*NT*3HviZB(`?vm*Ta)OWv* zr?EjX+VJ*nxs66WF^{s>QyllKs=^Gpf-9SYnblh{`JeB^FMw(XlNxQwgRp`rkWZww z10BN*;D_3}67HUuZ+yPb+t1%0y?3H5;q=hTVZv1W>xb>3BpZ;ayj=ab4Q)A%_UUbVjZ}N2Y#nB*CR=-2PFenT?O`y+4|RymOhBYWRo{;0x7+2 zasW<}<@6ybR6-)%uFZaQlqkz?kgCDH?BjD+v94EG0UA_OuwF-1&5lfCt14%T-5JJ^ zRhWG@hV9S&<@`SFwpMeG?yu3k!qjJ7!qjLCsMSssCmt4X$_#3(c=pXhmHX%4#l*-0 J)nMR8`X4LM4vhc+ literal 0 HcmV?d00001 diff --git a/static/img/tray/windows/tray.ico b/static/img/tray/windows/tray.ico new file mode 100644 index 0000000000000000000000000000000000000000..1e1ac47df384e77fe4502b27aedc9264a2d94f34 GIT binary patch literal 4414 zcmeHJYf#ix6yK&vo2CzC52i1TR@0a>(xhZEgM;#3UBnQTr%_f8#Uc;2G6e)fMlDiA zFkgtM!wMQcXbc}CAjZQFXbLVcioo)i(p^>_vX5WCdlg(w@dfpT%bfqc+20s#qV5m7-;X)tkL!xW+0aF)>dDvLhSe9PS`~DT%4!AkFA}@9do}p-*4F0-@;YHUE&6z^z;c>EcD8zX)j&C;;2xm zvpIb&u3h`fWC8Y2FMKl;fmNRDoSAL?UkMgp9+rT z!FQGu0_M5kOz8=c3!TY?2r4{3kRM#Pqh2KYi#65f5WgY5~*k;RE}(D0Y4RaQp>D#w+wa zTm)_aPTzy8*I&mzO(y*PT%b}qAY;=S-hm={?w&mV?ORh|G#Y5?R;ws4!Gh44P?*7{cGLbUD%nK1~0yqurK`}&UE*#4Ag2ba34PJ!;f2`#?qJt zu<+9LHF3V0oNbuv=X?j3Z~Z~7si^@g<056=lU6N7i>|3(wZ5(f-z{CpTug+s(>vI> z;Rl$lsHDPkLP_jPh>w=~%oA}lF?Y5zyr(iR@9G}MWjaF#YgC@=J3-mmBS7{X=ium5clHBHpNCDEU;##RsLg0aIO`8JUC zL8Y9CO=-!*trvSr8CNL#7w?DnpgHRM(C2f4GsDCD;l+0%I8|_~Z4-Q%vv(`&!!&rS zCgGQib!fbLna>PmJo-TDj(iZt!{)hn6rWLYPfu4z{()>6m#8ggD@#SKNA|AGnBzMI zKB~#su`NaL7Jn*1TwY(wfVKBw*tYAmHHq<@Y`)F);;jlyQS-By6Y`ee)Z>)dlp*;| zO1mR@j%xPJCB=oZcJe;=(l3EKgYvAc&qFmf8Zm}gIm9ix*$d@=g*#O74BH*f!2gkf Fe*kOu+aUk| literal 0 HcmV?d00001 diff --git a/static/img/untitled folder/trayTemplate.png b/static/img/untitled folder/trayTemplate.png new file mode 100644 index 0000000000000000000000000000000000000000..57b671483cc39488314c2c663b6e7ef00ab4a0f3 GIT binary patch literal 1408 zcmV-`1%LX9P)4Tx062|}Rb6NtRTMtEb7vzY&QokOg>Hg1+lHrgWS zWcKdPn90sKGrRqvPeo9CG3uKX#J{(IASm?@+di}}l?o-=)F3E6wD^Ni=!>T7nL9I? zX}YoAW$t|Qo$sD|?zw001?ah|SeB6#0T!CBEf+H4bBB+JJu8rehoBb*p;u8ID_yBf z0ya+zcePvJL&AGs+11_tpRKn>9TgyPA7ZoSs0)aX0r00)%XR^J`jH<$>RKN5V(7Oq zK*TS4xZz{h!*f1C3ECFkK$#7nA@pGN!$;%jYvwjAKwmYb0gKL(K8 z-kPtb5${A?tlI~wzMrJ6wTdBr=Y%%%EaEMQ&o}4FQ^DA)s*}Z>!FI&AHCpoWI|RUq zx?7s@$8!5^Q=anY%X@i5{QA6kNcMelpE>R6eCYFpmMsVTrI(b06~u#xf1yS} z_UGdMvD``!0~u->P=lA4?YN`hilQ|3tHka)7T{2CGqw zjZfMwx$5irQN_*|e4l)UHmiYuz74Yp1t^#>hrJ3-SOXDcC_o0^7T9R1gAN8V6s;5) zieI5-7aQlmJn}lUna#nz!j%5V$X|o`xX!dHWQRV27P1=rj;t2bW$~+pTw@bIek?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 Jan 2018 14:19:55 -0300 Subject: [PATCH 14/14] keeps node_modules up-to-date when yarn.lock changes due to git --- package.json | 6 +++++- yarn.lock | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index dd8d998d5..8c0682b6a 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,9 @@ "build": "yarn compile && electron-builder build", "build:dir": "yarn build -- --dir -c.compression=store -c.mac.identity=null", "postinstall": "electron-builder install-app-deps", + "postmerge": "yarnhook", + "postcheckout": "yarnhook", + "postrewrite": "yarnhook", "precommit": "lint-staged", "lint": "eslint 'src/**/*.{js,jsx}' --fix", "format": "prettier 'src/**/*.{js,jsx,scss,json}' --write" @@ -100,7 +103,8 @@ "prettier": "^1.4.2", "sass-loader": "^6.0.6", "webpack": "^3.10.0", - "webpack-build-notifier": "^0.1.18" + "webpack-build-notifier": "^0.1.18", + "yarnhook": "^0.1.1" }, "resolutions": { "webpack/webpack-sources": "1.0.1" diff --git a/yarn.lock b/yarn.lock index 464678fb4..0c540f5bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9448,6 +9448,13 @@ yargs@~3.10.0: decamelize "^1.0.0" window-size "0.1.0" +yarnhook@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/yarnhook/-/yarnhook-0.1.1.tgz#6e67757327e6390cb313f371bdc44ded7c5e047b" + dependencies: + execa "^0.8.0" + find-parent-dir "^0.3.0" + yauzl@2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005"