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

@ -50,9 +50,9 @@ bootstrap.ts
-------------
import {MainModuleNgFactory} from './main_module.ngfactory';
import {browserPlatform} from '@angular/platform-browser';
import {platformBrowser} from '@angular/platform-browser';
browserPlatform().bootstrapModuleFactory(MainModuleNgFactory);
platformBrowser().bootstrapModuleFactory(MainModuleNgFactory);
```
## Configuration

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {browserPlatform} from '@angular/platform-browser';
import {platformBrowser} from '@angular/platform-browser';
import {BasicComp} from './basic';
import {MainModuleNgFactory} from './module.ngfactory';

View File

@ -8,14 +8,14 @@
import {NgModuleFactory, NgModuleRef} from '@angular/core';
import {ComponentFixture} from '@angular/core/testing';
import {serverPlatform} from '@angular/platform-server';
import {platformServer} from '@angular/platform-server';
import {MainModule} from '../src/module';
import {MainModuleNgFactory} from '../src/module.ngfactory';
let mainModuleRef: NgModuleRef<MainModule> = null;
beforeEach((done) => {
serverPlatform().bootstrapModuleFactory(MainModuleNgFactory).then((moduleRef) => {
platformServer().bootstrapModuleFactory(MainModuleNgFactory).then((moduleRef: any) => {
mainModuleRef = moduleRef;
done();
});

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {COMPILER_OPTIONS, Compiler, CompilerFactory, CompilerOptions, Component, Inject, Injectable, OptionalMetadata, PLATFORM_DIRECTIVES, PLATFORM_INITIALIZER, PLATFORM_PIPES, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, Type, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore} from '@angular/core';
import {COMPILER_OPTIONS, Compiler, CompilerFactory, CompilerOptions, Component, Inject, Injectable, OptionalMetadata, PLATFORM_INITIALIZER, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, Type, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore} from '@angular/core';
export * from './template_parser/template_ast';
export {TEMPLATE_TRANSFORMS} from './template_parser/template_parser';
@ -90,9 +90,6 @@ export function analyzeAppProvidersForDeprecatedConfiguration(appProviders: any[
moduleDeclarations: Type<any>[],
deprecationMessages: string[]
} {
let platformDirectives: any[] = [];
let platformPipes: any[] = [];
let compilerProviders: any[] = [];
let useDebug: boolean;
let useJit: boolean;
@ -105,38 +102,18 @@ export function analyzeAppProvidersForDeprecatedConfiguration(appProviders: any[
const tempInj = ReflectiveInjector.resolveAndCreate(appProviders);
const compilerConfig: CompilerConfig = tempInj.get(CompilerConfig, null);
if (compilerConfig) {
platformDirectives = compilerConfig.platformDirectives;
platformPipes = compilerConfig.platformPipes;
useJit = compilerConfig.useJit;
useDebug = compilerConfig.genDebugInfo;
defaultEncapsulation = compilerConfig.defaultEncapsulation;
deprecationMessages.push(
`Passing CompilerConfig as a regular provider is deprecated. Use the "compilerOptions" parameter of "bootstrap()" or use a custom "CompilerFactory" platform provider instead.`);
} else {
// If nobody provided a CompilerConfig, use the
// PLATFORM_DIRECTIVES / PLATFORM_PIPES values directly if existing
platformDirectives = tempInj.get(PLATFORM_DIRECTIVES, []);
platformPipes = tempInj.get(PLATFORM_PIPES, []);
}
platformDirectives = ListWrapper.flatten(platformDirectives);
platformPipes = ListWrapper.flatten(platformPipes);
const xhr = tempInj.get(XHR, null);
if (xhr) {
compilerProviders.push([{provide: XHR, useValue: xhr}]);
deprecationMessages.push(
`Passing XHR as regular provider is deprecated. Pass the provider via "compilerOptions" instead.`);
}
if (platformDirectives.length > 0) {
deprecationMessages.push(
`The PLATFORM_DIRECTIVES provider and CompilerConfig.platformDirectives is deprecated. Add the directives to an NgModule instead! ` +
`(Directives: ${platformDirectives.map(type => stringify(type))})`);
}
if (platformPipes.length > 0) {
deprecationMessages.push(
`The PLATFORM_PIPES provider and CompilerConfig.platformPipes is deprecated. Add the pipes to an NgModule instead! ` +
`(Pipes: ${platformPipes.map(type => stringify(type))})`);
}
const compilerOptions: CompilerOptions = {
useJit: useJit,
useDebug: useDebug,
@ -144,18 +121,7 @@ export function analyzeAppProvidersForDeprecatedConfiguration(appProviders: any[
providers: compilerProviders
};
// Declare a component that uses @Component.directives / pipes as these
// will be added to the module declarations only if they are not already
// imported by other modules.
@Component({directives: platformDirectives, pipes: platformPipes, template: ''})
class DynamicComponent {
}
return {
compilerOptions,
moduleDeclarations: [DynamicComponent],
deprecationMessages: deprecationMessages
};
return {compilerOptions, moduleDeclarations: [], deprecationMessages: deprecationMessages};
}
@Injectable()

View File

@ -21,36 +21,21 @@ export class CompilerConfig {
private _genDebugInfo: boolean;
private _logBindingUpdate: boolean;
public useJit: boolean;
/**
* @deprecated Providing platform directives via the {@link CompilerConfig} is deprecated. Provide
* platform directives via an {@link NgModule} instead.
*/
public platformDirectives: any[];
/**
* @deprecated Providing platform pipes via the {@link CompilerConfig} is deprecated. Provide
* platform pipes via an {@link NgModule} instead.
*/
public platformPipes: any[];
constructor(
{renderTypes = new DefaultRenderTypes(), defaultEncapsulation = ViewEncapsulation.Emulated,
genDebugInfo, logBindingUpdate, useJit = true, deprecatedPlatformDirectives = [],
deprecatedPlatformPipes = []}: {
genDebugInfo, logBindingUpdate, useJit = true}: {
renderTypes?: RenderTypes,
defaultEncapsulation?: ViewEncapsulation,
genDebugInfo?: boolean,
logBindingUpdate?: boolean,
useJit?: boolean,
deprecatedPlatformDirectives?: any[],
deprecatedPlatformPipes?: any[]
useJit?: boolean
} = {}) {
this.renderTypes = renderTypes;
this.defaultEncapsulation = defaultEncapsulation;
this._genDebugInfo = genDebugInfo;
this._logBindingUpdate = logBindingUpdate;
this.useJit = useJit;
this.platformDirectives = deprecatedPlatformDirectives;
this.platformPipes = deprecatedPlatformPipes;
}
get genDebugInfo(): boolean {

View File

@ -23,7 +23,6 @@ export * from './src/linker';
export {DebugElement, DebugNode, asNativeElements, getDebugNode} from './src/debug/debug_node';
export * from './src/testability/testability';
export * from './src/change_detection';
export * from './src/platform_directives_and_pipes';
export * from './src/platform_core_providers';
export {TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID} from './src/i18n/tokens';
export {APPLICATION_COMMON_PROVIDERS, ApplicationModule} from './src/application_module';

View File

@ -170,9 +170,9 @@ export abstract class PlatformRef {
*
* main.ts:
* import {MyModuleNgFactory} from './my_module.ngfactory';
* import {browserPlatform} from '@angular/platform-browser';
* import {platformBrowser} from '@angular/platform-browser';
*
* let moduleRef = browserPlatform().bootstrapModuleFactory(MyModuleNgFactory);
* let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
* ```
*
* @experimental APIs related to application bootstrap are currently under review.
@ -192,7 +192,7 @@ export abstract class PlatformRef {
* })
* class MyModule {}
*
* let moduleRef = browserPlatform().bootstrapModule(MyModule);
* let moduleRef = platformBrowser().bootstrapModule(MyModule);
* ```
* @stable
*/

View File

@ -30,10 +30,3 @@ const _CORE_PLATFORM_PROVIDERS: Array<any|Type<any>|Provider|any[]> = [
* @experimental
*/
export const platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
/**
* A default set of providers which should be included in any Angular platform.
*
* @deprecated Create platforms via `createPlatformFactory(corePlatform, ...) instead!
*/
export const PLATFORM_COMMON_PROVIDERS = _CORE_PLATFORM_PROVIDERS;

