import { ListWrapper, MapWrapper, Map, StringMapWrapper, List, StringMap } from 'angular2/src/facade/collection'; import { AST, BindingRecord, ChangeDetector, ChangeDetectorRef, ChangeDispatcher, DirectiveIndex, DirectiveRecord, Locals, ProtoChangeDetector } from 'angular2/src/change_detection/change_detection'; import {DebugContext} from 'angular2/src/change_detection/interfaces'; import { ProtoElementInjector, ElementInjector, PreBuiltObjects, DirectiveBinding } from './element_injector'; import {ElementBinder} from './element_binder'; import {isPresent, isBlank, BaseException} from 'angular2/src/facade/lang'; import * as renderApi from 'angular2/src/render/api'; import {RenderEventDispatcher} from 'angular2/src/render/api'; import {ViewRef, ProtoViewRef, internalView} from './view_ref'; import {ElementRef} from './element_ref'; import {ProtoPipes} from 'angular2/src/core/pipes/pipes'; export {DebugContext} from 'angular2/src/change_detection/interfaces'; export class AppProtoViewMergeMapping { renderProtoViewRef: renderApi.RenderProtoViewRef; renderFragmentCount: number; renderElementIndices: number[]; renderInverseElementIndices: number[]; renderTextIndices: number[]; nestedViewIndicesByElementIndex: number[]; hostElementIndicesByViewIndex: number[]; nestedViewCountByViewIndex: number[]; constructor(renderProtoViewMergeMapping: renderApi.RenderProtoViewMergeMapping) { this.renderProtoViewRef = renderProtoViewMergeMapping.mergedProtoViewRef; this.renderFragmentCount = renderProtoViewMergeMapping.fragmentCount; this.renderElementIndices = renderProtoViewMergeMapping.mappedElementIndices; this.renderInverseElementIndices = inverseIndexMapping( this.renderElementIndices, renderProtoViewMergeMapping.mappedElementCount); this.renderTextIndices = renderProtoViewMergeMapping.mappedTextIndices; this.hostElementIndicesByViewIndex = renderProtoViewMergeMapping.hostElementIndicesByViewIndex; this.nestedViewIndicesByElementIndex = inverseIndexMapping(this.hostElementIndicesByViewIndex, this.renderElementIndices.length); this.nestedViewCountByViewIndex = renderProtoViewMergeMapping.nestedViewCountByViewIndex; } } function inverseIndexMapping(input: number[], resultLength: number): number[] { var result = ListWrapper.createGrowableSize(resultLength); for (var i = 0; i < input.length; i++) { var value = input[i]; if (isPresent(value)) { result[input[i]] = i; } } return result; } export class AppViewContainer { // The order in this list matches the DOM order. views: List = []; } /** * Cost of making objects: http://jsperf.com/instantiate-size-of-object * */ export class AppView implements ChangeDispatcher, RenderEventDispatcher { // AppViews that have been merged in depth first order. // This list is shared between all merged views. Use this.elementOffset to get the local // entries. views: List = null; // root elementInjectors of this AppView // This list is local to this AppView and not shared with other Views. rootElementInjectors: List; // ElementInjectors of all AppViews in views grouped by view. // This list is shared between all merged views. Use this.elementOffset to get the local // entries. elementInjectors: List = null; // ViewContainers of all AppViews in views grouped by view. // This list is shared between all merged views. Use this.elementOffset to get the local // entries. viewContainers: List = null; // PreBuiltObjects of all AppViews in views grouped by view. // This list is shared between all merged views. Use this.elementOffset to get the local // entries. preBuiltObjects: List = null; // ElementRef of all AppViews in views grouped by view. // This list is shared between all merged views. Use this.elementOffset to get the local // entries. elementRefs: List; ref: ViewRef; changeDetector: ChangeDetector = null; /** * The context against which data-binding expressions in this view are evaluated against. * This is always a component instance. */ context: any = null; /** * Variables, local to this view, that can be used in binding expressions (in addition to the * context). This is used for thing like `