From 2d3cd2b96908f73d0c6fa3c309ac184b3ced0461 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 25 Mar 2021 21:25:03 +0000 Subject: [PATCH] refactor(compiler): rename `R3FactoryTarget` to `FactoryTarget` (#41231) This enumeration will now start to appear in publicly facing code, as part of declarations, so we remove the R3 to make it less specific to the internal name for the Ivy renderer/compiler. PR Close #41231 --- .../partial_factory_linker_1.ts | 4 ++-- .../src/ngtsc/annotations/src/component.ts | 6 ++--- .../src/ngtsc/annotations/src/directive.ts | 7 +++--- .../src/ngtsc/annotations/src/injectable.ts | 6 ++--- .../src/ngtsc/annotations/src/ng_module.ts | 4 ++-- .../src/ngtsc/annotations/src/pipe.ts | 6 ++--- .../src/ngtsc/annotations/src/util.ts | 4 ++-- packages/compiler/src/compiler.ts | 2 +- .../compiler/src/compiler_facade_interface.ts | 8 +++---- .../compiler/src/injectable_compiler_2.ts | 4 ++-- packages/compiler/src/jit_compiler_facade.ts | 4 ++-- packages/compiler/src/render3/partial/api.ts | 4 ++-- .../compiler/src/render3/partial/factory.ts | 4 ++-- packages/compiler/src/render3/r3_factory.ts | 22 +++++++++---------- .../compiler/src/render3/r3_identifiers.ts | 2 +- .../test/compiler_facade_interface_spec.ts | 14 ++++++------ .../src/compiler/compiler_facade_interface.ts | 2 +- .../core/src/core_render3_private_export.ts | 2 +- packages/core/src/di/interface/injector.ts | 3 +++ packages/core/src/di/jit/injectable.ts | 2 +- packages/core/src/render3/jit/directive.ts | 2 +- packages/core/src/render3/jit/module.ts | 2 +- packages/core/src/render3/jit/partial.ts | 2 +- packages/core/src/render3/jit/pipe.ts | 2 +- 24 files changed, 60 insertions(+), 58 deletions(-) diff --git a/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_factory_linker_1.ts b/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_factory_linker_1.ts index c19e509716..b8b8d375a2 100644 --- a/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_factory_linker_1.ts +++ b/packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_factory_linker_1.ts @@ -5,7 +5,7 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import {compileFactoryFunction, ConstantPool, R3DeclareDependencyMetadata, R3DeclareFactoryMetadata, R3DependencyMetadata, R3FactoryMetadata, R3FactoryTarget, R3PartialDeclaration} from '@angular/compiler'; +import {compileFactoryFunction, ConstantPool, FactoryTarget, R3DeclareDependencyMetadata, R3DeclareFactoryMetadata, R3DependencyMetadata, R3FactoryMetadata, R3PartialDeclaration} from '@angular/compiler'; import * as o from '@angular/compiler/src/output/output_ast'; import {AstObject} from '../../ast/ast_value'; @@ -44,7 +44,7 @@ export function toR3FactoryMeta( type: wrapReference(typeExpr.getOpaque()), internalType: metaObj.getOpaque('type'), typeArgumentCount: 0, - target: parseEnum(metaObj.getValue('target'), R3FactoryTarget), + target: parseEnum(metaObj.getValue('target'), FactoryTarget), deps: getDeps(metaObj, 'deps'), }; } diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/component.ts b/packages/compiler-cli/src/ngtsc/annotations/src/component.ts index 16c57a1bf8..3795f7e0b7 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/component.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/component.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {compileComponentFromMetadata, compileDeclareComponentFromMetadata, ConstantPool, CssSelector, DeclarationListEmitMode, DEFAULT_INTERPOLATION_CONFIG, DomElementSchemaRegistry, Expression, ExternalExpr, InterpolationConfig, LexerRange, makeBindingParser, ParsedTemplate, ParseSourceFile, parseTemplate, R3ComponentMetadata, R3FactoryMetadata, R3FactoryTarget, R3TargetBinder, R3UsedDirectiveMetadata, SelectorMatcher, Statement, TmplAstNode, WrappedNodeExpr} from '@angular/compiler'; +import {compileComponentFromMetadata, compileDeclareComponentFromMetadata, ConstantPool, CssSelector, DeclarationListEmitMode, DEFAULT_INTERPOLATION_CONFIG, DomElementSchemaRegistry, Expression, ExternalExpr, FactoryTarget, InterpolationConfig, LexerRange, makeBindingParser, ParsedTemplate, ParseSourceFile, parseTemplate, R3ComponentMetadata, R3FactoryMetadata, R3TargetBinder, R3UsedDirectiveMetadata, SelectorMatcher, Statement, TmplAstNode, WrappedNodeExpr} from '@angular/compiler'; import * as ts from 'typescript'; import {Cycle, CycleAnalyzer, CycleHandlingStrategy} from '../../cycles'; @@ -833,7 +833,7 @@ export class ComponentDecoratorHandler implements return []; } const meta: R3ComponentMetadata = {...analysis.meta, ...resolution}; - const fac = compileNgFactoryDefField(toFactoryMetadata(meta, R3FactoryTarget.Component)); + const fac = compileNgFactoryDefField(toFactoryMetadata(meta, FactoryTarget.Component)); const def = compileComponentFromMetadata(meta, pool, makeBindingParser()); return compileResults(fac, def, analysis.metadataStmt, 'ɵcmp'); } @@ -845,7 +845,7 @@ export class ComponentDecoratorHandler implements return []; } const meta: R3ComponentMetadata = {...analysis.meta, ...resolution}; - const fac = compileDeclareFactory(toFactoryMetadata(meta, R3FactoryTarget.Component)); + const fac = compileDeclareFactory(toFactoryMetadata(meta, FactoryTarget.Component)); const def = compileDeclareComponentFromMetadata(meta, analysis.template); return compileResults(fac, def, analysis.metadataStmt, 'ɵcmp'); } diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts b/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts index 14b2a71d6f..78a775b519 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, ConstantPool, Expression, ExternalExpr, getSafePropertyAccessString, makeBindingParser, ParsedHostBindings, ParseError, parseHostBindings, R3DirectiveMetadata, R3FactoryMetadata, R3FactoryTarget, R3QueryMetadata, Statement, verifyHostBindings, WrappedNodeExpr} from '@angular/compiler'; +import {compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, ConstantPool, Expression, ExternalExpr, FactoryTarget, getSafePropertyAccessString, makeBindingParser, ParsedHostBindings, ParseError, parseHostBindings, R3DirectiveMetadata, R3FactoryMetadata, R3QueryMetadata, Statement, verifyHostBindings, WrappedNodeExpr} from '@angular/compiler'; import {emitDistinctChangesOnlyDefaultValue} from '@angular/compiler/src/core'; import * as ts from 'typescript'; @@ -302,8 +302,7 @@ export class DirectiveDecoratorHandler implements compileFull( node: ClassDeclaration, analysis: Readonly, resolution: Readonly, pool: ConstantPool): CompileResult[] { - const fac = - compileNgFactoryDefField(toFactoryMetadata(analysis.meta, R3FactoryTarget.Directive)); + const fac = compileNgFactoryDefField(toFactoryMetadata(analysis.meta, FactoryTarget.Directive)); const def = compileDirectiveFromMetadata(analysis.meta, pool, makeBindingParser()); return compileResults(fac, def, analysis.metadataStmt, 'ɵdir'); } @@ -311,7 +310,7 @@ export class DirectiveDecoratorHandler implements compilePartial( node: ClassDeclaration, analysis: Readonly, resolution: Readonly): CompileResult[] { - const fac = compileDeclareFactory(toFactoryMetadata(analysis.meta, R3FactoryTarget.Directive)); + const fac = compileDeclareFactory(toFactoryMetadata(analysis.meta, FactoryTarget.Directive)); const def = compileDeclareDirectiveFromMetadata(analysis.meta); return compileResults(fac, def, analysis.metadataStmt, 'ɵdir'); } diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts b/packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts index 1e63bf0d30..63636a2ce6 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {compileInjectable as compileIvyInjectable, Expression, LiteralExpr, R3DependencyMetadata, R3FactoryMetadata, R3FactoryTarget, R3InjectableMetadata, Statement, WrappedNodeExpr} from '@angular/compiler'; +import {compileInjectable as compileIvyInjectable, Expression, FactoryTarget, LiteralExpr, R3DependencyMetadata, R3FactoryMetadata, R3InjectableMetadata, Statement, WrappedNodeExpr} from '@angular/compiler'; import * as ts from 'typescript'; import {ErrorCode, FatalDiagnosticError} from '../../diagnostics'; @@ -102,7 +102,7 @@ export class InjectableDecoratorHandler implements if (analysis.needsFactory) { const meta = analysis.meta; const factoryRes = compileNgFactoryDefField( - toFactoryMetadata({...meta, deps: analysis.ctorDeps}, R3FactoryTarget.Injectable)); + toFactoryMetadata({...meta, deps: analysis.ctorDeps}, FactoryTarget.Injectable)); if (analysis.metadataStmt !== null) { factoryRes.statements.push(analysis.metadataStmt); } @@ -134,7 +134,7 @@ export class InjectableDecoratorHandler implements if (analysis.needsFactory) { const meta = analysis.meta; const factoryRes = compileDeclareFactory( - toFactoryMetadata({...meta, deps: analysis.ctorDeps}, R3FactoryTarget.Injectable)); + toFactoryMetadata({...meta, deps: analysis.ctorDeps}, FactoryTarget.Injectable)); if (analysis.metadataStmt !== null) { factoryRes.statements.push(analysis.metadataStmt); } diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts b/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts index 74d5041472..d23d88fbd8 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, CUSTOM_ELEMENTS_SCHEMA, Expression, ExternalExpr, Identifiers as R3, InvokeFunctionExpr, LiteralArrayExpr, LiteralExpr, NO_ERRORS_SCHEMA, R3CompiledExpression, R3FactoryMetadata, R3FactoryTarget, R3Identifiers, R3InjectorMetadata, R3NgModuleMetadata, R3Reference, SchemaMetadata, Statement, STRING_TYPE, WrappedNodeExpr} from '@angular/compiler'; +import {compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, CUSTOM_ELEMENTS_SCHEMA, Expression, ExternalExpr, FactoryTarget, Identifiers as R3, InvokeFunctionExpr, LiteralArrayExpr, LiteralExpr, NO_ERRORS_SCHEMA, R3CompiledExpression, R3FactoryMetadata, R3Identifiers, R3InjectorMetadata, R3NgModuleMetadata, R3Reference, SchemaMetadata, Statement, STRING_TYPE, WrappedNodeExpr} from '@angular/compiler'; import * as ts from 'typescript'; import {ErrorCode, FatalDiagnosticError, makeDiagnostic, makeRelatedInformation} from '../../diagnostics'; @@ -352,7 +352,7 @@ export class NgModuleDecoratorHandler implements typeArgumentCount: 0, deps: getValidConstructorDependencies( node, this.reflector, this.defaultImportRecorder, this.isCore), - target: R3FactoryTarget.NgModule, + target: FactoryTarget.NgModule, }; return { diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts b/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts index 3630076014..76fc19aa11 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/pipe.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {compileDeclarePipeFromMetadata, compilePipeFromMetadata, R3FactoryTarget, R3PipeMetadata, Statement, WrappedNodeExpr} from '@angular/compiler'; +import {compileDeclarePipeFromMetadata, compilePipeFromMetadata, FactoryTarget, R3PipeMetadata, Statement, WrappedNodeExpr} from '@angular/compiler'; import * as ts from 'typescript'; import {ErrorCode, FatalDiagnosticError} from '../../diagnostics'; @@ -165,13 +165,13 @@ export class PipeDecoratorHandler implements } compileFull(node: ClassDeclaration, analysis: Readonly): CompileResult[] { - const fac = compileNgFactoryDefField(toFactoryMetadata(analysis.meta, R3FactoryTarget.Pipe)); + const fac = compileNgFactoryDefField(toFactoryMetadata(analysis.meta, FactoryTarget.Pipe)); const def = compilePipeFromMetadata(analysis.meta); return compileResults(fac, def, analysis.metadataStmt, 'ɵpipe'); } compilePartial(node: ClassDeclaration, analysis: Readonly): CompileResult[] { - const fac = compileDeclareFactory(toFactoryMetadata(analysis.meta, R3FactoryTarget.Pipe)); + const fac = compileDeclareFactory(toFactoryMetadata(analysis.meta, FactoryTarget.Pipe)); const def = compileDeclarePipeFromMetadata(analysis.meta); return compileResults(fac, def, analysis.metadataStmt, 'ɵpipe'); } diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/util.ts b/packages/compiler-cli/src/ngtsc/annotations/src/util.ts index f1ddbb2e72..5820adbb46 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/util.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/util.ts @@ -8,7 +8,7 @@ import {Expression, ExternalExpr, LiteralExpr, ParseLocation, ParseSourceFile, ParseSourceSpan, R3CompiledExpression, R3DependencyMetadata, R3Reference, ReadPropExpr, Statement, WrappedNodeExpr} from '@angular/compiler'; import {R3FactoryMetadata} from '@angular/compiler/src/compiler'; -import {R3FactoryTarget} from '@angular/compiler/src/render3/partial/api'; +import {FactoryTarget} from '@angular/compiler/src/render3/partial/api'; import * as ts from 'typescript'; import {ErrorCode, FatalDiagnosticError, makeDiagnostic, makeRelatedInformation} from '../../diagnostics'; @@ -583,7 +583,7 @@ export function compileResults( } export function toFactoryMetadata( - meta: Omit, target: R3FactoryTarget): R3FactoryMetadata { + meta: Omit, target: FactoryTarget): R3FactoryMetadata { return { name: meta.name, type: meta.type, diff --git a/packages/compiler/src/compiler.ts b/packages/compiler/src/compiler.ts index 6800cf5d20..9f1bc70dc6 100644 --- a/packages/compiler/src/compiler.ts +++ b/packages/compiler/src/compiler.ts @@ -97,7 +97,7 @@ export {BoundAttribute as TmplAstBoundAttribute, BoundEvent as TmplAstBoundEvent export * from './render3/view/t2_api'; export * from './render3/view/t2_binder'; export {Identifiers as R3Identifiers} from './render3/r3_identifiers'; -export {compileFactoryFunction, R3DependencyMetadata, R3FactoryMetadata, R3FactoryTarget} from './render3/r3_factory'; +export {compileFactoryFunction, R3DependencyMetadata, R3FactoryMetadata, FactoryTarget} from './render3/r3_factory'; export {compileNgModule, R3NgModuleMetadata} from './render3/r3_module_compiler'; export {compileInjector, R3InjectorMetadata} from './render3/r3_injector_compiler'; export {compilePipeFromMetadata, R3PipeMetadata} from './render3/r3_pipe_compiler'; diff --git a/packages/compiler/src/compiler_facade_interface.ts b/packages/compiler/src/compiler_facade_interface.ts index d18ee13010..1f6d803eef 100644 --- a/packages/compiler/src/compiler_facade_interface.ts +++ b/packages/compiler/src/compiler_facade_interface.ts @@ -60,7 +60,7 @@ export interface CompilerFacade { createParseSourceSpan(kind: string, typeName: string, sourceUrl: string): ParseSourceSpan; - R3FactoryTarget: typeof R3FactoryTarget; + FactoryTarget: typeof FactoryTarget; ResourceLoader: {new(): ResourceLoader}; } @@ -82,7 +82,7 @@ export type StringMapWithRename = { export type Provider = any; -export enum R3FactoryTarget { +export enum FactoryTarget { Directive = 0, Component = 1, Injectable = 2, @@ -228,13 +228,13 @@ export interface R3FactoryDefMetadataFacade { type: any; typeArgumentCount: number; deps: R3DependencyMetadataFacade[]|null; - target: R3FactoryTarget; + target: FactoryTarget; } export interface R3DeclareFactoryFacade { type: Function; deps: R3DeclareDependencyMetadataFacade[]|null; - target: R3FactoryTarget; + target: FactoryTarget; } export enum ViewEncapsulation { diff --git a/packages/compiler/src/injectable_compiler_2.ts b/packages/compiler/src/injectable_compiler_2.ts index 4faa6ea878..68b7fdb737 100644 --- a/packages/compiler/src/injectable_compiler_2.ts +++ b/packages/compiler/src/injectable_compiler_2.ts @@ -8,7 +8,7 @@ import {Identifiers} from './identifiers'; import * as o from './output/output_ast'; -import {compileFactoryFunction, R3DependencyMetadata, R3FactoryDelegateType, R3FactoryMetadata, R3FactoryTarget} from './render3/r3_factory'; +import {compileFactoryFunction, FactoryTarget, R3DependencyMetadata, R3FactoryDelegateType, R3FactoryMetadata} from './render3/r3_factory'; import {R3Reference, typeWithParameters} from './render3/util'; import {DefinitionMap} from './render3/view/util'; @@ -40,7 +40,7 @@ export function compileInjectable(meta: R3InjectableMetadata): InjectableDef { internalType: meta.internalType, typeArgumentCount: meta.typeArgumentCount, deps: [], - target: R3FactoryTarget.Injectable, + target: FactoryTarget.Injectable, }; if (meta.useClass !== undefined) { diff --git a/packages/compiler/src/jit_compiler_facade.ts b/packages/compiler/src/jit_compiler_facade.ts index 7ba0e81591..8c8b2b9036 100644 --- a/packages/compiler/src/jit_compiler_facade.ts +++ b/packages/compiler/src/jit_compiler_facade.ts @@ -15,7 +15,7 @@ import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from './ml_parser/int import {DeclareVarStmt, Expression, literal, LiteralExpr, Statement, StmtModifier, WrappedNodeExpr} from './output/output_ast'; import {JitEvaluator} from './output/output_jit'; import {ParseError, ParseSourceSpan, r3JitTypeSourceSpan} from './parse_util'; -import {compileFactoryFunction, R3DependencyMetadata, R3FactoryTarget} from './render3/r3_factory'; +import {compileFactoryFunction, FactoryTarget, R3DependencyMetadata} from './render3/r3_factory'; import {compileInjector, R3InjectorMetadata} from './render3/r3_injector_compiler'; import {R3JitReflector} from './render3/r3_jit'; import {compileNgModule, compileNgModuleDeclarationExpression, R3NgModuleMetadata} from './render3/r3_module_compiler'; @@ -28,7 +28,7 @@ import {ResourceLoader} from './resource_loader'; import {DomElementSchemaRegistry} from './schema/dom_element_schema_registry'; export class CompilerFacadeImpl implements CompilerFacade { - R3FactoryTarget = R3FactoryTarget as any; + FactoryTarget = FactoryTarget as any; ResourceLoader = ResourceLoader; private elementSchemaRegistry = new DomElementSchemaRegistry(); diff --git a/packages/compiler/src/render3/partial/api.ts b/packages/compiler/src/render3/partial/api.ts index 2ca458e4b6..124e953291 100644 --- a/packages/compiler/src/render3/partial/api.ts +++ b/packages/compiler/src/render3/partial/api.ts @@ -356,10 +356,10 @@ export interface R3DeclareFactoryMetadata extends R3PartialDeclaration { /** * Type of the target being created by the factory. */ - target: R3FactoryTarget; + target: FactoryTarget; } -export enum R3FactoryTarget { +export enum FactoryTarget { Directive = 0, Component = 1, Injectable = 2, diff --git a/packages/compiler/src/render3/partial/factory.ts b/packages/compiler/src/render3/partial/factory.ts index 8b371c8419..3a8e6d9eaa 100644 --- a/packages/compiler/src/render3/partial/factory.ts +++ b/packages/compiler/src/render3/partial/factory.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ import * as o from '../../output/output_ast'; -import {createFactoryType, R3DependencyMetadata, R3FactoryMetadata, R3FactoryTarget} from '../r3_factory'; +import {createFactoryType, FactoryTarget, R3DependencyMetadata, R3FactoryMetadata} from '../r3_factory'; import {Identifiers as R3} from '../r3_identifiers'; import {R3CompiledExpression} from '../util'; import {DefinitionMap} from '../view/util'; @@ -19,7 +19,7 @@ export function compileDeclareFactoryFunction(meta: R3FactoryMetadata): R3Compil definitionMap.set('ngImport', o.importExpr(R3.core)); definitionMap.set('type', meta.internalType); definitionMap.set('deps', compileDependencies(meta.deps)); - definitionMap.set('target', o.importExpr(R3.R3FactoryTarget).prop(R3FactoryTarget[meta.target])); + definitionMap.set('target', o.importExpr(R3.FactoryTarget).prop(FactoryTarget[meta.target])); return { expression: o.importExpr(R3.declareFactory).callFn([definitionMap.toLiteralMap()]), diff --git a/packages/compiler/src/render3/r3_factory.ts b/packages/compiler/src/render3/r3_factory.ts index 90b898928c..8cc4dbfc06 100644 --- a/packages/compiler/src/render3/r3_factory.ts +++ b/packages/compiler/src/render3/r3_factory.ts @@ -57,7 +57,7 @@ export interface R3ConstructorFactoryMetadata { /** * Type of the target being created by the factory. */ - target: R3FactoryTarget; + target: FactoryTarget; } export enum R3FactoryDelegateType { @@ -78,7 +78,7 @@ export interface R3ExpressionFactoryMetadata extends R3ConstructorFactoryMetadat export type R3FactoryMetadata = R3ConstructorFactoryMetadata|R3DelegatedFnOrClassMetadata|R3ExpressionFactoryMetadata; -export enum R3FactoryTarget { +export enum FactoryTarget { Directive = 0, Component = 1, Injectable = 2, @@ -222,12 +222,12 @@ export function createFactoryType(meta: R3FactoryMetadata) { [typeWithParameters(meta.type.type, meta.typeArgumentCount), ctorDepsType])); } -function injectDependencies(deps: R3DependencyMetadata[], target: R3FactoryTarget): o.Expression[] { +function injectDependencies(deps: R3DependencyMetadata[], target: FactoryTarget): o.Expression[] { return deps.map((dep, index) => compileInjectDependency(dep, target, index)); } function compileInjectDependency( - dep: R3DependencyMetadata, target: R3FactoryTarget, index: number): o.Expression { + dep: R3DependencyMetadata, target: FactoryTarget, index: number): o.Expression { // Interpret the dependency according to its resolved type. if (dep.token === null) { return o.importExpr(R3.invalidFactoryDep).callFn([o.literal(index)]); @@ -236,7 +236,7 @@ function compileInjectDependency( const flags = InjectFlags.Default | (dep.self ? InjectFlags.Self : 0) | (dep.skipSelf ? InjectFlags.SkipSelf : 0) | (dep.host ? InjectFlags.Host : 0) | (dep.optional ? InjectFlags.Optional : 0) | - (target === R3FactoryTarget.Pipe ? InjectFlags.ForPipe : 0); + (target === FactoryTarget.Pipe ? InjectFlags.ForPipe : 0); // If this dependency is optional or otherwise has non-default flags, then additional // parameters describing how to inject the dependency must be passed to the inject function @@ -314,14 +314,14 @@ export function isExpressionFactoryMetadata(meta: R3FactoryMetadata): return (meta as any).expression !== undefined; } -function getInjectFn(target: R3FactoryTarget): o.ExternalReference { +function getInjectFn(target: FactoryTarget): o.ExternalReference { switch (target) { - case R3FactoryTarget.Component: - case R3FactoryTarget.Directive: - case R3FactoryTarget.Pipe: + case FactoryTarget.Component: + case FactoryTarget.Directive: + case FactoryTarget.Pipe: return R3.directiveInject; - case R3FactoryTarget.NgModule: - case R3FactoryTarget.Injectable: + case FactoryTarget.NgModule: + case FactoryTarget.Injectable: default: return R3.inject; } diff --git a/packages/compiler/src/render3/r3_identifiers.ts b/packages/compiler/src/render3/r3_identifiers.ts index 329f17095f..89f26c9813 100644 --- a/packages/compiler/src/render3/r3_identifiers.ts +++ b/packages/compiler/src/render3/r3_identifiers.ts @@ -257,7 +257,7 @@ export class Identifiers { moduleName: CORE, }; static declareFactory: o.ExternalReference = {name: 'ɵɵngDeclareFactory', moduleName: CORE}; - static R3FactoryTarget: o.ExternalReference = {name: 'ɵɵFactoryTarget', moduleName: CORE}; + static FactoryTarget: o.ExternalReference = {name: 'ɵɵFactoryTarget', moduleName: CORE}; static defineDirective: o.ExternalReference = {name: 'ɵɵdefineDirective', moduleName: CORE}; static declareDirective: o.ExternalReference = {name: 'ɵɵngDeclareDirective', moduleName: CORE}; diff --git a/packages/compiler/test/compiler_facade_interface_spec.ts b/packages/compiler/test/compiler_facade_interface_spec.ts index 9082d3b9ba..7f2f56faa2 100644 --- a/packages/compiler/test/compiler_facade_interface_spec.ts +++ b/packages/compiler/test/compiler_facade_interface_spec.ts @@ -7,7 +7,7 @@ */ import * as core from '../../core/src/compiler/compiler_facade_interface'; -import {R3FactoryTarget} from '../public_api'; +import {FactoryTarget} from '../public_api'; import * as compiler from '../src/compiler_facade_interface'; /** @@ -45,14 +45,14 @@ const compilerStringMap: compiler.StringMap = null! as core.StringMap; const coreProvider: core.Provider = null! as compiler.Provider; const compilerProvider: compiler.Provider = null! as core.Provider; -const coreR3FactoryTarget: core.R3FactoryTarget = null! as compiler.R3FactoryTarget; -const compilerR3FactoryTarget: compiler.R3FactoryTarget = null! as core.R3FactoryTarget; +const coreR3FactoryTarget: core.FactoryTarget = null! as compiler.FactoryTarget; +const compilerR3FactoryTarget: compiler.FactoryTarget = null! as core.FactoryTarget; -const coreR3FactoryTarget2: R3FactoryTarget = null! as core.R3FactoryTarget; -const compilerR3FactoryTarget2: R3FactoryTarget = null! as core.R3FactoryTarget; +const coreR3FactoryTarget2: FactoryTarget = null! as core.FactoryTarget; +const compilerR3FactoryTarget2: FactoryTarget = null! as core.FactoryTarget; -const coreR3FactoryTarget3: core.R3FactoryTarget = null! as R3FactoryTarget; -const compilerR3FactoryTarget3: compiler.R3FactoryTarget = null! as R3FactoryTarget; +const coreR3FactoryTarget3: core.FactoryTarget = null! as FactoryTarget; +const compilerR3FactoryTarget3: compiler.FactoryTarget = null! as FactoryTarget; const coreR3DependencyMetadataFacade: core.R3DependencyMetadataFacade = null! as compiler.R3DependencyMetadataFacade; diff --git a/packages/core/src/compiler/compiler_facade_interface.ts b/packages/core/src/compiler/compiler_facade_interface.ts index ac3264d0c0..1f6d803eef 100644 --- a/packages/core/src/compiler/compiler_facade_interface.ts +++ b/packages/core/src/compiler/compiler_facade_interface.ts @@ -60,7 +60,7 @@ export interface CompilerFacade { createParseSourceSpan(kind: string, typeName: string, sourceUrl: string): ParseSourceSpan; - R3FactoryTarget: typeof FactoryTarget; + FactoryTarget: typeof FactoryTarget; ResourceLoader: {new(): ResourceLoader}; } diff --git a/packages/core/src/core_render3_private_export.ts b/packages/core/src/core_render3_private_export.ts index 940db40ba2..93d713fe05 100644 --- a/packages/core/src/core_render3_private_export.ts +++ b/packages/core/src/core_render3_private_export.ts @@ -268,7 +268,7 @@ export { transitiveScopesFor as ɵtransitiveScopesFor, } from './render3/jit/module'; export { - R3FactoryTarget as ɵɵFactoryTarget, + FactoryTarget as ɵɵFactoryTarget, ɵɵngDeclareComponent, ɵɵngDeclareDirective, ɵɵngDeclareFactory, diff --git a/packages/core/src/di/interface/injector.ts b/packages/core/src/di/interface/injector.ts index 276e116c2d..eb923095a8 100644 --- a/packages/core/src/di/interface/injector.ts +++ b/packages/core/src/di/interface/injector.ts @@ -73,6 +73,9 @@ export const enum InternalInjectFlags { /** * This token is being injected into a pipe. + * + * This flag is intentionally not in the public facing `InjectFlags` because it is only added by + * the compiler and is not a developer applicable flag. */ ForPipe = 0b10000, } diff --git a/packages/core/src/di/jit/injectable.ts b/packages/core/src/di/jit/injectable.ts index f3e27ca4fc..cec23913d7 100644 --- a/packages/core/src/di/jit/injectable.ts +++ b/packages/core/src/di/jit/injectable.ts @@ -54,7 +54,7 @@ export function compileInjectable(type: Type, srcMeta?: Injectable): void { type: metadata.type, typeArgumentCount: metadata.typeArgumentCount, deps: reflectDependencies(type), - target: compiler.R3FactoryTarget.Injectable + target: compiler.FactoryTarget.Injectable }); } return ngFactoryDef; diff --git a/packages/core/src/render3/jit/directive.ts b/packages/core/src/render3/jit/directive.ts index c619b9c59f..58ea28408e 100644 --- a/packages/core/src/render3/jit/directive.ts +++ b/packages/core/src/render3/jit/directive.ts @@ -215,7 +215,7 @@ function addDirectiveFactoryDef(type: Type, metadata: Directive|Component) type: meta.metadata.type, typeArgumentCount: 0, deps: reflectDependencies(type), - target: compiler.R3FactoryTarget.Directive + target: compiler.FactoryTarget.Directive }); } return ngFactoryDef; diff --git a/packages/core/src/render3/jit/module.ts b/packages/core/src/render3/jit/module.ts index 97dc04402a..50fd3d7536 100644 --- a/packages/core/src/render3/jit/module.ts +++ b/packages/core/src/render3/jit/module.ts @@ -149,7 +149,7 @@ export function compileNgModuleDefs( name: moduleType.name, type: moduleType, deps: reflectDependencies(moduleType), - target: compiler.R3FactoryTarget.NgModule, + target: compiler.FactoryTarget.NgModule, typeArgumentCount: 0, }); } diff --git a/packages/core/src/render3/jit/partial.ts b/packages/core/src/render3/jit/partial.ts index 320a6bbcfb..b84d308d5e 100644 --- a/packages/core/src/render3/jit/partial.ts +++ b/packages/core/src/render3/jit/partial.ts @@ -45,7 +45,7 @@ export function ɵɵngDeclareFactory(decl: R3DeclareFactoryFacade): unknown { /** * These enums are used in the partial factory declaration calls. */ -export {R3FactoryTarget} from '../../compiler/compiler_facade'; +export {FactoryTarget} from '../../compiler/compiler_facade'; /** * Compiles a partial injector declaration object into a full injector definition object. diff --git a/packages/core/src/render3/jit/pipe.ts b/packages/core/src/render3/jit/pipe.ts index 34e3427cfe..9377f44fdf 100644 --- a/packages/core/src/render3/jit/pipe.ts +++ b/packages/core/src/render3/jit/pipe.ts @@ -28,7 +28,7 @@ export function compilePipe(type: Type, meta: Pipe): void { type: metadata.type, typeArgumentCount: 0, deps: reflectDependencies(type), - target: compiler.R3FactoryTarget.Pipe + target: compiler.FactoryTarget.Pipe }); } return ngFactoryDef;