refactor: rename `ComponentRenderTypeV2` to `RendererTypeV2`

This commit is contained in:
Tobias Bosch 2017-02-17 09:01:37 -08:00 committed by Igor Minar
parent b9f17a9cb2
commit 778ded9fcf
20 changed files with 87 additions and 94 deletions

View File

@ -223,10 +223,7 @@ export class AotCompiler {
}
compiledAnimations.forEach(entry => targetStatements.push(...entry.statements));
targetStatements.push(...viewResult.statements);
return {
viewClassVar: viewResult.viewClassVar,
compRenderTypeVar: viewResult.componentRenderTypeVar
};
return {viewClassVar: viewResult.viewClassVar, compRenderTypeVar: viewResult.rendererTypeVar};
}
private _codgenStyles(

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {ChangeDetectionStrategy, ComponentFactory, ComponentRenderTypeV2, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core';
import {ChangeDetectionStrategy, ComponentFactory, RendererTypeV2, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core';
import {StaticSymbol} from './aot/static_symbol';
import {ListWrapper} from './facade/collection';
@ -117,7 +117,7 @@ export function viewClassName(compType: any, embeddedTemplateIndex: number): str
return `View_${identifierName({reference: compType})}_${embeddedTemplateIndex}`;
}
export function componentRenderTypeName(compType: any): string {
export function rendererTypeName(compType: any): string {
return `RenderType_${identifierName({reference: compType})}`;
}
@ -315,7 +315,7 @@ export interface CompileDirectiveSummary extends CompileTypeSummary {
template: CompileTemplateSummary;
wrapperType: StaticSymbol|ProxyClass;
componentViewType: StaticSymbol|ProxyClass;
componentRenderType: StaticSymbol|ComponentRenderTypeV2;
rendererType: StaticSymbol|RendererTypeV2;
componentFactory: StaticSymbol|ComponentFactory<any>;
}
@ -326,7 +326,7 @@ export class CompileDirectiveMetadata {
static create(
{isHost, type, isComponent, selector, exportAs, changeDetection, inputs, outputs, host,
providers, viewProviders, queries, viewQueries, entryComponents, template, wrapperType,
componentViewType, componentRenderType, componentFactory}: {
componentViewType, rendererType, componentFactory}: {
isHost?: boolean,
type?: CompileTypeMetadata,
isComponent?: boolean,
@ -344,7 +344,7 @@ export class CompileDirectiveMetadata {
template?: CompileTemplateMetadata,
wrapperType?: StaticSymbol|ProxyClass,
componentViewType?: StaticSymbol|ProxyClass,
componentRenderType?: StaticSymbol|ComponentRenderTypeV2,
rendererType?: StaticSymbol|RendererTypeV2,
componentFactory?: StaticSymbol|ComponentFactory<any>,
} = {}): CompileDirectiveMetadata {
const hostListeners: {[key: string]: string} = {};
@ -399,7 +399,7 @@ export class CompileDirectiveMetadata {
template,
wrapperType,
componentViewType,
componentRenderType,
rendererType,
componentFactory,
});
}
@ -424,13 +424,13 @@ export class CompileDirectiveMetadata {
wrapperType: StaticSymbol|ProxyClass;
componentViewType: StaticSymbol|ProxyClass;
componentRenderType: StaticSymbol|ComponentRenderTypeV2;
rendererType: StaticSymbol|RendererTypeV2;
componentFactory: StaticSymbol|ComponentFactory<any>;
constructor({isHost, type, isComponent, selector, exportAs,
changeDetection, inputs, outputs, hostListeners, hostProperties,
hostAttributes, providers, viewProviders, queries, viewQueries,
entryComponents, template, wrapperType, componentViewType, componentRenderType,
entryComponents, template, wrapperType, componentViewType, rendererType,
componentFactory}: {
isHost?: boolean,
type?: CompileTypeMetadata,
@ -451,7 +451,7 @@ export class CompileDirectiveMetadata {
template?: CompileTemplateMetadata,
wrapperType?: StaticSymbol|ProxyClass,
componentViewType?: StaticSymbol|ProxyClass,
componentRenderType?: StaticSymbol|ComponentRenderTypeV2,
rendererType?: StaticSymbol|RendererTypeV2,
componentFactory?: StaticSymbol|ComponentFactory<any>,
} = {}) {
this.isHost = !!isHost;
@ -474,7 +474,7 @@ export class CompileDirectiveMetadata {
this.wrapperType = wrapperType;
this.componentViewType = componentViewType;
this.componentRenderType = componentRenderType;
this.rendererType = rendererType;
this.componentFactory = componentFactory;
}
@ -499,7 +499,7 @@ export class CompileDirectiveMetadata {
template: this.template && this.template.toSummary(),
wrapperType: this.wrapperType,
componentViewType: this.componentViewType,
componentRenderType: this.componentRenderType,
rendererType: this.rendererType,
componentFactory: this.componentFactory
};
}
@ -535,8 +535,7 @@ export function createHostComponentMeta(
queries: [],
viewQueries: [],
componentViewType: hostViewType,
componentRenderType:
{id: '__Host__', encapsulation: ViewEncapsulation.None, styles: [], data: {}}
rendererType: {id: '__Host__', encapsulation: ViewEncapsulation.None, styles: [], data: {}}
});
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {ANALYZE_FOR_ENTRY_COMPONENTS, ChangeDetectionStrategy, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, ComponentRenderTypeV2, ElementRef, Injector, LOCALE_ID, NgModuleFactory, QueryList, RenderComponentType, Renderer, SecurityContext, SimpleChange, TRANSLATIONS_FORMAT, TemplateRef, ViewContainerRef, ViewEncapsulation, ɵAnimationGroupPlayer, ɵAnimationKeyframe, ɵAnimationSequencePlayer, ɵAnimationStyles, ɵAnimationTransition, ɵAppView, ɵChangeDetectorStatus, ɵCodegenComponentFactoryResolver, ɵComponentRef_, ɵDebugAppView, ɵDebugContext, ɵNgModuleInjector, ɵNoOpAnimationPlayer, ɵStaticNodeDebugInfo, ɵTemplateRef_, ɵValueUnwrapper, ɵViewContainer, ɵViewType, ɵbalanceAnimationKeyframes, ɵclearStyles, ɵcollectAndResolveStyles, ɵdevModeEqual, ɵprepareFinalAnimationStyles, ɵreflector, ɵregisterModuleFactory, ɵrenderStyles, ɵviewEngine, ɵview_utils} from '@angular/core';
import {ANALYZE_FOR_ENTRY_COMPONENTS, ChangeDetectionStrategy, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, ElementRef, Injector, LOCALE_ID, NgModuleFactory, QueryList, RenderComponentType, Renderer, RendererTypeV2, SecurityContext, SimpleChange, TRANSLATIONS_FORMAT, TemplateRef, ViewContainerRef, ViewEncapsulation, ɵAnimationGroupPlayer, ɵAnimationKeyframe, ɵAnimationSequencePlayer, ɵAnimationStyles, ɵAnimationTransition, ɵAppView, ɵChangeDetectorStatus, ɵCodegenComponentFactoryResolver, ɵComponentRef_, ɵDebugAppView, ɵDebugContext, ɵNgModuleInjector, ɵNoOpAnimationPlayer, ɵStaticNodeDebugInfo, ɵTemplateRef_, ɵValueUnwrapper, ɵViewContainer, ɵViewType, ɵbalanceAnimationKeyframes, ɵclearStyles, ɵcollectAndResolveStyles, ɵdevModeEqual, ɵprepareFinalAnimationStyles, ɵreflector, ɵregisterModuleFactory, ɵrenderStyles, ɵviewEngine, ɵview_utils} from '@angular/core';
import {CompileIdentifierMetadata, CompileTokenMetadata} from './compile_metadata';
@ -380,11 +380,11 @@ export class Identifiers {
member: 'unwrapValue',
runtime: ɵviewEngine.unwrapValue
};
static createComponentRenderTypeV2: IdentifierSpec = {
static createRendererTypeV2: IdentifierSpec = {
name: 'ɵviewEngine',
moduleUrl: CORE,
member: 'createComponentRenderTypeV2',
runtime: ɵviewEngine.createComponentRenderTypeV2
member: 'createRendererTypeV2',
runtime: ɵviewEngine.createRendererTypeV2
};
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Compiler, ComponentFactory, ComponentRenderTypeV2, Inject, Injector, ModuleWithComponentFactories, NgModuleFactory, Type} from '@angular/core';
import {Compiler, ComponentFactory, Inject, Injector, ModuleWithComponentFactories, NgModuleFactory, RendererTypeV2, Type} from '@angular/core';
import {AnimationCompiler} from '../animation/animation_compiler';
import {AnimationParser} from '../animation/animation_parser';
@ -290,18 +290,17 @@ export class JitCompiler implements Compiler {
.concat(...compiledAnimations.map(ca => ca.statements))
.concat(compileResult.statements);
let viewClass: any;
let componentRenderType: any;
let rendererType: any;
if (!this._compilerConfig.useJit) {
[viewClass, componentRenderType] = interpretStatements(
statements, [compileResult.viewClassVar, compileResult.componentRenderTypeVar]);
[viewClass, rendererType] = interpretStatements(
statements, [compileResult.viewClassVar, compileResult.rendererTypeVar]);
} else {
const sourceUrl =
`/${identifierName(template.ngModule.type)}/${identifierName(template.compType)}/${template.isHost?'host':'component'}.ngfactory.js`;
[viewClass, componentRenderType] = jitStatements(
sourceUrl, statements,
[compileResult.viewClassVar, compileResult.componentRenderTypeVar]);
[viewClass, rendererType] = jitStatements(
sourceUrl, statements, [compileResult.viewClassVar, compileResult.rendererTypeVar]);
}
template.compiled(viewClass, componentRenderType);
template.compiled(viewClass, rendererType);
}
private _resolveStylesCompileResult(
@ -336,11 +335,11 @@ class CompiledTemplate {
public compMeta: CompileDirectiveMetadata, public ngModule: CompileNgModuleMetadata,
public directives: CompileIdentifierMetadata[]) {}
compiled(viewClass: Function, componentRenderType: any) {
compiled(viewClass: Function, rendererType: any) {
this._viewClass = viewClass;
(<ProxyClass>this.compMeta.componentViewType).setDelegate(viewClass);
for (let prop in componentRenderType) {
(<any>this.compMeta.componentRenderType)[prop] = componentRenderType[prop];
for (let prop in rendererType) {
(<any>this.compMeta.rendererType)[prop] = rendererType[prop];
}
this.isCompiled = true;
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AnimationAnimateMetadata, AnimationEntryMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationStateDeclarationMetadata, AnimationStateMetadata, AnimationStateTransitionMetadata, AnimationStyleMetadata, AnimationWithStepsMetadata, Attribute, ChangeDetectionStrategy, Component, ComponentFactory, ComponentRenderTypeV2, Directive, Host, Inject, Injectable, InjectionToken, ModuleWithProviders, Optional, Provider, Query, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef} from '@angular/core';
import {AnimationAnimateMetadata, AnimationEntryMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationStateDeclarationMetadata, AnimationStateMetadata, AnimationStateTransitionMetadata, AnimationStyleMetadata, AnimationWithStepsMetadata, Attribute, ChangeDetectionStrategy, Component, ComponentFactory, Directive, Host, Inject, Injectable, InjectionToken, ModuleWithProviders, Optional, Provider, Query, RendererTypeV2, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef} from '@angular/core';
import {StaticSymbol, StaticSymbolCache} from './aot/static_symbol';
import {ngfactoryFilePath} from './aot/util';
@ -131,10 +131,10 @@ export class CompileMetadataResolver {
}
}
private getComponentRenderType(dirType: any): StaticSymbol|ComponentRenderTypeV2 {
private getRendererType(dirType: any): StaticSymbol|RendererTypeV2 {
if (dirType instanceof StaticSymbol) {
return this._staticSymbolCache.get(
ngfactoryFilePath(dirType.filePath), cpl.componentRenderTypeName(dirType));
ngfactoryFilePath(dirType.filePath), cpl.rendererTypeName(dirType));
} else {
// returning an object as proxy,
// that we fill later during runtime compilation.
@ -246,7 +246,7 @@ export class CompileMetadataResolver {
entryComponents: metadata.entryComponents,
wrapperType: metadata.wrapperType,
componentViewType: metadata.componentViewType,
componentRenderType: metadata.componentRenderType,
rendererType: metadata.rendererType,
componentFactory: metadata.componentFactory,
template: templateMetadata
});
@ -384,8 +384,7 @@ export class CompileMetadataResolver {
wrapperType: this.getDirectiveWrapperClass(directiveType),
componentViewType: nonNormalizedTemplateMetadata ? this.getComponentViewClass(directiveType) :
undefined,
componentRenderType:
nonNormalizedTemplateMetadata ? this.getComponentRenderType(directiveType) : undefined,
rendererType: nonNormalizedTemplateMetadata ? this.getRendererType(directiveType) : undefined,
componentFactory: nonNormalizedTemplateMetadata ?
this.getComponentFactory(selector, directiveType) :
undefined

View File

@ -7,7 +7,7 @@
*/
import {AnimationEntryCompileResult} from '../animation/animation_compiler';
import {CompileDirectiveMetadata, CompilePipeSummary, componentRenderTypeName, tokenName, viewClassName} from '../compile_metadata';
import {CompileDirectiveMetadata, CompilePipeSummary, rendererTypeName, tokenName, viewClassName} from '../compile_metadata';
import {EventHandlerVars, LegacyNameResolver} from '../compiler_util/expression_converter';
import {CompilerConfig} from '../config';
import {isPresent} from '../facade/lang';
@ -70,7 +70,7 @@ export class CompileView implements LegacyNameResolver {
public pipes: CompilePipe[] = [];
public locals = new Map<string, o.Expression>();
public className: string;
public renderComponentTypeName: string;
public rendererTypeName: string;
public classType: o.Type;
public classExpr: o.ReadVarExpr;
@ -103,7 +103,7 @@ export class CompileView implements LegacyNameResolver {
this.viewType = getViewType(component, viewIndex);
this.className = viewClassName(component.type.reference, viewIndex);
this.renderComponentTypeName = componentRenderTypeName(component.type.reference);
this.rendererTypeName = rendererTypeName(component.type.reference);
this.classType = o.expressionType(o.variable(this.className));
this.classExpr = o.variable(this.className);
if (this.viewType === ViewType.COMPONENT || this.viewType === ViewType.HOST) {

View File

@ -386,7 +386,7 @@ function createViewTopLevelStmts(view: CompileView, targetStatements: o.Statemen
const renderCompTypeVar: o.ReadVarExpr =
o.variable(view.renderComponentTypeName); // fix highlighting: `
o.variable(view.rendererTypeName); // fix highlighting: `
if (view.viewIndex === 0) {
let templateUrlInfo: string;
if (view.component.template.templateUrl == identifierModuleUrl(view.component.type)) {

View File

@ -24,8 +24,7 @@ export {ComponentFactoryDependency, ComponentViewDependency, DirectiveWrapperDep
export class ViewCompileResult {
constructor(
public statements: o.Statement[], public viewClassVar: string,
public componentRenderTypeVar: string,
public statements: o.Statement[], public viewClassVar: string, public rendererTypeVar: string,
public dependencies:
Array<ComponentViewDependency|ComponentFactoryDependency|DirectiveWrapperDependency>) {}
}
@ -52,6 +51,6 @@ export class ViewCompiler {
finishView(view, statements);
return new ViewCompileResult(
statements, view.classExpr.name, view.renderComponentTypeName, dependencies);
statements, view.classExpr.name, view.rendererTypeName, dependencies);
}
}

View File

@ -9,7 +9,7 @@
import {ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
import {AnimationEntryCompileResult} from '../animation/animation_compiler';
import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileDirectiveSummary, CompilePipeSummary, CompileProviderMetadata, CompileTokenMetadata, CompileTypeMetadata, componentRenderTypeName, identifierModuleUrl, identifierName, tokenReference, viewClassName} from '../compile_metadata';
import {CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileDirectiveSummary, CompilePipeSummary, CompileProviderMetadata, CompileTokenMetadata, CompileTypeMetadata, identifierModuleUrl, identifierName, rendererTypeName, tokenReference, viewClassName} from '../compile_metadata';
import {BuiltinConverter, BuiltinConverterFactory, EventHandlerVars, LocalResolver, convertActionBinding, convertPropertyBinding, convertPropertyBindingBuiltins} from '../compiler_util/expression_converter';
import {CompilerConfig} from '../config';
import {AST, ASTWithSource, Interpolation} from '../expression_parser/ast';
@ -45,10 +45,10 @@ export class ViewCompilerNext extends ViewCompiler {
const statements: o.Statement[] = [];
const renderComponentVar = o.variable(componentRenderTypeName(component.type.reference));
const renderComponentVar = o.variable(rendererTypeName(component.type.reference));
statements.push(
renderComponentVar
.set(o.importExpr(createIdentifier(Identifiers.createComponentRenderTypeV2)).callFn([
.set(o.importExpr(createIdentifier(Identifiers.createRendererTypeV2)).callFn([
new o.LiteralMapExpr([
new o.LiteralMapEntry('encapsulation', o.literal(component.template.encapsulation)),
new o.LiteralMapEntry('styles', styles),
@ -481,11 +481,11 @@ class ViewBuilder implements TemplateAstVisitor, LocalResolver, BuiltinConverter
}
});
let compRenderType = o.NULL_EXPR;
let rendererType = o.NULL_EXPR;
let compView = o.NULL_EXPR;
if (directiveAst.directive.isComponent) {
compView = o.importExpr({reference: directiveAst.directive.componentViewType});
compRenderType = o.importExpr({reference: directiveAst.directive.componentRenderType});
rendererType = o.importExpr({reference: directiveAst.directive.rendererType});
}
const inputDefs = directiveAst.inputs.map((inputAst, inputIndex) => {
@ -533,7 +533,7 @@ class ViewBuilder implements TemplateAstVisitor, LocalResolver, BuiltinConverter
o.literal(flags), queryMatchExprs.length ? o.literalArr(queryMatchExprs) : o.NULL_EXPR,
o.literal(childCount), providerExpr, depsExpr,
inputDefs.length ? new o.LiteralMapExpr(inputDefs) : o.NULL_EXPR,
outputDefs.length ? new o.LiteralMapExpr(outputDefs) : o.NULL_EXPR, compView, compRenderType
outputDefs.length ? new o.LiteralMapExpr(outputDefs) : o.NULL_EXPR, compView, rendererType
]);
this.nodeDefs[nodeIndex] = nodeDef;

View File

@ -7,4 +7,4 @@
*/
// Public API for render
export {ComponentRenderTypeV2, RenderComponentType, Renderer, RendererFactoryV2, RendererV2, RootRenderer} from './render/api';
export {RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer} from './render/api';

View File

@ -111,7 +111,7 @@ export abstract class RootRenderer {
/**
* @experimental
*/
export interface ComponentRenderTypeV2 {
export interface RendererTypeV2 {
id: string;
encapsulation: ViewEncapsulation;
styles: (string|any[])[];
@ -122,7 +122,7 @@ export interface ComponentRenderTypeV2 {
* @experimental
*/
export abstract class RendererFactoryV2 {
abstract createRenderer(hostElement: any, type: ComponentRenderTypeV2): RendererV2;
abstract createRenderer(hostElement: any, type: RendererTypeV2): RendererV2;
}
/**

View File

@ -14,7 +14,7 @@ export {queryDef} from './query';
export {ViewRef_, createComponentFactory, nodeValue} from './refs';
export {initServicesIfNeeded} from './services';
export {textDef} from './text';
export {createComponentRenderTypeV2, elementEventFullName, rootRenderNodes, unwrapValue} from './util';
export {createRendererTypeV2, elementEventFullName, rootRenderNodes, unwrapValue} from './util';
export {viewDef} from './view';
export {attachEmbeddedView, detachEmbeddedView, moveEmbeddedView} from './view_attach';

View File

@ -12,7 +12,7 @@ import {ElementRef} from '../linker/element_ref';
import {TemplateRef} from '../linker/template_ref';
import {ViewContainerRef} from '../linker/view_container_ref';
import {ViewEncapsulation} from '../metadata/view';
import {ComponentRenderTypeV2, Renderer as RendererV1, RendererFactoryV2, RendererV2} from '../render/api';
import {Renderer as RendererV1, RendererFactoryV2, RendererTypeV2, RendererV2} from '../render/api';
import {createChangeDetectorRef, createInjector, createRendererV1, createTemplateRef, createViewContainerRef} from './refs';
import {BindingDef, BindingType, DepDef, DepFlags, DirectiveOutputDef, DisposableFn, NodeData, NodeDef, NodeFlags, NodeType, ProviderData, ProviderType, QueryBindingType, QueryDef, QueryValueType, RootData, Services, ViewData, ViewDefinition, ViewFlags, ViewState, asElementData, asProviderData} from './types';
@ -32,7 +32,7 @@ export function directiveDef(
flags: NodeFlags, matchedQueries: [string | number, QueryValueType][], childCount: number,
ctor: any, deps: ([DepFlags, any] | any)[], props?: {[name: string]: [number, string]},
outputs?: {[name: string]: string}, component?: () => ViewDefinition,
componentRenderType?: ComponentRenderTypeV2): NodeDef {
rendererType?: RendererTypeV2): NodeDef {
const bindings: BindingDef[] = [];
if (props) {
for (let prop in props) {
@ -54,7 +54,7 @@ export function directiveDef(
}
return _def(
NodeType.Directive, flags, matchedQueries, childCount, ProviderType.Class, ctor, ctor, deps,
bindings, outputDefs, component, componentRenderType);
bindings, outputDefs, component, rendererType);
}
export function pipeDef(flags: NodeFlags, ctor: any, deps: ([DepFlags, any] | any)[]): NodeDef {
@ -71,12 +71,12 @@ export function _def(
type: NodeType, flags: NodeFlags, matchedQueriesDsl: [string | number, QueryValueType][],
childCount: number, providerType: ProviderType, token: any, value: any,
deps: ([DepFlags, any] | any)[], bindings?: BindingDef[], outputs?: DirectiveOutputDef[],
component?: () => ViewDefinition, componentRenderType?: ComponentRenderTypeV2): NodeDef {
component?: () => ViewDefinition, rendererType?: RendererTypeV2): NodeDef {
const {matchedQueries, references, matchedQueryIds} = splitMatchedQueriesDsl(matchedQueriesDsl);
// This is needed as the jit compiler always uses an empty hash as default ComponentRenderTypeV2,
// This is needed as the jit compiler always uses an empty hash as default RendererTypeV2,
// which is not filled for host views.
if (componentRenderType && componentRenderType.encapsulation == null) {
componentRenderType = null;
if (rendererType && rendererType.encapsulation == null) {
rendererType = null;
}
if (!outputs) {
outputs = [];
@ -120,7 +120,7 @@ export function _def(
type: providerType,
token,
tokenKey: tokenKey(token), value,
deps: depDefs, outputs, component, componentRenderType
deps: depDefs, outputs, component, rendererType
},
text: undefined,
pureExpression: undefined,

View File

@ -9,7 +9,7 @@
import {isDevMode} from '../application_ref';
import {DebugElement, DebugNode, EventListener, getDebugNode, indexDebugNode, removeDebugNodeFromIndex} from '../debug/debug_node';
import {Injector} from '../di';
import {ComponentRenderTypeV2, RendererFactoryV2, RendererV2} from '../render/api';
import {RendererFactoryV2, RendererTypeV2, RendererV2} from '../render/api';
import {Sanitizer, SecurityContext} from '../security';
import {isViewDebugError, viewDestroyedError, viewWrappedDebugError} from './errors';
@ -399,7 +399,7 @@ export function getCurrentDebugContext(): DebugContext {
class DebugRendererFactoryV2 implements RendererFactoryV2 {
constructor(private delegate: RendererFactoryV2) {}
createRenderer(element: any, renderData: ComponentRenderTypeV2): RendererV2 {
createRenderer(element: any, renderData: RendererTypeV2): RendererV2 {
return new DebugRendererV2(this.delegate.createRenderer(element, renderData));
}
}

View File

@ -14,7 +14,7 @@ import {TemplateRef} from '../linker/template_ref';
import {ViewContainerRef} from '../linker/view_container_ref';
import {ViewRef} from '../linker/view_ref';
import {ViewEncapsulation} from '../metadata/view';
import {ComponentRenderTypeV2, RendererFactoryV2, RendererV2} from '../render/api';
import {RendererFactoryV2, RendererTypeV2, RendererV2} from '../render/api';
import {Sanitizer, SecurityContext} from '../security';
// -------------------------------------
@ -219,7 +219,7 @@ export interface ProviderDef {
value: any;
deps: DepDef[];
outputs: DirectiveOutputDef[];
componentRenderType: ComponentRenderTypeV2;
rendererType: RendererTypeV2;
// closure to allow recursive components
component: ViewDefinitionFactory;
}

View File

@ -15,7 +15,7 @@ import {TemplateRef} from '../linker/template_ref';
import {ViewContainerRef} from '../linker/view_container_ref';
import {ViewRef} from '../linker/view_ref';
import {ViewEncapsulation} from '../metadata/view';
import {ComponentRenderTypeV2, Renderer} from '../render/api';
import {Renderer, RendererTypeV2} from '../render/api';
import {expressionChangedAfterItHasBeenCheckedError, isViewDebugError, viewDestroyedError, viewWrappedDebugError} from './errors';
import {DebugContext, ElementData, NodeData, NodeDef, NodeFlags, NodeType, QueryValueType, Services, ViewData, ViewDefinition, ViewDefinitionFactory, ViewFlags, ViewState, asElementData, asProviderData, asTextData} from './types';
@ -43,11 +43,11 @@ export function unwrapValue(value: any): any {
let _renderCompCount = 0;
export function createComponentRenderTypeV2(values: {
export function createRendererTypeV2(values: {
styles: (string | any[])[],
encapsulation: ViewEncapsulation,
data: {[kind: string]: any[]}
}): ComponentRenderTypeV2 {
}): RendererTypeV2 {
const isFilled = values && (values.encapsulation !== ViewEncapsulation.None ||
values.styles.length || Object.keys(values.data).length);
if (isFilled) {
@ -173,8 +173,8 @@ export function getParentRenderElement(view: ViewData, renderHost: any, def: Nod
if (renderParent) {
const parent = def.parent;
if (parent && (parent.type !== NodeType.Element || !parent.element.component ||
(parent.element.component.provider.componentRenderType &&
parent.element.component.provider.componentRenderType.encapsulation ===
(parent.element.component.provider.rendererType &&
parent.element.component.provider.rendererType.encapsulation ===
ViewEncapsulation.Native))) {
// only children of non components, or children of components with native encapsulation should
// be attached.

View File

@ -7,7 +7,7 @@
*/
import {ViewEncapsulation} from '../metadata/view';
import {ComponentRenderTypeV2, RendererV2} from '../render/api';
import {RendererTypeV2, RendererV2} from '../render/api';
import {checkAndUpdateElementDynamic, checkAndUpdateElementInline, createElement} from './element';
import {expressionChangedAfterItHasBeenCheckedError} from './errors';
@ -291,13 +291,13 @@ function createViewNodes(view: ViewData) {
// the component view. Therefore, we create the component view first
// and set the ProviderData in ViewData, and then instantiate the provider.
const compViewDef = resolveViewDefinition(nodeDef.provider.component);
const compRenderType = nodeDef.provider.componentRenderType;
const rendererType = nodeDef.provider.rendererType;
let compRenderer: RendererV2;
if (!compRenderType) {
if (!rendererType) {
compRenderer = view.root.renderer;
} else {
const hostEl = asElementData(view, nodeDef.parent.index).renderElement;
compRenderer = view.root.rendererFactory.createRenderer(hostEl, compRenderType);
compRenderer = view.root.rendererFactory.createRenderer(hostEl, rendererType);
}
const componentView = createView(view.root, compRenderer, view, nodeDef, compViewDef);
const providerData = <ProviderData>{componentView, instance: undefined};

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {APP_ID, ComponentRenderTypeV2, Inject, Injectable, RenderComponentType, Renderer, RendererFactoryV2, RendererV2, RootRenderer, ViewEncapsulation} from '@angular/core';
import {APP_ID, Inject, Injectable, RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer, ViewEncapsulation} from '@angular/core';
import {isPresent, stringify} from '../facade/lang';
import {AnimationKeyframe, AnimationPlayer, AnimationStyles, DirectRenderer, NoOpAnimationPlayer, RenderDebugInfo} from '../private_import_core';
@ -369,7 +369,7 @@ export class DomRendererFactoryV2 implements RendererFactoryV2 {
this.defaultRenderer = new DefaultDomRendererV2(eventManager);
};
createRenderer(element: any, type: ComponentRenderTypeV2): RendererV2 {
createRenderer(element: any, type: RendererTypeV2): RendererV2 {
if (!element || !type) {
return this.defaultRenderer;
}
@ -505,7 +505,7 @@ class EmulatedEncapsulationDomRendererV2 extends DefaultDomRendererV2 {
constructor(
eventManager: EventManager, sharedStylesHost: DomSharedStylesHost,
private component: ComponentRenderTypeV2) {
private component: RendererTypeV2) {
super(eventManager);
const styles = flattenStyles(component.id, component.styles, []);
sharedStylesHost.addStyles(styles);
@ -528,7 +528,7 @@ class ShadowDomRenderer extends DefaultDomRendererV2 {
constructor(
eventManager: EventManager, private sharedStylesHost: DomSharedStylesHost,
private hostEl: any, private component: ComponentRenderTypeV2) {
private hostEl: any, private component: RendererTypeV2) {
super(eventManager);
this.shadowRoot = (hostEl as any).createShadowRoot();
this.sharedStylesHost.addHost(this.shadowRoot);

View File

@ -7,7 +7,7 @@
*/
import {DomElementSchemaRegistry} from '@angular/compiler';
import {APP_ID, ComponentRenderTypeV2, Inject, Injectable, NgZone, RenderComponentType, Renderer, RendererFactoryV2, RendererV2, RootRenderer, ViewEncapsulation} from '@angular/core';
import {APP_ID, Inject, Injectable, NgZone, RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer, ViewEncapsulation} from '@angular/core';
import {AnimationDriver, DOCUMENT} from '@angular/platform-browser';
import {isBlank, isPresent, stringify} from './facade/lang';
@ -273,7 +273,7 @@ export class ServerRendererFactoryV2 implements RendererFactoryV2 {
this.defaultRenderer = new DefaultServerRendererV2(document, ngZone);
};
createRenderer(element: any, type: ComponentRenderTypeV2): RendererV2 {
createRenderer(element: any, type: RendererTypeV2): RendererV2 {
if (!element || !type) {
return this.defaultRenderer;
}
@ -404,7 +404,7 @@ class EmulatedEncapsulationServerRendererV2 extends DefaultServerRendererV2 {
constructor(
document: any, ngZone: NgZone, sharedStylesHost: SharedStylesHost,
private component: ComponentRenderTypeV2) {
private component: RendererTypeV2) {
super(document, ngZone);
const styles = flattenStyles(component.id, component.styles, []);
sharedStylesHost.addStyles(styles);

View File

@ -292,16 +292,6 @@ export declare abstract class ComponentRef<C> {
abstract onDestroy(callback: Function): void;
}
/** @experimental */
export interface ComponentRenderTypeV2 {
data: {
[kind: string]: any[];
};
encapsulation: ViewEncapsulation;
id: string;
styles: (string | any[])[];
}
/** @stable */
export declare const ContentChild: ContentChildDecorator;
@ -859,7 +849,17 @@ export declare abstract class Renderer {
/** @experimental */
export declare abstract class RendererFactoryV2 {
abstract createRenderer(hostElement: any, type: ComponentRenderTypeV2): RendererV2;
abstract createRenderer(hostElement: any, type: RendererTypeV2): RendererV2;
}
/** @experimental */
export interface RendererTypeV2 {
data: {
[kind: string]: any[];
};
encapsulation: ViewEncapsulation;
id: string;
styles: (string | any[])[];
}
/** @experimental */