refactor: rename annotations to metadata
BREAKING CHANGE (maybe) Well as long as our customers use public API this should not be a breaking change, but we have changed import structure as well as internal names, so it could be breaking. import: angular2/annotations => angular2/metadata Classes: *Annotations => *Metadata renderer.DirectiveMetadata => renderer.RendererDirectiveMetadata renderer.ElementBinder => renderer.RendererElementBinder impl.Directive => impl.DirectiveMetadata impl.Component => impl.ComponentMetadata impl.View => impl.ViewMetadata Closes #3660
This commit is contained in:

committed by
Miško Hevery

parent
5e6317fecc
commit
ea6673947c
@ -6,7 +6,8 @@ import {implementsOnDestroy} from './pipe_lifecycle_reflector';
|
||||
|
||||
|
||||
/**
|
||||
* Indicates that the result of a {@link Pipe} transformation has changed even though the reference
|
||||
* Indicates that the result of a {@link PipeMetadata} transformation has changed even though the
|
||||
* reference
|
||||
* has not changed.
|
||||
*
|
||||
* The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
|
||||
|
@ -1,8 +0,0 @@
|
||||
/**
|
||||
* This indirection is needed for TS compilation path.
|
||||
* See comment in annotations.es6.
|
||||
*/
|
||||
|
||||
library angular2.core.annotations.annotations;
|
||||
|
||||
export "../annotations_impl/annotations.dart";
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* This indirection is needed to free up Component, etc symbols in the public API
|
||||
* to be used by the decorator versions of these annotations.
|
||||
*/
|
||||
|
||||
export {
|
||||
Component as ComponentAnnotation,
|
||||
Directive as DirectiveAnnotation,
|
||||
Pipe as PipeAnnotation,
|
||||
LifecycleEvent
|
||||
} from '../annotations_impl/annotations';
|
@ -1,5 +0,0 @@
|
||||
library angular2.core.decorators;
|
||||
|
||||
export '../annotations_impl/annotations.dart';
|
||||
export '../annotations_impl/view.dart';
|
||||
export '../annotations_impl/di.dart';
|
@ -1,3 +0,0 @@
|
||||
library angular2.core.annotations.di;
|
||||
|
||||
export "../annotations_impl/di.dart";
|
@ -1,5 +0,0 @@
|
||||
export {
|
||||
Query as QueryAnnotation,
|
||||
ViewQuery as ViewQueryAnnotation,
|
||||
Attribute as AttributeAnnotation,
|
||||
} from '../annotations_impl/di';
|
@ -1,3 +0,0 @@
|
||||
library angular2.core.annotations.view;
|
||||
|
||||
export "../annotations_impl/view.dart";
|
@ -1 +0,0 @@
|
||||
export {View as ViewAnnotation, ViewEncapsulation} from '../annotations_impl/view';
|
@ -359,12 +359,12 @@ export class ApplicationRef {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current {@link Component} type.
|
||||
* Returns the current {@link ComponentMetadata} type.
|
||||
*/
|
||||
get hostComponentType(): Type { return this._hostComponentType; }
|
||||
|
||||
/**
|
||||
* Returns the current {@link Component} instance.
|
||||
* Returns the current {@link ComponentMetadata} instance.
|
||||
*/
|
||||
get hostComponent(): any { return this._hostComponent.instance; }
|
||||
|
||||
|
@ -20,7 +20,7 @@ import {ProtoViewRef} from './view_ref';
|
||||
import {DirectiveBinding} from './element_injector';
|
||||
import {ViewResolver} from './view_resolver';
|
||||
import {PipeResolver} from './pipe_resolver';
|
||||
import {View} from '../annotations_impl/view';
|
||||
import {ViewMetadata} from 'angular2/metadata';
|
||||
import {ComponentUrlMapper} from './component_url_mapper';
|
||||
import {ProtoViewFactory} from './proto_view_factory';
|
||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||
@ -30,7 +30,14 @@ import {wtfStartTimeRange, wtfEndTimeRange} from '../../profile/profile';
|
||||
import {PipeBinding} from '../pipes/pipe_binding';
|
||||
import {DEFAULT_PIPES_TOKEN} from 'angular2/pipes';
|
||||
|
||||
import * as renderApi from 'angular2/src/render/api';
|
||||
import {
|
||||
RenderDirectiveMetadata,
|
||||
ViewDefinition,
|
||||
RenderCompiler,
|
||||
ViewType,
|
||||
RenderProtoViewMergeMapping,
|
||||
RenderProtoViewRef
|
||||
} from 'angular2/src/render/api';
|
||||
|
||||
/**
|
||||
* Cache that stores the AppProtoView of the template of a component.
|
||||
@ -97,8 +104,8 @@ export class Compiler {
|
||||
@Inject(DEFAULT_PIPES_TOKEN) _defaultPipes: Type[],
|
||||
private _compilerCache: CompilerCache, private _viewResolver: ViewResolver,
|
||||
private _componentUrlMapper: ComponentUrlMapper, private _urlResolver: UrlResolver,
|
||||
private _render: renderApi.RenderCompiler,
|
||||
private _protoViewFactory: ProtoViewFactory, appUrl: AppRootUrl) {
|
||||
private _render: RenderCompiler, private _protoViewFactory: ProtoViewFactory,
|
||||
appUrl: AppRootUrl) {
|
||||
this._defaultPipes = _defaultPipes;
|
||||
this._appUrl = appUrl.value;
|
||||
}
|
||||
@ -215,7 +222,7 @@ export class Compiler {
|
||||
componentPath: Map<Type, AppProtoView>): Promise<AppProtoView> {
|
||||
var nestedPVPromises = [];
|
||||
componentPath = MapWrapper.clone(componentPath);
|
||||
if (appProtoViews[0].type === renderApi.ViewType.COMPONENT) {
|
||||
if (appProtoViews[0].type === ViewType.COMPONENT) {
|
||||
componentPath.set(componentType, appProtoViews[0]);
|
||||
}
|
||||
appProtoViews.forEach(appProtoView => {
|
||||
@ -230,7 +237,7 @@ export class Compiler {
|
||||
if (appProtoView.isEmbeddedFragment) {
|
||||
throw new BaseException(
|
||||
`<ng-content> is used within the recursive path of ${stringify(nestedComponentType)}`);
|
||||
} else if (appProtoView.type === renderApi.ViewType.COMPONENT) {
|
||||
} else if (appProtoView.type === ViewType.COMPONENT) {
|
||||
throw new BaseException(
|
||||
`Unconditional component cycle in ${stringify(nestedComponentType)}`);
|
||||
} else {
|
||||
@ -253,18 +260,17 @@ export class Compiler {
|
||||
}
|
||||
|
||||
private _mergeProtoView(appProtoView: AppProtoView): Promise<any> {
|
||||
if (appProtoView.type !== renderApi.ViewType.HOST &&
|
||||
appProtoView.type !== renderApi.ViewType.EMBEDDED) {
|
||||
if (appProtoView.type !== ViewType.HOST && appProtoView.type !== ViewType.EMBEDDED) {
|
||||
return null;
|
||||
}
|
||||
return this._render.mergeProtoViewsRecursively(this._collectMergeRenderProtoViews(appProtoView))
|
||||
.then((mergeResult: renderApi.RenderProtoViewMergeMapping) => {
|
||||
.then((mergeResult: RenderProtoViewMergeMapping) => {
|
||||
appProtoView.mergeMapping = new AppProtoViewMergeMapping(mergeResult);
|
||||
});
|
||||
}
|
||||
|
||||
private _collectMergeRenderProtoViews(
|
||||
appProtoView: AppProtoView): List<renderApi.RenderProtoViewRef | List<any>> {
|
||||
private _collectMergeRenderProtoViews(appProtoView:
|
||||
AppProtoView): List<RenderProtoViewRef | List<any>> {
|
||||
var result = [appProtoView.render];
|
||||
for (var i = 0; i < appProtoView.elementBinders.length; i++) {
|
||||
var binder = appProtoView.elementBinders[i];
|
||||
@ -290,7 +296,7 @@ export class Compiler {
|
||||
return componentElementBinders;
|
||||
}
|
||||
|
||||
private _buildRenderTemplate(component, view, directives): renderApi.ViewDefinition {
|
||||
private _buildRenderTemplate(component, view, directives): ViewDefinition {
|
||||
var componentUrl =
|
||||
this._urlResolver.resolve(this._appUrl, this._componentUrlMapper.getUrl(component));
|
||||
var templateAbsUrl = null;
|
||||
@ -307,7 +313,7 @@ export class Compiler {
|
||||
styleAbsUrls =
|
||||
ListWrapper.map(view.styleUrls, url => this._urlResolver.resolve(componentUrl, url));
|
||||
}
|
||||
return new renderApi.ViewDefinition({
|
||||
return new ViewDefinition({
|
||||
componentId: stringify(component),
|
||||
templateAbsUrl: templateAbsUrl, template: view.template,
|
||||
styleAbsUrls: styleAbsUrls,
|
||||
@ -317,14 +323,14 @@ export class Compiler {
|
||||
});
|
||||
}
|
||||
|
||||
private _flattenPipes(view: View): any[] {
|
||||
private _flattenPipes(view: ViewMetadata): any[] {
|
||||
if (isBlank(view.pipes)) return this._defaultPipes;
|
||||
var pipes = ListWrapper.clone(this._defaultPipes);
|
||||
this._flattenList(view.pipes, pipes);
|
||||
return pipes;
|
||||
}
|
||||
|
||||
private _flattenDirectives(view: View): List<Type> {
|
||||
private _flattenDirectives(view: ViewMetadata): List<Type> {
|
||||
if (isBlank(view.directives)) return [];
|
||||
var directives = [];
|
||||
this._flattenList(view.directives, directives);
|
||||
@ -347,7 +353,7 @@ export class Compiler {
|
||||
}
|
||||
|
||||
private static _assertTypeIsComponent(directiveBinding: DirectiveBinding): void {
|
||||
if (directiveBinding.metadata.type !== renderApi.DirectiveMetadata.COMPONENT_TYPE) {
|
||||
if (directiveBinding.metadata.type !== RenderDirectiveMetadata.COMPONENT_TYPE) {
|
||||
throw new BaseException(
|
||||
`Could not load '${stringify(directiveBinding.key.token)}' because it is not a component.`);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import {Type, isPresent} from 'angular2/src/facade/lang';
|
||||
import {Map, MapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
/**
|
||||
* Resolve a `Type` from a {@link Component} into a URL.
|
||||
* Resolve a `Type` from a {@link ComponentMetadata} into a URL.
|
||||
*
|
||||
* This interface can be overridden by the application developer to create custom behavior.
|
||||
*
|
||||
|
@ -1,10 +1,10 @@
|
||||
library angular2.src.core.compiler.directive_lifecycle_reflector;
|
||||
|
||||
import 'package:angular2/src/core/annotations_impl/annotations.dart';
|
||||
import 'package:angular2/src/core/metadata.dart';
|
||||
import 'package:angular2/src/core/compiler/interfaces.dart';
|
||||
import 'package:angular2/src/reflection/reflection.dart';
|
||||
|
||||
bool hasLifecycleHook(LifecycleEvent e, type, Directive annotation) {
|
||||
bool hasLifecycleHook(LifecycleEvent e, type, DirectiveMetadata annotation) {
|
||||
if (annotation.lifecycle != null) {
|
||||
return annotation.lifecycle.contains(e);
|
||||
} else {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {Type, isPresent} from 'angular2/src/facade/lang';
|
||||
import {LifecycleEvent, Directive} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {LifecycleEvent, DirectiveMetadata} from 'angular2/metadata';
|
||||
|
||||
export function hasLifecycleHook(e: LifecycleEvent, type, annotation: Directive): boolean {
|
||||
export function hasLifecycleHook(e: LifecycleEvent, type, annotation: DirectiveMetadata): boolean {
|
||||
if (isPresent(annotation.lifecycle)) {
|
||||
return annotation.lifecycle.indexOf(e) !== -1;
|
||||
} else {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import {resolveForwardRef, Injectable} from 'angular2/di';
|
||||
import {Type, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
|
||||
import {Directive} from '../annotations_impl/annotations';
|
||||
import {DirectiveMetadata} from 'angular2/metadata';
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
|
||||
/**
|
||||
* Resolve a `Type` for {@link Directive}.
|
||||
* Resolve a `Type` for {@link DirectiveMetadata}.
|
||||
*
|
||||
* This interface can be overridden by the application developer to create custom behavior.
|
||||
*
|
||||
@ -13,14 +13,14 @@ import {reflector} from 'angular2/src/reflection/reflection';
|
||||
@Injectable()
|
||||
export class DirectiveResolver {
|
||||
/**
|
||||
* Return {@link Directive} for a given `Type`.
|
||||
* Return {@link DirectiveMetadata} for a given `Type`.
|
||||
*/
|
||||
resolve(type: Type): Directive {
|
||||
resolve(type: Type): DirectiveMetadata {
|
||||
var annotations = reflector.annotations(resolveForwardRef(type));
|
||||
if (isPresent(annotations)) {
|
||||
for (var i = 0; i < annotations.length; i++) {
|
||||
var annotation = annotations[i];
|
||||
if (annotation instanceof Directive) {
|
||||
if (annotation instanceof DirectiveMetadata) {
|
||||
return annotation;
|
||||
}
|
||||
}
|
||||
|
@ -31,19 +31,19 @@ import {
|
||||
BindingWithVisibility
|
||||
} from 'angular2/src/di/injector';
|
||||
|
||||
import {Attribute, Query} from 'angular2/src/core/annotations_impl/di';
|
||||
import {AttributeMetadata, QueryMetadata} from '../metadata/di';
|
||||
|
||||
import * as viewModule from './view';
|
||||
import * as avmModule from './view_manager';
|
||||
import {ViewContainerRef} from './view_container_ref';
|
||||
import {ElementRef} from './element_ref';
|
||||
import {TemplateRef} from './template_ref';
|
||||
import {Directive, Component, LifecycleEvent} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {DirectiveMetadata, ComponentMetadata, LifecycleEvent} from '../metadata/directives';
|
||||
import {hasLifecycleHook} from './directive_lifecycle_reflector';
|
||||
import {ChangeDetector, ChangeDetectorRef} from 'angular2/src/change_detection/change_detection';
|
||||
import {QueryList} from './query_list';
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
import {DirectiveMetadata} from 'angular2/src/render/api';
|
||||
import {RenderDirectiveMetadata} from 'angular2/src/render/api';
|
||||
import {PipeBinding} from '../pipes/pipe_binding';
|
||||
|
||||
var _staticKeys;
|
||||
@ -160,7 +160,7 @@ export class TreeNode<T extends TreeNode<any>> {
|
||||
export class DirectiveDependency extends Dependency {
|
||||
constructor(key: Key, optional: boolean, lowerBoundVisibility: Object,
|
||||
upperBoundVisibility: Object, properties: List<any>, public attributeName: string,
|
||||
public queryDecorator: Query) {
|
||||
public queryDecorator: QueryMetadata) {
|
||||
super(key, optional, lowerBoundVisibility, upperBoundVisibility, properties);
|
||||
this._verify();
|
||||
}
|
||||
@ -181,12 +181,12 @@ export class DirectiveDependency extends Dependency {
|
||||
}
|
||||
|
||||
static _attributeName(properties): string {
|
||||
var p = <Attribute>ListWrapper.find(properties, (p) => p instanceof Attribute);
|
||||
var p = <AttributeMetadata>ListWrapper.find(properties, (p) => p instanceof AttributeMetadata);
|
||||
return isPresent(p) ? p.attributeName : null;
|
||||
}
|
||||
|
||||
static _query(properties): Query {
|
||||
return <Query>ListWrapper.find(properties, (p) => p instanceof Query);
|
||||
static _query(properties): QueryMetadata {
|
||||
return <QueryMetadata>ListWrapper.find(properties, (p) => p instanceof QueryMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||
constructor(key: Key, factory: Function, dependencies: List<Dependency>,
|
||||
public resolvedBindings: List<ResolvedBinding>,
|
||||
public resolvedViewBindings: List<ResolvedBinding>,
|
||||
public metadata: DirectiveMetadata) {
|
||||
public metadata: RenderDirectiveMetadata) {
|
||||
super(key, factory, dependencies);
|
||||
}
|
||||
|
||||
@ -218,21 +218,21 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||
|
||||
get changeDetection() { return this.metadata.changeDetection; }
|
||||
|
||||
static createFromBinding(binding: Binding, ann: Directive): DirectiveBinding {
|
||||
static createFromBinding(binding: Binding, ann: DirectiveMetadata): DirectiveBinding {
|
||||
if (isBlank(ann)) {
|
||||
ann = new Directive();
|
||||
ann = new DirectiveMetadata();
|
||||
}
|
||||
|
||||
var rb = binding.resolve();
|
||||
var deps = ListWrapper.map(rb.dependencies, DirectiveDependency.createFrom);
|
||||
var resolvedBindings = isPresent(ann.bindings) ? Injector.resolve(ann.bindings) : [];
|
||||
var resolvedViewBindings = ann instanceof Component && isPresent(ann.viewBindings) ?
|
||||
var resolvedViewBindings = ann instanceof ComponentMetadata && isPresent(ann.viewBindings) ?
|
||||
Injector.resolve(ann.viewBindings) :
|
||||
[];
|
||||
var metadata = DirectiveMetadata.create({
|
||||
var metadata = RenderDirectiveMetadata.create({
|
||||
id: stringify(rb.key.token),
|
||||
type: ann instanceof Component ? DirectiveMetadata.COMPONENT_TYPE :
|
||||
DirectiveMetadata.DIRECTIVE_TYPE,
|
||||
type: ann instanceof ComponentMetadata ? RenderDirectiveMetadata.COMPONENT_TYPE :
|
||||
RenderDirectiveMetadata.DIRECTIVE_TYPE,
|
||||
selector: ann.selector,
|
||||
compileChildren: ann.compileChildren,
|
||||
events: ann.events,
|
||||
@ -246,7 +246,7 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||
callOnInit: hasLifecycleHook(LifecycleEvent.onInit, rb.key.token, ann),
|
||||
callOnAllChangesDone: hasLifecycleHook(LifecycleEvent.onAllChangesDone, rb.key.token, ann),
|
||||
|
||||
changeDetection: ann instanceof Component ? ann.changeDetection : null,
|
||||
changeDetection: ann instanceof ComponentMetadata ? ann.changeDetection : null,
|
||||
|
||||
exportAs: ann.exportAs
|
||||
});
|
||||
@ -264,7 +264,7 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||
return readAttributes;
|
||||
}
|
||||
|
||||
static createFromType(type: Type, annotation: Directive): DirectiveBinding {
|
||||
static createFromType(type: Type, annotation: DirectiveMetadata): DirectiveBinding {
|
||||
var binding = new Binding(type, {toClass: type});
|
||||
return DirectiveBinding.createFromBinding(binding, annotation);
|
||||
}
|
||||
@ -608,7 +608,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
|
||||
if (dirDep.key.id === StaticKeys.instance().changeDetectorRefId) {
|
||||
// We provide the component's view change detector to components and
|
||||
// the surrounding component's change detector to directives.
|
||||
if (dirBin.metadata.type === DirectiveMetadata.COMPONENT_TYPE) {
|
||||
if (dirBin.metadata.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
|
||||
var componentView = this._preBuiltObjects.view.getNestedView(
|
||||
this._preBuiltObjects.elementRef.boundElementIndex);
|
||||
return componentView.changeDetector.ref;
|
||||
@ -713,7 +713,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
|
||||
matched.forEach(s => queryRef.list.add(s));
|
||||
}
|
||||
|
||||
private _createQueryRef(query: Query): void {
|
||||
private _createQueryRef(query: QueryMetadata): void {
|
||||
var queryList = new QueryList<any>();
|
||||
if (isBlank(this._query0)) {
|
||||
this._query0 = new QueryRef(query, queryList, this);
|
||||
@ -726,7 +726,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
|
||||
}
|
||||
}
|
||||
|
||||
addDirectivesMatchingQuery(query: Query, list: any[]): void {
|
||||
addDirectivesMatchingQuery(query: QueryMetadata, list: any[]): void {
|
||||
var templateRef = this._preBuiltObjects.templateRef;
|
||||
if (query.selector === TemplateRef && isPresent(templateRef)) {
|
||||
list.push(templateRef);
|
||||
@ -873,7 +873,7 @@ interface _ElementInjectorStrategy {
|
||||
getComponent(): any;
|
||||
isComponentKey(key: Key): boolean;
|
||||
buildQueries(): void;
|
||||
addDirectivesMatchingQuery(q: Query, res: any[]): void;
|
||||
addDirectivesMatchingQuery(q: QueryMetadata, res: any[]): void;
|
||||
getComponentBinding(): DirectiveBinding;
|
||||
hydrate(): void;
|
||||
dehydrate(): void;
|
||||
@ -1006,7 +1006,7 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
addDirectivesMatchingQuery(query: Query, list: any[]): void {
|
||||
addDirectivesMatchingQuery(query: QueryMetadata, list: any[]): void {
|
||||
var i = this.injectorStrategy;
|
||||
var p = i.protoStrategy;
|
||||
|
||||
@ -1112,7 +1112,7 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
addDirectivesMatchingQuery(query: Query, list: any[]): void {
|
||||
addDirectivesMatchingQuery(query: QueryMetadata, list: any[]): void {
|
||||
var ist = this.injectorStrategy;
|
||||
var p = ist.protoStrategy;
|
||||
|
||||
@ -1144,7 +1144,7 @@ export class QueryError extends BaseException {
|
||||
}
|
||||
|
||||
export class QueryRef {
|
||||
constructor(public query: Query, public list: QueryList<any>,
|
||||
constructor(public query: QueryMetadata, public list: QueryList<any>,
|
||||
public originator: ElementInjector) {}
|
||||
|
||||
get isViewQuery(): boolean { return this.query.isViewQuery; }
|
||||
|
@ -1,10 +1,10 @@
|
||||
import {resolveForwardRef, Injectable} from 'angular2/di';
|
||||
import {Type, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
|
||||
import {Pipe} from '../annotations_impl/annotations';
|
||||
import {PipeMetadata} from '../metadata/directives';
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
|
||||
/**
|
||||
* Resolve a `Type` for {@link Pipe}.
|
||||
* Resolve a `Type` for {@link PipeMetadata}.
|
||||
*
|
||||
* This interface can be overridden by the application developer to create custom behavior.
|
||||
*
|
||||
@ -13,14 +13,14 @@ import {reflector} from 'angular2/src/reflection/reflection';
|
||||
@Injectable()
|
||||
export class PipeResolver {
|
||||
/**
|
||||
* Return {@link Pipe} for a given `Type`.
|
||||
* Return {@link PipeMetadata} for a given `Type`.
|
||||
*/
|
||||
resolve(type: Type): Pipe {
|
||||
resolve(type: Type): PipeMetadata {
|
||||
var metas = reflector.annotations(resolveForwardRef(type));
|
||||
if (isPresent(metas)) {
|
||||
for (var i = 0; i < metas.length; i++) {
|
||||
var annotation = metas[i];
|
||||
if (annotation instanceof Pipe) {
|
||||
if (annotation instanceof PipeMetadata) {
|
||||
return annotation;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,14 @@ import {
|
||||
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
|
||||
import {ProtoPipes} from 'angular2/src/core/pipes/pipes';
|
||||
|
||||
import * as renderApi from 'angular2/src/render/api';
|
||||
import {
|
||||
RenderDirectiveMetadata,
|
||||
RenderElementBinder,
|
||||
PropertyBindingType,
|
||||
DirectiveBinder,
|
||||
ProtoViewDto,
|
||||
ViewType
|
||||
} from 'angular2/src/render/api';
|
||||
import {AppProtoView} from './view';
|
||||
import {ElementBinder} from './element_binder';
|
||||
import {ProtoElementInjector, DirectiveBinding} from './element_injector';
|
||||
@ -26,8 +33,8 @@ import {ProtoElementInjector, DirectiveBinding} from './element_injector';
|
||||
export class BindingRecordsCreator {
|
||||
_directiveRecordsMap: Map<number, DirectiveRecord> = new Map();
|
||||
|
||||
getEventBindingRecords(elementBinders: List<renderApi.ElementBinder>,
|
||||
allDirectiveMetadatas: renderApi.DirectiveMetadata[]): BindingRecord[] {
|
||||
getEventBindingRecords(elementBinders: List<RenderElementBinder>,
|
||||
allDirectiveMetadatas: RenderDirectiveMetadata[]): BindingRecord[] {
|
||||
var res = [];
|
||||
for (var boundElementIndex = 0; boundElementIndex < elementBinders.length;
|
||||
boundElementIndex++) {
|
||||
@ -41,16 +48,15 @@ export class BindingRecordsCreator {
|
||||
}
|
||||
|
||||
private _createTemplateEventRecords(res: BindingRecord[],
|
||||
renderElementBinder: renderApi.ElementBinder,
|
||||
renderElementBinder: RenderElementBinder,
|
||||
boundElementIndex: number): void {
|
||||
renderElementBinder.eventBindings.forEach(eb => {
|
||||
res.push(BindingRecord.createForEvent(eb.source, eb.fullName, boundElementIndex));
|
||||
});
|
||||
}
|
||||
|
||||
private _createHostEventRecords(res: BindingRecord[],
|
||||
renderElementBinder: renderApi.ElementBinder,
|
||||
allDirectiveMetadatas: renderApi.DirectiveMetadata[],
|
||||
private _createHostEventRecords(res: BindingRecord[], renderElementBinder: RenderElementBinder,
|
||||
allDirectiveMetadatas: RenderDirectiveMetadata[],
|
||||
boundElementIndex: number): void {
|
||||
for (var i = 0; i < renderElementBinder.directives.length; ++i) {
|
||||
var dir = renderElementBinder.directives[i];
|
||||
@ -63,9 +69,9 @@ export class BindingRecordsCreator {
|
||||
}
|
||||
|
||||
getPropertyBindingRecords(textBindings: List<ASTWithSource>,
|
||||
elementBinders: List<renderApi.ElementBinder>,
|
||||
elementBinders: List<RenderElementBinder>,
|
||||
allDirectiveMetadatas:
|
||||
List<renderApi.DirectiveMetadata>): List<BindingRecord> {
|
||||
List<RenderDirectiveMetadata>): List<BindingRecord> {
|
||||
var bindings = [];
|
||||
|
||||
this._createTextNodeRecords(bindings, textBindings);
|
||||
@ -80,9 +86,8 @@ export class BindingRecordsCreator {
|
||||
return bindings;
|
||||
}
|
||||
|
||||
getDirectiveRecords(elementBinders: List<renderApi.ElementBinder>,
|
||||
allDirectiveMetadatas:
|
||||
List<renderApi.DirectiveMetadata>): List<DirectiveRecord> {
|
||||
getDirectiveRecords(elementBinders: List<RenderElementBinder>,
|
||||
allDirectiveMetadatas: List<RenderDirectiveMetadata>): List<DirectiveRecord> {
|
||||
var directiveRecords = [];
|
||||
|
||||
for (var elementIndex = 0; elementIndex < elementBinders.length; ++elementIndex) {
|
||||
@ -103,18 +108,18 @@ export class BindingRecordsCreator {
|
||||
}
|
||||
|
||||
_createElementPropertyRecords(bindings: List<BindingRecord>, boundElementIndex: number,
|
||||
renderElementBinder: renderApi.ElementBinder) {
|
||||
renderElementBinder: RenderElementBinder) {
|
||||
ListWrapper.forEach(renderElementBinder.propertyBindings, (binding) => {
|
||||
if (binding.type === renderApi.PropertyBindingType.PROPERTY) {
|
||||
if (binding.type === PropertyBindingType.PROPERTY) {
|
||||
bindings.push(BindingRecord.createForElementProperty(binding.astWithSource,
|
||||
boundElementIndex, binding.property));
|
||||
} else if (binding.type === renderApi.PropertyBindingType.ATTRIBUTE) {
|
||||
} else if (binding.type === PropertyBindingType.ATTRIBUTE) {
|
||||
bindings.push(BindingRecord.createForElementAttribute(binding.astWithSource,
|
||||
boundElementIndex, binding.property));
|
||||
} else if (binding.type === renderApi.PropertyBindingType.CLASS) {
|
||||
} else if (binding.type === PropertyBindingType.CLASS) {
|
||||
bindings.push(BindingRecord.createForElementClass(binding.astWithSource, boundElementIndex,
|
||||
binding.property));
|
||||
} else if (binding.type === renderApi.PropertyBindingType.STYLE) {
|
||||
} else if (binding.type === PropertyBindingType.STYLE) {
|
||||
bindings.push(BindingRecord.createForElementStyle(binding.astWithSource, boundElementIndex,
|
||||
binding.property, binding.unit));
|
||||
}
|
||||
@ -122,8 +127,8 @@ export class BindingRecordsCreator {
|
||||
}
|
||||
|
||||
_createDirectiveRecords(bindings: List<BindingRecord>, boundElementIndex: number,
|
||||
directiveBinders: List<renderApi.DirectiveBinder>,
|
||||
allDirectiveMetadatas: List<renderApi.DirectiveMetadata>) {
|
||||
directiveBinders: List<DirectiveBinder>,
|
||||
allDirectiveMetadatas: List<RenderDirectiveMetadata>) {
|
||||
for (var i = 0; i < directiveBinders.length; i++) {
|
||||
var directiveBinder = directiveBinders[i];
|
||||
var directiveMetadata = allDirectiveMetadatas[directiveBinder.directiveIndex];
|
||||
@ -154,16 +159,16 @@ export class BindingRecordsCreator {
|
||||
// host properties
|
||||
ListWrapper.forEach(directiveBinder.hostPropertyBindings, (binding) => {
|
||||
var dirIndex = new DirectiveIndex(boundElementIndex, i);
|
||||
if (binding.type === renderApi.PropertyBindingType.PROPERTY) {
|
||||
if (binding.type === PropertyBindingType.PROPERTY) {
|
||||
bindings.push(BindingRecord.createForHostProperty(dirIndex, binding.astWithSource,
|
||||
binding.property));
|
||||
} else if (binding.type === renderApi.PropertyBindingType.ATTRIBUTE) {
|
||||
} else if (binding.type === PropertyBindingType.ATTRIBUTE) {
|
||||
bindings.push(BindingRecord.createForHostAttribute(dirIndex, binding.astWithSource,
|
||||
binding.property));
|
||||
} else if (binding.type === renderApi.PropertyBindingType.CLASS) {
|
||||
} else if (binding.type === PropertyBindingType.CLASS) {
|
||||
bindings.push(
|
||||
BindingRecord.createForHostClass(dirIndex, binding.astWithSource, binding.property));
|
||||
} else if (binding.type === renderApi.PropertyBindingType.STYLE) {
|
||||
} else if (binding.type === PropertyBindingType.STYLE) {
|
||||
bindings.push(BindingRecord.createForHostStyle(dirIndex, binding.astWithSource,
|
||||
binding.property, binding.unit));
|
||||
}
|
||||
@ -172,7 +177,7 @@ export class BindingRecordsCreator {
|
||||
}
|
||||
|
||||
_getDirectiveRecord(boundElementIndex: number, directiveIndex: number,
|
||||
directiveMetadata: renderApi.DirectiveMetadata): DirectiveRecord {
|
||||
directiveMetadata: RenderDirectiveMetadata): DirectiveRecord {
|
||||
var id = boundElementIndex * 100 + directiveIndex;
|
||||
|
||||
if (!this._directiveRecordsMap.has(id)) {
|
||||
@ -198,8 +203,7 @@ export class ProtoViewFactory {
|
||||
*/
|
||||
constructor(public _changeDetection: ChangeDetection) {}
|
||||
|
||||
createAppProtoViews(hostComponentBinding: DirectiveBinding,
|
||||
rootRenderProtoView: renderApi.ProtoViewDto,
|
||||
createAppProtoViews(hostComponentBinding: DirectiveBinding, rootRenderProtoView: ProtoViewDto,
|
||||
allDirectives: List<DirectiveBinding>, pipes: PipeBinding[]): AppProtoView[] {
|
||||
var allRenderDirectiveMetadata =
|
||||
ListWrapper.map(allDirectives, directiveBinding => directiveBinding.metadata);
|
||||
@ -233,8 +237,8 @@ export class ProtoViewFactory {
|
||||
* for the given ProtoView and all nested ProtoViews.
|
||||
*/
|
||||
export function getChangeDetectorDefinitions(
|
||||
hostComponentMetadata: renderApi.DirectiveMetadata, rootRenderProtoView: renderApi.ProtoViewDto,
|
||||
allRenderDirectiveMetadata: List<renderApi.DirectiveMetadata>): List<ChangeDetectorDefinition> {
|
||||
hostComponentMetadata: RenderDirectiveMetadata, rootRenderProtoView: ProtoViewDto,
|
||||
allRenderDirectiveMetadata: List<RenderDirectiveMetadata>): List<ChangeDetectorDefinition> {
|
||||
var nestedPvsWithIndex = _collectNestedProtoViews(rootRenderProtoView);
|
||||
var nestedPvVariableNames = _collectNestedProtoViewsVariableNames(nestedPvsWithIndex);
|
||||
return _getChangeDetectorDefinitions(hostComponentMetadata, nestedPvsWithIndex,
|
||||
@ -242,7 +246,7 @@ export function getChangeDetectorDefinitions(
|
||||
}
|
||||
|
||||
function _collectNestedProtoViews(
|
||||
renderProtoView: renderApi.ProtoViewDto, parentIndex: number = null, boundElementIndex = null,
|
||||
renderProtoView: ProtoViewDto, parentIndex: number = null, boundElementIndex = null,
|
||||
result: List<RenderProtoViewWithIndex> = null): List<RenderProtoViewWithIndex> {
|
||||
if (isBlank(result)) {
|
||||
result = [];
|
||||
@ -263,9 +267,9 @@ function _collectNestedProtoViews(
|
||||
}
|
||||
|
||||
function _getChangeDetectorDefinitions(
|
||||
hostComponentMetadata: renderApi.DirectiveMetadata,
|
||||
hostComponentMetadata: RenderDirectiveMetadata,
|
||||
nestedPvsWithIndex: List<RenderProtoViewWithIndex>, nestedPvVariableNames: List<List<string>>,
|
||||
allRenderDirectiveMetadata: List<renderApi.DirectiveMetadata>): List<ChangeDetectorDefinition> {
|
||||
allRenderDirectiveMetadata: List<RenderDirectiveMetadata>): List<ChangeDetectorDefinition> {
|
||||
return ListWrapper.map(nestedPvsWithIndex, (pvWithIndex) => {
|
||||
var elementBinders = pvWithIndex.renderProtoView.elementBinders;
|
||||
var bindingRecordsCreator = new BindingRecordsCreator();
|
||||
@ -277,10 +281,10 @@ function _getChangeDetectorDefinitions(
|
||||
bindingRecordsCreator.getDirectiveRecords(elementBinders, allRenderDirectiveMetadata);
|
||||
var strategyName = DEFAULT;
|
||||
var typeString;
|
||||
if (pvWithIndex.renderProtoView.type === renderApi.ViewType.COMPONENT) {
|
||||
if (pvWithIndex.renderProtoView.type === ViewType.COMPONENT) {
|
||||
strategyName = hostComponentMetadata.changeDetection;
|
||||
typeString = 'comp';
|
||||
} else if (pvWithIndex.renderProtoView.type === renderApi.ViewType.HOST) {
|
||||
} else if (pvWithIndex.renderProtoView.type === ViewType.HOST) {
|
||||
typeString = 'host';
|
||||
} else {
|
||||
typeString = 'embedded';
|
||||
@ -293,7 +297,7 @@ function _getChangeDetectorDefinitions(
|
||||
}
|
||||
|
||||
function _createAppProtoView(
|
||||
renderProtoView: renderApi.ProtoViewDto, protoChangeDetector: ProtoChangeDetector,
|
||||
renderProtoView: ProtoViewDto, protoChangeDetector: ProtoChangeDetector,
|
||||
variableBindings: Map<string, string>, allDirectives: List<DirectiveBinding>,
|
||||
pipes: PipeBinding[]): AppProtoView {
|
||||
var elementBinders = renderProtoView.elementBinders;
|
||||
@ -346,7 +350,7 @@ function _createVariableNames(parentVariableNames: List<string>, renderProtoView
|
||||
return res;
|
||||
}
|
||||
|
||||
export function createVariableLocations(elementBinders: List<renderApi.ElementBinder>):
|
||||
export function createVariableLocations(elementBinders: List<RenderElementBinder>):
|
||||
Map<string, number> {
|
||||
var variableLocations = new Map();
|
||||
for (var i = 0; i < elementBinders.length; i++) {
|
||||
@ -368,7 +372,7 @@ function _createElementBinders(protoView, elementBinders, allDirectiveBindings)
|
||||
ListWrapper.map(dirs, (dir) => allDirectiveBindings[dir.directiveIndex]);
|
||||
var componentDirectiveBinding = null;
|
||||
if (directiveBindings.length > 0) {
|
||||
if (directiveBindings[0].metadata.type === renderApi.DirectiveMetadata.COMPONENT_TYPE) {
|
||||
if (directiveBindings[0].metadata.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
|
||||
componentDirectiveBinding = directiveBindings[0];
|
||||
}
|
||||
}
|
||||
@ -439,7 +443,7 @@ function _createElementBinder(protoView: AppProtoView, boundElementIndex, render
|
||||
return elBinder;
|
||||
}
|
||||
|
||||
export function createDirectiveVariableBindings(renderElementBinder: renderApi.ElementBinder,
|
||||
export function createDirectiveVariableBindings(renderElementBinder: RenderElementBinder,
|
||||
directiveBindings: List<DirectiveBinding>):
|
||||
Map<string, number> {
|
||||
var directiveVariableBindings = new Map();
|
||||
@ -478,7 +482,7 @@ function _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, e
|
||||
function _directiveExportAs(directive): string {
|
||||
var directiveExportAs = directive.metadata.exportAs;
|
||||
if (isBlank(directiveExportAs) &&
|
||||
directive.metadata.type === renderApi.DirectiveMetadata.COMPONENT_TYPE) {
|
||||
directive.metadata.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
|
||||
return "$implicit";
|
||||
} else {
|
||||
return directiveExportAs;
|
||||
@ -486,7 +490,7 @@ function _directiveExportAs(directive): string {
|
||||
}
|
||||
|
||||
class RenderProtoViewWithIndex {
|
||||
constructor(public renderProtoView: renderApi.ProtoViewDto, public index: number,
|
||||
constructor(public renderProtoView: ProtoViewDto, public index: number,
|
||||
public parentIndex: number, public boundElementIndex: number) {}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Injectable} from 'angular2/di';
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
import {ViewMetadata} from '../metadata/view';
|
||||
|
||||
import {Type, stringify, isBlank, BaseException} from 'angular2/src/facade/lang';
|
||||
import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection';
|
||||
@ -11,7 +11,7 @@ import {reflector} from 'angular2/src/reflection/reflection';
|
||||
export class ViewResolver {
|
||||
_cache: Map<Type, /*node*/ any> = new Map();
|
||||
|
||||
resolve(component: Type): View {
|
||||
resolve(component: Type): ViewMetadata {
|
||||
var view = this._cache.get(component);
|
||||
|
||||
if (isBlank(view)) {
|
||||
@ -22,11 +22,11 @@ export class ViewResolver {
|
||||
return view;
|
||||
}
|
||||
|
||||
_resolve(component: Type): View {
|
||||
_resolve(component: Type): ViewMetadata {
|
||||
var annotations = reflector.annotations(component);
|
||||
for (var i = 0; i < annotations.length; i++) {
|
||||
var annotation = annotations[i];
|
||||
if (annotation instanceof View) {
|
||||
if (annotation instanceof ViewMetadata) {
|
||||
return annotation;
|
||||
}
|
||||
}
|
||||
|
97
modules/angular2/src/core/metadata.dart
Normal file
97
modules/angular2/src/core/metadata.dart
Normal file
@ -0,0 +1,97 @@
|
||||
library angular2.src.core.metadata;
|
||||
|
||||
import "package:angular2/src/facade/collection.dart" show List;
|
||||
import "./metadata/di.dart";
|
||||
import "./metadata/directives.dart";
|
||||
import "./metadata/view.dart";
|
||||
|
||||
export "./metadata/di.dart";
|
||||
export "./metadata/directives.dart";
|
||||
export "./metadata/view.dart";
|
||||
|
||||
/**
|
||||
* See: [DirectiveMetadata] for docs.
|
||||
*/
|
||||
class Directive extends DirectiveMetadata {
|
||||
const Directive({String selector, List<String> properties,
|
||||
List<String> events, Map<String, String> host,
|
||||
List<LifecycleEvent> lifecycle, List bindings, String exportAs,
|
||||
bool compileChildren: true})
|
||||
: super(
|
||||
selector: selector,
|
||||
properties: properties,
|
||||
events: events,
|
||||
host: host,
|
||||
lifecycle: lifecycle,
|
||||
bindings: bindings,
|
||||
exportAs: exportAs,
|
||||
compileChildren: compileChildren);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [ComponentMetadata] for docs.
|
||||
*/
|
||||
class Component extends ComponentMetadata {
|
||||
const Component({String selector, List<String> properties,
|
||||
List<String> events, Map<String, String> host,
|
||||
List<LifecycleEvent> lifecycle, List bindings, String exportAs,
|
||||
bool compileChildren, List viewBindings, String changeDetection})
|
||||
: super(
|
||||
selector: selector,
|
||||
properties: properties,
|
||||
events: events,
|
||||
host: host,
|
||||
lifecycle: lifecycle,
|
||||
bindings: bindings,
|
||||
exportAs: exportAs,
|
||||
compileChildren: compileChildren,
|
||||
viewBindings: viewBindings,
|
||||
changeDetection: changeDetection);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [ViewMetadata] for docs.
|
||||
*/
|
||||
class View extends ViewMetadata {
|
||||
const View({String templateUrl, String template, dynamic directives,
|
||||
dynamic pipes, ViewEncapsulation encapsulation, List<String> styles,
|
||||
List<String> styleUrls})
|
||||
: super(
|
||||
templateUrl: templateUrl,
|
||||
template: template,
|
||||
directives: directives,
|
||||
pipes: pipes,
|
||||
encapsulation: encapsulation,
|
||||
styles: styles,
|
||||
styleUrls: styleUrls);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [PipeMetadata] for docs.
|
||||
*/
|
||||
class Pipe extends PipeMetadata {
|
||||
const Pipe({name}) : super(name: name);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [AttributeMetadata] for docs.
|
||||
*/
|
||||
class Attribute extends AttributeMetadata {
|
||||
const Attribute(String attributeName) : super(attributeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [QueryMetadata] for docs.
|
||||
*/
|
||||
class Query extends QueryMetadata {
|
||||
const Query(dynamic /*Type | string*/ selector, {bool descendants: false})
|
||||
: super(selector, descendants: descendants);
|
||||
}
|
||||
|
||||
/**
|
||||
* See: [ViewQueryMetadata] for docs.
|
||||
*/
|
||||
class ViewQuery extends ViewQueryMetadata {
|
||||
const ViewQuery(dynamic /*Type | string*/ selector, {bool descendants: false})
|
||||
: super(selector, descendants: descendants);
|
||||
}
|
@ -1,30 +1,57 @@
|
||||
import {
|
||||
ComponentAnnotation,
|
||||
DirectiveAnnotation,
|
||||
PipeAnnotation,
|
||||
/**
|
||||
* This indirection is needed to free up Component, etc symbols in the public API
|
||||
* to be used by the decorator versions of these annotations.
|
||||
*/
|
||||
|
||||
export {
|
||||
QueryMetadata,
|
||||
ViewQueryMetadata,
|
||||
AttributeMetadata,
|
||||
} from './metadata/di';
|
||||
|
||||
export {
|
||||
ComponentMetadata,
|
||||
DirectiveMetadata,
|
||||
PipeMetadata,
|
||||
LifecycleEvent
|
||||
} from './annotations';
|
||||
import {ViewAnnotation} from './view';
|
||||
import {AttributeAnnotation, QueryAnnotation, ViewQueryAnnotation} from './di';
|
||||
import {makeDecorator, makeParamDecorator, TypeDecorator, Class} from '../../util/decorators';
|
||||
} from './metadata/directives';
|
||||
|
||||
export {ViewMetadata, ViewEncapsulation} from './metadata/view';
|
||||
|
||||
|
||||
import {
|
||||
QueryMetadata,
|
||||
ViewQueryMetadata,
|
||||
AttributeMetadata,
|
||||
} from './metadata/di';
|
||||
|
||||
import {
|
||||
ComponentMetadata,
|
||||
DirectiveMetadata,
|
||||
PipeMetadata,
|
||||
LifecycleEvent
|
||||
} from './metadata/directives';
|
||||
|
||||
import {ViewMetadata, ViewEncapsulation} from './metadata/view';
|
||||
|
||||
import {makeDecorator, makeParamDecorator, TypeDecorator, Class} from '../util/decorators';
|
||||
import {Type} from 'angular2/src/facade/lang';
|
||||
import {ViewEncapsulation} from 'angular2/src/render/api';
|
||||
|
||||
/**
|
||||
* Interface for the {@link Directive} decorator function.
|
||||
* Interface for the {@link DirectiveMetadata} decorator function.
|
||||
*
|
||||
* See {@link DirectiveFactory}.
|
||||
*/
|
||||
export interface DirectiveDecorator extends TypeDecorator {}
|
||||
|
||||
/**
|
||||
* Interface for the {@link Component} decorator function.
|
||||
* Interface for the {@link ComponentMetadata} decorator function.
|
||||
*
|
||||
* See {@link ComponentFactory}.
|
||||
*/
|
||||
export interface ComponentDecorator extends TypeDecorator {
|
||||
/**
|
||||
* Chain {@link View} annotation.
|
||||
* Chain {@link ViewMetadata} annotation.
|
||||
*/
|
||||
View(obj: {
|
||||
templateUrl?: string,
|
||||
@ -38,13 +65,13 @@ export interface ComponentDecorator extends TypeDecorator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for the {@link View} decorator function.
|
||||
* Interface for the {@link ViewMetadata} decorator function.
|
||||
*
|
||||
* See {@link ViewFactory}.
|
||||
*/
|
||||
export interface ViewDecorator extends TypeDecorator {
|
||||
/**
|
||||
* Chain {@link View} annotation.
|
||||
* Chain {@link ViewMetadata} annotation.
|
||||
*/
|
||||
View(obj: {
|
||||
templateUrl?: string,
|
||||
@ -58,7 +85,7 @@ export interface ViewDecorator extends TypeDecorator {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Directive} factory for creating annotations, decorators or DSL.
|
||||
* {@link DirectiveMetadata} factory for creating annotations, decorators or DSL.
|
||||
*
|
||||
* ## Example as TypeScript Decorator
|
||||
*
|
||||
@ -107,7 +134,7 @@ export interface DirectiveFactory {
|
||||
selector?: string, properties?: List<string>, events?: List<string>,
|
||||
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>, bindings?: List<any>,
|
||||
exportAs?: string, compileChildren?: boolean;
|
||||
}): DirectiveAnnotation;
|
||||
}): DirectiveMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,7 +204,7 @@ export interface ComponentFactory {
|
||||
compileChildren?: boolean,
|
||||
viewBindings?: List<any>,
|
||||
changeDetection?: string,
|
||||
}): ComponentAnnotation;
|
||||
}): ComponentMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -239,11 +266,11 @@ export interface ViewFactory {
|
||||
encapsulation?: ViewEncapsulation,
|
||||
styles?: List<string>,
|
||||
styleUrls?: List<string>,
|
||||
}): ViewAnnotation;
|
||||
}): ViewMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Attribute} factory for creating annotations, decorators or DSL.
|
||||
* {@link AttributeMetadata} factory for creating annotations, decorators or DSL.
|
||||
*
|
||||
* ## Example as TypeScript Decorator
|
||||
*
|
||||
@ -290,11 +317,11 @@ export interface ViewFactory {
|
||||
*/
|
||||
export interface AttributeFactory {
|
||||
(name: string): TypeDecorator;
|
||||
new (name: string): AttributeAnnotation;
|
||||
new (name: string): AttributeMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Query} factory for creating annotations, decorators or DSL.
|
||||
* {@link QueryMetadata} factory for creating annotations, decorators or DSL.
|
||||
*
|
||||
* ## Example as TypeScript Decorator
|
||||
*
|
||||
@ -341,11 +368,11 @@ export interface AttributeFactory {
|
||||
*/
|
||||
export interface QueryFactory {
|
||||
(selector: Type | string, {descendants}?: {descendants?: boolean}): ParameterDecorator;
|
||||
new (selector: Type | string, {descendants}?: {descendants?: boolean}): QueryAnnotation;
|
||||
new (selector: Type | string, {descendants}?: {descendants?: boolean}): QueryMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Pipe} factory for creating decorators.
|
||||
* {@link PipeMetadata} factory for creating decorators.
|
||||
*
|
||||
* ## Example as TypeScript Decorator
|
||||
*
|
||||
@ -370,38 +397,38 @@ export interface PipeFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Component} factory function.
|
||||
* {@link ComponentMetadata} factory function.
|
||||
*/
|
||||
export var Component: ComponentFactory =
|
||||
<ComponentFactory>makeDecorator(ComponentAnnotation, (fn: any) => fn.View = View);
|
||||
<ComponentFactory>makeDecorator(ComponentMetadata, (fn: any) => fn.View = View);
|
||||
/**
|
||||
* {@link Directive} factory function.
|
||||
* {@link DirectiveMetadata} factory function.
|
||||
*/
|
||||
export var Directive: DirectiveFactory = <DirectiveFactory>makeDecorator(DirectiveAnnotation);
|
||||
export var Directive: DirectiveFactory = <DirectiveFactory>makeDecorator(DirectiveMetadata);
|
||||
|
||||
/**
|
||||
* {@link View} factory function.
|
||||
* {@link ViewMetadata} factory function.
|
||||
*/
|
||||
export var View: ViewFactory =
|
||||
<ViewFactory>makeDecorator(ViewAnnotation, (fn: any) => fn.View = View);
|
||||
<ViewFactory>makeDecorator(ViewMetadata, (fn: any) => fn.View = View);
|
||||
|
||||
/**
|
||||
* {@link Attribute} factory function.
|
||||
* {@link AttributeMetadata} factory function.
|
||||
*/
|
||||
export var Attribute: AttributeFactory = makeParamDecorator(AttributeAnnotation);
|
||||
export var Attribute: AttributeFactory = makeParamDecorator(AttributeMetadata);
|
||||
|
||||
/**
|
||||
* {@link Query} factory function.
|
||||
* {@link QueryMetadata} factory function.
|
||||
*/
|
||||
export var Query: QueryFactory = makeParamDecorator(QueryAnnotation);
|
||||
export var Query: QueryFactory = makeParamDecorator(QueryMetadata);
|
||||
|
||||
|
||||
/**
|
||||
* {@link ViewQuery} factory function.
|
||||
* {@link ViewQueryMetadata} factory function.
|
||||
*/
|
||||
export var ViewQuery: QueryFactory = makeParamDecorator(ViewQueryAnnotation);
|
||||
export var ViewQuery: QueryFactory = makeParamDecorator(ViewQueryMetadata);
|
||||
|
||||
/**
|
||||
* {@link Pipe} factory function.
|
||||
* {@link PipeMetadata} factory function.
|
||||
*/
|
||||
export var Pipe: PipeFactory = <PipeFactory>makeDecorator(PipeAnnotation);
|
||||
export var Pipe: PipeFactory = <PipeFactory>makeDecorator(PipeMetadata);
|
@ -29,7 +29,7 @@ import {resolveForwardRef} from 'angular2/di';
|
||||
* ```
|
||||
*/
|
||||
@CONST()
|
||||
export class Attribute extends DependencyMetadata {
|
||||
export class AttributeMetadata extends DependencyMetadata {
|
||||
constructor(public attributeName: string) { super(); }
|
||||
|
||||
get token() {
|
||||
@ -49,7 +49,7 @@ export class Attribute extends DependencyMetadata {
|
||||
* See {@link QueryList} for usage and example.
|
||||
*/
|
||||
@CONST()
|
||||
export class Query extends DependencyMetadata {
|
||||
export class QueryMetadata extends DependencyMetadata {
|
||||
descendants: boolean;
|
||||
constructor(private _selector: Type | string,
|
||||
{descendants = false}: {descendants?: boolean} = {}) {
|
||||
@ -74,7 +74,7 @@ export class Query extends DependencyMetadata {
|
||||
* See {@link QueryList} for usage and example.
|
||||
*/
|
||||
@CONST()
|
||||
export class ViewQuery extends Query {
|
||||
export class ViewQueryMetadata extends QueryMetadata {
|
||||
constructor(_selector: Type | string, {descendants = false}: {descendants?: boolean} = {}) {
|
||||
super(_selector, {descendants: descendants});
|
||||
}
|
@ -6,7 +6,7 @@ import {DEFAULT} from 'angular2/change_detection';
|
||||
/**
|
||||
* Directives allow you to attach behavior to elements in the DOM.
|
||||
*
|
||||
* {@link Directive}s with an embedded view are called {@link Component}s.
|
||||
* {@link DirectiveMetadata}s with an embedded view are called {@link ComponentMetadata}s.
|
||||
*
|
||||
* A directive consists of a single directive annotation and a controller class. When the
|
||||
* directive's `selector` matches
|
||||
@ -39,7 +39,7 @@ import {DEFAULT} from 'angular2/change_detection';
|
||||
* current `ElementInjector` resolves the constructor dependencies for each directive.
|
||||
*
|
||||
* Angular then resolves dependencies as follows, according to the order in which they appear in the
|
||||
* {@link View}:
|
||||
* {@link ViewMetadata}:
|
||||
*
|
||||
* 1. Dependencies on the current element
|
||||
* 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM boundary
|
||||
@ -64,7 +64,7 @@ import {DEFAULT} from 'angular2/change_detection';
|
||||
* To inject element-specific special objects, declare the constructor parameter as:
|
||||
* - `element: ElementRef` to obtain a reference to logical element in the view.
|
||||
* - `viewContainer: ViewContainerRef` to control child template instantiation, for
|
||||
* {@link Directive} directives only
|
||||
* {@link DirectiveMetadata} directives only
|
||||
* - `bindingPropagation: BindingPropagation` to control change detection in a more granular way.
|
||||
*
|
||||
* ## Example
|
||||
@ -288,7 +288,7 @@ import {DEFAULT} from 'angular2/change_detection';
|
||||
* location in the current view
|
||||
* where these actions are performed.
|
||||
*
|
||||
* Views are always created as children of the current {@link View}, and as siblings of the
|
||||
* Views are always created as children of the current {@link ViewMetadata}, and as siblings of the
|
||||
* `<template>` element. Thus a
|
||||
* directive in a child view cannot inject the directive that created it.
|
||||
*
|
||||
@ -378,7 +378,7 @@ import {DEFAULT} from 'angular2/change_detection';
|
||||
* view occurs on the second `<li></li>` which is a sibling to the `<template>` element.
|
||||
*/
|
||||
@CONST()
|
||||
export class Directive extends InjectableMetadata {
|
||||
export class DirectiveMetadata extends InjectableMetadata {
|
||||
/**
|
||||
* The CSS selector that triggers the instantiation of a directive.
|
||||
*
|
||||
@ -422,7 +422,7 @@ export class Directive extends InjectableMetadata {
|
||||
* - `directiveProperty` specifies the component property where the value is written.
|
||||
* - `bindingProperty` specifies the DOM property where the value is read from.
|
||||
*
|
||||
* You can include a {@link Pipe} when specifying a `bindingProperty` to allow for data
|
||||
* You can include a {@link PipeMetadata} when specifying a `bindingProperty` to allow for data
|
||||
* transformation and structural change detection of the value. These pipes will be evaluated in
|
||||
* the context of this component.
|
||||
*
|
||||
@ -768,7 +768,7 @@ export class Directive extends InjectableMetadata {
|
||||
*
|
||||
* All template expressions and statements are then evaluated against the component instance.
|
||||
*
|
||||
* For details on the `@View` annotation, see {@link View}.
|
||||
* For details on the `@View` annotation, see {@link ViewMetadata}.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
@ -790,7 +790,7 @@ export class Directive extends InjectableMetadata {
|
||||
*
|
||||
*/
|
||||
@CONST()
|
||||
export class Component extends Directive {
|
||||
export class ComponentMetadata extends DirectiveMetadata {
|
||||
/**
|
||||
* Defines the used change detection strategy.
|
||||
*
|
||||
@ -884,7 +884,7 @@ export class Component extends Directive {
|
||||
*/
|
||||
export enum LifecycleEvent {
|
||||
/**
|
||||
* Notify a directive whenever a {@link View} that contains it is destroyed.
|
||||
* Notify a directive whenever a {@link ViewMetadata} that contains it is destroyed.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
@ -1022,7 +1022,7 @@ export enum LifecycleEvent {
|
||||
* ```
|
||||
*/
|
||||
@CONST()
|
||||
export class Pipe extends InjectableMetadata {
|
||||
export class PipeMetadata extends InjectableMetadata {
|
||||
name: string;
|
||||
|
||||
constructor({name}: {name: string}) {
|
@ -13,7 +13,7 @@ export {ViewEncapsulation} from 'angular2/src/render/api';
|
||||
* When a component is instantiated, the template is loaded into the component's shadow root, and
|
||||
* the expressions and statements in the template are evaluated against the component.
|
||||
*
|
||||
* For details on the `@Component` annotation, see {@link Component}.
|
||||
* For details on the `@Component` annotation, see {@link ComponentMetadata}.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
@ -35,7 +35,7 @@ export {ViewEncapsulation} from 'angular2/src/render/api';
|
||||
* ```
|
||||
*/
|
||||
@CONST()
|
||||
export class View {
|
||||
export class ViewMetadata {
|
||||
/**
|
||||
* Specifies a template URL for an angular component.
|
||||
*
|
@ -1,15 +1,15 @@
|
||||
import {Type} from 'angular2/src/facade/lang';
|
||||
import {Key, Dependency, ResolvedBinding, Binding} from 'angular2/di';
|
||||
import {Pipe} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {PipeMetadata} from '../metadata/directives';
|
||||
|
||||
export class PipeBinding extends ResolvedBinding {
|
||||
constructor(public name: string, key: Key, factory: Function, dependencies: Dependency[]) {
|
||||
super(key, factory, dependencies);
|
||||
}
|
||||
|
||||
static createFromType(type: Type, metadata: Pipe): PipeBinding {
|
||||
static createFromType(type: Type, metadata: PipeMetadata): PipeBinding {
|
||||
var binding = new Binding(type, {toClass: type});
|
||||
var rb = binding.resolve();
|
||||
return new PipeBinding(metadata.name, rb.key, rb.factory, rb.dependencies);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import * as cd from 'angular2/src/change_detection/pipes';
|
||||
|
||||
export class ProtoPipes {
|
||||
/**
|
||||
* Map of {@link Pipe} names to {@link Pipe} implementations.
|
||||
* Map of {@link PipeMetadata} names to {@link PipeMetadata} implementations.
|
||||
*/
|
||||
config: StringMap<string, PipeBinding> = {};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {isPresent, isString, StringWrapper, isBlank} from 'angular2/src/facade/lang';
|
||||
import {Directive, LifecycleEvent} from 'angular2/annotations';
|
||||
import {Directive, LifecycleEvent} from 'angular2/metadata';
|
||||
import {ElementRef} from 'angular2/core';
|
||||
import {Renderer} from 'angular2/src/render/api';
|
||||
import {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Directive, LifecycleEvent} from 'angular2/annotations';
|
||||
import {Directive, LifecycleEvent} from 'angular2/metadata';
|
||||
import {ViewContainerRef, ViewRef, TemplateRef} from 'angular2/core';
|
||||
import {ChangeDetectorRef, IterableDiffer, IterableDiffers} from 'angular2/change_detection';
|
||||
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Directive} from 'angular2/annotations';
|
||||
import {Directive} from 'angular2/metadata';
|
||||
import {ViewContainerRef, TemplateRef} from 'angular2/core';
|
||||
import {isBlank} from 'angular2/src/facade/lang';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Directive} from 'angular2/annotations';
|
||||
import {Directive} from 'angular2/metadata';
|
||||
|
||||
/**
|
||||
* The `NgNonBindable` directive tells Angular not to compile or bind the contents of the current
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Directive, LifecycleEvent} from 'angular2/annotations';
|
||||
import {Directive, LifecycleEvent} from 'angular2/metadata';
|
||||
import {ElementRef} from 'angular2/core';
|
||||
import {KeyValueDiffer, KeyValueDiffers} from 'angular2/change_detection';
|
||||
import {isPresent, isBlank, print} from 'angular2/src/facade/lang';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Directive} from 'angular2/annotations';
|
||||
import {Directive} from 'angular2/metadata';
|
||||
import {Host} from 'angular2/di';
|
||||
import {ViewContainerRef, TemplateRef} from 'angular2/core';
|
||||
import {isPresent, isBlank, normalizeBlank, CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Renderer} from 'angular2/render';
|
||||
import {Directive} from 'angular2/annotations';
|
||||
import {Directive} from 'angular2/metadata';
|
||||
import {ElementRef} from 'angular2/core';
|
||||
import {Self} from 'angular2/di';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {Renderer} from 'angular2/render';
|
||||
import {Directive} from 'angular2/annotations';
|
||||
import {Directive} from 'angular2/metadata';
|
||||
import {ElementRef} from 'angular2/core';
|
||||
import {Self} from 'angular2/di';
|
||||
import {NgControl} from './ng_control';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Directive, LifecycleEvent} from 'angular2/annotations';
|
||||
import {Directive, LifecycleEvent} from 'angular2/metadata';
|
||||
import {Inject, Host, SkipSelf, forwardRef, Binding} from 'angular2/di';
|
||||
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
|
@ -3,7 +3,7 @@ import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||
import {List, StringMap} from 'angular2/src/facade/collection';
|
||||
|
||||
import {QueryList} from 'angular2/core';
|
||||
import {Query, Directive, LifecycleEvent} from 'angular2/annotations';
|
||||
import {Query, Directive, LifecycleEvent} from 'angular2/metadata';
|
||||
import {forwardRef, Host, SkipSelf, Binding, Inject} from 'angular2/di';
|
||||
|
||||
import {ControlContainer} from './control_container';
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
} from 'angular2/src/facade/async';
|
||||
import {StringMapWrapper, List, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {isPresent, isBlank, CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
import {Directive} from 'angular2/annotations';
|
||||
import {Directive} from 'angular2/metadata';
|
||||
import {forwardRef, Binding} from 'angular2/di';
|
||||
import {NgControl} from './ng_control';
|
||||
import {Form} from './form_interface';
|
||||
|
@ -2,7 +2,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
import {QueryList} from 'angular2/core';
|
||||
import {Query, Directive, LifecycleEvent} from 'angular2/annotations';
|
||||
import {Query, Directive, LifecycleEvent} from 'angular2/metadata';
|
||||
import {forwardRef, Binding} from 'angular2/di';
|
||||
|
||||
import {NgControl} from './ng_control';
|
||||
|
@ -2,7 +2,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {ObservableWrapper, EventEmitter} from 'angular2/src/facade/async';
|
||||
|
||||
import {Directive, LifecycleEvent} from 'angular2/annotations';
|
||||
import {Directive, LifecycleEvent} from 'angular2/metadata';
|
||||
import {forwardRef, Binding} from 'angular2/di';
|
||||
import {NgControl} from './ng_control';
|
||||
import {NgControlGroup} from './ng_control_group';
|
||||
|
@ -2,7 +2,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
import {QueryList} from 'angular2/core';
|
||||
import {Query, Directive, LifecycleEvent} from 'angular2/annotations';
|
||||
import {Query, Directive, LifecycleEvent} from 'angular2/metadata';
|
||||
import {forwardRef, Binding} from 'angular2/di';
|
||||
|
||||
import {NgControl} from './ng_control';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {Renderer} from 'angular2/render';
|
||||
import {ElementRef, QueryList} from 'angular2/core';
|
||||
import {Self} from 'angular2/di';
|
||||
import {Query, Directive} from 'angular2/annotations';
|
||||
import {Query, Directive} from 'angular2/metadata';
|
||||
|
||||
import {NgControl} from './ng_control';
|
||||
import {ControlValueAccessor} from './control_value_accessor';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {forwardRef, Binding} from 'angular2/di';
|
||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
import {Directive} from 'angular2/annotations';
|
||||
import {Directive} from 'angular2/metadata';
|
||||
import {Validators} from '../validators';
|
||||
|
||||
export class NgValidator {
|
||||
|
@ -1,24 +1,24 @@
|
||||
import {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {Type, isPresent, BaseException, stringify, isBlank} from 'angular2/src/facade/lang';
|
||||
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
import {ViewMetadata} from '../core/metadata';
|
||||
import {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
|
||||
|
||||
export class MockViewResolver extends ViewResolver {
|
||||
_views: Map<Type, View> = new Map();
|
||||
_views: Map<Type, ViewMetadata> = new Map();
|
||||
_inlineTemplates: Map<Type, string> = new Map();
|
||||
_viewCache: Map<Type, View> = new Map();
|
||||
_viewCache: Map<Type, ViewMetadata> = new Map();
|
||||
_directiveOverrides: Map<Type, Map<Type, Type>> = new Map();
|
||||
|
||||
constructor() { super(); }
|
||||
|
||||
/**
|
||||
* Overrides the {@link View} for a component.
|
||||
* Overrides the {@link ViewMetadata} for a component.
|
||||
*
|
||||
* @param {Type} component
|
||||
* @param {ViewDefinition} view
|
||||
*/
|
||||
setView(component: Type, view: View): void {
|
||||
setView(component: Type, view: ViewMetadata): void {
|
||||
this._checkOverrideable(component);
|
||||
this._views.set(component, view);
|
||||
}
|
||||
@ -35,7 +35,7 @@ export class MockViewResolver extends ViewResolver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides a directive from the component {@link View}.
|
||||
* Overrides a directive from the component {@link ViewMetadata}.
|
||||
*
|
||||
* @param {Type} component
|
||||
* @param {Type} from
|
||||
@ -55,8 +55,8 @@ export class MockViewResolver extends ViewResolver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link View} for a component:
|
||||
* - Set the {@link View} to the overridden view when it exists or fallback to the default
|
||||
* Returns the {@link ViewMetadata} for a component:
|
||||
* - Set the {@link ViewMetadata} to the overridden view when it exists or fallback to the default
|
||||
* `ViewResolver`,
|
||||
* see `setView`.
|
||||
* - Override the directives, see `overrideViewDirective`.
|
||||
@ -65,7 +65,7 @@ export class MockViewResolver extends ViewResolver {
|
||||
* @param component
|
||||
* @returns {ViewDefinition}
|
||||
*/
|
||||
resolve(component: Type): View {
|
||||
resolve(component: Type): ViewMetadata {
|
||||
var view = this._viewCache.get(component);
|
||||
if (isPresent(view)) return view;
|
||||
|
||||
@ -87,13 +87,14 @@ export class MockViewResolver extends ViewResolver {
|
||||
}
|
||||
directives[srcIndex] = to;
|
||||
});
|
||||
view = new View(
|
||||
view = new ViewMetadata(
|
||||
{template: view.template, templateUrl: view.templateUrl, directives: directives});
|
||||
}
|
||||
|
||||
var inlineTemplate = this._inlineTemplates.get(component);
|
||||
if (isPresent(inlineTemplate)) {
|
||||
view = new View({template: inlineTemplate, templateUrl: null, directives: view.directives});
|
||||
view = new ViewMetadata(
|
||||
{template: inlineTemplate, templateUrl: null, directives: view.directives});
|
||||
}
|
||||
|
||||
this._viewCache.set(component, view);
|
||||
|
@ -6,7 +6,7 @@ import {PipeTransform, PipeOnDestroy, WrappedValue} from 'angular2/change_detect
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
import {ChangeDetectorRef} from 'angular2/change_detection';
|
||||
|
||||
import {Pipe} from 'angular2/src/core/annotations/decorators';
|
||||
import {Pipe} from '../core/metadata';
|
||||
|
||||
|
||||
class ObservableStrategy {
|
||||
@ -127,4 +127,4 @@ export class AsyncPipe implements PipeTransform, PipeOnDestroy {
|
||||
this._ref.requestCheck();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import {StringMapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
import {Pipe} from 'angular2/src/core/annotations/decorators';
|
||||
import {Pipe} from '../core/metadata';
|
||||
|
||||
// TODO: move to a global configable location along with other i18n components.
|
||||
var defaultLocale: string = 'en-US';
|
||||
|
@ -3,7 +3,7 @@ import {Injectable} from 'angular2/di';
|
||||
|
||||
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||
|
||||
import {Pipe} from 'angular2/src/core/annotations/decorators';
|
||||
import {Pipe} from '../core/metadata';
|
||||
|
||||
/**
|
||||
* Implements json transforms to any object.
|
||||
|
@ -13,7 +13,7 @@ import {Injectable} from 'angular2/di';
|
||||
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
import {Pipe} from 'angular2/src/core/annotations/decorators';
|
||||
import {Pipe} from '../core/metadata';
|
||||
|
||||
/**
|
||||
* Creates a new List or String containing only a prefix/suffix of the
|
||||
|
@ -5,7 +5,7 @@ import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
|
||||
import {Pipe} from 'angular2/src/core/annotations/decorators';
|
||||
import {Pipe} from '../core/metadata';
|
||||
|
||||
/**
|
||||
* Implements lowercase transforms to text.
|
||||
|
@ -16,7 +16,7 @@ import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
import {Pipe} from 'angular2/src/core/annotations/decorators';
|
||||
import {Pipe} from '../core/metadata';
|
||||
|
||||
var defaultLocale: string = 'en-US';
|
||||
var _re = RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$');
|
||||
|
@ -4,7 +4,7 @@ import {Injectable} from 'angular2/di';
|
||||
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
import {Pipe} from 'angular2/src/core/annotations/decorators';
|
||||
import {Pipe} from '../core/metadata';
|
||||
|
||||
/**
|
||||
* Implements uppercase transforms to text.
|
||||
|
@ -36,7 +36,7 @@ export class ElementPropertyBinding {
|
||||
public property: string, public unit: string = null) {}
|
||||
}
|
||||
|
||||
export class ElementBinder {
|
||||
export class RenderElementBinder {
|
||||
index: number;
|
||||
parentIndex: number;
|
||||
distanceToParent: number;
|
||||
@ -110,7 +110,7 @@ export enum ViewType {
|
||||
|
||||
export class ProtoViewDto {
|
||||
render: RenderProtoViewRef;
|
||||
elementBinders: List<ElementBinder>;
|
||||
elementBinders: List<RenderElementBinder>;
|
||||
variableBindings: Map<string, string>;
|
||||
type: ViewType;
|
||||
textBindings: List<ASTWithSource>;
|
||||
@ -119,7 +119,7 @@ export class ProtoViewDto {
|
||||
constructor({render, elementBinders, variableBindings, type, textBindings,
|
||||
transitiveNgContentCount}: {
|
||||
render?: RenderProtoViewRef,
|
||||
elementBinders?: List<ElementBinder>,
|
||||
elementBinders?: List<RenderElementBinder>,
|
||||
variableBindings?: Map<string, string>,
|
||||
type?: ViewType,
|
||||
textBindings?: List<ASTWithSource>,
|
||||
@ -134,7 +134,7 @@ export class ProtoViewDto {
|
||||
}
|
||||
}
|
||||
|
||||
export class DirectiveMetadata {
|
||||
export class RenderDirectiveMetadata {
|
||||
static get DIRECTIVE_TYPE() { return 0; }
|
||||
static get COMPONENT_TYPE() { return 1; }
|
||||
id: any;
|
||||
@ -220,7 +220,7 @@ export class DirectiveMetadata {
|
||||
callOnAllChangesDone?: boolean,
|
||||
changeDetection?: string,
|
||||
exportAs?: string
|
||||
}): DirectiveMetadata {
|
||||
}): RenderDirectiveMetadata {
|
||||
let hostListeners = new Map();
|
||||
let hostProperties = new Map();
|
||||
let hostAttributes = new Map();
|
||||
@ -228,7 +228,7 @@ export class DirectiveMetadata {
|
||||
|
||||
if (isPresent(host)) {
|
||||
MapWrapper.forEach(host, (value: string, key: string) => {
|
||||
var matches = RegExpWrapper.firstMatch(DirectiveMetadata._hostRegExp, key);
|
||||
var matches = RegExpWrapper.firstMatch(RenderDirectiveMetadata._hostRegExp, key);
|
||||
if (isBlank(matches)) {
|
||||
hostAttributes.set(key, value);
|
||||
} else if (isPresent(matches[1])) {
|
||||
@ -241,7 +241,7 @@ export class DirectiveMetadata {
|
||||
});
|
||||
}
|
||||
|
||||
return new DirectiveMetadata({
|
||||
return new RenderDirectiveMetadata({
|
||||
id: id,
|
||||
selector: selector,
|
||||
compileChildren: compileChildren,
|
||||
@ -296,7 +296,7 @@ export class ViewDefinition {
|
||||
componentId: string;
|
||||
templateAbsUrl: string;
|
||||
template: string;
|
||||
directives: List<DirectiveMetadata>;
|
||||
directives: List<RenderDirectiveMetadata>;
|
||||
styleAbsUrls: List<string>;
|
||||
styles: List<string>;
|
||||
encapsulation: ViewEncapsulation;
|
||||
@ -308,7 +308,7 @@ export class ViewDefinition {
|
||||
template?: string,
|
||||
styleAbsUrls?: List<string>,
|
||||
styles?: List<string>,
|
||||
directives?: List<DirectiveMetadata>,
|
||||
directives?: List<RenderDirectiveMetadata>,
|
||||
encapsulation?: ViewEncapsulation
|
||||
} = {}) {
|
||||
this.componentId = componentId;
|
||||
@ -348,7 +348,7 @@ export class RenderCompiler {
|
||||
/**
|
||||
* Creats a ProtoViewDto that contains a single nested component with the given componentId.
|
||||
*/
|
||||
compileHost(directiveMetadata: DirectiveMetadata): Promise<ProtoViewDto> { return null; }
|
||||
compileHost(directiveMetadata: RenderDirectiveMetadata): Promise<ProtoViewDto> { return null; }
|
||||
|
||||
/**
|
||||
* Compiles a single DomProtoView. Non recursive so that
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
ViewDefinition,
|
||||
ProtoViewDto,
|
||||
ViewType,
|
||||
DirectiveMetadata,
|
||||
RenderDirectiveMetadata,
|
||||
RenderCompiler,
|
||||
RenderProtoViewRef,
|
||||
RenderProtoViewMergeMapping,
|
||||
@ -50,7 +50,7 @@ export class DomCompiler extends RenderCompiler {
|
||||
});
|
||||
}
|
||||
|
||||
compileHost(directiveMetadata: DirectiveMetadata): Promise<ProtoViewDto> {
|
||||
compileHost(directiveMetadata: RenderDirectiveMetadata): Promise<ProtoViewDto> {
|
||||
let hostViewDef = new ViewDefinition({
|
||||
componentId: directiveMetadata.id,
|
||||
templateAbsUrl: null, template: null,
|
||||
|
@ -9,7 +9,7 @@ import {CompileStep} from './compile_step';
|
||||
import {CompileElement} from './compile_element';
|
||||
import {CompileControl} from './compile_control';
|
||||
|
||||
import {DirectiveMetadata} from '../../api';
|
||||
import {RenderDirectiveMetadata} from '../../api';
|
||||
import {dashCaseToCamelCase, camelCaseToDashCase, EVENT_TARGET_SEPARATOR} from '../util';
|
||||
import {DirectiveBuilder, ElementBinderBuilder} from '../view/proto_view_builder';
|
||||
|
||||
@ -20,7 +20,7 @@ import {DirectiveBuilder, ElementBinderBuilder} from '../view/proto_view_builder
|
||||
export class DirectiveParser implements CompileStep {
|
||||
_selectorMatcher: SelectorMatcher = new SelectorMatcher();
|
||||
|
||||
constructor(public _parser: Parser, public _directives: List<DirectiveMetadata>) {
|
||||
constructor(public _parser: Parser, public _directives: List<RenderDirectiveMetadata>) {
|
||||
for (var i = 0; i < _directives.length; i++) {
|
||||
var directive = _directives[i];
|
||||
var selector = CssSelector.parse(directive.selector);
|
||||
@ -48,7 +48,7 @@ export class DirectiveParser implements CompileStep {
|
||||
var directive = this._directives[directiveIndex];
|
||||
|
||||
elementBinder = current.bindElement();
|
||||
if (directive.type === DirectiveMetadata.COMPONENT_TYPE) {
|
||||
if (directive.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
|
||||
this._ensureHasOnlyOneComponent(elementBinder, current.elementDescription);
|
||||
|
||||
// components need to go first, so it is easier to locate them in the result.
|
||||
|
@ -1,12 +1,12 @@
|
||||
import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {isPresent, isArray} from 'angular2/src/facade/lang';
|
||||
import {DirectiveMetadata} from 'angular2/src/render/api';
|
||||
import {RenderDirectiveMetadata} from 'angular2/src/render/api';
|
||||
|
||||
/**
|
||||
* Converts a [DirectiveMetadata] to a map representation. This creates a copy,
|
||||
* that is, subsequent changes to `meta` will not be mirrored in the map.
|
||||
*/
|
||||
export function directiveMetadataToMap(meta: DirectiveMetadata): Map<string, any> {
|
||||
export function directiveMetadataToMap(meta: RenderDirectiveMetadata): Map<string, any> {
|
||||
return MapWrapper.createFromPairs([
|
||||
['id', meta.id],
|
||||
['selector', meta.selector],
|
||||
@ -35,8 +35,8 @@ export function directiveMetadataToMap(meta: DirectiveMetadata): Map<string, any
|
||||
* [DirectiveMetadata] object. This creates a copy, that is, subsequent changes
|
||||
* to `map` will not be mirrored in the [DirectiveMetadata] object.
|
||||
*/
|
||||
export function directiveMetadataFromMap(map: Map<string, any>): DirectiveMetadata {
|
||||
return new DirectiveMetadata({
|
||||
export function directiveMetadataFromMap(map: Map<string, any>): RenderDirectiveMetadata {
|
||||
return new RenderDirectiveMetadata({
|
||||
id:<string>map.get('id'),
|
||||
selector:<string>map.get('selector'),
|
||||
compileChildren:<boolean>map.get('compileChildren'),
|
||||
|
@ -23,7 +23,16 @@ import {DomElementBinder, Event, HostAction} from './element_binder';
|
||||
import {ElementSchemaRegistry} from '../schema/element_schema_registry';
|
||||
import {TemplateCloner} from '../template_cloner';
|
||||
|
||||
import * as api from '../../api';
|
||||
import {
|
||||
ViewType,
|
||||
ViewEncapsulation,
|
||||
ProtoViewDto,
|
||||
DirectiveBinder,
|
||||
RenderElementBinder,
|
||||
EventBinding,
|
||||
ElementPropertyBinding,
|
||||
PropertyBindingType
|
||||
} from '../../api';
|
||||
|
||||
import {
|
||||
NG_BINDING_CLASS,
|
||||
@ -39,8 +48,8 @@ export class ProtoViewBuilder {
|
||||
ngContentCount: number = 0;
|
||||
hostAttributes: Map<string, string> = new Map();
|
||||
|
||||
constructor(public rootElement, public type: api.ViewType,
|
||||
public viewEncapsulation: api.ViewEncapsulation) {}
|
||||
constructor(public rootElement, public type: ViewType,
|
||||
public viewEncapsulation: ViewEncapsulation) {}
|
||||
|
||||
bindElement(element: HTMLElement, description: string = null): ElementBinderBuilder {
|
||||
var builder = new ElementBinderBuilder(this.elements.length, element, description);
|
||||
@ -70,7 +79,7 @@ export class ProtoViewBuilder {
|
||||
|
||||
setHostAttribute(name: string, value: string) { this.hostAttributes.set(name, value); }
|
||||
|
||||
build(schemaRegistry: ElementSchemaRegistry, templateCloner: TemplateCloner): api.ProtoViewDto {
|
||||
build(schemaRegistry: ElementSchemaRegistry, templateCloner: TemplateCloner): ProtoViewDto {
|
||||
var domElementBinders = [];
|
||||
|
||||
var apiElementBinders = [];
|
||||
@ -89,7 +98,7 @@ export class ProtoViewBuilder {
|
||||
ebb.eventBuilder.merge(dbb.eventBuilder);
|
||||
ListWrapper.forEach(dbb.templatePropertyNames,
|
||||
(name) => directiveTemplatePropertyNames.add(name));
|
||||
return new api.DirectiveBinder({
|
||||
return new DirectiveBinder({
|
||||
directiveIndex: dbb.directiveIndex,
|
||||
propertyBindings: dbb.propertyBindings,
|
||||
eventBindings: dbb.eventBindings,
|
||||
@ -109,7 +118,7 @@ export class ProtoViewBuilder {
|
||||
textNodeExpressions.push(expression);
|
||||
textNodeIndices.push(nodeIndex);
|
||||
});
|
||||
apiElementBinders.push(new api.ElementBinder({
|
||||
apiElementBinders.push(new RenderElementBinder({
|
||||
index: ebb.index,
|
||||
parentIndex: parentIndex,
|
||||
distanceToParent: ebb.distanceToParent,
|
||||
@ -132,7 +141,7 @@ export class ProtoViewBuilder {
|
||||
}));
|
||||
});
|
||||
var rootNodeCount = DOM.childNodes(DOM.content(this.rootElement)).length;
|
||||
return new api.ProtoViewDto({
|
||||
return new ProtoViewDto({
|
||||
render: new DomProtoViewRef(DomProtoView.create(
|
||||
templateCloner, this.type, this.rootElement, this.viewEncapsulation, [rootNodeCount],
|
||||
rootTextNodeIndices, domElementBinders, this.hostAttributes)),
|
||||
@ -152,7 +161,7 @@ export class ElementBinderBuilder {
|
||||
nestedProtoView: ProtoViewBuilder = null;
|
||||
propertyBindings: Map<string, ASTWithSource> = new Map();
|
||||
variableBindings: Map<string, string> = new Map();
|
||||
eventBindings: List<api.EventBinding> = [];
|
||||
eventBindings: List<EventBinding> = [];
|
||||
eventBuilder: EventBuilder = new EventBuilder();
|
||||
textBindings: Map<Node, ASTWithSource> = new Map();
|
||||
readAttributes: Map<string, string> = new Map();
|
||||
@ -185,7 +194,7 @@ export class ElementBinderBuilder {
|
||||
throw new BaseException('Only one nested view per element is allowed');
|
||||
}
|
||||
this.nestedProtoView =
|
||||
new ProtoViewBuilder(rootElement, api.ViewType.EMBEDDED, api.ViewEncapsulation.NONE);
|
||||
new ProtoViewBuilder(rootElement, ViewType.EMBEDDED, ViewEncapsulation.NONE);
|
||||
return this.nestedProtoView;
|
||||
}
|
||||
|
||||
@ -230,7 +239,7 @@ export class DirectiveBuilder {
|
||||
// property names used in the template
|
||||
templatePropertyNames: List<string> = [];
|
||||
hostPropertyBindings: Map<string, ASTWithSource> = new Map();
|
||||
eventBindings: List<api.EventBinding> = [];
|
||||
eventBindings: List<EventBinding> = [];
|
||||
eventBuilder: EventBuilder = new EventBuilder();
|
||||
|
||||
constructor(public directiveIndex: number) {}
|
||||
@ -261,14 +270,14 @@ export class EventBuilder extends AstTransformer {
|
||||
|
||||
constructor() { super(); }
|
||||
|
||||
add(name: string, source: ASTWithSource, target: string): api.EventBinding {
|
||||
add(name: string, source: ASTWithSource, target: string): EventBinding {
|
||||
// TODO(tbosch): reenable this when we are parsing element properties
|
||||
// out of action expressions
|
||||
// var adjustedAst = astWithSource.ast.visit(this);
|
||||
var adjustedAst = source.ast;
|
||||
var fullName = isPresent(target) ? target + EVENT_TARGET_SEPARATOR + name : name;
|
||||
var result = new api.EventBinding(
|
||||
fullName, new ASTWithSource(adjustedAst, source.source, source.location));
|
||||
var result =
|
||||
new EventBinding(fullName, new ASTWithSource(adjustedAst, source.source, source.location));
|
||||
var event = new Event(name, target, fullName);
|
||||
if (isBlank(target)) {
|
||||
this.localEvents.push(event);
|
||||
@ -331,7 +340,7 @@ const STYLE_PREFIX = 'style';
|
||||
function buildElementPropertyBindings(
|
||||
schemaRegistry: ElementSchemaRegistry, protoElement: /*element*/ any, isNgComponent: boolean,
|
||||
bindingsInTemplate: Map<string, ASTWithSource>, directiveTemplatePropertyNames: Set<string>):
|
||||
List<api.ElementPropertyBinding> {
|
||||
List<ElementPropertyBinding> {
|
||||
var propertyBindings = [];
|
||||
|
||||
MapWrapper.forEach(bindingsInTemplate, (ast, propertyNameInTemplate) => {
|
||||
@ -361,8 +370,8 @@ function buildElementPropertyBindings(
|
||||
|
||||
function isValidElementPropertyBinding(schemaRegistry: ElementSchemaRegistry,
|
||||
protoElement: /*element*/ any, isNgComponent: boolean,
|
||||
binding: api.ElementPropertyBinding): boolean {
|
||||
if (binding.type === api.PropertyBindingType.PROPERTY) {
|
||||
binding: ElementPropertyBinding): boolean {
|
||||
if (binding.type === PropertyBindingType.PROPERTY) {
|
||||
if (!isNgComponent) {
|
||||
return schemaRegistry.hasProperty(protoElement, binding.property);
|
||||
} else {
|
||||
@ -374,19 +383,19 @@ function isValidElementPropertyBinding(schemaRegistry: ElementSchemaRegistry,
|
||||
}
|
||||
|
||||
function createElementPropertyBinding(schemaRegistry: ElementSchemaRegistry, ast: ASTWithSource,
|
||||
propertyNameInTemplate: string): api.ElementPropertyBinding {
|
||||
propertyNameInTemplate: string): ElementPropertyBinding {
|
||||
var parts = StringWrapper.split(propertyNameInTemplate, PROPERTY_PARTS_SEPARATOR);
|
||||
if (parts.length === 1) {
|
||||
var propName = schemaRegistry.getMappedPropName(parts[0]);
|
||||
return new api.ElementPropertyBinding(api.PropertyBindingType.PROPERTY, ast, propName);
|
||||
return new ElementPropertyBinding(PropertyBindingType.PROPERTY, ast, propName);
|
||||
} else if (parts[0] == ATTRIBUTE_PREFIX) {
|
||||
return new api.ElementPropertyBinding(api.PropertyBindingType.ATTRIBUTE, ast, parts[1]);
|
||||
return new ElementPropertyBinding(PropertyBindingType.ATTRIBUTE, ast, parts[1]);
|
||||
} else if (parts[0] == CLASS_PREFIX) {
|
||||
return new api.ElementPropertyBinding(api.PropertyBindingType.CLASS, ast,
|
||||
camelCaseToDashCase(parts[1]));
|
||||
return new ElementPropertyBinding(PropertyBindingType.CLASS, ast,
|
||||
camelCaseToDashCase(parts[1]));
|
||||
} else if (parts[0] == STYLE_PREFIX) {
|
||||
var unit = parts.length > 2 ? parts[2] : null;
|
||||
return new api.ElementPropertyBinding(api.PropertyBindingType.STYLE, ast, parts[1], unit);
|
||||
return new ElementPropertyBinding(PropertyBindingType.STYLE, ast, parts[1], unit);
|
||||
} else {
|
||||
throw new BaseException(`Invalid property name ${propertyNameInTemplate}`);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Directive} from 'angular2/src/core/annotations/decorators';
|
||||
import {Directive} from '../core/metadata';
|
||||
import {List, StringMap, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {Router} from './router';
|
||||
|
@ -2,7 +2,7 @@ import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {isBlank, isPresent} from 'angular2/src/facade/lang';
|
||||
|
||||
import {Directive, Attribute} from 'angular2/src/core/annotations/decorators';
|
||||
import {Directive, Attribute} from '../core/metadata';
|
||||
import {DynamicComponentLoader, ComponentRef, ElementRef} from 'angular2/core';
|
||||
import {Injector, bind, Dependency, UNDEFINED} from 'angular2/di';
|
||||
|
||||
|
@ -4,7 +4,7 @@ import {Type, isPresent, BaseException, isBlank} from 'angular2/src/facade/lang'
|
||||
import {Promise} from 'angular2/src/facade/async';
|
||||
import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||
import {ViewMetadata} from '../core/metadata';
|
||||
|
||||
import {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
|
||||
import {AppView} from 'angular2/src/core/compiler/view';
|
||||
@ -48,7 +48,7 @@ var _nextRootElementId = 0;
|
||||
@Injectable()
|
||||
export class TestComponentBuilder {
|
||||
_injector: Injector;
|
||||
_viewOverrides: Map<Type, View>;
|
||||
_viewOverrides: Map<Type, ViewMetadata>;
|
||||
_directiveOverrides: Map<Type, Map<Type, Type>>;
|
||||
_templateOverrides: Map<Type, string>;
|
||||
|
||||
@ -68,8 +68,8 @@ export class TestComponentBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides only the html of a {@link Component}.
|
||||
* All the other properties of the component's {@link View} are preserved.
|
||||
* Overrides only the html of a {@link ComponentMetadata}.
|
||||
* All the other properties of the component's {@link ViewMetadata} are preserved.
|
||||
*
|
||||
* @param {Type} component
|
||||
* @param {string} html
|
||||
@ -83,21 +83,21 @@ export class TestComponentBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides a component's {@link View}.
|
||||
* Overrides a component's {@link ViewMetadata}.
|
||||
*
|
||||
* @param {Type} component
|
||||
* @param {view} View
|
||||
*
|
||||
* @return {TestComponentBuilder}
|
||||
*/
|
||||
overrideView(componentType: Type, view: View): TestComponentBuilder {
|
||||
overrideView(componentType: Type, view: ViewMetadata): TestComponentBuilder {
|
||||
var clone = this._clone();
|
||||
clone._viewOverrides.set(componentType, view);
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the directives from the component {@link View}.
|
||||
* Overrides the directives from the component {@link ViewMetadata}.
|
||||
*
|
||||
* @param {Type} component
|
||||
* @param {Type} from
|
||||
|
@ -18,16 +18,11 @@ const INJECTABLES = const [
|
||||
];
|
||||
|
||||
const DIRECTIVES = const [
|
||||
const ClassDescriptor(
|
||||
'Directive', 'package:angular2/src/core/annotations/annotations.dart',
|
||||
const ClassDescriptor('Directive', 'package:angular2/src/core/metadatada/directive.dart',
|
||||
superClass: 'Injectable'),
|
||||
const ClassDescriptor(
|
||||
'Directive', 'package:angular2/src/core/annotations/decorators.dart',
|
||||
const ClassDescriptor('Directive', 'package:angular2/src/core/metadata.dart',
|
||||
superClass: 'Injectable'),
|
||||
const ClassDescriptor('Directive',
|
||||
'package:angular2/src/core/annotations_impl/annotations.dart',
|
||||
superClass: 'Injectable'),
|
||||
const ClassDescriptor('Directive', 'package:angular2/annotations.dart',
|
||||
const ClassDescriptor('Directive', 'package:angular2/metadata.dart',
|
||||
superClass: 'Injectable'),
|
||||
const ClassDescriptor('Directive', 'package:angular2/angular2.dart',
|
||||
superClass: 'Injectable'),
|
||||
@ -38,34 +33,26 @@ const DIRECTIVES = const [
|
||||
];
|
||||
|
||||
const COMPONENTS = const [
|
||||
const ClassDescriptor(
|
||||
'Component', 'package:angular2/src/core/annotations/annotations.dart',
|
||||
const ClassDescriptor('Component', 'package:angular2/src/core/metadata/directive.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor(
|
||||
'Component', 'package:angular2/src/core/annotations/decorators.dart',
|
||||
const ClassDescriptor('Component', 'package:angular2/src/core/metadata.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor('Component',
|
||||
'package:angular2/src/core/annotations_impl/annotations.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor('Component', 'package:angular2/annotations.dart',
|
||||
const ClassDescriptor('Component', 'package:angular2/metadata.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor('Component', 'package:angular2/angular2.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor('Component', 'package:angular2/bootstrap_static.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor('Component', 'package:angular2/core.dart',
|
||||
superClass: 'Directive'),
|
||||
superClass: '`Directive'),
|
||||
];
|
||||
|
||||
const VIEWS = const [
|
||||
const ClassDescriptor('View', 'package:angular2/view.dart'),
|
||||
const ClassDescriptor('View', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor('View', 'package:angular2/bootstrap_static.dart'),
|
||||
const ClassDescriptor('View', 'package:angular2/core.dart'),
|
||||
const ClassDescriptor(
|
||||
'View', 'package:angular2/src/core/annotations/view.dart'),
|
||||
const ClassDescriptor(
|
||||
'View', 'package:angular2/src/core/annotations_impl/view.dart'),
|
||||
const ClassDescriptor('View', 'package:angular2/src/core/metadata/view.dart'),
|
||||
const ClassDescriptor('View', 'package:angular2/src/core/metadata.dart'),
|
||||
];
|
||||
|
||||
/// Checks if a given [Annotation] matches any of the given
|
||||
|
@ -4,10 +4,10 @@ import 'package:analyzer/analyzer.dart';
|
||||
import 'package:analyzer/src/generated/element.dart';
|
||||
import 'package:angular2/src/render/api.dart';
|
||||
|
||||
/// Reads [DirectiveMetadata] from the `node`. `node` is expected to be an
|
||||
/// Reads [RenderDirectiveMetadata] from the `node`. `node` is expected to be an
|
||||
/// instance of [Annotation], [NodeList<Annotation>], ListLiteral, or
|
||||
/// [InstanceCreationExpression].
|
||||
DirectiveMetadata readDirectiveMetadata(dynamic node) {
|
||||
RenderDirectiveMetadata readDirectiveMetadata(dynamic node) {
|
||||
assert(node is Annotation ||
|
||||
node is NodeList ||
|
||||
node is InstanceCreationExpression ||
|
||||
@ -22,10 +22,10 @@ num _getDirectiveType(String annotationName, Element element) {
|
||||
// TODO(kegluneq): Detect subtypes & implementations of `Directive`s.
|
||||
switch (annotationName) {
|
||||
case 'Directive':
|
||||
byNameMatch = DirectiveMetadata.DIRECTIVE_TYPE;
|
||||
byNameMatch = RenderDirectiveMetadata.DIRECTIVE_TYPE;
|
||||
break;
|
||||
case 'Component':
|
||||
byNameMatch = DirectiveMetadata.COMPONENT_TYPE;
|
||||
byNameMatch = RenderDirectiveMetadata.COMPONENT_TYPE;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
@ -34,8 +34,8 @@ num _getDirectiveType(String annotationName, Element element) {
|
||||
var byResolvedAst = -1;
|
||||
var libName = element.library.name;
|
||||
// If we have resolved, ensure the library is correct.
|
||||
if (libName == 'angular2.src.core.annotations.annotations' ||
|
||||
libName == 'angular2.src.core.annotations_impl.annotations') {
|
||||
if (libName == 'angular2.src.core.metadata.directives' ||
|
||||
libName == 'angular2.src.core.metadata') {
|
||||
byResolvedAst = byNameMatch;
|
||||
}
|
||||
// TODO(kegluneq): @keertip, can we expose this as a warning?
|
||||
@ -45,7 +45,7 @@ num _getDirectiveType(String annotationName, Element element) {
|
||||
}
|
||||
|
||||
/// Visitor responsible for processing the `annotations` property of a
|
||||
/// [RegisterType] object and pulling out [DirectiveMetadata].
|
||||
/// [RegisterType] object and pulling out [RenderDirectiveMetadata].
|
||||
class _DirectiveMetadataVisitor extends Object
|
||||
with RecursiveAstVisitor<Object> {
|
||||
bool get _hasMeta => _type != null;
|
||||
@ -87,7 +87,7 @@ class _DirectiveMetadataVisitor extends Object
|
||||
_events = [];
|
||||
}
|
||||
|
||||
DirectiveMetadata get meta => DirectiveMetadata.create(
|
||||
RenderDirectiveMetadata get meta => RenderDirectiveMetadata.create(
|
||||
type: _type,
|
||||
selector: _selector,
|
||||
compileChildren: _compileChildren,
|
||||
|
@ -11,32 +11,32 @@ export 'class_matcher_base.dart' show ClassDescriptor;
|
||||
/// covers all libraries which provide them.
|
||||
const _ON_CHANGE_INTERFACES = const [
|
||||
const ClassDescriptor('OnChange', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor('OnChange', 'package:angular2/annotations.dart'),
|
||||
const ClassDescriptor('OnChange', 'package:angular2/metadata.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnChange', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||
];
|
||||
const _ON_DESTROY_INTERFACES = const [
|
||||
const ClassDescriptor('OnDestroy', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor('OnDestroy', 'package:angular2/annotations.dart'),
|
||||
const ClassDescriptor('OnDestroy', 'package:angular2/metadata.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnDestroy', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||
];
|
||||
const _ON_CHECK_INTERFACES = const [
|
||||
const ClassDescriptor('OnCheck', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor('OnCheck', 'package:angular2/annotations.dart'),
|
||||
const ClassDescriptor('OnCheck', 'package:angular2/metadata.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnCheck', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||
];
|
||||
const _ON_INIT_INTERFACES = const [
|
||||
const ClassDescriptor('OnInit', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor('OnInit', 'package:angular2/annotations.dart'),
|
||||
const ClassDescriptor('OnInit', 'package:angular2/metadata.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnInit', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||
];
|
||||
const _ON_ALL_CHANGES_DONE_INTERFACES = const [
|
||||
const ClassDescriptor('OnAllChangesDone', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnAllChangesDone', 'package:angular2/annotations.dart'),
|
||||
'OnAllChangesDone', 'package:angular2/metadata.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnAllChangesDone', 'package:angular2/src/core/compiler/interfaces.dart')
|
||||
];
|
||||
|
@ -20,7 +20,7 @@ import 'logging.dart';
|
||||
/// easier.
|
||||
class NgMeta {
|
||||
/// Directive metadata for each type annotated as a directive.
|
||||
final Map<String, DirectiveMetadata> types;
|
||||
final Map<String, RenderDirectiveMetadata> types;
|
||||
|
||||
/// List of other types and names associated with a given name.
|
||||
final Map<String, List<String>> aliases;
|
||||
@ -66,7 +66,7 @@ class NgMeta {
|
||||
}
|
||||
|
||||
/// Returns the metadata for every type associated with the given [alias].
|
||||
List<DirectiveMetadata> flatten(String alias) {
|
||||
List<RenderDirectiveMetadata> flatten(String alias) {
|
||||
var result = [];
|
||||
var seen = new Set();
|
||||
helper(name) {
|
||||
|
@ -23,7 +23,7 @@ class RegisteredType {
|
||||
/// The annotations registered.
|
||||
final Expression annotations;
|
||||
|
||||
DirectiveMetadata _directiveMetadata = null;
|
||||
RenderDirectiveMetadata _directiveMetadata = null;
|
||||
|
||||
RegisteredType._(this.typeName, this.registerMethod, this.factoryFn,
|
||||
this.parameters, this.annotations);
|
||||
@ -37,7 +37,7 @@ class RegisteredType {
|
||||
visitor.factoryFn, visitor.parameters, visitor.annotations);
|
||||
}
|
||||
|
||||
DirectiveMetadata get directiveMetadata {
|
||||
RenderDirectiveMetadata get directiveMetadata {
|
||||
if (_directiveMetadata == null) {
|
||||
try {
|
||||
_directiveMetadata = readDirectiveMetadata(annotations);
|
||||
|
@ -3,7 +3,7 @@ library angular2.transform.directive_processor.visitors;
|
||||
import 'dart:async';
|
||||
import 'package:analyzer/analyzer.dart';
|
||||
import 'package:analyzer/src/generated/java_core.dart';
|
||||
import 'package:angular2/annotations.dart' show LifecycleEvent;
|
||||
import 'package:angular2/metadata.dart' show LifecycleEvent;
|
||||
import 'package:angular2/src/render/xhr.dart' show XHR;
|
||||
import 'package:angular2/src/transform/common/annotation_matcher.dart';
|
||||
import 'package:angular2/src/transform/common/async_string_writer.dart';
|
||||
|
@ -27,7 +27,7 @@ class ViewDefinitionResults {
|
||||
}
|
||||
|
||||
class ViewDefinitionEntry {
|
||||
final DirectiveMetadata hostMetadata;
|
||||
final RenderDirectiveMetadata hostMetadata;
|
||||
final ViewDefinition viewDef;
|
||||
|
||||
ViewDefinitionEntry._(this.hostMetadata, this.viewDef);
|
||||
@ -113,7 +113,7 @@ class _ViewDefinitionCreator {
|
||||
|
||||
/// Reads the `.ng_meta.json` files associated with all of `entryPoint`'s
|
||||
/// imports and creates a map `Type` name, prefixed if appropriate to the
|
||||
/// associated [DirectiveMetadata].
|
||||
/// associated [RenderDirectiveMetadata].
|
||||
///
|
||||
/// For example, if in `entryPoint` we have:
|
||||
///
|
||||
@ -129,13 +129,13 @@ class _ViewDefinitionCreator {
|
||||
/// ```
|
||||
///
|
||||
/// This method will look for `component.ng_meta.json`to contain the
|
||||
/// serialized [DirectiveMetadata] for `MyComponent` and any other
|
||||
/// serialized [RenderDirectiveMetadata] for `MyComponent` and any other
|
||||
/// `Directive`s declared in `component.dart`. We use this information to
|
||||
/// build a map:
|
||||
///
|
||||
/// ```
|
||||
/// {
|
||||
/// "prefix.MyComponent": [DirectiveMetadata for MyComponent],
|
||||
/// "prefix.MyComponent": [RenderDirectiveMetadata for MyComponent],
|
||||
/// ...<any other entries>...
|
||||
/// }
|
||||
/// ```
|
||||
@ -184,7 +184,7 @@ class _TemplateExtractVisitor extends Object with RecursiveAstVisitor<Object> {
|
||||
@override
|
||||
Object visitInstanceCreationExpression(InstanceCreationExpression node) {
|
||||
if (_isViewAnnotation(node)) {
|
||||
viewDef = new ViewDefinition(directives: <DirectiveMetadata>[]);
|
||||
viewDef = new ViewDefinition(directives: <RenderDirectiveMetadata>[]);
|
||||
node.visitChildren(this);
|
||||
}
|
||||
return null;
|
||||
|
@ -1 +1 @@
|
||||
library util_decorators;
|
||||
library angular2.core.util.decorators;
|
||||
|
@ -53,7 +53,7 @@ export interface TypeDecorator {
|
||||
// ParameterDecorator is declared in lib.d.ts as a `declare type`
|
||||
// so we cannot declare this interface as a subtype.
|
||||
// see https://github.com/angular/angular/issues/3379#issuecomment-126169417
|
||||
(target: Object, propertyKey: string | symbol, parameterIndex: number): void;
|
||||
(target: Object, propertyKey?: string | symbol, parameterIndex?: number): void;
|
||||
|
||||
/**
|
||||
* Storage for the accumulated annotations so far used by the DSL syntax.
|
||||
|
@ -16,8 +16,8 @@ import {
|
||||
} from "angular2/src/facade/collection";
|
||||
import {
|
||||
ProtoViewDto,
|
||||
DirectiveMetadata,
|
||||
ElementBinder,
|
||||
RenderDirectiveMetadata,
|
||||
RenderElementBinder,
|
||||
DirectiveBinder,
|
||||
ElementPropertyBinding,
|
||||
EventBinding,
|
||||
@ -85,9 +85,9 @@ export class Serializer {
|
||||
return this._serializeDirectiveBinder(obj);
|
||||
} else if (type == ProtoViewDto) {
|
||||
return this._serializeProtoViewDto(obj);
|
||||
} else if (type == ElementBinder) {
|
||||
} else if (type == RenderElementBinder) {
|
||||
return this._serializeElementBinder(obj);
|
||||
} else if (type == DirectiveMetadata) {
|
||||
} else if (type == RenderDirectiveMetadata) {
|
||||
return this._serializeDirectiveMetadata(obj);
|
||||
} else if (type == ASTWithSource) {
|
||||
return this._serializeASTWithSource(obj);
|
||||
@ -129,9 +129,9 @@ export class Serializer {
|
||||
return this._deserializeDirectiveBinder(map);
|
||||
} else if (type == ProtoViewDto) {
|
||||
return this._deserializeProtoViewDto(map);
|
||||
} else if (type == DirectiveMetadata) {
|
||||
} else if (type == RenderDirectiveMetadata) {
|
||||
return this._deserializeDirectiveMetadata(map);
|
||||
} else if (type == ElementBinder) {
|
||||
} else if (type == RenderElementBinder) {
|
||||
return this._deserializeElementBinder(map);
|
||||
} else if (type == ASTWithSource) {
|
||||
return this._deserializeASTWithSource(map, data);
|
||||
@ -271,7 +271,7 @@ export class Serializer {
|
||||
'componentId': view.componentId,
|
||||
'templateAbsUrl': view.templateAbsUrl,
|
||||
'template': view.template,
|
||||
'directives': this.serialize(view.directives, DirectiveMetadata),
|
||||
'directives': this.serialize(view.directives, RenderDirectiveMetadata),
|
||||
'styleAbsUrls': view.styleAbsUrls,
|
||||
'styles': view.styles,
|
||||
'encapsulation': serializeEnum(view.encapsulation)
|
||||
@ -282,7 +282,7 @@ export class Serializer {
|
||||
return new ViewDefinition({
|
||||
componentId: obj['componentId'],
|
||||
templateAbsUrl: obj['templateAbsUrl'], template: obj['template'],
|
||||
directives: this.deserialize(obj['directives'], DirectiveMetadata),
|
||||
directives: this.deserialize(obj['directives'], RenderDirectiveMetadata),
|
||||
styleAbsUrls: obj['styleAbsUrls'],
|
||||
styles: obj['styles'],
|
||||
encapsulation:
|
||||
@ -308,7 +308,7 @@ export class Serializer {
|
||||
});
|
||||
}
|
||||
|
||||
private _serializeElementBinder(binder: ElementBinder): Object {
|
||||
private _serializeElementBinder(binder: RenderElementBinder): Object {
|
||||
return {
|
||||
'index': binder.index,
|
||||
'parentIndex': binder.parentIndex,
|
||||
@ -322,8 +322,8 @@ export class Serializer {
|
||||
};
|
||||
}
|
||||
|
||||
private _deserializeElementBinder(obj: StringMap<string, any>): ElementBinder {
|
||||
return new ElementBinder({
|
||||
private _deserializeElementBinder(obj: StringMap<string, any>): RenderElementBinder {
|
||||
return new RenderElementBinder({
|
||||
index: obj['index'],
|
||||
parentIndex: obj['parentIndex'],
|
||||
distanceToParent: obj['distanceToParent'],
|
||||
@ -339,7 +339,7 @@ export class Serializer {
|
||||
private _serializeProtoViewDto(view: ProtoViewDto): Object {
|
||||
return {
|
||||
'render': this._protoViewStore.serialize(view.render),
|
||||
'elementBinders': this.serialize(view.elementBinders, ElementBinder),
|
||||
'elementBinders': this.serialize(view.elementBinders, RenderElementBinder),
|
||||
'variableBindings': this.mapToObject(view.variableBindings),
|
||||
'type': serializeEnum(view.type),
|
||||
'textBindings': this.serialize(view.textBindings, ASTWithSource),
|
||||
@ -350,7 +350,7 @@ export class Serializer {
|
||||
private _deserializeProtoViewDto(obj: StringMap<string, any>): ProtoViewDto {
|
||||
return new ProtoViewDto({
|
||||
render: this._protoViewStore.deserialize(obj["render"]),
|
||||
elementBinders: this.deserialize(obj['elementBinders'], ElementBinder),
|
||||
elementBinders: this.deserialize(obj['elementBinders'], RenderElementBinder),
|
||||
variableBindings: this.objectToMap(obj['variableBindings']),
|
||||
textBindings: this.deserialize(obj['textBindings'], ASTWithSource, "interpolation"),
|
||||
type: deserializeEnum(obj['type'], this._enumRegistry.get(ViewType)),
|
||||
@ -358,7 +358,7 @@ export class Serializer {
|
||||
});
|
||||
}
|
||||
|
||||
private _serializeDirectiveMetadata(meta: DirectiveMetadata): Object {
|
||||
private _serializeDirectiveMetadata(meta: RenderDirectiveMetadata): Object {
|
||||
var obj = {
|
||||
'id': meta.id,
|
||||
'selector': meta.selector,
|
||||
@ -381,8 +381,8 @@ export class Serializer {
|
||||
};
|
||||
return obj;
|
||||
}
|
||||
private _deserializeDirectiveMetadata(obj: StringMap<string, any>): DirectiveMetadata {
|
||||
return new DirectiveMetadata({
|
||||
private _deserializeDirectiveMetadata(obj: StringMap<string, any>): RenderDirectiveMetadata {
|
||||
return new RenderDirectiveMetadata({
|
||||
id: obj['id'],
|
||||
selector: obj['selector'],
|
||||
compileChildren: obj['compileChildren'],
|
||||
|
@ -9,7 +9,7 @@ import {createInjector} from "./di_bindings";
|
||||
import {
|
||||
Renderer,
|
||||
RenderCompiler,
|
||||
DirectiveMetadata,
|
||||
RenderDirectiveMetadata,
|
||||
ProtoViewDto,
|
||||
ViewDefinition,
|
||||
RenderProtoViewRef,
|
||||
@ -94,7 +94,7 @@ export class WebWorkerMain {
|
||||
var promise: Promise<any>;
|
||||
switch (data.method) {
|
||||
case "compileHost":
|
||||
var directiveMetadata = this._serializer.deserialize(data.args[0], DirectiveMetadata);
|
||||
var directiveMetadata = this._serializer.deserialize(data.args[0], RenderDirectiveMetadata);
|
||||
promise = this._renderCompiler.compileHost(directiveMetadata);
|
||||
this._wrapWebWorkerPromise(data.id, promise, ProtoViewDto);
|
||||
break;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {
|
||||
Renderer,
|
||||
RenderCompiler,
|
||||
DirectiveMetadata,
|
||||
RenderDirectiveMetadata,
|
||||
ProtoViewDto,
|
||||
ViewDefinition,
|
||||
RenderProtoViewRef,
|
||||
@ -28,8 +28,8 @@ export class WebWorkerCompiler implements RenderCompiler {
|
||||
/**
|
||||
* Creats a ProtoViewDto that contains a single nested component with the given componentId.
|
||||
*/
|
||||
compileHost(directiveMetadata: DirectiveMetadata): Promise<ProtoViewDto> {
|
||||
var fnArgs: List<FnArg> = [new FnArg(directiveMetadata, DirectiveMetadata)];
|
||||
compileHost(directiveMetadata: RenderDirectiveMetadata): Promise<ProtoViewDto> {
|
||||
var fnArgs: List<FnArg> = [new FnArg(directiveMetadata, RenderDirectiveMetadata)];
|
||||
var args: UiArguments = new UiArguments("compiler", "compileHost", fnArgs);
|
||||
return this._messageBroker.runOnUiThread(args, ProtoViewDto);
|
||||
}
|
||||
|
Reference in New Issue
Block a user