2017-08-24 21:54:02 +00:00
|
|
|
import app from './routes';
|
|
|
|
import locale from '../common/locales';
|
|
|
|
import fileManager from './fileManager';
|
|
|
|
import dragManager from './dragManager';
|
|
|
|
import { canHasSend } from './utils';
|
|
|
|
import assets from '../common/assets';
|
|
|
|
import storage from './storage';
|
|
|
|
import metrics from './metrics';
|
2017-09-12 00:09:29 +00:00
|
|
|
import experiments from './experiments';
|
2017-08-24 21:54:02 +00:00
|
|
|
import Raven from 'raven-js';
|
|
|
|
|
|
|
|
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) {
|
|
|
|
Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.use((state, emitter) => {
|
|
|
|
// init state
|
|
|
|
state.transfer = null;
|
|
|
|
state.fileInfo = null;
|
|
|
|
state.translate = locale.getTranslator();
|
|
|
|
state.storage = storage;
|
|
|
|
state.raven = Raven;
|
|
|
|
emitter.on('DOMContentLoaded', async () => {
|
2017-11-06 22:09:15 +00:00
|
|
|
let reason = null;
|
2017-09-13 19:01:55 +00:00
|
|
|
if (
|
|
|
|
/firefox/i.test(navigator.userAgent) &&
|
|
|
|
parseInt(navigator.userAgent.match(/firefox\/*([^\n\r]*)\./i)[1], 10) <=
|
|
|
|
49
|
|
|
|
) {
|
2017-11-06 22:09:15 +00:00
|
|
|
reason = 'outdated';
|
2017-09-13 19:01:55 +00:00
|
|
|
}
|
2017-11-06 21:36:36 +00:00
|
|
|
if (/edge\/\d+/i.test(navigator.userAgent)) {
|
2017-11-06 22:09:15 +00:00
|
|
|
reason = 'edge';
|
2017-11-06 21:36:36 +00:00
|
|
|
}
|
2017-08-24 21:54:02 +00:00
|
|
|
const ok = await canHasSend(assets.get('cryptofill.js'));
|
|
|
|
if (!ok) {
|
2017-11-06 22:09:15 +00:00
|
|
|
reason = /firefox/i.test(navigator.userAgent) ? 'outdated' : 'gcm';
|
|
|
|
}
|
|
|
|
if (reason) {
|
|
|
|
setTimeout(() => emitter.emit('replaceState', `/unsupported/${reason}`));
|
2017-08-24 21:54:02 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
app.use(metrics);
|
|
|
|
app.use(fileManager);
|
|
|
|
app.use(dragManager);
|
2017-09-12 00:09:29 +00:00
|
|
|
app.use(experiments);
|
2017-08-24 21:54:02 +00:00
|
|
|
|
2017-11-07 23:54:42 +00:00
|
|
|
app.mount('body');
|