Skip to content

Commit

Permalink
RendererV2 -> Renderer2 rename (angular#14998)
Browse files Browse the repository at this point in the history
* refactor: rename `RendererV2` into `Renderer2`

BREAKING CHANGE (since 4.0 rc.1):
- rename `RendererV2` to `Renderer2`
- rename `RendererTypeV2` to `RendererType2`
- rename `RendererFactoryV2` to `RendererFactory2`
  • Loading branch information
tbosch authored and chuckjaz committed Mar 8, 2017
1 parent 5df998d commit ad3b44a
Show file tree
Hide file tree
Showing 40 changed files with 230 additions and 235 deletions.
10 changes: 5 additions & 5 deletions modules/@angular/compiler-cli/integrationtest/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ApplicationRef, NgModule, NgZone, Provider, RendererFactoryV2} from '@angular/core';
import {ApplicationRef, NgModule, NgZone, Provider, RendererFactory2} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {NoopAnimationsModule, ɵAnimationEngine, ɵAnimationRendererFactory} from '@angular/platform-browser/animations';
import {ServerModule, ɵServerRendererFactoryV2} from '@angular/platform-server';
import {ServerModule, ɵServerRendererFactory2} from '@angular/platform-server';
import {MdButtonModule} from '@angular2-material/button';
// Note: don't refer to third_party_src as we want to test that
// we can compile components from node_modules!
Expand All @@ -26,16 +26,16 @@ import {CompWithNgContent, ProjectingComp} from './projection';
import {CompForChildQuery, CompWithChildQuery, CompWithDirectiveChild, DirectiveForQuery} from './queries';

export function instantiateServerRendererFactory(
renderer: RendererFactoryV2, engine: ɵAnimationEngine, zone: NgZone) {
renderer: RendererFactory2, engine: ɵAnimationEngine, zone: NgZone) {
return new ɵAnimationRendererFactory(renderer, engine, zone);
}

// TODO(matsko): create a server module for animations and use
// that instead of these manual providers here.
export const SERVER_ANIMATIONS_PROVIDERS: Provider[] = [{
provide: RendererFactoryV2,
provide: RendererFactory2,
useFactory: instantiateServerRendererFactory,
deps: [ɵServerRendererFactoryV2, ɵAnimationEngine, NgZone]
deps: [ɵServerRendererFactory2, ɵAnimationEngine, NgZone]
}];

