From 8824e393259d286c7d2de440f57cffe13b9e6a5d Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Fri, 24 Feb 2017 14:47:36 -0800 Subject: [PATCH] refactor(platform-browser): extract animations providers into separate file This is needed so that we can use them in a local modification in G3. Attention: This change will conflict with a local mod in G3. --- .../animations/src/animations.ts | 3 +- .../platform-browser/animations/src/module.ts | 31 +++++++++++++ .../animations/src/noop_animations_module.ts | 34 -------------- ...wser_animations_module.ts => providers.ts} | 44 ++++++++++++------- .../test/noop_animations_module_spec.ts | 2 +- .../test/animation/animation_renderer_spec.ts | 2 +- 6 files changed, 61 insertions(+), 55 deletions(-) create mode 100644 modules/@angular/platform-browser/animations/src/module.ts delete mode 100644 modules/@angular/platform-browser/animations/src/noop_animations_module.ts rename modules/@angular/platform-browser/animations/src/{browser_animations_module.ts => providers.ts} (55%) diff --git a/modules/@angular/platform-browser/animations/src/animations.ts b/modules/@angular/platform-browser/animations/src/animations.ts index 1ed06372c0..49a6a9c6eb 100644 --- a/modules/@angular/platform-browser/animations/src/animations.ts +++ b/modules/@angular/platform-browser/animations/src/animations.ts @@ -11,7 +11,6 @@ * @description * Entry point for all animation APIs of the animation browser package. */ -export {BrowserAnimationsModule} from './browser_animations_module'; -export {NoopAnimationsModule} from './noop_animations_module'; +export {BrowserAnimationsModule, NoopAnimationsModule} from './module'; export {AnimationDriver} from './render/animation_driver'; export * from './private_export'; diff --git a/modules/@angular/platform-browser/animations/src/module.ts b/modules/@angular/platform-browser/animations/src/module.ts new file mode 100644 index 0000000000..29376dad63 --- /dev/null +++ b/modules/@angular/platform-browser/animations/src/module.ts @@ -0,0 +1,31 @@ +/** + * @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 {NgModule} from '@angular/core'; +import {BrowserModule, ɵDomRendererFactoryV2} from '@angular/platform-browser'; + +import {BROWSER_ANIMATIONS_PROVIDERS, BROWSER_NOOP_ANIMATIONS_PROVIDERS} from './providers'; + +/** + * @experimental Animation support is experimental. + */ +@NgModule({ + imports: [BrowserModule], + providers: BROWSER_ANIMATIONS_PROVIDERS, +}) +export class BrowserAnimationsModule { +} + +/** + * @experimental Animation support is experimental. + */ +@NgModule({ + imports: [BrowserModule], + providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS, +}) +export class NoopAnimationsModule { +} diff --git a/modules/@angular/platform-browser/animations/src/noop_animations_module.ts b/modules/@angular/platform-browser/animations/src/noop_animations_module.ts deleted file mode 100644 index fd3f38fa51..0000000000 --- a/modules/@angular/platform-browser/animations/src/noop_animations_module.ts +++ /dev/null @@ -1,34 +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 {NgModule, NgZone, RendererFactoryV2} from '@angular/core'; -import {BrowserModule, ɵDomRendererFactoryV2} from '@angular/platform-browser'; - -import {AnimationEngine} from './animation_engine'; -import {AnimationRendererFactory} from './render/animation_renderer'; -import {NoopAnimationEngine} from './render/noop_animation_engine'; - -export function instantiateRendererFactory( - renderer: ɵDomRendererFactoryV2, engine: AnimationEngine, zone: NgZone) { - return new AnimationRendererFactory(renderer, engine, zone); -} - -/** - * @experimental Animation support is experimental. - */ -@NgModule({ - imports: [BrowserModule], - providers: [ - {provide: AnimationEngine, useClass: NoopAnimationEngine}, { - provide: RendererFactoryV2, - useFactory: instantiateRendererFactory, - deps: [ɵDomRendererFactoryV2, AnimationEngine, NgZone] - } - ] -}) -export class NoopAnimationsModule { -} diff --git a/modules/@angular/platform-browser/animations/src/browser_animations_module.ts b/modules/@angular/platform-browser/animations/src/providers.ts similarity index 55% rename from modules/@angular/platform-browser/animations/src/browser_animations_module.ts rename to modules/@angular/platform-browser/animations/src/providers.ts index e82438fafe..c15e8377a3 100644 --- a/modules/@angular/platform-browser/animations/src/browser_animations_module.ts +++ b/modules/@angular/platform-browser/animations/src/providers.ts @@ -5,8 +5,9 @@ * 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 {Injectable, NgModule, NgZone, RendererFactoryV2} from '@angular/core'; -import {BrowserModule, ɵDomRendererFactoryV2} from '@angular/platform-browser'; + +import {Injectable, NgZone, Provider, RendererFactoryV2} from '@angular/core'; +import {ɵDomRendererFactoryV2} from '@angular/platform-browser'; import {AnimationEngine} from './animation_engine'; import {AnimationStyleNormalizer} from './dsl/style_normalization/animation_style_normalizer'; @@ -14,6 +15,7 @@ import {WebAnimationsStyleNormalizer} from './dsl/style_normalization/web_animat import {AnimationDriver, NoopAnimationDriver} from './render/animation_driver'; import {AnimationRendererFactory} from './render/animation_renderer'; import {DomAnimationEngine} from './render/dom_animation_engine'; +import {NoopAnimationEngine} from './render/noop_animation_engine'; import {WebAnimationsDriver, supportsWebAnimations} from './render/web_animations/web_animations_driver'; @Injectable() @@ -40,19 +42,27 @@ export function instantiateRendererFactory( } /** - * @experimental Animation support is experimental. + * Separate providers from the actual module so that we can do a local modification in Google3 to + * include them in the BrowserModule. */ -@NgModule({ - imports: [BrowserModule], - providers: [ - {provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver}, - {provide: AnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer}, - {provide: AnimationEngine, useClass: InjectableAnimationEngine}, { - provide: RendererFactoryV2, - useFactory: instantiateRendererFactory, - deps: [ɵDomRendererFactoryV2, AnimationEngine, NgZone] - } - ] -}) -export class BrowserAnimationsModule { -} +export const BROWSER_ANIMATIONS_PROVIDERS: Provider[] = [ + {provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver}, + {provide: AnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer}, + {provide: AnimationEngine, useClass: InjectableAnimationEngine}, { + provide: RendererFactoryV2, + useFactory: instantiateRendererFactory, + deps: [ɵDomRendererFactoryV2, AnimationEngine, NgZone] + } +]; + +/** + * Separate providers from the actual module so that we can do a local modification in Google3 to + * include them in the BrowserTestingModule. + */ +export const BROWSER_NOOP_ANIMATIONS_PROVIDERS: Provider[] = [ + {provide: AnimationEngine, useClass: NoopAnimationEngine}, { + provide: RendererFactoryV2, + useFactory: instantiateRendererFactory, + deps: [ɵDomRendererFactoryV2, AnimationEngine, NgZone] + } +]; \ No newline at end of file diff --git a/modules/@angular/platform-browser/animations/test/noop_animations_module_spec.ts b/modules/@angular/platform-browser/animations/test/noop_animations_module_spec.ts index a083cca646..e0ff669a60 100644 --- a/modules/@angular/platform-browser/animations/test/noop_animations_module_spec.ts +++ b/modules/@angular/platform-browser/animations/test/noop_animations_module_spec.ts @@ -10,7 +10,7 @@ import {USE_VIEW_ENGINE} from '@angular/compiler/src/config'; import {Component} from '@angular/core'; import {TestBed} from '@angular/core/testing'; import {ɵAnimationEngine} from '@angular/platform-browser/animations'; -import {NoopAnimationsModule} from '../src/noop_animations_module'; +import {NoopAnimationsModule} from '../src/module'; import {NoopAnimationEngine} from '../src/render/noop_animation_engine'; export function main() { diff --git a/modules/@angular/platform-browser/test/animation/animation_renderer_spec.ts b/modules/@angular/platform-browser/test/animation/animation_renderer_spec.ts index 361938be49..0bcfe7c533 100644 --- a/modules/@angular/platform-browser/test/animation/animation_renderer_spec.ts +++ b/modules/@angular/platform-browser/test/animation/animation_renderer_spec.ts @@ -11,7 +11,7 @@ import {AnimationPlayer, Component, Injectable, RendererFactoryV2, RendererTypeV import {TestBed} from '@angular/core/testing'; import {BrowserAnimationsModule, ɵAnimationEngine, ɵAnimationRendererFactory} from '@angular/platform-browser/animations'; -import {InjectableAnimationEngine} from '../../animations/src/browser_animations_module'; +import {InjectableAnimationEngine} from '../../animations/src/providers'; import {el} from '../../testing/browser_util'; export function main() {