refactor(core): move directives, pipes, and forms into common

BREAKING CHANGE

All private exports from 'angular2/src/core/{directives,pipes,forms}' should be replaced with 'angular2/src/common/{directives,pipes,formis}'

Closes #5153
This commit is contained in:
vsavkin 2015-11-05 14:58:24 -08:00 committed by Victor Savkin
parent 6edd964a83
commit 695923dcd6
82 changed files with 166 additions and 147 deletions

View File

@ -966,7 +966,7 @@ var bundleConfig = {
// TODO: upgrade system builder and find a way to declare all input as cjs.
meta: {
'angular2/src/router/route_definition': {format: 'cjs'},
'angular2/src/core/directives/observable_list_diff': {format: 'cjs'},
'angular2/src/common/directives/observable_list_diff': {format: 'cjs'},
'angular2/lifecycle_hooks': {format: 'cjs'}
}
};

View File

@ -1,51 +1,4 @@
import {CONST_EXPR, Type} from './src/core/facade/lang';
import {FORM_DIRECTIVES} from './src/core/forms';
import {CORE_DIRECTIVES} from './src/core/directives';
export * from './src/core/pipes';
export * from './src/core/directives';
/**
* A collection of Angular core directives that are likely to be used in each and every Angular
* application. This includes core directives (e.g., NgIf and NgFor), and forms directives (e.g.,
* NgModel).
*
* This collection can be used to quickly enumerate all the built-in directives in the `directives`
* property of the `@Component` or `@View` decorators.
*
* ### Example
*
* Instead of writing:
*
* ```typescript
* import {NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault, NgModel, NgForm} from
* 'angular2/angular2';
* import {OtherDirective} from './myDirectives';
*
* @Component({
* selector: 'my-component',
* templateUrl: 'myComponent.html',
* directives: [NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault, NgModel, NgForm,
* OtherDirective]
* })
* export class MyComponent {
* ...
* }
* ```
* one could import all the common directives at once:
*
* ```typescript
* import {COMMON_DIRECTIVES} from 'angular2/angular2';
* import {OtherDirective} from './myDirectives';
*
* @Component({
* selector: 'my-component',
* templateUrl: 'myComponent.html',
* directives: [COMMON_DIRECTIVES, OtherDirective]
* })
* export class MyComponent {
* ...
* }
* ```
*/
export const COMMON_DIRECTIVES: Type[][] = CONST_EXPR([CORE_DIRECTIVES, FORM_DIRECTIVES]);
export * from './src/common/pipes';
export * from './src/common/directives';
export * from './src/common/forms';
export * from './src/common/common_directives';

View File

@ -4,7 +4,7 @@ library angular2.core;
export 'package:angular2/src/core/metadata.dart';
export 'package:angular2/src/core/util.dart';
export 'package:angular2/src/core/di.dart';
export 'package:angular2/src/core/pipes.dart';
export 'package:angular2/src/common/pipes.dart';
export 'package:angular2/src/core/facade.dart';
// Do not export application for dart. Must import from angular2/bootstrap
//export 'package:angular2/src/core/application.dart';
@ -14,7 +14,7 @@ export 'package:angular2/src/core/services.dart';
export 'package:angular2/src/core/linker.dart';
export 'package:angular2/src/core/zone.dart';
export 'package:angular2/src/core/render.dart';
export 'package:angular2/src/core/directives.dart';
export 'package:angular2/src/core/forms.dart';
export 'package:angular2/src/common/directives.dart';
export 'package:angular2/src/common/forms.dart';
export 'package:angular2/src/core/debug.dart';
export 'package:angular2/src/core/change_detection.dart';

View File

@ -6,7 +6,7 @@
export * from './src/core/metadata';
export * from './src/core/util';
export * from './src/core/di';
export * from './src/core/pipes';
export * from './src/common/pipes';
export * from './src/core/facade';
export * from './src/core/application';
export * from './src/core/bootstrap';
@ -15,8 +15,8 @@ export * from './src/core/linker';
export {ApplicationRef} from './src/core/application_ref';
export * from './src/core/zone';
export * from './src/core/render';
export * from './src/core/directives';
export * from './src/core/forms';
export * from './src/common/directives';
export * from './src/common/forms';
export * from './src/core/debug';
export * from './src/core/change_detection';
export * from './src/core/ambient';

View File

