2019-04-26 20:30:33 +00:00
|
|
|
/* global DEFAULTS LIMITS PREFS */
|
2018-11-20 14:50:59 +00:00
|
|
|
import 'core-js';
|
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';
|
2018-11-12 19:13:31 +00:00
|
|
|
import choo from 'choo';
|
|
|
|
import nanotiming from 'nanotiming';
|
2018-09-18 23:23:58 +00:00
|
|
|
import routes from './routes';
|
2018-12-13 19:12:06 +00:00
|
|
|
import getCapabilities from './capabilities';
|
2018-11-08 23:12:07 +00:00
|
|
|
import controller from './controller';
|
2017-08-24 21:54:02 +00:00
|
|
|
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 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';
|
2018-08-07 22:40:17 +00:00
|
|
|
import User from './user';
|
2018-11-20 14:50:59 +00:00
|
|
|
import { getTranslator } from './locale';
|
2018-12-21 18:27:46 +00:00
|
|
|
import Archive from './archive';
|
2019-04-26 20:30:33 +00:00
|
|
|
import { setTranslate, locale } from './utils';
|
2017-08-24 21:54:02 +00:00
|
|
|
|
2018-11-27 00:05:22 +00:00
|
|
|
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 18:29:26 +00:00
|
|
|
(async function start() {
|
2018-12-13 19:12:06 +00:00
|
|
|
const capabilities = await getCapabilities();
|
2019-02-21 23:20:28 +00:00
|
|
|
if (
|
|
|
|
!capabilities.crypto &&
|
|
|
|
window.location.pathname !== '/unsupported/crypto'
|
|
|
|
) {
|
2018-12-18 20:27:43 +00:00
|
|
|
return window.location.assign('/unsupported/crypto');
|
|
|
|
}
|
2018-12-13 19:12:06 +00:00
|
|
|
if (capabilities.serviceWorker) {
|
2019-03-13 03:53:54 +00:00
|
|
|
try {
|
|
|
|
await navigator.serviceWorker.register('/serviceWorker.js');
|
|
|
|
await navigator.serviceWorker.ready;
|
|
|
|
} catch (e) {
|
|
|
|
// continue but disable streaming downloads
|
|
|
|
capabilities.streamDownload = false;
|
|
|
|
}
|
2018-07-31 18:29:26 +00:00
|
|
|
}
|
2018-09-14 15:00:33 +00:00
|
|
|
|
2019-04-26 20:30:33 +00:00
|
|
|
const translate = await getTranslator(locale());
|
2019-03-12 02:28:22 +00:00
|
|
|
setTranslate(translate);
|
2018-12-13 19:12:06 +00:00
|
|
|
window.initialState = {
|
2019-02-26 18:39:50 +00:00
|
|
|
LIMITS,
|
|
|
|
DEFAULTS,
|
2019-04-26 20:30:33 +00:00
|
|
|
PREFS,
|
2019-02-26 18:39:50 +00:00
|
|
|
archive: new Archive([], DEFAULTS.EXPIRE_SECONDS),
|
2018-12-13 19:12:06 +00:00
|
|
|
capabilities,
|
|
|
|
translate,
|
|
|
|
storage,
|
|
|
|
raven: Raven,
|
2019-02-26 18:39:50 +00:00
|
|
|
user: new User(storage, LIMITS, window.AUTH_CONFIG),
|
2018-12-13 19:12:06 +00:00
|
|
|
transfer: null,
|
|
|
|
fileInfo: null
|
|
|
|
};
|
2018-11-20 14:50:59 +00:00
|
|
|
|
2018-12-13 19:12:06 +00:00
|
|
|
const app = routes(choo());
|
2019-02-19 22:14:28 +00:00
|
|
|
window.app = app;
|
2018-07-31 18:29:26 +00:00
|
|
|
app.use(metrics);
|
2018-11-08 23:12:07 +00:00
|
|
|
app.use(controller);
|
2018-07-31 18:29:26 +00:00
|
|
|
app.use(dragManager);
|
|
|
|
app.use(experiments);
|
|
|
|
app.use(pasteManager);
|
|
|
|
app.mount('body');
|
|
|
|
})();
|