From 60b10134df1c1bd15229b999e327fb3c29f16483 Mon Sep 17 00:00:00 2001 From: Victor Savkin Date: Mon, 15 Aug 2016 13:44:01 -0700 Subject: [PATCH] cleanup(platform): removed webworker and server deprecated apis (#10745) --- modules/@angular/compiler-cli/README.md | 4 +- .../integrationtest/src/bootstrap.ts | 2 +- .../compiler-cli/integrationtest/test/util.ts | 4 +- modules/@angular/compiler/src/compiler.ts | 38 +-------- modules/@angular/compiler/src/config.ts | 19 +---- modules/@angular/core/index.ts | 1 - modules/@angular/core/src/application_ref.ts | 6 +- .../core/src/platform_core_providers.ts | 7 -- .../core/src/platform_directives_and_pipes.ts | 67 --------------- modules/@angular/forms/src/form_providers.ts | 2 +- .../platform-browser-dynamic/index.ts | 51 ------------ modules/@angular/platform-browser/index.ts | 2 +- .../@angular/platform-browser/src/browser.ts | 31 +------ .../platform-browser/src/worker_app.ts | 22 +---- .../platform-browser/src/worker_render.ts | 20 +---- .../test/browser/bootstrap_spec.ts | 23 +----- .../platform-browser/testing/browser.ts | 2 +- modules/@angular/platform-server/index.ts | 2 +- .../@angular/platform-server/src/server.ts | 81 +++---------------- .../platform-server/test/integration_spec.ts | 25 +++--- .../web_workers/images/background_index.ts | 12 ++- .../src/web_workers/input/background_index.ts | 12 ++- .../kitchen_sink/background_index.ts | 12 ++- .../message_broker/background_index.ts | 13 ++- .../src/web_workers/todo/background_index.ts | 12 ++- tools/public_api_guard/core/index.d.ts | 9 --- .../platform-browser-dynamic/index.d.ts | 12 --- .../platform-browser/index.d.ts | 27 ------- .../platform-server/index.d.ts | 14 +--- 29 files changed, 94 insertions(+), 438 deletions(-) delete mode 100644 modules/@angular/core/src/platform_directives_and_pipes.ts diff --git a/modules/@angular/compiler-cli/README.md b/modules/@angular/compiler-cli/README.md index 4ce8961962..61f7efe963 100644 --- a/modules/@angular/compiler-cli/README.md +++ b/modules/@angular/compiler-cli/README.md @@ -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 diff --git a/modules/@angular/compiler-cli/integrationtest/src/bootstrap.ts b/modules/@angular/compiler-cli/integrationtest/src/bootstrap.ts index 2d00a897e5..d8c8a50674 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/bootstrap.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/bootstrap.ts @@ -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'; diff --git a/modules/@angular/compiler-cli/integrationtest/test/util.ts b/modules/@angular/compiler-cli/integrationtest/test/util.ts index ac476a32ed..e08d3ea44b 100644 --- a/modules/@angular/compiler-cli/integrationtest/test/util.ts +++ b/modules/@angular/compiler-cli/integrationtest/test/util.ts @@ -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 = null; beforeEach((done) => { - serverPlatform().bootstrapModuleFactory(MainModuleNgFactory).then((moduleRef) => { + platformServer().bootstrapModuleFactory(MainModuleNgFactory).then((moduleRef: any) => { mainModuleRef = moduleRef; done(); }); diff --git a/modules/@angular/compiler/src/compiler.ts b/modules/@angular/compiler/src/compiler.ts index 93a2172700..f96e6fe505 100644 --- a/modules/@angular/compiler/src/compiler.ts +++ b/modules/@angular/compiler/src/compiler.ts @@ -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[], 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() diff --git a/modules/@angular/compiler/src/config.ts b/modules/@angular/compiler/src/config.ts index c4a59856c4..e5315106a9 100644 --- a/modules/@angular/compiler/src/config.ts +++ b/modules/@angular/compiler/src/config.ts @@ -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 { diff --git a/modules/@angular/core/index.ts b/modules/@angular/core/index.ts index 0f53f30281..bd572307df 100644 --- a/modules/@angular/core/index.ts +++ b/modules/@angular/core/index.ts @@ -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'; diff --git a/modules/@angular/core/src/application_ref.ts b/modules/@angular/core/src/application_ref.ts index fdbefcaa25..9345041636 100644 --- a/modules/@angular/core/src/application_ref.ts +++ b/modules/@angular/core/src/application_ref.ts @@ -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 */ diff --git a/modules/@angular/core/src/platform_core_providers.ts b/modules/@angular/core/src/platform_core_providers.ts index 9680f6b4bb..7cd7833601 100644 --- a/modules/@angular/core/src/platform_core_providers.ts +++ b/modules/@angular/core/src/platform_core_providers.ts @@ -30,10 +30,3 @@ const _CORE_PLATFORM_PROVIDERS: Array|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; diff --git a/modules/@angular/core/src/platform_directives_and_pipes.ts b/modules/@angular/core/src/platform_directives_and_pipes.ts deleted file mode 100644 index 250aff2fd0..0000000000 --- a/modules/@angular/core/src/platform_directives_and_pipes.ts +++ /dev/null @@ -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: ` - * - * - * ` - * }) - * 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'); diff --git a/modules/@angular/forms/src/form_providers.ts b/modules/@angular/forms/src/form_providers.ts index 166a7cf4aa..51c532361c 100644 --- a/modules/@angular/forms/src/form_providers.ts +++ b/modules/@angular/forms/src/form_providers.ts @@ -48,4 +48,4 @@ export class FormsModule { exports: [InternalFormsSharedModule, REACTIVE_DRIVEN_DIRECTIVES] }) export class ReactiveFormsModule { -} +} \ No newline at end of file diff --git a/modules/@angular/platform-browser-dynamic/index.ts b/modules/@angular/platform-browser-dynamic/index.ts index b8a3f68b25..9f514e7d03 100644 --- a/modules/@angular/platform-browser-dynamic/index.ts +++ b/modules/@angular/platform-browser-dynamic/index.ts @@ -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 = []; - /** * @experimental */ @@ -35,11 +27,6 @@ export const CACHED_TEMPLATE_PROVIDER: Array = 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( - appComponentType: Type, - customProviders?: Array): Promise> { - 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 : []; } diff --git a/modules/@angular/platform-browser/index.ts b/modules/@angular/platform-browser/index.ts index 310c543355..a96c2c798d 100644 --- a/modules/@angular/platform-browser/index.ts +++ b/modules/@angular/platform-browser/index.ts @@ -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'; diff --git a/modules/@angular/platform-browser/src/browser.ts b/modules/@angular/platform-browser/src/browser.ts index 1f2b03f40d..30fe543148 100644 --- a/modules/@angular/platform-browser/src/browser.ts +++ b/modules/@angular/platform-browser/src/browser.ts @@ -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 = - [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 = [ {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 = []; - /** * @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(); diff --git a/modules/@angular/platform-browser/src/worker_app.ts b/modules/@angular/platform-browser/src/worker_app.ts index f8234a9116..7db89f5d4e 100644 --- a/modules/@angular/platform-browser/src/worker_app.ts +++ b/modules/@angular/platform-browser/src/worker_app.ts @@ -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 = - 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 = []; - /** * @experimental */ export const platformWorkerApp = createPlatformFactory(platformCore, 'workerApp'); -/** - * @deprecated Use {@link platformWorkerApp} instead - */ -export const workerAppPlatform = platformWorkerApp; - function _exceptionHandler(): ExceptionHandler { return new ExceptionHandler(new PrintLogger()); } diff --git a/modules/@angular/platform-browser/src/worker_render.ts b/modules/@angular/platform-browser/src/worker_render.ts index c1a7912643..3cc37703aa 100644 --- a/modules/@angular/platform-browser/src/worker_render.ts +++ b/modules/@angular/platform-browser/src/worker_render.ts @@ -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 = - [PLATFORM_COMMON_PROVIDERS, _WORKER_UI_PLATFORM_PROVIDERS]; - -/** - * @deprecated Worker UI only has a platform but no application - */ -export const WORKER_UI_APPLICATION_PROVIDERS: Array = []; - 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()); } diff --git a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts index d062746f40..a7e0ef88a6 100644 --- a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts +++ b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts @@ -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!'); diff --git a/modules/@angular/platform-browser/testing/browser.ts b/modules/@angular/platform-browser/testing/browser.ts index 7b32589320..a5d2209e2d 100644 --- a/modules/@angular/platform-browser/testing/browser.ts +++ b/modules/@angular/platform-browser/testing/browser.ts @@ -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'; diff --git a/modules/@angular/platform-server/index.ts b/modules/@angular/platform-server/index.ts index fbd3baf782..b5b90b4d74 100644 --- a/modules/@angular/platform-server/index.ts +++ b/modules/@angular/platform-server/index.ts @@ -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'; diff --git a/modules/@angular/platform-server/src/server.ts b/modules/@angular/platform-server/src/server.ts index b0a8f4c3b8..7ce077cc9c 100644 --- a/modules/@angular/platform-server/src/server.ts +++ b/modules/@angular/platform-server/src/server.ts @@ -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 = - [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( - appComponentType: Type, - customProviders: Array): Promise> { - 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); \ No newline at end of file diff --git a/modules/@angular/platform-server/test/integration_spec.ts b/modules/@angular/platform-server/test/integration_spec.ts index cfd02ab82a..1cb4c3e866 100644 --- a/modules/@angular/platform-server/test/integration_spec.ts +++ b/modules/@angular/platform-server/test/integration_spec.ts @@ -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(''); - 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 { -} diff --git a/modules/playground/src/web_workers/images/background_index.ts b/modules/playground/src/web_workers/images/background_index.ts index 1a0638f715..aba2285db2 100644 --- a/modules/playground/src/web_workers/images/background_index.ts +++ b/modules/playground/src/web_workers/images/background_index.ts @@ -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); +} \ No newline at end of file diff --git a/modules/playground/src/web_workers/input/background_index.ts b/modules/playground/src/web_workers/input/background_index.ts index ac66a74827..b368d53e79 100644 --- a/modules/playground/src/web_workers/input/background_index.ts +++ b/modules/playground/src/web_workers/input/background_index.ts @@ -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); } diff --git a/modules/playground/src/web_workers/kitchen_sink/background_index.ts b/modules/playground/src/web_workers/kitchen_sink/background_index.ts index 547ae64acf..4ff96794e5 100644 --- a/modules/playground/src/web_workers/kitchen_sink/background_index.ts +++ b/modules/playground/src/web_workers/kitchen_sink/background_index.ts @@ -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); } diff --git a/modules/playground/src/web_workers/message_broker/background_index.ts b/modules/playground/src/web_workers/message_broker/background_index.ts index f3145d3d7e..87b08aca9f 100644 --- a/modules/playground/src/web_workers/message_broker/background_index.ts +++ b/modules/playground/src/web_workers/message_broker/background_index.ts @@ -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); } diff --git a/modules/playground/src/web_workers/todo/background_index.ts b/modules/playground/src/web_workers/todo/background_index.ts index e6b6566a93..2a3bc98852 100644 --- a/modules/playground/src/web_workers/todo/background_index.ts +++ b/modules/playground/src/web_workers/todo/background_index.ts @@ -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); } diff --git a/tools/public_api_guard/core/index.d.ts b/tools/public_api_guard/core/index.d.ts index 0c7bdeb3fb..0420ed707e 100644 --- a/tools/public_api_guard/core/index.d.ts +++ b/tools/public_api_guard/core/index.d.ts @@ -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; diff --git a/tools/public_api_guard/platform-browser-dynamic/index.d.ts b/tools/public_api_guard/platform-browser-dynamic/index.d.ts index 55f0d7077f..d50a394239 100644 --- a/tools/public_api_guard/platform-browser-dynamic/index.d.ts +++ b/tools/public_api_guard/platform-browser-dynamic/index.d.ts @@ -1,18 +1,9 @@ /** @deprecated */ export declare function bootstrap(appComponentType: Type, customProviders?: Array): Promise>; -/** @deprecated */ -export declare function bootstrapWorkerApp(appComponentType: Type, customProviders?: Array): Promise>; - /** @experimental */ export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: Array): Promise; -/** @deprecated */ -export declare const BROWSER_APP_COMPILER_PROVIDERS: Array; - -/** @deprecated */ -export declare const browserDynamicPlatform: (extraProviders?: any[]) => PlatformRef; - /** @experimental */ export declare const CACHED_TEMPLATE_PROVIDER: Array; @@ -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; diff --git a/tools/public_api_guard/platform-browser/index.d.ts b/tools/public_api_guard/platform-browser/index.d.ts index d618c355d2..0020bd1c97 100644 --- a/tools/public_api_guard/platform-browser/index.d.ts +++ b/tools/public_api_guard/platform-browser/index.d.ts @@ -7,12 +7,6 @@ export declare abstract class AnimationDriver { static NOOP: AnimationDriver; } -/** @deprecated */ -export declare const BROWSER_APP_PROVIDERS: Array; - -/** @deprecated */ -export declare const BROWSER_PLATFORM_PROVIDERS: Array; - /** @experimental */ export declare const BROWSER_SANITIZATION_PROVIDERS: Array; @@ -20,9 +14,6 @@ export declare const BROWSER_SANITIZATION_PROVIDERS: Array; 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; - /** @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; - /** @experimental */ export declare const WORKER_SCRIPT: OpaqueToken; -/** @deprecated */ -export declare const WORKER_UI_APPLICATION_PROVIDERS: Array; - /** @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; - /** @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; diff --git a/tools/public_api_guard/platform-server/index.d.ts b/tools/public_api_guard/platform-server/index.d.ts index c8ef4e33a9..124f89a4b5 100644 --- a/tools/public_api_guard/platform-server/index.d.ts +++ b/tools/public_api_guard/platform-server/index.d.ts @@ -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; - -/** @deprecated */ -export declare function serverBootstrap(appComponentType: Type, customProviders: Array): Promise>; - -/** @deprecated */ -export declare const serverDynamicPlatform: (extraProviders?: any[]) => PlatformRef; - -/** @deprecated */ -export declare const serverPlatform: (extraProviders?: any[]) => PlatformRef; +/** @experimental */ +export declare class ServerModule { +}