@ -0,0 +1,49 @@
import {CONST_EXPR, Type} from 'angular2/src/core/facade/lang';
import {FORM_DIRECTIVES} from './forms';
import {CORE_DIRECTIVES} from './directives';
/**
* A collection of Angular core directives that are likely to be used in each and every Angular
* application. This includes core directives (e.g., NgIf and NgFor), and forms directives (e.g.,
* NgModel).
*
* This collection can be used to quickly enumerate all the built-in directives in the `directives`
* property of the `@Component` or `@View` decorators.
*
* ### Example
*
* Instead of writing:
*
* ```typescript
* import {NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault, NgModel, NgForm} from
* 'angular2/angular2';
* import {OtherDirective} from './myDirectives';
*
* @Component({
* selector: 'my-component',
* templateUrl: 'myComponent.html',
* directives: [NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault, NgModel, NgForm,
* OtherDirective]
* })
* export class MyComponent {
* ...
* }
* ```
* one could import all the common directives at once:
*
* ```typescript
* import {COMMON_DIRECTIVES} from 'angular2/angular2';
* import {OtherDirective} from './myDirectives';
*
* @Component({
* selector: 'my-component',
* templateUrl: 'myComponent.html',
* directives: [COMMON_DIRECTIVES, OtherDirective]
* })
* export class MyComponent {
* ...
* }
* ```
*/
export const COMMON_DIRECTIVES: Type[][] = CONST_EXPR([CORE_DIRECTIVES, FORM_DIRECTIVES]);

View File

@ -0,0 +1,12 @@
/**
* @module
* @description
* Common directives shipped with Angular.
*/
export {NgClass} from './directives/ng_class';
export {NgFor} from './directives/ng_for';
export {NgIf} from './directives/ng_if';
export {NgStyle} from './directives/ng_style';
export {NgSwitch, NgSwitchWhen, NgSwitchDefault} from './directives/ng_switch';
export * from './directives/observable_list_diff';
export {CORE_DIRECTIVES} from './directives/core_directives';

View File

@ -1,22 +1,9 @@
/**
* @module
* @description
* Common directives shipped with Angular.
*/
import {CONST_EXPR, Type} from './facade/lang';
import {NgClass} from './directives/ng_class';
import {NgFor} from './directives/ng_for';
import {NgIf} from './directives/ng_if';
import {NgStyle} from './directives/ng_style';
import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from './directives/ng_switch';
export {NgClass} from './directives/ng_class';
export {NgFor} from './directives/ng_for';
export {NgIf} from './directives/ng_if';
export {NgStyle} from './directives/ng_style';
export {NgSwitch, NgSwitchWhen, NgSwitchDefault} from './directives/ng_switch';
export * from './directives/observable_list_diff';
import {CONST_EXPR, Type} from 'angular2/src/core/facade/lang';
import {NgClass} from './ng_class';
import {NgFor} from './ng_for';
import {NgIf} from './ng_if';
import {NgStyle} from './ng_style';
import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from './ng_switch';
/**
* A collection of Angular core directives that are likely to be used in each and every Angular

View File

@ -11,7 +11,6 @@
* explicitly.
*
*/
export {AbstractControl, Control, ControlGroup, ControlArray} from './forms/model';
export {AbstractControlDirective} from './forms/directives/abstract_control_directive';
@ -40,23 +39,4 @@ export {
MaxLengthValidator,
Validator
} from './forms/directives/validators';
export {FormBuilder} from './forms/form_builder';
import {FormBuilder} from './forms/form_builder';
import {CONST_EXPR, Type} from './facade/lang';
/**
* Shorthand set of providers used for building Angular forms.
*
* ### Example
*
* ```typescript
* bootstrap(MyApp, [FORM_PROVIDERS]);
* ```
*/
export const FORM_PROVIDERS: Type[] = CONST_EXPR([FormBuilder]);
/**
* @deprecated
*/
export const FORM_BINDINGS = FORM_PROVIDERS;
export {FormBuilder, FORM_PROVIDERS, FORM_BINDINGS} from './forms/form_builder';

View File

@ -1,6 +1,6 @@
library angular2.core.forms.normalize_validators;
import 'package:angular2/src/core/forms/directives/validators.dart' show Validator;
import 'package:angular2/src/common/forms/directives/validators.dart' show Validator;
Function normalizeValidator(dynamic validator){
if (validator is Validator) {

View File

@ -1,6 +1,6 @@
import {Injectable} from 'angular2/src/core/di';
import {StringMapWrapper} from 'angular2/src/core/facade/collection';
import {isPresent, isArray} from 'angular2/src/core/facade/lang';
import {isPresent, isArray, CONST_EXPR, Type} from 'angular2/src/core/facade/lang';
import * as modelModule from './model';
@ -106,3 +106,19 @@ export class FormBuilder {
}
}
}
/**
* Shorthand set of providers used for building Angular forms.
*
* ### Example
*
* ```typescript
* bootstrap(MyApp, [FORM_PROVIDERS]);
* ```
*/
export const FORM_PROVIDERS: Type[] = CONST_EXPR([FormBuilder]);
/**
* @deprecated
*/
export const FORM_BINDINGS = FORM_PROVIDERS;

View File

