2018-04-04 04:14:54 +02:00
|
|
|
import { enableProdMode } from '@angular/core';
|
|
|
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
2018-04-11 16:57:34 +02:00
|
|
|
import 'web-animations-js';
|
2018-04-04 04:14:54 +02:00
|
|
|
|
|
|
|
// tslint:disable-next-line
|
2018-04-11 04:20:50 +02:00
|
|
|
require('./scss/popup.scss');
|
2018-04-04 04:14:54 +02:00
|
|
|
|
2018-09-30 04:58:36 +02:00
|
|
|
import { BrowserApi } from '../browser/browserApi';
|
2018-04-04 04:14:54 +02:00
|
|
|
import { AppModule } from './app.module';
|
|
|
|
|
2018-04-13 21:14:04 +02:00
|
|
|
if (process.env.ENV === 'production') {
|
|
|
|
enableProdMode();
|
|
|
|
}
|
2018-04-04 04:14:54 +02:00
|
|
|
|
2018-09-30 04:58:36 +02:00
|
|
|
function bootstrapModule() {
|
|
|
|
platformBrowserDynamic().bootstrapModule(AppModule, { preserveWhitespaces: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bug in Edge 18 has null getBackgroundPage() result initially. Can be removed in future.
|
2018-09-30 14:25:56 +02:00
|
|
|
if (BrowserApi.getBackgroundPage() == null && BrowserApi.isEdge18) {
|
2018-09-30 04:58:36 +02:00
|
|
|
const sleep = (time: number) => new Promise((resolve) => window.setTimeout(resolve, time));
|
|
|
|
const bootstrapForEdge18 = async () => {
|
|
|
|
let bgAttempts = 1;
|
|
|
|
while (BrowserApi.getBackgroundPage() == null) {
|
|
|
|
if (bgAttempts > 30) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// tslint:disable-next-line
|
|
|
|
console.log('Waiting for background page to not be null. Attempt #' + bgAttempts);
|
|
|
|
await sleep(200);
|
|
|
|
bgAttempts++;
|
|
|
|
}
|
|
|
|
if (BrowserApi.getBackgroundPage() == null) {
|
|
|
|
// tslint:disable-next-line
|
|
|
|
console.log('Reload page.');
|
|
|
|
window.location.reload();
|
|
|
|
} else {
|
|
|
|
bootstrapModule();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
bootstrapForEdge18();
|
|
|
|
} else {
|
2018-09-30 14:25:56 +02:00
|
|
|
if (BrowserApi.isEdge18) {
|
|
|
|
// tslint:disable-next-line
|
|
|
|
console.log('Normal bootstrap.');
|
|
|
|
}
|
2018-09-30 04:58:36 +02:00
|
|
|
bootstrapModule();
|
|
|
|
}
|