Socket
Socket
Sign inDemoInstall

@angular/compiler

Package Overview
Dependencies
Maintainers
1
Versions
843
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angular/compiler - npm Package Compare versions

Comparing version 0.0.0-0 to 0.0.0-1

esm/src/metadata_resolver.d.ts

15

core_private.d.ts

@@ -16,2 +16,4 @@ import { __core_private_types__ as t } from '@angular/core';

export declare var AppView: typeof t.AppView;
export declare type DebugAppView<T> = t.DebugAppView<T>;
export declare var DebugAppView: typeof t.DebugAppView;
export declare type ViewType = t.ViewType;

@@ -35,1 +37,14 @@ export declare var ViewType: typeof t.ViewType;

export declare var isProviderLiteral: typeof t.isProviderLiteral;
export declare var pureProxy1: typeof t.pureProxy1;
export declare var pureProxy2: typeof t.pureProxy2;
export declare var pureProxy3: typeof t.pureProxy3;
export declare var pureProxy4: typeof t.pureProxy4;
export declare var pureProxy5: typeof t.pureProxy5;
export declare var pureProxy6: typeof t.pureProxy6;
export declare var pureProxy7: typeof t.pureProxy7;
export declare var pureProxy8: typeof t.pureProxy8;
export declare var pureProxy9: typeof t.pureProxy9;
export declare var pureProxy10: typeof t.pureProxy10;
export declare var castByValue: typeof t.castByValue;
export declare type Console = t.Console;
export declare var Console: typeof t.Console;

@@ -13,2 +13,3 @@ "use strict";

exports.AppView = core_1.__core_private__.AppView;
exports.DebugAppView = core_1.__core_private__.DebugAppView;
exports.ViewType = core_1.__core_private__.ViewType;

@@ -30,2 +31,14 @@ exports.MAX_INTERPOLATION_VALUES = core_1.__core_private__.MAX_INTERPOLATION_VALUES;

exports.isProviderLiteral = core_1.__core_private__.isProviderLiteral;
exports.pureProxy1 = core_1.__core_private__.pureProxy1;
exports.pureProxy2 = core_1.__core_private__.pureProxy2;
exports.pureProxy3 = core_1.__core_private__.pureProxy3;
exports.pureProxy4 = core_1.__core_private__.pureProxy4;
exports.pureProxy5 = core_1.__core_private__.pureProxy5;
exports.pureProxy6 = core_1.__core_private__.pureProxy6;
exports.pureProxy7 = core_1.__core_private__.pureProxy7;
exports.pureProxy8 = core_1.__core_private__.pureProxy8;
exports.pureProxy9 = core_1.__core_private__.pureProxy9;
exports.pureProxy10 = core_1.__core_private__.pureProxy10;
exports.castByValue = core_1.__core_private__.castByValue;
exports.Console = core_1.__core_private__.Console;
//# sourceMappingURL=core_private.js.map

@@ -16,2 +16,4 @@ import { __core_private_types__ as t } from '@angular/core';

export declare var AppView: typeof t.AppView;
export declare type DebugAppView<T> = t.DebugAppView<T>;
export declare var DebugAppView: typeof t.DebugAppView;
export declare type ViewType = t.ViewType;

@@ -35,1 +37,14 @@ export declare var ViewType: typeof t.ViewType;

export declare var isProviderLiteral: typeof t.isProviderLiteral;
export declare var pureProxy1: typeof t.pureProxy1;
export declare var pureProxy2: typeof t.pureProxy2;
export declare var pureProxy3: typeof t.pureProxy3;
export declare var pureProxy4: typeof t.pureProxy4;
export declare var pureProxy5: typeof t.pureProxy5;
export declare var pureProxy6: typeof t.pureProxy6;
export declare var pureProxy7: typeof t.pureProxy7;
export declare var pureProxy8: typeof t.pureProxy8;
export declare var pureProxy9: typeof t.pureProxy9;
export declare var pureProxy10: typeof t.pureProxy10;
export declare var castByValue: typeof t.castByValue;
export declare type Console = t.Console;
export declare var Console: typeof t.Console;

@@ -12,2 +12,3 @@ import { __core_private__ as r } from '@angular/core';

export var AppView = r.AppView;
export var DebugAppView = r.DebugAppView;
export var ViewType = r.ViewType;

@@ -29,2 +30,14 @@ export var MAX_INTERPOLATION_VALUES = r.MAX_INTERPOLATION_VALUES;

export var isProviderLiteral = r.isProviderLiteral;
export var pureProxy1 = r.pureProxy1;
export var pureProxy2 = r.pureProxy2;
export var pureProxy3 = r.pureProxy3;
export var pureProxy4 = r.pureProxy4;
export var pureProxy5 = r.pureProxy5;
export var pureProxy6 = r.pureProxy6;
export var pureProxy7 = r.pureProxy7;
export var pureProxy8 = r.pureProxy8;
export var pureProxy9 = r.pureProxy9;
export var pureProxy10 = r.pureProxy10;
export var castByValue = r.castByValue;
export var Console = r.Console;
//# sourceMappingURL=core_private.js.map

4

esm/src/compile_metadata.d.ts