@ -1,9 +1,9 @@
import {isBlank, isPresent, CONST_EXPR} from 'angular2/src/core/facade/lang';
import {PromiseWrapper} from 'angular2/src/core/facade/promise';
import {ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
import {OpaqueToken} from 'angular2/src/core/di';
import * as modelModule from './model';
import {PromiseWrapper} from "../facade/promise";
/**
* Providers for validators to be used for {@link Control}s in a form.

View File

@ -0,0 +1,25 @@
/**
* @module
* @description
* This module provides a set of common Pipes.
*/
import {AsyncPipe} from './async_pipe';
import {UpperCasePipe} from './uppercase_pipe';
import {LowerCasePipe} from './lowercase_pipe';
import {JsonPipe} from './json_pipe';
import {SlicePipe} from './slice_pipe';
import {DatePipe} from './date_pipe';
import {DecimalPipe, PercentPipe, CurrencyPipe} from './number_pipe';
import {CONST_EXPR} from 'angular2/src/core/facade/lang';
export const COMMON_PIPES = CONST_EXPR([
AsyncPipe,
UpperCasePipe,
LowerCasePipe,
JsonPipe,
SlicePipe,
DecimalPipe,
PercentPipe,
CurrencyPipe,
DatePipe
]);

View File

@ -6,7 +6,7 @@ import {Injectable} from 'angular2/src/core/di';
import {PipeTransform, WrappedValue} from 'angular2/src/core/change_detection';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {Pipe} from '../metadata';
import {Pipe} from 'angular2/src/core/metadata';
/**
* Creates a new List or String containing only a subset (slice) of the

View File

@ -1,4 +1,4 @@
import {FORM_PROVIDERS} from 'angular2/src/core/forms';
import {FORM_PROVIDERS} from 'angular2/src/common/forms';
import {provide, Provider} from 'angular2/src/core/di';
import {Type, isBlank, isPresent, stringify} from 'angular2/src/core/facade/lang';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';

View File

@ -1,5 +1,5 @@
import {Injector, provide, OpaqueToken, Provider} from 'angular2/src/core/di';
import {FORM_PROVIDERS} from 'angular2/src/core/forms';
import {FORM_PROVIDERS} from 'angular2/src/common/forms';
import {
NumberWrapper,
Type,

View File

@ -16,7 +16,7 @@ import {
} from 'angular2/testing_internal';
import {ListWrapper, StringMapWrapper, SetWrapper} from 'angular2/src/core/facade/collection';
import {Component, View, NgFor, provide} from 'angular2/angular2';
import {NgClass} from 'angular2/src/core/directives/ng_class';
import {NgClass} from 'angular2/src/common/directives/ng_class';
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
function detectChangesAndCheck(fixture: ComponentFixture, classes: string, elIndex: number = 0) {

View File

@ -17,7 +17,7 @@ import {ListWrapper} from 'angular2/src/core/facade/collection';
import {Component, View, TemplateRef, ContentChild} from 'angular2/angular2';
import {NgFor} from 'angular2/src/core/directives/ng_for';
import {NgFor} from 'angular2/src/common/directives/ng_for';
export function main() {

View File

@ -19,7 +19,7 @@ import {StringMapWrapper} from 'angular2/src/core/facade/collection';
import {Component, View} from 'angular2/angular2';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {NgStyle} from 'angular2/src/core/directives/ng_style';
import {NgStyle} from 'angular2/src/common/directives/ng_style';
export function main() {
describe('binding to CSS styles', () => {

View File

@ -14,7 +14,7 @@ import {
import {Component, View} from 'angular2/angular2';
import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/src/core/directives/ng_switch';
import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/src/common/directives/ng_switch';
export function main() {
describe('switch', () => {

View File

@ -17,7 +17,6 @@ import {
import {SpyNgControl, SpyValueAccessor} from '../spies';
import {
ControlGroup,
Control,
@ -38,7 +37,7 @@ import {
} from 'angular2/core';
import {selectValueAccessor, composeValidators} from 'angular2/src/core/forms/directives/shared';
import {selectValueAccessor, composeValidators} from 'angular2/src/common/forms/directives/shared';
import {TimerWrapper} from 'angular2/src/core/facade/async';
import {PromiseWrapper} from 'angular2/src/core/facade/promise';
import {SimpleChange} from 'angular2/src/core/change_detection';

View File

@ -9,10 +9,9 @@ import {
afterEach,
AsyncTestCompleter,
inject,
SpyObject,
browserDetection
} from 'angular2/testing_internal';
import {SpyChangeDetectorRef} from './spies';
import {SpyChangeDetectorRef} from '../spies';
import {isBlank} from 'angular2/src/core/facade/lang';
import {AsyncPipe, WrappedValue} from 'angular2/core';

View File

@ -10,7 +10,6 @@ import {
AsyncTestCompleter,
inject,
proxy,
SpyObject,
TestComponentBuilder
} from 'angular2/testing_internal';
import {Json, RegExp, NumberWrapper, StringWrapper} from 'angular2/src/core/facade/lang';

View File

@ -0,0 +1,20 @@
library core.spies;
import 'package:angular2/common.dart';
import 'package:angular2/src/core/change_detection/change_detection.dart';
import 'package:angular2/testing_internal.dart';
@proxy
class SpyNgControl extends SpyObject implements NgControl {
noSuchMethod(m) => super.noSuchMethod(m);
}
@proxy
class SpyValueAccessor extends SpyObject implements ControlValueAccessor {
noSuchMethod(m) => super.noSuchMethod(m);
}
@proxy
class SpyChangeDetectorRef extends SpyObject implements ChangeDetectorRef {
noSuchMethod(m) => super.noSuchMethod(m);
}

View File

@ -1,7 +1,10 @@
import {ChangeDetectorRef_} from 'angular2/src/core/change_detection/change_detector_ref';
import {SpyObject, proxy} from 'angular2/testing_internal';
export class SpyChangeDetectorRef extends SpyObject {
constructor() { super(ChangeDetectorRef_); }
}
}
export class SpyNgControl extends SpyObject {}
export class SpyValueAccessor extends SpyObject {}

View File

@ -1,9 +0,0 @@
library pipes.spies;
import 'package:angular2/src/core/change_detection/change_detection.dart';
import 'package:angular2/testing_internal.dart';
@proxy
class SpyChangeDetectorRef extends SpyObject implements ChangeDetectorRef {
noSuchMethod(m) => super.noSuchMethod(m);
}

View File

@ -106,14 +106,4 @@ class SpyDomAdapter extends SpyObject implements DomAdapter {
class SpyRenderEventDispatcher extends SpyObject
implements RenderEventDispatcher {
noSuchMethod(m) => super.noSuchMethod(m);
}
@proxy
class SpyNgControl extends SpyObject implements NgControl {
noSuchMethod(m) => super.noSuchMethod(m);
}
@proxy
class SpyValueAccessor extends SpyObject implements ControlValueAccessor {
noSuchMethod(m) => super.noSuchMethod(m);
}
}

View File

@ -105,8 +105,4 @@ export class SpyRenderEventDispatcher extends SpyObject {
super();
this.spy('dispatchRenderEvent');
}
}
export class SpyNgControl extends SpyObject {}
export class SpyValueAccessor extends SpyObject {}
}

View File

@ -2,7 +2,7 @@ export * from '../lifecycle_hooks';
export * from '../src/core/metadata';
export * from '../src/core/util';
export * from '../src/core/di';
export * from '../src/core/pipes';
export * from '../src/common/pipes';
export * from '../src/core/facade';
// Do not export application in web_worker,
// web_worker exports its own
@ -32,8 +32,8 @@ export {
RenderEmbeddedTemplateCmd,
RenderBeginCmd
} from '../src/core/render/render';
export * from '../src/core/directives';
export * from '../src/core/forms';
export * from '../src/common/directives';
export * from '../src/common/forms';
export * from '../src/core/debug';
export * from '../src/core/change_detection';

View File

@ -17,7 +17,7 @@ dependency_overrides:
path: ../angular2_material
transformers:
- angular2:
ambient_directives: 'package:angular2/src/core/directives.dart#CORE_DIRECTIVES'
ambient_directives: 'package:angular2/src/common/directives.dart#CORE_DIRECTIVES'
entry_points:
- web/src/gestures/index.dart
- web/src/hello_world/index.dart

View File

@ -41,7 +41,7 @@ class TransformerOptions {
final bool reflectPropertiesAsAttributes;
/// A set of directives that will be automatically passed-in to the template compiler
/// Format of an item in the list: angular2/lib/src/core/directives.dart#CORE_DIRECTIVES
/// Format of an item in the list: angular2/lib/src/common/directives.dart#CORE_DIRECTIVES
final List<String> ambientDirectives;
/// Whether to format generated code.

View File

@ -11,7 +11,7 @@ final ngFor = {
"type": {
"id": 9999,
"name": "NgFor",
"moduleUrl": "asset:angular2/lib/src/core/directives/ng_for.dart"
"moduleUrl": "asset:angular2/lib/src/common/directives/ng_for.dart"
},
"changeDetection": null,
"inputs": {"ngForOf": "ngForOf"},

View File

@ -25,7 +25,7 @@ module.exports = function makeNodeTree(destinationPath) {
'angular2/test/testing/fake_async_spec.ts',
'angular2/test/testing/testing_public_spec.ts',
'angular2/test/compiler/xhr_impl_spec.ts',
'angular2/test/core/forms/**',
'angular2/test/common/forms/**',
'angular2/test/tools/tools_spec.ts',
'angular1_router/**',
'angular2/examples/**/!(*_spec.ts)',