refactor(core): introduce ComponentFactory.
Each compile template now exposes a `<CompName>NgFactory` variable with an instance of a `ComponentFactory`. Calling `ComponentFactory.create` returns a `ComponentRef` that can be used directly. BREAKING CHANGE: - `Compiler` is renamed to `ComponentResolver`, `Compiler.compileInHost` has been renamed to `ComponentResolver.resolveComponent`. - `ComponentRef.dispose` is renamed to `ComponentRef.destroy` - `ViewContainerRef.createHostView` is renamed to `ViewContainerRef.createComponent` - `ComponentFixture_` has been removed, the class `ComponentFixture` can now be created directly as it is no more using private APIs.
This commit is contained in:
@ -29,10 +29,6 @@ const CORE = [
|
||||
'AfterViewInit',
|
||||
'AfterViewInit.ngAfterViewInit():any',
|
||||
'AppViewManager',
|
||||
'AppViewManager.createRootHostView(hostViewFactoryRef:HostViewFactoryRef, overrideSelector:string, injector:Injector, projectableNodes:any[][]):HostViewRef',
|
||||
'AppViewManager.destroyRootHostView(hostViewRef:HostViewRef):any',
|
||||
'AppViewManager.getComponent(hostLocation:ElementRef):any',
|
||||
'AppViewManager.getHostElement(hostViewRef:HostViewRef):ElementRef',
|
||||
'AppViewManager.getNamedElementInComponentView(hostLocation:ElementRef, variableName:string):ElementRef',
|
||||
'AppViewManager.getViewContainer(location:ElementRef):ViewContainerRef',
|
||||
'ApplicationRef',
|
||||
@ -44,7 +40,7 @@ const CORE = [
|
||||
'ApplicationRef.registerDisposeListener(dispose:() => void):void',
|
||||
'ApplicationRef.tick():void',
|
||||
'ApplicationRef.zone:NgZone',
|
||||
'AttributeFactory',
|
||||
'AttributeMetadataFactory',
|
||||
'AttributeMetadata',
|
||||
'AttributeMetadata.constructor(attributeName:string)',
|
||||
'AttributeMetadata.toString():string',
|
||||
@ -77,12 +73,12 @@ const CORE = [
|
||||
'CollectionChangeRecord.currentIndex:number',
|
||||
'CollectionChangeRecord.previousIndex:number',
|
||||
'CollectionChangeRecord.toString():string',
|
||||
'Compiler',
|
||||
'Compiler.clearCache():any',
|
||||
'Compiler.compileInHost(componentType:Type):Promise<HostViewFactoryRef>',
|
||||
'ComponentResolver',
|
||||
'ComponentResolver.clearCache():any',
|
||||
'ComponentResolver.resolveComponent(componentType:Type):Promise<ComponentFactory>',
|
||||
'ComponentDecorator',
|
||||
'ComponentDecorator.View(obj:{templateUrl?:string, template?:string, directives?:Array<Type|any[]>, pipes?:Array<Type|any[]>, renderer?:string, styles?:string[], styleUrls?:string[]}):ViewDecorator',
|
||||
'ComponentFactory',
|
||||
'ComponentMetadataFactory',
|
||||
'ComponentMetadata',
|
||||
'ComponentMetadata.changeDetection:ChangeDetectionStrategy',
|
||||
'ComponentMetadata.constructor({selector,inputs,outputs,properties,events,host,exportAs,moduleId,bindings,providers,viewBindings,viewProviders,changeDetection=ChangeDetectionStrategy.Default,queries,templateUrl,template,styleUrls,styles,directives,pipes,encapsulation}:{selector?:string, inputs?:string[], outputs?:string[], properties?:string[], events?:string[], host?:{[key:string]:string}, bindings?:any[], providers?:any[], exportAs?:string, moduleId?:string, viewBindings?:any[], viewProviders?:any[], queries?:{[key:string]:any}, changeDetection?:ChangeDetectionStrategy, templateUrl?:string, template?:string, styleUrls?:string[], styles?:string[], directives?:Array<Type|any[]>, pipes?:Array<Type|any[]>, encapsulation?:ViewEncapsulation})',
|
||||
@ -98,17 +94,18 @@ const CORE = [
|
||||
'ComponentMetadata.viewProviders:any[]',
|
||||
'ComponentRef',
|
||||
'ComponentRef.componentType:Type',
|
||||
'ComponentRef.dispose():void',
|
||||
'ComponentRef.hostComponent:any',
|
||||
'ComponentRef.hostView:HostViewRef',
|
||||
'ComponentRef.injector:Injector',
|
||||
'ComponentRef.instance:any',
|
||||
'ComponentRef.location:ElementRef',
|
||||
'ComponentRef.destroy():void',
|
||||
'ComponentRef.hostView:ViewRef',
|
||||
'ComponentRef.onDestroy(callback:Function):void',
|
||||
'ComponentRef.changeDetectorRef:ChangeDetectorRef',
|
||||
'ConcreteType',
|
||||
'ContentChildFactory',
|
||||
'ContentChildMetadataFactory',
|
||||
'ContentChildMetadata',
|
||||
'ContentChildMetadata.constructor(_selector:Type|string)',
|
||||
'ContentChildrenFactory',
|
||||
'ContentChildrenMetadataFactory',
|
||||
'ContentChildrenMetadata',
|
||||
'ContentChildrenMetadata.constructor(_selector:Type|string, {descendants=false}:{descendants?:boolean})',
|
||||
'CyclicDependencyError',
|
||||
@ -147,7 +144,7 @@ const CORE = [
|
||||
'DependencyMetadata',
|
||||
'DependencyMetadata.token:any',
|
||||
'DirectiveDecorator',
|
||||
'DirectiveFactory',
|
||||
'DirectiveMetadataFactory',
|
||||
'DirectiveMetadata',
|
||||
'DirectiveMetadata.bindings:any[]',
|
||||
'DirectiveMetadata.constructor({selector,inputs,outputs,properties,events,host,bindings,providers,exportAs,queries}:{selector?:string, inputs?:string[], outputs?:string[], properties?:string[], events?:string[], host?:{[key:string]:string}, providers?:any[], bindings?:any[], exportAs?:string, queries?:{[key:string]:any}})',
|
||||
@ -163,7 +160,7 @@ const CORE = [
|
||||
'DoCheck',
|
||||
'DoCheck.ngDoCheck():any',
|
||||
'DynamicComponentLoader',
|
||||
'DynamicComponentLoader.loadAsRoot(type:Type, overrideSelector:string, injector:Injector, onDispose:() => void, projectableNodes:any[][]):Promise<ComponentRef>',
|
||||
'DynamicComponentLoader.loadAsRoot(type:Type, overrideSelectorOrNode:string, injector:Injector, onDispose:() => void, projectableNodes:any[][]):Promise<ComponentRef>',
|
||||
'DynamicComponentLoader.loadIntoLocation(type:Type, hostLocation:ElementRef, anchorName:string, providers:ResolvedProvider[], projectableNodes:any[][]):Promise<ComponentRef>',
|
||||
'DynamicComponentLoader.loadNextToLocation(type:Type, location:ElementRef, providers:ResolvedProvider[], projectableNodes:any[][]):Promise<ComponentRef>',
|
||||
'ElementRef',
|
||||
@ -172,6 +169,7 @@ const CORE = [
|
||||
'EmbeddedViewRef.hasLocal(variableName:string):boolean',
|
||||
'EmbeddedViewRef.rootNodes:any[]',
|
||||
'EmbeddedViewRef.setLocal(variableName:string, value:any):void',
|
||||
'EmbeddedViewRef.destroy():any',
|
||||
'EventEmitter.constructor(isAsync:boolean)',
|
||||
'EventEmitter.emit(value:T):any',
|
||||
'EventEmitter.next(value:any):any',
|
||||
@ -187,23 +185,24 @@ const CORE = [
|
||||
'GetTestability',
|
||||
'GetTestability.addToWindow(registry:TestabilityRegistry):void',
|
||||
'GetTestability.findTestabilityInTree(registry:TestabilityRegistry, elem:any, findInAncestors:boolean):Testability',
|
||||
'HostBindingFactory',
|
||||
'HostBindingMetadataFactory',
|
||||
'HostBindingMetadata',
|
||||
'HostBindingMetadata.constructor(hostPropertyName:string)',
|
||||
'HostFactory',
|
||||
'HostListenerFactory',
|
||||
'HostMetadataFactory',
|
||||
'HostListenerMetadataFactory',
|
||||
'HostListenerMetadata',
|
||||
'HostListenerMetadata.constructor(eventName:string, args:string[])',
|
||||
'HostMetadata',
|
||||
'HostMetadata.toString():string',
|
||||
'HostViewFactoryRef',
|
||||
'HostViewRef',
|
||||
'HostViewRef.rootNodes:any[]',
|
||||
'InjectFactory',
|
||||
'ComponentFactory',
|
||||
'ComponentFactory.componentType:Type',
|
||||
'ComponentFactory.constructor(selector:string, _viewFactory:Function, _componentType:Type)',
|
||||
'ComponentFactory.create(injector:Injector, projectableNodes:any[][], rootSelectorOrNode:string|any):ComponentRef',
|
||||
'InjectMetadataFactory',
|
||||
'InjectMetadata',
|
||||
'InjectMetadata.constructor(token:any)',
|
||||
'InjectMetadata.toString():string',
|
||||
'InjectableFactory',
|
||||
'InjectableMetadataFactory',
|
||||
'InjectableMetadata',
|
||||
'InjectableMetadata.constructor()',
|
||||
'Injector',
|
||||
@ -219,7 +218,7 @@ const CORE = [
|
||||
'Injector.resolveAndCreate(providers:Array<Type|Provider|any[]>):Injector',
|
||||
'Injector.resolveAndCreateChild(providers:Array<Type|Provider|any[]>):Injector',
|
||||
'Injector.resolveAndInstantiate(provider:Type|Provider):any',
|
||||
'InputFactory',
|
||||
'InputMetadataFactory',
|
||||
'InputMetadata',
|
||||
'InputMetadata.constructor(bindingPropertyName:string)',
|
||||
'InstantiationError',
|
||||
@ -292,15 +291,15 @@ const CORE = [
|
||||
'OpaqueToken',
|
||||
'OpaqueToken.constructor(_desc:string)',
|
||||
'OpaqueToken.toString():string',
|
||||
'OptionalFactory',
|
||||
'OptionalMetadataFactory',
|
||||
'OptionalMetadata',
|
||||
'OptionalMetadata.toString():string',
|
||||
'OutOfBoundsError',
|
||||
'OutOfBoundsError.constructor(index:any)',
|
||||
'OutputFactory',
|
||||
'OutputMetadataFactory',
|
||||
'OutputMetadata',
|
||||
'OutputMetadata.constructor(bindingPropertyName:string)',
|
||||
'PipeFactory',
|
||||
'PipeMetadataFactory',
|
||||
'PipeMetadata',
|
||||
'PipeMetadata.constructor({name,pure}:{name:string, pure?:boolean})',
|
||||
'PipeMetadata.name:string',
|
||||
@ -328,7 +327,7 @@ const CORE = [
|
||||
'ProviderBuilder.toClass(type:Type):Provider',
|
||||
'ProviderBuilder.toFactory(factory:Function, dependencies:any[]):Provider',
|
||||
'ProviderBuilder.toValue(value:any):Provider',
|
||||
'QueryFactory',
|
||||
'QueryMetadataFactory',
|
||||
'QueryList.changes:Observable<any>',
|
||||
'QueryList.dirty:any',
|
||||
'QueryList.filter(fn:(item: T) => boolean):T[]',
|
||||
@ -389,7 +388,7 @@ const CORE = [
|
||||
'Renderer.listen(renderElement:any, name:string, callback:Function):Function',
|
||||
'Renderer.listenGlobal(target:string, name:string, callback:Function):Function',
|
||||
'Renderer.projectNodes(parentElement:any, nodes:any[]):void',
|
||||
'Renderer.selectRootElement(selector:string, debugInfo:RenderDebugInfo):any',
|
||||
'Renderer.selectRootElement(selectorOrNode:string|any, debugInfo:RenderDebugInfo):any',
|
||||
'Renderer.setBindingDebugInfo(renderElement:any, propertyName:string, propertyValue:string):void',
|
||||
'Renderer.setElementAttribute(renderElement:any, attributeName:string, attributeValue:string):void',
|
||||
'Renderer.setElementClass(renderElement:any, className:string, isAdd:boolean):any',
|
||||
@ -405,17 +404,18 @@ const CORE = [
|
||||
'ResolvedProvider.resolvedFactories:ResolvedFactory[]',
|
||||
'RootRenderer',
|
||||
'RootRenderer.renderComponent(componentType:RenderComponentType):Renderer',
|
||||
'SelfFactory',
|
||||
'SelfMetadataFactory',
|
||||
'SelfMetadata',
|
||||
'SelfMetadata.toString():string',
|
||||
'SimpleChange',
|
||||
'SimpleChange.constructor(previousValue:any, currentValue:any)',
|
||||
'SimpleChange.isFirstChange():boolean',
|
||||
'SkipSelfFactory',
|
||||
'SkipSelfMetadataFactory',
|
||||
'SkipSelfMetadata',
|
||||
'SkipSelfMetadata.toString():string',
|
||||
'TemplateRef',
|
||||
'TemplateRef.elementRef:ElementRef',
|
||||
'TemplateRef.createEmbeddedView():EmbeddedViewRef',
|
||||
'Testability',
|
||||
'Testability.constructor(_ngZone:NgZone)',
|
||||
'Testability.decreasePendingRequestCount():number',
|
||||
@ -436,16 +436,16 @@ const CORE = [
|
||||
'TypeDecorator',
|
||||
'TypeDecorator.Class(obj:ClassDefinition):ConcreteType',
|
||||
'TypeDecorator.annotations:any[]',
|
||||
'ViewChildFactory',
|
||||
'ViewChildMetadataFactory',
|
||||
'ViewChildMetadata',
|
||||
'ViewChildMetadata.constructor(_selector:Type|string)',
|
||||
'ViewChildrenFactory',
|
||||
'ViewChildrenMetadataFactory',
|
||||
'ViewChildrenMetadata',
|
||||
'ViewChildrenMetadata.constructor(_selector:Type|string)',
|
||||
'ViewContainerRef',
|
||||
'ViewContainerRef.clear():void',
|
||||
'ViewContainerRef.createEmbeddedView(templateRef:TemplateRef, index:number):EmbeddedViewRef',
|
||||
'ViewContainerRef.createHostView(hostViewFactoryRef:HostViewFactoryRef, index:number, dynamicallyCreatedProviders:ResolvedProvider[], projectableNodes:any[][]):HostViewRef',
|
||||
'ViewContainerRef.createComponent(componentFactory:ComponentFactory, index:number, dynamicallyCreatedProviders:ResolvedProvider[], projectableNodes:any[][]):ComponentRef',
|
||||
'ViewContainerRef.detach(index:number):ViewRef',
|
||||
'ViewContainerRef.element:ElementRef',
|
||||
'ViewContainerRef.get(index:number):ViewRef',
|
||||
@ -459,7 +459,7 @@ const CORE = [
|
||||
'ViewEncapsulation.Emulated',
|
||||
'ViewEncapsulation.Native',
|
||||
'ViewEncapsulation.None',
|
||||
'ViewFactory',
|
||||
'ViewMetadataFactory',
|
||||
'ViewMetadata',
|
||||
'ViewMetadata.constructor({templateUrl,template,directives,pipes,encapsulation,styles,styleUrls}:{templateUrl?:string, template?:string, directives?:Array<Type|any[]>, pipes?:Array<Type|any[]>, encapsulation?:ViewEncapsulation, styles?:string[], styleUrls?:string[]})',
|
||||
'ViewMetadata.directives:Array<Type|any[]>',
|
||||
@ -476,6 +476,7 @@ const CORE = [
|
||||
'ViewRef',
|
||||
'ViewRef.changeDetectorRef:ChangeDetectorRef',
|
||||
'ViewRef.destroyed:boolean',
|
||||
'ViewRef.onDestroy(callback:Function):any',
|
||||
'WrappedException',
|
||||
'WrappedException.constructor(_wrapperMessage:string, _originalException:any, _originalStack:any, _context:any)',
|
||||
'WrappedException.context:any',
|
||||
@ -505,27 +506,27 @@ const CORE = [
|
||||
'provide(token:any, {useClass,useValue,useExisting,useFactory,deps,multi}:{useClass?:Type, useValue?:any, useExisting?:any, useFactory?:Function, deps?:Object[], multi?:boolean}):Provider',
|
||||
'resolveForwardRef(type:any):any',
|
||||
'setTestabilityGetter(getter:GetTestability):void',
|
||||
'var Attribute:AttributeFactory',
|
||||
'var Component:ComponentFactory',
|
||||
'var ContentChild:ContentChildFactory',
|
||||
'var ContentChildren:ContentChildrenFactory',
|
||||
'var Directive:DirectiveFactory',
|
||||
'var Host:HostFactory',
|
||||
'var HostBinding:HostBindingFactory',
|
||||
'var HostListener:HostListenerFactory',
|
||||
'var Inject:InjectFactory',
|
||||
'var Injectable:InjectableFactory',
|
||||
'var Input:InputFactory',
|
||||
'var Optional:OptionalFactory',
|
||||
'var Output:OutputFactory',
|
||||
'var Pipe:PipeFactory',
|
||||
'var Query:QueryFactory',
|
||||
'var Self:SelfFactory',
|
||||
'var SkipSelf:SkipSelfFactory',
|
||||
'var Attribute:AttributeMetadataFactory',
|
||||
'var Component:ComponentMetadataFactory',
|
||||
'var ContentChild:ContentChildMetadataFactory',
|
||||
'var ContentChildren:ContentChildrenMetadataFactory',
|
||||
'var Directive:DirectiveMetadataFactory',
|
||||
'var Host:HostMetadataFactory',
|
||||
'var HostBinding:HostBindingMetadataFactory',
|
||||
'var HostListener:HostListenerMetadataFactory',
|
||||
'var Inject:InjectMetadataFactory',
|
||||
'var Injectable:InjectableMetadataFactory',
|
||||
'var Input:InputMetadataFactory',
|
||||
'var Optional:OptionalMetadataFactory',
|
||||
'var Output:OutputMetadataFactory',
|
||||
'var Pipe:PipeMetadataFactory',
|
||||
'var Query:QueryMetadataFactory',
|
||||
'var Self:SelfMetadataFactory',
|
||||
'var SkipSelf:SkipSelfMetadataFactory',
|
||||
'var Type:any',
|
||||
'var ViewChild:ViewChildFactory',
|
||||
'var ViewChildren:ViewChildrenFactory',
|
||||
'var ViewQuery:QueryFactory',
|
||||
'var ViewChild:ViewChildMetadataFactory',
|
||||
'var ViewChildren:ViewChildrenMetadataFactory',
|
||||
'var ViewQuery:QueryMetadataFactory',
|
||||
'var reflector:any'
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user