Merge branch 'develop' into lint

This commit is contained in:
Travis Ralston 2018-10-25 16:06:02 -06:00
commit 10efaaa078
7 changed files with 1208 additions and 478 deletions

1574
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -96,7 +96,7 @@
"babel-preset-es2017": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"chokidar": "^1.6.1",
"chokidar": "^2.0.4",
"concurrently": "^4.0.1",
"cpx": "^1.3.2",
"cross-env": "^4.0.0",
@ -146,11 +146,11 @@
"webpack-dev-server": "^3.1.9"
},
"optionalDependencies": {
"olm": "https://matrix.org/packages/npm/olm/olm-2.2.1.tgz"
"olm": "https://matrix.org/packages/npm/olm/olm-3.0.0.tgz"
},
"build": {
"appId": "im.riot.app",
"electronVersion": "3.0.3",
"electronVersion": "3.0.5",
"files": [
"node_modules/**",
"src/**",

View File

@ -57,6 +57,11 @@ const COPY_LIST = [
["res/themes/**", "webapp/themes"],
["node_modules/emojione/assets/svg/*", "webapp/emojione/svg/"],
["node_modules/emojione/assets/png/*", "webapp/emojione/png/"],
// XXX: This is tied quite heavily to the matching olm.js so it really should be
// in the bundle dir with the js to avoid caching issues giving us wasm that
// doesn't match our js, but I cannot find any way to get webpack to do this.
["node_modules/olm/olm.wasm", "webapp", { directwatch: 1 }],
["node_modules/olm/olm_legacy.js", "webapp", { directwatch: 1 }],
["./config.json", "webapp", { directwatch: 1 }],
];

View File

@ -34,6 +34,6 @@
"Support for those using, running and writing other bridges": "Ondersteuning voor het gebruiken, draaien en ontwikkelen aan andere bruggen",
"Dev chat for the Riot/Web dev team": "Dev-chat voor het Riot/Web ontwikkelteam",
"Dev chat for the Dendrite dev team": "Dev-chat voor het Dendrite-ontwikkelteam",
"You can use the custom server options to sign into other Matrix servers by specifying a different Home server URL.<br/>This allows you to use Riot with an existing Matrix account on a different home server.<br/><br/>You can also set a custom identity server but you won't be able to invite users by email address, or be invited by email address yourself.": "Je kan de custom server opties gebruiken om op andere Matrix server in te loggen door een andere Home server URL op te geven.<br/> Dit laat je toe om Riot te gebruiken met een bestaande Matrix account op een andere home server.<br/><br/>Je kan ook een custom identiteits-server opzetten maar dan kan je geen gebruikers uitnodigen via hun email adres, of zelf uitgenodigd worden via je email adres.",
"You can use the custom server options to sign into other Matrix servers by specifying a different Home server URL.<br/>This allows you to use Riot with an existing Matrix account on a different home server.<br/><br/>You can also set a custom identity server but you won't be able to invite users by email address, or be invited by email address yourself.": "Je kan de custom serveropties gebruiken om op andere Matrix-servers in te loggen door een andere thuisserver-URL op te geven.<br/> Dit laat je toe om Riot te gebruiken met een bestaand Matrix-account op een andere thuisserver.<br/><br/>Je kan ook een aangepaste-identiteitsserver opzetten maar dan kan je geen gebruikers uitnodigen via hun e-mailadres, of zelf uitgenodigd worden via je e-mailadres.",
"Co-ordination for Riot translators": "Coördinatie voor Riot vertalers"
}

View File

@ -51,6 +51,8 @@ import SettingsStore from "matrix-react-sdk/lib/settings/SettingsStore";
import Tinter from 'matrix-react-sdk/lib/Tinter';
import SdkConfig from "matrix-react-sdk/lib/SdkConfig";
import Olm from 'olm';
import rageshake from "matrix-react-sdk/lib/rageshake/rageshake";
import CallHandler from 'matrix-react-sdk/lib/CallHandler';
@ -226,6 +228,8 @@ async function loadApp() {
window.addEventListener('hashchange', onHashChange);
await loadOlm();
await loadLanguage();
const fragparts = parseQsFromFragment(window.location);
@ -358,6 +362,42 @@ async function loadApp() {
}
}
function loadOlm() {
/* Load Olm. We try the WebAssembly version first, and then the legacy,
* asm.js version if that fails. For this reason we need to wait for this
* to finish before continuing to load the rest of the app. In future
* we could somehow pass a promise down to react-sdk and have it wait on
* that so olm can be loading in parallel with the rest of the app.
*
* We also need to tell the Olm js to look for its wasm file at the same
* level as index.html. It really should be in the same place as the js,
* ie. in the bundle directory, to avoid caching issues, but as far as I
* can tell this is completely impossible with webpack.
*/
return Olm.init({
locateFile: () => 'olm.wasm',
}).then(() => {
console.log("Using WebAssembly Olm");
}).catch((e) => {
console.log("Failed to load Olm: trying legacy version");
return new Promise((resolve, reject) => {
const s = document.createElement('script');
s.src = 'olm_legacy.js';
s.onload = resolve;
s.onerror = reject;
document.body.appendChild(s);
}).then(() => {
// Init window.Olm, ie. the one just loaded by the script tag,
// not 'Olm' which is still the failed wasm version.
return window.Olm.init();
}).then(() => {
console.log("Using legacy Olm");
}).catch((e) => {
console.log("Both WebAssembly and asm.js Olm failed!", e);
});
});
}
async function loadLanguage() {
const prefLang = SettingsStore.getValue("language", null, /*excludeDefault=*/true);
let langs = [];

View File

@ -1,41 +0,0 @@
/*
Copyright 2016 OpenMarket Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* a very thin shim for loading olm.js: just sets the global OLM_OPTIONS and
* requires the actual olm.js library.
*
* olm.js reads global.OLM_OPTIONS and defines global.Olm. The latter is fine for us,
* but we need to prepare the former.
*
* We can't use webpack's definePlugin to do this, because we tell webpack not
* to parse olm.js. We also can't put this code in index.js, because olm and
* index.js are loaded in parallel, and we need to make sure OLM_OPTIONS is set
* before olm.js is loaded.
*/
/* total_memory must be a power of two, and at least twice the stack.
*
* We don't need a lot of stack, but we do need about 128K of heap to encrypt a
* 64K event (enough to store the ciphertext and the plaintext, bearing in mind
* that the plaintext can only be 48K because base64). We also have about 36K
* of statics. So let's have 256K of memory.
*/
global.OLM_OPTIONS = {
TOTAL_STACK: 64*1024,
TOTAL_MEMORY: 256*1024,
};
require('olm/olm.js');

View File

@ -15,15 +15,6 @@ module.exports = {
"mobileguide": "./src/vector/mobile_guide/index.js",
// We ship olm.js as a separate lump of javascript. This makes it get
// loaded via a separate <script/> tag in index.html (which loads it
// into the browser global `Olm`, where js-sdk expects to find it).
//
// (we should probably make js-sdk load it asynchronously at some
// point, so that it doesn't block the pageload, but that is a separate
// problem)
"olm": "./src/vector/olm-loader.js",
// CSS themes
"theme-light": "./node_modules/matrix-react-sdk/res/themes/light/css/light.scss",
"theme-dark": "./node_modules/matrix-react-sdk/res/themes/dark/css/dark.scss",
@ -171,12 +162,3 @@ module.exports = {
inline: false,
},
};
// olm is an optional dependency. Ignore it if it's not installed, to avoid a
// scary-looking error.
try {
require('olm');
} catch (e) {
console.log("Olm is not installed; not shipping it");
delete(module.exports.entry["olm"]);
}