( componentDefinition: ComponentDefinition<T>, )
| 334 | * @codeGenApi |
| 335 | */ |
| 336 | export function ɵɵdefineComponent<T>( |
| 337 | componentDefinition: ComponentDefinition<T>, |
| 338 | ): ComponentDef<any> { |
| 339 | return noSideEffects(() => { |
| 340 | // Initialize ngDevMode. This must be the first statement in ɵɵdefineComponent. |
| 341 | // See the `initNgDevMode` docstring for more information. |
| 342 | (typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode(); |
| 343 | |
| 344 | const baseDef = getNgDirectiveDef(componentDefinition as DirectiveDefinition<T>); |
| 345 | const def: Writable<ComponentDef<T>> = { |
| 346 | ...baseDef, |
| 347 | decls: componentDefinition.decls, |
| 348 | vars: componentDefinition.vars, |
| 349 | template: componentDefinition.template, |
| 350 | consts: componentDefinition.consts || null, |
| 351 | ngContentSelectors: componentDefinition.ngContentSelectors, |
| 352 | onPush: componentDefinition.changeDetection !== ChangeDetectionStrategy.Eager, |
| 353 | directiveDefs: null!, // assigned in noSideEffects |
| 354 | pipeDefs: null!, // assigned in noSideEffects |
| 355 | dependencies: (baseDef.standalone && componentDefinition.dependencies) || null, |
| 356 | getStandaloneInjector: baseDef.standalone |
| 357 | ? (parentInjector: EnvironmentInjector) => { |
| 358 | return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(def); |
| 359 | } |
| 360 | : null, |
| 361 | getExternalStyles: null, |
| 362 | signals: componentDefinition.signals ?? false, |
| 363 | data: componentDefinition.data || {}, |
| 364 | encapsulation: componentDefinition.encapsulation || ViewEncapsulation.Emulated, |
| 365 | styles: componentDefinition.styles || EMPTY_ARRAY, |
| 366 | _: null, |
| 367 | schemas: componentDefinition.schemas || null, |
| 368 | tView: null, |
| 369 | id: '', |
| 370 | }; |
| 371 | |
| 372 | // TODO: Do we still need/want this ? |
| 373 | if (baseDef.standalone) { |
| 374 | performanceMarkFeature('NgStandalone'); |
| 375 | } |
| 376 | |
| 377 | initFeatures(def); |
| 378 | const dependencies = componentDefinition.dependencies; |
| 379 | def.directiveDefs = extractDefListOrFactory(dependencies, extractDirectiveDef); |
| 380 | def.pipeDefs = extractDefListOrFactory(dependencies, getPipeDef); |
| 381 | def.id = getComponentId(def); |
| 382 | |
| 383 | return def; |
| 384 | }); |
| 385 | } |
| 386 | |
| 387 | export function extractDirectiveDef(type: Type<any>): DirectiveDef<any> | ComponentDef<any> | null { |
| 388 | return getComponentDef(type) || getDirectiveDef(type); |
no test coverage detected
searching dependent graphs…