Update electron version and add compiling docs

This commit is contained in:
Andrew Morgan 2019-04-08 18:16:55 +01:00
parent c8a04cdfcc
commit 10d0b728fd
4 changed files with 70 additions and 9 deletions

View File

@ -196,7 +196,7 @@ Running as a Desktop app
Riot can also be run as a desktop app, wrapped in electron. You can download a
pre-built version from https://riot.im/desktop.html or, if you prefer,
build it yourself. Requires Electron >=1.6.0
build it yourself. Requires Electron >=1.6.0.
To run as a desktop app:
@ -233,7 +233,14 @@ for 64 bit Linux:
1. Follow the instructions in 'Building From Source' above
2. `node_modules/.bin/build -l --x64`
All electron packages go into `electron_app/dist/`
All electron packages go into `electron_app/dist/`.
Electron Specific Features
--------------------------
The electron version of Riot contains some features that are only possible from electron rather than within a browser window. This includes the "Push-to-Talk" feature, which allows you to toggle your microphone during a call even if Riot is not in focus.
This requires the use of a native node module called [iohook](https://github.com/matrix-org/iohook/). Native node modules are written in C, and by default during the build of Riot the compiled binaries will be downloaded from npm. If you would like to build this module from source yourself, please read [Compiling iohook](docs/native_node_modules.md#compiling-iohook).
Many thanks to @aviraldg for the initial work on the electron integration.

View File

@ -0,0 +1,47 @@
# Native Node Modules
Since v???, the electron version of Riot can make use of native node modules. These allow Riot to integrate with the desktop in ways that a browser cannot.
While handy, these modules must be compiled and are thus downloaded pre-compiled during build so that a single OS can compile Riot for all platforms. If you would like to compile the native node modules from source, as is done for Riot releases, instead of trusting binaries hosted on npm, then please read on.
Do note that compiling a module for a particular operating system (Linux/Mac/Windows) and architecture (x64/x86) will need to be done on a system that is currently running that
## Compiling iohook
[iohook](https://github.com/matrix-org/iohook/) is a native node module written in C/C++ that allows for cross-platform capturing of keystrokes. This is used for providing Push-to-Talk functionality (pressing a key to toggle the microphone in a call) and is ONLY enabled during a call and while setting the keybinding in settings.
If you would like to rebuild the module yourself and replace the downloaded binaries, use the following commands from Riot's root directory:
```bash
cd electron_app/node_modules
rm -rf iohook
git clone https://github.com/matrix-org/iohook
cd iohook
npm i
rm -rf builds/* # Delete any downloaded binaries
npm run build # This builds libuiohook
node build.js --runtime electron --version 4.1.3 --abi 69 --no-upload # This builds the module for the current OS
```
You then need to copy the built module to the correct folder depending on the operating system and architecture you're building for:
```bash
# Run one of the following depending on your architecture:
# 64-bit
osarch="64"
# 32-bit
osarch="32"
# Run one of the following depending on your operating system:
# Windows
ostype="win32"
# Linux
ostype="linux"
# MacOS
ostype="darwin"
# Finally, copy the module:
folder="electron-v69-$ostype-x$osarch"
mkdir -p builds/$folder/build/Release
cp build/Release/iohook.node builds/$folder/build/Release/
```

View File

@ -9,12 +9,19 @@
"auto-launch": "^5.0.1",
"electron-store": "^2.0.0",
"electron-window-state": "^4.1.0",
"iohook": "^0.4.0",
"iohook": "^0.4.2",
"minimist": "^1.2.0",
"png-to-ico": "^1.0.2"
},
"cmake-js": {
"runtime": "electron",
"runtimeVersion": "4.0.6"
}
"runtimeVersion": "4.1.3"
},
"supportedTargets": [
[
"electron",
"4.1.3",
"69"
]
]
}

View File

@ -400,10 +400,10 @@ inherits@~2.0.3:
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
iohook@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/iohook/-/iohook-0.3.1.tgz#dab2cd194f0bcfe7cb4879a0b7a9541a9b1bced7"
integrity sha512-E4+KO7ZN9GJBAQmM/htvE2bv+IOwXX68dV5qRS9O0wt6nQXk9v/K3wOl/uPI7hl3ysgKC447yYqBP2mrgLAwZw==
iohook@^0.4.2:
version "0.4.2"
resolved "https://registry.yarnpkg.com/iohook/-/iohook-0.4.2.tgz#9c9a2e3c80dc32a226bf993863720e7dfea292ad"
integrity sha512-xlrau0SdwtCYU2+jqAxZKbXSxFi16AR6PQr/op//j18uRl6bttEwnS5CaZ+7RYD3e7TxF1CrG78O7PF1bnwbKw==
dependencies:
"@types/node" "^7.0.62"
bindings "^1.3.0"