fix(compiler): no longer uses assetCacheKey for token identity.
Fixes #10545, Fixes #10538
This commit is contained in:
parent
c377e80670
commit
51877ef4ed
@ -42,6 +42,16 @@ export class StaticAndDynamicReflectionCapabilities {
|
|||||||
setter(name: string) { return this.dynamicDelegate.setter(name); }
|
setter(name: string) { return this.dynamicDelegate.setter(name); }
|
||||||
method(name: string) { return this.dynamicDelegate.method(name); }
|
method(name: string) { return this.dynamicDelegate.method(name); }
|
||||||
importUri(type: any): string { return this.staticDelegate.importUri(type); }
|
importUri(type: any): string { return this.staticDelegate.importUri(type); }
|
||||||
|
resolveType(name: string, moduleUrl: string) {
|
||||||
|
return this.staticDelegate.resolveType(name, moduleUrl);
|
||||||
|
}
|
||||||
|
resolveEnum(enumType: any, name: string): any {
|
||||||
|
if (isStaticType(enumType)) {
|
||||||
|
return this.staticDelegate.resolveEnum(enumType, name);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isStaticType(type: any): boolean {
|
function isStaticType(type: any): boolean {
|
||||||
|
@ -74,6 +74,16 @@ export class StaticReflector implements ReflectorReader {
|
|||||||
return staticSymbol ? staticSymbol.filePath : null;
|
return staticSymbol ? staticSymbol.filePath : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolveType(name: string, moduleUrl: string): any {
|
||||||
|
const result = this.host.findDeclaration(moduleUrl, name, '');
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolveEnum(enumType: any, name: string): any {
|
||||||
|
const staticSymbol: StaticSymbol = enumType;
|
||||||
|
return this.host.getStaticSymbol(staticSymbol.filePath, staticSymbol.name, [name]);
|
||||||
|
}
|
||||||
|
|
||||||
public annotations(type: StaticSymbol): any[] {
|
public annotations(type: StaticSymbol): any[] {
|
||||||
let annotations = this.annotationCache.get(type);
|
let annotations = this.annotationCache.get(type);
|
||||||
if (!annotations) {
|
if (!annotations) {
|
||||||
|
@ -10,7 +10,7 @@ import {ANY_STATE, AnimationOutput, DEFAULT_STATE, EMPTY_STATE} from '../../core
|
|||||||
import {CompileDirectiveMetadata} from '../compile_metadata';
|
import {CompileDirectiveMetadata} from '../compile_metadata';
|
||||||
import {StringMapWrapper} from '../facade/collection';
|
import {StringMapWrapper} from '../facade/collection';
|
||||||
import {isBlank, isPresent} from '../facade/lang';
|
import {isBlank, isPresent} from '../facade/lang';
|
||||||
import {Identifiers} from '../identifiers';
|
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
import * as t from '../template_parser/template_ast';
|
import * as t from '../template_parser/template_ast';
|
||||||
|
|
||||||
@ -114,8 +114,8 @@ class _AnimationBuilder implements AnimationAstVisitor {
|
|||||||
o.literalMap(StringMapWrapper.keys(entry).map(key => [key, o.literal(entry[key])])));
|
o.literalMap(StringMapWrapper.keys(entry).map(key => [key, o.literal(entry[key])])));
|
||||||
});
|
});
|
||||||
|
|
||||||
return o.importExpr(Identifiers.AnimationStyles).instantiate([
|
return o.importExpr(resolveIdentifier(Identifiers.AnimationStyles)).instantiate([
|
||||||
o.importExpr(Identifiers.collectAndResolveStyles).callFn([
|
o.importExpr(resolveIdentifier(Identifiers.collectAndResolveStyles)).callFn([
|
||||||
_ANIMATION_COLLECTED_STYLES, o.literalArr(stylesArr)
|
_ANIMATION_COLLECTED_STYLES, o.literalArr(stylesArr)
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
@ -123,7 +123,7 @@ class _AnimationBuilder implements AnimationAstVisitor {
|
|||||||
|
|
||||||
visitAnimationKeyframe(ast: AnimationKeyframeAst, context: _AnimationBuilderContext):
|
visitAnimationKeyframe(ast: AnimationKeyframeAst, context: _AnimationBuilderContext):
|
||||||
o.Expression {
|
o.Expression {
|
||||||
return o.importExpr(Identifiers.AnimationKeyframe).instantiate([
|
return o.importExpr(resolveIdentifier(Identifiers.AnimationKeyframe)).instantiate([
|
||||||
o.literal(ast.offset), ast.styles.visit(this, context)
|
o.literal(ast.offset), ast.styles.visit(this, context)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -144,7 +144,8 @@ class _AnimationBuilder implements AnimationAstVisitor {
|
|||||||
_visitEndStateAnimation(ast: AnimationStepAst, context: _AnimationBuilderContext): o.Expression {
|
_visitEndStateAnimation(ast: AnimationStepAst, context: _AnimationBuilderContext): o.Expression {
|
||||||
var startingStylesExpr = ast.startingStyles.visit(this, context);
|
var startingStylesExpr = ast.startingStyles.visit(this, context);
|
||||||
var keyframeExpressions = ast.keyframes.map(keyframe => keyframe.visit(this, context));
|
var keyframeExpressions = ast.keyframes.map(keyframe => keyframe.visit(this, context));
|
||||||
var keyframesExpr = o.importExpr(Identifiers.balanceAnimationKeyframes).callFn([
|
var keyframesExpr =
|
||||||
|
o.importExpr(resolveIdentifier(Identifiers.balanceAnimationKeyframes)).callFn([
|
||||||
_ANIMATION_COLLECTED_STYLES, _ANIMATION_END_STATE_STYLES_VAR,
|
_ANIMATION_COLLECTED_STYLES, _ANIMATION_END_STATE_STYLES_VAR,
|
||||||
o.literalArr(keyframeExpressions)
|
o.literalArr(keyframeExpressions)
|
||||||
]);
|
]);
|
||||||
@ -166,13 +167,16 @@ class _AnimationBuilder implements AnimationAstVisitor {
|
|||||||
visitAnimationSequence(ast: AnimationSequenceAst, context: _AnimationBuilderContext):
|
visitAnimationSequence(ast: AnimationSequenceAst, context: _AnimationBuilderContext):
|
||||||
o.Expression {
|
o.Expression {
|
||||||
var playerExprs = ast.steps.map(step => step.visit(this, context));
|
var playerExprs = ast.steps.map(step => step.visit(this, context));
|
||||||
return o.importExpr(Identifiers.AnimationSequencePlayer).instantiate([o.literalArr(
|
return o.importExpr(resolveIdentifier(Identifiers.AnimationSequencePlayer)).instantiate([
|
||||||
playerExprs)]);
|
o.literalArr(playerExprs)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitAnimationGroup(ast: AnimationGroupAst, context: _AnimationBuilderContext): o.Expression {
|
visitAnimationGroup(ast: AnimationGroupAst, context: _AnimationBuilderContext): o.Expression {
|
||||||
var playerExprs = ast.steps.map(step => step.visit(this, context));
|
var playerExprs = ast.steps.map(step => step.visit(this, context));
|
||||||
return o.importExpr(Identifiers.AnimationGroupPlayer).instantiate([o.literalArr(playerExprs)]);
|
return o.importExpr(resolveIdentifier(Identifiers.AnimationGroupPlayer)).instantiate([
|
||||||
|
o.literalArr(playerExprs)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitAnimationStateDeclaration(
|
visitAnimationStateDeclaration(
|
||||||
@ -265,16 +269,16 @@ class _AnimationBuilder implements AnimationAstVisitor {
|
|||||||
_ANIMATION_END_STATE_STYLES_VAR.equals(o.NULL_EXPR),
|
_ANIMATION_END_STATE_STYLES_VAR.equals(o.NULL_EXPR),
|
||||||
[_ANIMATION_END_STATE_STYLES_VAR.set(_ANIMATION_DEFAULT_STATE_VAR).toStmt()]));
|
[_ANIMATION_END_STATE_STYLES_VAR.set(_ANIMATION_DEFAULT_STATE_VAR).toStmt()]));
|
||||||
|
|
||||||
var RENDER_STYLES_FN = o.importExpr(Identifiers.renderStyles);
|
var RENDER_STYLES_FN = o.importExpr(resolveIdentifier(Identifiers.renderStyles));
|
||||||
|
|
||||||
// before we start any animation we want to clear out the starting
|
// before we start any animation we want to clear out the starting
|
||||||
// styles from the element's style property (since they were placed
|
// styles from the element's style property (since they were placed
|
||||||
// there at the end of the last animation
|
// there at the end of the last animation
|
||||||
statements.push(
|
statements.push(RENDER_STYLES_FN
|
||||||
RENDER_STYLES_FN
|
|
||||||
.callFn([
|
.callFn([
|
||||||
_ANIMATION_FACTORY_ELEMENT_VAR, _ANIMATION_FACTORY_RENDERER_VAR,
|
_ANIMATION_FACTORY_ELEMENT_VAR, _ANIMATION_FACTORY_RENDERER_VAR,
|
||||||
o.importExpr(Identifiers.clearStyles).callFn([_ANIMATION_START_STATE_STYLES_VAR])
|
o.importExpr(resolveIdentifier(Identifiers.clearStyles))
|
||||||
|
.callFn([_ANIMATION_START_STATE_STYLES_VAR])
|
||||||
])
|
])
|
||||||
.toStmt());
|
.toStmt());
|
||||||
|
|
||||||
@ -284,7 +288,8 @@ class _AnimationBuilder implements AnimationAstVisitor {
|
|||||||
// so that the onDone callback can be used for tracking
|
// so that the onDone callback can be used for tracking
|
||||||
statements.push(new o.IfStmt(
|
statements.push(new o.IfStmt(
|
||||||
_ANIMATION_PLAYER_VAR.equals(o.NULL_EXPR),
|
_ANIMATION_PLAYER_VAR.equals(o.NULL_EXPR),
|
||||||
[_ANIMATION_PLAYER_VAR.set(o.importExpr(Identifiers.NoOpAnimationPlayer).instantiate([]))
|
[_ANIMATION_PLAYER_VAR
|
||||||
|
.set(o.importExpr(resolveIdentifier(Identifiers.NoOpAnimationPlayer)).instantiate([]))
|
||||||
.toStmt()]));
|
.toStmt()]));
|
||||||
|
|
||||||
// once complete we want to apply the styles on the element
|
// once complete we want to apply the styles on the element
|
||||||
@ -295,10 +300,12 @@ class _AnimationBuilder implements AnimationAstVisitor {
|
|||||||
.callMethod(
|
.callMethod(
|
||||||
'onDone',
|
'onDone',
|
||||||
[o.fn(
|
[o.fn(
|
||||||
[], [RENDER_STYLES_FN
|
[],
|
||||||
|
[RENDER_STYLES_FN
|
||||||
.callFn([
|
.callFn([
|
||||||
_ANIMATION_FACTORY_ELEMENT_VAR, _ANIMATION_FACTORY_RENDERER_VAR,
|
_ANIMATION_FACTORY_ELEMENT_VAR, _ANIMATION_FACTORY_RENDERER_VAR,
|
||||||
o.importExpr(Identifiers.prepareFinalAnimationStyles).callFn([
|
o.importExpr(resolveIdentifier(Identifiers.prepareFinalAnimationStyles))
|
||||||
|
.callFn([
|
||||||
_ANIMATION_START_STATE_STYLES_VAR, _ANIMATION_END_STATE_STYLES_VAR
|
_ANIMATION_START_STATE_STYLES_VAR, _ANIMATION_END_STATE_STYLES_VAR
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
@ -319,7 +326,7 @@ class _AnimationBuilder implements AnimationAstVisitor {
|
|||||||
[
|
[
|
||||||
new o.FnParam(
|
new o.FnParam(
|
||||||
_ANIMATION_FACTORY_VIEW_VAR.name,
|
_ANIMATION_FACTORY_VIEW_VAR.name,
|
||||||
o.importType(Identifiers.AppView, [o.DYNAMIC_TYPE])),
|
o.importType(resolveIdentifier(Identifiers.AppView), [o.DYNAMIC_TYPE])),
|
||||||
new o.FnParam(_ANIMATION_FACTORY_ELEMENT_VAR.name, o.DYNAMIC_TYPE),
|
new o.FnParam(_ANIMATION_FACTORY_ELEMENT_VAR.name, o.DYNAMIC_TYPE),
|
||||||
new o.FnParam(_ANIMATION_CURRENT_STATE_VAR.name, o.DYNAMIC_TYPE),
|
new o.FnParam(_ANIMATION_CURRENT_STATE_VAR.name, o.DYNAMIC_TYPE),
|
||||||
new o.FnParam(_ANIMATION_NEXT_STATE_VAR.name, o.DYNAMIC_TYPE)
|
new o.FnParam(_ANIMATION_NEXT_STATE_VAR.name, o.DYNAMIC_TYPE)
|
||||||
|
@ -32,8 +32,6 @@ export abstract class CompileMetadataWithIdentifier {
|
|||||||
|
|
||||||
get runtimeCacheKey(): any { return unimplemented(); }
|
get runtimeCacheKey(): any { return unimplemented(); }
|
||||||
|
|
||||||
get assetCacheKey(): any { return unimplemented(); }
|
|
||||||
|
|
||||||
equalsTo(id2: CompileMetadataWithIdentifier): boolean { return unimplemented(); }
|
equalsTo(id2: CompileMetadataWithIdentifier): boolean { return unimplemented(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +91,6 @@ export class CompileIdentifierMetadata implements CompileMetadataWithIdentifier
|
|||||||
prefix: string;
|
prefix: string;
|
||||||
moduleUrl: string;
|
moduleUrl: string;
|
||||||
value: any;
|
value: any;
|
||||||
private _assetCacheKey: any = UNDEFINED;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
{runtime, name, moduleUrl, prefix, value}:
|
{runtime, name, moduleUrl, prefix, value}:
|
||||||
@ -109,23 +106,9 @@ export class CompileIdentifierMetadata implements CompileMetadataWithIdentifier
|
|||||||
|
|
||||||
get runtimeCacheKey(): any { return this.identifier.runtime; }
|
get runtimeCacheKey(): any { return this.identifier.runtime; }
|
||||||
|
|
||||||
get assetCacheKey(): any {
|
|
||||||
if (this._assetCacheKey === UNDEFINED) {
|
|
||||||
if (isPresent(this.moduleUrl) && isPresent(getUrlScheme(this.moduleUrl))) {
|
|
||||||
var uri = reflector.importUri({'filePath': this.moduleUrl, 'name': this.name});
|
|
||||||
this._assetCacheKey = `${this.name}|${uri}`;
|
|
||||||
} else {
|
|
||||||
this._assetCacheKey = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this._assetCacheKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
equalsTo(id2: CompileIdentifierMetadata): boolean {
|
equalsTo(id2: CompileIdentifierMetadata): boolean {
|
||||||
var rk = this.runtimeCacheKey;
|
var rk = this.runtimeCacheKey;
|
||||||
var ak = this.assetCacheKey;
|
return isPresent(rk) && rk == id2.runtimeCacheKey;
|
||||||
return (isPresent(rk) && rk == id2.runtimeCacheKey) ||
|
|
||||||
(isPresent(ak) && ak == id2.assetCacheKey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,19 +216,9 @@ export class CompileTokenMetadata implements CompileMetadataWithIdentifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get assetCacheKey(): any {
|
|
||||||
if (isPresent(this.identifier)) {
|
|
||||||
return this.identifier.assetCacheKey;
|
|
||||||
} else {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
equalsTo(token2: CompileTokenMetadata): boolean {
|
equalsTo(token2: CompileTokenMetadata): boolean {
|
||||||
var rk = this.runtimeCacheKey;
|
var rk = this.runtimeCacheKey;
|
||||||
var ak = this.assetCacheKey;
|
return isPresent(rk) && rk == token2.runtimeCacheKey;
|
||||||
return (isPresent(rk) && rk == token2.runtimeCacheKey) ||
|
|
||||||
(isPresent(ak) && ak == token2.assetCacheKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get name(): string {
|
get name(): string {
|
||||||
@ -275,24 +248,17 @@ export class CompileIdentifierMap<KEY extends CompileMetadataWithIdentifier, VAL
|
|||||||
this._tokens.push(token);
|
this._tokens.push(token);
|
||||||
this._values.push(value);
|
this._values.push(value);
|
||||||
var rk = token.runtimeCacheKey;
|
var rk = token.runtimeCacheKey;
|
||||||
if (isPresent(rk)) {
|
if (!isPresent(rk)) {
|
||||||
|
throw new Error(`Cannot find a key for Token: ${token.identifier.name}`);
|
||||||
|
}
|
||||||
this._valueMap.set(rk, value);
|
this._valueMap.set(rk, value);
|
||||||
}
|
}
|
||||||
var ak = token.assetCacheKey;
|
|
||||||
if (isPresent(ak)) {
|
|
||||||
this._valueMap.set(ak, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
get(token: KEY): VALUE {
|
get(token: KEY): VALUE {
|
||||||
var rk = token.runtimeCacheKey;
|
var rk = token.runtimeCacheKey;
|
||||||
var ak = token.assetCacheKey;
|
|
||||||
var result: VALUE;
|
var result: VALUE;
|
||||||
if (isPresent(rk)) {
|
if (isPresent(rk)) {
|
||||||
result = this._valueMap.get(rk);
|
result = this._valueMap.get(rk);
|
||||||
}
|
}
|
||||||
if (isBlank(result) && isPresent(ak)) {
|
|
||||||
result = this._valueMap.get(ak);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
keys(): KEY[] { return this._tokens; }
|
keys(): KEY[] { return this._tokens; }
|
||||||
@ -547,8 +513,6 @@ export class CompileDirectiveMetadata implements CompileMetadataWithIdentifier {
|
|||||||
|
|
||||||
get runtimeCacheKey(): any { return this.type.runtimeCacheKey; }
|
get runtimeCacheKey(): any { return this.type.runtimeCacheKey; }
|
||||||
|
|
||||||
get assetCacheKey(): any { return this.type.assetCacheKey; }
|
|
||||||
|
|
||||||
equalsTo(other: CompileMetadataWithIdentifier): boolean {
|
equalsTo(other: CompileMetadataWithIdentifier): boolean {
|
||||||
return this.type.equalsTo(other.identifier);
|
return this.type.equalsTo(other.identifier);
|
||||||
}
|
}
|
||||||
@ -568,6 +532,7 @@ export function createHostComponentMeta(compMeta: CompileDirectiveMetadata):
|
|||||||
isHost: true
|
isHost: true
|
||||||
}),
|
}),
|
||||||
template: new CompileTemplateMetadata({
|
template: new CompileTemplateMetadata({
|
||||||
|
encapsulation: ViewEncapsulation.None,
|
||||||
template: template,
|
template: template,
|
||||||
templateUrl: '',
|
templateUrl: '',
|
||||||
styles: [],
|
styles: [],
|
||||||
@ -606,8 +571,6 @@ export class CompilePipeMetadata implements CompileMetadataWithIdentifier {
|
|||||||
get identifier(): CompileIdentifierMetadata { return this.type; }
|
get identifier(): CompileIdentifierMetadata { return this.type; }
|
||||||
get runtimeCacheKey(): any { return this.type.runtimeCacheKey; }
|
get runtimeCacheKey(): any { return this.type.runtimeCacheKey; }
|
||||||
|
|
||||||
get assetCacheKey(): any { return this.type.assetCacheKey; }
|
|
||||||
|
|
||||||
equalsTo(other: CompileMetadataWithIdentifier): boolean {
|
equalsTo(other: CompileMetadataWithIdentifier): boolean {
|
||||||
return this.type.equalsTo(other.identifier);
|
return this.type.equalsTo(other.identifier);
|
||||||
}
|
}
|
||||||
@ -668,8 +631,6 @@ export class CompileNgModuleMetadata implements CompileMetadataWithIdentifier {
|
|||||||
get identifier(): CompileIdentifierMetadata { return this.type; }
|
get identifier(): CompileIdentifierMetadata { return this.type; }
|
||||||
get runtimeCacheKey(): any { return this.type.runtimeCacheKey; }
|
get runtimeCacheKey(): any { return this.type.runtimeCacheKey; }
|
||||||
|
|
||||||
get assetCacheKey(): any { return this.type.assetCacheKey; }
|
|
||||||
|
|
||||||
equalsTo(other: CompileMetadataWithIdentifier): boolean {
|
equalsTo(other: CompileMetadataWithIdentifier): boolean {
|
||||||
return this.type.equalsTo(other.identifier);
|
return this.type.equalsTo(other.identifier);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import {ViewEncapsulation, isDevMode} from '@angular/core';
|
import {ViewEncapsulation, isDevMode} from '@angular/core';
|
||||||
|
|
||||||
import {CompileIdentifierMetadata} from './compile_metadata';
|
import {CompileIdentifierMetadata} from './compile_metadata';
|
||||||
import {Identifiers} from './identifiers';
|
import {Identifiers, resolveIdentifier} from './identifiers';
|
||||||
|
|
||||||
function unimplemented(): any {
|
function unimplemented(): any {
|
||||||
throw new Error('unimplemented');
|
throw new Error('unimplemented');
|
||||||
@ -61,7 +61,7 @@ export abstract class RenderTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class DefaultRenderTypes implements RenderTypes {
|
export class DefaultRenderTypes implements RenderTypes {
|
||||||
renderer = Identifiers.Renderer;
|
get renderer() { return resolveIdentifier(Identifiers.Renderer); };
|
||||||
renderText: any = null;
|
renderText: any = null;
|
||||||
renderElement: any = null;
|
renderElement: any = null;
|
||||||
renderComment: any = null;
|
renderComment: any = null;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, ChangeDetectionStrategy, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ElementRef, Injector, LOCALE_ID as LOCALE_ID_, NgModuleFactory, QueryList, RenderComponentType, Renderer, SecurityContext, SimpleChange, TRANSLATIONS_FORMAT as TRANSLATIONS_FORMAT_, TemplateRef, ViewContainerRef, ViewEncapsulation} from '@angular/core';
|
import {ANALYZE_FOR_ENTRY_COMPONENTS, ChangeDetectionStrategy, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ElementRef, Injector, LOCALE_ID as LOCALE_ID_, NgModuleFactory, QueryList, RenderComponentType, Renderer, SecurityContext, SimpleChange, TRANSLATIONS_FORMAT as TRANSLATIONS_FORMAT_, TemplateRef, ViewContainerRef, ViewEncapsulation} from '@angular/core';
|
||||||
|
|
||||||
import {AnimationGroupPlayer as AnimationGroupPlayer_, AnimationKeyframe as AnimationKeyframe_, AnimationOutput as AnimationOutput_, AnimationSequencePlayer as AnimationSequencePlayer_, AnimationStyles as AnimationStyles_, AppElement, AppView, ChangeDetectorStatus, CodegenComponentFactoryResolver, DebugAppView, DebugContext, EMPTY_ARRAY, EMPTY_MAP, NgModuleInjector, NoOpAnimationPlayer as NoOpAnimationPlayer_, StaticNodeDebugInfo, TemplateRef_, UNINITIALIZED, ValueUnwrapper, ViewType, ViewUtils, balanceAnimationKeyframes as impBalanceAnimationKeyframes, castByValue, checkBinding, clearStyles as impClearStyles, collectAndResolveStyles as impCollectAndResolveStyles, devModeEqual, flattenNestedViewRenderNodes, interpolate, prepareFinalAnimationStyles as impBalanceAnimationStyles, pureProxy1, pureProxy10, pureProxy2, pureProxy3, pureProxy4, pureProxy5, pureProxy6, pureProxy7, pureProxy8, pureProxy9, renderStyles as impRenderStyles} from '../core_private';
|
import {AnimationGroupPlayer as AnimationGroupPlayer_, AnimationKeyframe as AnimationKeyframe_, AnimationOutput as AnimationOutput_, AnimationSequencePlayer as AnimationSequencePlayer_, AnimationStyles as AnimationStyles_, AppElement, AppView, ChangeDetectorStatus, CodegenComponentFactoryResolver, DebugAppView, DebugContext, EMPTY_ARRAY, EMPTY_MAP, NgModuleInjector, NoOpAnimationPlayer as NoOpAnimationPlayer_, StaticNodeDebugInfo, TemplateRef_, UNINITIALIZED, ValueUnwrapper, ViewType, ViewUtils, balanceAnimationKeyframes as impBalanceAnimationKeyframes, castByValue, checkBinding, clearStyles as impClearStyles, collectAndResolveStyles as impCollectAndResolveStyles, devModeEqual, flattenNestedViewRenderNodes, interpolate, prepareFinalAnimationStyles as impBalanceAnimationStyles, pureProxy1, pureProxy10, pureProxy2, pureProxy3, pureProxy4, pureProxy5, pureProxy6, pureProxy7, pureProxy8, pureProxy9, reflector, renderStyles as impRenderStyles} from '../core_private';
|
||||||
|
|
||||||
import {CompileIdentifierMetadata, CompileTokenMetadata} from './compile_metadata';
|
import {CompileIdentifierMetadata, CompileTokenMetadata} from './compile_metadata';
|
||||||
import {assetUrl} from './util';
|
import {assetUrl} from './util';
|
||||||
@ -58,215 +58,286 @@ var impAnimationOutput = AnimationOutput_;
|
|||||||
|
|
||||||
var ANIMATION_STYLE_UTIL_ASSET_URL = assetUrl('core', 'animation/animation_style_util');
|
var ANIMATION_STYLE_UTIL_ASSET_URL = assetUrl('core', 'animation/animation_style_util');
|
||||||
|
|
||||||
|
export interface IdentifierSpec {
|
||||||
|
name: string;
|
||||||
|
moduleUrl: string;
|
||||||
|
runtime: any;
|
||||||
|
}
|
||||||
|
|
||||||
export class Identifiers {
|
export class Identifiers {
|
||||||
static ANALYZE_FOR_ENTRY_COMPONENTS = new CompileIdentifierMetadata({
|
static ANALYZE_FOR_ENTRY_COMPONENTS: IdentifierSpec = {
|
||||||
name: 'ANALYZE_FOR_ENTRY_COMPONENTS',
|
name: 'ANALYZE_FOR_ENTRY_COMPONENTS',
|
||||||
moduleUrl: assetUrl('core', 'metadata/di'),
|
moduleUrl: assetUrl('core', 'metadata/di'),
|
||||||
runtime: ANALYZE_FOR_ENTRY_COMPONENTS
|
runtime: ANALYZE_FOR_ENTRY_COMPONENTS
|
||||||
});
|
};
|
||||||
static ViewUtils = new CompileIdentifierMetadata(
|
static ViewUtils: IdentifierSpec = {
|
||||||
{name: 'ViewUtils', moduleUrl: assetUrl('core', 'linker/view_utils'), runtime: impViewUtils});
|
name: 'ViewUtils',
|
||||||
static AppView = new CompileIdentifierMetadata(
|
moduleUrl: assetUrl('core', 'linker/view_utils'),
|
||||||
{name: 'AppView', moduleUrl: APP_VIEW_MODULE_URL, runtime: impAppView});
|
runtime: impViewUtils
|
||||||
static DebugAppView = new CompileIdentifierMetadata(
|
};
|
||||||
{name: 'DebugAppView', moduleUrl: APP_VIEW_MODULE_URL, runtime: impDebugAppView});
|
static AppView:
|
||||||
static AppElement = new CompileIdentifierMetadata(
|
IdentifierSpec = {name: 'AppView', moduleUrl: APP_VIEW_MODULE_URL, runtime: impAppView};
|
||||||
{name: 'AppElement', moduleUrl: assetUrl('core', 'linker/element'), runtime: impAppElement});
|
static DebugAppView: IdentifierSpec = {
|
||||||
static ElementRef = new CompileIdentifierMetadata({
|
name: 'DebugAppView',
|
||||||
|
moduleUrl: APP_VIEW_MODULE_URL,
|
||||||
|
runtime: impDebugAppView
|
||||||
|
};
|
||||||
|
static AppElement: IdentifierSpec = {
|
||||||
|
name: 'AppElement',
|
||||||
|
moduleUrl: assetUrl('core', 'linker/element'),
|
||||||
|
runtime: impAppElement
|
||||||
|
};
|
||||||
|
static ElementRef: IdentifierSpec = {
|
||||||
name: 'ElementRef',
|
name: 'ElementRef',
|
||||||
moduleUrl: assetUrl('core', 'linker/element_ref'),
|
moduleUrl: assetUrl('core', 'linker/element_ref'),
|
||||||
runtime: impElementRef
|
runtime: impElementRef
|
||||||
});
|
};
|
||||||
static ViewContainerRef = new CompileIdentifierMetadata({
|
static ViewContainerRef: IdentifierSpec = {
|
||||||
name: 'ViewContainerRef',
|
name: 'ViewContainerRef',
|
||||||
moduleUrl: assetUrl('core', 'linker/view_container_ref'),
|
moduleUrl: assetUrl('core', 'linker/view_container_ref'),
|
||||||
runtime: impViewContainerRef
|
runtime: impViewContainerRef
|
||||||
});
|
};
|
||||||
static ChangeDetectorRef = new CompileIdentifierMetadata({
|
static ChangeDetectorRef: IdentifierSpec = {
|
||||||
name: 'ChangeDetectorRef',
|
name: 'ChangeDetectorRef',
|
||||||
moduleUrl: assetUrl('core', 'change_detection/change_detector_ref'),
|
moduleUrl: assetUrl('core', 'change_detection/change_detector_ref'),
|
||||||
runtime: impChangeDetectorRef
|
runtime: impChangeDetectorRef
|
||||||
});
|
};
|
||||||
static RenderComponentType = new CompileIdentifierMetadata({
|
static RenderComponentType: IdentifierSpec = {
|
||||||
name: 'RenderComponentType',
|
name: 'RenderComponentType',
|
||||||
moduleUrl: assetUrl('core', 'render/api'),
|
moduleUrl: assetUrl('core', 'render/api'),
|
||||||
runtime: impRenderComponentType
|
runtime: impRenderComponentType
|
||||||
});
|
};
|
||||||
static QueryList = new CompileIdentifierMetadata(
|
static QueryList: IdentifierSpec = {
|
||||||
{name: 'QueryList', moduleUrl: assetUrl('core', 'linker/query_list'), runtime: impQueryList});
|
name: 'QueryList',
|
||||||
static TemplateRef = new CompileIdentifierMetadata({
|
moduleUrl: assetUrl('core', 'linker/query_list'),
|
||||||
|
runtime: impQueryList
|
||||||
|
};
|
||||||
|
static TemplateRef: IdentifierSpec = {
|
||||||
name: 'TemplateRef',
|
name: 'TemplateRef',
|
||||||
moduleUrl: assetUrl('core', 'linker/template_ref'),
|
moduleUrl: assetUrl('core', 'linker/template_ref'),
|
||||||
runtime: impTemplateRef
|
runtime: impTemplateRef
|
||||||
});
|
};
|
||||||
static TemplateRef_ = new CompileIdentifierMetadata({
|
static TemplateRef_: IdentifierSpec = {
|
||||||
name: 'TemplateRef_',
|
name: 'TemplateRef_',
|
||||||
moduleUrl: assetUrl('core', 'linker/template_ref'),
|
moduleUrl: assetUrl('core', 'linker/template_ref'),
|
||||||
runtime: impTemplateRef_
|
runtime: impTemplateRef_
|
||||||
});
|
};
|
||||||
static CodegenComponentFactoryResolver = new CompileIdentifierMetadata({
|
static CodegenComponentFactoryResolver: IdentifierSpec = {
|
||||||
name: 'CodegenComponentFactoryResolver',
|
name: 'CodegenComponentFactoryResolver',
|
||||||
moduleUrl: assetUrl('core', 'linker/component_factory_resolver'),
|
moduleUrl: assetUrl('core', 'linker/component_factory_resolver'),
|
||||||
runtime: CodegenComponentFactoryResolver
|
runtime: CodegenComponentFactoryResolver
|
||||||
});
|
};
|
||||||
static ComponentFactoryResolver = new CompileIdentifierMetadata({
|
static ComponentFactoryResolver: IdentifierSpec = {
|
||||||
name: 'ComponentFactoryResolver',
|
name: 'ComponentFactoryResolver',
|
||||||
moduleUrl: assetUrl('core', 'linker/component_factory_resolver'),
|
moduleUrl: assetUrl('core', 'linker/component_factory_resolver'),
|
||||||
runtime: ComponentFactoryResolver
|
runtime: ComponentFactoryResolver
|
||||||
});
|
};
|
||||||
static ComponentFactory = new CompileIdentifierMetadata({
|
static ComponentFactory: IdentifierSpec = {
|
||||||
name: 'ComponentFactory',
|
name: 'ComponentFactory',
|
||||||
runtime: ComponentFactory,
|
runtime: ComponentFactory,
|
||||||
moduleUrl: assetUrl('core', 'linker/component_factory')
|
moduleUrl: assetUrl('core', 'linker/component_factory')
|
||||||
});
|
};
|
||||||
static NgModuleFactory = new CompileIdentifierMetadata({
|
static NgModuleFactory: IdentifierSpec = {
|
||||||
name: 'NgModuleFactory',
|
name: 'NgModuleFactory',
|
||||||
runtime: NgModuleFactory,
|
runtime: NgModuleFactory,
|
||||||
moduleUrl: assetUrl('core', 'linker/ng_module_factory')
|
moduleUrl: assetUrl('core', 'linker/ng_module_factory')
|
||||||
});
|
};
|
||||||
static NgModuleInjector = new CompileIdentifierMetadata({
|
static NgModuleInjector: IdentifierSpec = {
|
||||||
name: 'NgModuleInjector',
|
name: 'NgModuleInjector',
|
||||||
runtime: NgModuleInjector,
|
runtime: NgModuleInjector,
|
||||||
moduleUrl: assetUrl('core', 'linker/ng_module_factory')
|
moduleUrl: assetUrl('core', 'linker/ng_module_factory')
|
||||||
});
|
};
|
||||||
static ValueUnwrapper = new CompileIdentifierMetadata(
|
static ValueUnwrapper: IdentifierSpec = {
|
||||||
{name: 'ValueUnwrapper', moduleUrl: CD_MODULE_URL, runtime: impValueUnwrapper});
|
name: 'ValueUnwrapper',
|
||||||
static Injector = new CompileIdentifierMetadata(
|
moduleUrl: CD_MODULE_URL,
|
||||||
{name: 'Injector', moduleUrl: assetUrl('core', 'di/injector'), runtime: impInjector});
|
runtime: impValueUnwrapper
|
||||||
static ViewEncapsulation = new CompileIdentifierMetadata({
|
};
|
||||||
|
static Injector: IdentifierSpec = {
|
||||||
|
name: 'Injector',
|
||||||
|
moduleUrl: assetUrl('core', 'di/injector'),
|
||||||
|
runtime: impInjector
|
||||||
|
};
|
||||||
|
static ViewEncapsulation: IdentifierSpec = {
|
||||||
name: 'ViewEncapsulation',
|
name: 'ViewEncapsulation',
|
||||||
moduleUrl: assetUrl('core', 'metadata/view'),
|
moduleUrl: assetUrl('core', 'metadata/view'),
|
||||||
runtime: impViewEncapsulation
|
runtime: impViewEncapsulation
|
||||||
});
|
};
|
||||||
static ViewType = new CompileIdentifierMetadata(
|
static ViewType: IdentifierSpec = {
|
||||||
{name: 'ViewType', moduleUrl: assetUrl('core', 'linker/view_type'), runtime: impViewType});
|
name: 'ViewType',
|
||||||
static ChangeDetectionStrategy = new CompileIdentifierMetadata({
|
moduleUrl: assetUrl('core', 'linker/view_type'),
|
||||||
|
runtime: impViewType
|
||||||
|
};
|
||||||
|
static ChangeDetectionStrategy: IdentifierSpec = {
|
||||||
name: 'ChangeDetectionStrategy',
|
name: 'ChangeDetectionStrategy',
|
||||||
moduleUrl: CD_MODULE_URL,
|
moduleUrl: CD_MODULE_URL,
|
||||||
runtime: impChangeDetectionStrategy
|
runtime: impChangeDetectionStrategy
|
||||||
});
|
};
|
||||||
static StaticNodeDebugInfo = new CompileIdentifierMetadata({
|
static StaticNodeDebugInfo: IdentifierSpec = {
|
||||||
name: 'StaticNodeDebugInfo',
|
name: 'StaticNodeDebugInfo',
|
||||||
moduleUrl: assetUrl('core', 'linker/debug_context'),
|
moduleUrl: assetUrl('core', 'linker/debug_context'),
|
||||||
runtime: impStaticNodeDebugInfo
|
runtime: impStaticNodeDebugInfo
|
||||||
});
|
};
|
||||||
static DebugContext = new CompileIdentifierMetadata({
|
static DebugContext: IdentifierSpec = {
|
||||||
name: 'DebugContext',
|
name: 'DebugContext',
|
||||||
moduleUrl: assetUrl('core', 'linker/debug_context'),
|
moduleUrl: assetUrl('core', 'linker/debug_context'),
|
||||||
runtime: impDebugContext
|
runtime: impDebugContext
|
||||||
});
|
};
|
||||||
static Renderer = new CompileIdentifierMetadata(
|
static Renderer: IdentifierSpec = {
|
||||||
{name: 'Renderer', moduleUrl: assetUrl('core', 'render/api'), runtime: impRenderer});
|
name: 'Renderer',
|
||||||
static SimpleChange = new CompileIdentifierMetadata(
|
moduleUrl: assetUrl('core', 'render/api'),
|
||||||
{name: 'SimpleChange', moduleUrl: CD_MODULE_URL, runtime: impSimpleChange});
|
runtime: impRenderer
|
||||||
static UNINITIALIZED = new CompileIdentifierMetadata(
|
};
|
||||||
{name: 'UNINITIALIZED', moduleUrl: CD_MODULE_URL, runtime: impUNINITIALIZED});
|
static SimpleChange:
|
||||||
static ChangeDetectorStatus = new CompileIdentifierMetadata(
|
IdentifierSpec = {name: 'SimpleChange', moduleUrl: CD_MODULE_URL, runtime: impSimpleChange};
|
||||||
{name: 'ChangeDetectorStatus', moduleUrl: CD_MODULE_URL, runtime: impChangeDetectorStatus});
|
static UNINITIALIZED:
|
||||||
static checkBinding = new CompileIdentifierMetadata(
|
IdentifierSpec = {name: 'UNINITIALIZED', moduleUrl: CD_MODULE_URL, runtime: impUNINITIALIZED};
|
||||||
{name: 'checkBinding', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: impCheckBinding});
|
static ChangeDetectorStatus: IdentifierSpec = {
|
||||||
static flattenNestedViewRenderNodes = new CompileIdentifierMetadata({
|
name: 'ChangeDetectorStatus',
|
||||||
|
moduleUrl: CD_MODULE_URL,
|
||||||
|
runtime: impChangeDetectorStatus
|
||||||
|
};
|
||||||
|
static checkBinding: IdentifierSpec = {
|
||||||
|
name: 'checkBinding',
|
||||||
|
moduleUrl: VIEW_UTILS_MODULE_URL,
|
||||||
|
runtime: impCheckBinding
|
||||||
|
};
|
||||||
|
static flattenNestedViewRenderNodes: IdentifierSpec = {
|
||||||
name: 'flattenNestedViewRenderNodes',
|
name: 'flattenNestedViewRenderNodes',
|
||||||
moduleUrl: VIEW_UTILS_MODULE_URL,
|
moduleUrl: VIEW_UTILS_MODULE_URL,
|
||||||
runtime: impFlattenNestedViewRenderNodes
|
runtime: impFlattenNestedViewRenderNodes
|
||||||
});
|
};
|
||||||
static devModeEqual = new CompileIdentifierMetadata(
|
static devModeEqual:
|
||||||
{name: 'devModeEqual', moduleUrl: CD_MODULE_URL, runtime: impDevModeEqual});
|
IdentifierSpec = {name: 'devModeEqual', moduleUrl: CD_MODULE_URL, runtime: impDevModeEqual};
|
||||||
static interpolate = new CompileIdentifierMetadata(
|
static interpolate: IdentifierSpec = {
|
||||||
{name: 'interpolate', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: impInterpolate});
|
name: 'interpolate',
|
||||||
static castByValue = new CompileIdentifierMetadata(
|
moduleUrl: VIEW_UTILS_MODULE_URL,
|
||||||
{name: 'castByValue', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: impCastByValue});
|
runtime: impInterpolate
|
||||||
static EMPTY_ARRAY = new CompileIdentifierMetadata(
|
};
|
||||||
{name: 'EMPTY_ARRAY', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: impEMPTY_ARRAY});
|
static castByValue: IdentifierSpec = {
|
||||||
static EMPTY_MAP = new CompileIdentifierMetadata(
|
name: 'castByValue',
|
||||||
{name: 'EMPTY_MAP', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: impEMPTY_MAP});
|
moduleUrl: VIEW_UTILS_MODULE_URL,
|
||||||
|
runtime: impCastByValue
|
||||||
|
};
|
||||||
|
static EMPTY_ARRAY: IdentifierSpec = {
|
||||||
|
name: 'EMPTY_ARRAY',
|
||||||
|
moduleUrl: VIEW_UTILS_MODULE_URL,
|
||||||
|
runtime: impEMPTY_ARRAY
|
||||||
|
};
|
||||||
|
static EMPTY_MAP:
|
||||||
|
IdentifierSpec = {name: 'EMPTY_MAP', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: impEMPTY_MAP};
|
||||||
|
|
||||||
static pureProxies = [
|
static pureProxies = [
|
||||||
null,
|
null,
|
||||||
new CompileIdentifierMetadata(
|
{name: 'pureProxy1', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy1},
|
||||||
{name: 'pureProxy1', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy1}),
|
{name: 'pureProxy2', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy2},
|
||||||
new CompileIdentifierMetadata(
|
{name: 'pureProxy3', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy3},
|
||||||
{name: 'pureProxy2', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy2}),
|
{name: 'pureProxy4', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy4},
|
||||||
new CompileIdentifierMetadata(
|
{name: 'pureProxy5', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy5},
|
||||||
{name: 'pureProxy3', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy3}),
|
{name: 'pureProxy6', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy6},
|
||||||
new CompileIdentifierMetadata(
|
{name: 'pureProxy7', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy7},
|
||||||
{name: 'pureProxy4', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy4}),
|
{name: 'pureProxy8', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy8},
|
||||||
new CompileIdentifierMetadata(
|
{name: 'pureProxy9', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy9},
|
||||||
{name: 'pureProxy5', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy5}),
|
{name: 'pureProxy10', moduleUrl: VIEW_UTILS_MODULE_URL, runtime: pureProxy10},
|
||||||
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}),
|
|
||||||
];
|
];
|
||||||
static SecurityContext = new CompileIdentifierMetadata({
|
static SecurityContext: IdentifierSpec = {
|
||||||
name: 'SecurityContext',
|
name: 'SecurityContext',
|
||||||
moduleUrl: assetUrl('core', 'security'),
|
moduleUrl: assetUrl('core', 'security'),
|
||||||
runtime: SecurityContext,
|
runtime: SecurityContext,
|
||||||
});
|
};
|
||||||
static AnimationKeyframe = new CompileIdentifierMetadata({
|
static AnimationKeyframe: IdentifierSpec = {
|
||||||
name: 'AnimationKeyframe',
|
name: 'AnimationKeyframe',
|
||||||
moduleUrl: assetUrl('core', 'animation/animation_keyframe'),
|
moduleUrl: assetUrl('core', 'animation/animation_keyframe'),
|
||||||
runtime: impAnimationKeyframe
|
runtime: impAnimationKeyframe
|
||||||
});
|
};
|
||||||
static AnimationStyles = new CompileIdentifierMetadata({
|
static AnimationStyles: IdentifierSpec = {
|
||||||
name: 'AnimationStyles',
|
name: 'AnimationStyles',
|
||||||
moduleUrl: assetUrl('core', 'animation/animation_styles'),
|
moduleUrl: assetUrl('core', 'animation/animation_styles'),
|
||||||
runtime: impAnimationStyles
|
runtime: impAnimationStyles
|
||||||
});
|
};
|
||||||
static NoOpAnimationPlayer = new CompileIdentifierMetadata({
|
static NoOpAnimationPlayer: IdentifierSpec = {
|
||||||
name: 'NoOpAnimationPlayer',
|
name: 'NoOpAnimationPlayer',
|
||||||
moduleUrl: assetUrl('core', 'animation/animation_player'),
|
moduleUrl: assetUrl('core', 'animation/animation_player'),
|
||||||
runtime: impNoOpAnimationPlayer
|
runtime: impNoOpAnimationPlayer
|
||||||
});
|
};
|
||||||
static AnimationGroupPlayer = new CompileIdentifierMetadata({
|
static AnimationGroupPlayer: IdentifierSpec = {
|
||||||
name: 'AnimationGroupPlayer',
|
name: 'AnimationGroupPlayer',
|
||||||
moduleUrl: assetUrl('core', 'animation/animation_group_player'),
|
moduleUrl: assetUrl('core', 'animation/animation_group_player'),
|
||||||
runtime: impAnimationGroupPlayer
|
runtime: impAnimationGroupPlayer
|
||||||
});
|
};
|
||||||
static AnimationSequencePlayer = new CompileIdentifierMetadata({
|
static AnimationSequencePlayer: IdentifierSpec = {
|
||||||
name: 'AnimationSequencePlayer',
|
name: 'AnimationSequencePlayer',
|
||||||
moduleUrl: assetUrl('core', 'animation/animation_sequence_player'),
|
moduleUrl: assetUrl('core', 'animation/animation_sequence_player'),
|
||||||
runtime: impAnimationSequencePlayer
|
runtime: impAnimationSequencePlayer
|
||||||
});
|
};
|
||||||
static prepareFinalAnimationStyles = new CompileIdentifierMetadata({
|
static prepareFinalAnimationStyles: IdentifierSpec = {
|
||||||
name: 'prepareFinalAnimationStyles',
|
name: 'prepareFinalAnimationStyles',
|
||||||
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
||||||
runtime: impBalanceAnimationStyles
|
runtime: impBalanceAnimationStyles
|
||||||
});
|
};
|
||||||
static balanceAnimationKeyframes = new CompileIdentifierMetadata({
|
static balanceAnimationKeyframes: IdentifierSpec = {
|
||||||
name: 'balanceAnimationKeyframes',
|
name: 'balanceAnimationKeyframes',
|
||||||
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
||||||
runtime: impBalanceAnimationKeyframes
|
runtime: impBalanceAnimationKeyframes
|
||||||
});
|
};
|
||||||
static clearStyles = new CompileIdentifierMetadata(
|
static clearStyles: IdentifierSpec = {
|
||||||
{name: 'clearStyles', moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL, runtime: impClearStyles});
|
name: 'clearStyles',
|
||||||
static renderStyles = new CompileIdentifierMetadata(
|
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
||||||
{name: 'renderStyles', moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL, runtime: impRenderStyles});
|
runtime: impClearStyles
|
||||||
static collectAndResolveStyles = new CompileIdentifierMetadata({
|
};
|
||||||
|
static renderStyles: IdentifierSpec = {
|
||||||
|
name: 'renderStyles',
|
||||||
|
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
||||||
|
runtime: impRenderStyles
|
||||||
|
};
|
||||||
|
static collectAndResolveStyles: IdentifierSpec = {
|
||||||
name: 'collectAndResolveStyles',
|
name: 'collectAndResolveStyles',
|
||||||
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
moduleUrl: ANIMATION_STYLE_UTIL_ASSET_URL,
|
||||||
runtime: impCollectAndResolveStyles
|
runtime: impCollectAndResolveStyles
|
||||||
});
|
};
|
||||||
static LOCALE_ID = new CompileIdentifierMetadata(
|
static LOCALE_ID: IdentifierSpec = {
|
||||||
{name: 'LOCALE_ID', moduleUrl: assetUrl('core', 'i18n/tokens'), runtime: LOCALE_ID_});
|
name: 'LOCALE_ID',
|
||||||
static TRANSLATIONS_FORMAT = new CompileIdentifierMetadata({
|
moduleUrl: assetUrl('core', 'i18n/tokens'),
|
||||||
|
runtime: LOCALE_ID_
|
||||||
|
};
|
||||||
|
static TRANSLATIONS_FORMAT: IdentifierSpec = {
|
||||||
name: 'TRANSLATIONS_FORMAT',
|
name: 'TRANSLATIONS_FORMAT',
|
||||||
moduleUrl: assetUrl('core', 'i18n/tokens'),
|
moduleUrl: assetUrl('core', 'i18n/tokens'),
|
||||||
runtime: TRANSLATIONS_FORMAT_
|
runtime: TRANSLATIONS_FORMAT_
|
||||||
});
|
};
|
||||||
static AnimationOutput = new CompileIdentifierMetadata({
|
static AnimationOutput: IdentifierSpec = {
|
||||||
name: 'AnimationOutput',
|
name: 'AnimationOutput',
|
||||||
moduleUrl: assetUrl('core', 'animation/animation_output'),
|
moduleUrl: assetUrl('core', 'animation/animation_output'),
|
||||||
runtime: impAnimationOutput
|
runtime: impAnimationOutput
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveIdentifier(identifier: IdentifierSpec) {
|
||||||
|
return new CompileIdentifierMetadata({
|
||||||
|
name: identifier.name,
|
||||||
|
moduleUrl: identifier.moduleUrl,
|
||||||
|
runtime: reflector.resolveType(identifier.name, identifier.moduleUrl) || identifier.runtime
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function identifierToken(identifier: CompileIdentifierMetadata): CompileTokenMetadata {
|
export function identifierToken(identifier: CompileIdentifierMetadata): CompileTokenMetadata {
|
||||||
return new CompileTokenMetadata({identifier: identifier});
|
return new CompileTokenMetadata({identifier: identifier});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resolveIdentifierToken(identifier: IdentifierSpec): CompileTokenMetadata {
|
||||||
|
return identifierToken(resolveIdentifier(identifier));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveEnumIdentifier(
|
||||||
|
enumType: CompileIdentifierMetadata, name: string): CompileIdentifierMetadata {
|
||||||
|
const resolvedEnum = reflector.resolveEnum(enumType, name);
|
||||||
|
if (resolvedEnum) {
|
||||||
|
return new CompileIdentifierMetadata(
|
||||||
|
{name: enumType.name, moduleUrl: enumType.moduleUrl, runtime: resolvedEnum});
|
||||||
|
} else {
|
||||||
|
return new CompileIdentifierMetadata({
|
||||||
|
name: `${enumType.name}.${name}`,
|
||||||
|
moduleUrl: enumType.moduleUrl,
|
||||||
|
runtime: enumType.runtime[name]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@ import {assertArrayOfStrings, assertInterpolationSymbols} from './assertions';
|
|||||||
import * as cpl from './compile_metadata';
|
import * as cpl from './compile_metadata';
|
||||||
import {DirectiveResolver} from './directive_resolver';
|
import {DirectiveResolver} from './directive_resolver';
|
||||||
import {isArray, isBlank, isPresent, isString, stringify} from './facade/lang';
|
import {isArray, isBlank, isPresent, isString, stringify} from './facade/lang';
|
||||||
import {Identifiers, identifierToken} from './identifiers';
|
import {Identifiers, resolveIdentifierToken} from './identifiers';
|
||||||
import {hasLifecycleHook} from './lifecycle_reflector';
|
import {hasLifecycleHook} from './lifecycle_reflector';
|
||||||
import {NgModuleResolver} from './ng_module_resolver';
|
import {NgModuleResolver} from './ng_module_resolver';
|
||||||
import {PipeResolver} from './pipe_resolver';
|
import {PipeResolver} from './pipe_resolver';
|
||||||
@ -565,7 +565,7 @@ export class CompileMetadataResolver {
|
|||||||
compileProvider = this.getProvidersMetadata(provider, targetEntryComponents, debugInfo);
|
compileProvider = this.getProvidersMetadata(provider, targetEntryComponents, debugInfo);
|
||||||
} else if (provider instanceof cpl.ProviderMeta) {
|
} else if (provider instanceof cpl.ProviderMeta) {
|
||||||
let tokenMeta = this.getTokenMetadata(provider.token);
|
let tokenMeta = this.getTokenMetadata(provider.token);
|
||||||
if (tokenMeta.equalsTo(identifierToken(Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS))) {
|
if (tokenMeta.equalsTo(resolveIdentifierToken(Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS))) {
|
||||||
targetEntryComponents.push(...this._getEntryComponentsFromProvider(provider));
|
targetEntryComponents.push(...this._getEntryComponentsFromProvider(provider));
|
||||||
} else {
|
} else {
|
||||||
compileProvider = this.getProviderMetadata(provider);
|
compileProvider = this.getProviderMetadata(provider);
|
||||||
|
@ -12,7 +12,7 @@ import {LifecycleHooks} from '../core_private';
|
|||||||
|
|
||||||
import {CompileDiDependencyMetadata, CompileIdentifierMap, CompileIdentifierMetadata, CompileNgModuleMetadata, CompileProviderMetadata, CompileTokenMetadata} from './compile_metadata';
|
import {CompileDiDependencyMetadata, CompileIdentifierMap, CompileIdentifierMetadata, CompileNgModuleMetadata, CompileProviderMetadata, CompileTokenMetadata} from './compile_metadata';
|
||||||
import {isBlank, isPresent} from './facade/lang';
|
import {isBlank, isPresent} from './facade/lang';
|
||||||
import {Identifiers, identifierToken} from './identifiers';
|
import {Identifiers, identifierToken, resolveIdentifier, resolveIdentifierToken} from './identifiers';
|
||||||
import * as o from './output/output_ast';
|
import * as o from './output/output_ast';
|
||||||
import {convertValueToOutputAst} from './output/value_util';
|
import {convertValueToOutputAst} from './output/value_util';
|
||||||
import {ParseLocation, ParseSourceFile, ParseSourceSpan} from './parse_util';
|
import {ParseLocation, ParseSourceFile, ParseSourceSpan} from './parse_util';
|
||||||
@ -62,12 +62,12 @@ export class NgModuleCompiler {
|
|||||||
var ngModuleFactoryVar = `${ngModuleMeta.type.name}NgFactory`;
|
var ngModuleFactoryVar = `${ngModuleMeta.type.name}NgFactory`;
|
||||||
var ngModuleFactoryStmt =
|
var ngModuleFactoryStmt =
|
||||||
o.variable(ngModuleFactoryVar)
|
o.variable(ngModuleFactoryVar)
|
||||||
.set(o.importExpr(Identifiers.NgModuleFactory)
|
.set(o.importExpr(resolveIdentifier(Identifiers.NgModuleFactory))
|
||||||
.instantiate(
|
.instantiate(
|
||||||
[o.variable(injectorClass.name), o.importExpr(ngModuleMeta.type)],
|
[o.variable(injectorClass.name), o.importExpr(ngModuleMeta.type)],
|
||||||
o.importType(
|
o.importType(
|
||||||
Identifiers.NgModuleFactory, [o.importType(ngModuleMeta.type)],
|
resolveIdentifier(Identifiers.NgModuleFactory),
|
||||||
[o.TypeModifier.Const])))
|
[o.importType(ngModuleMeta.type)], [o.TypeModifier.Const])))
|
||||||
.toDeclStmt(null, [o.StmtModifier.Final]);
|
.toDeclStmt(null, [o.StmtModifier.Final]);
|
||||||
|
|
||||||
return new NgModuleCompileResult(
|
return new NgModuleCompileResult(
|
||||||
@ -128,7 +128,9 @@ class _InjectorBuilder {
|
|||||||
];
|
];
|
||||||
|
|
||||||
var ctor = new o.ClassMethod(
|
var ctor = new o.ClassMethod(
|
||||||
null, [new o.FnParam(InjectorProps.parent.name, o.importType(Identifiers.Injector))],
|
null,
|
||||||
|
[new o.FnParam(
|
||||||
|
InjectorProps.parent.name, o.importType(resolveIdentifier(Identifiers.Injector)))],
|
||||||
[o.SUPER_EXPR
|
[o.SUPER_EXPR
|
||||||
.callFn([
|
.callFn([
|
||||||
o.variable(InjectorProps.parent.name),
|
o.variable(InjectorProps.parent.name),
|
||||||
@ -141,8 +143,9 @@ class _InjectorBuilder {
|
|||||||
|
|
||||||
var injClassName = `${this._ngModuleMeta.type.name}Injector`;
|
var injClassName = `${this._ngModuleMeta.type.name}Injector`;
|
||||||
return new o.ClassStmt(
|
return new o.ClassStmt(
|
||||||
injClassName,
|
injClassName, o.importExpr(
|
||||||
o.importExpr(Identifiers.NgModuleInjector, [o.importType(this._ngModuleMeta.type)]),
|
resolveIdentifier(Identifiers.NgModuleInjector),
|
||||||
|
[o.importType(this._ngModuleMeta.type)]),
|
||||||
this._fields, this._getters, ctor, methods);
|
this._fields, this._getters, ctor, methods);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,8 +209,8 @@ class _InjectorBuilder {
|
|||||||
}
|
}
|
||||||
if (!dep.isSkipSelf) {
|
if (!dep.isSkipSelf) {
|
||||||
if (dep.token &&
|
if (dep.token &&
|
||||||
(dep.token.equalsTo(identifierToken(Identifiers.Injector)) ||
|
(dep.token.equalsTo(resolveIdentifierToken(Identifiers.Injector)) ||
|
||||||
dep.token.equalsTo(identifierToken(Identifiers.ComponentFactoryResolver)))) {
|
dep.token.equalsTo(resolveIdentifierToken(Identifiers.ComponentFactoryResolver)))) {
|
||||||
result = o.THIS_EXPR;
|
result = o.THIS_EXPR;
|
||||||
}
|
}
|
||||||
if (isBlank(result)) {
|
if (isBlank(result)) {
|
||||||
|
@ -11,7 +11,7 @@ import {SchemaMetadata} from '@angular/core';
|
|||||||
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileNgModuleMetadata, CompilePipeMetadata, CompileProviderMetadata, CompileTokenMetadata, StaticSymbol, createHostComponentMeta} from './compile_metadata';
|
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileNgModuleMetadata, CompilePipeMetadata, CompileProviderMetadata, CompileTokenMetadata, StaticSymbol, createHostComponentMeta} from './compile_metadata';
|
||||||
import {DirectiveNormalizer} from './directive_normalizer';
|
import {DirectiveNormalizer} from './directive_normalizer';
|
||||||
import {ListWrapper} from './facade/collection';
|
import {ListWrapper} from './facade/collection';
|
||||||
import {Identifiers} from './identifiers';
|
import {Identifiers, resolveIdentifier, resolveIdentifierToken} from './identifiers';
|
||||||
import {CompileMetadataResolver} from './metadata_resolver';
|
import {CompileMetadataResolver} from './metadata_resolver';
|
||||||
import {NgModuleCompiler} from './ng_module_compiler';
|
import {NgModuleCompiler} from './ng_module_compiler';
|
||||||
import {OutputEmitter} from './output/abstract_emitter';
|
import {OutputEmitter} from './output/abstract_emitter';
|
||||||
@ -108,12 +108,10 @@ export class OfflineCompiler {
|
|||||||
private _compileModule(ngModuleType: StaticSymbol, targetStatements: o.Statement[]): string {
|
private _compileModule(ngModuleType: StaticSymbol, targetStatements: o.Statement[]): string {
|
||||||
const ngModule = this._metadataResolver.getNgModuleMetadata(<any>ngModuleType);
|
const ngModule = this._metadataResolver.getNgModuleMetadata(<any>ngModuleType);
|
||||||
let appCompileResult = this._ngModuleCompiler.compile(ngModule, [
|
let appCompileResult = this._ngModuleCompiler.compile(ngModule, [
|
||||||
|
new CompileProviderMetadata(
|
||||||
|
{token: resolveIdentifierToken(Identifiers.LOCALE_ID), useValue: this._localeId}),
|
||||||
new CompileProviderMetadata({
|
new CompileProviderMetadata({
|
||||||
token: new CompileTokenMetadata({identifier: Identifiers.LOCALE_ID}),
|
token: resolveIdentifierToken(Identifiers.TRANSLATIONS_FORMAT),
|
||||||
useValue: this._localeId
|
|
||||||
}),
|
|
||||||
new CompileProviderMetadata({
|
|
||||||
token: new CompileTokenMetadata({identifier: Identifiers.TRANSLATIONS_FORMAT}),
|
|
||||||
useValue: this._translationFormat
|
useValue: this._translationFormat
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
@ -134,15 +132,16 @@ export class OfflineCompiler {
|
|||||||
var compFactoryVar = _componentFactoryName(compMeta.type);
|
var compFactoryVar = _componentFactoryName(compMeta.type);
|
||||||
targetStatements.push(
|
targetStatements.push(
|
||||||
o.variable(compFactoryVar)
|
o.variable(compFactoryVar)
|
||||||
.set(o.importExpr(Identifiers.ComponentFactory, [o.importType(compMeta.type)])
|
.set(o.importExpr(resolveIdentifier(Identifiers.ComponentFactory), [o.importType(
|
||||||
|
compMeta.type)])
|
||||||
.instantiate(
|
.instantiate(
|
||||||
[
|
[
|
||||||
o.literal(compMeta.selector), o.variable(hostViewFactoryVar),
|
o.literal(compMeta.selector), o.variable(hostViewFactoryVar),
|
||||||
o.importExpr(compMeta.type)
|
o.importExpr(compMeta.type)
|
||||||
],
|
],
|
||||||
o.importType(
|
o.importType(
|
||||||
Identifiers.ComponentFactory, [o.importType(compMeta.type)],
|
resolveIdentifier(Identifiers.ComponentFactory),
|
||||||
[o.TypeModifier.Const])))
|
[o.importType(compMeta.type)], [o.TypeModifier.Const])))
|
||||||
.toDeclStmt(null, [o.StmtModifier.Final]));
|
.toDeclStmt(null, [o.StmtModifier.Final]));
|
||||||
return compFactoryVar;
|
return compFactoryVar;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileIdentifierMap, CompileNgModuleMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTokenMetadata, CompileTypeMetadata} from './compile_metadata';
|
import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileIdentifierMap, CompileNgModuleMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTokenMetadata, CompileTypeMetadata} from './compile_metadata';
|
||||||
import {ListWrapper} from './facade/collection';
|
import {ListWrapper} from './facade/collection';
|
||||||
import {isArray, isBlank, isPresent, normalizeBlank} from './facade/lang';
|
import {isArray, isBlank, isPresent, normalizeBlank} from './facade/lang';
|
||||||
import {Identifiers, identifierToken} from './identifiers';
|
import {Identifiers, resolveIdentifierToken} from './identifiers';
|
||||||
import {ParseError, ParseSourceSpan} from './parse_util';
|
import {ParseError, ParseSourceSpan} from './parse_util';
|
||||||
import {AttrAst, DirectiveAst, ProviderAst, ProviderAstType, ReferenceAst, VariableAst} from './template_parser/template_ast';
|
import {AttrAst, DirectiveAst, ProviderAst, ProviderAstType, ReferenceAst, VariableAst} from './template_parser/template_ast';
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ export class ProviderElementContext {
|
|||||||
refs.forEach((refAst) => {
|
refs.forEach((refAst) => {
|
||||||
this._addQueryReadsTo(new CompileTokenMetadata({value: refAst.name}), queriedTokens);
|
this._addQueryReadsTo(new CompileTokenMetadata({value: refAst.name}), queriedTokens);
|
||||||
});
|
});
|
||||||
if (isPresent(queriedTokens.get(identifierToken(Identifiers.ViewContainerRef)))) {
|
if (isPresent(queriedTokens.get(resolveIdentifierToken(Identifiers.ViewContainerRef)))) {
|
||||||
this._hasViewContainer = true;
|
this._hasViewContainer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,18 +206,18 @@ export class ProviderElementContext {
|
|||||||
// access builtints
|
// access builtints
|
||||||
if ((requestingProviderType === ProviderAstType.Directive ||
|
if ((requestingProviderType === ProviderAstType.Directive ||
|
||||||
requestingProviderType === ProviderAstType.Component)) {
|
requestingProviderType === ProviderAstType.Component)) {
|
||||||
if (dep.token.equalsTo(identifierToken(Identifiers.Renderer)) ||
|
if (dep.token.equalsTo(resolveIdentifierToken(Identifiers.Renderer)) ||
|
||||||
dep.token.equalsTo(identifierToken(Identifiers.ElementRef)) ||
|
dep.token.equalsTo(resolveIdentifierToken(Identifiers.ElementRef)) ||
|
||||||
dep.token.equalsTo(identifierToken(Identifiers.ChangeDetectorRef)) ||
|
dep.token.equalsTo(resolveIdentifierToken(Identifiers.ChangeDetectorRef)) ||
|
||||||
dep.token.equalsTo(identifierToken(Identifiers.TemplateRef))) {
|
dep.token.equalsTo(resolveIdentifierToken(Identifiers.TemplateRef))) {
|
||||||
return dep;
|
return dep;
|
||||||
}
|
}
|
||||||
if (dep.token.equalsTo(identifierToken(Identifiers.ViewContainerRef))) {
|
if (dep.token.equalsTo(resolveIdentifierToken(Identifiers.ViewContainerRef))) {
|
||||||
this._hasViewContainer = true;
|
this._hasViewContainer = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// access the injector
|
// access the injector
|
||||||
if (dep.token.equalsTo(identifierToken(Identifiers.Injector))) {
|
if (dep.token.equalsTo(resolveIdentifierToken(Identifiers.Injector))) {
|
||||||
return dep;
|
return dep;
|
||||||
}
|
}
|
||||||
// access providers
|
// access providers
|
||||||
@ -254,7 +254,7 @@ export class ProviderElementContext {
|
|||||||
// check @Host restriction
|
// check @Host restriction
|
||||||
if (isBlank(result)) {
|
if (isBlank(result)) {
|
||||||
if (!dep.isHost || this._viewContext.component.type.isHost ||
|
if (!dep.isHost || this._viewContext.component.type.isHost ||
|
||||||
identifierToken(this._viewContext.component.type).equalsTo(dep.token) ||
|
resolveIdentifierToken(this._viewContext.component.type).equalsTo(dep.token) ||
|
||||||
isPresent(this._viewContext.viewProviders.get(dep.token))) {
|
isPresent(this._viewContext.viewProviders.get(dep.token))) {
|
||||||
result = dep;
|
result = dep;
|
||||||
} else {
|
} else {
|
||||||
@ -363,8 +363,8 @@ export class NgModuleProviderAnalyzer {
|
|||||||
var foundLocal = false;
|
var foundLocal = false;
|
||||||
if (!dep.isSkipSelf && isPresent(dep.token)) {
|
if (!dep.isSkipSelf && isPresent(dep.token)) {
|
||||||
// access the injector
|
// access the injector
|
||||||
if (dep.token.equalsTo(identifierToken(Identifiers.Injector)) ||
|
if (dep.token.equalsTo(resolveIdentifierToken(Identifiers.Injector)) ||
|
||||||
dep.token.equalsTo(identifierToken(Identifiers.ComponentFactoryResolver))) {
|
dep.token.equalsTo(resolveIdentifierToken(Identifiers.ComponentFactoryResolver))) {
|
||||||
foundLocal = true;
|
foundLocal = true;
|
||||||
// access providers
|
// access providers
|
||||||
} else if (isPresent(this._getOrCreateLocalProvider(dep.token, eager))) {
|
} else if (isPresent(this._getOrCreateLocalProvider(dep.token, eager))) {
|
||||||
|
@ -15,7 +15,7 @@ import {Parser} from '../expression_parser/parser';
|
|||||||
import {ListWrapper, SetWrapper, StringMapWrapper} from '../facade/collection';
|
import {ListWrapper, SetWrapper, StringMapWrapper} from '../facade/collection';
|
||||||
import {isBlank, isPresent, isString} from '../facade/lang';
|
import {isBlank, isPresent, isString} from '../facade/lang';
|
||||||
import {HtmlParser} from '../i18n/html_parser';
|
import {HtmlParser} from '../i18n/html_parser';
|
||||||
import {Identifiers, identifierToken} from '../identifiers';
|
import {Identifiers, identifierToken, resolveIdentifierToken} from '../identifiers';
|
||||||
import * as html from '../ml_parser/ast';
|
import * as html from '../ml_parser/ast';
|
||||||
import {ParseTreeResult} from '../ml_parser/html_parser';
|
import {ParseTreeResult} from '../ml_parser/html_parser';
|
||||||
import {expandNodes} from '../ml_parser/icu_ast_expander';
|
import {expandNodes} from '../ml_parser/icu_ast_expander';
|
||||||
@ -732,7 +732,7 @@ class TemplateParseVisitor implements html.Visitor {
|
|||||||
} else if (isBlank(component)) {
|
} else if (isBlank(component)) {
|
||||||
let refToken: CompileTokenMetadata = null;
|
let refToken: CompileTokenMetadata = null;
|
||||||
if (isTemplateElement) {
|
if (isTemplateElement) {
|
||||||
refToken = identifierToken(Identifiers.TemplateRef);
|
refToken = resolveIdentifierToken(Identifiers.TemplateRef);
|
||||||
}
|
}
|
||||||
targetReferences.push(new ReferenceAst(elOrDirRef.name, refToken, elOrDirRef.sourceSpan));
|
targetReferences.push(new ReferenceAst(elOrDirRef.name, refToken, elOrDirRef.sourceSpan));
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileIdentifierMap, CompileIdentifierMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTokenMetadata} from '../compile_metadata';
|
import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileIdentifierMap, CompileIdentifierMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTokenMetadata} from '../compile_metadata';
|
||||||
import {ListWrapper, StringMapWrapper} from '../facade/collection';
|
import {ListWrapper, StringMapWrapper} from '../facade/collection';
|
||||||
import {isBlank, isPresent} from '../facade/lang';
|
import {isBlank, isPresent} from '../facade/lang';
|
||||||
import {Identifiers, identifierToken} from '../identifiers';
|
import {Identifiers, identifierToken, resolveIdentifier, resolveIdentifierToken} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
import {convertValueToOutputAst} from '../output/value_util';
|
import {convertValueToOutputAst} from '../output/value_util';
|
||||||
import {ProviderAst, ProviderAstType, ReferenceAst, TemplateAst} from '../template_parser/template_ast';
|
import {ProviderAst, ProviderAstType, ReferenceAst, TemplateAst} from '../template_parser/template_ast';
|
||||||
@ -62,11 +62,12 @@ export class CompileElement extends CompileNode {
|
|||||||
this.referenceTokens = {};
|
this.referenceTokens = {};
|
||||||
references.forEach(ref => this.referenceTokens[ref.name] = ref.value);
|
references.forEach(ref => this.referenceTokens[ref.name] = ref.value);
|
||||||
|
|
||||||
this.elementRef = o.importExpr(Identifiers.ElementRef).instantiate([this.renderNode]);
|
this.elementRef =
|
||||||
this.instances.add(identifierToken(Identifiers.ElementRef), this.elementRef);
|
o.importExpr(resolveIdentifier(Identifiers.ElementRef)).instantiate([this.renderNode]);
|
||||||
|
this.instances.add(resolveIdentifierToken(Identifiers.ElementRef), this.elementRef);
|
||||||
this.injector = o.THIS_EXPR.callMethod('injector', [o.literal(this.nodeIndex)]);
|
this.injector = o.THIS_EXPR.callMethod('injector', [o.literal(this.nodeIndex)]);
|
||||||
this.instances.add(identifierToken(Identifiers.Injector), this.injector);
|
this.instances.add(resolveIdentifierToken(Identifiers.Injector), this.injector);
|
||||||
this.instances.add(identifierToken(Identifiers.Renderer), o.THIS_EXPR.prop('renderer'));
|
this.instances.add(resolveIdentifierToken(Identifiers.Renderer), o.THIS_EXPR.prop('renderer'));
|
||||||
if (this.hasViewContainer || this.hasEmbeddedView || isPresent(this.component)) {
|
if (this.hasViewContainer || this.hasEmbeddedView || isPresent(this.component)) {
|
||||||
this._createAppElement();
|
this._createAppElement();
|
||||||
}
|
}
|
||||||
@ -77,16 +78,17 @@ export class CompileElement extends CompileNode {
|
|||||||
var parentNodeIndex = this.isRootElement() ? null : this.parent.nodeIndex;
|
var parentNodeIndex = this.isRootElement() ? null : this.parent.nodeIndex;
|
||||||
// private is fine here as no child view will reference an AppElement
|
// private is fine here as no child view will reference an AppElement
|
||||||
this.view.fields.push(new o.ClassField(
|
this.view.fields.push(new o.ClassField(
|
||||||
fieldName, o.importType(Identifiers.AppElement), [o.StmtModifier.Private]));
|
fieldName, o.importType(resolveIdentifier(Identifiers.AppElement)),
|
||||||
|
[o.StmtModifier.Private]));
|
||||||
var statement =
|
var statement =
|
||||||
o.THIS_EXPR.prop(fieldName)
|
o.THIS_EXPR.prop(fieldName)
|
||||||
.set(o.importExpr(Identifiers.AppElement).instantiate([
|
.set(o.importExpr(resolveIdentifier(Identifiers.AppElement)).instantiate([
|
||||||
o.literal(this.nodeIndex), o.literal(parentNodeIndex), o.THIS_EXPR, this.renderNode
|
o.literal(this.nodeIndex), o.literal(parentNodeIndex), o.THIS_EXPR, this.renderNode
|
||||||
]))
|
]))
|
||||||
.toStmt();
|
.toStmt();
|
||||||
this.view.createMethod.addStmt(statement);
|
this.view.createMethod.addStmt(statement);
|
||||||
this.appElement = o.THIS_EXPR.prop(fieldName);
|
this.appElement = o.THIS_EXPR.prop(fieldName);
|
||||||
this.instances.add(identifierToken(Identifiers.AppElement), this.appElement);
|
this.instances.add(resolveIdentifierToken(Identifiers.AppElement), this.appElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createComponentFactoryResolver(entryComponents: CompileIdentifierMetadata[]) {
|
public createComponentFactoryResolver(entryComponents: CompileIdentifierMetadata[]) {
|
||||||
@ -94,12 +96,13 @@ export class CompileElement extends CompileNode {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var createComponentFactoryResolverExpr =
|
var createComponentFactoryResolverExpr =
|
||||||
o.importExpr(Identifiers.CodegenComponentFactoryResolver).instantiate([
|
o.importExpr(resolveIdentifier(Identifiers.CodegenComponentFactoryResolver)).instantiate([
|
||||||
o.literalArr(entryComponents.map((entryComponent) => o.importExpr(entryComponent))),
|
o.literalArr(entryComponents.map((entryComponent) => o.importExpr(entryComponent))),
|
||||||
injectFromViewParentInjector(identifierToken(Identifiers.ComponentFactoryResolver), false)
|
injectFromViewParentInjector(
|
||||||
|
resolveIdentifierToken(Identifiers.ComponentFactoryResolver), false)
|
||||||
]);
|
]);
|
||||||
var provider = new CompileProviderMetadata({
|
var provider = new CompileProviderMetadata({
|
||||||
token: identifierToken(Identifiers.ComponentFactoryResolver),
|
token: resolveIdentifierToken(Identifiers.ComponentFactoryResolver),
|
||||||
useValue: createComponentFactoryResolverExpr
|
useValue: createComponentFactoryResolverExpr
|
||||||
});
|
});
|
||||||
// Add ComponentFactoryResolver as first provider as it does not have deps on other providers
|
// Add ComponentFactoryResolver as first provider as it does not have deps on other providers
|
||||||
@ -122,11 +125,14 @@ export class CompileElement extends CompileNode {
|
|||||||
setEmbeddedView(embeddedView: CompileView) {
|
setEmbeddedView(embeddedView: CompileView) {
|
||||||
this.embeddedView = embeddedView;
|
this.embeddedView = embeddedView;
|
||||||
if (isPresent(embeddedView)) {
|
if (isPresent(embeddedView)) {
|
||||||
var createTemplateRefExpr = o.importExpr(Identifiers.TemplateRef_).instantiate([
|
var createTemplateRefExpr =
|
||||||
|
o.importExpr(resolveIdentifier(Identifiers.TemplateRef_)).instantiate([
|
||||||
this.appElement, this.embeddedView.viewFactory
|
this.appElement, this.embeddedView.viewFactory
|
||||||
]);
|
]);
|
||||||
var provider = new CompileProviderMetadata(
|
var provider = new CompileProviderMetadata({
|
||||||
{token: identifierToken(Identifiers.TemplateRef), useValue: createTemplateRefExpr});
|
token: resolveIdentifierToken(Identifiers.TemplateRef),
|
||||||
|
useValue: createTemplateRefExpr
|
||||||
|
});
|
||||||
// Add TemplateRef as first provider as it does not have deps on other providers
|
// Add TemplateRef as first provider as it does not have deps on other providers
|
||||||
this._resolvedProvidersArray.unshift(new ProviderAst(
|
this._resolvedProvidersArray.unshift(new ProviderAst(
|
||||||
provider.token, false, true, [provider], ProviderAstType.Builtin, [],
|
provider.token, false, true, [provider], ProviderAstType.Builtin, [],
|
||||||
@ -137,7 +143,7 @@ export class CompileElement extends CompileNode {
|
|||||||
beforeChildren(): void {
|
beforeChildren(): void {
|
||||||
if (this.hasViewContainer) {
|
if (this.hasViewContainer) {
|
||||||
this.instances.add(
|
this.instances.add(
|
||||||
identifierToken(Identifiers.ViewContainerRef), this.appElement.prop('vcRef'));
|
resolveIdentifierToken(Identifiers.ViewContainerRef), this.appElement.prop('vcRef'));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._resolvedProviders = new CompileIdentifierMap<CompileTokenMetadata, ProviderAst>();
|
this._resolvedProviders = new CompileIdentifierMap<CompileTokenMetadata, ProviderAst>();
|
||||||
@ -319,7 +325,7 @@ export class CompileElement extends CompileNode {
|
|||||||
if (isPresent(dep.token)) {
|
if (isPresent(dep.token)) {
|
||||||
// access builtins with special visibility
|
// access builtins with special visibility
|
||||||
if (isBlank(result)) {
|
if (isBlank(result)) {
|
||||||
if (dep.token.equalsTo(identifierToken(Identifiers.ChangeDetectorRef))) {
|
if (dep.token.equalsTo(resolveIdentifierToken(Identifiers.ChangeDetectorRef))) {
|
||||||
if (requestingProviderType === ProviderAstType.Component) {
|
if (requestingProviderType === ProviderAstType.Component) {
|
||||||
return this._compViewExpr.prop('ref');
|
return this._compViewExpr.prop('ref');
|
||||||
} else {
|
} else {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import {CompilePipeMetadata} from '../compile_metadata';
|
import {CompilePipeMetadata} from '../compile_metadata';
|
||||||
import {isBlank, isPresent} from '../facade/lang';
|
import {isBlank, isPresent} from '../facade/lang';
|
||||||
import {Identifiers, identifierToken} from '../identifiers';
|
import {Identifiers, identifierToken, resolveIdentifier, resolveIdentifierToken} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
|
|
||||||
import {CompileView} from './compile_view';
|
import {CompileView} from './compile_view';
|
||||||
@ -42,7 +42,7 @@ export class CompilePipe {
|
|||||||
constructor(public view: CompileView, public meta: CompilePipeMetadata) {
|
constructor(public view: CompileView, public meta: CompilePipeMetadata) {
|
||||||
this.instance = o.THIS_EXPR.prop(`_pipe_${meta.name}_${view.pipeCount++}`);
|
this.instance = o.THIS_EXPR.prop(`_pipe_${meta.name}_${view.pipeCount++}`);
|
||||||
var deps = this.meta.type.diDeps.map((diDep) => {
|
var deps = this.meta.type.diDeps.map((diDep) => {
|
||||||
if (diDep.token.equalsTo(identifierToken(Identifiers.ChangeDetectorRef))) {
|
if (diDep.token.equalsTo(resolveIdentifierToken(Identifiers.ChangeDetectorRef))) {
|
||||||
return getPropertyInView(o.THIS_EXPR.prop('ref'), this.view, this.view.componentView);
|
return getPropertyInView(o.THIS_EXPR.prop('ref'), this.view, this.view.componentView);
|
||||||
}
|
}
|
||||||
return injectFromViewParentInjector(diDep.token, false);
|
return injectFromViewParentInjector(diDep.token, false);
|
||||||
@ -66,7 +66,7 @@ export class CompilePipe {
|
|||||||
pipeInstanceSeenFromPureProxy.prop('transform')
|
pipeInstanceSeenFromPureProxy.prop('transform')
|
||||||
.callMethod(o.BuiltinMethod.Bind, [pipeInstanceSeenFromPureProxy]),
|
.callMethod(o.BuiltinMethod.Bind, [pipeInstanceSeenFromPureProxy]),
|
||||||
args.length, purePipeProxyInstance, callingView);
|
args.length, purePipeProxyInstance, callingView);
|
||||||
return o.importExpr(Identifiers.castByValue)
|
return o.importExpr(resolveIdentifier(Identifiers.castByValue))
|
||||||
.callFn([purePipeProxyInstance, pipeInstanceSeenFromPureProxy.prop('transform')])
|
.callFn([purePipeProxyInstance, pipeInstanceSeenFromPureProxy.prop('transform')])
|
||||||
.callFn(args);
|
.callFn(args);
|
||||||
} else {
|
} else {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import {CompileIdentifierMap, CompileQueryMetadata, CompileTokenMetadata} from '../compile_metadata';
|
import {CompileIdentifierMap, CompileQueryMetadata, CompileTokenMetadata} from '../compile_metadata';
|
||||||
import {ListWrapper} from '../facade/collection';
|
import {ListWrapper} from '../facade/collection';
|
||||||
import {isBlank, isPresent} from '../facade/lang';
|
import {isBlank, isPresent} from '../facade/lang';
|
||||||
import {Identifiers} from '../identifiers';
|
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
|
|
||||||
import {CompileElement} from './compile_element';
|
import {CompileElement} from './compile_element';
|
||||||
@ -115,12 +115,13 @@ function mapNestedViews(
|
|||||||
export function createQueryList(
|
export function createQueryList(
|
||||||
query: CompileQueryMetadata, directiveInstance: o.Expression, propertyName: string,
|
query: CompileQueryMetadata, directiveInstance: o.Expression, propertyName: string,
|
||||||
compileView: CompileView): o.Expression {
|
compileView: CompileView): o.Expression {
|
||||||
compileView.fields.push(
|
compileView.fields.push(new o.ClassField(
|
||||||
new o.ClassField(propertyName, o.importType(Identifiers.QueryList, [o.DYNAMIC_TYPE])));
|
propertyName, o.importType(resolveIdentifier(Identifiers.QueryList), [o.DYNAMIC_TYPE])));
|
||||||
var expr = o.THIS_EXPR.prop(propertyName);
|
var expr = o.THIS_EXPR.prop(propertyName);
|
||||||
compileView.createMethod.addStmt(
|
compileView.createMethod.addStmt(
|
||||||
o.THIS_EXPR.prop(propertyName)
|
o.THIS_EXPR.prop(propertyName)
|
||||||
.set(o.importExpr(Identifiers.QueryList, [o.DYNAMIC_TYPE]).instantiate([]))
|
.set(o.importExpr(resolveIdentifier(Identifiers.QueryList), [o.DYNAMIC_TYPE])
|
||||||
|
.instantiate([]))
|
||||||
.toStmt());
|
.toStmt());
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import {CompileDirectiveMetadata, CompileIdentifierMap, CompileIdentifierMetadat
|
|||||||
import {CompilerConfig} from '../config';
|
import {CompilerConfig} from '../config';
|
||||||
import {ListWrapper} from '../facade/collection';
|
import {ListWrapper} from '../facade/collection';
|
||||||
import {isBlank, isPresent} from '../facade/lang';
|
import {isBlank, isPresent} from '../facade/lang';
|
||||||
import {Identifiers} from '../identifiers';
|
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
import {createDiTokenExpression} from '../util';
|
import {createDiTokenExpression} from '../util';
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ export class CompileView implements NameResolver {
|
|||||||
|
|
||||||
createLiteralArray(values: o.Expression[]): o.Expression {
|
createLiteralArray(values: o.Expression[]): o.Expression {
|
||||||
if (values.length === 0) {
|
if (values.length === 0) {
|
||||||
return o.importExpr(Identifiers.EMPTY_ARRAY);
|
return o.importExpr(resolveIdentifier(Identifiers.EMPTY_ARRAY));
|
||||||
}
|
}
|
||||||
var proxyExpr = o.THIS_EXPR.prop(`_arr_${this.literalArrayCount++}`);
|
var proxyExpr = o.THIS_EXPR.prop(`_arr_${this.literalArrayCount++}`);
|
||||||
var proxyParams: o.FnParam[] = [];
|
var proxyParams: o.FnParam[] = [];
|
||||||
@ -170,7 +170,7 @@ export class CompileView implements NameResolver {
|
|||||||
|
|
||||||
createLiteralMap(entries: Array<Array<string|o.Expression>>): o.Expression {
|
createLiteralMap(entries: Array<Array<string|o.Expression>>): o.Expression {
|
||||||
if (entries.length === 0) {
|
if (entries.length === 0) {
|
||||||
return o.importExpr(Identifiers.EMPTY_MAP);
|
return o.importExpr(resolveIdentifier(Identifiers.EMPTY_MAP));
|
||||||
}
|
}
|
||||||
var proxyExpr = o.THIS_EXPR.prop(`_map_${this.literalMapCount++}`);
|
var proxyExpr = o.THIS_EXPR.prop(`_map_${this.literalMapCount++}`);
|
||||||
var proxyParams: o.FnParam[] = [];
|
var proxyParams: o.FnParam[] = [];
|
||||||
|
@ -10,56 +10,80 @@ import {ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
|
|||||||
|
|
||||||
import {ChangeDetectorStatus, ViewType} from '../../core_private';
|
import {ChangeDetectorStatus, ViewType} from '../../core_private';
|
||||||
import {CompileIdentifierMetadata} from '../compile_metadata';
|
import {CompileIdentifierMetadata} from '../compile_metadata';
|
||||||
import {isBlank, resolveEnumToken} from '../facade/lang';
|
import {isBlank} from '../facade/lang';
|
||||||
import {Identifiers} from '../identifiers';
|
import {Identifiers, resolveEnumIdentifier, resolveIdentifier} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
|
|
||||||
function _enumExpression(classIdentifier: CompileIdentifierMetadata, value: any): o.Expression {
|
function _enumExpression(classIdentifier: CompileIdentifierMetadata, name: string): o.Expression {
|
||||||
if (isBlank(value)) return o.NULL_EXPR;
|
return o.importExpr(resolveEnumIdentifier(classIdentifier, name));
|
||||||
var name = resolveEnumToken(classIdentifier.runtime, value);
|
|
||||||
return o.importExpr(new CompileIdentifierMetadata({
|
|
||||||
name: `${classIdentifier.name}.${name}`,
|
|
||||||
moduleUrl: classIdentifier.moduleUrl,
|
|
||||||
runtime: value
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ViewTypeEnum {
|
export class ViewTypeEnum {
|
||||||
static fromValue(value: ViewType): o.Expression {
|
static fromValue(value: ViewType): o.Expression {
|
||||||
return _enumExpression(Identifiers.ViewType, value);
|
const viewType = resolveIdentifier(Identifiers.ViewType);
|
||||||
|
switch (value) {
|
||||||
|
case ViewType.HOST:
|
||||||
|
return _enumExpression(viewType, 'HOST');
|
||||||
|
case ViewType.COMPONENT:
|
||||||
|
return _enumExpression(viewType, 'COMPONENT');
|
||||||
|
case ViewType.EMBEDDED:
|
||||||
|
return _enumExpression(viewType, 'EMBEDDED');
|
||||||
|
default:
|
||||||
|
throw Error(`Inavlid ViewType value: ${value}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static HOST = ViewTypeEnum.fromValue(ViewType.HOST);
|
|
||||||
static COMPONENT = ViewTypeEnum.fromValue(ViewType.COMPONENT);
|
|
||||||
static EMBEDDED = ViewTypeEnum.fromValue(ViewType.EMBEDDED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ViewEncapsulationEnum {
|
export class ViewEncapsulationEnum {
|
||||||
static fromValue(value: ViewEncapsulation): o.Expression {
|
static fromValue(value: ViewEncapsulation): o.Expression {
|
||||||
return _enumExpression(Identifiers.ViewEncapsulation, value);
|
const viewEncapsulation = resolveIdentifier(Identifiers.ViewEncapsulation);
|
||||||
|
switch (value) {
|
||||||
|
case ViewEncapsulation.Emulated:
|
||||||
|
return _enumExpression(viewEncapsulation, 'Emulated');
|
||||||
|
case ViewEncapsulation.Native:
|
||||||
|
return _enumExpression(viewEncapsulation, 'Native');
|
||||||
|
case ViewEncapsulation.None:
|
||||||
|
return _enumExpression(viewEncapsulation, 'None');
|
||||||
|
default:
|
||||||
|
throw Error(`Inavlid ViewEncapsulation value: ${value}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static Emulated = ViewEncapsulationEnum.fromValue(ViewEncapsulation.Emulated);
|
|
||||||
static Native = ViewEncapsulationEnum.fromValue(ViewEncapsulation.Native);
|
|
||||||
static None = ViewEncapsulationEnum.fromValue(ViewEncapsulation.None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ChangeDetectionStrategyEnum {
|
export class ChangeDetectionStrategyEnum {
|
||||||
static fromValue(value: ChangeDetectionStrategy): o.Expression {
|
static fromValue(value: ChangeDetectionStrategy): o.Expression {
|
||||||
return _enumExpression(Identifiers.ChangeDetectionStrategy, value);
|
const changeDetectionStrategy = resolveIdentifier(Identifiers.ChangeDetectionStrategy);
|
||||||
|
switch (value) {
|
||||||
|
case ChangeDetectionStrategy.OnPush:
|
||||||
|
return _enumExpression(changeDetectionStrategy, 'OnPush');
|
||||||
|
case ChangeDetectionStrategy.Default:
|
||||||
|
return _enumExpression(changeDetectionStrategy, 'Default');
|
||||||
|
default:
|
||||||
|
throw Error(`Inavlid ChangeDetectionStrategy value: ${value}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static OnPush = ChangeDetectionStrategyEnum.fromValue(ChangeDetectionStrategy.OnPush);
|
|
||||||
static Default = ChangeDetectionStrategyEnum.fromValue(ChangeDetectionStrategy.Default);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ChangeDetectorStatusEnum {
|
export class ChangeDetectorStatusEnum {
|
||||||
static fromValue(value: ChangeDetectorStatusEnum): o.Expression {
|
static fromValue(value: ChangeDetectorStatusEnum): o.Expression {
|
||||||
return _enumExpression(Identifiers.ChangeDetectorStatus, value);
|
const changeDetectorStatus = resolveIdentifier(Identifiers.ChangeDetectorStatus);
|
||||||
|
switch (value) {
|
||||||
|
case ChangeDetectorStatus.CheckOnce:
|
||||||
|
return _enumExpression(changeDetectorStatus, 'CheckOnce');
|
||||||
|
case ChangeDetectorStatus.Checked:
|
||||||
|
return _enumExpression(changeDetectorStatus, 'Checked');
|
||||||
|
case ChangeDetectorStatus.CheckAlways:
|
||||||
|
return _enumExpression(changeDetectorStatus, 'CheckAlways');
|
||||||
|
case ChangeDetectorStatus.Detached:
|
||||||
|
return _enumExpression(changeDetectorStatus, 'Detached');
|
||||||
|
case ChangeDetectorStatus.Errored:
|
||||||
|
return _enumExpression(changeDetectorStatus, 'Errored');
|
||||||
|
case ChangeDetectorStatus.Destroyed:
|
||||||
|
return _enumExpression(changeDetectorStatus, 'Destroyed');
|
||||||
|
default:
|
||||||
|
throw Error(`Inavlid ChangeDetectorStatus value: ${value}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static CheckOnce = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.CheckOnce);
|
|
||||||
static Checked = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.Checked);
|
|
||||||
static CheckAlways = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.CheckAlways);
|
|
||||||
static Detached = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.Detached);
|
|
||||||
static Errored = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.Errored);
|
|
||||||
static Destroyed = ChangeDetectorStatusEnum.fromValue(ChangeDetectorStatus.Destroyed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ViewConstructorVars {
|
export class ViewConstructorVars {
|
||||||
|
@ -10,7 +10,7 @@ import {AnimationOutput} from '../../core_private';
|
|||||||
import {CompileDirectiveMetadata} from '../compile_metadata';
|
import {CompileDirectiveMetadata} from '../compile_metadata';
|
||||||
import {ListWrapper, StringMapWrapper} from '../facade/collection';
|
import {ListWrapper, StringMapWrapper} from '../facade/collection';
|
||||||
import {StringWrapper, isBlank, isPresent} from '../facade/lang';
|
import {StringWrapper, isBlank, isPresent} from '../facade/lang';
|
||||||
import {Identifiers, identifierToken} from '../identifiers';
|
import {Identifiers, identifierToken, resolveIdentifier} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
import {BoundEventAst, DirectiveAst} from '../template_parser/template_ast';
|
import {BoundEventAst, DirectiveAst} from '../template_parser/template_ast';
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ export class CompileEventListener {
|
|||||||
'registerAnimationOutput',
|
'registerAnimationOutput',
|
||||||
[
|
[
|
||||||
this.compileElement.renderNode,
|
this.compileElement.renderNode,
|
||||||
o.importExpr(Identifiers.AnimationOutput).instantiate([
|
o.importExpr(resolveIdentifier(Identifiers.AnimationOutput)).instantiate([
|
||||||
o.literal(output.name), o.literal(output.phase)
|
o.literal(output.name), o.literal(output.phase)
|
||||||
]),
|
]),
|
||||||
outputListener
|
outputListener
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import * as cdAst from '../expression_parser/ast';
|
import * as cdAst from '../expression_parser/ast';
|
||||||
import {isArray, isBlank, isPresent} from '../facade/lang';
|
import {isArray, isBlank, isPresent} from '../facade/lang';
|
||||||
import {Identifiers} from '../identifiers';
|
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
|
|
||||||
export interface NameResolver {
|
export interface NameResolver {
|
||||||
@ -193,7 +193,7 @@ class _AstToIrVisitor implements cdAst.AstVisitor {
|
|||||||
args.push(this.visit(ast.expressions[i], _Mode.Expression));
|
args.push(this.visit(ast.expressions[i], _Mode.Expression));
|
||||||
}
|
}
|
||||||
args.push(o.literal(ast.strings[ast.strings.length - 1]));
|
args.push(o.literal(ast.strings[ast.strings.length - 1]));
|
||||||
return o.importExpr(Identifiers.interpolate).callFn(args);
|
return o.importExpr(resolveIdentifier(Identifiers.interpolate)).callFn(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitKeyedRead(ast: cdAst.KeyedRead, mode: _Mode): any {
|
visitKeyedRead(ast: cdAst.KeyedRead, mode: _Mode): any {
|
||||||
|
@ -11,7 +11,7 @@ import {SecurityContext} from '@angular/core';
|
|||||||
import {EMPTY_STATE as EMPTY_ANIMATION_STATE, LifecycleHooks, isDefaultChangeDetectionStrategy} from '../../core_private';
|
import {EMPTY_STATE as EMPTY_ANIMATION_STATE, LifecycleHooks, isDefaultChangeDetectionStrategy} from '../../core_private';
|
||||||
import * as cdAst from '../expression_parser/ast';
|
import * as cdAst from '../expression_parser/ast';
|
||||||
import {isBlank, isPresent} from '../facade/lang';
|
import {isBlank, isPresent} from '../facade/lang';
|
||||||
import {Identifiers} from '../identifiers';
|
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
import {BoundElementPropertyAst, BoundTextAst, DirectiveAst, PropertyBindingType} from '../template_parser/template_ast';
|
import {BoundElementPropertyAst, BoundTextAst, DirectiveAst, PropertyBindingType} from '../template_parser/template_ast';
|
||||||
import {camelCaseToDashCase} from '../util';
|
import {camelCaseToDashCase} from '../util';
|
||||||
@ -52,8 +52,9 @@ function bind(
|
|||||||
|
|
||||||
// private is fine here as no child view will reference the cached value...
|
// private is fine here as no child view will reference the cached value...
|
||||||
view.fields.push(new o.ClassField(fieldExpr.name, null, [o.StmtModifier.Private]));
|
view.fields.push(new o.ClassField(fieldExpr.name, null, [o.StmtModifier.Private]));
|
||||||
view.createMethod.addStmt(
|
view.createMethod.addStmt(o.THIS_EXPR.prop(fieldExpr.name)
|
||||||
o.THIS_EXPR.prop(fieldExpr.name).set(o.importExpr(Identifiers.UNINITIALIZED)).toStmt());
|
.set(o.importExpr(resolveIdentifier(Identifiers.UNINITIALIZED)))
|
||||||
|
.toStmt());
|
||||||
|
|
||||||
if (checkExpression.needsValueUnwrapper) {
|
if (checkExpression.needsValueUnwrapper) {
|
||||||
var initValueUnwrapperStmt = DetectChangesVars.valUnwrapper.callMethod('reset', []).toStmt();
|
var initValueUnwrapperStmt = DetectChangesVars.valUnwrapper.callMethod('reset', []).toStmt();
|
||||||
@ -62,7 +63,7 @@ function bind(
|
|||||||
method.addStmt(
|
method.addStmt(
|
||||||
currValExpr.set(checkExpression.expression).toDeclStmt(null, [o.StmtModifier.Final]));
|
currValExpr.set(checkExpression.expression).toDeclStmt(null, [o.StmtModifier.Final]));
|
||||||
|
|
||||||
var condition: o.Expression = o.importExpr(Identifiers.checkBinding).callFn([
|
var condition: o.Expression = o.importExpr(resolveIdentifier(Identifiers.checkBinding)).callFn([
|
||||||
DetectChangesVars.throwOnChange, fieldExpr, currValExpr
|
DetectChangesVars.throwOnChange, fieldExpr, currValExpr
|
||||||
]);
|
]);
|
||||||
if (checkExpression.needsValueUnwrapper) {
|
if (checkExpression.needsValueUnwrapper) {
|
||||||
@ -160,14 +161,14 @@ function bindAndWriteToRenderer(
|
|||||||
var oldRenderVar = o.variable('oldRenderVar');
|
var oldRenderVar = o.variable('oldRenderVar');
|
||||||
updateStmts.push(oldRenderVar.set(oldRenderValue).toDeclStmt());
|
updateStmts.push(oldRenderVar.set(oldRenderValue).toDeclStmt());
|
||||||
updateStmts.push(new o.IfStmt(
|
updateStmts.push(new o.IfStmt(
|
||||||
oldRenderVar.equals(o.importExpr(Identifiers.UNINITIALIZED)),
|
oldRenderVar.equals(o.importExpr(resolveIdentifier(Identifiers.UNINITIALIZED))),
|
||||||
[oldRenderVar.set(emptyStateValue).toStmt()]));
|
[oldRenderVar.set(emptyStateValue).toStmt()]));
|
||||||
|
|
||||||
// ... => void
|
// ... => void
|
||||||
var newRenderVar = o.variable('newRenderVar');
|
var newRenderVar = o.variable('newRenderVar');
|
||||||
updateStmts.push(newRenderVar.set(renderValue).toDeclStmt());
|
updateStmts.push(newRenderVar.set(renderValue).toDeclStmt());
|
||||||
updateStmts.push(new o.IfStmt(
|
updateStmts.push(new o.IfStmt(
|
||||||
newRenderVar.equals(o.importExpr(Identifiers.UNINITIALIZED)),
|
newRenderVar.equals(o.importExpr(resolveIdentifier(Identifiers.UNINITIALIZED))),
|
||||||
[newRenderVar.set(emptyStateValue).toStmt()]));
|
[newRenderVar.set(emptyStateValue).toStmt()]));
|
||||||
|
|
||||||
updateStmts.push(
|
updateStmts.push(
|
||||||
@ -218,7 +219,8 @@ function sanitizedValue(
|
|||||||
throw new Error(`internal error, unexpected SecurityContext ${boundProp.securityContext}.`);
|
throw new Error(`internal error, unexpected SecurityContext ${boundProp.securityContext}.`);
|
||||||
}
|
}
|
||||||
let ctx = ViewProperties.viewUtils.prop('sanitizer');
|
let ctx = ViewProperties.viewUtils.prop('sanitizer');
|
||||||
let args = [o.importExpr(Identifiers.SecurityContext).prop(enumValue), renderValue];
|
let args =
|
||||||
|
[o.importExpr(resolveIdentifier(Identifiers.SecurityContext)).prop(enumValue), renderValue];
|
||||||
return ctx.callMethod('sanitize', args);
|
return ctx.callMethod('sanitize', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,11 +266,12 @@ export function bindDirectiveInputs(
|
|||||||
statements.push(new o.IfStmt(
|
statements.push(new o.IfStmt(
|
||||||
DetectChangesVars.changes.identical(o.NULL_EXPR),
|
DetectChangesVars.changes.identical(o.NULL_EXPR),
|
||||||
[DetectChangesVars.changes
|
[DetectChangesVars.changes
|
||||||
.set(o.literalMap([], new o.MapType(o.importType(Identifiers.SimpleChange))))
|
.set(o.literalMap(
|
||||||
|
[], new o.MapType(o.importType(resolveIdentifier(Identifiers.SimpleChange)))))
|
||||||
.toStmt()]));
|
.toStmt()]));
|
||||||
statements.push(
|
statements.push(DetectChangesVars.changes.key(o.literal(input.directiveName))
|
||||||
DetectChangesVars.changes.key(o.literal(input.directiveName))
|
.set(o.importExpr(resolveIdentifier(Identifiers.SimpleChange))
|
||||||
.set(o.importExpr(Identifiers.SimpleChange).instantiate([fieldExpr, currValExpr]))
|
.instantiate([fieldExpr, currValExpr]))
|
||||||
.toStmt());
|
.toStmt());
|
||||||
}
|
}
|
||||||
if (isOnPushComp) {
|
if (isOnPushComp) {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import {CompileDirectiveMetadata, CompileTokenMetadata} from '../compile_metadata';
|
import {CompileDirectiveMetadata, CompileTokenMetadata} from '../compile_metadata';
|
||||||
import {isBlank, isPresent} from '../facade/lang';
|
import {isBlank, isPresent} from '../facade/lang';
|
||||||
import {Identifiers} from '../identifiers';
|
import {Identifiers, resolveIdentifier} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
import {createDiTokenExpression} from '../util';
|
import {createDiTokenExpression} from '../util';
|
||||||
|
|
||||||
@ -87,6 +87,7 @@ export function createPureProxy(
|
|||||||
if (isBlank(pureProxyId)) {
|
if (isBlank(pureProxyId)) {
|
||||||
throw new Error(`Unsupported number of argument for pure functions: ${argCount}`);
|
throw new Error(`Unsupported number of argument for pure functions: ${argCount}`);
|
||||||
}
|
}
|
||||||
view.createMethod.addStmt(
|
view.createMethod.addStmt(o.THIS_EXPR.prop(pureProxyProp.name)
|
||||||
o.THIS_EXPR.prop(pureProxyProp.name).set(o.importExpr(pureProxyId).callFn([fn])).toStmt());
|
.set(o.importExpr(resolveIdentifier(pureProxyId)).callFn([fn]))
|
||||||
|
.toStmt());
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import {AnimationCompiler} from '../animation/animation_compiler';
|
|||||||
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileTokenMetadata, CompileTypeMetadata} from '../compile_metadata';
|
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileTokenMetadata, CompileTypeMetadata} from '../compile_metadata';
|
||||||
import {ListWrapper, SetWrapper, StringMapWrapper} from '../facade/collection';
|
import {ListWrapper, SetWrapper, StringMapWrapper} from '../facade/collection';
|
||||||
import {StringWrapper, isPresent} from '../facade/lang';
|
import {StringWrapper, isPresent} from '../facade/lang';
|
||||||
import {Identifiers, identifierToken} from '../identifiers';
|
import {Identifiers, identifierToken, resolveIdentifier, resolveIdentifierToken} from '../identifiers';
|
||||||
import * as o from '../output/output_ast';
|
import * as o from '../output/output_ast';
|
||||||
import {AttrAst, BoundDirectivePropertyAst, BoundElementPropertyAst, BoundEventAst, BoundTextAst, DirectiveAst, ElementAst, EmbeddedTemplateAst, NgContentAst, ProviderAst, ReferenceAst, TemplateAst, TemplateAstVisitor, TextAst, VariableAst, templateVisitAll} from '../template_parser/template_ast';
|
import {AttrAst, BoundDirectivePropertyAst, BoundElementPropertyAst, BoundEventAst, BoundTextAst, DirectiveAst, ElementAst, EmbeddedTemplateAst, NgContentAst, ProviderAst, ReferenceAst, TemplateAst, TemplateAstVisitor, TextAst, VariableAst, templateVisitAll} from '../template_parser/template_ast';
|
||||||
import {createDiTokenExpression} from '../util';
|
import {createDiTokenExpression} from '../util';
|
||||||
@ -148,7 +148,8 @@ class ViewBuilderVisitor implements TemplateAstVisitor {
|
|||||||
'projectNodes',
|
'projectNodes',
|
||||||
[
|
[
|
||||||
parentRenderNode,
|
parentRenderNode,
|
||||||
o.importExpr(Identifiers.flattenNestedViewRenderNodes).callFn([nodesExpression])
|
o.importExpr(resolveIdentifier(Identifiers.flattenNestedViewRenderNodes))
|
||||||
|
.callFn([nodesExpression])
|
||||||
])
|
])
|
||||||
.toStmt());
|
.toStmt());
|
||||||
} else if (this._isRootNode(parent)) {
|
} else if (this._isRootNode(parent)) {
|
||||||
@ -396,7 +397,8 @@ function createViewTopLevelStmts(view: CompileView, targetStatements: o.Statemen
|
|||||||
.set(o.literalArr(
|
.set(o.literalArr(
|
||||||
view.nodes.map(createStaticNodeDebugInfo),
|
view.nodes.map(createStaticNodeDebugInfo),
|
||||||
new o.ArrayType(
|
new o.ArrayType(
|
||||||
new o.ExternalType(Identifiers.StaticNodeDebugInfo), [o.TypeModifier.Const])))
|
new o.ExternalType(resolveIdentifier(Identifiers.StaticNodeDebugInfo)),
|
||||||
|
[o.TypeModifier.Const])))
|
||||||
.toDeclStmt(null, [o.StmtModifier.Final]));
|
.toDeclStmt(null, [o.StmtModifier.Final]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,8 +406,9 @@ function createViewTopLevelStmts(view: CompileView, targetStatements: o.Statemen
|
|||||||
var renderCompTypeVar: o.ReadVarExpr =
|
var renderCompTypeVar: o.ReadVarExpr =
|
||||||
o.variable(`renderType_${view.component.type.name}`); // fix highlighting: `
|
o.variable(`renderType_${view.component.type.name}`); // fix highlighting: `
|
||||||
if (view.viewIndex === 0) {
|
if (view.viewIndex === 0) {
|
||||||
targetStatements.push(renderCompTypeVar.set(o.NULL_EXPR)
|
targetStatements.push(
|
||||||
.toDeclStmt(o.importType(Identifiers.RenderComponentType)));
|
renderCompTypeVar.set(o.NULL_EXPR)
|
||||||
|
.toDeclStmt(o.importType(resolveIdentifier(Identifiers.RenderComponentType))));
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewClass = createViewClass(view, renderCompTypeVar, nodeDebugInfosVar);
|
var viewClass = createViewClass(view, renderCompTypeVar, nodeDebugInfosVar);
|
||||||
@ -429,23 +432,29 @@ function createStaticNodeDebugInfo(node: CompileNode): o.Expression {
|
|||||||
[varName, isPresent(token) ? createDiTokenExpression(token) : o.NULL_EXPR]);
|
[varName, isPresent(token) ? createDiTokenExpression(token) : o.NULL_EXPR]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return o.importExpr(Identifiers.StaticNodeDebugInfo)
|
return o.importExpr(resolveIdentifier(Identifiers.StaticNodeDebugInfo))
|
||||||
.instantiate(
|
.instantiate(
|
||||||
[
|
[
|
||||||
o.literalArr(providerTokens, new o.ArrayType(o.DYNAMIC_TYPE, [o.TypeModifier.Const])),
|
o.literalArr(providerTokens, new o.ArrayType(o.DYNAMIC_TYPE, [o.TypeModifier.Const])),
|
||||||
componentToken,
|
componentToken,
|
||||||
o.literalMap(varTokenEntries, new o.MapType(o.DYNAMIC_TYPE, [o.TypeModifier.Const]))
|
o.literalMap(varTokenEntries, new o.MapType(o.DYNAMIC_TYPE, [o.TypeModifier.Const]))
|
||||||
],
|
],
|
||||||
o.importType(Identifiers.StaticNodeDebugInfo, null, [o.TypeModifier.Const]));
|
o.importType(
|
||||||
|
resolveIdentifier(Identifiers.StaticNodeDebugInfo), null, [o.TypeModifier.Const]));
|
||||||
}
|
}
|
||||||
|
|
||||||
function createViewClass(
|
function createViewClass(
|
||||||
view: CompileView, renderCompTypeVar: o.ReadVarExpr,
|
view: CompileView, renderCompTypeVar: o.ReadVarExpr,
|
||||||
nodeDebugInfosVar: o.Expression): o.ClassStmt {
|
nodeDebugInfosVar: o.Expression): o.ClassStmt {
|
||||||
var viewConstructorArgs = [
|
var viewConstructorArgs = [
|
||||||
new o.FnParam(ViewConstructorVars.viewUtils.name, o.importType(Identifiers.ViewUtils)),
|
new o.FnParam(
|
||||||
new o.FnParam(ViewConstructorVars.parentInjector.name, o.importType(Identifiers.Injector)),
|
ViewConstructorVars.viewUtils.name, o.importType(resolveIdentifier(Identifiers.ViewUtils))),
|
||||||
new o.FnParam(ViewConstructorVars.declarationEl.name, o.importType(Identifiers.AppElement))
|
new o.FnParam(
|
||||||
|
ViewConstructorVars.parentInjector.name,
|
||||||
|
o.importType(resolveIdentifier(Identifiers.Injector))),
|
||||||
|
new o.FnParam(
|
||||||
|
ViewConstructorVars.declarationEl.name,
|
||||||
|
o.importType(resolveIdentifier(Identifiers.AppElement)))
|
||||||
];
|
];
|
||||||
var superConstructorArgs = [
|
var superConstructorArgs = [
|
||||||
o.variable(view.className), renderCompTypeVar, ViewTypeEnum.fromValue(view.viewType),
|
o.variable(view.className), renderCompTypeVar, ViewTypeEnum.fromValue(view.viewType),
|
||||||
@ -462,7 +471,7 @@ function createViewClass(
|
|||||||
var viewMethods = [
|
var viewMethods = [
|
||||||
new o.ClassMethod(
|
new o.ClassMethod(
|
||||||
'createInternal', [new o.FnParam(rootSelectorVar.name, o.STRING_TYPE)],
|
'createInternal', [new o.FnParam(rootSelectorVar.name, o.STRING_TYPE)],
|
||||||
generateCreateMethod(view), o.importType(Identifiers.AppElement)),
|
generateCreateMethod(view), o.importType(resolveIdentifier(Identifiers.AppElement))),
|
||||||
new o.ClassMethod(
|
new o.ClassMethod(
|
||||||
'injectorGetInternal',
|
'injectorGetInternal',
|
||||||
[
|
[
|
||||||
@ -482,17 +491,23 @@ function createViewClass(
|
|||||||
].concat(view.eventHandlerMethods);
|
].concat(view.eventHandlerMethods);
|
||||||
var superClass = view.genConfig.genDebugInfo ? Identifiers.DebugAppView : Identifiers.AppView;
|
var superClass = view.genConfig.genDebugInfo ? Identifiers.DebugAppView : Identifiers.AppView;
|
||||||
var viewClass = new o.ClassStmt(
|
var viewClass = new o.ClassStmt(
|
||||||
view.className, o.importExpr(superClass, [getContextType(view)]), view.fields, view.getters,
|
view.className, o.importExpr(resolveIdentifier(superClass), [getContextType(view)]),
|
||||||
viewConstructor, viewMethods.filter((method) => method.body.length > 0));
|
view.fields, view.getters, viewConstructor,
|
||||||
|
viewMethods.filter((method) => method.body.length > 0));
|
||||||
return viewClass;
|
return viewClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createViewFactory(
|
function createViewFactory(
|
||||||
view: CompileView, viewClass: o.ClassStmt, renderCompTypeVar: o.ReadVarExpr): o.Statement {
|
view: CompileView, viewClass: o.ClassStmt, renderCompTypeVar: o.ReadVarExpr): o.Statement {
|
||||||
var viewFactoryArgs = [
|
var viewFactoryArgs = [
|
||||||
new o.FnParam(ViewConstructorVars.viewUtils.name, o.importType(Identifiers.ViewUtils)),
|
new o.FnParam(
|
||||||
new o.FnParam(ViewConstructorVars.parentInjector.name, o.importType(Identifiers.Injector)),
|
ViewConstructorVars.viewUtils.name, o.importType(resolveIdentifier(Identifiers.ViewUtils))),
|
||||||
new o.FnParam(ViewConstructorVars.declarationEl.name, o.importType(Identifiers.AppElement))
|
new o.FnParam(
|
||||||
|
ViewConstructorVars.parentInjector.name,
|
||||||
|
o.importType(resolveIdentifier(Identifiers.Injector))),
|
||||||
|
new o.FnParam(
|
||||||
|
ViewConstructorVars.declarationEl.name,
|
||||||
|
o.importType(resolveIdentifier(Identifiers.AppElement)))
|
||||||
];
|
];
|
||||||
var initRenderCompTypeStmts: any[] = [];
|
var initRenderCompTypeStmts: any[] = [];
|
||||||
var templateUrlInfo: string;
|
var templateUrlInfo: string;
|
||||||
@ -522,7 +537,7 @@ function createViewFactory(
|
|||||||
o.variable(viewClass.name)
|
o.variable(viewClass.name)
|
||||||
.instantiate(viewClass.constructorMethod.params.map(
|
.instantiate(viewClass.constructorMethod.params.map(
|
||||||
(param) => o.variable(param.name))))]),
|
(param) => o.variable(param.name))))]),
|
||||||
o.importType(Identifiers.AppView, [getContextType(view)]))
|
o.importType(resolveIdentifier(Identifiers.AppView), [getContextType(view)]))
|
||||||
.toDeclStmt(view.viewFactory.name, [o.StmtModifier.Final]);
|
.toDeclStmt(view.viewFactory.name, [o.StmtModifier.Final]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,12 +604,14 @@ function generateDetectChangesMethod(view: CompileView): o.Statement[] {
|
|||||||
varStmts.push(DetectChangesVars.changed.set(o.literal(true)).toDeclStmt(o.BOOL_TYPE));
|
varStmts.push(DetectChangesVars.changed.set(o.literal(true)).toDeclStmt(o.BOOL_TYPE));
|
||||||
}
|
}
|
||||||
if (SetWrapper.has(readVars, DetectChangesVars.changes.name)) {
|
if (SetWrapper.has(readVars, DetectChangesVars.changes.name)) {
|
||||||
varStmts.push(DetectChangesVars.changes.set(o.NULL_EXPR)
|
varStmts.push(
|
||||||
.toDeclStmt(new o.MapType(o.importType(Identifiers.SimpleChange))));
|
DetectChangesVars.changes.set(o.NULL_EXPR)
|
||||||
|
.toDeclStmt(new o.MapType(o.importType(resolveIdentifier(Identifiers.SimpleChange)))));
|
||||||
}
|
}
|
||||||
if (SetWrapper.has(readVars, DetectChangesVars.valUnwrapper.name)) {
|
if (SetWrapper.has(readVars, DetectChangesVars.valUnwrapper.name)) {
|
||||||
varStmts.push(
|
varStmts.push(
|
||||||
DetectChangesVars.valUnwrapper.set(o.importExpr(Identifiers.ValueUnwrapper).instantiate([]))
|
DetectChangesVars.valUnwrapper
|
||||||
|
.set(o.importExpr(resolveIdentifier(Identifiers.ValueUnwrapper)).instantiate([]))
|
||||||
.toDeclStmt(null, [o.StmtModifier.Final]));
|
.toDeclStmt(null, [o.StmtModifier.Final]));
|
||||||
}
|
}
|
||||||
return varStmts.concat(stmts);
|
return varStmts.concat(stmts);
|
||||||
|
34
modules/@angular/compiler/test/compiler_spec.ts
Normal file
34
modules/@angular/compiler/test/compiler_spec.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright Google Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by an MIT-style license that can be
|
||||||
|
* found in the LICENSE file at https://angular.io/license
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {Component} from '@angular/core';
|
||||||
|
import {TestBed} from '@angular/core/testing';
|
||||||
|
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||||
|
|
||||||
|
export function main() {
|
||||||
|
describe('Compiler', () => {
|
||||||
|
it('should generate the correct output when constructors have the same name', () => {
|
||||||
|
function ComponentFactory(selector: string, template: string) {
|
||||||
|
@Component({selector, template})
|
||||||
|
class MyComponent {
|
||||||
|
}
|
||||||
|
return MyComponent;
|
||||||
|
}
|
||||||
|
const HeroComponent = ComponentFactory('my-hero', 'my hero');
|
||||||
|
const VillianComponent = ComponentFactory('a-villian', 'a villian');
|
||||||
|
const MainComponent = ComponentFactory(
|
||||||
|
'my-app', 'I was saved by <my-hero></my-hero> from <a-villian></a-villian>.');
|
||||||
|
|
||||||
|
TestBed.configureTestingModule(
|
||||||
|
{declarations: [HeroComponent, VillianComponent, MainComponent]});
|
||||||
|
const fixture = TestBed.createComponent(MainComponent);
|
||||||
|
expect(fixture.debugElement.nativeElement)
|
||||||
|
.toHaveText('I was saved by my hero from a villian.');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
@ -13,12 +13,12 @@ import {AttrAst, BoundDirectivePropertyAst, BoundElementPropertyAst, BoundEventA
|
|||||||
import {TEMPLATE_TRANSFORMS, TemplateParser, splitClasses} from '@angular/compiler/src/template_parser/template_parser';
|
import {TEMPLATE_TRANSFORMS, TemplateParser, splitClasses} from '@angular/compiler/src/template_parser/template_parser';
|
||||||
import {MockSchemaRegistry} from '@angular/compiler/testing';
|
import {MockSchemaRegistry} from '@angular/compiler/testing';
|
||||||
import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/testing/test_bindings';
|
import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/testing/test_bindings';
|
||||||
import {SchemaMetadata, SecurityContext} from '@angular/core';
|
import {SchemaMetadata, SecurityContext, Type} from '@angular/core';
|
||||||
import {Console} from '@angular/core/src/console';
|
import {Console} from '@angular/core/src/console';
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
||||||
|
|
||||||
import {Identifiers, identifierToken} from '../../src/identifiers';
|
import {Identifiers, identifierToken, resolveIdentifierToken} from '../../src/identifiers';
|
||||||
import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../../src/ml_parser/interpolation_config';
|
import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../../src/ml_parser/interpolation_config';
|
||||||
import {unparse} from '../expression_parser/unparser';
|
import {unparse} from '../expression_parser/unparser';
|
||||||
|
|
||||||
@ -44,12 +44,14 @@ export function main() {
|
|||||||
beforeEach(inject([TemplateParser], (parser: TemplateParser) => {
|
beforeEach(inject([TemplateParser], (parser: TemplateParser) => {
|
||||||
var component = CompileDirectiveMetadata.create({
|
var component = CompileDirectiveMetadata.create({
|
||||||
selector: 'root',
|
selector: 'root',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'Root'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'Root', runtime: {} as Type<any>}),
|
||||||
isComponent: true
|
isComponent: true
|
||||||
});
|
});
|
||||||
ngIf = CompileDirectiveMetadata.create({
|
ngIf = CompileDirectiveMetadata.create({
|
||||||
selector: '[ngIf]',
|
selector: '[ngIf]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'NgIf'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'NgIf', runtime: {} as Type<any>}),
|
||||||
inputs: ['ngIf']
|
inputs: ['ngIf']
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -176,7 +178,8 @@ export function main() {
|
|||||||
inject([TemplateParser], (parser: TemplateParser) => {
|
inject([TemplateParser], (parser: TemplateParser) => {
|
||||||
const component = CompileDirectiveMetadata.create({
|
const component = CompileDirectiveMetadata.create({
|
||||||
selector: 'test',
|
selector: 'test',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'Test'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'Test', runtime: {} as Type<any>}),
|
||||||
isComponent: true,
|
isComponent: true,
|
||||||
template: new CompileTemplateMetadata({interpolation: ['{%', '%}']})
|
template: new CompileTemplateMetadata({interpolation: ['{%', '%}']})
|
||||||
});
|
});
|
||||||
@ -305,7 +308,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
() => {
|
() => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
host: {'[@prop]': 'expr'}
|
host: {'[@prop]': 'expr'}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -316,7 +320,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should throw descriptive error when a host binding is not a string expression', () => {
|
it('should throw descriptive error when a host binding is not a string expression', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'broken',
|
selector: 'broken',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
host: {'[class.foo]': null}
|
host: {'[class.foo]': null}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -328,7 +333,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should throw descriptive error when a host event is not a string expression', () => {
|
it('should throw descriptive error when a host event is not a string expression', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'broken',
|
selector: 'broken',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
host: {'(click)': null}
|
host: {'(click)': null}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -390,7 +396,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'template',
|
selector: 'template',
|
||||||
outputs: ['e'],
|
outputs: ['e'],
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<template (e)="f"></template>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<template (e)="f"></template>', [dirA]))).toEqual([
|
||||||
[EmbeddedTemplateAst],
|
[EmbeddedTemplateAst],
|
||||||
@ -426,15 +433,18 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
() => {
|
() => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
var dirB = CompileDirectiveMetadata.create({
|
var dirB = CompileDirectiveMetadata.create({
|
||||||
selector: '[b]',
|
selector: '[b]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirB'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirB', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
var dirC = CompileDirectiveMetadata.create({
|
var dirC = CompileDirectiveMetadata.create({
|
||||||
selector: '[c]',
|
selector: '[c]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirC'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirC', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div a c b a b>', [dirA, dirB, dirC]))).toEqual([
|
expect(humanizeTplAst(parse('<div a c b a b>', [dirA, dirB, dirC]))).toEqual([
|
||||||
[ElementAst, 'div'], [AttrAst, 'a', ''], [AttrAst, 'c', ''], [AttrAst, 'b', ''],
|
[ElementAst, 'div'], [AttrAst, 'a', ''], [AttrAst, 'c', ''], [AttrAst, 'b', ''],
|
||||||
@ -446,11 +456,13 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should locate directives in property bindings', () => {
|
it('should locate directives in property bindings', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a=b]',
|
selector: '[a=b]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
var dirB = CompileDirectiveMetadata.create({
|
var dirB = CompileDirectiveMetadata.create({
|
||||||
selector: '[b]',
|
selector: '[b]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirB'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirB', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div [a]="b">', [dirA, dirB]))).toEqual([
|
expect(humanizeTplAst(parse('<div [a]="b">', [dirA, dirB]))).toEqual([
|
||||||
[ElementAst, 'div'],
|
[ElementAst, 'div'],
|
||||||
@ -462,7 +474,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should locate directives in event bindings', () => {
|
it('should locate directives in event bindings', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirB'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirB', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(humanizeTplAst(parse('<div (a)="b">', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div (a)="b">', [dirA]))).toEqual([
|
||||||
@ -473,7 +486,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should parse directive host properties', () => {
|
it('should parse directive host properties', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
host: {'[a]': 'expr'}
|
host: {'[a]': 'expr'}
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div></div>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div></div>', [dirA]))).toEqual([
|
||||||
@ -485,7 +499,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should parse directive host listeners', () => {
|
it('should parse directive host listeners', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
host: {'(a)': 'expr'}
|
host: {'(a)': 'expr'}
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div></div>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div></div>', [dirA]))).toEqual([
|
||||||
@ -496,7 +511,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should parse directive properties', () => {
|
it('should parse directive properties', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
inputs: ['aProp']
|
inputs: ['aProp']
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div [aProp]="expr"></div>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div [aProp]="expr"></div>', [dirA]))).toEqual([
|
||||||
@ -508,7 +524,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should parse renamed directive properties', () => {
|
it('should parse renamed directive properties', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
inputs: ['b:a']
|
inputs: ['b:a']
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div [a]="expr"></div>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div [a]="expr"></div>', [dirA]))).toEqual([
|
||||||
@ -519,7 +536,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should parse literal directive properties', () => {
|
it('should parse literal directive properties', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
inputs: ['a']
|
inputs: ['a']
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div a="literal"></div>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div a="literal"></div>', [dirA]))).toEqual([
|
||||||
@ -531,7 +549,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should favor explicit bound properties over literal properties', () => {
|
it('should favor explicit bound properties over literal properties', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
inputs: ['a']
|
inputs: ['a']
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div a="literal" [a]="\'literal2\'"></div>', [dirA])))
|
expect(humanizeTplAst(parse('<div a="literal" [a]="\'literal2\'"></div>', [dirA])))
|
||||||
@ -544,7 +563,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should support optional directive properties', () => {
|
it('should support optional directive properties', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
inputs: ['a']
|
inputs: ['a']
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div></div>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div></div>', [dirA]))).toEqual([
|
||||||
@ -560,9 +580,10 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
function createToken(value: string): CompileTokenMetadata {
|
function createToken(value: string): CompileTokenMetadata {
|
||||||
let token: CompileTokenMetadata;
|
let token: CompileTokenMetadata;
|
||||||
if (value.startsWith('type:')) {
|
if (value.startsWith('type:')) {
|
||||||
|
const name = value.substring(5);
|
||||||
token = new CompileTokenMetadata({
|
token = new CompileTokenMetadata({
|
||||||
identifier:
|
identifier: new CompileTypeMetadata(
|
||||||
new CompileTypeMetadata({moduleUrl: someModuleUrl, name: value.substring(5)})
|
{moduleUrl: someModuleUrl, name, runtime: name as any as Type<any>})
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
token = new CompileTokenMetadata({value: value});
|
token = new CompileTokenMetadata({value: value});
|
||||||
@ -593,10 +614,11 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
function createProvider(
|
function createProvider(
|
||||||
token: string, {multi = false, deps = []}: {multi?: boolean, deps?: string[]} = {}):
|
token: string, {multi = false, deps = []}: {multi?: boolean, deps?: string[]} = {}):
|
||||||
CompileProviderMetadata {
|
CompileProviderMetadata {
|
||||||
|
const name = `provider${nextProviderId++}`;
|
||||||
return new CompileProviderMetadata({
|
return new CompileProviderMetadata({
|
||||||
token: createToken(token),
|
token: createToken(token),
|
||||||
multi: multi,
|
multi: multi,
|
||||||
useClass: new CompileTypeMetadata({name: `provider${nextProviderId++}`}),
|
useClass: new CompileTypeMetadata({name, runtime: name as any as Type<any>}),
|
||||||
deps: deps.map(createDep)
|
deps: deps.map(createDep)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -611,8 +633,12 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
var isComponent = !selector.startsWith('[');
|
var isComponent = !selector.startsWith('[');
|
||||||
return CompileDirectiveMetadata.create({
|
return CompileDirectiveMetadata.create({
|
||||||
selector: selector,
|
selector: selector,
|
||||||
type: new CompileTypeMetadata(
|
type: new CompileTypeMetadata({
|
||||||
{moduleUrl: someModuleUrl, name: selector, diDeps: deps.map(createDep)}),
|
moduleUrl: someModuleUrl,
|
||||||
|
name: selector,
|
||||||
|
diDeps: deps.map(createDep),
|
||||||
|
runtime: selector as any as Type<any>
|
||||||
|
}),
|
||||||
isComponent: isComponent,
|
isComponent: isComponent,
|
||||||
template: new CompileTemplateMetadata({ngContentSelectors: []}),
|
template: new CompileTemplateMetadata({ngContentSelectors: []}),
|
||||||
providers: providers,
|
providers: providers,
|
||||||
@ -860,7 +886,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
|||||||
it('should assign references to directives via exportAs', () => {
|
it('should assign references to directives via exportAs', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
exportAs: 'dirA'
|
exportAs: 'dirA'
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div a #a="dirA"></div>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div a #a="dirA"></div>', [dirA]))).toEqual([
|
||||||
@ -904,7 +931,8 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
|||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
isComponent: true,
|
isComponent: true,
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
exportAs: 'dirA',
|
exportAs: 'dirA',
|
||||||
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
||||||
});
|
});
|
||||||
@ -919,7 +947,8 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
|||||||
it('should not locate directives in references', () => {
|
it('should not locate directives in references', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div ref-a>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div ref-a>', [dirA]))).toEqual([
|
||||||
[ElementAst, 'div'], [ReferenceAst, 'a', null]
|
[ElementAst, 'div'], [ReferenceAst, 'a', null]
|
||||||
@ -945,13 +974,15 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
|||||||
|
|
||||||
it('should support references via #...', () => {
|
it('should support references via #...', () => {
|
||||||
expect(humanizeTplAst(parse('<template #a>', []))).toEqual([
|
expect(humanizeTplAst(parse('<template #a>', []))).toEqual([
|
||||||
[EmbeddedTemplateAst], [ReferenceAst, 'a', identifierToken(Identifiers.TemplateRef)]
|
[EmbeddedTemplateAst],
|
||||||
|
[ReferenceAst, 'a', resolveIdentifierToken(Identifiers.TemplateRef)]
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support references via ref-...', () => {
|
it('should support references via ref-...', () => {
|
||||||
expect(humanizeTplAst(parse('<template ref-a>', []))).toEqual([
|
expect(humanizeTplAst(parse('<template ref-a>', []))).toEqual([
|
||||||
[EmbeddedTemplateAst], [ReferenceAst, 'a', identifierToken(Identifiers.TemplateRef)]
|
[EmbeddedTemplateAst],
|
||||||
|
[ReferenceAst, 'a', resolveIdentifierToken(Identifiers.TemplateRef)]
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -963,7 +994,8 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
|||||||
it('should not locate directives in variables', () => {
|
it('should not locate directives in variables', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<template let-a="b"></template>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<template let-a="b"></template>', [dirA]))).toEqual([
|
||||||
[EmbeddedTemplateAst], [VariableAst, 'a', 'b']
|
[EmbeddedTemplateAst], [VariableAst, 'a', 'b']
|
||||||
@ -1005,12 +1037,14 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
|||||||
it('should locate directives in property bindings', () => {
|
it('should locate directives in property bindings', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a=b]',
|
selector: '[a=b]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
inputs: ['a']
|
inputs: ['a']
|
||||||
});
|
});
|
||||||
var dirB = CompileDirectiveMetadata.create({
|
var dirB = CompileDirectiveMetadata.create({
|
||||||
selector: '[b]',
|
selector: '[b]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirB'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirB', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div template="a b" b>', [dirA, dirB]))).toEqual([
|
expect(humanizeTplAst(parse('<div template="a b" b>', [dirA, dirB]))).toEqual([
|
||||||
[EmbeddedTemplateAst], [DirectiveAst, dirA], [BoundDirectivePropertyAst, 'a', 'b'],
|
[EmbeddedTemplateAst], [DirectiveAst, dirA], [BoundDirectivePropertyAst, 'a', 'b'],
|
||||||
@ -1021,7 +1055,8 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
|||||||
it('should not locate directives in variables', () => {
|
it('should not locate directives in variables', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div template="let a=b">', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div template="let a=b">', [dirA]))).toEqual([
|
||||||
[EmbeddedTemplateAst], [VariableAst, 'a', 'b'], [ElementAst, 'div']
|
[EmbeddedTemplateAst], [VariableAst, 'a', 'b'], [ElementAst, 'div']
|
||||||
@ -1031,7 +1066,8 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
|||||||
it('should not locate directives in references', () => {
|
it('should not locate directives in references', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
expect(humanizeTplAst(parse('<div ref-a>', [dirA]))).toEqual([
|
expect(humanizeTplAst(parse('<div ref-a>', [dirA]))).toEqual([
|
||||||
[ElementAst, 'div'], [ReferenceAst, 'a', null]
|
[ElementAst, 'div'], [ReferenceAst, 'a', null]
|
||||||
@ -1065,8 +1101,11 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
|||||||
return CompileDirectiveMetadata.create({
|
return CompileDirectiveMetadata.create({
|
||||||
selector: selector,
|
selector: selector,
|
||||||
isComponent: true,
|
isComponent: true,
|
||||||
type:
|
type: new CompileTypeMetadata({
|
||||||
new CompileTypeMetadata({moduleUrl: someModuleUrl, name: `SomeComp${compCounter++}`}),
|
moduleUrl: someModuleUrl,
|
||||||
|
name: `SomeComp${compCounter++}`,
|
||||||
|
runtime: {} as Type<any>
|
||||||
|
}),
|
||||||
template: new CompileTemplateMetadata({ngContentSelectors: ngContentSelectors})
|
template: new CompileTemplateMetadata({ngContentSelectors: ngContentSelectors})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1074,8 +1113,11 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
|||||||
function createDir(selector: string): CompileDirectiveMetadata {
|
function createDir(selector: string): CompileDirectiveMetadata {
|
||||||
return CompileDirectiveMetadata.create({
|
return CompileDirectiveMetadata.create({
|
||||||
selector: selector,
|
selector: selector,
|
||||||
type: new CompileTypeMetadata(
|
type: new CompileTypeMetadata({
|
||||||
{moduleUrl: someModuleUrl, name: `SomeDir${compCounter++}`})
|
moduleUrl: someModuleUrl,
|
||||||
|
name: `SomeDir${compCounter++}`,
|
||||||
|
runtime: {} as Type<any>
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1242,7 +1284,8 @@ Can't bind to 'invalidProp' since it isn't a known property of 'div'. ("<div [ER
|
|||||||
it('should report invalid host property names', () => {
|
it('should report invalid host property names', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
host: {'[invalidProp]': 'someProp'}
|
host: {'[invalidProp]': 'someProp'}
|
||||||
});
|
});
|
||||||
expect(() => parse('<div></div>', [dirA])).toThrowError(`Template parse errors:
|
expect(() => parse('<div></div>', [dirA])).toThrowError(`Template parse errors:
|
||||||
@ -1258,7 +1301,8 @@ Parser Error: Unexpected token 'b' at column 3 in [a b] in TestComp@0:5 ("<div [
|
|||||||
() => {
|
() => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
inputs: ['invalidProp']
|
inputs: ['invalidProp']
|
||||||
});
|
});
|
||||||
expect(() => parse('<div [invalid-prop]></div>', [dirA])).not.toThrow();
|
expect(() => parse('<div [invalid-prop]></div>', [dirA])).not.toThrow();
|
||||||
@ -1268,13 +1312,15 @@ Parser Error: Unexpected token 'b' at column 3 in [a b] in TestComp@0:5 ("<div [
|
|||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
isComponent: true,
|
isComponent: true,
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
||||||
});
|
});
|
||||||
var dirB = CompileDirectiveMetadata.create({
|
var dirB = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
isComponent: true,
|
isComponent: true,
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirB'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirB', runtime: {} as Type<any>}),
|
||||||
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
||||||
});
|
});
|
||||||
expect(() => parse('<div>', [dirB, dirA])).toThrowError(`Template parse errors:
|
expect(() => parse('<div>', [dirB, dirA])).toThrowError(`Template parse errors:
|
||||||
@ -1286,7 +1332,8 @@ More than one component: DirB,DirA ("[ERROR ->]<div>"): TestComp@0:0`);
|
|||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
isComponent: true,
|
isComponent: true,
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
||||||
});
|
});
|
||||||
expect(() => parse('<template [a]="b" (e)="f"></template>', [dirA]))
|
expect(() => parse('<template [a]="b" (e)="f"></template>', [dirA]))
|
||||||
@ -1300,7 +1347,8 @@ Property binding a not used by any directive on an embedded template. Make sure
|
|||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
isComponent: true,
|
isComponent: true,
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
||||||
});
|
});
|
||||||
expect(() => parse('<div *a="b"></div>', [dirA])).toThrowError(`Template parse errors:
|
expect(() => parse('<div *a="b"></div>', [dirA])).toThrowError(`Template parse errors:
|
||||||
@ -1452,12 +1500,14 @@ Property binding a not used by any directive on an embedded template. Make sure
|
|||||||
it('should support directive', () => {
|
it('should support directive', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: '[a]',
|
selector: '[a]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
var comp = CompileDirectiveMetadata.create({
|
var comp = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
isComponent: true,
|
isComponent: true,
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'ZComp'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'ZComp', runtime: {} as Type<any>}),
|
||||||
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
template: new CompileTemplateMetadata({ngContentSelectors: []})
|
||||||
});
|
});
|
||||||
expect(humanizeTplAstSourceSpans(parse('<div a>', [dirA, comp]))).toEqual([
|
expect(humanizeTplAstSourceSpans(parse('<div a>', [dirA, comp]))).toEqual([
|
||||||
@ -1469,11 +1519,13 @@ Property binding a not used by any directive on an embedded template. Make sure
|
|||||||
it('should support directive in namespace', () => {
|
it('should support directive in namespace', () => {
|
||||||
var tagSel = CompileDirectiveMetadata.create({
|
var tagSel = CompileDirectiveMetadata.create({
|
||||||
selector: 'circle',
|
selector: 'circle',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'elDir'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'elDir', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
var attrSel = CompileDirectiveMetadata.create({
|
var attrSel = CompileDirectiveMetadata.create({
|
||||||
selector: '[href]',
|
selector: '[href]',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'attrDir'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'attrDir', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(humanizeTplAstSourceSpans(
|
expect(humanizeTplAstSourceSpans(
|
||||||
@ -1491,7 +1543,8 @@ Property binding a not used by any directive on an embedded template. Make sure
|
|||||||
it('should support directive property', () => {
|
it('should support directive property', () => {
|
||||||
var dirA = CompileDirectiveMetadata.create({
|
var dirA = CompileDirectiveMetadata.create({
|
||||||
selector: 'div',
|
selector: 'div',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'}),
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>}),
|
||||||
inputs: ['aProp']
|
inputs: ['aProp']
|
||||||
});
|
});
|
||||||
expect(humanizeTplAstSourceSpans(parse('<div [aProp]="foo"></div>', [dirA]))).toEqual([
|
expect(humanizeTplAstSourceSpans(parse('<div [aProp]="foo"></div>', [dirA]))).toEqual([
|
||||||
@ -1506,7 +1559,8 @@ Property binding a not used by any directive on an embedded template. Make sure
|
|||||||
it('should allow pipes that have been defined as dependencies', () => {
|
it('should allow pipes that have been defined as dependencies', () => {
|
||||||
var testPipe = new CompilePipeMetadata({
|
var testPipe = new CompilePipeMetadata({
|
||||||
name: 'test',
|
name: 'test',
|
||||||
type: new CompileTypeMetadata({moduleUrl: someModuleUrl, name: 'DirA'})
|
type: new CompileTypeMetadata(
|
||||||
|
{moduleUrl: someModuleUrl, name: 'DirA', runtime: {} as Type<any>})
|
||||||
});
|
});
|
||||||
expect(() => parse('{{a | test}}', [], [testPipe])).not.toThrow();
|
expect(() => parse('{{a | test}}', [], [testPipe])).not.toThrow();
|
||||||
});
|
});
|
||||||
|
@ -21,4 +21,6 @@ export interface PlatformReflectionCapabilities {
|
|||||||
setter(name: string): SetterFn;
|
setter(name: string): SetterFn;
|
||||||
method(name: string): MethodFn;
|
method(name: string): MethodFn;
|
||||||
importUri(type: Type<any>): string;
|
importUri(type: Type<any>): string;
|
||||||
|
resolveType(name: string, moduleUrl: string): any;
|
||||||
|
resolveEnum(enumType: any, name: string): any;
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,9 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
|||||||
// Runtime type
|
// Runtime type
|
||||||
return `./${stringify(type)}`;
|
return `./${stringify(type)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolveType(name: string, moduleUrl: string): any { return null; }
|
||||||
|
resolveEnum(enumType: any, name: string): any { return null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertTsickleDecoratorIntoMetadata(decoratorInvocations: any[]): any[] {
|
function convertTsickleDecoratorIntoMetadata(decoratorInvocations: any[]): any[] {
|
||||||
|
@ -176,6 +176,13 @@ export class Reflector extends ReflectorReader {
|
|||||||
_containsReflectionInfo(typeOrFunc: any) { return this._injectableInfo.has(typeOrFunc); }
|
_containsReflectionInfo(typeOrFunc: any) { return this._injectableInfo.has(typeOrFunc); }
|
||||||
|
|
||||||
importUri(type: any): string { return this.reflectionCapabilities.importUri(type); }
|
importUri(type: any): string { return this.reflectionCapabilities.importUri(type); }
|
||||||
|
|
||||||
|
resolveType(name: string, moduleUrl: string): any {
|
||||||
|
return this.reflectionCapabilities.resolveType(name, moduleUrl);
|
||||||
|
}
|
||||||
|
resolveEnum(type: any, name: string): any {
|
||||||
|
return this.reflectionCapabilities.resolveEnum(type, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _mergeMaps(target: Map<string, Function>, config: {[key: string]: Function}): void {
|
function _mergeMaps(target: Map<string, Function>, config: {[key: string]: Function}): void {
|
||||||
|
@ -15,4 +15,6 @@ export abstract class ReflectorReader {
|
|||||||
abstract annotations(typeOrFunc: /*Type*/ any): any[];
|
abstract annotations(typeOrFunc: /*Type*/ any): any[];
|
||||||
abstract propMetadata(typeOrFunc: /*Type*/ any): {[key: string]: any[]};
|
abstract propMetadata(typeOrFunc: /*Type*/ any): {[key: string]: any[]};
|
||||||
abstract importUri(typeOrFunc: /*Type*/ any): string;
|
abstract importUri(typeOrFunc: /*Type*/ any): string;
|
||||||
|
abstract resolveType(name: string, moduleUrl: string): any;
|
||||||
|
abstract resolveEnum(type: any, name: string): any;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user