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
This commit is contained in:
Pete Bacon Darwin 2021-03-25 21:25:03 +00:00 committed by Alex Rickabaugh
parent 0c1259505b
commit 2d3cd2b969
24 changed files with 60 additions and 58 deletions

View File

@ -5,7 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be * 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 * 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 * as o from '@angular/compiler/src/output/output_ast';
import {AstObject} from '../../ast/ast_value'; import {AstObject} from '../../ast/ast_value';
@ -44,7 +44,7 @@ export function toR3FactoryMeta<TExpression>(
type: wrapReference(typeExpr.getOpaque()), type: wrapReference(typeExpr.getOpaque()),
internalType: metaObj.getOpaque('type'), internalType: metaObj.getOpaque('type'),
typeArgumentCount: 0, typeArgumentCount: 0,
target: parseEnum(metaObj.getValue('target'), R3FactoryTarget), target: parseEnum(metaObj.getValue('target'), FactoryTarget),
deps: getDeps(metaObj, 'deps'), deps: getDeps(metaObj, 'deps'),
}; };
} }

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * 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 * as ts from 'typescript';
import {Cycle, CycleAnalyzer, CycleHandlingStrategy} from '../../cycles'; import {Cycle, CycleAnalyzer, CycleHandlingStrategy} from '../../cycles';
@ -833,7 +833,7 @@ export class ComponentDecoratorHandler implements
return []; return [];
} }
const meta: R3ComponentMetadata = {...analysis.meta, ...resolution}; 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()); const def = compileComponentFromMetadata(meta, pool, makeBindingParser());
return compileResults(fac, def, analysis.metadataStmt, 'ɵcmp'); return compileResults(fac, def, analysis.metadataStmt, 'ɵcmp');
} }
@ -845,7 +845,7 @@ export class ComponentDecoratorHandler implements
return []; return [];
} }
const meta: R3ComponentMetadata = {...analysis.meta, ...resolution}; 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); const def = compileDeclareComponentFromMetadata(meta, analysis.template);
return compileResults(fac, def, analysis.metadataStmt, 'ɵcmp'); return compileResults(fac, def, analysis.metadataStmt, 'ɵcmp');
} }

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * 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 {emitDistinctChangesOnlyDefaultValue} from '@angular/compiler/src/core';
import * as ts from 'typescript'; import * as ts from 'typescript';
@ -302,8 +302,7 @@ export class DirectiveDecoratorHandler implements
compileFull( compileFull(
node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>, node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>,
resolution: Readonly<unknown>, pool: ConstantPool): CompileResult[] { resolution: Readonly<unknown>, pool: ConstantPool): CompileResult[] {
const fac = const fac = compileNgFactoryDefField(toFactoryMetadata(analysis.meta, FactoryTarget.Directive));
compileNgFactoryDefField(toFactoryMetadata(analysis.meta, R3FactoryTarget.Directive));
const def = compileDirectiveFromMetadata(analysis.meta, pool, makeBindingParser()); const def = compileDirectiveFromMetadata(analysis.meta, pool, makeBindingParser());
return compileResults(fac, def, analysis.metadataStmt, 'ɵdir'); return compileResults(fac, def, analysis.metadataStmt, 'ɵdir');
} }
@ -311,7 +310,7 @@ export class DirectiveDecoratorHandler implements
compilePartial( compilePartial(
node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>, node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>,
resolution: Readonly<unknown>): CompileResult[] { resolution: Readonly<unknown>): CompileResult[] {
const fac = compileDeclareFactory(toFactoryMetadata(analysis.meta, R3FactoryTarget.Directive)); const fac = compileDeclareFactory(toFactoryMetadata(analysis.meta, FactoryTarget.Directive));
const def = compileDeclareDirectiveFromMetadata(analysis.meta); const def = compileDeclareDirectiveFromMetadata(analysis.meta);
return compileResults(fac, def, analysis.metadataStmt, 'ɵdir'); return compileResults(fac, def, analysis.metadataStmt, 'ɵdir');
} }

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * 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 * as ts from 'typescript';
import {ErrorCode, FatalDiagnosticError} from '../../diagnostics'; import {ErrorCode, FatalDiagnosticError} from '../../diagnostics';
@ -102,7 +102,7 @@ export class InjectableDecoratorHandler implements
if (analysis.needsFactory) { if (analysis.needsFactory) {
const meta = analysis.meta; const meta = analysis.meta;
const factoryRes = compileNgFactoryDefField( const factoryRes = compileNgFactoryDefField(
toFactoryMetadata({...meta, deps: analysis.ctorDeps}, R3FactoryTarget.Injectable)); toFactoryMetadata({...meta, deps: analysis.ctorDeps}, FactoryTarget.Injectable));
if (analysis.metadataStmt !== null) { if (analysis.metadataStmt !== null) {
factoryRes.statements.push(analysis.metadataStmt); factoryRes.statements.push(analysis.metadataStmt);
} }
@ -134,7 +134,7 @@ export class InjectableDecoratorHandler implements
if (analysis.needsFactory) { if (analysis.needsFactory) {
const meta = analysis.meta; const meta = analysis.meta;
const factoryRes = compileDeclareFactory( const factoryRes = compileDeclareFactory(
toFactoryMetadata({...meta, deps: analysis.ctorDeps}, R3FactoryTarget.Injectable)); toFactoryMetadata({...meta, deps: analysis.ctorDeps}, FactoryTarget.Injectable));
if (analysis.metadataStmt !== null) { if (analysis.metadataStmt !== null) {
factoryRes.statements.push(analysis.metadataStmt); factoryRes.statements.push(analysis.metadataStmt);
} }

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * 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 * as ts from 'typescript';
import {ErrorCode, FatalDiagnosticError, makeDiagnostic, makeRelatedInformation} from '../../diagnostics'; import {ErrorCode, FatalDiagnosticError, makeDiagnostic, makeRelatedInformation} from '../../diagnostics';
@ -352,7 +352,7 @@ export class NgModuleDecoratorHandler implements
typeArgumentCount: 0, typeArgumentCount: 0,
deps: getValidConstructorDependencies( deps: getValidConstructorDependencies(
node, this.reflector, this.defaultImportRecorder, this.isCore), node, this.reflector, this.defaultImportRecorder, this.isCore),
target: R3FactoryTarget.NgModule, target: FactoryTarget.NgModule,
}; };
return { return {

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * 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 * as ts from 'typescript';
import {ErrorCode, FatalDiagnosticError} from '../../diagnostics'; import {ErrorCode, FatalDiagnosticError} from '../../diagnostics';
@ -165,13 +165,13 @@ export class PipeDecoratorHandler implements
} }
compileFull(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): CompileResult[] { compileFull(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): CompileResult[] {
const fac = compileNgFactoryDefField(toFactoryMetadata(analysis.meta, R3FactoryTarget.Pipe)); const fac = compileNgFactoryDefField(toFactoryMetadata(analysis.meta, FactoryTarget.Pipe));
const def = compilePipeFromMetadata(analysis.meta); const def = compilePipeFromMetadata(analysis.meta);
return compileResults(fac, def, analysis.metadataStmt, 'ɵpipe'); return compileResults(fac, def, analysis.metadataStmt, 'ɵpipe');
} }
compilePartial(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): CompileResult[] { compilePartial(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): CompileResult[] {
const fac = compileDeclareFactory(toFactoryMetadata(analysis.meta, R3FactoryTarget.Pipe)); const fac = compileDeclareFactory(toFactoryMetadata(analysis.meta, FactoryTarget.Pipe));
const def = compileDeclarePipeFromMetadata(analysis.meta); const def = compileDeclarePipeFromMetadata(analysis.meta);
return compileResults(fac, def, analysis.metadataStmt, 'ɵpipe'); return compileResults(fac, def, analysis.metadataStmt, 'ɵpipe');
} }

View File

@ -8,7 +8,7 @@
import {Expression, ExternalExpr, LiteralExpr, ParseLocation, ParseSourceFile, ParseSourceSpan, R3CompiledExpression, R3DependencyMetadata, R3Reference, ReadPropExpr, Statement, WrappedNodeExpr} from '@angular/compiler'; import {Expression, ExternalExpr, LiteralExpr, ParseLocation, ParseSourceFile, ParseSourceSpan, R3CompiledExpression, R3DependencyMetadata, R3Reference, ReadPropExpr, Statement, WrappedNodeExpr} from '@angular/compiler';
import {R3FactoryMetadata} from '@angular/compiler/src/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 * as ts from 'typescript';
import {ErrorCode, FatalDiagnosticError, makeDiagnostic, makeRelatedInformation} from '../../diagnostics'; import {ErrorCode, FatalDiagnosticError, makeDiagnostic, makeRelatedInformation} from '../../diagnostics';
@ -583,7 +583,7 @@ export function compileResults(
} }
export function toFactoryMetadata( export function toFactoryMetadata(
meta: Omit<R3FactoryMetadata, 'target'>, target: R3FactoryTarget): R3FactoryMetadata { meta: Omit<R3FactoryMetadata, 'target'>, target: FactoryTarget): R3FactoryMetadata {
return { return {
name: meta.name, name: meta.name,
type: meta.type, type: meta.type,

View File

@ -97,7 +97,7 @@ export {BoundAttribute as TmplAstBoundAttribute, BoundEvent as TmplAstBoundEvent
export * from './render3/view/t2_api'; export * from './render3/view/t2_api';
export * from './render3/view/t2_binder'; export * from './render3/view/t2_binder';
export {Identifiers as R3Identifiers} from './render3/r3_identifiers'; 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 {compileNgModule, R3NgModuleMetadata} from './render3/r3_module_compiler';
export {compileInjector, R3InjectorMetadata} from './render3/r3_injector_compiler'; export {compileInjector, R3InjectorMetadata} from './render3/r3_injector_compiler';
export {compilePipeFromMetadata, R3PipeMetadata} from './render3/r3_pipe_compiler'; export {compilePipeFromMetadata, R3PipeMetadata} from './render3/r3_pipe_compiler';

View File

@ -60,7 +60,7 @@ export interface CompilerFacade {
createParseSourceSpan(kind: string, typeName: string, sourceUrl: string): ParseSourceSpan; createParseSourceSpan(kind: string, typeName: string, sourceUrl: string): ParseSourceSpan;
R3FactoryTarget: typeof R3FactoryTarget; FactoryTarget: typeof FactoryTarget;
ResourceLoader: {new(): ResourceLoader}; ResourceLoader: {new(): ResourceLoader};
} }
@ -82,7 +82,7 @@ export type StringMapWithRename = {
export type Provider = any; export type Provider = any;
export enum R3FactoryTarget { export enum FactoryTarget {
Directive = 0, Directive = 0,
Component = 1, Component = 1,
Injectable = 2, Injectable = 2,
@ -228,13 +228,13 @@ export interface R3FactoryDefMetadataFacade {
type: any; type: any;
typeArgumentCount: number; typeArgumentCount: number;
deps: R3DependencyMetadataFacade[]|null; deps: R3DependencyMetadataFacade[]|null;
target: R3FactoryTarget; target: FactoryTarget;
} }
export interface R3DeclareFactoryFacade { export interface R3DeclareFactoryFacade {
type: Function; type: Function;
deps: R3DeclareDependencyMetadataFacade[]|null; deps: R3DeclareDependencyMetadataFacade[]|null;
target: R3FactoryTarget; target: FactoryTarget;
} }
export enum ViewEncapsulation { export enum ViewEncapsulation {

View File

@ -8,7 +8,7 @@
import {Identifiers} from './identifiers'; import {Identifiers} from './identifiers';
import * as o from './output/output_ast'; 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 {R3Reference, typeWithParameters} from './render3/util';
import {DefinitionMap} from './render3/view/util'; import {DefinitionMap} from './render3/view/util';
@ -40,7 +40,7 @@ export function compileInjectable(meta: R3InjectableMetadata): InjectableDef {
internalType: meta.internalType, internalType: meta.internalType,
typeArgumentCount: meta.typeArgumentCount, typeArgumentCount: meta.typeArgumentCount,
deps: [], deps: [],
target: R3FactoryTarget.Injectable, target: FactoryTarget.Injectable,
}; };
if (meta.useClass !== undefined) { if (meta.useClass !== undefined) {

View File

@ -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 {DeclareVarStmt, Expression, literal, LiteralExpr, Statement, StmtModifier, WrappedNodeExpr} from './output/output_ast';
import {JitEvaluator} from './output/output_jit'; import {JitEvaluator} from './output/output_jit';
import {ParseError, ParseSourceSpan, r3JitTypeSourceSpan} from './parse_util'; 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 {compileInjector, R3InjectorMetadata} from './render3/r3_injector_compiler';
import {R3JitReflector} from './render3/r3_jit'; import {R3JitReflector} from './render3/r3_jit';
import {compileNgModule, compileNgModuleDeclarationExpression, R3NgModuleMetadata} from './render3/r3_module_compiler'; 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'; import {DomElementSchemaRegistry} from './schema/dom_element_schema_registry';
export class CompilerFacadeImpl implements CompilerFacade { export class CompilerFacadeImpl implements CompilerFacade {
R3FactoryTarget = R3FactoryTarget as any; FactoryTarget = FactoryTarget as any;
ResourceLoader = ResourceLoader; ResourceLoader = ResourceLoader;
private elementSchemaRegistry = new DomElementSchemaRegistry(); private elementSchemaRegistry = new DomElementSchemaRegistry();

View File

@ -356,10 +356,10 @@ export interface R3DeclareFactoryMetadata extends R3PartialDeclaration {
/** /**
* Type of the target being created by the factory. * Type of the target being created by the factory.
*/ */
target: R3FactoryTarget; target: FactoryTarget;
} }
export enum R3FactoryTarget { export enum FactoryTarget {
Directive = 0, Directive = 0,
Component = 1, Component = 1,
Injectable = 2, Injectable = 2,

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import * as o from '../../output/output_ast'; 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 {Identifiers as R3} from '../r3_identifiers';
import {R3CompiledExpression} from '../util'; import {R3CompiledExpression} from '../util';
import {DefinitionMap} from '../view/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('ngImport', o.importExpr(R3.core));
definitionMap.set('type', meta.internalType); definitionMap.set('type', meta.internalType);
definitionMap.set('deps', compileDependencies(meta.deps)); 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 { return {
expression: o.importExpr(R3.declareFactory).callFn([definitionMap.toLiteralMap()]), expression: o.importExpr(R3.declareFactory).callFn([definitionMap.toLiteralMap()]),

View File

@ -57,7 +57,7 @@ export interface R3ConstructorFactoryMetadata {
/** /**
* Type of the target being created by the factory. * Type of the target being created by the factory.
*/ */
target: R3FactoryTarget; target: FactoryTarget;
} }
export enum R3FactoryDelegateType { export enum R3FactoryDelegateType {
@ -78,7 +78,7 @@ export interface R3ExpressionFactoryMetadata extends R3ConstructorFactoryMetadat
export type R3FactoryMetadata = export type R3FactoryMetadata =
R3ConstructorFactoryMetadata|R3DelegatedFnOrClassMetadata|R3ExpressionFactoryMetadata; R3ConstructorFactoryMetadata|R3DelegatedFnOrClassMetadata|R3ExpressionFactoryMetadata;
export enum R3FactoryTarget { export enum FactoryTarget {
Directive = 0, Directive = 0,
Component = 1, Component = 1,
Injectable = 2, Injectable = 2,
@ -222,12 +222,12 @@ export function createFactoryType(meta: R3FactoryMetadata) {
[typeWithParameters(meta.type.type, meta.typeArgumentCount), ctorDepsType])); [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)); return deps.map((dep, index) => compileInjectDependency(dep, target, index));
} }
function compileInjectDependency( 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. // Interpret the dependency according to its resolved type.
if (dep.token === null) { if (dep.token === null) {
return o.importExpr(R3.invalidFactoryDep).callFn([o.literal(index)]); return o.importExpr(R3.invalidFactoryDep).callFn([o.literal(index)]);
@ -236,7 +236,7 @@ function compileInjectDependency(
const flags = InjectFlags.Default | (dep.self ? InjectFlags.Self : 0) | const flags = InjectFlags.Default | (dep.self ? InjectFlags.Self : 0) |
(dep.skipSelf ? InjectFlags.SkipSelf : 0) | (dep.host ? InjectFlags.Host : 0) | (dep.skipSelf ? InjectFlags.SkipSelf : 0) | (dep.host ? InjectFlags.Host : 0) |
(dep.optional ? InjectFlags.Optional : 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 // 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 // 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; return (meta as any).expression !== undefined;
} }
function getInjectFn(target: R3FactoryTarget): o.ExternalReference { function getInjectFn(target: FactoryTarget): o.ExternalReference {
switch (target) { switch (target) {
case R3FactoryTarget.Component: case FactoryTarget.Component:
case R3FactoryTarget.Directive: case FactoryTarget.Directive:
case R3FactoryTarget.Pipe: case FactoryTarget.Pipe:
return R3.directiveInject; return R3.directiveInject;
case R3FactoryTarget.NgModule: case FactoryTarget.NgModule:
case R3FactoryTarget.Injectable: case FactoryTarget.Injectable:
default: default:
return R3.inject; return R3.inject;
} }

View File

@ -257,7 +257,7 @@ export class Identifiers {
moduleName: CORE, moduleName: CORE,
}; };
static declareFactory: o.ExternalReference = {name: 'ɵɵngDeclareFactory', 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 defineDirective: o.ExternalReference = {name: 'ɵɵdefineDirective', moduleName: CORE};
static declareDirective: o.ExternalReference = {name: 'ɵɵngDeclareDirective', moduleName: CORE}; static declareDirective: o.ExternalReference = {name: 'ɵɵngDeclareDirective', moduleName: CORE};

View File

@ -7,7 +7,7 @@
*/ */
import * as core from '../../core/src/compiler/compiler_facade_interface'; 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'; 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 coreProvider: core.Provider = null! as compiler.Provider;
const compilerProvider: compiler.Provider = null! as core.Provider; const compilerProvider: compiler.Provider = null! as core.Provider;
const coreR3FactoryTarget: core.R3FactoryTarget = null! as compiler.R3FactoryTarget; const coreR3FactoryTarget: core.FactoryTarget = null! as compiler.FactoryTarget;
const compilerR3FactoryTarget: compiler.R3FactoryTarget = null! as core.R3FactoryTarget; const compilerR3FactoryTarget: compiler.FactoryTarget = null! as core.FactoryTarget;
const coreR3FactoryTarget2: R3FactoryTarget = null! as core.R3FactoryTarget; const coreR3FactoryTarget2: FactoryTarget = null! as core.FactoryTarget;
const compilerR3FactoryTarget2: R3FactoryTarget = null! as core.R3FactoryTarget; const compilerR3FactoryTarget2: FactoryTarget = null! as core.FactoryTarget;
const coreR3FactoryTarget3: core.R3FactoryTarget = null! as R3FactoryTarget; const coreR3FactoryTarget3: core.FactoryTarget = null! as FactoryTarget;
const compilerR3FactoryTarget3: compiler.R3FactoryTarget = null! as R3FactoryTarget; const compilerR3FactoryTarget3: compiler.FactoryTarget = null! as FactoryTarget;
const coreR3DependencyMetadataFacade: core.R3DependencyMetadataFacade = const coreR3DependencyMetadataFacade: core.R3DependencyMetadataFacade =
null! as compiler.R3DependencyMetadataFacade; null! as compiler.R3DependencyMetadataFacade;

View File

@ -60,7 +60,7 @@ export interface CompilerFacade {
createParseSourceSpan(kind: string, typeName: string, sourceUrl: string): ParseSourceSpan; createParseSourceSpan(kind: string, typeName: string, sourceUrl: string): ParseSourceSpan;
R3FactoryTarget: typeof FactoryTarget; FactoryTarget: typeof FactoryTarget;
ResourceLoader: {new(): ResourceLoader}; ResourceLoader: {new(): ResourceLoader};
} }

View File

@ -268,7 +268,7 @@ export {
transitiveScopesFor as ɵtransitiveScopesFor, transitiveScopesFor as ɵtransitiveScopesFor,
} from './render3/jit/module'; } from './render3/jit/module';
export { export {
R3FactoryTarget as ɵɵFactoryTarget, FactoryTarget as ɵɵFactoryTarget,
ɵɵngDeclareComponent, ɵɵngDeclareComponent,
ɵɵngDeclareDirective, ɵɵngDeclareDirective,
ɵɵngDeclareFactory, ɵɵngDeclareFactory,

View File

@ -73,6 +73,9 @@ export const enum InternalInjectFlags {
/** /**
* This token is being injected into a pipe. * 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, ForPipe = 0b10000,
} }

View File

@ -54,7 +54,7 @@ export function compileInjectable(type: Type<any>, srcMeta?: Injectable): void {
type: metadata.type, type: metadata.type,
typeArgumentCount: metadata.typeArgumentCount, typeArgumentCount: metadata.typeArgumentCount,
deps: reflectDependencies(type), deps: reflectDependencies(type),
target: compiler.R3FactoryTarget.Injectable target: compiler.FactoryTarget.Injectable
}); });
} }
return ngFactoryDef; return ngFactoryDef;

View File

@ -215,7 +215,7 @@ function addDirectiveFactoryDef(type: Type<any>, metadata: Directive|Component)
type: meta.metadata.type, type: meta.metadata.type,
typeArgumentCount: 0, typeArgumentCount: 0,
deps: reflectDependencies(type), deps: reflectDependencies(type),
target: compiler.R3FactoryTarget.Directive target: compiler.FactoryTarget.Directive
}); });
} }
return ngFactoryDef; return ngFactoryDef;

View File

@ -149,7 +149,7 @@ export function compileNgModuleDefs(
name: moduleType.name, name: moduleType.name,
type: moduleType, type: moduleType,
deps: reflectDependencies(moduleType), deps: reflectDependencies(moduleType),
target: compiler.R3FactoryTarget.NgModule, target: compiler.FactoryTarget.NgModule,
typeArgumentCount: 0, typeArgumentCount: 0,
}); });
} }

View File

@ -45,7 +45,7 @@ export function ɵɵngDeclareFactory(decl: R3DeclareFactoryFacade): unknown {
/** /**
* These enums are used in the partial factory declaration calls. * 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. * Compiles a partial injector declaration object into a full injector definition object.

View File

@ -28,7 +28,7 @@ export function compilePipe(type: Type<any>, meta: Pipe): void {
type: metadata.type, type: metadata.type,
typeArgumentCount: 0, typeArgumentCount: 0,
deps: reflectDependencies(type), deps: reflectDependencies(type),
target: compiler.R3FactoryTarget.Pipe target: compiler.FactoryTarget.Pipe
}); });
} }
return ngFactoryDef; return ngFactoryDef;