PeerTube/client/src/app/environment.ts

56 lines
1.2 KiB
TypeScript
Raw Normal View History

2016-09-06 20:40:57 +00:00
// Angular 2
// rc2 workaround
import { enableDebugTools, disableDebugTools } from '@angular/platform-browser';
import { enableProdMode, ApplicationRef } from '@angular/core';
// Environment Providers
2017-01-13 11:16:00 +00:00
let PROVIDERS: any[] = [
2016-09-06 20:40:57 +00:00
// common env directives
];
// Angular debug tools in the dev console
// https://github.com/angular/angular/blob/86405345b781a9dc2438c0fbe3e9409245647019/TOOLS_JS.md
2017-01-13 11:16:00 +00:00
let _decorateModuleRef = function identity<T>(value: T): T { return value; };
2016-09-06 20:40:57 +00:00
if ('production' === ENV) {
enableProdMode();
2017-01-13 11:16:00 +00:00
// Production
_decorateModuleRef = (modRef: any) => {
disableDebugTools();
return modRef;
};
2016-09-06 20:40:57 +00:00
PROVIDERS = [
...PROVIDERS,
// custom providers in production
];
} else {
_decorateModuleRef = (modRef: any) => {
const appRef = modRef.injector.get(ApplicationRef);
const cmpRef = appRef.components[0];
let _ng = (<any>window).ng;
enableDebugTools(cmpRef);
(<any>window).ng.probe = _ng.probe;
(<any>window).ng.coreTokens = _ng.coreTokens;
return modRef;
};
// Development
PROVIDERS = [
...PROVIDERS,
// custom providers in development
];
}
export const decorateModuleRef = _decorateModuleRef;
export const ENV_PROVIDERS = [
...PROVIDERS
];