PeerTube/client/src/main.browser.ts

46 lines
1.1 KiB
TypeScript
Raw Normal View History

/* tslint: disable */
2017-09-06 21:48:15 +02:00
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
import { decorateModuleRef } from './app/environment'
import { hmrModule } from '@angularclass/hmr'
2017-06-11 12:28:22 +02:00
/**
2016-09-06 22:40:57 +02:00
* App Module
* our top level module that holds all of our components
*/
2017-09-06 21:48:15 +02:00
import { AppModule } from './app'
2017-06-11 12:28:22 +02:00
/**
2016-09-06 22:40:57 +02:00
* Bootstrap our Angular app with a top level NgModule
*/
2017-09-06 21:48:15 +02:00
export function main (): Promise<any> {
2016-09-06 22:40:57 +02:00
return platformBrowserDynamic()
.bootstrapModule(AppModule)
.then(decorateModuleRef)
2017-09-06 21:48:15 +02:00
.then((ngModuleRef: any) => {
// `module` global ref for webpackhmr
// Don't run this in Prod
return hmrModule(ngModuleRef, module)
})
.catch((err) => console.error(err))
}
2017-06-11 12:28:22 +02:00
/**
* Needed for hmr
* in prod this is replace for document ready
*/
switch (document.readyState) {
case 'loading':
2017-09-06 21:48:15 +02:00
document.addEventListener('DOMContentLoaded', _domReadyHandler, false)
break
2017-06-11 12:28:22 +02:00
case 'interactive':
case 'complete':
default:
2017-09-06 21:48:15 +02:00
main()
2017-06-11 12:28:22 +02:00
}
2017-09-06 21:48:15 +02:00
function _domReadyHandler () {
document.removeEventListener('DOMContentLoaded', _domReadyHandler, false)
main()
2017-06-11 12:28:22 +02:00
}