2018-03-01 04:24:41 +01:00
|
|
|
import 'fast-text-encoding'; // MS Edge support
|
2017-11-30 22:41:09 +01:00
|
|
|
import 'fluent-intl-polyfill';
|
2018-09-19 01:23:58 +02:00
|
|
|
import routes from './routes';
|
2018-07-31 20:29:26 +02:00
|
|
|
import capabilities from './capabilities';
|
2017-08-24 23:54:02 +02:00
|
|
|
import locale from '../common/locales';
|
|
|
|
import fileManager from './fileManager';
|
|
|
|
import dragManager from './dragManager';
|
2018-06-06 06:39:26 +02:00
|
|
|
import pasteManager from './pasteManager';
|
2017-08-24 23:54:02 +02:00
|
|
|
import storage from './storage';
|
|
|
|
import metrics from './metrics';
|
2017-09-12 02:09:29 +02:00
|
|
|
import experiments from './experiments';
|
2017-08-24 23:54:02 +02:00
|
|
|
import Raven from 'raven-js';
|
2018-07-12 22:13:49 +02:00
|
|
|
import './main.css';
|
2018-08-08 00:40:17 +02:00
|
|
|
import User from './user';
|
2017-08-24 23:54:02 +02:00
|
|
|
|
2018-07-31 20:29:26 +02:00
|
|
|
(async function start() {
|
2018-09-19 01:23:58 +02:00
|
|
|
const app = routes();
|
2018-07-31 20:29:26 +02:00
|
|
|
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) {
|
|
|
|
Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install();
|
|
|
|
}
|
|
|
|
const capa = await capabilities();
|
|
|
|
if (capa.streamDownload) {
|
|
|
|
navigator.serviceWorker.register('/serviceWorker.js');
|
|
|
|
}
|
2018-09-14 17:00:33 +02:00
|
|
|
|
2018-07-31 20:29:26 +02:00
|
|
|
app.use((state, emitter) => {
|
|
|
|
state.capabilities = capa;
|
|
|
|
state.transfer = null;
|
|
|
|
state.fileInfo = null;
|
|
|
|
state.translate = locale.getTranslator();
|
|
|
|
state.storage = storage;
|
|
|
|
state.raven = Raven;
|
2018-09-14 17:00:33 +02:00
|
|
|
state.user = new User(storage);
|
2018-07-31 20:29:26 +02:00
|
|
|
window.appState = state;
|
2018-09-07 19:53:40 +02:00
|
|
|
window.appEmit = emitter.emit.bind(emitter);
|
2018-01-24 19:23:13 +01:00
|
|
|
let unsupportedReason = null;
|
2017-09-13 21:01:55 +02:00
|
|
|
if (
|
2018-01-24 19:23:13 +01:00
|
|
|
// Firefox < 50
|
2017-09-13 21:01:55 +02:00
|
|
|
/firefox/i.test(navigator.userAgent) &&
|
2018-01-24 19:23:13 +01:00
|
|
|
parseInt(navigator.userAgent.match(/firefox\/*([^\n\r]*)\./i)[1], 10) < 50
|
2017-09-13 21:01:55 +02:00
|
|
|
) {
|
2018-01-24 19:23:13 +01:00
|
|
|
unsupportedReason = 'outdated';
|
2017-09-13 21:01:55 +02:00
|
|
|
}
|
2018-07-31 20:29:26 +02:00
|
|
|
if (!state.capabilities.crypto) {
|
2018-01-24 19:23:13 +01:00
|
|
|
unsupportedReason = /firefox/i.test(navigator.userAgent)
|
|
|
|
? 'outdated'
|
|
|
|
: 'gcm';
|
2017-11-06 23:09:15 +01:00
|
|
|
}
|
2018-01-24 19:23:13 +01:00
|
|
|
if (unsupportedReason) {
|
|
|
|
setTimeout(() =>
|
|
|
|
emitter.emit('replaceState', `/unsupported/${unsupportedReason}`)
|
|
|
|
);
|
2017-08-24 23:54:02 +02:00
|
|
|
}
|
|
|
|
});
|
2018-07-31 20:29:26 +02:00
|
|
|
app.use(metrics);
|
|
|
|
app.use(fileManager);
|
|
|
|
app.use(dragManager);
|
|
|
|
app.use(experiments);
|
|
|
|
app.use(pasteManager);
|
|
|
|
app.mount('body');
|
|
|
|
})();
|