Skip to content

Commit

Permalink
refactor(platform-browser): move platform-browser/animations to anima…
Browse files Browse the repository at this point in the history
…tions/browser (angular#15130)

Closes: angular#15130
  • Loading branch information
matsko authored and Zhicheng Wang committed Aug 11, 2017
1 parent 5c5307f commit 5430179
Show file tree
Hide file tree
Showing 60 changed files with 221 additions and 95 deletions.
14 changes: 14 additions & 0 deletions packages/animations/browser/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @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
*/

// This file is not used to build this module. It is only used during editing
// by the TypeScript language serivce and during build for verifcation. `ngc`
// replaces this file with production index.ts when it rewrites private symbol
// names.

export * from './src/browser';
6 changes: 6 additions & 0 deletions packages/animations/browser/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"typings": "../typings/browser/index.d.ts",
"main": "../bundles/animation-browser.umd.js",
"module": "../@angular/animations/browser.es5.js",
"es2015": "../@angular/animations/browser.js"
}
14 changes: 14 additions & 0 deletions packages/animations/browser/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @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
*/

/**
* @module
* @description
* Entry point for all public APIs of the animation package.
*/
export * from './src/browser';
19 changes: 19 additions & 0 deletions packages/animations/browser/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @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
*/

export default {
entry: '../../../dist/packages-dist/animations/@angular/animations/browser.es5.js',
dest: '../../../dist/packages-dist/animations/bundles/animations-browser.umd.js',
format: 'umd',
moduleName: 'ng.animations.browser',
globals: {
'@angular/core': 'ng.core',
'@angular/common': 'ng.common',
'@angular/animations': 'ng.animations'
}
};
15 changes: 15 additions & 0 deletions packages/animations/browser/src/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @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
*/

/**
* @module
* @description
* Entry point for all animation APIs of the animation browser package.
*/
export {AnimationDriver} from './render/animation_driver';
export * from './private_export';
15 changes: 15 additions & 0 deletions packages/animations/browser/src/private_export.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @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
*/
export {AnimationEngine as ɵAnimationEngine} from './animation_engine';
export {Animation as ɵAnimation} from './dsl/animation';
export {AnimationStyleNormalizer as ɵAnimationStyleNormalizer, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer} from './dsl/style_normalization/animation_style_normalizer';
export {WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer} from './dsl/style_normalization/web_animations_style_normalizer';
export {NoopAnimationDriver as ɵNoopAnimationDriver} from './render/animation_driver';
export {DomAnimationEngine as ɵDomAnimationEngine} from './render/dom_animation_engine';
export {NoopAnimationEngine as ɵNoopAnimationEngine} from './render/noop_animation_engine';
export {WebAnimationsDriver as ɵWebAnimationsDriver, supportsWebAnimations as ɵsupportsWebAnimations} from './render/web_animations/web_animations_driver';
File renamed without changes.
19 changes: 19 additions & 0 deletions packages/animations/browser/testing/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @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
*/

export default {
entry: '../../../../dist/packages-dist/animations/@angular/animations/browser/testing.es5.js',
dest: '../../../../dist/packages-dist/animations/bundles/animations-browser-testing.umd.js',
format: 'umd',
moduleName: 'ng.animations.browser.testing',
globals: {
'@angular/core': 'ng.core',
'@angular/common': 'ng.common',
'@angular/animations': 'ng.animations'
}
};
17 changes: 17 additions & 0 deletions packages/animations/browser/testing/tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../tsconfig-build",
"compilerOptions": {
"paths": {
"@angular/animations": ["../../dist/packages/animations"]
}
},
"files": [
"index.ts",
"../../../../node_modules/@types/hammerjs/index.d.ts",
"../../../../node_modules/@types/jasmine/index.d.ts",
"../../../../node_modules/zone.js/dist/zone.js.d.ts"
],
"angularCompilerOptions": {
"strictMetadataEmit": true
}
}
20 changes: 20 additions & 0 deletions packages/animations/browser/tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "../tsconfig-build",

"compilerOptions": {
"paths": {
"@angular/animations": ["../../dist/packages/animations"]
}
},
"files": [
"public_api.ts",
"../../../node_modules/zone.js/dist/zone.js.d.ts",
"../../system.d.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/animations/browser"
}
}
16 changes: 15 additions & 1 deletion packages/animations/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@
* Entry point for all public APIs of the animation package.
*/

import {Version} from '@angular/core';
/**
* @whatItDoes Represents the version of angular/animations
*
* @stable
*/
export class Version {
constructor(public full: string) {}

get major(): string { return this.full.split('.')[0]; }

get minor(): string { return this.full.split('.')[1]; }

get patch(): string { return this.full.split('.').slice(2).join('.'); }
}

