drop.chapril.org-firefoxsend/app/main.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

/* global LOCALE */
import 'core-js';
import 'fast-text-encoding'; // MS Edge support
2017-11-30 22:41:09 +01:00
import 'fluent-intl-polyfill';
import choo from 'choo';
import nanotiming from 'nanotiming';
import routes from './routes';
2018-12-13 20:12:06 +01:00
import getCapabilities from './capabilities';
import controller from './controller';
import dragManager from './dragManager';
2018-06-06 06:39:26 +02:00
import pasteManager from './pasteManager';
import storage from './storage';
import metrics from './metrics';
2017-09-12 02:09:29 +02:00
import experiments from './experiments';
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';
import { getTranslator } from './locale';
import Archive from './archive';
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) {
Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install();
}
if (process.env.NODE_ENV === 'production') {
nanotiming.disabled = true;
}
2018-07-31 20:29:26 +02:00
(async function start() {
2018-12-13 20:12:06 +01:00
const capabilities = await getCapabilities();
if (
!capabilities.crypto &&
window.location.pathname !== '/unsupported/crypto'
) {
2018-12-18 21:27:43 +01:00
return window.location.assign('/unsupported/crypto');
}
2018-12-13 20:12:06 +01:00
if (capabilities.serviceWorker) {
await navigator.serviceWorker.register('/serviceWorker.js');
await navigator.serviceWorker.ready;
2018-07-31 20:29:26 +02:00
}
const translate = await getTranslator(LOCALE);
2018-12-13 20:12:06 +01:00
window.initialState = {
archive: new Archive(),
2018-12-13 20:12:06 +01:00
capabilities,
translate,
storage,
raven: Raven,
user: new User(storage),
transfer: null,
fileInfo: null
};
2018-12-13 20:12:06 +01:00
const app = routes(choo());
2019-02-19 23:14:28 +01:00
window.app = app;
2018-07-31 20:29:26 +02:00
app.use(metrics);
app.use(controller);
2018-07-31 20:29:26 +02:00
app.use(dragManager);
app.use(experiments);
app.use(pasteManager);
app.mount('body');
})();