View File

@ -1,67 +0,0 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {OpaqueToken} from './di';
/**
* A token that can be provided when bootstrapping an application to make an array of directives
* available in every component of the application.
*
* ### Example
*
* ```typescript
* import {PLATFORM_DIRECTIVES} from '@angular/core';
* import {OtherDirective} from './myDirectives';
*
* @Component({
* selector: 'my-component',
* template: `
* <!-- can use other directive even though the component does not list it in `directives` -->
* <other-directive></other-directive>
* `
* })
* export class MyComponent {
* ...
* }
*
* bootstrap(MyComponent, [{provide: PLATFORM_DIRECTIVES, useValue: [OtherDirective],
multi:true}]);
* ```
*
* @deprecated Providing platform directives via a provider is deprecated. Provide platform
* directives via an {@link NgModule} instead.
*/
export const PLATFORM_DIRECTIVES: OpaqueToken = new OpaqueToken('Platform Directives');
/**
* A token that can be provided when bootstraping an application to make an array of pipes
* available in every component of the application.
*
* ### Example
*
* ```typescript
* import {PLATFORM_PIPES} from '@angular/core';
* import {OtherPipe} from './myPipe';
*
* @Component({
* selector: 'my-component',
* template: `
* {{123 | other-pipe}}
* `
* })
* export class MyComponent {
* ...
* }
*
* bootstrap(MyComponent, [{provide: PLATFORM_PIPES, useValue: [OtherPipe], multi:true}]);
* ```
*
* @deprecated Providing platform pipes via a provider is deprecated. Provide platform pipes via an
* {@link NgModule} instead.
*/
export const PLATFORM_PIPES: OpaqueToken = new OpaqueToken('Platform Pipes');