/**
* @stable
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/animations/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"moduleResolution": "node",
"outDir": "../../dist/packages/animations",
"paths": {
"@angular/core": ["../../dist/packages/core"],
"@angular/core/testing": ["../../dist/packages/core/testing"]
},
"rootDir": ".",
"sourceMap": true,
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler-cli/integrationtest/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ɵAnimationEngine} from '@angular/animations/browser';
import {ApplicationRef, NgModule, NgZone, Provider, RendererFactory2} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {NoopAnimationsModule, ɵAnimationEngine, ɵAnimationRendererFactory} from '@angular/platform-browser/animations';
import {NoopAnimationsModule, ɵAnimationRendererFactory} from '@angular/platform-browser/animations';
import {ServerModule, ɵServerRendererFactory2} from '@angular/platform-server';
import {MdButtonModule} from '@angular2-material/button';
// Note: don't refer to third_party_src as we want to test that
Expand Down
5 changes: 3 additions & 2 deletions packages/core/test/animation/animation_integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AUTO_STYLE, AnimationEvent, animate, keyframes, state, style, transition, trigger} from '@angular/animations';
import {AnimationDriver, ɵAnimationEngine} from '@angular/animations/browser';
import {MockAnimationDriver, MockAnimationPlayer} from '@angular/animations/browser/testing';
import {Component, HostBinding, HostListener, RendererFactory2, ViewChild} from '@angular/core';
import {ɵDomRendererFactory2} from '@angular/platform-browser';
import {AnimationDriver, BrowserAnimationsModule, ɵAnimationEngine} from '@angular/platform-browser/animations';
import {MockAnimationDriver, MockAnimationPlayer} from '@angular/platform-browser/animations/testing';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';

import {TestBed} from '../../testing';
Expand Down
1 change: 1 addition & 0 deletions packages/examples/_common/system-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ System.config({
'@angular/common': '/vendor/@angular/common/bundles/common.umd.js',
'@angular/compiler': '/vendor/@angular/compiler/bundles/compiler.umd.js',
'@angular/animations': '/vendor/@angular/animations/bundles/animations.umd.js',
'@angular/animations/browser': '/vendor/@angular/animations/bundles/animations-browser.umd.js',
'@angular/platform-browser/animations':
'/vendor/@angular/platform-browser/bundles/platform-browser-animations.umd.js',
'@angular/core': '/vendor/@angular/core/bundles/core.umd.js',
Expand Down
3 changes: 2 additions & 1 deletion packages/examples/core/animation/ts/dsl/animation_example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

// #docregion Component
import {Component, NgModule, animate, state, style, transition, trigger} from '@angular/core';
import {animate, state, style, transition, trigger} from '@angular/animations';
import {Component, NgModule} from '@angular/core';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';

@Component({
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-browser/animations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
// replaces this file with production index.ts when it rewrites private symbol
// names.

export * from './src/animations';
export * from './public_api';
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
* 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 {AnimationEvent, AnimationTriggerMetadata} from '@angular/animations';
import {AnimationTriggerMetadata} from '@angular/animations';
import {ɵAnimationEngine as AnimationEngine} from '@angular/animations/browser';
import {Injectable, NgZone, Renderer2, RendererFactory2, RendererStyleFlags2, RendererType2} from '@angular/core';

import {AnimationEngine} from '../animation_engine';

@Injectable()
export class AnimationRendererFactory implements RendererFactory2 {
constructor(
Expand Down
1 change: 0 additions & 1 deletion packages/platform-browser/animations/src/animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
* Entry point for all animation APIs of the animation browser package.
*/
export {BrowserAnimationsModule, NoopAnimationsModule} from './module';
export {AnimationDriver} from './render/animation_driver';
export * from './private_export';
2 changes: 1 addition & 1 deletion packages/platform-browser/animations/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {NgModule} from '@angular/core';
import {BrowserModule, ɵDomRendererFactory2} from '@angular/platform-browser';
import {BrowserModule} from '@angular/platform-browser';

import {BROWSER_ANIMATIONS_PROVIDERS, BROWSER_NOOP_ANIMATIONS_PROVIDERS} from './providers';