@NgModule({
Expand Down
10 changes: 5 additions & 5 deletions modules/@angular/compiler/src/compile_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ChangeDetectionStrategy, ComponentFactory, RendererTypeV2, SchemaMetadata, Type, ViewEncapsulation, ɵLifecycleHooks, ɵreflector, ɵstringify as stringify} from '@angular/core';
import {ChangeDetectionStrategy, ComponentFactory, RendererType2, SchemaMetadata, Type, ViewEncapsulation, ɵLifecycleHooks, ɵreflector, ɵstringify as stringify} from '@angular/core';
import {StaticSymbol} from './aot/static_symbol';
import {CssSelector} from './selector';
import {splitAtColon} from './util';
Expand Down Expand Up @@ -310,7 +310,7 @@ export interface CompileDirectiveSummary extends CompileTypeSummary {
changeDetection: ChangeDetectionStrategy;
template: CompileTemplateSummary;
componentViewType: StaticSymbol|ProxyClass;
rendererType: StaticSymbol|RendererTypeV2;
rendererType: StaticSymbol|RendererType2;
componentFactory: StaticSymbol|ComponentFactory<any>;
}

Expand Down Expand Up @@ -338,7 +338,7 @@ export class CompileDirectiveMetadata {
entryComponents?: CompileEntryComponentMetadata[],
template?: CompileTemplateMetadata,
componentViewType?: StaticSymbol|ProxyClass,
rendererType?: StaticSymbol|RendererTypeV2,
rendererType?: StaticSymbol|RendererType2,
componentFactory?: StaticSymbol|ComponentFactory<any>,
} = {}): CompileDirectiveMetadata {
const hostListeners: {[key: string]: string} = {};
Expand Down Expand Up @@ -416,7 +416,7 @@ export class CompileDirectiveMetadata {
template: CompileTemplateMetadata;

componentViewType: StaticSymbol|ProxyClass;
rendererType: StaticSymbol|RendererTypeV2;
rendererType: StaticSymbol|RendererType2;
componentFactory: StaticSymbol|ComponentFactory<any>;

constructor({isHost, type, isComponent, selector, exportAs,
Expand All @@ -441,7 +441,7 @@ export class CompileDirectiveMetadata {
entryComponents?: CompileEntryComponentMetadata[],
template?: CompileTemplateMetadata,
componentViewType?: StaticSymbol|ProxyClass,
rendererType?: StaticSymbol|RendererTypeV2,
rendererType?: StaticSymbol|RendererType2,
componentFactory?: StaticSymbol|ComponentFactory<any>,
} = {}) {
this.isHost = !!isHost;
Expand Down
6 changes: 3 additions & 3 deletions modules/@angular/compiler/src/identifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export class Identifiers {
static nodeValue: IdentifierSpec = {name: 'ɵnov', moduleUrl: CORE, runtime: ɵnov};
static ngContentDef: IdentifierSpec = {name: 'ɵncd', moduleUrl: CORE, runtime: ɵncd};
static unwrapValue: IdentifierSpec = {name: 'ɵunv', moduleUrl: CORE, runtime: ɵunv};
static createRendererTypeV2: IdentifierSpec = {name: 'ɵcrt', moduleUrl: CORE, runtime: ɵcrt};
static RendererTypeV2: IdentifierSpec = {
name: 'RendererTypeV2',
static createRendererType2: IdentifierSpec = {name: 'ɵcrt', moduleUrl: CORE, runtime: ɵcrt};
static RendererType2: IdentifierSpec = {
name: 'RendererType2',
moduleUrl: CORE,
// type only
runtime: null
Expand Down
4 changes: 2 additions & 2 deletions modules/@angular/compiler/src/metadata_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Attribute, ChangeDetectionStrategy, Component, ComponentFactory, Directive, Host, Inject, Injectable, InjectionToken, ModuleWithProviders, Optional, Provider, Query, RendererTypeV2, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef, ɵERROR_COMPONENT_TYPE, ɵLIFECYCLE_HOOKS_VALUES, ɵReflectorReader, ɵccf as createComponentFactory, ɵreflector, ɵstringify as stringify} from '@angular/core';
import {Attribute, ChangeDetectionStrategy, Component, ComponentFactory, Directive, Host, Inject, Injectable, InjectionToken, ModuleWithProviders, Optional, Provider, Query, RendererType2, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef, ɵERROR_COMPONENT_TYPE, ɵLIFECYCLE_HOOKS_VALUES, ɵReflectorReader, ɵccf as createComponentFactory, ɵreflector, ɵstringify as stringify} from '@angular/core';
import {StaticSymbol, StaticSymbolCache} from './aot/static_symbol';
import {ngfactoryFilePath} from './aot/util';
import {assertArrayOfStrings, assertInterpolationSymbols} from './assertions';
Expand Down Expand Up @@ -124,7 +124,7 @@ export class CompileMetadataResolver {
}
}

private getRendererType(dirType: any): StaticSymbol|RendererTypeV2 {
private getRendererType(dirType: any): StaticSymbol|RendererType2 {
if (dirType instanceof StaticSymbol) {
return this._staticSymbolCache.get(
ngfactoryFilePath(dirType.filePath), cpl.rendererTypeName(dirType));
Expand Down
7 changes: 3 additions & 4 deletions modules/@angular/compiler/src/view_compiler/view_compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,15 @@ export class ViewCompiler {
const renderComponentVar = o.variable(rendererTypeName(component.type.reference));
statements.push(
renderComponentVar
.set(o.importExpr(createIdentifier(Identifiers.createRendererTypeV2)).callFn([
.set(o.importExpr(createIdentifier(Identifiers.createRendererType2)).callFn([
new o.LiteralMapExpr([
new o.LiteralMapEntry('encapsulation', o.literal(component.template.encapsulation)),
new o.LiteralMapEntry('styles', styles),
new o.LiteralMapEntry('data', new o.LiteralMapExpr(customRenderData))
])
]))
.toDeclStmt(
o.importType(createIdentifier(Identifiers.RendererTypeV2)),
[o.StmtModifier.Final]));
o.importType(createIdentifier(Identifiers.RendererType2)), [o.StmtModifier.Final]));

const viewBuilderFactory = (parent: ViewBuilder): ViewBuilder => {
const embeddedViewIndex = embeddedViewCount++;
Expand Down Expand Up @@ -331,7 +330,7 @@ class ViewBuilder implements TemplateAstVisitor, LocalResolver, BuiltinConverter
// BindingType.DirectiveHostProperty, string, SecurityContext])[],
// outputs?: ([OutputType.ElementOutput | OutputType.DirectiveHostOutput, string, string])[],
// handleEvent?: ElementHandleEventFn,
// componentView?: () => ViewDefinition, componentRendererType?: RendererTypeV2): NodeDef;
// componentView?: () => ViewDefinition, componentRendererType?: RendererType2): NodeDef;
const nodeDef = () => o.importExpr(createIdentifier(Identifiers.elementDef)).callFn([
o.literal(flags), queryMatchesExpr, o.literal(ast.ngContentIndex), o.literal(childCount),
o.literal(elName), elName ? fixedAttrsDef(ast) : o.NULL_EXPR,
Expand Down
2 changes: 1 addition & 1 deletion modules/@angular/core/src/codegen_private_exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export {CodegenComponentFactoryResolver as ɵCodegenComponentFactoryResolver} fr
export {NgModuleInjector as ɵNgModuleInjector} from './linker/ng_module_factory';
export {registerModuleFactory as ɵregisterModuleFactory} from './linker/ng_module_factory_loader';
export {reflector as ɵreflector} from './reflection/reflection';
export {ArgumentType as ɵArgumentType, BindingType as ɵBindingType, DepFlags as ɵDepFlags, EMPTY_ARRAY as ɵEMPTY_ARRAY, EMPTY_MAP as ɵEMPTY_MAP, NodeFlags as ɵNodeFlags, QueryBindingType as ɵQueryBindingType, QueryValueType as ɵQueryValueType, ViewDefinition as ɵViewDefinition, ViewFlags as ɵViewFlags, anchorDef as ɵand, createComponentFactory as ɵccf, createRendererTypeV2 as ɵcrt, directiveDef as ɵdid, elementDef as ɵeld, elementEventFullName as ɵelementEventFullName, getComponentViewDefinitionFactory as ɵgetComponentViewDefinitionFactory, inlineInterpolate as ɵinlineInterpolate, interpolate as ɵinterpolate, ngContentDef as ɵncd, nodeValue as ɵnov, pipeDef as ɵpid, providerDef as ɵprd, pureArrayDef as ɵpad, pureObjectDef as ɵpod, purePipeDef as ɵppd, queryDef as ɵqud, textDef as ɵted, unwrapValue as ɵunv, viewDef as ɵvid} from './view/index';
export {ArgumentType as ɵArgumentType, BindingType as ɵBindingType, DepFlags as ɵDepFlags, EMPTY_ARRAY as ɵEMPTY_ARRAY, EMPTY_MAP as ɵEMPTY_MAP, NodeFlags as ɵNodeFlags, QueryBindingType as ɵQueryBindingType, QueryValueType as ɵQueryValueType, ViewDefinition as ɵViewDefinition, ViewFlags as ɵViewFlags, anchorDef as ɵand, createComponentFactory as ɵccf, createRendererType2 as ɵcrt, directiveDef as ɵdid, elementDef as ɵeld, elementEventFullName as ɵelementEventFullName, getComponentViewDefinitionFactory as ɵgetComponentViewDefinitionFactory, inlineInterpolate as ɵinlineInterpolate, interpolate as ɵinterpolate, ngContentDef as ɵncd, nodeValue as ɵnov, pipeDef as ɵpid, providerDef as ɵprd, pureArrayDef as ɵpad, pureObjectDef as ɵpod, purePipeDef as ɵppd, queryDef as ɵqud, textDef as ɵted, unwrapValue as ɵunv, viewDef as ɵvid} from './view/index';
2 changes: 1 addition & 1 deletion modules/@angular/core/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
*/

// Public API for render
export {RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer} from './render/api';
export {RenderComponentType, Renderer, Renderer2, RendererFactory2, RendererType2, RootRenderer} from './render/api';
20 changes: 10 additions & 10 deletions modules/@angular/core/src/render/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {InjectionToken, Injector} from '../di';
import {ViewEncapsulation} from '../metadata/view';

/**
* @deprecated Use `RendererTypeV2` (and `RendererV2`) instead.
* @deprecated Use `RendererType2` (and `Renderer2`) instead.
*/
export class RenderComponentType {
constructor(
Expand All @@ -32,7 +32,7 @@ export abstract class RenderDebugInfo {
}

/**
* @deprecated Use the `RendererV2` instead.
* @deprecated Use the `Renderer2` instead.
*/
export interface DirectRenderer {
remove(node: any): void;
Expand All @@ -43,7 +43,7 @@ export interface DirectRenderer {
}

/**
* @deprecated Use the `RendererV2` instead.
* @deprecated Use the `Renderer2` instead.
*/
export abstract class Renderer {
abstract selectRootElement(selectorOrNode: string|any, debugInfo?: RenderDebugInfo): any;
Expand Down Expand Up @@ -92,7 +92,7 @@ export abstract class Renderer {
easing: string, previousPlayers?: any[]): any;
}

export const RendererV2Interceptor = new InjectionToken<RendererV2[]>('RendererV2Interceptor');
export const Renderer2Interceptor = new InjectionToken<Renderer2[]>('Renderer2Interceptor');

/**
* Injectable service that provides a low-level interface for modifying the UI.
Expand All @@ -106,7 +106,7 @@ export const RendererV2Interceptor = new InjectionToken<RendererV2[]>('RendererV
*
* The default Renderer implementation is `DomRenderer`. Also available is `WebWorkerRenderer`.
*
* @deprecated Use `RendererFactoryV2` instead.
* @deprecated Use `RendererFactory2` instead.
*/
export abstract class RootRenderer {
abstract renderComponent(componentType: RenderComponentType): Renderer;
Expand All @@ -115,7 +115,7 @@ export abstract class RootRenderer {
/**
* @experimental
*/
export interface RendererTypeV2 {
export interface RendererType2 {
id: string;
encapsulation: ViewEncapsulation;
styles: (string|any[])[];
Expand All @@ -125,14 +125,14 @@ export interface RendererTypeV2 {
/**
* @experimental
*/
export abstract class RendererFactoryV2 {
abstract createRenderer(hostElement: any, type: RendererTypeV2): RendererV2;
export abstract class RendererFactory2 {
abstract createRenderer(hostElement: any, type: RendererType2): Renderer2;
}

/**
* @experimental
*/
export abstract class RendererV2 {
export abstract class Renderer2 {
/**
* This field can be used to store arbitrary data on this renderer instance.
* This is useful for renderers that delegate to other renderers.
Expand Down Expand Up @@ -176,5 +176,5 @@ export abstract class RendererV2 {
abstract setValue(node: any, value: string): void;
abstract listen(
target: 'window'|'document'|'body'|any, eventName: string,
callback: (event: any) => boolean): () => void;
callback: (event: any) => boolean | void): () => void;
}
6 changes: 3 additions & 3 deletions modules/@angular/core/src/view/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {isDevMode} from '../application_ref';
import {RendererTypeV2, RendererV2} from '../render/api';
import {Renderer2, RendererType2} from '../render/api';
import {SecurityContext} from '../security';

import {BindingDef, BindingType, DebugContext, DisposableFn, ElementData, ElementHandleEventFn, NodeData, NodeDef, NodeFlags, OutputDef, OutputType, QueryValueType, Services, ViewData, ViewDefinition, ViewDefinitionFactory, ViewFlags, asElementData, asProviderData} from './types';
Expand Down Expand Up @@ -71,7 +71,7 @@ export function elementDef(
string, SecurityContext
])[],
outputs?: ([string, string])[], handleEvent?: ElementHandleEventFn,
componentView?: () => ViewDefinition, componentRendererType?: RendererTypeV2): NodeDef {
componentView?: () => ViewDefinition, componentRendererType?: RendererType2): NodeDef {
if (!handleEvent) {
handleEvent = NOOP;
}
Expand Down Expand Up @@ -119,7 +119,7 @@ export function elementDef(
const [ns, name] = splitNamespace(namespaceAndName);
return [ns, name, value];
});
// This is needed as the jit compiler always uses an empty hash as default RendererTypeV2,
// This is needed as the jit compiler always uses an empty hash as default RendererType2,
// which is not filled for host views.
if (componentRendererType && componentRendererType.encapsulation == null) {
componentRendererType = null;
Expand Down
2 changes: 1 addition & 1 deletion modules/@angular/core/src/view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export {queryDef} from './query';
export {ViewRef_, createComponentFactory, getComponentViewDefinitionFactory, nodeValue} from './refs';
export {initServicesIfNeeded} from './services';
export {textDef} from './text';
export {EMPTY_ARRAY, EMPTY_MAP, createRendererTypeV2, elementEventFullName, inlineInterpolate, interpolate, rootRenderNodes, unwrapValue} from './util';
export {EMPTY_ARRAY, EMPTY_MAP, createRendererType2, elementEventFullName, inlineInterpolate, interpolate, rootRenderNodes, unwrapValue} from './util';
export {viewDef} from './view';
export {attachEmbeddedView, detachEmbeddedView, moveEmbeddedView} from './view_attach';

Expand Down
6 changes: 3 additions & 3 deletions modules/@angular/core/src/view/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ 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 {Renderer as RendererV1, RendererFactoryV2, RendererTypeV2, RendererV2} from '../render/api';
import {Renderer as RendererV1, Renderer2, RendererFactory2, RendererType2} from '../render/api';

import {createChangeDetectorRef, createInjector, createRendererV1, createTemplateRef, createViewContainerRef} from './refs';
import {BindingDef, BindingType, DepDef, DepFlags, DisposableFn, NodeData, NodeDef, NodeFlags, OutputDef, OutputType, ProviderData, QueryBindingType, QueryDef, QueryValueType, RootData, Services, ViewData, ViewDefinition, ViewFlags, ViewState, asElementData, asProviderData} from './types';
import {checkBinding, dispatchEvent, filterQueryId, isComponentView, splitMatchedQueriesDsl, tokenKey, viewParentEl} from './util';

const RendererV1TokenKey = tokenKey(RendererV1);
const RendererV2TokenKey = tokenKey(RendererV2);
const Renderer2TokenKey = tokenKey(Renderer2);
const ElementRefTokenKey = tokenKey(ElementRef);
const ViewContainerRefTokenKey = tokenKey(ViewContainerRef);
const TemplateRefTokenKey = tokenKey(TemplateRef);
Expand Down Expand Up @@ -349,7 +349,7 @@ export function resolveDep(
const compView = findCompView(view, elDef, allowPrivateServices);
return createRendererV1(compView);
}
case RendererV2TokenKey: {
case Renderer2TokenKey: {
const compView = findCompView(view, elDef, allowPrivateServices);
return compView.renderer;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/@angular/core/src/view/refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {ElementRef} from '../linker/element_ref';
import {TemplateRef} from '../linker/template_ref';
import {ViewContainerRef} from '../linker/view_container_ref';
import {EmbeddedViewRef, InternalViewRef, ViewRef} from '../linker/view_ref';
import {Renderer as RendererV1, RendererV2} from '../render/api';
import {Renderer as RendererV1, Renderer2} from '../render/api';
import {Type} from '../type';
import {VERSION} from '../version';

Expand Down Expand Up @@ -291,7 +291,7 @@ export function createRendererV1(view: ViewData): RendererV1 {
}

class RendererAdapter implements RendererV1 {
constructor(private delegate: RendererV2) {}
constructor(private delegate: Renderer2) {}
selectRootElement(selectorOrNode: string|Element): Element {
return this.delegate.selectRootElement(selectorOrNode);
}
Expand Down
Loading

0 comments on commit ad3b44a

Please sign in to comment.