View File

@ -48,4 +48,4 @@ export class FormsModule {
exports: [InternalFormsSharedModule, REACTIVE_DRIVEN_DIRECTIVES]
})
export class ReactiveFormsModule {
}
}

View File

@ -15,14 +15,6 @@ import {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './src/platform_provid
import {CachedXHR} from './src/xhr/xhr_cache';
import {XHRImpl} from './src/xhr/xhr_impl';
/**
* @deprecated The compiler providers are already included in the {@link CompilerFactory} that is
* contained the {@link browserDynamicPlatform}()`.
*/
export const BROWSER_APP_COMPILER_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [];
/**
* @experimental
*/
@ -35,11 +27,6 @@ export const CACHED_TEMPLATE_PROVIDER: Array<any /*Type | Provider | any[]*/> =
export const platformBrowserDynamic = createPlatformFactory(
platformCoreDynamic, 'browserDynamic', INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
/**
* @deprecated Use {@link platformBrowserDynamic} instead
*/
export const browserDynamicPlatform = platformBrowserDynamic;
/**
* Bootstrapping for Angular applications.
*
@ -177,44 +164,6 @@ export const platformWorkerAppDynamic =
multi: true
}]);
/**
* @deprecated Use {@link platformWorkerAppDynamic} instead
*/
export const workerAppDynamicPlatform = platformWorkerAppDynamic;
/**
* @deprecated Create an {@link NgModule} that includes the {@link WorkerAppModule} and use {@link
* bootstrapModule}
* with the {@link workerAppDynamicPlatform}() instead.
*/
export function bootstrapWorkerApp<T>(
appComponentType: Type<T>,
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<T>> {
console.warn(
'bootstrapWorkerApp is deprecated. Create an @NgModule that includes the `WorkerAppModule` and use `bootstrapModule` with the `workerAppDynamicPlatform()` instead.');
const deprecatedConfiguration = analyzeAppProvidersForDeprecatedConfiguration(customProviders);
const declarations = [deprecatedConfiguration.moduleDeclarations.concat([appComponentType])];
@NgModule({
providers: customProviders,
declarations: declarations,
imports: [WorkerAppModule],
bootstrap: [appComponentType]
})
class DynamicModule {
}
return platformWorkerAppDynamic()
.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];
});
}
function normalizeArray(arr: any[]): any[] {
return arr ? arr : [];
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
export {BROWSER_APP_PROVIDERS, BROWSER_PLATFORM_PROVIDERS, BROWSER_SANITIZATION_PROVIDERS, BrowserModule, browserPlatform, platformBrowser} from './src/browser';
export {BROWSER_SANITIZATION_PROVIDERS, BrowserModule, platformBrowser} from './src/browser';
export {BrowserPlatformLocation} from './src/browser/location/browser_platform_location';
export {Title} from './src/browser/title';
export {disableDebugTools, enableDebugTools} from './src/browser/tools/tools';

View File

@ -7,7 +7,7 @@
*/
import {CommonModule, PlatformLocation} from '@angular/common';
import {ApplicationModule, ExceptionHandler, NgModule, NgModuleFactory, NgModuleRef, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, RootRenderer, SanitizationService, Testability, assertPlatform, createPlatform, createPlatformFactory, getPlatform, isDevMode, platformCore} from '@angular/core';
import {ApplicationModule, ExceptionHandler, NgModule, NgModuleFactory, NgModuleRef, NgZone, OpaqueToken, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, RootRenderer, SanitizationService, Testability, assertPlatform, createPlatform, createPlatformFactory, getPlatform, isDevMode, platformCore} from '@angular/core';
import {wtfInit} from '../core_private';
import {AnimationDriver} from '../src/dom/animation_driver';
@ -33,17 +33,6 @@ export const INTERNAL_BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider |
{provide: PlatformLocation, useClass: BrowserPlatformLocation}
];
/**
* A set of providers to initialize the Angular platform in a web browser.
*
* Used automatically by `bootstrap`, or can be passed to `platform`.
*
* @deprecated Use `platformBrowser()` or create a custom platform factory via
* `createPlatformFactory(platformBrowser, ...)`
*/
export const BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
[PLATFORM_COMMON_PROVIDERS, INTERNAL_BROWSER_PLATFORM_PROVIDERS];
/**
* @security Replacing built-in sanitization providers exposes the application to XSS risks.
* Attacker-controlled data introduced by an unsanitized provider could expose your
@ -55,30 +44,12 @@ export const BROWSER_SANITIZATION_PROVIDERS: Array<any> = [
{provide: DomSanitizationService, useClass: DomSanitizationServiceImpl},
];
/**
* A set of providers to initialize an Angular application in a web browser.
*
* Used automatically by `bootstrap`, or can be passed to {@link PlatformRef
* PlatformRef.application}.
*
* @deprecated Create a module that includes `BrowserModule` instead. This is empty for backwards
* compatibility,
* as all of our bootstrap methods add a module implicitly, i.e. keeping this filled would add the
* providers 2x.
*/
export const BROWSER_APP_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [];
/**
* @experimental API related to bootstrapping are still under review.
*/
export const platformBrowser =
createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
/**
* @deprecated Use {@link platformBrowser} instead
*/
export const browserPlatform = platformBrowser;
export function initDomAdapter() {
BrowserDomAdapter.makeCurrent();
wtfInit();

View File

@ -7,7 +7,7 @@
*/
import {CommonModule} from '@angular/common';
import {APP_INITIALIZER, ApplicationModule, ExceptionHandler, NgModule, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PlatformRef, ReflectiveInjector, RootRenderer, assertPlatform, createPlatform, createPlatformFactory, getPlatform, platformCore} from '@angular/core';
import {APP_INITIALIZER, ApplicationModule, ExceptionHandler, NgModule, NgZone, OpaqueToken, PlatformRef, ReflectiveInjector, RootRenderer, assertPlatform, createPlatform, createPlatformFactory, getPlatform, platformCore} from '@angular/core';
import {BROWSER_SANITIZATION_PROVIDERS} from './browser';
import {isBlank, print} from './facade/lang';
@ -28,31 +28,11 @@ class PrintLogger {
logGroupEnd() {}
}
/**
* @deprecated Use `platformWorkerApp()` or create a custom platform factory via
* `createPlatformFactory(platformWorkerApp, ...)`
*/
export const WORKER_APP_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
PLATFORM_COMMON_PROVIDERS;
/**
* @deprecated Create a module that includes `WorkerAppModule` instead. This is empty for backwards
* compatibility,
* as all of our bootstrap methods add a module implicitly, i.e. keeping this filled would add the
* providers 2x.
*/
export const WORKER_APP_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [];
/**
* @experimental
*/
export const platformWorkerApp = createPlatformFactory(platformCore, 'workerApp');
/**
* @deprecated Use {@link platformWorkerApp} instead
*/
export const workerAppPlatform = platformWorkerApp;
function _exceptionHandler(): ExceptionHandler {
return new ExceptionHandler(new PrintLogger());
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, ExceptionHandler, Injectable, Injector, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, RootRenderer, Testability, assertPlatform, createPlatform, createPlatformFactory, getPlatform, isDevMode, platformCore} from '@angular/core';
import {BaseException, ExceptionHandler, Injectable, Injector, NgZone, OpaqueToken, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, RootRenderer, Testability, assertPlatform, createPlatform, createPlatformFactory, getPlatform, isDevMode, platformCore} from '@angular/core';
import {wtfInit} from '../core_private';
@ -105,18 +105,6 @@ export const _WORKER_UI_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*
{provide: MessageBus, useFactory: messageBusFactory, deps: [WebWorkerInstance]}
];
/**
* * @deprecated Use `platformWorkerUi()` or create a custom platform factory via
* `createPlatformFactory(platformWorkerUi, ...)`
*/
export const WORKER_UI_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
[PLATFORM_COMMON_PROVIDERS, _WORKER_UI_PLATFORM_PROVIDERS];
/**
* @deprecated Worker UI only has a platform but no application
*/
export const WORKER_UI_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [];
function initializeGenericWorkerRenderer(injector: Injector) {
var bus = injector.get(MessageBus);
let zone = injector.get(NgZone);
@ -157,12 +145,6 @@ function initWebWorkerRenderPlatform(injector: Injector): () => void {
export const platformWorkerUi =
createPlatformFactory(platformCore, 'workerUi', _WORKER_UI_PLATFORM_PROVIDERS);
/**
* @deprecated Use {@link platformWorkerUi} instead
*/
export const workerUiPlatform = platformWorkerUi;
function _exceptionHandler(): ExceptionHandler {
return new ExceptionHandler(getDOM());
}

View File

@ -7,7 +7,7 @@
*/
import {XHR} from '@angular/compiler';
import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Component, Directive, ExceptionHandler, Inject, Input, NgModule, OnDestroy, PLATFORM_DIRECTIVES, PLATFORM_INITIALIZER, PLATFORM_PIPES, Pipe, ReflectiveInjector, createPlatform, createPlatformFactory, provide} from '@angular/core';
import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Component, Directive, ExceptionHandler, Inject, Input, NgModule, OnDestroy, PLATFORM_INITIALIZER, Pipe, ReflectiveInjector, createPlatform, createPlatformFactory, provide} from '@angular/core';
import {ApplicationRef, destroyPlatform} from '@angular/core/src/application_ref';
import {Console} from '@angular/core/src/console';
import {ComponentRef} from '@angular/core/src/linker/component_factory';
@ -311,27 +311,6 @@ export function main() {
});
}));
// Note: This will soon be deprecated as bootstrap creates a separate injector for the compiler,
// i.e. such providers needs to go into that injecotr (when calling `browserCompiler`);
it('should still allow to provide platform directives/pipes via the regular providers',
inject([Console, AsyncTestCompleter], (console: DummyConsole, async: AsyncTestCompleter) => {
bootstrap(HelloCmpUsingPlatformDirectiveAndPipe, testProviders.concat([
{provide: PLATFORM_DIRECTIVES, useValue: [SomeDirective]},
{provide: PLATFORM_PIPES, useValue: [SomePipe]}
])).then((compRef) => {
let compFixture = new ComponentFixture(compRef, null, null);
compFixture.detectChanges();
expect(compFixture.debugElement.children[0].properties['title'])
.toBe('transformed someValue');
expect(compilerConsole.warnings).toEqual([
`The PLATFORM_DIRECTIVES provider and CompilerConfig.platformDirectives is deprecated. Add the directives to an NgModule instead! (Directives: ${stringify(SomeDirective)})`,
`The PLATFORM_PIPES provider and CompilerConfig.platformPipes is deprecated. Add the pipes to an NgModule instead! (Pipes: ${stringify(SomePipe)})`
]);
async.done();
});
}));
it('should allow to pass schemas', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
bootstrap(HelloCmpUsingCustomElement, testProviders).then((compRef) => {
expect(el).toHaveText('hello world!');

View File

@ -7,7 +7,7 @@
*/
import {LocationStrategy} from '@angular/common';
import {APP_ID, NgModule, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, assertPlatform, createPlatform, createPlatformFactory, getPlatform, platformCore} from '@angular/core';
import {APP_ID, NgModule, NgZone, OpaqueToken, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, assertPlatform, createPlatform, createPlatformFactory, getPlatform, platformCore} from '@angular/core';
import {BrowserModule} from '../src/browser';
import {BrowserDomAdapter} from '../src/browser/browser_adapter';

View File

@ -6,4 +6,4 @@
* found in the LICENSE file at https://angular.io/license
*/
export {SERVER_PLATFORM_PROVIDERS, platformDynamicServer, platformServer, serverBootstrap, serverDynamicPlatform, serverPlatform} from './src/server';
export {ServerModule, platformDynamicServer, platformServer} from './src/server';

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);

View File

@ -6,12 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, destroyPlatform} from '@angular/core';
import {Component, NgModule, destroyPlatform} from '@angular/core';
import {async} from '@angular/core/testing';
import {BROWSER_APP_PROVIDERS} from '@angular/platform-browser';
import {BROWSER_APP_COMPILER_PROVIDERS} from '@angular/platform-browser-dynamic';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {serverBootstrap} from '@angular/platform-server';
import {ServerModule, platformDynamicServer} from '@angular/platform-server';
function writeBody(html: string): any {
var dom = getDOM();
@ -21,6 +19,15 @@ function writeBody(html: string): any {
return body;
}
@Component({selector: 'app', template: `Works!`})
class MyServerApp {
}
@NgModule({imports: [ServerModule], bootstrap: [MyServerApp]})
class ExampleModule {
}
export function main() {
if (getDOM().supportsDOMEvents()) return; // NODE only
@ -31,13 +38,9 @@ export function main() {
it('should bootstrap', async(() => {
var body = writeBody('<app></app>');
serverBootstrap(MyServerApp, [
BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS
]).then(() => { expect(getDOM().getText(body)).toEqual('Works!'); });
platformDynamicServer().bootstrapModule(ExampleModule).then(() => {
expect(getDOM().getText(body)).toEqual('Works!');
});
}));
});
}
@Component({selector: 'app', template: `Works!`})
class MyServerApp {
}

View File

@ -6,10 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
import {NgModule} from '@angular/core';
import {WorkerAppModule} from '@angular/platform-browser';
import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic';
import {ImageDemo} from './index_common';
export function main() {
bootstrapWorkerApp(ImageDemo);
@NgModule({imports: [WorkerAppModule], bootstrap: [ImageDemo]})
class ExampleModule {
}
export function main() {
platformWorkerAppDynamic().bootstrapModule(ExampleModule);
}

View File

@ -6,10 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
import {NgModule} from '@angular/core';
import {WorkerAppModule} from '@angular/platform-browser';
import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic';
import {InputCmp} from './index_common';
export function main() {
bootstrapWorkerApp(InputCmp);
@NgModule({imports: [WorkerAppModule], bootstrap: [InputCmp]})
class ExampleModule {
}
export function main() {
platformWorkerAppDynamic().bootstrapModule(ExampleModule);
}

View File

@ -6,10 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
import {NgModule} from '@angular/core';
import {WorkerAppModule} from '@angular/platform-browser';
import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic';
import {HelloCmp} from './index_common';
export function main() {
bootstrapWorkerApp(HelloCmp);
@NgModule({imports: [WorkerAppModule], bootstrap: [HelloCmp]})
class ExampleModule {
}
export function main() {
platformWorkerAppDynamic().bootstrapModule(ExampleModule);
}

View File

@ -6,9 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
import {NgModule} from '@angular/core';
import {WorkerAppModule} from '@angular/platform-browser';
import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic';
import {App} from './index_common';
export function main() {
bootstrapWorkerApp(App);
@NgModule({imports: [WorkerAppModule], bootstrap: [App]})
class ExampleModule {
}
export function main() {
platformWorkerAppDynamic().bootstrapModule(ExampleModule);
}

View File

@ -6,10 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {bootstrapWorkerApp} from '@angular/platform-browser-dynamic';
import {NgModule} from '@angular/core';
import {WorkerAppModule} from '@angular/platform-browser';
import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic';
import {TodoApp} from './index_common';
export function main() {
bootstrapWorkerApp(TodoApp);
@NgModule({imports: [WorkerAppModule], bootstrap: [TodoApp]})
class ExampleModule {
}
export function main() {
platformWorkerAppDynamic().bootstrapModule(ExampleModule);
}

View File

@ -964,18 +964,9 @@ export interface PipeTransform {
transform(value: any, ...args: any[]): any;
}
/** @deprecated */
export declare const PLATFORM_COMMON_PROVIDERS: any[];
/** @deprecated */
export declare const PLATFORM_DIRECTIVES: OpaqueToken;
/** @experimental */
export declare const PLATFORM_INITIALIZER: any;
/** @deprecated */
export declare const PLATFORM_PIPES: OpaqueToken;
/** @experimental */
export declare const platformCore: (extraProviders?: any[]) => PlatformRef;

View File

@ -1,18 +1,9 @@
/** @deprecated */
export declare function bootstrap<C>(appComponentType: Type<C>, customProviders?: Array<any>): Promise<ComponentRef<C>>;
/** @deprecated */
export declare function bootstrapWorkerApp<T>(appComponentType: Type<T>, customProviders?: Array<any>): Promise<ComponentRef<T>>;
/** @experimental */
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: Array<any>): Promise<PlatformRef>;
/** @deprecated */
export declare const BROWSER_APP_COMPILER_PROVIDERS: Array<any>;
/** @deprecated */
export declare const browserDynamicPlatform: (extraProviders?: any[]) => PlatformRef;
/** @experimental */
export declare const CACHED_TEMPLATE_PROVIDER: Array<any>;
@ -21,6 +12,3 @@ export declare const platformBrowserDynamic: (extraProviders?: any[]) => Platfor
/** @experimental */
export declare const platformWorkerAppDynamic: (extraProviders?: any[]) => PlatformRef;
/** @deprecated */
export declare const workerAppDynamicPlatform: (extraProviders?: any[]) => PlatformRef;

View File

@ -7,12 +7,6 @@ export declare abstract class AnimationDriver {
static NOOP: AnimationDriver;
}
/** @deprecated */
export declare const BROWSER_APP_PROVIDERS: Array<any>;
/** @deprecated */
export declare const BROWSER_PLATFORM_PROVIDERS: Array<any>;
/** @experimental */
export declare const BROWSER_SANITIZATION_PROVIDERS: Array<any>;
@ -20,9 +14,6 @@ export declare const BROWSER_SANITIZATION_PROVIDERS: Array<any>;
export declare class BrowserModule {
}
/** @deprecated */
export declare const browserPlatform: (extraProviders?: any[]) => PlatformRef;
/** @stable */
export declare class BrowserPlatformLocation extends PlatformLocation {
hash: string;
@ -203,9 +194,6 @@ export declare class WebWorkerInstance {
worker: Worker;
}
/** @deprecated */
export declare const WORKER_APP_APPLICATION_PROVIDERS: Array<any>;
/** @experimental */
export declare const WORKER_APP_LOCATION_PROVIDERS: ({
provide: typeof PlatformLocation;
@ -217,15 +205,9 @@ export declare const WORKER_APP_LOCATION_PROVIDERS: ({
deps: (typeof PlatformLocation | typeof NgZone)[];
})[];
/** @deprecated */
export declare const WORKER_APP_PLATFORM_PROVIDERS: Array<any>;
/** @experimental */
export declare const WORKER_SCRIPT: OpaqueToken;
/** @deprecated */
export declare const WORKER_UI_APPLICATION_PROVIDERS: Array<any>;
/** @experimental */
export declare const WORKER_UI_LOCATION_PROVIDERS: (typeof MessageBasedPlatformLocation | typeof BrowserPlatformLocation | {
provide: any;
@ -234,18 +216,9 @@ export declare const WORKER_UI_LOCATION_PROVIDERS: (typeof MessageBasedPlatformL
deps: typeof Injector[];
})[];
/** @deprecated */
export declare const WORKER_UI_PLATFORM_PROVIDERS: Array<any>;
/** @experimental */
export declare const WORKER_UI_STARTABLE_MESSAGING_SERVICE: OpaqueToken;
/** @experimental */
export declare class WorkerAppModule {
}
/** @deprecated */
export declare const workerAppPlatform: (extraProviders?: any[]) => PlatformRef;
/** @deprecated */
export declare const workerUiPlatform: (extraProviders?: any[]) => PlatformRef;

View File

@ -4,14 +4,6 @@ export declare const platformDynamicServer: (extraProviders?: any[]) => Platform
/** @experimental */
export declare const platformServer: (extraProviders?: any[]) => PlatformRef;
/** @deprecated */
export declare const SERVER_PLATFORM_PROVIDERS: Array<any>;
/** @deprecated */
export declare function serverBootstrap<T>(appComponentType: Type<T>, customProviders: Array<any>): Promise<ComponentRef<T>>;
/** @deprecated */
export declare const serverDynamicPlatform: (extraProviders?: any[]) => PlatformRef;
/** @deprecated */
export declare const serverPlatform: (extraProviders?: any[]) => PlatformRef;
/** @experimental */
export declare class ServerModule {
}