Expand Down
7 changes: 1 addition & 6 deletions packages/platform-browser/animations/src/private_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@
* 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
*/
export {AnimationEngine as ɵAnimationEngine} from './animation_engine';
export {Animation as ɵAnimation} from './dsl/animation';
export {AnimationStyleNormalizer as ɵAnimationStyleNormalizer, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer} from './dsl/style_normalization/animation_style_normalizer';
export {NoopAnimationDriver as ɵNoopAnimationDriver} from './render/animation_driver';
export {AnimationRenderer as ɵAnimationRenderer, AnimationRendererFactory as ɵAnimationRendererFactory} from './render/animation_renderer';
export {DomAnimationEngine as ɵDomAnimationEngine} from './render/dom_animation_engine';
export {AnimationRenderer as ɵAnimationRenderer, AnimationRendererFactory as ɵAnimationRendererFactory} from './animation_renderer';
20 changes: 7 additions & 13 deletions packages/platform-browser/animations/src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@
* found in the LICENSE file at https://angular.io/license
*/

import {AnimationDriver, ɵAnimationEngine as AnimationEngine, ɵAnimationStyleNormalizer as AnimationStyleNormalizer, ɵDomAnimationEngine as DomAnimationEngine, ɵNoopAnimationDriver as NoopAnimationDriver, ɵNoopAnimationEngine as NoopAnimationEngine, ɵWebAnimationsDriver as WebAnimationsDriver, ɵWebAnimationsStyleNormalizer as WebAnimationsStyleNormalizer, ɵsupportsWebAnimations as supportsWebAnimations} from '@angular/animations/browser';
import {Injectable, NgZone, Provider, RendererFactory2} from '@angular/core';
import {ɵDomRendererFactory2} from '@angular/platform-browser';
import {ɵDomRendererFactory2 as DomRendererFactory2} from '@angular/platform-browser';

import {AnimationEngine} from './animation_engine';
import {AnimationStyleNormalizer} from './dsl/style_normalization/animation_style_normalizer';
import {WebAnimationsStyleNormalizer} from './dsl/style_normalization/web_animations_style_normalizer';
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';
import {AnimationRendererFactory} from './animation_renderer';

@Injectable()
export class InjectableAnimationEngine extends DomAnimationEngine {
Expand All @@ -37,7 +31,7 @@ export function instantiateDefaultStyleNormalizer() {
}

export function instantiateRendererFactory(
renderer: ɵDomRendererFactory2, engine: AnimationEngine, zone: NgZone) {
renderer: DomRendererFactory2, engine: AnimationEngine, zone: NgZone) {
return new AnimationRendererFactory(renderer, engine, zone);
}

Expand All @@ -51,7 +45,7 @@ export const BROWSER_ANIMATIONS_PROVIDERS: Provider[] = [
{provide: AnimationEngine, useClass: InjectableAnimationEngine}, {
provide: RendererFactory2,
useFactory: instantiateRendererFactory,
deps: [ɵDomRendererFactory2, AnimationEngine, NgZone]
deps: [DomRendererFactory2, AnimationEngine, NgZone]
}
];

Expand All @@ -63,6 +57,6 @@ export const BROWSER_NOOP_ANIMATIONS_PROVIDERS: Provider[] = [
{provide: AnimationEngine, useClass: NoopAnimationEngine}, {
provide: RendererFactory2,
useFactory: instantiateRendererFactory,
deps: [ɵDomRendererFactory2, AnimationEngine, NgZone]
deps: [DomRendererFactory2, AnimationEngine, NgZone]
}
];
];
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/
import {state, style, trigger} from '@angular/animations';
import {ɵNoopAnimationEngine as NoopAnimationEngine} from '@angular/animations/browser';
import {el} from '@angular/platform-browser/testing/src/browser_util';

import {NoopAnimationEngine} from '../src/render/noop_animation_engine';

export function main() {
describe('NoopAnimationEngine', () => {
let captures: string[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
* 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 {animate, state, style, transition, trigger} from '@angular/animations';
import {animate, style, transition, trigger} from '@angular/animations';
import {ɵAnimationEngine, ɵNoopAnimationEngine} from '@angular/animations/browser';
import {Component} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {ɵAnimationEngine} from '@angular/platform-browser/animations';

import {NoopAnimationsModule} from '../src/module';
import {NoopAnimationEngine} from '../src/render/noop_animation_engine';

export function main() {
describe('NoopAnimationsModule', () => {
beforeEach(() => { TestBed.configureTestingModule({imports: [NoopAnimationsModule]}); });

it('the engine should be a Noop engine', () => {
const engine = TestBed.get(ɵAnimationEngine);
expect(engine instanceof NoopAnimationEngine).toBeTruthy();
expect(engine instanceof ɵNoopAnimationEngine).toBeTruthy();
});

it('should flush and fire callbacks when the zone becomes stable', (async) => {
Expand Down
21 changes: 0 additions & 21 deletions packages/platform-browser/animations/testing/rollup.config.js

This file was deleted.

Loading

0 comments on commit 5430179

Please sign in to comment.