@@ -205,3 +205,4 @@ import { ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';

ngContentSelectors: string[];
constructor({encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors}?: {
baseUrl: string;
constructor({encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors, baseUrl}?: {
encapsulation?: ViewEncapsulation;

@@ -213,2 +214,3 @@ template?: string;

ngContentSelectors?: string[];
baseUrl?: string;
});

@@ -215,0 +217,0 @@ static fromJson(data: {

@@ -306,3 +306,3 @@ import { ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';

export class CompileTemplateMetadata {
constructor({ encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors } = {}) {
constructor({ encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors, baseUrl } = {}) {
this.encapsulation = isPresent(encapsulation) ? encapsulation : ViewEncapsulation.Emulated;

@@ -314,2 +314,3 @@ this.template = template;

this.ngContentSelectors = isPresent(ngContentSelectors) ? ngContentSelectors : [];
this.baseUrl = baseUrl;
}

@@ -325,3 +326,4 @@ static fromJson(data) {

styleUrls: data['styleUrls'],
ngContentSelectors: data['ngContentSelectors']
ngContentSelectors: data['ngContentSelectors'],
baseUrl: data['baseUrl']
});

@@ -336,3 +338,4 @@ }

'styleUrls': this.styleUrls,
'ngContentSelectors': this.ngContentSelectors
'ngContentSelectors': this.ngContentSelectors,
'baseUrl': this.baseUrl
};

@@ -339,0 +342,0 @@ }

@@ -17,3 +17,3 @@ import { ComponentResolver } from '@angular/core';

import { DirectiveNormalizer } from './directive_normalizer';
import { RuntimeMetadataResolver } from './runtime_metadata';
import { CompileMetadataResolver } from './metadata_resolver';
import { StyleCompiler } from './style_compiler';

@@ -44,3 +44,3 @@ import { ViewCompiler } from './view_compiler/view_compiler';

DirectiveNormalizer,
RuntimeMetadataResolver,
CompileMetadataResolver,
DEFAULT_PACKAGE_URL_PROVIDER,

@@ -59,6 +59,2 @@ StyleCompiler,

];
// CONST_EXPR
// /* @const */
// /* @Provider */ ({provide: CompilerConfig, useFactory: _createCompilerConfig, deps: []}),
// const Provider(CompilerConfig, {useFactory: _createCompilerConfig, deps: []}),
//# sourceMappingURL=compiler.js.map

@@ -54,6 +54,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

if (isPresent(template.template)) {
return PromiseWrapper.resolve(this.normalizeLoadedTemplate(directiveType, template, template.template, directiveType.moduleUrl));
return PromiseWrapper.resolve(this.normalizeLoadedTemplate(directiveType, template, template.template, template.baseUrl));
}
else if (isPresent(template.templateUrl)) {
var sourceAbsUrl = this._urlResolver.resolve(directiveType.moduleUrl, template.templateUrl);
var sourceAbsUrl = this._urlResolver.resolve(template.baseUrl, template.templateUrl);
return this._xhr.get(sourceAbsUrl)

@@ -78,3 +78,3 @@ .then(templateContent => this.normalizeLoadedTemplate(directiveType, template, templateContent, sourceAbsUrl));

.concat(templateMeta.styleUrls.filter(isStyleUrlResolvable)
.map(url => this._urlResolver.resolve(directiveType.moduleUrl, url)));
.map(url => this._urlResolver.resolve(templateMeta.baseUrl, url)));
var allResolvedStyles = allStyles.map(style => {

@@ -81,0 +81,0 @@ var styleWithImports = extractStyleUrls(this._urlResolver, templateAbsUrl, style);

@@ -25,3 +25,4 @@ import { BaseException } from '../../src/facade/exceptions';

isKeyword(): boolean;
isKeywordVar(): boolean;
isKeywordDeprecatedVar(): boolean;
isKeywordLet(): boolean;
isKeywordNull(): boolean;

@@ -28,0 +29,0 @@ isKeywordUndefined(): boolean;

@@ -56,3 +56,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

isKeyword() { return (this.type == TokenType.Keyword); }
isKeywordVar() { return (this.type == TokenType.Keyword && this.strValue == "var"); }
isKeywordDeprecatedVar() {
return (this.type == TokenType.Keyword && this.strValue == "var");
}
isKeywordLet() { return (this.type == TokenType.Keyword && this.strValue == "let"); }
isKeywordNull() { return (this.type == TokenType.Keyword && this.strValue == "null"); }

@@ -437,3 +440,3 @@ isKeywordUndefined() {

]);
var KEYWORDS = SetWrapper.createFromList(['var', 'null', 'undefined', 'true', 'false', 'if', 'else']);
var KEYWORDS = SetWrapper.createFromList(['var', 'let', 'null', 'undefined', 'true', 'false', 'if', 'else']);
//# sourceMappingURL=lexer.js.map

@@ -8,2 +8,7 @@ import { Lexer, Token } from './lexer';

}
export declare class TemplateBindingParseResult {
templateBindings: TemplateBinding[];
warnings: string[];
constructor(templateBindings: TemplateBinding[], warnings: string[]);
}
export declare class Parser {

@@ -17,3 +22,3 @@ /** @internal */ _lexer: Lexer;

private _parseQuote(input, location);
parseTemplateBindings(input: string, location: any): TemplateBinding[];
parseTemplateBindings(input: string, location: any): TemplateBindingParseResult;
parseInterpolation(input: string, location: any): ASTWithSource;

@@ -39,4 +44,5 @@ splitInterpolation(input: string, location: string): SplitInterpolation;

optionalCharacter(code: number): boolean;
optionalKeywordVar(): boolean;
peekKeywordVar(): boolean;
peekKeywordLet(): boolean;
peekDeprecatedKeywordVar(): boolean;
peekDeprecatedOperatorHash(): boolean;
expectCharacter(code: number): void;

@@ -69,4 +75,4 @@ optionalOperator(op: string): boolean;

expectTemplateBindingKey(): string;
parseTemplateBindings(): any[];
parseTemplateBindings(): TemplateBindingParseResult;
error(message: string, index?: number): void;
}

@@ -30,2 +30,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

}
export class TemplateBindingParseResult {
constructor(templateBindings, warnings) {
this.templateBindings = templateBindings;
this.warnings = warnings;
}
}
export let Parser = class Parser {

@@ -180,12 +186,5 @@ constructor(/** @internal */ _lexer) {

}
optionalKeywordVar() {
if (this.peekKeywordVar()) {
this.advance();
return true;
}
else {
return false;
}
}
peekKeywordVar() { return this.next.isKeywordVar() || this.next.isOperator('#'); }
peekKeywordLet() { return this.next.isKeywordLet(); }
peekDeprecatedKeywordVar() { return this.next.isKeywordDeprecatedVar(); }
peekDeprecatedOperatorHash() { return this.next.isOperator('#'); }
expectCharacter(code) {

@@ -567,4 +566,16 @@ if (this.optionalCharacter(code))

var prefix = null;
var warnings = [];
while (this.index < this.tokens.length) {
var keyIsVar = this.optionalKeywordVar();
var keyIsVar = this.peekKeywordLet();
if (!keyIsVar && this.peekDeprecatedKeywordVar()) {
keyIsVar = true;
warnings.push(`"var" inside of expressions is deprecated. Use "let" instead!`);
}
if (!keyIsVar && this.peekDeprecatedOperatorHash()) {
keyIsVar = true;
warnings.push(`"#" inside of expressions is deprecated. Use "let" instead!`);
}
if (keyIsVar) {
this.advance();
}
var key = this.expectTemplateBindingKey();

@@ -590,3 +601,4 @@ if (!keyIsVar) {

}
else if (this.next !== EOF && !this.peekKeywordVar()) {
else if (this.next !== EOF && !this.peekKeywordLet() && !this.peekDeprecatedKeywordVar() &&
!this.peekDeprecatedOperatorHash()) {
var start = this.inputIndex;

@@ -602,3 +614,3 @@ var ast = this.parsePipe();

}
return bindings;
return new TemplateBindingParseResult(bindings, warnings);
}

@@ -605,0 +617,0 @@ error(message, index = null) {

@@ -133,2 +133,3 @@ export interface BrowserNodeGlobal {

export declare function print(obj: Error | Object): void;
export declare function warn(obj: Error | Object): void;
export declare class Json {

@@ -135,0 +136,0 @@ static parse(s: string): Object;

@@ -298,2 +298,5 @@ var globalScope;

}
export function warn(obj) {
console.warn(obj);
}
// Can't be all uppercase as our transpiler would think it is a special directive...

@@ -337,3 +340,3 @@ export class Json {

if (isBlank(_symbolIterator)) {
if (isPresent(Symbol) && isPresent(Symbol.iterator)) {
if (isPresent(globalScope.Symbol) && isPresent(Symbol.iterator)) {
_symbolIterator = Symbol.iterator;

@@ -340,0 +343,0 @@ }

@@ -5,2 +5,3 @@ import { CompileIdentifierMetadata, CompileTokenMetadata } from './compile_metadata';

static AppView: CompileIdentifierMetadata;
static DebugAppView: CompileIdentifierMetadata;
static AppElement: CompileIdentifierMetadata;

@@ -29,3 +30,5 @@ static ElementRef: CompileIdentifierMetadata;

static interpolate: CompileIdentifierMetadata;
static castByValue: CompileIdentifierMetadata;
static pureProxies: CompileIdentifierMetadata[];
}
export declare function identifierToken(identifier: CompileIdentifierMetadata): CompileTokenMetadata;
import { SimpleChange, ChangeDetectorRef, ChangeDetectionStrategy, ElementRef, ViewContainerRef, Renderer, RenderComponentType, Injector, QueryList, ViewEncapsulation, TemplateRef } from '@angular/core';
import { AppElement, AppView, ChangeDetectorState, checkBinding, DebugContext, devModeEqual, flattenNestedViewRenderNodes, interpolate, StaticNodeDebugInfo, TemplateRef_, uninitialized, ValueUnwrapper, ViewType, ViewUtils } from '../core_private';
import { AppElement, AppView, DebugAppView, ChangeDetectorState, checkBinding, DebugContext, devModeEqual, flattenNestedViewRenderNodes, interpolate, StaticNodeDebugInfo, TemplateRef_, uninitialized, ValueUnwrapper, ViewType, ViewUtils, castByValue, pureProxy1, pureProxy2, pureProxy3, pureProxy4, pureProxy5, pureProxy6, pureProxy7, pureProxy8, pureProxy9, pureProxy10 } from '../core_private';
import { CompileIdentifierMetadata, CompileTokenMetadata } from './compile_metadata';

@@ -13,2 +13,3 @@ import { MODULE_SUFFIX } from './util';

var impAppView = AppView;
var impDebugAppView = DebugAppView;
var impDebugContext = DebugContext;

@@ -37,2 +38,3 @@ var impAppElement = AppElement;

var impCheckBinding = checkBinding;
var impCastByValue = castByValue;
export class Identifiers {

@@ -46,2 +48,3 @@ }

Identifiers.AppView = new CompileIdentifierMetadata({ name: 'AppView', moduleUrl: APP_VIEW_MODULE_URL, runtime: impAppView });
Identifiers.DebugAppView = new CompileIdentifierMetadata({ name: 'DebugAppView', moduleUrl: APP_VIEW_MODULE_URL, runtime: impDebugAppView });
Identifiers.AppElement = new CompileIdentifierMetadata({

@@ -134,2 +137,16 @@ name: 'AppElement',

Identifiers.interpolate = new CompileIdentifierMetadata({ name: 'interpolate', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: impInterpolate });
Identifiers.castByValue = new CompileIdentifierMetadata({ name: 'castByValue', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: impCastByValue });
Identifiers.pureProxies = [
null,
new CompileIdentifierMetadata({ name: 'pureProxy1', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy1 }),
new CompileIdentifierMetadata({ name: 'pureProxy2', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy2 }),
new CompileIdentifierMetadata({ name: 'pureProxy3', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy3 }),
new CompileIdentifierMetadata({ name: 'pureProxy4', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy4 }),
new CompileIdentifierMetadata({ name: 'pureProxy5', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy5 }),
new CompileIdentifierMetadata({ name: 'pureProxy6', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy6 }),
new CompileIdentifierMetadata({ name: 'pureProxy7', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy7 }),
new CompileIdentifierMetadata({ name: 'pureProxy8', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy8 }),
new CompileIdentifierMetadata({ name: 'pureProxy9', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy9 }),
new CompileIdentifierMetadata({ name: 'pureProxy10', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy10 }),
];
export function identifierToken(identifier) {

@@ -136,0 +153,0 @@ return new CompileTokenMetadata({ identifier: identifier });

@@ -168,2 +168,7 @@ import { isPresent, isBlank, isString, StringWrapper } from '../../src/facade/lang';

name = this.getBuiltinMethodName(expr.builtin);
if (isBlank(name)) {
// some builtins just mean to skip the call.
// e.g. `bind` in Dart.
return null;
}
}

@@ -227,2 +232,3 @@ ctx.print(`.${name}(`);

visitConditionalExpr(ast, ctx) {
ctx.print(`(`);
ast.condition.visitExpression(this, ctx);

@@ -233,2 +239,3 @@ ctx.print('? ');

ast.falseCase.visitExpression(this, ctx);
ctx.print(`)`);
return null;

@@ -235,0 +242,0 @@ }

@@ -146,2 +146,5 @@ import { isPresent } from '../../src/facade/lang';

break;
case o.BuiltinMethod.bind:
name = 'bind';
break;
default:

@@ -148,0 +151,0 @@ throw new BaseException(`Unknown builtin method: ${method}`);

@@ -200,2 +200,5 @@ import { isPresent, isBlank, isArray } from '../../src/facade/lang';

break;
case o.BuiltinMethod.bind:
name = null;
break;
default:

@@ -202,0 +205,0 @@ throw new BaseException(`Unknown builtin method: ${method}`);

@@ -1,2 +0,2 @@

import { AppView } from '../../core_private';
import { AppView, DebugAppView } from '../../core_private';
import { isPresent } from '../../src/facade/lang';

@@ -7,10 +7,17 @@ import { BaseException } from '../../src/facade/exceptions';

if (superClass === AppView) {
// We are always using DebugAppView as parent.
// However, in prod mode we generate a constructor call that does
// not have the argument for the debugNodeInfos.
args = args.concat([null]);
return new _InterpretiveAppView(args, props, getters, methods);
}
else if (superClass === DebugAppView) {
return new _InterpretiveAppView(args, props, getters, methods);
}
throw new BaseException(`Can't instantiate class ${superClass} in interpretative mode`);
}
}
class _InterpretiveAppView extends AppView {
class _InterpretiveAppView extends DebugAppView {
constructor(args, props, getters, methods) {
super(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10]);
super(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
this.props = props;

@@ -17,0 +24,0 @@ this.getters = getters;

@@ -135,2 +135,3 @@ import { CompileIdentifierMetadata } from '../compile_metadata';

SubscribeObservable = 1,
bind = 2,
}

@@ -137,0 +138,0 @@ export declare class InvokeMethodExpr extends Expression {

@@ -218,2 +218,3 @@ import { isString, isPresent, isBlank } from '../../src/facade/lang';

BuiltinMethod[BuiltinMethod["SubscribeObservable"] = 1] = "SubscribeObservable";
BuiltinMethod[BuiltinMethod["bind"] = 2] = "bind";
})(BuiltinMethod || (BuiltinMethod = {}));

@@ -380,3 +381,2 @@ export class InvokeMethodExpr extends Expression {

}
;
visitExpression(visitor, context) {

@@ -383,0 +383,0 @@ return visitor.visitLiteralMapExpr(this, context);

@@ -168,2 +168,10 @@ import { reflector } from '@angular/core';

break;
case o.BuiltinMethod.bind:
if (IS_DART) {
result = receiver;
}
else {
result = receiver.bind(args[0]);
}
break;
default:

@@ -321,2 +329,5 @@ throw new BaseException(`Unknown builtin method ${expr.builtin}`);

}
else if (di.methods.has(ast.name)) {
result = di.methods.get(ast.name);
}
else {

@@ -323,0 +334,0 @@ result = reflector.getter(ast.name)(receiver);

@@ -120,2 +120,5 @@ import * as o from './output_ast';

}
else {
ctx.print(`: any`);
}
ctx.println(`;`);

@@ -280,2 +283,5 @@ }

break;
case o.BuiltinMethod.bind:
name = 'bind';
break;
default:

@@ -282,0 +288,0 @@ throw new BaseException(`Unknown builtin method: ${method}`);

@@ -20,7 +20,12 @@ export declare class ParseLocation {

}
export declare enum ParseErrorLevel {
WARNING = 0,
FATAL = 1,
}
export declare abstract class ParseError {
span: ParseSourceSpan;
msg: string;
constructor(span: ParseSourceSpan, msg: string);
level: ParseErrorLevel;
constructor(span: ParseSourceSpan, msg: string, level?: ParseErrorLevel);
toString(): string;
}

@@ -25,6 +25,12 @@ export class ParseLocation {

}
export var ParseErrorLevel;
(function (ParseErrorLevel) {
ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING";
ParseErrorLevel[ParseErrorLevel["FATAL"] = 1] = "FATAL";
})(ParseErrorLevel || (ParseErrorLevel = {}));
export class ParseError {
constructor(span, msg) {
constructor(span, msg, level = ParseErrorLevel.FATAL) {
this.span = span;
this.msg = msg;
this.level = level;
}

@@ -31,0 +37,0 @@ toString() {

@@ -1,2 +0,2 @@

import { VariableAst, AttrAst, DirectiveAst, ProviderAst } from './template_ast';
import { AttrAst, DirectiveAst, ProviderAst, ReferenceAst } from './template_ast';
import { CompileTokenMap, CompileQueryMetadata, CompileDirectiveMetadata } from './compile_metadata';

@@ -33,3 +33,3 @@ import { ParseSourceSpan, ParseError } from './parse_util';

private _hasViewContainer;
constructor(_viewContext: ProviderViewContext, _parent: ProviderElementContext, _isViewRoot: boolean, _directiveAsts: DirectiveAst[], attrs: AttrAst[], vars: VariableAst[], _sourceSpan: ParseSourceSpan);
constructor(_viewContext: ProviderViewContext, _parent: ProviderElementContext, _isViewRoot: boolean, _directiveAsts: DirectiveAst[], attrs: AttrAst[], refs: ReferenceAst[], _sourceSpan: ParseSourceSpan);
afterElement(): void;

@@ -36,0 +36,0 @@ readonly transformProviders: ProviderAst[];

@@ -28,3 +28,3 @@ import { isPresent, isBlank, isArray, normalizeBlank } from '../src/facade/lang';

export class ProviderElementContext {
constructor(_viewContext, _parent, _isViewRoot, _directiveAsts, attrs, vars, _sourceSpan) {
constructor(_viewContext, _parent, _isViewRoot, _directiveAsts, attrs, refs, _sourceSpan) {
this._viewContext = _viewContext;

@@ -46,5 +46,4 @@ this._parent = _parent;

this._allProviders.values().forEach((provider) => { this._addQueryReadsTo(provider.token, queriedTokens); });
vars.forEach((varAst) => {
var varToken = new CompileTokenMetadata({ value: varAst.name });
this._addQueryReadsTo(varToken, queriedTokens);
refs.forEach((refAst) => {
this._addQueryReadsTo(new CompileTokenMetadata({ value: refAst.name }), queriedTokens);
});

@@ -72,3 +71,3 @@ if (isPresent(queriedTokens.get(identifierToken(Identifiers.ViewContainerRef)))) {

var sortedDirectives = ListWrapper.clone(this._directiveAsts);
ListWrapper.sort(this._directiveAsts, (dir1, dir2) => sortedProviderTypes.indexOf(dir1.directive.type) -
ListWrapper.sort(sortedDirectives, (dir1, dir2) => sortedProviderTypes.indexOf(dir1.directive.type) -
sortedProviderTypes.indexOf(dir2.directive.type));

@@ -75,0 +74,0 @@ return sortedDirectives;

@@ -7,3 +7,3 @@ import { ComponentFactory, ComponentResolver } from '@angular/core';

import { DirectiveNormalizer } from './directive_normalizer';
import { RuntimeMetadataResolver } from './runtime_metadata';
import { CompileMetadataResolver } from './metadata_resolver';
import { CompilerConfig } from './config';

@@ -17,3 +17,3 @@ import { XHR } from './xhr';

export declare class RuntimeCompiler implements ComponentResolver {
private _runtimeMetadataResolver;
private _metadataResolver;
private _templateNormalizer;

@@ -29,3 +29,3 @@ private _templateParser;

private _compiledTemplateDone;
constructor(_runtimeMetadataResolver: RuntimeMetadataResolver, _templateNormalizer: DirectiveNormalizer, _templateParser: TemplateParser, _styleCompiler: StyleCompiler, _viewCompiler: ViewCompiler, _xhr: XHR, _genConfig: CompilerConfig);
constructor(_metadataResolver: CompileMetadataResolver, _templateNormalizer: DirectiveNormalizer, _templateParser: TemplateParser, _styleCompiler: StyleCompiler, _viewCompiler: ViewCompiler, _xhr: XHR, _genConfig: CompilerConfig);
resolveComponent(componentType: Type): Promise<ComponentFactory>;

@@ -32,0 +32,0 @@ clearCache(): void;

@@ -20,3 +20,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

import { DirectiveNormalizer } from './directive_normalizer';
import { RuntimeMetadataResolver } from './runtime_metadata';
import { CompileMetadataResolver } from './metadata_resolver';
import { CompilerConfig } from './config';

@@ -34,4 +34,4 @@ import * as ir from './output/output_ast';

export let RuntimeCompiler = class RuntimeCompiler {
constructor(_runtimeMetadataResolver, _templateNormalizer, _templateParser, _styleCompiler, _viewCompiler, _xhr, _genConfig) {
this._runtimeMetadataResolver = _runtimeMetadataResolver;
constructor(_metadataResolver, _templateNormalizer, _templateParser, _styleCompiler, _viewCompiler, _xhr, _genConfig) {
this._metadataResolver = _metadataResolver;
this._templateNormalizer = _templateNormalizer;

@@ -49,3 +49,3 @@ this._templateParser = _templateParser;

resolveComponent(componentType) {
var compMeta = this._runtimeMetadataResolver.getDirectiveMetadata(componentType);
var compMeta = this._metadataResolver.getDirectiveMetadata(componentType);
var hostCacheKey = this._hostCacheKeys.get(componentType);

@@ -93,4 +93,4 @@ if (isBlank(hostCacheKey)) {

var childCacheKey = dep.comp.type.runtime;
var childViewDirectives = this._runtimeMetadataResolver.getViewDirectivesMetadata(dep.comp.type.runtime);
var childViewPipes = this._runtimeMetadataResolver.getViewPipesMetadata(dep.comp.type.runtime);
var childViewDirectives = this._metadataResolver.getViewDirectivesMetadata(dep.comp.type.runtime);
var childViewPipes = this._metadataResolver.getViewPipesMetadata(dep.comp.type.runtime);
var childIsRecursive = ListWrapper.contains(childCompilingComponentsPath, childCacheKey);

@@ -158,3 +158,3 @@ childCompilingComponentsPath.push(childCacheKey);

Injectable(),
__metadata('design:paramtypes', [RuntimeMetadataResolver, DirectiveNormalizer, TemplateParser, StyleCompiler, ViewCompiler, XHR, CompilerConfig])
__metadata('design:paramtypes', [CompileMetadataResolver, DirectiveNormalizer, TemplateParser, StyleCompiler, ViewCompiler, XHR, CompilerConfig])
], RuntimeCompiler);

@@ -161,0 +161,0 @@ class CompiledTemplate {

@@ -72,4 +72,14 @@ import { AST } from './expression_parser/ast';

/**
* A variable declaration on an element (e.g. `#var="expression"`).
* A reference declaration on an element (e.g. `let someName="expression"`).
*/
export declare class ReferenceAst implements TemplateAst {
name: string;
value: CompileTokenMetadata;
sourceSpan: ParseSourceSpan;
constructor(name: string, value: CompileTokenMetadata, sourceSpan: ParseSourceSpan);
visit(visitor: TemplateAstVisitor, context: any): any;
}
/**
* A variable declaration on a <template> (e.g. `var-someName="someLocalName"`).
*/
export declare class VariableAst implements TemplateAst {

@@ -90,3 +100,3 @@ name: string;

outputs: BoundEventAst[];
exportAsVars: VariableAst[];
references: ReferenceAst[];
directives: DirectiveAst[];

@@ -98,9 +108,5 @@ providers: ProviderAst[];

sourceSpan: ParseSourceSpan;
constructor(name: string, attrs: AttrAst[], inputs: BoundElementPropertyAst[], outputs: BoundEventAst[], exportAsVars: VariableAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan);
constructor(name: string, attrs: AttrAst[], inputs: BoundElementPropertyAst[], outputs: BoundEventAst[], references: ReferenceAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan);
visit(visitor: TemplateAstVisitor, context: any): any;
/**
* Whether the element has any active bindings (inputs, outputs, vars, or directives).
*/
isBound(): boolean;
/**
* Get the component associated with this element, if any.

@@ -116,3 +122,4 @@ */

outputs: BoundEventAst[];
vars: VariableAst[];
references: ReferenceAst[];
variables: VariableAst[];
directives: DirectiveAst[];

@@ -124,3 +131,3 @@ providers: ProviderAst[];

sourceSpan: ParseSourceSpan;
constructor(attrs: AttrAst[], outputs: BoundEventAst[], vars: VariableAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan);
constructor(attrs: AttrAst[], outputs: BoundEventAst[], references: ReferenceAst[], variables: VariableAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan);
visit(visitor: TemplateAstVisitor, context: any): any;

@@ -147,5 +154,4 @@ }

hostEvents: BoundEventAst[];
exportAsVars: VariableAst[];
sourceSpan: ParseSourceSpan;
constructor(directive: CompileDirectiveMetadata, inputs: BoundDirectivePropertyAst[], hostProperties: BoundElementPropertyAst[], hostEvents: BoundEventAst[], exportAsVars: VariableAst[], sourceSpan: ParseSourceSpan);
constructor(directive: CompileDirectiveMetadata, inputs: BoundDirectivePropertyAst[], hostProperties: BoundElementPropertyAst[], hostEvents: BoundEventAst[], sourceSpan: ParseSourceSpan);
visit(visitor: TemplateAstVisitor, context: any): any;

@@ -211,2 +217,3 @@ }

visitElement(ast: ElementAst, context: any): any;
visitReference(ast: ReferenceAst, context: any): any;
visitVariable(ast: VariableAst, context: any): any;

@@ -213,0 +220,0 @@ visitEvent(ast: BoundEventAst, context: any): any;

@@ -75,4 +75,17 @@ import { isPresent } from '../src/facade/lang';

/**
* A variable declaration on an element (e.g. `#var="expression"`).
* A reference declaration on an element (e.g. `let someName="expression"`).
*/
export class ReferenceAst {
constructor(name, value, sourceSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
}
visit(visitor, context) {
return visitor.visitReference(this, context);
}
}
/**
* A variable declaration on a <template> (e.g. `var-someName="someLocalName"`).
*/
export class VariableAst {

@@ -92,3 +105,3 @@ constructor(name, value, sourceSpan) {

export class ElementAst {
constructor(name, attrs, inputs, outputs, exportAsVars, directives, providers, hasViewContainer, children, ngContentIndex, sourceSpan) {
constructor(name, attrs, inputs, outputs, references, directives, providers, hasViewContainer, children, ngContentIndex, sourceSpan) {
this.name = name;

@@ -98,3 +111,3 @@ this.attrs = attrs;

this.outputs = outputs;
this.exportAsVars = exportAsVars;
this.references = references;
this.directives = directives;

@@ -111,15 +124,12 @@ this.providers = providers;

/**
* Whether the element has any active bindings (inputs, outputs, vars, or directives).
*/
isBound() {
return (this.inputs.length > 0 || this.outputs.length > 0 || this.exportAsVars.length > 0 ||
this.directives.length > 0);
}
/**
* Get the component associated with this element, if any.
*/
getComponent() {
return this.directives.length > 0 && this.directives[0].directive.isComponent ?
this.directives[0].directive :
null;
for (var i = 0; i < this.directives.length; i++) {
var dirAst = this.directives[i];
if (dirAst.directive.isComponent) {
return dirAst.directive;
}
}
return null;
}

@@ -131,6 +141,7 @@ }

export class EmbeddedTemplateAst {
constructor(attrs, outputs, vars, directives, providers, hasViewContainer, children, ngContentIndex, sourceSpan) {
constructor(attrs, outputs, references, variables, directives, providers, hasViewContainer, children, ngContentIndex, sourceSpan) {
this.attrs = attrs;
this.outputs = outputs;
this.vars = vars;
this.references = references;
this.variables = variables;
this.directives = directives;

@@ -165,3 +176,3 @@ this.providers = providers;

export class DirectiveAst {
constructor(directive, inputs, hostProperties, hostEvents, exportAsVars, sourceSpan) {
constructor(directive, inputs, hostProperties, hostEvents, sourceSpan) {
this.directive = directive;

@@ -171,3 +182,2 @@ this.inputs = inputs;

this.hostEvents = hostEvents;
this.exportAsVars = exportAsVars;
this.sourceSpan = sourceSpan;

@@ -174,0 +184,0 @@ }

@@ -0,1 +1,2 @@

import { Console } from '../core_private';
import { RecursiveAstVisitor, BindingPipe } from './expression_parser/ast';

@@ -5,3 +6,3 @@ import { Parser } from './expression_parser/parser';

import { HtmlParser } from './html_parser';
import { ParseSourceSpan, ParseError } from './parse_util';
import { ParseSourceSpan, ParseError, ParseErrorLevel } from './parse_util';
import { TemplateAst, TemplateAstVisitor } from './template_ast';

@@ -18,3 +19,3 @@ import { ElementSchemaRegistry } from './schema/element_schema_registry';

export declare class TemplateParseError extends ParseError {
constructor(message: string, span: ParseSourceSpan);
constructor(message: string, span: ParseSourceSpan, level: ParseErrorLevel);
}

@@ -30,4 +31,5 @@ export declare class TemplateParseResult {

private _htmlParser;
private _console;
transforms: TemplateAstVisitor[];
constructor(_exprParser: Parser, _schemaRegistry: ElementSchemaRegistry, _htmlParser: HtmlParser, transforms: TemplateAstVisitor[]);
constructor(_exprParser: Parser, _schemaRegistry: ElementSchemaRegistry, _htmlParser: HtmlParser, _console: Console, transforms: TemplateAstVisitor[]);
parse(component: CompileDirectiveMetadata, template: string, directives: CompileDirectiveMetadata[], pipes: CompilePipeMetadata[], templateUrl: string): TemplateAst[];

@@ -34,0 +36,0 @@ tryParse(component: CompileDirectiveMetadata, template: string, directives: CompileDirectiveMetadata[], pipes: CompilePipeMetadata[], templateUrl: string): TemplateParseResult;

@@ -14,3 +14,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

import { Injectable, Inject, OpaqueToken, Optional } from '@angular/core';
import { MAX_INTERPOLATION_VALUES } from '../core_private';
import { MAX_INTERPOLATION_VALUES, Console } from '../core_private';
import { ListWrapper, StringMapWrapper, SetWrapper } from '../src/facade/collection';

@@ -23,4 +23,4 @@ import { RegExpWrapper, isPresent, StringWrapper, isBlank } from '../src/facade/lang';

import { splitNsName, mergeNsAndName } from './html_tags';
import { ParseError } from './parse_util';
import { ElementAst, BoundElementPropertyAst, BoundEventAst, VariableAst, templateVisitAll, TextAst, BoundTextAst, EmbeddedTemplateAst, AttrAst, NgContentAst, PropertyBindingType, DirectiveAst, BoundDirectivePropertyAst } from './template_ast';
import { ParseError, ParseErrorLevel } from './parse_util';
import { ElementAst, BoundElementPropertyAst, BoundEventAst, ReferenceAst, templateVisitAll, TextAst, BoundTextAst, EmbeddedTemplateAst, AttrAst, NgContentAst, PropertyBindingType, DirectiveAst, BoundDirectivePropertyAst, VariableAst } from './template_ast';
import { CssSelector, SelectorMatcher } from './selector';

@@ -32,12 +32,15 @@ import { ElementSchemaRegistry } from './schema/element_schema_registry';

import { splitAtColon } from './util';
import { identifierToken, Identifiers } from './identifiers';
import { ProviderElementContext, ProviderViewContext } from './provider_parser';
// Group 1 = "bind-"
// Group 2 = "var-" or "#"
// Group 3 = "on-"
// Group 4 = "bindon-"
// Group 5 = the identifier after "bind-", "var-/#", or "on-"
// Group 6 = identifier inside [()]
// Group 7 = identifier inside []
// Group 8 = identifier inside ()
var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(var-|#)|(on-)|(bindon-))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/g;
// Group 2 = "var-"
// Group 3 = "let-"
// Group 4 = "ref-/#"
// Group 5 = "on-"
// Group 6 = "bindon-"
// Group 7 = the identifier after "bind-", "var-/#", or "on-"
// Group 8 = identifier inside [()]
// Group 9 = identifier inside []
// Group 10 = identifier inside ()
var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(var-)|(let-)|(ref-|#)|(on-)|(bindon-))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/g;
const TEMPLATE_ELEMENT = 'template';

@@ -61,4 +64,4 @@ const TEMPLATE_ATTR = 'template';

export class TemplateParseError extends ParseError {
constructor(message, span) {
super(span, message);
constructor(message, span, level) {
super(span, message, level);
}

@@ -73,6 +76,7 @@ }

export let TemplateParser = class TemplateParser {
constructor(_exprParser, _schemaRegistry, _htmlParser, transforms) {
constructor(_exprParser, _schemaRegistry, _htmlParser, _console, transforms) {
this._exprParser = _exprParser;
this._schemaRegistry = _schemaRegistry;
this._htmlParser = _htmlParser;
this._console = _console;
this.transforms = transforms;

@@ -82,4 +86,9 @@ }

var result = this.tryParse(component, template, directives, pipes, templateUrl);
if (isPresent(result.errors)) {
var errorString = result.errors.join('\n');
var warnings = result.errors.filter(error => error.level === ParseErrorLevel.WARNING);
var errors = result.errors.filter(error => error.level === ParseErrorLevel.FATAL);
if (warnings.length > 0) {
this._console.warn(`Template parse warnings:\n${warnings.join('\n')}`);
}
if (errors.length > 0) {
var errorString = errors.join('\n');
throw new BaseException(`Template parse errors:\n${errorString}`);

@@ -110,3 +119,3 @@ }

}
return new TemplateParseResult(result);
return new TemplateParseResult(result, errors);
}

@@ -116,5 +125,5 @@ };

Injectable(),
__param(3, Optional()),
__param(3, Inject(TEMPLATE_TRANSFORMS)),
__metadata('design:paramtypes', [Parser, ElementSchemaRegistry, HtmlParser, Array])
__param(4, Optional()),
__param(4, Inject(TEMPLATE_TRANSFORMS)),
__metadata('design:paramtypes', [Parser, ElementSchemaRegistry, HtmlParser, Console, Array])
], TemplateParser);

@@ -138,4 +147,4 @@ class TemplateParseVisitor {

}
_reportError(message, sourceSpan) {
this.errors.push(new TemplateParseError(message, sourceSpan));
_reportError(message, sourceSpan, level = ParseErrorLevel.FATAL) {
this.errors.push(new TemplateParseError(message, sourceSpan, level));
}

@@ -185,4 +194,4 @@ _parseInterpolation(value, sourceSpan) {

try {
var bindings = this._exprParser.parseTemplateBindings(value, sourceInfo);
bindings.forEach((binding) => {
var bindingsResult = this._exprParser.parseTemplateBindings(value, sourceInfo);
bindingsResult.templateBindings.forEach((binding) => {
if (isPresent(binding.expression)) {

@@ -192,3 +201,4 @@ this._checkPipes(binding.expression, sourceSpan);

});
return bindings;
bindingsResult.warnings.forEach((warning) => { this._reportError(warning, sourceSpan, ParseErrorLevel.WARNING); });
return bindingsResult.templateBindings;
}

@@ -245,12 +255,15 @@ catch (e) {

var elementOrDirectiveProps = [];
var vars = [];
var elementOrDirectiveRefs = [];
var elementVars = [];
var events = [];
var templateElementOrDirectiveProps = [];
var templateVars = [];
var templateMatchableAttrs = [];
var templateElementVars = [];
var hasInlineTemplates = false;
var attrs = [];
var lcElName = splitNsName(nodeName.toLowerCase())[1];
var isTemplateElement = lcElName == TEMPLATE_ELEMENT;
element.attrs.forEach(attr => {
var hasBinding = this._parseAttr(attr, matchableAttrs, elementOrDirectiveProps, events, vars);
var hasTemplateBinding = this._parseInlineTemplateBinding(attr, templateMatchableAttrs, templateElementOrDirectiveProps, templateVars);
var hasBinding = this._parseAttr(isTemplateElement, attr, matchableAttrs, elementOrDirectiveProps, events, elementOrDirectiveRefs, elementVars);
var hasTemplateBinding = this._parseInlineTemplateBinding(attr, templateMatchableAttrs, templateElementOrDirectiveProps, templateElementVars);
if (!hasBinding && !hasTemplateBinding) {

@@ -265,10 +278,9 @@ // don't include the bindings as attributes as well in the AST

});
var lcElName = splitNsName(nodeName.toLowerCase())[1];
var isTemplateElement = lcElName == TEMPLATE_ELEMENT;
var elementCssSelector = createElementCssSelector(nodeName, matchableAttrs);
var directiveMetas = this._parseDirectives(this.selectorMatcher, elementCssSelector);
var directiveAsts = this._createDirectiveAsts(element.name, directiveMetas, elementOrDirectiveProps, isTemplateElement ? [] : vars, element.sourceSpan);
var references = [];
var directiveAsts = this._createDirectiveAsts(isTemplateElement, element.name, directiveMetas, elementOrDirectiveProps, elementOrDirectiveRefs, element.sourceSpan, references);
var elementProps = this._createElementPropertyAsts(element.name, elementOrDirectiveProps, directiveAsts);
var isViewRoot = parent.isTemplateElement || hasInlineTemplates;
var providerContext = new ProviderElementContext(this.providerViewContext, parent.providerContext, isViewRoot, directiveAsts, attrs, vars, element.sourceSpan);
var providerContext = new ProviderElementContext(this.providerViewContext, parent.providerContext, isViewRoot, directiveAsts, attrs, references, element.sourceSpan);
var children = htmlVisitAll(preparsedElement.nonBindable ? NON_BINDABLE_VISITOR : this, element.children, ElementContext.create(isTemplateElement, directiveAsts, isTemplateElement ? parent.providerContext : providerContext));

@@ -291,9 +303,8 @@ providerContext.afterElement();

this._assertNoComponentsNorElementBindingsOnTemplate(directiveAsts, elementProps, element.sourceSpan);
parsedElement = new EmbeddedTemplateAst(attrs, events, vars, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, children, hasInlineTemplates ? null : ngContentIndex, element.sourceSpan);
parsedElement = new EmbeddedTemplateAst(attrs, events, references, elementVars, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, children, hasInlineTemplates ? null : ngContentIndex, element.sourceSpan);
}
else {
this._assertOnlyOneComponent(directiveAsts, element.sourceSpan);
var elementExportAsVars = vars.filter(varAst => varAst.value.length === 0);
let ngContentIndex = hasInlineTemplates ? null : parent.findNgContentIndex(projectionSelector);
parsedElement = new ElementAst(nodeName, attrs, elementProps, events, elementExportAsVars, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, children, hasInlineTemplates ? null : ngContentIndex, element.sourceSpan);
parsedElement = new ElementAst(nodeName, attrs, elementProps, events, references, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, children, hasInlineTemplates ? null : ngContentIndex, element.sourceSpan);
}

@@ -303,8 +314,8 @@ if (hasInlineTemplates) {

var templateDirectiveMetas = this._parseDirectives(this.selectorMatcher, templateCssSelector);
var templateDirectiveAsts = this._createDirectiveAsts(element.name, templateDirectiveMetas, templateElementOrDirectiveProps, [], element.sourceSpan);
var templateDirectiveAsts = this._createDirectiveAsts(true, element.name, templateDirectiveMetas, templateElementOrDirectiveProps, [], element.sourceSpan, []);
var templateElementProps = this._createElementPropertyAsts(element.name, templateElementOrDirectiveProps, templateDirectiveAsts);
this._assertNoComponentsNorElementBindingsOnTemplate(templateDirectiveAsts, templateElementProps, element.sourceSpan);
var templateProviderContext = new ProviderElementContext(this.providerViewContext, parent.providerContext, parent.isTemplateElement, templateDirectiveAsts, [], templateVars, element.sourceSpan);
var templateProviderContext = new ProviderElementContext(this.providerViewContext, parent.providerContext, parent.isTemplateElement, templateDirectiveAsts, [], [], element.sourceSpan);
templateProviderContext.afterElement();
parsedElement = new EmbeddedTemplateAst([], [], templateVars, templateProviderContext.transformedDirectiveAsts, templateProviderContext.transformProviders, templateProviderContext.transformedHasViewContainer, [parsedElement], ngContentIndex, element.sourceSpan);
parsedElement = new EmbeddedTemplateAst([], [], [], templateElementVars, templateProviderContext.transformedDirectiveAsts, templateProviderContext.transformProviders, templateProviderContext.transformedHasViewContainer, [parsedElement], ngContentIndex, element.sourceSpan);
}

@@ -328,3 +339,2 @@ return parsedElement;

targetVars.push(new VariableAst(binding.key, binding.name, attr.sourceSpan));
targetMatchableAttrs.push([binding.key, binding.name]);
}

@@ -343,3 +353,3 @@ else if (isPresent(binding.expression)) {

}
_parseAttr(attr, targetMatchableAttrs, targetProps, targetEvents, targetVars) {
_parseAttr(isTemplateElement, attr, targetMatchableAttrs, targetProps, targetEvents, targetRefs, targetVars) {
var attrName = this._normalizeAttributeName(attr.name);

@@ -352,25 +362,45 @@ var attrValue = attr.value;

if (isPresent(bindParts[1])) {
this._parseProperty(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
this._parseProperty(bindParts[7], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
}
else if (isPresent(bindParts[2])) {
var identifier = bindParts[5];
this._parseVariable(identifier, attrValue, attr.sourceSpan, targetVars);
var identifier = bindParts[7];
if (isTemplateElement) {
this._reportError(`"var-" on <template> elements is deprecated. Use "let-" instead!`, attr.sourceSpan, ParseErrorLevel.WARNING);
this._parseVariable(identifier, attrValue, attr.sourceSpan, targetVars);
}
else {
this._reportError(`"var-" on non <template> elements is deprecated. Use "ref-" instead!`, attr.sourceSpan, ParseErrorLevel.WARNING);
this._parseReference(identifier, attrValue, attr.sourceSpan, targetRefs);
}
}
else if (isPresent(bindParts[3])) {
this._parseEvent(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
if (isTemplateElement) {
var identifier = bindParts[7];
this._parseVariable(identifier, attrValue, attr.sourceSpan, targetVars);
}
else {
this._reportError(`"let-" is only supported on template elements.`, attr.sourceSpan);
}
}
else if (isPresent(bindParts[4])) {
this._parseProperty(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
this._parseAssignmentEvent(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
var identifier = bindParts[7];
this._parseReference(identifier, attrValue, attr.sourceSpan, targetRefs);
}
else if (isPresent(bindParts[5])) {
this._parseEvent(bindParts[7], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
}
else if (isPresent(bindParts[6])) {
this._parseProperty(bindParts[6], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
this._parseAssignmentEvent(bindParts[6], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
}
else if (isPresent(bindParts[7])) {
this._parseProperty(bindParts[7], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
this._parseAssignmentEvent(bindParts[7], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
}
else if (isPresent(bindParts[8])) {
this._parseEvent(bindParts[8], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
this._parseProperty(bindParts[8], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
this._parseAssignmentEvent(bindParts[8], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
}
else if (isPresent(bindParts[9])) {
this._parseProperty(bindParts[9], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
}
else if (isPresent(bindParts[10])) {
this._parseEvent(bindParts[10], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
}
}

@@ -394,2 +424,8 @@ else {

}
_parseReference(identifier, value, sourceSpan, targetRefs) {
if (identifier.indexOf('-') > -1) {
this._reportError(`"-" is not allowed in reference names`, sourceSpan);
}
targetRefs.push(new ElementOrDirectiveRef(identifier, value, sourceSpan));
}
_parseProperty(name, expression, sourceSpan, targetMatchableAttrs, targetProps) {

@@ -428,25 +464,18 @@ this._parsePropertyAst(name, this._parseBinding(expression, sourceSpan), sourceSpan, targetMatchableAttrs, targetProps);

_parseDirectives(selectorMatcher, elementCssSelector) {
var directives = [];
selectorMatcher.match(elementCssSelector, (selector, directive) => { directives.push(directive); });
// Need to sort the directives so that we get consistent results throughout,
// as selectorMatcher uses Maps inside.
// Also need to make components the first directive in the array
ListWrapper.sort(directives, (dir1, dir2) => {
var dir1Comp = dir1.isComponent;
var dir2Comp = dir2.isComponent;
if (dir1Comp && !dir2Comp) {
return -1;
}
else if (!dir1Comp && dir2Comp) {
return 1;
}
else {
return this.directivesIndex.get(dir1) - this.directivesIndex.get(dir2);
}
// Also dedupe directives as they might match more than one time!
var directives = ListWrapper.createFixedSize(this.directivesIndex.size);
selectorMatcher.match(elementCssSelector, (selector, directive) => {
directives[this.directivesIndex.get(directive)] = directive;
});
return directives;
return directives.filter(dir => isPresent(dir));
}
_createDirectiveAsts(elementName, directives, props, possibleExportAsVars, sourceSpan) {
var matchedVariables = new Set();
_createDirectiveAsts(isTemplateElement, elementName, directives, props, elementOrDirectiveRefs, sourceSpan, targetReferences) {
var matchedReferences = new Set();
var component = null;
var directiveAsts = directives.map((directive) => {
if (directive.isComponent) {
component = directive;
}
var hostProperties = [];

@@ -458,16 +487,25 @@ var hostEvents = [];

this._createDirectivePropertyAsts(directive.inputs, props, directiveProperties);
var exportAsVars = [];
possibleExportAsVars.forEach((varAst) => {
if ((varAst.value.length === 0 && directive.isComponent) ||
(directive.exportAs == varAst.value)) {
exportAsVars.push(varAst);
matchedVariables.add(varAst.name);
elementOrDirectiveRefs.forEach((elOrDirRef) => {
if ((elOrDirRef.value.length === 0 && directive.isComponent) ||
(directive.exportAs == elOrDirRef.value)) {
targetReferences.push(new ReferenceAst(elOrDirRef.name, identifierToken(directive.type), elOrDirRef.sourceSpan));
matchedReferences.add(elOrDirRef.name);
}
});
return new DirectiveAst(directive, directiveProperties, hostProperties, hostEvents, exportAsVars, sourceSpan);
return new DirectiveAst(directive, directiveProperties, hostProperties, hostEvents, sourceSpan);
});
possibleExportAsVars.forEach((varAst) => {
if (varAst.value.length > 0 && !SetWrapper.has(matchedVariables, varAst.name)) {
this._reportError(`There is no directive with "exportAs" set to "${varAst.value}"`, varAst.sourceSpan);
elementOrDirectiveRefs.forEach((elOrDirRef) => {
if (elOrDirRef.value.length > 0) {
if (!SetWrapper.has(matchedReferences, elOrDirRef.name)) {
this._reportError(`There is no directive with "exportAs" set to "${elOrDirRef.value}"`, elOrDirRef.sourceSpan);
}
;
}
else if (isBlank(component)) {
var refToken = null;
if (isTemplateElement) {
refToken = identifierToken(Identifiers.TemplateRef);
}
targetReferences.push(new ReferenceAst(elOrDirRef.name, refToken, elOrDirRef.sourceSpan));
}
});

@@ -637,2 +675,9 @@ return directiveAsts;

}
class ElementOrDirectiveRef {
constructor(name, value, sourceSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
}
}
export function splitClasses(classAttrValue) {

@@ -639,0 +684,0 @@ return StringWrapper.split(classAttrValue.trim(), /\s+/g);

import * as o from '../output/output_ast';
import { CompileView } from './compile_view';
import { TemplateAst, ProviderAst } from '../template_ast';
import { TemplateAst, ProviderAst, ReferenceAst } from '../template_ast';
import { CompileDirectiveMetadata, CompileTokenMetadata } from '../compile_metadata';

@@ -21,5 +21,2 @@ export declare class CompileNode {

hasEmbeddedView: boolean;
variableTokens: {
[key: string]: CompileTokenMetadata;
};
static createNull(): CompileElement;

@@ -38,5 +35,6 @@ private _compViewExpr;

directiveInstances: o.Expression[];
constructor(parent: CompileElement, view: CompileView, nodeIndex: number, renderNode: o.Expression, sourceAst: TemplateAst, component: CompileDirectiveMetadata, _directives: CompileDirectiveMetadata[], _resolvedProvidersArray: ProviderAst[], hasViewContainer: boolean, hasEmbeddedView: boolean, variableTokens: {
referenceTokens: {
[key: string]: CompileTokenMetadata;
});
};
constructor(parent: CompileElement, view: CompileView, nodeIndex: number, renderNode: o.Expression, sourceAst: TemplateAst, component: CompileDirectiveMetadata, _directives: CompileDirectiveMetadata[], _resolvedProvidersArray: ProviderAst[], hasViewContainer: boolean, hasEmbeddedView: boolean, references: ReferenceAst[]);
private _createAppElement();

@@ -50,3 +48,2 @@ setComponentView(compViewExpr: o.Expression): void;

getProviderTokens(): o.Expression[];
getDeclaredVariablesNames(): string[];
private _getQueriesFor(token);

@@ -53,0 +50,0 @@ private _addQuery(queryMeta, directiveInstance);

@@ -23,3 +23,3 @@ import { isPresent, isBlank } from '../../src/facade/lang';

export class CompileElement extends CompileNode {
constructor(parent, view, nodeIndex, renderNode, sourceAst, component, _directives, _resolvedProvidersArray, hasViewContainer, hasEmbeddedView, variableTokens) {
constructor(parent, view, nodeIndex, renderNode, sourceAst, component, _directives, _resolvedProvidersArray, hasViewContainer, hasEmbeddedView, references) {
super(parent, view, nodeIndex, renderNode, sourceAst);

@@ -31,3 +31,2 @@ this.component = component;

this.hasEmbeddedView = hasEmbeddedView;
this.variableTokens = variableTokens;
this._compViewExpr = null;

@@ -39,2 +38,4 @@ this._instances = new CompileTokenMap();

this.contentNodesByNgContentIndex = null;
this.referenceTokens = {};
references.forEach(ref => this.referenceTokens[ref.name] = ref.value);
this.elementRef = o.importExpr(Identifiers.ElementRef).instantiate([this.renderNode]);

@@ -50,3 +51,3 @@ this._instances.add(identifierToken(Identifiers.ElementRef), this.elementRef);

static createNull() {
return new CompileElement(null, null, null, null, null, null, [], [], false, false, {});
return new CompileElement(null, null, null, null, null, null, [], [], false, false, []);
}

@@ -140,4 +141,4 @@ _createAppElement() {

});
StringMapWrapper.forEach(this.variableTokens, (_, varName) => {
var token = this.variableTokens[varName];
StringMapWrapper.forEach(this.referenceTokens, (_, varName) => {
var token = this.referenceTokens[varName];
var varValue;

@@ -150,3 +151,3 @@ if (isPresent(token)) {

}
this.view.variables.set(varName, varValue);
this.view.locals.set(varName, varValue);
var varToken = new CompileTokenMetadata({ value: varName });

@@ -163,4 +164,4 @@ ListWrapper.addAll(queriesWithReads, this._getQueriesFor(varToken)

else {
// query for a variable
var token = this.variableTokens[queryWithRead.read.value];
// query for a reference
var token = this.referenceTokens[queryWithRead.read.value];
if (isPresent(token)) {

@@ -210,7 +211,2 @@ value = this._instances.get(token);

}
getDeclaredVariablesNames() {
var res = [];
StringMapWrapper.forEach(this.variableTokens, (_, key) => { res.push(key); });
return res;
}
_getQueriesFor(token) {

@@ -276,3 +272,2 @@ var result = [];

var currElement = this;
var currView = currElement.view;
var result = null;

@@ -285,10 +280,5 @@ if (dep.isValue) {

}
var resultViewPath = [];
// check parent elements
while (isBlank(result) && !currElement.parent.isNull()) {
currElement = currElement.parent;
while (currElement.view !== currView && currView != null) {
currView = currView.declarationElement.view;
resultViewPath.push(currView);
}
result = currElement._getLocalDependency(ProviderAstType.PublicService, new CompileDiDependencyMetadata({ token: dep.token }));

@@ -302,3 +292,3 @@ }

}
return getPropertyInView(result, resultViewPath);
return getPropertyInView(result, this.view, currElement.view);
}

@@ -305,0 +295,0 @@ }

@@ -23,3 +23,2 @@ import { isPresent, isBlank } from '../../src/facade/lang';

var elPath = [];
var viewPath = [];
while (isPresent(currentView) && currentView !== this.view) {

@@ -29,5 +28,4 @@ var parentEl = currentView.declarationElement;

currentView = parentEl.view;
viewPath.push(currentView);
}
var queryListForDirtyExpr = getPropertyInView(this.queryList, viewPath);
var queryListForDirtyExpr = getPropertyInView(this.queryList, view, this.view);
var viewValues = this._values;

@@ -34,0 +32,0 @@ elPath.forEach((el) => {

@@ -7,8 +7,6 @@ import { ViewType } from '../../core_private';

import { CompileMethod } from './compile_method';
import { CompilePipe } from './compile_pipe';
import { CompileDirectiveMetadata, CompilePipeMetadata, CompileTokenMap } from '../compile_metadata';
import { CompilerConfig } from '../config';
import { CompileBinding } from './compile_binding';
export declare class CompilePipe {
constructor();
}
export declare class CompileView implements NameResolver {

@@ -44,4 +42,5 @@ component: CompileDirectiveMetadata;

componentView: CompileView;
pipes: Map<string, o.Expression>;
variables: Map<string, o.Expression>;
purePipes: Map<string, CompilePipe>;
pipes: CompilePipe[];
locals: Map<string, o.Expression>;
className: string;

@@ -52,8 +51,10 @@ classType: o.Type;

literalMapCount: number;
pipeCount: number;
componentContext: o.Expression;
constructor(component: CompileDirectiveMetadata, genConfig: CompilerConfig, pipeMetas: CompilePipeMetadata[], styles: o.Expression, viewIndex: number, declarationElement: CompileElement, templateVariableBindings: string[][]);
callPipe(name: string, input: o.Expression, args: o.Expression[]): o.Expression;
getVariable(name: string): o.Expression;
getLocal(name: string): o.Expression;
createLiteralArray(values: o.Expression[]): o.Expression;
createLiteralMap(values: Array<Array<string | o.Expression>>): o.Expression;
createLiteralMap(entries: Array<Array<string | o.Expression>>): o.Expression;
afterNodes(): void;
}
import { ViewType } from '../../core_private';
import { isPresent, isBlank } from '../../src/facade/lang';
import { ListWrapper } from '../../src/facade/collection';
import { BaseException } from '../../src/facade/exceptions';
import * as o from '../output/output_ast';
import { Identifiers, identifierToken } from '../identifiers';
import { EventHandlerVars } from './constants';
import { CompileQuery, createQueryList, addQueryToTokenMap } from './compile_query';
import { CompileMethod } from './compile_method';
import { CompilePipe } from './compile_pipe';
import { CompileIdentifierMetadata, CompileTokenMap } from '../compile_metadata';
import { getViewFactoryName, injectFromViewParentInjector, getPropertyInView } from './util';
import { bindPipeDestroyLifecycleCallbacks } from './lifecycle_binder';
export class CompilePipe {
constructor() {
}
}
import { getViewFactoryName, getPropertyInView, createPureProxy } from './util';
export class CompileView {

@@ -36,6 +30,8 @@ constructor(component, genConfig, pipeMetas, styles, viewIndex, declarationElement, templateVariableBindings) {

this.subscriptions = [];
this.pipes = new Map();
this.variables = new Map();
this.purePipes = new Map();
this.pipes = [];
this.locals = new Map();
this.literalArrayCount = 0;
this.literalMapCount = 0;
this.pipeCount = 0;
this.createMethod = new CompileMethod(this);

@@ -61,2 +57,4 @@ this.injectorGetMethod = new CompileMethod(this);

}
this.componentContext =
getPropertyInView(o.THIS_EXPR.prop('context'), this, this.componentView);
var viewQueries = new CompileTokenMap();

@@ -83,5 +81,3 @@ if (this.viewType === ViewType.COMPONENT) {

this.viewQueries = viewQueries;
templateVariableBindings.forEach((entry) => {
this.variables.set(entry[1], o.THIS_EXPR.prop('locals').key(o.literal(entry[0])));
});
templateVariableBindings.forEach((entry) => { this.locals.set(entry[1], o.THIS_EXPR.prop('context').prop(entry[0])); });
if (!this.declarationElement.isNull()) {

@@ -92,47 +88,14 @@ this.declarationElement.setEmbeddedView(this);

callPipe(name, input, args) {
var pipeMeta = null;
for (var i = this.pipeMetas.length - 1; i >= 0; i--) {
var localPipeMeta = this.pipeMetas[i];
if (localPipeMeta.name == name) {
pipeMeta = localPipeMeta;
break;
var compView = this.componentView;
var pipe = compView.purePipes.get(name);
if (isBlank(pipe)) {
pipe = new CompilePipe(compView, name);
if (pipe.pure) {
compView.purePipes.set(name, pipe);
}
compView.pipes.push(pipe);
}
if (isBlank(pipeMeta)) {
throw new BaseException(`Illegal state: Could not find pipe ${name} although the parser should have detected this error!`);
}
var pipeFieldName = pipeMeta.pure ? `_pipe_${name}` : `_pipe_${name}_${this.pipes.size}`;
var pipeExpr = this.pipes.get(pipeFieldName);
var pipeFieldCacheProp = o.THIS_EXPR.prop(`${pipeFieldName}_cache`);
if (isBlank(pipeExpr)) {
var deps = pipeMeta.type.diDeps.map((diDep) => {
if (diDep.token.equalsTo(identifierToken(Identifiers.ChangeDetectorRef))) {
return o.THIS_EXPR.prop('ref');
}
return injectFromViewParentInjector(diDep.token, false);
});
this.fields.push(new o.ClassField(pipeFieldName, o.importType(pipeMeta.type), [o.StmtModifier.Private]));
if (pipeMeta.pure) {
this.fields.push(new o.ClassField(pipeFieldCacheProp.name, null, [o.StmtModifier.Private]));
this.createMethod.addStmt(o.THIS_EXPR.prop(pipeFieldCacheProp.name)
.set(o.importExpr(Identifiers.uninitialized))
.toStmt());
}
this.createMethod.resetDebugInfo(null, null);
this.createMethod.addStmt(o.THIS_EXPR.prop(pipeFieldName)
.set(o.importExpr(pipeMeta.type).instantiate(deps))
.toStmt());
pipeExpr = o.THIS_EXPR.prop(pipeFieldName);
this.pipes.set(pipeFieldName, pipeExpr);
bindPipeDestroyLifecycleCallbacks(pipeMeta, pipeExpr, this);
}
var callPipeExpr = pipeExpr.callMethod('transform', [input, o.literalArr(args)]);
if (pipeMeta.pure) {
callPipeExpr =
o.THIS_EXPR.callMethod('checkPurePipe', [o.literal(this.literalArrayCount++), o.literalArr([input].concat(args))])
.conditional(pipeFieldCacheProp.set(callPipeExpr), pipeFieldCacheProp);
}
return callPipeExpr;
return pipe.call(this, [input].concat(args));
}
getVariable(name) {
getLocal(name) {
if (name == EventHandlerVars.event.name) {

@@ -142,11 +105,9 @@ return EventHandlerVars.event;

var currView = this;
var result = currView.variables.get(name);
var viewPath = [];
var result = currView.locals.get(name);
while (isBlank(result) && isPresent(currView.declarationElement.view)) {
currView = currView.declarationElement.view;
result = currView.variables.get(name);
viewPath.push(currView);
result = currView.locals.get(name);
}
if (isPresent(result)) {
return getPropertyInView(result, viewPath);
return getPropertyInView(result, this, currView);
}

@@ -158,8 +119,29 @@ else {

createLiteralArray(values) {
return o.THIS_EXPR.callMethod('literalArray', [o.literal(this.literalArrayCount++), o.literalArr(values)]);
var proxyExpr = o.THIS_EXPR.prop(`_arr_${this.literalArrayCount++}`);
var proxyParams = [];
var proxyReturnEntries = [];
for (var i = 0; i < values.length; i++) {
var paramName = `p${i}`;
proxyParams.push(new o.FnParam(paramName));
proxyReturnEntries.push(o.variable(paramName));
}
createPureProxy(o.fn(proxyParams, [new o.ReturnStatement(o.literalArr(proxyReturnEntries))]), values.length, proxyExpr, this);
return proxyExpr.callFn(values);
}
createLiteralMap(values) {
return o.THIS_EXPR.callMethod('literalMap', [o.literal(this.literalMapCount++), o.literalMap(values)]);
createLiteralMap(entries) {
var proxyExpr = o.THIS_EXPR.prop(`_map_${this.literalMapCount++}`);
var proxyParams = [];
var proxyReturnEntries = [];
var values = [];
for (var i = 0; i < entries.length; i++) {
var paramName = `p${i}`;
proxyParams.push(new o.FnParam(paramName));
proxyReturnEntries.push([entries[i][0], o.variable(paramName)]);
values.push(entries[i][1]);
}
createPureProxy(o.fn(proxyParams, [new o.ReturnStatement(o.literalMap(proxyReturnEntries))]), entries.length, proxyExpr, this);
return proxyExpr.callFn(values);
}
afterNodes() {
this.pipes.forEach((pipe) => pipe.create());
this.viewQueries.values().forEach((queries) => queries.forEach((query) => query.afterChildren(this.updateViewQueriesMethod)));

@@ -166,0 +148,0 @@ }

@@ -35,3 +35,4 @@ import { isBlank, isPresent, StringWrapper } from '../../src/facade/lang';

this._method.resetDebugInfo(this.compileElement.nodeIndex, hostEvent);
var context = isPresent(directiveInstance) ? directiveInstance : o.THIS_EXPR.prop('context');
var context = isPresent(directiveInstance) ? directiveInstance :
this.compileElement.view.componentContext;
var actionStmts = convertCdStatementToIr(this.compileElement.view, context, hostEvent.handler);

@@ -70,3 +71,3 @@ var lastIndex = actionStmts.length - 1;

new o.ReturnStatement(o.THIS_EXPR.callMethod(this._methodName, [EventHandlerVars.event]))
])
], o.BOOL_TYPE)
]);

@@ -73,0 +74,0 @@ if (isPresent(this.eventTarget)) {

@@ -5,3 +5,3 @@ import * as cdAst from '../expression_parser/ast';

callPipe(name: string, input: o.Expression, args: o.Expression[]): o.Expression;
getVariable(name: string): o.Expression;
getLocal(name: string): o.Expression;
createLiteralArray(values: o.Expression[]): o.Expression;

@@ -8,0 +8,0 @@ createLiteralMap(values: Array<Array<string | o.Expression>>): o.Expression;

@@ -117,5 +117,5 @@ import { BaseException } from '../../src/facade/exceptions';

var args = this.visitAll(ast.args, _Mode.Expression);
var pipeResult = this._nameResolver.callPipe(ast.name, input, args);
var value = this._nameResolver.callPipe(ast.name, input, args);
this.needsValueUnwrapper = true;
return convertToStatementIfNeeded(mode, this._valueUnwrapper.callMethod('unwrap', [pipeResult]));
return convertToStatementIfNeeded(mode, this._valueUnwrapper.callMethod('unwrap', [value]));
}

@@ -167,3 +167,3 @@ visitFunctionCall(ast, mode) {

if (receiver === IMPLICIT_RECEIVER) {
var varExpr = this._nameResolver.getVariable(ast.name);
var varExpr = this._nameResolver.getLocal(ast.name);
if (isPresent(varExpr)) {

@@ -188,3 +188,3 @@ result = varExpr.callFn(args);

if (receiver === IMPLICIT_RECEIVER) {
result = this._nameResolver.getVariable(ast.name);
result = this._nameResolver.getLocal(ast.name);
if (isBlank(result)) {

@@ -202,5 +202,5 @@ receiver = this._implicitReceiver;

if (receiver === IMPLICIT_RECEIVER) {
var varExpr = this._nameResolver.getVariable(ast.name);
var varExpr = this._nameResolver.getLocal(ast.name);
if (isPresent(varExpr)) {
throw new BaseException('Cannot reassign a variable binding');
throw new BaseException('Cannot assign to a reference or variable!');
}

@@ -207,0 +207,0 @@ receiver = this._implicitReceiver;

@@ -10,2 +10,2 @@ import * as o from '../output/output_ast';

export declare function bindDirectiveDestroyLifecycleCallbacks(directiveMeta: CompileDirectiveMetadata, directiveInstance: o.Expression, compileElement: CompileElement): void;
export declare function bindPipeDestroyLifecycleCallbacks(pipeMeta: CompilePipeMetadata, directiveInstance: o.Expression, view: CompileView): void;
export declare function bindPipeDestroyLifecycleCallbacks(pipeMeta: CompilePipeMetadata, pipeInstance: o.Expression, view: CompileView): void;

@@ -51,8 +51,8 @@ import { LifecycleHooks } from '../../core_private';

}
export function bindPipeDestroyLifecycleCallbacks(pipeMeta, directiveInstance, view) {
export function bindPipeDestroyLifecycleCallbacks(pipeMeta, pipeInstance, view) {
var onDestroyMethod = view.destroyMethod;
if (pipeMeta.lifecycleHooks.indexOf(LifecycleHooks.OnDestroy) !== -1) {
onDestroyMethod.addStmt(directiveInstance.callMethod('ngOnDestroy', []).toStmt());
onDestroyMethod.addStmt(pipeInstance.callMethod('ngOnDestroy', []).toStmt());
}
}
//# sourceMappingURL=lifecycle_binder.js.map

@@ -42,3 +42,3 @@ import { LifecycleHooks, isDefaultChangeDetectionStrategy } from '../../core_private';

view.detectChangesRenderPropertiesMethod.resetDebugInfo(compileNode.nodeIndex, boundText);
bind(view, currValExpr, valueField, boundText.value, o.THIS_EXPR.prop('context'), [
bind(view, currValExpr, valueField, boundText.value, view.componentContext, [
o.THIS_EXPR.prop('renderer')

@@ -92,3 +92,3 @@ .callMethod('setText', [compileNode.renderNode, currValExpr])

export function bindRenderInputs(boundProps, compileElement) {
bindAndWriteToRenderer(boundProps, o.THIS_EXPR.prop('context'), compileElement);
bindAndWriteToRenderer(boundProps, compileElement.view.componentContext, compileElement);
}

@@ -137,3 +137,3 @@ export function bindDirectiveHostProps(directiveAst, directiveInstance, compileElement) {

}
bind(view, currValExpr, fieldExpr, input.value, o.THIS_EXPR.prop('context'), statements, detectChangesInInputsMethod);
bind(view, currValExpr, fieldExpr, input.value, view.componentContext, statements, detectChangesInInputsMethod);
});

@@ -140,0 +140,0 @@ if (isOnPushComp) {

import * as o from '../output/output_ast';
import { CompileTokenMetadata, CompileDirectiveMetadata } from '../compile_metadata';
import { CompileView } from './compile_view';
export declare function getPropertyInView(property: o.Expression, viewPath: CompileView[]): o.Expression;
export declare function getPropertyInView(property: o.Expression, callingView: CompileView, definedView: CompileView): o.Expression;
export declare function injectFromViewParentInjector(token: CompileTokenMetadata, optional: boolean): o.Expression;

@@ -9,1 +9,2 @@ export declare function getViewFactoryName(component: CompileDirectiveMetadata, embeddedTemplateIndex: number): string;

export declare function createFlatArray(expressions: o.Expression[]): o.Expression;
export declare function createPureProxy(fn: o.Expression, argCount: number, pureProxyProp: o.ReadPropExpr, view: CompileView): void;

@@ -1,5 +0,7 @@

import { isPresent } from '../../src/facade/lang';
import { isPresent, isBlank } from '../../src/facade/lang';
import { BaseException } from '../../src/facade/exceptions';
import * as o from '../output/output_ast';
export function getPropertyInView(property, viewPath) {
if (viewPath.length === 0) {
import { Identifiers } from '../identifiers';
export function getPropertyInView(property, callingView, definedView) {
if (callingView === definedView) {
return property;

@@ -9,12 +11,16 @@ }

var viewProp = o.THIS_EXPR;
for (var i = 0; i < viewPath.length; i++) {
viewProp = viewProp.prop('declarationAppElement').prop('parentView');
var currView = callingView;
while (currView !== definedView && isPresent(currView.declarationElement.view)) {
currView = currView.declarationElement.view;
viewProp = viewProp.prop('parent');
}
if (currView !== definedView) {
throw new BaseException(`Internal error: Could not calculate a property in a parent view: ${property}`);
}
if (property instanceof o.ReadPropExpr) {
var lastView = viewPath[viewPath.length - 1];
let readPropExpr = property;
// Note: Don't cast for members of the AppView base class...
if (lastView.fields.some((field) => field.name == readPropExpr.name) ||
lastView.getters.some((field) => field.name == readPropExpr.name)) {
viewProp = viewProp.cast(lastView.classType);
if (definedView.fields.some((field) => field.name == readPropExpr.name) ||
definedView.getters.some((field) => field.name == readPropExpr.name)) {
viewProp = viewProp.cast(definedView.classType);
}

@@ -70,2 +76,10 @@ }

}
export function createPureProxy(fn, argCount, pureProxyProp, view) {
view.fields.push(new o.ClassField(pureProxyProp.name, null, [o.StmtModifier.Private]));
var pureProxyId = argCount < Identifiers.pureProxies.length ? Identifiers.pureProxies[argCount] : null;
if (isBlank(pureProxyId)) {
throw new BaseException(`Unsupported number of argument for pure functions: ${argCount}`);
}
view.createMethod.addStmt(o.THIS_EXPR.prop(pureProxyProp.name).set(o.importExpr(pureProxyId).callFn([fn])).toStmt());
}
//# sourceMappingURL=util.js.map

@@ -5,6 +5,7 @@ import { ListWrapper } from '../../src/facade/collection';

import { bindRenderOutputs, collectEventListeners, bindDirectiveOutputs } from './event_binder';
import { bindDirectiveAfterContentLifecycleCallbacks, bindDirectiveAfterViewLifecycleCallbacks, bindDirectiveDestroyLifecycleCallbacks, bindDirectiveDetectChangesLifecycleCallbacks } from './lifecycle_binder';
import { bindDirectiveAfterContentLifecycleCallbacks, bindDirectiveAfterViewLifecycleCallbacks, bindDirectiveDestroyLifecycleCallbacks, bindPipeDestroyLifecycleCallbacks, bindDirectiveDetectChangesLifecycleCallbacks } from './lifecycle_binder';
export function bindView(view, parsedTemplate) {
var visitor = new ViewBinderVisitor(view);
templateVisitAll(visitor, parsedTemplate);
view.pipes.forEach((pipe) => { bindPipeDestroyLifecycleCallbacks(pipe.meta, pipe.instance, pipe.view); });
}

@@ -61,2 +62,3 @@ class ViewBinderVisitor {

});
bindView(compileElement.embeddedView, ast.children);
return null;

@@ -69,2 +71,3 @@ }

}
visitReference(ast, ctx) { return null; }
visitVariable(ast, ctx) { return null; }

@@ -71,0 +74,0 @@ visitDirectiveProperty(ast, context) { return null; }

@@ -10,2 +10,3 @@ import * as o from '../output/output_ast';

}
export declare function buildView(view: CompileView, template: TemplateAst[], targetDependencies: ViewCompileDependency[], targetStatements: o.Statement[]): number;
export declare function buildView(view: CompileView, template: TemplateAst[], targetDependencies: ViewCompileDependency[]): number;
export declare function finishView(view: CompileView, targetStatements: o.Statement[]): void;

@@ -13,3 +13,2 @@ import { ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';

import { CompileIdentifierMetadata } from '../compile_metadata';
import { bindView } from './view_binder';
const IMPLICIT_TEMPLATE_VAR = '\$implicit';

@@ -26,19 +25,22 @@ const CLASS_ATTR = 'class';

}
export function buildView(view, template, targetDependencies, targetStatements) {
var builderVisitor = new ViewBuilderVisitor(view, targetDependencies, targetStatements);
export function buildView(view, template, targetDependencies) {
var builderVisitor = new ViewBuilderVisitor(view, targetDependencies);
templateVisitAll(builderVisitor, template, view.declarationElement.isNull() ?
view.declarationElement :
view.declarationElement.parent);
// Need to separate binding from creation to be able to refer to
// variables that have been declared after usage.
bindView(view, template);
return builderVisitor.nestedViewCount;
}
export function finishView(view, targetStatements) {
view.afterNodes();
createViewTopLevelStmts(view, targetStatements);
return builderVisitor.nestedViewCount;
view.nodes.forEach((node) => {
if (node instanceof CompileElement && node.hasEmbeddedView) {
finishView(node.embeddedView, targetStatements);
}
});
}
class ViewBuilderVisitor {
constructor(view, targetDependencies, targetStatements) {
constructor(view, targetDependencies) {
this.view = view;
this.targetDependencies = targetDependencies;
this.targetStatements = targetStatements;
this.nestedViewCount = 0;

@@ -142,3 +144,2 @@ }

var directives = ast.directives.map(directiveAst => directiveAst.directive);
var variables = _readHtmlAndDirectiveVariables(ast.exportAsVars, ast.directives, this.view.viewType);
var htmlAttrs = _readHtmlAttrs(ast.attrs);

@@ -152,3 +153,3 @@ var attrNameAndValues = _mergeHtmlAndDirectiveAttrs(htmlAttrs, directives);

}
var compileElement = new CompileElement(parent, this.view, nodeIndex, renderNode, ast, component, directives, ast.providers, ast.hasViewContainer, false, variables);
var compileElement = new CompileElement(parent, this.view, nodeIndex, renderNode, ast, component, directives, ast.providers, ast.hasViewContainer, false, ast.references);
this.view.nodes.push(compileElement);

@@ -181,3 +182,4 @@ var compViewExpr = null;

}
this.view.createMethod.addStmt(compViewExpr.callMethod('create', [codeGenContentNodes, o.NULL_EXPR]).toStmt());
this.view.createMethod.addStmt(compViewExpr.callMethod('create', [compileElement.getComponent(), codeGenContentNodes, o.NULL_EXPR])
.toStmt());
}

@@ -197,10 +199,9 @@ return null;

var renderNode = o.THIS_EXPR.prop(fieldName);
var templateVariableBindings = ast.vars.map(varAst => [varAst.value.length > 0 ? varAst.value : IMPLICIT_TEMPLATE_VAR, varAst.name]);
var templateVariableBindings = ast.variables.map(varAst => [varAst.value.length > 0 ? varAst.value : IMPLICIT_TEMPLATE_VAR, varAst.name]);
var directives = ast.directives.map(directiveAst => directiveAst.directive);
var compileElement = new CompileElement(parent, this.view, nodeIndex, renderNode, ast, null, directives, ast.providers, ast.hasViewContainer, true, {});
var compileElement = new CompileElement(parent, this.view, nodeIndex, renderNode, ast, null, directives, ast.providers, ast.hasViewContainer, true, ast.references);
this.view.nodes.push(compileElement);
this.nestedViewCount++;
var embeddedView = new CompileView(this.view.component, this.view.genConfig, this.view.pipeMetas, o.NULL_EXPR, this.view.viewIndex + this.nestedViewCount, compileElement, templateVariableBindings);
this.nestedViewCount +=
buildView(embeddedView, ast.children, this.targetDependencies, this.targetStatements);
this.nestedViewCount += buildView(embeddedView, ast.children, this.targetDependencies);
compileElement.beforeChildren();

@@ -216,2 +217,3 @@ this._addRootNodeAndProject(compileElement, ast.ngContentIndex, parent);

}
visitReference(ast, ctx) { return null; }
visitVariable(ast, ctx) { return null; }

@@ -237,16 +239,2 @@ visitDirectiveProperty(ast, context) { return null; }

}
function _readHtmlAndDirectiveVariables(elementExportAsVars, directives, viewType) {
var variables = {};
var component = null;
directives.forEach((directive) => {
if (directive.directive.isComponent) {
component = directive.directive;
}
directive.exportAsVars.forEach(varAst => { variables[varAst.name] = identifierToken(directive.directive.type); });
});
elementExportAsVars.forEach((varAst) => {
variables[varAst.name] = isPresent(component) ? identifierToken(component.type) : null;
});
return variables;
}
function mergeAttributeValue(attrName, attrValue1, attrValue2) {

@@ -297,3 +285,3 @@ if (attrName == CLASS_ATTR || attrName == STYLE_ATTR) {

}
StringMapWrapper.forEach(compileElement.variableTokens, (token, varName) => {
StringMapWrapper.forEach(compileElement.referenceTokens, (token, varName) => {
varTokenEntries.push([varName, isPresent(token) ? createDiTokenExpression(token) : o.NULL_EXPR]);

@@ -310,3 +298,2 @@ });

function createViewClass(view, renderCompTypeVar, nodeDebugInfosVar) {
var emptyTemplateVariableBindings = view.templateVariableBindings.map((entry) => [entry[0], o.NULL_EXPR]);
var viewConstructorArgs = [

@@ -317,18 +304,15 @@ new o.FnParam(ViewConstructorVars.viewUtils.name, o.importType(Identifiers.ViewUtils)),

];
var viewConstructor = new o.ClassMethod(null, viewConstructorArgs, [
o.SUPER_EXPR.callFn([
o.variable(view.className),
renderCompTypeVar,
ViewTypeEnum.fromValue(view.viewType),
o.literalMap(emptyTemplateVariableBindings),
ViewConstructorVars.viewUtils,
ViewConstructorVars.parentInjector,
ViewConstructorVars.declarationEl,
ChangeDetectionStrategyEnum.fromValue(getChangeDetectionMode(view)),
o.literal(view.literalArrayCount),
o.literal(view.literalMapCount),
nodeDebugInfosVar
])
.toStmt()
]);
var superConstructorArgs = [
o.variable(view.className),
renderCompTypeVar,
ViewTypeEnum.fromValue(view.viewType),
ViewConstructorVars.viewUtils,
ViewConstructorVars.parentInjector,
ViewConstructorVars.declarationEl,
ChangeDetectionStrategyEnum.fromValue(getChangeDetectionMode(view))
];
if (view.genConfig.genDebugInfo) {
superConstructorArgs.push(nodeDebugInfosVar);
}
var viewConstructor = new o.ClassMethod(null, viewConstructorArgs, [o.SUPER_EXPR.callFn(superConstructorArgs).toStmt()]);
var viewMethods = [

@@ -346,3 +330,4 @@ new o.ClassMethod('createInternal', [new o.FnParam(rootSelectorVar.name, o.STRING_TYPE)], generateCreateMethod(view), o.importType(Identifiers.AppElement)),

].concat(view.eventHandlerMethods);
var viewClass = new o.ClassStmt(view.className, o.importExpr(Identifiers.AppView, [getContextType(view)]), view.fields, view.getters, viewConstructor, viewMethods.filter((method) => method.body.length > 0));
var superClass = view.genConfig.genDebugInfo ? Identifiers.DebugAppView : Identifiers.AppView;
var viewClass = new o.ClassStmt(view.className, o.importExpr(superClass, [getContextType(view)]), view.fields, view.getters, viewConstructor, viewMethods.filter((method) => method.body.length > 0));
return viewClass;

@@ -462,4 +447,6 @@ }

function getContextType(view) {
var typeMeta = view.component.type;
return typeMeta.isHost ? o.DYNAMIC_TYPE : o.importType(typeMeta);
if (view.viewType === ViewType.COMPONENT) {
return o.importType(view.component.type);
}
return o.DYNAMIC_TYPE;
}

@@ -466,0 +453,0 @@ function getChangeDetectionMode(view) {

@@ -13,3 +13,4 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

import { CompileView } from './compile_view';
import { buildView } from './view_builder';
import { buildView, finishView } from './view_builder';
import { bindView } from './view_binder';
import { CompilerConfig } from '../config';

@@ -31,3 +32,7 @@ export class ViewCompileResult {

var view = new CompileView(component, this._genConfig, pipes, styles, 0, CompileElement.createNull(), []);
buildView(view, template, dependencies, statements);
buildView(view, template, dependencies);
// Need to separate binding from creation to be able to refer to
// variables that have been declared after usage.
bindView(view, template);
finishView(view, statements);
return new ViewCompileResult(statements, view.viewFactory.name, dependencies);

@@ -34,0 +39,0 @@ }

{
"name": "@angular/compiler",
"version": "0.0.0-0",
"version": "0.0.0-1",
"description": "",

@@ -11,4 +11,4 @@ "main": "index.js",

"peerDependencies": {
"@angular/core": "0.0.0-0"
"@angular/core": "0.0.0-1"
}
}

@@ -205,3 +205,4 @@ import { ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';

ngContentSelectors: string[];
constructor({encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors}?: {
baseUrl: string;
constructor({encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors, baseUrl}?: {
encapsulation?: ViewEncapsulation;

@@ -213,2 +214,3 @@ template?: string;

ngContentSelectors?: string[];
baseUrl?: string;
});

@@ -215,0 +217,0 @@ static fromJson(data: {

@@ -391,3 +391,3 @@ "use strict";

function CompileTemplateMetadata(_a) {
var _b = _a === void 0 ? {} : _a, encapsulation = _b.encapsulation, template = _b.template, templateUrl = _b.templateUrl, styles = _b.styles, styleUrls = _b.styleUrls, ngContentSelectors = _b.ngContentSelectors;
var _b = _a === void 0 ? {} : _a, encapsulation = _b.encapsulation, template = _b.template, templateUrl = _b.templateUrl, styles = _b.styles, styleUrls = _b.styleUrls, ngContentSelectors = _b.ngContentSelectors, baseUrl = _b.baseUrl;
this.encapsulation = lang_1.isPresent(encapsulation) ? encapsulation : core_1.ViewEncapsulation.Emulated;

@@ -399,2 +399,3 @@ this.template = template;

this.ngContentSelectors = lang_1.isPresent(ngContentSelectors) ? ngContentSelectors : [];
this.baseUrl = baseUrl;
}

@@ -410,3 +411,4 @@ CompileTemplateMetadata.fromJson = function (data) {

styleUrls: data['styleUrls'],
ngContentSelectors: data['ngContentSelectors']
ngContentSelectors: data['ngContentSelectors'],
baseUrl: data['baseUrl']
});

@@ -421,3 +423,4 @@ };

'styleUrls': this.styleUrls,
'ngContentSelectors': this.ngContentSelectors
'ngContentSelectors': this.ngContentSelectors,
'baseUrl': this.baseUrl
};

@@ -424,0 +427,0 @@ };

@@ -28,3 +28,3 @@ "use strict";

var directive_normalizer_1 = require('./directive_normalizer');
var runtime_metadata_1 = require('./runtime_metadata');
var metadata_resolver_1 = require('./metadata_resolver');
var style_compiler_1 = require('./style_compiler');

@@ -55,3 +55,3 @@ var view_compiler_1 = require('./view_compiler/view_compiler');

directive_normalizer_1.DirectiveNormalizer,
runtime_metadata_1.RuntimeMetadataResolver,
metadata_resolver_1.CompileMetadataResolver,
url_resolver_2.DEFAULT_PACKAGE_URL_PROVIDER,

@@ -70,6 +70,2 @@ style_compiler_1.StyleCompiler,

];
// CONST_EXPR
// /* @const */
// /* @Provider */ ({provide: CompilerConfig, useFactory: _createCompilerConfig, deps: []}),
// const Provider(CompilerConfig, {useFactory: _createCompilerConfig, deps: []}),
//# sourceMappingURL=compiler.js.map

@@ -56,6 +56,6 @@ "use strict";

if (lang_1.isPresent(template.template)) {
return async_1.PromiseWrapper.resolve(this.normalizeLoadedTemplate(directiveType, template, template.template, directiveType.moduleUrl));
return async_1.PromiseWrapper.resolve(this.normalizeLoadedTemplate(directiveType, template, template.template, template.baseUrl));
}
else if (lang_1.isPresent(template.templateUrl)) {
var sourceAbsUrl = this._urlResolver.resolve(directiveType.moduleUrl, template.templateUrl);
var sourceAbsUrl = this._urlResolver.resolve(template.baseUrl, template.templateUrl);
return this._xhr.get(sourceAbsUrl)

@@ -81,3 +81,3 @@ .then(function (templateContent) { return _this.normalizeLoadedTemplate(directiveType, template, templateContent, sourceAbsUrl); });

.concat(templateMeta.styleUrls.filter(style_url_resolver_1.isStyleUrlResolvable)
.map(function (url) { return _this._urlResolver.resolve(directiveType.moduleUrl, url); }));
.map(function (url) { return _this._urlResolver.resolve(templateMeta.baseUrl, url); }));
var allResolvedStyles = allStyles.map(function (style) {

@@ -84,0 +84,0 @@ var styleWithImports = style_url_resolver_1.extractStyleUrls(_this._urlResolver, templateAbsUrl, style);

@@ -25,3 +25,4 @@ import { BaseException } from '../../src/facade/exceptions';

isKeyword(): boolean;
isKeywordVar(): boolean;
isKeywordDeprecatedVar(): boolean;
isKeywordLet(): boolean;
isKeywordNull(): boolean;

@@ -28,0 +29,0 @@ isKeywordUndefined(): boolean;

@@ -66,3 +66,6 @@ "use strict";

Token.prototype.isKeyword = function () { return (this.type == TokenType.Keyword); };
Token.prototype.isKeywordVar = function () { return (this.type == TokenType.Keyword && this.strValue == "var"); };
Token.prototype.isKeywordDeprecatedVar = function () {
return (this.type == TokenType.Keyword && this.strValue == "var");
};
Token.prototype.isKeywordLet = function () { return (this.type == TokenType.Keyword && this.strValue == "let"); };
Token.prototype.isKeywordNull = function () { return (this.type == TokenType.Keyword && this.strValue == "null"); };

@@ -455,3 +458,3 @@ Token.prototype.isKeywordUndefined = function () {

]);
var KEYWORDS = collection_1.SetWrapper.createFromList(['var', 'null', 'undefined', 'true', 'false', 'if', 'else']);
var KEYWORDS = collection_1.SetWrapper.createFromList(['var', 'let', 'null', 'undefined', 'true', 'false', 'if', 'else']);
//# sourceMappingURL=lexer.js.map

@@ -8,2 +8,7 @@ import { Lexer, Token } from './lexer';

}
export declare class TemplateBindingParseResult {
templateBindings: TemplateBinding[];
warnings: string[];
constructor(templateBindings: TemplateBinding[], warnings: string[]);
}
export declare class Parser {

@@ -17,3 +22,3 @@ /** @internal */ _lexer: Lexer;

private _parseQuote(input, location);
parseTemplateBindings(input: string, location: any): TemplateBinding[];
parseTemplateBindings(input: string, location: any): TemplateBindingParseResult;
parseInterpolation(input: string, location: any): ASTWithSource;

@@ -39,4 +44,5 @@ splitInterpolation(input: string, location: string): SplitInterpolation;

optionalCharacter(code: number): boolean;
optionalKeywordVar(): boolean;
peekKeywordVar(): boolean;
peekKeywordLet(): boolean;
peekDeprecatedKeywordVar(): boolean;
peekDeprecatedOperatorHash(): boolean;
expectCharacter(code: number): void;

@@ -69,4 +75,4 @@ optionalOperator(op: string): boolean;

expectTemplateBindingKey(): string;
parseTemplateBindings(): any[];
parseTemplateBindings(): TemplateBindingParseResult;
error(message: string, index?: number): void;
}

@@ -40,2 +40,10 @@ "use strict";

exports.SplitInterpolation = SplitInterpolation;
var TemplateBindingParseResult = (function () {
function TemplateBindingParseResult(templateBindings, warnings) {
this.templateBindings = templateBindings;
this.warnings = warnings;
}
return TemplateBindingParseResult;
}());
exports.TemplateBindingParseResult = TemplateBindingParseResult;
var Parser = (function () {

@@ -200,12 +208,5 @@ function Parser(/** @internal */ _lexer) {

};
_ParseAST.prototype.optionalKeywordVar = function () {
if (this.peekKeywordVar()) {
this.advance();
return true;
}
else {
return false;
}
};
_ParseAST.prototype.peekKeywordVar = function () { return this.next.isKeywordVar() || this.next.isOperator('#'); };
_ParseAST.prototype.peekKeywordLet = function () { return this.next.isKeywordLet(); };
_ParseAST.prototype.peekDeprecatedKeywordVar = function () { return this.next.isKeywordDeprecatedVar(); };
_ParseAST.prototype.peekDeprecatedOperatorHash = function () { return this.next.isOperator('#'); };
_ParseAST.prototype.expectCharacter = function (code) {

@@ -588,4 +589,16 @@ if (this.optionalCharacter(code))

var prefix = null;
var warnings = [];
while (this.index < this.tokens.length) {
var keyIsVar = this.optionalKeywordVar();
var keyIsVar = this.peekKeywordLet();
if (!keyIsVar && this.peekDeprecatedKeywordVar()) {
keyIsVar = true;
warnings.push("\"var\" inside of expressions is deprecated. Use \"let\" instead!");
}
if (!keyIsVar && this.peekDeprecatedOperatorHash()) {
keyIsVar = true;
warnings.push("\"#\" inside of expressions is deprecated. Use \"let\" instead!");
}
if (keyIsVar) {
this.advance();
}
var key = this.expectTemplateBindingKey();

@@ -611,3 +624,4 @@ if (!keyIsVar) {

}
else if (this.next !== lexer_1.EOF && !this.peekKeywordVar()) {
else if (this.next !== lexer_1.EOF && !this.peekKeywordLet() && !this.peekDeprecatedKeywordVar() &&
!this.peekDeprecatedOperatorHash()) {
var start = this.inputIndex;

@@ -623,3 +637,3 @@ var ast = this.parsePipe();

}
return bindings;
return new TemplateBindingParseResult(bindings, warnings);
};

@@ -626,0 +640,0 @@ _ParseAST.prototype.error = function (message, index) {

@@ -133,2 +133,3 @@ export interface BrowserNodeGlobal {

export declare function print(obj: Error | Object): void;
export declare function warn(obj: Error | Object): void;
export declare class Json {

@@ -135,0 +136,0 @@ static parse(s: string): Object;

@@ -368,2 +368,6 @@ "use strict";

exports.print = print;
function warn(obj) {
console.warn(obj);
}
exports.warn = warn;
// Can't be all uppercase as our transpiler would think it is a special directive...

@@ -422,3 +426,3 @@ var Json = (function () {

if (isBlank(_symbolIterator)) {
if (isPresent(Symbol) && isPresent(Symbol.iterator)) {
if (isPresent(globalScope.Symbol) && isPresent(Symbol.iterator)) {
_symbolIterator = Symbol.iterator;

@@ -425,0 +429,0 @@ }

@@ -5,2 +5,3 @@ import { CompileIdentifierMetadata, CompileTokenMetadata } from './compile_metadata';

static AppView: CompileIdentifierMetadata;
static DebugAppView: CompileIdentifierMetadata;
static AppElement: CompileIdentifierMetadata;

@@ -29,3 +30,5 @@ static ElementRef: CompileIdentifierMetadata;

static interpolate: CompileIdentifierMetadata;
static castByValue: CompileIdentifierMetadata;
static pureProxies: CompileIdentifierMetadata[];
}
export declare function identifierToken(identifier: CompileIdentifierMetadata): CompileTokenMetadata;

@@ -14,2 +14,3 @@ "use strict";

var impAppView = core_private_1.AppView;
var impDebugAppView = core_private_1.DebugAppView;
var impDebugContext = core_private_1.DebugContext;

@@ -38,2 +39,3 @@ var impAppElement = core_private_1.AppElement;

var impCheckBinding = core_private_1.checkBinding;
var impCastByValue = core_private_1.castByValue;
var Identifiers = (function () {

@@ -48,2 +50,3 @@ function Identifiers() {

Identifiers.AppView = new compile_metadata_1.CompileIdentifierMetadata({ name: 'AppView', moduleUrl: APP_VIEW_MODULE_URL, runtime: impAppView });
Identifiers.DebugAppView = new compile_metadata_1.CompileIdentifierMetadata({ name: 'DebugAppView', moduleUrl: APP_VIEW_MODULE_URL, runtime: impDebugAppView });
Identifiers.AppElement = new compile_metadata_1.CompileIdentifierMetadata({

@@ -136,2 +139,16 @@ name: 'AppElement',

Identifiers.interpolate = new compile_metadata_1.CompileIdentifierMetadata({ name: 'interpolate', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: impInterpolate });
Identifiers.castByValue = new compile_metadata_1.CompileIdentifierMetadata({ name: 'castByValue', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: impCastByValue });
Identifiers.pureProxies = [
null,
new compile_metadata_1.CompileIdentifierMetadata({ name: 'pureProxy1', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: core_private_1.pureProxy1 }),
new compile_metadata_1.CompileIdentifierMetadata({ name: 'pureProxy2', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: core_private_1.pureProxy2 }),
new compile_metadata_1.CompileIdentifierMetadata({ name: 'pureProxy3', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: core_private_1.pureProxy3 }),
new compile_metadata_1.CompileIdentifierMetadata({ name: 'pureProxy4', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: core_private_1.pureProxy4 }),
new compile_metadata_1.CompileIdentifierMetadata({ name: 'pureProxy5', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: core_private_1.pureProxy5 }),
new compile_metadata_1.CompileIdentifierMetadata({ name: 'pureProxy6', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: core_private_1.pureProxy6 }),
new compile_metadata_1.CompileIdentifierMetadata({ name: 'pureProxy7', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: core_private_1.pureProxy7 }),
new compile_metadata_1.CompileIdentifierMetadata({ name: 'pureProxy8', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: core_private_1.pureProxy8 }),
new compile_metadata_1.CompileIdentifierMetadata({ name: 'pureProxy9', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: core_private_1.pureProxy9 }),
new compile_metadata_1.CompileIdentifierMetadata({ name: 'pureProxy10', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: core_private_1.pureProxy10 }),
];
return Identifiers;

@@ -138,0 +155,0 @@ }());

@@ -188,2 +188,7 @@ "use strict";

name = this.getBuiltinMethodName(expr.builtin);
if (lang_1.isBlank(name)) {
// some builtins just mean to skip the call.
// e.g. `bind` in Dart.
return null;
}
}

@@ -247,2 +252,3 @@ ctx.print("." + name + "(");

AbstractEmitterVisitor.prototype.visitConditionalExpr = function (ast, ctx) {
ctx.print("(");
ast.condition.visitExpression(this, ctx);

@@ -253,2 +259,3 @@ ctx.print('? ');

ast.falseCase.visitExpression(this, ctx);
ctx.print(")");
return null;

@@ -255,0 +262,0 @@ };

@@ -154,2 +154,5 @@ "use strict";

break;
case o.BuiltinMethod.bind:
name = 'bind';
break;
default:

@@ -156,0 +159,0 @@ throw new exceptions_1.BaseException("Unknown builtin method: " + method);

@@ -211,2 +211,5 @@ "use strict";

break;
case o.BuiltinMethod.bind:
name = null;
break;
default:

@@ -213,0 +216,0 @@ throw new exceptions_1.BaseException("Unknown builtin method: " + method);

@@ -15,4 +15,11 @@ "use strict";

if (superClass === core_private_1.AppView) {
// We are always using DebugAppView as parent.
// However, in prod mode we generate a constructor call that does
// not have the argument for the debugNodeInfos.
args = args.concat([null]);
return new _InterpretiveAppView(args, props, getters, methods);
}
else if (superClass === core_private_1.DebugAppView) {
return new _InterpretiveAppView(args, props, getters, methods);
}
throw new exceptions_1.BaseException("Can't instantiate class " + superClass + " in interpretative mode");

@@ -26,3 +33,3 @@ };

function _InterpretiveAppView(args, props, getters, methods) {
_super.call(this, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10]);
_super.call(this, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
this.props = props;

@@ -78,3 +85,3 @@ this.getters = getters;

return _InterpretiveAppView;
}(core_private_1.AppView));
}(core_private_1.DebugAppView));
//# sourceMappingURL=interpretive_view.js.map

@@ -135,2 +135,3 @@ import { CompileIdentifierMetadata } from '../compile_metadata';

SubscribeObservable = 1,
bind = 2,
}

@@ -137,0 +138,0 @@ export declare class InvokeMethodExpr extends Expression {

@@ -266,2 +266,3 @@ "use strict";

BuiltinMethod[BuiltinMethod["SubscribeObservable"] = 1] = "SubscribeObservable";
BuiltinMethod[BuiltinMethod["bind"] = 2] = "bind";
})(exports.BuiltinMethod || (exports.BuiltinMethod = {}));

@@ -486,3 +487,2 @@ var BuiltinMethod = exports.BuiltinMethod;

}
;
LiteralMapExpr.prototype.visitExpression = function (visitor, context) {

@@ -489,0 +489,0 @@ return visitor.visitLiteralMapExpr(this, context);

@@ -196,2 +196,10 @@ "use strict";

break;
case o.BuiltinMethod.bind:
if (lang_1.IS_DART) {
result = receiver;
}
else {
result = receiver.bind(args[0]);
}
break;
default:

@@ -350,2 +358,5 @@ throw new exceptions_1.BaseException("Unknown builtin method " + expr.builtin);

}
else if (di.methods.has(ast.name)) {
result = di.methods.get(ast.name);
}
else {

@@ -352,0 +363,0 @@ result = core_1.reflector.getter(ast.name)(receiver);

@@ -131,2 +131,5 @@ "use strict";

}
else {
ctx.print(": any");
}
ctx.println(";");

@@ -291,2 +294,5 @@ };

break;
case o.BuiltinMethod.bind:
name = 'bind';
break;
default:

@@ -293,0 +299,0 @@ throw new exceptions_1.BaseException("Unknown builtin method: " + method);

@@ -20,7 +20,12 @@ export declare class ParseLocation {

}
export declare enum ParseErrorLevel {
WARNING = 0,
FATAL = 1,
}
export declare abstract class ParseError {
span: ParseSourceSpan;
msg: string;
constructor(span: ParseSourceSpan, msg: string);
level: ParseErrorLevel;
constructor(span: ParseSourceSpan, msg: string, level?: ParseErrorLevel);
toString(): string;
}

@@ -32,6 +32,13 @@ "use strict";

exports.ParseSourceSpan = ParseSourceSpan;
(function (ParseErrorLevel) {
ParseErrorLevel[ParseErrorLevel["WARNING"] = 0] = "WARNING";
ParseErrorLevel[ParseErrorLevel["FATAL"] = 1] = "FATAL";
})(exports.ParseErrorLevel || (exports.ParseErrorLevel = {}));
var ParseErrorLevel = exports.ParseErrorLevel;
var ParseError = (function () {
function ParseError(span, msg) {
function ParseError(span, msg, level) {
if (level === void 0) { level = ParseErrorLevel.FATAL; }
this.span = span;
this.msg = msg;
this.level = level;
}

@@ -38,0 +45,0 @@ ParseError.prototype.toString = function () {

@@ -1,2 +0,2 @@

import { VariableAst, AttrAst, DirectiveAst, ProviderAst } from './template_ast';
import { AttrAst, DirectiveAst, ProviderAst, ReferenceAst } from './template_ast';
import { CompileTokenMap, CompileQueryMetadata, CompileDirectiveMetadata } from './compile_metadata';

@@ -33,3 +33,3 @@ import { ParseSourceSpan, ParseError } from './parse_util';

private _hasViewContainer;
constructor(_viewContext: ProviderViewContext, _parent: ProviderElementContext, _isViewRoot: boolean, _directiveAsts: DirectiveAst[], attrs: AttrAst[], vars: VariableAst[], _sourceSpan: ParseSourceSpan);
constructor(_viewContext: ProviderViewContext, _parent: ProviderElementContext, _isViewRoot: boolean, _directiveAsts: DirectiveAst[], attrs: AttrAst[], refs: ReferenceAst[], _sourceSpan: ParseSourceSpan);
afterElement(): void;

@@ -36,0 +36,0 @@ transformProviders: ProviderAst[];

@@ -40,3 +40,3 @@ "use strict";

var ProviderElementContext = (function () {
function ProviderElementContext(_viewContext, _parent, _isViewRoot, _directiveAsts, attrs, vars, _sourceSpan) {
function ProviderElementContext(_viewContext, _parent, _isViewRoot, _directiveAsts, attrs, refs, _sourceSpan) {
var _this = this;

@@ -59,5 +59,4 @@ this._viewContext = _viewContext;

this._allProviders.values().forEach(function (provider) { _this._addQueryReadsTo(provider.token, queriedTokens); });
vars.forEach(function (varAst) {
var varToken = new compile_metadata_1.CompileTokenMetadata({ value: varAst.name });
_this._addQueryReadsTo(varToken, queriedTokens);
refs.forEach(function (refAst) {
_this._addQueryReadsTo(new compile_metadata_1.CompileTokenMetadata({ value: refAst.name }), queriedTokens);
});

@@ -91,3 +90,3 @@ if (lang_1.isPresent(queriedTokens.get(identifiers_1.identifierToken(identifiers_1.Identifiers.ViewContainerRef)))) {

var sortedDirectives = collection_1.ListWrapper.clone(this._directiveAsts);
collection_1.ListWrapper.sort(this._directiveAsts, function (dir1, dir2) { return sortedProviderTypes.indexOf(dir1.directive.type) -
collection_1.ListWrapper.sort(sortedDirectives, function (dir1, dir2) { return sortedProviderTypes.indexOf(dir1.directive.type) -
sortedProviderTypes.indexOf(dir2.directive.type); });

@@ -94,0 +93,0 @@ return sortedDirectives;

@@ -7,3 +7,3 @@ import { ComponentFactory, ComponentResolver } from '@angular/core';

import { DirectiveNormalizer } from './directive_normalizer';
import { RuntimeMetadataResolver } from './runtime_metadata';
import { CompileMetadataResolver } from './metadata_resolver';
import { CompilerConfig } from './config';

@@ -17,3 +17,3 @@ import { XHR } from './xhr';

export declare class RuntimeCompiler implements ComponentResolver {
private _runtimeMetadataResolver;
private _metadataResolver;
private _templateNormalizer;

@@ -29,3 +29,3 @@ private _templateParser;

private _compiledTemplateDone;
constructor(_runtimeMetadataResolver: RuntimeMetadataResolver, _templateNormalizer: DirectiveNormalizer, _templateParser: TemplateParser, _styleCompiler: StyleCompiler, _viewCompiler: ViewCompiler, _xhr: XHR, _genConfig: CompilerConfig);
constructor(_metadataResolver: CompileMetadataResolver, _templateNormalizer: DirectiveNormalizer, _templateParser: TemplateParser, _styleCompiler: StyleCompiler, _viewCompiler: ViewCompiler, _xhr: XHR, _genConfig: CompilerConfig);
resolveComponent(componentType: Type): Promise<ComponentFactory>;

@@ -32,0 +32,0 @@ clearCache(): void;

@@ -21,3 +21,3 @@ "use strict";

var directive_normalizer_1 = require('./directive_normalizer');
var runtime_metadata_1 = require('./runtime_metadata');
var metadata_resolver_1 = require('./metadata_resolver');
var config_1 = require('./config');

@@ -35,4 +35,4 @@ var ir = require('./output/output_ast');

var RuntimeCompiler = (function () {
function RuntimeCompiler(_runtimeMetadataResolver, _templateNormalizer, _templateParser, _styleCompiler, _viewCompiler, _xhr, _genConfig) {
this._runtimeMetadataResolver = _runtimeMetadataResolver;
function RuntimeCompiler(_metadataResolver, _templateNormalizer, _templateParser, _styleCompiler, _viewCompiler, _xhr, _genConfig) {
this._metadataResolver = _metadataResolver;
this._templateNormalizer = _templateNormalizer;

@@ -50,3 +50,3 @@ this._templateParser = _templateParser;

RuntimeCompiler.prototype.resolveComponent = function (componentType) {
var compMeta = this._runtimeMetadataResolver.getDirectiveMetadata(componentType);
var compMeta = this._metadataResolver.getDirectiveMetadata(componentType);
var hostCacheKey = this._hostCacheKeys.get(componentType);

@@ -96,4 +96,4 @@ if (lang_1.isBlank(hostCacheKey)) {

var childCacheKey = dep.comp.type.runtime;
var childViewDirectives = _this._runtimeMetadataResolver.getViewDirectivesMetadata(dep.comp.type.runtime);
var childViewPipes = _this._runtimeMetadataResolver.getViewPipesMetadata(dep.comp.type.runtime);
var childViewDirectives = _this._metadataResolver.getViewDirectivesMetadata(dep.comp.type.runtime);
var childViewPipes = _this._metadataResolver.getViewPipesMetadata(dep.comp.type.runtime);
var childIsRecursive = collection_1.ListWrapper.contains(childCompilingComponentsPath, childCacheKey);

@@ -161,3 +161,3 @@ childCompilingComponentsPath.push(childCacheKey);

core_1.Injectable(),
__metadata('design:paramtypes', [runtime_metadata_1.RuntimeMetadataResolver, directive_normalizer_1.DirectiveNormalizer, template_parser_1.TemplateParser, style_compiler_1.StyleCompiler, view_compiler_1.ViewCompiler, xhr_1.XHR, config_1.CompilerConfig])
__metadata('design:paramtypes', [metadata_resolver_1.CompileMetadataResolver, directive_normalizer_1.DirectiveNormalizer, template_parser_1.TemplateParser, style_compiler_1.StyleCompiler, view_compiler_1.ViewCompiler, xhr_1.XHR, config_1.CompilerConfig])
], RuntimeCompiler);

@@ -164,0 +164,0 @@ return RuntimeCompiler;

@@ -72,4 +72,14 @@ import { AST } from './expression_parser/ast';

/**
* A variable declaration on an element (e.g. `#var="expression"`).
* A reference declaration on an element (e.g. `let someName="expression"`).
*/
export declare class ReferenceAst implements TemplateAst {
name: string;
value: CompileTokenMetadata;
sourceSpan: ParseSourceSpan;
constructor(name: string, value: CompileTokenMetadata, sourceSpan: ParseSourceSpan);
visit(visitor: TemplateAstVisitor, context: any): any;
}
/**
* A variable declaration on a <template> (e.g. `var-someName="someLocalName"`).
*/
export declare class VariableAst implements TemplateAst {

@@ -90,3 +100,3 @@ name: string;

outputs: BoundEventAst[];
exportAsVars: VariableAst[];
references: ReferenceAst[];
directives: DirectiveAst[];

@@ -98,9 +108,5 @@ providers: ProviderAst[];

sourceSpan: ParseSourceSpan;
constructor(name: string, attrs: AttrAst[], inputs: BoundElementPropertyAst[], outputs: BoundEventAst[], exportAsVars: VariableAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan);
constructor(name: string, attrs: AttrAst[], inputs: BoundElementPropertyAst[], outputs: BoundEventAst[], references: ReferenceAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan);
visit(visitor: TemplateAstVisitor, context: any): any;
/**
* Whether the element has any active bindings (inputs, outputs, vars, or directives).
*/
isBound(): boolean;
/**
* Get the component associated with this element, if any.

@@ -116,3 +122,4 @@ */

outputs: BoundEventAst[];
vars: VariableAst[];
references: ReferenceAst[];
variables: VariableAst[];
directives: DirectiveAst[];

@@ -124,3 +131,3 @@ providers: ProviderAst[];

sourceSpan: ParseSourceSpan;
constructor(attrs: AttrAst[], outputs: BoundEventAst[], vars: VariableAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan);
constructor(attrs: AttrAst[], outputs: BoundEventAst[], references: ReferenceAst[], variables: VariableAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan);
visit(visitor: TemplateAstVisitor, context: any): any;

@@ -147,5 +154,4 @@ }

hostEvents: BoundEventAst[];
exportAsVars: VariableAst[];
sourceSpan: ParseSourceSpan;
constructor(directive: CompileDirectiveMetadata, inputs: BoundDirectivePropertyAst[], hostProperties: BoundElementPropertyAst[], hostEvents: BoundEventAst[], exportAsVars: VariableAst[], sourceSpan: ParseSourceSpan);
constructor(directive: CompileDirectiveMetadata, inputs: BoundDirectivePropertyAst[], hostProperties: BoundElementPropertyAst[], hostEvents: BoundEventAst[], sourceSpan: ParseSourceSpan);
visit(visitor: TemplateAstVisitor, context: any): any;

@@ -211,2 +217,3 @@ }

visitElement(ast: ElementAst, context: any): any;
visitReference(ast: ReferenceAst, context: any): any;
visitVariable(ast: VariableAst, context: any): any;

@@ -213,0 +220,0 @@ visitEvent(ast: BoundEventAst, context: any): any;

@@ -90,4 +90,19 @@ "use strict";

/**
* A variable declaration on an element (e.g. `#var="expression"`).
* A reference declaration on an element (e.g. `let someName="expression"`).
*/
var ReferenceAst = (function () {
function ReferenceAst(name, value, sourceSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
}
ReferenceAst.prototype.visit = function (visitor, context) {
return visitor.visitReference(this, context);
};
return ReferenceAst;
}());
exports.ReferenceAst = ReferenceAst;
/**
* A variable declaration on a <template> (e.g. `var-someName="someLocalName"`).
*/
var VariableAst = (function () {

@@ -109,3 +124,3 @@ function VariableAst(name, value, sourceSpan) {

var ElementAst = (function () {
function ElementAst(name, attrs, inputs, outputs, exportAsVars, directives, providers, hasViewContainer, children, ngContentIndex, sourceSpan) {
function ElementAst(name, attrs, inputs, outputs, references, directives, providers, hasViewContainer, children, ngContentIndex, sourceSpan) {
this.name = name;

@@ -115,3 +130,3 @@ this.attrs = attrs;

this.outputs = outputs;
this.exportAsVars = exportAsVars;
this.references = references;
this.directives = directives;

@@ -128,15 +143,12 @@ this.providers = providers;

/**
* Whether the element has any active bindings (inputs, outputs, vars, or directives).
*/
ElementAst.prototype.isBound = function () {
return (this.inputs.length > 0 || this.outputs.length > 0 || this.exportAsVars.length > 0 ||
this.directives.length > 0);
};
/**
* Get the component associated with this element, if any.
*/
ElementAst.prototype.getComponent = function () {
return this.directives.length > 0 && this.directives[0].directive.isComponent ?
this.directives[0].directive :
null;
for (var i = 0; i < this.directives.length; i++) {
var dirAst = this.directives[i];
if (dirAst.directive.isComponent) {
return dirAst.directive;
}
}
return null;
};

@@ -150,6 +162,7 @@ return ElementAst;

var EmbeddedTemplateAst = (function () {
function EmbeddedTemplateAst(attrs, outputs, vars, directives, providers, hasViewContainer, children, ngContentIndex, sourceSpan) {
function EmbeddedTemplateAst(attrs, outputs, references, variables, directives, providers, hasViewContainer, children, ngContentIndex, sourceSpan) {
this.attrs = attrs;
this.outputs = outputs;
this.vars = vars;
this.references = references;
this.variables = variables;
this.directives = directives;

@@ -188,3 +201,3 @@ this.providers = providers;

var DirectiveAst = (function () {
function DirectiveAst(directive, inputs, hostProperties, hostEvents, exportAsVars, sourceSpan) {
function DirectiveAst(directive, inputs, hostProperties, hostEvents, sourceSpan) {
this.directive = directive;

@@ -194,3 +207,2 @@ this.inputs = inputs;

this.hostEvents = hostEvents;
this.exportAsVars = exportAsVars;
this.sourceSpan = sourceSpan;

@@ -197,0 +209,0 @@ }

@@ -0,1 +1,2 @@

import { Console } from '../core_private';
import { RecursiveAstVisitor, BindingPipe } from './expression_parser/ast';

@@ -5,3 +6,3 @@ import { Parser } from './expression_parser/parser';

import { HtmlParser } from './html_parser';
import { ParseSourceSpan, ParseError } from './parse_util';
import { ParseSourceSpan, ParseError, ParseErrorLevel } from './parse_util';
import { TemplateAst, TemplateAstVisitor } from './template_ast';

@@ -18,3 +19,3 @@ import { ElementSchemaRegistry } from './schema/element_schema_registry';

export declare class TemplateParseError extends ParseError {
constructor(message: string, span: ParseSourceSpan);
constructor(message: string, span: ParseSourceSpan, level: ParseErrorLevel);
}

@@ -30,4 +31,5 @@ export declare class TemplateParseResult {

private _htmlParser;
private _console;
transforms: TemplateAstVisitor[];
constructor(_exprParser: Parser, _schemaRegistry: ElementSchemaRegistry, _htmlParser: HtmlParser, transforms: TemplateAstVisitor[]);
constructor(_exprParser: Parser, _schemaRegistry: ElementSchemaRegistry, _htmlParser: HtmlParser, _console: Console, transforms: TemplateAstVisitor[]);
parse(component: CompileDirectiveMetadata, template: string, directives: CompileDirectiveMetadata[], pipes: CompilePipeMetadata[], templateUrl: string): TemplateAst[];

@@ -34,0 +36,0 @@ tryParse(component: CompileDirectiveMetadata, template: string, directives: CompileDirectiveMetadata[], pipes: CompilePipeMetadata[], templateUrl: string): TemplateParseResult;

@@ -36,12 +36,15 @@ "use strict";

var util_1 = require('./util');
var identifiers_1 = require('./identifiers');
var provider_parser_1 = require('./provider_parser');
// Group 1 = "bind-"
// Group 2 = "var-" or "#"
// Group 3 = "on-"
// Group 4 = "bindon-"
// Group 5 = the identifier after "bind-", "var-/#", or "on-"
// Group 6 = identifier inside [()]
// Group 7 = identifier inside []
// Group 8 = identifier inside ()
var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(var-|#)|(on-)|(bindon-))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/g;
// Group 2 = "var-"
// Group 3 = "let-"
// Group 4 = "ref-/#"
// Group 5 = "on-"
// Group 6 = "bindon-"
// Group 7 = the identifier after "bind-", "var-/#", or "on-"
// Group 8 = identifier inside [()]
// Group 9 = identifier inside []
// Group 10 = identifier inside ()
var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(var-)|(let-)|(ref-|#)|(on-)|(bindon-))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/g;
var TEMPLATE_ELEMENT = 'template';

@@ -66,4 +69,4 @@ var TEMPLATE_ATTR = 'template';

__extends(TemplateParseError, _super);
function TemplateParseError(message, span) {
_super.call(this, span, message);
function TemplateParseError(message, span, level) {
_super.call(this, span, message, level);
}

@@ -82,6 +85,7 @@ return TemplateParseError;

var TemplateParser = (function () {
function TemplateParser(_exprParser, _schemaRegistry, _htmlParser, transforms) {
function TemplateParser(_exprParser, _schemaRegistry, _htmlParser, _console, transforms) {
this._exprParser = _exprParser;
this._schemaRegistry = _schemaRegistry;
this._htmlParser = _htmlParser;
this._console = _console;
this.transforms = transforms;

@@ -91,4 +95,9 @@ }

var result = this.tryParse(component, template, directives, pipes, templateUrl);
if (lang_1.isPresent(result.errors)) {
var errorString = result.errors.join('\n');
var warnings = result.errors.filter(function (error) { return error.level === parse_util_1.ParseErrorLevel.WARNING; });
var errors = result.errors.filter(function (error) { return error.level === parse_util_1.ParseErrorLevel.FATAL; });
if (warnings.length > 0) {
this._console.warn("Template parse warnings:\n" + warnings.join('\n'));
}
if (errors.length > 0) {
var errorString = errors.join('\n');
throw new exceptions_1.BaseException("Template parse errors:\n" + errorString);

@@ -119,9 +128,9 @@ }

}
return new TemplateParseResult(result);
return new TemplateParseResult(result, errors);
};
TemplateParser = __decorate([
core_1.Injectable(),
__param(3, core_1.Optional()),
__param(3, core_1.Inject(exports.TEMPLATE_TRANSFORMS)),
__metadata('design:paramtypes', [parser_1.Parser, element_schema_registry_1.ElementSchemaRegistry, html_parser_1.HtmlParser, Array])
__param(4, core_1.Optional()),
__param(4, core_1.Inject(exports.TEMPLATE_TRANSFORMS)),
__metadata('design:paramtypes', [parser_1.Parser, element_schema_registry_1.ElementSchemaRegistry, html_parser_1.HtmlParser, core_private_1.Console, Array])
], TemplateParser);

@@ -149,4 +158,5 @@ return TemplateParser;

}
TemplateParseVisitor.prototype._reportError = function (message, sourceSpan) {
this.errors.push(new TemplateParseError(message, sourceSpan));
TemplateParseVisitor.prototype._reportError = function (message, sourceSpan, level) {
if (level === void 0) { level = parse_util_1.ParseErrorLevel.FATAL; }
this.errors.push(new TemplateParseError(message, sourceSpan, level));
};

@@ -197,4 +207,4 @@ TemplateParseVisitor.prototype._parseInterpolation = function (value, sourceSpan) {

try {
var bindings = this._exprParser.parseTemplateBindings(value, sourceInfo);
bindings.forEach(function (binding) {
var bindingsResult = this._exprParser.parseTemplateBindings(value, sourceInfo);
bindingsResult.templateBindings.forEach(function (binding) {
if (lang_1.isPresent(binding.expression)) {

@@ -204,3 +214,4 @@ _this._checkPipes(binding.expression, sourceSpan);

});
return bindings;
bindingsResult.warnings.forEach(function (warning) { _this._reportError(warning, sourceSpan, parse_util_1.ParseErrorLevel.WARNING); });
return bindingsResult.templateBindings;
}

@@ -259,12 +270,15 @@ catch (e) {

var elementOrDirectiveProps = [];
var vars = [];
var elementOrDirectiveRefs = [];
var elementVars = [];
var events = [];
var templateElementOrDirectiveProps = [];
var templateVars = [];
var templateMatchableAttrs = [];
var templateElementVars = [];
var hasInlineTemplates = false;
var attrs = [];
var lcElName = html_tags_1.splitNsName(nodeName.toLowerCase())[1];
var isTemplateElement = lcElName == TEMPLATE_ELEMENT;
element.attrs.forEach(function (attr) {
var hasBinding = _this._parseAttr(attr, matchableAttrs, elementOrDirectiveProps, events, vars);
var hasTemplateBinding = _this._parseInlineTemplateBinding(attr, templateMatchableAttrs, templateElementOrDirectiveProps, templateVars);
var hasBinding = _this._parseAttr(isTemplateElement, attr, matchableAttrs, elementOrDirectiveProps, events, elementOrDirectiveRefs, elementVars);
var hasTemplateBinding = _this._parseInlineTemplateBinding(attr, templateMatchableAttrs, templateElementOrDirectiveProps, templateElementVars);
if (!hasBinding && !hasTemplateBinding) {

@@ -279,10 +293,9 @@ // don't include the bindings as attributes as well in the AST

});
var lcElName = html_tags_1.splitNsName(nodeName.toLowerCase())[1];
var isTemplateElement = lcElName == TEMPLATE_ELEMENT;
var elementCssSelector = createElementCssSelector(nodeName, matchableAttrs);
var directiveMetas = this._parseDirectives(this.selectorMatcher, elementCssSelector);
var directiveAsts = this._createDirectiveAsts(element.name, directiveMetas, elementOrDirectiveProps, isTemplateElement ? [] : vars, element.sourceSpan);
var references = [];
var directiveAsts = this._createDirectiveAsts(isTemplateElement, element.name, directiveMetas, elementOrDirectiveProps, elementOrDirectiveRefs, element.sourceSpan, references);
var elementProps = this._createElementPropertyAsts(element.name, elementOrDirectiveProps, directiveAsts);
var isViewRoot = parent.isTemplateElement || hasInlineTemplates;
var providerContext = new provider_parser_1.ProviderElementContext(this.providerViewContext, parent.providerContext, isViewRoot, directiveAsts, attrs, vars, element.sourceSpan);
var providerContext = new provider_parser_1.ProviderElementContext(this.providerViewContext, parent.providerContext, isViewRoot, directiveAsts, attrs, references, element.sourceSpan);
var children = html_ast_1.htmlVisitAll(preparsedElement.nonBindable ? NON_BINDABLE_VISITOR : this, element.children, ElementContext.create(isTemplateElement, directiveAsts, isTemplateElement ? parent.providerContext : providerContext));

@@ -305,9 +318,8 @@ providerContext.afterElement();

this._assertNoComponentsNorElementBindingsOnTemplate(directiveAsts, elementProps, element.sourceSpan);
parsedElement = new template_ast_1.EmbeddedTemplateAst(attrs, events, vars, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, children, hasInlineTemplates ? null : ngContentIndex, element.sourceSpan);
parsedElement = new template_ast_1.EmbeddedTemplateAst(attrs, events, references, elementVars, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, children, hasInlineTemplates ? null : ngContentIndex, element.sourceSpan);
}
else {
this._assertOnlyOneComponent(directiveAsts, element.sourceSpan);
var elementExportAsVars = vars.filter(function (varAst) { return varAst.value.length === 0; });
var ngContentIndex_1 = hasInlineTemplates ? null : parent.findNgContentIndex(projectionSelector);
parsedElement = new template_ast_1.ElementAst(nodeName, attrs, elementProps, events, elementExportAsVars, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, children, hasInlineTemplates ? null : ngContentIndex_1, element.sourceSpan);
parsedElement = new template_ast_1.ElementAst(nodeName, attrs, elementProps, events, references, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, children, hasInlineTemplates ? null : ngContentIndex_1, element.sourceSpan);
}

@@ -317,8 +329,8 @@ if (hasInlineTemplates) {

var templateDirectiveMetas = this._parseDirectives(this.selectorMatcher, templateCssSelector);
var templateDirectiveAsts = this._createDirectiveAsts(element.name, templateDirectiveMetas, templateElementOrDirectiveProps, [], element.sourceSpan);
var templateDirectiveAsts = this._createDirectiveAsts(true, element.name, templateDirectiveMetas, templateElementOrDirectiveProps, [], element.sourceSpan, []);
var templateElementProps = this._createElementPropertyAsts(element.name, templateElementOrDirectiveProps, templateDirectiveAsts);
this._assertNoComponentsNorElementBindingsOnTemplate(templateDirectiveAsts, templateElementProps, element.sourceSpan);
var templateProviderContext = new provider_parser_1.ProviderElementContext(this.providerViewContext, parent.providerContext, parent.isTemplateElement, templateDirectiveAsts, [], templateVars, element.sourceSpan);
var templateProviderContext = new provider_parser_1.ProviderElementContext(this.providerViewContext, parent.providerContext, parent.isTemplateElement, templateDirectiveAsts, [], [], element.sourceSpan);
templateProviderContext.afterElement();
parsedElement = new template_ast_1.EmbeddedTemplateAst([], [], templateVars, templateProviderContext.transformedDirectiveAsts, templateProviderContext.transformProviders, templateProviderContext.transformedHasViewContainer, [parsedElement], ngContentIndex, element.sourceSpan);
parsedElement = new template_ast_1.EmbeddedTemplateAst([], [], [], templateElementVars, templateProviderContext.transformedDirectiveAsts, templateProviderContext.transformProviders, templateProviderContext.transformedHasViewContainer, [parsedElement], ngContentIndex, element.sourceSpan);
}

@@ -342,3 +354,2 @@ return parsedElement;

targetVars.push(new template_ast_1.VariableAst(binding.key, binding.name, attr.sourceSpan));
targetMatchableAttrs.push([binding.key, binding.name]);
}

@@ -357,3 +368,3 @@ else if (lang_1.isPresent(binding.expression)) {

};
TemplateParseVisitor.prototype._parseAttr = function (attr, targetMatchableAttrs, targetProps, targetEvents, targetVars) {
TemplateParseVisitor.prototype._parseAttr = function (isTemplateElement, attr, targetMatchableAttrs, targetProps, targetEvents, targetRefs, targetVars) {
var attrName = this._normalizeAttributeName(attr.name);

@@ -366,25 +377,45 @@ var attrValue = attr.value;

if (lang_1.isPresent(bindParts[1])) {
this._parseProperty(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
this._parseProperty(bindParts[7], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
}
else if (lang_1.isPresent(bindParts[2])) {
var identifier = bindParts[5];
this._parseVariable(identifier, attrValue, attr.sourceSpan, targetVars);
var identifier = bindParts[7];
if (isTemplateElement) {
this._reportError("\"var-\" on <template> elements is deprecated. Use \"let-\" instead!", attr.sourceSpan, parse_util_1.ParseErrorLevel.WARNING);
this._parseVariable(identifier, attrValue, attr.sourceSpan, targetVars);
}
else {
this._reportError("\"var-\" on non <template> elements is deprecated. Use \"ref-\" instead!", attr.sourceSpan, parse_util_1.ParseErrorLevel.WARNING);
this._parseReference(identifier, attrValue, attr.sourceSpan, targetRefs);
}
}
else if (lang_1.isPresent(bindParts[3])) {
this._parseEvent(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
if (isTemplateElement) {
var identifier = bindParts[7];
this._parseVariable(identifier, attrValue, attr.sourceSpan, targetVars);
}
else {
this._reportError("\"let-\" is only supported on template elements.", attr.sourceSpan);
}
}
else if (lang_1.isPresent(bindParts[4])) {
this._parseProperty(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
this._parseAssignmentEvent(bindParts[5], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
var identifier = bindParts[7];
this._parseReference(identifier, attrValue, attr.sourceSpan, targetRefs);
}
else if (lang_1.isPresent(bindParts[5])) {
this._parseEvent(bindParts[7], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
}
else if (lang_1.isPresent(bindParts[6])) {
this._parseProperty(bindParts[6], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
this._parseAssignmentEvent(bindParts[6], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
}
else if (lang_1.isPresent(bindParts[7])) {
this._parseProperty(bindParts[7], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
this._parseAssignmentEvent(bindParts[7], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
}
else if (lang_1.isPresent(bindParts[8])) {
this._parseEvent(bindParts[8], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
this._parseProperty(bindParts[8], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
this._parseAssignmentEvent(bindParts[8], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
}
else if (lang_1.isPresent(bindParts[9])) {
this._parseProperty(bindParts[9], attrValue, attr.sourceSpan, targetMatchableAttrs, targetProps);
}
else if (lang_1.isPresent(bindParts[10])) {
this._parseEvent(bindParts[10], attrValue, attr.sourceSpan, targetMatchableAttrs, targetEvents);
}
}

@@ -408,2 +439,8 @@ else {

};
TemplateParseVisitor.prototype._parseReference = function (identifier, value, sourceSpan, targetRefs) {
if (identifier.indexOf('-') > -1) {
this._reportError("\"-\" is not allowed in reference names", sourceSpan);
}
targetRefs.push(new ElementOrDirectiveRef(identifier, value, sourceSpan));
};
TemplateParseVisitor.prototype._parseProperty = function (name, expression, sourceSpan, targetMatchableAttrs, targetProps) {

@@ -443,26 +480,19 @@ this._parsePropertyAst(name, this._parseBinding(expression, sourceSpan), sourceSpan, targetMatchableAttrs, targetProps);

var _this = this;
var directives = [];
selectorMatcher.match(elementCssSelector, function (selector, directive) { directives.push(directive); });
// Need to sort the directives so that we get consistent results throughout,
// as selectorMatcher uses Maps inside.
// Also need to make components the first directive in the array
collection_1.ListWrapper.sort(directives, function (dir1, dir2) {
var dir1Comp = dir1.isComponent;
var dir2Comp = dir2.isComponent;
if (dir1Comp && !dir2Comp) {
return -1;
}
else if (!dir1Comp && dir2Comp) {
return 1;
}
else {
return _this.directivesIndex.get(dir1) - _this.directivesIndex.get(dir2);
}
// Also dedupe directives as they might match more than one time!
var directives = collection_1.ListWrapper.createFixedSize(this.directivesIndex.size);
selectorMatcher.match(elementCssSelector, function (selector, directive) {
directives[_this.directivesIndex.get(directive)] = directive;
});
return directives;
return directives.filter(function (dir) { return lang_1.isPresent(dir); });
};
TemplateParseVisitor.prototype._createDirectiveAsts = function (elementName, directives, props, possibleExportAsVars, sourceSpan) {
TemplateParseVisitor.prototype._createDirectiveAsts = function (isTemplateElement, elementName, directives, props, elementOrDirectiveRefs, sourceSpan, targetReferences) {
var _this = this;
var matchedVariables = new Set();
var matchedReferences = new Set();
var component = null;
var directiveAsts = directives.map(function (directive) {
if (directive.isComponent) {
component = directive;
}
var hostProperties = [];

@@ -474,16 +504,25 @@ var hostEvents = [];

_this._createDirectivePropertyAsts(directive.inputs, props, directiveProperties);
var exportAsVars = [];
possibleExportAsVars.forEach(function (varAst) {
if ((varAst.value.length === 0 && directive.isComponent) ||
(directive.exportAs == varAst.value)) {
exportAsVars.push(varAst);
matchedVariables.add(varAst.name);
elementOrDirectiveRefs.forEach(function (elOrDirRef) {
if ((elOrDirRef.value.length === 0 && directive.isComponent) ||
(directive.exportAs == elOrDirRef.value)) {
targetReferences.push(new template_ast_1.ReferenceAst(elOrDirRef.name, identifiers_1.identifierToken(directive.type), elOrDirRef.sourceSpan));
matchedReferences.add(elOrDirRef.name);
}
});
return new template_ast_1.DirectiveAst(directive, directiveProperties, hostProperties, hostEvents, exportAsVars, sourceSpan);
return new template_ast_1.DirectiveAst(directive, directiveProperties, hostProperties, hostEvents, sourceSpan);
});
possibleExportAsVars.forEach(function (varAst) {
if (varAst.value.length > 0 && !collection_1.SetWrapper.has(matchedVariables, varAst.name)) {
_this._reportError("There is no directive with \"exportAs\" set to \"" + varAst.value + "\"", varAst.sourceSpan);
elementOrDirectiveRefs.forEach(function (elOrDirRef) {
if (elOrDirRef.value.length > 0) {
if (!collection_1.SetWrapper.has(matchedReferences, elOrDirRef.name)) {
_this._reportError("There is no directive with \"exportAs\" set to \"" + elOrDirRef.value + "\"", elOrDirRef.sourceSpan);
}
;
}
else if (lang_1.isBlank(component)) {
var refToken = null;
if (isTemplateElement) {
refToken = identifiers_1.identifierToken(identifiers_1.Identifiers.TemplateRef);
}
targetReferences.push(new template_ast_1.ReferenceAst(elOrDirRef.name, refToken, elOrDirRef.sourceSpan));
}
});

@@ -663,2 +702,10 @@ return directiveAsts;

}());
var ElementOrDirectiveRef = (function () {
function ElementOrDirectiveRef(name, value, sourceSpan) {
this.name = name;
this.value = value;
this.sourceSpan = sourceSpan;
}
return ElementOrDirectiveRef;
}());
function splitClasses(classAttrValue) {

@@ -665,0 +712,0 @@ return lang_1.StringWrapper.split(classAttrValue.trim(), /\s+/g);

import * as o from '../output/output_ast';
import { CompileView } from './compile_view';
import { TemplateAst, ProviderAst } from '../template_ast';
import { TemplateAst, ProviderAst, ReferenceAst } from '../template_ast';
import { CompileDirectiveMetadata, CompileTokenMetadata } from '../compile_metadata';

@@ -21,5 +21,2 @@ export declare class CompileNode {

hasEmbeddedView: boolean;
variableTokens: {
[key: string]: CompileTokenMetadata;
};
static createNull(): CompileElement;

@@ -38,5 +35,6 @@ private _compViewExpr;

directiveInstances: o.Expression[];
constructor(parent: CompileElement, view: CompileView, nodeIndex: number, renderNode: o.Expression, sourceAst: TemplateAst, component: CompileDirectiveMetadata, _directives: CompileDirectiveMetadata[], _resolvedProvidersArray: ProviderAst[], hasViewContainer: boolean, hasEmbeddedView: boolean, variableTokens: {
referenceTokens: {
[key: string]: CompileTokenMetadata;
});
};
constructor(parent: CompileElement, view: CompileView, nodeIndex: number, renderNode: o.Expression, sourceAst: TemplateAst, component: CompileDirectiveMetadata, _directives: CompileDirectiveMetadata[], _resolvedProvidersArray: ProviderAst[], hasViewContainer: boolean, hasEmbeddedView: boolean, references: ReferenceAst[]);
private _createAppElement();

@@ -50,3 +48,2 @@ setComponentView(compViewExpr: o.Expression): void;

getProviderTokens(): o.Expression[];
getDeclaredVariablesNames(): string[];
private _getQueriesFor(token);

@@ -53,0 +50,0 @@ private _addQuery(queryMeta, directiveInstance);

@@ -32,3 +32,4 @@ "use strict";

__extends(CompileElement, _super);
function CompileElement(parent, view, nodeIndex, renderNode, sourceAst, component, _directives, _resolvedProvidersArray, hasViewContainer, hasEmbeddedView, variableTokens) {
function CompileElement(parent, view, nodeIndex, renderNode, sourceAst, component, _directives, _resolvedProvidersArray, hasViewContainer, hasEmbeddedView, references) {
var _this = this;
_super.call(this, parent, view, nodeIndex, renderNode, sourceAst);

@@ -40,3 +41,2 @@ this.component = component;

this.hasEmbeddedView = hasEmbeddedView;
this.variableTokens = variableTokens;
this._compViewExpr = null;

@@ -48,2 +48,4 @@ this._instances = new compile_metadata_1.CompileTokenMap();

this.contentNodesByNgContentIndex = null;
this.referenceTokens = {};
references.forEach(function (ref) { return _this.referenceTokens[ref.name] = ref.value; });
this.elementRef = o.importExpr(identifiers_1.Identifiers.ElementRef).instantiate([this.renderNode]);

@@ -59,3 +61,3 @@ this._instances.add(identifiers_1.identifierToken(identifiers_1.Identifiers.ElementRef), this.elementRef);

CompileElement.createNull = function () {
return new CompileElement(null, null, null, null, null, null, [], [], false, false, {});
return new CompileElement(null, null, null, null, null, null, [], [], false, false, []);
};

@@ -152,4 +154,4 @@ CompileElement.prototype._createAppElement = function () {

});
collection_1.StringMapWrapper.forEach(this.variableTokens, function (_, varName) {
var token = _this.variableTokens[varName];
collection_1.StringMapWrapper.forEach(this.referenceTokens, function (_, varName) {
var token = _this.referenceTokens[varName];
var varValue;

@@ -162,3 +164,3 @@ if (lang_1.isPresent(token)) {

}
_this.view.variables.set(varName, varValue);
_this.view.locals.set(varName, varValue);
var varToken = new compile_metadata_1.CompileTokenMetadata({ value: varName });

@@ -175,4 +177,4 @@ collection_1.ListWrapper.addAll(queriesWithReads, _this._getQueriesFor(varToken)

else {
// query for a variable
var token = _this.variableTokens[queryWithRead.read.value];
// query for a reference
var token = _this.referenceTokens[queryWithRead.read.value];
if (lang_1.isPresent(token)) {

@@ -225,7 +227,2 @@ value = _this._instances.get(token);

};
CompileElement.prototype.getDeclaredVariablesNames = function () {
var res = [];
collection_1.StringMapWrapper.forEach(this.variableTokens, function (_, key) { res.push(key); });
return res;
};
CompileElement.prototype._getQueriesFor = function (token) {

@@ -291,3 +288,2 @@ var result = [];

var currElement = this;
var currView = currElement.view;
var result = null;

@@ -300,10 +296,5 @@ if (dep.isValue) {

}
var resultViewPath = [];
// check parent elements
while (lang_1.isBlank(result) && !currElement.parent.isNull()) {
currElement = currElement.parent;
while (currElement.view !== currView && currView != null) {
currView = currView.declarationElement.view;
resultViewPath.push(currView);
}
result = currElement._getLocalDependency(template_ast_1.ProviderAstType.PublicService, new compile_metadata_1.CompileDiDependencyMetadata({ token: dep.token }));

@@ -317,3 +308,3 @@ }

}
return util_1.getPropertyInView(result, resultViewPath);
return util_1.getPropertyInView(result, this.view, currElement.view);
};

@@ -320,0 +311,0 @@ return CompileElement;

@@ -25,3 +25,2 @@ "use strict";

var elPath = [];
var viewPath = [];
while (lang_1.isPresent(currentView) && currentView !== this.view) {

@@ -31,5 +30,4 @@ var parentEl = currentView.declarationElement;

currentView = parentEl.view;
viewPath.push(currentView);
}
var queryListForDirtyExpr = util_1.getPropertyInView(this.queryList, viewPath);
var queryListForDirtyExpr = util_1.getPropertyInView(this.queryList, view, this.view);
var viewValues = this._values;

@@ -36,0 +34,0 @@ elPath.forEach(function (el) {

@@ -7,8 +7,6 @@ import { ViewType } from '../../core_private';

import { CompileMethod } from './compile_method';
import { CompilePipe } from './compile_pipe';
import { CompileDirectiveMetadata, CompilePipeMetadata, CompileTokenMap } from '../compile_metadata';
import { CompilerConfig } from '../config';
import { CompileBinding } from './compile_binding';
export declare class CompilePipe {
constructor();
}
export declare class CompileView implements NameResolver {

@@ -44,4 +42,5 @@ component: CompileDirectiveMetadata;

componentView: CompileView;
pipes: Map<string, o.Expression>;
variables: Map<string, o.Expression>;
purePipes: Map<string, CompilePipe>;
pipes: CompilePipe[];
locals: Map<string, o.Expression>;
className: string;

@@ -52,8 +51,10 @@ classType: o.Type;

literalMapCount: number;
pipeCount: number;
componentContext: o.Expression;
constructor(component: CompileDirectiveMetadata, genConfig: CompilerConfig, pipeMetas: CompilePipeMetadata[], styles: o.Expression, viewIndex: number, declarationElement: CompileElement, templateVariableBindings: string[][]);
callPipe(name: string, input: o.Expression, args: o.Expression[]): o.Expression;
getVariable(name: string): o.Expression;
getLocal(name: string): o.Expression;
createLiteralArray(values: o.Expression[]): o.Expression;
createLiteralMap(values: Array<Array<string | o.Expression>>): o.Expression;
createLiteralMap(entries: Array<Array<string | o.Expression>>): o.Expression;
afterNodes(): void;
}

@@ -5,17 +5,9 @@ "use strict";

var collection_1 = require('../../src/facade/collection');
var exceptions_1 = require('../../src/facade/exceptions');
var o = require('../output/output_ast');
var identifiers_1 = require('../identifiers');
var constants_1 = require('./constants');
var compile_query_1 = require('./compile_query');
var compile_method_1 = require('./compile_method');
var compile_pipe_1 = require('./compile_pipe');
var compile_metadata_1 = require('../compile_metadata');
var util_1 = require('./util');
var lifecycle_binder_1 = require('./lifecycle_binder');
var CompilePipe = (function () {
function CompilePipe() {
}
return CompilePipe;
}());
exports.CompilePipe = CompilePipe;
var CompileView = (function () {

@@ -41,6 +33,8 @@ function CompileView(component, genConfig, pipeMetas, styles, viewIndex, declarationElement, templateVariableBindings) {

this.subscriptions = [];
this.pipes = new Map();
this.variables = new Map();
this.purePipes = new Map();
this.pipes = [];
this.locals = new Map();
this.literalArrayCount = 0;
this.literalMapCount = 0;
this.pipeCount = 0;
this.createMethod = new compile_method_1.CompileMethod(this);

@@ -66,2 +60,4 @@ this.injectorGetMethod = new compile_method_1.CompileMethod(this);

}
this.componentContext =
util_1.getPropertyInView(o.THIS_EXPR.prop('context'), this, this.componentView);
var viewQueries = new compile_metadata_1.CompileTokenMap();

@@ -88,5 +84,3 @@ if (this.viewType === core_private_1.ViewType.COMPONENT) {

this.viewQueries = viewQueries;
templateVariableBindings.forEach(function (entry) {
_this.variables.set(entry[1], o.THIS_EXPR.prop('locals').key(o.literal(entry[0])));
});
templateVariableBindings.forEach(function (entry) { _this.locals.set(entry[1], o.THIS_EXPR.prop('context').prop(entry[0])); });
if (!this.declarationElement.isNull()) {

@@ -97,47 +91,14 @@ this.declarationElement.setEmbeddedView(this);

CompileView.prototype.callPipe = function (name, input, args) {
var pipeMeta = null;
for (var i = this.pipeMetas.length - 1; i >= 0; i--) {
var localPipeMeta = this.pipeMetas[i];
if (localPipeMeta.name == name) {
pipeMeta = localPipeMeta;
break;
var compView = this.componentView;
var pipe = compView.purePipes.get(name);
if (lang_1.isBlank(pipe)) {
pipe = new compile_pipe_1.CompilePipe(compView, name);
if (pipe.pure) {
compView.purePipes.set(name, pipe);
}
compView.pipes.push(pipe);
}
if (lang_1.isBlank(pipeMeta)) {
throw new exceptions_1.BaseException("Illegal state: Could not find pipe " + name + " although the parser should have detected this error!");
}
var pipeFieldName = pipeMeta.pure ? "_pipe_" + name : "_pipe_" + name + "_" + this.pipes.size;
var pipeExpr = this.pipes.get(pipeFieldName);
var pipeFieldCacheProp = o.THIS_EXPR.prop(pipeFieldName + "_cache");
if (lang_1.isBlank(pipeExpr)) {
var deps = pipeMeta.type.diDeps.map(function (diDep) {
if (diDep.token.equalsTo(identifiers_1.identifierToken(identifiers_1.Identifiers.ChangeDetectorRef))) {
return o.THIS_EXPR.prop('ref');
}
return util_1.injectFromViewParentInjector(diDep.token, false);
});
this.fields.push(new o.ClassField(pipeFieldName, o.importType(pipeMeta.type), [o.StmtModifier.Private]));
if (pipeMeta.pure) {
this.fields.push(new o.ClassField(pipeFieldCacheProp.name, null, [o.StmtModifier.Private]));
this.createMethod.addStmt(o.THIS_EXPR.prop(pipeFieldCacheProp.name)
.set(o.importExpr(identifiers_1.Identifiers.uninitialized))
.toStmt());
}
this.createMethod.resetDebugInfo(null, null);
this.createMethod.addStmt(o.THIS_EXPR.prop(pipeFieldName)
.set(o.importExpr(pipeMeta.type).instantiate(deps))
.toStmt());
pipeExpr = o.THIS_EXPR.prop(pipeFieldName);
this.pipes.set(pipeFieldName, pipeExpr);
lifecycle_binder_1.bindPipeDestroyLifecycleCallbacks(pipeMeta, pipeExpr, this);
}
var callPipeExpr = pipeExpr.callMethod('transform', [input, o.literalArr(args)]);
if (pipeMeta.pure) {
callPipeExpr =
o.THIS_EXPR.callMethod('checkPurePipe', [o.literal(this.literalArrayCount++), o.literalArr([input].concat(args))])
.conditional(pipeFieldCacheProp.set(callPipeExpr), pipeFieldCacheProp);
}
return callPipeExpr;
return pipe.call(this, [input].concat(args));
};
CompileView.prototype.getVariable = function (name) {
CompileView.prototype.getLocal = function (name) {
if (name == constants_1.EventHandlerVars.event.name) {

@@ -147,11 +108,9 @@ return constants_1.EventHandlerVars.event;

var currView = this;
var result = currView.variables.get(name);
var viewPath = [];
var result = currView.locals.get(name);
while (lang_1.isBlank(result) && lang_1.isPresent(currView.declarationElement.view)) {
currView = currView.declarationElement.view;
result = currView.variables.get(name);
viewPath.push(currView);
result = currView.locals.get(name);
}
if (lang_1.isPresent(result)) {
return util_1.getPropertyInView(result, viewPath);
return util_1.getPropertyInView(result, this, currView);
}

@@ -163,9 +122,30 @@ else {

CompileView.prototype.createLiteralArray = function (values) {
return o.THIS_EXPR.callMethod('literalArray', [o.literal(this.literalArrayCount++), o.literalArr(values)]);
var proxyExpr = o.THIS_EXPR.prop("_arr_" + this.literalArrayCount++);
var proxyParams = [];
var proxyReturnEntries = [];
for (var i = 0; i < values.length; i++) {
var paramName = "p" + i;
proxyParams.push(new o.FnParam(paramName));
proxyReturnEntries.push(o.variable(paramName));
}
util_1.createPureProxy(o.fn(proxyParams, [new o.ReturnStatement(o.literalArr(proxyReturnEntries))]), values.length, proxyExpr, this);
return proxyExpr.callFn(values);
};
CompileView.prototype.createLiteralMap = function (values) {
return o.THIS_EXPR.callMethod('literalMap', [o.literal(this.literalMapCount++), o.literalMap(values)]);
CompileView.prototype.createLiteralMap = function (entries) {
var proxyExpr = o.THIS_EXPR.prop("_map_" + this.literalMapCount++);
var proxyParams = [];
var proxyReturnEntries = [];
var values = [];
for (var i = 0; i < entries.length; i++) {
var paramName = "p" + i;
proxyParams.push(new o.FnParam(paramName));
proxyReturnEntries.push([entries[i][0], o.variable(paramName)]);
values.push(entries[i][1]);
}
util_1.createPureProxy(o.fn(proxyParams, [new o.ReturnStatement(o.literalMap(proxyReturnEntries))]), entries.length, proxyExpr, this);
return proxyExpr.callFn(values);
};
CompileView.prototype.afterNodes = function () {
var _this = this;
this.pipes.forEach(function (pipe) { return pipe.create(); });
this.viewQueries.values().forEach(function (queries) { return queries.forEach(function (query) { return query.afterChildren(_this.updateViewQueriesMethod); }); });

@@ -172,0 +152,0 @@ };

@@ -36,3 +36,4 @@ "use strict";

this._method.resetDebugInfo(this.compileElement.nodeIndex, hostEvent);
var context = lang_1.isPresent(directiveInstance) ? directiveInstance : o.THIS_EXPR.prop('context');
var context = lang_1.isPresent(directiveInstance) ? directiveInstance :
this.compileElement.view.componentContext;
var actionStmts = expression_converter_1.convertCdStatementToIr(this.compileElement.view, context, hostEvent.handler);

@@ -71,3 +72,3 @@ var lastIndex = actionStmts.length - 1;

new o.ReturnStatement(o.THIS_EXPR.callMethod(this._methodName, [constants_1.EventHandlerVars.event]))
])
], o.BOOL_TYPE)
]);

@@ -74,0 +75,0 @@ if (lang_1.isPresent(this.eventTarget)) {

@@ -5,3 +5,3 @@ import * as cdAst from '../expression_parser/ast';

callPipe(name: string, input: o.Expression, args: o.Expression[]): o.Expression;
getVariable(name: string): o.Expression;
getLocal(name: string): o.Expression;
createLiteralArray(values: o.Expression[]): o.Expression;

@@ -8,0 +8,0 @@ createLiteralMap(values: Array<Array<string | o.Expression>>): o.Expression;

@@ -122,5 +122,5 @@ "use strict";

var args = this.visitAll(ast.args, _Mode.Expression);
var pipeResult = this._nameResolver.callPipe(ast.name, input, args);
var value = this._nameResolver.callPipe(ast.name, input, args);
this.needsValueUnwrapper = true;
return convertToStatementIfNeeded(mode, this._valueUnwrapper.callMethod('unwrap', [pipeResult]));
return convertToStatementIfNeeded(mode, this._valueUnwrapper.callMethod('unwrap', [value]));
};

@@ -172,3 +172,3 @@ _AstToIrVisitor.prototype.visitFunctionCall = function (ast, mode) {

if (receiver === IMPLICIT_RECEIVER) {
var varExpr = this._nameResolver.getVariable(ast.name);
var varExpr = this._nameResolver.getLocal(ast.name);
if (lang_1.isPresent(varExpr)) {

@@ -193,3 +193,3 @@ result = varExpr.callFn(args);

if (receiver === IMPLICIT_RECEIVER) {
result = this._nameResolver.getVariable(ast.name);
result = this._nameResolver.getLocal(ast.name);
if (lang_1.isBlank(result)) {

@@ -207,5 +207,5 @@ receiver = this._implicitReceiver;

if (receiver === IMPLICIT_RECEIVER) {
var varExpr = this._nameResolver.getVariable(ast.name);
var varExpr = this._nameResolver.getLocal(ast.name);
if (lang_1.isPresent(varExpr)) {
throw new exceptions_1.BaseException('Cannot reassign a variable binding');
throw new exceptions_1.BaseException('Cannot assign to a reference or variable!');
}

@@ -212,0 +212,0 @@ receiver = this._implicitReceiver;

@@ -10,2 +10,2 @@ import * as o from '../output/output_ast';

export declare function bindDirectiveDestroyLifecycleCallbacks(directiveMeta: CompileDirectiveMetadata, directiveInstance: o.Expression, compileElement: CompileElement): void;
export declare function bindPipeDestroyLifecycleCallbacks(pipeMeta: CompilePipeMetadata, directiveInstance: o.Expression, view: CompileView): void;
export declare function bindPipeDestroyLifecycleCallbacks(pipeMeta: CompilePipeMetadata, pipeInstance: o.Expression, view: CompileView): void;

@@ -56,6 +56,6 @@ "use strict";

exports.bindDirectiveDestroyLifecycleCallbacks = bindDirectiveDestroyLifecycleCallbacks;
function bindPipeDestroyLifecycleCallbacks(pipeMeta, directiveInstance, view) {
function bindPipeDestroyLifecycleCallbacks(pipeMeta, pipeInstance, view) {
var onDestroyMethod = view.destroyMethod;
if (pipeMeta.lifecycleHooks.indexOf(core_private_1.LifecycleHooks.OnDestroy) !== -1) {
onDestroyMethod.addStmt(directiveInstance.callMethod('ngOnDestroy', []).toStmt());
onDestroyMethod.addStmt(pipeInstance.callMethod('ngOnDestroy', []).toStmt());
}

@@ -62,0 +62,0 @@ }

@@ -43,3 +43,3 @@ "use strict";

view.detectChangesRenderPropertiesMethod.resetDebugInfo(compileNode.nodeIndex, boundText);
bind(view, currValExpr, valueField, boundText.value, o.THIS_EXPR.prop('context'), [
bind(view, currValExpr, valueField, boundText.value, view.componentContext, [
o.THIS_EXPR.prop('renderer')

@@ -94,3 +94,3 @@ .callMethod('setText', [compileNode.renderNode, currValExpr])

function bindRenderInputs(boundProps, compileElement) {
bindAndWriteToRenderer(boundProps, o.THIS_EXPR.prop('context'), compileElement);
bindAndWriteToRenderer(boundProps, compileElement.view.componentContext, compileElement);
}

@@ -141,3 +141,3 @@ exports.bindRenderInputs = bindRenderInputs;

}
bind(view, currValExpr, fieldExpr, input.value, o.THIS_EXPR.prop('context'), statements, detectChangesInInputsMethod);
bind(view, currValExpr, fieldExpr, input.value, view.componentContext, statements, detectChangesInInputsMethod);
});

@@ -144,0 +144,0 @@ if (isOnPushComp) {

import * as o from '../output/output_ast';
import { CompileTokenMetadata, CompileDirectiveMetadata } from '../compile_metadata';
import { CompileView } from './compile_view';
export declare function getPropertyInView(property: o.Expression, viewPath: CompileView[]): o.Expression;
export declare function getPropertyInView(property: o.Expression, callingView: CompileView, definedView: CompileView): o.Expression;
export declare function injectFromViewParentInjector(token: CompileTokenMetadata, optional: boolean): o.Expression;

@@ -9,1 +9,2 @@ export declare function getViewFactoryName(component: CompileDirectiveMetadata, embeddedTemplateIndex: number): string;

export declare function createFlatArray(expressions: o.Expression[]): o.Expression;
export declare function createPureProxy(fn: o.Expression, argCount: number, pureProxyProp: o.ReadPropExpr, view: CompileView): void;
"use strict";
var lang_1 = require('../../src/facade/lang');
var exceptions_1 = require('../../src/facade/exceptions');
var o = require('../output/output_ast');
function getPropertyInView(property, viewPath) {
if (viewPath.length === 0) {
var identifiers_1 = require('../identifiers');
function getPropertyInView(property, callingView, definedView) {
if (callingView === definedView) {
return property;

@@ -10,12 +12,16 @@ }

var viewProp = o.THIS_EXPR;
for (var i = 0; i < viewPath.length; i++) {
viewProp = viewProp.prop('declarationAppElement').prop('parentView');
var currView = callingView;
while (currView !== definedView && lang_1.isPresent(currView.declarationElement.view)) {
currView = currView.declarationElement.view;
viewProp = viewProp.prop('parent');
}
if (currView !== definedView) {
throw new exceptions_1.BaseException("Internal error: Could not calculate a property in a parent view: " + property);
}
if (property instanceof o.ReadPropExpr) {
var lastView = viewPath[viewPath.length - 1];
var readPropExpr_1 = property;
// Note: Don't cast for members of the AppView base class...
if (lastView.fields.some(function (field) { return field.name == readPropExpr_1.name; }) ||
lastView.getters.some(function (field) { return field.name == readPropExpr_1.name; })) {
viewProp = viewProp.cast(lastView.classType);
if (definedView.fields.some(function (field) { return field.name == readPropExpr_1.name; }) ||
definedView.getters.some(function (field) { return field.name == readPropExpr_1.name; })) {
viewProp = viewProp.cast(definedView.classType);
}

@@ -76,2 +82,11 @@ }

exports.createFlatArray = createFlatArray;
function createPureProxy(fn, argCount, pureProxyProp, view) {
view.fields.push(new o.ClassField(pureProxyProp.name, null, [o.StmtModifier.Private]));
var pureProxyId = argCount < identifiers_1.Identifiers.pureProxies.length ? identifiers_1.Identifiers.pureProxies[argCount] : null;
if (lang_1.isBlank(pureProxyId)) {
throw new exceptions_1.BaseException("Unsupported number of argument for pure functions: " + argCount);
}
view.createMethod.addStmt(o.THIS_EXPR.prop(pureProxyProp.name).set(o.importExpr(pureProxyId).callFn([fn])).toStmt());
}
exports.createPureProxy = createPureProxy;
//# sourceMappingURL=util.js.map

@@ -10,2 +10,3 @@ "use strict";

template_ast_1.templateVisitAll(visitor, parsedTemplate);
view.pipes.forEach(function (pipe) { lifecycle_binder_1.bindPipeDestroyLifecycleCallbacks(pipe.meta, pipe.instance, pipe.view); });
}

@@ -63,2 +64,3 @@ exports.bindView = bindView;

});
bindView(compileElement.embeddedView, ast.children);
return null;

@@ -71,2 +73,3 @@ };

};
ViewBinderVisitor.prototype.visitReference = function (ast, ctx) { return null; };
ViewBinderVisitor.prototype.visitVariable = function (ast, ctx) { return null; };

@@ -73,0 +76,0 @@ ViewBinderVisitor.prototype.visitDirectiveProperty = function (ast, context) { return null; };

@@ -10,2 +10,3 @@ import * as o from '../output/output_ast';

}
export declare function buildView(view: CompileView, template: TemplateAst[], targetDependencies: ViewCompileDependency[], targetStatements: o.Statement[]): number;
export declare function buildView(view: CompileView, template: TemplateAst[], targetDependencies: ViewCompileDependency[]): number;
export declare function finishView(view: CompileView, targetStatements: o.Statement[]): void;

@@ -14,3 +14,2 @@ "use strict";

var compile_metadata_1 = require('../compile_metadata');
var view_binder_1 = require('./view_binder');
var IMPLICIT_TEMPLATE_VAR = '\$implicit';

@@ -29,20 +28,24 @@ var CLASS_ATTR = 'class';

exports.ViewCompileDependency = ViewCompileDependency;
function buildView(view, template, targetDependencies, targetStatements) {
var builderVisitor = new ViewBuilderVisitor(view, targetDependencies, targetStatements);
function buildView(view, template, targetDependencies) {
var builderVisitor = new ViewBuilderVisitor(view, targetDependencies);
template_ast_1.templateVisitAll(builderVisitor, template, view.declarationElement.isNull() ?
view.declarationElement :
view.declarationElement.parent);
// Need to separate binding from creation to be able to refer to
// variables that have been declared after usage.
view_binder_1.bindView(view, template);
return builderVisitor.nestedViewCount;
}
exports.buildView = buildView;
function finishView(view, targetStatements) {
view.afterNodes();
createViewTopLevelStmts(view, targetStatements);
return builderVisitor.nestedViewCount;
view.nodes.forEach(function (node) {
if (node instanceof compile_element_1.CompileElement && node.hasEmbeddedView) {
finishView(node.embeddedView, targetStatements);
}
});
}
exports.buildView = buildView;
exports.finishView = finishView;
var ViewBuilderVisitor = (function () {
function ViewBuilderVisitor(view, targetDependencies, targetStatements) {
function ViewBuilderVisitor(view, targetDependencies) {
this.view = view;
this.targetDependencies = targetDependencies;
this.targetStatements = targetStatements;
this.nestedViewCount = 0;

@@ -146,3 +149,2 @@ }

var directives = ast.directives.map(function (directiveAst) { return directiveAst.directive; });
var variables = _readHtmlAndDirectiveVariables(ast.exportAsVars, ast.directives, this.view.viewType);
var htmlAttrs = _readHtmlAttrs(ast.attrs);

@@ -156,3 +158,3 @@ var attrNameAndValues = _mergeHtmlAndDirectiveAttrs(htmlAttrs, directives);

}
var compileElement = new compile_element_1.CompileElement(parent, this.view, nodeIndex, renderNode, ast, component, directives, ast.providers, ast.hasViewContainer, false, variables);
var compileElement = new compile_element_1.CompileElement(parent, this.view, nodeIndex, renderNode, ast, component, directives, ast.providers, ast.hasViewContainer, false, ast.references);
this.view.nodes.push(compileElement);

@@ -185,3 +187,4 @@ var compViewExpr = null;

}
this.view.createMethod.addStmt(compViewExpr.callMethod('create', [codeGenContentNodes, o.NULL_EXPR]).toStmt());
this.view.createMethod.addStmt(compViewExpr.callMethod('create', [compileElement.getComponent(), codeGenContentNodes, o.NULL_EXPR])
.toStmt());
}

@@ -201,10 +204,9 @@ return null;

var renderNode = o.THIS_EXPR.prop(fieldName);
var templateVariableBindings = ast.vars.map(function (varAst) { return [varAst.value.length > 0 ? varAst.value : IMPLICIT_TEMPLATE_VAR, varAst.name]; });
var templateVariableBindings = ast.variables.map(function (varAst) { return [varAst.value.length > 0 ? varAst.value : IMPLICIT_TEMPLATE_VAR, varAst.name]; });
var directives = ast.directives.map(function (directiveAst) { return directiveAst.directive; });
var compileElement = new compile_element_1.CompileElement(parent, this.view, nodeIndex, renderNode, ast, null, directives, ast.providers, ast.hasViewContainer, true, {});
var compileElement = new compile_element_1.CompileElement(parent, this.view, nodeIndex, renderNode, ast, null, directives, ast.providers, ast.hasViewContainer, true, ast.references);
this.view.nodes.push(compileElement);
this.nestedViewCount++;
var embeddedView = new compile_view_1.CompileView(this.view.component, this.view.genConfig, this.view.pipeMetas, o.NULL_EXPR, this.view.viewIndex + this.nestedViewCount, compileElement, templateVariableBindings);
this.nestedViewCount +=
buildView(embeddedView, ast.children, this.targetDependencies, this.targetStatements);
this.nestedViewCount += buildView(embeddedView, ast.children, this.targetDependencies);
compileElement.beforeChildren();

@@ -220,2 +222,3 @@ this._addRootNodeAndProject(compileElement, ast.ngContentIndex, parent);

};
ViewBuilderVisitor.prototype.visitReference = function (ast, ctx) { return null; };
ViewBuilderVisitor.prototype.visitVariable = function (ast, ctx) { return null; };

@@ -242,16 +245,2 @@ ViewBuilderVisitor.prototype.visitDirectiveProperty = function (ast, context) { return null; };

}
function _readHtmlAndDirectiveVariables(elementExportAsVars, directives, viewType) {
var variables = {};
var component = null;
directives.forEach(function (directive) {
if (directive.directive.isComponent) {
component = directive.directive;
}
directive.exportAsVars.forEach(function (varAst) { variables[varAst.name] = identifiers_1.identifierToken(directive.directive.type); });
});
elementExportAsVars.forEach(function (varAst) {
variables[varAst.name] = lang_1.isPresent(component) ? identifiers_1.identifierToken(component.type) : null;
});
return variables;
}
function mergeAttributeValue(attrName, attrValue1, attrValue2) {

@@ -302,3 +291,3 @@ if (attrName == CLASS_ATTR || attrName == STYLE_ATTR) {

}
collection_1.StringMapWrapper.forEach(compileElement.variableTokens, function (token, varName) {
collection_1.StringMapWrapper.forEach(compileElement.referenceTokens, function (token, varName) {
varTokenEntries.push([varName, lang_1.isPresent(token) ? util_1.createDiTokenExpression(token) : o.NULL_EXPR]);

@@ -315,3 +304,2 @@ });

function createViewClass(view, renderCompTypeVar, nodeDebugInfosVar) {
var emptyTemplateVariableBindings = view.templateVariableBindings.map(function (entry) { return [entry[0], o.NULL_EXPR]; });
var viewConstructorArgs = [

@@ -322,18 +310,15 @@ new o.FnParam(constants_1.ViewConstructorVars.viewUtils.name, o.importType(identifiers_1.Identifiers.ViewUtils)),

];
var viewConstructor = new o.ClassMethod(null, viewConstructorArgs, [
o.SUPER_EXPR.callFn([
o.variable(view.className),
renderCompTypeVar,
constants_1.ViewTypeEnum.fromValue(view.viewType),
o.literalMap(emptyTemplateVariableBindings),
constants_1.ViewConstructorVars.viewUtils,
constants_1.ViewConstructorVars.parentInjector,
constants_1.ViewConstructorVars.declarationEl,
constants_1.ChangeDetectionStrategyEnum.fromValue(getChangeDetectionMode(view)),
o.literal(view.literalArrayCount),
o.literal(view.literalMapCount),
nodeDebugInfosVar
])
.toStmt()
]);
var superConstructorArgs = [
o.variable(view.className),
renderCompTypeVar,
constants_1.ViewTypeEnum.fromValue(view.viewType),
constants_1.ViewConstructorVars.viewUtils,
constants_1.ViewConstructorVars.parentInjector,
constants_1.ViewConstructorVars.declarationEl,
constants_1.ChangeDetectionStrategyEnum.fromValue(getChangeDetectionMode(view))
];
if (view.genConfig.genDebugInfo) {
superConstructorArgs.push(nodeDebugInfosVar);
}
var viewConstructor = new o.ClassMethod(null, viewConstructorArgs, [o.SUPER_EXPR.callFn(superConstructorArgs).toStmt()]);
var viewMethods = [

@@ -351,3 +336,4 @@ new o.ClassMethod('createInternal', [new o.FnParam(rootSelectorVar.name, o.STRING_TYPE)], generateCreateMethod(view), o.importType(identifiers_1.Identifiers.AppElement)),

].concat(view.eventHandlerMethods);
var viewClass = new o.ClassStmt(view.className, o.importExpr(identifiers_1.Identifiers.AppView, [getContextType(view)]), view.fields, view.getters, viewConstructor, viewMethods.filter(function (method) { return method.body.length > 0; }));
var superClass = view.genConfig.genDebugInfo ? identifiers_1.Identifiers.DebugAppView : identifiers_1.Identifiers.AppView;
var viewClass = new o.ClassStmt(view.className, o.importExpr(superClass, [getContextType(view)]), view.fields, view.getters, viewConstructor, viewMethods.filter(function (method) { return method.body.length > 0; }));
return viewClass;

@@ -467,4 +453,6 @@ }

function getContextType(view) {
var typeMeta = view.component.type;
return typeMeta.isHost ? o.DYNAMIC_TYPE : o.importType(typeMeta);
if (view.viewType === core_private_1.ViewType.COMPONENT) {
return o.importType(view.component.type);
}
return o.DYNAMIC_TYPE;
}

@@ -471,0 +459,0 @@ function getChangeDetectionMode(view) {

@@ -15,2 +15,3 @@ "use strict";

var view_builder_1 = require('./view_builder');
var view_binder_1 = require('./view_binder');
var config_1 = require('../config');

@@ -34,3 +35,7 @@ var ViewCompileResult = (function () {

var view = new compile_view_1.CompileView(component, this._genConfig, pipes, styles, 0, compile_element_1.CompileElement.createNull(), []);
view_builder_1.buildView(view, template, dependencies, statements);
view_builder_1.buildView(view, template, dependencies);
// Need to separate binding from creation to be able to refer to
// variables that have been declared after usage.
view_binder_1.bindView(view, template);
view_builder_1.finishView(view, statements);
return new ViewCompileResult(statements, view.viewFactory.name, dependencies);

@@ -37,0 +42,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc