RendererV2 -> Renderer2 rename (#14998)
* refactor: rename `RendererV2` into `Renderer2` BREAKING CHANGE (since 4.0 rc.1): - rename `RendererV2` to `Renderer2` - rename `RendererTypeV2` to `RendererType2` - rename `RendererFactoryV2` to `RendererFactory2`
This commit is contained in:
parent
5df998d086
commit
ad3b44aef7
|
@ -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!
|
||||
|
@ -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({
|
||||
|
|
|
@ -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';
|
||||
|
@ -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>;
|
||||
}
|
||||
|
||||
|
@ -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} = {};
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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';
|
||||
|
@ -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));
|
||||
|
|
|
@ -52,7 +52,7 @@ 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),
|
||||
|
@ -60,8 +60,7 @@ export class ViewCompiler {
|
|||
])
|
||||
]))
|
||||
.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++;
|
||||
|
@ -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,
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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(
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -115,7 +115,7 @@ export abstract class RootRenderer {
|
|||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface RendererTypeV2 {
|
||||
export interface RendererType2 {
|
||||
id: string;
|
||||
encapsulation: ViewEncapsulation;
|
||||
styles: (string|any[])[];
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 {RendererFactoryV2, RendererTypeV2, RendererV2} from '../render/api';
|
||||
import {Renderer2, RendererFactory2, RendererType2} from '../render/api';
|
||||
import {Sanitizer, SecurityContext} from '../security';
|
||||
|
||||
import {isViewDebugError, viewDestroyedError, viewWrappedDebugError} from './errors';
|
||||
|
@ -82,7 +82,7 @@ function createDebugServices() {
|
|||
function createProdRootView(
|
||||
injector: Injector, projectableNodes: any[][], rootSelectorOrNode: string | any,
|
||||
def: ViewDefinition, context?: any): ViewData {
|
||||
const rendererFactory: RendererFactoryV2 = injector.get(RendererFactoryV2);
|
||||
const rendererFactory: RendererFactory2 = injector.get(RendererFactory2);
|
||||
return createRootView(
|
||||
createRootData(injector, rendererFactory, projectableNodes, rootSelectorOrNode), def,
|
||||
context);
|
||||
|
@ -91,14 +91,14 @@ function createProdRootView(
|
|||
function debugCreateRootView(
|
||||
injector: Injector, projectableNodes: any[][], rootSelectorOrNode: string | any,
|
||||
def: ViewDefinition, context?: any): ViewData {
|
||||
const rendererFactory: RendererFactoryV2 = injector.get(RendererFactoryV2);
|
||||
const rendererFactory: RendererFactory2 = injector.get(RendererFactory2);
|
||||
const root = createRootData(
|
||||
injector, new DebugRendererFactoryV2(rendererFactory), projectableNodes, rootSelectorOrNode);
|
||||
injector, new DebugRendererFactory2(rendererFactory), projectableNodes, rootSelectorOrNode);
|
||||
return callWithDebugContext(DebugAction.create, createRootView, null, [root, def, context]);
|
||||
}
|
||||
|
||||
function createRootData(
|
||||
injector: Injector, rendererFactory: RendererFactoryV2, projectableNodes: any[][],
|
||||
injector: Injector, rendererFactory: RendererFactory2, projectableNodes: any[][],
|
||||
rootSelectorOrNode: any): RootData {
|
||||
const sanitizer = injector.get(Sanitizer);
|
||||
const renderer = rendererFactory.createRenderer(null, null);
|
||||
|
@ -415,17 +415,17 @@ export function getCurrentDebugContext(): DebugContext {
|
|||
}
|
||||
|
||||
|
||||
class DebugRendererFactoryV2 implements RendererFactoryV2 {
|
||||
constructor(private delegate: RendererFactoryV2) {}
|
||||
class DebugRendererFactory2 implements RendererFactory2 {
|
||||
constructor(private delegate: RendererFactory2) {}
|
||||
|
||||
createRenderer(element: any, renderData: RendererTypeV2): RendererV2 {
|
||||
return new DebugRendererV2(this.delegate.createRenderer(element, renderData));
|
||||
createRenderer(element: any, renderData: RendererType2): Renderer2 {
|
||||
return new DebugRenderer2(this.delegate.createRenderer(element, renderData));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DebugRendererV2 implements RendererV2 {
|
||||
constructor(private delegate: RendererV2) {}
|
||||
class DebugRenderer2 implements Renderer2 {
|
||||
constructor(private delegate: Renderer2) {}
|
||||
|
||||
get data() { return this.delegate.data; }
|
||||
|
||||
|
|
|
@ -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 {RendererFactoryV2, RendererTypeV2, RendererV2} from '../render/api';
|
||||
import {Renderer2, RendererFactory2, RendererType2} from '../render/api';
|
||||
import {Sanitizer, SecurityContext} from '../security';
|
||||
|
||||
// -------------------------------------
|
||||
|
@ -208,7 +208,7 @@ export interface ElementDef {
|
|||
attrs: [string, string, string][];
|
||||
template: ViewDefinition;
|
||||
componentProvider: NodeDef;
|
||||
componentRendererType: RendererTypeV2;
|
||||
componentRendererType: RendererType2;
|
||||
// closure to allow recursive components
|
||||
componentView: ViewDefinitionFactory;
|
||||
/**
|
||||
|
@ -290,7 +290,7 @@ export interface NgContentDef {
|
|||
export interface ViewData {
|
||||
def: ViewDefinition;
|
||||
root: RootData;
|
||||
renderer: RendererV2;
|
||||
renderer: Renderer2;
|
||||
// index of component provider / anchor.
|
||||
parentNodeDef: NodeDef;
|
||||
parent: ViewData;
|
||||
|
@ -409,8 +409,8 @@ export interface RootData {
|
|||
injector: Injector;
|
||||
projectableNodes: any[][];
|
||||
selectorOrNode: any;
|
||||
renderer: RendererV2;
|
||||
rendererFactory: RendererFactoryV2;
|
||||
renderer: Renderer2;
|
||||
rendererFactory: RendererFactory2;
|
||||
sanitizer: Sanitizer;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {Renderer, RendererTypeV2} from '../render/api';
|
||||
import {Renderer, RendererType2} from '../render/api';
|
||||
import {looseIdentical, stringify} from '../util';
|
||||
|
||||
import {expressionChangedAfterItHasBeenCheckedError, isViewDebugError, viewDestroyedError, viewWrappedDebugError} from './errors';
|
||||
|
@ -43,11 +43,11 @@ export function unwrapValue(value: any): any {
|
|||
|
||||
let _renderCompCount = 0;
|
||||
|
||||
export function createRendererTypeV2(values: {
|
||||
export function createRendererType2(values: {
|
||||
styles: (string | any[])[],
|
||||
encapsulation: ViewEncapsulation,
|
||||
data: {[kind: string]: any[]}
|
||||
}): RendererTypeV2 {
|
||||
}): RendererType2 {
|
||||
const isFilled = values && (values.encapsulation !== ViewEncapsulation.None ||
|
||||
values.styles.length || Object.keys(values.data).length);
|
||||
if (isFilled) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {ViewEncapsulation} from '../metadata/view';
|
||||
import {RendererTypeV2, RendererV2} from '../render/api';
|
||||
import {Renderer2, RendererType2} from '../render/api';
|
||||
|
||||
import {checkAndUpdateElementDynamic, checkAndUpdateElementInline, createElement, listenToElementOutputs} from './element';
|
||||
import {expressionChangedAfterItHasBeenCheckedError} from './errors';
|
||||
|
@ -202,7 +202,7 @@ export function createRootView(root: RootData, def: ViewDefinition, context?: an
|
|||
}
|
||||
|
||||
function createView(
|
||||
root: RootData, renderer: RendererV2, parent: ViewData, parentNodeDef: NodeDef,
|
||||
root: RootData, renderer: Renderer2, parent: ViewData, parentNodeDef: NodeDef,
|
||||
def: ViewDefinition): ViewData {
|
||||
const nodes: NodeData[] = new Array(def.nodes.length);
|
||||
const disposables = def.outputCount ? new Array(def.outputCount) : undefined;
|
||||
|
@ -242,7 +242,7 @@ function createViewNodes(view: ViewData) {
|
|||
if (nodeDef.flags & NodeFlags.ComponentView) {
|
||||
const compViewDef = resolveViewDefinition(nodeDef.element.componentView);
|
||||
const rendererType = nodeDef.element.componentRendererType;
|
||||
let compRenderer: RendererV2;
|
||||
let compRenderer: Renderer2;
|
||||
if (!rendererType) {
|
||||
compRenderer = view.root.renderer;
|
||||
} else {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {AUTO_STYLE, AnimationEvent, animate, keyframes, state, style, transition, trigger} from '@angular/animations';
|
||||
import {Component, HostBinding, HostListener, RendererFactoryV2, ViewChild} from '@angular/core';
|
||||
import {ɵDomRendererFactoryV2} from '@angular/platform-browser';
|
||||
import {Component, HostBinding, HostListener, RendererFactory2, ViewChild} from '@angular/core';
|
||||
import {ɵDomRendererFactory2} from '@angular/platform-browser';
|
||||
import {AnimationDriver, BrowserAnimationsModule, ɵAnimationEngine} from '@angular/platform-browser/animations';
|
||||
import {MockAnimationDriver, MockAnimationPlayer} from '@angular/platform-browser/animations/testing';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
@ -555,7 +555,7 @@ export function main() {
|
|||
describe('errors for not using the animation module', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [{provide: RendererFactoryV2, useExisting: ɵDomRendererFactoryV2}],
|
||||
providers: [{provide: RendererFactory2, useExisting: ɵDomRendererFactory2}],
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {ElementSchemaRegistry} from '@angular/compiler/src/schema/element_schema_registry';
|
||||
import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/testing/test_bindings';
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, DoCheck, EventEmitter, HostBinding, Inject, Injectable, Input, OnChanges, OnDestroy, OnInit, Output, Pipe, PipeTransform, RenderComponentType, Renderer, RendererFactoryV2, RootRenderer, SimpleChange, SimpleChanges, TemplateRef, Type, ViewChild, ViewContainerRef, WrappedValue} from '@angular/core';
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, DoCheck, EventEmitter, HostBinding, Inject, Injectable, Input, OnChanges, OnDestroy, OnInit, Output, Pipe, PipeTransform, RenderComponentType, Renderer, RendererFactory2, RootRenderer, SimpleChange, SimpleChanges, TemplateRef, Type, ViewChild, ViewContainerRef, WrappedValue} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, fakeAsync} from '@angular/core/testing';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
@ -37,7 +37,7 @@ export function main() {
|
|||
renderLog = TestBed.get(RenderLog);
|
||||
directiveLog = TestBed.get(DirectiveLog);
|
||||
elSchema.existingProperties['someProp'] = true;
|
||||
patchLoggingRendererV2(TestBed.get(RendererFactoryV2), renderLog);
|
||||
patchLoggingRenderer2(TestBed.get(RendererFactory2), renderLog);
|
||||
}
|
||||
|
||||
function queryDirs(el: DebugElement, dirType: Type<any>): any {
|
||||
|
@ -1307,7 +1307,7 @@ class DirectiveLogEntry {
|
|||
constructor(public directiveName: string, public method: string) {}
|
||||
}
|
||||
|
||||
function patchLoggingRendererV2(rendererFactory: RendererFactoryV2, log: RenderLog) {
|
||||
function patchLoggingRenderer2(rendererFactory: RendererFactory2, log: RenderLog) {
|
||||
if ((<any>rendererFactory).__patchedForLogging) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, InjectionToken, Injector, Pipe, PipeTransform, Provider, RendererV2} from '@angular/core';
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, InjectionToken, Injector, Pipe, PipeTransform, Provider, Renderer2} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
||||
|
@ -213,7 +213,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
it('should allow to use the renderer outside of views', () => {
|
||||
@Component({template: ''})
|
||||
class MyComp {
|
||||
constructor(public renderer: RendererV2) {}
|
||||
constructor(public renderer: Renderer2) {}
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [MyComp]});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectorRef, DoCheck, ElementRef, EventEmitter, Injector, OnChanges, OnDestroy, OnInit, RenderComponentType, Renderer, RendererV2, RootRenderer, Sanitizer, SecurityContext, SimpleChange, TemplateRef, ViewContainerRef, ViewEncapsulation, WrappedValue, getDebugNode} from '@angular/core';
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectorRef, DoCheck, ElementRef, EventEmitter, Injector, OnChanges, OnDestroy, OnInit, RenderComponentType, Renderer, Renderer2, RootRenderer, Sanitizer, SecurityContext, SimpleChange, TemplateRef, ViewContainerRef, ViewEncapsulation, WrappedValue, getDebugNode} from '@angular/core';
|
||||
import {getDebugContext} from '@angular/core/src/errors';
|
||||
import {ArgumentType, BindingType, DebugContext, DepFlags, NodeDef, NodeFlags, RootData, Services, ViewData, ViewDefinition, ViewDefinitionFactory, ViewFlags, ViewHandleEventFn, ViewUpdateFn, anchorDef, asElementData, asProviderData, directiveDef, elementDef, providerDef, rootRenderNodes, textDef, viewDef} from '@angular/core/src/view/index';
|
||||
import {TestBed, inject, withModule} from '@angular/core/testing';
|
||||
|
@ -296,12 +296,12 @@ export function main() {
|
|||
expect(instance.dep.createElement).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should inject RendererV2', () => {
|
||||
it('should inject Renderer2', () => {
|
||||
createAndGetRootNodes(compViewDef([
|
||||
elementDef(
|
||||
NodeFlags.None, null, null, 1, 'span', null, null, null, null,
|
||||
() => compViewDef([anchorDef(NodeFlags.None, null, null, 0)])),
|
||||
directiveDef(NodeFlags.Component, null, 0, SomeService, [RendererV2])
|
||||
directiveDef(NodeFlags.Component, null, 0, SomeService, [Renderer2])
|
||||
]));
|
||||
|
||||
expect(instance.dep.createElement).toBeTruthy();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {NgModule} from '@angular/core';
|
||||
import {BrowserModule, ɵDomRendererFactoryV2} from '@angular/platform-browser';
|
||||
import {BrowserModule, ɵDomRendererFactory2} from '@angular/platform-browser';
|
||||
|
||||
import {BROWSER_ANIMATIONS_PROVIDERS, BROWSER_NOOP_ANIMATIONS_PROVIDERS} from './providers';
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injectable, NgZone, Provider, RendererFactoryV2} from '@angular/core';
|
||||
import {ɵDomRendererFactoryV2} from '@angular/platform-browser';
|
||||
import {Injectable, NgZone, Provider, RendererFactory2} from '@angular/core';
|
||||
import {ɵDomRendererFactory2} from '@angular/platform-browser';
|
||||
|
||||
import {AnimationEngine} from './animation_engine';
|
||||
import {AnimationStyleNormalizer} from './dsl/style_normalization/animation_style_normalizer';
|
||||
|
@ -37,7 +37,7 @@ export function instantiateDefaultStyleNormalizer() {
|
|||
}
|
||||
|
||||
export function instantiateRendererFactory(
|
||||
renderer: ɵDomRendererFactoryV2, engine: AnimationEngine, zone: NgZone) {
|
||||
renderer: ɵDomRendererFactory2, engine: AnimationEngine, zone: NgZone) {
|
||||
return new AnimationRendererFactory(renderer, engine, zone);
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ export const BROWSER_ANIMATIONS_PROVIDERS: Provider[] = [
|
|||
{provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver},
|
||||
{provide: AnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer},
|
||||
{provide: AnimationEngine, useClass: InjectableAnimationEngine}, {
|
||||
provide: RendererFactoryV2,
|
||||
provide: RendererFactory2,
|
||||
useFactory: instantiateRendererFactory,
|
||||
deps: [ɵDomRendererFactoryV2, AnimationEngine, NgZone]
|
||||
deps: [ɵDomRendererFactory2, AnimationEngine, NgZone]
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -61,8 +61,8 @@ export const BROWSER_ANIMATIONS_PROVIDERS: Provider[] = [
|
|||
*/
|
||||
export const BROWSER_NOOP_ANIMATIONS_PROVIDERS: Provider[] = [
|
||||
{provide: AnimationEngine, useClass: NoopAnimationEngine}, {
|
||||
provide: RendererFactoryV2,
|
||||
provide: RendererFactory2,
|
||||
useFactory: instantiateRendererFactory,
|
||||
deps: [ɵDomRendererFactoryV2, AnimationEngine, NgZone]
|
||||
deps: [ɵDomRendererFactory2, AnimationEngine, NgZone]
|
||||
}
|
||||
];
|
|
@ -6,17 +6,17 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {AnimationEvent, AnimationTriggerMetadata} from '@angular/animations';
|
||||
import {Injectable, NgZone, RendererFactoryV2, RendererTypeV2, RendererV2} from '@angular/core';
|
||||
import {Injectable, NgZone, Renderer2, RendererFactory2, RendererType2} from '@angular/core';
|
||||
|
||||
import {AnimationEngine} from '../animation_engine';
|
||||
|
||||
@Injectable()
|
||||
export class AnimationRendererFactory implements RendererFactoryV2 {
|
||||
export class AnimationRendererFactory implements RendererFactory2 {
|
||||
constructor(
|
||||
private delegate: RendererFactoryV2, private _engine: AnimationEngine,
|
||||
private _zone: NgZone) {}
|
||||
private delegate: RendererFactory2, private _engine: AnimationEngine, private _zone: NgZone) {
|
||||
}
|
||||
|
||||
createRenderer(hostElement: any, type: RendererTypeV2): RendererV2 {
|
||||
createRenderer(hostElement: any, type: RendererType2): Renderer2 {
|
||||
let delegate = this.delegate.createRenderer(hostElement, type);
|
||||
if (!hostElement || !type || !type.data || !type.data['animation']) return delegate;
|
||||
|
||||
|
@ -28,12 +28,12 @@ export class AnimationRendererFactory implements RendererFactoryV2 {
|
|||
}
|
||||
}
|
||||
|
||||
export class AnimationRenderer implements RendererV2 {
|
||||
export class AnimationRenderer implements Renderer2 {
|
||||
public destroyNode: (node: any) => (void|any) = null;
|
||||
private _flushPromise: Promise<any> = null;
|
||||
|
||||
constructor(
|
||||
public delegate: RendererV2, private _engine: AnimationEngine, private _zone: NgZone,
|
||||
public delegate: Renderer2, private _engine: AnimationEngine, private _zone: NgZone,
|
||||
private _namespaceId: string) {
|
||||
this.destroyNode = this.delegate.destroyNode ? (n) => delegate.destroyNode(n) : null;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {CommonModule, PlatformLocation, ɵPLATFORM_BROWSER_ID as PLATFORM_BROWSER_ID} from '@angular/common';
|
||||
import {APP_ID, ApplicationModule, ErrorHandler, ModuleWithProviders, NgModule, Optional, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, Provider, RendererFactoryV2, RootRenderer, Sanitizer, SkipSelf, Testability, createPlatformFactory, platformCore} from '@angular/core';
|
||||
import {APP_ID, ApplicationModule, ErrorHandler, ModuleWithProviders, NgModule, Optional, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, Provider, RendererFactory2, RootRenderer, Sanitizer, SkipSelf, Testability, createPlatformFactory, platformCore} from '@angular/core';
|
||||
|
||||
import {BrowserDomAdapter} from './browser/browser_adapter';
|
||||
import {BrowserPlatformLocation} from './browser/location/browser_platform_location';
|
||||
|
@ -17,7 +17,7 @@ import {BrowserGetTestability} from './browser/testability';
|
|||
import {Title} from './browser/title';
|
||||
import {ELEMENT_PROBE_PROVIDERS} from './dom/debug/ng_probe';
|
||||
import {getDOM} from './dom/dom_adapter';
|
||||
import {DomRendererFactoryV2} from './dom/dom_renderer';
|
||||
import {DomRendererFactory2} from './dom/dom_renderer';
|
||||
import {DOCUMENT} from './dom/dom_tokens';
|
||||
import {DomEventsPlugin} from './dom/events/dom_events';
|
||||
import {EVENT_MANAGER_PLUGINS, EventManager} from './dom/events/event_manager';
|
||||
|
@ -76,8 +76,8 @@ export function _document(): any {
|
|||
{provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true},
|
||||
{provide: EVENT_MANAGER_PLUGINS, useClass: HammerGesturesPlugin, multi: true},
|
||||
{provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig},
|
||||
DomRendererFactoryV2,
|
||||
{provide: RendererFactoryV2, useExisting: DomRendererFactoryV2},
|
||||
DomRendererFactory2,
|
||||
{provide: RendererFactory2, useExisting: DomRendererFactory2},
|
||||
{provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
||||
DomSharedStylesHost,
|
||||
Testability,
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {APP_ID, Inject, Injectable, RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer, ViewEncapsulation} from '@angular/core';
|
||||
import {APP_ID, Inject, Injectable, RenderComponentType, Renderer, Renderer2, RendererFactory2, RendererType2, RootRenderer, ViewEncapsulation} from '@angular/core';
|
||||
|
||||
import {EventManager} from './events/event_manager';
|
||||
import {DomSharedStylesHost} from './shared_styles_host';
|
||||
|
||||
|
@ -57,15 +58,15 @@ function decoratePreventDefault(eventHandler: Function): Function {
|
|||
}
|
||||
|
||||
@Injectable()
|
||||
export class DomRendererFactoryV2 implements RendererFactoryV2 {
|
||||
private rendererByCompId = new Map<string, RendererV2>();
|
||||
private defaultRenderer: RendererV2;
|
||||
export class DomRendererFactory2 implements RendererFactory2 {
|
||||
private rendererByCompId = new Map<string, Renderer2>();
|
||||
private defaultRenderer: Renderer2;
|
||||
|
||||
constructor(private eventManager: EventManager, private sharedStylesHost: DomSharedStylesHost) {
|
||||
this.defaultRenderer = new DefaultDomRendererV2(eventManager);
|
||||
this.defaultRenderer = new DefaultDomRenderer2(eventManager);
|
||||
};
|
||||
|
||||
createRenderer(element: any, type: RendererTypeV2): RendererV2 {
|
||||
createRenderer(element: any, type: RendererType2): Renderer2 {
|
||||
if (!element || !type) {
|
||||
return this.defaultRenderer;
|
||||
}
|
||||
|
@ -73,11 +74,11 @@ export class DomRendererFactoryV2 implements RendererFactoryV2 {
|
|||
case ViewEncapsulation.Emulated: {
|
||||
let renderer = this.rendererByCompId.get(type.id);
|
||||
if (!renderer) {
|
||||
renderer = new EmulatedEncapsulationDomRendererV2(
|
||||
this.eventManager, this.sharedStylesHost, type);
|
||||
renderer =
|
||||
new EmulatedEncapsulationDomRenderer2(this.eventManager, this.sharedStylesHost, type);
|
||||
this.rendererByCompId.set(type.id, renderer);
|
||||
}
|
||||
(<EmulatedEncapsulationDomRendererV2>renderer).applyToHost(element);
|
||||
(<EmulatedEncapsulationDomRenderer2>renderer).applyToHost(element);
|
||||
return renderer;
|
||||
}
|
||||
case ViewEncapsulation.Native:
|
||||
|
@ -94,7 +95,7 @@ export class DomRendererFactoryV2 implements RendererFactoryV2 {
|
|||
}
|
||||
}
|
||||
|
||||
class DefaultDomRendererV2 implements RendererV2 {
|
||||
class DefaultDomRenderer2 implements Renderer2 {
|
||||
data: {[key: string]: any} = Object.create(null);
|
||||
|
||||
constructor(private eventManager: EventManager) {}
|
||||
|
@ -209,13 +210,13 @@ function checkNoSyntheticProp(name: string, nameKind: string) {
|
|||
}
|
||||
}
|
||||
|
||||
class EmulatedEncapsulationDomRendererV2 extends DefaultDomRendererV2 {
|
||||
class EmulatedEncapsulationDomRenderer2 extends DefaultDomRenderer2 {
|
||||
private contentAttr: string;
|
||||
private hostAttr: string;
|
||||
|
||||
constructor(
|
||||
eventManager: EventManager, sharedStylesHost: DomSharedStylesHost,
|
||||
private component: RendererTypeV2) {
|
||||
private component: RendererType2) {
|
||||
super(eventManager);
|
||||
const styles = flattenStyles(component.id, component.styles, []);
|
||||
sharedStylesHost.addStyles(styles);
|
||||
|
@ -233,12 +234,12 @@ class EmulatedEncapsulationDomRendererV2 extends DefaultDomRendererV2 {
|
|||
}
|
||||
}
|
||||
|
||||
class ShadowDomRenderer extends DefaultDomRendererV2 {
|
||||
class ShadowDomRenderer extends DefaultDomRenderer2 {
|
||||
private shadowRoot: any;
|
||||
|
||||
constructor(
|
||||
eventManager: EventManager, private sharedStylesHost: DomSharedStylesHost,
|
||||
private hostEl: any, private component: RendererTypeV2) {
|
||||
private hostEl: any, private component: RendererType2) {
|
||||
super(eventManager);
|
||||
this.shadowRoot = (hostEl as any).createShadowRoot();
|
||||
this.sharedStylesHost.addHost(this.shadowRoot);
|
||||
|
|
|
@ -14,7 +14,7 @@ export {TRANSITION_ID as ɵTRANSITION_ID} from './browser/server-transition';
|
|||
export {BrowserGetTestability as ɵBrowserGetTestability} from './browser/testability';
|
||||
export {ELEMENT_PROBE_PROVIDERS as ɵELEMENT_PROBE_PROVIDERS} from './dom/debug/ng_probe';
|
||||
export {DomAdapter as ɵDomAdapter, getDOM as ɵgetDOM, setRootDomAdapter as ɵsetRootDomAdapter} from './dom/dom_adapter';
|
||||
export {DomRendererFactoryV2 as ɵDomRendererFactoryV2, NAMESPACE_URIS as ɵNAMESPACE_URIS, flattenStyles as ɵflattenStyles, shimContentAttribute as ɵshimContentAttribute, shimHostAttribute as ɵshimHostAttribute} from './dom/dom_renderer';
|
||||
export {DomRendererFactory2 as ɵDomRendererFactory2, NAMESPACE_URIS as ɵNAMESPACE_URIS, flattenStyles as ɵflattenStyles, shimContentAttribute as ɵshimContentAttribute, shimHostAttribute as ɵshimHostAttribute} from './dom/dom_renderer';
|
||||
export {DomEventsPlugin as ɵDomEventsPlugin} from './dom/events/dom_events';
|
||||
export {HammerGesturesPlugin as ɵHammerGesturesPlugin} from './dom/events/hammer_gestures';
|
||||
export {KeyEventsPlugin as ɵKeyEventsPlugin} from './dom/events/key_events';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {AnimationPlayer, AnimationTriggerMetadata, animate, state, style, transition, trigger} from '@angular/animations';
|
||||
import {Component, Injectable, RendererFactoryV2, RendererTypeV2, ViewChild} from '@angular/core';
|
||||
import {Component, Injectable, RendererFactory2, RendererType2, ViewChild} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {BrowserAnimationsModule, ɵAnimationEngine, ɵAnimationRendererFactory} from '@angular/platform-browser/animations';
|
||||
|
||||
|
@ -26,13 +26,13 @@ export function main() {
|
|||
});
|
||||
|
||||
function makeRenderer(animationTriggers: any[] = []) {
|
||||
const type = <RendererTypeV2>{
|
||||
const type = <RendererType2>{
|
||||
id: 'id',
|
||||
encapsulation: null,
|
||||
styles: [],
|
||||
data: {'animation': animationTriggers}
|
||||
};
|
||||
return (TestBed.get(RendererFactoryV2) as ɵAnimationRendererFactory)
|
||||
return (TestBed.get(RendererFactory2) as ɵAnimationRendererFactory)
|
||||
.createRenderer(element, type);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,4 +8,4 @@
|
|||
|
||||
|
||||
export {INTERNAL_SERVER_PLATFORM_PROVIDERS as ɵINTERNAL_SERVER_PLATFORM_PROVIDERS, SERVER_RENDER_PROVIDERS as ɵSERVER_RENDER_PROVIDERS} from './server';
|
||||
export {ServerRendererFactoryV2 as ɵServerRendererFactoryV2} from './server_renderer';
|
||||
export {ServerRendererFactory2 as ɵServerRendererFactory2} from './server_renderer';
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {PlatformLocation, ɵPLATFORM_SERVER_ID as PLATFORM_SERVER_ID} from '@angular/common';
|
||||
import {platformCoreDynamic} from '@angular/compiler';
|
||||
import {Injectable, InjectionToken, Injector, NgModule, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, Provider, RendererFactoryV2, RootRenderer, Testability, createPlatformFactory, isDevMode, platformCore, ɵALLOW_MULTIPLE_PLATFORMS as ALLOW_MULTIPLE_PLATFORMS} from '@angular/core';
|
||||
import {Injectable, InjectionToken, Injector, NgModule, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, Provider, RendererFactory2, RootRenderer, Testability, createPlatformFactory, isDevMode, platformCore, ɵALLOW_MULTIPLE_PLATFORMS as ALLOW_MULTIPLE_PLATFORMS} from '@angular/core';
|
||||
import {HttpModule} from '@angular/http';
|
||||
import {BrowserModule, DOCUMENT, ɵSharedStylesHost as SharedStylesHost, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||
|
||||
|
@ -16,7 +16,7 @@ import {SERVER_HTTP_PROVIDERS} from './http';
|
|||
import {ServerPlatformLocation} from './location';
|
||||
import {Parse5DomAdapter, parseDocument} from './parse5_adapter';
|
||||
import {PlatformState} from './platform_state';
|
||||
import {ServerRendererFactoryV2} from './server_renderer';
|
||||
import {ServerRendererFactory2} from './server_renderer';
|
||||
import {ServerStylesHost} from './styles_host';
|
||||
import {INITIAL_CONFIG, PlatformConfig} from './tokens';
|
||||
|
||||
|
@ -38,8 +38,8 @@ function initParse5Adapter(injector: Injector) {
|
|||
}
|
||||
|
||||
export const SERVER_RENDER_PROVIDERS: Provider[] = [
|
||||
ServerRendererFactoryV2,
|
||||
{provide: RendererFactoryV2, useExisting: ServerRendererFactoryV2},
|
||||
ServerRendererFactory2,
|
||||
{provide: RendererFactory2, useExisting: ServerRendererFactory2},
|
||||
ServerStylesHost,
|
||||
{provide: SharedStylesHost, useExisting: ServerStylesHost},
|
||||
];
|
||||
|
|
|
@ -7,24 +7,24 @@
|
|||
*/
|
||||
|
||||
import {DomElementSchemaRegistry} from '@angular/compiler';
|
||||
import {APP_ID, Inject, Injectable, NgZone, RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer, ViewEncapsulation, ɵstringify as stringify} from '@angular/core';
|
||||
import {APP_ID, Inject, Injectable, NgZone, RenderComponentType, Renderer, Renderer2, RendererFactory2, RendererType2, RootRenderer, ViewEncapsulation, ɵstringify as stringify} from '@angular/core';
|
||||
import {DOCUMENT, ɵNAMESPACE_URIS as NAMESPACE_URIS, ɵSharedStylesHost as SharedStylesHost, ɵflattenStyles as flattenStyles, ɵgetDOM as getDOM, ɵshimContentAttribute as shimContentAttribute, ɵshimHostAttribute as shimHostAttribute} from '@angular/platform-browser';
|
||||
|
||||
const EMPTY_ARRAY: any[] = [];
|
||||
|
||||
@Injectable()
|
||||
export class ServerRendererFactoryV2 implements RendererFactoryV2 {
|
||||
private rendererByCompId = new Map<string, RendererV2>();
|
||||
private defaultRenderer: RendererV2;
|
||||
export class ServerRendererFactory2 implements RendererFactory2 {
|
||||
private rendererByCompId = new Map<string, Renderer2>();
|
||||
private defaultRenderer: Renderer2;
|
||||
private schema = new DomElementSchemaRegistry();
|
||||
|
||||
constructor(
|
||||
private ngZone: NgZone, @Inject(DOCUMENT) private document: any,
|
||||
private sharedStylesHost: SharedStylesHost) {
|
||||
this.defaultRenderer = new DefaultServerRendererV2(document, ngZone, this.schema);
|
||||
this.defaultRenderer = new DefaultServerRenderer2(document, ngZone, this.schema);
|
||||
};
|
||||
|
||||
createRenderer(element: any, type: RendererTypeV2): RendererV2 {
|
||||
createRenderer(element: any, type: RendererType2): Renderer2 {
|
||||
if (!element || !type) {
|
||||
return this.defaultRenderer;
|
||||
}
|
||||
|
@ -32,11 +32,11 @@ export class ServerRendererFactoryV2 implements RendererFactoryV2 {
|
|||
case ViewEncapsulation.Emulated: {
|
||||
let renderer = this.rendererByCompId.get(type.id);
|
||||
if (!renderer) {
|
||||
renderer = new EmulatedEncapsulationServerRendererV2(
|
||||
renderer = new EmulatedEncapsulationServerRenderer2(
|
||||
this.document, this.ngZone, this.sharedStylesHost, this.schema, type);
|
||||
this.rendererByCompId.set(type.id, renderer);
|
||||
}
|
||||
(<EmulatedEncapsulationServerRendererV2>renderer).applyToHost(element);
|
||||
(<EmulatedEncapsulationServerRenderer2>renderer).applyToHost(element);
|
||||
return renderer;
|
||||
}
|
||||
case ViewEncapsulation.Native:
|
||||
|
@ -53,7 +53,7 @@ export class ServerRendererFactoryV2 implements RendererFactoryV2 {
|
|||
}
|
||||
}
|
||||
|
||||
class DefaultServerRendererV2 implements RendererV2 {
|
||||
class DefaultServerRenderer2 implements Renderer2 {
|
||||
data: {[key: string]: any} = Object.create(null);
|
||||
|
||||
constructor(
|
||||
|
@ -181,13 +181,13 @@ function checkNoSyntheticProp(name: string, nameKind: string) {
|
|||
}
|
||||
}
|
||||
|
||||
class EmulatedEncapsulationServerRendererV2 extends DefaultServerRendererV2 {
|
||||
class EmulatedEncapsulationServerRenderer2 extends DefaultServerRenderer2 {
|
||||
private contentAttr: string;
|
||||
private hostAttr: string;
|
||||
|
||||
constructor(
|
||||
document: any, ngZone: NgZone, sharedStylesHost: SharedStylesHost,
|
||||
schema: DomElementSchemaRegistry, private component: RendererTypeV2) {
|
||||
schema: DomElementSchemaRegistry, private component: RendererType2) {
|
||||
super(document, ngZone, schema);
|
||||
const styles = flattenStyles(component.id, component.styles, []);
|
||||
sharedStylesHost.addStyles(styles);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* All channels used by angular's WebWorker components are listed here.
|
||||
* You should not use these channels in your application code.
|
||||
*/
|
||||
export const RENDERER_V2_CHANNEL = 'v2.ng-Renderer';
|
||||
export const EVENT_V2_CHANNEL = 'v2.ng-Events';
|
||||
export const RENDERER_2_CHANNEL = 'v2.ng-Renderer';
|
||||
export const EVENT_2_CHANNEL = 'v2.ng-Events';
|
||||
|
||||
export const ROUTER_CHANNEL = 'ng-Router';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injectable, RenderComponentType, RendererTypeV2, Type, ɵstringify as stringify} from '@angular/core';
|
||||
import {Injectable, RenderComponentType, RendererType2, Type, ɵstringify as stringify} from '@angular/core';
|
||||
import {RenderStore} from './render_store';
|
||||
|
||||
|
||||
|
@ -29,8 +29,8 @@ export class LocationType {
|
|||
* @experimental WebWorker support in Angular is currently experimental.
|
||||
*/
|
||||
export const enum SerializerTypes {
|
||||
// RendererTypeV2
|
||||
RENDERER_TYPE_V2,
|
||||
// RendererType2
|
||||
RENDERER_TYPE_2,
|
||||
// Primitive types
|
||||
PRIMITIVE,
|
||||
// An object stored in a RenderStore
|
||||
|
@ -54,8 +54,8 @@ export class Serializer {
|
|||
if (type === RenderComponentType) {
|
||||
return this._serializeRenderComponentType(obj);
|
||||
}
|
||||
if (type === SerializerTypes.RENDERER_TYPE_V2) {
|
||||
return this._serializeRendererTypeV2(obj);
|
||||
if (type === SerializerTypes.RENDERER_TYPE_2) {
|
||||
return this._serializeRendererType2(obj);
|
||||
}
|
||||
if (type === LocationType) {
|
||||
return this._serializeLocation(obj);
|
||||
|
@ -77,8 +77,8 @@ export class Serializer {
|
|||
if (type === RenderComponentType) {
|
||||
return this._deserializeRenderComponentType(map);
|
||||
}
|
||||
if (type === SerializerTypes.RENDERER_TYPE_V2) {
|
||||
return this._deserializeRendererTypeV2(map);
|
||||
if (type === SerializerTypes.RENDERER_TYPE_2) {
|
||||
return this._deserializeRendererType2(map);
|
||||
}
|
||||
if (type === LocationType) {
|
||||
return this._deserializeLocation(map);
|
||||
|
@ -122,7 +122,7 @@ export class Serializer {
|
|||
this.deserialize(props['encapsulation']), this.deserialize(props['styles']), {});
|
||||
}
|
||||
|
||||
private _serializeRendererTypeV2(type: RendererTypeV2): {[key: string]: any} {
|
||||
private _serializeRendererType2(type: RendererType2): {[key: string]: any} {
|
||||
return {
|
||||
'id': type.id,
|
||||
'encapsulation': this.serialize(type.encapsulation),
|
||||
|
@ -131,7 +131,7 @@ export class Serializer {
|
|||
};
|
||||
}
|
||||
|
||||
private _deserializeRendererTypeV2(props: {[key: string]: any}): RendererTypeV2 {
|
||||
private _deserializeRendererType2(props: {[key: string]: any}): RendererType2 {
|
||||
return {
|
||||
id: props['id'],
|
||||
encapsulation: props['encapsulation'],
|
||||
|
|
|
@ -6,34 +6,34 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injectable, RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer} from '@angular/core';
|
||||
import {Injectable, RenderComponentType, Renderer, Renderer2, RendererFactory2, RendererType2, RootRenderer} from '@angular/core';
|
||||
|
||||
import {MessageBus} from '../shared/message_bus';
|
||||
import {EVENT_V2_CHANNEL, RENDERER_V2_CHANNEL} from '../shared/messaging_api';
|
||||
import {EVENT_2_CHANNEL, RENDERER_2_CHANNEL} from '../shared/messaging_api';
|
||||
import {RenderStore} from '../shared/render_store';
|
||||
import {Serializer, SerializerTypes} from '../shared/serializer';
|
||||
import {ServiceMessageBroker, ServiceMessageBrokerFactory} from '../shared/service_message_broker';
|
||||
import {EventDispatcher} from '../ui/event_dispatcher';
|
||||
|
||||
@Injectable()
|
||||
export class MessageBasedRendererV2 {
|
||||
export class MessageBasedRenderer2 {
|
||||
private _eventDispatcher: EventDispatcher;
|
||||
|
||||
constructor(
|
||||
private _brokerFactory: ServiceMessageBrokerFactory, private _bus: MessageBus,
|
||||
private _serializer: Serializer, private _renderStore: RenderStore,
|
||||
private _rendererFactory: RendererFactoryV2) {}
|
||||
private _rendererFactory: RendererFactory2) {}
|
||||
|
||||
start(): void {
|
||||
const broker = this._brokerFactory.createMessageBroker(RENDERER_V2_CHANNEL);
|
||||
const broker = this._brokerFactory.createMessageBroker(RENDERER_2_CHANNEL);
|
||||
|
||||
this._bus.initChannel(EVENT_V2_CHANNEL);
|
||||
this._eventDispatcher = new EventDispatcher(this._bus.to(EVENT_V2_CHANNEL), this._serializer);
|
||||
this._bus.initChannel(EVENT_2_CHANNEL);
|
||||
this._eventDispatcher = new EventDispatcher(this._bus.to(EVENT_2_CHANNEL), this._serializer);
|
||||
|
||||
const [RSO, P, CRT] = [
|
||||
SerializerTypes.RENDER_STORE_OBJECT,
|
||||
SerializerTypes.PRIMITIVE,
|
||||
SerializerTypes.RENDERER_TYPE_V2,
|
||||
SerializerTypes.RENDERER_TYPE_2,
|
||||
];
|
||||
|
||||
const methods: any[][] = [
|
||||
|
@ -61,80 +61,80 @@ export class MessageBasedRendererV2 {
|
|||
});
|
||||
}
|
||||
|
||||
private destroy(r: RendererV2) { r.destroy(); }
|
||||
private destroy(r: Renderer2) { r.destroy(); }
|
||||
|
||||
private destroyNode(r: RendererV2, node: any) {
|
||||
private destroyNode(r: Renderer2, node: any) {
|
||||
if (r.destroyNode) {
|
||||
r.destroyNode(node);
|
||||
}
|
||||
this._renderStore.remove(node);
|
||||
}
|
||||
|
||||
private createRenderer(el: any, type: RendererTypeV2, id: number) {
|
||||
private createRenderer(el: any, type: RendererType2, id: number) {
|
||||
this._renderStore.store(this._rendererFactory.createRenderer(el, type), id);
|
||||
}
|
||||
|
||||
private createElement(r: RendererV2, name: string, namespace: string, id: number) {
|
||||
private createElement(r: Renderer2, name: string, namespace: string, id: number) {
|
||||
this._renderStore.store(r.createElement(name, namespace), id);
|
||||
}
|
||||
|
||||
private createComment(r: RendererV2, value: string, id: number) {
|
||||
private createComment(r: Renderer2, value: string, id: number) {
|
||||
this._renderStore.store(r.createComment(value), id);
|
||||
}
|
||||
|
||||
private createText(r: RendererV2, value: string, id: number) {
|
||||
private createText(r: Renderer2, value: string, id: number) {
|
||||
this._renderStore.store(r.createText(value), id);
|
||||
}
|
||||
|
||||
private appendChild(r: RendererV2, parent: any, child: any) { r.appendChild(parent, child); }
|
||||
private appendChild(r: Renderer2, parent: any, child: any) { r.appendChild(parent, child); }
|
||||
|
||||
private insertBefore(r: RendererV2, parent: any, child: any, ref: any) {
|
||||
private insertBefore(r: Renderer2, parent: any, child: any, ref: any) {
|
||||
r.insertBefore(parent, child, ref);
|
||||
}
|
||||
|
||||
private removeChild(r: RendererV2, parent: any, child: any) { r.removeChild(parent, child); }
|
||||
private removeChild(r: Renderer2, parent: any, child: any) { r.removeChild(parent, child); }
|
||||
|
||||
private selectRootElement(r: RendererV2, selector: string, id: number) {
|
||||
private selectRootElement(r: Renderer2, selector: string, id: number) {
|
||||
this._renderStore.store(r.selectRootElement(selector), id);
|
||||
}
|
||||
|
||||
private parentNode(r: RendererV2, node: any, id: number) {
|
||||
private parentNode(r: Renderer2, node: any, id: number) {
|
||||
this._renderStore.store(r.parentNode(node), id);
|
||||
}
|
||||
|
||||
private nextSibling(r: RendererV2, node: any, id: number) {
|
||||
private nextSibling(r: Renderer2, node: any, id: number) {
|
||||
this._renderStore.store(r.nextSibling(node), id);
|
||||
}
|
||||
|
||||
private setAttribute(r: RendererV2, el: any, name: string, value: string, namespace: string) {
|
||||
private setAttribute(r: Renderer2, el: any, name: string, value: string, namespace: string) {
|
||||
r.setAttribute(el, name, value, namespace);
|
||||
}
|
||||
|
||||
private removeAttribute(r: RendererV2, el: any, name: string, namespace: string) {
|
||||
private removeAttribute(r: Renderer2, el: any, name: string, namespace: string) {
|
||||
r.removeAttribute(el, name, namespace);
|
||||
}
|
||||
|
||||
private addClass(r: RendererV2, el: any, name: string) { r.addClass(el, name); }
|
||||
private addClass(r: Renderer2, el: any, name: string) { r.addClass(el, name); }
|
||||
|
||||
private removeClass(r: RendererV2, el: any, name: string) { r.removeClass(el, name); }
|
||||
private removeClass(r: Renderer2, el: any, name: string) { r.removeClass(el, name); }
|
||||
|
||||
private setStyle(
|
||||
r: RendererV2, el: any, style: string, value: any, hasVendorPrefix: boolean,
|
||||
r: Renderer2, el: any, style: string, value: any, hasVendorPrefix: boolean,
|
||||
hasImportant: boolean) {
|
||||
r.setStyle(el, style, value, hasVendorPrefix, hasImportant);
|
||||
}
|
||||
|
||||
private removeStyle(r: RendererV2, el: any, style: string, hasVendorPrefix: boolean) {
|
||||
private removeStyle(r: Renderer2, el: any, style: string, hasVendorPrefix: boolean) {
|
||||
r.removeStyle(el, style, hasVendorPrefix);
|
||||
}
|
||||
|
||||
private setProperty(r: RendererV2, el: any, name: string, value: any) {
|
||||
private setProperty(r: Renderer2, el: any, name: string, value: any) {
|
||||
r.setProperty(el, name, value);
|
||||
}
|
||||
|
||||
private setValue(r: RendererV2, node: any, value: string) { r.setValue(node, value); }
|
||||
private setValue(r: Renderer2, node: any, value: string) { r.setValue(node, value); }
|
||||
|
||||
private listen(r: RendererV2, el: any, elName: string, eventName: string, unlistenId: number) {
|
||||
private listen(r: Renderer2, el: any, elName: string, eventName: string, unlistenId: number) {
|
||||
const listener = (event: any) => {
|
||||
return this._eventDispatcher.dispatchRenderEvent(el, elName, eventName, event);
|
||||
};
|
||||
|
@ -143,5 +143,5 @@ export class MessageBasedRendererV2 {
|
|||
this._renderStore.store(unlisten, unlistenId);
|
||||
}
|
||||
|
||||
private unlisten(r: RendererV2, unlisten: () => boolean) { unlisten(); }
|
||||
private unlisten(r: Renderer2, unlisten: () => boolean) { unlisten(); }
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injectable, RenderComponentType, Renderer, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer, ViewEncapsulation} from '@angular/core';
|
||||
import {Injectable, RenderComponentType, Renderer, Renderer2, RendererFactory2, RendererType2, RootRenderer, ViewEncapsulation} from '@angular/core';
|
||||
|
||||
import {ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments} from '../shared/client_message_broker';
|
||||
import {MessageBus} from '../shared/message_bus';
|
||||
import {EVENT_V2_CHANNEL, RENDERER_V2_CHANNEL} from '../shared/messaging_api';
|
||||
import {EVENT_2_CHANNEL, RENDERER_2_CHANNEL} from '../shared/messaging_api';
|
||||
import {RenderStore} from '../shared/render_store';
|
||||
import {Serializer, SerializerTypes} from '../shared/serializer';
|
||||
|
||||
|
@ -53,7 +53,7 @@ function eventNameWithTarget(target: string, eventName: string): string {
|
|||
}
|
||||
|
||||
@Injectable()
|
||||
export class WebWorkerRendererFactoryV2 implements RendererFactoryV2 {
|
||||
export class WebWorkerRendererFactory2 implements RendererFactory2 {
|
||||
globalEvents = new NamedEventEmitter();
|
||||
|
||||
private _messageBroker: ClientMessageBroker;
|
||||
|
@ -61,20 +61,20 @@ export class WebWorkerRendererFactoryV2 implements RendererFactoryV2 {
|
|||
constructor(
|
||||
messageBrokerFactory: ClientMessageBrokerFactory, bus: MessageBus,
|
||||
private _serializer: Serializer, public renderStore: RenderStore) {
|
||||
this._messageBroker = messageBrokerFactory.createMessageBroker(RENDERER_V2_CHANNEL);
|
||||
bus.initChannel(EVENT_V2_CHANNEL);
|
||||
const source = bus.from(EVENT_V2_CHANNEL);
|
||||
this._messageBroker = messageBrokerFactory.createMessageBroker(RENDERER_2_CHANNEL);
|
||||
bus.initChannel(EVENT_2_CHANNEL);
|
||||
const source = bus.from(EVENT_2_CHANNEL);
|
||||
source.subscribe({next: (message: any) => this._dispatchEvent(message)});
|
||||
}
|
||||
|
||||
createRenderer(element: any, type: RendererTypeV2): RendererV2 {
|
||||
const renderer = new WebWorkerRendererV2(this);
|
||||
createRenderer(element: any, type: RendererType2): Renderer2 {
|
||||
const renderer = new WebWorkerRenderer2(this);
|
||||
|
||||
const id = this.renderStore.allocateId();
|
||||
this.renderStore.store(renderer, id);
|
||||
this.callUI('createRenderer', [
|
||||
new FnArg(element, SerializerTypes.RENDER_STORE_OBJECT),
|
||||
new FnArg(type, SerializerTypes.RENDERER_TYPE_V2),
|
||||
new FnArg(type, SerializerTypes.RENDERER_TYPE_2),
|
||||
new FnArg(renderer, SerializerTypes.RENDER_STORE_OBJECT),
|
||||
]);
|
||||
|
||||
|
@ -114,10 +114,10 @@ export class WebWorkerRendererFactoryV2 implements RendererFactoryV2 {
|
|||
}
|
||||
|
||||
|
||||
export class WebWorkerRendererV2 implements RendererV2 {
|
||||
export class WebWorkerRenderer2 implements Renderer2 {
|
||||
data: {[key: string]: any} = Object.create(null);
|
||||
|
||||
constructor(private _rendererFactory: WebWorkerRendererFactoryV2) {}
|
||||
constructor(private _rendererFactory: WebWorkerRendererFactory2) {}
|
||||
|
||||
private asFnArg = new FnArg(this, SerializerTypes.RENDER_STORE_OBJECT);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {CommonModule, ɵPLATFORM_WORKER_APP_ID as PLATFORM_WORKER_APP_ID} from '@angular/common';
|
||||
import {APP_INITIALIZER, ApplicationModule, ErrorHandler, NgModule, NgZone, PLATFORM_ID, PlatformRef, Provider, RendererFactoryV2, RootRenderer, createPlatformFactory, platformCore} from '@angular/core';
|
||||
import {APP_INITIALIZER, ApplicationModule, ErrorHandler, NgModule, NgZone, PLATFORM_ID, PlatformRef, Provider, RendererFactory2, RootRenderer, createPlatformFactory, platformCore} from '@angular/core';
|
||||
import {DOCUMENT, ɵBROWSER_SANITIZATION_PROVIDERS as BROWSER_SANITIZATION_PROVIDERS} from '@angular/platform-browser';
|
||||
import {ON_WEB_WORKER} from './web_workers/shared/api';
|
||||
import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from './web_workers/shared/client_message_broker';
|
||||
|
@ -16,7 +16,7 @@ import {PostMessageBus, PostMessageBusSink, PostMessageBusSource} from './web_wo
|
|||
import {RenderStore} from './web_workers/shared/render_store';
|
||||
import {Serializer} from './web_workers/shared/serializer';
|
||||
import {ServiceMessageBrokerFactory, ServiceMessageBrokerFactory_} from './web_workers/shared/service_message_broker';
|
||||
import {WebWorkerRendererFactoryV2} from './web_workers/worker/renderer';
|
||||
import {WebWorkerRendererFactory2} from './web_workers/worker/renderer';
|
||||
import {WorkerDomAdapter} from './web_workers/worker/worker_adapter';
|
||||
|
||||
|
||||
|
@ -63,8 +63,8 @@ export function setupWebWorker(): void {
|
|||
{provide: DOCUMENT, useValue: null},
|
||||
{provide: ClientMessageBrokerFactory, useClass: ClientMessageBrokerFactory_},
|
||||
{provide: ServiceMessageBrokerFactory, useClass: ServiceMessageBrokerFactory_},
|
||||
WebWorkerRendererFactoryV2,
|
||||
{provide: RendererFactoryV2, useExisting: WebWorkerRendererFactoryV2},
|
||||
WebWorkerRendererFactory2,
|
||||
{provide: RendererFactory2, useExisting: WebWorkerRendererFactory2},
|
||||
{provide: ON_WEB_WORKER, useValue: true},
|
||||
RenderStore,
|
||||
{provide: ErrorHandler, useFactory: errorHandler, deps: []},
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
*/
|
||||
|
||||
import {CommonModule, ɵPLATFORM_WORKER_UI_ID as PLATFORM_WORKER_UI_ID} from '@angular/common';
|
||||
import {ErrorHandler, Injectable, InjectionToken, Injector, NgZone, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, Provider, RendererFactoryV2, RootRenderer, Testability, createPlatformFactory, isDevMode, platformCore, ɵAPP_ID_RANDOM_PROVIDER as APP_ID_RANDOM_PROVIDER} from '@angular/core';
|
||||
import {DOCUMENT, EVENT_MANAGER_PLUGINS, EventManager, HAMMER_GESTURE_CONFIG, HammerGestureConfig, ɵBROWSER_SANITIZATION_PROVIDERS as BROWSER_SANITIZATION_PROVIDERS, ɵBrowserDomAdapter as BrowserDomAdapter, ɵBrowserGetTestability as BrowserGetTestability, ɵDomEventsPlugin as DomEventsPlugin, ɵDomRendererFactoryV2 as DomRendererFactoryV2, ɵDomSharedStylesHost as DomSharedStylesHost, ɵHammerGesturesPlugin as HammerGesturesPlugin, ɵKeyEventsPlugin as KeyEventsPlugin, ɵSharedStylesHost as SharedStylesHost, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||
import {ErrorHandler, Injectable, InjectionToken, Injector, NgZone, PLATFORM_ID, PLATFORM_INITIALIZER, PlatformRef, Provider, RendererFactory2, RootRenderer, Testability, createPlatformFactory, isDevMode, platformCore, ɵAPP_ID_RANDOM_PROVIDER as APP_ID_RANDOM_PROVIDER} from '@angular/core';
|
||||
import {DOCUMENT, EVENT_MANAGER_PLUGINS, EventManager, HAMMER_GESTURE_CONFIG, HammerGestureConfig, ɵBROWSER_SANITIZATION_PROVIDERS as BROWSER_SANITIZATION_PROVIDERS, ɵBrowserDomAdapter as BrowserDomAdapter, ɵBrowserGetTestability as BrowserGetTestability, ɵDomEventsPlugin as DomEventsPlugin, ɵDomRendererFactory2 as DomRendererFactory2, ɵDomSharedStylesHost as DomSharedStylesHost, ɵHammerGesturesPlugin as HammerGesturesPlugin, ɵKeyEventsPlugin as KeyEventsPlugin, ɵSharedStylesHost as SharedStylesHost, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||
|
||||
import {ON_WEB_WORKER} from './web_workers/shared/api';
|
||||
import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from './web_workers/shared/client_message_broker';
|
||||
|
@ -17,7 +17,7 @@ import {PostMessageBus, PostMessageBusSink, PostMessageBusSource} from './web_wo
|
|||
import {RenderStore} from './web_workers/shared/render_store';
|
||||
import {Serializer} from './web_workers/shared/serializer';
|
||||
import {ServiceMessageBrokerFactory, ServiceMessageBrokerFactory_} from './web_workers/shared/service_message_broker';
|
||||
import {MessageBasedRendererV2} from './web_workers/ui/renderer';
|
||||
import {MessageBasedRenderer2} from './web_workers/ui/renderer';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -54,12 +54,8 @@ export const WORKER_UI_STARTABLE_MESSAGING_SERVICE =
|
|||
|
||||
export const _WORKER_UI_PLATFORM_PROVIDERS: Provider[] = [
|
||||
{provide: NgZone, useFactory: createNgZone, deps: []},
|
||||
MessageBasedRendererV2,
|
||||
{
|
||||
provide: WORKER_UI_STARTABLE_MESSAGING_SERVICE,
|
||||
useExisting: MessageBasedRendererV2,
|
||||
multi: true
|
||||
},
|
||||
MessageBasedRenderer2,
|
||||
{provide: WORKER_UI_STARTABLE_MESSAGING_SERVICE, useExisting: MessageBasedRenderer2, multi: true},
|
||||
BROWSER_SANITIZATION_PROVIDERS,
|
||||
{provide: ErrorHandler, useFactory: _exceptionHandler, deps: []},
|
||||
{provide: DOCUMENT, useFactory: _document, deps: []},
|
||||
|
@ -70,8 +66,8 @@ export const _WORKER_UI_PLATFORM_PROVIDERS: Provider[] = [
|
|||
{provide: EVENT_MANAGER_PLUGINS, useClass: HammerGesturesPlugin, multi: true},
|
||||
{provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig},
|
||||
APP_ID_RANDOM_PROVIDER,
|
||||
DomRendererFactoryV2,
|
||||
{provide: RendererFactoryV2, useExisting: DomRendererFactoryV2},
|
||||
DomRendererFactory2,
|
||||
{provide: RendererFactory2, useExisting: DomRendererFactory2},
|
||||
{provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
||||
{provide: ServiceMessageBrokerFactory, useClass: ServiceMessageBrokerFactory_},
|
||||
{provide: ClientMessageBrokerFactory, useClass: ClientMessageBrokerFactory_},
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Component, ComponentRef, RendererFactoryV2, RendererTypeV2, RendererV2, RootRenderer} from '@angular/core';
|
||||
import {Component, ComponentRef, Renderer2, RendererFactory2, RendererType2, RootRenderer} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {DomRendererFactoryV2} from '@angular/platform-browser/src/dom/dom_renderer';
|
||||
import {DomRendererFactory2} from '@angular/platform-browser/src/dom/dom_renderer';
|
||||
import {BrowserTestingModule} from '@angular/platform-browser/testing';
|
||||
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
@ -19,11 +19,11 @@ import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from '../../../
|
|||
import {RenderStore} from '../../../src/web_workers/shared/render_store';
|
||||
import {Serializer} from '../../../src/web_workers/shared/serializer';
|
||||
import {ServiceMessageBrokerFactory_} from '../../../src/web_workers/shared/service_message_broker';
|
||||
import {MessageBasedRendererV2} from '../../../src/web_workers/ui/renderer';
|
||||
import {WebWorkerRendererFactoryV2} from '../../../src/web_workers/worker/renderer';
|
||||
import {MessageBasedRenderer2} from '../../../src/web_workers/ui/renderer';
|
||||
import {WebWorkerRendererFactory2} from '../../../src/web_workers/worker/renderer';
|
||||
import {PairedMessageBuses, createPairedMessageBuses} from '../shared/web_worker_test_util';
|
||||
|
||||
let lastCreatedRenderer: RendererV2;
|
||||
let lastCreatedRenderer: Renderer2;
|
||||
|
||||
export function main() {
|
||||
describe('Web Worker Renderer v2', () => {
|
||||
|
@ -43,12 +43,12 @@ export function main() {
|
|||
providers: [
|
||||
Serializer,
|
||||
{provide: RenderStore, useValue: uiRenderStore},
|
||||
DomRendererFactoryV2,
|
||||
{provide: RendererFactoryV2, useExisting: DomRendererFactoryV2},
|
||||
DomRendererFactory2,
|
||||
{provide: RendererFactory2, useExisting: DomRendererFactory2},
|
||||
]
|
||||
});
|
||||
const uiSerializer = uiInjector.get(Serializer);
|
||||
const domRendererFactory = uiInjector.get(RendererFactoryV2);
|
||||
const domRendererFactory = uiInjector.get(RendererFactory2);
|
||||
|
||||
// Worker side
|
||||
lastCreatedRenderer = null;
|
||||
|
@ -61,9 +61,9 @@ export function main() {
|
|||
Serializer,
|
||||
{provide: RenderStore, useValue: wwRenderStore},
|
||||
{
|
||||
provide: RendererFactoryV2,
|
||||
provide: RendererFactory2,
|
||||
useFactory:
|
||||
(wwSerializer: Serializer) => createWebWorkerRendererFactoryV2(
|
||||
(wwSerializer: Serializer) => createWebWorkerRendererFactory2(
|
||||
wwSerializer, uiSerializer, domRendererFactory, uiRenderStore, wwRenderStore),
|
||||
deps: [Serializer],
|
||||
},
|
||||
|
@ -174,7 +174,7 @@ class MyComp2 {
|
|||
|
||||
function createWebWorkerBrokerFactory(
|
||||
messageBuses: PairedMessageBuses, wwSerializer: Serializer, uiSerializer: Serializer,
|
||||
domRendererFactory: DomRendererFactoryV2,
|
||||
domRendererFactory: DomRendererFactory2,
|
||||
uiRenderStore: RenderStore): ClientMessageBrokerFactory {
|
||||
const uiMessageBus = messageBuses.ui;
|
||||
const wwMessageBus = messageBuses.worker;
|
||||
|
@ -184,17 +184,16 @@ function createWebWorkerBrokerFactory(
|
|||
|
||||
// set up the ui side
|
||||
const uiBrokerFactory = new ServiceMessageBrokerFactory_(uiMessageBus, uiSerializer);
|
||||
const renderer = new MessageBasedRendererV2(
|
||||
const renderer = new MessageBasedRenderer2(
|
||||
uiBrokerFactory, uiMessageBus, uiSerializer, uiRenderStore, domRendererFactory);
|
||||
renderer.start();
|
||||
|
||||
return wwBrokerFactory;
|
||||
}
|
||||
|
||||
function createWebWorkerRendererFactoryV2(
|
||||
workerSerializer: Serializer, uiSerializer: Serializer,
|
||||
domRendererFactory: DomRendererFactoryV2, uiRenderStore: RenderStore,
|
||||
workerRenderStore: RenderStore): RendererFactoryV2 {
|
||||
function createWebWorkerRendererFactory2(
|
||||
workerSerializer: Serializer, uiSerializer: Serializer, domRendererFactory: DomRendererFactory2,
|
||||
uiRenderStore: RenderStore, workerRenderStore: RenderStore): RendererFactory2 {
|
||||
const messageBuses = createPairedMessageBuses();
|
||||
const brokerFactory = createWebWorkerBrokerFactory(
|
||||
messageBuses, workerSerializer, uiSerializer, domRendererFactory, uiRenderStore);
|
||||
|
@ -205,8 +204,8 @@ function createWebWorkerRendererFactoryV2(
|
|||
return rendererFactory;
|
||||
}
|
||||
|
||||
class RenderFactory extends WebWorkerRendererFactoryV2 {
|
||||
createRenderer(element: any, type: RendererTypeV2): RendererV2 {
|
||||
class RenderFactory extends WebWorkerRendererFactory2 {
|
||||
createRenderer(element: any, type: RendererType2): Renderer2 {
|
||||
lastCreatedRenderer = super.createRenderer(element, type);
|
||||
return lastCreatedRenderer;
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
*/
|
||||
|
||||
import {NgIf} from '@angular/common';
|
||||
import {ComponentFactory, ComponentRef, Injector, RendererFactoryV2, RootRenderer, Sanitizer, TemplateRef, ViewContainerRef} from '@angular/core';
|
||||
import {ComponentFactory, ComponentRef, Injector, RendererFactory2, RootRenderer, Sanitizer, TemplateRef, ViewContainerRef} from '@angular/core';
|
||||
import {ArgumentType, BindingType, NodeFlags, ViewDefinition, ViewFlags, anchorDef, createComponentFactory, directiveDef, elementDef, initServicesIfNeeded, textDef, viewDef} from '@angular/core/src/view/index';
|
||||
import {DomRendererFactoryV2} from '@angular/platform-browser/src/dom/dom_renderer';
|
||||
import {DomRendererFactory2} from '@angular/platform-browser/src/dom/dom_renderer';
|
||||
import {DomSanitizerImpl, SafeStyle} from '@angular/platform-browser/src/security/dom_sanitization_service';
|
||||
|
||||
import {TreeNode, emptyTree} from '../util';
|
||||
|
@ -87,14 +87,14 @@ function TreeComponent_0(): ViewDefinition {
|
|||
export class AppModule implements Injector {
|
||||
private sanitizer: DomSanitizerImpl;
|
||||
private componentFactory: ComponentFactory<TreeComponent>;
|
||||
private rendererV2: RendererFactoryV2;
|
||||
private renderer2: RendererFactory2;
|
||||
|
||||
componentRef: ComponentRef<TreeComponent>;
|
||||
|
||||
constructor() {
|
||||
initServicesIfNeeded();
|
||||
this.sanitizer = new DomSanitizerImpl(document);
|
||||
this.rendererV2 = new DomRendererFactoryV2(null, null);
|
||||
this.renderer2 = new DomRendererFactory2(null, null);
|
||||
trustedEmptyColor = this.sanitizer.bypassSecurityTrustStyle('');
|
||||
trustedGreyColor = this.sanitizer.bypassSecurityTrustStyle('grey');
|
||||
this.componentFactory = createComponentFactory('#root', TreeComponent, TreeComponent_Host);
|
||||
|
@ -102,8 +102,8 @@ export class AppModule implements Injector {
|
|||
|
||||
get(token: any, notFoundValue: any = Injector.THROW_IF_NOT_FOUND): any {
|
||||
switch (token) {
|
||||
case RendererFactoryV2:
|
||||
return this.rendererV2;
|
||||
case RendererFactory2:
|
||||
return this.renderer2;
|
||||
case Sanitizer:
|
||||
return this.sanitizer;
|
||||
case RootRenderer:
|
||||
|
|
|
@ -807,22 +807,7 @@ export declare abstract class Renderer {
|
|||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare abstract class RendererFactoryV2 {
|
||||
abstract createRenderer(hostElement: any, type: RendererTypeV2): RendererV2;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export interface RendererTypeV2 {
|
||||
data: {
|
||||
[kind: string]: any;
|
||||
};
|
||||
encapsulation: ViewEncapsulation;
|
||||
id: string;
|
||||
styles: (string | any[])[];
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare abstract class RendererV2 {
|
||||
export declare abstract class Renderer2 {
|
||||
readonly abstract data: {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
@ -834,7 +819,7 @@ export declare abstract class RendererV2 {
|
|||
abstract createText(value: string): any;
|
||||
abstract destroy(): void;
|
||||
abstract insertBefore(parent: any, newChild: any, refChild: any): void;
|
||||
abstract listen(target: 'window' | 'document' | 'body' | any, eventName: string, callback: (event: any) => boolean): () => void;
|
||||
abstract listen(target: 'window' | 'document' | 'body' | any, eventName: string, callback: (event: any) => boolean | void): () => void;
|
||||
abstract nextSibling(node: any): any;
|
||||
abstract parentNode(node: any): any;
|
||||
abstract removeAttribute(el: any, name: string, namespace?: string): void;
|
||||
|
@ -848,6 +833,21 @@ export declare abstract class RendererV2 {
|
|||
abstract setValue(node: any, value: string): void;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare abstract class RendererFactory2 {
|
||||
abstract createRenderer(hostElement: any, type: RendererType2): Renderer2;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export interface RendererType2 {
|
||||
data: {
|
||||
[kind: string]: any;
|
||||
};
|
||||
encapsulation: ViewEncapsulation;
|
||||
id: string;
|
||||
styles: (string | any[])[];
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare class ResolvedReflectiveFactory {
|
||||
dependencies: ReflectiveDependency[];
|
||||
|
|
|
@ -59,7 +59,7 @@ export interface ReceivedMessage {
|
|||
|
||||
/** @experimental */
|
||||
export declare const enum SerializerTypes {
|
||||
RENDERER_TYPE_V2 = 0,
|
||||
RENDERER_TYPE_2 = 0,
|
||||
PRIMITIVE = 1,
|
||||
RENDER_STORE_OBJECT = 2,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue