2018-03-01 03:24:41 +00:00
|
|
|
import 'fast-text-encoding'; // MS Edge support
|
2017-11-30 21:41:09 +00:00
|
|
|
import 'fluent-intl-polyfill';
|
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';
|
2018-06-06 04:39:26 +00:00
|
|
|
import pasteManager from './pasteManager';
|
2017-08-24 21:54:02 +00:00
|
|
|
import { canHasSend } from './utils';
|
|
|
|
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';
|
2018-07-12 20:13:49 +00:00
|
|
|
import './main.css';
|
2017-08-24 21:54:02 +00:00
|
|
|
|
|
|
|
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) {
|
|
|
|
Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.use((state, emitter) => {
|
|
|
|
state.transfer = null;
|
|
|
|
state.fileInfo = null;
|
|
|
|
state.translate = locale.getTranslator();
|
|
|
|
state.storage = storage;
|
|
|
|
state.raven = Raven;
|
2018-01-24 18:23:13 +00:00
|
|
|
window.appState = state;
|
|
|
|
emitter.on('DOMContentLoaded', async function checkSupport() {
|
|
|
|
let unsupportedReason = null;
|
2017-09-13 19:01:55 +00:00
|
|
|
if (
|
2018-01-24 18:23:13 +00:00
|
|
|
// Firefox < 50
|
2017-09-13 19:01:55 +00:00
|
|
|
/firefox/i.test(navigator.userAgent) &&
|
2018-01-24 18:23:13 +00:00
|
|
|
parseInt(navigator.userAgent.match(/firefox\/*([^\n\r]*)\./i)[1], 10) < 50
|
2017-09-13 19:01:55 +00:00
|
|
|
) {
|
2018-01-24 18:23:13 +00:00
|
|
|
unsupportedReason = 'outdated';
|
2017-09-13 19:01:55 +00:00
|
|
|
}
|
2018-03-01 03:24:41 +00:00
|
|
|
const ok = await canHasSend();
|
2017-08-24 21:54:02 +00:00
|
|
|
if (!ok) {
|
2018-01-24 18:23:13 +00:00
|
|
|
unsupportedReason = /firefox/i.test(navigator.userAgent)
|
|
|
|
? 'outdated'
|
|
|
|
: 'gcm';
|
2017-11-06 22:09:15 +00:00
|
|
|
}
|
2018-01-24 18:23:13 +00:00
|
|
|
if (unsupportedReason) {
|
|
|
|
setTimeout(() =>
|
|
|
|
emitter.emit('replaceState', `/unsupported/${unsupportedReason}`)
|
|
|
|
);
|
2017-08-24 21:54:02 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-06 22:49:50 +00:00
|
|
|
app.use(() => {
|
|
|
|
navigator.serviceWorker.register('/serviceWorker.js');
|
|
|
|
});
|
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);
|
2018-06-06 04:39:26 +00:00
|
|
|
app.use(pasteManager);
|
2017-08-24 21:54:02 +00:00
|
|
|
|
2017-11-07 23:54:42 +00:00
|
|
|
app.mount('body');
|