66 * found in the LICENSE file at https://angular.io/license
77 */
88
9+ import './ng_dev_mode' ;
10+
911import { ChangeDetectionStrategy } from '../change_detection/constants' ;
10- import { Provider } from '../core' ;
12+ import { Provider , ViewEncapsulation } from '../core' ;
1113import { NgModuleDef , NgModuleDefInternal } from '../metadata/ng_module' ;
12- import { RendererType2 } from '../render/api' ;
1314import { Type } from '../type' ;
14- import { resolveRendererType2 } from '../view/util' ;
1515
1616import { BaseDef , ComponentDefFeature , ComponentDefInternal , ComponentQuery , ComponentTemplate , ComponentType , DirectiveDefFeature , DirectiveDefInternal , DirectiveType , DirectiveTypesOrFactory , PipeDefInternal , PipeType , PipeTypesOrFactory } from './interfaces/definition' ;
1717import { CssSelectorList , SelectorFlags } from './interfaces/projection' ;
1818
1919
20+ const EMPTY : { } = { } ;
21+ const EMPTY_ARRAY : any [ ] = [ ] ;
22+ ngDevMode && Object . freeze ( EMPTY ) ;
23+ ngDevMode && Object . freeze ( EMPTY_ARRAY ) ;
24+ let _renderCompCount = 0 ;
2025
2126/**
2227 * Create a component definition object.
@@ -180,8 +185,28 @@ export function defineComponent<T>(componentDefinition: {
180185 */
181186 features ?: ComponentDefFeature [ ] ;
182187
183- rendererType ?: RendererType2 ;
188+ /**
189+ * Defines template and style encapsulation options available for Component's {@link Component}.
190+ */
191+ encapsulation ?: ViewEncapsulation ;
192+
193+ /**
194+ * Defines arbitrary developer-defined data to be stored on a renderer instance.
195+ * This is useful for renderers that delegate to other renderers.
196+ *
197+ * see: animation
198+ */
199+ data ?: { [ kind : string ] : any } ;
184200
201+ /**
202+ * A set of styles that the component needs to be present for component to render correctly.
203+ */
204+ styles ?: string [ ] ;
205+
206+ /**
207+ * The strategy that the default change detector uses to detect changes.
208+ * When set, takes effect the next time change detection is triggered.
209+ */
185210 changeDetection ?: ChangeDetectionStrategy ;
186211
187212 /**
@@ -215,6 +240,7 @@ export function defineComponent<T>(componentDefinition: {
215240 const pipeTypes = componentDefinition . pipes ! ;
216241 const directiveTypes = componentDefinition . directives ! ;
217242 const declaredInputs : { [ key : string ] : string } = { } as any ;
243+ const encapsulation = componentDefinition . encapsulation ;
218244 const def : ComponentDefInternal < any > = {
219245 type : type ,
220246 diPublic : null ,
@@ -227,7 +253,6 @@ export function defineComponent<T>(componentDefinition: {
227253 inputs : invertObject ( componentDefinition . inputs , declaredInputs ) ,
228254 declaredInputs : declaredInputs ,
229255 outputs : invertObject ( componentDefinition . outputs ) ,
230- rendererType : resolveRendererType2 ( componentDefinition . rendererType ) || null ,
231256 exportAs : componentDefinition . exportAs || null ,
232257 onInit : type . prototype . ngOnInit || null ,
233258 doCheck : type . prototype . ngDoCheck || null ,
@@ -247,6 +272,12 @@ export function defineComponent<T>(componentDefinition: {
247272 selectors : componentDefinition . selectors ,
248273 viewQuery : componentDefinition . viewQuery || null ,
249274 features : componentDefinition . features || null ,
275+ data : componentDefinition . data || EMPTY ,
276+ // TODO(misko): convert ViewEncapsulation into const enum so that it can be used directly in the
277+ // next line. Also `None` should be 0 not 2.
278+ encapsulation : encapsulation == null ? 2 /* ViewEncapsulation.None */ : encapsulation ,
279+ id : `c${ _renderCompCount ++ } ` ,
280+ styles : EMPTY_ARRAY ,
250281 } ;
251282 const feature = componentDefinition . features ;
252283 feature && feature . forEach ( ( fn ) => fn ( def ) ) ;
@@ -273,17 +304,15 @@ export function extractPipeDef(type: PipeType<any>): PipeDefInternal<any> {
273304export function defineNgModule < T > ( def : { type : T } & Partial < NgModuleDef < T , any , any , any > > ) : never {
274305 const res : NgModuleDefInternal < T > = {
275306 type : def . type ,
276- bootstrap : def . bootstrap || [ ] ,
277- declarations : def . declarations || [ ] ,
278- imports : def . imports || [ ] ,
279- exports : def . exports || [ ] ,
307+ bootstrap : def . bootstrap || EMPTY_ARRAY ,
308+ declarations : def . declarations || EMPTY_ARRAY ,
309+ imports : def . imports || EMPTY_ARRAY ,
310+ exports : def . exports || EMPTY_ARRAY ,
280311 transitiveCompileScopes : null ,
281312 } ;
282313 return res as never ;
283314}
284315
285- const EMPTY = { } ;
286-
287316/**
288317 * Inverts an inputs or outputs lookup such that the keys, which were the
289318 * minified keys, are part of the values, and the values are parsed so that
0 commit comments