import {isPresent, isBlank, RegExpWrapper} from 'angular2/src/facade/lang'; import {Promise} from 'angular2/src/facade/async'; import {List, Map, MapWrapper, StringMap, StringMapWrapper} from 'angular2/src/facade/collection'; import {ASTWithSource} from 'angular2/change_detection'; /** * General notes: * * The methods for creating / destroying views in this API are used in the AppViewHydrator * and RenderViewHydrator as well. * * We are already parsing expressions on the render side: * - this makes the ElementBinders more compact * (e.g. no need to distinguish interpolations from regular expressions from literals) * - allows to retrieve which properties should be accessed from the event * by looking at the expression * - we need the parse at least for the `template` attribute to match * directives in it * - render compiler is not on the critical path as * its output will be stored in precompiled templates. */ export class EventBinding { constructor(public fullName: string, public source: ASTWithSource) {} } export class ElementBinder { index: number; parentIndex: number; distanceToParent: number; directives: List; nestedProtoView: ProtoViewDto; propertyBindings: Map; variableBindings: Map; // Note: this contains a preprocessed AST // that replaced the values that should be extracted from the element // with a local name eventBindings: List; textBindings: List; readAttributes: Map; constructor({index, parentIndex, distanceToParent, directives, nestedProtoView, propertyBindings, variableBindings, eventBindings, textBindings, readAttributes}: { index?: number, parentIndex?: number, distanceToParent?: number, directives?: List, nestedProtoView?: ProtoViewDto, propertyBindings?: Map, variableBindings?: Map, eventBindings?: List, textBindings?: List, readAttributes?: Map } = {}) { this.index = index; this.parentIndex = parentIndex; this.distanceToParent = distanceToParent; this.directives = directives; this.nestedProtoView = nestedProtoView; this.propertyBindings = propertyBindings; this.variableBindings = variableBindings; this.eventBindings = eventBindings; this.textBindings = textBindings; this.readAttributes = readAttributes; } } export class DirectiveBinder { // Index into the array of directives in the View instance directiveIndex: number; propertyBindings: Map; // Note: this contains a preprocessed AST // that replaced the values that should be extracted from the element // with a local name eventBindings: List; hostPropertyBindings: Map; constructor({directiveIndex, propertyBindings, eventBindings, hostPropertyBindings}: { directiveIndex?: number, propertyBindings?: Map, eventBindings?: List, hostPropertyBindings?: Map }) { this.directiveIndex = directiveIndex; this.propertyBindings = propertyBindings; this.eventBindings = eventBindings; this.hostPropertyBindings = hostPropertyBindings; } } export enum ViewType { // A view that contains the host element with bound component directive. // Contains a COMPONENT view HOST, // The view of the component // Can contain 0 to n EMBEDDED views COMPONENT, // A view that is embedded into another View via a