cleanup(platform): removed webworker and server deprecated apis (#10745)

This commit is contained in:
Victor Savkin
2016-08-15 13:44:01 -07:00
committed by vikerman
parent 73c0a9daaf
commit 60b10134df
29 changed files with 94 additions and 438 deletions

View File

@ -8,7 +8,7 @@
import {PlatformLocation} from '@angular/common';
import {analyzeAppProvidersForDeprecatedConfiguration, platformCoreDynamic} from '@angular/compiler';
import {ApplicationRef, ComponentRef, NgModule, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, Type, createPlatformFactory, platformCore} from '@angular/core';
import {ApplicationRef, ComponentRef, NgModule, PLATFORM_INITIALIZER, PlatformRef, Type, createPlatformFactory, platformCore} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {Console, ReflectionCapabilities, reflector, wtfInit} from '../core_private';
@ -37,89 +37,30 @@ export const INTERNAL_SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | a
{provide: PlatformLocation, useClass: ServerPlatformLocation},
];
/**
* A set of providers to initialize the Angular platform in a server.
*
* Used automatically by `serverBootstrap`, or can be passed to `platform`.
* @deprecated Use `platformServer()` or create a custom platform factory via
* `createPlatformFactory(platformServer, ...)`
*/
export const SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
[PLATFORM_COMMON_PROVIDERS, INTERNAL_SERVER_PLATFORM_PROVIDERS];
function initParse5Adapter() {
Parse5DomAdapter.makeCurrent();
wtfInit();
}
/**
* The ng module for the server.
*
* @experimental
*/
@NgModule({imports: [BrowserModule]})
export class ServerModule {
}
/**
* @experimental
*/
export const platformServer =
createPlatformFactory(platformCore, 'server', INTERNAL_SERVER_PLATFORM_PROVIDERS);
/**
* @deprecated Use {@link platformServer} instead
*/
export const serverPlatform = platformServer;
/**
* The server platform that supports the runtime compiler.
*
* @experimental
*/
export const platformDynamicServer =
createPlatformFactory(platformCoreDynamic, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS);
/**
* @deprecated Use {@link platformDynamicServer} instead
*/
export const serverDynamicPlatform = platformDynamicServer;
/**
* Used to bootstrap Angular in server environment (such as node).
*
* This version of bootstrap only creates platform injector and does not define anything for
* application injector. It is expected that application providers are imported from other
* packages such as `@angular/platform-browser` or `@angular/platform-browser-dynamic`.
*
* ```
* import {BROWSER_APP_PROVIDERS} from '@angular/platform-browser';
* import {BROWSER_APP_COMPILER_PROVIDERS} from '@angular/platform-browser-dynamic';
*
* serverBootstrap(..., [BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS])
* ```
*
* @deprecated create an {@link NgModule} and use {@link bootstrapModule} with the {@link
* serverDynamicPlatform}()
* instead.
*/
export function serverBootstrap<T>(
appComponentType: Type<T>,
customProviders: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<T>> {
console.warn(
'serverBootstrap is deprecated. Create an @NgModule and use `bootstrapModule` with the `serverDynamicPlatform()` instead.');
reflector.reflectionCapabilities = new ReflectionCapabilities();
const deprecatedConfiguration = analyzeAppProvidersForDeprecatedConfiguration(customProviders);
const declarations = [deprecatedConfiguration.moduleDeclarations.concat([appComponentType])];
@NgModule({
providers: customProviders,
declarations: declarations,
imports: [BrowserModule],
bootstrap: [appComponentType]
})
class DynamicModule {
}
return platformDynamicServer()
.bootstrapModule(DynamicModule, deprecatedConfiguration.compilerOptions)
.then((moduleRef) => {
const console = moduleRef.injector.get(Console);
deprecatedConfiguration.deprecationMessages.forEach((msg) => console.warn(msg));
const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
return appRef.components[0];
});
}
createPlatformFactory(platformCoreDynamic, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS);